rc

[fork] interactive rc shell
git clone https://hhvn.uk/rc
git clone git://hhvn.uk/rc
Log | Files | Refs | README | LICENSE

proto.h (2366B)


      1 /*
      2   The idea of this file is to include prototypes for all external
      3   functions that rc uses, either by including the appropriate header
      4   file, or---for older systems---declaring the functions directly.
      5 */
      6 
      7 #if HAVE_SYS_TYPES_H
      8 #include <sys/types.h>
      9 #endif
     10 
     11 #include <signal.h>
     12 
     13 #if HAVE_QUAD_T
     14 typedef quad_t align_t;
     15 #else
     16 typedef long align_t;
     17 #endif
     18 
     19 /*
     20   We need <stdarg.h>.  If you really need to build rc on a system which
     21   doesn't have it, please contact the maintainer.
     22 */
     23 
     24 #include <stdarg.h>
     25 
     26 /* C 99 specifies a va_copy() macro to be used for copying
     27 objects of type va_list. If this doesn't exist, hope that simple
     28 assignment works. */
     29 #ifndef va_copy
     30 #define va_copy(x,y) (x)=(y)
     31 #endif
     32 
     33 #if STDC_HEADERS
     34 
     35 #include <stdlib.h>
     36 #include <string.h>
     37 
     38 #else /* STDC_HEADERS */
     39 
     40 /* fake string.h */
     41 extern int strncmp(const char *, const char *, size_t);
     42 extern int strcmp(const char *, const char *);
     43 extern size_t strlen(const char *);
     44 extern char *strchr(const char *, int);
     45 extern char *strrchr(const char *, int);
     46 extern char *strcpy(char *, const char *);
     47 extern char *strncpy(char *, const char *, size_t);
     48 extern char *strcat(char *, const char *);
     49 extern char *strncat(char *, const char *, size_t);
     50 extern void *memcpy(void *, const void *, size_t);
     51 extern void *memset(void *, int, size_t);
     52 
     53 /* fake stdlib.h */
     54 extern void exit(int);
     55 extern void free(void *);
     56 extern void *malloc(size_t);
     57 extern void *realloc(void *, size_t);
     58 extern void qsort(void *, size_t, size_t, int (*)(const void *, const void *));
     59 
     60 #endif /* STDC_HEADERS */
     61 
     62 #if HAVE_STRERROR
     63 /* Smells like POSIX. */
     64 #else
     65 /* Assume BSD-style sys_errlist[]. */
     66 extern int sys_nerr;
     67 extern char *sys_errlist[];
     68 #define strerror(x) ((0 <= (x)) && (errno < (x)) ? sys_errlist[x] : (char *)0)
     69 #endif
     70 
     71 #if HAVE_UNISTD_H
     72 #include <unistd.h>
     73 #endif
     74 
     75 #if HAVE_SETPGRP
     76 
     77 #if SETPGRP_VOID
     78 /* Smells like POSIX: should all be ok. */
     79 #else
     80 /* Old BSD: fake it. */
     81 #define setpgid(pid, pgrp) setpgrp(pid, pgrp)
     82 #include <sys/ioctl.h>
     83 #define tcgetpgrp(fd) ioctl((fd), TIOCGPGRP)
     84 #define tcsetpgrp(fd, pgrp) ioctl((fd), TIOCSPGRP, &(pgrp))
     85 #endif
     86 
     87 #else /* HAVE_SETPGRP */
     88 
     89 /* Nothing doing. */
     90 #define setpgid()
     91 #define tcgetpgrp()
     92 #define tcsetpgrp()
     93 
     94 #endif /*HAVE_SETPGRP */
     95 
     96 
     97 /* fake errno.h for mips (which doesn't declare errno in errno.h!?!?) */
     98 #ifdef host_mips
     99 extern int errno;
    100 #endif