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@
26 /* The definition of GL_LINK_WARNING is copied here. */
29 /* Declare overridden functions. */
38 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
39 to GID (if GID is not -1).
40 Return 0 if successful, otherwise -1 and errno set.
41 See the POSIX:2001 specification
42 <http://www.opengroup.org/susv3xsh/chown.html>. */
43 # define chown rpl_chown
44 extern int chown (const char *file, uid_t uid, gid_t gid);
46 #elif defined GNULIB_POSIXCHECK
48 # define chown(f,u,g) \
49 (GL_LINK_WARNING ("chown fails to follow symlinks on some systems and " \
50 "doesn't treat a uid or gid of -1 on some systems - " \
51 "use gnulib module chown for portability"), \
58 /* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if
59 NEWFD = OLDFD, otherwise close NEWFD first if it is open.
60 Return 0 if successful, otherwise -1 and errno set.
61 See the POSIX:2001 specification
62 <http://www.opengroup.org/susv3xsh/dup2.html>. */
63 extern int dup2 (int oldfd, int newfd);
65 #elif defined GNULIB_POSIXCHECK
68 (GL_LINK_WARNING ("dup2 is unportable - " \
69 "use gnulib module dup2 for portability"), \
77 /* Change the process' current working directory to the directory on which
78 the given file descriptor is open.
79 Return 0 if successful, otherwise -1 and errno set.
80 See the POSIX:2001 specification
81 <http://www.opengroup.org/susv3xsh/fchdir.html>. */
82 extern int fchdir (int /*fd*/);
84 # define close rpl_close
85 extern int close (int);
88 # define dup2 rpl_dup2
89 extern int dup2 (int, int);
92 #elif defined GNULIB_POSIXCHECK
95 (GL_LINK_WARNING ("fchdir is unportable - " \
96 "use gnulib module fchdir for portability"), \
101 #if @GNULIB_FTRUNCATE@
102 # if !@HAVE_FTRUNCATE@
103 /* Change the size of the file to which FD is opened to become equal to LENGTH.
104 Return 0 if successful, otherwise -1 and errno set.
105 See the POSIX:2001 specification
106 <http://www.opengroup.org/susv3xsh/ftruncate.html>. */
107 extern int ftruncate (int fd, off_t length);
109 #elif defined GNULIB_POSIXCHECK
111 # define ftruncate(f,l) \
112 (GL_LINK_WARNING ("ftruncate is unportable - " \
113 "use gnulib module ftruncate for portability"), \
119 /* Include the headers that might declare getcwd so that they will not
120 cause confusion if included after this file. */
122 # if @REPLACE_GETCWD@
123 /* Get the name of the current working directory, and put it in SIZE bytes
125 Return BUF if successful, or NULL if the directory couldn't be determined
126 or SIZE was too small.
127 See the POSIX:2001 specification
128 <http://www.opengroup.org/susv3xsh/getcwd.html>.
129 Additionally, the gnulib module 'getcwd' guarantees the following GNU
130 extension: If BUF is NULL, an array is allocated with 'malloc'; the array
131 is SIZE bytes long, unless SIZE == 0, in which case it is as big as
133 # define getcwd rpl_getcwd
134 extern char * getcwd (char *buf, size_t size);
136 #elif defined GNULIB_POSIXCHECK
138 # define getcwd(b,s) \
139 (GL_LINK_WARNING ("getcwd is unportable - " \
140 "use gnulib module getcwd for portability"), \
145 #if @GNULIB_GETLOGIN_R@
146 /* Copies the user's login name to NAME.
147 The array pointed to by NAME has room for SIZE bytes.
149 Returns 0 if successful. Upon error, an error number is returned, or -1 in
150 the case that the login name cannot be found but no specific error is
151 provided (this case is hopefully rare but is left open by the POSIX spec).
153 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
155 # if !@HAVE_DECL_GETLOGIN_R@
157 extern int getlogin_r (char *name, size_t size);
159 #elif defined GNULIB_POSIXCHECK
161 # define getlogin_r(n,s) \
162 (GL_LINK_WARNING ("getlogin_r is unportable - " \
163 "use gnulib module getlogin_r for portability"), \
168 #if @GNULIB_READLINK@
169 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
170 bytes of it into BUF. Return the number of bytes placed into BUF if
171 successful, otherwise -1 and errno set.
172 See the POSIX:2001 specification
173 <http://www.opengroup.org/susv3xsh/readlink.html>. */
174 # if !@HAVE_READLINK@
176 extern int readlink (const char *file, char *buf, size_t bufsize);
178 #elif defined GNULIB_POSIXCHECK
180 # define readlink(f,b,s) \
181 (GL_LINK_WARNING ("readlink is unportable - " \
182 "use gnulib module readlink for portability"), \
192 #endif /* _GL_UNISTD_H */