5 |
|
* Radiance holodeck generation controller |
6 |
|
*/ |
7 |
|
|
8 |
+ |
#include <stdio.h> |
9 |
+ |
#include <time.h> |
10 |
|
#include <signal.h> |
11 |
|
#include <sys/stat.h> |
12 |
|
#include <string.h> |
13 |
|
|
12 |
– |
#include "rholo.h" |
14 |
|
#include "platform.h" |
15 |
+ |
#include "rterror.h" |
16 |
+ |
#include "resolu.h" |
17 |
+ |
#include "rholo.h" |
18 |
|
#include "random.h" |
19 |
|
|
20 |
|
#ifndef FRAGWARN |
69 |
|
|
70 |
|
extern int nowarn; /* turn warnings off? */ |
71 |
|
|
72 |
< |
extern time_t time(); |
72 |
> |
static void onsig(int signo); |
73 |
> |
static void sigdie(int signo, char *msg); |
74 |
> |
static int resfmode(int fd, int mod); |
75 |
> |
static void initrholo(void); |
76 |
> |
static int rholo(void); |
77 |
> |
static void setdefaults(HDGRID *gp); |
78 |
> |
static void creatholo(HDGRID *gp); |
79 |
> |
static gethfunc headline; |
80 |
> |
static void loadholo(void); |
81 |
> |
static void rootname(char *rn, char *fn); |
82 |
> |
static void badvalue(int vc); |
83 |
|
|
84 |
|
|
85 |
< |
main(argc, argv) |
86 |
< |
int argc; |
87 |
< |
char *argv[]; |
85 |
> |
int |
86 |
> |
main( |
87 |
> |
int argc, |
88 |
> |
char *argv[] |
89 |
> |
) |
90 |
|
{ |
91 |
|
int i; |
92 |
|
|
168 |
|
"Usage: %s [-n nprocs][-o disp][-w][-r|-f] output.hdk [control.hif|+|- [VAR=val ..]]\n", |
169 |
|
progname); |
170 |
|
quit(1); |
171 |
+ |
return 1; /* pro forma return */ |
172 |
|
} |
173 |
|
|
174 |
|
|
175 |
< |
void |
176 |
< |
onsig(signo) /* fatal signal */ |
177 |
< |
int signo; |
175 |
> |
static void |
176 |
> |
onsig( /* fatal signal */ |
177 |
> |
int signo |
178 |
> |
) |
179 |
|
{ |
180 |
|
static int gotsig = 0; |
181 |
|
|
193 |
|
} |
194 |
|
|
195 |
|
|
196 |
< |
sigdie(signo, msg) /* set fatal signal */ |
197 |
< |
int signo; |
198 |
< |
char *msg; |
196 |
> |
static void |
197 |
> |
sigdie( /* set fatal signal */ |
198 |
> |
int signo, |
199 |
> |
char *msg |
200 |
> |
) |
201 |
|
{ |
202 |
|
if (signal(signo, onsig) == SIG_IGN) |
203 |
|
signal(signo, SIG_IGN); |
205 |
|
} |
206 |
|
|
207 |
|
|
208 |
< |
int |
209 |
< |
resfmode(fd, mod) /* restrict open file access mode */ |
210 |
< |
int fd, mod; |
208 |
> |
static int |
209 |
> |
resfmode( /* restrict open file access mode */ |
210 |
> |
int fd, |
211 |
> |
int mod |
212 |
> |
) |
213 |
|
{ |
214 |
|
struct stat stbuf; |
215 |
|
/* get original mode */ |
227 |
|
} |
228 |
|
|
229 |
|
|
230 |
< |
initrholo() /* get our holodeck running */ |
230 |
> |
static void |
231 |
> |
initrholo(void) /* get our holodeck running */ |
232 |
|
{ |
233 |
|
extern int global_packet(); |
234 |
|
register int i; |
317 |
|
} |
318 |
|
|
319 |
|
|
320 |
< |
rholo() /* holodeck main loop */ |
320 |
> |
static int |
321 |
> |
rholo(void) /* holodeck main loop */ |
322 |
|
{ |
323 |
|
static long nextfragwarn = 100*(1L<<20); |
324 |
|
static int idle = 0; |
345 |
|
} |
346 |
|
#if FRAGWARN |
347 |
|
if (fsiz >= nextfragwarn && |
348 |
< |
(fsiz-hdfiluse(hdlist[0]->fd,0))/(fsiz/100) > FRAGWARN) { |
349 |
< |
sprintf(errmsg, "holodeck file fragmentation is %.0f%%", |
350 |
< |
100.*(fsiz-hdfiluse(hdlist[0]->fd,1))/fsiz); |
351 |
< |
error(WARNING, errmsg); |
352 |
< |
nextfragwarn = fsiz + (fsiz>>2); /* decent interval */ |
348 |
> |
(fsiz-hdfiluse(hdlist[0]->fd,0))/(fsiz/100) > FRAGWARN) { |
349 |
> |
double pctfrag = 100.*(fsiz-hdfiluse(hdlist[0]->fd,1))/fsiz; |
350 |
> |
if (pctfrag >= (double)FRAGWARN) { |
351 |
> |
sprintf(errmsg, "holodeck file fragmentation is %.0f%%", |
352 |
> |
pctfrag); |
353 |
> |
error(WARNING, errmsg); |
354 |
> |
nextfragwarn = fsiz + (fsiz>>2); |
355 |
> |
} |
356 |
|
} |
357 |
|
#endif |
358 |
|
t = time(NULL); /* check time */ |
390 |
|
} |
391 |
|
|
392 |
|
|
393 |
< |
setdefaults(gp) /* set default values */ |
394 |
< |
register HDGRID *gp; |
393 |
> |
static void |
394 |
> |
setdefaults( /* set default values */ |
395 |
> |
register HDGRID *gp |
396 |
> |
) |
397 |
|
{ |
398 |
|
extern char *atos(); |
399 |
|
register int i; |
400 |
|
int n; |
401 |
|
double len[3], d; |
373 |
– |
char buf[64]; |
402 |
|
|
403 |
|
if (!vdef(SECTION)) { |
404 |
|
sprintf(errmsg, "%s must be defined", vnam(SECTION)); |
448 |
|
} |
449 |
|
|
450 |
|
|
451 |
< |
creatholo(gp) /* create a holodeck output file */ |
452 |
< |
HDGRID *gp; |
451 |
> |
static void |
452 |
> |
creatholo( /* create a holodeck output file */ |
453 |
> |
HDGRID *gp |
454 |
> |
) |
455 |
|
{ |
456 |
|
extern char VersionID[]; |
457 |
|
int32 lastloc, nextloc; |
489 |
|
} |
490 |
|
|
491 |
|
|
492 |
< |
int |
493 |
< |
headline(s) /* process information header line */ |
494 |
< |
char *s; |
492 |
> |
static int |
493 |
> |
headline( /* process information header line */ |
494 |
> |
char *s, |
495 |
> |
void *p |
496 |
> |
) |
497 |
|
{ |
498 |
|
extern char FMTSTR[]; |
499 |
|
register char *cp; |
517 |
|
} |
518 |
|
|
519 |
|
|
520 |
< |
loadholo() /* start loading a holodeck from fname */ |
520 |
> |
static void |
521 |
> |
loadholo(void) /* start loading a holodeck from fname */ |
522 |
|
{ |
523 |
|
FILE *fp; |
524 |
|
int fd; |
566 |
|
} |
567 |
|
|
568 |
|
|
569 |
< |
done_packets(pl) /* handle finished packets */ |
570 |
< |
PACKET *pl; |
569 |
> |
extern void |
570 |
> |
done_packets( /* handle finished packets */ |
571 |
> |
PACKET *pl |
572 |
> |
) |
573 |
|
{ |
574 |
|
static int n2flush = 0; |
575 |
|
register PACKET *p; |
601 |
|
} |
602 |
|
|
603 |
|
|
604 |
< |
rootname(rn, fn) /* remove tail from end of fn */ |
605 |
< |
register char *rn, *fn; |
604 |
> |
static void |
605 |
> |
rootname( /* remove tail from end of fn */ |
606 |
> |
register char *rn, |
607 |
> |
register char *fn |
608 |
> |
) |
609 |
|
{ |
610 |
|
char *tp, *dp; |
611 |
|
|
620 |
|
} |
621 |
|
|
622 |
|
|
623 |
< |
badvalue(vc) /* report bad variable value and exit */ |
624 |
< |
int vc; |
623 |
> |
static void |
624 |
> |
badvalue( /* report bad variable value and exit */ |
625 |
> |
int vc |
626 |
> |
) |
627 |
|
{ |
628 |
|
sprintf(errmsg, "bad value for variable '%s'", vnam(vc)); |
629 |
|
error(USER, errmsg); |