ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/duphead.c
Revision: 2.2
Committed: Tue Sep 21 10:58:22 1993 UTC (30 years, 7 months ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 2.1: +3 -1 lines
Log Message:
fix for NeXT

File Contents

# Content
1 /* Copyright (c) 1993 Regents of the University of California */
2
3 #ifndef lint
4 static char SCCSid[] = "$SunId$ LBL";
5 #endif
6
7 /*
8 * Duplicate header on stdout.
9 */
10
11 #include "standard.h"
12 #include "paths.h"
13
14
15 int headismine = 1; /* true if header file belongs to me */
16
17 static char *headfname = NULL; /* temp file name */
18 static FILE *headfp = NULL; /* temp file pointer */
19
20
21 headclean() /* remove header temp file (if one) */
22 {
23 if (headfname != NULL) {
24 if (headfp != NULL)
25 fclose(headfp);
26 if (headismine)
27 unlink(headfname);
28 }
29 }
30
31
32 openheader() /* save standard output to header file */
33 {
34 static char template[] = TEMPLATE;
35
36 headfname = mktemp(template);
37 if (freopen(headfname, "w", stdout) == NULL) {
38 sprintf(errmsg, "cannot open header file \"%s\"", headfname);
39 error(SYSTEM, errmsg);
40 }
41 }
42
43
44 dupheader() /* repeat header on standard output */
45 {
46 register int c;
47
48 if (headfp == NULL) {
49 if ((headfp = fopen(headfname, "r")) == NULL)
50 error(SYSTEM, "error reopening header file");
51 #ifdef MSDOS
52 setmode(fileno(headfp), O_BINARY);
53 #endif
54 } else if (fseek(headfp, 0L, 0) < 0)
55 error(SYSTEM, "seek error on header file");
56 while ((c = getc(headfp)) != EOF)
57 putchar(c);
58 }