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