1 |
|
#ifndef lint |
2 |
< |
static const char RCSid[] = "$Id$"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
4 |
|
/* |
5 |
|
* xform.c - program to transform object files. |
9 |
|
* 11/6/86 Finally added error checking! |
10 |
|
*/ |
11 |
|
|
12 |
– |
#include "standard.h" |
13 |
– |
|
14 |
– |
#include "paths.h" |
15 |
– |
|
12 |
|
#include <ctype.h> |
13 |
|
|
14 |
+ |
#include "platform.h" |
15 |
+ |
#include "rtmath.h" |
16 |
+ |
#include "rtprocess.h" /* win_popen() */ |
17 |
+ |
#include "paths.h" |
18 |
|
#include "object.h" |
19 |
– |
|
19 |
|
#include "otypes.h" |
20 |
|
|
21 |
|
int xac; /* global xform argument count */ |
33 |
|
|
34 |
|
char *idprefix; /* prefix for object identifiers */ |
35 |
|
|
36 |
< |
#define ALIAS NUMOTYPE /* put alias at end of array */ |
36 |
> |
FUN ofun[NUMOTYPE] = INIT_OTYPE; /* default types and actions */ |
37 |
|
|
39 |
– |
#define NUMTYPES (NUMOTYPE+1) /* total number of object types */ |
40 |
– |
|
41 |
– |
FUN ofun[NUMTYPES] = INIT_OTYPE; /* default types and actions */ |
42 |
– |
|
38 |
|
short tinvers[NUMOTYPE]; /* inverse types for surfaces */ |
39 |
|
|
40 |
|
int nrept = 1; /* number of array repetitions */ |
41 |
|
|
42 |
|
int stdinused = 0; /* stdin has been used by -f option? */ |
43 |
|
|
44 |
< |
char mainfn[MAXPATH]; /* main file name */ |
44 |
> |
char mainfn[PATH_MAX]; /* main file name */ |
45 |
|
FILE *mainfp = NULL; /* main file pointer */ |
46 |
|
|
47 |
|
#define progname (xav[0]) |
73 |
|
if (argv[a][0] == '-') |
74 |
|
switch (argv[a][1]) { |
75 |
|
case 'm': |
76 |
< |
if (argv[a][2] | a+1 >= argc) |
76 |
> |
if (argv[a][2] | (a+1 >= argc)) |
77 |
|
break; |
78 |
|
a++; |
79 |
|
if (newmod == NULL) |
80 |
|
newmod = argv[a]; |
81 |
|
continue; |
82 |
|
case 'n': |
83 |
< |
if (argv[a][2] | a+1 >= argc) |
83 |
> |
if (argv[a][2] | (a+1 >= argc)) |
84 |
|
break; |
85 |
|
a++; |
86 |
|
if (idprefix == NULL) |
122 |
|
|
123 |
|
a += xf(&tot, argc-a, argv+a); |
124 |
|
|
125 |
< |
if (reverse = tot.sca < 0.0) |
125 |
> |
if ( (reverse = tot.sca < 0.0) ) |
126 |
|
tot.sca = -tot.sca; |
127 |
|
if (invert) |
128 |
|
reverse = !reverse; |
221 |
|
skipspaces: |
222 |
|
while (isspace(*cp)) /* nullify spaces */ |
223 |
|
*cp++ = '\0'; |
224 |
< |
if ((*cp == '"' | *cp == '\'')) |
224 |
> |
if ((*cp == '"') | (*cp == '\'')) |
225 |
|
inquote = *cp++; |
226 |
|
if (!*cp) /* all done? */ |
227 |
|
break; |
487 |
|
} |
488 |
|
|
489 |
|
|
495 |
– |
int |
496 |
– |
otype(ofname) /* get object function number from its name */ |
497 |
– |
register char *ofname; |
498 |
– |
{ |
499 |
– |
register int i; |
500 |
– |
|
501 |
– |
for (i = 0; i < NUMTYPES; i++) |
502 |
– |
if (!strcmp(ofun[i].funame, ofname)) |
503 |
– |
return(i); |
504 |
– |
|
505 |
– |
return(-1); /* not found */ |
506 |
– |
} |
507 |
– |
|
508 |
– |
|
490 |
|
alias(fin) /* transfer alias */ |
491 |
|
FILE *fin; |
492 |
|
{ |
823 |
|
|
824 |
|
if (ofun[OBJ_SOURCE].funp == o_source) |
825 |
|
return; /* done already */ |
845 |
– |
/* alias is additional */ |
846 |
– |
ofun[ALIAS].funame = ALIASID; |
847 |
– |
ofun[ALIAS].flags = 0; |
826 |
|
/* functions get new transform */ |
827 |
< |
for (i = 0; i < NUMTYPES; i++) |
827 |
> |
for (i = 0; i < NUMOTYPE; i++) |
828 |
|
if (hasfunc(i)) |
829 |
|
ofun[i].funp = addxform; |
830 |
|
/* special cases */ |
837 |
|
ofun[OBJ_CYLINDER].funp = |
838 |
|
ofun[OBJ_TUBE].funp = o_cylinder; |
839 |
|
ofun[OBJ_RING].funp = o_ring; |
840 |
< |
ofun[OBJ_INSTANCE].funp = addxform; |
840 |
> |
ofun[OBJ_INSTANCE].funp = |
841 |
> |
ofun[OBJ_MESH].funp = addxform; |
842 |
|
ofun[MAT_GLOW].funp = m_glow; |
843 |
|
ofun[MAT_SPOT].funp = m_spot; |
844 |
|
ofun[MAT_DIELECTRIC].funp = m_dielectric; |
847 |
|
ofun[PAT_CTEXT].funp = |
848 |
|
ofun[PAT_BTEXT].funp = |
849 |
|
ofun[MIX_TEXT].funp = text; |
850 |
< |
ofun[ALIAS].funp = alias; |
850 |
> |
ofun[MOD_ALIAS].funp = alias; |
851 |
|
/* surface inverses */ |
852 |
|
tinvers[OBJ_FACE] = OBJ_FACE; |
853 |
|
tinvers[OBJ_SOURCE] = OBJ_SOURCE; |
889 |
|
openmain(iname) /* open input, changing directory for file */ |
890 |
|
char *iname; |
891 |
|
{ |
892 |
< |
static char origdir[MAXPATH]; |
893 |
< |
static char curfn[MAXPATH]; |
892 |
> |
static char origdir[PATH_MAX]; |
893 |
> |
static char curfn[PATH_MAX]; |
894 |
|
static int diffdir; |
895 |
|
register char *fpath; |
896 |
|
|
916 |
|
return; |
917 |
|
} |
918 |
|
if (mainfp == NULL) { /* first call, initialize */ |
919 |
< |
getwd(origdir); |
919 |
> |
getcwd(origdir, sizeof(origdir)); |
920 |
|
} else if (!strcmp(iname, curfn)) { /* just need to rewind? */ |
921 |
|
rewind(mainfp); |
922 |
|
return; |
930 |
|
} |
931 |
|
strcpy(curfn, iname); /* remember input name */ |
932 |
|
/* get full path for file */ |
933 |
< |
if ((fpath = getpath(iname, getlibpath(), R_OK)) == NULL) { |
933 |
> |
if ((fpath = getpath(iname, getrlibpath(), R_OK)) == NULL) { |
934 |
|
fprintf(stderr, "%s: cannot find file \"%s\"\n", |
935 |
|
progname, iname); |
936 |
|
exit(1); |