MOD aaa-12 配置管理模块增加模块初始化钩子
SOL 配置管理模块增加模块初始化钩子 修改人:zhangliang 检视人:zhangliang
This commit is contained in:
parent
0c75e14a95
commit
ee27856922
|
@ -72,10 +72,22 @@ extern "C" {
|
|||
#define s2j_struct_get_basic_element(to_struct, from_json, type, element) \
|
||||
S2J_STRUCT_GET_BASIC_ELEMENT(to_struct, from_json, type, element)
|
||||
|
||||
#define s2j_struct_get_string_element(to_struct, from_json, type, element, n) \
|
||||
S2J_STRUCT_GET_STRING_ELEMENT_N(to_struct, from_json, type, element, n)
|
||||
|
||||
/* Get array type element for structure object */
|
||||
#define s2j_struct_get_array_element(to_struct, from_json, type, element) \
|
||||
S2J_STRUCT_GET_ARRAY_ELEMENT(to_struct, from_json, type, element)
|
||||
|
||||
/* Get array type element for structure object */
|
||||
#define s2j_struct_get_array_element_n(to_struct, from_json, type, element, NUM) \
|
||||
S2J_STRUCT_GET_ARRAY_ELEMENT_N(to_struct, from_json, type, element)
|
||||
|
||||
/* Get array type element for structure object */
|
||||
#define s2j_struct_get_array_string_n(to_struct, from_json, type, element, NUM, BUFFLEN) \
|
||||
S2J_STRUCT_GET_STR_ARRAY_ELEMENT_N(to_struct, from_json, type, element, NUM, BUFFLEN)
|
||||
|
||||
|
||||
/* Get child structure type element for structure object */
|
||||
#define s2j_struct_get_struct_element(child_struct, to_struct, child_json, from_json, type, element) \
|
||||
S2J_STRUCT_GET_STRUCT_ELEMENT(child_struct, to_struct, child_json, from_json, type, element)
|
||||
|
|
|
@ -52,8 +52,9 @@ typedef struct {
|
|||
|
||||
#define S2J_STRUCT_GET_STRING_ELEMENT_N(to_struct, from_json, _element, n) \
|
||||
json_temp = cJSON_GetObjectItem(from_json, #_element); \
|
||||
if (json_temp && json_temp->valuestring && n > 1)\
|
||||
strncpy((to_struct)->_element, json_temp->valuestring, n-1);
|
||||
if (json_temp && json_temp->valuestring && n > 1){\
|
||||
strncpy((to_struct)->_element, json_temp->valuestring, n - 1);\
|
||||
to_struct->_element[n - 1] = '\0';}
|
||||
|
||||
#define S2J_STRUCT_GET_double_ELEMENT(to_struct, from_json, _element) \
|
||||
json_temp = cJSON_GetObjectItem(from_json, #_element); \
|
||||
|
@ -65,6 +66,9 @@ typedef struct {
|
|||
#define S2J_STRUCT_ARRAY_GET_string_ELEMENT(to_struct, from_json, _element, index) \
|
||||
strcpy((to_struct)->_element[index], from_json->valuestring);
|
||||
|
||||
#define S2J_STRUCT_ARRAY_GET_string_ELEMENT_n(to_struct, from_json, _element, index, maxlen) \
|
||||
strncpy((to_struct)->_element + maxlen * index, from_json->valuestring, maxlen - 1);
|
||||
|
||||
#define S2J_STRUCT_ARRAY_GET_double_ELEMENT(to_struct, from_json, _element, index) \
|
||||
(to_struct)->_element[index] = from_json->valuedouble;
|
||||
|
||||
|
@ -145,6 +149,38 @@ typedef struct {
|
|||
} \
|
||||
}
|
||||
|
||||
#define S2J_STRUCT_GET_ARRAY_ELEMENT_N(to_struct, from_json, type, _element, NUM) \
|
||||
{ \
|
||||
cJSON *array, *array_element; \
|
||||
size_t index = 0, size = 0; \
|
||||
array = cJSON_GetObjectItem(from_json, #_element); \
|
||||
if (array) { \
|
||||
size = cJSON_GetArraySize(array); \
|
||||
while (index < size && index < NUM) { \
|
||||
array_element = cJSON_GetArrayItem(array, index); \
|
||||
if (array_element) S2J_STRUCT_ARRAY_GET_ELEMENT(to_struct, array_element, type, _element, index++); \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
#define S2J_STRUCT_GET_STR_ARRAY_ELEMENT_N(to_struct, from_json, type, _element, NUM, LEN) \
|
||||
{ \
|
||||
cJSON *array, *array_element; \
|
||||
size_t index = 0, size = 0; \
|
||||
array = cJSON_GetObjectItem(from_json, #_element); \
|
||||
if (array) { \
|
||||
size = cJSON_GetArraySize(array); \
|
||||
NUM = size;\
|
||||
(to_struct)->_element = (char *)malloc(size * LEN);\
|
||||
memset((to_struct)->_element, 0, size * LEN);\
|
||||
while (index < size) { \
|
||||
array_element = cJSON_GetArrayItem(array, index); \
|
||||
if (array_element) S2J_STRUCT_ARRAY_GET_string_ELEMENT_n(to_struct, array_element, type, _element, index++, LEN); \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
#define S2J_STRUCT_GET_STRUCT_ELEMENT(child_struct, to_struct, child_json, from_json, type, _element) \
|
||||
type *child_struct = &((to_struct)->_element); \
|
||||
cJSON *child_json = cJSON_GetObjectItem(from_json, #_element);
|
||||
|
|
|
@ -169,7 +169,7 @@ typedef struct _config_init config_init_t;
|
|||
|
||||
/* 配置注册 */
|
||||
struct _config_service {
|
||||
uint32 config_id; /* 配置ID,全局唯一,用于寻找对应的配置业务*/
|
||||
uint64 config_id; /* 配置ID,全局唯一,用于寻找对应的配置业务*/
|
||||
uint config_src; /* 配置源检查,全局唯一,用于寻找对应的配置业务,从低位到高位,第一位表示web,后续配置扩展 */
|
||||
boolean recovery; /* 配置恢复处理函数,如果为FALSE则不进行配置恢复 */
|
||||
boolean multi_inst; /* 是否是多实例 */
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#ifndef PARSEFILE_H_
|
||||
#define PARSEFILE_H_
|
||||
|
||||
#include "rpc_common.h"
|
||||
|
||||
#define IFCONFIG_PATH "/etc/network/interfaces"
|
||||
#define IF_BUFF_LEN 128
|
||||
|
||||
|
|
Loading…
Reference in New Issue