Mercurial > hg > th-libs
comparison th_args.c @ 616:594f197f7005
Slight improvements to the almost non-existing Doxygen documentation.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 17 Jan 2020 03:18:40 +0200 |
parents | 1e9fa00cc63f |
children | 6d99150a8f89 |
comparison
equal
deleted
inserted
replaced
615:b87395754c8d | 616:594f197f7005 |
---|---|
13 | 13 |
14 | 14 |
15 /** | 15 /** |
16 * Parse and optionally handle the given long or short option argument. | 16 * Parse and optionally handle the given long or short option argument. |
17 * @param currArg current argument string | 17 * @param currArg current argument string |
18 * @param argIndex pointer to index of current argument in argv[] | 18 * @param[in,out] argIndex pointer to index of current argument in argv[] |
19 * @param argc number of arguments | 19 * @param argc number of arguments |
20 * @param argv argument string array | 20 * @param argv argument string array |
21 * @param opts options list array | 21 * @param[in] opts options list array |
22 * @param nopts number of elements in options list array | 22 * @param[in] nopts number of elements in options list array |
23 * @param handle_option function pointer to callback that handles option arguments | 23 * @param[in] handle_option function pointer to callback that handles option arguments |
24 * @param doProcess if TRUE, actually handle the argument, aka call the handle_option() function. if FALSE, only validity of options are checked. | 24 * @param[in] doProcess if TRUE, actually handle the argument, aka call the handle_option() function. if FALSE, only validity of options are checked. |
25 * @param isLong TRUE if the option is a --long-format one | 25 * @param[in] isLong TRUE if the option is a --long-format one |
26 * @returns returns @c TRUE if option processing was successful | |
26 */ | 27 */ |
27 static BOOL th_args_process_opt( | 28 static BOOL th_args_process_opt( |
28 char *currArg, int *argIndex, | 29 char *currArg, int *argIndex, |
29 int argc, char *argv[], | 30 int argc, char *argv[], |
30 const th_optarg opts[], int nopts, | 31 const th_optarg opts[], int nopts, |
109 * Process given array of commandline arguments, handling short | 110 * Process given array of commandline arguments, handling short |
110 * and long options by calling the respective callback functions. | 111 * and long options by calling the respective callback functions. |
111 * | 112 * |
112 * @param argc number of arguments | 113 * @param argc number of arguments |
113 * @param argv argument list | 114 * @param argv argument list |
114 * @param opts supported option list array | 115 * @param[in] opts supported option list array |
115 * @param nopts number of elements in the option list array | 116 * @param[in] nopts number of elements in the option list array |
116 * @param handle_option callback function | 117 * @param[in] handle_option callback function |
117 * @param handle_other callback function | 118 * @param[in] handle_other callback function |
118 * @param flags processing flags | 119 * @param[in] flags processing flags |
119 * @return return TRUE if all is well | 120 * @return returns @c TRUE if arguments were processed successfully |
120 */ | 121 */ |
121 BOOL th_args_process(int argc, char *argv[], | 122 BOOL th_args_process(int argc, char *argv[], |
122 const th_optarg *opts, const int nopts, | 123 const th_optarg *opts, const int nopts, |
123 BOOL(*handle_option)(int id, char *, char *), | 124 BOOL(*handle_option)(int id, char *, char *), |
124 BOOL(*handle_other)(char *), const int flags) | 125 BOOL(*handle_other)(char *), const int flags) |
186 | 187 |
187 /** | 188 /** |
188 * Print given string indented in such a way that it is automatically | 189 * Print given string indented in such a way that it is automatically |
189 * line-wrapped as necessary, taking hard linefeeds into account as well. | 190 * line-wrapped as necessary, taking hard linefeeds into account as well. |
190 * @param fh stdio file handle to output to | 191 * @param fh stdio file handle to output to |
191 * @param spad starting pad/indent of the first line | 192 * @param[in] spad starting pad/indent of the first line |
192 * @param rpad how much to pad the other lines | 193 * @param[in] rpad how much to pad the other lines |
193 * @param width total line width to wrap at | 194 * @param[in] width total line width to wrap at |
194 * @param str string to output | 195 * @param[in] str string to output |
195 */ | 196 */ |
196 void th_print_wrap(FILE *fh, const int spad, int const rpad, | 197 void th_print_wrap(FILE *fh, const int spad, int const rpad, |
197 const int width, const char *str) | 198 const int width, const char *str) |
198 { | 199 { |
199 size_t pos = 0; | 200 size_t pos = 0; |
329 | 330 |
330 | 331 |
331 /** | 332 /** |
332 * Print help for commandline arguments/options | 333 * Print help for commandline arguments/options |
333 * @param fh stdio file handle to output to | 334 * @param fh stdio file handle to output to |
334 * @param opts options list array | 335 * @param[in] opts options list array |
335 * @param nopts number of elements in options list array | 336 * @param[in] nopts number of elements in options list array |
336 * @param flags flags (currently unused) | 337 * @param[in] flags flags (currently unused) |
337 * @param width width of the terminal or desired width of the print out | 338 * @param[in] width width of the terminal or desired width of the print out |
338 */ | 339 */ |
339 void th_args_help(FILE *fh, const th_optarg *opts, | 340 void th_args_help(FILE *fh, const th_optarg *opts, |
340 const int nopts, const int flags, const int width) | 341 const int nopts, const int flags, const int width) |
341 { | 342 { |
342 int index, maxOptWidth; | 343 int index, maxOptWidth; |