Generate file which recognizes __need_FOPEN_MAX.
[glibc/history.git] / posix / unistd.h
blob004d6a84f1c7749a154377a7125fd3f7b9d12a90
1 /* Copyright (C) 1991, 92, 93, 94, 95, 96, 97 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
9 The GNU C Library 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 GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public
15 License along with the GNU C Library; see the file COPYING.LIB. If not,
16 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. */
20 * POSIX Standard: 2.10 Symbolic Constants <unistd.h>
23 #ifndef _UNISTD_H
25 #define _UNISTD_H 1
26 #include <features.h>
28 __BEGIN_DECLS
30 /* These may be used to determine what facilities are present at compile time.
31 Their values can be obtained at run time from `sysconf'. */
33 /* POSIX Standard approved as IEEE Std 1003.1 as of August, 1988 and
34 extended by P1003.1b (aka POSIX.4). */
35 #define _POSIX_VERSION 199309L
37 /* These are not #ifdef __USE_POSIX2 because they are
38 in the theoretically application-owned namespace. */
40 #define _POSIX2_C_VERSION 199912L /* Invalid until 1003.2 is done. */
42 /* If defined, the implementation supports the
43 C Language Bindings Option. */
44 #define _POSIX2_C_BIND 1
46 /* If defined, the implementation supports the
47 C Language Development Utilities Option. */
48 #define _POSIX2_C_DEV 1
50 /* If defined, the implementation supports the
51 Software Development Utilities Option. */
52 #define _POSIX2_SW_DEV 1
54 /* If defined, the implementation supports the
55 creation of locales with the localedef utility. */
56 #define _POSIX2_LOCALEDEF 1
58 /* Library conforms to X/Open version 4. */
59 #define _XOPEN_VERSION 4
61 /* Commands and utilities from XPG4 are available. */
62 #define _XOPEN_XCU_VERSION 4
64 /* We are compatible with the old published standards as well. */
65 #define _XOPEN_XPG2 1
66 #define _XOPEN_XPG3 1
67 #define _XOPEN_XPG4 1
69 /* The X/Open Unix extensions are available. */
70 #define _XOPEN_UNIX 1
72 /* Encryption is present. */
73 #define _XOPEN_CRYPT 1
75 /* The enhanced internationalization capabilities according to XPG4.2
76 are present. */
77 #define _XOPEN_ENH_I18N 1
80 /* Get values of POSIX options:
82 If these symbols are defined, the corresponding features are
83 always available. If not, they may be available sometimes.
84 The current values can be obtained with `sysconf'.
86 _POSIX_JOB_CONTROL Job control is supported.
87 _POSIX_SAVED_IDS Processes have a saved set-user-ID
88 and a saved set-group-ID.
89 _POSIX_REALTIME_SIGNALS Real-time, queued signals are supported.
90 _POSIX_PRIORITY_SCHEDULING Priority scheduling is supported.
91 _POSIX_TIMERS POSIX.4 clocks and timers are supported.
92 _POSIX_ASYNCHRONOUS_IO Asynchronous I/O is supported.
93 _POSIX_PRIORITIZED_IO Prioritized asynchronous I/O is supported.
94 _POSIX_SYNCHRONIZED_IO Synchronizing file data is supported.
95 _POSIX_FSYNC The fsync function is present.
96 _POSIX_MAPPED_FILES Mapping of files to memory is supported.
97 _POSIX_MEMLOCK Locking of all memory is supported.
98 _POSIX_MEMLOCK_RANGE Locking of ranges of memory is supported.
99 _POSIX_MEMORY_PROTECTION Setting of memory protections is supported.
100 _POSIX_MESSAGE_PASSING POSIX.4 message queues are supported.
101 _POSIX_SEMAPHORES POSIX.4 counting semaphores are supported.
102 _POSIX_SHARED_MEMORY_OBJECTS POSIX.4 shared memory objects are supported.
103 _POSIX_PII Protocol-independent interfaces are supported.
104 _POSIX_PII_XTI XTI protocol-indep. interfaces are supported.
105 _POSIX_PII_SOCKET Socket protocol-indep. interfaces are supported.
106 _POSIX_PII_INTERNET Internet family of protocols supported.
107 _POSIX_PII_INTERNET_STREAM Connection-mode Internet protocol supported.
108 _POSIX_PII_INTERNET_DGRAM Connectionless Internet protocol supported.
109 _POSIX_PII_OSI ISO/OSI family of protocols supported.
110 _POSIX_PII_OSI_COTS Connection-mode ISO/OSI service supported.
111 _POSIX_PII_OSI_CLTS Connectionless ISO/OSI service supported.
112 _POSIX_POLL Implementation supports `poll' function.
113 _POSIX_SELECT Implementation supports `select' and `pselect'.
115 _XOPEN_SHM Shared memory interface according to XPG4.2.
117 If any of these symbols is defined as -1, the corresponding option is not
118 true for any file. If any is defined as other than -1, the corresponding
119 option is true for all files. If a symbol is not defined at all, the value
120 for a specific file can be obtained from `pathconf' and `fpathconf'.
122 _POSIX_CHOWN_RESTRICTED Only the super user can use `chown' to change
123 the owner of a file. `chown' can only be used
124 to change the group ID of a file to a group of
125 which the calling process is a member.
126 _POSIX_NO_TRUNC Pathname components longer than
127 NAME_MAX generate an error.
128 _POSIX_VDISABLE If defined, if the value of an element of the
129 `c_cc' member of `struct termios' is
130 _POSIX_VDISABLE, no character will have the
131 effect associated with that element.
132 _POSIX_SYNC_IO Synchronous I/O may be performed.
133 _POSIX_ASYNC_IO Asynchronous I/O may be performed.
134 _POSIX_PRIO_IO Prioritized Asynchronous I/O may be performed.
137 #include <posix_opt.h>
140 /* Standard file descriptors. */
141 #define STDIN_FILENO 0 /* Standard input. */
142 #define STDOUT_FILENO 1 /* Standard output. */
143 #define STDERR_FILENO 2 /* Standard error output. */
146 /* All functions that are not declared anywhere else. */
148 #include <gnu/types.h>
150 #ifndef ssize_t
151 typedef __ssize_t ssize_t;
152 #define ssize_t ssize_t
153 #endif
155 #define __need_size_t
156 #define __need_NULL
157 #include <stddef.h>
160 /* Values for the second argument to access.
161 These may be OR'd together. */
162 #define R_OK 4 /* Test for read permission. */
163 #define W_OK 2 /* Test for write permission. */
164 #define X_OK 1 /* Test for execute permission. */
165 #define F_OK 0 /* Test for existence. */
167 /* Test for access to NAME using the real UID and real GID. */
168 extern int __access __P ((__const char *__name, int __type));
169 extern int access __P ((__const char *__name, int __type));
171 #ifdef __USE_GNU
172 /* Test for access to NAME using the effective UID and GID
173 (as normal file operations use). */
174 extern int __euidaccess __P ((__const char *__name, int __type));
175 extern int euidaccess __P ((__const char *__name, int __type));
176 #endif
179 /* Values for the WHENCE argument to lseek. */
180 #ifndef _STDIO_H /* <stdio.h> has the same definitions. */
181 #define SEEK_SET 0 /* Seek from beginning of file. */
182 #define SEEK_CUR 1 /* Seek from current position. */
183 #define SEEK_END 2 /* Seek from end of file. */
184 #endif
186 #if defined (__USE_BSD) && !defined (L_SET)
187 /* Old BSD names for the same constants; just for compatibility. */
188 #define L_SET SEEK_SET
189 #define L_INCR SEEK_CUR
190 #define L_XTND SEEK_END
191 #endif
194 /* Move FD's file position to OFFSET bytes from the
195 beginning of the file (if WHENCE is SEEK_SET),
196 the current position (if WHENCE is SEEK_CUR),
197 or the end of the file (if WHENCE is SEEK_END).
198 Return the new file position. */
199 extern __off_t __lseek __P ((int __fd, __off_t __offset, int __whence));
200 extern __off_t lseek __P ((int __fd, __off_t __offset, int __whence));
202 /* Close the file descriptor FD. */
203 extern int __close __P ((int __fd));
204 extern int close __P ((int __fd));
206 /* Read NBYTES into BUF from FD. Return the
207 number read, -1 for errors or 0 for EOF. */
208 extern ssize_t __read __P ((int __fd, __ptr_t __buf, size_t __nbytes));
209 extern ssize_t read __P ((int __fd, __ptr_t __buf, size_t __nbytes));
211 /* Write N bytes of BUF to FD. Return the number written, or -1. */
212 extern ssize_t __write __P ((int __fd, __const __ptr_t __buf, size_t __n));
213 extern ssize_t write __P ((int __fd, __const __ptr_t __buf, size_t __n));
216 /* Create a one-way communication channel (pipe).
217 If successful, two file descriptors are stored in PIPEDES;
218 bytes written on PIPEDES[1] can be read from PIPEDES[0].
219 Returns 0 if successful, -1 if not. */
220 extern int __pipe __P ((int __pipedes[2]));
221 extern int pipe __P ((int __pipedes[2]));
223 /* Schedule an alarm. In SECONDS seconds, the process will get a SIGALRM.
224 If SECONDS is zero, any currently scheduled alarm will be cancelled.
225 The function returns the number of seconds remaining until the last
226 alarm scheduled would have signaled, or zero if there wasn't one.
227 There is no return value to indicate an error, but you can set `errno'
228 to 0 and check its value after calling `alarm', and this might tell you.
229 The signal may come late due to processor scheduling. */
230 extern unsigned int alarm __P ((unsigned int __seconds));
232 /* Make the process sleep for SECONDS seconds, or until a signal arrives
233 and is not ignored. The function returns the number of seconds less
234 than SECONDS which it actually slept (thus zero if it slept the full time).
235 If a signal handler does a `longjmp' or modifies the handling of the
236 SIGALRM signal while inside `sleep' call, the handling of the SIGALRM
237 signal afterwards is undefined. There is no return value to indicate
238 error, but if `sleep' returns SECONDS, it probably didn't work. */
239 extern unsigned int sleep __P ((unsigned int __seconds));
241 #if defined(__USE_BSD) || defined(__USE_XOPEN_EXTENDED)
242 /* Set an alarm to go off (generating a SIGALRM signal) in VALUE
243 microseconds. If INTERVAL is nonzero, when the alarm goes off, the
244 timer is reset to go off every INTERVAL microseconds thereafter.
245 Returns the number of microseconds remaining before the alarm. */
246 extern unsigned int ualarm __P ((unsigned int __value,
247 unsigned int __interval));
249 /* Sleep USECONDS microseconds, or until a signal arrives that is not blocked
250 or ignored. */
251 extern void usleep __P ((unsigned int __useconds));
252 #endif
255 /* Suspend the process until a signal arrives.
256 This always returns -1 and sets `errno' to EINTR. */
257 extern int pause __P ((void));
260 /* Change the owner and group of FILE. */
261 extern int __chown __P ((__const char *__file,
262 __uid_t __owner, __gid_t __group));
263 extern int chown __P ((__const char *__file,
264 __uid_t __owner, __gid_t __group));
266 #if defined(__USE_BSD) || defined(__USE_XOPEN_EXTENDED)
267 /* Change the owner and group of the file that FD is open on. */
268 extern int __fchown __P ((int __fd,
269 __uid_t __owner, __gid_t __group));
270 extern int fchown __P ((int __fd,
271 __uid_t __owner, __gid_t __group));
274 /* Change owner and group of FILE, if it is a symbolic
275 link the ownership of the symbolic link is changed. */
276 extern int __lchown __P ((__const char *__file, __uid_t __owner,
277 __gid_t __group));
278 extern int lchown __P ((__const char *__file, __uid_t __owner,
279 __gid_t __group));
281 #endif /* Use BSD || X/Open Unix. */
283 /* Change the process's working directory to PATH. */
284 extern int __chdir __P ((__const char *__path));
285 extern int chdir __P ((__const char *__path));
287 #if defined(__USE_BSD) || defined(__USE_XOPEN_EXTENDED)
288 /* Change the process's working directory to the one FD is open on. */
289 extern int fchdir __P ((int __fd));
290 #endif
292 /* Get the pathname of the current working directory,
293 and put it in SIZE bytes of BUF. Returns NULL if the
294 directory couldn't be determined or SIZE was too small.
295 If successful, returns BUF. In GNU, if BUF is NULL,
296 an array is allocated with `malloc'; the array is SIZE
297 bytes long, unless SIZE <= 0, in which case it is as
298 big as necessary. */
299 extern char *__getcwd __P ((char *__buf, size_t __size));
300 extern char *getcwd __P ((char *__buf, size_t __size));
302 #ifdef __USE_GNU
303 /* Return a malloc'd string containing the current directory name.
304 If the environment variable `PWD' is set, and its value is correct,
305 that value is used. */
306 extern char *get_current_dir_name __P ((void));
308 /* Get the canonical absolute name of the named directory, and put it in SIZE
309 bytes of BUF. Returns NULL if the directory couldn't be determined or
310 SIZE was too small. If successful, returns BUF. In GNU, if BUF is
311 NULL, an array is allocated with `malloc'; the array is SIZE bytes long,
312 unless SIZE <= 0, in which case it is as big as necessary. */
314 char *__canonicalize_directory_name_internal __P ((__const char *__thisdir,
315 char *__buf,
316 size_t __size));
317 #endif
319 #if defined(__USE_BSD) || defined(__USE_XOPEN_EXTENDED)
320 /* Put the absolute pathname of the current working directory in BUF.
321 If successful, return BUF. If not, put an error message in
322 BUF and return NULL. BUF should be at least PATH_MAX bytes long. */
323 extern char *getwd __P ((char *__buf));
324 #endif
327 /* Duplicate FD, returning a new file descriptor on the same file. */
328 extern int __dup __P ((int __fd));
329 extern int dup __P ((int __fd));
331 /* Duplicate FD to FD2, closing FD2 and making it open on the same file. */
332 extern int __dup2 __P ((int __fd, int __fd2));
333 extern int dup2 __P ((int __fd, int __fd2));
335 /* NULL-terminated array of "NAME=VALUE" environment variables. */
336 extern char **__environ;
337 #ifdef __USE_GNU
338 extern char **environ;
339 #endif
342 /* Replace the current process, executing PATH with arguments ARGV and
343 environment ENVP. ARGV and ENVP are terminated by NULL pointers. */
344 extern int __execve __P ((__const char *__path, char *__const __argv[],
345 char *__const __envp[]));
346 extern int execve __P ((__const char *__path, char *__const __argv[],
347 char *__const __envp[]));
349 #ifdef __USE_GNU
350 /* Execute the file FD refers to, overlaying the running program image.
351 ARGV and ENVP are passed to the new program, as for `execve'. */
352 extern int fexecve __P ((int __fd,
353 char *__const __argv[], char *__const __envp[]));
355 #endif
358 /* Execute PATH with arguments ARGV and environment from `environ'. */
359 extern int execv __P ((__const char *__path, char *__const __argv[]));
361 /* Execute PATH with all arguments after PATH until a NULL pointer,
362 and the argument after that for environment. */
363 extern int execle __P ((__const char *__path, __const char *__arg, ...));
365 /* Execute PATH with all arguments after PATH until
366 a NULL pointer and environment from `environ'. */
367 extern int execl __P ((__const char *__path, __const char *__arg, ...));
369 /* Execute FILE, searching in the `PATH' environment variable if it contains
370 no slashes, with arguments ARGV and environment from `environ'. */
371 extern int execvp __P ((__const char *__file, char *__const __argv[]));
373 /* Execute FILE, searching in the `PATH' environment variable if
374 it contains no slashes, with all arguments after FILE until a
375 NULL pointer and environment from `environ'. */
376 extern int execlp __P ((__const char *__file, __const char *__arg, ...));
379 #if defined(__USE_MISC) || defined(__USE_XOPEN)
380 /* Add INC to priority of the current process. */
381 extern int nice __P ((int __inc));
382 #endif
385 /* Terminate program execution with the low-order 8 bits of STATUS. */
386 extern void _exit __P ((int __status)) __attribute__ ((__noreturn__));
389 /* Get the `_PC_*' symbols for the NAME argument to `pathconf' and `fpathconf';
390 the `_SC_*' symbols for the NAME argument to `sysconf';
391 and the `_CS_*' symbols for the NAME argument to `confstr'. */
392 #include <confname.h>
394 /* Get file-specific configuration information about PATH. */
395 extern long int __pathconf __P ((__const char *__path, int __name));
396 extern long int pathconf __P ((__const char *__path, int __name));
398 /* Get file-specific configuration about descriptor FD. */
399 extern long int __fpathconf __P ((int __fd, int __name));
400 extern long int fpathconf __P ((int __fd, int __name));
402 /* Get the value of the system variable NAME. */
403 extern long int __sysconf __P ((int __name));
404 extern long int sysconf __P ((int __name));
406 #ifdef __USE_POSIX2
407 /* Get the value of the string-valued system variable NAME. */
408 extern size_t confstr __P ((int __name, char *__buf, size_t __len));
409 #endif
412 /* Get the process ID of the calling process. */
413 extern __pid_t __getpid __P ((void));
414 extern __pid_t getpid __P ((void));
416 /* Get the process ID of the calling process's parent. */
417 extern __pid_t __getppid __P ((void));
418 extern __pid_t getppid __P ((void));
420 /* Get the process group ID of the calling process. */
421 extern __pid_t getpgrp __P ((void));
423 /* Set the process group ID of the process matching PID to PGID.
424 If PID is zero, the current process's process group ID is set.
425 If PGID is zero, the process ID of the process is used. */
426 extern int setpgid __P ((__pid_t __pid, __pid_t __pgid));
428 /* Get the process group ID of process PID. */
429 extern __pid_t __getpgid __P ((__pid_t __pid));
430 #ifdef __USE_XOPEN_EXTENDED
431 extern __pid_t getpgid __P ((__pid_t __pid));
432 #endif
434 #if defined(__USE_SVID) || defined(__USE_BSD) || defined(__USE_XOPEN_EXTENDED)
435 /* Both System V and BSD have `setpgrp' functions, but with different
436 calling conventions. The BSD function is the same as POSIX.1 `setpgid'
437 (above). The System V function takes no arguments and puts the calling
438 process in its on group like `setpgid (0, 0)'.
440 New programs should always use `setpgid' instead.
442 The default in GNU is to provide the System V function. The BSD
443 function is available under -D_BSD_SOURCE with -lbsd-compat. */
445 #ifndef __FAVOR_BSD
447 /* Set the process group ID of the calling process to its own PID.
448 This is exactly the same as `setpgid (0, 0)'. */
449 extern int setpgrp __P ((void));
451 #else
453 /* Another name for `setpgid' (above). */
454 extern int setpgrp __P ((__pid_t __pid, __pid_t __pgrp));
456 #endif /* Favor BSD. */
457 #endif /* Use SVID or BSD. */
459 /* Create a new session with the calling process as its leader.
460 The process group IDs of the session and the calling process
461 are set to the process ID of the calling process, which is returned. */
462 extern __pid_t __setsid __P ((void));
463 extern __pid_t setsid __P ((void));
465 #ifdef __USE_XOPEN_EXTENDED
466 /* Return the session ID of the given process. */
467 extern __pid_t getsid __P ((__pid_t __pid));
468 #endif
470 /* Get the real user ID of the calling process. */
471 extern __uid_t __getuid __P ((void));
472 extern __uid_t getuid __P ((void));
474 /* Get the effective user ID of the calling process. */
475 extern __uid_t __geteuid __P ((void));
476 extern __uid_t geteuid __P ((void));
478 /* Get the real group ID of the calling process. */
479 extern __gid_t __getgid __P ((void));
480 extern __gid_t getgid __P ((void));
482 /* Get the effective group ID of the calling process. */
483 extern __gid_t __getegid __P ((void));
484 extern __gid_t getegid __P ((void));
486 /* If SIZE is zero, return the number of supplementary groups
487 the calling process is in. Otherwise, fill in the group IDs
488 of its supplementary groups in LIST and return the number written. */
489 extern int __getgroups __P ((int __size, __gid_t __list[]));
490 extern int getgroups __P ((int __size, __gid_t __list[]));
492 #ifdef __USE_GNU
493 /* Return nonzero iff the calling process is in group GID. */
494 extern int __group_member __P ((__gid_t __gid));
495 extern int group_member __P ((__gid_t __gid));
496 #endif
498 /* Set the user ID of the calling process to UID.
499 If the calling process is the super-user, set the real
500 and effective user IDs, and the saved set-user-ID to UID;
501 if not, the effective user ID is set to UID. */
502 extern int __setuid __P ((__uid_t __uid));
503 extern int setuid __P ((__uid_t __uid));
505 #if defined(__USE_BSD) || defined(__USE_XOPEN_EXTENDED)
506 /* Set the real user ID of the calling process to RUID,
507 and the effective user ID of the calling process to EUID. */
508 extern int __setreuid __P ((__uid_t __ruid, __uid_t __euid));
509 extern int setreuid __P ((__uid_t __ruid, __uid_t __euid));
510 #endif
512 #ifdef __USE_BSD
513 /* Set the effective user ID of the calling process to UID. */
514 extern int seteuid __P ((__uid_t __uid));
515 #endif /* Use BSD. */
517 /* Set the group ID of the calling process to GID.
518 If the calling process is the super-user, set the real
519 and effective group IDs, and the saved set-group-ID to GID;
520 if not, the effective group ID is set to GID. */
521 extern int __setgid __P ((__gid_t __gid));
522 extern int setgid __P ((__gid_t __gid));
524 #if defined(__USE_BSD) || defined(__USE_XOPEN_EXTENDED)
525 /* Set the real group ID of the calling process to RGID,
526 and the effective group ID of the calling process to EGID. */
527 extern int __setregid __P ((__gid_t __rgid, __gid_t __egid));
528 extern int setregid __P ((__gid_t __rgid, __gid_t __egid));
529 #endif
531 #ifdef __USE_BSD
532 /* Set the effective group ID of the calling process to GID. */
533 extern int setegid __P ((__gid_t __gid));
534 #endif /* Use BSD. */
537 /* Clone the calling process, creating an exact copy.
538 Return -1 for errors, 0 to the new process,
539 and the process ID of the new process to the old process. */
540 extern __pid_t __fork __P ((void));
541 extern __pid_t fork __P ((void));
543 #if defined(__USE_BSD) || defined(__USE_XOPEN_EXTENDED)
544 /* Clone the calling process, but without copying the whole address space.
545 The the calling process is suspended until the the new process exits or is
546 replaced by a call to `execve'. Return -1 for errors, 0 to the new process,
547 and the process ID of the new process to the old process. */
548 extern __pid_t __vfork __P ((void));
549 extern __pid_t vfork __P ((void));
550 #endif /* Use BSD. */
553 /* Return the pathname of the terminal FD is open on, or NULL on errors.
554 The returned storage is good only until the next call to this function. */
555 extern char *ttyname __P ((int __fd));
557 /* Store at most BUFLEN characters of the pathname of the terminal FD is
558 open on in BUF. Return 0 on success, otherwise an error number. */
559 extern int __ttyname_r __P ((int __fd, char *__buf, size_t __buflen));
560 extern int ttyname_r __P ((int __fd, char *__buf, size_t __buflen));
562 /* Return 1 if FD is a valid descriptor associated
563 with a terminal, zero if not. */
564 extern int __isatty __P ((int __fd));
565 extern int isatty __P ((int __fd));
567 #if defined(__USE_BSD) || defined(__USE_XOPEN_EXTENDED)
568 /* Return the index into the active-logins file (utmp) for
569 the controlling terminal. */
570 extern int ttyslot __P ((void));
571 #endif
574 /* Make a link to FROM named TO. */
575 extern int __link __P ((__const char *__from, __const char *__to));
576 extern int link __P ((__const char *__from, __const char *__to));
578 #if defined(__USE_BSD) || defined(__USE_XOPEN_EXTENDED)
579 /* Make a symbolic link to FROM named TO. */
580 extern int __symlink __P ((__const char *__from, __const char *__to));
581 extern int symlink __P ((__const char *__from, __const char *__to));
583 /* Read the contents of the symbolic link PATH into no more than
584 LEN bytes of BUF. The contents are not null-terminated.
585 Returns the number of characters read, or -1 for errors. */
586 extern int __readlink __P ((__const char *__path, char *__buf, size_t __len));
587 extern int readlink __P ((__const char *__path, char *__buf, size_t __len));
588 #endif /* Use BSD. */
590 /* Remove the link NAME. */
591 extern int __unlink __P ((__const char *__name));
592 extern int unlink __P ((__const char *__name));
594 /* Remove the directory PATH. */
595 extern int __rmdir __P ((__const char *__path));
596 extern int rmdir __P ((__const char *__path));
599 /* Return the foreground process group ID of FD. */
600 extern __pid_t tcgetpgrp __P ((int __fd));
602 /* Set the foreground process group ID of FD set PGRP_ID. */
603 extern int tcsetpgrp __P ((int __fd, __pid_t __pgrp_id));
606 /* Return the login name of the user. */
607 extern char *getlogin __P ((void));
608 #ifdef __USE_REENTRANT
609 /* Return at most NAME_LEN characters of the login name of the user in NAME.
610 If it cannot be determined or some other error occurred, return the error
611 code. Otherwise return 0. */
612 extern int getlogin_r __P ((char *__name, size_t __name_len));
613 #endif
615 #ifdef __USE_BSD
616 /* Set the login name returned by `getlogin'. */
617 extern int setlogin __P ((__const char *__name));
618 #endif
621 #ifdef __USE_POSIX2
622 /* Process the arguments in ARGV (ARGC of them, minus
623 the program name) for options given in OPTS.
625 If `opterr' is zero, no messages are generated
626 for invalid options; it defaults to 1.
627 `optind' is the current index into ARGV.
628 `optarg' is the argument corresponding to the current option.
629 Return the option character from OPTS just read.
630 Return -1 when there are no more options.
631 For unrecognized options, or options missing arguments,
632 `optopt' is set to the option letter, and '?' is returned.
634 The OPTS string is a list of characters which are recognized option
635 letters, optionally followed by colons, specifying that that letter
636 takes an argument, to be placed in `optarg'.
638 If a letter in OPTS is followed by two colons, its argument is optional.
639 This behavior is specific to the GNU `getopt'.
641 The argument `--' causes premature termination of argument scanning,
642 explicitly telling `getopt' that there are no more options.
644 If OPTS begins with `--', then non-option arguments
645 are treated as arguments to the option '\0'.
646 This behavior is specific to the GNU `getopt'. */
647 extern int getopt __P ((int __argc, char *__const * __argv,
648 __const char *__opts));
649 extern int opterr;
650 extern int optind;
651 extern int optopt;
652 extern char *optarg;
653 #endif
656 #if defined(__USE_BSD) || defined (__USE_XOPEN)
658 /* Put the name of the current host in no more than LEN bytes of NAME.
659 The result is null-terminated if LEN is large enough for the full
660 name and the terminator. */
661 extern int __gethostname __P ((char *__name, size_t __len));
662 extern int gethostname __P ((char *__name, size_t __len));
664 /* Set the name of the current host to NAME, which is LEN bytes long.
665 This call is restricted to the super-user. */
666 extern int sethostname __P ((__const char *__name, size_t __len));
668 /* Set the current machine's Internet number to ID.
669 This call is restricted to the super-user. */
670 extern int sethostid __P ((long int __id));
673 /* Get and set the NIS (aka YP) domain name, if any.
674 Called just like `gethostname' and `sethostname'.
675 The NIS domain name is usually the empty string when not using NIS. */
676 extern int getdomainname __P ((char *__name, size_t __len));
677 extern int setdomainname __P ((__const char *__name, size_t __len));
680 /* Make all changes done to FD actually appear on disk. */
681 extern int fsync __P ((int __fd));
684 /* Revoke access permissions to all processes currently communicating
685 with the control terminal, and then send a SIGHUP signal to the process
686 group of the control terminal. */
687 extern int vhangup __P ((void));
689 /* Revoke the access of all descriptors currently open on FILE. */
690 extern int revoke __P ((__const char *__file));
693 /* Enable statistical profiling, writing samples of the PC into at most
694 SIZE bytes of SAMPLE_BUFFER; every processor clock tick while profiling
695 is enabled, the system examines the user PC and increments
696 SAMPLE_BUFFER[((PC - OFFSET) / 2) * SCALE / 65536]. If SCALE is zero,
697 disable profiling. Returns zero on success, -1 on error. */
698 extern int profil __P ((unsigned short int *__sample_buffer, size_t __size,
699 size_t __offset, unsigned int __scale));
702 /* Turn accounting on if NAME is an existing file. The system will then write
703 a record for each process as it terminates, to this file. If NAME is NULL,
704 turn accounting off. This call is restricted to the super-user. */
705 extern int acct __P ((__const char *__name));
707 /* Make PATH be the root directory (the starting point for absolute paths).
708 This call is restricted to the super-user. */
709 extern int chroot __P ((__const char *__path));
712 /* Successive calls return the shells listed in `/etc/shells'. */
713 extern char *getusershell __P ((void));
714 extern void endusershell __P ((void)); /* Discard cached info. */
715 extern void setusershell __P ((void)); /* Rewind and re-read the file. */
718 /* Prompt with PROMPT and read a string from the terminal without echoing.
719 Uses /dev/tty if possible; otherwise stderr and stdin. */
720 extern char *getpass __P ((__const char *__prompt));
722 /* Put the program in the background, and dissociate from the controlling
723 terminal. If NOCHDIR is zero, do `chdir ("/")'. If NOCLOSE is zero,
724 redirects stdin, stdout, and stderr to /dev/null. */
725 extern int daemon __P ((int __nochdir, int __noclose));
727 #endif /* Use BSD || X/Open. */
730 #if defined(__USE_BSD) || defined(__USE_XOPEN_EXTENDED)
732 /* Return the current machine's Internet number. */
733 extern long int gethostid __P ((void));
735 /* Make all changes done to all files actually appear on disk. */
736 extern int sync __P ((void));
739 /* Return the number of bytes in a page. This is the system's page size,
740 which is not necessarily the same as the hardware page size. */
741 extern int __getpagesize __P ((void));
742 extern int getpagesize __P ((void));
745 /* Truncate FILE to LENGTH bytes. */
746 extern int truncate __P ((__const char *__file, __off_t __length));
748 /* Truncate the file FD is open on to LENGTH bytes. */
749 extern int ftruncate __P ((int __fd, __off_t __length));
752 /* Return the maximum number of file descriptors
753 the current process could possibly have. */
754 extern int __getdtablesize __P ((void));
755 extern int getdtablesize __P ((void));
757 #endif /* Use BSD || X/Open Unix. */
760 #if defined(__USE_MISC) || defined(__USE_XOPEN_EXTENDED)
762 /* Set the end of accessible data space (aka "the break") to ADDR.
763 Returns zero on success and -1 for errors (with errno set). */
764 extern int __brk __P ((__ptr_t __addr));
765 extern int brk __P ((__ptr_t __addr));
767 #define __need_ptrdiff_t
768 #include <stddef.h>
770 /* Increase or decrease the end of accessible data space by DELTA bytes.
771 If successful, returns the address the previous end of data space
772 (i.e. the beginning of the new space, if DELTA > 0);
773 returns (void *) -1 for errors (with errno set). */
774 extern __ptr_t __sbrk __P ((ptrdiff_t __delta));
775 extern __ptr_t sbrk __P ((ptrdiff_t __delta));
776 #endif
779 #ifdef __USE_MISC
780 /* Invoke `system call' number SYSNO, passing it the remaining arguments.
781 This is completely system-dependent, and not often useful.
783 In Unix, `syscall' sets `errno' for all errors and most calls return -1
784 for errors; in many systems you cannot pass arguments or get return
785 values for all system calls (`pipe', `fork', and `getppid' typically
786 among them).
788 In Mach, all system calls take normal arguments and always return an
789 error code (zero for success). */
790 extern long int syscall __P ((long int __sysno, ...));
792 #endif /* Use misc. */
795 #if (defined (__USE_MISC) || defined (__USE_XOPEN_EXTENDED)) \
796 && !defined (F_LOCK)
797 /* NOTE: These declarations also appear in <fcntl.h>; be sure to keep both
798 files consistent. Some systems have them there and some here, and some
799 software depends on the macros being defined without including both. */
801 /* `lockf' is a simpler interface to the locking facilities of `fcntl'.
802 LEN is always relative to the current file position.
803 The CMD argument is one of the following. */
805 #define F_ULOCK 0 /* Unlock a previously locked region. */
806 #define F_LOCK 1 /* Lock a region for exclusive use. */
807 #define F_TLOCK 2 /* Test and lock a region for exclusive use. */
808 #define F_TEST 3 /* Test a region for other processes locks. */
810 extern int lockf __P ((int __fd, int __cmd, __off_t __len));
811 #endif /* Use misc and F_LOCK not already defined. */
814 #ifdef __USE_GNU
816 /* Evaluate EXPRESSION, and repeat as long as it returns -1 with `errno'
817 set to EINTR. */
819 #define TEMP_FAILURE_RETRY(expression) \
820 (__extension__ \
821 ({ long int __result; \
822 do __result = (long int) (expression); \
823 while (__result == -1L && errno == EINTR); \
824 __result; })) \
827 /* This variable is set nonzero at startup if the process's effective IDs
828 differ from its real IDs, or it is otherwise indicated that extra
829 security should be used. When this is set the dynamic linker ignores
830 the various environment variables that normally affect it. */
831 extern int __libc_enable_secure;
833 #endif
835 #ifdef __USE_POSIX199309
836 /* Synchronize at least the data part of a file with the underlying
837 media. */
838 extern int fdatasync __P ((int __fildes));
839 #endif /* Use POSIX199309 */
842 /* XPG4.2 specifies that prototypes for the encryption functions must
843 be defined here. */
844 #ifdef __USE_XOPEN
845 /* Encrypt at most 8 characters from KEY using salt to perturb DES. */
846 extern char *crypt __P ((__const char *__key, __const char *__salt));
848 /* Setup DES tables according KEY. */
849 extern void setkey __P ((__const char *__key));
851 /* Encrypt data in BLOCK in place if EDFLAG is zero; otherwise decrypt
852 block in place. */
853 extern void encrypt __P ((char *__block, int __edflag));
856 /* Swab pairs bytes in the first N bytes of the area pointed to by
857 FROM and copy the result to TO. The value of TO must not be in the
858 range [FROM - N + 1, FROM - 1]. If N is odd the first byte in FROM
859 is without partner. */
860 extern void swab __P ((__const char *__from, char *__to, ssize_t __n));
861 #endif
863 __END_DECLS
865 #endif /* unistd.h */