"Fossies" - the Fresh Open Source Software Archive 
Member "nss_ldap-265/tests/testpw3.c" (6 Nov 2009, 762 Bytes) of package /linux/privat/old/nss_ldap-265.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
1 #include <stdio.h>
2 #include <pwd.h>
3
4 void
5 main (int argc, char **argv)
6 {
7 scan_passwd ();
8
9 exit (0);
10 }
11 scan_passwd ()
12 {
13 struct passwd p;
14 char buf[1024];
15 int i = 1;
16
17 #ifdef WEIRD_GETPWENT
18 FILE *fp = NULL;
19 #endif
20 memset (buf, 0xFF, sizeof (buf));
21
22 #ifdef WEIRD_GETPWENT
23 setpwent_r (&fp);
24 #else
25 setpwent_r ();
26 #endif
27
28 #ifdef WEIRD_GETPWENT
29 while (getpwent_r (&p, buf, (int) sizeof (buf), &fp) == 0)
30 #else
31 while (getpwent_r (&p, buf, (int) sizeof (buf)) == 0)
32 #endif
33 {
34 printf ("%s:%s:%d:%d:%s:%s:%s\n",
35 p.pw_name,
36 p.pw_passwd,
37 p.pw_uid, p.pw_gid, p.pw_gecos, p.pw_dir, p.pw_shell);
38 i++;
39 }
40
41 #ifdef WEIRD_GETPWENT
42 endpwent_r (&fp);
43 #else
44 endpwent_r ();
45 #endif
46 fprintf (stderr, ">>>>>>> %d\n", i);
47
48 }