putpwent.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * putpwent.c - This file is part of the libc-8086/pwd package for ELKS,
  4. * Copyright (C) 1995, 1996 Nat Friedman <ndf@linux.mit.edu>.
  5. * Copyright (C) 2001-2003 Erik Andersen <andersee@debian.org>
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Library General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2 of the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Library General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Library General Public
  18. * License along with this library; if not, write to the Free
  19. * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. *
  21. */
  22. #include <stdio.h>
  23. #include <errno.h>
  24. #include "config.h"
  25. int putpwent(const struct passwd *passwd, FILE * f)
  26. {
  27. if (passwd == NULL || f == NULL) {
  28. __set_errno(EINVAL);
  29. return -1;
  30. }
  31. if (fprintf
  32. (f, "%s:%s:%u:%u:%s:%s:%s\n", passwd->pw_name, passwd->pw_passwd,
  33. passwd->pw_uid, passwd->pw_gid, passwd->pw_gecos, passwd->pw_dir,
  34. passwd->pw_shell) < 0)
  35. return -1;
  36. return 0;
  37. }