group()
public
Provides a convenient Ruby iterator which executes a block for each entry
in the /etc/group file.
The code block is passed an Struct::Group struct; see getgrent above for details.
Example:
require 'etc'
Etc.group {|g|
puts g.name + ": " + g.mem.join(', ')
}
static VALUE
etc_group(VALUE obj)
{
#ifdef HAVE_GETGRENT
struct group *grp;
rb_secure(4);
if (rb_block_given_p()) {
if (group_blocking) {
rb_raise(rb_eRuntimeError, "parallel group iteration");
}
group_blocking = Qtrue;
rb_ensure(group_iterate, 0, group_ensure, 0);
}
if (grp = getgrent()) {
return setup_group(grp);
}
#endif
return Qnil;
}