Revamp lchown so that it lives in unistd.h where it belongs.
[pspp] / lib / unistd_.h
index da165c5bfff934b15eacdf883d017b45b43feccd..24090053103d4200f50e1fff0d0ce6d09e24a5cf 100644 (file)
@@ -16,8 +16,8 @@
    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
 
 #ifndef _GL_UNISTD_H
-#define _GL_UNISTD_H
 
+/* The include_next requires a split double-inclusion guard.  */
 #if @HAVE_UNISTD_H@
 # if @HAVE_INCLUDE_NEXT@
 #  include_next <unistd.h>
@@ -26,6 +26,9 @@
 # endif
 #endif
 
+#ifndef _GL_UNISTD_H
+#define _GL_UNISTD_H
+
 /* mingw doesn't define the SEEK_* macros in <unistd.h>.  */
 #if !(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET)
 # include <stdio.h>
@@ -46,13 +49,18 @@ extern "C" {
 
 #if @GNULIB_CHOWN@
 # if @REPLACE_CHOWN@
+#  ifndef REPLACE_CHOWN
+#   define REPLACE_CHOWN 1
+#  endif
+#  if REPLACE_CHOWN
 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
-   to GID (if GID is not -1).
+   to GID (if GID is not -1).  Follow symbolic links.
    Return 0 if successful, otherwise -1 and errno set.
    See the POSIX:2001 specification
    <http://www.opengroup.org/susv3xsh/chown.html>.  */
-#  define chown rpl_chown
+#   define chown rpl_chown
 extern int chown (const char *file, uid_t uid, gid_t gid);
+#  endif
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef chown
@@ -176,6 +184,25 @@ extern int getlogin_r (char *name, size_t size);
 #endif
 
 
+#if @GNULIB_LCHOWN@
+# if @REPLACE_LCHOWN@
+/* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
+   to GID (if GID is not -1).  Do not follow symbolic links.
+   Return 0 if successful, otherwise -1 and errno set.
+   See the POSIX:2001 specification
+   <http://www.opengroup.org/susv3xsh/lchown.html>.  */
+#  define lchown rpl_lchown
+extern int lchown (char const *file, uid_t owner, gid_t group);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef lchown
+# define lchown(f,u,g) \
+    (GL_LINK_WARNING ("lchown is unportable to pre-POSIX.1-2001 " \
+                      "systems - use gnulib module lchown for portability"), \
+     lchown (f, u, g))
+#endif
+
+
 #if @GNULIB_LSEEK@
 # if @REPLACE_LSEEK@
 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
@@ -188,9 +215,8 @@ extern int getlogin_r (char *name, size_t size);
 #elif defined GNULIB_POSIXCHECK
 # undef lseek
 # define lseek(f,o,w) \
-    (GL_LINK_WARNING ("lseek does not fail with ESPIPE on non-seekable " \
-                      "files on some systems - " \
-                      "use gnulib module lseek for portability"), \
+    (GL_LINK_WARNING ("lseek does not fail with ESPIPE on pipes on some " \
+                      "systems - use gnulib module lseek for portability"), \
      lseek (f, o, w))
 #endif
 
@@ -237,3 +263,4 @@ extern unsigned int sleep (unsigned int n);
 
 
 #endif /* _GL_UNISTD_H */
+#endif /* _GL_UNISTD_H */