Browse Source

* misc fixes

master
Alex 'AdUser' Z 9 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 != NULL);
assert(config->type == t_backend); assert(config->type == t_backend);
f2b_config_find_param(config->param, BACKEND_LIBRARY_PARAM); param = f2b_config_find_param(config->param, BACKEND_LIBRARY_PARAM);
if (!param) if (!param) {
f2b_log_msg(log_error, "can't find '%s' param in backend config", BACKEND_LIBRARY_PARAM);
return NULL; return NULL;
}
if ((backend = calloc(1, sizeof(f2b_backend_t))) == NULL) if ((backend = calloc(1, sizeof(f2b_backend_t))) == NULL)
return 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); f2b_log_msg(log_error, "backend '%s' not fully configured", config->name);
cleanup: cleanup:
f2b_log_msg(log_error, "load error: %s", dlerror());
if (backend->h) { if (backend->h) {
if (backend->cfg && backend->destroy) if (backend->cfg && backend->destroy)
backend->destroy(backend->cfg); backend->destroy(backend->cfg);

3
src/common.h

@ -7,8 +7,9 @@
#include <dlfcn.h> #include <dlfcn.h>
#include <errno.h> #include <errno.h>
#include <limits.h> #include <limits.h>
#include <stdio.h> #include <stdarg.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/stat.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); p = value + strlen(value);
if (p > value) if (p > value)
p--; /* step back at char before '\0' */ p--; /* step back at char before '\0' */
while (p > value && isblank(*p)) while (p > value && isspace(*p))
p--; p--;
p++, *p = '\0'; p++, *p = '\0';
@ -147,7 +147,7 @@ f2b_config_load(const char *path) {
size_t linenum = 0; /* current line number in config */ size_t linenum = 0; /* current line number in config */
if ((f = fopen(path, "r")) == NULL) { 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; return NULL;
} }

11
src/log.c

@ -1,7 +1,3 @@
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include "common.h" #include "common.h"
#include "log.h" #include "log.h"
@ -26,9 +22,12 @@ void f2b_log_msg(log_msgtype_t l, const char *fmt, ...) {
return; return;
va_start(args, fmt); va_start(args, fmt);
snprintf(msg, sizeof(msg), fmt, args); vsnprintf(msg, sizeof(msg), fmt, args);
va_end(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; return;
} }

Loading…
Cancel
Save