Browse Source

* misc fixes

master
Alex 'AdUser' Z 8 years ago
parent
commit
7d82c5ffb5
  1. 7
      src/backend.c
  2. 3
      src/common.h
  3. 4
      src/config.c
  4. 11
      src/log.c

7
src/backend.c

@ -12,9 +12,11 @@ f2b_backend_create(f2b_config_section_t *config, const char *id) {
assert(config != NULL);
assert(config->type == t_backend);
f2b_config_find_param(config->param, BACKEND_LIBRARY_PARAM);
if (!param)
param = f2b_config_find_param(config->param, BACKEND_LIBRARY_PARAM);
if (!param) {
f2b_log_msg(log_error, "can't find '%s' param in backend config", BACKEND_LIBRARY_PARAM);
return NULL;
}
if ((backend = calloc(1, sizeof(f2b_backend_t))) == NULL)
return NULL;
@ -64,6 +66,7 @@ f2b_backend_create(f2b_config_section_t *config, const char *id) {
f2b_log_msg(log_error, "backend '%s' not fully configured", config->name);
cleanup:
f2b_log_msg(log_error, "load error: %s", dlerror());
if (backend->h) {
if (backend->cfg && backend->destroy)
backend->destroy(backend->cfg);

3
src/common.h

@ -7,8 +7,9 @@
#include <dlfcn.h>
#include <errno.h>
#include <limits.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>

4
src/config.c

@ -40,7 +40,7 @@ f2b_config_parse_kv_pair(const char *src) {
p = value + strlen(value);
if (p > value)
p--; /* step back at char before '\0' */
while (p > value && isblank(*p))
while (p > value && isspace(*p))
p--;
p++, *p = '\0';
@ -147,7 +147,7 @@ f2b_config_load(const char *path) {
size_t linenum = 0; /* current line number in config */
if ((f = fopen(path, "r")) == NULL) {
f2b_log_msg(log_error, "can't open config file: %s: %s", path, strerror(errno));
f2b_log_msg(log_error, "can't open config file '%s': %s", path, strerror(errno));
return NULL;
}

11
src/log.c

@ -1,7 +1,3 @@
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include "common.h"
#include "log.h"
@ -26,9 +22,12 @@ void f2b_log_msg(log_msgtype_t l, const char *fmt, ...) {
return;
va_start(args, fmt);
snprintf(msg, sizeof(msg), fmt, args);
vsnprintf(msg, sizeof(msg), fmt, args);
va_end(args);
printf(line, LOGLINE_MAX, "[%s] %s", loglevels[l], msg);
snprintf(line, LOGLINE_MAX, "[%s] %s", loglevels[l], msg);
/* TODO */
fputs(line, stderr);
fputc('\n', stderr);
return;
}

Loading…
Cancel
Save