annotate src/dmargs.h @ 2294:7f6ba3b32f54

Cleanups.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 03 Jul 2019 10:28:43 +0300
parents ddec147d1f90
children c801995cbb13
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 /*
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2 * Simple commandline argument processing functions
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
3 * Programmed and designed by Matti 'ccr' Hamalainen
1742
ddec147d1f90 Bring in changes from the th-libs version of commandline argument handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 1554
diff changeset
4 * (C) Copyright 2002-2018 Tecnic Software productions (TNSP)
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5 *
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
6 * Please read file 'COPYING' for information on license and distribution.
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7 */
1742
ddec147d1f90 Bring in changes from the th-libs version of commandline argument handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 1554
diff changeset
8 /// @file
ddec147d1f90 Bring in changes from the th-libs version of commandline argument handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 1554
diff changeset
9 /// @brief Simple commandline argument processing functions
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10 #ifndef DMARGS_H
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11 #define DMARGS_H
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
12
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
13 #include "dmlib.h"
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
14
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
15 #ifdef __cplusplus
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
16 extern "C" {
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
17 #endif
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
18
1742
ddec147d1f90 Bring in changes from the th-libs version of commandline argument handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 1554
diff changeset
19 /** @def Option argument flags
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
20 */
1742
ddec147d1f90 Bring in changes from the th-libs version of commandline argument handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 1554
diff changeset
21 #define OPT_NONE (0) ///< Simple option with no arguments
ddec147d1f90 Bring in changes from the th-libs version of commandline argument handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 1554
diff changeset
22 #define OPT_ARGREQ (1) ///< Option requires an argument
ddec147d1f90 Bring in changes from the th-libs version of commandline argument handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 1554
diff changeset
23 #define OPT_ARGMASK (1) ///< Mask for option argument flags
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
24
1742
ddec147d1f90 Bring in changes from the th-libs version of commandline argument handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 1554
diff changeset
25 /** @def Option processing flags
ddec147d1f90 Bring in changes from the th-libs version of commandline argument handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 1554
diff changeset
26 */
ddec147d1f90 Bring in changes from the th-libs version of commandline argument handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 1554
diff changeset
27 #define OPTH_BAILOUT 0x0001 ///< Bail out on errors
ddec147d1f90 Bring in changes from the th-libs version of commandline argument handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 1554
diff changeset
28 #define OPTH_ONLY_OPTS 0x0010 ///< Handle only options
ddec147d1f90 Bring in changes from the th-libs version of commandline argument handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 1554
diff changeset
29 #define OPTH_ONLY_OTHER 0x0020 ///< Handle only "non-options"
ddec147d1f90 Bring in changes from the th-libs version of commandline argument handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 1554
diff changeset
30 #define OPTH_ONLY_MASK 0x00f0 ///< Mask
860
daebbf28953d The argument handling API in dmargs* was synced with th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents: 812
diff changeset
31
daebbf28953d The argument handling API in dmargs* was synced with th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents: 812
diff changeset
32
1742
ddec147d1f90 Bring in changes from the th-libs version of commandline argument handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 1554
diff changeset
33 /** Option argument structure
860
daebbf28953d The argument handling API in dmargs* was synced with th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents: 812
diff changeset
34 */
daebbf28953d The argument handling API in dmargs* was synced with th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents: 812
diff changeset
35 typedef struct
daebbf28953d The argument handling API in dmargs* was synced with th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents: 812
diff changeset
36 {
1742
ddec147d1f90 Bring in changes from the th-libs version of commandline argument handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 1554
diff changeset
37 int id; ///< Option ID (should be unique for each option)
ddec147d1f90 Bring in changes from the th-libs version of commandline argument handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 1554
diff changeset
38 char o_short; ///< Short option name (one character)
ddec147d1f90 Bring in changes from the th-libs version of commandline argument handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 1554
diff changeset
39 char *o_long; ///< Long option name
ddec147d1f90 Bring in changes from the th-libs version of commandline argument handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 1554
diff changeset
40 char *desc; ///< Option description
ddec147d1f90 Bring in changes from the th-libs version of commandline argument handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 1554
diff changeset
41 int flags; ///< Flags (see OPT_*)
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
42 } DMOptArg;
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
43
860
daebbf28953d The argument handling API in dmargs* was synced with th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents: 812
diff changeset
44
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
45 BOOL dmArgsProcess(int argc, char *argv[],
1742
ddec147d1f90 Bring in changes from the th-libs version of commandline argument handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 1554
diff changeset
46 const DMOptArg *opts, const int nopts,
ddec147d1f90 Bring in changes from the th-libs version of commandline argument handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 1554
diff changeset
47 BOOL (*handle_option)(int id, char *, char *),
ddec147d1f90 Bring in changes from the th-libs version of commandline argument handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 1554
diff changeset
48 BOOL (*handle_other)(char *), const int flags);
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
49
1742
ddec147d1f90 Bring in changes from the th-libs version of commandline argument handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 1554
diff changeset
50 void dmArgsPrintHelp(FILE *, const DMOptArg *opts,
ddec147d1f90 Bring in changes from the th-libs version of commandline argument handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 1554
diff changeset
51 const int nopts, const int flags);
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
52
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
53 #ifdef __cplusplus
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
54 }
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
55 #endif
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
56 #endif // DMARGS_H