|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T i
Length: 1193 (0x4a9) Types: TextFile Names: »ioop.c«
└─⟦87ddcff64⟧ Bits:30001253 CPHDIST85 Tape, 1985 Autumn Conference Copenhagen └─⟦this⟧ »cph85dist/stage2/ioop.c«
/* ioop - Input/output routine for SIMCOMP * * status=ioop(op,chan,buf,ptr1,ptr2) * * See the book for details. * */ #include <stdio.h> #define OK 0 #define Eof 1 #define ILLEGAL 2 #define ERROR 3 #define READ -1 #define CONTROL 0 #define WRITE 1 #define TRUE -1 #define FALSE 0 #define MAXCH 5 int ioop(op,chan,buf,ptr1,ptr2) int op, chan, buf[], *ptr1, *ptr2 ; { static FILE *chanid[MAXCH] = {NULL,stdin,NULL,stdout,stderr}; int tmp; switch(chan) { case 0: return(op==READ? Eof : OK); case 1: { if (op == CONTROL) return(OK); if (op == WRITE) return(ILLEGAL); goto streamin; } case 2: { return(ILLEGAL); } case 3: { if (op == CONTROL) return(OK); if (op == READ) return(ILLEGAL); goto streamout; } case 4: { if (op == CONTROL) return(OK); if (op == READ) return(ILLEGAL); goto streamout; } default: return(ILLEGAL); } streamin: *ptr2 = *ptr1; while(TRUE) { if ((buf[*ptr2] = getc(chanid[chan])) == EOF) return(Eof); if (buf[*ptr2] == '\n') return(OK); (*ptr2)++; } streamout: tmp = *ptr1; while(tmp < *ptr2) { putc(buf[tmp++],chanid[chan]); } putc('\n',chanid[chan]); return(OK); }