Mercurial > hg > th-libs
comparison th_args.c @ 436:9148bc3fa838
Begin adding Doxygen documentation for some things. Very rudimentary, and
most things are not documented yet.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 10 May 2017 21:00:37 +0300 |
parents | 1b3472ba7b23 |
children | 2991e6b52d95 |
comparison
equal
deleted
inserted
replaced
435:468d521240c6 | 436:9148bc3fa838 |
---|---|
3 * Programmed and designed by Matti 'ccr' Hamalainen | 3 * Programmed and designed by Matti 'ccr' Hamalainen |
4 * (C) Copyright 2002-2017 Tecnic Software productions (TNSP) | 4 * (C) Copyright 2002-2017 Tecnic Software productions (TNSP) |
5 * | 5 * |
6 * Please read file 'COPYING' for information on license and distribution. | 6 * Please read file 'COPYING' for information on license and distribution. |
7 */ | 7 */ |
8 /// @file | |
9 /// @brief Simple commandline argument processing functions | |
8 #ifndef TH_EXTERNAL | 10 #ifndef TH_EXTERNAL |
9 #include "th_util.h" | 11 #include "th_util.h" |
10 #include "th_args.h" | 12 #include "th_args.h" |
11 #include "th_string.h" | 13 #include "th_string.h" |
12 #endif | 14 #endif |
13 | 15 |
14 | 16 |
15 /* Parse long and short options | 17 /** |
18 * Parse and optionally handle the given long or short option argument. | |
19 * @param currArg current argument string | |
20 * @param argIndex pointer to index of current argument in argv[] | |
21 * @param argc number of arguments | |
22 * @param argv argument string array | |
23 * @param opts options list array | |
24 * @param nopts number of elements in options list array | |
25 * @param handle_option function pointer to callback that handles option arguments | |
26 * @param doProcess if TRUE, actually handle the argument, aka call the handle_option() function. if FALSE, only validity of options are checked. | |
27 * @param isLong TRUE if the option is a --long-format one | |
16 */ | 28 */ |
17 static BOOL th_args_process_opt( | 29 static BOOL th_args_process_opt( |
18 char *currArg, int *argIndex, | 30 char *currArg, int *argIndex, |
19 int argc, char *argv[], | 31 int argc, char *argv[], |
20 const th_optarg opts[], int nopts, | 32 const th_optarg opts[], int nopts, |
93 | 105 |
94 return TRUE; | 106 return TRUE; |
95 } | 107 } |
96 | 108 |
97 | 109 |
98 /* Process arguments, handling short and long options by | 110 /** |
99 * calling the given callback functions. | 111 * Process given array of commandline arguments, handling short |
112 * and long options by calling the respective callback functions. | |
113 * | |
114 * @param argc number of arguments | |
115 * @param argv argument list | |
116 * @param opts supported option list array | |
117 * @param nopts number of elements in the option list array | |
118 * @param handle_option callback function | |
119 * @param handle_other callback function | |
120 * @param flags processing flags | |
121 * @return return TRUE if all is well | |
100 */ | 122 */ |
101 BOOL th_args_process(int argc, char *argv[], | 123 BOOL th_args_process(int argc, char *argv[], |
102 const th_optarg *opts, const int nopts, | 124 const th_optarg *opts, const int nopts, |
103 BOOL(*handle_option)(int id, char *, char *), | 125 BOOL(*handle_option)(int id, char *, char *), |
104 BOOL(*handle_other)(char *), const int flags) | 126 BOOL(*handle_other)(char *), const int flags) |
155 | 177 |
156 return optionsOK; | 178 return optionsOK; |
157 } | 179 } |
158 | 180 |
159 | 181 |
160 /* Print help for commandline arguments/options | 182 /** |
183 * Print help for commandline arguments/options | |
184 * @param fh stdio file handle to output to | |
185 * @param opts options list array | |
186 * @param nopts number of elements in options list array | |
187 * @param flags flags (currently unused) | |
161 */ | 188 */ |
162 void th_args_help(FILE *fh, | 189 void th_args_help(FILE *fh, |
163 const th_optarg *opts, const int nopts, | 190 const th_optarg *opts, const int nopts, |
164 const int flags) | 191 const int flags) |
165 { | 192 { |