Main Page | Class List | Directories | File List | Class Members | File Members

grcat.c

Go to the documentation of this file.
00001 /*
00002  * grcat.c
00003  *
00004  * Generate a printable version of the group database
00005  */
00006 /*
00007  * Arnold Robbins, arnold@gnu.org, May 1993
00008  * Public Domain
00009  */
00010 
00011 /* For OS/2, do nothing. */
00012 #if HAVE_CONFIG_H
00013 #include <config.h>
00014 #endif
00015 
00016 #if defined (STDC_HEADERS)
00017 #include <stdlib.h>
00018 #endif
00019 
00020 #ifndef HAVE_GETGRENT
00021 int main() { return 0; }
00022 #else
00023 #include <stdio.h>
00024 #include <grp.h>
00025 
00026 int
00027 main(argc, argv)
00028 int argc;
00029 char **argv;
00030 {
00031     struct group *g;
00032     int i;
00033 
00034     while ((g = getgrent()) != NULL) {
00035         printf("%s:%s:%ld:", g->gr_name, g->gr_passwd,
00036                                      (long) g->gr_gid);
00037         for (i = 0; g->gr_mem[i] != NULL; i++) {
00038             printf("%s", g->gr_mem[i]);
00039             if (g->gr_mem[i+1] != NULL)
00040                 putchar(',');
00041         }
00042         putchar('\n');
00043     }
00044     endgrent();
00045     return 0;
00046 }
00047 #endif /* HAVE_GETGRENT */

© sourcejam.com 2005-2008