Mercurial > hg > th-libs
diff th_args.h @ 0:bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
here, because it's cluttered and commit messages are mostly crap.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 26 Mar 2008 04:41:58 +0200 |
parents | |
children | a25f5d22483e |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/th_args.h Wed Mar 26 04:41:58 2008 +0200 @@ -0,0 +1,50 @@ +/* + * Simple commandline argument processing function + * Programmed and designed by Matti 'ccr' Hamalainen + * (C) Copyright 2002-2008 Tecnic Software productions (TNSP) + * + * Please read file 'COPYING' for information on license and distribution. + */ +#ifndef _TH_ARGS +#define _TH_ARGS + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdio.h> +#include "th_util.h" + + +/* 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 */ + + +typedef struct { + int optID; + char optShort; + char *optLong; + char *optDesc; + int optFlags; +} optarg_t; + + +BOOL th_args_process(int argc, char *argv[], + optarg_t argList[], int argListN, + BOOL (*handleOpt)(int, char *, char *), + BOOL (*handleFile)(char *), BOOL); + +void th_args_help(FILE *, optarg_t optList[], int optListN, + char *, char *); + +#ifdef __cplusplus +} +#endif +#endif /* _TH_ARGS */