| 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 |
|
*/ |
|
/*************************************************************************** |
|
|
* * |
|
|
* 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. * |
|
|
* * |
|
|
***************************************************************************/ |
|
| 8 |
|
|
|
#define _POSIX_C_SOURCE 200809L |
|
|
|
|
|
#include "init.h" |
|
|
#include "database.h" |
|
| 9 |
#include "bbs.h" |
#include "bbs.h" |
| 10 |
#include "common.h" |
#include "common.h" |
| 11 |
#include "log.h" |
#include "database.h" |
| 12 |
|
#include "init.h" |
| 13 |
#include "io.h" |
#include "io.h" |
| 14 |
#include <string.h> |
#include "log.h" |
|
#include <strings.h> |
|
|
#include <stdlib.h> |
|
| 15 |
#include <signal.h> |
#include <signal.h> |
| 16 |
|
#include <stdlib.h> |
| 17 |
|
#include <string.h> |
| 18 |
#include <unistd.h> |
#include <unistd.h> |
| 19 |
#include <sys/param.h> |
#include <sys/param.h> |
|
#include <sys/types.h> |
|
| 20 |
#include <sys/stat.h> |
#include <sys/stat.h> |
| 21 |
|
#include <sys/types.h> |
| 22 |
|
|
| 23 |
#define CONF_DELIM_WITH_SPACE " \t\r\n" |
static const char CONF_DELIM_WITH_SPACE[] = " \t\r\n"; |
| 24 |
|
|
| 25 |
int init_daemon(void) |
int init_daemon(void) |
| 26 |
{ |
{ |
| 63 |
char *saveptr = NULL; |
char *saveptr = NULL; |
| 64 |
char *p, *q, *r; |
char *p, *q, *r; |
| 65 |
char *y, *m, *d; |
char *y, *m, *d; |
| 66 |
|
int v; |
| 67 |
FILE *fin; |
FILE *fin; |
| 68 |
|
|
| 69 |
// Load configuration |
// Load configuration |
| 147 |
BBS_max_client_per_ip = MAX_CLIENT_PER_IP_LIMIT; |
BBS_max_client_per_ip = MAX_CLIENT_PER_IP_LIMIT; |
| 148 |
} |
} |
| 149 |
} |
} |
|
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; |
|
|
} |
|
|
} |
|
| 150 |
else if (strcasecmp(p, "bbs_start_dt") == 0) |
else if (strcasecmp(p, "bbs_start_dt") == 0) |
| 151 |
{ |
{ |
| 152 |
y = strtok_r(q, "-", &saveptr); |
y = strtok_r(q, "-", &saveptr); |
| 158 |
log_error("Ignore config bbs_start_dt with incorrect value\n"); |
log_error("Ignore config bbs_start_dt with incorrect value\n"); |
| 159 |
continue; |
continue; |
| 160 |
} |
} |
| 161 |
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); |
| 162 |
|
} |
| 163 |
|
else if (strcasecmp(p, "bbs_sys_id") == 0) |
| 164 |
|
{ |
| 165 |
|
v = atoi(q); |
| 166 |
|
if (v <= 0) |
| 167 |
|
{ |
| 168 |
|
log_error("Ignore config bbs_sys_id with incorrect value %d\n", v); |
| 169 |
|
continue; |
| 170 |
|
} |
| 171 |
|
BBS_sys_id = v; |
| 172 |
} |
} |
| 173 |
else if (strcasecmp(p, "db_host") == 0) |
else if (strcasecmp(p, "db_host") == 0) |
| 174 |
{ |
{ |