|
Mixe for Privacy and Anonymity in the Internet
|
00001 /* (C) 1998 Red Hat Software, Inc. -- Licensing details are in the COPYING 00002 file accompanying popt source distributions, available from 00003 ftp://ftp.redhat.com/pub/code/popt */ 00004 00005 #ifndef H_POPT 00006 #define H_POPT 00007 00008 /*#ifdef __cplusplus 00009 extern "C" { 00010 #endif 00011 */ 00012 #include <stdio.h> /* for FILE * */ 00013 00014 #define POPT_OPTION_DEPTH 10 00015 00016 #define POPT_ARG_NONE 0 00017 #define POPT_ARG_STRING 1 00018 #define POPT_ARG_INT 2 00019 #define POPT_ARG_LONG 3 00020 #define POPT_ARG_INCLUDE_TABLE 4 /* arg points to table */ 00021 #define POPT_ARG_CALLBACK 5 /* table-wide callback... must be 00022 set first in table; arg points 00023 to callback, descrip points to 00024 callback data to pass */ 00025 #define POPT_ARG_INTL_DOMAIN 6 /* set the translation domain 00026 for this table and any 00027 included tables; arg points 00028 to the domain string */ 00029 #define POPT_ARG_VAL 7 /* arg should take value val */ 00030 #define POPT_ARG_MASK 0x0000FFFF 00031 #define POPT_ARGFLAG_ONEDASH 0x80000000 /* allow -longoption */ 00032 #define POPT_ARGFLAG_DOC_HIDDEN 0x40000000 /* don't show in help/usage */ 00033 #define POPT_ARGFLAG_STRIP 0x20000000 /* strip this arg from argv (only applies to long args) */ 00034 #define POPT_CBFLAG_PRE 0x80000000 /* call the callback before parse */ 00035 #define POPT_CBFLAG_POST 0x40000000 /* call the callback after parse */ 00036 #define POPT_CBFLAG_INC_DATA 0x20000000 /* use data from the include line, 00037 not the subtable */ 00038 00039 #define POPT_ERROR_NOARG -10 00040 #define POPT_ERROR_BADOPT -11 00041 #define POPT_ERROR_OPTSTOODEEP -13 00042 #define POPT_ERROR_BADQUOTE -15 /* only from poptParseArgString() */ 00043 #define POPT_ERROR_ERRNO -16 /* only from poptParseArgString() */ 00044 #define POPT_ERROR_BADNUMBER -17 00045 #define POPT_ERROR_OVERFLOW -18 00046 00047 /* poptBadOption() flags */ 00048 #define POPT_BADOPTION_NOALIAS (1 << 0) /* don't go into an alias */ 00049 00050 /* poptGetContext() flags */ 00051 #define POPT_CONTEXT_NO_EXEC (1 << 0) /* ignore exec expansions */ 00052 #define POPT_CONTEXT_KEEP_FIRST (1 << 1) /* pay attention to argv[0] */ 00053 #define POPT_CONTEXT_POSIXMEHARDER (1 << 2) /* options can't follow args */ 00054 00055 struct poptOption { 00056 /*@observer@*/ /*@null@*/ const char * longName; /* may be NULL */ 00057 char shortName; /* may be '\0' */ 00058 int argInfo; 00059 /*@shared@*/ /*@null@*/ void * arg; /* depends on argInfo */ 00060 int val; /* 0 means don't return, just update flag */ 00061 /*@shared@*/ /*@null@*/ const char * descrip; /* description for autohelp -- may be NULL */ 00062 /*@shared@*/ /*@null@*/ const char * argDescrip; /* argument description for autohelp */ 00063 }; 00064 00065 struct poptAlias { 00066 /*@owned@*/ /*@null@*/ const char * longName; /* may be NULL */ 00067 char shortName; /* may be '\0' */ 00068 int argc; 00069 /*@owned@*/ const char ** argv; /* must be free()able */ 00070 }; 00071 00072 extern struct poptOption poptHelpOptions[]; 00073 #define POPT_AUTOHELP { NULL, '\0', POPT_ARG_INCLUDE_TABLE, poptHelpOptions, \ 00074 0, "Help options", NULL }, 00075 00076 typedef struct poptContext_s * poptContext; 00077 #ifndef __cplusplus 00078 typedef struct poptOption * poptOption; 00079 #endif 00080 00081 enum poptCallbackReason { POPT_CALLBACK_REASON_PRE, 00082 POPT_CALLBACK_REASON_POST, 00083 POPT_CALLBACK_REASON_OPTION }; 00084 typedef void (*poptCallbackType)(poptContext con, 00085 enum poptCallbackReason reason, 00086 const struct poptOption * opt, 00087 const char * arg, const void * data); 00088 00089 /*@only@*/ poptContext poptGetContext(/*@keep@*/ const char * name, 00090 int argc, /*@keep@*/ const char ** argv, 00091 /*@keep@*/ const struct poptOption * options, int flags); 00092 void poptResetContext(poptContext con); 00093 00094 /* returns 'val' element, -1 on last item, POPT_ERROR_* on error */ 00095 int poptGetNextOpt(poptContext con); 00096 /* returns NULL if no argument is available */ 00097 /*@observer@*/ /*@null@*/ const char * poptGetOptArg(poptContext con); 00098 /* returns NULL if no more options are available */ 00099 /*@observer@*/ /*@null@*/ const char * poptGetArg(poptContext con); 00100 /*@observer@*/ /*@null@*/ const char * poptPeekArg(poptContext con); 00101 /*@observer@*/ /*@null@*/ const char ** poptGetArgs(poptContext con); 00102 /* returns the option which caused the most recent error */ 00103 /*@observer@*/ const char * poptBadOption(poptContext con, int flags); 00104 void poptFreeContext( /*@only@*/ poptContext con); 00105 int poptStuffArgs(poptContext con, /*@keep@*/ const char ** argv); 00106 int poptAddAlias(poptContext con, struct poptAlias alias, int flags); 00107 int poptReadConfigFile(poptContext con, const char * fn); 00108 /* like above, but reads /etc/popt and $HOME/.popt along with environment 00109 vars */ 00110 int poptReadDefaultConfig(poptContext con, int useEnv); 00111 /* argv should be freed -- this allows ', ", and \ quoting, but ' is treated 00112 the same as " and both may include \ quotes */ 00113 int poptDupArgv(int argc, const char **argv, 00114 /*@out@*/ int * argcPtr, /*@out@*/ const char *** argvPtr); 00115 int poptParseArgvString(const char * s, 00116 /*@out@*/ int * argcPtr, /*@out@*/ const char *** argvPtr); 00117 /*@observer@*/ const char * /*const*/ poptStrerror(const int error); 00118 void poptSetExecPath(poptContext con, const char * path, int allowAbsolute); 00119 void poptPrintHelp(poptContext con, FILE * f, int flags); 00120 void poptPrintUsage(poptContext con, FILE * f, int flags); 00121 void poptSetOtherOptionHelp(poptContext con, const char * text); 00122 /*@observer@*/ const char * poptGetInvocationName(poptContext con); 00123 /* shuffles argv pointers to remove stripped args, returns new argc */ 00124 int poptStrippedArgv(poptContext con, int argc, char **argv); 00125 /* 00126 #ifdef __cplusplus 00127 } 00128 #endif 00129 */ 00130 #endif
1.7.6.1