#include "names.h"
#include "netutl.h" /* for str2address */
#include "protocol.h"
-#include "utils.h" /* for cp */
#include "xalloc.h"
-splay_tree_t *config_tree = NULL;
-
int pinginterval = 0; /* seconds between pings */
int pingtimeout = 0; /* seconds to wait for response */
-list_t *cmdline_conf = NULL; /* global/host configuration values given at the command line */
+
+/* global/host configuration values given at the command line */
+list_t cmdline_conf = {
+ .head = NULL,
+ .tail = NULL,
+ .count = 0,
+ .delete = (list_action_t)free_config,
+};
static int config_compare(const config_t *a, const config_t *b) {
int result;
}
}
-void init_configuration(splay_tree_t **config_tree) {
- *config_tree = splay_alloc_tree((splay_compare_t) config_compare, (splay_action_t) free_config);
+splay_tree_t config_tree = {
+ .compare = (splay_compare_t) config_compare,
+ .delete = (splay_action_t) free_config,
+};
+
+splay_tree_t *create_configuration() {
+ splay_tree_t *tree = splay_alloc_tree(NULL, NULL);
+ init_configuration(tree);
+ return tree;
+}
+
+void init_configuration(splay_tree_t *tree) {
+ memset(tree, 0, sizeof(*tree));
+ tree->compare = (splay_compare_t) config_compare;
+ tree->delete = (splay_action_t) free_config;
}
void exit_configuration(splay_tree_t **config_tree) {
return NULL;
}
- p = fgets(buf, buflen, fp);
+ p = fgets(buf, (int) buflen, fp);
if(!p) {
return NULL;
config_t *parse_config_line(char *line, const char *fname, int lineno) {
config_t *cfg;
- int len;
char *variable, *value, *eol;
variable = value = line;
*eol = '\0';
}
- len = strcspn(value, "\t =");
+ size_t len = strcspn(value, "\t =");
value += len;
value += strspn(value, "\t ");
}
void read_config_options(splay_tree_t *config_tree, const char *prefix) {
- if(!cmdline_conf) {
- return;
- }
-
size_t prefix_len = prefix ? strlen(prefix) : 0;
- for(const list_node_t *node = cmdline_conf->tail; node; node = node->prev) {
+ for(const list_node_t *node = cmdline_conf.tail; node; node = node->prev) {
const config_t *cfg = node->data;
config_t *new;