Annotation of researchv8dc/cmd/plot/pltprnt.c, revision 1.1.1.1

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

unix.superglobalmegacorp.com

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