|
|
1.1 ! root 1: /* ! 2: * misc.h ! 3: * Miscellaneous useful user functions. ! 4: * Sugggestions and additions are welcome. ! 5: */ ! 6: #include <stdio.h> ! 7: extern fatal(); /* like fprintf(stderr, ...); exit(0); */ ! 8: extern usage(); /* like fatal but message starts usage: */ ! 9: extern FILE *xopen(); /* xopen(filename, access); fopen or die */ ! 10: extern char *pathn(); /* pathn("helpfile", "LIBPATH", ",,\lib", "r"); ! 11: * gets full pathname given an filename ! 12: * env var with path, default path and access rights */ ! 13: extern xdump(); /* xdump(ptr, size) hex dumps an area */ ! 14: extern long randl(); /* IEEE random number (random bits) */ ! 15: extern srandl(); /* srandl(unsigned long s1, s2); */ ! 16: extern unsigned short crc16(); /* crc16(char *p) calculate 16 bit crc */ ! 17: extern char *ask(); /* ask(reply, msg); ! 18: * like printf(msg, ...) returns a user reply */ ! 19: extern int yn(); /* like printf(msg, ...) returns yes=1 or no=0 reply */ ! 20: extern char *alloc(); /* get space or die */ ! 21: extern void banner(); /* banner("Done", 3) prints a banner saying ! 22: * Done with 3 spaces infront. */ ! 23: extern strcmpl(); /* case insensative strcmp() */ ! 24: extern char *lcase(); /* convert string to lower case */ ! 25: extern char *ucase(); /* convert string to upper case */ ! 26: extern char *newcpy(); /* make a malloced copy of a string */ ! 27: extern char *match(); /* match(s1, pat, fin) ! 28: * finds pat in s1 by pnmatch rules ! 29: * returns start of pattern or NULL ! 30: * places pointer to end in *fin ! 31: */ ! 32: extern char *replace(); /* replace(s1, pat, s3, all, matcher) ! 33: * search s1 for pat and replace by s3. ! 34: * Using matcher which is a pointer to ! 35: * a function that looks externally like match. ! 36: * Returns a new malloced string or NULL ! 37: * does all if all != 0 else first. */ ! 38: extern char * span(); /* span(s1, matcher, fin) ! 39: * matches all chars passing function ! 40: * matcher. Looks like match. */ ! 41: extern char * skip(); /* skip(s1, matcher, fin) ! 42: * matches all chars not passing function ! 43: * matcher. Looks like match. */ ! 44: extern approx(); /* approx(double a, double b) 1 if == within epsilon */ ! 45: extern double epsilon; ! 46: extern int is_fs(); /* is_fs(char *special) test if special is filesystem */ ! 47: extern void vinit(); /* vinit(char * workFileName, unsigned storAmt); ! 48: * Init the software virtual system telling it how much ! 49: * storage it may use for buffers */ ! 50: extern void vshutdown(); /* Shut down the virtual system and free its storage */ ! 51: extern unsigned vopen(); /* vopen(long amt); Set up a virtual object amt ! 52: * bytes long and return a vid number. */ ! 53: extern char *vfind(); /* vfind(int vid, long disp, int dirty); ! 54: * Point to a byte disp bytes into vid, set the ! 55: * dirty bit if dirty == 1 */ ! 56: extern strchrtr(); ! 57: /* strchrtr(char *from, char *to, int c, int d) ! 58: * Find c in from and return the corresponding char ! 59: * in to or def if there is none. ! 60: */ ! 61: #define ENDOF(x) (((char *)(x))+sizeof(x)) /* end of some thing */ ! 62: #define SETIN(a, b) !((a) & ~(b)) /* a in b */ ! 63: #define SWAP(a, b) a ^= b ^= a ^= b; /* be sure a isn't identical to b */ ! 64: #define strlcpy(to, from) memcpy(to, from, sizeof(to)); ! 65: ! 66: #ifdef M68000 ! 67: #define ptrdiff(a, b) ((long)a - (long)b) ! 68: #else ! 69: #ifdef LARGE ! 70: #define ptrdiff(a, b) (((((long)a>>16)-((long)b>>16))<<4)+((int)a-(int)b)) ! 71: #else ! 72: #define ptrdiff(a, b) ((int)a - (int)b) ! 73: #endif ! 74: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.