/* options.c * * Copyright (C) 1994-5, All rights reserved. * written by Gyudong Kim(chilly@eleceng.adelaide.edu.au) * last revised at 14, October, 1994 * * check options * default : interactive mode * -A : all topcells * -c CIFfile : cif Format * -D : dangling cells * -f filename : input command file specification * -g GDSIIfile : gdsII Format * -h : help message * -I : included cells (useful for tar) * -i : ignore case (as in grep) * -m : magic Format * -n number_option : fin[r] * -o filename : output file specification * -p : PC stream Format * -R : reverse graph * -S : directory summary * -T : enumerate topcells * -t : TeX * -v : VALID GED format (NOT verbose!) * -X : excluded cells (useful for rm or mv) * */ #include "findhier.h" #include "version.h" #define OPTIONS "Ac:Df:g:hIimn:o:pRSTtv:X" extern char *optarg; extern int optind, opterr; int (*mystrcmp)()=strcmp; char *(*getcell)(); void (*set_tree)(); char *(*mycase)()=dummycase; int NORMAL = 1; int specified = 0; char *target; int topspecified = 0; char *topcell; int onlytop = 0; int mode = 0; int interactive = 1; FORMAT Format = MAGIC; char *dbname; char *dbdir; FILE *dbfile; char *myname; int numberformat = DEFNUMFORMAT; extern FILE *OUTPUT; extern FILE *INPUT; static void Usage() { warning("Layout Hierarchy Manager %s",myname); warning(" %s\n",VERSION); warning("Usage : %s",myname);warning(" [-%s]\n",OPTIONS); warning(" each colon in option string requires an argument.\n",""); warning(" -A : all topcells\n",""); warning(" -c CIFfile : cif Format\n",""); warning(" -D : dangling cells\n",""); warning(" -f filename : input command file\n",""); warning(" -g GDSIIfile : gdsII Format\n",""); warning(" -h : help message\n",""); warning(" -I : included cells (useful for tar)\n",""); warning(" -m : MAGIC Format (default)\n",""); warning(" -n number_option : numbering [(f)|i|n|r]\n",""); warning(" -o filename : output file\n",""); warning(" -p : PC stream Format\n",""); warning(" -R : reverse graph\n",""); warning(" -S : directory summary\n",""); warning(" -T : enumerate topcells\n",""); warning(" -t : [La]TeX\n",""); warning(" -v workfile : VALID GED format\n",""); warning(" -X : excluded cells (useful for rm or mv)\n",""); exit(0); } static char *getthearg(c) int c; { if (optarg[0]=='-') { warning("option %c requires an argument such as : ",c); warning("-%c filename/option\n",c); exit(0); } return(optarg); } void mygetopt(argc, argv) int argc; char **argv; { int c; int errflg = 0; char *ofile,*ifile; getcell = getmagline; /* default magic read */ myname = basename(argv[0]); if (argc < 2) return; /* interactive mode */ ofile = ifile = (char *)NULL; while ((c = getopt(argc, argv, OPTIONS)) != -1) switch (c) { case 'A': interactive = 0; onlytop = 2; break; case 'S': /* summary print */ interactive = 0; NORMAL = 1; break; case 'h': Usage(); break; case 'R': interactive = 0; NORMAL = 0; break; case 'T': interactive = 0; onlytop = 1; break; case 'f': ifile = getthearg(c); break; case 'n': numberformat = getthearg(c)[0]; switch (numberformat) { case 'f': case 'i': case 'n': case 'r': break; default: numberformat = DEFNUMFORMAT; break; } break; case 'o': ofile = getthearg(c); break; case 'i': mystrcmp = strcmpi; break; case 'X': case 'I': case 'D': interactive = 0; mode = c + ( 'a'-'A' ); /* to lower cases */ break; case 'c': Format = CIF; dbname = getthearg(c); set_tree = cif_tree; break; case 'g': Format = GDSII; dbname = getthearg(c); set_tree = gds_tree; break; case 'm': Format = MAGIC; getcell = getmagline; break; case 'p': Format = PCSTR; getcell = pcstream_read; break; case 't': Format = TeX; getcell = get_tex; break; case 'v': /* NOT verbose */ Format = VALID; dbname = getthearg(c); set_tree = GED_tree; break; case '?': errflg++; /* no default is required here */ } if (errflg) Usage(); if ( mode=='x' || mode=='i' ) if (optind < argc) { topcell = argv[optind]; topspecified = 1; optind++; } else Usage(); if (!NORMAL) { if (optind >= argc) Usage(); target = argv[optind]; specified = 1; optind++; if (optind < argc) { topcell = argv[optind]; topspecified = 1; optind++; } } else { if (optind < argc) { target = argv[optind]; specified = 1; optind++; } } if (ofile!=NULL) redirect('>',ofile); if (ifile!=NULL) redirect('<',ifile); if (Format == CIF || Format == GDSII || Format == VALID ) { if (dbname!=NULL) { if (Format==GDSII) dbfile = fopen(dbname,OPENMODE); else dbfile = fopen(dbname,"r"); if (dbfile == NULL) warning("File %s not found\n",dbname); dbdir = (char *)myalloc((SIZE)(strlen(dbname)+1),"mygetopt"); (void)strcpy(dbdir,dbname); dbdir = dirname(dbdir); } if (dbfile == NULL) Usage(); } switch (Format) { case PCSTR: mycase=strlwr; case GDSII: set_byte_order(); break; default: break; } } void no_target() { warning("%s : Can not find any target.\n",myname); Usage(); } /* options.c */