#include #include "sqcom.h" #include "sq.h" #define ERROR -1 #ifdef TOPS20 static int incnt = 0; #endif /* Get next byte from file and update checksum */ int getc_crc(ib) FILE *ib; { int c; #ifdef TOPS20 if ((c = fgetc(ib)) == EOF) { if (incnt & 0x7F) { c = (bytsiz != 7) ? 0 : 0x1A; } else { return (c = EOF); } } ++incnt; c &= 0xFF; crc += c; crc &= 0xFFFF; return (c); #else c = getc(ib); if (c != EOF) crc += c; /* checksum */ return (c); #endif } /* Output functions with error reporting */ static char obuf[128]; static int oblen = 0; putce(c, iob) int c; FILE *iob; { /* obuf[oblen++] = c; */ obuf[oblen++] = (c & 0xff); /*rev 3.3*/ if (oblen >= sizeof(obuf)) oflush(iob); } putwe(w, iob) int w; FILE *iob; { /* obuf[oblen++] = w; */ obuf[oblen++] = (w & 0xff); /*rev 3.3*/ if (oblen >= sizeof(obuf)) oflush(iob); /* obuf[oblen++] = w >> 8; */ obuf[oblen++] = (w >> 8) & 0xff;/*rev 3.3*/ if (oblen >= sizeof(obuf)) oflush(iob); } oflush(iob) /* flush output buffer */ FILE *iob; { if (oblen && !fwrite(obuf, oblen, 1, iob)) { printf("Error writing output file\n"); exit(1); } oblen = 0; #ifdef COMMENT int i; if (oblen) for (i = 0; i < sizeof(obuf); ++i) fputc (obuf[i], iob); oblen = 0; fflush(iob); #endif }