Browse Source

+ src/backend-test.c

master
Alex 'AdUser' Z 9 years ago
parent
commit
4afef75f55
  1. 6
      src/CMakeLists.txt
  2. 40
      src/backend-test.c

6
src/CMakeLists.txt

@ -2,9 +2,13 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES "main.c" "logfile.c" "log.c" "matches.c" "ipaddr.c" "filelist.c" "regexps_posix.c" "config.c" "jail.c" "backend.c") set(SOURCES "main.c" "logfile.c" "log.c" "matches.c" "ipaddr.c" "filelist.c" "regexps_posix.c" "config.c" "jail.c" "backend.c")
add_executable(f2b ${SOURCES}) add_executable("f2b" ${SOURCES})
target_link_libraries(f2b "dl") target_link_libraries(f2b "dl")
set(SOURCES "backend-test.c" "log.c" "backend.c" "config.c")
add_executable("backend-test" ${SOURCES})
target_link_libraries("backend-test" "dl")
install(TARGETS f2b install(TARGETS f2b
RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/bin") RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")

40
src/backend-test.c

@ -0,0 +1,40 @@
#include "common.h"
#include "config.h"
#include "log.h"
#include "backend.h"
void usage() {
fprintf(stderr, "Usage: backend-test <config-file.conf> <id>\n");
exit(EXIT_FAILURE);
}
int main(int argc, char *argv[]) {
f2b_config_section_t *config = NULL;
f2b_config_section_t *b_conf = NULL;
f2b_backend_t *backend = NULL;
if (argc < 3)
usage();
if ((config = f2b_config_load(argv[1])) == NULL) {
f2b_log_msg(log_error, "can't load config");
return EXIT_FAILURE;
}
if ((b_conf = f2b_config_find_section(config, t_backend, "test")) == NULL) {
f2b_log_msg(log_error, "can't find config section for backend '%s'", "test");
return EXIT_FAILURE;
}
if ((backend = f2b_backend_create(config, argv[2])) == NULL) {
f2b_log_msg(log_error, "can't create backend");
return EXIT_FAILURE;
}
/* TODO */
f2b_backend_destroy(backend);
f2b_config_free(config);
return EXIT_SUCCESS;
}
Loading…
Cancel
Save