1: #ifndef lint
   2: static char sccsid[] = "@(#)driver.c	4.4 (Berkeley) 9/21/85";
   3: #endif
   4: 
   5: #include <stdio.h>
   6: 
   7: float deltx;
   8: float delty;
   9: int PlotRes;
  10: 
  11: main(argc,argv)
  12:     int argc;
  13:     char *argv[];
  14: {
  15:     int std = 1;
  16:     char *progname;
  17:     FILE *fin;
  18: 
  19:     progname = argv[0];
  20:     for (argc--, argv++; argc > 0; argc--, argv++) {
  21:         if (argv[0][0] == '-') {
  22:             switch (argv[0][1]) {
  23:             case 'l':
  24:                 deltx = atoi(&argv[0][2]) - 1;
  25:                 break;
  26:             case 'w':
  27:                 delty = atoi(&argv[0][2]) - 1;
  28:                 break;
  29:             case 'r':
  30:                 PlotRes = atoi(&argv[0][2]);
  31:                 break;
  32:             }
  33:             continue;
  34:         }
  35:         std = 0;
  36:         fin = fopen(argv[0], "r");
  37:         if (fin == NULL) {
  38:             fprintf(stderr, "%s: can't open %s\n", progname,
  39:                 argv[0]);
  40:             exit(1);
  41:         }
  42:         fplt(fin);
  43:         fclose(fin);
  44:     }
  45:     if (std)
  46:         fplt(stdin);
  47:     exit(0);
  48: }
  49: 
  50: fplt(fin)
  51:     FILE *fin;
  52: {
  53:     register 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:             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:             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:         case 'd':
 117:             xi = getsi(fin);
 118:             yi = getsi(fin);
 119:             dx = getsi(fin);
 120:             n = getsi(fin);
 121:             for(i=0; i<n; i++)
 122:                 pat[i] = getsi(fin);
 123:             dot(xi,yi,dx,n,pat);
 124:             break;
 125:         }
 126:     }
 127:     closepl();
 128: }
 129: 
 130: /* get an integer stored in 2 ascii bytes. */
 131: getsi(fin)
 132:     register FILE *fin;
 133: {
 134:     short a, b;
 135: 
 136:     if((b = getc(fin)) == EOF)
 137:         return(EOF);
 138:     if((a = getc(fin)) == EOF)
 139:         return(EOF);
 140:     a = a<<8;
 141:     return(a|b);
 142: }
 143: 
 144: getstr(s, fin)
 145:     register char *s;
 146:     register FILE *fin;
 147: {
 148: 
 149:     for( ; *s = getc(fin); s++)
 150:         if(*s == '\n')
 151:             break;
 152:     *s = '\0';
 153: }

Defined functions

fplt defined in line 50; used 2 times
getsi defined in line 131; used 28 times
getstr defined in line 144; used 2 times
main defined in line 11; never used

Defined variables

PlotRes defined in line 9; used 1 times
  • in line 30
deltx defined in line 7; used 1 times
  • in line 24
delty defined in line 8; used 1 times
  • in line 27
sccsid defined in line 2; never used
Last modified: 1985-11-11
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1149
Valid CSS Valid XHTML 1.0 Strict