--- lbbs/src/bbs.c 2025/10/23 14:49:24 1.32 +++ lbbs/src/bbs.c 2025/12/02 08:48:05 1.41 @@ -1,18 +1,14 @@ -/*************************************************************************** - bbs.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 */ +/* + * bbs + * - BBS related common definitions + * + * Copyright (C) 2004-2025 Leaflet + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif #include "bbs.h" #include "common.h" @@ -22,8 +18,11 @@ #include #include -#define BBS_port_default 23 -#define BBS_ssh_port_default 22 +enum _bbs_port_constant_t +{ + BBS_port_default = 23, + BBS_ssh_port_default = 22, +}; // BBS enviroment char BBS_id[BBS_id_max_len + 1] = "Example BBS"; @@ -36,7 +35,7 @@ int BBS_max_client_per_ip = MAX_CLIENT_P char BBS_start_dt[BBS_start_dt_max_len + 1] = "2000年 1月 1日"; int BBS_sys_id = 1; -const int BBS_section_list_load_interval = 5; // second +const int BBS_section_list_load_interval = 1; // second // User const int BBS_user_list_load_interval = 60; // 1 minute @@ -48,6 +47,9 @@ char BBS_nickname[BBS_nickname_max_len + char BBS_user_tz[BBS_user_tz_max_len + 1]; int BBS_user_exp; +time_t BBS_eula_tm; +int BBS_update_eula = 0; + time_t BBS_login_tm; time_t BBS_last_access_tm; @@ -62,7 +64,7 @@ static const int astro_dates[] = { static const char *astro_names[] = { "摩羯", "水瓶", "双鱼", "白羊", "金牛", "双子", "巨蟹", "狮子", "处女", "天秤", "天蝎", "射手", "摩羯"}; -static const int user_level_points[] = { +static const int BBS_user_level_points[] = { INT_MIN, // 0 50, // 1 200, // 2 @@ -79,10 +81,9 @@ static const int user_level_points[] = { 80000, // 13 90000, // 14 100000, // 15 - INT_MAX, // 16 }; -static const char *user_level_names[] = { +static const char *BBS_user_level_names[] = { "新手上路", // 0 "初来乍练", // 1 "白手起家", // 2 @@ -101,7 +102,7 @@ static const char *user_level_names[] = "★★★★★", // 15 }; -static const int user_level_cnt = sizeof(user_level_names) / sizeof(const char *); +static const int BBS_user_level_cnt = sizeof(BBS_user_level_names) / sizeof(const char *); const char *get_astro_name(time_t birthday) { @@ -117,34 +118,44 @@ const char *get_astro_name(time_t birthd return astro_names[tm_birth.tm_mon + 1]; } -const char *get_user_level_name(int point) +int get_user_level(int point) { int left; int right; int mid; left = 0; - right = user_level_cnt - 1; + right = BBS_user_level_cnt - 1; while (left < right) { mid = (left + right) / 2; - if (point < user_level_points[mid + 1]) + if (point < BBS_user_level_points[mid]) { - right = mid; + right = mid - 1; } - else if (point > user_level_points[mid + 1]) + else if (point > BBS_user_level_points[mid]) { left = mid + 1; } else // if (point == user_level_points[mid]) { - left = mid + 1; + left = mid; break; } } - return user_level_names[left]; + if (point < BBS_user_level_points[left]) + { + left--; + } + + return left; +} + +const char *get_user_level_name(int level) +{ + return BBS_user_level_names[level]; } char *setuserfile(char *buf, size_t len, const char *filename)