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.
26 int main(int argc, char **argv)
28 struct passwd *passwd;
31 fprintf(stdout, "Beginning test of libc/pwd...\n");
33 fprintf(stdout, "=> Testing setpwent(), getpwent(), endpwent()...\n");
34 fprintf(stdout, "-> setpwent()...\n");
36 fprintf(stdout, "-> getpwent()...\n");
38 ("********************************************************************************\n");
39 while ((passwd = getpwent()) != NULL) {
40 printf("pw_name\t\t: %s\n", passwd->pw_name);
41 printf("pw_passwd\t: %s\n", passwd->pw_passwd);
42 printf("pw_uid\t\t: %d\n", (int) passwd->pw_uid);
43 printf("pw_gid\t\t: %d\n", (int) passwd->pw_gid);
44 printf("pw_gecos\t: %s\n", passwd->pw_gecos);
45 printf("pw_dir\t\t: %s\n", passwd->pw_dir);
46 printf("pw_shell\t: %s\n", passwd->pw_shell);
48 ("********************************************************************************\n");
50 fprintf(stdout, "-> endpwent()...\n");
53 "=> Test of setpwent(), getpwent(), endpwent() complete.\n");
54 fprintf(stdout, "=> Testing getpwuid(), getpwnam()...\n");
55 fprintf(stdout, "-> getpwuid()...\n");
57 ("********************************************************************************\n");
58 for (test_uid = 0; test_uid < 1000; test_uid++) {
59 fprintf(stdout, "-> getpwuid(%d)...\n", test_uid);
60 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);
70 ("********************************************************************************\n");
73 fprintf(stdout, "-> getpwnam()...\n");
74 passwd = getpwnam("root");
78 printf("pw_name\t\t: %s\n", passwd->pw_name);
79 printf("pw_passwd\t: %s\n", passwd->pw_passwd);
80 printf("pw_uid\t\t: %d\n", (int) passwd->pw_uid);
81 printf("pw_gid\t\t: %d\n", (int) passwd->pw_gid);
82 printf("pw_gecos\t: %s\n", passwd->pw_gecos);
83 printf("pw_dir\t\t: %s\n", passwd->pw_dir);
84 printf("pw_shell\t: %s\n", passwd->pw_shell);