1: #ifndef lint
   2: static char sccsid[] = "@(#)atoplot.c	4.2 (Berkeley) 1/9/85";
   3: #endif
   4: 
   5: #include <stdio.h>
   6: 
   7: float deltx;
   8: float delty;
   9: 
  10: char    *mapLineType();
  11: 
  12: main(argc,argv)  char **argv; {
  13:     int std=1;
  14:     FILE *fin;
  15: 
  16:     while(argc-- > 1) {
  17:         if(*argv[1] == '-')
  18:             switch(argv[1][1]) {
  19:                 case 'l':
  20:                     deltx = atoi(&argv[1][2]) - 1;
  21:                     break;
  22:                 case 'w':
  23:                     delty = atoi(&argv[1][2]) - 1;
  24:                     break;
  25:                 }
  26: 
  27:         else {
  28:             std = 0;
  29:             if ((fin = fopen(argv[1], "r")) == NULL) {
  30:                 fprintf(stderr, "can't open %s\n", argv[1]);
  31:                 exit(1);
  32:                 }
  33:             fplt(fin);
  34:             fclose(fin);
  35:             }
  36:         argv++;
  37:         }
  38:     if (std)
  39:         fplt( stdin );
  40:     exit(0);
  41:     }
  42: 
  43: 
  44: fplt(fin)  FILE *fin; {
  45:     int c;
  46:     char s[256];
  47:     int xi,yi,x0,y0,x1,y1,r,dx,n,i;
  48:     int pat[256];
  49: 
  50:     openpl();
  51:     while((c=getc(fin)) != EOF){
  52:         switch(c){
  53:         case 'm':
  54:             xi = getsi(fin);
  55:             yi = getsi(fin);
  56:             move(xi,yi);
  57:             break;
  58:         case 'l':
  59:             x0 = getsi(fin);
  60:             y0 = getsi(fin);
  61:             x1 = getsi(fin);
  62:             y1 = getsi(fin);
  63:             line(x0,y0,x1,y1);
  64:             break;
  65:         case 't':
  66:             getstr(s,fin);
  67:             label(s);
  68:             break;
  69:         case 'e':
  70:             erase();
  71:             break;
  72:         case 'p':
  73:             xi = getsi(fin);
  74:             yi = getsi(fin);
  75:             point(xi,yi);
  76:             break;
  77:         case 'n':
  78:             xi = getsi(fin);
  79:             yi = getsi(fin);
  80:             cont(xi,yi);
  81:             break;
  82:         case 's':
  83:             x0 = getsi(fin);
  84:             y0 = getsi(fin);
  85:             x1 = getsi(fin);
  86:             y1 = getsi(fin);
  87:             space(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:             arc(xi,yi,x0,y0,x1,y1);
  97:             break;
  98:         case 'c':
  99:             xi = getsi(fin);
 100:             yi = getsi(fin);
 101:             r = getsi(fin);
 102:             circle(xi,yi,r);
 103:             break;
 104:         case 'f':
 105:             getstr(s,fin);
 106:             linemod( mapLineType(s) );
 107:             break;
 108:         case 'd':
 109:             xi = getsi(fin);
 110:             yi = getsi(fin);
 111:             dx = getsi(fin);
 112:             n = getsi(fin);
 113:             for(i=0; i<n; i++)pat[i] = getsi(fin);
 114:             dot(xi,yi,dx,n,pat);
 115:             break;
 116:             }
 117:         /* scan to newline */
 118:         while( (c = getc( fin )) != '\n' ) {
 119:             if ( c == EOF ) {
 120:                 break;
 121:             }
 122:             }
 123:         }
 124:     closepl();
 125:     }
 126: getsi(fin)  FILE *fin; {    /* get an integer stored in 2 ascii bytes. */
 127:     int i;
 128: 
 129:     if ( fscanf(fin, " %d", & i) != 1 ) {
 130:         return(EOF);
 131:     }
 132:     return( i );
 133: }
 134: getstr(s,fin)  char *s;  FILE *fin; {
 135:     for( ; *s = getc(fin); s++)
 136:         if(*s == '\n')
 137:             break;
 138:     *s = '\0';
 139: }
 140: 
 141: char    *lineMap[] = {
 142:     "solid",        /* line type 0 */
 143:     "solid",        /* line type 1 */
 144:     "dotted",       /* line type 2 */
 145:     "dotdashed",    /* line type 3 */
 146:     "shortdashed",  /* line type 4 */
 147:     "longdashed",   /* line type 5 */
 148:     "dotlongdash",  /* line type 6 */
 149:     "dotshortdash", /* line type 7 */
 150:     "dotdotdash",   /* line type 8 */
 151: }   ;
 152: 
 153: char *
 154: mapLineType( cp )
 155:     char    *cp;
 156: {
 157:     int     i;
 158: 
 159:     if ( sscanf(cp, "%d", &i) == 1 ) {
 160:     if ( i < 0 || i > sizeof(lineMap)/sizeof(char *) ) {
 161:         i = 1;
 162:     }
 163:     return( lineMap[i] );
 164:     }
 165:     else {
 166:     return( cp );
 167:     }
 168: }

Defined functions

fplt defined in line 44; used 2 times
getsi defined in line 126; used 28 times
getstr defined in line 134; used 2 times
main defined in line 12; never used
mapLineType defined in line 153; used 2 times

Defined variables

deltx defined in line 7; used 1 times
  • in line 20
delty defined in line 8; used 1 times
  • in line 23
lineMap defined in line 141; used 2 times
sccsid defined in line 2; never used
Last modified: 1987-02-17
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2653
Valid CSS Valid XHTML 1.0 Strict