inet_ntop.c: s/socklen_t/ares_socklen_t
[platform/upstream/c-ares.git] / ares_getopt.c
index fc6e887..1e02d08 100644 (file)
@@ -3,7 +3,6 @@
  * on 2007-04-11.  Lifted from version 5.2 of the 'Open Mash' project with
  * the modified BSD license, BSD license without the advertising clause.
  *
- * $Id$
  */
 
 /*
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-
-/* declarations to provide consistent linkage */
-extern char *optarg;
-extern int optind;
-extern int opterr;
+#include "ares_getopt.h"
 
 int   opterr = 1,     /* if error message should be printed */
-      optind = 1,     /* index into parent argv vector */
-      optopt,         /* character checked for validity */
-      optreset;       /* reset getopt */
+      optind = 1;     /* index into parent argv vector */
+int   optopt = 0;     /* character checked for validity */
+static int optreset;  /* reset getopt */
 char  *optarg;        /* argument associated with option */
 
 #define  BADCH   (int)'?'
 #define  BADARG  (int)':'
-#define  EMSG    ""
+#define  EMSG    (char *)""
 
 /*
- * getopt --
+ * ares_getopt --
  *    Parse argc/argv argument vector.
  */
 int
-getopt(nargc, nargv, ostr)
-    int nargc;
-    char * const *nargv;
-    const char *ostr;
+ares_getopt(int nargc, char * const nargv[], const char *ostr)
 {
     static char *place = EMSG;                /* option letter processing */
     char *oli;                                /* option letter list index */
@@ -89,7 +81,7 @@ getopt(nargc, nargv, ostr)
         }
     }                                         /* option letter okay? */
     if ((optopt = (int)*place++) == (int)':' ||
-        !(oli = strchr(ostr, optopt))) {
+        (oli = strchr(ostr, optopt)) == NULL) {
         /*
          * if the user didn't specify '-' as an option,
          * assume it means EOF.