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]) |
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 */ |
845 |
|
ofun[PAT_CTEXT].funp = |
846 |
|
ofun[PAT_BTEXT].funp = |
847 |
|
ofun[MIX_TEXT].funp = text; |
848 |
< |
ofun[ALIAS].funp = alias; |
848 |
> |
ofun[MOD_ALIAS].funp = alias; |
849 |
|
/* surface inverses */ |
850 |
|
tinvers[OBJ_FACE] = OBJ_FACE; |
851 |
|
tinvers[OBJ_SOURCE] = OBJ_SOURCE; |
887 |
|
openmain(iname) /* open input, changing directory for file */ |
888 |
|
char *iname; |
889 |
|
{ |
890 |
< |
static char origdir[MAXPATH]; |
891 |
< |
static char curfn[MAXPATH]; |
890 |
> |
static char origdir[PATH_MAX]; |
891 |
> |
static char curfn[PATH_MAX]; |
892 |
|
static int diffdir; |
893 |
|
register char *fpath; |
894 |
|
|
914 |
|
return; |
915 |
|
} |
916 |
|
if (mainfp == NULL) { /* first call, initialize */ |
917 |
< |
getwd(origdir); |
917 |
> |
getcwd(origdir, sizeof(origdir)); |
918 |
|
} else if (!strcmp(iname, curfn)) { /* just need to rewind? */ |
919 |
|
rewind(mainfp); |
920 |
|
return; |
928 |
|
} |
929 |
|
strcpy(curfn, iname); /* remember input name */ |
930 |
|
/* get full path for file */ |
931 |
< |
if ((fpath = getpath(iname, getlibpath(), R_OK)) == NULL) { |
931 |
> |
if ((fpath = getpath(iname, getrlibpath(), R_OK)) == NULL) { |
932 |
|
fprintf(stderr, "%s: cannot find file \"%s\"\n", |
933 |
|
progname, iname); |
934 |
|
exit(1); |