summaryrefslogtreecommitdiff
path: root/usr/src/lib/libbc/libc/gen/common/getopt.c
diff options
context:
space:
mode:
authorToomas Soome <tsoome@me.com>2020-02-08 20:24:21 +0200
committerToomas Soome <tsoome@me.com>2020-03-18 19:36:25 +0200
commit97b5374547d500fded52d886ceba8a9962af0527 (patch)
tree58133eb5538d122ed076707c9abe35530356cc0c /usr/src/lib/libbc/libc/gen/common/getopt.c
parent20d3bf629e3e91ea61dee8153d5bc47daeab26b0 (diff)
downloadillumos-gate-97b5374547d500fded52d886ceba8a9962af0527.tar.gz
12292 retire libbc
Reviewed by: Peter Tribble <peter.tribble@gmail.com> Reviewed by: Andy Stormont <astormont@racktopsystems.com> Reviewed by: Alexander Eremin <aeremin@tintri.com> Approved by: Garrett D'Amore <garrett@damore.org>
Diffstat (limited to 'usr/src/lib/libbc/libc/gen/common/getopt.c')
-rw-r--r--usr/src/lib/libbc/libc/gen/common/getopt.c107
1 files changed, 0 insertions, 107 deletions
diff --git a/usr/src/lib/libbc/libc/gen/common/getopt.c b/usr/src/lib/libbc/libc/gen/common/getopt.c
deleted file mode 100644
index 84d33cdc25..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/getopt.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright 1989 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-/*
- * Copyright (c) 1987 Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley. The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-
-/* LINTLIBRARY */
-
-#include <stdio.h>
-#include <string.h>
-
-/*
- * get option letter from argument vector
- */
-/* See lib/libc/gen/common/optind.c for next 3 definitions. */
-extern char *optarg; /* argument associated with option */
-extern int opterr; /* if error message should be printed */
-extern int optind; /* index into parent argv vector */
-int optopt; /* character checked for validity */
-
-
-#define BADCH (int)'?'
-#define EMSG ""
-
-int
-getopt(int nargc, char **nargv, char *ostr)
-{
- static char *place = EMSG; /* option letter processing */
- char *oli; /* option letter list index */
- char *p;
-
- if (!*place) { /* update scanning pointer */
- if (optind >= nargc || *(place = nargv[optind]) != '-') {
- place = EMSG;
- return (EOF);
- }
- if (place[1] && *++place == '-') { /* found "--" */
- ++optind;
- place = EMSG;
- return (EOF);
- }
- } /* option letter okay? */
- if ((optopt = (int)*place++) == (int)':' ||
- !(oli = strchr(ostr, optopt))) {
-
- /*
- * For backwards compatibility: don't treat '-' as an
- * option letter unless caller explicitly asked for it.
- */
- if (optopt == (int)'-')
- return (EOF);
- if (!*place)
- ++optind;
- if (opterr) {
- if (!(p = strrchr(*nargv, '/')))
- p = *nargv;
- else
- ++p;
- (void)fprintf(stderr, "%s: illegal option -- %c\n",
- p, optopt);
- }
- return (BADCH);
- }
- if (*++oli != ':') { /* don't need argument */
- optarg = NULL;
- if (!*place)
- ++optind;
- } else { /* need an argument */
- if (*place) /* no white space */
- optarg = place;
- else if (nargc <= ++optind) { /* no arg */
- place = EMSG;
- if (!(p = strrchr(*nargv, '/')))
- p = *nargv;
- else
- ++p;
- if (opterr)
- (void)fprintf(stderr,
- "%s: option requires an argument -- %c\n",
- p, optopt);
- return (BADCH);
- } else /* white space */
- optarg = nargv[optind];
- place = EMSG;
- ++optind;
- }
- return (optopt); /* dump back option letter */
-}