# 2.11BSD#431 - /usr/src/usr.bin/plot/plottoa.c

##### Functions

    arc               X
    circle            X
    closepl           X
    cont              X
    dot               X
    erase             X
    fplt              X
    getsi             X
    getstr            X
    label             X
    line              X
    linemod           X
    main              X
    move              X
    openpl            X
    point             X
    space             X

##### Variables

    deltx             X
    delty             X

       1: #ifndef lint
       2: static char sccsid[] = "@(#)plottoa.c	4.2 (Berkeley) 1/9/85";
       3: #endif
       4:
       5: /*
       6:  * Convert the standard plot input into a readable form for debugging.
       7:  */
       8:
       9: #include <stdio.h>
      10:
      11: float deltx;
      12: float delty;
      13:
      14: main(argc, argv)
      15: char **argv;
      16: {
      17:     int std=1;
      18:     FILE *fin;
      19:
      20:     while(argc-- > 1) {
      21:         if(*argv[1] == '-')
      22:             switch(argv[1][1]) {
      23:             case 'l':
      24:                 deltx = atoi(&argv[1][2]) - 1;
      25:                 break;
      26:             case 'w':
      27:                 delty = atoi(&argv[1][2]) - 1;
      28:                 break;
      29:             }
      30:         else {
      31:             std = 0;
      32:             if ((fin = fopen(argv[1], "r")) == NULL) {
      33:                 fprintf(stderr, "can't open %s\n", argv[1]);
      34:                 exit(1);
      35:             }
      36:             fplt(fin);
      37:             fclose(fin);
      38:         }
      39:         argv++;
      40:     }
      41:     if (std)
      42:         fplt( stdin );
      43:     exit(0);
      44: }
      45:
      46:
      47: fplt(fin)
      48: FILE *fin;
      49: {
      50:     int c;
      51:     char s[256];
      52:     int xi,yi,x0,y0,x1,y1,r,dx,n,i;
      53:     int pat[256];
      54:
      55:     openpl();
      56:     while((c = getc(fin)) != EOF){
      57:         switch(c){
      58:         case 'm':
      59:             xi = getsi(fin);
      60:             yi = getsi(fin);
      61:             move(xi,yi);
      62:             break;
      63:         case 'l':
      64:             x0 = getsi(fin);
      65:             y0 = getsi(fin);
      66:             x1 = getsi(fin);
      67:             y1 = getsi(fin);
      68:             line(x0,y0,x1,y1);
      69:             break;
      70:         case 't':
      71:             getstr(s,fin);
      72:             label(s);
      73:             break;
      74:         case 'e':
      75:             erase();
      76:             break;
      77:         case 'p':
      78:             xi = getsi(fin);
      79:             yi = getsi(fin);
      80:             point(xi,yi);
      81:             break;
      82:         case 'n':
      83:             xi = getsi(fin);
      84:             yi = getsi(fin);
      85:             cont(xi,yi);
      86:             break;
      87:         case 's':
      88:             x0 = getsi(fin);
      89:             y0 = getsi(fin);
      90:             x1 = getsi(fin);
      91:             y1 = getsi(fin);
      92:             space(x0,y0,x1,y1);
      93:             break;
      94:         case 'a':
      95:             xi = getsi(fin);
      96:             yi = getsi(fin);
      97:             x0 = getsi(fin);
      98:             y0 = getsi(fin);
      99:             x1 = getsi(fin);
     100:             y1 = getsi(fin);
     101:             arc(xi,yi,x0,y0,x1,y1);
     102:             break;
     103:         case 'c':
     104:             xi = getsi(fin);
     105:             yi = getsi(fin);
     106:             r = getsi(fin);
     107:             circle(xi,yi,r);
     108:             break;
     109:         case 'f':
     110:             getstr(s,fin);
     111:             linemod(s);
     112:             break;
     113:         case 'd':
     114:             xi = getsi(fin);
     115:             yi = getsi(fin);
     116:             dx = getsi(fin);
     117:             n = getsi(fin);
     118:             for(i=0; i<n; i++)pat[i] = getsi(fin);
     119:             dot(xi,yi,dx,n,pat);
     120:             break;
     121:         }
     122:     }
     123:     closepl();
     124: }
     125:
     126: /* get an integer stored in 2 ascii bytes. */
     127: getsi(fin)
     128: FILE *fin;
     129: {
     130:     short a, b;
     131:     if((b = getc(fin)) == EOF)
     132:         return(EOF);
     133:     if((a = getc(fin)) == EOF)
     134:         return(EOF);
     135:     a = a<<8;
     136:     return(a|b);
     137: }
     138:
     139: getstr(s,fin)
     140: char *s;
     141: FILE *fin;
     142: {
     143:     for( ; *s = getc(fin); s++)
     144:         if(*s == '\n')
     145:             break;
     146:     *s = '\0';
     147: }
     148:
     149: /* Print out the arguments to plot routines. */
     150:
     151: space(x0,y0,x1,y1)
     152: int x0,y0,x1,y1;
     153: {
     154:     printf( "s %d %d %d %d\n", x0, y0, x1, y1 );
     155: }
     156:
     157: openpl()
     158: {
     159: }
     160:
     161: closepl()
     162: {
     163: }
     164:
     165: erase()
     166: {
     167:     printf( "e\n" );
     168: }
     169:
     170: move(xi,yi)
     171: int xi,yi;
     172: {
     173:     printf( "m %d %d\n", xi, yi );
     174: }
     175:
     176: cont(xi,yi)
     177: int xi,yi;
     178: {
     179:     printf( "n %d %d\n", xi, yi );
     180: }
     181:
     182: line(x0,y0,x1,y1)
     183: int x0,y0,x1,y1;
     184: {
     185:     printf( "l %d %d %d %d\n", x0, y0, x1, y1 );
     186: }
     187:
     188: point(xi,yi)
     189: int xi,yi;
     190: {
     191:     printf( "p %d %d\n", xi, yi );
     192: }
     193:
     194: label(s)
     195: char *s;
     196: {
     197:     printf( "t%s\n\n", s );
     198: }
     199:
     200:
     201: arc(xcent,ycent,xbeg,ybeg,xend,yend)
     202: int xcent,ycent,xbeg,ybeg,xend,yend;
     203: {
     204:     printf( "a %d %d %d %d %d %d\n", xcent, ycent, xbeg, ybeg, xend, yend );
     205: }
     206:
     207: circle (xc,yc,r)
     208: int xc,yc,r;
     209: {
     210:     printf( "c %d %d %d\n", xc, yc, r );
     211: }
     212:
     213: linemod( line )
     214: char    *line;
     215: {
     216:     printf( "f%s\n\n", line );
     217: }
     218:
     219: /* don't know what this should do */
     220: dot(xi,yi,dx,n,pat)
     221: int xi,yi,dx,n;
     222: char *pat;
     223: {
     224:     printf("d %d %d %d %d %s\n\n", xi, yi, dx, n, pat);
     225: }

#### Defined functions

arc defined in line 201; used 4 times

- in line 101
- in /usr/src/usr.bin/plot/atoplot.c line 96
- in /usr/src/usr.bin/plot/crtdriver.c line 104
- in /usr/src/usr.bin/plot/driver.c line 104

circle defined in line 207; used 4 times

- in line 107
- in /usr/src/usr.bin/plot/atoplot.c line 102
- in /usr/src/usr.bin/plot/crtdriver.c line 110
- in /usr/src/usr.bin/plot/driver.c line 110

closepl defined in line 161; used 4 times

- in line 123
- in /usr/src/usr.bin/plot/atoplot.c line 124
- in /usr/src/usr.bin/plot/crtdriver.c line 121
- in /usr/src/usr.bin/plot/driver.c line 127

cont defined in line 176; used 4 times

- in line 85
- in /usr/src/usr.bin/plot/atoplot.c line 80
- in /usr/src/usr.bin/plot/crtdriver.c line 88
- in /usr/src/usr.bin/plot/driver.c line 88

dot defined in line 220; used 3 times

- in line 119
- in /usr/src/usr.bin/plot/atoplot.c line 114
- in /usr/src/usr.bin/plot/driver.c line 123

erase defined in line 165; used 3 times

- in line 75
- in /usr/src/usr.bin/plot/atoplot.c line 70
- in /usr/src/usr.bin/plot/driver.c line 78

fplt defined in line 47; used 2 times

- in line 36, 42

getsi defined in line 127; used 28 times

- in line 59-67(6), 78-106(17), 114-118(5)

getstr defined in line 139; used 2 times

- in line 71, 110

label defined in line 194; used 4 times

- in line 72
- in /usr/src/usr.bin/plot/atoplot.c line 67
- in /usr/src/usr.bin/plot/crtdriver.c line 75
- in /usr/src/usr.bin/plot/driver.c line 75

line defined in line 182; used 7 times

- in line 68, 213-216(3)
- in /usr/src/usr.bin/plot/atoplot.c line 63
- in /usr/src/usr.bin/plot/crtdriver.c line 71
- in /usr/src/usr.bin/plot/driver.c line 71

linemod defined in line 213; used 4 times

- in line 111
- in /usr/src/usr.bin/plot/atoplot.c line 106
- in /usr/src/usr.bin/plot/crtdriver.c line 114
- in /usr/src/usr.bin/plot/driver.c line 114

main defined in line 14; never used
move defined in line 170; used 3 times

- in line 61
- in /usr/src/usr.bin/plot/atoplot.c line 56
- in /usr/src/usr.bin/plot/driver.c line 64

openpl defined in line 157; used 4 times

- in line 55
- in /usr/src/usr.bin/plot/atoplot.c line 50
- in /usr/src/usr.bin/plot/crtdriver.c line 58
- in /usr/src/usr.bin/plot/driver.c line 58

point defined in line 188; used 4 times

- in line 80
- in /usr/src/usr.bin/plot/atoplot.c line 75
- in /usr/src/usr.bin/plot/crtdriver.c line 83
- in /usr/src/usr.bin/plot/driver.c line 83

space defined in line 151; used 4 times

- in line 92
- in /usr/src/usr.bin/plot/atoplot.c line 87
- in /usr/src/usr.bin/plot/crtdriver.c line 95
- in /usr/src/usr.bin/plot/driver.c line 95

#### Defined variables

deltx defined in line 11; used 1 times

- in line 24

delty defined in line 12; used 1 times

- in line 27

sccsid defined in line 2; never used

Last modified: 1987-02-17 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 990 |