Added getoptions() and made minor adjustment to poptReadDefaultOptions()

svn:r25
This commit is contained in:
Bruce Montrose
2002-07-03 16:31:22 +00:00
parent 419781685c
commit a3609f4d5d
4 changed files with 108 additions and 7 deletions
+5 -2
View File
@@ -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;
}
+13 -2
View File
@@ -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