annotate th_args.h @ 0:728243125263

Import.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 20 Mar 2008 00:15:03 +0000
parents
children 69aed051f84d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 /*
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2 * Simple commandline argument processing function
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
3 * Programmed and designed by Matti 'ccr' Hamalainen
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
4 * (C) Copyright 2002-2008 Tecnic Software productions (TNSP)
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5 *
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
6 * Please read file 'COPYING' for information on license and distribution.
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7 */
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8 #ifndef _TH_ARGS
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9 #define _TH_ARGS
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11 #ifdef __cplusplus
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
12 extern "C" {
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
13 #endif
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
14
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
15 #include <stdio.h>
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
16 #include "th_util.h"
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
17
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
18
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
19 /* Option flags
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
20 */
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
21 #define OPT_NONE (0) /* Simple option with no arguments */
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
22
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
23 #define OPT_ARGREQ (1) /* Option's argument is required */
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
24 #define OPT_ARGOPT (3) /* Option's argument is optional */
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
25 #define OPT_ARGMASK (3) /* Mask for option argument flags */
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
26
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
27 #define OPT_REQUIRED (4) /* This option is required to be given */
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
28
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
29
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
30 typedef struct {
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
31 int optID;
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
32 char optShort;
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
33 char *optLong;
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
34 char *optDesc;
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
35 int optFlags;
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
36 } optarg_t;
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
37
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
38
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
39 BOOL th_args_process(int argc, char *argv[],
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
40 optarg_t argList[], int argListN,
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
41 BOOL (*handleOpt)(int, char *, char *),
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
42 BOOL (*handleFile)(char *), BOOL);
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
43
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
44 void th_args_help(FILE *, optarg_t optList[], int optListN,
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
45 char *, char *);
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
46
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
47 #ifdef __cplusplus
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
48 }
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
49 #endif
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
50 #endif /* _TH_ARGS */