grcat.c 557 B

1234567891011121314151617181920212223242526272829303132
  1. /*
  2. * grcat.c
  3. *
  4. * Generate a printable version of the group database
  5. */
  6. /*
  7. * Arnold Robbins, arnold@gnu.org, May 1993
  8. * Public Domain
  9. */
  10. #include <stdlib.h>
  11. #include <stdio.h>
  12. #include <grp.h>
  13. int main(int argc, char **argv)
  14. {
  15. struct group *g;
  16. int i;
  17. while ((g = getgrent()) != NULL) {
  18. printf("%s:%s:%ld:", g->gr_name, g->gr_passwd,
  19. (long) g->gr_gid);
  20. for (i = 0; g->gr_mem[i] != NULL; i++) {
  21. printf("%s", g->gr_mem[i]);
  22. if (g->gr_mem[i+1] != NULL)
  23. putchar(',');
  24. }
  25. putchar('\n');
  26. }
  27. endgrent();
  28. return 0;
  29. }