* gcustom-layout.c, gprefs.c: Make the preferences dialog
[midnight-commander.git] / src / popt.h
blobe21604949b22da4fc6f41495e459212e5596d350
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 */
5 #ifndef H_POPT
6 #define H_POPT
8 #include <stdio.h> /* for FILE * */
10 #define POPT_OPTION_DEPTH 10
12 #define POPT_ARG_NONE 0
13 #define POPT_ARG_STRING 1
14 #define POPT_ARG_INT 2
15 #define POPT_ARG_LONG 3
16 #define POPT_ARG_INCLUDE_TABLE 4 /* arg points to table */
17 #define POPT_ARG_CALLBACK 5 /* table-wide callback... must be
18 set first in table; arg points
19 to callback, descrip points to
20 callback data to pass */
21 #define POPT_ARG_INTL_DOMAIN 6 /* set the translation domain
22 for this table and any
23 included tables; arg points
24 to the domain string */
25 #define POPT_ARG_MASK 0x0000FFFF
26 #define POPT_ARGFLAG_ONEDASH 0x80000000 /* allow -longoption */
27 #define POPT_ARGFLAG_DOC_HIDDEN 0x40000000 /* don't show in help/usage */
28 #define POPT_CBFLAG_PRE 0x80000000 /* call the callback before parse */
29 #define POPT_CBFLAG_POST 0x40000000 /* call the callback after parse */
30 #define POPT_CBFLAG_INC_DATA 0x20000000 /* use data from the include line,
31 not the subtable */
33 #define POPT_ERROR_NOARG -10
34 #define POPT_ERROR_BADOPT -11
35 #define POPT_ERROR_OPTSTOODEEP -13
36 #define POPT_ERROR_BADQUOTE -15 /* only from poptParseArgString() */
37 #define POPT_ERROR_ERRNO -16 /* only from poptParseArgString() */
38 #define POPT_ERROR_BADNUMBER -17
39 #define POPT_ERROR_OVERFLOW -18
41 /* poptBadOption() flags */
42 #define POPT_BADOPTION_NOALIAS (1 << 0) /* don't go into an alias */
44 /* poptGetContext() flags */
45 #define POPT_CONTEXT_NO_EXEC (1 << 0) /* ignore exec expansions */
46 #define POPT_CONTEXT_KEEP_FIRST (1 << 1) /* pay attention to argv[0] */
47 #define POPT_CONTEXT_POSIXMEHARDER (1 << 2) /* options can't follow args */
49 struct poptOption {
50 const char * longName; /* may be NULL */
51 char shortName; /* may be '\0' */
52 int argInfo;
53 void * arg; /* depends on argInfo */
54 int val; /* 0 means don't return, just update flag */
55 char * descrip; /* description for autohelp -- may be NULL */
56 char * argDescrip; /* argument description for autohelp */
59 struct poptAlias {
60 char * longName; /* may be NULL */
61 char shortName; /* may be '\0' */
62 int argc;
63 char ** argv; /* must be free()able */
66 extern struct poptOption poptHelpOptions[];
67 #define POPT_AUTOHELP { NULL, '\0', POPT_ARG_INCLUDE_TABLE, poptHelpOptions, \
68 0, "Help options", NULL },
70 typedef struct poptContext_s * poptContext;
71 #ifndef __cplusplus
72 typedef struct poptOption * poptOption;
73 #endif
75 enum poptCallbackReason { POPT_CALLBACK_REASON_PRE,
76 POPT_CALLBACK_REASON_POST,
77 POPT_CALLBACK_REASON_OPTION };
78 typedef void (*poptCallbackType)(poptContext con,
79 enum poptCallbackReason reason,
80 const struct poptOption * opt,
81 const char * arg, void * data);
83 poptContext poptGetContext(char * name, int argc, char ** argv,
84 const struct poptOption * options, int flags);
85 void poptResetContext(poptContext con);
87 /* returns 'val' element, -1 on last item, POPT_ERROR_* on error */
88 int poptGetNextOpt(poptContext con);
89 /* returns NULL if no argument is available */
90 char * poptGetOptArg(poptContext con);
91 /* returns NULL if no more options are available */
92 char * poptGetArg(poptContext con);
93 char * poptPeekArg(poptContext con);
94 char ** poptGetArgs(poptContext con);
95 /* returns the option which caused the most recent error */
96 char * poptBadOption(poptContext con, int flags);
97 void poptFreeContext(poptContext con);
98 int poptStuffArgs(poptContext con, char ** argv);
99 int poptAddAlias(poptContext con, struct poptAlias alias, int flags);
100 int poptReadConfigFile(poptContext con, char * fn);
101 /* like above, but reads /etc/popt and $HOME/.popt along with environment
102 vars */
103 int poptReadDefaultConfig(poptContext con, int useEnv);
104 /* argv should be freed -- this allows ', ", and \ quoting, but ' is treated
105 the same as " and both may include \ quotes */
106 int poptParseArgvString(char * s, int * argcPtr, char *** argvPtr);
107 const char * poptStrerror(const int error);
108 void poptSetExecPath(poptContext con, const char * path, int allowAbsolute);
109 void poptPrintHelp(poptContext con, FILE * f, int flags);
110 void poptPrintUsage(poptContext con, FILE * f, int flags);
111 void poptSetOtherOptionHelp(poptContext con, const char * text);
112 const char * poptGetInvocationName(poptContext con);
114 #endif