Add getusershell(), setusershell(), endusershell() declarations to <unistd.h>.
authorBruno Haible <bruno@clisp.org>
Sun, 19 Oct 2008 11:07:15 +0000 (13:07 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 19 Oct 2008 11:07:15 +0000 (13:07 +0200)
ChangeLog
lib/getusershell.c
lib/unistd.in.h
m4/getusershell.m4
m4/unistd_h.m4
modules/getusershell
modules/unistd

index 76667be..cf1f711 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,23 @@
 2008-10-18  Bruno Haible  <bruno@clisp.org>
 
+       Add getusershell(), setusershell(), endusershell() declarations to
+       <unistd.h>.
+       * lib/unistd.in.h (getusershell, setusershell, endusershell): New
+       declarations.
+       * lib/getusershell.c: Include unistd.h.
+       * m4/getusershell.m4 (gl_FUNC_GETUSERSHELL): Require
+       gl_UNISTD_H_DEFAULTS and AC_USE_SYSTEM_EXTENSIONS. Set
+       HAVE_GETUSERSHELL.
+       * m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Initialize GNULIB_GETUSERSHELL
+       and HAVE_GETUSERSHELL.
+       * modules/getusershell (Depends-on): Add unistd, extensions.
+       (configure.ac): Invoke gl_UNISTD_MODULE_INDICATOR.
+       (Include): Specify <unistd.h>.
+       * modules/unistd (Makefile.am): Substitute GNULIB_GETUSERSHELL and
+       HAVE_GETUSERSHELL.
+
+2008-10-18  Bruno Haible  <bruno@clisp.org>
+
        Add a getloadavg() declaration to <stdlib.h>.
        * lib/stdlib.in.h; Include <sys/loadavg.h> when needed for the
        getloadavg declaration.
index fa1b120..bea62a0 100644 (file)
@@ -1,6 +1,6 @@
 /* getusershell.c -- Return names of valid user shells.
 
-   Copyright (C) 1991, 1997, 2000, 2001, 2003, 2004, 2005, 2006 Free
+   Copyright (C) 1991, 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008 Free
    Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
@@ -20,6 +20,9 @@
 
 #include <config.h>
 
+/* Specification.  */
+#include <unistd.h>
+
 #ifndef SHELLS_FILE
 # ifndef __DJGPP__
 /* File containing a list of nonrestricted shells, one per line. */
index a73a201..3700958 100644 (file)
@@ -353,6 +353,36 @@ extern int getpagesize (void);
 #endif
 
 
+#if @GNULIB_GETUSERSHELL@
+# if !@HAVE_GETUSERSHELL@
+/* Return the next valid login shell on the system, or NULL when the end of
+   the list has been reached.  */
+extern char *getusershell (void);
+/* Rewind to pointer that is advanced at each getusershell() call.  */
+extern void setusershell (void);
+/* Free the pointer that is advanced at each getusershell() call and
+   associated resources.  */
+extern void endusershell (void);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef getusershell
+# define getusershell() \
+    (GL_LINK_WARNING ("getusershell is unportable - " \
+                      "use gnulib module getusershell for portability"), \
+     getusershell ())
+# undef setusershell
+# define setusershell() \
+    (GL_LINK_WARNING ("setusershell is unportable - " \
+                      "use gnulib module getusershell for portability"), \
+     setusershell ())
+# undef endusershell
+# define endusershell() \
+    (GL_LINK_WARNING ("endusershell is unportable - " \
+                      "use gnulib module getusershell for portability"), \
+     endusershell ())
+#endif
+
+
 #if @GNULIB_LCHOWN@
 # if @REPLACE_LCHOWN@
 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
index de602d3..17182dc 100644 (file)
@@ -1,10 +1,18 @@
-# getusershell.m4 serial 4
-dnl Copyright (C) 2002, 2003, 2006 Free Software Foundation, Inc.
+# getusershell.m4 serial 5
+dnl Copyright (C) 2002, 2003, 2006, 2008 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
 
 AC_DEFUN([gl_FUNC_GETUSERSHELL],
 [
-  AC_REPLACE_FUNCS(getusershell)
+  AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
+
+  dnl Persuade glibc <unistd.h> to declare {get,set,end}usershell().
+  AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+
+  AC_REPLACE_FUNCS([getusershell])
+  if test $ac_cv_func_getusershell = no; then
+    HAVE_GETUSERSHELL=0
+  fi
 ])
index b4a6055..7a3798b 100644 (file)
@@ -45,6 +45,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
   GNULIB_GETDTABLESIZE=0;    AC_SUBST([GNULIB_GETDTABLESIZE])
   GNULIB_GETLOGIN_R=0;       AC_SUBST([GNULIB_GETLOGIN_R])
   GNULIB_GETPAGESIZE=0;      AC_SUBST([GNULIB_GETPAGESIZE])
+  GNULIB_GETUSERSHELL=0;     AC_SUBST([GNULIB_GETUSERSHELL])
   GNULIB_LCHOWN=0;           AC_SUBST([GNULIB_LCHOWN])
   GNULIB_LSEEK=0;            AC_SUBST([GNULIB_LSEEK])
   GNULIB_READLINK=0;         AC_SUBST([GNULIB_READLINK])
@@ -59,6 +60,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
   HAVE_GETDOMAINNAME=1;   AC_SUBST([HAVE_GETDOMAINNAME])
   HAVE_GETDTABLESIZE=1;   AC_SUBST([HAVE_GETDTABLESIZE])
   HAVE_GETPAGESIZE=1;     AC_SUBST([HAVE_GETPAGESIZE])
+  HAVE_GETUSERSHELL=1;    AC_SUBST([HAVE_GETUSERSHELL])
   HAVE_READLINK=1;        AC_SUBST([HAVE_READLINK])
   HAVE_SLEEP=1;           AC_SUBST([HAVE_SLEEP])
   HAVE_DECL_ENVIRON=1;    AC_SUBST([HAVE_DECL_ENVIRON])
index 8b64506..9ae7dca 100644 (file)
@@ -6,15 +6,19 @@ lib/getusershell.c
 m4/getusershell.m4
 
 Depends-on:
+unistd
+extensions
 fopen-safer
 xalloc
 
 configure.ac:
 gl_FUNC_GETUSERSHELL
+gl_UNISTD_MODULE_INDICATOR([getusershell])
 
 Makefile.am:
 
 Include:
+<unistd.h>
 
 License:
 GPL
index 1822190..2f1c0aa 100644 (file)
@@ -37,6 +37,7 @@ unistd.h: unistd.in.h
              -e 's|@''GNULIB_GETDTABLESIZE''@|$(GNULIB_GETDTABLESIZE)|g' \
              -e 's|@''GNULIB_GETLOGIN_R''@|$(GNULIB_GETLOGIN_R)|g' \
              -e 's|@''GNULIB_GETPAGESIZE''@|$(GNULIB_GETPAGESIZE)|g' \
+             -e 's|@''GNULIB_GETUSERSHELL''@|$(GNULIB_GETUSERSHELL)|g' \
              -e 's|@''GNULIB_LCHOWN''@|$(GNULIB_LCHOWN)|g' \
              -e 's|@''GNULIB_LSEEK''@|$(GNULIB_LSEEK)|g' \
              -e 's|@''GNULIB_READLINK''@|$(GNULIB_READLINK)|g' \
@@ -50,6 +51,7 @@ unistd.h: unistd.in.h
              -e 's|@''HAVE_GETDOMAINNAME''@|$(HAVE_GETDOMAINNAME)|g' \
              -e 's|@''HAVE_GETDTABLESIZE''@|$(HAVE_GETDTABLESIZE)|g' \
              -e 's|@''HAVE_GETPAGESIZE''@|$(HAVE_GETPAGESIZE)|g' \
+             -e 's|@''HAVE_GETUSERSHELL''@|$(HAVE_GETUSERSHELL)|g' \
              -e 's|@''HAVE_READLINK''@|$(HAVE_READLINK)|g' \
              -e 's|@''HAVE_SLEEP''@|$(HAVE_SLEEP)|g' \
              -e 's|@''HAVE_DECL_ENVIRON''@|$(HAVE_DECL_ENVIRON)|g' \