/[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.20 - (show annotations)
Sun Nov 2 14:38:53 2025 UTC (4 months, 2 weeks ago) by sysadm
Branch: MAIN
Changes since 1.19: +3 -1 lines
Content type: text/x-chdr
Add user search in user list display
Fix bug: memory of user introduction pointed by USER_INFO.intro might be overwritten during user_list_pool_reload(),
         use external buffer passed into query_user_info_by_uid() to prevent this issue.

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

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