2 * test_pwd.c - This file is part of the libc-8086/pwd 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.
27 main(int argc
, char ** argv
)
29 struct passwd
* passwd
;
32 fprintf(stderr
, "Beginning test of libc/pwd...\n");
34 fprintf(stderr
, "=> Testing setpwent(), getpwent(), endpwent()...\n");
35 fprintf(stderr
, "-> setpwent()...\n");
37 fprintf(stderr
, "-> getpwent()...\n");
38 printf("********************************************************************************\n");
39 while ((passwd
=getpwent())!=NULL
)
41 printf("pw_name\t\t: %s\n", passwd
->pw_name
);
42 printf("pw_passwd\t: %s\n", passwd
->pw_passwd
);
43 printf("pw_uid\t\t: %d\n", (int) passwd
->pw_uid
);
44 printf("pw_gid\t\t: %d\n", (int) passwd
->pw_gid
);
45 printf("pw_gecos\t: %s\n", passwd
->pw_gecos
);
46 printf("pw_dir\t\t: %s\n", passwd
->pw_dir
);
47 printf("pw_shell\t: %s\n", passwd
->pw_shell
);
48 printf("********************************************************************************\n");
50 fprintf(stderr
, "-> endpwent()...\n");
52 fprintf(stderr
, "=> Test of setpwent(), getpwent(), endpwent() complete.\n");
53 fprintf(stderr
, "=> Testing getpwuid(), getpwnam()...\n");
54 fprintf(stderr
, "-> getpwuid()...\n");
55 printf("********************************************************************************\n");
56 for(test_uid
=0;test_uid
<1000;test_uid
++)
58 fprintf(stderr
, "-> getpwuid(%d)...\n", test_uid
);
59 passwd
=getpwuid((uid_t
) test_uid
);
62 printf("pw_name\t\t: %s\n", passwd
->pw_name
);
63 printf("pw_passwd\t: %s\n", passwd
->pw_passwd
);
64 printf("pw_uid\t\t: %d\n", (int) passwd
->pw_uid
);
65 printf("pw_gid\t\t: %d\n", (int) passwd
->pw_gid
);
66 printf("pw_gecos\t: %s\n", passwd
->pw_gecos
);
67 printf("pw_dir\t\t: %s\n", passwd
->pw_dir
);
68 printf("pw_shell\t: %s\n", passwd
->pw_shell
);
69 printf("********************************************************************************\n");
72 fprintf(stderr
, "-> getpwnam()...\n");
73 passwd
=getpwnam("root");
80 printf("pw_name\t\t: %s\n", passwd
->pw_name
);
81 printf("pw_passwd\t: %s\n", passwd
->pw_passwd
);
82 printf("pw_uid\t\t: %d\n", (int) passwd
->pw_uid
);
83 printf("pw_gid\t\t: %d\n", (int) passwd
->pw_gid
);
84 printf("pw_gecos\t: %s\n", passwd
->pw_gecos
);
85 printf("pw_dir\t\t: %s\n", passwd
->pw_dir
);
86 printf("pw_shell\t: %s\n", passwd
->pw_shell
);