OCT 1. 更新代码格式
This commit is contained in:
parent
2c149cdb91
commit
f82cb95c05
|
@ -28,6 +28,7 @@ typedef struct {
|
|||
#define CFG_BOOL_VALUE(p) (p->value.longValue == FALSE ? FALSE : TRUE)
|
||||
#define CFG_FLOAT_VALUE(p) (p->value.floatValue)
|
||||
#define CFG_STRING_VALUE(p) (p->value.strValue)
|
||||
#define ENC_HEAD ("AES@")
|
||||
|
||||
typedef union {
|
||||
long long longValue;
|
||||
|
@ -57,6 +58,7 @@ PCONFIG_ITEM g_pConfigItem = NULL;
|
|||
#define DEF_CFG_ITEM(id, key, type, defVal, desc) \
|
||||
{ .cfgId = (id), .cfgPath = (key), .valType = (type), .defValue = (defVal), .readme = (desc), .pStrId = (#id) }
|
||||
|
||||
// clang-format off
|
||||
static CFG_ITEM g_cfgItem[] = {
|
||||
DEF_CFG_ITEM(CFG_DIRECTORY, "system.config_file_path", VAL_STR, ".", "Configuration files location path"),
|
||||
DEF_CFG_ITEM(CFG_CURL_CA_PATH, "system.ssl_ca_file_path", VAL_STR, "~/.ssh/ca.crt", "Libcurl access HTTPS CA File"),
|
||||
|
@ -124,8 +126,7 @@ static int cfg_is_upgrade(PCONFIG_ITEM pItem) {
|
|||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#define ENC_HEAD ("AES@")
|
||||
// clang-format on
|
||||
|
||||
static const char *load_string_value(const char *pKeyName) {
|
||||
const char *pCfgVal;
|
||||
|
@ -148,7 +149,8 @@ static const char *load_string_value(const char *pKeyName) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (symmetric_decrypto(AES128_ECB_PKCS7PADDING_SHA1PRNG, pBuf, bufSize, &buf, &outSize, pKey) != ERR_SUCCESS) {
|
||||
if (symmetric_decrypto(AES128_ECB_PKCS7PADDING_SHA1PRNG, pBuf, bufSize, &buf, &outSize, pKey)
|
||||
!= ERR_SUCCESS) {
|
||||
free((void *)pKey);
|
||||
free(pBuf);
|
||||
return NULL;
|
||||
|
@ -226,8 +228,9 @@ static int cmp_dhcp_obj(const void *a, const void *b) {
|
|||
POBJ_DHCP_RNG pV1 = (POBJ_DHCP_RNG)a;
|
||||
POBJ_DHCP_RNG pV2 = (POBJ_DHCP_RNG)b;
|
||||
|
||||
if (strcmp(pV1->rangAddr, pV2->rangAddr) == 0 && strcmp(pV1->subnet, pV2->subnet) == 0 && strcmp(pV1->dnsSvr, pV2->dnsSvr) == 0
|
||||
&& strcmp(pV1->gateway, pV2->gateway) == 0 && pV1->lease == pV2->lease) {
|
||||
if (strcmp(pV1->rangAddr, pV2->rangAddr) == 0 && strcmp(pV1->subnet, pV2->subnet) == 0
|
||||
&& strcmp(pV1->dnsSvr, pV2->dnsSvr) == 0 && strcmp(pV1->gateway, pV2->gateway) == 0
|
||||
&& pV1->lease == pV2->lease) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -324,8 +327,12 @@ static int setConfigItemValue(PCONFIG_ITEM pItem, const char *pValue) {
|
|||
return ERR_SUCCESS;
|
||||
}
|
||||
|
||||
static int add_new_cfg_item(CONFIG_ITEM_ID id, const char *pKey, CONFIG_VALUE_TYPE valType, const char *pDefVal, const char *pStrId,
|
||||
const char *pDesc) {
|
||||
static int add_new_cfg_item(CONFIG_ITEM_ID id,
|
||||
const char *pKey,
|
||||
CONFIG_VALUE_TYPE valType,
|
||||
const char *pDefVal,
|
||||
const char *pStrId,
|
||||
const char *pDesc) {
|
||||
PCONFIG_ITEM pItem;
|
||||
int ret;
|
||||
|
||||
|
@ -379,7 +386,10 @@ static void refreshCfgFileCb() {
|
|||
int cfgUpgrade = FALSE;
|
||||
|
||||
if (!config_read_file(&g_cfgContent, g_cfgFilePath)) {
|
||||
dzlog_error("%s:%d - %s\n", config_error_file(&g_cfgContent), config_error_line(&g_cfgContent), config_error_text(&g_cfgContent));
|
||||
dzlog_error("%s:%d - %s\n",
|
||||
config_error_file(&g_cfgContent),
|
||||
config_error_line(&g_cfgContent),
|
||||
config_error_text(&g_cfgContent));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -492,14 +502,24 @@ const char *config_item_dump_fmt(const char *titleMessage) {
|
|||
sprintf(tmp2, "%s%s", cfg_is_upgrade(pItem) ? "*" : " ", pItem->pStrId);
|
||||
switch (pItem->valType) {
|
||||
case VAL_BOOL:
|
||||
s = sdscatprintf(
|
||||
s, "|%4d | %-25s | %-45s | %-64s |\n", pItem->cfgId, tmp2, pItem->pcfgKey, CFG_BOOL_VALUE(pItem) ? "True" : "False");
|
||||
s = sdscatprintf(s,
|
||||
"|%4d | %-25s | %-45s | %-64s |\n",
|
||||
pItem->cfgId,
|
||||
tmp2,
|
||||
pItem->pcfgKey,
|
||||
CFG_BOOL_VALUE(pItem) ? "True" : "False");
|
||||
break;
|
||||
case VAL_INT:
|
||||
s = sdscatprintf(s, "|%4d | %-25s | %-45s | %-64lld |\n", pItem->cfgId, tmp2, pItem->pcfgKey, CFG_INT_VALUE(pItem));
|
||||
s = sdscatprintf(
|
||||
s, "|%4d | %-25s | %-45s | %-64lld |\n", pItem->cfgId, tmp2, pItem->pcfgKey, CFG_INT_VALUE(pItem));
|
||||
break;
|
||||
case VAL_FLOAT:
|
||||
s = sdscatprintf(s, "|%4d | %-25s | %-45s | %-64Lf |\n", pItem->cfgId, tmp2, pItem->pcfgKey, CFG_FLOAT_VALUE(pItem));
|
||||
s = sdscatprintf(s,
|
||||
"|%4d | %-25s | %-45s | %-64Lf |\n",
|
||||
pItem->cfgId,
|
||||
tmp2,
|
||||
pItem->pcfgKey,
|
||||
CFG_FLOAT_VALUE(pItem));
|
||||
break;
|
||||
case VAL_STR:
|
||||
tmp = sdsempty();
|
||||
|
|
Loading…
Reference in New Issue