Class: GSSAPI::LibGSSAPI::UnManagedGssBufferDesc

Inherits:
GssUMStruct
  • Object
show all
Includes:
GssBufferDescLayout
Defined in:
lib/gssapi/lib_gssapi.rb

Overview

This class implements the gss_buffer_desc type. Use #pointer to emulate gss_buffer_t If you are setting the value of the buffer and it is not being set from the function this is the type of buffer you should use. If the buffer is being allocated and set inside the function you should use a ManagedGssBufferDesc instead so gss_release_buffer is called for it. It states in the manpage for each gss function whether or not gss_release_buffer needs to be called or not.

Examples:

buff = UnManagedGssBufferDesc.new
buff.value = "This is a test"

Instance Method Summary collapse

Methods included from GssBufferDescLayout

included

Constructor Details

#initialize(ptr = nil) ⇒ UnManagedGssBufferDesc

Returns a new instance of UnManagedGssBufferDesc.


79
80
81
82
83
84
85
# File 'lib/gssapi/lib_gssapi.rb', line 79

def initialize(ptr = nil)
  if(ptr.nil?)
    super(FFI::Pointer.new(FFI::MemoryPointer.new(self.size)))
  else
    super(ptr)
  end
end

Instance Method Details

#value=(val) ⇒ Object

Set the value of the string for the “value” parameter. This method also

appropriately sets the length parameter.

89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/gssapi/lib_gssapi.rb', line 89

def value=(val)
  if(val.nil?)
    self[:length] = 0
    self[:value] = val
  elsif(val.is_a?(String))
    buff = FFI::MemoryPointer.from_string(val)
    self[:length] = val.length
    self[:value] = buff
  elsif(val.is_a?(Fixnum))
    buff = FFI::MemoryPointer.new :OM_uint32
    buff.write_int val
    self[:length] = FFI::type_size :OM_uint32
    self[:value] = buff
  else
    raise StandardError, "Can't handle type #{val.class.name}"
  end
end