Class: KerberosAuthenticator::Krb5::Data
- Inherits:
-
FFI::ManagedStruct
- Object
- FFI::ManagedStruct
- KerberosAuthenticator::Krb5::Data
- Defined in:
- lib/kerberos_authenticator/krb5/data.rb
Overview
Generic Kerberos library data structure.
Class Method Summary collapse
-
.release(pointer) ⇒ Object
private
Frees the contents of a Data struct.
Instance Method Summary collapse
-
#initialize(pointer = nil) ⇒ Data
constructor
Allocates and zeroes a new krb5_data struct or cast some existing memory to one.
-
#read_string ⇒ String
Reads the data into a string.
Constructor Details
#initialize(pointer = nil) ⇒ Data
Allocates and zeroes a new krb5_data struct or cast some existing memory to one.
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/kerberos_authenticator/krb5/data.rb', line 13 def initialize(pointer = nil) unless pointer pointer = FFI::MemoryPointer.new :char, self.class.size # HACK: AutoPointer won't accept a MemoryPointer, only a Pointer pointer.autorelease = false pointer = FFI::Pointer.new(pointer) end super(pointer) end |
Class Method Details
.release(pointer) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Frees the contents of a Data struct
35 36 37 |
# File 'lib/kerberos_authenticator/krb5/data.rb', line 35 def self.release(pointer) Krb5.free_data_contents(Context.context.ptr, pointer) end |
Instance Method Details
#read_string ⇒ String
Reads the data into a string.
27 28 29 30 |
# File 'lib/kerberos_authenticator/krb5/data.rb', line 27 def read_string return '' if self[:length].zero? self[:data_ptr].read_bytes(self[:length]) end |