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

Diff of /lbbs/src/init.c

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

Revision 1.24 by sysadm, Thu Jun 5 08:36:02 2025 UTC Revision 1.36 by sysadm, Fri Dec 19 06:16:27 2025 UTC
# Line 1  Line 1 
1  /***************************************************************************  /* SPDX-License-Identifier: GPL-3.0-or-later */
2                                                    init.c  -  description  /*
3                                                           -------------------   * init
4          Copyright            : (C) 2004-2025 by Leaflet   *   - initializer of server daemon
5          Email                : leaflet@leafok.com   *
6   ***************************************************************************/   * Copyright (C) 2004-2025  Leaflet <leaflet@leafok.com>
7     */
8  /***************************************************************************  
9   *                                                                         *  #ifdef HAVE_CONFIG_H
10   *   This program is free software; you can redistribute it and/or modify  *  #include "config.h"
11   *   it under the terms of the GNU General Public License as published by  *  #endif
  *   the Free Software Foundation; either version 3 of the License, or     *  
  *   (at your option) any later version.                                   *  
  *                                                                         *  
  ***************************************************************************/  
12    
 #include "init.h"  
 #include "database.h"  
13  #include "bbs.h"  #include "bbs.h"
14  #include "common.h"  #include "common.h"
15  #include "log.h"  #include "database.h"
16    #include "init.h"
17  #include "io.h"  #include "io.h"
18  #include <string.h>  #include "log.h"
 #include <stdlib.h>  
19  #include <signal.h>  #include <signal.h>
20    #include <stdlib.h>
21    #include <string.h>
22    #include <unistd.h>
23  #include <sys/param.h>  #include <sys/param.h>
 #include <sys/types.h>  
24  #include <sys/stat.h>  #include <sys/stat.h>
25  #include <unistd.h>  #include <sys/types.h>
26    
27  #define CONF_DELIM_WITH_SPACE " \t\r\n"  static const char CONF_DELIM_WITH_SPACE[] = " \t\r\n";
28    
29  int init_daemon(void)  int init_daemon(void)
30  {  {
# Line 71  int load_conf(const char *conf_file) Line 67  int load_conf(const char *conf_file)
67          char *saveptr = NULL;          char *saveptr = NULL;
68          char *p, *q, *r;          char *p, *q, *r;
69          char *y, *m, *d;          char *y, *m, *d;
70            int v;
71          FILE *fin;          FILE *fin;
72    
73          // Load configuration          // Load configuration
# Line 96  int load_conf(const char *conf_file) Line 93  int load_conf(const char *conf_file)
93                  q = strtok_r(NULL, CONF_DELIM_WITH_SPACE, &saveptr);                  q = strtok_r(NULL, CONF_DELIM_WITH_SPACE, &saveptr);
94                  if (q == NULL) // Empty value                  if (q == NULL) // Empty value
95                  {                  {
96                          log_error("Skip empty value of config item: %s\n", p);                          log_error("Skip empty value of config item: %s", p);
97                          continue;                          continue;
98                  }                  }
99    
# Line 104  int load_conf(const char *conf_file) Line 101  int load_conf(const char *conf_file)
101                  r = strtok_r(NULL, CONF_DELIM_WITH_SPACE, &saveptr);                  r = strtok_r(NULL, CONF_DELIM_WITH_SPACE, &saveptr);
102                  if (r != NULL && r[0] != '#')                  if (r != NULL && r[0] != '#')
103                  {                  {
104                          log_error("Skip config line with extra value %s = %s %s\n", p, q, r);                          log_error("Skip config line with extra value %s = %s %s", p, q, r);
105                          continue;                          continue;
106                  }                  }
107    
# Line 141  int load_conf(const char *conf_file) Line 138  int load_conf(const char *conf_file)
138                          BBS_max_client = atoi(q);                          BBS_max_client = atoi(q);
139                          if (BBS_max_client <= 0 || BBS_max_client > MAX_CLIENT_LIMIT)                          if (BBS_max_client <= 0 || BBS_max_client > MAX_CLIENT_LIMIT)
140                          {                          {
141                                  log_error("Ignore config bbs_max_client with incorrect value %d\n", BBS_max_client);                                  log_error("Ignore config bbs_max_client with incorrect value %d", BBS_max_client);
142                                  BBS_max_client = MAX_CLIENT_LIMIT;                                  BBS_max_client = MAX_CLIENT_LIMIT;
143                          }                          }
144                  }                  }
# Line 150  int load_conf(const char *conf_file) Line 147  int load_conf(const char *conf_file)
147                          BBS_max_client_per_ip = atoi(q);                          BBS_max_client_per_ip = atoi(q);
148                          if (BBS_max_client_per_ip <= 0 || BBS_max_client_per_ip > MAX_CLIENT_PER_IP_LIMIT)                          if (BBS_max_client_per_ip <= 0 || BBS_max_client_per_ip > MAX_CLIENT_PER_IP_LIMIT)
149                          {                          {
150                                  log_error("Ignore config bbs_max_client with incorrect value %d\n", BBS_max_client_per_ip);                                  log_error("Ignore config bbs_max_client with incorrect value %d", BBS_max_client_per_ip);
151                                  BBS_max_client_per_ip = MAX_CLIENT_PER_IP_LIMIT;                                  BBS_max_client_per_ip = MAX_CLIENT_PER_IP_LIMIT;
152                          }                          }
153                  }                  }
                 else if (strcasecmp(p, "bbs_max_user") == 0)  
                 {  
                         BBS_max_user = atoi(q);  
                         if (BBS_max_user <= 0 || BBS_max_user > BBS_MAX_USER_LIMIT)  
                         {  
                                 log_error("Ignore config bbs_max_client with incorrect value %d\n", BBS_max_user);  
                                 BBS_max_user = BBS_MAX_USER_LIMIT;  
                         }  
                 }  
154                  else if (strcasecmp(p, "bbs_start_dt") == 0)                  else if (strcasecmp(p, "bbs_start_dt") == 0)
155                  {                  {
156                          y = strtok_r(q, "-", &saveptr);                          y = strtok_r(q, "-", &saveptr);
# Line 171  int load_conf(const char *conf_file) Line 159  int load_conf(const char *conf_file)
159    
160                          if (y == NULL || m == NULL || d == NULL)                          if (y == NULL || m == NULL || d == NULL)
161                          {                          {
162                                  log_error("Ignore config bbs_start_dt with incorrect value\n");                                  log_error("Ignore config bbs_start_dt with incorrect value");
163                                    continue;
164                            }
165                            snprintf(BBS_start_dt, sizeof(BBS_start_dt), "%4så¹´%2s月%2sæ—¥", y, m, d);
166                    }
167                    else if (strcasecmp(p, "bbs_sys_id") == 0)
168                    {
169                            v = atoi(q);
170                            if (v <= 0)
171                            {
172                                    log_error("Ignore config bbs_sys_id with incorrect value %d", v);
173                                  continue;                                  continue;
174                          }                          }
175                          snprintf(BBS_start_dt, sizeof(BBS_start_dt), "%4sÄê%2sÔÂ%2sÈÕ", y, m, d);                          BBS_sys_id = v;
176                  }                  }
177                  else if (strcasecmp(p, "db_host") == 0)                  else if (strcasecmp(p, "db_host") == 0)
178                  {                  {
# Line 203  int load_conf(const char *conf_file) Line 201  int load_conf(const char *conf_file)
201                  }                  }
202                  else                  else
203                  {                  {
204                          log_error("Unknown config %s = %s\n", p, q);                          log_error("Unknown config %s = %s", p, q);
205                  }                  }
206          }          }
207    


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

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