OCT 1. 重新格式化代码
This commit is contained in:
parent
40aace4969
commit
694da892ee
|
@ -59,7 +59,7 @@ BreakConstructorInitializersBeforeComma: false
|
||||||
BreakConstructorInitializers: BeforeColon
|
BreakConstructorInitializers: BeforeColon
|
||||||
BreakAfterJavaFieldAnnotations: false
|
BreakAfterJavaFieldAnnotations: false
|
||||||
BreakStringLiterals: true
|
BreakStringLiterals: true
|
||||||
ColumnLimit: 100
|
ColumnLimit: 120
|
||||||
CommentPragmas: '^ IWYU pragma:'
|
CommentPragmas: '^ IWYU pragma:'
|
||||||
CompactNamespaces: true
|
CompactNamespaces: true
|
||||||
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
||||||
|
|
|
@ -1477,8 +1477,8 @@ static void warnx(const char *fmt, ...) {
|
||||||
*/
|
*/
|
||||||
memset(opterrmsg, 0, sizeof(opterrmsg));
|
memset(opterrmsg, 0, sizeof(opterrmsg));
|
||||||
if (fmt != NULL)
|
if (fmt != NULL)
|
||||||
#if (defined(__STDC_LIB_EXT1__) && defined(__STDC_WANT_LIB_EXT1__)) \
|
#if (defined(__STDC_LIB_EXT1__) && defined(__STDC_WANT_LIB_EXT1__)) || \
|
||||||
|| (defined(__STDC_SECURE_LIB__) && defined(__STDC_WANT_SECURE_LIB__))
|
(defined(__STDC_SECURE_LIB__) && defined(__STDC_WANT_SECURE_LIB__))
|
||||||
_vsnprintf_s(opterrmsg, sizeof(opterrmsg), sizeof(opterrmsg) - 1, fmt, ap);
|
_vsnprintf_s(opterrmsg, sizeof(opterrmsg), sizeof(opterrmsg) - 1, fmt, ap);
|
||||||
#else
|
#else
|
||||||
_vsnprintf(opterrmsg, sizeof(opterrmsg) - 1, fmt, ap);
|
_vsnprintf(opterrmsg, sizeof(opterrmsg) - 1, fmt, ap);
|
||||||
|
@ -1617,9 +1617,8 @@ static int parse_long_options(char *const *nargv,
|
||||||
|
|
||||||
if (match == -1) { /* first partial match */
|
if (match == -1) { /* first partial match */
|
||||||
match = i;
|
match = i;
|
||||||
} else if ((flags & FLAG_LONGONLY) || long_options[i].has_arg != long_options[match].has_arg
|
} else if ((flags & FLAG_LONGONLY) || long_options[i].has_arg != long_options[match].has_arg ||
|
||||||
|| long_options[i].flag != long_options[match].flag
|
long_options[i].flag != long_options[match].flag || long_options[i].val != long_options[match].val) {
|
||||||
|| long_options[i].val != long_options[match].val) {
|
|
||||||
second_partial_match = 1;
|
second_partial_match = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1750,9 +1749,9 @@ static int getopt_internal(int nargc,
|
||||||
* string begins with a '+'.
|
* string begins with a '+'.
|
||||||
*/
|
*/
|
||||||
if (posixly_correct == -1 || optreset) {
|
if (posixly_correct == -1 || optreset) {
|
||||||
#if defined(_WIN32) \
|
#if defined(_WIN32) && \
|
||||||
&& ((defined(__STDC_LIB_EXT1__) && defined(__STDC_WANT_LIB_EXT1__)) \
|
((defined(__STDC_LIB_EXT1__) && defined(__STDC_WANT_LIB_EXT1__)) || \
|
||||||
|| (defined(__STDC_SECURE_LIB__) && defined(__STDC_WANT_SECURE_LIB__)))
|
(defined(__STDC_SECURE_LIB__) && defined(__STDC_WANT_SECURE_LIB__)))
|
||||||
size_t requiredSize;
|
size_t requiredSize;
|
||||||
getenv_s(&requiredSize, NULL, 0, "POSIXLY_CORRECT");
|
getenv_s(&requiredSize, NULL, 0, "POSIXLY_CORRECT");
|
||||||
posixly_correct = requiredSize != 0;
|
posixly_correct = requiredSize != 0;
|
||||||
|
@ -1880,8 +1879,8 @@ start:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((optchar = (int)*place++) == (int)':' || (optchar == (int)'-' && *place != '\0')
|
if ((optchar = (int)*place++) == (int)':' || (optchar == (int)'-' && *place != '\0') ||
|
||||||
|| (oli = strchr(options, optchar)) == NULL) {
|
(oli = strchr(options, optchar)) == NULL) {
|
||||||
/*
|
/*
|
||||||
* If the user specified "-" and '-' isn't listed in
|
* If the user specified "-" and '-' isn't listed in
|
||||||
* options, return -1 (non-option) as per POSIX.
|
* options, return -1 (non-option) as per POSIX.
|
||||||
|
@ -2765,8 +2764,8 @@ struct arg_dbl *arg_dbln(const char *shortopts,
|
||||||
maxcount = (maxcount < mincount) ? mincount : maxcount;
|
maxcount = (maxcount < mincount) ? mincount : maxcount;
|
||||||
|
|
||||||
nbytes = sizeof(struct arg_dbl) /* storage for struct arg_dbl */
|
nbytes = sizeof(struct arg_dbl) /* storage for struct arg_dbl */
|
||||||
+ (size_t)(maxcount + 1)
|
+ (size_t)(maxcount + 1) *
|
||||||
* sizeof(double); /* storage for dval[maxcount] array plus one extra for padding to memory boundary */
|
sizeof(double); /* storage for dval[maxcount] array plus one extra for padding to memory boundary */
|
||||||
|
|
||||||
result = (struct arg_dbl *)xmalloc(nbytes);
|
result = (struct arg_dbl *)xmalloc(nbytes);
|
||||||
|
|
||||||
|
@ -4343,8 +4342,8 @@ static int trex_element(TRex *exp) {
|
||||||
ret = nnode;
|
ret = nnode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((*exp->_p != TREX_SYMBOL_BRANCH) && (*exp->_p != ')') && (*exp->_p != TREX_SYMBOL_GREEDY_ZERO_OR_MORE)
|
if ((*exp->_p != TREX_SYMBOL_BRANCH) && (*exp->_p != ')') && (*exp->_p != TREX_SYMBOL_GREEDY_ZERO_OR_MORE) &&
|
||||||
&& (*exp->_p != TREX_SYMBOL_GREEDY_ONE_OR_MORE) && (*exp->_p != '\0')) {
|
(*exp->_p != TREX_SYMBOL_GREEDY_ONE_OR_MORE) && (*exp->_p != '\0')) {
|
||||||
int nnode = trex_element(exp);
|
int nnode = trex_element(exp);
|
||||||
exp->_nodes[ret].next = nnode;
|
exp->_nodes[ret].next = nnode;
|
||||||
}
|
}
|
||||||
|
@ -4477,8 +4476,8 @@ static const TRexChar *trex_matchnode(TRex *exp, TRexNode *node, const TRexChar
|
||||||
if (greedystop) {
|
if (greedystop) {
|
||||||
/* checks that 0 matches satisfy the expression(if so skips) */
|
/* checks that 0 matches satisfy the expression(if so skips) */
|
||||||
/* if not would always stop(for instance if is a '?') */
|
/* if not would always stop(for instance if is a '?') */
|
||||||
if (greedystop->type != OP_GREEDY
|
if (greedystop->type != OP_GREEDY ||
|
||||||
|| (greedystop->type == OP_GREEDY && ((greedystop->right >> 16) & 0x0000FFFF) != 0)) {
|
(greedystop->type == OP_GREEDY && ((greedystop->right >> 16) & 0x0000FFFF) != 0)) {
|
||||||
TRexNode *gnext = NULL;
|
TRexNode *gnext = NULL;
|
||||||
if (greedystop->next != -1) {
|
if (greedystop->next != -1) {
|
||||||
gnext = &exp->_nodes[greedystop->next];
|
gnext = &exp->_nodes[greedystop->next];
|
||||||
|
@ -4567,9 +4566,9 @@ static const TRexChar *trex_matchnode(TRex *exp, TRexNode *node, const TRexChar
|
||||||
return cur;
|
return cur;
|
||||||
}
|
}
|
||||||
case OP_WB:
|
case OP_WB:
|
||||||
if ((str == exp->_bol && !isspace((int)(*str))) || (str == exp->_eol && !isspace((int)(*(str - 1))))
|
if ((str == exp->_bol && !isspace((int)(*str))) || (str == exp->_eol && !isspace((int)(*(str - 1)))) ||
|
||||||
|| (!isspace((int)(*str)) && isspace((int)(*(str + 1))))
|
(!isspace((int)(*str)) && isspace((int)(*(str + 1)))) ||
|
||||||
|| (isspace((int)(*str)) && !isspace((int)(*(str + 1))))) {
|
(isspace((int)(*str)) && !isspace((int)(*(str + 1))))) {
|
||||||
return (node->left == 'b') ? str : NULL;
|
return (node->left == 'b') ? str : NULL;
|
||||||
}
|
}
|
||||||
return (node->left == 'b') ? NULL : str;
|
return (node->left == 'b') ? NULL : str;
|
||||||
|
@ -4956,8 +4955,8 @@ void arg_set_module_name(const char *name) {
|
||||||
s_module_name = (char *)xmalloc(slen + 1);
|
s_module_name = (char *)xmalloc(slen + 1);
|
||||||
memset(s_module_name, 0, slen + 1);
|
memset(s_module_name, 0, slen + 1);
|
||||||
|
|
||||||
#if (defined(__STDC_LIB_EXT1__) && defined(__STDC_WANT_LIB_EXT1__)) \
|
#if (defined(__STDC_LIB_EXT1__) && defined(__STDC_WANT_LIB_EXT1__)) || \
|
||||||
|| (defined(__STDC_SECURE_LIB__) && defined(__STDC_WANT_SECURE_LIB__))
|
(defined(__STDC_SECURE_LIB__) && defined(__STDC_WANT_SECURE_LIB__))
|
||||||
strncpy_s(s_module_name, slen + 1, name, slen);
|
strncpy_s(s_module_name, slen + 1, name, slen);
|
||||||
#else
|
#else
|
||||||
memcpy(s_module_name, name, slen);
|
memcpy(s_module_name, name, slen);
|
||||||
|
@ -4977,8 +4976,8 @@ void arg_set_module_version(int major, int minor, int patch, const char *tag) {
|
||||||
s_mod_ver_tag = (char *)xmalloc(slen_tag + 1);
|
s_mod_ver_tag = (char *)xmalloc(slen_tag + 1);
|
||||||
memset(s_mod_ver_tag, 0, slen_tag + 1);
|
memset(s_mod_ver_tag, 0, slen_tag + 1);
|
||||||
|
|
||||||
#if (defined(__STDC_LIB_EXT1__) && defined(__STDC_WANT_LIB_EXT1__)) \
|
#if (defined(__STDC_LIB_EXT1__) && defined(__STDC_WANT_LIB_EXT1__)) || \
|
||||||
|| (defined(__STDC_SECURE_LIB__) && defined(__STDC_WANT_SECURE_LIB__))
|
(defined(__STDC_SECURE_LIB__) && defined(__STDC_WANT_SECURE_LIB__))
|
||||||
strncpy_s(s_mod_ver_tag, slen_tag + 1, tag, slen_tag);
|
strncpy_s(s_mod_ver_tag, slen_tag + 1, tag, slen_tag);
|
||||||
#else
|
#else
|
||||||
memcpy(s_mod_ver_tag, tag, slen_tag);
|
memcpy(s_mod_ver_tag, tag, slen_tag);
|
||||||
|
@ -4995,8 +4994,8 @@ void arg_set_module_version(int major, int minor, int patch, const char *tag) {
|
||||||
s_mod_ver = (char *)xmalloc(slen_ds + 1);
|
s_mod_ver = (char *)xmalloc(slen_ds + 1);
|
||||||
memset(s_mod_ver, 0, slen_ds + 1);
|
memset(s_mod_ver, 0, slen_ds + 1);
|
||||||
|
|
||||||
#if (defined(__STDC_LIB_EXT1__) && defined(__STDC_WANT_LIB_EXT1__)) \
|
#if (defined(__STDC_LIB_EXT1__) && defined(__STDC_WANT_LIB_EXT1__)) || \
|
||||||
|| (defined(__STDC_SECURE_LIB__) && defined(__STDC_WANT_SECURE_LIB__))
|
(defined(__STDC_SECURE_LIB__) && defined(__STDC_WANT_SECURE_LIB__))
|
||||||
strncpy_s(s_mod_ver, slen_ds + 1, arg_dstr_cstr(ds), slen_ds);
|
strncpy_s(s_mod_ver, slen_ds + 1, arg_dstr_cstr(ds), slen_ds);
|
||||||
#else
|
#else
|
||||||
memcpy(s_mod_ver, arg_dstr_cstr(ds), slen_ds);
|
memcpy(s_mod_ver, arg_dstr_cstr(ds), slen_ds);
|
||||||
|
@ -5051,8 +5050,8 @@ void arg_cmd_register(const char *name, arg_cmdfn *proc, const char *description
|
||||||
cmd_info = (arg_cmd_info_t *)xmalloc(sizeof(arg_cmd_info_t));
|
cmd_info = (arg_cmd_info_t *)xmalloc(sizeof(arg_cmd_info_t));
|
||||||
memset(cmd_info, 0, sizeof(arg_cmd_info_t));
|
memset(cmd_info, 0, sizeof(arg_cmd_info_t));
|
||||||
|
|
||||||
#if (defined(__STDC_LIB_EXT1__) && defined(__STDC_WANT_LIB_EXT1__)) \
|
#if (defined(__STDC_LIB_EXT1__) && defined(__STDC_WANT_LIB_EXT1__)) || \
|
||||||
|| (defined(__STDC_SECURE_LIB__) && defined(__STDC_WANT_SECURE_LIB__))
|
(defined(__STDC_SECURE_LIB__) && defined(__STDC_WANT_SECURE_LIB__))
|
||||||
strncpy_s(cmd_info->name, ARG_CMD_NAME_LEN, name, strlen(name));
|
strncpy_s(cmd_info->name, ARG_CMD_NAME_LEN, name, strlen(name));
|
||||||
strncpy_s(cmd_info->description, ARG_CMD_DESCRIPTION_LEN, description, strlen(description));
|
strncpy_s(cmd_info->description, ARG_CMD_DESCRIPTION_LEN, description, strlen(description));
|
||||||
#else
|
#else
|
||||||
|
@ -5066,8 +5065,8 @@ void arg_cmd_register(const char *name, arg_cmdfn *proc, const char *description
|
||||||
k = xmalloc(slen_name + 1);
|
k = xmalloc(slen_name + 1);
|
||||||
memset(k, 0, slen_name + 1);
|
memset(k, 0, slen_name + 1);
|
||||||
|
|
||||||
#if (defined(__STDC_LIB_EXT1__) && defined(__STDC_WANT_LIB_EXT1__)) \
|
#if (defined(__STDC_LIB_EXT1__) && defined(__STDC_WANT_LIB_EXT1__)) || \
|
||||||
|| (defined(__STDC_SECURE_LIB__) && defined(__STDC_WANT_SECURE_LIB__))
|
(defined(__STDC_SECURE_LIB__) && defined(__STDC_WANT_SECURE_LIB__))
|
||||||
strncpy_s((char *)k, slen_name + 1, name, slen_name);
|
strncpy_s((char *)k, slen_name + 1, name, slen_name);
|
||||||
#else
|
#else
|
||||||
memcpy((char *)k, name, slen_name);
|
memcpy((char *)k, name, slen_name);
|
||||||
|
@ -5760,8 +5759,8 @@ static void arg_cat_option(char *dest,
|
||||||
|
|
||||||
/* add comma separated option tag */
|
/* add comma separated option tag */
|
||||||
ncspn = strcspn(longopts, ",");
|
ncspn = strcspn(longopts, ",");
|
||||||
#if (defined(__STDC_LIB_EXT1__) && defined(__STDC_WANT_LIB_EXT1__)) \
|
#if (defined(__STDC_LIB_EXT1__) && defined(__STDC_WANT_LIB_EXT1__)) || \
|
||||||
|| (defined(__STDC_SECURE_LIB__) && defined(__STDC_WANT_SECURE_LIB__))
|
(defined(__STDC_SECURE_LIB__) && defined(__STDC_WANT_SECURE_LIB__))
|
||||||
strncat_s(dest, ndest, longopts, (ncspn < ndest) ? ncspn : ndest);
|
strncat_s(dest, ndest, longopts, (ncspn < ndest) ? ncspn : ndest);
|
||||||
#else
|
#else
|
||||||
strncat(dest, longopts, (ncspn < ndest) ? ncspn : ndest);
|
strncat(dest, longopts, (ncspn < ndest) ? ncspn : ndest);
|
||||||
|
@ -5831,8 +5830,8 @@ static void arg_cat_optionv(char *dest,
|
||||||
|
|
||||||
/* add comma separated option tag */
|
/* add comma separated option tag */
|
||||||
ncspn = strcspn(c, ",");
|
ncspn = strcspn(c, ",");
|
||||||
#if (defined(__STDC_LIB_EXT1__) && defined(__STDC_WANT_LIB_EXT1__)) \
|
#if (defined(__STDC_LIB_EXT1__) && defined(__STDC_WANT_LIB_EXT1__)) || \
|
||||||
|| (defined(__STDC_SECURE_LIB__) && defined(__STDC_WANT_SECURE_LIB__))
|
(defined(__STDC_SECURE_LIB__) && defined(__STDC_WANT_SECURE_LIB__))
|
||||||
strncat_s(dest, ndest, c, (ncspn < ndest) ? ncspn : ndest);
|
strncat_s(dest, ndest, c, (ncspn < ndest) ? ncspn : ndest);
|
||||||
#else
|
#else
|
||||||
strncat(dest, c, (ncspn < ndest) ? ncspn : ndest);
|
strncat(dest, c, (ncspn < ndest) ? ncspn : ndest);
|
||||||
|
@ -5978,8 +5977,12 @@ void arg_print_syntax_ds(arg_dstr_t ds, void **argtable, const char *suffix) {
|
||||||
shortopts = table[tabindex]->shortopts;
|
shortopts = table[tabindex]->shortopts;
|
||||||
longopts = table[tabindex]->longopts;
|
longopts = table[tabindex]->longopts;
|
||||||
datatype = table[tabindex]->datatype;
|
datatype = table[tabindex]->datatype;
|
||||||
arg_cat_option(
|
arg_cat_option(syntax,
|
||||||
syntax, sizeof(syntax) - 1, shortopts, longopts, datatype, table[tabindex]->flag & ARG_HASOPTVALUE);
|
sizeof(syntax) - 1,
|
||||||
|
shortopts,
|
||||||
|
longopts,
|
||||||
|
datatype,
|
||||||
|
table[tabindex]->flag & ARG_HASOPTVALUE);
|
||||||
|
|
||||||
if (strlen(syntax) > 0) {
|
if (strlen(syntax) > 0) {
|
||||||
/* print mandatory instances of this option */
|
/* print mandatory instances of this option */
|
||||||
|
@ -6038,8 +6041,13 @@ void arg_print_syntaxv_ds(arg_dstr_t ds, void **argtable, const char *suffix) {
|
||||||
shortopts = table[tabindex]->shortopts;
|
shortopts = table[tabindex]->shortopts;
|
||||||
longopts = table[tabindex]->longopts;
|
longopts = table[tabindex]->longopts;
|
||||||
datatype = table[tabindex]->datatype;
|
datatype = table[tabindex]->datatype;
|
||||||
arg_cat_optionv(
|
arg_cat_optionv(syntax,
|
||||||
syntax, sizeof(syntax) - 1, shortopts, longopts, datatype, table[tabindex]->flag & ARG_HASOPTVALUE, "|");
|
sizeof(syntax) - 1,
|
||||||
|
shortopts,
|
||||||
|
longopts,
|
||||||
|
datatype,
|
||||||
|
table[tabindex]->flag & ARG_HASOPTVALUE,
|
||||||
|
"|");
|
||||||
|
|
||||||
/* print mandatory options */
|
/* print mandatory options */
|
||||||
for (i = 0; i < table[tabindex]->mincount; i++) {
|
for (i = 0; i < table[tabindex]->mincount; i++) {
|
||||||
|
|
|
@ -343,8 +343,8 @@ static int on_cmd6(void *pTbl[], const char *pName, void *pInfo) {
|
||||||
return ERR_MENU_EXIT;
|
return ERR_MENU_EXIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (symmetric_encrypto(DES3_CBC_PKCS7PADDING, (unsigned char *)pKey, strlen(pKey), &buf, &outSize, pKeygen)
|
if (symmetric_encrypto(DES3_CBC_PKCS7PADDING, (unsigned char *)pKey, strlen(pKey), &buf, &outSize, pKeygen) !=
|
||||||
!= ERR_SUCCESS) {
|
ERR_SUCCESS) {
|
||||||
free((void *)pKeygen);
|
free((void *)pKeygen);
|
||||||
return -ERR_EVP_ENCRYPTION;
|
return -ERR_EVP_ENCRYPTION;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -151,8 +151,8 @@ static const char *load_string_value(const char *pKeyName) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (symmetric_decrypto(AES128_ECB_PKCS7PADDING_SHA1PRNG, pBuf, bufSize, &buf, &outSize, pKey)
|
if (symmetric_decrypto(AES128_ECB_PKCS7PADDING_SHA1PRNG, pBuf, bufSize, &buf, &outSize, pKey) !=
|
||||||
!= ERR_SUCCESS) {
|
ERR_SUCCESS) {
|
||||||
free((void *)pKey);
|
free((void *)pKey);
|
||||||
free(pBuf);
|
free(pBuf);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -230,9 +230,8 @@ static int cmp_dhcp_obj(const void *a, const void *b) {
|
||||||
POBJ_DHCP_RNG pV1 = (POBJ_DHCP_RNG)a;
|
POBJ_DHCP_RNG pV1 = (POBJ_DHCP_RNG)a;
|
||||||
POBJ_DHCP_RNG pV2 = (POBJ_DHCP_RNG)b;
|
POBJ_DHCP_RNG pV2 = (POBJ_DHCP_RNG)b;
|
||||||
|
|
||||||
if (strcmp(pV1->rangAddr, pV2->rangAddr) == 0 && strcmp(pV1->subnet, pV2->subnet) == 0
|
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
|
strcmp(pV1->dnsSvr, pV2->dnsSvr) == 0 && strcmp(pV1->gateway, pV2->gateway) == 0 && pV1->lease == pV2->lease) {
|
||||||
&& pV1->lease == pV2->lease) {
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -512,8 +511,12 @@ const char *config_item_dump_fmt(const char *titleMessage) {
|
||||||
CFG_BOOL_VALUE(pItem) ? "True" : "False");
|
CFG_BOOL_VALUE(pItem) ? "True" : "False");
|
||||||
break;
|
break;
|
||||||
case VAL_INT:
|
case VAL_INT:
|
||||||
s = sdscatprintf(
|
s = sdscatprintf(s,
|
||||||
s, "|%4d | %-25s | %-45s | %-64lld |\n", pItem->cfgId, tmp2, pItem->pcfgKey, CFG_INT_VALUE(pItem));
|
"|%4d | %-25s | %-45s | %-64lld |\n",
|
||||||
|
pItem->cfgId,
|
||||||
|
tmp2,
|
||||||
|
pItem->pcfgKey,
|
||||||
|
CFG_INT_VALUE(pItem));
|
||||||
break;
|
break;
|
||||||
case VAL_FLOAT:
|
case VAL_FLOAT:
|
||||||
s = sdscatprintf(s,
|
s = sdscatprintf(s,
|
||||||
|
|
|
@ -220,14 +220,22 @@ typedef struct {
|
||||||
for (; index_##_element < realsize_##_element && index_##_element < size; index_##_element++) { \
|
for (; index_##_element < realsize_##_element && index_##_element < size; index_##_element++) { \
|
||||||
array_item_##_element = cJSON_GetArrayItem(array_##_element, index_##_element); \
|
array_item_##_element = cJSON_GetArrayItem(array_##_element, index_##_element); \
|
||||||
if (array_item_##_element) { \
|
if (array_item_##_element) { \
|
||||||
S2J_STRUCT_ARRAY_GET_ELEMENT_EX( \
|
S2J_STRUCT_ARRAY_GET_ELEMENT_EX(to_struct, \
|
||||||
to_struct, array_item_##_element, type, _element, index_##_element, _defval); \
|
array_item_##_element, \
|
||||||
|
type, \
|
||||||
|
_element, \
|
||||||
|
index_##_element, \
|
||||||
|
_defval); \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
} else { \
|
} else { \
|
||||||
for (; index_##_element < realsize_##_element && index_##_element < size; index_##_element++) { \
|
for (; index_##_element < realsize_##_element && index_##_element < size; index_##_element++) { \
|
||||||
S2J_STRUCT_ARRAY_GET_ELEMENT_EX( \
|
S2J_STRUCT_ARRAY_GET_ELEMENT_EX(to_struct, \
|
||||||
to_struct, array_##_element, type, _element, index_##_element, _defval); \
|
array_##_element, \
|
||||||
|
type, \
|
||||||
|
_element, \
|
||||||
|
index_##_element, \
|
||||||
|
_defval); \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
} else { \
|
} else { \
|
||||||
|
|
|
@ -221,8 +221,9 @@ typedef struct {
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
if ((a)->i > ((pos) + (len))) { \
|
if ((a)->i > ((pos) + (len))) { \
|
||||||
memmove( \
|
memmove(_utarray_eltptr(a, pos), \
|
||||||
_utarray_eltptr(a, pos), _utarray_eltptr(a, (pos) + (len)), ((a)->i - ((pos) + (len))) * (a)->icd.sz); \
|
_utarray_eltptr(a, (pos) + (len)), \
|
||||||
|
((a)->i - ((pos) + (len))) * (a)->icd.sz); \
|
||||||
} \
|
} \
|
||||||
(a)->i -= (len); \
|
(a)->i -= (len); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
|
@ -226,8 +226,8 @@ typedef unsigned char uint8_t;
|
||||||
(head)->hh.tbl->num_buckets = HASH_INITIAL_NUM_BUCKETS; \
|
(head)->hh.tbl->num_buckets = HASH_INITIAL_NUM_BUCKETS; \
|
||||||
(head)->hh.tbl->log2_num_buckets = HASH_INITIAL_NUM_BUCKETS_LOG2; \
|
(head)->hh.tbl->log2_num_buckets = HASH_INITIAL_NUM_BUCKETS_LOG2; \
|
||||||
(head)->hh.tbl->hho = (char *)(&(head)->hh) - (char *)(head); \
|
(head)->hh.tbl->hho = (char *)(&(head)->hh) - (char *)(head); \
|
||||||
(head)->hh.tbl->buckets = (UT_hash_bucket *)uthash_malloc(HASH_INITIAL_NUM_BUCKETS \
|
(head)->hh.tbl->buckets = (UT_hash_bucket *)uthash_malloc(HASH_INITIAL_NUM_BUCKETS * \
|
||||||
* sizeof(struct UT_hash_bucket)); \
|
sizeof(struct UT_hash_bucket)); \
|
||||||
(head)->hh.tbl->signature = HASH_SIGNATURE; \
|
(head)->hh.tbl->signature = HASH_SIGNATURE; \
|
||||||
if (!(head)->hh.tbl->buckets) { \
|
if (!(head)->hh.tbl->buckets) { \
|
||||||
HASH_RECORD_OOM(oomed); \
|
HASH_RECORD_OOM(oomed); \
|
||||||
|
@ -523,8 +523,10 @@ typedef unsigned char uint8_t;
|
||||||
_prev = NULL; \
|
_prev = NULL; \
|
||||||
while (_thh) { \
|
while (_thh) { \
|
||||||
if (_prev != (char *)(_thh->hh_prev)) { \
|
if (_prev != (char *)(_thh->hh_prev)) { \
|
||||||
HASH_OOPS( \
|
HASH_OOPS("%s: invalid hh_prev %p, actual %p\n", \
|
||||||
"%s: invalid hh_prev %p, actual %p\n", (where), (void *)_thh->hh_prev, (void *)_prev); \
|
(where), \
|
||||||
|
(void *)_thh->hh_prev, \
|
||||||
|
(void *)_prev); \
|
||||||
} \
|
} \
|
||||||
_bkt_count++; \
|
_bkt_count++; \
|
||||||
_prev = (char *)(_thh); \
|
_prev = (char *)(_thh); \
|
||||||
|
@ -663,12 +665,12 @@ typedef unsigned char uint8_t;
|
||||||
_hj_i = _hj_j = 0x9e3779b9u; \
|
_hj_i = _hj_j = 0x9e3779b9u; \
|
||||||
_hj_k = (unsigned)(keylen); \
|
_hj_k = (unsigned)(keylen); \
|
||||||
while (_hj_k >= 12U) { \
|
while (_hj_k >= 12U) { \
|
||||||
_hj_i += (_hj_key[0] + ((unsigned)_hj_key[1] << 8) + ((unsigned)_hj_key[2] << 16) \
|
_hj_i += (_hj_key[0] + ((unsigned)_hj_key[1] << 8) + ((unsigned)_hj_key[2] << 16) + \
|
||||||
+ ((unsigned)_hj_key[3] << 24)); \
|
((unsigned)_hj_key[3] << 24)); \
|
||||||
_hj_j += (_hj_key[4] + ((unsigned)_hj_key[5] << 8) + ((unsigned)_hj_key[6] << 16) \
|
_hj_j += (_hj_key[4] + ((unsigned)_hj_key[5] << 8) + ((unsigned)_hj_key[6] << 16) + \
|
||||||
+ ((unsigned)_hj_key[7] << 24)); \
|
((unsigned)_hj_key[7] << 24)); \
|
||||||
hashv += (_hj_key[8] + ((unsigned)_hj_key[9] << 8) + ((unsigned)_hj_key[10] << 16) \
|
hashv += (_hj_key[8] + ((unsigned)_hj_key[9] << 8) + ((unsigned)_hj_key[10] << 16) + \
|
||||||
+ ((unsigned)_hj_key[11] << 24)); \
|
((unsigned)_hj_key[11] << 24)); \
|
||||||
\
|
\
|
||||||
HASH_JEN_MIX(_hj_i, _hj_j, hashv); \
|
HASH_JEN_MIX(_hj_i, _hj_j, hashv); \
|
||||||
\
|
\
|
||||||
|
@ -706,8 +708,8 @@ typedef unsigned char uint8_t;
|
||||||
|
|
||||||
/* The Paul Hsieh hash function */
|
/* The Paul Hsieh hash function */
|
||||||
#undef get16bits
|
#undef get16bits
|
||||||
#if (defined(__GNUC__) && defined(__i386__)) || defined(__WATCOMC__) || defined(_MSC_VER) || defined(__BORLANDC__) \
|
#if (defined(__GNUC__) && defined(__i386__)) || defined(__WATCOMC__) || defined(_MSC_VER) || defined(__BORLANDC__) || \
|
||||||
|| defined(__TURBOC__)
|
defined(__TURBOC__)
|
||||||
#define get16bits(d) (*((const uint16_t *)(d)))
|
#define get16bits(d) (*((const uint16_t *)(d)))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -795,8 +797,8 @@ typedef unsigned char uint8_t;
|
||||||
_ha_head->hh_head->hh_prev = (addhh); \
|
_ha_head->hh_head->hh_prev = (addhh); \
|
||||||
} \
|
} \
|
||||||
_ha_head->hh_head = (addhh); \
|
_ha_head->hh_head = (addhh); \
|
||||||
if ((_ha_head->count >= ((_ha_head->expand_mult + 1U) * HASH_BKT_CAPACITY_THRESH)) \
|
if ((_ha_head->count >= ((_ha_head->expand_mult + 1U) * HASH_BKT_CAPACITY_THRESH)) && \
|
||||||
&& !(addhh)->tbl->noexpand) { \
|
!(addhh)->tbl->noexpand) { \
|
||||||
HASH_EXPAND_BUCKETS(addhh, (addhh)->tbl, oomed); \
|
HASH_EXPAND_BUCKETS(addhh, (addhh)->tbl, oomed); \
|
||||||
IF_HASH_NONFATAL_OOM(if (oomed) { HASH_DEL_IN_BKT(head, addhh); }) \
|
IF_HASH_NONFATAL_OOM(if (oomed) { HASH_DEL_IN_BKT(head, addhh); }) \
|
||||||
} \
|
} \
|
||||||
|
@ -858,8 +860,8 @@ typedef unsigned char uint8_t;
|
||||||
HASH_RECORD_OOM(oomed); \
|
HASH_RECORD_OOM(oomed); \
|
||||||
} else { \
|
} else { \
|
||||||
uthash_bzero(_he_new_buckets, sizeof(struct UT_hash_bucket) * (tbl)->num_buckets * 2U); \
|
uthash_bzero(_he_new_buckets, sizeof(struct UT_hash_bucket) * (tbl)->num_buckets * 2U); \
|
||||||
(tbl)->ideal_chain_maxlen = ((tbl)->num_items >> ((tbl)->log2_num_buckets + 1U)) \
|
(tbl)->ideal_chain_maxlen = ((tbl)->num_items >> ((tbl)->log2_num_buckets + 1U)) + \
|
||||||
+ ((((tbl)->num_items & (((tbl)->num_buckets * 2U) - 1U)) != 0U) ? 1U : 0U); \
|
((((tbl)->num_items & (((tbl)->num_buckets * 2U) - 1U)) != 0U) ? 1U : 0U); \
|
||||||
(tbl)->nonideal_items = 0; \
|
(tbl)->nonideal_items = 0; \
|
||||||
for (_he_bkt_i = 0; _he_bkt_i < (tbl)->num_buckets; _he_bkt_i++) { \
|
for (_he_bkt_i = 0; _he_bkt_i < (tbl)->num_buckets; _he_bkt_i++) { \
|
||||||
_he_thh = (tbl)->buckets[_he_bkt_i].hh_head; \
|
_he_thh = (tbl)->buckets[_he_bkt_i].hh_head; \
|
||||||
|
@ -938,8 +940,7 @@ typedef unsigned char uint8_t;
|
||||||
} \
|
} \
|
||||||
_hs_psize--; \
|
_hs_psize--; \
|
||||||
} else if ((cmpfcn(DECLTYPE(head)(ELMT_FROM_HH((head)->hh.tbl, _hs_p)), \
|
} else if ((cmpfcn(DECLTYPE(head)(ELMT_FROM_HH((head)->hh.tbl, _hs_p)), \
|
||||||
DECLTYPE(head)(ELMT_FROM_HH((head)->hh.tbl, _hs_q)))) \
|
DECLTYPE(head)(ELMT_FROM_HH((head)->hh.tbl, _hs_q)))) <= 0) { \
|
||||||
<= 0) { \
|
|
||||||
_hs_e = _hs_p; \
|
_hs_e = _hs_p; \
|
||||||
if (_hs_p != NULL) { \
|
if (_hs_p != NULL) { \
|
||||||
_hs_p = ((_hs_p->next != NULL) ? HH_FROM_ELMT((head)->hh.tbl, _hs_p->next) : NULL); \
|
_hs_p = ((_hs_p->next != NULL) ? HH_FROM_ELMT((head)->hh.tbl, _hs_p->next) : NULL); \
|
||||||
|
@ -1045,9 +1046,9 @@ typedef unsigned char uint8_t;
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define HASH_OVERHEAD(hh, head) \
|
#define HASH_OVERHEAD(hh, head) \
|
||||||
(((head) != NULL) ? ((size_t)(((head)->hh.tbl->num_items * sizeof(UT_hash_handle)) \
|
(((head) != NULL) ? ((size_t)(((head)->hh.tbl->num_items * sizeof(UT_hash_handle)) + \
|
||||||
+ ((head)->hh.tbl->num_buckets * sizeof(UT_hash_bucket)) + sizeof(UT_hash_table) \
|
((head)->hh.tbl->num_buckets * sizeof(UT_hash_bucket)) + sizeof(UT_hash_table) + \
|
||||||
+ (HASH_BLOOM_BYTELEN))) \
|
(HASH_BLOOM_BYTELEN))) \
|
||||||
: 0U)
|
: 0U)
|
||||||
|
|
||||||
#ifdef NO_DECLTYPE
|
#ifdef NO_DECLTYPE
|
||||||
|
|
|
@ -107,8 +107,8 @@
|
||||||
#elif defined(__aarch32__)
|
#elif defined(__aarch32__)
|
||||||
#define CPU_TYPE ARM32
|
#define CPU_TYPE ARM32
|
||||||
#define Arch32
|
#define Arch32
|
||||||
#elif defined(__amd64__) || defined(__x86_64__) || defined(__ia64__) || defined(_M_IA64) || defined(_M_AMD64) \
|
#elif defined(__amd64__) || defined(__x86_64__) || defined(__ia64__) || defined(_M_IA64) || defined(_M_AMD64) || \
|
||||||
|| defined(_M_X64)
|
defined(_M_X64)
|
||||||
#define CPU_TYPE x86_64
|
#define CPU_TYPE x86_64
|
||||||
#define Arch64
|
#define Arch64
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -939,7 +939,11 @@ cJSON_ParseWithLengthOpts(const char *value,
|
||||||
const char **return_parse_end,
|
const char **return_parse_end,
|
||||||
cJSON_bool require_null_terminated) {
|
cJSON_bool require_null_terminated) {
|
||||||
parse_buffer buffer = {
|
parse_buffer buffer = {
|
||||||
0, 0, 0, 0, {0, 0, 0}
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
{0, 0, 0}
|
||||||
};
|
};
|
||||||
cJSON *item = NULL;
|
cJSON *item = NULL;
|
||||||
|
|
||||||
|
@ -1084,7 +1088,13 @@ CJSON_PUBLIC(char *) cJSON_PrintUnformatted(const cJSON *item) {
|
||||||
|
|
||||||
CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON_bool fmt) {
|
CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON_bool fmt) {
|
||||||
printbuffer p = {
|
printbuffer p = {
|
||||||
0, 0, 0, 0, 0, 0, {0, 0, 0}
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
{0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (prebuffer < 0) {
|
if (prebuffer < 0) {
|
||||||
|
@ -1112,7 +1122,13 @@ CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON
|
||||||
|
|
||||||
CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buffer, const int length, const cJSON_bool format) {
|
CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buffer, const int length, const cJSON_bool format) {
|
||||||
printbuffer p = {
|
printbuffer p = {
|
||||||
0, 0, 0, 0, 0, 0, {0, 0, 0}
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
{0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
if ((length < 0) || (buffer == NULL)) {
|
if ((length < 0) || (buffer == NULL)) {
|
||||||
|
@ -1160,9 +1176,9 @@ static cJSON_bool parse_value(cJSON *const item, parse_buffer *const input_buffe
|
||||||
return parse_string(item, input_buffer);
|
return parse_string(item, input_buffer);
|
||||||
}
|
}
|
||||||
/* number */
|
/* number */
|
||||||
if (can_access_at_index(input_buffer, 0)
|
if (can_access_at_index(input_buffer, 0) &&
|
||||||
&& ((buffer_at_offset(input_buffer)[0] == '-')
|
((buffer_at_offset(input_buffer)[0] == '-') ||
|
||||||
|| ((buffer_at_offset(input_buffer)[0] >= '0') && (buffer_at_offset(input_buffer)[0] <= '9')))) {
|
((buffer_at_offset(input_buffer)[0] >= '0') && (buffer_at_offset(input_buffer)[0] <= '9')))) {
|
||||||
return parse_number(item, input_buffer);
|
return parse_number(item, input_buffer);
|
||||||
}
|
}
|
||||||
/* array */
|
/* array */
|
||||||
|
@ -1626,15 +1642,14 @@ static cJSON *get_object_item(const cJSON *const object, const char *const name,
|
||||||
|
|
||||||
current_element = object->child;
|
current_element = object->child;
|
||||||
if (case_sensitive) {
|
if (case_sensitive) {
|
||||||
while ((current_element != NULL) && (current_element->string != NULL)
|
while ((current_element != NULL) && (current_element->string != NULL) &&
|
||||||
&& (strcmp(name, current_element->string) != 0)) {
|
(strcmp(name, current_element->string) != 0)) {
|
||||||
current_element = current_element->next;
|
current_element = current_element->next;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
while (
|
while ((current_element != NULL) &&
|
||||||
(current_element != NULL)
|
(case_insensitive_strcmp((const unsigned char *)name,
|
||||||
&& (case_insensitive_strcmp((const unsigned char *)name, (const unsigned char *)(current_element->string))
|
(const unsigned char *)(current_element->string)) != 0)) {
|
||||||
!= 0)) {
|
|
||||||
current_element = current_element->next;
|
current_element = current_element->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -389,8 +389,8 @@ void sdsIncrLen(sds s, int incr) {
|
||||||
}
|
}
|
||||||
case SDS_TYPE_32: {
|
case SDS_TYPE_32: {
|
||||||
SDS_HDR_VAR(32, s);
|
SDS_HDR_VAR(32, s);
|
||||||
assert((incr >= 0 && sh->alloc - sh->len >= (unsigned int)incr)
|
assert((incr >= 0 && sh->alloc - sh->len >= (unsigned int)incr) ||
|
||||||
|| (incr < 0 && sh->len >= (unsigned int)(-incr)));
|
(incr < 0 && sh->len >= (unsigned int)(-incr)));
|
||||||
len = (sh->len += incr);
|
len = (sh->len += incr);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1331,12 +1331,11 @@ int sdsTest(void) {
|
||||||
x = sdsnew("--");
|
x = sdsnew("--");
|
||||||
x = sdscatfmt(x, "Hello %s World %I,%I--", "Hi!", LLONG_MIN, LLONG_MAX);
|
x = sdscatfmt(x, "Hello %s World %I,%I--", "Hi!", LLONG_MIN, LLONG_MAX);
|
||||||
test_cond("sdscatfmt() seems working in the base case",
|
test_cond("sdscatfmt() seems working in the base case",
|
||||||
sdslen(x) == 60
|
sdslen(x) == 60 &&
|
||||||
&& memcmp(x,
|
memcmp(x,
|
||||||
"--Hello Hi! World -9223372036854775808,"
|
"--Hello Hi! World -9223372036854775808,"
|
||||||
"9223372036854775807--",
|
"9223372036854775807--",
|
||||||
60)
|
60) == 0) printf("[%s]\n", x);
|
||||||
== 0) printf("[%s]\n", x);
|
|
||||||
|
|
||||||
sdsfree(x);
|
sdsfree(x);
|
||||||
x = sdsnew("--");
|
x = sdsnew("--");
|
||||||
|
@ -1444,8 +1443,7 @@ int sdsTest(void) {
|
||||||
memcmp("0ABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGH"
|
memcmp("0ABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGH"
|
||||||
"IJABCDEFGHIJ",
|
"IJABCDEFGHIJ",
|
||||||
x,
|
x,
|
||||||
101)
|
101) == 0);
|
||||||
== 0);
|
|
||||||
test_cond("sdsMakeRoomFor() final length", sdslen(x) == 101);
|
test_cond("sdsMakeRoomFor() final length", sdslen(x) == 101);
|
||||||
|
|
||||||
sdsfree(x);
|
sdsfree(x);
|
||||||
|
|
|
@ -307,7 +307,8 @@ p_throw_error(const zvect_retval error_code, const char *error_message) {
|
||||||
break;
|
break;
|
||||||
case ZVERR_VECTDATASIZE:
|
case ZVERR_VECTDATASIZE:
|
||||||
message = (char *)safe_strncpy(
|
message = (char *)safe_strncpy(
|
||||||
"This operation requires two (or more vectors) with the same data size.\n\0", msg_len);
|
"This operation requires two (or more vectors) with the same data size.\n\0",
|
||||||
|
msg_len);
|
||||||
break;
|
break;
|
||||||
case ZVERR_VECTEMPTY:
|
case ZVERR_VECTEMPTY:
|
||||||
message = (char *)safe_strncpy("Vector is empty.\n\0", msg_len);
|
message = (char *)safe_strncpy("Vector is empty.\n\0", msg_len);
|
||||||
|
@ -351,8 +352,8 @@ static inline
|
||||||
// Using improved memcpy (where improved means for
|
// Using improved memcpy (where improved means for
|
||||||
// embedded systems only!):
|
// embedded systems only!):
|
||||||
if (size > 0) {
|
if (size > 0) {
|
||||||
if (((uintptr_t)dst % sizeof(ADDR_TYPE1) == 0) && ((uintptr_t)src % sizeof(ADDR_TYPE1) == 0)
|
if (((uintptr_t)dst % sizeof(ADDR_TYPE1) == 0) && ((uintptr_t)src % sizeof(ADDR_TYPE1) == 0) &&
|
||||||
&& (size % sizeof(ADDR_TYPE1) == 0)) {
|
(size % sizeof(ADDR_TYPE1) == 0)) {
|
||||||
ADDR_TYPE1 *pExDst = (ADDR_TYPE1 *)dst;
|
ADDR_TYPE1 *pExDst = (ADDR_TYPE1 *)dst;
|
||||||
ADDR_TYPE1 const *pExSrc = (ADDR_TYPE1 const *)src;
|
ADDR_TYPE1 const *pExSrc = (ADDR_TYPE1 const *)src;
|
||||||
size_t end = size / sizeof(ADDR_TYPE1);
|
size_t end = size / sizeof(ADDR_TYPE1);
|
||||||
|
@ -2887,8 +2888,9 @@ void vect_insert(vector const v1, vector const v2, const zvect_index s2, const z
|
||||||
const void *rptr = NULL;
|
const void *rptr = NULL;
|
||||||
|
|
||||||
// Reserve appropriate space in the destination vector
|
// Reserve appropriate space in the destination vector
|
||||||
rptr = p_vect_memmove(
|
rptr = p_vect_memmove(v1->data + (v1->begin + s1 + ee2),
|
||||||
v1->data + (v1->begin + s1 + ee2), v1->data + (v1->begin + s1), sizeof(void *) * (p_vect_size(v1) - s1));
|
v1->data + (v1->begin + s1),
|
||||||
|
sizeof(void *) * (p_vect_size(v1) - s1));
|
||||||
|
|
||||||
if (rptr == NULL) {
|
if (rptr == NULL) {
|
||||||
rval = ZVERR_VECTCORRUPTED;
|
rval = ZVERR_VECTCORRUPTED;
|
||||||
|
@ -3016,11 +3018,13 @@ static inline zvect_retval p_vect_move(vector const v1, vector v2, const zvect_i
|
||||||
// Move v2 (from s2) in v1 at the end of v1:
|
// Move v2 (from s2) in v1 at the end of v1:
|
||||||
const void *rptr = NULL;
|
const void *rptr = NULL;
|
||||||
if (v1 != v2) {
|
if (v1 != v2) {
|
||||||
rptr = p_vect_memcpy(
|
rptr = p_vect_memcpy(v1->data + (v1->begin + p_vect_size(v1)),
|
||||||
v1->data + (v1->begin + p_vect_size(v1)), v2->data + (v2->begin + s2), sizeof(void *) * ee2);
|
v2->data + (v2->begin + s2),
|
||||||
|
sizeof(void *) * ee2);
|
||||||
} else {
|
} else {
|
||||||
rptr = p_vect_memmove(
|
rptr = p_vect_memmove(v1->data + (v1->begin + p_vect_size(v1)),
|
||||||
v1->data + (v1->begin + p_vect_size(v1)), v2->data + (v2->begin + s2), sizeof(void *) * ee2);
|
v2->data + (v2->begin + s2),
|
||||||
|
sizeof(void *) * ee2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rptr == NULL) {
|
if (rptr == NULL) {
|
||||||
|
|
|
@ -229,8 +229,10 @@ static void checkMultiInfo(void) {
|
||||||
pReq->errCode = 0;
|
pReq->errCode = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uv_fs_fdatasync(
|
uv_fs_fdatasync(get_task_manager(),
|
||||||
get_task_manager(), &pReq->uvFsDataSync, (uv_file)pReq->uvFsOpen.result, uvFsDataSyncCb);
|
&pReq->uvFsDataSync,
|
||||||
|
(uv_file)pReq->uvFsOpen.result,
|
||||||
|
uvFsDataSyncCb);
|
||||||
} else if (pReq->type == INET_HTTP_WEBSERVICE_POST) {
|
} else if (pReq->type == INET_HTTP_WEBSERVICE_POST) {
|
||||||
if (pMsg->data.result != CURLE_OK) {
|
if (pMsg->data.result != CURLE_OK) {
|
||||||
if (pReq->onRspCb && pReq->isCancel == FALSE) {
|
if (pReq->onRspCb && pReq->isCancel == FALSE) {
|
||||||
|
@ -400,8 +402,13 @@ static size_t writeDataCb(void *pData, size_t size, size_t nmemb, void *pParams)
|
||||||
|
|
||||||
pReq->uvFsBuf = uv_buf_init(pData, iMemSize);
|
pReq->uvFsBuf = uv_buf_init(pData, iMemSize);
|
||||||
|
|
||||||
wr = uv_fs_write(
|
wr = uv_fs_write(get_task_manager(),
|
||||||
get_task_manager(), &pReq->uvFsWrite, (uv_file)pReq->uvFsOpen.result, &pReq->uvFsBuf, 1, -1, NULL);
|
&pReq->uvFsWrite,
|
||||||
|
(uv_file)pReq->uvFsOpen.result,
|
||||||
|
&pReq->uvFsBuf,
|
||||||
|
1,
|
||||||
|
-1,
|
||||||
|
NULL);
|
||||||
|
|
||||||
if (wr > 0) {
|
if (wr > 0) {
|
||||||
pReq->dlSize += wr;
|
pReq->dlSize += wr;
|
||||||
|
@ -433,8 +440,10 @@ static int progressCb(void *pData, double total, double now, double UNUSED(ulTot
|
||||||
|
|
||||||
if (pParams->onPrgCb) {
|
if (pParams->onPrgCb) {
|
||||||
if (pParams->type == INET_HTTP_DOWNLOAD_FILE) {
|
if (pParams->type == INET_HTTP_DOWNLOAD_FILE) {
|
||||||
pParams->onPrgCb(
|
pParams->onPrgCb(pParams->pReqUrl,
|
||||||
pParams->pReqUrl, pParams->pTaskUuid, (unsigned char)(now * 100.0 / total), pParams->pData);
|
pParams->pTaskUuid,
|
||||||
|
(unsigned char)(now * 100.0 / total),
|
||||||
|
pParams->pData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -608,8 +617,12 @@ const char *inet_download_file_async(const char *pURL,
|
||||||
|
|
||||||
dzlog_debug("[%s]: File %s used temp path %s\n", pParams->pTaskUuid, pParams->sPath, pParams->sDlPath);
|
dzlog_debug("[%s]: File %s used temp path %s\n", pParams->pTaskUuid, pParams->sPath, pParams->sDlPath);
|
||||||
|
|
||||||
uv_fs_open(
|
uv_fs_open(get_task_manager(),
|
||||||
get_task_manager(), &pParams->uvFsOpen, pParams->sDlPath, O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR, NULL);
|
&pParams->uvFsOpen,
|
||||||
|
pParams->sDlPath,
|
||||||
|
O_RDWR | O_CREAT | O_TRUNC,
|
||||||
|
S_IRUSR | S_IWUSR,
|
||||||
|
NULL);
|
||||||
|
|
||||||
curl_easy_setopt(pCurl, CURLOPT_WRITEFUNCTION, writeDataCb);
|
curl_easy_setopt(pCurl, CURLOPT_WRITEFUNCTION, writeDataCb);
|
||||||
curl_easy_setopt(pCurl, CURLOPT_WRITEDATA, pParams);
|
curl_easy_setopt(pCurl, CURLOPT_WRITEDATA, pParams);
|
||||||
|
|
|
@ -87,15 +87,10 @@ const char *proto_decode_context(const char *pString, unsigned int *pVer, unsign
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pBase64 = (unsigned char *)base64_decode(pMsgCtx->valuestring,
|
pBase64 = (unsigned char *)base64_decode(pMsgCtx->valuestring, (unsigned int *)&outSize);
|
||||||
(unsigned int *)&outSize);
|
|
||||||
|
|
||||||
if (symmetric_decrypto(cryptoType,
|
if (symmetric_decrypto(cryptoType, pBase64, outSize, (unsigned char **)(&pMsgContent), &decodeSize, pKey) !=
|
||||||
pBase64,
|
ERR_SUCCESS) {
|
||||||
outSize,
|
|
||||||
(unsigned char **)(&pMsgContent),
|
|
||||||
&decodeSize,
|
|
||||||
pKey) != ERR_SUCCESS) {
|
|
||||||
free((void *)pBase64);
|
free((void *)pBase64);
|
||||||
if (pMsgContent) {
|
if (pMsgContent) {
|
||||||
free(pMsgContent);
|
free(pMsgContent);
|
||||||
|
@ -166,9 +161,7 @@ const char *proto_create_new(cJSON *pMsgCtx, int httpCode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pKey == NULL || strlen(pKey) == 0) {
|
if (pKey == NULL || strlen(pKey) == 0) {
|
||||||
dzlog_error(
|
dzlog_error("Cryptography key empty of algorithm %d, Used default algorithm BASE64\n", cryptoType);
|
||||||
"Cryptography key empty of algorithm %d, Used default algorithm BASE64\n",
|
|
||||||
cryptoType);
|
|
||||||
base64 = base64_encode((unsigned char *)pStrMsg, strlen(pStrMsg));
|
base64 = base64_encode((unsigned char *)pStrMsg, strlen(pStrMsg));
|
||||||
pro.cryptoType = CRYPTO_BASE64;
|
pro.cryptoType = CRYPTO_BASE64;
|
||||||
} else {
|
} else {
|
||||||
|
@ -176,16 +169,10 @@ const char *proto_create_new(cJSON *pMsgCtx, int httpCode) {
|
||||||
unsigned char *buf;
|
unsigned char *buf;
|
||||||
int outSize = 0;
|
int outSize = 0;
|
||||||
|
|
||||||
ret = symmetric_encrypto(cryptoType,
|
ret = symmetric_encrypto(cryptoType, (unsigned char *)pStrMsg, strlen(pStrMsg), &buf, &outSize, pKey);
|
||||||
(unsigned char *)pStrMsg,
|
|
||||||
strlen(pStrMsg),
|
|
||||||
&buf,
|
|
||||||
&outSize,
|
|
||||||
pKey);
|
|
||||||
|
|
||||||
if (ret != ERR_SUCCESS) {
|
if (ret != ERR_SUCCESS) {
|
||||||
dzlog_error("Unsupported protocol crypto : %d, Used default algorithm BASE64\n",
|
dzlog_error("Unsupported protocol crypto : %d, Used default algorithm BASE64\n", cryptoType);
|
||||||
cryptoType);
|
|
||||||
base64 = base64_encode((unsigned char *)pStrMsg, strlen(pStrMsg));
|
base64 = base64_encode((unsigned char *)pStrMsg, strlen(pStrMsg));
|
||||||
pro.cryptoType = CRYPTO_BASE64;
|
pro.cryptoType = CRYPTO_BASE64;
|
||||||
} else {
|
} else {
|
||||||
|
@ -198,9 +185,7 @@ const char *proto_create_new(cJSON *pMsgCtx, int httpCode) {
|
||||||
cJSON_free(pro.msgContend);
|
cJSON_free(pro.msgContend);
|
||||||
} break;
|
} break;
|
||||||
default:
|
default:
|
||||||
dzlog_error(
|
dzlog_error("Unsupported protocol crypto algorithms: %d, Used default algorithm BASE64\n", pro.cryptoType);
|
||||||
"Unsupported protocol crypto algorithms: %d, Used default algorithm BASE64\n",
|
|
||||||
pro.cryptoType);
|
|
||||||
cJSON_free(pro.msgContend);
|
cJSON_free(pro.msgContend);
|
||||||
cJSON_Delete(pRoot);
|
cJSON_Delete(pRoot);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Reference in New Issue