/[LeafOK_CVS]/lbbs/include/user_list.h
ViewVC logotype

Contents of /lbbs/include/user_list.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.27 - (show annotations)
Sat Jan 3 10:27:14 2026 UTC (2 months, 1 week ago) by sysadm
Branch: MAIN
CVS Tags: HEAD
Changes since 1.26: +1 -1 lines
Content type: text/x-chdr
Update copyright info

1 /* SPDX-License-Identifier: GPL-3.0-or-later */
2 /*
3 * user_list
4 * - data model and basic operations of (online) user list
5 *
6 * Copyright (C) 2004-2026 Leaflet <leaflet@leafok.com>
7 */
8
9 #ifndef _USER_LIST_H_
10 #define _USER_LIST_H_
11
12 #include "bbs.h"
13 #include "common.h"
14 #include <mysql.h>
15
16 enum user_list_constant_t
17 {
18 BBS_user_limit_per_page = 20,
19 BBS_session_id_length = 32,
20
21 BBS_user_intro_avg_len = 256,
22 BBS_user_intro_max_len = 4096,
23 BBS_user_intro_max_line = 10,
24 };
25
26 struct user_info_t
27 {
28 int32_t id;
29 int32_t uid;
30 char username[BBS_username_max_len + 1];
31 char nickname[BBS_nickname_max_len + 1];
32 char gender;
33 int8_t gender_pub;
34 int32_t life;
35 int32_t exp;
36 int32_t visit_count;
37 time_t signup_dt;
38 time_t last_login_dt;
39 time_t last_logout_dt;
40 time_t birthday;
41 const char *intro;
42 };
43 typedef struct user_info_t USER_INFO;
44
45 struct user_info_index_uid_t
46 {
47 int32_t uid;
48 int32_t id;
49 };
50 typedef struct user_info_index_uid_t USER_INFO_INDEX_UID;
51
52 struct user_list_t
53 {
54 USER_INFO users[BBS_max_user_count];
55 USER_INFO_INDEX_UID index_uid[BBS_max_user_count];
56 int32_t user_count;
57 char user_intro_buf[BBS_user_intro_avg_len * BBS_max_user_count];
58 };
59 typedef struct user_list_t USER_LIST;
60
61 struct user_online_info_t
62 {
63 int32_t id;
64 char session_id[BBS_session_id_length + 1];
65 USER_INFO user_info;
66 char ip[IP_ADDR_LEN];
67 char current_action[BBS_current_action_max_len + 1];
68 const char *current_action_title;
69 time_t login_tm;
70 time_t last_tm;
71 };
72 typedef struct user_online_info_t USER_ONLINE_INFO;
73
74 struct user_online_list_t
75 {
76 USER_ONLINE_INFO users[BBS_max_user_online_count];
77 USER_INFO_INDEX_UID index_uid[BBS_max_user_online_count];
78 int32_t user_count;
79 int32_t guest_count;
80 };
81 typedef struct user_online_list_t USER_ONLINE_LIST;
82
83 extern int user_list_pool_init(const char *filename);
84 extern void user_list_pool_cleanup(void);
85 extern int set_user_list_pool_shm_readonly(void);
86 extern int detach_user_list_pool_shm(void);
87
88 extern int user_list_pool_reload(int online_user);
89
90 extern int query_user_list(int page_id, USER_INFO *p_users, int *p_user_count, int *p_page_count);
91 extern int query_user_online_list(int page_id, USER_ONLINE_INFO *p_online_users, int *p_user_count, int *p_page_count);
92
93 extern int get_user_list_count(int *p_user_cnt);
94 extern int get_user_online_list_count(int *p_user_cnt, int *p_guest_cnt);
95 extern int get_user_login_count(int *p_login_cnt);
96
97 extern int query_user_info(int32_t id, USER_INFO *p_user);
98 extern int query_user_info_by_uid(int32_t uid, USER_INFO *p_user, char *p_intro_buf, size_t intro_buf_len);
99 extern int query_user_info_by_username(const char *username_prefix, int max_user_cnt,
100 int32_t uid_list[], char username_list[][BBS_username_max_len + 1]);
101
102 extern int query_user_online_info(int32_t id, USER_ONLINE_INFO *p_user);
103 extern int query_user_online_info_by_uid(int32_t uid, USER_ONLINE_INFO *p_users, int *p_user_cnt, int start_id);
104
105 extern int get_user_id_list(int32_t *p_uid_list, int *p_user_cnt, int start_uid);
106
107 extern int user_stat_update(void);
108 extern int user_article_cnt_inc(int32_t uid, int n);
109 extern int get_user_article_cnt(int32_t uid);
110
111 #endif //_USER_LIST_H_

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