Annotation of 41BSD/cmd/cifplot/main.c, revision 1.1

1.1     ! root        1: /*******************************************************************
        !             2: *                                                                  *
        !             3: *    File: CIFPLOT/main.c                                          *
        !             4: *    Written by Dan Fitzpatrick                                    *
        !             5: *    copyright 1980 -- Regents of the University of California     *
        !             6: *                                                                  *
        !             7: ********************************************************************/
        !             8: 
        !             9: #include <stdio.h>
        !            10: #include "defs.h"
        !            11: #include "globals.h"
        !            12: #include "structs.h"
        !            13: #include "scanner.h"
        !            14: #include "alloc.h"
        !            15: 
        !            16: IMPORT InitInput();
        !            17: IMPORT InitError();
        !            18: IMPORT InitInter();
        !            19: IMPORT InitText();
        !            20: IMPORT yyparser();
        !            21: IMPORT string Concat();
        !            22: IMPORT ErrorSummary();
        !            23: IMPORT AllocSummary();
        !            24: IMPORT InterSummary();
        !            25: IMPORT float PlotSize();
        !            26: IMPORT float PlotScale();
        !            27: IMPORT transform *MakeTransform();
        !            28: IMPORT transform *Rotate();
        !            29: IMPORT point *MakePoint();
        !            30: 
        !            31: extern int FatalError;
        !            32: 
        !            33: main(n,v)
        !            34: int n;
        !            35: char **v;
        !            36: {
        !            37:     int b;
        !            38:     char ch;
        !            39:     InitGet();
        !            40:     InitError();
        !            41:     InitInter();
        !            42:     b = options(1,n,v);
        !            43:     if(extractor) InitExtractor();
        !            44:     InitInput(b,n,v);
        !            45:     InitText();
        !            46:     if(parser()) 
        !            47:        Error("Unrecoverable Syntax Error-Quit\n",FATAL);
        !            48:     Summary();
        !            49:     if(FatalError) exit(1);
        !            50:     if(output == NOPLOT) Intermediate();
        !            51:     InitFill();
        !            52:     FixScale();
        !            53:     AdjustWindow();
        !            54:     InitPlotter();
        !            55:     Grid();
        !            56:     fprintf(stderr,"Window %d %d %d %d\n",(int) GWindow.xmin,(int) GWindow.xmax,
        !            57:                                  (int) GWindow.ymin,(int) GWindow.ymax);
        !            58:     fprintf(stderr,"Scale: 1 micron is %f inches\n",scale);
        !            59:     if(MoreToPlot == 0)
        !            60:         fprintf(stderr,"The plot will be %4.2f feet\n",PlotSize());
        !            61:       else
        !            62:         fprintf(stderr,"The plot will be %d pages, %4.2f feet each\n",
        !            63:                MoreToPlot+1,PlotSize());
        !            64:     if(ask) {
        !            65:        fprintf(stderr,"Do you want a plot?  ");
        !            66:        ch = getchar();
        !            67:        if(!(ch == 'y' || ch == 'Y' || ch == EOF)) exit(0);
        !            68:        if(ch == EOF) {
        !            69:                fprintf(stderr,"\n");
        !            70:                }
        !            71:        }
        !            72:     if(extractor) OpenExtractor();
        !            73:     Plot();
        !            74:     while(MoreToPlot) {
        !            75:        AdjustWindow();
        !            76:        ReStartPlotter();
        !            77:        Grid();
        !            78:        Plot();
        !            79:        }
        !            80:     if(debug) {
        !            81:        AllocSummary();
        !            82:        SortSummary();
        !            83:        CheckUnAct();
        !            84:        }
        !            85:     if(extractor) Extract();
        !            86:     }
        !            87: 
        !            88: options(b,n,v)
        !            89: int b,n;
        !            90: char **v;
        !            91: {
        !            92:     programName = "cifplot*";
        !            93:     debug = 0;
        !            94:     depth = 0;
        !            95:     list = 0;
        !            96:     standard = 0;
        !            97:     banner = "";
        !            98:     outline = 1;
        !            99:     SetScale = 0;
        !           100:     plot = 1;
        !           101:     extractor = 0;
        !           102:     baseName = "";
        !           103:     symbox = 1;
        !           104:     circle = 8;
        !           105:     RetCmt = 1;
        !           106:     text = 1;
        !           107:     printSymbolName = 1;
        !           108:     grid = 0;
        !           109:     ask = 1;
        !           110:     output = VARIAN;
        !           111:     NoPixcels = 2000;
        !           112:     GlobalTransform = MakeTransform();
        !           113:     while (v[b][0] == '-') {
        !           114:        switch(v[b][1]) {
        !           115:                case 'a':
        !           116:                        if('0' <= v[b][2] && v[b][2] <= '9') {
        !           117:                                sscanf(&v[b][2],"%d",&circle);
        !           118:                                if(circle < 4) circle = 8;
        !           119:                                }
        !           120:                              else {
        !           121:                                sscanf(v[++b],"%d",&circle);
        !           122:                                if(circle < 4) circle = 8;
        !           123:                                }
        !           124:                        break;
        !           125:                case 'B':
        !           126:                        symbox = 0;
        !           127:                        break;
        !           128:                case 'b':
        !           129:                        banner = v[++b];
        !           130:                        if(b >= n) {
        !           131:                                fprintf(stderr,"Banner must appear after the -b option\n");
        !           132:                                abort();
        !           133:                                }
        !           134:                        break;
        !           135:                case 'C':
        !           136:                        RetCmt = 0;
        !           137:                        break;
        !           138:                case 'd':
        !           139:                        if(v[b][2] != '\0') depth = atoi(&v[b][2]);
        !           140:                                else depth = atoi(v[++b]);
        !           141:                        break;
        !           142:                case 'D':
        !           143:                        debug = 1;
        !           144:                        if(v[b][2] != '\0') debug += v[b][2] - '0';
        !           145:                        break;
        !           146:                case 'f':
        !           147:                        outline = 0;
        !           148:                        break;
        !           149:                case 'F':
        !           150:                        if(v[b][2] != '\0')
        !           151:                                fontfile = &(v[b][2]);
        !           152:                            else
        !           153:                                fontfile = v[++b];
        !           154:                        break;
        !           155:                case 'g':
        !           156:                        if(v[b][2] != '\0')
        !           157:                                grid = atoi(&(v[b][2]));
        !           158:                            else
        !           159:                                grid = atoi(v[++b]);
        !           160:                        break;
        !           161:                case 'H':
        !           162:                        output = HP2648A;
        !           163:                        break;
        !           164:                case 'i':
        !           165:                        circle = 0;
        !           166:                        break;
        !           167:                case 'I':
        !           168:                        ask = 0;
        !           169:                        break;
        !           170:                case 'l':
        !           171:                        if(v[b][2] != '\0') Invisible(&v[b][2]);
        !           172:                                else Invisible(v[++b]);
        !           173:                        break;
        !           174:                case 'L':
        !           175:                        list = 1;
        !           176:                        break;
        !           177:                case 'r':
        !           178:                   {    transform *temp;
        !           179:                        point pt;
        !           180:                        pt.x = 0;   pt.y = -1;
        !           181:                        temp = Rotate(&pt,GlobalTransform);
        !           182:                        FreeTransform(GlobalTransform);
        !           183:                        GlobalTransform = temp;
        !           184:                        }
        !           185:                        break;
        !           186:                case 's':
        !           187:                        SetScale = 1;
        !           188:                        if(v[b][2] != '\0') {
        !           189:                            if(EOF == sscanf(&(v[b][2]),"%f",&scale)) {
        !           190:                                fprintf(stderr,"bad format on -s option\n");
        !           191:                                abort();
        !           192:                                }
        !           193:                            }
        !           194:                        else if(EOF == sscanf(v[++b],"%f",&scale)) {
        !           195:                                fprintf(stderr,"bad format on -s option\n");
        !           196:                                abort();
        !           197:                                }
        !           198:                        break;
        !           199:                case 't':
        !           200:                        text = 0;
        !           201:                        break;
        !           202:                case 'e':
        !           203:                        standard = 1;
        !           204:                        break;
        !           205:                case 'O':
        !           206:                        output = NOPLOT;
        !           207:                        if(v[b][2] != '\0') outfile = &(v[b][2]);
        !           208:                                else outfile = v[++b];
        !           209:                        if(b >= n) {
        !           210:                                fprintf(stderr,"file name must appear after -O option\n");
        !           211:                                abort();
        !           212:                                }
        !           213:                        break;
        !           214:                case 'p':
        !           215:                        if(v[b][2] != '\0') {
        !           216:                                readpat(&(v[b][2]));
        !           217:                                break;
        !           218:                                }
        !           219:                        if(b+2 >= n) {
        !           220:                                fprintf(stderr,"usage: %s -p file.stipple file.cif\n",v[0]);
        !           221:                                abort();
        !           222:                                }
        !           223:                        readpat(v[++b]);
        !           224:                        break;
        !           225:                case 'P':
        !           226:                        output = LINEPRINTER;
        !           227:                        break;
        !           228:                case 'S':
        !           229:                        output = VSPOOL;
        !           230:                        break;
        !           231:                case 'V':
        !           232:                        output = VARIAN;
        !           233:                        break;
        !           234:                case 'w':
        !           235:                        if(b+5 >= n) {
        !           236:                                fprintf(stderr,"usage: %s -w xmin xmax ymin ymax file.cif\n",v[0]);
        !           237:                                abort();
        !           238:                                }
        !           239:                        GWindow.xmin = atoi(v[++b]);
        !           240:                        GWindow.xmax = atoi(v[++b]);
        !           241:                        GWindow.ymin = atoi(v[++b]);
        !           242:                        GWindow.ymax = atoi(v[++b]);
        !           243:                        if(GWindow.xmin > GWindow.xmax) {
        !           244:                                fprintf(stderr,"error: xmin must be less than xmax\n");
        !           245:                                abort();
        !           246:                                }
        !           247:                        if(GWindow.ymin > GWindow.ymax) {
        !           248:                                fprintf(stderr,"error: ymin must be less than ymax\n");
        !           249:                                abort();
        !           250:                                }
        !           251:                        break;
        !           252:                case 'W':
        !           253:                        output = VERSATEC;
        !           254:                        break;
        !           255:                case 'n':
        !           256:                        plot = 0;
        !           257:                        break;
        !           258:                case 'X':
        !           259:                        plot = 0;
        !           260:                        extractor = 1;
        !           261:                        SetScale = 1;
        !           262:                        scale = 0.02;
        !           263:                        baseName = v[++b];
        !           264:                        break;
        !           265:                default:
        !           266:                        fprintf(stderr,"%s: Unknown option-Ignored\n",v[b]);
        !           267:                        break;
        !           268:                }
        !           269:        b++;
        !           270:        }
        !           271:     file1 = Concat(v[b],0);
        !           272:     return(b);
        !           273:     }
        !           274: 
        !           275: Summary()
        !           276: {
        !           277:     ErrorSummary();
        !           278:     if(debug) AllocSummary();
        !           279:     InterSummary();
        !           280:     }

unix.superglobalmegacorp.com

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