2 * test_grp.c - This file is part of the libc-8086/grp package for ELKS,
3 * Copyright (C) 1995, 1996 Nat Friedman <ndf@linux.mit.edu>.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the Free
17 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 int main(int argc, char **argv)
32 fprintf(stdout, "Beginning test of libc/grp...\n");
34 fprintf(stdout, "=> Testing setgrent(), getgrent(), endgrent()...\n");
35 fprintf(stdout, "-> setgrent()...\n");
37 fprintf(stdout, "-> getgrent()...\n");
39 ("********************************************************************************\n");
40 while ((group = getgrent()) != NULL) {
41 printf("gr_name\t\t: %s\n", group->gr_name);
42 printf("gr_passwd\t: %s\n", group->gr_passwd);
43 printf("gr_gid\t\t: %d\n", (int) group->gr_gid);
44 printf("gr_mem\t\t: ");
46 tmp_mem = group->gr_mem;
47 while (*tmp_mem != NULL) {
48 printf("%s, ", *tmp_mem);
52 ("\n********************************************************************************\n");
54 fprintf(stdout, "-> endgrent()...\n");
57 "=> Test of setgrent(), getgrent(), endgrent() complete.\n");
58 fprintf(stdout, "=> Testing getgrid(), getgrnam()...\n");
59 fprintf(stdout, "-> getgrgid()...\n");
61 ("********************************************************************************\n");
62 for (test_gid = 0; test_gid < 100; test_gid++) {
63 fprintf(stdout, "-> getgrgid(%d)...\n", test_gid);
64 group = getgrgid((gid_t) test_gid);
66 printf("gr_name\t: %s\n", group->gr_name);
67 printf("gr_passwd\t: %s\n", group->gr_passwd);
68 printf("gr_gid\t: %d\n", (int) group->gr_gid);
69 printf("gr_mem\t\t: ");
71 tmp_mem = group->gr_mem;
72 while (*tmp_mem != NULL) {
73 printf("%s, ", *tmp_mem);
78 ("\n********************************************************************************\n");
80 fprintf(stdout, "-> getgrnam()...\n");
81 group = getgrnam("root");
85 printf("gr_name\t: %s\n", group->gr_name);
86 printf("gr_passwd\t: %s\n", group->gr_passwd);
87 printf("gr_gid\t: %d\n", (int) group->gr_gid);
88 printf("gr_mem\t\t: ");
90 tmp_mem = group->gr_mem;
91 while (*tmp_mem != NULL) {
92 printf("%s, ", *tmp_mem);