]> git.kaiwu.me - klib.git/commitdiff
documentation
authorHeng Li <lh3@me.com>
Thu, 30 Aug 2018 05:46:32 +0000 (19:46 -1000)
committerHeng Li <lh3@me.com>
Thu, 30 Aug 2018 05:46:32 +0000 (19:46 -1000)
ketopt.h

index 8b72efe5f5c0b73903ac73148b73f13e15d4181b..786e17e632843909427906f0c9b0caf204f7a306 100644 (file)
--- a/ketopt.h
+++ b/ketopt.h
@@ -25,6 +25,26 @@ extern "C" {
 
 extern ketopt_t KETOPT_INIT;
 
+/**
+ * Parse command-line options and arguments
+ *
+ * This fuction has a similar interface to GNU's getopt_long(). Each call
+ * parses one option and returns the option name.  s->arg points to the option
+ * argument if present. The function returns -1 when all command-line arguments
+ * are parsed. In this case, s->ind is the index of the first non-option
+ * argument.
+ *
+ * @param s         status; shall be initialized to KETOPT_INIT on the first call
+ * @param argc      length of argv[]
+ * @param argv      list of command-line arguments; argv[0] is ignored
+ * @param permute   non-zero to move options ahead of non-option arguments
+ * @param ostr      option string
+ * @param longopts  long options
+ *
+ * @return ASCII for a short option; ko_longopt_t::val for a long option; -1 if
+ *         argv[] is fully processed; '?' for an unknown option or an ambiguous
+ *         long option; ':' if an option argument is missing
+ */
 int ketopt(ketopt_t *s, int argc, char *argv[], int permute, const char *ostr, const ko_longopt_t *longopts);
 
 #ifdef __cplusplus