llib-lposix revision 1.2
11.2Scgd/*	$NetBSD: llib-lposix,v 1.2 1995/07/03 21:25:09 cgd Exp $	*/
21.2Scgd
31.1Scgd/*
41.1Scgd * Copyright (c) 1994, 1995 Jochen Pohl
51.1Scgd * All Rights Reserved.
61.1Scgd *
71.1Scgd * Redistribution and use in source and binary forms, with or without
81.1Scgd * modification, are permitted provided that the following conditions
91.1Scgd * are met:
101.1Scgd * 1. Redistributions of source code must retain the above copyright
111.1Scgd *    notice, this list of conditions and the following disclaimer.
121.1Scgd * 2. Redistributions in binary form must reproduce the above copyright
131.1Scgd *    notice, this list of conditions and the following disclaimer in the
141.1Scgd *    documentation and/or other materials provided with the distribution.
151.1Scgd * 3. All advertising materials mentioning features or use of this software
161.1Scgd *    must display the following acknowledgement:
171.1Scgd *      This product includes software developed by Jochen Pohl for
181.1Scgd *	The NetBSD Project.
191.1Scgd * 4. The name of the author may not be used to endorse or promote products
201.1Scgd *    derived from this software without specific prior written permission.
211.1Scgd *
221.1Scgd * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
231.1Scgd * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
241.1Scgd * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
251.1Scgd * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
261.1Scgd * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
271.1Scgd * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
281.1Scgd * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
291.1Scgd * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
301.1Scgd * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
311.1Scgd * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
321.1Scgd */
331.1Scgd
341.1Scgd/* LINTLIBRARY */
351.1Scgd
361.1Scgd#define _POSIX_SOURCE
371.1Scgd
381.1Scgd#include <sys/types.h>
391.1Scgd#include <sys/stat.h>
401.1Scgd#include <sys/utsname.h>
411.1Scgd#include <sys/times.h>
421.1Scgd#include <stdio.h>
431.1Scgd#include <stdarg.h>
441.1Scgd#include <stdlib.h>
451.1Scgd#include <unistd.h>
461.1Scgd#include <math.h>
471.1Scgd#include <time.h>
481.1Scgd#include <assert.h>
491.1Scgd#include <termios.h>
501.1Scgd#include <dirent.h>
511.1Scgd#include <fcntl.h>
521.1Scgd#include <grp.h>
531.1Scgd#include <pwd.h>
541.1Scgd#include <ctype.h>
551.1Scgd#include <signal.h>
561.1Scgd#include <locale.h>
571.1Scgd#include <setjmp.h>
581.1Scgd#include <string.h>
591.1Scgd#include <utime.h>
601.1Scgd
611.1Scgd
621.1Scgd/* PROTOLIB1 */
631.1Scgd
641.1Scgd
651.1Scgdvoid	(abort)(void);
661.1Scgdint	(abs)(int j);
671.1Scgdint	(access)(const char *path, int amode);
681.1Scgddouble	(acos)(double x);
691.1Scgdunsigned (alarm)(unsigned seconds);
701.1Scgdchar	*(asctime)(const struct tm *timeptr);
711.1Scgddouble	(asin)(double x);
721.1Scgdvoid	(__assert)(const char *expression, int line, const char *file);
731.1Scgddouble	(atan)(double x);
741.1Scgddouble	(atan2)(double y, double x);
751.1Scgdint	(atexit)(void (*func)(void));
761.1Scgddouble	(atof)(const char *nptr);
771.1Scgdint	(atoi)(const char *nptr);
781.1Scgdlong	(atol)(const char *nptr);
791.1Scgdvoid	*(bsearch)(const void *key, const void *base, size_t nmemb,
801.1Scgd		   size_t size, int (*compar)(const void *, const void *));
811.1Scgdvoid	*(calloc)(size_t nmemb, size_t size);
821.1Scgddouble	(ceil)(double x);
831.1Scgdspeed_t	(cfgetispeed)(const struct termios *p);
841.1Scgdspeed_t	(cfgetospeed)(const struct termios *p);
851.1Scgdint	(cfsetispeed)(struct termios *p, speed_t speed);
861.1Scgdint	(cfsetospeed)(struct termios *p, speed_t speed);
871.1Scgdint	(chdir)(const char *path);
881.1Scgdint	(chmod)(const char *path, mode_t mode);
891.1Scgdint	(chown)(const char *path, uid_t owner, gid_t group);
901.1Scgdvoid	(clearerr)(FILE *stream);
911.1Scgdclock_t	(clock)(void);
921.1Scgdint	(close)(int fildes);
931.1Scgdint	(closedir)(DIR *dirp);
941.1Scgddouble	(cos)(double x);
951.1Scgddouble	(cosh)(double x);
961.1Scgdint	(creat)(const char *path, mode_t mode);
971.1Scgdchar	*(ctermid)(char *s);
981.1Scgdchar	*(ctime)(const time_t *timer);
991.1Scgdchar	*(cuserid)(char *s);
1001.1Scgddouble	(difftime)(time_t time1, time_t time0);
1011.1Scgddiv_t	(div)(int numer, int denom);
1021.1Scgdint	(dup)(int fildes);
1031.1Scgdint	(dup2)(int fildes, int fildes2);
1041.1Scgdint	(errno);
1051.1Scgdint	(execl)(const char *path, const char *arg, ...);
1061.1Scgdint	(execle)(const char *path, const char *arg, ...);
1071.1Scgdint	(execlp)(const char *file, const char *arg, ...);
1081.1Scgdint	(execv)(const char *path, char *const argv[]);
1091.1Scgdint	(execve)(const char *path, char *const argv[], char *const *envp);
1101.1Scgdint	(execvp)(const char *file, char *const argv[]);
1111.1Scgdvoid	(exit)(int status);
1121.1Scgdvoid	(_exit)(int status);
1131.1Scgddouble	(exp)(double x);
1141.1Scgddouble	(fabs)(double x);
1151.1Scgdint	(fclose)(FILE *stream);
1161.1Scgdint	(fcntl)(int fildes, int cmd, ...);
1171.1ScgdFILE	*(fdopen)(int fildes, const char *type);
1181.1Scgdint	(feof)(FILE *stream);
1191.1Scgdint	(ferror)(FILE *stream);
1201.1Scgdint	(fflush)(FILE *stream);
1211.1Scgdint	(fgetc)(FILE *stream);
1221.1Scgdint	(fgetpos)(FILE *stream, fpos_t *pos);
1231.1Scgdchar	*(fgets)(char *s, int n, FILE *stream);
1241.1Scgdint	(fileno)(FILE *stream);
1251.1Scgddouble	(floor)(double x);
1261.1Scgddouble	(fmod)(double x, double y);
1271.1ScgdFILE	*(fopen)(const char *filename, const char *mode);
1281.1Scgdpid_t	(fork)(void);
1291.1Scgdlong	(fpathconf)(int fildes, int name);
1301.1Scgd/* PRINTFLIKE2 */
1311.1Scgdint	(fprintf)(FILE *stream, const char *format, ...);
1321.1Scgdint	(fputc)(int c, FILE *stream);
1331.1Scgdint	(fputs)(const char *s, FILE *stream);
1341.1Scgdsize_t	(fread)(void *ptr, size_t size, size_t nmemb, FILE *stream);
1351.1Scgdvoid	(free)(void *ptr);
1361.1ScgdFILE	*(freopen)(const char *filename, const char *mode, FILE *stream);
1371.1Scgddouble	(frepx)(double value, int *exp);
1381.1Scgd/* SCANFLIKE2 */
1391.1Scgdint	(fscanf)(FILE *stream, const char *format, ...);
1401.1Scgdint	(fseek)(FILE *stream, long int offset, int whence);
1411.1Scgdint	(fsetpos)(FILE *stream, const fpos_t *pos);
1421.1Scgdint	(fstat)(int fildes, struct stat *buf);
1431.1Scgdlong	(ftell)(FILE *stream);
1441.1Scgdsize_t	(fwrite)(const void *ptr, size_t size, size_t nmemb, FILE *stream);
1451.1Scgdint	(getc)(FILE *stream);
1461.1Scgdint	(getchar)(void);
1471.1Scgdchar	*(getcwd)(char *buf, size_t size);
1481.1Scgdgid_t	(getegid)(void);
1491.1Scgdchar	*(getenv)(const char *name);
1501.1Scgduid_t	(geteuid)(void);
1511.1Scgdgid_t	(getgid)(void);
1521.1Scgdstruct	group *(getgrgid)(gid_t gid);
1531.1Scgdstruct	group *(getgrnam)(const char *name);
1541.1Scgdint	(getgroups)(int gidsetsize, gid_t grouplist[]);
1551.1Scgdchar	*(getlogin)(void);
1561.1Scgdpid_t	(getpgrp)(void);
1571.1Scgdpid_t	(getpid)(void);
1581.1Scgdpid_t	(getppid)(void);
1591.1Scgdstruct	passwd *(getpwnam)(const char *name);
1601.1Scgdstruct	passwd *(getpwuid)(uid_t uid);
1611.1Scgdchar	*(gets)(char *s);
1621.1Scgduid_t	(getuid)(void);
1631.1Scgdstruct	tm *(gmtime)(const time_t *timer);
1641.1Scgdint	(isalnum)(int c);
1651.1Scgdint	(isalpha)(int c);
1661.1Scgdint	(isatty)(int fildes);
1671.1Scgdint	(iscntrl)(int c);
1681.1Scgdint	(isdigit)(int c);
1691.1Scgdint	(isgraph)(int c);
1701.1Scgdint	(islower)(int c);
1711.1Scgdint	(isprint)(int c);
1721.1Scgdint	(ispunct)(int c);
1731.1Scgdint	(isspace)(int c);
1741.1Scgdint	(isupper)(int c);
1751.1Scgdint	(isxdigit)(int c);
1761.1Scgdint	(kill)(pid_t pid, int sig);
1771.1Scgdlong	(labs)(long j);
1781.1Scgddouble	(ldexp)(double x, int exp);
1791.1Scgdldiv_t	(ldiv)(long numer, long denom);
1801.1Scgdint	(link)(const char *existing, const char *new);
1811.1Scgdstruct	lconv *(localeconv)(void);
1821.1Scgdstruct	tm *(localtime)(const time_t *timer);
1831.1Scgddouble	(log)(double x);
1841.1Scgddouble	(log10)(double x);
1851.1Scgdvoid	(longjmp)(jmp_buf env, int val);
1861.1Scgdoff_t	(lseek)(int fildes, off_t offset, int whence);
1871.1Scgdvoid	*(malloc)(size_t size);
1881.1Scgdint	(mblen)(const char *s, size_t n);
1891.1Scgdsize_t	(mbstowcs)(wchar_t *pwcs, const char *s, size_t n);
1901.1Scgdint	(mbtowc)(wchar_t *pwc, const char *s, size_t n);
1911.1Scgdvoid	*(memchr)(const void *s, int c, size_t n);
1921.1Scgdint	(memcmp)(const void *s1, const void *s2, size_t n);
1931.1Scgdvoid	*(memcpy)(void *s1, const void *s2, size_t n);
1941.1Scgdvoid	*(memmove)(void *s1, const void *s2, size_t n);
1951.1Scgdvoid	*(memset)(void *s, int c, size_t n);
1961.1Scgdint	(mkdir)(const char *path, mode_t mode);
1971.1Scgdint	(mkfifo)(const char *path, mode_t mode);
1981.1Scgdtime_t	(mktime)(struct tm *timeptr);
1991.1Scgddouble	(modf)(double value, double *iptr);
2001.1Scgdint	(open)(const char *path, int oflag, ...);
2011.1ScgdDIR	*(opendir)(const char *dirname);
2021.1Scgdlong	(pathconf)(const char *path, int name);
2031.1Scgdint	(pause)(void);
2041.1Scgdvoid	(perror)(const char *s);
2051.1Scgdint	(pipe)(int fildes[2]);
2061.1Scgddouble	(pow)(double x, double y);
2071.1Scgd/* PRINTFLIKE1 */
2081.1Scgdint	(printf)(const char *format, ...);
2091.1Scgdint	(putc)(int c, FILE *stream);
2101.1Scgdint	(putchar)(int c);
2111.1Scgdint	(puts)(const char *s);
2121.1Scgdvoid	(qsort)(void *base, size_t nmemb, size_t size,
2131.1Scgd	        int (*compar)(const void *, const void *));
2141.1Scgdint	(raise)(int sig);
2151.1Scgdint	(rand)(void);
2161.1Scgdssize_t	(read)(int fildes, void *buf, size_t nbyte);
2171.1Scgdstruct	dirent *(readdir)(DIR *dirp);
2181.1Scgdvoid	*(realloc)(void *ptr, size_t size);
2191.1Scgdint	(remove)(const char *filename);
2201.1Scgdint	(rename)(const char *old, const char *new);
2211.1Scgdvoid	(rewind)(FILE *stream);
2221.1Scgdvoid	(rewinddir)(DIR *dirp);
2231.1Scgdint	(rmdir)(const char *path);
2241.1Scgd/* SCANFLIKE1 */
2251.1Scgdint	(scanf)(const char *format, ...);
2261.1Scgdvoid	(setbuf)(FILE *stream, char *buf);
2271.1Scgdint	(setgid)(gid_t gid);
2281.1Scgdint	(setjmp)(jmp_buf env);
2291.1Scgdchar	*(setlocale)(int category, const char *locale);
2301.1Scgdint	(setpgid)(pid_t pid, pid_t pgid);
2311.1Scgdpid_t	(setsid)(void);
2321.1Scgdint	(setuid)(uid_t uid);
2331.1Scgdint	(setvbuf)(FILE *stream, char *buf, int mode, size_t size);
2341.1Scgdint	(sigaction)(int sig, const struct sigaction *act,
2351.1Scgd		    struct sigaction *oact);
2361.1Scgdint	(sigaddset)(sigset_t *set, int signo);
2371.1Scgdint	(sigdelset)(sigset_t *set, int signo);
2381.1Scgdint	(sigemptyset)(sigset_t *set);
2391.1Scgdint	(sigfillset)(sigset_t *set);
2401.1Scgdint	(sigismember)(const sigset_t *set, int signo);
2411.1Scgdvoid	(siglongjmp)(sigjmp_buf env, int val);
2421.1Scgdvoid	(*(signal)(int sig, void (*func)(int)))(int);
2431.1Scgdint	(sigpending)(sigset_t *set);
2441.1Scgdint	(sigprocmask)(int how, const sigset_t *set, sigset_t *oset);
2451.1Scgdint	(sigsetjmp)(sigjmp_buf env, int savemask);
2461.1Scgdint	(sigsuspend)(const sigset_t *sigmask);
2471.1Scgddouble	(sin)(double x);
2481.1Scgddouble	(sinh)(double x);
2491.1Scgdunsigned (sleep)(unsigned seconds);
2501.1Scgd/* PRINTFLIKE2 */
2511.1Scgdint	(sprintf)(char *s, const char *format, ...);
2521.1Scgddouble	(sqrt)(double x);
2531.1Scgdvoid	(srand)(unsigned seed);
2541.1Scgd/* SCANFLIKE2 */
2551.1Scgdint	(sscanf)(const char *s, const char *format, ...);
2561.1Scgdint	(stat)(const char *path, struct stat *buf);
2571.1Scgdchar	*(strcat)(char *s1, const char *s2);
2581.1Scgdchar	*(strchr)(const char *s, int c);
2591.1Scgdint	(strcmp)(const char *s1, const char *s2);
2601.1Scgdint	(strcoll)(const char *s1, const char *s2);
2611.1Scgdchar	*(strcpy)(char *s1, const char *s2);
2621.1Scgdsize_t	(strcspn)(const char *s1, const char *s2);
2631.1Scgdchar	*(strerror)(int errnum);
2641.1Scgdsize_t	(strftime)(char *s, size_t maxsize, const char *format,
2651.1Scgd		    const struct tm *timeptr);
2661.1Scgdsize_t	(strlen)(const char *s);
2671.1Scgdchar	*(strncat)(char *s1, const char *s2, size_t n);
2681.1Scgdint	(strncmp)(const char *s1, const char *s2, size_t n);
2691.1Scgdchar	*(strncpy)(char *s1, const char *s2, size_t n);
2701.1Scgdchar	*(strpbrk)(const char *s1, const char *s2);
2711.1Scgdchar	*(strrchr)(const char *s, int c);
2721.1Scgdsize_t	(strspn)(const char *s1, const char *s2);
2731.1Scgdchar	*(strstr)(const char *s1, const char *s2);
2741.1Scgddouble	(strtod)(const char *nptr, char **endptr);
2751.1Scgdchar	*(strtok)(char *s1, const char *s2);
2761.1Scgdlong	(strtol)(const char *nptr, char **endptr, int base);
2771.1Scgdunsigned long (strtoul)(const char *nptr, char **endptr, int base);
2781.1Scgdsize_t	(strxfrm)(char *s1, const char *s2, size_t n);
2791.1Scgdlong	(sysconf)(int name);
2801.1Scgdint	(system)(const char *string);
2811.1Scgddouble	(tan)(double x);
2821.1Scgddouble	(tanh)(double x);
2831.1Scgdint	(tcdrain)(int fildes);
2841.1Scgdint	(tcflow)(int fildes, int action);
2851.1Scgdint	(tcflush)(int fildes, int queue_selector);
2861.1Scgdint	(tcgetattr)(int fildes, struct termios *tp);
2871.1Scgdpid_t	(tcgetpgrp)(int fildes);
2881.1Scgdint	(tcsendbreak)(int fildes, int duration);
2891.1Scgdint	(tcsetattr)(int fildes, int options, const struct termios *tp);
2901.1Scgdint	(tcsetpgrp)(int fildes, pid_t pgrpid);
2911.1Scgdtime_t	(time)(time_t *timer);
2921.1Scgdclock_t	(times)(struct tms *buffer);
2931.1ScgdFILE	*(tmpfile)(void);
2941.1Scgdchar	*(tmpnam)(char *s);
2951.1Scgdint	(tolower)(int c);
2961.1Scgdint	(toupper)(int c);
2971.1Scgdchar	*(ttyname)(int filedes);
2981.1Scgdvoid	(tzset)(void);
2991.1Scgdmode_t	(umask)(mode_t cmask);
3001.1Scgdint	(uname)(struct utsname *name);
3011.1Scgdint	(ungetc)(int c, FILE *stream);
3021.1Scgdint	(unlink)(const char *path);
3031.1Scgdint	(utime)(const char *path, const struct utimbuf *times);
3041.1Scgdint	(vfprintf)(FILE *stream, const char *format, va_list arg);
3051.1Scgdint	(vprintf)(const char *format, va_list arg);
3061.1Scgdint	(vsprintf)(char *s, const char *format, va_list arg);
3071.1Scgdpid_t	(wait)(int *statloc);
3081.1Scgdpid_t	(waitpid)(pid_t pid, int *stat_loc, int options);
3091.1Scgdsize_t	(wcstombs)(char *s, const wchar_t *pwcs, size_t n);
3101.1Scgdint	(wctomb)(char *s, wchar_t wchar);
3111.1Scgdssize_t	(write)(int fildes, const void *buf, size_t nbyte);
312