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