1/*	$NetBSD: llib-lposix,v 1.2 1995/07/03 21:25:09 cgd Exp $	*/
2/* $FreeBSD$ */
3
4/*
5 * Copyright (c) 1994, 1995 Jochen Pohl
6 * All Rights Reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 *    notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 *    notice, this list of conditions and the following disclaimer in the
15 *    documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 *    must display the following acknowledgement:
18 *      This product includes software developed by Jochen Pohl for
19 *	The NetBSD Project.
20 * 4. The name of the author may not be used to endorse or promote products
21 *    derived from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35/* LINTLIBRARY */
36
37#define _POSIX_SOURCE
38
39#include <sys/types.h>
40#include <sys/time.h>
41#include <sys/stat.h>
42#include <sys/utsname.h>
43#include <sys/times.h>
44#include <stdio.h>
45#include <stdarg.h>
46#include <stdlib.h>
47#include <unistd.h>
48#include <math.h>
49#include <time.h>
50#include <assert.h>
51#include <termios.h>
52#include <dirent.h>
53#include <fcntl.h>
54#include <grp.h>
55#include <pwd.h>
56#include <ctype.h>
57#include <signal.h>
58#include <locale.h>
59#include <setjmp.h>
60#include <string.h>
61#include <utime.h>
62
63
64/* PROTOLIB1 */
65
66
67void	(abort)(void);
68int	(abs)(int j);
69int	(access)(const char *path, int amode);
70double	(acos)(double x);
71unsigned (alarm)(unsigned seconds);
72char	*(asctime)(const struct tm *timeptr);
73double	(asin)(double x);
74void	(__assert)(const char *expression, const char *func, int line,
75		   const char *file);
76double	(atan)(double x);
77double	(atan2)(double y, double x);
78int	(atexit)(void (*func)(void));
79double	(atof)(const char *nptr);
80int	(atoi)(const char *nptr);
81long	(atol)(const char *nptr);
82void	*(bsearch)(const void *key, const void *base, size_t nmemb,
83		   size_t size, int (*compar)(const void *, const void *));
84void	*(calloc)(size_t nmemb, size_t size);
85double	(ceil)(double x);
86speed_t	(cfgetispeed)(const struct termios *p);
87speed_t	(cfgetospeed)(const struct termios *p);
88int	(cfsetispeed)(struct termios *p, speed_t speed);
89int	(cfsetospeed)(struct termios *p, speed_t speed);
90int	(chdir)(const char *path);
91int	(chmod)(const char *path, mode_t mode);
92int	(chown)(const char *path, uid_t owner, gid_t group);
93void	(clearerr)(FILE *stream);
94clock_t	(clock)(void);
95int	(close)(int fildes);
96int	(closedir)(DIR *dirp);
97double	(cos)(double x);
98double	(cosh)(double x);
99int	(creat)(const char *path, mode_t mode);
100char	*(ctermid)(char *s);
101char	*(ctime)(const time_t *timer);
102char	*(cuserid)(char *s);
103double	(difftime)(time_t time1, time_t time0);
104div_t	(div)(int numer, int denom);
105int	(dup)(int fildes);
106int	(dup2)(int fildes, int fildes2);
107int	(errno);
108int	(execl)(const char *path, const char *arg, ...);
109int	(execle)(const char *path, const char *arg, ...);
110int	(execlp)(const char *file, const char *arg, ...);
111int	(execv)(const char *path, char *const argv[]);
112int	(execve)(const char *path, char *const argv[], char *const *envp);
113int	(execvp)(const char *file, char *const argv[]);
114void	(exit)(int status);
115void	(_exit)(int status);
116double	(exp)(double x);
117double	(fabs)(double x);
118int	(fclose)(FILE *stream);
119int	(fcntl)(int fildes, int cmd, ...);
120FILE	*(fdopen)(int fildes, const char *type);
121int	(feof)(FILE *stream);
122int	(ferror)(FILE *stream);
123int	(fflush)(FILE *stream);
124int	(fgetc)(FILE *stream);
125int	(fgetpos)(FILE *stream, fpos_t *pos);
126char	*(fgets)(char *s, int n, FILE *stream);
127int	(fileno)(FILE *stream);
128double	(floor)(double x);
129double	(fmod)(double x, double y);
130FILE	*(fopen)(const char *filename, const char *mode);
131pid_t	(fork)(void);
132long	(fpathconf)(int fildes, int name);
133/* PRINTFLIKE2 */
134int	(fprintf)(FILE *stream, const char *format, ...);
135int	(fputc)(int c, FILE *stream);
136int	(fputs)(const char *s, FILE *stream);
137size_t	(fread)(void *ptr, size_t size, size_t nmemb, FILE *stream);
138void	(free)(void *ptr);
139FILE	*(freopen)(const char *filename, const char *mode, FILE *stream);
140double	(frepx)(double value, int *exp);
141/* SCANFLIKE2 */
142int	(fscanf)(FILE *stream, const char *format, ...);
143int	(fseek)(FILE *stream, long int offset, int whence);
144int	(fsetpos)(FILE *stream, const fpos_t *pos);
145int	(fstat)(int fildes, struct stat *buf);
146long	(ftell)(FILE *stream);
147size_t	(fwrite)(const void *ptr, size_t size, size_t nmemb, FILE *stream);
148int	(getc)(FILE *stream);
149int	(getchar)(void);
150char	*(getcwd)(char *buf, size_t size);
151gid_t	(getegid)(void);
152char	*(getenv)(const char *name);
153uid_t	(geteuid)(void);
154gid_t	(getgid)(void);
155struct	group *(getgrgid)(gid_t gid);
156struct	group *(getgrnam)(const char *name);
157int	(getgroups)(int gidsetsize, gid_t grouplist[]);
158char	*(getlogin)(void);
159pid_t	(getpgrp)(void);
160pid_t	(getpid)(void);
161pid_t	(getppid)(void);
162struct	passwd *(getpwnam)(const char *name);
163struct	passwd *(getpwuid)(uid_t uid);
164char	*(gets)(char *s);
165uid_t	(getuid)(void);
166struct	tm *(gmtime)(const time_t *timer);
167int	(isalnum)(int c);
168int	(isalpha)(int c);
169int	(isatty)(int fildes);
170int	(iscntrl)(int c);
171int	(isdigit)(int c);
172int	(isgraph)(int c);
173int	(islower)(int c);
174int	(isprint)(int c);
175int	(ispunct)(int c);
176int	(isspace)(int c);
177int	(isupper)(int c);
178int	(isxdigit)(int c);
179int	(kill)(pid_t pid, int sig);
180long	(labs)(long j);
181double	(ldexp)(double x, int exp);
182ldiv_t	(ldiv)(long numer, long denom);
183int	(link)(const char *existing, const char *new);
184struct	lconv *(localeconv)(void);
185struct	tm *(localtime)(const time_t *timer);
186double	(log)(double x);
187double	(log10)(double x);
188void	(longjmp)(jmp_buf env, int val);
189off_t	(lseek)(int fildes, off_t offset, int whence);
190void	*(malloc)(size_t size);
191int	(mblen)(const char *s, size_t n);
192size_t	(mbstowcs)(wchar_t *pwcs, const char *s, size_t n);
193int	(mbtowc)(wchar_t *pwc, const char *s, size_t n);
194void	*(memchr)(const void *s, int c, size_t n);
195int	(memcmp)(const void *s1, const void *s2, size_t n);
196void	*(memcpy)(void *s1, const void *s2, size_t n);
197void	*(memmove)(void *s1, const void *s2, size_t n);
198void	*(memset)(void *s, int c, size_t n);
199int	(mkdir)(const char *path, mode_t mode);
200int	(mkfifo)(const char *path, mode_t mode);
201time_t	(mktime)(struct tm *timeptr);
202double	(modf)(double value, double *iptr);
203int	(open)(const char *path, int oflag, ...);
204DIR	*(opendir)(const char *dirname);
205long	(pathconf)(const char *path, int name);
206int	(pause)(void);
207void	(perror)(const char *s);
208int	(pipe)(int fildes[2]);
209double	(pow)(double x, double y);
210/* PRINTFLIKE1 */
211int	(printf)(const char *format, ...);
212int	(putc)(int c, FILE *stream);
213int	(putchar)(int c);
214int	(puts)(const char *s);
215void	(qsort)(void *base, size_t nmemb, size_t size,
216	        int (*compar)(const void *, const void *));
217int	(raise)(int sig);
218int	(rand)(void);
219ssize_t	(read)(int fildes, void *buf, size_t nbyte);
220struct	dirent *(readdir)(DIR *dirp);
221void	*(realloc)(void *ptr, size_t size);
222int	(remove)(const char *filename);
223int	(rename)(const char *old, const char *new);
224void	(rewind)(FILE *stream);
225void	(rewinddir)(DIR *dirp);
226int	(rmdir)(const char *path);
227/* SCANFLIKE1 */
228int	(scanf)(const char *format, ...);
229void	(setbuf)(FILE *stream, char *buf);
230int	(setgid)(gid_t gid);
231int	(setjmp)(jmp_buf env);
232char	*(setlocale)(int category, const char *locale);
233int	(setpgid)(pid_t pid, pid_t pgid);
234pid_t	(setsid)(void);
235int	(setuid)(uid_t uid);
236int	(setvbuf)(FILE *stream, char *buf, int mode, size_t size);
237int	(sigaction)(int sig, const struct sigaction *act,
238		    struct sigaction *oact);
239int	(sigaddset)(sigset_t *set, int signo);
240int	(sigdelset)(sigset_t *set, int signo);
241int	(sigemptyset)(sigset_t *set);
242int	(sigfillset)(sigset_t *set);
243int	(sigismember)(const sigset_t *set, int signo);
244void	(siglongjmp)(sigjmp_buf env, int val);
245void	(*(signal)(int sig, void (*func)(int)))(int);
246int	(sigpending)(sigset_t *set);
247int	(sigprocmask)(int how, const sigset_t *set, sigset_t *oset);
248int	(sigsetjmp)(sigjmp_buf env, int savemask);
249int	(sigsuspend)(const sigset_t *sigmask);
250double	(sin)(double x);
251double	(sinh)(double x);
252unsigned (sleep)(unsigned seconds);
253/* PRINTFLIKE2 */
254int	(sprintf)(char *s, const char *format, ...);
255double	(sqrt)(double x);
256void	(srand)(unsigned seed);
257/* SCANFLIKE2 */
258int	(sscanf)(const char *s, const char *format, ...);
259int	(stat)(const char *path, struct stat *buf);
260char	*(strcat)(char *s1, const char *s2);
261char	*(strchr)(const char *s, int c);
262int	(strcmp)(const char *s1, const char *s2);
263int	(strcoll)(const char *s1, const char *s2);
264char	*(strcpy)(char *s1, const char *s2);
265size_t	(strcspn)(const char *s1, const char *s2);
266char	*(strerror)(int errnum);
267size_t	(strftime)(char *s, size_t maxsize, const char *format,
268		    const struct tm *timeptr);
269size_t	(strlen)(const char *s);
270char	*(strncat)(char *s1, const char *s2, size_t n);
271int	(strncmp)(const char *s1, const char *s2, size_t n);
272char	*(strncpy)(char *s1, const char *s2, size_t n);
273char	*(strpbrk)(const char *s1, const char *s2);
274char	*(strrchr)(const char *s, int c);
275size_t	(strspn)(const char *s1, const char *s2);
276char	*(strstr)(const char *s1, const char *s2);
277double	(strtod)(const char *nptr, char **endptr);
278char	*(strtok)(char *s1, const char *s2);
279long	(strtol)(const char *nptr, char **endptr, int base);
280unsigned long (strtoul)(const char *nptr, char **endptr, int base);
281size_t	(strxfrm)(char *s1, const char *s2, size_t n);
282long	(sysconf)(int name);
283int	(system)(const char *string);
284double	(tan)(double x);
285double	(tanh)(double x);
286int	(tcdrain)(int fildes);
287int	(tcflow)(int fildes, int action);
288int	(tcflush)(int fildes, int queue_selector);
289int	(tcgetattr)(int fildes, struct termios *tp);
290pid_t	(tcgetpgrp)(int fildes);
291int	(tcsendbreak)(int fildes, int duration);
292int	(tcsetattr)(int fildes, int options, const struct termios *tp);
293int	(tcsetpgrp)(int fildes, pid_t pgrpid);
294time_t	(time)(time_t *timer);
295clock_t	(times)(struct tms *buffer);
296FILE	*(tmpfile)(void);
297char	*(tmpnam)(char *s);
298int	(tolower)(int c);
299int	(toupper)(int c);
300char	*(ttyname)(int filedes);
301void	(tzset)(void);
302mode_t	(umask)(mode_t cmask);
303int	(uname)(struct utsname *name);
304int	(ungetc)(int c, FILE *stream);
305int	(unlink)(const char *path);
306int	(utime)(const char *path, const struct utimbuf *times);
307int	(vfprintf)(FILE *stream, const char *format, va_list arg);
308int	(vprintf)(const char *format, va_list arg);
309int	(vsprintf)(char *s, const char *format, va_list arg);
310pid_t	(wait)(int *statloc);
311pid_t	(waitpid)(pid_t pid, int *stat_loc, int options);
312size_t	(wcstombs)(char *s, const wchar_t *pwcs, size_t n);
313int	(wctomb)(char *s, wchar_t wchar);
314ssize_t	(write)(int fildes, const void *buf, size_t nbyte);
315