comparison th_args.h @ 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 54081d784d75
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 function
8 #ifndef TH_ARGS 10 #ifndef TH_ARGS
9 #define TH_ARGS 11 #define TH_ARGS
10 12
11 #include "th_util.h" 13 #include "th_util.h"
12 #include <stdio.h> 14 #include <stdio.h>
13 15
14 #ifdef __cplusplus 16 #ifdef __cplusplus
15 extern "C" { 17 extern "C" {
16 #endif 18 #endif
17 19
18 /* Option flags 20 /** @def Option argument flags
19 */ 21 */
20 #define OPT_NONE (0) // Simple option with no arguments 22 #define OPT_NONE (0) ///< Simple option with no arguments
21 #define OPT_ARGREQ (1) // Option requires an argument 23 #define OPT_ARGREQ (1) ///< Option requires an argument
22 #define OPT_ARGMASK (1) // Mask for option argument flags 24 #define OPT_ARGMASK (1) ///< Mask for option argument flags
23 25
24 #define OPTH_BAILOUT 0x0001 // Bail out on errors 26 /** @def Option processing flags
25 #define OPTH_ONLY_OPTS 0x0010 // Handle only options 27 */
26 #define OPTH_ONLY_OTHER 0x0020 // Handle only "non-options" 28 #define OPTH_BAILOUT 0x0001 ///< Bail out on errors
27 #define OPTH_ONLY_MASK 0x00f0 // Mask 29 #define OPTH_ONLY_OPTS 0x0010 ///< Handle only options
30 #define OPTH_ONLY_OTHER 0x0020 ///< Handle only "non-options"
31 #define OPTH_ONLY_MASK 0x00f0 ///< Mask
28 32
29 33
30 /* Option argument structure 34 /** Option argument structure
31 */ 35 */
32 typedef struct 36 typedef struct
33 { 37 {
34 int id; 38 int id; ///< Option ID (should be unique for each option)
35 char o_short; 39 char o_short; ///< Short option name (one character)
36 char *o_long; 40 char *o_long; ///< Long option name
37 char *desc; 41 char *desc; ///< Option description
38 int flags; 42 int flags; ///< Flags (see OPT_*)
39 } th_optarg; 43 } th_optarg;
40 44
41 45
42 BOOL th_args_process(int argc, char *argv[], 46 BOOL th_args_process(int argc, char *argv[],
43 const th_optarg *opts, const int nopts, 47 const th_optarg *opts, const int nopts,