| 6 |
* Copyright (C) 2004-2025 Leaflet <leaflet@leafok.com> |
* Copyright (C) 2004-2025 Leaflet <leaflet@leafok.com> |
| 7 |
*/ |
*/ |
| 8 |
|
|
| 9 |
|
#ifdef HAVE_CONFIG_H |
| 10 |
|
#include "config.h" |
| 11 |
|
#endif |
| 12 |
|
|
| 13 |
#include "bbs.h" |
#include "bbs.h" |
| 14 |
#include "common.h" |
#include "common.h" |
| 15 |
#include "database.h" |
#include "database.h" |
| 24 |
#include <sys/stat.h> |
#include <sys/stat.h> |
| 25 |
#include <sys/types.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 |
{ |
{ |
| 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 |
|
|
| 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 |
|
|
| 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 |
} |
} |
| 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 |
} |
} |
| 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; |
continue; |
| 164 |
} |
} |
| 165 |
snprintf(BBS_start_dt, sizeof(BBS_start_dt), "%4s年%2s月%2s日", y, m, d); |
snprintf(BBS_start_dt, sizeof(BBS_start_dt), "%4s年%2s月%2s日", y, m, d); |
| 169 |
v = atoi(q); |
v = atoi(q); |
| 170 |
if (v <= 0) |
if (v <= 0) |
| 171 |
{ |
{ |
| 172 |
log_error("Ignore config bbs_sys_id with incorrect value %d\n", v); |
log_error("Ignore config bbs_sys_id with incorrect value %d", v); |
| 173 |
continue; |
continue; |
| 174 |
} |
} |
| 175 |
BBS_sys_id = v; |
BBS_sys_id = v; |
| 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 |
|
|