--- lbbs/src/init.c 2025/10/10 01:55:06 1.30 +++ lbbs/src/init.c 2026/01/03 10:27:14 1.37 @@ -1,18 +1,14 @@ -/*************************************************************************** - init.c - description - ------------------- - Copyright : (C) 2004-2025 by Leaflet - Email : leaflet@leafok.com - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 3 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ +/* SPDX-License-Identifier: GPL-3.0-or-later */ +/* + * init + * - initializer of server daemon + * + * Copyright (C) 2004-2026 Leaflet + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif #include "bbs.h" #include "common.h" @@ -28,7 +24,7 @@ #include #include -#define CONF_DELIM_WITH_SPACE " \t\r\n" +static const char CONF_DELIM_WITH_SPACE[] = " \t\r\n"; int init_daemon(void) { @@ -97,7 +93,7 @@ int load_conf(const char *conf_file) q = strtok_r(NULL, CONF_DELIM_WITH_SPACE, &saveptr); if (q == NULL) // Empty value { - log_error("Skip empty value of config item: %s\n", p); + log_error("Skip empty value of config item: %s", p); continue; } @@ -105,7 +101,7 @@ int load_conf(const char *conf_file) r = strtok_r(NULL, CONF_DELIM_WITH_SPACE, &saveptr); if (r != NULL && r[0] != '#') { - 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); continue; } @@ -142,7 +138,7 @@ int load_conf(const char *conf_file) BBS_max_client = atoi(q); if (BBS_max_client <= 0 || BBS_max_client > MAX_CLIENT_LIMIT) { - 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); BBS_max_client = MAX_CLIENT_LIMIT; } } @@ -151,19 +147,10 @@ int load_conf(const char *conf_file) BBS_max_client_per_ip = atoi(q); if (BBS_max_client_per_ip <= 0 || BBS_max_client_per_ip > MAX_CLIENT_PER_IP_LIMIT) { - 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); BBS_max_client_per_ip = MAX_CLIENT_PER_IP_LIMIT; } } - 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; - } - } else if (strcasecmp(p, "bbs_start_dt") == 0) { y = strtok_r(q, "-", &saveptr); @@ -172,7 +159,7 @@ int load_conf(const char *conf_file) if (y == NULL || m == NULL || d == NULL) { - log_error("Ignore config bbs_start_dt with incorrect value\n"); + log_error("Ignore config bbs_start_dt with incorrect value"); continue; } snprintf(BBS_start_dt, sizeof(BBS_start_dt), "%4s年%2s月%2s日", y, m, d); @@ -180,9 +167,9 @@ int load_conf(const char *conf_file) else if (strcasecmp(p, "bbs_sys_id") == 0) { v = atoi(q); - if (v <= 0 || v > BBS_MAX_USER_LIMIT) + if (v <= 0) { - 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); continue; } BBS_sys_id = v; @@ -214,7 +201,7 @@ int load_conf(const char *conf_file) } else { - log_error("Unknown config %s = %s\n", p, q); + log_error("Unknown config %s = %s", p, q); } }