added "more" command
[unix-history] / usr / src / usr.bin / plot / driver.c
CommitLineData
b0fb34bd 1#ifndef lint
e24c105d 2static char sccsid[] = "@(#)driver.c 4.3 (Berkeley) %G%";
b0fb34bd
SL
3#endif
4
5#include <stdio.h>
6
7float deltx;
8float delty;
9
10main(argc,argv) char **argv; {
11 int std=1;
12 FILE *fin;
13
14 while(argc-- > 1) {
15 if(*argv[1] == '-')
16 switch(argv[1][1]) {
17 case 'l':
18 deltx = atoi(&argv[1][2]) - 1;
19 break;
20 case 'w':
21 delty = atoi(&argv[1][2]) - 1;
22 break;
23 }
24
25 else {
26 std = 0;
27 if ((fin = fopen(argv[1], "r")) == NULL) {
28 fprintf(stderr, "can't open %s\n", argv[1]);
29 exit(1);
30 }
31 fplt(fin);
f1c69d41 32 fclose(fin);
b0fb34bd
SL
33 }
34 argv++;
35 }
36 if (std)
37 fplt( stdin );
38 exit(0);
39 }
40
41
42fplt(fin) FILE *fin; {
43 int c;
44 char s[256];
45 int xi,yi,x0,y0,x1,y1,r,dx,n,i;
46 int pat[256];
47
48 openpl();
49 while((c=getc(fin)) != EOF){
50 switch(c){
51 case 'm':
52 xi = getsi(fin);
53 yi = getsi(fin);
54 move(xi,yi);
55 break;
56 case 'l':
57 x0 = getsi(fin);
58 y0 = getsi(fin);
59 x1 = getsi(fin);
60 y1 = getsi(fin);
61 line(x0,y0,x1,y1);
62 break;
63 case 't':
e24c105d 64 getstr(s,fin);
b0fb34bd
SL
65 label(s);
66 break;
67 case 'e':
68 erase();
69 break;
70 case 'p':
71 xi = getsi(fin);
72 yi = getsi(fin);
73 point(xi,yi);
74 break;
75 case 'n':
76 xi = getsi(fin);
77 yi = getsi(fin);
78 cont(xi,yi);
79 break;
80 case 's':
81 x0 = getsi(fin);
82 y0 = getsi(fin);
83 x1 = getsi(fin);
84 y1 = getsi(fin);
85 space(x0,y0,x1,y1);
86 break;
87 case 'a':
88 xi = getsi(fin);
89 yi = getsi(fin);
90 x0 = getsi(fin);
91 y0 = getsi(fin);
92 x1 = getsi(fin);
93 y1 = getsi(fin);
94 arc(xi,yi,x0,y0,x1,y1);
95 break;
96 case 'c':
97 xi = getsi(fin);
98 yi = getsi(fin);
99 r = getsi(fin);
100 circle(xi,yi,r);
101 break;
102 case 'f':
e24c105d 103 getstr(s,fin);
b0fb34bd
SL
104 linemod(s);
105 break;
106 case 'd':
107 xi = getsi(fin);
108 yi = getsi(fin);
109 dx = getsi(fin);
110 n = getsi(fin);
111 for(i=0; i<n; i++)pat[i] = getsi(fin);
112 dot(xi,yi,dx,n,pat);
113 break;
114 }
115 }
116 closepl();
117 }
118getsi(fin) FILE *fin; { /* get an integer stored in 2 ascii bytes. */
119 short a, b;
120 if((b = getc(fin)) == EOF)
121 return(EOF);
122 if((a = getc(fin)) == EOF)
123 return(EOF);
124 a = a<<8;
125 return(a|b);
126}
e24c105d 127getstr(s,fin) char *s; FILE *fin; {
b0fb34bd
SL
128 for( ; *s = getc(fin); s++)
129 if(*s == '\n')
130 break;
131 *s = '\0';
b0fb34bd 132}