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