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()) {
each_group();
}
else if (grp = getgrent()) {
return setup_group(grp);
}
#endif
return Qnil;
}