summaryrefslogtreecommitdiff
path: root/ares_getopt.c
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2007-04-12 17:45:57 +0000
committerYang Tse <yangsita@gmail.com>2007-04-12 17:45:57 +0000
commit8438d08ff86ad8e58ceafc0e1c223295175340e4 (patch)
tree819b01309c3c33105b06f1953e14abd472119218 /ares_getopt.c
parent4dc8ca29b710ce33c3aac7f91142698c0fbc2392 (diff)
downloadc-ares-8438d08ff86ad8e58ceafc0e1c223295175340e4.tar.gz
c-ares-8438d08ff86ad8e58ceafc0e1c223295175340e4.tar.bz2
c-ares-8438d08ff86ad8e58ceafc0e1c223295175340e4.zip
Replace tabs with spaces
Diffstat (limited to 'ares_getopt.c')
-rw-r--r--ares_getopt.c132
1 files changed, 66 insertions, 66 deletions
diff --git a/ares_getopt.c b/ares_getopt.c
index 3ed40cd..fc6e887 100644
--- a/ares_getopt.c
+++ b/ares_getopt.c
@@ -40,7 +40,7 @@
*/
/* #if !defined(lint)
- * static char sccsid[] = "@(#)getopt.c 8.2 (Berkeley) 4/2/94";
+ * static char sccsid[] = "@(#)getopt.c 8.2 (Berkeley) 4/2/94";
* #endif
*/
@@ -53,78 +53,78 @@ extern char *optarg;
extern int optind;
extern int opterr;
-int opterr = 1, /* if error message should be printed */
- optind = 1, /* index into parent argv vector */
- optopt, /* character checked for validity */
- optreset; /* reset getopt */
-char *optarg; /* argument associated with option */
+int opterr = 1, /* if error message should be printed */
+ optind = 1, /* index into parent argv vector */
+ optopt, /* character checked for validity */
+ optreset; /* reset getopt */
+char *optarg; /* argument associated with option */
-#define BADCH (int)'?'
-#define BADARG (int)':'
-#define EMSG ""
+#define BADCH (int)'?'
+#define BADARG (int)':'
+#define EMSG ""
/*
* getopt --
- * Parse argc/argv argument vector.
+ * Parse argc/argv argument vector.
*/
int
getopt(nargc, nargv, ostr)
- int nargc;
- char * const *nargv;
- const char *ostr;
+ int nargc;
+ char * const *nargv;
+ const char *ostr;
{
- static char *place = EMSG; /* option letter processing */
- char *oli; /* option letter list index */
+ static char *place = EMSG; /* option letter processing */
+ char *oli; /* option letter list index */
- if (optreset || !*place) { /* update scanning pointer */
- optreset = 0;
- 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))) {
- /*
- * if the user didn't specify '-' as an option,
- * assume it means EOF.
- */
- if (optopt == (int)'-')
- return (EOF);
- if (!*place)
- ++optind;
- if (opterr && *ostr != ':')
- (void)fprintf(stderr,
- "%s: illegal option -- %c\n", __FILE__, 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 (*ostr == ':')
- return (BADARG);
- if (opterr)
- (void)fprintf(stderr,
- "%s: option requires an argument -- %c\n",
- __FILE__, optopt);
- return (BADCH);
- }
- else /* white space */
- optarg = nargv[optind];
- place = EMSG;
- ++optind;
- }
- return (optopt); /* dump back option letter */
+ if (optreset || !*place) { /* update scanning pointer */
+ optreset = 0;
+ 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))) {
+ /*
+ * if the user didn't specify '-' as an option,
+ * assume it means EOF.
+ */
+ if (optopt == (int)'-')
+ return (EOF);
+ if (!*place)
+ ++optind;
+ if (opterr && *ostr != ':')
+ (void)fprintf(stderr,
+ "%s: illegal option -- %c\n", __FILE__, 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 (*ostr == ':')
+ return (BADARG);
+ if (opterr)
+ (void)fprintf(stderr,
+ "%s: option requires an argument -- %c\n",
+ __FILE__, optopt);
+ return (BADCH);
+ }
+ else /* white space */
+ optarg = nargv[optind];
+ place = EMSG;
+ ++optind;
+ }
+ return (optopt); /* dump back option letter */
}