}
void exit_configuration(splay_tree_t **config_tree) {
- splay_delete_tree(*config_tree);
+ if(*config_tree)
+ splay_delete_tree(*config_tree);
*config_tree = NULL;
}
return true;
}
- logger(DEBUG_ALWAYS, LOG_ERR, "\"yes\" or \"no\" expected for configuration variable %s in %s line %d",
+ logger(NULL, MESHLINK_ERROR, "\"yes\" or \"no\" expected for configuration variable %s in %s line %d",
cfg->variable, cfg->file, cfg->line);
return false;
if(sscanf(cfg->value, "%d", result) == 1)
return true;
- logger(DEBUG_ALWAYS, LOG_ERR, "Integer expected for configuration variable %s in %s line %d",
+ logger(NULL, MESHLINK_ERROR, "Integer expected for configuration variable %s in %s line %d",
cfg->variable, cfg->file, cfg->line);
return false;
return true;
}
- logger(DEBUG_ALWAYS, LOG_ERR, "Hostname or IP address expected for configuration variable %s in %s line %d",
+ logger(NULL, MESHLINK_ERROR, "Hostname or IP address expected for configuration variable %s in %s line %d",
cfg->variable, cfg->file, cfg->line);
return false;
if(!*value) {
const char err[] = "No value for variable";
- logger(DEBUG_ALWAYS, LOG_ERR, "%s `%s' on line %d while reading config file %s",
+ logger(NULL, MESHLINK_ERROR, "%s `%s' on line %d while reading config file %s",
err, variable, lineno, fname);
return NULL;
}
fp = fopen(fname, "r");
if(!fp) {
- logger(DEBUG_ALWAYS, LOG_ERR, "Cannot open config file %s: %s", fname, strerror(errno));
+ logger(NULL, MESHLINK_ERROR, "Cannot open config file %s: %s", fname, strerror(errno));
return false;
}
x = read_config_file(mesh->config, filename);
if(!x && errno)
- logger(DEBUG_ALWAYS, LOG_ERR, "Failed to read `%s': %s", filename, strerror(errno));
+ logger(mesh, MESHLINK_ERROR, "Failed to read `%s': %s", filename, strerror(errno));
return x;
}
FILE *fp = fopen(filename, "a");
if(!fp) {
- logger(DEBUG_ALWAYS, LOG_ERR, "Cannot open config file %s: %s", filename, strerror(errno));
+ logger(mesh, MESHLINK_ERROR, "Cannot open config file %s: %s", filename, strerror(errno));
} else {
- fprintf(fp, "\n# The following line was automatically added by tinc\n%s = %s\n", key, value);
+ fprintf(fp, "%s = %s\n", key, value);
fclose(fp);
}
-
return fp != NULL;
}