--- ray/src/util/getinfo.c 1989/02/02 10:49:19 1.1 +++ ray/src/util/getinfo.c 1992/11/12 10:06:11 2.3 @@ -1,4 +1,4 @@ -/* Copyright (c) 1986 Regents of the University of California */ +/* Copyright (c) 1992 Regents of the University of California */ #ifndef lint static char SCCSid[] = "$SunId$ LBL"; @@ -12,7 +12,14 @@ static char SCCSid[] = "$SunId$ LBL"; #include +#ifdef MSDOS +#include +extern int _fmode; +#endif +extern int fputs(); + + tabstr(s) /* put out line followed by tab */ register char *s; { @@ -27,7 +34,7 @@ register char *s; main(argc, argv) int argc; -char *argv[]; +char **argv; { int dim = 0; FILE *fp; @@ -36,6 +43,17 @@ char *argv[]; if (argc > 1 && !strcmp(argv[1], "-d")) { argc--; argv++; dim = 1; +#ifdef MSDOS + setmode(fileno(stdin), _fmode = O_BINARY); +#endif + } else if (argc == 2 && !strcmp(argv[1], "-")) { +#ifdef MSDOS + setmode(fileno(stdin), O_BINARY); + setmode(fileno(stdout), O_BINARY); +#endif + getheader(stdin, NULL, NULL); + copycat(); + exit(0); } for (i = 1; i < argc; i++) { fputs(argv[i], stdout); @@ -47,7 +65,7 @@ char *argv[]; getdim(fp); } else { tabstr(":\n"); - getheader(fp, tabstr); + getheader(fp, tabstr, NULL); putchar('\n'); } fclose(fp); @@ -57,7 +75,7 @@ char *argv[]; if (dim) { getdim(stdin); } else { - copyheader(stdin, stdout); + getheader(stdin, fputs, stdout); putchar('\n'); } exit(0); @@ -70,7 +88,7 @@ register FILE *fp; int j; register int c; - getheader(fp, NULL); /* skip header */ + getheader(fp, NULL, NULL); /* skip header */ switch (c = getc(fp)) { case '+': /* picture */ @@ -96,4 +114,13 @@ register FILE *fp; fputs("unknown file type\n", stdout); break; } +} + + +copycat() /* copy input to output */ +{ + register int c; + + while ((c = getchar()) != EOF) + putchar(c); }