From aef1b985ea3c7899b44c3aee4db4bab3a5829a5f Mon Sep 17 00:00:00 2001 From: ChenLing Date: Mon, 15 Jul 2019 12:37:37 +0800 Subject: [PATCH] =?UTF-8?q?Mod=20=20aaa-12=20=E5=88=A0=E9=99=A4=E4=B9=8B?= =?UTF-8?q?=E5=89=8D=E5=86=99=E7=9A=84=E7=94=A8=E6=88=B7=E8=AE=A4=E8=AF=81?= =?UTF-8?q?=E7=9B=91=E6=B5=8B=E8=A1=A8=E5=A2=9E=E5=88=A0=E6=94=B9=E6=9F=A5?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=20RCA=EF=BC=9A=20SOL=EF=BC=9A=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E4=BA=BA=EF=BC=9Achenling=20=E6=A3=80=E8=A7=86?= =?UTF-8?q?=E4=BA=BA=EF=BC=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Product/common/u-hashtable.c | 62 ------------------------------------ Product/common/u-hashtable.h | 40 ----------------------- 2 files changed, 102 deletions(-) delete mode 100644 Product/common/u-hashtable.c delete mode 100644 Product/common/u-hashtable.h diff --git a/Product/common/u-hashtable.c b/Product/common/u-hashtable.c deleted file mode 100644 index 2db599223..000000000 --- a/Product/common/u-hashtable.c +++ /dev/null @@ -1,62 +0,0 @@ -#include -#include -#include -#include -#include "u-hashtable.h" - -/*initialize */ -USER_STRUCT *users = NULL; - -/*add user information */ -void uadd_user(uint32_t user_ip, USER user_info) -{ - USER_STRUCT *s ; - HASH_FIND_INT(users, &user_ip, s); /*ip already in the hash? */ - if(s == NULL) - { - s = (struct user_struct *)malloc(sizeof *s); - s->ip = user_ip; - HASH_ADD_INT(users, ip, s); - } - - s->info = user_info; -} - -/*find user information */ -USER_STRUCT *ufind_user(uint32_t user_ip) -{ - USER_STRUCT *s; - HASH_FIND_INT(users, &user_ip, s); - printf("user_nams: %s user_id:%d usergroud_id:%d\n", s->info.name, s->info.user_id, s->info.usergroud_id); - return s; -} - -/*delete user information */ -void udelete_user(USER_STRUCT *user) -{ - HASH_DEL(users, user); /* user: pointer to delete */ - free(user); -} - -/*delect all uesr'informations */ -void udelete_all() -{ - USER_STRUCT *current_user, *tmp; - HASH_ITER(hh, users, current_user, tmp) - { - HASH_DEL(users,current_user); /* delete; users advances to next */ - free(current_user); - } -} - -/*printf user information */ -void uprint_users() -{ - USER_STRUCT *s; - char str[32]; - for(s=users; s != NULL; s=(USER_STRUCT *)(s->hh.next)) - { - inet_ntop(AF_INET, (void *)&s->ip, str, 32); - printf(" user_ip: %s user_nams: %s user_id:%d usergroud_id:%d\n", str, s->info.name, s->info.user_id, s->info.usergroud_id); - } -} diff --git a/Product/common/u-hashtable.h b/Product/common/u-hashtable.h deleted file mode 100644 index 38702564b..000000000 --- a/Product/common/u-hashtable.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef U_HASHTABLE_H -#define U_HASHTABLE_H -#include -#include -#include "uthash.h" - -typedef struct user_info -{ - char name[32]; /*用户名 */ - int user_id; /*用户ID */ - int usergroud_id; /*用户组ID */ - uint64_t message_num; /*下行报文数 */ - uint64_t byte_num; /*下行字节数*/ - time_t online_time; /*在线时间 */ -}USER; - - -typedef struct user_struct -{ - uint32_t ip; /*用户IP key*/ - USER info; /*用户信息 */ - UT_hash_handle hh; -}USER_STRUCT; - -/*add user information */ -void uadd_user(uint32_t user_ip, USER user_info); - -/*find user information */ -USER_STRUCT *ufind_user(uint32_t user_ip); - -/*delete user information */ -void udelete_user(USER_STRUCT *user); - -/*delect all uesr'informations */ -void udelete_all(); - -/*printf user information */ -void uprint_users(); - -#endif \ No newline at end of file