/usr/include/libHX/option.h is in libhx-dev 3.11-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | #ifndef _LIBHX_OPTION_H
#define _LIBHX_OPTION_H 1
#ifdef __cplusplus
# include <cstddef>
# include <cstdio>
#else
# include <stddef.h>
# include <stdio.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __libhx_internal_hxmc_t_defined
#define __libhx_internal_hxmc_t_defined 1
typedef char hxmc_t;
#endif
struct HXoption;
/*
* FORMAT.C
*/
extern struct HXformat_map *HXformat_init(void);
extern void HXformat_free(struct HXformat_map *);
extern int HXformat_add(struct HXformat_map *, const char *, const void *,
unsigned int);
extern int HXformat2_aprintf(const struct HXformat_map *,
hxmc_t **, const char *);
extern int HXformat2_sprintf(const struct HXformat_map *,
char *, size_t, const char *);
extern int HXformat2_fprintf(const struct HXformat_map *,
FILE *, const char *);
/*
* OPT.C
*/
enum {
/* .type */
HXTYPE_NONE = 0,
/* for opt: set specific integer value */
HXTYPE_VAL,
/* for opt: set specific string value */
HXTYPE_SVAL,
/*
* accept a string "yes", "no", "true", "false" and
* put into *(unsigned int*)
*/
HXTYPE_BOOL,
/* read _one byte_ and put it into *(unsigned char *) */
HXTYPE_BYTE,
/* read an integer/float (sscanf %d/%o/%x/%f) */
HXTYPE_UCHAR,
HXTYPE_CHAR,
HXTYPE_USHORT,
HXTYPE_SHORT,
HXTYPE_UINT,
HXTYPE_INT,
HXTYPE_ULONG,
HXTYPE_LONG,
HXTYPE_ULLONG,
HXTYPE_LLONG,
HXTYPE_FLOAT,
HXTYPE_DOUBLE,
/* read string and put into *(const char **) */
HXTYPE_STRING,
HXTYPE_STRP, /* (const char **) */
HXTYPE_STRDQ,
HXTYPE_UINT8,
HXTYPE_UINT16,
HXTYPE_UINT32,
HXTYPE_UINT64,
HXTYPE_INT8,
HXTYPE_INT16,
HXTYPE_INT32,
HXTYPE_INT64,
HXTYPE_MCSTR, /* put into hxmc_t */
HXTYPE_XSNTMARK, /* sentinel marker */
/* .type extra flags */
/* argument is optional */
HXOPT_OPTIONAL = 1 << 6,
/* increase pointed variable */
HXOPT_INC = 1 << 7,
/* decrease pointed variable */
HXOPT_DEC = 1 << 8,
/* negate input first */
HXOPT_NOT = 1 << 9,
/* or pointed variable with input */
HXOPT_OR = 1 << 10,
/* and pointed variable with input */
HXOPT_AND = 1 << 11,
/* xor pointed variable with input */
HXOPT_XOR = 1 << 12,
HXFORMAT_IMMED = 1 << 13,
/* HX_getopt() flags */
HXOPT_PTHRU = 1 << 0,
HXOPT_DESTROY_OLD = 1 << 1,
HXOPT_QUIET = 1 << 2,
HXOPT_HELPONERR = 1 << 3,
HXOPT_USAGEONERR = 1 << 4,
/* Return types for HX_getopt() */
HXOPT_ERR_UNKN = 1,
HXOPT_ERR_VOID,
HXOPT_ERR_MIS,
SHCONF_ONE = 1 << 0, /* only read one configuration file */
};
struct HXoptcb {
const char *arg0;
const struct HXoption *table, *current;
const char *data;
union {
double data_dbl;
long data_long;
};
const char *match_ln;
char match_sh;
};
struct HXoption {
const char *ln;
char sh;
unsigned int type;
void *ptr, *uptr;
void (*cb)(const struct HXoptcb *);
int val;
const char *sval, *help, *htyp;
};
extern int HX_getopt(const struct HXoption *, int *, const char ***,
unsigned int);
extern void HX_getopt_help(const struct HXoptcb *, FILE *);
extern void HX_getopt_help_cb(const struct HXoptcb *);
extern void HX_getopt_usage(const struct HXoptcb *, FILE *);
extern void HX_getopt_usage_cb(const struct HXoptcb *);
extern int HX_shconfig(const char *, const struct HXoption *);
extern struct HXmap *HX_shconfig_map(const char *);
extern int HX_shconfig_pv(const char **, const char *,
const struct HXoption *, unsigned int);
extern void HX_shconfig_free(const struct HXoption *);
#ifdef __cplusplus
} /* extern "C" */
#endif
#ifndef __cplusplus
# define HXOPT_AUTOHELP \
{.ln = "help", .sh = '?', .type = HXTYPE_NONE, \
.cb = HX_getopt_help_cb, .help = "Show this help message"}, \
{.ln = "usage", .type = HXTYPE_NONE, \
.cb = HX_getopt_usage_cb, \
.help = "Display brief usage message"}
# define HXOPT_TABLEEND {.type = HXTYPE_XSNTMARK}
#else
# define HXOPT_AUTOHELP \
{NULL, '?', HXTYPE_NONE, NULL, NULL, HX_getopt_help_cb, \
0, NULL, "Show this help message"}
# define HXOPT_TABLEEND {NULL, 0, HXTYPE_XSNTMARK}
#endif
#endif /* _LIBHX_OPTION_H */
|