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

Defined functions

fplt defined in line 52; used 2 times
getsi defined in line 123; used 23 times
getstr defined in line 132; used 2 times
main defined in line 21; never used

Defined variables

deltx defined in line 18; used 1 times
  • in line 29
delty defined in line 19; used 1 times
  • in line 32
sccsid defined in line 2; never used
Last modified: 1985-01-09
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1189
Valid CSS Valid XHTML 1.0 Strict