Created
June 28, 2016 12:54
-
-
Save bararchy/abb0750f8bda54382211ec0f147ece15 to your computer and use it in GitHub Desktop.
Krb5 Bindings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@[Link("krb5")] | |
lib LibKRB | |
fun krb5_init_context(buff : UInt8*) : UInt32 | |
fun krb5_free_context(buff : UInt8*) : Void | |
end | |
class Krb5 | |
def initialize | |
ctx = Pointer(UInt8) | |
ret = LibKRB.krb5_init_context(ctx) | |
raise "krb5_init_context() failed" if ret == 0 | |
end | |
end | |
puts Krb5.new |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module FFI::Krb5 | |
extend FFI::Library | |
ffi_lib "krb5" | |
attach_function :krb5_init_context, [:buffer_out], :uint | |
attach_function :krb5_free_context, [:pointer], :void | |
end | |
## What you pass to krb5_init_context is really a pointer to a pointer. You | |
## can now use that this way: | |
buf = FFI::Buffer.new(:pointer) | |
res = FFI::Krb5.krb5_init_context(buf) | |
puts res |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment