X-Git-Url: https://www.tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=src%2Fconf.c;h=e67c7ac1ff934bd6f61cff2109861622e8e236e7;hp=e7703c16bbe71bd2862fec3239013f4d2aee85b5;hb=4c85542894f7fca823b119b05e07179deb24229a;hpb=5dde6461a321ee47b06e33f8203f2acf00a31a51 diff --git a/src/conf.c b/src/conf.c index e7703c16..e67c7ac1 100644 --- a/src/conf.c +++ b/src/conf.c @@ -53,27 +53,19 @@ static int config_compare(const config_t *a, const config_t *b) { } void init_configuration(avl_tree_t ** config_tree) { - cp(); - *config_tree = avl_alloc_tree((avl_compare_t) config_compare, (avl_action_t) free_config); } void exit_configuration(avl_tree_t ** config_tree) { - cp(); - avl_delete_tree(*config_tree); *config_tree = NULL; } config_t *new_config(void) { - cp(); - return xmalloc_and_zero(sizeof(config_t)); } void free_config(config_t *cfg) { - cp(); - if(cfg->variable) free(cfg->variable); @@ -87,16 +79,12 @@ void free_config(config_t *cfg) { } void config_add(avl_tree_t *config_tree, config_t *cfg) { - cp(); - avl_insert(config_tree, cfg); } config_t *lookup_config(avl_tree_t *config_tree, char *variable) { config_t cfg, *found; - cp(); - cfg.variable = variable; cfg.file = ""; cfg.line = 0; @@ -116,8 +104,6 @@ config_t *lookup_config_next(avl_tree_t *config_tree, const config_t *cfg) { avl_node_t *node; config_t *found; - cp(); - node = avl_search_node(config_tree, cfg); if(node) { @@ -133,8 +119,6 @@ config_t *lookup_config_next(avl_tree_t *config_tree, const config_t *cfg) { } bool get_config_bool(const config_t *cfg, bool *result) { - cp(); - if(!cfg) return false; @@ -146,30 +130,26 @@ bool get_config_bool(const config_t *cfg, bool *result) { return true; } - logger(LOG_ERR, _("\"yes\" or \"no\" expected for configuration variable %s in %s line %d"), + logger(LOG_ERR, "\"yes\" or \"no\" expected for configuration variable %s in %s line %d", cfg->variable, cfg->file, cfg->line); return false; } bool get_config_int(const config_t *cfg, int *result) { - cp(); - if(!cfg) return false; if(sscanf(cfg->value, "%d", result) == 1) return true; - logger(LOG_ERR, _("Integer expected for configuration variable %s in %s line %d"), + logger(LOG_ERR, "Integer expected for configuration variable %s in %s line %d", cfg->variable, cfg->file, cfg->line); return false; } bool get_config_string(const config_t *cfg, char **result) { - cp(); - if(!cfg) return false; @@ -181,8 +161,6 @@ bool get_config_string(const config_t *cfg, char **result) { bool get_config_address(const config_t *cfg, struct addrinfo **result) { struct addrinfo *ai; - cp(); - if(!cfg) return false; @@ -193,7 +171,7 @@ bool get_config_address(const config_t *cfg, struct addrinfo **result) { return true; } - logger(LOG_ERR, _("Hostname or IP address expected for configuration variable %s in %s line %d"), + logger(LOG_ERR, "Hostname or IP address expected for configuration variable %s in %s line %d", cfg->variable, cfg->file, cfg->line); return false; @@ -202,13 +180,11 @@ bool get_config_address(const config_t *cfg, struct addrinfo **result) { bool get_config_subnet(const config_t *cfg, subnet_t ** result) { subnet_t subnet = {0}; - cp(); - if(!cfg) return false; if(!str2net(&subnet, cfg->value)) { - logger(LOG_ERR, _("Subnet expected for configuration variable %s in %s line %d"), + logger(LOG_ERR, "Subnet expected for configuration variable %s in %s line %d", cfg->variable, cfg->file, cfg->line); return false; } @@ -219,7 +195,7 @@ bool get_config_subnet(const config_t *cfg, subnet_t ** result) { && !maskcheck(&subnet.net.ipv4.address, subnet.net.ipv4.prefixlength, sizeof(ipv4_t))) || ((subnet.type == SUBNET_IPV6) && !maskcheck(&subnet.net.ipv6.address, subnet.net.ipv6.prefixlength, sizeof(ipv6_t)))) { - logger(LOG_ERR, _ ("Network address and prefix length do not match for configuration variable %s in %s line %d"), + logger(LOG_ERR, "Network address and prefix length do not match for configuration variable %s in %s line %d", cfg->variable, cfg->file, cfg->line); return false; } @@ -314,12 +290,10 @@ int read_config_file(avl_tree_t *config_tree, const char *fname) { config_t *cfg; size_t bufsize; - cp(); - fp = fopen(fname, "r"); if(!fp) { - logger(LOG_ERR, _("Cannot open config file %s: %s"), fname, + logger(LOG_ERR, "Cannot open config file %s: %s", fname, strerror(errno)); return -3; } @@ -373,7 +347,7 @@ int read_config_file(avl_tree_t *config_tree, const char *fname) { if(!*value) { - logger(LOG_ERR, _("No value for variable `%s' on line %d while reading config file %s"), + logger(LOG_ERR, "No value for variable `%s' on line %d while reading config file %s", variable, lineno, fname); break; } @@ -397,13 +371,11 @@ bool read_server_config() { char *fname; int x; - cp(); - xasprintf(&fname, "%s/tinc.conf", confbase); x = read_config_file(config_tree, fname); if(x == -1) { /* System error: complain */ - logger(LOG_ERR, _("Failed to read `%s': %s"), fname, strerror(errno)); + logger(LOG_ERR, "Failed to read `%s': %s", fname, strerror(errno)); } free(fname); @@ -424,14 +396,14 @@ FILE *ask_and_open(const char *filename, const char *what) { fn = xstrdup(filename); } else { /* Ask for a file and/or directory name. */ - fprintf(stdout, _("Please enter a file to save %s to [%s]: "), + fprintf(stdout, "Please enter a file to save %s to [%s]: ", what, filename); fflush(stdout); fn = readline(stdin, NULL, NULL); if(!fn) { - fprintf(stderr, _("Error while reading stdin: %s\n"), + fprintf(stderr, "Error while reading stdin: %s\n", strerror(errno)); return NULL; } @@ -463,7 +435,7 @@ FILE *ask_and_open(const char *filename, const char *what) { r = fopen(fn, "r+") ?: fopen(fn, "w+"); if(!r) { - fprintf(stderr, _("Error opening file `%s': %s\n"), + fprintf(stderr, "Error opening file `%s': %s\n", fn, strerror(errno)); free(fn); return NULL;