[or-cvs] Added getoptions() and made minor adjustment to poptReadDef...

montrose at seul.org montrose at seul.org
Wed Jul 3 16:31:24 UTC 2002


Update of /home/or/cvsroot/src/common
In directory moria.seul.org:/tmp/cvs-serv12155/src/common

Modified Files:
	config.c config.h 
Log Message:
Added getoptions() and made minor adjustment to poptReadDefaultOptions()


Index: config.c
===================================================================
RCS file: /home/or/cvsroot/src/common/config.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- config.c	28 Jun 2002 18:14:55 -0000	1.2
+++ config.c	3 Jul 2002 16:31:22 -0000	1.3
@@ -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 @@
    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 @@
       sprintf(fname,"~/.%src",cmd);
       c = poptReadOptions(optCon,fname);
    }
-   return c;
+   return (c == INT_MIN) ? -1 : c;
 }
 

Index: config.h
===================================================================
RCS file: /home/or/cvsroot/src/common/config.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- config.h	26 Jun 2002 22:45:50 -0000	1.1.1.1
+++ config.h	3 Jul 2002 16:31:22 -0000	1.2
@@ -8,6 +8,9 @@
 /*
  * Changes :
  * $Log$
+ * 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
  *
@@ -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
@@ -83,6 +88,12 @@
 
 /* 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



More information about the tor-commits mailing list