| 7 |
*/ |
*/ |
| 8 |
|
|
| 9 |
#include "bbs.h" |
#include "bbs.h" |
| 10 |
|
#include "bwf.h" |
| 11 |
#include "common.h" |
#include "common.h" |
| 12 |
#include "file_loader.h" |
#include "file_loader.h" |
| 13 |
#include "init.h" |
#include "init.h" |
| 19 |
#include "user_list.h" |
#include "user_list.h" |
| 20 |
#include <errno.h> |
#include <errno.h> |
| 21 |
#include <libgen.h> |
#include <libgen.h> |
| 22 |
|
#include <locale.h> |
| 23 |
#include <signal.h> |
#include <signal.h> |
| 24 |
#include <stdio.h> |
#include <stdio.h> |
| 25 |
#include <stdlib.h> |
#include <stdlib.h> |
| 134 |
return -1; |
return -1; |
| 135 |
} |
} |
| 136 |
|
|
| 137 |
|
// Apply the specified locale |
| 138 |
|
if (setlocale(LC_ALL, "en_US.UTF-8") == NULL) |
| 139 |
|
{ |
| 140 |
|
fprintf(stderr, "setlocale(LC_ALL, en_US.UTF-8) error\n"); |
| 141 |
|
return -1; |
| 142 |
|
} |
| 143 |
|
|
| 144 |
// Initialize log |
// Initialize log |
| 145 |
if (log_begin(LOG_FILE_INFO, LOG_FILE_ERROR) < 0) |
if (log_begin(LOG_FILE_INFO, LOG_FILE_ERROR) < 0) |
| 146 |
{ |
{ |
| 164 |
return -2; |
return -2; |
| 165 |
} |
} |
| 166 |
|
|
| 167 |
|
// Load BWF config |
| 168 |
|
if (bwf_load(CONF_BWF) < 0) |
| 169 |
|
{ |
| 170 |
|
return -2; |
| 171 |
|
} |
| 172 |
|
|
| 173 |
// Check article cache dir |
// Check article cache dir |
| 174 |
ret = mkdir(VAR_ARTICLE_CACHE_DIR, 0750); |
ret = mkdir(VAR_ARTICLE_CACHE_DIR, 0750); |
| 175 |
if (ret == -1 && errno != EEXIST) |
if (ret == -1 && errno != EEXIST) |
| 217 |
printf("trie_dict_init(%s, %d) error\n", VAR_TRIE_DICT_SHM, TRIE_NODE_PER_POOL); |
printf("trie_dict_init(%s, %d) error\n", VAR_TRIE_DICT_SHM, TRIE_NODE_PER_POOL); |
| 218 |
goto cleanup; |
goto cleanup; |
| 219 |
} |
} |
| 220 |
if (article_block_init(VAR_ARTICLE_BLOCK_SHM, BBS_article_limit_per_section * BBS_max_section / ARTICLE_PER_BLOCK) < 0) |
if (article_block_init(VAR_ARTICLE_BLOCK_SHM, BBS_article_limit_per_section * BBS_max_section / BBS_article_count_per_block) < 0) |
| 221 |
{ |
{ |
| 222 |
log_error("article_block_init(%s, %d) error\n", VAR_ARTICLE_BLOCK_SHM, BBS_article_limit_per_section * BBS_max_section / ARTICLE_PER_BLOCK); |
log_error("article_block_init(%s, %d) error\n", VAR_ARTICLE_BLOCK_SHM, BBS_article_limit_per_section * BBS_max_section / BBS_article_count_per_block); |
| 223 |
goto cleanup; |
goto cleanup; |
| 224 |
} |
} |
| 225 |
if (section_list_init(VAR_SECTION_LIST_SHM) < 0) |
if (section_list_init(VAR_SECTION_LIST_SHM) < 0) |
| 352 |
trie_dict_cleanup(); |
trie_dict_cleanup(); |
| 353 |
user_list_pool_cleanup(); |
user_list_pool_cleanup(); |
| 354 |
|
|
| 355 |
|
// Cleanup BWF |
| 356 |
|
bwf_unload(); |
| 357 |
|
|
| 358 |
if (unlink(VAR_ARTICLE_BLOCK_SHM) < 0) |
if (unlink(VAR_ARTICLE_BLOCK_SHM) < 0) |
| 359 |
{ |
{ |
| 360 |
log_error("unlink(%s) error\n", VAR_ARTICLE_BLOCK_SHM); |
log_error("unlink(%s) error\n", VAR_ARTICLE_BLOCK_SHM); |