annotate th_args.h @ 322:b9c15c57dc8f

Clean up message functions, add new printMsgQ() helper function for messages that should not go into the log file. Add skeleton help function, accessible via F1 key. And other cleanups.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 11 Jun 2011 09:48:26 +0300
parents 59992d930e70
children
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 */
182
59992d930e70 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
21 #define OPT_NONE (0) /* Simple option with no arguments */
59992d930e70 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
22 #define OPT_ARGREQ (1) /* Option's argument is required */
59992d930e70 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
23 #define OPT_ARGOPT (3) /* Option's argument is optional */
81
69aed051f84d Synced th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
24 #define OPT_ARGMASK (3) /* Mask for option argument flags */
182
59992d930e70 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
25 #define OPT_REQUIRED (4) /* This option is required to be given */
0
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
26
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
27
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
28 typedef struct {
81
69aed051f84d Synced th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
29 int optID;
69aed051f84d Synced th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
30 char optShort;
69aed051f84d Synced th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
31 char *optLong;
69aed051f84d Synced th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
32 char *optDesc;
69aed051f84d Synced th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
33 int optFlags;
0
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
34 } optarg_t;
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
35
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
36
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
37 BOOL th_args_process(int argc, char *argv[],
182
59992d930e70 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
38 optarg_t argList[], int argListN,
59992d930e70 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
39 BOOL (*handleOpt)(int, char *, char *),
59992d930e70 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
40 BOOL (*handleFile)(char *), BOOL);
0
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
41
182
59992d930e70 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
42 void th_args_help(FILE *, optarg_t optList[], int optListN, char *, char *);
0
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
43
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
44 #ifdef __cplusplus
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
45 }
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
46 #endif
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
47 #endif /* _TH_ARGS */