1 /* Substitute for and wrapper around <unistd.h>.
2 Copyright (C) 2004-2007 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
9 This program 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
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software Foundation,
16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
22 # include @ABSOLUTE_UNISTD_H@
25 /* mingw doesn't define the SEEK_* macros in <unistd.h>. */
26 #if !(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET)
31 /* The definition of GL_LINK_WARNING is copied here. */
34 /* Declare overridden functions. */
43 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
44 to GID (if GID is not -1).
45 Return 0 if successful, otherwise -1 and errno set.
46 See the POSIX:2001 specification
47 <http://www.opengroup.org/susv3xsh/chown.html>. */
48 # define chown rpl_chown
49 extern int chown (const char *file, uid_t uid, gid_t gid);
51 #elif defined GNULIB_POSIXCHECK
53 # define chown(f,u,g) \
54 (GL_LINK_WARNING ("chown fails to follow symlinks on some systems and " \
55 "doesn't treat a uid or gid of -1 on some systems - " \
56 "use gnulib module chown for portability"), \
63 /* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if
64 NEWFD = OLDFD, otherwise close NEWFD first if it is open.
65 Return 0 if successful, otherwise -1 and errno set.
66 See the POSIX:2001 specification
67 <http://www.opengroup.org/susv3xsh/dup2.html>. */
68 extern int dup2 (int oldfd, int newfd);
70 #elif defined GNULIB_POSIXCHECK
73 (GL_LINK_WARNING ("dup2 is unportable - " \
74 "use gnulib module dup2 for portability"), \
82 /* Change the process' current working directory to the directory on which
83 the given file descriptor is open.
84 Return 0 if successful, otherwise -1 and errno set.
85 See the POSIX:2001 specification
86 <http://www.opengroup.org/susv3xsh/fchdir.html>. */
87 extern int fchdir (int /*fd*/);
89 # define close rpl_close
90 extern int close (int);
93 # define dup2 rpl_dup2
94 extern int dup2 (int, int);
97 #elif defined GNULIB_POSIXCHECK
100 (GL_LINK_WARNING ("fchdir is unportable - " \
101 "use gnulib module fchdir for portability"), \
106 #if @GNULIB_FTRUNCATE@
107 # if !@HAVE_FTRUNCATE@
108 /* Change the size of the file to which FD is opened to become equal to LENGTH.
109 Return 0 if successful, otherwise -1 and errno set.
110 See the POSIX:2001 specification
111 <http://www.opengroup.org/susv3xsh/ftruncate.html>. */
112 extern int ftruncate (int fd, off_t length);
114 #elif defined GNULIB_POSIXCHECK
116 # define ftruncate(f,l) \
117 (GL_LINK_WARNING ("ftruncate is unportable - " \
118 "use gnulib module ftruncate for portability"), \
124 /* Include the headers that might declare getcwd so that they will not
125 cause confusion if included after this file. */
127 # if @REPLACE_GETCWD@
128 /* Get the name of the current working directory, and put it in SIZE bytes
130 Return BUF if successful, or NULL if the directory couldn't be determined
131 or SIZE was too small.
132 See the POSIX:2001 specification
133 <http://www.opengroup.org/susv3xsh/getcwd.html>.
134 Additionally, the gnulib module 'getcwd' guarantees the following GNU
135 extension: If BUF is NULL, an array is allocated with 'malloc'; the array
136 is SIZE bytes long, unless SIZE == 0, in which case it is as big as
138 # define getcwd rpl_getcwd
139 extern char * getcwd (char *buf, size_t size);
141 #elif defined GNULIB_POSIXCHECK
143 # define getcwd(b,s) \
144 (GL_LINK_WARNING ("getcwd is unportable - " \
145 "use gnulib module getcwd for portability"), \
150 #if @GNULIB_GETLOGIN_R@
151 /* Copies the user's login name to NAME.
152 The array pointed to by NAME has room for SIZE bytes.
154 Returns 0 if successful. Upon error, an error number is returned, or -1 in
155 the case that the login name cannot be found but no specific error is
156 provided (this case is hopefully rare but is left open by the POSIX spec).
158 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
160 # if !@HAVE_DECL_GETLOGIN_R@
162 extern int getlogin_r (char *name, size_t size);
164 #elif defined GNULIB_POSIXCHECK
166 # define getlogin_r(n,s) \
167 (GL_LINK_WARNING ("getlogin_r is unportable - " \
168 "use gnulib module getlogin_r for portability"), \
173 #if @GNULIB_READLINK@
174 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
175 bytes of it into BUF. Return the number of bytes placed into BUF if
176 successful, otherwise -1 and errno set.
177 See the POSIX:2001 specification
178 <http://www.opengroup.org/susv3xsh/readlink.html>. */
179 # if !@HAVE_READLINK@
181 extern int readlink (const char *file, char *buf, size_t bufsize);
183 #elif defined GNULIB_POSIXCHECK
185 # define readlink(f,b,s) \
186 (GL_LINK_WARNING ("readlink is unportable - " \
187 "use gnulib module readlink for portability"), \
197 #endif /* _GL_UNISTD_H */