| 1 |
sysadm |
1.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 <mysql/mysql.h>
|
| 22 |
|
|
|
| 23 |
sysadm |
1.2 |
#define BBS_user_limit_per_page 20
|
| 24 |
sysadm |
1.5 |
#define BBS_session_id_length 32
|
| 25 |
sysadm |
1.2 |
|
| 26 |
sysadm |
1.10 |
#define BBS_user_intro_avg_len 256
|
| 27 |
|
|
|
| 28 |
sysadm |
1.1 |
struct user_info_t
|
| 29 |
|
|
{
|
| 30 |
sysadm |
1.6 |
int32_t id;
|
| 31 |
sysadm |
1.1 |
int32_t uid;
|
| 32 |
|
|
char username[BBS_username_max_len + 1];
|
| 33 |
|
|
char nickname[BBS_nickname_max_len + 1];
|
| 34 |
|
|
char gender;
|
| 35 |
|
|
int8_t gender_pub;
|
| 36 |
|
|
int32_t life;
|
| 37 |
|
|
int32_t exp;
|
| 38 |
sysadm |
1.10 |
int32_t visit_count;
|
| 39 |
sysadm |
1.1 |
time_t signup_dt;
|
| 40 |
|
|
time_t last_login_dt;
|
| 41 |
|
|
time_t birthday;
|
| 42 |
sysadm |
1.10 |
const char *intro;
|
| 43 |
sysadm |
1.1 |
};
|
| 44 |
|
|
typedef struct user_info_t USER_INFO;
|
| 45 |
|
|
|
| 46 |
sysadm |
1.6 |
struct user_info_index_uid_t
|
| 47 |
|
|
{
|
| 48 |
|
|
int32_t uid;
|
| 49 |
|
|
int32_t id;
|
| 50 |
|
|
};
|
| 51 |
|
|
typedef struct user_info_index_uid_t USER_INFO_INDEX_UID;
|
| 52 |
|
|
|
| 53 |
sysadm |
1.1 |
struct user_list_t
|
| 54 |
|
|
{
|
| 55 |
|
|
USER_INFO users[BBS_max_user_count];
|
| 56 |
sysadm |
1.6 |
USER_INFO_INDEX_UID index_uid[BBS_max_user_count];
|
| 57 |
sysadm |
1.1 |
int32_t user_count;
|
| 58 |
sysadm |
1.10 |
char user_intro_buf[BBS_user_intro_avg_len * BBS_max_user_count];
|
| 59 |
sysadm |
1.1 |
};
|
| 60 |
|
|
typedef struct user_list_t USER_LIST;
|
| 61 |
|
|
|
| 62 |
sysadm |
1.5 |
struct user_online_info_t
|
| 63 |
|
|
{
|
| 64 |
sysadm |
1.6 |
int32_t id;
|
| 65 |
sysadm |
1.5 |
char session_id[BBS_session_id_length + 1];
|
| 66 |
|
|
USER_INFO user_info;
|
| 67 |
|
|
char ip[IP_ADDR_LEN];
|
| 68 |
|
|
char current_action[BBS_current_action_max_len + 1];
|
| 69 |
|
|
const char *current_action_title;
|
| 70 |
|
|
time_t login_tm;
|
| 71 |
|
|
time_t last_tm;
|
| 72 |
|
|
};
|
| 73 |
|
|
typedef struct user_online_info_t USER_ONLINE_INFO;
|
| 74 |
|
|
|
| 75 |
|
|
struct user_online_list_t
|
| 76 |
|
|
{
|
| 77 |
|
|
USER_ONLINE_INFO users[BBS_max_user_online_count];
|
| 78 |
sysadm |
1.9 |
USER_INFO_INDEX_UID index_uid[BBS_max_user_online_count];
|
| 79 |
sysadm |
1.5 |
int32_t user_count;
|
| 80 |
|
|
};
|
| 81 |
|
|
typedef struct user_online_list_t USER_ONLINE_LIST;
|
| 82 |
sysadm |
1.1 |
|
| 83 |
|
|
extern int user_list_pool_init(void);
|
| 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 |
sysadm |
1.5 |
extern int user_list_pool_reload(int online_user);
|
| 89 |
sysadm |
1.1 |
|
| 90 |
sysadm |
1.2 |
extern int query_user_list(int page_id, USER_INFO *p_users, int *p_user_count, int *p_page_count);
|
| 91 |
sysadm |
1.5 |
extern int query_user_online_list(int page_id, USER_ONLINE_INFO *p_online_users, int *p_user_count, int *p_page_count);
|
| 92 |
sysadm |
1.2 |
|
| 93 |
sysadm |
1.6 |
extern int query_user_info(int32_t id, USER_INFO *p_user);
|
| 94 |
|
|
extern int query_user_info_by_uid(int32_t uid, USER_INFO *p_user);
|
| 95 |
sysadm |
1.8 |
|
| 96 |
sysadm |
1.6 |
extern int query_user_online_info(int32_t id, USER_ONLINE_INFO *p_user);
|
| 97 |
sysadm |
1.8 |
extern int query_user_online_info_by_uid(int32_t uid, USER_ONLINE_INFO *p_users, int *p_user_cnt, int start_id);
|
| 98 |
sysadm |
1.3 |
|
| 99 |
sysadm |
1.1 |
#endif //_USER_LIST_H_
|