1*65874Sbostic #include <fcntl.h> 2*65874Sbostic #include <errno.h> 3*65874Sbostic #include <stdio.h> 4*65874Sbostic #include <sys/types.h> 5*65874Sbostic #include <sys/stat.h> 6*65874Sbostic #include <ctype.h> 7*65874Sbostic #include <string.h> 8*65874Sbostic #include <sys/file.h> 9*65874Sbostic #include <alloca.h> 10*65874Sbostic #ifndef O_ACCMODE 11*65874Sbostic #define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR) 12*65874Sbostic #endif 13*65874Sbostic #define SEEK_SET 0 14*65874Sbostic #define SEEK_CUR 1 15*65874Sbostic #ifdef __STDC__ 16*65874Sbostic #if __GNUC__ >= 2 17*65874Sbostic #define abort __hide_abort 18*65874Sbostic #define exit __hide_exit 19*65874Sbostic #endif 20*65874Sbostic #include <stdlib.h> 21*65874Sbostic #undef exit 22*65874Sbostic #undef abort 23*65874Sbostic #include <string.h> 24*65874Sbostic #else 25*65874Sbostic extern char *EXFUN(mktemp,(CONST char*)); 26*65874Sbostic extern int EXFUN(fflush,(FILE *)); 27*65874Sbostic extern int EXFUN(write,(int, CONST char *, int)); 28*65874Sbostic extern int EXFUN(index,(CONST char *, char c)); 29*65874Sbostic extern void EXFUN(abort,(void)); 30*65874Sbostic extern int EXFUN(close,(int)); 31*65874Sbostic extern int EXFUN(fcntl,(int des, int cmd, int e)); 32*65874Sbostic extern int EXFUN(fprintf,(FILE *,char *,...)); 33*65874Sbostic extern int EXFUN(printf,(char *,...)); 34*65874Sbostic extern int EXFUN(qsort,(void *data,int els, int siz, int func())); 35*65874Sbostic extern void EXFUN(exit,(int)); 36*65874Sbostic extern int EXFUN(fseek,(FILE*, int, int)); 37*65874Sbostic extern int EXFUN(fclose,(FILE*)); 38*65874Sbostic extern void EXFUN(bcopy,(char*,char*,int)); 39*65874Sbostic extern int EXFUN(bcmp,(char *, char *, int)); 40*65874Sbostic extern void EXFUN(bzero,(char *, int)); 41*65874Sbostic extern PTR EXFUN(memset,(PTR, int, int)); 42*65874Sbostic extern void EXFUN(puts,(CONST char*)); 43*65874Sbostic extern void EXFUN(fputs,(CONST char*,FILE*)); 44*65874Sbostic extern int EXFUN(rmdir,(CONST char *)); 45*65874Sbostic extern int EXFUN(getuid,(void)); 46*65874Sbostic extern int EXFUN(getgid,(void)); 47*65874Sbostic extern int EXFUN(rename,(CONST char *, CONST char*)); 48*65874Sbostic extern int EXFUN(etuid,()); 49*65874Sbostic extern int EXFUN(etgid,()); 50*65874Sbostic extern void EXFUN(perror,(CONST char *)); 51*65874Sbostic #ifndef DONTDECLARE_MALLOC 52*65874Sbostic extern PTR EXFUN(malloc,(unsigned)); 53*65874Sbostic extern PTR EXFUN(realloc, (PTR, unsigned)); 54*65874Sbostic #endif 55*65874Sbostic 56*65874Sbostic #ifndef __GNUC__ 57*65874Sbostic extern PTR EXFUN(memcpy,(PTR,CONST PTR,unsigned int)); 58*65874Sbostic #else 59*65874Sbostic /* char * EXFUN( memcpy,(char *,CONST char *,unsigned int)); */ 60*65874Sbostic #endif 61*65874Sbostic 62*65874Sbostic 63*65874Sbostic extern char * strchr(); 64*65874Sbostic extern char *getenv(); 65*65874Sbostic extern char *memchr(); 66*65874Sbostic extern char *strrchr(); 67*65874Sbostic extern int chmod(); 68*65874Sbostic extern int fread(); 69*65874Sbostic extern int fstat(); 70*65874Sbostic extern int fwrite(); 71*65874Sbostic extern int sscanf(); 72*65874Sbostic extern int stat(); 73*65874Sbostic extern int strtol(); 74*65874Sbostic extern int EXFUN(free,(PTR)); 75*65874Sbostic 76*65874Sbostic 77*65874Sbostic extern char *strrchr(); 78*65874Sbostic extern char *ctime(); 79*65874Sbostic extern int _flsbuf(); 80*65874Sbostic extern int fclose(); 81*65874Sbostic extern int time(); 82*65874Sbostic extern int utimes(); 83*65874Sbostic extern int vfprintf(); 84*65874Sbostic extern long atol(); 85*65874Sbostic extern char *getenv(); 86*65874Sbostic extern int fputc(); 87*65874Sbostic extern int unlink(); 88*65874Sbostic #endif /* __STDC__ */ 89*65874Sbostic 90*65874Sbostic /* EXACT TYPES */ 91*65874Sbostic typedef char int8e_type; 92*65874Sbostic typedef unsigned char uint8e_type; 93*65874Sbostic typedef short int16e_type; 94*65874Sbostic typedef unsigned short uint16e_type; 95*65874Sbostic typedef int int32e_type; 96*65874Sbostic typedef unsigned int uint32e_type; 97*65874Sbostic 98*65874Sbostic 99*65874Sbostic #ifdef __GNUC__ 100*65874Sbostic typedef unsigned long long uint64e_type; 101*65874Sbostic 102*65874Sbostic #else 103*65874Sbostic typedef struct { 104*65874Sbostic uint32e_type low, high; 105*65874Sbostic } uint64e_type; 106*65874Sbostic 107*65874Sbostic #endif 108*65874Sbostic /* CORRECT SIZE OR GREATER */ 109*65874Sbostic typedef char int8_type; 110*65874Sbostic typedef unsigned char uint8_type; 111*65874Sbostic typedef short int16_type; 112*65874Sbostic typedef unsigned short uint16_type; 113*65874Sbostic typedef int int32_type; 114*65874Sbostic typedef unsigned int uint32_type; 115*65874Sbostic 116*65874Sbostic #ifdef __GNUC__ 117*65874Sbostic typedef unsigned long long uint64_type; 118*65874Sbostic typedef long long int64_type; 119*65874Sbostic #else 120*65874Sbostic typedef struct { 121*65874Sbostic uint32e_type low, high; 122*65874Sbostic } uint64_type; 123*65874Sbostic 124*65874Sbostic typedef struct { 125*65874Sbostic uint32e_type low, high; 126*65874Sbostic } int64_type; 127*65874Sbostic 128*65874Sbostic #endif 129*65874Sbostic 130*65874Sbostic 131*65874Sbostic #define BYTES_IN_PRINTF_INT 4 132*65874Sbostic #ifndef __GNUC__ 133*65874Sbostic #define uint64_typeLOW(x) (uint32_type)(((x).low)) 134*65874Sbostic #define uint64_typeHIGH(x) (uint32_type)(((x).high)) 135*65874Sbostic #else 136*65874Sbostic #define uint64_typeLOW(x) (uint32_type)(((x) & 0xffffffff)) 137*65874Sbostic #define uint64_typeHIGH(x) (uint32_type)(((x) >> 32) & 0xffffffff) 138*65874Sbostic #endif 139*65874Sbostic 140*65874Sbostic 141*65874Sbostic #include "fopen-same.h" 142