Merge branch 'master' of http://git.komect.net/ISG/secogateway
This commit is contained in:
commit
ebc8d47cf0
|
@ -42,6 +42,7 @@
|
|||
|
||||
#define USER_MANAGER_CONFIG_GROUP (uint64)((uint64)USER_MANAGER_CONFIG_MODULE<<32|1)
|
||||
#define USER_MANAGER_CONFIG_USER (uint64)((uint64)USER_MANAGER_CONFIG_MODULE<<32|2)
|
||||
#define USER_MANAGER_CONFIG_RECOVER (uint64)((uint64)USER_MANAGER_CONFIG_MODULE<<32|3)
|
||||
|
||||
#define AUTHFREE_CONFIG (uint64)((uint64)LOCALAUTH_CONFIG_MODULE<<32|1)
|
||||
#define FREEPARAMETERS_CONFIG (uint64)((uint64)LOCALAUTH_CONFIG_MODULE<<32|2)
|
||||
|
|
|
@ -98,6 +98,7 @@ public class HuaweiNetconfSpeaker implements DataTreeChangeListener<ConnectorInf
|
|||
InstanceIdentifier<ConnectorInfo> connectPath = InstanceIdentifier.create(ConnectorInfo.class);
|
||||
final DataTreeIdentifier<ConnectorInfo> dataTreeIdentifier = new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, connectPath);
|
||||
configurationReg = dataBroker.registerDataTreeChangeListener(dataTreeIdentifier, this);
|
||||
LOG.info("HuaweiNetconfSpeaker Session Initiated");
|
||||
}
|
||||
|
||||
|
||||
|
@ -105,9 +106,7 @@ public class HuaweiNetconfSpeaker implements DataTreeChangeListener<ConnectorInf
|
|||
/**create netconf node with connect device information */
|
||||
final NetconfNodeBuilder netconfNodeBuilder = new NetconfNodeBuilder();
|
||||
netconfNodeBuilder.setHost(new Host(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress(connectDevice.getIp().getIpv4Address())))
|
||||
.setPort(new PortNumber(connectDevice.getPort().getValue()))
|
||||
.setTcpOnly(true)
|
||||
.setSchemaless(true);
|
||||
.setPort(new PortNumber(connectDevice.getPort().getValue()));
|
||||
String username = connectDevice.getUserName();
|
||||
String password = connectDevice.getPassword();
|
||||
if (Strings.isNullOrEmpty(username) || Strings.isNullOrEmpty(password)) {
|
||||
|
@ -259,10 +258,12 @@ public class HuaweiNetconfSpeaker implements DataTreeChangeListener<ConnectorInf
|
|||
readInfoFromDevice(nodeId);
|
||||
}, 0, 10000, TimeUnit.MILLISECONDS);
|
||||
if (Objects.nonNull(threads.get(nodeId))) {
|
||||
LOG.info("remove exist pool in thread map");
|
||||
if (!threads.get(nodeId).isShutdown()) {
|
||||
threads.get(nodeId).shutdownNow();
|
||||
}
|
||||
}
|
||||
LOG.info("put pool in thread map with key {}",nodeId);
|
||||
threads.put(nodeId, pool);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ COMMON_SRCS = configserver.c \
|
|||
web_config/config-adm/user_authpara.c \
|
||||
web_config/config-adm/user_authfree.c \
|
||||
web_config/authfree.c web_config/auth_parameters.c\
|
||||
user_manager_config/user_group_config.c user_manager_config/user_account_config.c user_manager_config/usermanager-server/array_index.c \
|
||||
user_manager_config/user_recover_config.c user_manager_config/user_group_config.c user_manager_config/user_account_config.c user_manager_config/usermanager-server/array_index.c \
|
||||
user_manager_config/usermanager-server/user_group.c user_manager_config/usermanager-server/user_mod.c user_manager_config/usermanager-server/user.c \
|
||||
log_config/log_config_console.c log_config/log_config_init.c log_config/log_config_cm.c log_config/log_config_monitor.c log_config/log_config_remote.c log_config/log_config_file.c \
|
||||
nat_config/natconfig.c
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "../../../../../Common/commuapinl.h"
|
||||
#include "../user_manager_config/user_group_config.h"
|
||||
#include "../user_manager_config/user_account_config.h"
|
||||
#include "../user_manager_config/user_recover_config.h"
|
||||
#include "netconfig.h"
|
||||
#include "log_config.h"
|
||||
#include "../web_config/authfree.h"
|
||||
|
@ -84,6 +85,15 @@
|
|||
usergroup_config_get, \
|
||||
usergroup_config_get_all \
|
||||
},\
|
||||
{\
|
||||
USER_MANAGER_CONFIG_RECOVER, \
|
||||
CONFIG_FROM_RECOVER1, \
|
||||
TRUE, \
|
||||
userecover_config_chk, \
|
||||
userecover_config_proc, \
|
||||
userecover_config_get, \
|
||||
userecover_config_get_all \
|
||||
},\
|
||||
{ \
|
||||
AUTHFREE_CONFIG, \
|
||||
CONFIG_FROM_WEB|CONFIG_FROM_NETOPEER, \
|
||||
|
|
|
@ -92,7 +92,7 @@ ret_code user_config_chk(uint source, uint *config_type,
|
|||
|
||||
* 0:成功、1:失败
|
||||
*/
|
||||
static ret_code user_config_get_detail_proc(uint source, uint config_type,
|
||||
static ret_code user_config_get_detail_proc(uint source,
|
||||
pointer input, int input_len,
|
||||
pointer output, int *output_len)
|
||||
{
|
||||
|
@ -215,7 +215,7 @@ static ret_code user_config_get_detail_proc(uint source, uint config_type,
|
|||
|
||||
* 0:成功、1:失败
|
||||
*/
|
||||
static ret_code user_config_get_uuid_proc(uint source, uint config_type,
|
||||
static ret_code user_config_get_uuid_proc(uint source,
|
||||
pointer input, int input_len,
|
||||
pointer output, int *output_len)
|
||||
{
|
||||
|
@ -300,7 +300,7 @@ static ret_code user_config_get_uuid_proc(uint source, uint config_type,
|
|||
}
|
||||
* 0:成功、1:失败
|
||||
*/
|
||||
static ret_code user_config_get_list_proc(uint source, uint config_type,
|
||||
static ret_code user_config_get_list_proc(uint source,
|
||||
pointer input, int input_len,
|
||||
pointer output, int *output_len)
|
||||
{
|
||||
|
@ -1067,16 +1067,16 @@ ret_code user_config_proc(uint source, uint config_type,
|
|||
input, input_len,
|
||||
output, output_len);
|
||||
break;
|
||||
case USER_CONFIG_GET:
|
||||
ret = user_config_get_detail_proc(source, config_type,
|
||||
input, input_len,
|
||||
output, output_len);
|
||||
break;
|
||||
case USER_CONFIG_GET_ALL:
|
||||
ret = user_config_get_list_proc(source, config_type,
|
||||
input, input_len,
|
||||
output, output_len);
|
||||
break;
|
||||
// case USER_CONFIG_GET:
|
||||
// ret = user_config_get_detail_proc(source, config_type,
|
||||
// input, input_len,
|
||||
// output, output_len);
|
||||
// break;
|
||||
// case USER_CONFIG_GET_ALL:
|
||||
// ret = user_config_get_list_proc(source, config_type,
|
||||
// input, input_len,
|
||||
// output, output_len);
|
||||
// break;
|
||||
case USER_CONFIG_MOD_LINE:
|
||||
ret = user_config_mod_line_proc(source, config_type,
|
||||
input, input_len,
|
||||
|
@ -1087,8 +1087,54 @@ ret_code user_config_proc(uint source, uint config_type,
|
|||
input, input_len,
|
||||
output, output_len);
|
||||
break;
|
||||
// case USER_CONFIG_GET_UUID:
|
||||
// ret = user_config_get_uuid_proc(source, config_type,
|
||||
// input, input_len,
|
||||
// output, output_len);
|
||||
// break;
|
||||
default:
|
||||
ret = RET_NOTSUPPORT;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* 查询函数接口
|
||||
* iuput格式:{"type": 0,"data": {xxx}}
|
||||
*/
|
||||
ret_code user_config_get(uint source,
|
||||
pointer input, int input_len,
|
||||
pointer output, int *output_len)
|
||||
{
|
||||
ret_code ret = RET_OK;
|
||||
cJSON *root, *type_json;
|
||||
int fun_type;
|
||||
|
||||
/* 获取对应的函数type */
|
||||
FUNCTYPE_GET(input, fun_type);
|
||||
|
||||
if(ERR_FUNC_TYPE == fun_type)
|
||||
{
|
||||
ret = RET_INPUTERR;
|
||||
//ASSERT_RET(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
switch(fun_type)
|
||||
{
|
||||
case USER_CONFIG_GET:
|
||||
ret = user_config_get_detail_proc(source,
|
||||
input, input_len,
|
||||
output, output_len);
|
||||
break;
|
||||
case USER_CONFIG_GET_ALL:
|
||||
ret = user_config_get_list_proc(source,
|
||||
input, input_len,
|
||||
output, output_len);
|
||||
break;
|
||||
case USER_CONFIG_GET_UUID:
|
||||
ret = user_config_get_uuid_proc(source, config_type,
|
||||
ret = user_config_get_uuid_proc(source,
|
||||
input, input_len,
|
||||
output, output_len);
|
||||
break;
|
||||
|
@ -1099,14 +1145,6 @@ ret_code user_config_proc(uint source, uint config_type,
|
|||
return ret;
|
||||
}
|
||||
|
||||
ret_code user_config_get(uint source,
|
||||
pointer input, int input_len,
|
||||
pointer output, int *output_len)
|
||||
{
|
||||
ret_code ret = RET_OK;
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret_code user_config_get_all(uint source,
|
||||
pointer output, int *output_len)
|
||||
{
|
||||
|
|
|
@ -87,7 +87,7 @@ ret_code usergroup_config_chk(uint source, uint *config_type,
|
|||
|
||||
* 0:成功、1:失败
|
||||
*/
|
||||
static ret_code usergroup_config_get_list_proc(uint source, uint config_type,
|
||||
static ret_code usergroup_config_get_list_proc(uint source,
|
||||
pointer input, int input_len,
|
||||
pointer output, int *output_len)
|
||||
{
|
||||
|
@ -178,7 +178,7 @@ static ret_code usergroup_config_get_list_proc(uint source, uint config_type,
|
|||
|
||||
* 0:成功、1:失败
|
||||
*/
|
||||
static ret_code usergroup_config_get_uuid_proc(uint source, uint config_type,
|
||||
static ret_code usergroup_config_get_uuid_proc(uint source,
|
||||
pointer input, int input_len,
|
||||
pointer output, int *output_len)
|
||||
{
|
||||
|
@ -490,7 +490,7 @@ static ret_code usergroup_config_del_proc(uint source, uint config_type,
|
|||
|
||||
/*用户组配置处理
|
||||
*input格式:{"type": 0,"data": {xxx}}
|
||||
*output格式:{"result": 0}
|
||||
*output格式:
|
||||
*/
|
||||
ret_code usergroup_config_proc(uint source, uint config_type,
|
||||
pointer input, int input_len,
|
||||
|
@ -527,13 +527,54 @@ ret_code usergroup_config_proc(uint source, uint config_type,
|
|||
input, input_len,
|
||||
output, output_len);
|
||||
break;
|
||||
// case USERGROUP_CONFIG_GET_ALL:
|
||||
// ret = usergroup_config_get_list_proc(source, config_type,
|
||||
// input, input_len,
|
||||
// output, output_len);
|
||||
// break;
|
||||
// case USERGROUP_CONFIG_GET_UUID:
|
||||
// ret = usergroup_config_get_uuid_proc(source, config_type,
|
||||
// input, input_len,
|
||||
// output, output_len);
|
||||
// break;
|
||||
default:
|
||||
ret = RET_NOTSUPPORT;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*用户组查询
|
||||
*input格式:{"type": 0,"data": {xxx}}
|
||||
*output格式:
|
||||
*/
|
||||
ret_code usergroup_config_get(uint source,
|
||||
pointer input, int input_len,
|
||||
pointer output, int *output_len)
|
||||
{
|
||||
ret_code ret = RET_OK;
|
||||
int fun_type;
|
||||
cJSON *root, *type_json;
|
||||
|
||||
/* 获取对应的函数type */
|
||||
FUNCTYPE_GET(input, fun_type);
|
||||
|
||||
if(ERR_FUNC_TYPE == fun_type)
|
||||
{
|
||||
ret = RET_INPUTERR;
|
||||
//ASSERT_RET(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
switch(fun_type)
|
||||
{
|
||||
case USERGROUP_CONFIG_GET_ALL:
|
||||
ret = usergroup_config_get_list_proc(source, config_type,
|
||||
ret = usergroup_config_get_list_proc(source,
|
||||
input, input_len,
|
||||
output, output_len);
|
||||
break;
|
||||
case USERGROUP_CONFIG_GET_UUID:
|
||||
ret = usergroup_config_get_uuid_proc(source, config_type,
|
||||
ret = usergroup_config_get_uuid_proc(source,
|
||||
input, input_len,
|
||||
output, output_len);
|
||||
break;
|
||||
|
@ -544,14 +585,6 @@ ret_code usergroup_config_proc(uint source, uint config_type,
|
|||
return ret;
|
||||
}
|
||||
|
||||
ret_code usergroup_config_get(uint source,
|
||||
pointer input, int input_len,
|
||||
pointer output, int *output_len)
|
||||
{
|
||||
ret_code ret = RET_OK;
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret_code usergroup_config_get_all(uint source,
|
||||
pointer output, int *output_len)
|
||||
{
|
||||
|
|
|
@ -0,0 +1,175 @@
|
|||
#include <cjson/cJSON.h>
|
||||
#include "configm.h"
|
||||
#include "user_recover_config.h"
|
||||
#include "usermanager-server/include/user_group.h"
|
||||
#include "usermanager-server/include/user.h"
|
||||
#include "usermanager-server/include/common_user.h"
|
||||
#include "usermanager-server/include/array_index.h"
|
||||
#include "rpc.h"
|
||||
#include "parsefile.h"
|
||||
#include "database.h"
|
||||
#include "s2j/s2j.h"
|
||||
#include "s2j/s2jdef.h"
|
||||
|
||||
void * um_hdbc = NULL;//用户管理数据库连接句柄
|
||||
extern ARRAY g_user_index_head;
|
||||
extern ARRAY g_group_index_head;
|
||||
extern USERACCOUNT g_user_table[];
|
||||
extern USERGROUP g_group_table[];
|
||||
|
||||
ret_code userecover_config_chk(uint source, uint *config_type,
|
||||
pointer input, int *input_len,
|
||||
pointer output, int *output_len)
|
||||
{
|
||||
ret_code ret = RET_OK;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
ret_code userecover_config_proc(uint source, uint config_type,
|
||||
pointer input, int input_len,
|
||||
pointer output, int *output_len)
|
||||
{
|
||||
ret_code ret = RET_OK;
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret_code userecover_config_get(uint source,
|
||||
pointer input, int input_len,
|
||||
pointer output, int *output_len)
|
||||
{
|
||||
ret_code ret = RET_OK;
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret_code userecover_config_get_all(uint source,
|
||||
pointer output, int *output_len)
|
||||
{
|
||||
ret_code ret = RET_OK;
|
||||
char * group_db = NULL;
|
||||
char * user_db = NULL;
|
||||
|
||||
if(CONFIG_FROM_RECOVER1 != source)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
um_hdbc = connect_database(USER_MANAGER_DBID);
|
||||
|
||||
if(NULL == um_hdbc)
|
||||
{
|
||||
ret = RET_SYSERR;
|
||||
return ret;
|
||||
}
|
||||
init_group();
|
||||
init_user();
|
||||
|
||||
um_getgroup_db(&group_db);
|
||||
if(NULL != group_db)
|
||||
{
|
||||
cJSON * root_g = cJSON_Parse(group_db);
|
||||
if(NULL == root_g)
|
||||
{
|
||||
UCHAR_FREE(group_db);
|
||||
ret = RET_ERR;
|
||||
return ret;
|
||||
}
|
||||
|
||||
cJSON * array_g = cJSON_GetObjectItem(root_g, "data");
|
||||
if(NULL == array_g)
|
||||
{
|
||||
UCHAR_FREE(group_db);
|
||||
cJSON_Delete(root_g);
|
||||
ret = RET_ERR;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int mun_g = cJSON_GetArraySize(array_g);
|
||||
if(0 == mun_g)
|
||||
{
|
||||
UCHAR_FREE(group_db);
|
||||
cJSON_Delete(root_g);
|
||||
return ret;
|
||||
}
|
||||
|
||||
s2j_create_struct_obj(temp_group, USERGROUP);
|
||||
|
||||
for (int i = 0; i < mun_g; i++)
|
||||
{
|
||||
cJSON * group = cJSON_GetArrayItem(array_g, i);
|
||||
|
||||
s2j_struct_get_basic_element(temp_group, group, int, ID);
|
||||
s2j_struct_get_basic_element(temp_group, group, string, gname);
|
||||
s2j_struct_get_basic_element(temp_group, group, string, gdescription);
|
||||
|
||||
g_group_table[temp_group->ID].ID = temp_group->ID;
|
||||
strcpy(g_group_table[temp_group->ID].gname, temp_group->gname);
|
||||
strcpy(g_group_table[temp_group->ID].gdescription, temp_group->gdescription);
|
||||
|
||||
alloc_index_special(&g_group_index_head, temp_group->ID);
|
||||
}
|
||||
s2j_delete_struct_obj(temp_group);
|
||||
UCHAR_FREE(group_db);
|
||||
}
|
||||
|
||||
|
||||
um_getuser_db(&user_db);
|
||||
if(NULL != user_db)
|
||||
{
|
||||
cJSON * root_u = cJSON_Parse(user_db);
|
||||
if(NULL == root_u)
|
||||
{
|
||||
UCHAR_FREE(user_db);
|
||||
ret = RET_ERR;
|
||||
return ret;
|
||||
}
|
||||
cJSON * array_u = cJSON_GetObjectItem(root_u, "data");
|
||||
if(NULL == array_u)
|
||||
{
|
||||
UCHAR_FREE(user_db);
|
||||
cJSON_Delete(root_u);
|
||||
ret = RET_ERR;
|
||||
return ret;
|
||||
}
|
||||
int mun_u = cJSON_GetArraySize(array_u);
|
||||
if(0 == mun_u)
|
||||
{
|
||||
UCHAR_FREE(user_db);
|
||||
cJSON_Delete(root_u);
|
||||
return ret;
|
||||
}
|
||||
|
||||
s2j_create_struct_obj(temp_user, USERLIST);
|
||||
|
||||
for (int i = 0; i < mun_u; i++)
|
||||
{
|
||||
cJSON * user = cJSON_GetArrayItem(array_u, i);
|
||||
|
||||
s2j_struct_get_basic_element(temp_user, user, int, ID);
|
||||
s2j_struct_get_basic_element(temp_user, user, int, GID);
|
||||
s2j_struct_get_basic_element(temp_user, user, int, multi);
|
||||
s2j_struct_get_basic_element(temp_user, user, int, valid);
|
||||
s2j_struct_get_basic_element(temp_user, user, string, uname);
|
||||
s2j_struct_get_basic_element(temp_user, user, string, udescription);
|
||||
s2j_struct_get_basic_element(temp_user, user, string, valid_begin_time);
|
||||
s2j_struct_get_basic_element(temp_user, user, string, valid_end_time);
|
||||
|
||||
g_user_table[temp_user->ID].ID = temp_user->ID;
|
||||
g_user_table[temp_user->ID].GID = temp_user->ID;
|
||||
g_user_table[temp_user->ID].multi_valid = MULTI_VALID(temp_user->multi, temp_user->valid);
|
||||
strcpy(g_user_table[temp_user->ID].uname, temp_user->uname);
|
||||
strcpy(g_user_table[temp_user->ID].udescription, temp_user->udescription);
|
||||
if (1 == temp_user->valid)
|
||||
{
|
||||
STRING2TIME_T(temp_user->valid_begin_time, g_user_table[temp_user->ID].valid_begin_time);
|
||||
STRING2TIME_T(temp_user->valid_end_time, g_user_table[temp_user->ID].valid_end_time);
|
||||
}
|
||||
|
||||
alloc_index_special(&g_user_index_head, temp_user->ID);
|
||||
}
|
||||
s2j_delete_struct_obj(temp_user);
|
||||
UCHAR_FREE(user_db);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
#ifndef USER_RECOVER_CONFIG_H_
|
||||
#define USER_RECOVER_CONFIG_H_
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <net/if.h>
|
||||
#include <cjson/cJSON.h>
|
||||
|
||||
|
||||
#include "configmapi.h"
|
||||
#include "rpc_common.h"
|
||||
|
||||
|
||||
/* user 恢复 config */
|
||||
ret_code userecover_config_chk(uint source, uint *config_type,
|
||||
pointer input, int *input_len,
|
||||
pointer output, int *output_len);
|
||||
|
||||
ret_code userecover_config_proc(uint source, uint config_type,
|
||||
pointer input, int input_len,
|
||||
pointer output, int *output_len);
|
||||
|
||||
ret_code userecover_config_get(uint source,
|
||||
pointer input, int input_len,
|
||||
pointer output, int *output_len);
|
||||
|
||||
ret_code userecover_config_get_all(uint source,
|
||||
pointer output, int *output_len);
|
||||
|
||||
#endif
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#define USER_TABLE "user_account"
|
||||
#define USER_GROUP_TABLE "user_group"
|
||||
#define USER_MANAGER_DBID 3
|
||||
|
||||
#define TIME_T2STRING(time_int, time_char) (strftime((time_char), 20, "%Y-%m-%d %H:%M:%S", (localtime(&time_int))))
|
||||
#define STRING2TIME_T(time_char,time_int) \
|
||||
|
@ -31,6 +32,7 @@ do { \
|
|||
#define MULTI_SET(element, value) (((element) & VALID_MASK) | (((value) << 1) & MULTI_MASK))
|
||||
#define VALID_GET(element) ((element) & VALID_MASK)
|
||||
#define VALID_SET(element, value) (((element) & MULTI_MASK) | ((value) & VALID_MASK))
|
||||
#define MULTI_VALID(multi, valid) ((((multi) << 1) & MULTI_MASK) | ((valid) & VALID_MASK))
|
||||
|
||||
#define FUNCTYPE_GET(input,fun_type) \
|
||||
do { \
|
||||
|
|
|
@ -119,4 +119,7 @@ void offline_force_one_user(unsigned short user_id);
|
|||
/* 查询用户列表 */
|
||||
bool useraccount_showlist(int group_id, char * user_name, int page_start, int page_counts, char ** user_list);
|
||||
|
||||
/* 查询 user_account 内存恢复 */
|
||||
void um_getuser_db(char ** user_db);
|
||||
|
||||
#endif
|
|
@ -85,5 +85,11 @@ void offline_force_by_groupid(char *groupid);
|
|||
/*解析用户组id的json字符串 --> 用户组id*/
|
||||
unsigned short id_json2int(char * gid, char * para_name);
|
||||
|
||||
/*查user_group表 内存恢复*/
|
||||
void um_getgroup_db(char ** group_db);
|
||||
|
||||
/*数据库重连*/
|
||||
void re_connect();
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
extern ARRAY g_user_index_head;
|
||||
extern USERGROUP g_group_table[];
|
||||
extern exce_mod_user g_user_modfunc_table[];
|
||||
extern void * um_hdbc;
|
||||
//extern USER_AUTH_LIST g_user_auth_ret_table[];
|
||||
USERACCOUNT g_user_table[USER_INDEX_MAX];
|
||||
|
||||
|
@ -36,7 +37,6 @@ int init_user()
|
|||
/*添加元素-新增用户*/
|
||||
void usermanager_add_user(char* uname, char* gname, char* udesp, char* pwd, int multi, int valid, char* valid_begin_time, char* valid_end_time, USERADD* uaddres)
|
||||
{
|
||||
void *adduser_hdbc;
|
||||
time_t begin_time;
|
||||
time_t end_time;
|
||||
|
||||
|
@ -104,8 +104,9 @@ void usermanager_add_user(char* uname, char* gname, char* udesp, char* pwd, int
|
|||
}
|
||||
|
||||
/* 连接数据库 */
|
||||
adduser_hdbc = connect_database(USER_ACCOUNT_DATABASE_ID);
|
||||
if(NULL == adduser_hdbc)
|
||||
//adduser_hdbc = connect_database(USER_ACCOUNT_DATABASE_ID);
|
||||
re_connect();
|
||||
if(NULL == um_hdbc)
|
||||
{
|
||||
/* 记录日志 */
|
||||
uaddres->result = ADDUSER_FAIL_DATABASE;
|
||||
|
@ -113,18 +114,16 @@ void usermanager_add_user(char* uname, char* gname, char* udesp, char* pwd, int
|
|||
}
|
||||
|
||||
/* 根据用户组名查询用户组ID */
|
||||
unsigned short GID_temp = get_groupid_by_name(gname, adduser_hdbc);
|
||||
unsigned short GID_temp = get_groupid_by_name(gname, um_hdbc);
|
||||
if(INVALID_INDEX == GID_temp)
|
||||
{
|
||||
disconnect_database(USER_ACCOUNT_DATABASE_ID, adduser_hdbc); // ret_release记录日志
|
||||
uaddres->result = ADDUSER_FAIL_NOGROUP;
|
||||
return;
|
||||
}
|
||||
|
||||
/* 校验重名 */
|
||||
if(0 != get_userid_by_name(uname, adduser_hdbc))
|
||||
if(0 != get_userid_by_name(uname, um_hdbc))
|
||||
{
|
||||
disconnect_database(USER_ACCOUNT_DATABASE_ID, adduser_hdbc); // ret_release记录日志
|
||||
uaddres->result =ADDUSER_FAIL_NAMEDUP;
|
||||
return;
|
||||
}
|
||||
|
@ -133,7 +132,6 @@ void usermanager_add_user(char* uname, char* gname, char* udesp, char* pwd, int
|
|||
unsigned short ID = alloc_index(&g_user_index_head);
|
||||
if (INVALID_INDEX == ID)
|
||||
{
|
||||
disconnect_database(USER_ACCOUNT_DATABASE_ID, adduser_hdbc); // ret_release记录日志
|
||||
uaddres->result = ADDUSER_FAIL_USERFULL;
|
||||
return;
|
||||
}
|
||||
|
@ -141,7 +139,7 @@ void usermanager_add_user(char* uname, char* gname, char* udesp, char* pwd, int
|
|||
/* 连接数据库,存user_account表 */
|
||||
char *adduser_sql = "INSERT INTO `user_account` SET id = ?, group_id = ?, user_name = ?, password = ?, udescription = ?, \
|
||||
multi_player = ?, valid_always = ?, valid_begin_time = ?, valid_end_time = ?";
|
||||
int ret_adduser = update_database(USER_ACCOUNT_DATABASE_ID, adduser_hdbc, DB_OP_INSERT, USER_TABLE, adduser_sql, 9,
|
||||
int ret_adduser = update_database(USER_MANAGER_DBID, um_hdbc, DB_OP_INSERT, USER_TABLE, adduser_sql, 9,
|
||||
DB_DATA_INT_TYPE, sizeof(ID), ID,
|
||||
DB_DATA_INT_TYPE, sizeof(GID_temp), GID_temp,
|
||||
DB_DATA_STRING_TYPE, strlen(uname)+1, uname,
|
||||
|
@ -151,11 +149,9 @@ void usermanager_add_user(char* uname, char* gname, char* udesp, char* pwd, int
|
|||
DB_DATA_INT_TYPE, sizeof(valid), valid,
|
||||
DB_DATA_STRING_TYPE, strlen(valid_begin_time)+1, valid_begin_time,
|
||||
DB_DATA_STRING_TYPE, strlen(valid_end_time)+1,valid_end_time);
|
||||
disconnect_database(USER_ACCOUNT_DATABASE_ID, adduser_hdbc); // ret_release记录日志
|
||||
if(DB_RET_OK != ret_adduser)
|
||||
{
|
||||
free_index(&g_user_index_head, ID);
|
||||
//disconnect_database(USER_ACCOUNT_DATABASE_ID, adduser_hdbc); // ret_release记录日志
|
||||
uaddres->result = ADDUSER_FAIL_DATABASE;
|
||||
return;
|
||||
}
|
||||
|
@ -176,7 +172,6 @@ void usermanager_add_user(char* uname, char* gname, char* udesp, char* pwd, int
|
|||
g_user_table[ID].valid_end_time = end_time;
|
||||
}
|
||||
|
||||
//int ret_release = disconnect_database(USER_ACCOUNT_DATABASE_ID, adduser_hdbc); // ret_release记录日志
|
||||
uaddres->result = ADDUSER_SUCCESS;
|
||||
uaddres->userID = ID;
|
||||
return;
|
||||
|
@ -185,7 +180,6 @@ void usermanager_add_user(char* uname, char* gname, char* udesp, char* pwd, int
|
|||
/* 按照用户uuid查询用户详情 */
|
||||
bool get_user_detail_by_user_uuid(int user_uuid, char ** user_detail)
|
||||
{
|
||||
void * gud_hdbc;
|
||||
char * point;
|
||||
int num;
|
||||
if (NULL == user_detail)
|
||||
|
@ -193,8 +187,9 @@ bool get_user_detail_by_user_uuid(int user_uuid, char ** user_detail)
|
|||
return false;
|
||||
}
|
||||
|
||||
gud_hdbc = connect_database(USER_ACCOUNT_DATABASE_ID);
|
||||
if (NULL == gud_hdbc)
|
||||
//gud_hdbc = connect_database(USER_ACCOUNT_DATABASE_ID);
|
||||
re_connect();
|
||||
if (NULL == um_hdbc)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -202,9 +197,8 @@ bool get_user_detail_by_user_uuid(int user_uuid, char ** user_detail)
|
|||
char * select_sql = "SELECT U.uuid ID, G.uuid GID, U.user_name uname, G.gname gname, U.udescription udescription,\
|
||||
U.multi_player multi, U.valid_always valid, U.valid_begin_time, U.valid_end_time \
|
||||
FROM user_account U, user_group G WHERE U.group_id = G.id AND U.uuid = ? ";
|
||||
char * udetail = select_datebase_by_number(USER_ACCOUNT_DATABASE_ID, gud_hdbc, USER_TABLE, select_sql, 1, 0, &num, 1,
|
||||
char * udetail = select_datebase_by_number(USER_MANAGER_DBID, um_hdbc, USER_TABLE, select_sql, 1, 0, &num, 1,
|
||||
DB_DATA_INT_TYPE, sizeof(user_uuid), user_uuid);
|
||||
int ret_discon = disconnect_database(USER_ACCOUNT_DATABASE_ID, gud_hdbc);
|
||||
|
||||
if (0 == num || NULL == udetail)
|
||||
{
|
||||
|
@ -277,7 +271,6 @@ void get_user_by_id(unsigned short ID, USERLIST* ulist)
|
|||
/* 修改用户-web */
|
||||
bool mod_user_web(USERLIST* ulist)
|
||||
{
|
||||
void *moduser_web_hdbc;
|
||||
int ret_release;
|
||||
time_t cur_time;
|
||||
char *temp_begin_time, *temp_end_time, *temp_pwd, *temp_udes, *temp_user_json;
|
||||
|
@ -326,8 +319,6 @@ bool mod_user_web(USERLIST* ulist)
|
|||
temp_pwd = ulist->passwd;
|
||||
}
|
||||
|
||||
//get_user_by_id(ulist->ID, &temp_user);
|
||||
|
||||
/* 获取修改前的数据 - 这里的temp_user_json需要释放 */
|
||||
bool ret_getuser = get_user_detail_by_user_uuid(ulist->ID, &temp_user_json);
|
||||
if (!ret_getuser)
|
||||
|
@ -382,19 +373,19 @@ bool mod_user_web(USERLIST* ulist)
|
|||
UCHAR_FREE(temp_user_json);
|
||||
|
||||
/* 连接数据库,更新user表 */
|
||||
moduser_web_hdbc = connect_database(USER_ACCOUNT_DATABASE_ID);
|
||||
if(NULL == moduser_web_hdbc)
|
||||
//moduser_web_hdbc = connect_database(USER_ACCOUNT_DATABASE_ID);
|
||||
re_connect();
|
||||
if(NULL == um_hdbc)
|
||||
{
|
||||
s2j_delete_struct_obj(temp_user);
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned short user_id = get_userid_by_name(ulist->uname, moduser_web_hdbc);
|
||||
unsigned short group_id = get_groupid_by_name(ulist->gname, moduser_web_hdbc);
|
||||
unsigned short user_id = get_userid_by_name(ulist->uname, um_hdbc);
|
||||
unsigned short group_id = get_groupid_by_name(ulist->gname, um_hdbc);
|
||||
if(INVALID_INDEX == user_id || INVALID_INDEX == group_id)
|
||||
{
|
||||
s2j_delete_struct_obj(temp_user);
|
||||
ret_release = disconnect_database(USER_ACCOUNT_DATABASE_ID, moduser_web_hdbc); //ret_release记录日志
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -404,7 +395,7 @@ bool mod_user_web(USERLIST* ulist)
|
|||
{
|
||||
moduser_web_sql = "UPDATE `user_account` SET group_id = (SELECT user_group.id FROM user_group WHERE user_group.uuid = ?),\
|
||||
udescription = ?, password = ?, multi_player = ?, valid_always = ?, valid_begin_time = ?, valid_end_time = ? WHERE uuid = ?";
|
||||
ret_moduser_web = update_database(USER_ACCOUNT_DATABASE_ID, moduser_web_hdbc, DB_OP_UPDATE, USER_TABLE, moduser_web_sql, 8,
|
||||
ret_moduser_web = update_database(USER_MANAGER_DBID, um_hdbc, DB_OP_UPDATE, USER_TABLE, moduser_web_sql, 8,
|
||||
DB_DATA_INT_TYPE, sizeof(ulist->GID), ulist->GID,
|
||||
DB_DATA_STRING_TYPE, strlen(temp_udes)+1, temp_udes,
|
||||
DB_DATA_STRING_TYPE, strlen(temp_pwd)+1, temp_pwd,
|
||||
|
@ -417,7 +408,7 @@ bool mod_user_web(USERLIST* ulist)
|
|||
{
|
||||
moduser_web_sql = "UPDATE `user_account` SET group_id = (SELECT user_group.id FROM user_group WHERE user_group.uuid = ?),\
|
||||
udescription = ?, multi_player = ?, valid_always = ?, valid_begin_time = ?, valid_end_time = ? WHERE uuid = ?";
|
||||
ret_moduser_web = update_database(USER_ACCOUNT_DATABASE_ID, moduser_web_hdbc, DB_OP_UPDATE, USER_TABLE, moduser_web_sql, 7,
|
||||
ret_moduser_web = update_database(USER_MANAGER_DBID, um_hdbc, DB_OP_UPDATE, USER_TABLE, moduser_web_sql, 7,
|
||||
DB_DATA_INT_TYPE, sizeof(ulist->GID), ulist->GID,
|
||||
DB_DATA_STRING_TYPE, strlen(temp_udes)+1, temp_udes,
|
||||
DB_DATA_INT_TYPE, sizeof(ulist->multi), ulist->multi,
|
||||
|
@ -427,7 +418,6 @@ bool mod_user_web(USERLIST* ulist)
|
|||
DB_DATA_INT_TYPE, sizeof(ulist->ID), ulist->ID);
|
||||
}
|
||||
|
||||
ret_release = disconnect_database(USER_ACCOUNT_DATABASE_ID, moduser_web_hdbc); //ret_release记录日志
|
||||
if(DB_RET_OK != ret_moduser_web)
|
||||
{
|
||||
s2j_delete_struct_obj(temp_user);
|
||||
|
@ -549,8 +539,7 @@ bool uuid_json2int(char * gid, char * name, unsigned short * id)
|
|||
bool get_user_uuid_by_name(char* uname, unsigned short * user_uuid)
|
||||
{
|
||||
char *uid = NULL;
|
||||
int num, discon;
|
||||
void * uhdbc;
|
||||
int num;
|
||||
unsigned short uuid_temp = INVALID_INDEX;
|
||||
|
||||
if (NULL == uname || NULL == user_uuid)
|
||||
|
@ -558,19 +547,17 @@ bool get_user_uuid_by_name(char* uname, unsigned short * user_uuid)
|
|||
return false;
|
||||
}
|
||||
|
||||
uhdbc = connect_database(USER_ACCOUNT_DATABASE_ID);
|
||||
if (NULL == uhdbc)
|
||||
//uhdbc = connect_database(USER_ACCOUNT_DATABASE_ID);
|
||||
re_connect();
|
||||
if (NULL == um_hdbc)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/* 连接数据库,根据用户名查询user表中的uuid */
|
||||
char* select_sql = "SELECT uuid FROM user_account WHERE user_name = ?";
|
||||
uid = select_datebase_by_number(USER_ACCOUNT_DATABASE_ID, uhdbc, USER_TABLE, select_sql, 1, 0, &num, 1,
|
||||
uid = select_datebase_by_number(USER_MANAGER_DBID, um_hdbc, USER_TABLE, select_sql, 1, 0, &num, 1,
|
||||
DB_DATA_STRING_TYPE, strlen(uname)+1, uname);
|
||||
/* 删除数据连接 */
|
||||
discon = disconnect_database(USER_ACCOUNT_DATABASE_ID, uhdbc); //discon记录日志
|
||||
|
||||
if(0 == num)
|
||||
{
|
||||
*user_uuid = INVALID_INDEX;
|
||||
|
@ -604,7 +591,7 @@ unsigned short get_userid_by_name(char* uname, void* hdbc)
|
|||
|
||||
/* 连接数据库,根据用户名查询user表中的id */
|
||||
char* select_sql = "SELECT id FROM user_account WHERE user_name = ?";
|
||||
uid = select_datebase_by_number(USER_ACCOUNT_DATABASE_ID, hdbc, USER_TABLE, select_sql, 1, 0, &num, 1,
|
||||
uid = select_datebase_by_number(USER_MANAGER_DBID, hdbc, USER_TABLE, select_sql, 1, 0, &num, 1,
|
||||
DB_DATA_STRING_TYPE, strlen(uname)+1, uname);
|
||||
if(0 == num)
|
||||
{
|
||||
|
@ -619,7 +606,6 @@ unsigned short get_userid_by_name(char* uname, void* hdbc)
|
|||
/* 修改用户-命令行 */
|
||||
bool mod_user_line(char* uname, const int intype, char* in)
|
||||
{
|
||||
void *moduser_line_hdbc;
|
||||
unsigned short uid;
|
||||
bool result = true;
|
||||
if (NULL == uname || NULL == in)
|
||||
|
@ -634,16 +620,15 @@ bool mod_user_line(char* uname, const int intype, char* in)
|
|||
}
|
||||
|
||||
/* 连接数据库,更新user表 */
|
||||
moduser_line_hdbc = connect_database(13);
|
||||
if(NULL == moduser_line_hdbc)
|
||||
re_connect();
|
||||
//moduser_line_hdbc = connect_database(13);
|
||||
if(NULL == um_hdbc)
|
||||
{
|
||||
/* 记录日志 */
|
||||
//printf("moduser_line_hdbc连接数据库失败 .\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
/* 根据用户名查询用户ID */
|
||||
uid = get_userid_by_name(uname, moduser_line_hdbc);
|
||||
uid = get_userid_by_name(uname, um_hdbc);
|
||||
|
||||
if (INVALID_INDEX == uid)
|
||||
{
|
||||
|
@ -651,9 +636,7 @@ bool mod_user_line(char* uname, const int intype, char* in)
|
|||
}
|
||||
|
||||
/*(0)描述、(1)所属组名、(2)登陆密码、(3)公用账号、(4)永久有效、(5)有效期开始时间、(6)有效期结束时间 */
|
||||
result = g_user_modfunc_table[intype](uid, in, moduser_line_hdbc);
|
||||
|
||||
int ret_release = disconnect_database(USER_ACCOUNT_DATABASE_ID, moduser_line_hdbc); //ret_release记录日志
|
||||
result = g_user_modfunc_table[intype](uid, in, um_hdbc);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -661,7 +644,6 @@ bool mod_user_line(char* uname, const int intype, char* in)
|
|||
/* 修改用户-移动分组 */
|
||||
bool move_user_group(int flag_all, unsigned short new_group_uuid, unsigned short old_group_uuid, unsigned short * user_uuid, int user_uuid_num)
|
||||
{
|
||||
void * moveug_hdbc,* selectgid_hdbc;;
|
||||
char * moveug_sql;
|
||||
char * selectuid_sql;
|
||||
char * ret_userids;
|
||||
|
@ -676,31 +658,20 @@ bool move_user_group(int flag_all, unsigned short new_group_uuid, unsigned short
|
|||
}
|
||||
|
||||
//连接数据库
|
||||
moveug_hdbc = connect_database(USER_ACCOUNT_DATABASE_ID); //更新用户表
|
||||
if (NULL == moveug_hdbc || NULL == selectgid_hdbc)
|
||||
//moveug_hdbc = connect_database(USER_ACCOUNT_DATABASE_ID); //更新用户表
|
||||
re_connect();
|
||||
if (NULL == um_hdbc)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//根据新组的uuid获取新组的id
|
||||
temp_groupid = get_groupid_by_uuid(new_group_uuid, moveug_hdbc);
|
||||
temp_groupid = get_groupid_by_uuid(new_group_uuid, um_hdbc);
|
||||
if (INVALID_INDEX == temp_groupid)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// char * ret_new_groupid_json = select_datebase_by_number(USER_GROUP_DATABASE_ID, selectgid_hdbc, USER_GROUP_TABLE, "SELECT id FROM `user_group` WHERE uuid = ?",
|
||||
// 1, 0, &sql_num, 1,
|
||||
// DB_DATA_INT_TYPE, sizeof(new_group_uuid), new_group_uuid);
|
||||
// if (0 == sql_num || NULL == ret_new_groupid_json)
|
||||
// {
|
||||
// ret_discon = disconnect_database(USER_GROUP_DATABASE_ID, selectgid_hdbc);
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// ARRAYJSON2INT(ret_new_groupid_json, "id", &temp_groupid);
|
||||
//temp_groupid = id_json2int(temp_test01, "id");
|
||||
|
||||
//按照group_uuid移动
|
||||
if (0 == flag_all || NULL ==user_uuid)
|
||||
{
|
||||
|
@ -722,26 +693,23 @@ bool move_user_group(int flag_all, unsigned short new_group_uuid, unsigned short
|
|||
)";
|
||||
selectuid_sql = "SELECT id FROM `user_account` WHERE group_id = (SELECT user_group.id FROM user_group WHERE user_group.uuid = ?)";
|
||||
|
||||
ret_userids = select_datebase_by_number(USER_ACCOUNT_DATABASE_ID, moveug_hdbc, USER_TABLE, selectuid_sql, 1, 0, &sql_num, 1,
|
||||
ret_userids = select_datebase_by_number(USER_MANAGER_DBID, um_hdbc, USER_TABLE, selectuid_sql, 1, 0, &sql_num, 1,
|
||||
DB_DATA_INT_TYPE, sizeof(old_group_uuid), old_group_uuid);
|
||||
//解析ret_userids --> temp_userids
|
||||
if(0 == sql_num || NULL == ret_userids)
|
||||
{
|
||||
ret_discon = disconnect_database(USER_ACCOUNT_DATABASE_ID, moveug_hdbc);
|
||||
return false;
|
||||
}
|
||||
|
||||
cJSON * ret_root_json = cJSON_Parse(ret_userids);
|
||||
if (NULL == ret_root_json)
|
||||
{
|
||||
ret_discon = disconnect_database(USER_ACCOUNT_DATABASE_ID, moveug_hdbc);
|
||||
return false;
|
||||
}
|
||||
|
||||
cJSON * ret_data_json = cJSON_GetObjectItem(ret_root_json, "data");
|
||||
if(NULL == ret_data_json)
|
||||
{
|
||||
ret_discon = disconnect_database(USER_ACCOUNT_DATABASE_ID, moveug_hdbc);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -752,17 +720,15 @@ bool move_user_group(int flag_all, unsigned short new_group_uuid, unsigned short
|
|||
cJSON * ret_id_json = cJSON_GetArrayItem(ret_data_json, i);
|
||||
if (NULL == ret_id_json)
|
||||
{
|
||||
ret_discon = disconnect_database(USER_ACCOUNT_DATABASE_ID, moveug_hdbc);
|
||||
return false;
|
||||
}
|
||||
temp_userids[ret_id_json->valueint] = ret_id_json->valueint;
|
||||
}
|
||||
}
|
||||
|
||||
ret_sql = update_database(USER_ACCOUNT_DATABASE_ID, moveug_hdbc, DB_OP_UPDATE, USER_TABLE, moveug_sql, 2,
|
||||
ret_sql = update_database(USER_MANAGER_DBID, um_hdbc, DB_OP_UPDATE, USER_TABLE, moveug_sql, 2,
|
||||
DB_DATA_INT_TYPE, sizeof(temp_groupid), temp_groupid,
|
||||
DB_DATA_INT_TYPE, sizeof(old_group_uuid), old_group_uuid);
|
||||
ret_discon = disconnect_database(USER_ACCOUNT_DATABASE_ID, moveug_hdbc);
|
||||
if (DB_RET_OK != ret_sql)
|
||||
{
|
||||
return false;
|
||||
|
@ -774,7 +740,6 @@ bool move_user_group(int flag_all, unsigned short new_group_uuid, unsigned short
|
|||
{
|
||||
if (NULL == user_uuid)
|
||||
{
|
||||
ret_discon = disconnect_database(USER_ACCOUNT_DATABASE_ID, moveug_hdbc);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -783,27 +748,24 @@ bool move_user_group(int flag_all, unsigned short new_group_uuid, unsigned short
|
|||
for (int i = 0; i < user_uuid_num; i++)
|
||||
{
|
||||
unsigned short temp_uesr_uuid = 0;
|
||||
ret_userids = select_datebase_by_number(USER_ACCOUNT_DATABASE_ID, moveug_hdbc, USER_TABLE, selectuid_sql, 1, 0, &sql_num, 1,
|
||||
ret_userids = select_datebase_by_number(USER_MANAGER_DBID, um_hdbc, USER_TABLE, selectuid_sql, 1, 0, &sql_num, 1,
|
||||
DB_DATA_INT_TYPE, sizeof(user_uuid[i]), user_uuid[i]);
|
||||
if(0 == sql_num || NULL ==ret_userids)
|
||||
{
|
||||
ret_discon = disconnect_database(USER_ACCOUNT_DATABASE_ID, moveug_hdbc);
|
||||
return false;
|
||||
}
|
||||
ARRAYJSON2INT(ret_userids, "id", &temp_userid);
|
||||
temp_userids[temp_userid] = temp_userid;
|
||||
|
||||
temp_uesr_uuid = user_uuid[i];
|
||||
ret_sql = update_database(USER_ACCOUNT_DATABASE_ID, moveug_hdbc, DB_OP_UPDATE, USER_TABLE, moveug_sql, 2,
|
||||
ret_sql = update_database(USER_MANAGER_DBID, um_hdbc, DB_OP_UPDATE, USER_TABLE, moveug_sql, 2,
|
||||
DB_DATA_INT_TYPE, sizeof(temp_groupid), temp_groupid,
|
||||
DB_DATA_INT_TYPE, sizeof(temp_uesr_uuid), temp_uesr_uuid);
|
||||
if(DB_RET_OK != ret_sql)
|
||||
{
|
||||
ret_discon = disconnect_database(USER_ACCOUNT_DATABASE_ID, moveug_hdbc);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
ret_discon = disconnect_database(USER_ACCOUNT_DATABASE_ID, moveug_hdbc);
|
||||
}
|
||||
|
||||
//修改内存
|
||||
|
@ -877,7 +839,6 @@ void offline_force_one_user(unsigned short user_id)
|
|||
int usermanager_del_user(USER_DEL* in)
|
||||
{
|
||||
unsigned short user_id_temp;
|
||||
void * deluser_hdbc;
|
||||
|
||||
if(NULL == in)
|
||||
{
|
||||
|
@ -885,8 +846,9 @@ int usermanager_del_user(USER_DEL* in)
|
|||
}
|
||||
|
||||
/* 连接数据库 */
|
||||
deluser_hdbc = connect_database(12);
|
||||
if(NULL == deluser_hdbc)
|
||||
//deluser_hdbc = connect_database(12);
|
||||
re_connect();
|
||||
if(NULL == um_hdbc)
|
||||
{
|
||||
/* 记录日志 */
|
||||
return DELUSER_FAIL_DATABASE;
|
||||
|
@ -901,7 +863,7 @@ int usermanager_del_user(USER_DEL* in)
|
|||
{
|
||||
return DELUSER_FAIL_NOTEXIST;
|
||||
}
|
||||
user_id_temp = get_userid_by_name(in->id_name.uname, deluser_hdbc);
|
||||
user_id_temp = get_userid_by_name(in->id_name.uname, um_hdbc);
|
||||
if (INVALID_INDEX == user_id_temp)
|
||||
{
|
||||
return DELUSER_FAIL_NOTEXIST;
|
||||
|
@ -922,13 +884,12 @@ int usermanager_del_user(USER_DEL* in)
|
|||
|
||||
/* 删数据库user_account */
|
||||
char* deluser_sql = "DELETE FROM user_account WHERE id = ?";
|
||||
int ret_del = update_database(USER_ACCOUNT_DATABASE_ID, deluser_hdbc, DB_OP_DEL, USER_TABLE, deluser_sql, 1,
|
||||
int ret_del = update_database(USER_MANAGER_DBID, um_hdbc, DB_OP_DEL, USER_TABLE, deluser_sql, 1,
|
||||
DB_DATA_INT_TYPE, sizeof(user_id_temp), user_id_temp);
|
||||
|
||||
/* 删内存,根据用户ID删除用户列表中对应的用户 - 释放index、ID置0 */
|
||||
free_index(&g_user_index_head, user_id_temp);
|
||||
g_user_table[user_id_temp].ID = INVALID_INDEX;
|
||||
int ret_release = disconnect_database(USER_ACCOUNT_DATABASE_ID, deluser_hdbc);
|
||||
return DELUSER_SUCCESS;
|
||||
/* 强制用户下线在外面 */
|
||||
}
|
||||
|
@ -936,7 +897,6 @@ int usermanager_del_user(USER_DEL* in)
|
|||
/* 查询用户列表 */
|
||||
bool useraccount_showlist(int uugroup_id, char * user_name, int page_start, int page_counts, char ** user_list)
|
||||
{
|
||||
void * getulist_hdbc; //数据库句柄
|
||||
int num, arrlen, page_s;
|
||||
char * ulist, *point, *select_sql;
|
||||
|
||||
|
@ -965,8 +925,9 @@ bool useraccount_showlist(int uugroup_id, char * user_name, int page_start, int
|
|||
page_s = (page_start - 1)*page_counts;
|
||||
|
||||
/* 连接数据库 */
|
||||
getulist_hdbc = connect_database(USER_ACCOUNT_DATABASE_ID);
|
||||
if(NULL == getulist_hdbc)
|
||||
//getulist_hdbc = connect_database(USER_ACCOUNT_DATABASE_ID);
|
||||
re_connect();
|
||||
if(NULL == um_hdbc)
|
||||
{
|
||||
/* 记录日志 */
|
||||
return false;
|
||||
|
@ -977,7 +938,7 @@ bool useraccount_showlist(int uugroup_id, char * user_name, int page_start, int
|
|||
select_sql = "SELECT U.uuid ID, G.uuid GID, U.user_name uname, G.gname gname, U.udescription udescription,\
|
||||
U.multi_player multi, U.valid_always valid, U.valid_begin_time, U.valid_end_time \
|
||||
FROM user_account U, user_group G WHERE U.group_id = G.id AND U.user_name LIKE ? LIMIT ?, ?";
|
||||
ulist = select_datebase_by_number(USER_ACCOUNT_DATABASE_ID, getulist_hdbc, USER_GROUP_TABLE, select_sql, 1, 0, &num, 3,
|
||||
ulist = select_datebase_by_number(USER_MANAGER_DBID, um_hdbc, USER_GROUP_TABLE, select_sql, 1, 0, &num, 3,
|
||||
DB_DATA_STRING_TYPE, arrlen+1, temp_uname,
|
||||
DB_DATA_INT_TYPE, sizeof(page_s), page_s,
|
||||
DB_DATA_INT_TYPE, sizeof(page_counts), page_counts);
|
||||
|
@ -986,13 +947,12 @@ bool useraccount_showlist(int uugroup_id, char * user_name, int page_start, int
|
|||
select_sql = "SELECT U.uuid ID, G.uuid GID, U.user_name uname, G.gname gname, U.udescription udescription,\
|
||||
U.multi_player multi, U.valid_always valid, U.valid_begin_time, U.valid_end_time \
|
||||
FROM user_account U, user_group G WHERE G.uuid = ? AND U.group_id = G.id AND U.user_name LIKE ? LIMIT ?, ?";
|
||||
ulist = select_datebase_by_number(USER_ACCOUNT_DATABASE_ID, getulist_hdbc, USER_GROUP_TABLE, select_sql, 1, 0, &num, 4,
|
||||
ulist = select_datebase_by_number(USER_MANAGER_DBID, um_hdbc, USER_GROUP_TABLE, select_sql, 1, 0, &num, 4,
|
||||
DB_DATA_INT_TYPE, sizeof(uugroup_id), uugroup_id,
|
||||
DB_DATA_STRING_TYPE, arrlen+1, temp_uname,
|
||||
DB_DATA_INT_TYPE, sizeof(page_s), page_s,
|
||||
DB_DATA_INT_TYPE, sizeof(page_counts), page_counts);
|
||||
}
|
||||
int discon = disconnect_database(USER_ACCOUNT_DATABASE_ID, getulist_hdbc); //discon记录日志
|
||||
if (0 == num || NULL == ulist) //查询结果为空
|
||||
{
|
||||
cJSON * root = cJSON_CreateObject();
|
||||
|
@ -1020,3 +980,36 @@ bool useraccount_showlist(int uugroup_id, char * user_name, int page_start, int
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* 查询 user_account 内存恢复 */
|
||||
void um_getuser_db(char ** user_db)
|
||||
{
|
||||
int num = 0;
|
||||
int size = 0;
|
||||
|
||||
re_connect();
|
||||
if(NULL == um_hdbc)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
char * select_sql = "SELECT id ID, group_id GID, multi_player multi, valid_always valid, user_name uname, udescription, valid_begin_time,valid_end_time FROM `user_account`";
|
||||
char * ret_user = select_datebase_by_number(USER_MANAGER_DBID, um_hdbc, USER_TABLE, select_sql, 1, 0, &num, 0);
|
||||
|
||||
if(0 == num || NULL == ret_user)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
size = strlen(ret_user)+1;
|
||||
char * point = (char*)malloc(size);
|
||||
if(NULL == point)
|
||||
{
|
||||
return;
|
||||
}
|
||||
memset(point, 0, size);
|
||||
memcpy(point, ret_user, size);
|
||||
*user_db = point; //在函数外面释放
|
||||
|
||||
return;
|
||||
}
|
|
@ -13,6 +13,7 @@
|
|||
extern ARRAY g_group_index_head;
|
||||
extern ARRAY g_user_index_head;
|
||||
extern USERACCOUNT g_user_table[];
|
||||
extern void * um_hdbc;
|
||||
USERGROUP g_group_table[GROUP_INDEX_MAX];
|
||||
|
||||
/* 初始化参数 */
|
||||
|
@ -31,8 +32,8 @@ int init_group()
|
|||
/* 添加元素 */
|
||||
int add_group(char* name, char* description)
|
||||
{
|
||||
void *addgroup_hdbc;
|
||||
int ret_release;
|
||||
//void *addgroup_hdbc;
|
||||
//int ret_release;
|
||||
if (NULL == name)
|
||||
{
|
||||
return ADDGROUP_ERROR;
|
||||
|
@ -56,17 +57,17 @@ int add_group(char* name, char* description)
|
|||
}
|
||||
|
||||
/* 连接数据库 */
|
||||
addgroup_hdbc = connect_database(USER_GROUP_DATABASE_ID);
|
||||
if(NULL == addgroup_hdbc)
|
||||
re_connect();
|
||||
//addgroup_hdbc = connect_database(USER_GROUP_DATABASE_ID);
|
||||
if(NULL == um_hdbc)
|
||||
{
|
||||
/* 记录日志 */
|
||||
return ADDGROUP_FAIL_DATABASE;
|
||||
}
|
||||
|
||||
/* 校验重名 */
|
||||
if(0 != get_groupid_by_name(name, addgroup_hdbc))
|
||||
if(0 != get_groupid_by_name(name, um_hdbc))
|
||||
{
|
||||
disconnect_database(USER_GROUP_DATABASE_ID, addgroup_hdbc); // ret_release记录日志
|
||||
return ADDGROUP_FAIL_DUP;
|
||||
}
|
||||
|
||||
|
@ -74,13 +75,12 @@ int add_group(char* name, char* description)
|
|||
unsigned short ID = alloc_index(&g_group_index_head);
|
||||
if (INVALID_INDEX == ID)
|
||||
{
|
||||
disconnect_database(USER_GROUP_DATABASE_ID, addgroup_hdbc); // ret_release记录日志
|
||||
return ADDGROUP_FAIL_FULL;
|
||||
}
|
||||
|
||||
/* 连接数据库,向user_group表中添加:用户组ID、用户组名和用户组描述 */
|
||||
char *addgroup_sql = "INSERT INTO user_group SET id = ?, gname = ?, gdescription = ?";
|
||||
int ret_addgroup = update_database(USER_GROUP_DATABASE_ID, addgroup_hdbc, DB_OP_INSERT, USER_GROUP_TABLE, addgroup_sql, 3,
|
||||
int ret_addgroup = update_database(USER_MANAGER_DBID, um_hdbc, DB_OP_INSERT, USER_GROUP_TABLE, addgroup_sql, 3,
|
||||
DB_DATA_INT_TYPE, sizeof(ID), ID,
|
||||
DB_DATA_STRING_TYPE, strlen(name)+1, name,
|
||||
DB_DATA_STRING_TYPE, strlen(description)+1,description);
|
||||
|
@ -88,7 +88,6 @@ int add_group(char* name, char* description)
|
|||
if(DB_RET_OK != ret_addgroup)
|
||||
{
|
||||
free_index(&g_group_index_head, ID);
|
||||
ret_release = disconnect_database(USER_GROUP_DATABASE_ID, addgroup_hdbc); // ret_release记录日志
|
||||
return ADDGROUP_FAIL_DATABASE;
|
||||
}
|
||||
|
||||
|
@ -97,16 +96,14 @@ int add_group(char* name, char* description)
|
|||
strcpy(g_group_table[ID].gname, name);
|
||||
strcpy(g_group_table[ID].gdescription, description);
|
||||
|
||||
ret_release = disconnect_database(USER_GROUP_DATABASE_ID, addgroup_hdbc); // ret_release记录日志
|
||||
|
||||
return ADDGROUP_SUCCESS;
|
||||
}
|
||||
|
||||
/* 修改用户组描述 */
|
||||
unsigned short mod_group_desp(int group_uuid, char* gdesp)
|
||||
{
|
||||
void *modgroup_hdbc;
|
||||
int ret_release;
|
||||
//void *modgroup_hdbc;
|
||||
//int ret_release;
|
||||
int num;
|
||||
if(NULL == gdesp)
|
||||
{
|
||||
|
@ -114,27 +111,25 @@ unsigned short mod_group_desp(int group_uuid, char* gdesp)
|
|||
}
|
||||
|
||||
/* 连接数据库 */
|
||||
modgroup_hdbc = connect_database(USER_GROUP_DATABASE_ID);
|
||||
if(NULL == modgroup_hdbc)
|
||||
re_connect();
|
||||
//modgroup_hdbc = connect_database(USER_GROUP_DATABASE_ID);
|
||||
if(NULL == um_hdbc)
|
||||
{
|
||||
/* 记录日志 */
|
||||
return MODGROUP_FAIL_DATABASE;
|
||||
}
|
||||
|
||||
unsigned short group_id = get_groupid_by_uuid(group_uuid, modgroup_hdbc);
|
||||
unsigned short group_id = get_groupid_by_uuid(group_uuid, um_hdbc);
|
||||
if(INVALID_INDEX == group_id)
|
||||
{
|
||||
ret_release = disconnect_database(USER_GROUP_DATABASE_ID, modgroup_hdbc); //ret_release记录日志
|
||||
return MODGROUP_FAIL_INPUT;
|
||||
}
|
||||
|
||||
/* 修改数据库 */
|
||||
char *modgroup_sql = "UPDATE user_group SET gdescription = ? WHERE uuid = ? ";
|
||||
int ret_modgroup = update_database(1, modgroup_hdbc, DB_OP_UPDATE, USER_GROUP_TABLE, modgroup_sql, 2,
|
||||
int ret_modgroup = update_database(USER_MANAGER_DBID, um_hdbc, DB_OP_UPDATE, USER_GROUP_TABLE, modgroup_sql, 2,
|
||||
DB_DATA_STRING_TYPE, strlen(gdesp), gdesp,
|
||||
DB_DATA_INT_TYPE, sizeof(group_uuid), group_uuid);
|
||||
ret_release = disconnect_database(USER_GROUP_DATABASE_ID, modgroup_hdbc); //ret_release记录日志
|
||||
|
||||
if(DB_RET_OK != ret_modgroup)
|
||||
{
|
||||
return MODGROUP_FAIL_DATABASE;
|
||||
|
@ -194,15 +189,14 @@ unsigned short get_group_count()
|
|||
/* 查询用户组列表 */
|
||||
bool show_group_list(char ** group_list)
|
||||
{
|
||||
void * getglist_hdbc;
|
||||
int num;
|
||||
if (NULL == group_list)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
getglist_hdbc = connect_database(USER_GROUP_DATABASE_ID);
|
||||
if (NULL == getglist_hdbc)
|
||||
re_connect();
|
||||
if(NULL == um_hdbc)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -225,7 +219,7 @@ bool show_group_list(char ** group_list)
|
|||
) t1 ON user_group.id = t1.group_id\
|
||||
ORDER BY\
|
||||
user_group.uuid";
|
||||
char * glist = select_datebase_by_number(USER_ACCOUNT_DATABASE_ID, getglist_hdbc, USER_GROUP_TABLE, select_sql, 1, 0, &num, 0);
|
||||
char * glist = select_datebase_by_number(USER_MANAGER_DBID, um_hdbc, USER_GROUP_TABLE, select_sql, 1, 0, &num, 0);
|
||||
|
||||
if (0 == num || NULL == glist) //查询结果为空
|
||||
{
|
||||
|
@ -317,7 +311,7 @@ unsigned short get_groupid_by_uuid(int uugid, void * hdbc)
|
|||
}
|
||||
|
||||
char *select_sql = "SELECT id FROM user_group WHERE uuid = ?";
|
||||
gid = select_datebase_by_number(USER_GROUP_DATABASE_ID, hdbc, USER_GROUP_TABLE, select_sql, 1, 0, &num, 1,
|
||||
gid = select_datebase_by_number(USER_MANAGER_DBID, hdbc, USER_GROUP_TABLE, select_sql, 1, 0, &num, 1,
|
||||
DB_DATA_INT_TYPE, sizeof(uugid), uugid);
|
||||
|
||||
if(0 == num)
|
||||
|
@ -334,8 +328,7 @@ unsigned short get_groupid_by_uuid(int uugid, void * hdbc)
|
|||
bool get_group_uuid_by_name(char* gname, unsigned short * group_uuid)
|
||||
{
|
||||
char *gid = NULL;
|
||||
void * ghdbc;
|
||||
int num, discon;
|
||||
int num;
|
||||
unsigned short uuid_temp = INVALID_INDEX;
|
||||
|
||||
if (NULL == gname || NULL == group_uuid)
|
||||
|
@ -343,19 +336,17 @@ bool get_group_uuid_by_name(char* gname, unsigned short * group_uuid)
|
|||
return false;
|
||||
}
|
||||
|
||||
ghdbc = connect_database(USER_GROUP_DATABASE_ID);
|
||||
if (NULL == ghdbc)
|
||||
//ghdbc = connect_database(USER_GROUP_DATABASE_ID);
|
||||
re_connect();
|
||||
if (NULL == um_hdbc)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/* 连接数据库,根据用户名查询user表中的uuid */
|
||||
char* select_sql = "SELECT uuid FROM user_group WHERE gname = ?";
|
||||
gid = select_datebase_by_number(USER_GROUP_DATABASE_ID, ghdbc, USER_GROUP_TABLE, select_sql, 1, 0, &num, 1,
|
||||
gid = select_datebase_by_number(USER_MANAGER_DBID, um_hdbc, USER_GROUP_TABLE, select_sql, 1, 0, &num, 1,
|
||||
DB_DATA_STRING_TYPE, strlen(gname)+1, gname);
|
||||
/* 删除数据连接 */
|
||||
discon = disconnect_database(USER_GROUP_DATABASE_ID, ghdbc); //discon记录日志
|
||||
|
||||
if(0 == num || NULL == gid)
|
||||
{
|
||||
*group_uuid = INVALID_INDEX;
|
||||
|
@ -388,7 +379,7 @@ unsigned short get_groupid_by_name(char* gname, void* hdbc)
|
|||
|
||||
/* 数据库查询,根据用户组名查询user_grooup表中的id */
|
||||
char *select_sql = "SELECT id FROM user_group WHERE gname = ?";
|
||||
gid = select_datebase_by_number(USER_GROUP_DATABASE_ID, hdbc, USER_GROUP_TABLE, select_sql, 1, 0, &num, 1,
|
||||
gid = select_datebase_by_number(USER_MANAGER_DBID, hdbc, USER_GROUP_TABLE, select_sql, 1, 0, &num, 1,
|
||||
DB_DATA_STRING_TYPE, strlen(gname)+1, gname);
|
||||
|
||||
if(0 == num)
|
||||
|
@ -431,7 +422,6 @@ void offline_force_by_groupid(char *groupid)
|
|||
/*删除元素*/
|
||||
unsigned short del_group_by_name(GROUP_DEL* gname)
|
||||
{
|
||||
void * delgroup_hdbc;
|
||||
unsigned short GID_temp = 0;
|
||||
if (NULL == gname)
|
||||
{
|
||||
|
@ -439,8 +429,8 @@ unsigned short del_group_by_name(GROUP_DEL* gname)
|
|||
}
|
||||
|
||||
/* 连接数据库 */
|
||||
delgroup_hdbc = connect_database(12);
|
||||
if(NULL == delgroup_hdbc)
|
||||
re_connect();
|
||||
if(NULL == um_hdbc)
|
||||
{
|
||||
/* 记录日志 */
|
||||
return DELGROUP_FAIL_DATABASE;
|
||||
|
@ -455,7 +445,7 @@ unsigned short del_group_by_name(GROUP_DEL* gname)
|
|||
{
|
||||
return DELGROUP_FAIL_NOTEXIST;
|
||||
}
|
||||
GID_temp = get_groupid_by_name(gname->id_name.gname, delgroup_hdbc);
|
||||
GID_temp = get_groupid_by_name(gname->id_name.gname, um_hdbc);
|
||||
if (INVALID_INDEX == GID_temp)
|
||||
{
|
||||
return DELGROUP_FAIL_NOTEXIST;
|
||||
|
@ -490,15 +480,55 @@ unsigned short del_group_by_name(GROUP_DEL* gname)
|
|||
|
||||
/* 连接数据库,根据用户组ID删除 用户表 中对应数据*/
|
||||
char* deluser_sql = "DELETE FROM user WHERE group_id = ?";
|
||||
int ret_del = update_database(USER_GROUP_DATABASE_ID, delgroup_hdbc, DB_OP_DEL, USER_TABLE, deluser_sql, 1,
|
||||
int ret_del = update_database(USER_MANAGER_DBID, um_hdbc, DB_OP_DEL, USER_TABLE, deluser_sql, 1,
|
||||
DB_DATA_INT_TYPE, sizeof(GID_temp), GID_temp);
|
||||
/* 连接数据库,根据用户组ID删除 用户组表 中对应数据*/
|
||||
char *delgroup_sql = "DELETE FROM user_group WHERE id = ? ";
|
||||
ret_del = update_database(USER_GROUP_DATABASE_ID, delgroup_hdbc, DB_OP_DEL, USER_GROUP_TABLE, delgroup_sql, 1,
|
||||
ret_del = update_database(USER_MANAGER_DBID, um_hdbc, DB_OP_DEL, USER_GROUP_TABLE, delgroup_sql, 1,
|
||||
DB_DATA_INT_TYPE, sizeof(GID_temp), GID_temp);
|
||||
/* 删除结果记录日志 */
|
||||
int ret_release = disconnect_database(USER_GROUP_DATABASE_ID, delgroup_hdbc);
|
||||
/* 数据库连接释放结果记录日志 */
|
||||
|
||||
return DELGROUP_SUCCESS;
|
||||
}
|
||||
|
||||
/*数据库重连*/
|
||||
void re_connect()
|
||||
{
|
||||
if(NULL == um_hdbc)
|
||||
{
|
||||
um_hdbc = connect_database(USER_MANAGER_DBID);
|
||||
}
|
||||
}
|
||||
|
||||
/* 查询 user_group 内存恢复 */
|
||||
void um_getgroup_db(char ** group_db)
|
||||
{
|
||||
int num = 0;
|
||||
int size = 0;
|
||||
|
||||
re_connect();
|
||||
if(NULL == um_hdbc)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
char * select_sql = "SELECT user_group.id ID, user_group.gname, user_group.gdescription FROM `user_group`";
|
||||
char * ret_group = select_datebase_by_number(USER_MANAGER_DBID, um_hdbc, USER_GROUP_TABLE, select_sql, 1, 0, &num, 0);
|
||||
|
||||
if(0 == num || NULL == ret_group)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
size = strlen(ret_group)+1;
|
||||
char * point = (char*)malloc(size);
|
||||
if(NULL == point)
|
||||
{
|
||||
return;
|
||||
}
|
||||
memset(point, 0, size);
|
||||
memcpy(point, ret_group, size);
|
||||
*group_db = point; //在函数外面释放
|
||||
|
||||
return;
|
||||
}
|
|
@ -27,7 +27,7 @@ VPATH = ../user/user_manager/ ../../Platform/user/configm/config-server/user_man
|
|||
|
||||
# set the source file, don't used .o because of ...
|
||||
|
||||
COMMON_SRCS = usermanager-test/test_usermanager.c user_account_config.c user_group_config.c usermanager-server/array_index.c usermanager-server/user_group.c \
|
||||
COMMON_SRCS = usermanager-test/test_usermanager.c user_recover_config.c user_account_config.c user_group_config.c usermanager-server/array_index.c usermanager-server/user_group.c \
|
||||
usermanager-server/user_mod.c usermanager-server/user.c
|
||||
|
||||
# MRS Board Source Files
|
||||
|
|
|
@ -10,12 +10,13 @@
|
|||
#include "user.h"
|
||||
#include "user_account_config.h"
|
||||
#include "user_group_config.h"
|
||||
#include "user_recover_config.h"
|
||||
#include "user_auth.h"
|
||||
#include "database.h"
|
||||
#include "redisMq.h"
|
||||
|
||||
extern USERGROUP g_group_table[GROUP_INDEX_MAX];
|
||||
extern USERACCOUNT g_user_table[USER_INDEX_MAX];
|
||||
extern USERGROUP g_group_table[];
|
||||
extern USERACCOUNT g_user_table[];
|
||||
|
||||
// int main1(void)
|
||||
// {
|
||||
|
@ -123,8 +124,18 @@ extern USERACCOUNT g_user_table[USER_INDEX_MAX];
|
|||
// }
|
||||
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char * testrec;
|
||||
int testnum;
|
||||
userecover_config_get_all(CONFIG_FROM_RECOVER1,testrec, &testnum);
|
||||
|
||||
printf("hello. \n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int main1(void)
|
||||
{
|
||||
char * testin; //input
|
||||
char testout[2000]; //output
|
||||
|
|
|
@ -23,11 +23,20 @@ typedef enum { WEBM_HANDLE_INVALID_INDEX = -1,
|
|||
WEBM_HANDLE_LOGIN,
|
||||
WEBM_HANDLE_HOMEPAGE,
|
||||
|
||||
/* 以下是页面取数展示的case,后续提升性能可能通过数据库查询,所以先放到一起 */
|
||||
/* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҳ<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>չʾ<EFBFBD><EFBFBD>case<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܿ<EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷŵ<EFBFBD>һ<EFBFBD><EFBFBD> */
|
||||
WEBM_HANDLE_CONFIG_LIST_GROUP,
|
||||
|
||||
/* 以下是配置操作相关的case */
|
||||
/* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ò<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD>case */
|
||||
WEBM_HANDLE_CONFIG_ADD_GROUP,
|
||||
WEBM_HANDLE_CONFIG_UUID_GROUP,
|
||||
WEBM_HANDLE_CONFIG_MOD_GROUP,
|
||||
|
||||
WEBM_HANDLE_CONFIG_ADD_USER,
|
||||
WEBM_HANDLE_CONFIG_MODWEB_USER,
|
||||
WEBM_HANDLE_CONFIG_MODGROUP_USER,
|
||||
WEBM_HANDLE_CONFIG_LIST_USER,
|
||||
WEBM_HANDLE_CONFIG_UUID_USER,
|
||||
WEBM_HANDLE_CONFIG_DETAIL_USER,
|
||||
WEBM_HANDLE_CONFIG_IPV4,
|
||||
WEBM_HANDLE_MAX
|
||||
} webm_handle_index;
|
||||
|
@ -84,8 +93,8 @@ extern int webm_config_send_proc(server *srv, uint32_t config_type, uint64 confg
|
|||
\
|
||||
{\
|
||||
WEBM_HANDLE_CONFIG_LIST_GROUP, \
|
||||
"/FSG-CF/um-group-showlist", \
|
||||
4, \
|
||||
"/FSG-GF/um-group-showlist", \
|
||||
CM_CONFIG_GET, \
|
||||
USER_MANAGER_CONFIG_GROUP, \
|
||||
webm_config_send_proc \
|
||||
},\
|
||||
|
@ -98,6 +107,62 @@ extern int webm_config_send_proc(server *srv, uint32_t config_type, uint64 confg
|
|||
webm_config_send_proc \
|
||||
},\
|
||||
\
|
||||
{\
|
||||
WEBM_HANDLE_CONFIG_UUID_GROUP, \
|
||||
"/FSG-GF/um-group-getgid", \
|
||||
CM_CONFIG_GET, \
|
||||
USER_MANAGER_CONFIG_GROUP, \
|
||||
webm_config_send_proc \
|
||||
},\
|
||||
{\
|
||||
WEBM_HANDLE_CONFIG_MOD_GROUP, \
|
||||
"/FSG-CF/um-group-mod", \
|
||||
CM_CONFIG_SET, \
|
||||
USER_MANAGER_CONFIG_GROUP, \
|
||||
webm_config_send_proc \
|
||||
},\
|
||||
{\
|
||||
WEBM_HANDLE_CONFIG_ADD_USER, \
|
||||
"/FSG-CF/um-user-add", \
|
||||
CM_CONFIG_SET, \
|
||||
USER_MANAGER_CONFIG_USER, \
|
||||
webm_config_send_proc \
|
||||
},\
|
||||
{\
|
||||
WEBM_HANDLE_CONFIG_MODWEB_USER, \
|
||||
"/FSG-CF/um-user-mod", \
|
||||
CM_CONFIG_SET, \
|
||||
USER_MANAGER_CONFIG_USER, \
|
||||
webm_config_send_proc \
|
||||
},\
|
||||
{\
|
||||
WEBM_HANDLE_CONFIG_MODGROUP_USER, \
|
||||
"/FSG-CF/um-user-movegroup", \
|
||||
CM_CONFIG_SET, \
|
||||
USER_MANAGER_CONFIG_USER, \
|
||||
webm_config_send_proc \
|
||||
},\
|
||||
{\
|
||||
WEBM_HANDLE_CONFIG_LIST_USER, \
|
||||
"/FSG-GF/um-user-showlist", \
|
||||
CM_CONFIG_GET, \
|
||||
USER_MANAGER_CONFIG_USER, \
|
||||
webm_config_send_proc \
|
||||
},\
|
||||
{\
|
||||
WEBM_HANDLE_CONFIG_UUID_USER, \
|
||||
"/FSG-GF/um-user-getgid", \
|
||||
CM_CONFIG_GET, \
|
||||
USER_MANAGER_CONFIG_USER, \
|
||||
webm_config_send_proc \
|
||||
},\
|
||||
{\
|
||||
WEBM_HANDLE_CONFIG_DETAIL_USER, \
|
||||
"/FSG-GF/um-user-getuser", \
|
||||
CM_CONFIG_GET, \
|
||||
USER_MANAGER_CONFIG_USER, \
|
||||
webm_config_send_proc \
|
||||
},\
|
||||
{\
|
||||
WEBM_HANDLE_CONFIG_IPV4, \
|
||||
"/ISG-CF/ipv4", \
|
||||
|
@ -194,7 +259,7 @@ int webm_config_send_proc(server *srv, uint32_t config_type, uint64 confg_id, ch
|
|||
mess_str = "";
|
||||
}
|
||||
|
||||
if (NULL == cJSON_AddStringToObject(root,"message","系统错误"))
|
||||
if (NULL == cJSON_AddStringToObject(root,"message","ϵͳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"))
|
||||
{
|
||||
log_error_write(srv, __FILE__, __LINE__, "s", "json fail");
|
||||
goto end;
|
||||
|
@ -284,9 +349,9 @@ int webm_login_proc(server *srv, uint32_t config_type, uint64 confg_id, char *da
|
|||
int ret = 1;
|
||||
mod_webm_plugin_data *p_d = point;
|
||||
|
||||
p_d = p_d;//解决编译告警;
|
||||
confg_id = confg_id;//解决编译告警;
|
||||
config_type = config_type;//解决编译告警;
|
||||
p_d = p_d;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>澯<EFBFBD><EFBFBD>
|
||||
confg_id = confg_id;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>澯<EFBFBD><EFBFBD>
|
||||
config_type = config_type;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>澯<EFBFBD><EFBFBD>
|
||||
|
||||
if (NULL == data_out)
|
||||
{
|
||||
|
@ -347,10 +412,10 @@ int webm_homepage_ifstatus_proc(server *srv, uint32_t config_type, uint64 confg_
|
|||
int ret = 1;
|
||||
mod_webm_plugin_data *p_d = point;
|
||||
|
||||
p_d = p_d;//解决编译告警;
|
||||
confg_id = confg_id;//解决编译告警;
|
||||
data_in = data_in;//解决编译告警;
|
||||
config_type = config_type;//解决编译告警;
|
||||
p_d = p_d;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>澯<EFBFBD><EFBFBD>
|
||||
confg_id = confg_id;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>澯<EFBFBD><EFBFBD>
|
||||
data_in = data_in;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>澯<EFBFBD><EFBFBD>
|
||||
config_type = config_type;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>澯<EFBFBD><EFBFBD>
|
||||
|
||||
if (NULL == data_out)
|
||||
{
|
||||
|
@ -536,8 +601,8 @@ static handler_t mod_webm_uri_handler(server *srv, connection *con, void *p_d)
|
|||
SETDEFAULTS_FUNC(mod_webm_set_defaults)
|
||||
{
|
||||
mod_webm_plugin_data *p = p_d;
|
||||
p = p;//解决编译告警;
|
||||
srv = srv;//解决编译告警;
|
||||
p = p;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>澯<EFBFBD><EFBFBD>
|
||||
srv = srv;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>澯<EFBFBD><EFBFBD>
|
||||
|
||||
return HANDLER_GO_ON;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,275 @@
|
|||
set(CMAKE_LEGACY_CYGWIN_WIN32 0)
|
||||
cmake_minimum_required(VERSION 2.8.5)
|
||||
|
||||
project(cJSON C)
|
||||
|
||||
include(GNUInstallDirs)
|
||||
|
||||
set(PROJECT_VERSION_MAJOR 1)
|
||||
set(PROJECT_VERSION_MINOR 7)
|
||||
set(PROJECT_VERSION_PATCH 12)
|
||||
set(CJSON_VERSION_SO 1)
|
||||
set(CJSON_UTILS_VERSION_SO 1)
|
||||
set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
|
||||
|
||||
if(PLAT_ARM64)
|
||||
# this one is important
|
||||
SET(CMAKE_SYSTEM_NAME Linux)
|
||||
#this one not so much
|
||||
SET(CMAKE_SYSTEM_VERSION 1)
|
||||
|
||||
# specify the cross compiler
|
||||
SET(CMAKE_C_COMPILER aarch64-linux-gnu-gcc)
|
||||
SET(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++)
|
||||
SET(CMAKE_STRIP aarch64-fsl-linux-strip)
|
||||
|
||||
# specify the cross compile and link flags
|
||||
# set(CMAKE_C_FLAGS "--sysroot=$ENV{SDKTARGETSYSROOT}")
|
||||
# set(CMAKE_SHARED_LINKER_FLAGS "--sysroot=$ENV{SDKTARGETSYSROOT}")
|
||||
|
||||
# where is the target environment
|
||||
SET(CMAKE_FIND_ROOT_PATH ${SDKTARGETSYSROOT})
|
||||
|
||||
# search for programs in the build host directories
|
||||
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
# for libraries and headers in the target directories
|
||||
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
endif()
|
||||
|
||||
set(custom_compiler_flags)
|
||||
|
||||
include(CheckCCompilerFlag)
|
||||
option(ENABLE_CUSTOM_COMPILER_FLAGS "Enables custom compiler flags" ON)
|
||||
if (ENABLE_CUSTOM_COMPILER_FLAGS)
|
||||
if (("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang") OR ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU"))
|
||||
list(APPEND custom_compiler_flags
|
||||
-std=c89
|
||||
-pedantic
|
||||
-Wall
|
||||
-Wextra
|
||||
-Werror
|
||||
-Wstrict-prototypes
|
||||
-Wwrite-strings
|
||||
-Wshadow
|
||||
-Winit-self
|
||||
-Wcast-align
|
||||
-Wformat=2
|
||||
-Wmissing-prototypes
|
||||
-Wstrict-overflow=2
|
||||
-Wcast-qual
|
||||
-Wundef
|
||||
-Wswitch-default
|
||||
-Wconversion
|
||||
-Wc++-compat
|
||||
-fstack-protector-strong
|
||||
-Wcomma
|
||||
-Wdouble-promotion
|
||||
-Wparentheses
|
||||
-Wformat-overflow
|
||||
-Wunused-macros
|
||||
-Wmissing-variable-declarations
|
||||
-Wused-but-marked-unused
|
||||
-Wswitch-enum
|
||||
)
|
||||
elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
|
||||
# Disable warning c4001 - nonstandard extension 'single line comment' was used
|
||||
# Define _CRT_SECURE_NO_WARNINGS to disable deprecation warnings for "insecure" C library functions
|
||||
list(APPEND custom_compiler_flags
|
||||
/GS
|
||||
/Za
|
||||
/sdl
|
||||
/W4
|
||||
/wd4001
|
||||
/D_CRT_SECURE_NO_WARNINGS
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
option(ENABLE_SANITIZERS "Enables AddressSanitizer and UndefinedBehaviorSanitizer." OFF)
|
||||
if (ENABLE_SANITIZERS)
|
||||
list(APPEND custom_compiler_flags
|
||||
-fno-omit-frame-pointer
|
||||
-fsanitize=address
|
||||
-fsanitize=undefined
|
||||
-fsanitize=float-divide-by-zero
|
||||
-fsanitize=float-cast-overflow
|
||||
-fsanitize-address-use-after-scope
|
||||
-fsanitize=integer
|
||||
-01
|
||||
-fno-sanitize-recover
|
||||
)
|
||||
endif()
|
||||
|
||||
option(ENABLE_SAFE_STACK "Enables the SafeStack instrumentation pass by the Code Pointer Integrity Project" OFF)
|
||||
if (ENABLE_SAFE_STACK)
|
||||
if (ENABLE_SANITIZERS)
|
||||
message(FATAL_ERROR "ENABLE_SAFE_STACK cannot be used in combination with ENABLE_SANITIZERS")
|
||||
endif()
|
||||
list(APPEND custom_compiler_flags
|
||||
-fsanitize=safe-stack
|
||||
)
|
||||
endif()
|
||||
|
||||
option(ENABLE_PUBLIC_SYMBOLS "Export library symbols." On)
|
||||
if (ENABLE_PUBLIC_SYMBOLS)
|
||||
list(APPEND custom_compiler_flags -fvisibility=hidden)
|
||||
add_definitions(-DCJSON_EXPORT_SYMBOLS -DCJSON_API_VISIBILITY)
|
||||
endif()
|
||||
option(ENABLE_HIDDEN_SYMBOLS "Hide library symbols." Off)
|
||||
if (ENABLE_HIDDEN_SYMBOLS)
|
||||
add_definitions(-DCJSON_HIDE_SYMBOLS -UCJSON_API_VISIBILITY)
|
||||
endif()
|
||||
|
||||
# apply custom compiler flags
|
||||
foreach(compiler_flag ${custom_compiler_flags})
|
||||
#remove problematic characters
|
||||
string(REGEX REPLACE "[^a-zA-Z0-9]" "" current_variable ${compiler_flag})
|
||||
|
||||
CHECK_C_COMPILER_FLAG(${compiler_flag} "FLAG_SUPPORTED_${current_variable}")
|
||||
if (FLAG_SUPPORTED_${current_variable})
|
||||
list(APPEND supported_compiler_flags)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${compiler_flag}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${supported_compiler_flags}")
|
||||
|
||||
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
|
||||
option(ENABLE_TARGET_EXPORT "Enable exporting of CMake targets. Disable when it causes problems!" ON)
|
||||
|
||||
#cJSON
|
||||
set(CJSON_LIB cjson)
|
||||
|
||||
file(GLOB HEADERS cJSON.h)
|
||||
set(SOURCES cJSON.c)
|
||||
|
||||
option(BUILD_SHARED_AND_STATIC_LIBS "Build both shared and static libraries" Off)
|
||||
option(CJSON_OVERRIDE_BUILD_SHARED_LIBS "Override BUILD_SHARED_LIBS with CJSON_BUILD_SHARED_LIBS" OFF)
|
||||
option(CJSON_BUILD_SHARED_LIBS "Overrides BUILD_SHARED_LIBS if CJSON_OVERRIDE_BUILD_SHARED_LIBS is enabled" ON)
|
||||
|
||||
if ((CJSON_OVERRIDE_BUILD_SHARED_LIBS AND CJSON_BUILD_SHARED_LIBS) OR ((NOT CJSON_OVERRIDE_BUILD_SHARED_LIBS) AND BUILD_SHARED_LIBS))
|
||||
set(CJSON_LIBRARY_TYPE SHARED)
|
||||
else()
|
||||
set(CJSON_LIBRARY_TYPE STATIC)
|
||||
endif()
|
||||
|
||||
|
||||
if (NOT BUILD_SHARED_AND_STATIC_LIBS)
|
||||
add_library("${CJSON_LIB}" "${CJSON_LIBRARY_TYPE}" "${HEADERS}" "${SOURCES}")
|
||||
else()
|
||||
# See https://cmake.org/Wiki/CMake_FAQ#How_do_I_make_my_shared_and_static_libraries_have_the_same_root_name.2C_but_different_suffixes.3F
|
||||
add_library("${CJSON_LIB}" SHARED "${HEADERS}" "${SOURCES}")
|
||||
add_library("${CJSON_LIB}-static" STATIC "${HEADERS}" "${SOURCES}")
|
||||
set_target_properties("${CJSON_LIB}-static" PROPERTIES OUTPUT_NAME "${CJSON_LIB}")
|
||||
set_target_properties("${CJSON_LIB}-static" PROPERTIES PREFIX "lib")
|
||||
endif()
|
||||
if (NOT WIN32)
|
||||
target_link_libraries("${CJSON_LIB}" m)
|
||||
endif()
|
||||
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/library_config/libcjson.pc.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/libcjson.pc" @ONLY)
|
||||
|
||||
install(FILES cJSON.h DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}/cjson")
|
||||
install (FILES "${CMAKE_CURRENT_BINARY_DIR}/libcjson.pc" DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/pkgconfig")
|
||||
install(TARGETS "${CJSON_LIB}" DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}" EXPORT "${CJSON_LIB}")
|
||||
if (BUILD_SHARED_AND_STATIC_LIBS)
|
||||
install(TARGETS "${CJSON_LIB}-static" DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}")
|
||||
endif()
|
||||
if(ENABLE_TARGET_EXPORT)
|
||||
# export library information for CMake projects
|
||||
install(EXPORT "${CJSON_LIB}" DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/cmake/cJSON")
|
||||
endif()
|
||||
|
||||
set_target_properties("${CJSON_LIB}"
|
||||
PROPERTIES
|
||||
SOVERSION "${CJSON_VERSION_SO}"
|
||||
VERSION "${PROJECT_VERSION}")
|
||||
|
||||
#cJSON_Utils
|
||||
option(ENABLE_CJSON_UTILS "Enable building the cJSON_Utils library." OFF)
|
||||
if(ENABLE_CJSON_UTILS)
|
||||
set(CJSON_UTILS_LIB cjson_utils)
|
||||
|
||||
file(GLOB HEADERS_UTILS cJSON_Utils.h)
|
||||
set(SOURCES_UTILS cJSON_Utils.c)
|
||||
|
||||
if (NOT BUILD_SHARED_AND_STATIC_LIBS)
|
||||
add_library("${CJSON_UTILS_LIB}" "${CJSON_LIBRARY_TYPE}" "${HEADERS_UTILS}" "${SOURCES_UTILS}")
|
||||
target_link_libraries("${CJSON_UTILS_LIB}" "${CJSON_LIB}")
|
||||
else()
|
||||
add_library("${CJSON_UTILS_LIB}" SHARED "${HEADERS_UTILS}" "${SOURCES_UTILS}")
|
||||
target_link_libraries("${CJSON_UTILS_LIB}" "${CJSON_LIB}")
|
||||
add_library("${CJSON_UTILS_LIB}-static" STATIC "${HEADERS_UTILS}" "${SOURCES_UTILS}")
|
||||
target_link_libraries("${CJSON_UTILS_LIB}-static" "${CJSON_LIB}-static")
|
||||
set_target_properties("${CJSON_UTILS_LIB}-static" PROPERTIES OUTPUT_NAME "${CJSON_UTILS_LIB}")
|
||||
set_target_properties("${CJSON_UTILS_LIB}-static" PROPERTIES PREFIX "lib")
|
||||
endif()
|
||||
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/library_config/libcjson_utils.pc.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/libcjson_utils.pc" @ONLY)
|
||||
|
||||
install(TARGETS "${CJSON_UTILS_LIB}" DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}" EXPORT "${CJSON_UTILS_LIB}")
|
||||
if (BUILD_SHARED_AND_STATIC_LIBS)
|
||||
install(TARGETS "${CJSON_UTILS_LIB}-static" DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}")
|
||||
endif()
|
||||
install(FILES cJSON_Utils.h DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}/cjson")
|
||||
install (FILES "${CMAKE_CURRENT_BINARY_DIR}/libcjson_utils.pc" DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/pkgconfig")
|
||||
if(ENABLE_TARGET_EXPORT)
|
||||
# export library information for CMake projects
|
||||
install(EXPORT "${CJSON_UTILS_LIB}" DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/cmake/cJSON")
|
||||
endif()
|
||||
|
||||
set_target_properties("${CJSON_UTILS_LIB}"
|
||||
PROPERTIES
|
||||
SOVERSION "${CJSON_UTILS_VERSION_SO}"
|
||||
VERSION "${PROJECT_VERSION}")
|
||||
endif()
|
||||
|
||||
# create the other package config files
|
||||
configure_file(
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/library_config/cJSONConfig.cmake.in"
|
||||
${PROJECT_BINARY_DIR}/cJSONConfig.cmake @ONLY)
|
||||
configure_file(
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/library_config/cJSONConfigVersion.cmake.in"
|
||||
${PROJECT_BINARY_DIR}/cJSONConfigVersion.cmake @ONLY)
|
||||
|
||||
# Install package config files
|
||||
install(FILES ${PROJECT_BINARY_DIR}/cJSONConfig.cmake
|
||||
${PROJECT_BINARY_DIR}/cJSONConfigVersion.cmake
|
||||
DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/cmake/cJSON")
|
||||
|
||||
option(ENABLE_CJSON_TEST "Enable building cJSON test" ON)
|
||||
if(ENABLE_CJSON_TEST)
|
||||
enable_testing()
|
||||
|
||||
set(TEST_CJSON cJSON_test)
|
||||
add_executable("${TEST_CJSON}" test.c)
|
||||
target_link_libraries("${TEST_CJSON}" "${CJSON_LIB}")
|
||||
|
||||
add_test(NAME ${TEST_CJSON} COMMAND "${CMAKE_CURRENT_BINARY_DIR}/${TEST_CJSON}")
|
||||
|
||||
# Disable -fsanitize=float-divide-by-zero for cJSON_test
|
||||
if (FLAG_SUPPORTED_fsanitizefloatdividebyzero)
|
||||
if ("${CMAKE_VERSION}" VERSION_LESS "2.8.12")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-sanitize=float-divide-by-zero")
|
||||
else()
|
||||
target_compile_options(${TEST_CJSON} PRIVATE "-fno-sanitize=float-divide-by-zero")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#"check" target that automatically builds everything and runs the tests
|
||||
add_custom_target(check
|
||||
COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure
|
||||
DEPENDS ${TEST_CJSON})
|
||||
endif()
|
||||
|
||||
# Enable the use of locales
|
||||
option(ENABLE_LOCALES "Enable the use of locales" ON)
|
||||
if(ENABLE_LOCALES)
|
||||
add_definitions(-DENABLE_LOCALES)
|
||||
endif()
|
||||
|
||||
add_subdirectory(tests)
|
||||
add_subdirectory(fuzzing)
|
Loading…
Reference in New Issue