diff src/dmargs.h @ 1742:ddec147d1f90

Bring in changes from the th-libs version of commandline argument handling.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 09 Jun 2018 17:56:07 +0300
parents 7ed25973dbcb
children c801995cbb13
line wrap: on
line diff
--- a/src/dmargs.h	Sat Jun 09 17:04:33 2018 +0300
+++ b/src/dmargs.h	Sat Jun 09 17:56:07 2018 +0300
@@ -1,10 +1,12 @@
 /*
  * Simple commandline argument processing functions
  * Programmed and designed by Matti 'ccr' Hamalainen
- * (C) Copyright 2002-2015 Tecnic Software productions (TNSP)
+ * (C) Copyright 2002-2018 Tecnic Software productions (TNSP)
  *
  * Please read file 'COPYING' for information on license and distribution.
  */
+/// @file
+/// @brief Simple commandline argument processing functions
 #ifndef DMARGS_H
 #define DMARGS_H
 
@@ -14,40 +16,39 @@
 extern "C" {
 #endif
 
-/* Option flags
+/** @def Option argument flags
  */
-#define OPT_NONE             (0)    // Simple option with no arguments
-#define OPT_ARGREQ           (1)    // Option requires an argument
-#define OPT_ARGMASK          (1)    // Mask for option argument flags
+#define OPT_NONE             (0)    ///< Simple option with no arguments
+#define OPT_ARGREQ           (1)    ///< Option requires an argument
+#define OPT_ARGMASK          (1)    ///< Mask for option argument flags
 
-#define OPTH_BAILOUT         0x0001 // Bail out on errors
-#define OPTH_ONLY_OPTS       0x0010 // Handle only options
-#define OPTH_ONLY_OTHER      0x0020 // Handle only "non-options"
-#define OPTH_ONLY_MASK       0x00f0 // Mask
+/** @def Option processing flags
+ */
+#define OPTH_BAILOUT         0x0001 ///< Bail out on errors
+#define OPTH_ONLY_OPTS       0x0010 ///< Handle only options
+#define OPTH_ONLY_OTHER      0x0020 ///< Handle only "non-options"
+#define OPTH_ONLY_MASK       0x00f0 ///< Mask
 
 
-/* Option argument structure
+/** Option argument structure
  */
 typedef struct
 {
-    int id;
-    char optShort;
-    char *optLong;
-    char *desc;
-    int flags;
+    int id;           ///< Option ID (should be unique for each option)
+    char o_short;     ///< Short option name (one character)
+    char *o_long;     ///< Long option name
+    char *desc;       ///< Option description
+    int flags;        ///< Flags (see OPT_*)
 } DMOptArg;
 
 
 BOOL dmArgsProcess(int argc, char *argv[],
-     const DMOptArg optList[], int noptList,
-     BOOL (*handleOptionCB)(int, char *, char *),
-     BOOL (*handleFileCB)(char *), BOOL);
+     const DMOptArg *opts, const int nopts,
+     BOOL (*handle_option)(int id, char *, char *),
+     BOOL (*handle_other)(char *), const int flags);
 
-void dmArgsPrintHelp(FILE *,
-     const DMOptArg optList[],
-     const int noptList,
-     const int flags);
-
+void dmArgsPrintHelp(FILE *, const DMOptArg *opts,
+     const int nopts, const int flags);
 
 #ifdef __cplusplus
 }