44 lines
1.1 KiB
C
44 lines
1.1 KiB
C
#ifndef K_HASHTABLE_H
|
|
#define K_HASHTABLE_H
|
|
#include <stdint.h>
|
|
#include "hlist.h"
|
|
|
|
typedef struct online_user{
|
|
uint32_t user_ip; /*用户IP*/
|
|
char user_name[32]; /*用户名, 不允许重名*/
|
|
int user_id; /*用户ID,唯一标识用户*/
|
|
int group_id; /* 用户组ID,唯一标识用户组*/
|
|
uint64_t message_num; /*下行报文数*/
|
|
uint64_t byte_num; /*下行字节数*/
|
|
time_t online_time; /* 在线时间*/
|
|
}ONLINE_USER;
|
|
|
|
|
|
typedef struct user_info{
|
|
struct hlist_node hnode;
|
|
ONLINE_USER auth_user;
|
|
}USER_INFO;
|
|
|
|
|
|
/*计算hash值 */
|
|
struct hlist_head *call_hash(struct hlist_head *hash, uint32_t ip);
|
|
|
|
/*初始化函数 */
|
|
int Init_hash();
|
|
|
|
/*查找用户信息*/
|
|
struct user_info *ufind_user(uint32_t user_ip);
|
|
|
|
/*增加用户信息*/
|
|
int uadd_user(uint32_t user_ip, char *name, int user_id, int group_id, uint64_t message_num, uint64_t byte_num, time_t online_time);
|
|
|
|
/*删除用户信息 */
|
|
void udelete_user(int user_ip);
|
|
|
|
/*删除所有的hash节点 */
|
|
void udelete_all();
|
|
|
|
/*打印所有信息信息 */
|
|
void uprintf_users();
|
|
|
|
#endif |