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 "standard.h" |
15 |
+ |
#include "platform.h" |
16 |
+ |
#include "paths.h" |
17 |
|
#include "object.h" |
19 |
– |
|
18 |
|
#include "otypes.h" |
19 |
|
|
20 |
|
int xac; /* global xform argument count */ |
32 |
|
|
33 |
|
char *idprefix; /* prefix for object identifiers */ |
34 |
|
|
35 |
< |
#define ALIAS NUMOTYPE /* put alias at end of array */ |
35 |
> |
FUN ofun[NUMOTYPE] = INIT_OTYPE; /* default types and actions */ |
36 |
|
|
39 |
– |
#define NUMTYPES (NUMOTYPE+1) /* total number of object types */ |
40 |
– |
|
41 |
– |
FUN ofun[NUMTYPES] = INIT_OTYPE; /* default types and actions */ |
42 |
– |
|
37 |
|
short tinvers[NUMOTYPE]; /* inverse types for surfaces */ |
38 |
|
|
39 |
|
int nrept = 1; /* number of array repetitions */ |
40 |
|
|
41 |
|
int stdinused = 0; /* stdin has been used by -f option? */ |
42 |
|
|
43 |
< |
char mainfn[MAXPATH]; /* main file name */ |
43 |
> |
char mainfn[PATH_MAX]; /* main file name */ |
44 |
|
FILE *mainfp = NULL; /* main file pointer */ |
45 |
|
|
46 |
|
#define progname (xav[0]) |
72 |
|
if (argv[a][0] == '-') |
73 |
|
switch (argv[a][1]) { |
74 |
|
case 'm': |
75 |
< |
if (argv[a][2] | a+1 >= argc) |
75 |
> |
if (argv[a][2] | (a+1 >= argc)) |
76 |
|
break; |
77 |
|
a++; |
78 |
|
if (newmod == NULL) |
79 |
|
newmod = argv[a]; |
80 |
|
continue; |
81 |
|
case 'n': |
82 |
< |
if (argv[a][2] | a+1 >= argc) |
82 |
> |
if (argv[a][2] | (a+1 >= argc)) |
83 |
|
break; |
84 |
|
a++; |
85 |
|
if (idprefix == NULL) |
121 |
|
|
122 |
|
a += xf(&tot, argc-a, argv+a); |
123 |
|
|
124 |
< |
if (reverse = tot.sca < 0.0) |
124 |
> |
if ( (reverse = tot.sca < 0.0) ) |
125 |
|
tot.sca = -tot.sca; |
126 |
|
if (invert) |
127 |
|
reverse = !reverse; |
220 |
|
skipspaces: |
221 |
|
while (isspace(*cp)) /* nullify spaces */ |
222 |
|
*cp++ = '\0'; |
223 |
< |
if ((*cp == '"' | *cp == '\'')) |
223 |
> |
if ((*cp == '"') | (*cp == '\'')) |
224 |
|
inquote = *cp++; |
225 |
|
if (!*cp) /* all done? */ |
226 |
|
break; |
486 |
|
} |
487 |
|
|
488 |
|
|
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 |
– |
|
489 |
|
alias(fin) /* transfer alias */ |
490 |
|
FILE *fin; |
491 |
|
{ |
822 |
|
|
823 |
|
if (ofun[OBJ_SOURCE].funp == o_source) |
824 |
|
return; /* done already */ |
845 |
– |
/* alias is additional */ |
846 |
– |
ofun[ALIAS].funame = ALIASID; |
847 |
– |
ofun[ALIAS].flags = 0; |
825 |
|
/* functions get new transform */ |
826 |
< |
for (i = 0; i < NUMTYPES; i++) |
826 |
> |
for (i = 0; i < NUMOTYPE; i++) |
827 |
|
if (hasfunc(i)) |
828 |
|
ofun[i].funp = addxform; |
829 |
|
/* special cases */ |
836 |
|
ofun[OBJ_CYLINDER].funp = |
837 |
|
ofun[OBJ_TUBE].funp = o_cylinder; |
838 |
|
ofun[OBJ_RING].funp = o_ring; |
839 |
< |
ofun[OBJ_INSTANCE].funp = addxform; |
839 |
> |
ofun[OBJ_INSTANCE].funp = |
840 |
> |
ofun[OBJ_MESH].funp = addxform; |
841 |
|
ofun[MAT_GLOW].funp = m_glow; |
842 |
|
ofun[MAT_SPOT].funp = m_spot; |
843 |
|
ofun[MAT_DIELECTRIC].funp = m_dielectric; |
846 |
|
ofun[PAT_CTEXT].funp = |
847 |
|
ofun[PAT_BTEXT].funp = |
848 |
|
ofun[MIX_TEXT].funp = text; |
849 |
< |
ofun[ALIAS].funp = alias; |
849 |
> |
ofun[MOD_ALIAS].funp = alias; |
850 |
|
/* surface inverses */ |
851 |
|
tinvers[OBJ_FACE] = OBJ_FACE; |
852 |
|
tinvers[OBJ_SOURCE] = OBJ_SOURCE; |
888 |
|
openmain(iname) /* open input, changing directory for file */ |
889 |
|
char *iname; |
890 |
|
{ |
891 |
< |
static char origdir[MAXPATH]; |
892 |
< |
static char curfn[MAXPATH]; |
891 |
> |
static char origdir[PATH_MAX]; |
892 |
> |
static char curfn[PATH_MAX]; |
893 |
|
static int diffdir; |
894 |
|
register char *fpath; |
895 |
|
|
915 |
|
return; |
916 |
|
} |
917 |
|
if (mainfp == NULL) { /* first call, initialize */ |
918 |
< |
getwd(origdir); |
918 |
> |
getcwd(origdir, sizeof(origdir)); |
919 |
|
} else if (!strcmp(iname, curfn)) { /* just need to rewind? */ |
920 |
|
rewind(mainfp); |
921 |
|
return; |
929 |
|
} |
930 |
|
strcpy(curfn, iname); /* remember input name */ |
931 |
|
/* get full path for file */ |
932 |
< |
if ((fpath = getpath(iname, getlibpath(), R_OK)) == NULL) { |
932 |
> |
if ((fpath = getpath(iname, getrlibpath(), R_OK)) == NULL) { |
933 |
|
fprintf(stderr, "%s: cannot find file \"%s\"\n", |
934 |
|
progname, iname); |
935 |
|
exit(1); |