summaryrefslogtreecommitdiffstats
path: root/src/getopt.h
diff options
context:
space:
mode:
authorEvan Martin <martine@danga.com>2011-04-23 21:05:56 (GMT)
committerEvan Martin <martine@danga.com>2011-04-23 21:05:56 (GMT)
commit419868feaa649290c6dc94e8007c62ca1f3be66f (patch)
treedafb2cfc30e0e90af55caab7c27de178f507671c /src/getopt.h
parent0b660a82e76821c880c7f37c08c10f775a6fc4bc (diff)
downloadNinja-419868feaa649290c6dc94e8007c62ca1f3be66f.zip
Ninja-419868feaa649290c6dc94e8007c62ca1f3be66f.tar.gz
Ninja-419868feaa649290c6dc94e8007c62ca1f3be66f.tar.bz2
[win] check in public-domain getopt implementation
Diffstat (limited to 'src/getopt.h')
-rw-r--r--src/getopt.h55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/getopt.h b/src/getopt.h
new file mode 100644
index 0000000..49a107e
--- /dev/null
+++ b/src/getopt.h
@@ -0,0 +1,55 @@
+#ifndef GETOPT_H
+#define GETOPT_H
+
+/* include files needed by this include file */
+
+/* macros defined by this include file */
+#define no_argument 0
+#define REQUIRED_ARG 1
+#define OPTIONAL_ARG 2
+
+/* types defined by this include file */
+
+/* GETOPT_LONG_OPTION_T: The type of long option */
+typedef struct GETOPT_LONG_OPTION_T
+{
+ char *name; /* the name of the long option */
+ int has_arg; /* one of the above macros */
+ int *flag; /* determines if getopt_long() returns a
+ * value for a long option; if it is
+ * non-NULL, 0 is returned as a function
+ * value and the value of val is stored in
+ * the area pointed to by flag. Otherwise,
+ * val is returned. */
+ int val; /* determines the value to return if flag is
+ * NULL. */
+} GETOPT_LONG_OPTION_T;
+
+typedef GETOPT_LONG_OPTION_T option;
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ /* externally-defined variables */
+ extern char *optarg;
+ extern int optind;
+ extern int opterr;
+ extern int optopt;
+
+ /* function prototypes */
+ int getopt (int argc, char **argv, char *optstring);
+ int getopt_long (int argc, char **argv, char *shortopts,
+ GETOPT_LONG_OPTION_T * longopts, int *longind);
+ int getopt_long_only (int argc, char **argv, char *shortopts,
+ GETOPT_LONG_OPTION_T * longopts, int *longind);
+
+#ifdef __cplusplus
+};
+
+#endif
+
+#endif /* GETOPT_H */
+
+/* END OF FILE getopt.h */