--- ray/src/rt/duphead.c 1993/01/20 15:18:59 2.1 +++ ray/src/rt/duphead.c 2003/10/22 02:06:35 2.7 @@ -1,13 +1,15 @@ -/* Copyright (c) 1993 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: duphead.c,v 2.7 2003/10/22 02:06:35 greg Exp $"; #endif - /* * Duplicate header on stdout. + * + * Externals declared in ray.h */ +#include "copyright.h" + +#include "platform.h" #include "standard.h" #include "paths.h" @@ -18,20 +20,24 @@ static char *headfname = NULL; /* temp file name */ static FILE *headfp = NULL; /* temp file pointer */ +void headclean() /* remove header temp file (if one) */ { - if (headfname != NULL) { - if (headfp != NULL) - fclose(headfp); - if (headismine) - unlink(headfname); - } + if (headfname == NULL) + return; + if (headfp != NULL) + fclose(headfp); + if (headismine) + unlink(headfname); } +void openheader() /* save standard output to header file */ { - headfname = mktemp(TEMPLATE); + static char template[] = TEMPLATE; + + headfname = mktemp(template); if (freopen(headfname, "w", stdout) == NULL) { sprintf(errmsg, "cannot open header file \"%s\"", headfname); error(SYSTEM, errmsg); @@ -39,6 +45,7 @@ openheader() /* save standard output to header file } +void dupheader() /* repeat header on standard output */ { register int c; @@ -46,9 +53,7 @@ dupheader() /* repeat header on standard output */ if (headfp == NULL) { if ((headfp = fopen(headfname, "r")) == NULL) error(SYSTEM, "error reopening header file"); -#ifdef MSDOS - setmode(fileno(headfp), O_BINARY); -#endif + SET_FILE_BINARY(headfp); } else if (fseek(headfp, 0L, 0) < 0) error(SYSTEM, "seek error on header file"); while ((c = getc(headfp)) != EOF)