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