1 /*- 2 * %sccs.include.proprietary.c% 3 */ 4 5 #ifndef lint 6 static char sccsid[] = "@(#)crtdriver.c 4.3 (Berkeley) 04/18/91"; 7 #endif /* not lint */ 8 9 /* 10 This driver is used with crtplot.c. 11 It is essentially the same driver as the one in /usr/src/cmd/plot. 12 Unfortunately, the curses library has some of the same names as does 13 as the functions that the driver calls. These have been changed. 14 15 Also, one of the commands has been removed since they don't make sense 16 for crt's. 17 */ 18 19 20 #include <stdio.h> 21 22 float deltx; 23 float delty; 24 25 main(argc,argv) char **argv; { 26 int std=1; 27 FILE *fin; 28 29 while(argc-- > 1) { 30 if(*argv[1] == '-') 31 switch(argv[1][1]) { 32 case 'l': 33 deltx = atoi(&argv[1][2]) - 1; 34 break; 35 case 'w': 36 delty = atoi(&argv[1][2]) - 1; 37 break; 38 } 39 40 else { 41 std = 0; 42 if ((fin = fopen(argv[1], "r")) == NULL) { 43 fprintf(stderr, "can't open %s\n", argv[1]); 44 exit(1); 45 } 46 fplt(fin); 47 } 48 argv++; 49 } 50 if (std) 51 fplt( stdin ); 52 exit(0); 53 } 54 55 56 fplt(fin) FILE *fin; { 57 int c; 58 char s[256]; 59 int xi,yi,x0,y0,x1,y1,r/*,dx,n,i*/; 60 /*int pat[256];*/ 61 62 openpl(); 63 while((c=getc(fin)) != EOF){ 64 switch(c){ 65 case 'm': 66 xi = getsi(fin); 67 yi = getsi(fin); 68 plot_move(xi,yi); 69 break; 70 case 'l': 71 x0 = getsi(fin); 72 y0 = getsi(fin); 73 x1 = getsi(fin); 74 y1 = getsi(fin); 75 line(x0,y0,x1,y1); 76 break; 77 case 't': 78 getstr(s,fin); 79 label(s); 80 break; 81 case 'e': 82 plot_erase(); 83 break; 84 case 'p': 85 xi = getsi(fin); 86 yi = getsi(fin); 87 point(xi,yi); 88 break; 89 case 'n': 90 xi = getsi(fin); 91 yi = getsi(fin); 92 cont(xi,yi); 93 break; 94 case 's': 95 x0 = getsi(fin); 96 y0 = getsi(fin); 97 x1 = getsi(fin); 98 y1 = getsi(fin); 99 space(x0,y0,x1,y1); 100 break; 101 case 'a': 102 xi = getsi(fin); 103 yi = getsi(fin); 104 x0 = getsi(fin); 105 y0 = getsi(fin); 106 x1 = getsi(fin); 107 y1 = getsi(fin); 108 arc(xi,yi,x0,y0,x1,y1); 109 break; 110 case 'c': 111 xi = getsi(fin); 112 yi = getsi(fin); 113 r = getsi(fin); 114 circle(xi,yi,r); 115 break; 116 case 'f': 117 getstr(s,fin); 118 linemod(s); 119 break; 120 default: 121 fprintf(stderr, "Unknown command %c (%o)\n", c, c); 122 break; 123 } 124 } 125 closepl(); 126 } 127 getsi(fin) FILE *fin; { /* get an integer stored in 2 ascii bytes. */ 128 short a, b; 129 if((b = getc(fin)) == EOF) 130 return(EOF); 131 if((a = getc(fin)) == EOF) 132 return(EOF); 133 a = a<<8; 134 return(a|b); 135 } 136 getstr(s,fin) char *s; FILE *fin; { 137 for( ; *s = getc(fin); s++) 138 if(*s == '\n') 139 break; 140 *s = '\0'; 141 } 142