Skip to content

Instantly share code, notes, and snippets.

@hosiawak
Created October 29, 2012 18:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hosiawak/3975329 to your computer and use it in GitHub Desktop.
Save hosiawak/3975329 to your computer and use it in GitHub Desktop.
#ifdef HAVE_GETGRENT
static VALUE
setup_group(grp)
struct group *grp;
{
VALUE mem;
char **tbl;
mem = rb_ary_new();
tbl = grp->gr_mem;
while (*tbl) {
rb_ary_push(mem, safe_setup_str(*tbl));
tbl++;
}
def mem
ptr = self[:gr_mem].read_pointer
ary = []
2.times do |x|
unless ptr.null?
s = ptr.read_string
ary << s
end
ptr.address = ptr.address + s.length + 1
end
ary
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment