1*33667Sjaap#ifndef lint
2*33667Sjaapstatic char Notice[] = "Copyright (c) 1984, 1985 Adobe Systems Incorporated";
3*33667Sjaapstatic char *RCSID="$Header: psdit.c,v 2.1 85/11/24 11:50:41 shore Rel $";
4*33667Sjaap#endif
5*33667Sjaap# define XMOD
6*33667Sjaap/* psdit.c
7*33667Sjaap *
8*33667Sjaap * Copyright (c) 1984, 1985 Adobe Systems Incorporated
9*33667Sjaap
10*33667Sjaap.
11*33667Sjaap.
12*33667Sjaap.
13*33667Sjaap.
14*33667Sjaap
15*33667Sjaapprivate devcntrl(fp)	/* interpret device control functions */
16*33667SjaapFILE *fp;
17*33667Sjaap{
18*33667Sjaap    char    str[20], str1[50], buf[50];
19*33667Sjaap    int     c, n, res, minh, minv;
20*33667Sjaap
21*33667Sjaap    fscanf (fp, "%s", str);
22*33667Sjaap    switch (str[0]) {		/* crude for now */
23*33667Sjaap	case 'i': 		/* initialize */
24*33667Sjaap	    fileinit ();
25*33667Sjaap	    t_init ();
26*33667Sjaap.
27*33667Sjaap.
28*33667Sjaap.
29*33667Sjaap.
30*33667Sjaap.
31*33667Sjaap	    break;
32*33667Sjaap	case 'S': 		/* slant */
33*33667Sjaap	    fscanf (fp, "%d", &n);
34*33667Sjaap	    t_slant (n);
35*33667Sjaap	    lastcmd = FNT;
36*33667Sjaap	    break;
37*33667Sjaap#ifdef XMOD
38*33667Sjaap	case 'X': {		/* \X command from ditroff */
39*33667Sjaap            int last;
40*33667Sjaap	    char largebuf[128];
41*33667Sjaap	    fscanf (fp, "%1s", str);
42*33667Sjaap	    switch (str[0]) {
43*33667Sjaap		case 'p' :
44*33667Sjaap		    FlushShow(0);MoveTo();DoMove();
45*33667Sjaap		    fgets(largebuf, sizeof(largebuf), fp);
46*33667Sjaap		    last = strlen(largebuf) - 1;
47*33667Sjaap		    if (last >= 0 && largebuf[last] == '\n') {
48*33667Sjaap			ungetc('\n', fp);
49*33667Sjaap			largebuf[last] = ' ';
50*33667Sjaap		    }
51*33667Sjaap		    fputs(largebuf, tf);
52*33667Sjaap		    putc('\n', tf);
53*33667Sjaap		    break;
54*33667Sjaap		case 'f' :
55*33667Sjaap		    FlushShow(0);MoveTo();DoMove();
56*33667Sjaap		    if (fscanf(fp, "%s", largebuf) == 1) {
57*33667Sjaap			char *nl = (char *) index(largebuf, '\n');
58*33667Sjaap			if (nl) *nl = '\0';
59*33667Sjaap			includefile(largebuf);
60*33667Sjaap		    } else
61*33667Sjaap			fprintf(stderr, "warning - include cmd w/o path.\n");
62*33667Sjaap		    break;
63*33667Sjaap	    }
64*33667Sjaap	}
65*33667Sjaap	break;
66*33667Sjaap#endif
67*33667Sjaap    }
68*33667Sjaap    /* skip rest of input line */
69*33667Sjaap    while ((c = getc (fp)) != '\n') {if (c == EOF) break;};
70*33667Sjaap}
71*33667Sjaap
72*33667Sjaap#ifdef XMOD
73*33667Sjaapincludefile(filenm)
74*33667Sjaapchar *filenm; {
75*33667Sjaap
76*33667Sjaap	FILE *inf;
77*33667Sjaap	int ch, c1, c2, firstch = 0;
78*33667Sjaap
79*33667Sjaap	if (!(inf = fopen(filenm, "r"))) {
80*33667Sjaap		fprintf(stderr, "psdit: fopen(%s): ", filenm);
81*33667Sjaap		perror();
82*33667Sjaap		exit(1);
83*33667Sjaap	}
84*33667Sjaap	c1 = fgetc(inf); c2 = fgetc(inf);
85*33667Sjaap	if (c1 != '%' || c2 != '!')
86*33667Sjaap		fprintf(stderr, "psdit: %s not a postscript file.\n", filenm),
87*33667Sjaap		exit(1);
88*33667Sjaap
89*33667Sjaap	fputs("%!", tf);
90*33667Sjaap	while ((ch = fgetc(inf)) != EOF) {
91*33667Sjaap		fputc(ch, tf);
92*33667Sjaap		if (firstch && ch == '%') {
93*33667Sjaap			/* we have to double leading '%'s */
94*33667Sjaap			fputc('%', tf);
95*33667Sjaap		}
96*33667Sjaap		firstch = (ch == '\n');
97*33667Sjaap	}
98*33667Sjaap	fclose(inf);
99*33667Sjaap}
100*33667Sjaap#endif
101*33667Sjaapprivate fileinit()	/* read in font and code files, etc. */
102*33667Sjaap{
103*33667Sjaap
104*33667Sjaap.
105*33667Sjaap.
106*33667Sjaap.
107*33667Sjaap.
108