Mercurial > hg > dmlib
diff src/dmargs.h @ 860:daebbf28953d
The argument handling API in dmargs* was synced with th-libs.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 22 Nov 2014 18:50:07 +0200 |
parents | 1e5cf1144f36 |
children | 27949209238b |
line wrap: on
line diff
--- a/src/dmargs.h Sat Nov 22 18:45:12 2014 +0200 +++ b/src/dmargs.h Sat Nov 22 18:50:07 2014 +0200 @@ -1,7 +1,7 @@ /* * Simple commandline argument processing functions * Programmed and designed by Matti 'ccr' Hamalainen - * (C) Copyright 2002-2008 Tecnic Software productions (TNSP) + * (C) Copyright 2002-2014 Tecnic Software productions (TNSP) * * Please read file 'COPYING' for information on license and distribution. */ @@ -17,13 +17,20 @@ /* Option flags */ -#define OPT_NONE (0) // Simple option with no arguments -#define OPT_ARGREQ (1) // Option's argument is required -#define OPT_ARGOPT (3) // Option's argument is optional -#define OPT_ARGMASK (3) // Mask for option argument flags -#define OPT_REQUIRED (4) // This option is required to be given +#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 -typedef struct { +#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 + */ +typedef struct +{ int id; char optShort; char *optLong; @@ -31,12 +38,17 @@ int flags; } DMOptArg; + BOOL dmArgsProcess(int argc, char *argv[], - DMOptArg argList[], int argListN, - BOOL (*handleOpt)(int, char *, char *), - BOOL (*handleFile)(char *), BOOL); + const DMOptArg optList[], int noptList, + BOOL (*handleOptionCB)(int, char *, char *), + BOOL (*handleFileCB)(char *), BOOL); -void dmArgsPrintHelp(FILE *, DMOptArg optList[], int optListN); +void dmArgsPrintHelp(FILE *, + const DMOptArg optList[], + const int noptList, + const int flags); + #ifdef __cplusplus }