4.3BSD beta release manual page
[unix-history] / usr / src / usr.bin / plot / debug.c
CommitLineData
1de3ab2e 1#ifndef lint
e24c105d 2static char sccsid[] = "@(#)debug.c 4.2 (Berkeley) %G%";
1de3ab2e
RC
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);
32 }
33 argv++;
34 }
35 if (std)
36 fplt( stdin );
37 exit(0);
38 }
39
40
41fplt(fin) FILE *fin; {
42 int c;
43 char s[256];
44 int xi,yi,x0,y0,x1,y1,r/*,dx,n,i*/;
45
46 printf("openpl\n");
47 while((c=getc(fin)) != EOF){
48 switch(c){
49 case 'm':
50 xi = getsi(fin);
51 yi = getsi(fin);
52 printf("move %d %d\n", xi, yi);
53 break;
54 case 'l':
55 x0 = getsi(fin);
56 y0 = getsi(fin);
57 x1 = getsi(fin);
58 y1 = getsi(fin);
59 printf("line %d %d %d %d\n", x0, y0, x1, y1);
60 break;
61 case 't':
e24c105d 62 getstr(s,fin);
1de3ab2e
RC
63 printf("label %s\n", s);
64 break;
65 case 'e':
66 printf("erase\n");
67 break;
68 case 'p':
69 xi = getsi(fin);
70 yi = getsi(fin);
71 printf("point %d %d\n", xi, yi);
72 break;
73 case 'n':
74 xi = getsi(fin);
75 yi = getsi(fin);
76 printf("continue %d %d\n", xi, yi);
77 break;
78 case 's':
79 x0 = getsi(fin);
80 y0 = getsi(fin);
81 x1 = getsi(fin);
82 y1 = getsi(fin);
83 printf("space %d %d %d %d\n", x0, y0, x1, y1);
84 break;
85 case 'a':
86 xi = getsi(fin);
87 yi = getsi(fin);
88 x0 = getsi(fin);
89 y0 = getsi(fin);
90 x1 = getsi(fin);
91 y1 = getsi(fin);
92 printf("arc\n");
93 break;
94 case 'c':
95 xi = getsi(fin);
96 yi = getsi(fin);
97 r = getsi(fin);
98 printf("circle\n");
99 break;
100 case 'f':
e24c105d 101 getstr(s,fin);
1de3ab2e
RC
102 printf("linemod %s\n", s);
103 break;
104 default:
105 fprintf(stderr, "Unknown command %c (%o)\n", c, c);
106 break;
107 }
108 }
109 printf("closepl\n");
110 }
111getsi(fin) FILE *fin; { /* get an integer stored in 2 ascii bytes. */
112 short a, b;
113 if((b = getc(fin)) == EOF)
114 return(EOF);
115 if((a = getc(fin)) == EOF)
116 return(EOF);
117 a = a<<8;
118 return(a|b);
119}
e24c105d 120getstr(s,fin) char *s; FILE *fin; {
1de3ab2e
RC
121 for( ; *s = getc(fin); s++)
122 if(*s == '\n')
123 break;
124 *s = '\0';
1de3ab2e 125}