/[LeafOK_CVS]/lbbs/src/main.c
ViewVC logotype

Diff of /lbbs/src/main.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.69 by sysadm, Tue Nov 4 13:49:51 2025 UTC Revision 1.73 by sysadm, Sat Nov 8 08:21:31 2025 UTC
# Line 3  Line 3 
3   * main   * main
4   *   - entry of server program   *   - entry of server program
5   *   *
6   * Copyright (C) 2004-2025 by Leaflet <leaflet@leafok.com>   * Copyright (C) 2004-2025  Leaflet <leaflet@leafok.com>
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"
# Line 18  Line 19 
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>
# Line 132  int main(int argc, char *argv[]) Line 134  int main(int argc, char *argv[])
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          {          {
# Line 155  int main(int argc, char *argv[]) Line 164  int main(int argc, char *argv[])
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)
# Line 202  int main(int argc, char *argv[]) Line 217  int main(int argc, char *argv[])
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)
# Line 337  cleanup: Line 352  cleanup:
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);


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1