|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T g
Length: 2996 (0xbb4) Types: TextFile Names: »getopt.c«
└─⟦52210d11f⟧ Bits:30007239 EUUGD2: TeX 3 1992-12 └─⟦c319c2751⟧ »unix3.0/TeX3.0.tar.Z« └─⟦036c765ac⟧ └─⟦this⟧ »TeX3.0/TeXgraphics/transfig/fig2dev/getopt.c« └─⟦9ae75bfbd⟧ Bits:30007242 EUUGD3: Starter Kit └─⟦579681f02⟧ »EurOpenD3/utils/shar.tar.Z« └─⟦221e0edf4⟧ └─⟦this⟧ »shar/getopt.c« └─⟦a0efdde77⟧ Bits:30001252 EUUGD11 Tape, 1987 Spring Conference Helsinki └─⟦this⟧ »EUUGD11/stat-5.3/eu/stat/src/getopt.c« └─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987 └─⟦this⟧ »EUUGD18/General/Lotto/getopt.c« └─⟦52210d11f⟧ Bits:30007239 EUUGD2: TeX 3 1992-12 └─⟦63303ae94⟧ »unix3.14/TeX3.14.tar.Z« └─⟦c58930e5c⟧ └─⟦this⟧ »TeX3.14/TeXgraphics/transfig/fig2dev/getopt.c«
/* I got this off net.sources from Henry Spencer. It is a public domain getopt(3) like in System V. I have made the following modifications: index(s,c) was added because too many people could not compile getopt without it. A test main program was added, ifdeffed by GETOPT. This main program is a public domain implementation of the getopt(1) program like in System V. The getopt program can be used to standardize shell option handling. e.g. cc -DGETOPT getopt.c -o getopt */ #include <stdio.h> #ifndef lint static char sccsfid[] = "@(#) getopt.c 5.0 (UTZoo) 1985"; #endif #define ARGCH (int)':' #define BADCH (int)'?' #define EMSG "" #define ENDARGS "--" /* this is included because index is not on some UNIX systems */ static char * index (s, c) register char *s; register int c; { while (*s) if (c == *s) return (s); else s++; return (NULL); } /* * get option letter from argument vector */ int opterr = 1, /* useless, never set or used */ optind = 1, /* index into parent argv vector */ optopt; /* character checked for validity */ char *optarg; /* argument associated with option */ #define tell(s) fputs(*nargv,stderr);fputs(s,stderr); \ fputc(optopt,stderr);fputc('\n',stderr);return(BADCH); \f getopt(nargc,nargv,ostr) int nargc; char **nargv, *ostr; { static char *place = EMSG; /* option letter processing */ register char *oli; /* option letter list index */ char *index(); if(!*place) { /* update scanning pointer */ if(optind >= nargc || *(place = nargv[optind]) != '-' || !*++place) return(EOF); if (*place == '-') { /* found "--" */ ++optind; return(EOF); } } /* option letter okay? */ if ((optopt = (int)*place++) == ARGCH || !(oli = index(ostr,optopt))) { if(!*place) ++optind; tell(": illegal option -- "); } if (*++oli != ARGCH) { /* don't need argument */ optarg = NULL; if (!*place) ++optind; } else { /* need an argument */ if (*place) optarg = place; /* no white space */ else if (nargc <= ++optind) { /* no arg */ place = EMSG; tell(": option requires an argument -- "); } else optarg = nargv[optind]; /* white space */ place = EMSG; ++optind; } return(optopt); /* dump back option letter */ } \f #ifdef GETOPT #ifndef lint static char sccspid[] = "@(#) getopt.c 5.1 (WangInst) 6/15/85"; #endif main (argc, argv) char **argv; { char *optstring = argv[1]; char *argv0 = argv[0]; extern int optind; extern char *optarg; int opterr = 0; int C; char *opi; if (argc == 1) { fprintf (stderr, "Usage: %s optstring args\n", argv0); exit (1); } argv++; argc--; argv[0] = argv0; while ((C = getopt (argc, argv, optstring)) != EOF) { if (C == BADCH) opterr++; printf ("-%c ", C); opi = index (optstring, C); if (opi && opi[1] == ARGCH) if (optarg) printf ("\"%s\" ", optarg); else opterr++; } printf ("%s", ENDARGS); while (optind < argc) printf (" \"%s\"", argv[optind++]); putchar ('\n'); exit (opterr); } #endif