|
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 t
Length: 2786 (0xae2) Types: TextFile Names: »testspcl.c«
└─⟦52210d11f⟧ Bits:30007239 EUUGD2: TeX 3 1992-12 └─⟦af5ba6c8e⟧ »unix3.0/DVIWARE.tar.Z« └─⟦ca79c7339⟧ └─⟦this⟧ »DVIware/laser-setters/mctex/misc/testspcl.c«
/* test special decoding */ #include <stdio.h> #include "../h/types.h" #include "../h/sdecode.h" /* * Run this program with input from a file containing lines of the form * name arg1 arg2 ... argn */ void f_nop(), f_s(), f_d(), f_f(), f_dd(), f_ff(), f_ddddff(); void f_nd(), f_nx(), f_rest(); struct sdecode sd[] = { { "4d2f", sda_ddddff, f_ddddff }, { "array", sda_nd, f_nd }, { "float", sda_f, f_f }, { "hex", sda_nx, f_nx }, { "int", sda_d, f_d }, { "nop", sda_none, f_nop }, { "rest", sda_rest, f_rest }, { "string", sda_s, f_s }, { "twofloat", sda_ff, f_ff }, { "twoint", sda_dd, f_dd }, }; char *DVIFileName, *ProgName; /* ARGSUSED */ main(argc, argv) int argc; char **argv; { register int l; register long off; char buf[1024]; DVIFileName = "<stdin>"; ProgName = argv[0]; for (;;) { off = ftell(stdin); if (fgets(buf, sizeof(buf), stdin) == NULL) break; if ((l = strlen(buf)) == 0) continue; if (buf[--l] == '\n') buf[l] = 0; else { fprintf(stderr, "input line too long, aborting\n"); exit(1); } if (buf[0] == '#') { puts(buf + 1); continue; } /* printf("trying `%s'\n", buf); */ (void) fseek(stdin, off, 0); SDecode(stdin, l, sd, sizeof(sd) / sizeof(*sd)); if ((l = getchar()) != '\n') { fprintf(stderr, "oops! got %c (%o) instead of newline\n", l, l); exit(2); } } exit(0); } void f_nop(self) char *self; { printf("%s()\n", self); } void f_s(self, s) char *self, *s; { printf("%s(%s)\n", self, s); } void f_d(self, d) char *self; int d; { printf("%s(%d)\n", self, d); } void f_f(self, f) char *self; double f; { printf("%s(%f)\n", self, f); } void f_dd(self, d1, d2) char *self; int d1, d2; { printf("%s(%d, %d)\n", self, d1, d2); } void f_ff(self, f1, f2) char *self; double f1, f2; { printf("%s(%f, %f)\n", self, f1, f2); } void f_ddddff(self, d1, d2, d3, d4, f1, f2) char *self; int d1, d2, d3, d4; double f1, f2; { printf("%s(%d, %d, %d, %d, %f, %f)\n", self, d1, d2, d3, d4, f1, f2); } static void printarr(fn, fmt, n, arr) char *fn; register char *fmt; register int n, *arr; { register char *sep; if (n == 0) printf("%s()", fn); else { fputs(fn, stdout); sep = "("; while (--n >= 0) { fputs(sep, stdout); printf(fmt, *arr++); sep = ", "; } fputs(")", stdout); } puts(""); } void f_nd(self, n, arr) char *self; int n, *arr; { printarr(self, "%d", n, arr); } void f_nx(self, n, arr) char *self; int n, *arr; { printarr(self, "%#x", n, arr); } void f_rest(self, l1, s, l2) char *self; i32 l1; char *s; i32 l2; { printf("%s(%ld, s, %ld); s = `%.*s", self, (long)l1, (long)l2, l1 > 20 ? 20 : l1, s); if (l1 > 20) fputs("...", stdout); puts("'"); while (--l2 >= 0) (void) getchar(); }