Mixe for Privacy and Anonymity in the Internet
popt.h
Go to the documentation of this file.
1 /* (C) 1998 Red Hat Software, Inc. -- Licensing details are in the COPYING
2  file accompanying popt source distributions, available from
3  ftp://ftp.redhat.com/pub/code/popt */
4 
5 #ifndef H_POPT
6 #define H_POPT
7 
8 /*#ifdef __cplusplus
9 extern "C" {
10 #endif
11 */
12 #include <stdio.h> /* for FILE * */
13 
14 #define POPT_OPTION_DEPTH 10
15 
16 #define POPT_ARG_NONE 0
17 #define POPT_ARG_STRING 1
18 #define POPT_ARG_INT 2
19 #define POPT_ARG_LONG 3
20 #define POPT_ARG_INCLUDE_TABLE 4 /* arg points to table */
21 #define POPT_ARG_CALLBACK 5 /* table-wide callback... must be
22  set first in table; arg points
23  to callback, descrip points to
24  callback data to pass */
25 #define POPT_ARG_INTL_DOMAIN 6 /* set the translation domain
26  for this table and any
27  included tables; arg points
28  to the domain string */
29 #define POPT_ARG_VAL 7 /* arg should take value val */
30 #define POPT_ARG_MASK 0x0000FFFF
31 #define POPT_ARGFLAG_ONEDASH 0x80000000 /* allow -longoption */
32 #define POPT_ARGFLAG_DOC_HIDDEN 0x40000000 /* don't show in help/usage */
33 #define POPT_ARGFLAG_STRIP 0x20000000 /* strip this arg from argv (only applies to long args) */
34 #define POPT_CBFLAG_PRE 0x80000000 /* call the callback before parse */
35 #define POPT_CBFLAG_POST 0x40000000 /* call the callback after parse */
36 #define POPT_CBFLAG_INC_DATA 0x20000000 /* use data from the include line,
37  not the subtable */
38 
39 #define POPT_ERROR_NOARG -10
40 #define POPT_ERROR_BADOPT -11
41 #define POPT_ERROR_OPTSTOODEEP -13
42 #define POPT_ERROR_BADQUOTE -15 /* only from poptParseArgString() */
43 #define POPT_ERROR_ERRNO -16 /* only from poptParseArgString() */
44 #define POPT_ERROR_BADNUMBER -17
45 #define POPT_ERROR_OVERFLOW -18
46 
47 /* poptBadOption() flags */
48 #define POPT_BADOPTION_NOALIAS (1 << 0) /* don't go into an alias */
49 
50 /* poptGetContext() flags */
51 #define POPT_CONTEXT_NO_EXEC (1 << 0) /* ignore exec expansions */
52 #define POPT_CONTEXT_KEEP_FIRST (1 << 1) /* pay attention to argv[0] */
53 #define POPT_CONTEXT_POSIXMEHARDER (1 << 2) /* options can't follow args */
54 
55 struct poptOption {
56  /*@observer@*/ /*@null@*/ const char * longName; /* may be NULL */
57  char shortName; /* may be '\0' */
58  int argInfo;
59  /*@shared@*/ /*@null@*/ void * arg; /* depends on argInfo */
60  int val; /* 0 means don't return, just update flag */
61  /*@shared@*/ /*@null@*/ const char * descrip; /* description for autohelp -- may be NULL */
62  /*@shared@*/ /*@null@*/ const char * argDescrip; /* argument description for autohelp */
63 };
64 
65 struct poptAlias {
66  /*@owned@*/ /*@null@*/ const char * longName; /* may be NULL */
67  char shortName; /* may be '\0' */
68  int argc;
69  /*@owned@*/ const char ** argv; /* must be free()able */
70 };
71 
72 extern struct poptOption poptHelpOptions[];
73 #define POPT_AUTOHELP { NULL, '\0', POPT_ARG_INCLUDE_TABLE, poptHelpOptions, \
74  0, "Help options", NULL },
75 
76 typedef struct poptContext_s * poptContext;
77 #ifndef __cplusplus
78 typedef struct poptOption * poptOption;
79 #endif
80 
84 typedef void (*poptCallbackType)(poptContext con,
85  enum poptCallbackReason reason,
86  const struct poptOption * opt,
87  const char * arg, const void * data);
88 
89 /*@only@*/ poptContext poptGetContext(/*@keep@*/ const char * name,
90  int argc, /*@keep@*/ const char ** argv,
91  /*@keep@*/ const struct poptOption * options, int flags);
93 
94 /* returns 'val' element, -1 on last item, POPT_ERROR_* on error */
96 /* returns NULL if no argument is available */
97 /*@observer@*/ /*@null@*/ const char * poptGetOptArg(poptContext con);
98 /* returns NULL if no more options are available */
99 /*@observer@*/ /*@null@*/ const char * poptGetArg(poptContext con);
100 /*@observer@*/ /*@null@*/ const char * poptPeekArg(poptContext con);
101 /*@observer@*/ /*@null@*/ const char ** poptGetArgs(poptContext con);
102 /* returns the option which caused the most recent error */
103 /*@observer@*/ const char * poptBadOption(poptContext con, int flags);
104 void poptFreeContext( /*@only@*/ poptContext con);
105 int poptStuffArgs(poptContext con, /*@keep@*/ const char ** argv);
106 int poptAddAlias(poptContext con, struct poptAlias alias, int flags);
107 int poptReadConfigFile(poptContext con, const char * fn);
108 /* like above, but reads /etc/popt and $HOME/.popt along with environment
109  vars */
110 int poptReadDefaultConfig(poptContext con, int useEnv);
111 /* argv should be freed -- this allows ', ", and \ quoting, but ' is treated
112  the same as " and both may include \ quotes */
113 int poptDupArgv(int argc, const char **argv,
114  /*@out@*/ int * argcPtr, /*@out@*/ const char *** argvPtr);
115 int poptParseArgvString(const char * s,
116  /*@out@*/ int * argcPtr, /*@out@*/ const char *** argvPtr);
117 /*@observer@*/ const char * /*const*/ poptStrerror(const int error);
118 void poptSetExecPath(poptContext con, const char * path, int allowAbsolute);
119 void poptPrintHelp(poptContext con, FILE * f, int flags);
120 void poptPrintUsage(poptContext con, FILE * f, int flags);
121 void poptSetOtherOptionHelp(poptContext con, const char * text);
122 /*@observer@*/ const char * poptGetInvocationName(poptContext con);
123 /* shuffles argv pointers to remove stripped args, returns new argc */
124 int poptStrippedArgv(poptContext con, int argc, char **argv);
125 /*
126 #ifdef __cplusplus
127 }
128 #endif
129 */
130 #endif
struct poptOption poptHelpOptions[]
Definition: popthelp.cpp:21
void poptSetExecPath(poptContext con, const char *path, int allowAbsolute)
Definition: popt.cpp:25
const char * poptPeekArg(poptContext con)
Definition: popt.cpp:640
void(* poptCallbackType)(poptContext con, enum poptCallbackReason reason, const struct poptOption *opt, const char *arg, const void *data)
Definition: popt.h:77
struct poptOption * poptOption
Definition: popt.h:71
int poptStuffArgs(poptContext con, const char **argv)
Definition: popt.cpp:744
const char * poptGetInvocationName(poptContext con)
Definition: popt.cpp:765
const char ** poptGetArgs(poptContext con)
Definition: popt.cpp:645
const char * poptGetOptArg(poptContext con)
Definition: popt.cpp:629
int poptAddAlias(poptContext con, struct poptAlias alias, int flags)
Definition: popt.cpp:682
int poptStrippedArgv(poptContext con, int argc, char **argv)
Definition: popt.cpp:769
void poptPrintHelp(poptContext con, FILE *f, int flags)
Definition: popthelp.cpp:186
int poptDupArgv(int argc, const char **argv, int *argcPtr, const char ***argvPtr)
Definition: poptparse.cpp:10
void poptResetContext(poptContext con)
Definition: popt.cpp:104
const char * poptStrerror(const int error)
Definition: popt.cpp:723
int poptGetNextOpt(poptContext con)
Definition: popt.cpp:407
void poptFreeContext(poptContext con)
Definition: popt.cpp:654
int poptReadConfigFile(poptContext con, const char *fn)
int poptParseArgvString(const char *s, int *argcPtr, const char ***argvPtr)
Definition: poptparse.cpp:39
void poptSetOtherOptionHelp(poptContext con, const char *text)
Definition: popthelp.cpp:299
const char * poptGetArg(poptContext con)
Definition: popt.cpp:635
struct poptContext_s * poptContext
Definition: popt.h:69
poptContext poptGetContext(const char *name, int argc, const char **argv, const struct poptOption *options, int flags)
Definition: popt.cpp:51
const char * poptBadOption(poptContext con, int flags)
Definition: popt.cpp:706
void poptPrintUsage(poptContext con, FILE *f, int flags)
Definition: popthelp.cpp:283
poptCallbackReason
Definition: popt.h:74
@ POPT_CALLBACK_REASON_PRE
Definition: popt.h:74
@ POPT_CALLBACK_REASON_OPTION
Definition: popt.h:76
@ POPT_CALLBACK_REASON_POST
Definition: popt.h:75
int poptReadDefaultConfig(poptContext con, int useEnv)
Definition: popt.h:58
int argc
Definition: popt.h:61
const char ** argv
Definition: popt.h:62
const char * longName
Definition: popt.h:59
char shortName
Definition: popt.h:60
int argInfo
Definition: popt.h:51
void * arg
Definition: popt.h:52
char shortName
Definition: popt.h:50
const char * argDescrip
Definition: popt.h:55
int val
Definition: popt.h:53
const char * longName
Definition: popt.h:49
const char * descrip
Definition: popt.h:54
UINT16 flags
Definition: typedefs.hpp:1
UINT8 data[PAYLOAD_SIZE]
Definition: typedefs.hpp:2