--- ray/src/util/getinfo.c 2003/02/22 02:07:30 2.5 +++ ray/src/util/getinfo.c 2012/06/09 04:24:16 2.9 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: getinfo.c,v 2.5 2003/02/22 02:07:30 greg Exp $"; +static const char RCSid[] = "$Id: getinfo.c,v 2.9 2012/06/09 04:24:16 greg Exp $"; #endif /* * getinfo.c - program to read info. header from file. @@ -8,18 +8,29 @@ static const char RCSid[] = "$Id: getinfo.c,v 2.5 2003 */ #include +#include -#ifdef MSDOS -#include -extern int _fmode; +#include "platform.h" +#include "resolu.h" + +#ifdef getc_unlocked /* avoid nasty file-locking overhead */ +#undef getchar +#undef putchar +#define getchar getchar_unlocked +#define putchar putchar_unlocked #endif -extern int fputs(); +static gethfunc tabstr; +static void getdim(register FILE *fp); +static void copycat(void); -int -tabstr(s) /* put out line followed by tab */ -register char *s; + +static int +tabstr( /* put out line followed by tab */ + register char *s, + void *p +) { while (*s) { putchar(*s); @@ -31,9 +42,11 @@ register char *s; } -main(argc, argv) -int argc; -char **argv; +int +main( + int argc, + char **argv +) { int dim = 0; FILE *fp; @@ -42,17 +55,14 @@ char **argv; if (argc > 1 && !strcmp(argv[1], "-d")) { argc--; argv++; dim = 1; -#ifdef MSDOS - setmode(fileno(stdin), _fmode = O_BINARY); -#endif + SET_DEFAULT_BINARY(); /* for output file */ + SET_FILE_BINARY(stdin); } else if (argc == 2 && !strcmp(argv[1], "-")) { -#ifdef MSDOS - setmode(fileno(stdin), O_BINARY); - setmode(fileno(stdout), O_BINARY); -#endif + SET_FILE_BINARY(stdin); + SET_FILE_BINARY(stdout); getheader(stdin, NULL, NULL); copycat(); - exit(0); + return 0; } for (i = 1; i < argc; i++) { fputs(argv[i], stdout); @@ -63,26 +73,29 @@ char **argv; fputs(": ", stdout); getdim(fp); } else { - tabstr(":\n"); + tabstr(":\n", NULL); getheader(fp, tabstr, NULL); putchar('\n'); } fclose(fp); } } - if (argc == 1) + if (argc == 1) { if (dim) { getdim(stdin); } else { - getheader(stdin, fputs, stdout); + getheader(stdin, (gethfunc*)fputs, stdout); putchar('\n'); } - exit(0); + } + return 0; } -getdim(fp) /* get dimensions from file */ -register FILE *fp; +static void +getdim( /* get dimensions from file */ + register FILE *fp +) { int j; register int c; @@ -116,7 +129,8 @@ register FILE *fp; } -copycat() /* copy input to output */ +static void +copycat(void) /* copy input to output */ { register int c;