1
1
/* Substitute for and wrapper around <unistd.h>.
2
Copyright (C) 2004-2008 Free Software Foundation, Inc.
2
Copyright (C) 2003-2008 Free Software Foundation, Inc.
4
4
This program is free software; you can redistribute it and/or modify
5
5
it under the terms of the GNU Lesser General Public License as published by
33
37
/* mingw fails to declare _exit in <unistd.h>. */
38
/* mingw, BeOS, Haiku declare environ in <stdlib.h>, not in <unistd.h>. */
34
39
#include <stdlib.h>
41
#if @GNULIB_WRITE@ && @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@
43
# include <sys/types.h>
46
#if @GNULIB_GETHOSTNAME@
47
/* Get all possible declarations of gethostname(). */
48
# if @UNISTD_H_HAVE_WINSOCK2_H@
49
# include <winsock2.h>
50
# if !defined _GL_SYS_SOCKET_H
52
# define socket socket_used_without_including_sys_socket_h
54
# define connect connect_used_without_including_sys_socket_h
56
# define accept accept_used_without_including_sys_socket_h
58
# define bind bind_used_without_including_sys_socket_h
60
# define getpeername getpeername_used_without_including_sys_socket_h
62
# define getsockname getsockname_used_without_including_sys_socket_h
64
# define getsockopt getsockopt_used_without_including_sys_socket_h
66
# define listen listen_used_without_including_sys_socket_h
68
# define recv recv_used_without_including_sys_socket_h
70
# define send send_used_without_including_sys_socket_h
72
# define recvfrom recvfrom_used_without_including_sys_socket_h
74
# define sendto sendto_used_without_including_sys_socket_h
76
# define setsockopt setsockopt_used_without_including_sys_socket_h
78
# define shutdown shutdown_used_without_including_sys_socket_h
80
# if !defined _GL_SYS_SELECT_H
82
# define select select_used_without_including_sys_select_h
36
87
/* The definition of GL_LINK_WARNING is copied here. */
123
# if @UNISTD_H_HAVE_WINSOCK2_H@
124
/* Need a gnulib internal function. */
125
# define HAVE__GL_CLOSE_FD_MAYBE_SOCKET 1
128
/* Automatically included by modules that need a replacement for close. */
130
# define close rpl_close
131
extern int close (int);
133
#elif @UNISTD_H_HAVE_WINSOCK2_H@
135
# define close close_used_without_requesting_gnulib_module_close
136
#elif defined GNULIB_POSIXCHECK
139
(GL_LINK_WARNING ("close does not portably work on sockets - " \
140
"use gnulib module close for portability"), \
73
147
/* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if
183
#if @GNULIB_EUIDACCESS@
184
# if !@HAVE_EUIDACCESS@
185
/* Like access(), except that is uses the effective user id and group id of
186
the current process. */
187
extern int euidaccess (const char *filename, int mode);
189
#elif defined GNULIB_POSIXCHECK
191
# define euidaccess(f,m) \
192
(GL_LINK_WARNING ("euidaccess is unportable - " \
193
"use gnulib module euidaccess for portability"), \
109
198
#if @GNULIB_FCHDIR@
110
199
# if @REPLACE_FCHDIR@
224
/* Synchronize changes to a file.
225
Return 0 if successful, otherwise -1 and errno set.
226
See POSIX:2001 specification
227
<http://www.opengroup.org/susv3xsh/fsync.html>. */
229
extern int fsync (int fd);
231
#elif defined GNULIB_POSIXCHECK
234
(GL_LINK_WARNING ("fsync is unportable - " \
235
"use gnulib module fsync for portability"), \
136
240
#if @GNULIB_FTRUNCATE@
137
241
# if !@HAVE_FTRUNCATE@
138
242
/* Change the size of the file to which FD is opened to become equal to LENGTH.
284
#if @GNULIB_GETDOMAINNAME@
285
/* Return the NIS domain name of the machine.
286
WARNING! The NIS domain name is unrelated to the fully qualified host name
287
of the machine. It is also unrelated to email addresses.
288
WARNING! The NIS domain name is usually the empty string or "(none)" when
291
Put up to LEN bytes of the NIS domain name into NAME.
292
Null terminate it if the name is shorter than LEN.
293
If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
294
Return 0 if successful, otherwise set errno and return -1. */
295
# if !@HAVE_GETDOMAINNAME@
296
extern int getdomainname(char *name, size_t len);
298
#elif defined GNULIB_POSIXCHECK
299
# undef getdomainname
300
# define getdomainname(n,l) \
301
(GL_LINK_WARNING ("getdomainname is unportable - " \
302
"use gnulib module getdomainname for portability"), \
303
getdomainname (n, l))
307
#if @GNULIB_GETDTABLESIZE@
308
# if !@HAVE_GETDTABLESIZE@
309
/* Return the maximum number of file descriptors in the current process. */
310
extern int getdtablesize (void);
312
#elif defined GNULIB_POSIXCHECK
313
# undef getdtablesize
314
# define getdtablesize() \
315
(GL_LINK_WARNING ("getdtablesize is unportable - " \
316
"use gnulib module getdtablesize for portability"), \
321
#if @GNULIB_GETHOSTNAME@
322
/* Return the standard host name of the machine.
323
WARNING! The host name may or may not be fully qualified.
325
Put up to LEN bytes of the host name into NAME.
326
Null terminate it if the name is shorter than LEN.
327
If the host name is longer than LEN, set errno = EINVAL and return -1.
328
Return 0 if successful, otherwise set errno and return -1. */
329
# if @UNISTD_H_HAVE_WINSOCK2_H@
331
# define gethostname rpl_gethostname
333
# if @UNISTD_H_HAVE_WINSOCK2_H@ || !@HAVE_GETHOSTNAME@
334
extern int gethostname(char *name, size_t len);
336
#elif @UNISTD_H_HAVE_WINSOCK2_H@
338
# define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
339
#elif defined GNULIB_POSIXCHECK
341
# define gethostname(n,l) \
342
(GL_LINK_WARNING ("gethostname is unportable - " \
343
"use gnulib module gethostname for portability"), \
180
348
#if @GNULIB_GETLOGIN_R@
181
349
/* Copies the user's login name to NAME.
182
350
The array pointed to by NAME has room for SIZE bytes.
429
#if @GNULIB_GETUSERSHELL@
430
# if !@HAVE_GETUSERSHELL@
431
/* Return the next valid login shell on the system, or NULL when the end of
432
the list has been reached. */
433
extern char *getusershell (void);
434
/* Rewind to pointer that is advanced at each getusershell() call. */
435
extern void setusershell (void);
436
/* Free the pointer that is advanced at each getusershell() call and
437
associated resources. */
438
extern void endusershell (void);
440
#elif defined GNULIB_POSIXCHECK
442
# define getusershell() \
443
(GL_LINK_WARNING ("getusershell is unportable - " \
444
"use gnulib module getusershell for portability"), \
447
# define setusershell() \
448
(GL_LINK_WARNING ("setusershell is unportable - " \
449
"use gnulib module getusershell for portability"), \
452
# define endusershell() \
453
(GL_LINK_WARNING ("endusershell is unportable - " \
454
"use gnulib module getusershell for portability"), \
261
459
#if @GNULIB_LCHOWN@
262
460
# if @REPLACE_LCHOWN@
263
461
/* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
532
#if @GNULIB_WRITE@ && @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@
533
/* Write up to COUNT bytes starting at BUF to file descriptor FD.
534
See the POSIX:2001 specification
535
<http://www.opengroup.org/susv3xsh/write.html>. */
537
# define write rpl_write
538
extern ssize_t write (int fd, const void *buf, size_t count);
542
#ifdef FCHDIR_REPLACEMENT
543
/* gnulib internal function. */
544
extern void _gl_unregister_fd (int fd);
334
548
#ifdef __cplusplus