|
|
1.1 ! root 1: #include <jerq.h> ! 2: #include <jerqio.h> ! 3: #define _SYSOPEN 1 ! 4: #define _SYSCLOSE 2 ! 5: #define _SYSACCESS 8 ! 6: ! 7: access(file,mode) ! 8: char *file; ! 9: { ! 10: tag(_SYSACCESS); ! 11: jputstr(file); ! 12: jputshort(mode); ! 13: jflush(); ! 14: return(jgetshort()); ! 15: } ! 16: ! 17: FILE * ! 18: _open(file,mode,f,i) ! 19: char *file,*mode; ! 20: FILE *f; ! 21: { ! 22: tag(_SYSOPEN); ! 23: jputshort(i); ! 24: jputstr(file); ! 25: jputchar(*mode); ! 26: jflush(); ! 27: if (i != jgetshort()) ! 28: return((FILE *) NULL); ! 29: f->file = i; ! 30: if (*mode == 'r') { ! 31: f->count = 0; ! 32: f->flag |= _IOREAD; ! 33: } ! 34: else { ! 35: f->count = BUFSIZ; ! 36: f->flag |= _IOWRT; ! 37: } ! 38: f->base = f->cp = NULL; ! 39: return(f); ! 40: } ! 41: ! 42: FILE * ! 43: fopen(file,mode) ! 44: char *file,*mode; ! 45: { ! 46: register int i; ! 47: register FILE *f; ! 48: extern FILE *_lastbuf; ! 49: for (f = _iob, i = 0; f->flag & (_IOREAD | _IOWRT); f++, i++); ! 50: if (f >= _lastbuf) ! 51: return((FILE *) NULL); ! 52: return(_open(file,mode,f,i)); ! 53: } ! 54: ! 55: FILE * ! 56: freopen(file,mode,f) ! 57: char *file,*mode; ! 58: FILE *f; ! 59: { ! 60: fclose(f); ! 61: return(_open(file,mode,f,fileno(f))); ! 62: } ! 63: ! 64: fclose(f) ! 65: FILE *f; ! 66: { ! 67: if (f->flag != 0) { ! 68: fflush(f); ! 69: free(f->base); ! 70: f->base = f->cp = 0; ! 71: f->flag = 0; ! 72: tag(_SYSCLOSE); ! 73: jputshort(fileno(f)); ! 74: jflush(); ! 75: return(jgetshort()); ! 76: } ! 77: return -1; ! 78: } ! 79:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.