1 /* Copyright (C) 1991, 1992, 1996-1998, 2011 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22 #define flockfile(s) _IO_flockfile (s)
23 #define funlockfile(s) _IO_funlockfile (s)
25 #define _S(x) x ? x : ""
28 /* Write an entry to the given stream.
29 This must know the format of the password file. */
31 putspent (const struct spwd *p, FILE *stream)
37 if (fprintf (stream, "%s:%s:", p->sp_namp, _S (p->sp_pwdp)) < 0)
40 if ((p->sp_lstchg != (long int) -1
41 && fprintf (stream, "%ld:", p->sp_lstchg) < 0)
42 || (p->sp_lstchg == (long int) -1
43 && putc_unlocked (':', stream) == EOF))
46 if ((p->sp_min != (long int) -1
47 && fprintf (stream, "%ld:", p->sp_min) < 0)
48 || (p->sp_min == (long int) -1
49 && putc_unlocked (':', stream) == EOF))
52 if ((p->sp_max != (long int) -1
53 && fprintf (stream, "%ld:", p->sp_max) < 0)
54 || (p->sp_max == (long int) -1
55 && putc_unlocked (':', stream) == EOF))
58 if ((p->sp_warn != (long int) -1
59 && fprintf (stream, "%ld:", p->sp_warn) < 0)
60 || (p->sp_warn == (long int) -1
61 && putc_unlocked (':', stream) == EOF))
64 if ((p->sp_inact != (long int) -1
65 && fprintf (stream, "%ld:", p->sp_inact) < 0)
66 || (p->sp_inact == (long int) -1
67 && putc_unlocked (':', stream) == EOF))
70 if ((p->sp_expire != (long int) -1
71 && fprintf (stream, "%ld:", p->sp_expire) < 0)
72 || (p->sp_expire == (long int) -1
73 && putc_unlocked (':', stream) == EOF))
76 if (p->sp_flag != ~0ul
77 && fprintf (stream, "%ld", p->sp_flag) < 0)
80 if (putc_unlocked ('\n', stream) == EOF)
85 return errors ? -1 : 0;