summaryrefslogtreecommitdiff
path: root/popt.h
diff options
context:
space:
mode:
authorjbj <jbj>2008-12-19 20:43:38 +0000
committerjbj <jbj>2008-12-19 20:43:38 +0000
commit0905160cbdec9602335b4e485b9e6fa90c253bed (patch)
tree5b9d63a496ead84dafbad9850a9f47d283d211b0 /popt.h
parent088df65acb96ae079f5e74fcab6a453294fb2cd1 (diff)
downloadlibpopt-0905160cbdec9602335b4e485b9e6fa90c253bed.tar.gz
- add poptInit/poptFini/poptReadConfigFiles/poptSaneFile routines.
Diffstat (limited to 'popt.h')
-rw-r--r--popt.h67
1 files changed, 58 insertions, 9 deletions
diff --git a/popt.h b/popt.h
index 1d6163f..c6762f5 100644
--- a/popt.h
+++ b/popt.h
@@ -98,6 +98,7 @@
#define POPT_ERROR_BADOPERATION -19 /*!< mutually exclusive logical operations requested */
#define POPT_ERROR_NULLARG -20 /*!< opt->arg should not be NULL */
#define POPT_ERROR_MALLOC -21 /*!< memory allocation failed */
+#define POPT_ERROR_BADCONFIG -22 /*!< config file failed sanity test */
/*@}*/
/** \ingroup popt
@@ -237,6 +238,15 @@ typedef void (*poptCallbackType) (poptContext con,
/*@modifies internalState @*/;
/** \ingroup popt
+ * Destroy context.
+ * @param con context
+ * @return NULL always
+ */
+/*@null@*/
+poptContext poptFreeContext( /*@only@*/ /*@null@*/ poptContext con)
+ /*@modifies con @*/;
+
+/** \ingroup popt
* Initialize popt context.
* @param name context name (usually argv[0] program name)
* @param argc no. of arguments
@@ -255,6 +265,31 @@ poptContext poptGetContext(
/*@modifies internalState @*/;
/** \ingroup popt
+ * Destroy context (alternative implementation).
+ * @param con context
+ * @return NULL always
+ */
+/*@null@*/
+poptContext poptFini( /*@only@*/ /*@null@*/ poptContext con)
+ /*@modifies con @*/;
+
+/** \ingroup popt
+ * Initialize popt context (alternative implementation).
+ * This routine does poptGetContext() and then poptReadConfigFiles().
+ * @param argc no. of arguments
+ * @param argv argument array
+ * @param options address of popt option table
+ * @param configPaths colon separated file path(s) to read.
+ * @return initialized popt context (NULL on error).
+ */
+/*@only@*/ /*@null@*/ /*@unused@*/
+poptContext poptInit(int argc, /*@dependent@*/ /*@keep@*/ const char ** argv,
+ /*@dependent@*/ /*@keep@*/ const struct poptOption * options,
+ /*@null@*/ const char * configPaths)
+ /*@globals fileSystem, internalState @*/
+ /*@modifies fileSystem, internalState @*/;
+
+/** \ingroup popt
* Reinitialize popt context.
* @param con context
*/
@@ -318,15 +353,6 @@ const char * poptBadOption(/*@null@*/poptContext con, unsigned int flags)
/*@*/;
/** \ingroup popt
- * Destroy context.
- * @param con context
- * @return NULL always
- */
-/*@null@*/
-poptContext poptFreeContext( /*@only@*/ /*@null@*/ poptContext con)
- /*@modifies con @*/;
-
-/** \ingroup popt
* Add arguments to context.
* @param con context
* @param argv argument array, NULL terminated
@@ -371,6 +397,29 @@ int poptReadConfigFile(poptContext con, const char * fn)
errno, fileSystem, internalState @*/;
/** \ingroup popt
+ * Perform sanity checks on a file path.
+ * @param fn file path
+ * @return 0 on OK, 1 on NOTOK.
+ */
+int poptSaneFile(const char * fn)
+ /*@globals errno, internalState @*/
+ /*@modifies errno, internalState @*/;
+
+/** \ingroup popt
+ * Read configuration file(s).
+ * Colon separated files to read, looping over poptReadConfigFile().
+ * Note that an '@' character preceeding a path in the list will
+ * also perform additional sanity checks on the file before reading.
+ * @param con context
+ * @param paths colon separated file name(s) to read
+ * @return 0 on success, POPT_ERROR_BADCONFIG on failure
+ */
+int poptReadConfigFiles(poptContext con, /*@null@*/ const char * paths)
+ /*@globals errno, fileSystem, internalState @*/
+ /*@modifies con->execs, con->numExecs,
+ errno, fileSystem, internalState @*/;
+
+/** \ingroup popt
* Read default configuration from /etc/popt and $HOME/.popt.
* @param con context
* @param useEnv (unused)