Annotation of 42BSD/usr.bin/plot/driver.c, revision 1.1.1.1

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.