97cb5d8710fcda56f784c76459188757d7e9078b
/* main.c (Berkeley) 1.6 83/12/19 */
#define DEVDIR "/usr/lib/font" /* place to look up device files */
char *dev
= "va"; /* default typesetter is varian */
struct obj
*objlist
[MAXOBJ
]; /* store the elements here */
struct attr attr
[40]; /* attributes stored here as collected */
int nattr
= 0; /* number of entries in attr_list */
struct text text
[MAXTEXT
]; /* text strings stored here as collected */
int ntext1
= 0; /* record ntext here on entry to each figure */
int hvmode
= R_DIR
; /* R => join left to right, D => top to bottom, etc. */
int codegen
= 0; /* 1=>output for this picture; 0=>no output */
float deltx
= 6.0; /* max x value in output, for scaling */
float delty
= 6.0; /* max y value in output, for scaling */
float xbound
= 8.0; /* max allowed x value in output */
float ybound
= 10.0; /* max allowed y value in output */
extern FILE *yyin
, /* input file pointer */
*skeldb
; /* output pointer for dbg messeges */
int crop
= 1; /* trim off exterior white space if non-zero */
extern int useDline
; /* if set, use \D for all lines */
int res
; /* resolution of output device (dots/inch) */
int DX
; /* smallest change in X, and Y for output device */
float hshift
= 0; /* move this far left for text (in em's) */
float vshift
= 0.2; /* this far down */
float sxmin
; /* lower limit from s command */
float sxmax
= 4096; /* upper */
float xmin
= 30000; /* min values found in actual data */
float xmax
= -30000; /* max */
while (argc
> 1 && *argv
[1] == '-') {
xbound
= atof(&argv
[1][2]);
ybound
= atof(&argv
[1][2]);
if ((yyin
= fopen(*++argv
, "r")) == NULL
) {
fprintf(stderr
, "pic: can't open %s\n", *argv
);
sprintf(temp
, "%s/dev%s/DESC.out", devdir
, dev
);
if ((fin
= open(temp
, 0)) < 0) {
fprintf(stderr
, "can't open tables for %s\n", temp
);
read(fin
, &device
, sizeof(struct dev
));
setdefaults() /* set default sizes for variables like boxht */
for (i
= 0; defaults
[i
].name
!= NULL
; i
++) {
makevar(tostring(defaults
[i
].name
), VARNAME
, v
);
checkscale(s
) /* if s is "scale", adjust default variables */
if (strcmp(s
, "scale") == 0) {
scale
= getfval("scale");
for (i
= 1; defaults
[i
].name
!= NULL
; i
++)
setfval(defaults
[i
].name
, defaults
[i
].val
* scale
);
char buf
[1000], buf1
[50];
while (fgets(buf
, sizeof buf
, fin
) != NULL
) {
if (*buf
== '.' && *(buf
+1) == 'P' && *(buf
+2) == 'S') {
for (p
= &buf
[3]; *p
== ' '; p
++)
if ((yyin
= fopen(buf1
, "r")) == NULL
) {
fprintf(stderr
, "pic: can't open %s\n", buf1
);
/* yylval now contains 'E' or 'F' from .PE or .PF */
if (buf
[3] == ' ') /* assume next thing is width */
deltx
= delty
= atof(&buf
[4]);
deltx
/= getfval("scale");
dprintf("deltx = %.3f\n", deltx
);
if (codegen
&& !synerr
) {
openpl(&buf
[3]); /* puts out .PS, with ht & wid stuck in */
print(); /* assumes \n at end */
closepl(yylval
.p
); /* does the .PE/F */
for (i
= 0; i
< nobj
; i
++) {
freesymtab(op
->o_dotdash
); /* funny place */
for (i
= 0; i
< ntext
; i
++)