Created
April 29, 2015 17:23
-
-
Save mkomitee/a381600727cc5b395b3f to your computer and use it in GitHub Desktop.
how do 2?
This file contains 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
extern crate libc; | |
use libc::*; | |
use std::ptr; | |
#[allow(non_camel_case_types)] | |
#[repr(C)] | |
type krb5_error_code = c_uint; | |
#[allow(non_camel_case_types)] | |
#[repr(C)] | |
struct krb5_context; | |
impl krb5_context { | |
fn new<'a>() -> &'a krb5_context { | |
unsafe { | |
&*ptr::null() | |
} | |
} | |
} | |
impl Drop for krb5_context { | |
fn drop(&mut self) { | |
unsafe{ | |
krb5_free_context(self) | |
} | |
} | |
} | |
#[link(name = "krb5")] | |
extern "C" { | |
fn krb5_init_context(context: *mut krb5_context) -> krb5_error_code; | |
fn krb5_free_context(context: *mut krb5_context); | |
} | |
fn main() { | |
let res = unsafe { | |
let mut ctx = krb5_context::new(); | |
if krb5_init_context(ctx) == 0 { | |
Ok(()) | |
} else { | |
Err(()) | |
} | |
}; | |
// match res { | |
// Ok(_) => println!("SUCCESS!"), | |
// Err(_) => println!("ERROR!"), | |
// } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment