| 166 |
|
/* print all values if requested */ |
| 167 |
|
if (explicate) |
| 168 |
|
printvals(); |
| 169 |
< |
/* run simulation */ |
| 169 |
> |
/* build octree */ |
| 170 |
|
oconv(); |
| 171 |
+ |
/* check date on ambient file */ |
| 172 |
+ |
checkambfile(); |
| 173 |
+ |
/* run simulation */ |
| 174 |
|
renderopts(ropts); |
| 175 |
|
xferopts(ropts); |
| 176 |
|
if (rvdevice != NULL) |
| 557 |
|
} |
| 558 |
|
|
| 559 |
|
|
| 560 |
+ |
checkambfile() /* check date on ambient file */ |
| 561 |
+ |
{ |
| 562 |
+ |
long afdate; |
| 563 |
+ |
|
| 564 |
+ |
if (vdef(AMBFILE)) { |
| 565 |
+ |
afdate = fdate(vval(AMBFILE)); |
| 566 |
+ |
if (afdate >= 0 & octreedate > afdate) |
| 567 |
+ |
rmfile(vval(AMBFILE)); |
| 568 |
+ |
} |
| 569 |
+ |
} |
| 570 |
+ |
|
| 571 |
+ |
|
| 572 |
|
double |
| 573 |
|
ambval() /* compute ambient value */ |
| 574 |
|
{ |
| 784 |
|
char *ro; |
| 785 |
|
{ |
| 786 |
|
int fd, n; |
| 787 |
+ |
register char *cp; |
| 788 |
|
|
| 789 |
|
n = strlen(ro); |
| 790 |
|
if (n < 2) |
| 791 |
|
return; |
| 792 |
|
if (vdef(OPTFILE)) { |
| 793 |
< |
if ((fd = open(vval(OPTFILE), O_WRONLY|O_CREAT|O_TRUNC, 0666)) == -1) |
| 793 |
> |
for (cp = ro; cp[1]; cp++) |
| 794 |
> |
if (isspace(cp[1]) && cp[2] == '-' && isalpha(cp[3])) |
| 795 |
> |
*cp = '\n'; |
| 796 |
> |
else |
| 797 |
> |
*cp = cp[1]; |
| 798 |
> |
*cp = '\n'; |
| 799 |
> |
fd = open(vval(OPTFILE), O_WRONLY|O_CREAT|O_TRUNC, 0666); |
| 800 |
> |
if (fd < 0 || write(fd, ro, n) != n || close(fd) < 0) |
| 801 |
|
syserr(vval(OPTFILE)); |
| 779 |
– |
if (write(fd, ro+1, n-1) != n-1) |
| 780 |
– |
syserr(vval(OPTFILE)); |
| 781 |
– |
write(fd, "\n", 1); |
| 782 |
– |
close(fd); |
| 802 |
|
sprintf(ro, " \"^%s\"", vval(OPTFILE)); |
| 803 |
|
} |
| 804 |
|
#ifdef MSDOS |
| 805 |
|
else if (n > 50) { |
| 806 |
< |
register char *evp = bmalloc(n+6); |
| 788 |
< |
if (evp == NULL) |
| 789 |
< |
syserr(progname); |
| 790 |
< |
strcpy(evp, "ROPT="); |
| 791 |
< |
strcat(evp, ro); |
| 792 |
< |
if (putenv(evp) != 0) { |
| 793 |
< |
fprintf(stderr, "%s: out of environment space\n", |
| 794 |
< |
progname); |
| 795 |
< |
exit(1); |
| 796 |
< |
} |
| 806 |
> |
setenv("ROPT", ro+1); |
| 807 |
|
strcpy(ro, " $ROPT"); |
| 808 |
|
} |
| 809 |
|
#endif |
| 943 |
|
cp += strlen(cp); |
| 944 |
|
} |
| 945 |
|
} |
| 946 |
< |
/* append any additional options */ |
| 947 |
< |
strcpy(cp, vs); |
| 946 |
> |
strcpy(cp, vs); /* append any additional options */ |
| 947 |
> |
#ifdef MSDOS |
| 948 |
> |
if (strlen(viewopts) > 40) { |
| 949 |
> |
setenv("VIEW", viewopts); |
| 950 |
> |
return("$VIEW"); |
| 951 |
> |
} |
| 952 |
> |
#endif |
| 953 |
|
return(viewopts); |
| 954 |
|
} |
| 955 |
|
|
| 957 |
|
char * |
| 958 |
|
getview(n, vn) /* get view n, or NULL if none */ |
| 959 |
|
int n; |
| 960 |
< |
char *vn; |
| 960 |
> |
char *vn; /* returned view name */ |
| 961 |
|
{ |
| 962 |
< |
register char *mv; |
| 962 |
> |
register char *mv = NULL; |
| 963 |
|
|
| 964 |
< |
if (viewselect != NULL) { |
| 964 |
> |
if (viewselect != NULL) { /* command-line selected */ |
| 965 |
|
if (n) /* only do one */ |
| 966 |
|
return(NULL); |
| 967 |
|
if (viewselect[0] == '-') { /* already specified */ |
| 980 |
|
return(specview(mv)); |
| 981 |
|
return(specview(viewselect)); /* standard view? */ |
| 982 |
|
} |
| 983 |
< |
if (vn != NULL && (mv = nvalue(vv+VIEW, n)) != NULL) { |
| 983 |
> |
mv = nvalue(vv+VIEW, n); /* use view n */ |
| 984 |
> |
if (vn != NULL & mv != NULL) { |
| 985 |
|
if (*mv != '-') |
| 986 |
|
while (*mv && !isspace(*mv)) |
| 987 |
|
*vn++ = *mv++; |
| 988 |
|
*vn = '\0'; |
| 989 |
|
} |
| 990 |
< |
return(specview(nvalue(vv+VIEW, n))); /* use view n */ |
| 990 |
> |
return(specview(mv)); |
| 991 |
|
} |
| 992 |
|
|
| 993 |
|
|
| 1045 |
|
else |
| 1046 |
|
badvalue(REPORT); |
| 1047 |
|
} |
| 1032 |
– |
/* check date on ambient file */ |
| 1033 |
– |
if (vdef(AMBFILE)) { |
| 1034 |
– |
long afdate = fdate(vval(AMBFILE)); |
| 1035 |
– |
if (afdate >= 0 & octreedate > afdate) |
| 1036 |
– |
rmfile(vval(AMBFILE)); |
| 1037 |
– |
} |
| 1048 |
|
/* do each view */ |
| 1049 |
|
vn = 0; |
| 1050 |
|
while ((vw = getview(vn++, vs)) != NULL) { |
| 1129 |
|
return(0); |
| 1130 |
|
return(unlink(fn)); |
| 1131 |
|
} |
| 1132 |
+ |
|
| 1133 |
+ |
|
| 1134 |
+ |
#ifdef MSDOS |
| 1135 |
+ |
setenv(vname, value) /* set an environment variable */ |
| 1136 |
+ |
char *vname, *value; |
| 1137 |
+ |
{ |
| 1138 |
+ |
register char *evp; |
| 1139 |
+ |
|
| 1140 |
+ |
evp = bmalloc(strlen(vname)+strlen(value)+2); |
| 1141 |
+ |
if (evp == NULL) |
| 1142 |
+ |
syserr(progname); |
| 1143 |
+ |
sprintf(evp, "%s=%s", vname, value); |
| 1144 |
+ |
if (putenv(evp) != 0) { |
| 1145 |
+ |
fprintf(stderr, "%s: out of environment space\n", progname); |
| 1146 |
+ |
exit(1); |
| 1147 |
+ |
} |
| 1148 |
+ |
if (!silent) |
| 1149 |
+ |
printf("set %s\n", evp); |
| 1150 |
+ |
} |
| 1151 |
+ |
#endif |
| 1152 |
|
|
| 1153 |
|
|
| 1154 |
|
badvalue(vc) /* report bad variable value and exit */ |