summaryrefslogtreecommitdiff
path: root/src/unistd/getopt.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/unistd/getopt.c')
-rw-r--r--src/unistd/getopt.c88
1 files changed, 0 insertions, 88 deletions
diff --git a/src/unistd/getopt.c b/src/unistd/getopt.c
deleted file mode 100644
index 04348c7b..00000000
--- a/src/unistd/getopt.c
+++ /dev/null
@@ -1,88 +0,0 @@
-#if 0
-
-#include <sys/types.h>
-#include <string.h>
-#include <stdio.h>
-#include <unistd.h>
-
-int getopt(int argc, char * const argv[], const char *optstring)
-{
- static int optchar = 0;
- char *option = NULL;
-
- if (optind == 0) {
- optind = 1;
- optchar = 0;
- }
-
- if (argv[optind] == NULL) {
- return -1;
- }
-
- if (argv[optind][0] != '-') {
- return -1;
- }
-
- if (!strcmp(argv[optind], "-")) {
- return -1;
- }
-
- if (!strcmp(argv[optind], "--")) {
- optind++;
- optchar = 0;
- return -1;
- }
-
- if (optchar == 0 && argv[optind][optchar] != '-') {
- return -1;
- }
-
- optchar++;
-
- if (argv[optind][optchar] == '\0') {
- optind++;
- optchar = 0;
- return getopt(argc, argv, optstring);
- }
-
- option = strchr(optstring, argv[optind][optchar]);
-
- if (!option) {
- optopt = argv[optind][optchar];
- if (opterr != 0 && optstring[0] != ':') {
- fprintf(stderr, "%s: invalid option -%c\n", argv[0],
- optopt);
- }
- return '?';
- }
-
- if (option[1] != ':') {
- return *option;
- }
-
- if (argv[optind][optchar + 1] == '\0') {
- optarg = argv[++optind];
- } else {
- optarg = argv[optind] + optchar + 1;
- }
-
- optind++;
- if (optarg == NULL) {
- optopt = *option;
- if (opterr != 0 && optstring[0] != ':') {
- fprintf(stderr, "%s: missing argument to option -%c\n",
- argv[0], optopt);
- }
- return optstring[0] == ':' ? ':' : '?';
- }
-
- optchar = 0;
- return *option;
-}
-
-/*
-POSIX(2)
-*/
-
-
-#endif