From: Heng Li Date: Thu, 30 Aug 2018 05:46:32 +0000 (-1000) Subject: documentation X-Git-Url: http://www.kaiwu.me/postgresql/commit/?a=commitdiff_plain;h=9d39c39aabfd4899b3d49c7828bb400414142bc8;p=klib.git documentation --- diff --git a/ketopt.h b/ketopt.h index 8b72efe..786e17e 100644 --- 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