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

Diff of /lbbs/src/bbs.c

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

Revision 1.32 by sysadm, Thu Oct 23 14:49:24 2025 UTC Revision 1.41 by sysadm, Tue Dec 2 08:48:05 2025 UTC
# Line 1  Line 1 
1  /***************************************************************************  /* SPDX-License-Identifier: GPL-3.0-or-later */
2                                                          bbs.c  -  description  /*
3                                                           -------------------   * bbs
4          Copyright            : (C) 2004-2025 by Leaflet   *   - BBS related common definitions
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    
13  #include "bbs.h"  #include "bbs.h"
14  #include "common.h"  #include "common.h"
# Line 22  Line 18 
18  #include <signal.h>  #include <signal.h>
19  #include <time.h>  #include <time.h>
20    
21  #define BBS_port_default 23  enum _bbs_port_constant_t
22  #define BBS_ssh_port_default 22  {
23            BBS_port_default = 23,
24            BBS_ssh_port_default = 22,
25    };
26    
27  // BBS enviroment  // BBS enviroment
28  char BBS_id[BBS_id_max_len + 1] = "Example BBS";  char BBS_id[BBS_id_max_len + 1] = "Example BBS";
# Line 36  int BBS_max_client_per_ip = MAX_CLIENT_P Line 35  int BBS_max_client_per_ip = MAX_CLIENT_P
35  char BBS_start_dt[BBS_start_dt_max_len + 1] = "2000年 1月 1日";  char BBS_start_dt[BBS_start_dt_max_len + 1] = "2000年 1月 1日";
36  int BBS_sys_id = 1;  int BBS_sys_id = 1;
37    
38  const int BBS_section_list_load_interval = 5; // second  const int BBS_section_list_load_interval = 1; // second
39    
40  // User  // User
41  const int BBS_user_list_load_interval = 60;               // 1 minute  const int BBS_user_list_load_interval = 60;               // 1 minute
# Line 48  char BBS_nickname[BBS_nickname_max_len + Line 47  char BBS_nickname[BBS_nickname_max_len +
47  char BBS_user_tz[BBS_user_tz_max_len + 1];  char BBS_user_tz[BBS_user_tz_max_len + 1];
48  int BBS_user_exp;  int BBS_user_exp;
49    
50    time_t BBS_eula_tm;
51    int BBS_update_eula = 0;
52    
53  time_t BBS_login_tm;  time_t BBS_login_tm;
54  time_t BBS_last_access_tm;  time_t BBS_last_access_tm;
55    
# Line 62  static const int astro_dates[] = { Line 64  static const int astro_dates[] = {
64  static const char *astro_names[] = {  static const char *astro_names[] = {
65          "摩羯", "水瓶", "双鱼", "白羊", "金牛", "双子", "巨蟹", "狮子", "处女", "天秤", "天蝎", "射手", "摩羯"};          "摩羯", "水瓶", "双鱼", "白羊", "金牛", "双子", "巨蟹", "狮子", "处女", "天秤", "天蝎", "射手", "摩羯"};
66    
67  static const int user_level_points[] = {  static const int BBS_user_level_points[] = {
68          INT_MIN, // 0          INT_MIN, // 0
69          50,              // 1          50,              // 1
70          200,     // 2          200,     // 2
# Line 79  static const int user_level_points[] = { Line 81  static const int user_level_points[] = {
81          80000,   // 13          80000,   // 13
82          90000,   // 14          90000,   // 14
83          100000,  // 15          100000,  // 15
         INT_MAX, // 16  
84  };  };
85    
86  static const char *user_level_names[] = {  static const char *BBS_user_level_names[] = {
87          "新手上路", // 0          "新手上路", // 0
88          "初来乍练", // 1          "初来乍练", // 1
89          "白手起家", // 2          "白手起家", // 2
# Line 101  static const char *user_level_names[] = Line 102  static const char *user_level_names[] =
102          "★★★★★",        // 15          "★★★★★",        // 15
103  };  };
104    
105  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 *);
106    
107  const char *get_astro_name(time_t birthday)  const char *get_astro_name(time_t birthday)
108  {  {
# Line 117  const char *get_astro_name(time_t birthd Line 118  const char *get_astro_name(time_t birthd
118          return astro_names[tm_birth.tm_mon + 1];          return astro_names[tm_birth.tm_mon + 1];
119  }  }
120    
121  const char *get_user_level_name(int point)  int get_user_level(int point)
122  {  {
123          int left;          int left;
124          int right;          int right;
125          int mid;          int mid;
126    
127          left = 0;          left = 0;
128          right = user_level_cnt - 1;          right = BBS_user_level_cnt - 1;
129    
130          while (left < right)          while (left < right)
131          {          {
132                  mid = (left + right) / 2;                  mid = (left + right) / 2;
133                  if (point < user_level_points[mid + 1])                  if (point < BBS_user_level_points[mid])
134                  {                  {
135                          right = mid;                          right = mid - 1;
136                  }                  }
137                  else if (point > user_level_points[mid + 1])                  else if (point > BBS_user_level_points[mid])
138                  {                  {
139                          left = mid + 1;                          left = mid + 1;
140                  }                  }
141                  else // if (point == user_level_points[mid])                  else // if (point == user_level_points[mid])
142                  {                  {
143                          left = mid + 1;                          left = mid;
144                          break;                          break;
145                  }                  }
146          }          }
147    
148          return user_level_names[left];          if (point < BBS_user_level_points[left])
149            {
150                    left--;
151            }
152    
153            return left;
154    }
155    
156    const char *get_user_level_name(int level)
157    {
158            return BBS_user_level_names[level];
159  }  }
160    
161  char *setuserfile(char *buf, size_t len, const char *filename)  char *setuserfile(char *buf, size_t len, const char *filename)


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

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