--- lbbs/src/test_file_loader.c 2025/11/04 14:58:56 1.11 +++ lbbs/src/test_file_loader.c 2025/12/19 06:16:27 1.17 @@ -6,15 +6,17 @@ * Copyright (C) 2004-2025 Leaflet */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "file_loader.h" #include "log.h" -#include "trie_dict.h" #include +#include #include +#include #include -#include - -#define TRIE_DICT_SHM_FILE "~trie_dict_shm.dat" const char *files[] = { "../data/welcome.txt", @@ -28,14 +30,12 @@ int files_cnt = 6; int main(int argc, char *argv[]) { - int ret; int i; - const void *p_shm; + void *p_shm; size_t data_len; long line_total; const void *p_data; const long *p_line_offsets; - FILE *fp; if (log_begin("../log/bbsd.log", "../log/error.log") < 0) { @@ -46,32 +46,6 @@ int main(int argc, char *argv[]) log_common_redir(STDOUT_FILENO); log_error_redir(STDERR_FILENO); - if ((fp = fopen(TRIE_DICT_SHM_FILE, "w")) == NULL) - { - log_error("fopen(%s) error\n", TRIE_DICT_SHM_FILE); - return -1; - } - fclose(fp); - - if (trie_dict_init(TRIE_DICT_SHM_FILE, TRIE_NODE_PER_POOL) < 0) - { - printf("trie_dict_init failed\n"); - return -1; - } - - ret = file_loader_init(); - if (ret < 0) - { - printf("file_loader_init() error (%d)\n", ret); - return ret; - } - - ret = file_loader_init(); - if (ret == 0) - { - printf("Rerun file_loader_init() error\n"); - } - printf("Testing #1\n"); for (i = 0; i < files_cnt; i++) @@ -99,7 +73,7 @@ int main(int argc, char *argv[]) if (detach_file_shm(p_shm) < 0) { - log_error("detach_file_shm(%s) error\n", files[i]); + log_error("detach_file_shm(%s) error", files[i]); } } } @@ -149,23 +123,12 @@ int main(int argc, char *argv[]) if (detach_file_shm(p_shm) < 0) { - log_error("detach_file_shm(%s) error\n", files[i]); + log_error("detach_file_shm(%s) error", files[i]); } } } } - file_loader_cleanup(); - file_loader_cleanup(); - - trie_dict_cleanup(); - - if (unlink(TRIE_DICT_SHM_FILE) < 0) - { - log_error("unlink(%s) error\n", TRIE_DICT_SHM_FILE); - return -1; - } - log_end(); return 0;