1 |
– |
/* Copyright (c) 1986 Regents of the University of California */ |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
6 |
– |
|
4 |
|
/* |
5 |
|
* writeoct.c - routines for writing octree information to stdout. |
6 |
|
* |
15 |
|
|
16 |
|
#include "otypes.h" |
17 |
|
|
18 |
< |
static int putint(), putstr(), puttree(), putobj(); |
18 |
> |
static int oputint(), oputstr(), puttree(), putobj(); |
19 |
|
|
20 |
|
|
21 |
|
writeoct(store, scene, ofn) /* write octree structures to stdout */ |
26 |
|
char sbuf[64]; |
27 |
|
register int i; |
28 |
|
/* write format number */ |
29 |
< |
putint((long)(OCTMAGIC+sizeof(OBJECT)), 2); |
29 |
> |
oputint((long)(OCTMAGIC+sizeof(OBJECT)), 2); |
30 |
|
|
31 |
|
if (!(store & IO_BOUNDS)) |
32 |
|
return; |
33 |
|
/* write boundaries */ |
34 |
|
for (i = 0; i < 3; i++) { |
35 |
|
sprintf(sbuf, "%.12g", scene->cuorg[i]); |
36 |
< |
putstr(sbuf); |
36 |
> |
oputstr(sbuf); |
37 |
|
} |
38 |
|
sprintf(sbuf, "%.12g", scene->cusize); |
39 |
< |
putstr(sbuf); |
39 |
> |
oputstr(sbuf); |
40 |
|
/* write object file names */ |
41 |
|
if (store & IO_FILES) |
42 |
|
for (i = 0; ofn[i] != NULL; i++) |
43 |
< |
putstr(ofn[i]); |
44 |
< |
putstr(""); |
43 |
> |
oputstr(ofn[i]); |
44 |
> |
oputstr(""); |
45 |
|
/* write number of objects */ |
46 |
< |
putint((long)nobjects, sizeof(OBJECT)); |
46 |
> |
oputint((long)nobjects, sizeof(OBJECT)); |
47 |
|
|
48 |
|
if (!(store & IO_TREE)) |
49 |
|
return; |
54 |
|
return; |
55 |
|
/* write the scene */ |
56 |
|
for (i = 0; i < NUMOTYPE; i++) |
57 |
< |
putstr(ofun[i].funame); |
58 |
< |
putstr(""); |
57 |
> |
oputstr(ofun[i].funame); |
58 |
> |
oputstr(""); |
59 |
|
for (i = 0; i < nobjects; i++) |
60 |
|
putobj(objptr(i)); |
61 |
|
putobj(NULL); |
63 |
|
|
64 |
|
|
65 |
|
static |
66 |
< |
putstr(s) /* write null-terminated string to stdout */ |
66 |
> |
oputstr(s) /* write null-terminated string to stdout */ |
67 |
|
register char *s; |
68 |
|
{ |
69 |
< |
do |
73 |
< |
putc(*s, stdout); |
74 |
< |
while (*s++); |
69 |
> |
putstr(s, stdout); |
70 |
|
if (ferror(stdout)) |
71 |
|
error(SYSTEM, "write error in putstr"); |
72 |
|
} |
81 |
|
|
82 |
|
objset(oset, fn); |
83 |
|
for (i = 0; i <= oset[0]; i++) |
84 |
< |
putint((long)oset[i], sizeof(OBJECT)); |
84 |
> |
oputint((long)oset[i], sizeof(OBJECT)); |
85 |
|
} |
86 |
|
|
87 |
|
|
88 |
|
static |
89 |
< |
putint(i, siz) /* write a siz-byte integer to stdout */ |
89 |
> |
oputint(i, siz) /* write a siz-byte integer to stdout */ |
90 |
|
register long i; |
91 |
|
register int siz; |
92 |
|
{ |
93 |
< |
while (siz--) |
99 |
< |
putc(i>>(siz<<3) & 0xff, stdout); |
93 |
> |
putint(i, siz, stdout); |
94 |
|
if (ferror(stdout)) |
95 |
|
error(SYSTEM, "write error in putint"); |
96 |
|
} |
97 |
|
|
98 |
|
|
99 |
|
static |
100 |
< |
putflt(f) /* put out floating point number */ |
100 |
> |
oputflt(f) /* put out floating point number */ |
101 |
|
double f; |
102 |
|
{ |
103 |
< |
extern double frexp(); |
104 |
< |
int e; |
105 |
< |
|
112 |
< |
putint((long)(frexp(f,&e)*0x7fffffff), 4); |
113 |
< |
putint((long)e, 1); |
103 |
> |
putflt(f, stdout); |
104 |
> |
if (ferror(stdout)) |
105 |
> |
error(SYSTEM, "write error in putflt"); |
106 |
|
} |
107 |
|
|
108 |
|
|
131 |
|
register int i; |
132 |
|
|
133 |
|
if (o == NULL) { /* terminator */ |
134 |
< |
putint(-1L, 1); |
134 |
> |
oputint(-1L, 1); |
135 |
|
return; |
136 |
|
} |
137 |
< |
putint((long)o->otype, 1); |
138 |
< |
putint((long)o->omod, sizeof(OBJECT)); |
139 |
< |
putstr(o->oname); |
140 |
< |
putint((long)o->oargs.nsargs, 2); |
137 |
> |
oputint((long)o->otype, 1); |
138 |
> |
oputint((long)o->omod, sizeof(OBJECT)); |
139 |
> |
oputstr(o->oname); |
140 |
> |
oputint((long)o->oargs.nsargs, 2); |
141 |
|
for (i = 0; i < o->oargs.nsargs; i++) |
142 |
< |
putstr(o->oargs.sarg[i]); |
142 |
> |
oputstr(o->oargs.sarg[i]); |
143 |
|
#ifdef IARGS |
144 |
< |
putint((long)o->oargs.niargs, 2); |
144 |
> |
oputint((long)o->oargs.niargs, 2); |
145 |
|
for (i = 0; i < o->oargs.niargs; i++) |
146 |
< |
putint((long)o->oargs.iarg[i], 4); |
146 |
> |
oputint((long)o->oargs.iarg[i], 4); |
147 |
|
#endif |
148 |
< |
putint((long)o->oargs.nfargs, 2); |
148 |
> |
oputint((long)o->oargs.nfargs, 2); |
149 |
|
for (i = 0; i < o->oargs.nfargs; i++) |
150 |
< |
putflt(o->oargs.farg[i]); |
150 |
> |
oputflt(o->oargs.farg[i]); |
151 |
|
} |