1 /*
2  * Copyright 2011-2018 Brad Lanam, Walnut Creek, CA
3  */
4 
5 #ifndef DI_INC_GETOPTN_H_
6 #define DI_INC_GETOPTN_H_
7 
8 #if defined(TEST_GETOPTN)
9 # include "gconfig.h"
10 #else
11 # include "config.h"
12 #endif
13 
14 #if _sys_types \
15     && ! defined (DI_INC_SYS_TYPES_H) /* xenix */
16 # define DI_INC_SYS_TYPES_H
17 # include <sys/types.h>
18 #endif
19 
20 #if ! defined (TRUE)
21 # define TRUE             1
22 #endif
23 #if ! defined (FALSE)
24 # define FALSE            0
25 #endif
26 
27 #define GETOPTN_NOTFOUND -1
28 
29   /* option style */
30   /* GETOPTN_LEGACY:
31    *    -ab  processes both -a and -b flags.
32    * GETOPTN_MODERN:
33    *    -ab  processes -ab flag.
34    */
35 #define GETOPTN_LEGACY      'l'
36 #define GETOPTN_MODERN      'm'
37 
38   /* option types */
39 #define GETOPTN_BOOL        0    /* flips the value */
40 #define GETOPTN_INT         1
41 #define GETOPTN_LONG        2
42 #define GETOPTN_DOUBLE      3
43 #define GETOPTN_STRING      4
44 #define GETOPTN_STRPTR      5
45 #define GETOPTN_FUNC_BOOL   6
46 #define GETOPTN_FUNC_VALUE  7
47 #define GETOPTN_ALIAS       8
48 #define GETOPTN_IGNORE      9
49 #define GETOPTN_SIZET      10
50 
51 typedef struct {
52   const char    *option;
53   int           option_type;
54   void          *valptr;
55   Size_t        valsiz;
56   void          *value2;
57 } getoptn_opt_t;
58 
59 extern int getoptn _((int style, int argc, const char * const argv [],
60       Size_t optcount, getoptn_opt_t opts [], int *errorCount));
61 
62 #endif /*DI_INC_GETOPTN_H_ */
63