Skip to content

Instantly share code, notes, and snippets.

@lilyball
Forked from alan-andrade/id.rs
Last active August 29, 2015 13:56
Show Gist options
  • Select an option

  • Save lilyball/8928594 to your computer and use it in GitHub Desktop.

Select an option

Save lilyball/8928594 to your computer and use it in GitHub Desktop.
// The C method signature is as follows:
int
getgrouplist(const char *name, int basegid, int *groups, int *ngroups);
// My Rust extern block
extern {
fn getgrouplist(name: *libc::c_char,
basegid: libc::c_int,
groups: *mut libc::c_int,
ngroups: *mut libc::c_int) -> libc::c_int;
}
// Trying to use it
let groups = 0;
let num_groups = 0;
// How do I setup a pointer to integer type ?
unsafe {
getgrouplist((*pw).pw_name, (*pw).pw_gid, &mut groups, &mut num_groups);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment