typedef struct st_HASH_TAB
{
UINT4 hsize;
void **tab;
tMemPoolId *memid;
tMutex *mutex;
}HASH_TAB;
INT1 flw_sav_add_upload_uc_msgno_bind(INT1 *p_username, UINT1 user_type, UINT4 msg_no, UINT1 msg_type, UINT4 uc_msg_no)
{
UPLOAD_UC_MSGNO_MAP *p_app_uc_map = NULL;
UPLOAD_UC_MSGNO_MAP *p_app_location = NULL;
HASH_TAB *p_relation_tab = &g_uplaod_policy_hashtab;
INT4 hash_index = 0;
hash_index = FLW_SAV_username_type_hash(p_username,user_type,p_relation_tab->hsize);
//如果策略类型为上报,则加入上报哈希表
p_app_uc_map = ((UPLOAD_UC_MSGNO_MAP**)p_relation_tab->tab)[hash_index];
while(p_app_uc_map)
{
if((strncmp(p_app_uc_map->username, p_username,L_USERID) == 0)&&
(p_app_uc_map->msg_no == msg_no) &&
(p_app_uc_map->msg_type == msg_type)&&
(p_app_uc_map->uc_msg_no == uc_msg_no)&&
(p_app_uc_map->user_type == user_type))
{
DebugOut(FLW_MOD_SAVE, LEVEL_INFO, "exist! msg_type:%d,msg_no:%d,uc_msg_no:%d\n",
msg_type, msg_no, uc_msg_no);
return SUCCESS;
}
p_app_uc_map = p_app_uc_map->pnext;
}
p_app_uc_map = (UPLOAD_UC_MSGNO_MAP*)GetMemFromPool(p_relation_tab->memid);
if(NULL == p_app_uc_map)
{
DebugOut(FLW_MOD_SAVE, LEVEL_ERR, " get mem from pool failure!\n");
return FAILURE;
}
memset(p_app_uc_map, 0x0, sizeof(UPLOAD_UC_MSGNO_MAP));
strncpy(p_app_uc_map->username, p_username, L_USERID);
p_app_uc_map->uc_msg_no = uc_msg_no;
p_app_uc_map->msg_no = msg_no;
p_app_uc_map->msg_type = msg_type;
p_app_uc_map->user_type = user_type;
p_app_location = ((UPLOAD_UC_MSGNO_MAP **)p_relation_tab->tab)[hash_index];
if(p_app_location)
{
p_app_uc_map->pnext = p_app_location;
p_app_location->prev = p_app_uc_map;
}
((UPLOAD_UC_MSGNO_MAP **)p_relation_tab->tab)[hash_index] = p_app_uc_map;
DebugOut(FLW_MOD_SAVE, LEVEL_INFO, "add new node! msg_type:%d,msg_no:%d,uc_msg_no:%d\n",
msg_type, msg_no, uc_msg_no);
return SUCCESS;
}