--- ray/src/util/getinfo.c 1989/02/02 10:49:19 1.1 +++ ray/src/util/getinfo.c 2003/07/21 22:30:19 2.7 @@ -1,9 +1,6 @@ -/* Copyright (c) 1986 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: getinfo.c,v 2.7 2003/07/21 22:30:19 schorsch Exp $"; #endif - /* * getinfo.c - program to read info. header from file. * @@ -12,7 +9,11 @@ static char SCCSid[] = "$SunId$ LBL"; #include +#include "platform.h" + + +int tabstr(s) /* put out line followed by tab */ register char *s; { @@ -22,12 +23,13 @@ register char *s; } if (*--s == '\n') putchar('\t'); + return(0); } main(argc, argv) int argc; -char *argv[]; +char **argv; { int dim = 0; FILE *fp; @@ -36,6 +38,14 @@ char *argv[]; if (argc > 1 && !strcmp(argv[1], "-d")) { argc--; argv++; dim = 1; + SET_DEFAULT_BINARY(); /* for output file */ + SET_FILE_BINARY(stdin); + } else if (argc == 2 && !strcmp(argv[1], "-")) { + SET_FILE_BINARY(stdin); + SET_FILE_BINARY(stdout); + getheader(stdin, NULL, NULL); + copycat(); + exit(0); } for (i = 1; i < argc; i++) { fputs(argv[i], stdout); @@ -47,19 +57,20 @@ char *argv[]; getdim(fp); } else { tabstr(":\n"); - getheader(fp, tabstr); + getheader(fp, tabstr, NULL); putchar('\n'); } fclose(fp); } } - if (argc == 1) + if (argc == 1) { if (dim) { getdim(stdin); } else { - copyheader(stdin, stdout); + getheader(stdin, fputs, stdout); putchar('\n'); } + } exit(0); } @@ -70,7 +81,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 +107,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); }