aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorBruce Montrose <montrose@itd.nrl.navy.mil>2002-07-03 16:31:22 +0000
committerBruce Montrose <montrose@itd.nrl.navy.mil>2002-07-03 16:31:22 +0000
commita3609f4d5d66ce4eeb4492422e7a0ec2d623a43a (patch)
treec1f5d2f144c45c1b3017b97f8bb3fcbe550e411f /src/common
parent419781685cc7fcccb18634cdd23b639ea73ba39f (diff)
downloadtor-a3609f4d5d66ce4eeb4492422e7a0ec2d623a43a.tar.gz
tor-a3609f4d5d66ce4eeb4492422e7a0ec2d623a43a.zip
Added getoptions() and made minor adjustment to poptReadDefaultOptions()
svn:r25
Diffstat (limited to 'src/common')
-rw-r--r--src/common/config.c7
-rw-r--r--src/common/config.h15
2 files changed, 18 insertions, 4 deletions
diff --git a/src/common/config.c b/src/common/config.c
index 1d2f1a166e..3efcbe207a 100644
--- a/src/common/config.c
+++ b/src/common/config.c
@@ -8,6 +8,9 @@
/*
* Changes :
* $Log$
+ * Revision 1.3 2002/07/03 16:31:22 montrose
+ * Added getoptions() and made minor adjustment to poptReadDefaultOptions()
+ *
* Revision 1.2 2002/06/28 18:14:55 montrose
* Added poptReadOptions() and poptReadDefaultOptions()
*
@@ -360,7 +363,7 @@ RETURN VALUE: INT_MIN = problem opening config file, else standard poptGetNextOp
FILE *fp;
int argc, c;
char **argv;
- char line[256];
+ char line[1024];
line[0] = line[1] = '-'; /* prepend expected long name option flag */
fp = open_config(fname);
if ( fp == NULL ) return INT_MIN;
@@ -402,6 +405,6 @@ RETURN VALUE: same as poptReadOptions()
sprintf(fname,"~/.%src",cmd);
c = poptReadOptions(optCon,fname);
}
- return c;
+ return (c == INT_MIN) ? -1 : c;
}
diff --git a/src/common/config.h b/src/common/config.h
index 15d9b1e5d7..7642086b1f 100644
--- a/src/common/config.h
+++ b/src/common/config.h
@@ -8,8 +8,11 @@
/*
* Changes :
* $Log$
- * Revision 1.1 2002/06/26 22:45:50 arma
- * Initial revision
+ * Revision 1.2 2002/07/03 16:31:22 montrose
+ * Added getoptions() and made minor adjustment to poptReadDefaultOptions()
+ *
+ * Revision 1.1.1.1 2002/06/26 22:45:50 arma
+ * initial commit: current code
*
* Revision 1.7 2002/04/02 14:27:11 badbytes
* Final finishes.
@@ -39,6 +42,8 @@
# include <stdio.h>
+#include <popt.h>
+
/* enumeration of types which option values can take */
#define CONFIG_TYPE_STRING 0
#define CONFIG_TYPE_CHAR 1
@@ -84,5 +89,11 @@ int close_config(FILE *f);
/* parse the config file and obtain required option values */
int parse_config(FILE *f, config_opt_t *option);
+/* parse popt-style options in a config file */
+int poptReadOptions(poptContext optCon, const unsigned char *fname);
+
+/* parse popt-style options from /etc/<cmd>rc and ~/.<cmd>rc */
+int poptReadDefaultOptions(const char *cmd, poptContext optCon);
+
#define __CONFIG_H
#endif