[or-cvs] Add daemon option and bool config type
Nick Mathewson
nickm at seul.org
Mon Mar 17 02:27:21 UTC 2003
Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/tmp/cvs-serv1448/src/or
Modified Files:
config.c
Log Message:
Add daemon option and bool config type
Index: config.c
===================================================================
RCS file: /home/or/cvsroot/src/or/config.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- config.c 26 Jan 2003 09:02:24 -0000 1.25
+++ config.c 17 Mar 2003 02:27:19 -0000 1.26
@@ -134,6 +134,7 @@
}
int config_compare(struct config_line *c, char *key, int type, void *arg) {
+ int i;
if(strncasecmp(c->key,key,strlen(c->key)))
return 0;
@@ -145,6 +146,14 @@
case CONFIG_TYPE_INT:
*(int *)arg = atoi(c->value);
break;
+ case CONFIG_TYPE_BOOL:
+ i = atoi(c->value);
+ if (i != 0 && i != 1) {
+ log(LOG_ERR, "Boolean keyword '%s' expects 0 or 1", c->key);
+ return 0;
+ }
+ *(int *)arg = i;
+ break;
case CONFIG_TYPE_STRING:
*(char **)arg = strdup(c->value);
break;
@@ -176,13 +185,15 @@
config_compare(list, "OPPort", CONFIG_TYPE_INT, &options->OPPort) ||
config_compare(list, "ORPort", CONFIG_TYPE_INT, &options->ORPort) ||
config_compare(list, "DirPort", CONFIG_TYPE_INT, &options->DirPort) ||
- config_compare(list, "TrafficShaping", CONFIG_TYPE_INT, &options->TrafficShaping) ||
- config_compare(list, "LinkPadding", CONFIG_TYPE_INT, &options->LinkPadding) ||
config_compare(list, "DirRebuildPeriod",CONFIG_TYPE_INT, &options->DirRebuildPeriod) ||
config_compare(list, "DirFetchPeriod", CONFIG_TYPE_INT, &options->DirFetchPeriod) ||
config_compare(list, "KeepalivePeriod", CONFIG_TYPE_INT, &options->KeepalivePeriod) ||
config_compare(list, "MaxOnionsPending",CONFIG_TYPE_INT, &options->MaxOnionsPending) ||
+ config_compare(list, "Daemon", CONFIG_TYPE_BOOL, &options->Daemon) ||
+ config_compare(list, "TrafficShaping", CONFIG_TYPE_BOOL, &options->TrafficShaping) ||
+ config_compare(list, "LinkPadding", CONFIG_TYPE_BOOL, &options->LinkPadding) ||
+
/* float options */
config_compare(list, "CoinWeight", CONFIG_TYPE_DOUBLE, &options->CoinWeight)
@@ -207,6 +218,7 @@
/* give reasonable defaults for each option */
memset(options,0,sizeof(or_options_t));
+ options->Daemon = 0;
options->LogLevel = "debug";
options->loglevel = LOG_DEBUG;
options->CoinWeight = 0.8;
@@ -276,6 +288,7 @@
options->DirRebuildPeriod,
options->DirFetchPeriod,
options->KeepalivePeriod);
+ printf("Daemon=%d", options->Daemon);
}
/* Validate options */
@@ -351,6 +364,11 @@
if(options->MaxConn >= MAXCONNECTIONS) {
log(LOG_ERR,"MaxConn option must be less than %d.", MAXCONNECTIONS);
+ result = -1;
+ }
+
+ if(options->Daemon != 0 && options->Daemon != 1) {
+ log(LOG_ERR,"TrafficShaping option must be either 0 or 1.");
result = -1;
}
More information about the tor-commits
mailing list