diff --git a/Makefile.in b/Makefile.in index 74c740d7..59398471 100644 --- a/Makefile.in +++ b/Makefile.in @@ -5,6 +5,7 @@ SRCS= main.c \ commandline.c \ dataformats.c \ dna.c \ + conf.c \ log.c \ mkdir.c \ strbuf.c \ diff --git a/commandline.c b/commandline.c index 31c0bcb5..b63ca4dd 100644 --- a/commandline.c +++ b/commandline.c @@ -21,6 +21,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include #include #include +#include #ifdef HAVE_STRINGS_H #include #endif @@ -534,161 +535,6 @@ int app_dna_lookup(int argc, const char *const *argv, struct command_line_option return 0; } -int confValueRotor=0; -char confValue[4][128]; -const char *confValueGet(const char *var, const char *defaultValue) -{ - if (!var) return defaultValue; - int varLen=strlen(var); - - char filename[1024]; - if (!FORM_SERVAL_INSTANCE_PATH(filename, "serval.conf")) { - WARNF("Using default value of %s: %s", var, defaultValue); - return defaultValue; - } - FILE *f = fopen(filename,"r"); - if (!f) { - if (defaultValue) - WARNF("Cannot open serval.conf, using default value of %s: %s", var, defaultValue); - return defaultValue; - } - - char line[1024]; - line[0] = '\0'; - fgets(line, sizeof line, f); - while (line[0]) { - if (!strncasecmp(line, var, varLen) && line[varLen] == '=') { - fclose(f); - size_t len = strlen(&line[varLen + 1]); - if (len > sizeof confValue[0]) - return defaultValue; - if (len && line[varLen + len] == '\n') - line[varLen + len--] = '\0'; - if (len && line[varLen + len] == '\r') - line[varLen + len--] = '\0'; - /* The rotor is used to pick which of four buffers to return in. - This allows the use of up to four calls to confValueGet() in - a single string formatting exercise, without unexpected side - effect. */ - confValueRotor++; - confValueRotor &= 3; - strcpy(&confValue[confValueRotor][0], &line[varLen + 1]); - return &confValue[confValueRotor][0]; - } - line[0] = '\0'; - fgets(line, sizeof line, f); - } - fclose(f); - return defaultValue; -} - -int confValueGetBoolean(const char *var, int defaultValue) -{ - const char *value = confValueGet(var, NULL); - if (!value) - return defaultValue; - int flag = confParseBoolean(value, var); - if (flag >= 0) - return flag; - WARNF("Config option %s: using default value %s", var, defaultValue ? "true" : "false"); - return defaultValue; -} - -int64_t confValueGetInt64(const char *var, int64_t defaultValue) -{ - const char *start = confValueGet(var, NULL); - if (!start) - return defaultValue; - const char *end = start; - long long value = strtoll(start, (char **)&end, 10); - if (*start && !*end && end != start) - return value; - WARNF("Config option %s: '%s' is not an integer, using default value %lld", var, start, (long long) defaultValue); - return defaultValue; -} - -int64_t confValueGetInt64Range(const char *var, int64_t defaultValue, int64_t rangemin, int64_t rangemax) -{ - int64_t value = confValueGetInt64(var, defaultValue); - if (value >= rangemin || value <= rangemax) - return value; - WARNF("Config option %s: configured value %lld out of range [%lld,%lld], using default value %lld", - var, (long long) value, (long long) rangemin, (long long) rangemax, (long long) defaultValue); - return defaultValue; -} - -void confSetDebugFlags() -{ - char filename[1024]; - if (FORM_SERVAL_INSTANCE_PATH(filename, "serval.conf")) { - FILE *f = fopen(filename, "r"); - if (f) { - unsigned int setmask = 0; - unsigned int clearmask = 0; - int setall = 0; - int clearall = 0; - char line[1024]; - line[0] = '\0'; - fgets(line, sizeof line, f); - while (line[0]) { - if (!strncasecmp(line, "debug.", 6)) { - char *flagname = line + 6; - char *p = flagname; - while (*p && *p != '=') - ++p; - int flag; - if (*p) { - *p = '\0'; - char *q = p + 1; - while (*q && *q != '\n') - ++q; - *q = '\0'; - if ((flag = confParseBoolean(p + 1, flagname)) != -1) { - unsigned int mask = debugFlagMask(flagname); - if (mask == DEBUG_ALL) { - if (flag) { - // DEBUGF("Set all debug flags"); - setall = 1; - } else { - // DEBUGF("Clear all debug flags"); - clearall = 1; - } - } else { - if (flag) { - // DEBUGF("Set debug.%s", flagname); - setmask |= mask; - } else { - // DEBUGF("Clear debug.%s", flagname); - clearmask |= mask; - } - } - } - } - } - line[0] = '\0'; - fgets(line, sizeof line, f); - } - fclose(f); - if (setall) - debug = DEBUG_ALL; - else if (clearall) - debug = 0; - debug &= ~clearmask; - debug |= setmask; - } - } -} - -int confParseBoolean(const char *text, const char *option_name) -{ - if (!strcasecmp(text, "on") || !strcasecmp(text, "yes") || !strcasecmp(text, "true") || !strcmp(text, "1")) - return 1; - if (!strcasecmp(text, "off") || !strcasecmp(text, "no") || !strcasecmp(text, "false") || !strcmp(text, "0")) - return 0; - WARNF("Config option %s: invalid boolean value '%s'", option_name, text); - return -1; -} - int cli_absolute_path(const char *arg) { return arg[0] == '/' && arg[1] != '\0'; @@ -1048,118 +894,54 @@ int app_mdp_ping(int argc, const char *const *argv, struct command_line_option * return 0; } -static int set_variable(const char *var, const char *val) -{ - char conffile[1024]; - FILE *in; - if (!FORM_SERVAL_INSTANCE_PATH(conffile, "serval.conf") || - !((in = fopen(conffile, "r")) || (in = fopen(conffile, "w"))) - ) { - if (var) - return WHY("could not read configuration file."); - return -1; - } - - char tempfile[1024]; - FILE *out; - if (!FORM_SERVAL_INSTANCE_PATH(tempfile, "serval.conf.temp") || - !(out = fopen(tempfile, "w")) - ) { - fclose(in); - return WHY("could not write temporary file."); - } - - /* Read and write lines of config file, replacing the variable in question - if required. If the variable didn't already exist, then write it out at - the end. */ - char line[1024]; - int found=0; - int varlen=strlen(var); - line[0]=0; fgets(line,1024,in); - while(line[0]) { - if (!strncasecmp(var, line, varlen) && line[varlen] == '=') { - if (!found && val) - fprintf(out, "%s=%s\n", var, val); - found = 1; - } else - fprintf(out,"%s",line); - line[0]=0; fgets(line,1024,in); - } - if (!found && val) - fprintf(out, "%s=%s\n", var, val); - fclose(in); fclose(out); - - if (rename(tempfile,conffile)) { - return WHYF("Failed to rename \"%s\" to \"%s\".", tempfile, conffile); - } - - return 0; -} - -int cli_configvarname(const char *arg) -{ - if (arg[0] == '\0') - return 0; - if (!(isalnum(arg[0]) || arg[0] == '_')) - return 0; - const char *s = arg + 1; - for (; *s; ++s) - if (!(isalnum(*s) || *s == '_' || (*s == '.' && s[-1] != '.'))) - return 0; - return s[-1] != '.'; -} - int app_config_set(int argc, const char *const *argv, struct command_line_option *o) { const char *var, *val; - if ( cli_arg(argc, argv, o, "variable", &var, cli_configvarname, NULL) + if ( cli_arg(argc, argv, o, "variable", &var, is_configvarname, NULL) || cli_arg(argc, argv, o, "value", &val, NULL, "")) return -1; if (create_serval_instance_dir() == -1) return -1; - return set_variable(var, val); + return confValueSet(var, val) == -1 ? -1 : confWrite(); } int app_config_del(int argc, const char *const *argv, struct command_line_option *o) { const char *var; - if (cli_arg(argc, argv, o, "variable", &var, cli_configvarname, NULL)) + if (cli_arg(argc, argv, o, "variable", &var, is_configvarname, NULL)) return -1; if (create_serval_instance_dir() == -1) return -1; - return set_variable(var, NULL); + return confValueSet(var, NULL) == -1 ? -1 : confWrite(); } int app_config_get(int argc, const char *const *argv, struct command_line_option *o) { const char *var; - if (cli_arg(argc, argv, o, "variable", &var, cli_configvarname, NULL) == -1) + if (cli_arg(argc, argv, o, "variable", &var, is_configvarname, NULL) == -1) return -1; if (create_serval_instance_dir() == -1) return -1; - char conffile[1024]; - FILE *in; - if (!FORM_SERVAL_INSTANCE_PATH(conffile, "serval.conf") || - !((in = fopen(conffile, "r")) || (in = fopen(conffile, "w"))) - ) { - return WHY("could not read configuration file."); - } - /* Read lines of config file. */ - char line[1024]; - int varlen = var ? strlen(var) : 0; - line[0]=0; fgets(line,1024,in); - while(line[0]) { - if (varlen == 0) { - fputs(line, stdout); + if (var) { + const char *value = confValueGet(var, NULL); + if (value) { + cli_puts(var); + cli_delim("="); + cli_puts(value); + cli_delim("\n"); } - else if (!strncasecmp(var, line, varlen) && line[varlen] == '=') { - fputs(line, stdout); - break; + } else { + int n = confVarCount(); + if (n == -1) + return -1; + unsigned int i; + for (i = 0; i != n; ++i) { + cli_puts(confVar(i)); + cli_delim("="); + cli_puts(confValue(i)); + cli_delim("\n"); } - line[0]=0; - fgets(line,1024,in); } - fclose(in); return 0; } diff --git a/conf.c b/conf.c new file mode 100644 index 00000000..3d85f06e --- /dev/null +++ b/conf.c @@ -0,0 +1,401 @@ +/* +Serval Distributed Numbering Architecture (DNA) +Copyright (C) 2010-2012 Paul Gardner-Stephen + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include +#include +#include "serval.h" + +/* This predicate function defines the constraints on configuration option names. + Valid: + foo + foo.bar + foo.bar.chow + _word + word1 + word_1 + Invalid: + foo. + .foo + 1foo + foo.bar. + 12 + 1.2.3 + foo bar + @author Andrew Bettison + */ +int is_configvarname(const char *arg) +{ + if (arg[0] == '\0') + return 0; + if (!(isalnum(arg[0]) || arg[0] == '_')) + return 0; + const char *s = arg + 1; + for (; *s; ++s) + if (!(isalnum(*s) || *s == '_' || (*s == '.' && s[-1] != '.'))) + return 0; + return s[-1] != '.'; +} + +#define MAX_CONFIG_VARS (100) +#define CONFIG_BUFFER_ALLOCSIZE (1024) + +static char *config_buffer = NULL; +static char *config_buffer_top = NULL; +static char *config_buffer_end = NULL; +static unsigned int confc = 0; +static char *confvar[MAX_CONFIG_VARS]; +static char *confvalue[MAX_CONFIG_VARS]; + +static char *grow_config_buffer(size_t needed) +{ + size_t cursize = config_buffer_end - config_buffer; + size_t used = config_buffer_top - config_buffer; + size_t newsize = used + needed; + if (newsize > cursize) { + // Round up to nearest multiple of CONFIG_BUFFER_ALLOCSIZE. + newsize = newsize + CONFIG_BUFFER_ALLOCSIZE - ((newsize - 1) % CONFIG_BUFFER_ALLOCSIZE + 1); + DEBUGF("newsize=%llu", (unsigned long long) newsize); + char *newbuf = realloc(config_buffer, newsize); + if (newbuf == NULL) { + WHYF_perror("realloc(%llu)", newsize); + return NULL; + } + ssize_t dif = newbuf - config_buffer; + unsigned int i; + for (i = 0; i != confc; ++i) { + confvar[i] += dif; + confvalue[i] += dif; + } + config_buffer_end = newbuf + newsize; + config_buffer_top = newbuf + used; + config_buffer = newbuf; + } + char *ret = config_buffer_top; + config_buffer_top += needed; + return ret; +} + +static int read_config() +{ + char conffile[1024]; + if (!FORM_SERVAL_INSTANCE_PATH(conffile, "serval.conf")) + return -1; + size_t size = 0; + FILE *f = fopen(conffile, "r"); + if (f == NULL) { + if (errno != ENOENT) + return WHYF_perror("fopen(%s)", conffile); + } else { + if (fseeko(f, (off_t) 0, SEEK_END) == -1) { + WHYF_perror("fseeko(%s, 0, SEEK_END)", conffile); + fclose(f); + return -1; + } + off_t tell = ftello(f); + if (tell == -1) { + WHYF_perror("ftello(%s)", conffile); + fclose(f); + return -1; + } + size = tell; + if (fseeko(f, (off_t) 0, SEEK_SET) == -1) { + WHYF_perror("fseeko(%s, 0, SEEK_SET)", conffile); + fclose(f); + return -1; + } + if (grow_config_buffer(size) == NULL) { + fclose(f); + return -1; + } + confc = 0; + if (fread(config_buffer, size, 1, f) != 1) { + if (ferror(f)) + WHYF_perror("fread(%s, %llu)", conffile, (unsigned long long) size); + else + WHYF("fread(%s, %llu) hit EOF", conffile, (unsigned long long) size); + free(config_buffer); + config_buffer = NULL; + fclose(f); + return -1; + } + if (fclose(f) == EOF) + return WHYF_perror("fclose(%s)", conffile); + } + config_buffer_top = config_buffer_end = config_buffer + size; + char *c = config_buffer; + char *e = config_buffer_top; + unsigned int linenum; + char *problem = NULL; + char *extra = ""; + for (linenum = 1; !problem && c < e; ++linenum) { + if (*c == '#') { + // skip comment lines + while (c < e && *c != '\n') + ++c; + } else if (*c == '\n') { + // skip empty lines + ++c; + } else if (c < e - 1 && *c == '\r' && c[1] == '\n') { + // skip empty lines + c += 2; + } else if (confc < MAX_CONFIG_VARS) { + char *var = confvar[confc] = c; + while (c < e && *c != '=' && *c != '\r' && *c != '\n') + ++c; + if (c < e && *c == '=') { + *c++ = '\0'; + if (is_configvarname(var)) { + confvalue[confc] = c; + while (c < e && *c != '\r' && *c != '\n') + ++c; + if (c < e && *c == '\n') { + ++confc; + *c++ = '\0'; + } else if (c < e - 1 && *c == '\r' && c[1] == '\n') { + ++confc; + *c++ = '\0'; + *c++ = '\0'; + } else { + problem = "missing end-of-line"; + } + } else { + problem = "invalid variable name: "; + extra = var; + } + } else { + problem = "missing '='"; + } + } else { + problem = "too many variables"; + } + } + if (problem) + return WHYF("Error in %s at line %u: %s%s", conffile, linenum, problem, extra); + return 0; +} + +int confVarCount() +{ + if (!config_buffer && read_config() == -1) + return -1; + return confc; +} + +const char *confVar(unsigned int index) +{ + if (!config_buffer && read_config() == -1) + return NULL; + if (index >= confc) { + WHYF("Config index=%u too big, confc=%u", index, confc); + return NULL; + } + return confvar[index]; +} + +const char *confValue(unsigned int index) +{ + if (!config_buffer && read_config() == -1) + return NULL; + if (index >= confc) { + WHYF("Config index=%u too big, confc=%u", index, confc); + return NULL; + } + return confvalue[index]; +} + +const char *confValueGet(const char *var, const char *defaultValue) +{ + if (var == NULL) { + WHYF("NULL var name, returning default value: %s", defaultValue ? defaultValue : "NULL"); + return defaultValue; + } + if (!config_buffer && read_config() == -1) { + if (defaultValue) + WARNF("Config option %s: using default value: %s", var, defaultValue); + return defaultValue; + } + unsigned int i; + for (i = 0; i != confc; ++i) + if (strcasecmp(confvar[i], var) == 0) + return confvalue[i]; + return defaultValue; +} + +int confValueGetBoolean(const char *var, int defaultValue) +{ + const char *value = confValueGet(var, NULL); + if (!value) + return defaultValue; + int flag = confParseBoolean(value, var); + if (flag >= 0) + return flag; + WARNF("Config option %s: using default value %s", var, defaultValue ? "true" : "false"); + return defaultValue; +} + +int64_t confValueGetInt64(const char *var, int64_t defaultValue) +{ + const char *start = confValueGet(var, NULL); + if (!start) + return defaultValue; + const char *end = start; + long long value = strtoll(start, (char **)&end, 10); + if (*start && !*end && end != start) + return value; + WARNF("Config option %s: '%s' is not an integer, using default value %lld", var, start, (long long) defaultValue); + return defaultValue; +} + +int64_t confValueGetInt64Range(const char *var, int64_t defaultValue, int64_t rangemin, int64_t rangemax) +{ + int64_t value = confValueGetInt64(var, defaultValue); + if (value >= rangemin || value <= rangemax) + return value; + WARNF("Config option %s: configured value %lld out of range [%lld,%lld], using default value %lld", + var, (long long) value, (long long) rangemin, (long long) rangemax, (long long) defaultValue); + return defaultValue; +} + +void confSetDebugFlags() +{ + if (config_buffer || read_config() != -1) { + unsigned int setmask = 0; + unsigned int clearmask = 0; + int setall = 0; + int clearall = 0; + unsigned int i; + for (i = 0; i != confc; ++i) { + char *var = confvar[i]; + if (strncasecmp(var, "debug.", 6) == 0) { + unsigned int mask = debugFlagMask(var + 6); + if (mask == 0) + WARNF("Unsupported debug option '%s'", var); + else { + int flag = confParseBoolean(confvalue[i], var); + if (flag != -1) { + if (mask == DEBUG_ALL) { + if (flag) { + DEBUGF("Set all debug flags"); + setall = 1; + } else { + DEBUGF("Clear all debug flags"); + clearall = 1; + } + } else { + if (flag) { + DEBUGF("Set %s", var); + setmask |= mask; + } else { + DEBUGF("Clear %s", var); + clearmask |= mask; + } + } + } + } + } + } + if (setall) + debug = DEBUG_ALL; + else if (clearall) + debug = 0; + debug &= ~clearmask; + debug |= setmask; + } +} + +int confParseBoolean(const char *text, const char *option_name) +{ + if (!strcasecmp(text, "on") || !strcasecmp(text, "yes") || !strcasecmp(text, "true") || !strcmp(text, "1")) + return 1; + if (!strcasecmp(text, "off") || !strcasecmp(text, "no") || !strcasecmp(text, "false") || !strcmp(text, "0")) + return 0; + WARNF("Config option %s: invalid boolean value '%s'", option_name, text); + return -1; +} + +int confValueSet(const char *var, const char *value) +{ + if (!config_buffer && read_config() == -1) + return -1; + if (!is_configvarname(var)) + return WHYF("Cannot %s %s: invalid variable name", value ? "set" : "delete", var); + if (value == NULL) { + unsigned int i; + for (i = 0; i != confc; ++i) + DEBUGF("var=%s confvar[%u]=%s", var, i, confvar[i]); + if (strcasecmp(var, confvar[i]) == 0) { + DEBUGF("found"); + --confc; + for (; i != confc; ++i) { + confvar[i] = confvar[i + i]; + confvalue[i] = confvalue[i + i]; + } + } + } else { + if (confc >= MAX_CONFIG_VARS) + return WHYF("Cannot set %s: too many variables", var); + size_t valuelen = strlen(value); + unsigned int i; + for (i = 0; i != confc; ++i) + if (strcasecmp(var, confvar[i]) == 0) { + char *valueptr = confvalue[i]; + if (valuelen > strlen(valueptr)) { + if ((valueptr = grow_config_buffer(valuelen + 1)) == NULL) + return -1; + } + strcpy(confvar[i], var); + confvalue[i] = strcpy(valueptr, value); + return 0; + } + size_t varlen = strlen(var); + char *buf = grow_config_buffer(varlen + 1 + valuelen + 1); + if (buf == NULL) + return -1; + confvar[confc] = strcpy(buf, var); + confvalue[confc] = strcpy(buf + varlen + 1, value); + ++confc; + } + return 0; +} + +int confWrite() +{ + if (config_buffer) { + char conffile[1024]; + char tempfile[1024]; + FILE *outf = NULL; + if (!FORM_SERVAL_INSTANCE_PATH(conffile, "serval.conf")) + return -1; + if (!FORM_SERVAL_INSTANCE_PATH(tempfile, "serval.conf.temp")) + return -1; + if ((outf = fopen(tempfile, "w")) == NULL) + return WHYF_perror("fopen(%s, \"w\")", tempfile); + unsigned int i; + for (i = 0; i != confc; ++i) + fprintf(outf, "%s=%s\n", confvar[i], confvalue[i]); + if (fclose(outf) == EOF) + return WHYF_perror("fclose(%s)", tempfile); + if (rename(tempfile, conffile)) { + WHYF_perror("rename(%s, %s)", tempfile, conffile); + unlink(tempfile); + return -1; + } + } + return 0; +} diff --git a/log.c b/log.c index b38dc694..bbfb8ff3 100644 --- a/log.c +++ b/log.c @@ -23,6 +23,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. unsigned int debug = 0; static FILE *logfile = NULL; +static int opening = 0; #ifdef ANDROID #include @@ -31,19 +32,26 @@ static FILE *logfile = NULL; FILE *open_logging() { if (!logfile) { - const char *logpath = getenv("SERVALD_LOG_FILE"); - if (!logpath) - logpath = confValueGet("logfile", NULL); - if (!logpath) { + if (opening) { logfile = stderr; - INFO("No logfile configured -- logging to stderr"); - } else if ((logfile = fopen(logpath, "a"))) { - setlinebuf(logfile); - INFOF("Logging to %s (fd %d)", logpath, fileno(logfile)); + INFO("Premature logging to stderr"); } else { - logfile = stderr; - WARN_perror("fopen"); - WARNF("Cannot append to %s -- falling back to stderr", logpath); + ++opening; + const char *logpath = getenv("SERVALD_LOG_FILE"); + if (!logpath) + logpath = confValueGet("logfile", NULL); + if (!logpath) { + logfile = stderr; + INFO("No logfile configured -- logging to stderr"); + } else if ((logfile = fopen(logpath, "a"))) { + setlinebuf(logfile); + INFOF("Logging to %s (fd %d)", logpath, fileno(logfile)); + } else { + logfile = stderr; + WARN_perror("fopen"); + WARNF("Cannot append to %s -- falling back to stderr", logpath); + } + --opening; } } return logfile; @@ -190,7 +198,6 @@ unsigned int debugFlagMask(const char *flagname) { else if (!strcasecmp(flagname,"broadcasts")) return DEBUG_BROADCASTS; else if (!strcasecmp(flagname,"manifests")) return DEBUG_MANIFESTS; else if (!strcasecmp(flagname,"mdprequests")) return DEBUG_MDPREQUESTS; - WARNF("Unsupported debug flag '%s'", flagname); return 0; } diff --git a/serval.h b/serval.h index 5a0961b7..6d7ff73e 100755 --- a/serval.h +++ b/serval.h @@ -667,6 +667,11 @@ int64_t confValueGetInt64(const char *var, int64_t defaultValue); int64_t confValueGetInt64Range(const char *var, int64_t defaultValue, int64_t rangemin, int64_t rangemax); void confSetDebugFlags(); int confParseBoolean(const char *text, const char *option_name); +int confValueSet(const char *var, const char *value); +int confWrite(); +int confVarCount(); +const char *confVar(unsigned int index); +const char *confValue(unsigned int index); ssize_t recvwithttl(int sock, unsigned char *buffer, size_t bufferlen, int *ttl, struct sockaddr *recvaddr, socklen_t *recvaddrlen); @@ -800,6 +805,7 @@ const char *trimbuildpath(const char *s); #define WHYF(F,...) (LOGF(LOG_LEVEL_ERROR, F, ##__VA_ARGS__), -1) #define WHY(X) WHYF("%s", (X)) #define WHYNULL(X) (LOGF(LOG_LEVEL_ERROR, "%s", X), NULL) +#define WHYF_perror(F,...) WHYF(F ": %s [errno=%d]", ##__VA_ARGS__, strerror(errno), errno) #define WHY_perror(X) WHYF("%s: %s [errno=%d]", (X), strerror(errno), errno) #define WARNF(F,...) LOGF(LOG_LEVEL_WARN, F, ##__VA_ARGS__) @@ -1466,6 +1472,8 @@ int cli_puts(const char *str); int cli_printf(const char *fmt, ...); int cli_delim(const char *opt); +int is_configvarname(const char *arg); + int overlay_mdp_getmyaddr(int index,unsigned char *sid); int overlay_mdp_bind(unsigned char *localaddr,int port); int overlay_route_node_info(overlay_mdp_frame *mdp, diff --git a/testdefs.sh b/testdefs.sh index b6e7f982..d9505a23 100644 --- a/testdefs.sh +++ b/testdefs.sh @@ -40,6 +40,7 @@ setup_servald() { ln -f -s "$servald_build_executable" $servald unset SERVALD_OUTPUT_DELIMITER unset SERVALD_SERVER_START_DELAY + unset SERVALD_LOG_FILE servald_instances_dir="$SERVALD_VAR/instance" set_instance +Z }