OCT 1. 更新格式化代码
This commit is contained in:
parent
f82cb95c05
commit
abd393322d
|
@ -2,6 +2,7 @@
|
|||
Language: Cpp
|
||||
AccessModifierOffset: -4
|
||||
InsertBraces: true
|
||||
AlignArrayOfStructures: Left
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveMacros: Consecutive
|
||||
AlignConsecutiveAssignments: Consecutive
|
||||
|
@ -26,8 +27,9 @@ AlwaysBreakBeforeMultilineStrings: true
|
|||
AlwaysBreakTemplateDeclarations: MultiLine
|
||||
AttributeMacros:
|
||||
- __capability
|
||||
- __unused
|
||||
BinPackArguments: false
|
||||
BinPackParameters: true
|
||||
BinPackParameters: false
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: false
|
||||
AfterClass: false
|
||||
|
@ -57,7 +59,7 @@ BreakConstructorInitializersBeforeComma: false
|
|||
BreakConstructorInitializers: BeforeColon
|
||||
BreakAfterJavaFieldAnnotations: false
|
||||
BreakStringLiterals: true
|
||||
ColumnLimit: 140
|
||||
ColumnLimit: 120
|
||||
CommentPragmas: '^ IWYU pragma:'
|
||||
CompactNamespaces: true
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
||||
|
@ -174,7 +176,7 @@ SpaceAroundPointerQualifiers: Default
|
|||
SpaceBeforeRangeBasedForLoopColon: true
|
||||
SpaceInEmptyBlock: false
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 0
|
||||
SpacesBeforeTrailingComments: 4
|
||||
SpacesInAngles: false
|
||||
SpacesInConditionalStatement: false
|
||||
SpacesInContainerLiterals: false
|
||||
|
@ -199,3 +201,6 @@ WhitespaceSensitiveMacros:
|
|||
- BOOST_PP_STRINGIZE
|
||||
- NS_SWIFT_NAME
|
||||
- CF_SWIFT_NAME
|
||||
TypenameMacros:
|
||||
- CONFIG_ITEM
|
||||
- PCONFIG_ITEM
|
||||
|
|
|
@ -47,7 +47,7 @@ IF (USED_SQLITE)
|
|||
-DSQLITE_HAVE_ZLIB=1 -DSQLITE_TEMP_STORE=2")
|
||||
ENDIF ()
|
||||
|
||||
ADD_DEFINITIONS(-DBUILD_VERSION="${GIT_VERSION}" ${COMMON_DEFINE})
|
||||
ADD_DEFINITIONS(-DBUILD_VERSION= "${GIT_VERSION}" ${COMMON_DEFINE})
|
||||
|
||||
LINK_LIBRARIES(${COMMON_LIBS})
|
||||
ADD_LIBRARY(${LIB_PROJECT_TARGET} ${C_SRC} ${C_HEADS})
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -188,50 +188,110 @@ ARG_EXTERN struct arg_rem *arg_rem(const char *datatype, const char *glossary);
|
|||
|
||||
ARG_EXTERN struct arg_lit *arg_lit0(const char *shortopts, const char *longopts, const char *glossary);
|
||||
ARG_EXTERN struct arg_lit *arg_lit1(const char *shortopts, const char *longopts, const char *glossary);
|
||||
ARG_EXTERN struct arg_lit *arg_litn(const char *shortopts, const char *longopts, int mincount, int maxcount,
|
||||
ARG_EXTERN struct arg_lit *arg_litn(const char *shortopts,
|
||||
const char *longopts,
|
||||
int mincount,
|
||||
int maxcount,
|
||||
const char *glossary);
|
||||
|
||||
ARG_EXTERN struct arg_int *arg_int0(const char *shortopts, const char *longopts, const char *datatype,
|
||||
ARG_EXTERN struct arg_int *arg_int0(const char *shortopts,
|
||||
const char *longopts,
|
||||
const char *datatype,
|
||||
const char *glossary);
|
||||
ARG_EXTERN struct arg_int *arg_int1(const char *shortopts, const char *longopts, const char *datatype,
|
||||
ARG_EXTERN struct arg_int *arg_int1(const char *shortopts,
|
||||
const char *longopts,
|
||||
const char *datatype,
|
||||
const char *glossary);
|
||||
ARG_EXTERN struct arg_int *arg_intn(const char *shortopts,
|
||||
const char *longopts,
|
||||
const char *datatype,
|
||||
int mincount,
|
||||
int maxcount,
|
||||
const char *glossary);
|
||||
ARG_EXTERN struct arg_int *arg_intn(const char *shortopts, const char *longopts, const char *datatype, int mincount,
|
||||
int maxcount, const char *glossary);
|
||||
|
||||
ARG_EXTERN struct arg_dbl *arg_dbl0(const char *shortopts, const char *longopts, const char *datatype,
|
||||
ARG_EXTERN struct arg_dbl *arg_dbl0(const char *shortopts,
|
||||
const char *longopts,
|
||||
const char *datatype,
|
||||
const char *glossary);
|
||||
ARG_EXTERN struct arg_dbl *arg_dbl1(const char *shortopts, const char *longopts, const char *datatype,
|
||||
ARG_EXTERN struct arg_dbl *arg_dbl1(const char *shortopts,
|
||||
const char *longopts,
|
||||
const char *datatype,
|
||||
const char *glossary);
|
||||
ARG_EXTERN struct arg_dbl *arg_dbln(const char *shortopts,
|
||||
const char *longopts,
|
||||
const char *datatype,
|
||||
int mincount,
|
||||
int maxcount,
|
||||
const char *glossary);
|
||||
ARG_EXTERN struct arg_dbl *arg_dbln(const char *shortopts, const char *longopts, const char *datatype, int mincount,
|
||||
int maxcount, const char *glossary);
|
||||
|
||||
ARG_EXTERN struct arg_str *arg_str0(const char *shortopts, const char *longopts, const char *datatype,
|
||||
ARG_EXTERN struct arg_str *arg_str0(const char *shortopts,
|
||||
const char *longopts,
|
||||
const char *datatype,
|
||||
const char *glossary);
|
||||
ARG_EXTERN struct arg_str *arg_str1(const char *shortopts, const char *longopts, const char *datatype,
|
||||
ARG_EXTERN struct arg_str *arg_str1(const char *shortopts,
|
||||
const char *longopts,
|
||||
const char *datatype,
|
||||
const char *glossary);
|
||||
ARG_EXTERN struct arg_str *arg_strn(const char *shortopts,
|
||||
const char *longopts,
|
||||
const char *datatype,
|
||||
int mincount,
|
||||
int maxcount,
|
||||
const char *glossary);
|
||||
ARG_EXTERN struct arg_str *arg_strn(const char *shortopts, const char *longopts, const char *datatype, int mincount,
|
||||
int maxcount, const char *glossary);
|
||||
|
||||
ARG_EXTERN struct arg_rex *arg_rex0(const char *shortopts, const char *longopts, const char *pattern,
|
||||
const char *datatype, int flags, const char *glossary);
|
||||
ARG_EXTERN struct arg_rex *arg_rex1(const char *shortopts, const char *longopts, const char *pattern,
|
||||
const char *datatype, int flags, const char *glossary);
|
||||
ARG_EXTERN struct arg_rex *arg_rexn(const char *shortopts, const char *longopts, const char *pattern,
|
||||
const char *datatype, int mincount, int maxcount, int flags, const char *glossary);
|
||||
ARG_EXTERN struct arg_rex *arg_rex0(const char *shortopts,
|
||||
const char *longopts,
|
||||
const char *pattern,
|
||||
const char *datatype,
|
||||
int flags,
|
||||
const char *glossary);
|
||||
ARG_EXTERN struct arg_rex *arg_rex1(const char *shortopts,
|
||||
const char *longopts,
|
||||
const char *pattern,
|
||||
const char *datatype,
|
||||
int flags,
|
||||
const char *glossary);
|
||||
ARG_EXTERN struct arg_rex *arg_rexn(const char *shortopts,
|
||||
const char *longopts,
|
||||
const char *pattern,
|
||||
const char *datatype,
|
||||
int mincount,
|
||||
int maxcount,
|
||||
int flags,
|
||||
const char *glossary);
|
||||
|
||||
ARG_EXTERN struct arg_file *arg_file0(const char *shortopts, const char *longopts, const char *datatype,
|
||||
ARG_EXTERN struct arg_file *arg_file0(const char *shortopts,
|
||||
const char *longopts,
|
||||
const char *datatype,
|
||||
const char *glossary);
|
||||
ARG_EXTERN struct arg_file *arg_file1(const char *shortopts, const char *longopts, const char *datatype,
|
||||
ARG_EXTERN struct arg_file *arg_file1(const char *shortopts,
|
||||
const char *longopts,
|
||||
const char *datatype,
|
||||
const char *glossary);
|
||||
ARG_EXTERN struct arg_file *arg_filen(const char *shortopts,
|
||||
const char *longopts,
|
||||
const char *datatype,
|
||||
int mincount,
|
||||
int maxcount,
|
||||
const char *glossary);
|
||||
ARG_EXTERN struct arg_file *arg_filen(const char *shortopts, const char *longopts, const char *datatype, int mincount,
|
||||
int maxcount, const char *glossary);
|
||||
|
||||
ARG_EXTERN struct arg_date *arg_date0(const char *shortopts, const char *longopts, const char *format,
|
||||
const char *datatype, const char *glossary);
|
||||
ARG_EXTERN struct arg_date *arg_date1(const char *shortopts, const char *longopts, const char *format,
|
||||
const char *datatype, const char *glossary);
|
||||
ARG_EXTERN struct arg_date *arg_daten(const char *shortopts, const char *longopts, const char *format,
|
||||
const char *datatype, int mincount, int maxcount, const char *glossary);
|
||||
ARG_EXTERN struct arg_date *arg_date0(const char *shortopts,
|
||||
const char *longopts,
|
||||
const char *format,
|
||||
const char *datatype,
|
||||
const char *glossary);
|
||||
ARG_EXTERN struct arg_date *arg_date1(const char *shortopts,
|
||||
const char *longopts,
|
||||
const char *format,
|
||||
const char *datatype,
|
||||
const char *glossary);
|
||||
ARG_EXTERN struct arg_date *arg_daten(const char *shortopts,
|
||||
const char *longopts,
|
||||
const char *format,
|
||||
const char *datatype,
|
||||
int mincount,
|
||||
int maxcount,
|
||||
const char *glossary);
|
||||
|
||||
ARG_EXTERN struct arg_end *arg_end(int maxerrors);
|
||||
|
||||
|
@ -242,14 +302,20 @@ ARG_EXTERN struct arg_end *arg_end(int maxerrors);
|
|||
/**** other functions *******************************************/
|
||||
ARG_EXTERN int arg_nullcheck(void **argtable);
|
||||
ARG_EXTERN int arg_parse(int argc, char **argv, void **argtable);
|
||||
ARG_EXTERN void arg_print_option(FILE *fp, const char *shortopts, const char *longopts, const char *datatype,
|
||||
ARG_EXTERN void arg_print_option(FILE *fp,
|
||||
const char *shortopts,
|
||||
const char *longopts,
|
||||
const char *datatype,
|
||||
const char *suffix);
|
||||
ARG_EXTERN void arg_print_syntax(FILE *fp, void **argtable, const char *suffix);
|
||||
ARG_EXTERN void arg_print_syntaxv(FILE *fp, void **argtable, const char *suffix);
|
||||
ARG_EXTERN void arg_print_glossary(FILE *fp, void **argtable, const char *format);
|
||||
ARG_EXTERN void arg_print_glossary_gnu(FILE *fp, void **argtable);
|
||||
ARG_EXTERN void arg_print_errors(FILE *fp, struct arg_end *end, const char *progname);
|
||||
ARG_EXTERN void arg_print_option_ds(arg_dstr_t ds, const char *shortopts, const char *longopts, const char *datatype,
|
||||
ARG_EXTERN void arg_print_option_ds(arg_dstr_t ds,
|
||||
const char *shortopts,
|
||||
const char *longopts,
|
||||
const char *datatype,
|
||||
const char *suffix);
|
||||
ARG_EXTERN void arg_print_syntax_ds(arg_dstr_t ds, void **argtable, const char *suffix);
|
||||
ARG_EXTERN void arg_print_syntaxv_ds(arg_dstr_t ds, void **argtable, const char *suffix);
|
||||
|
@ -285,10 +351,15 @@ ARG_EXTERN void arg_mgsort(void *data, int size, int esize, int i, in
|
|||
ARG_EXTERN void arg_make_get_help_msg(arg_dstr_t res);
|
||||
ARG_EXTERN void arg_make_help_msg(arg_dstr_t ds, char *cmd_name, void **argtable);
|
||||
ARG_EXTERN void arg_make_syntax_err_msg(arg_dstr_t ds, void **argtable, struct arg_end *end);
|
||||
ARG_EXTERN int arg_make_syntax_err_help_msg(arg_dstr_t ds, char *name, int help, int nerrors, void **argtable,
|
||||
struct arg_end *end, int *exitcode);
|
||||
ARG_EXTERN void arg_set_module_name(const char *name);
|
||||
ARG_EXTERN void arg_set_module_version(int major, int minor, int patch, const char *tag);
|
||||
ARG_EXTERN int arg_make_syntax_err_help_msg(arg_dstr_t ds,
|
||||
char *name,
|
||||
int help,
|
||||
int nerrors,
|
||||
void **argtable,
|
||||
struct arg_end *end,
|
||||
int *exitcode);
|
||||
ARG_EXTERN void arg_set_module_name(const char *name);
|
||||
ARG_EXTERN void arg_set_module_version(int major, int minor, int patch, const char *tag);
|
||||
|
||||
/**** deprecated functions, for back-compatibility only ********/
|
||||
ARG_EXTERN void arg_free(void **argtable);
|
||||
|
|
|
@ -38,8 +38,8 @@ typedef struct __ARG_TBL_INFO {
|
|||
static PARG_TBL_INFO g_pArgTbl = NULL;
|
||||
static unsigned int g_nArgTbl = 0;
|
||||
static const char *g_toolsKey[][2] = {
|
||||
{"cfg_all", "get all configuration information"},
|
||||
{"mem_info", "show the memory alloc information"},
|
||||
{"cfg_all", "get all configuration information" },
|
||||
{"mem_info", "show the memory alloc information" },
|
||||
{"sys_info", "show the system and hardware information"},
|
||||
};
|
||||
|
||||
|
@ -428,8 +428,8 @@ static int on_cmd7(void *pTbl[], const char *pName, void *pInfo) {
|
|||
#endif
|
||||
|
||||
static int on_cmd_(void *pTbl[], const char *pName, void *pInfo) {
|
||||
PARG_TBL_INFO pArg = (PARG_TBL_INFO)pInfo;
|
||||
int help = get_help_cmd(pTbl, pArg)->count;
|
||||
PARG_TBL_INFO pArg = (PARG_TBL_INFO)pInfo;
|
||||
int help = get_help_cmd(pTbl, pArg)->count;
|
||||
//int version = ((arg_lit_t *)pTbl[0])->count;
|
||||
|
||||
if (help > 0) {
|
||||
|
|
|
@ -17,7 +17,7 @@ const vector config_get_dhcp_replication_svr() {
|
|||
}
|
||||
#endif
|
||||
|
||||
const char* config_get_http_server_addr() {
|
||||
const char *config_get_http_server_addr() {
|
||||
return cfg_get_string_value(CFG_HTTP_SVR_ADDR);
|
||||
}
|
||||
|
||||
|
|
|
@ -77,8 +77,12 @@ static void onEVPWorkCb(uv_work_t *pWork) {
|
|||
}
|
||||
}
|
||||
|
||||
int evp_add_crypto_task(CRYPTO_TYPE type, unsigned char *pInBuf, unsigned int iSize, unsigned char *pOutBuf, char *pKey,
|
||||
on_evp_crypto onEvpCryptCb) {
|
||||
int evp_add_crypto_task(CRYPTO_TYPE type,
|
||||
unsigned char *pInBuf,
|
||||
unsigned int iSize,
|
||||
unsigned char *pOutBuf,
|
||||
char *pKey,
|
||||
on_evp_crypto onEvpCryptCb) {
|
||||
uv_work_t *puvWork = NULL;
|
||||
PCRYPT_TASK_PARAMS pTask = NULL;
|
||||
|
||||
|
|
|
@ -92,8 +92,11 @@ int hash_digest_file(HASH_TYPE hashType, const char *pFileName, char **pHashValu
|
|||
* @param pHashValue
|
||||
* @return
|
||||
*/
|
||||
int hash_digest_mem(HASH_TYPE hashType, const unsigned char *pBuf, unsigned int iBufLen, unsigned char **pHashValue,
|
||||
unsigned int *pOutSize) {
|
||||
int hash_digest_mem(HASH_TYPE hashType,
|
||||
const unsigned char *pBuf,
|
||||
unsigned int iBufLen,
|
||||
unsigned char **pHashValue,
|
||||
unsigned int *pOutSize) {
|
||||
EVP_MD_CTX *pCtx;
|
||||
|
||||
if (pHashValue == NULL || pBuf == NULL || pOutSize == NULL) {
|
||||
|
|
|
@ -66,7 +66,7 @@ static int sha1prng_for_aes_key(const char *pKey, unsigned char *pShaPrng16) {
|
|||
strncpy((char *)keyBuf, pKey, EVP_CIPHER_key_length(pCipher)); \
|
||||
break; \
|
||||
case AES128_ECB_PKCS7PADDING_SHA1PRNG: \
|
||||
if (sha1prng_for_aes_key(pKey, keyBuf) != ERR_SUCCESS) { \
|
||||
if (sha1prng_for_aes_key(pKey, keyBuf) != ERR_SUCCESS) { \
|
||||
EVP_CIPHER_CTX_cleanup(pCtx); \
|
||||
return -ERR_AES128_KEYGEN; \
|
||||
} \
|
||||
|
@ -110,8 +110,12 @@ static int sha1prng_for_aes_key(const char *pKey, unsigned char *pShaPrng16) {
|
|||
} \
|
||||
} while (0)
|
||||
|
||||
int symmetric_decrypto(AES_TYPE algorithmType, unsigned char *pInBuf, unsigned int inSize, unsigned char **pOutBuf,
|
||||
int *pOutSize, const char *pKey) {
|
||||
int symmetric_decrypto(AES_TYPE algorithmType,
|
||||
unsigned char *pInBuf,
|
||||
unsigned int inSize,
|
||||
unsigned char **pOutBuf,
|
||||
int *pOutSize,
|
||||
const char *pKey) {
|
||||
int enBytes = 0;
|
||||
EVP_CIPHER_CTX *pCtx;
|
||||
unsigned char *pAesBuf;
|
||||
|
@ -180,8 +184,12 @@ int symmetric_decrypto(AES_TYPE algorithmType, unsigned char *pInBuf, unsigned i
|
|||
return ERR_SUCCESS;
|
||||
}
|
||||
|
||||
int symmetric_encrypto(AES_TYPE algorithmType, unsigned char *pInBuf, unsigned int inSize, unsigned char **pOutBuf,
|
||||
int *pOutSize, const char *pKey) {
|
||||
int symmetric_encrypto(AES_TYPE algorithmType,
|
||||
unsigned char *pInBuf,
|
||||
unsigned int inSize,
|
||||
unsigned char **pOutBuf,
|
||||
int *pOutSize,
|
||||
const char *pKey) {
|
||||
int enBytes = 0;
|
||||
unsigned char *pAesBuf;
|
||||
EVP_CIPHER_CTX *pCtx;
|
||||
|
|
|
@ -141,7 +141,7 @@
|
|||
|
||||
/* Enable large inode numbers on Mac OS X 10.5. */
|
||||
#ifndef _DARWIN_USE_64_BIT_INODE
|
||||
# define _DARWIN_USE_64_BIT_INODE 1
|
||||
#define _DARWIN_USE_64_BIT_INODE 1
|
||||
#endif
|
||||
|
||||
/* Number of bits in a file offset, on hosts where this is settable. */
|
||||
|
|
|
@ -111,7 +111,7 @@ int cfg_get_zero_mq_port();
|
|||
const char *cfg_get_zero_mq_data_path();
|
||||
|
||||
const char *cfg_get_string_value(CONFIG_ITEM_ID id);
|
||||
vector cfg_get_vector(CONFIG_ITEM_ID id);
|
||||
vector cfg_get_vector(CONFIG_ITEM_ID id);
|
||||
long double cfg_get_float_value(CONFIG_ITEM_ID id);
|
||||
int cfg_get_bool_value(CONFIG_ITEM_ID id);
|
||||
long long cfg_get_integral_value(CONFIG_ITEM_ID id);
|
||||
|
@ -137,4 +137,4 @@ const vector config_get_dhcp_replication_svr();
|
|||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif//DAEMON_AGENT_INCLUDE_CONFIG_H
|
||||
#endif //DAEMON_AGENT_INCLUDE_CONFIG_H
|
||||
|
|
|
@ -38,16 +38,27 @@ typedef enum {
|
|||
HASH_TYPE_SHA256 = 2,
|
||||
} HASH_TYPE;
|
||||
|
||||
typedef void (*on_evp_crypto)(CRYPTO_TYPE type, const unsigned char *pData, unsigned int iSize,
|
||||
const unsigned char *pSrcData, int iError);
|
||||
typedef void (*on_evp_crypto)(CRYPTO_TYPE type,
|
||||
const unsigned char *pData,
|
||||
unsigned int iSize,
|
||||
const unsigned char *pSrcData,
|
||||
int iError);
|
||||
|
||||
//*****************************************************
|
||||
// AES
|
||||
//*****************************************************
|
||||
int symmetric_encrypto(AES_TYPE algorithmType, unsigned char *pInBuf, unsigned int inSize, unsigned char **pOutBuf,
|
||||
int *pOutSize, const char *pKey);
|
||||
int symmetric_decrypto(AES_TYPE algorithmType, unsigned char *pInBuf, unsigned int inSize, unsigned char **pOutBuf,
|
||||
int *pOutSize, const char *pKey);
|
||||
int symmetric_encrypto(AES_TYPE algorithmType,
|
||||
unsigned char *pInBuf,
|
||||
unsigned int inSize,
|
||||
unsigned char **pOutBuf,
|
||||
int *pOutSize,
|
||||
const char *pKey);
|
||||
int symmetric_decrypto(AES_TYPE algorithmType,
|
||||
unsigned char *pInBuf,
|
||||
unsigned int inSize,
|
||||
unsigned char **pOutBuf,
|
||||
int *pOutSize,
|
||||
const char *pKey);
|
||||
//*****************************************************
|
||||
// BASE64
|
||||
//*****************************************************
|
||||
|
@ -62,18 +73,25 @@ unsigned char *base64_decode(const char *pBase64, unsigned int *pOutSize);
|
|||
// MD5
|
||||
//*****************************************************
|
||||
int hash_digest_file(HASH_TYPE hashType, const char *pFileName, char **pHashValue);
|
||||
int hash_digest_mem(HASH_TYPE hashType, const unsigned char *pBuf, unsigned int iBufLen, unsigned char **pHashValue,
|
||||
unsigned int *pOutSize);
|
||||
int hash_digest_mem(HASH_TYPE hashType,
|
||||
const unsigned char *pBuf,
|
||||
unsigned int iBufLen,
|
||||
unsigned char **pHashValue,
|
||||
unsigned int *pOutSize);
|
||||
|
||||
//*****************************************************
|
||||
// Async Engine
|
||||
//*****************************************************
|
||||
int evp_add_crypto_task(CRYPTO_TYPE type, unsigned char *pInBuf, unsigned int iSize, unsigned char *pOutBuf, char *pKey,
|
||||
on_evp_crypto onEvpCryptCb);
|
||||
int evp_add_crypto_task(CRYPTO_TYPE type,
|
||||
unsigned char *pInBuf,
|
||||
unsigned int iSize,
|
||||
unsigned char *pOutBuf,
|
||||
char *pKey,
|
||||
on_evp_crypto onEvpCryptCb);
|
||||
|
||||
void evp_system_init(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif//DAEMON_AGENT_CRYPTO_CRYPTO_H
|
||||
#endif //DAEMON_AGENT_CRYPTO_CRYPTO_H
|
||||
|
|
|
@ -10,15 +10,25 @@ extern "C" {
|
|||
|
||||
int inet_api_init(void);
|
||||
|
||||
typedef void (*on_http_response)(void *pData, unsigned int size, const char *pReqUrl, const char *pDlPath,
|
||||
const char *pTaskUuid, int iFinished, void *pUserData);
|
||||
typedef void (*on_progress_changed)(const char *pReqUrl, const char *pTaskUuid, unsigned char uPercent,
|
||||
void *pUserData);
|
||||
typedef void (*on_http_response)(void *pData,
|
||||
unsigned int size,
|
||||
const char *pReqUrl,
|
||||
const char *pDlPath,
|
||||
const char *pTaskUuid,
|
||||
int iFinished,
|
||||
void *pUserData);
|
||||
typedef void (*on_progress_changed)(const char *pReqUrl,
|
||||
const char *pTaskUuid,
|
||||
unsigned char uPercent,
|
||||
void *pUserData);
|
||||
|
||||
const char *inet_download_file_async(const char *pURL, const char *pPath, on_http_response onRespCb,
|
||||
on_progress_changed onProgressCb, void *pData);
|
||||
const char *inet_download_file_async(const char *pURL,
|
||||
const char *pPath,
|
||||
on_http_response onRespCb,
|
||||
on_progress_changed onProgressCb,
|
||||
void *pData);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif//DAEMON_AGENT_NETWORD_INET_MISC_H
|
||||
#endif //DAEMON_AGENT_NETWORD_INET_MISC_H
|
||||
|
|
|
@ -50,10 +50,13 @@ int copy_file(const char *pSrc, const char *pDest);
|
|||
char *bin2hex(char *p, const unsigned char *cp, unsigned int count);
|
||||
int shell_with_output(const char *pCmd, char **pResult);
|
||||
int str_to_mac(const char *str, unsigned char mac[6]);
|
||||
int get_nic_info(const char *pName, unsigned int *pIp, unsigned int *pNetmask, unsigned int *pGateway,
|
||||
int get_nic_info(const char *pName,
|
||||
unsigned int *pIp,
|
||||
unsigned int *pNetmask,
|
||||
unsigned int *pGateway,
|
||||
unsigned char *pMac);
|
||||
int str_to_ipaddr(const char *pIp, unsigned int *ipAddr);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif//DAEMON_AGENT_MISC_MISC_H
|
||||
#endif //DAEMON_AGENT_MISC_MISC_H
|
||||
|
|
|
@ -24,8 +24,7 @@
|
|||
#define cJSON__h
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if !defined(__WINDOWS__) && (defined(WIN32) || defined(WIN64) || defined(_MSC_VER) || defined(_WIN32))
|
||||
|
@ -52,7 +51,7 @@ then using the CJSON_API_VISIBILITY flag to "export" the same symbols the way CJ
|
|||
|
||||
*/
|
||||
|
||||
#define CJSON_CDECL __cdecl
|
||||
#define CJSON_CDECL __cdecl
|
||||
#define CJSON_STDCALL __stdcall
|
||||
|
||||
/* export symbols by default, this is necessary for copy pasting the C and header file */
|
||||
|
@ -61,18 +60,18 @@ then using the CJSON_API_VISIBILITY flag to "export" the same symbols the way CJ
|
|||
#endif
|
||||
|
||||
#if defined(CJSON_HIDE_SYMBOLS)
|
||||
#define CJSON_PUBLIC(type) type CJSON_STDCALL
|
||||
#define CJSON_PUBLIC(type) type CJSON_STDCALL
|
||||
#elif defined(CJSON_EXPORT_SYMBOLS)
|
||||
#define CJSON_PUBLIC(type) __declspec(dllexport) type CJSON_STDCALL
|
||||
#define CJSON_PUBLIC(type) __declspec(dllexport) type CJSON_STDCALL
|
||||
#elif defined(CJSON_IMPORT_SYMBOLS)
|
||||
#define CJSON_PUBLIC(type) __declspec(dllimport) type CJSON_STDCALL
|
||||
#define CJSON_PUBLIC(type) __declspec(dllimport) type CJSON_STDCALL
|
||||
#endif
|
||||
#else /* !__WINDOWS__ */
|
||||
#define CJSON_CDECL
|
||||
#define CJSON_STDCALL
|
||||
|
||||
#if (defined(__GNUC__) || defined(__SUNPRO_CC) || defined (__SUNPRO_C)) && defined(CJSON_API_VISIBILITY)
|
||||
#define CJSON_PUBLIC(type) __attribute__((visibility("default"))) type
|
||||
#if (defined(__GNUC__) || defined(__SUNPRO_CC) || defined(__SUNPRO_C)) && defined(CJSON_API_VISIBILITY)
|
||||
#define CJSON_PUBLIC(type) __attribute__((visibility("default"))) type
|
||||
#else
|
||||
#define CJSON_PUBLIC(type) type
|
||||
#endif
|
||||
|
@ -87,21 +86,20 @@ then using the CJSON_API_VISIBILITY flag to "export" the same symbols the way CJ
|
|||
|
||||
/* cJSON Types: */
|
||||
#define cJSON_Invalid (0)
|
||||
#define cJSON_False (1 << 0)
|
||||
#define cJSON_True (1 << 1)
|
||||
#define cJSON_NULL (1 << 2)
|
||||
#define cJSON_Number (1 << 3)
|
||||
#define cJSON_String (1 << 4)
|
||||
#define cJSON_Array (1 << 5)
|
||||
#define cJSON_Object (1 << 6)
|
||||
#define cJSON_Raw (1 << 7) /* raw json */
|
||||
#define cJSON_False (1 << 0)
|
||||
#define cJSON_True (1 << 1)
|
||||
#define cJSON_NULL (1 << 2)
|
||||
#define cJSON_Number (1 << 3)
|
||||
#define cJSON_String (1 << 4)
|
||||
#define cJSON_Array (1 << 5)
|
||||
#define cJSON_Object (1 << 6)
|
||||
#define cJSON_Raw (1 << 7) /* raw json */
|
||||
|
||||
#define cJSON_IsReference 256
|
||||
#define cJSON_IsReference 256
|
||||
#define cJSON_StringIsConst 512
|
||||
|
||||
/* The cJSON structure: */
|
||||
typedef struct cJSON
|
||||
{
|
||||
typedef struct cJSON {
|
||||
/* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */
|
||||
struct cJSON *next;
|
||||
struct cJSON *prev;
|
||||
|
@ -122,11 +120,10 @@ typedef struct cJSON
|
|||
char *string;
|
||||
} cJSON;
|
||||
|
||||
typedef struct cJSON_Hooks
|
||||
{
|
||||
/* malloc/free are CDECL on Windows regardless of the default calling convention of the compiler, so ensure the hooks allow passing those functions directly. */
|
||||
void *(CJSON_CDECL *malloc_fn)(size_t sz);
|
||||
void (CJSON_CDECL *free_fn)(void *ptr);
|
||||
typedef struct cJSON_Hooks {
|
||||
/* malloc/free are CDECL on Windows regardless of the default calling convention of the compiler, so ensure the hooks allow passing those functions directly. */
|
||||
void *(CJSON_CDECL *malloc_fn)(size_t sz);
|
||||
void(CJSON_CDECL *free_fn)(void *ptr);
|
||||
} cJSON_Hooks;
|
||||
|
||||
typedef int cJSON_bool;
|
||||
|
@ -138,10 +135,10 @@ typedef int cJSON_bool;
|
|||
#endif
|
||||
|
||||
/* returns the version of cJSON as a string */
|
||||
CJSON_PUBLIC(const char*) cJSON_Version(void);
|
||||
CJSON_PUBLIC(const char *) cJSON_Version(void);
|
||||
|
||||
/* Supply malloc, realloc and free functions to cJSON */
|
||||
CJSON_PUBLIC(void) cJSON_InitHooks(cJSON_Hooks* hooks);
|
||||
CJSON_PUBLIC(void) cJSON_InitHooks(cJSON_Hooks *hooks);
|
||||
|
||||
/* Memory Management: the caller is always responsible to free the results from all variants of cJSON_Parse (with cJSON_Delete) and cJSON_Print (with stdlib free, cJSON_Hooks.free_fn, or cJSON_free as appropriate). The exception is cJSON_PrintPreallocated, where the caller has full responsibility of the buffer. */
|
||||
/* Supply a block of JSON, and this returns a cJSON object you can interrogate. */
|
||||
|
@ -149,8 +146,13 @@ CJSON_PUBLIC(cJSON *) cJSON_Parse(const char *value);
|
|||
CJSON_PUBLIC(cJSON *) cJSON_ParseWithLength(const char *value, size_t buffer_length);
|
||||
/* ParseWithOpts allows you to require (and check) that the JSON is null terminated, and to retrieve the pointer to the final byte parsed. */
|
||||
/* If you supply a ptr in return_parse_end and parsing fails, then return_parse_end will contain a pointer to the error so will match cJSON_GetErrorPtr(). */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_ParseWithOpts(const char *value, const char **return_parse_end, cJSON_bool require_null_terminated);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_ParseWithLengthOpts(const char *value, size_t buffer_length, const char **return_parse_end, cJSON_bool require_null_terminated);
|
||||
CJSON_PUBLIC(cJSON *)
|
||||
cJSON_ParseWithOpts(const char *value, const char **return_parse_end, cJSON_bool require_null_terminated);
|
||||
CJSON_PUBLIC(cJSON *)
|
||||
cJSON_ParseWithLengthOpts(const char *value,
|
||||
size_t buffer_length,
|
||||
const char **return_parse_end,
|
||||
cJSON_bool require_null_terminated);
|
||||
|
||||
/* Render a cJSON entity to text for transfer/storage. */
|
||||
CJSON_PUBLIC(char *) cJSON_Print(const cJSON *item);
|
||||
|
@ -160,7 +162,8 @@ CJSON_PUBLIC(char *) cJSON_PrintUnformatted(const cJSON *item);
|
|||
CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON_bool fmt);
|
||||
/* Render a cJSON entity to text using a buffer already allocated in memory with given length. Returns 1 on success and 0 on failure. */
|
||||
/* NOTE: cJSON is not always 100% accurate in estimating how much memory it will use, so to be safe allocate 5 bytes more than you actually need */
|
||||
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);
|
||||
/* Delete a cJSON entity and all subentities. */
|
||||
CJSON_PUBLIC(void) cJSON_Delete(cJSON *item);
|
||||
|
||||
|
@ -169,27 +172,27 @@ CJSON_PUBLIC(int) cJSON_GetArraySize(const cJSON *array);
|
|||
/* Retrieve item number "index" from array "array". Returns NULL if unsuccessful. */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_GetArrayItem(const cJSON *array, int index);
|
||||
/* Get item "string" from object. Case insensitive. */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_GetObjectItem(const cJSON * const object, const char * const string);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_GetObjectItemCaseSensitive(const cJSON * const object, const char * const string);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_GetObjectItem(const cJSON *const object, const char *const string);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_GetObjectItemCaseSensitive(const cJSON *const object, const char *const string);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_HasObjectItem(const cJSON *object, const char *string);
|
||||
/* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */
|
||||
CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void);
|
||||
|
||||
/* Check item type and return its value */
|
||||
CJSON_PUBLIC(char *) cJSON_GetStringValue(const cJSON * const item);
|
||||
CJSON_PUBLIC(double) cJSON_GetNumberValue(const cJSON * const item);
|
||||
CJSON_PUBLIC(char *) cJSON_GetStringValue(const cJSON *const item);
|
||||
CJSON_PUBLIC(double) cJSON_GetNumberValue(const cJSON *const item);
|
||||
|
||||
/* These functions check the type of an item */
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsInvalid(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsFalse(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsTrue(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsBool(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsNull(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsNumber(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsString(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsArray(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsObject(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsRaw(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsInvalid(const cJSON *const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsFalse(const cJSON *const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsTrue(const cJSON *const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsBool(const cJSON *const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsNull(const cJSON *const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsNumber(const cJSON *const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsString(const cJSON *const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsArray(const cJSON *const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsObject(const cJSON *const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsRaw(const cJSON *const item);
|
||||
|
||||
/* These calls create a cJSON item of the appropriate type. */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateNull(void);
|
||||
|
@ -230,7 +233,7 @@ CJSON_PUBLIC(cJSON_bool) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item
|
|||
CJSON_PUBLIC(cJSON_bool) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item);
|
||||
|
||||
/* Remove/Detach items from Arrays/Objects. */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON *const item);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromArray(cJSON *array, int which);
|
||||
CJSON_PUBLIC(void) cJSON_DeleteItemFromArray(cJSON *array, int which);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObject(cJSON *object, const char *string);
|
||||
|
@ -239,11 +242,12 @@ CJSON_PUBLIC(void) cJSON_DeleteItemFromObject(cJSON *object, const char *string)
|
|||
CJSON_PUBLIC(void) cJSON_DeleteItemFromObjectCaseSensitive(cJSON *object, const char *string);
|
||||
|
||||
/* Update array items. */
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem); /* Shifts pre-existing items to the right. */
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON * const item, cJSON * replacement);
|
||||
CJSON_PUBLIC(cJSON_bool)
|
||||
cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem); /* Shifts pre-existing items to the right. */
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON *const parent, cJSON *const item, cJSON *replacement);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object,const char *string,cJSON *newitem);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObject(cJSON *object, const char *string, cJSON *newitem);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object, const char *string, cJSON *newitem);
|
||||
|
||||
/* Duplicate a cJSON item */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse);
|
||||
|
@ -252,7 +256,7 @@ CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse);
|
|||
* The item->next and ->prev pointers are always zero on return from Duplicate. */
|
||||
/* Recursively compare two cJSON items for equality. If either a or b is NULL or invalid, they will be considered unequal.
|
||||
* case_sensitive determines if object keys are treated case sensitive (1) or case insensitive (0) */
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * const b, const cJSON_bool case_sensitive);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON *const a, const cJSON *const b, const cJSON_bool case_sensitive);
|
||||
|
||||
/* Minify a strings, remove blank characters(such as ' ', '\t', '\r', '\n') from strings.
|
||||
* The input pointer json cannot point to a read-only address area, such as a string constant,
|
||||
|
@ -261,26 +265,29 @@ CJSON_PUBLIC(void) cJSON_Minify(char *json);
|
|||
|
||||
/* Helper functions for creating and adding items to an object at the same time.
|
||||
* They return the added item or NULL on failure. */
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddNullToObject(cJSON * const object, const char * const name);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddTrueToObject(cJSON * const object, const char * const name);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddFalseToObject(cJSON * const object, const char * const name);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddBoolToObject(cJSON * const object, const char * const name, const cJSON_bool boolean);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddNumberToObject(cJSON * const object, const char * const name, const double number);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddStringToObject(cJSON * const object, const char * const name, const char * const string);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddRawToObject(cJSON * const object, const char * const name, const char * const raw);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddObjectToObject(cJSON * const object, const char * const name);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddArrayToObject(cJSON * const object, const char * const name);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_AddNullToObject(cJSON *const object, const char *const name);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_AddTrueToObject(cJSON *const object, const char *const name);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_AddFalseToObject(cJSON *const object, const char *const name);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_AddBoolToObject(cJSON *const object, const char *const name, const cJSON_bool boolean);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_AddNumberToObject(cJSON *const object, const char *const name, const double number);
|
||||
CJSON_PUBLIC(cJSON *)
|
||||
cJSON_AddStringToObject(cJSON *const object, const char *const name, const char *const string);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_AddRawToObject(cJSON *const object, const char *const name, const char *const raw);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_AddObjectToObject(cJSON *const object, const char *const name);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_AddArrayToObject(cJSON *const object, const char *const name);
|
||||
|
||||
/* When assigning an integer value, it needs to be propagated to valuedouble too. */
|
||||
#define cJSON_SetIntValue(object, number) ((object) ? (object)->valueint = (object)->valuedouble = (number) : (number))
|
||||
/* helper for the cJSON_SetNumberValue macro */
|
||||
CJSON_PUBLIC(double) cJSON_SetNumberHelper(cJSON *object, double number);
|
||||
#define cJSON_SetNumberValue(object, number) ((object != NULL) ? cJSON_SetNumberHelper(object, (double)number) : (number))
|
||||
#define cJSON_SetNumberValue(object, number) \
|
||||
((object != NULL) ? cJSON_SetNumberHelper(object, (double)number) : (number))
|
||||
/* Change the valuestring of a cJSON_String object, only takes effect when type of object is cJSON_String */
|
||||
CJSON_PUBLIC(char*) cJSON_SetValuestring(cJSON *object, const char *valuestring);
|
||||
CJSON_PUBLIC(char *) cJSON_SetValuestring(cJSON *object, const char *valuestring);
|
||||
|
||||
/* Macro for iterating over an array or object */
|
||||
#define cJSON_ArrayForEach(element, array) for(element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)
|
||||
#define cJSON_ArrayForEach(element, array) \
|
||||
for (element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)
|
||||
|
||||
/* malloc/free objects using the malloc/free functions that have been set with cJSON_InitHooks */
|
||||
CJSON_PUBLIC(void *) cJSON_malloc(size_t size);
|
||||
|
|
|
@ -220,22 +220,14 @@ typedef struct {
|
|||
for (; index_##_element < realsize_##_element && index_##_element < size; index_##_element++) { \
|
||||
array_item_##_element = cJSON_GetArrayItem(array_##_element, index_##_element); \
|
||||
if (array_item_##_element) { \
|
||||
S2J_STRUCT_ARRAY_GET_ELEMENT_EX(to_struct, \
|
||||
array_item_##_element, \
|
||||
type, \
|
||||
_element, \
|
||||
index_##_element, \
|
||||
_defval); \
|
||||
S2J_STRUCT_ARRAY_GET_ELEMENT_EX( \
|
||||
to_struct, array_item_##_element, type, _element, index_##_element, _defval); \
|
||||
} \
|
||||
} \
|
||||
} else { \
|
||||
for (; index_##_element < realsize_##_element && index_##_element < size; index_##_element++) { \
|
||||
S2J_STRUCT_ARRAY_GET_ELEMENT_EX(to_struct, \
|
||||
array_##_element, \
|
||||
type, \
|
||||
_element, \
|
||||
index_##_element, \
|
||||
_defval); \
|
||||
S2J_STRUCT_ARRAY_GET_ELEMENT_EX( \
|
||||
to_struct, array_##_element, type, _element, index_##_element, _defval); \
|
||||
} \
|
||||
} \
|
||||
} else { \
|
||||
|
|
|
@ -40,14 +40,14 @@ extern "C" {
|
|||
/* Structure pointing to our actually configured allocators */
|
||||
typedef struct hiredisAllocFuncs {
|
||||
void *(*mallocFn)(size_t);
|
||||
void *(*callocFn)(size_t,size_t);
|
||||
void *(*reallocFn)(void*,size_t);
|
||||
char *(*strdupFn)(const char*);
|
||||
void (*freeFn)(void*);
|
||||
void *(*callocFn)(size_t, size_t);
|
||||
void *(*reallocFn)(void *, size_t);
|
||||
char *(*strdupFn)(const char *);
|
||||
void (*freeFn)(void *);
|
||||
} hiredisAllocFuncs;
|
||||
|
||||
hiredisAllocFuncs hiredisSetAllocators(hiredisAllocFuncs *ha);
|
||||
void hiredisResetAllocators(void);
|
||||
void hiredisResetAllocators(void);
|
||||
|
||||
#ifndef _WIN32
|
||||
|
||||
|
@ -80,7 +80,7 @@ void *hi_malloc(size_t size);
|
|||
void *hi_calloc(size_t nmemb, size_t size);
|
||||
void *hi_realloc(void *ptr, size_t size);
|
||||
char *hi_strdup(const char *str);
|
||||
void hi_free(void *ptr);
|
||||
void hi_free(void *ptr);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#ifndef __SDS_H
|
||||
#define __SDS_H
|
||||
|
||||
#define SDS_MAX_PREALLOC (1024*1024)
|
||||
#define SDS_MAX_PREALLOC (1024 * 1024)
|
||||
#ifdef _MSC_VER
|
||||
#define __attribute__(x)
|
||||
typedef long long ssize_t;
|
||||
|
@ -48,83 +48,83 @@ typedef char *sds;
|
|||
|
||||
/* Note: sdshdr5 is never used, we just access the flags byte directly.
|
||||
* However is here to document the layout of type 5 SDS strings. */
|
||||
struct __attribute__ ((__packed__)) sdshdr5 {
|
||||
struct __attribute__((__packed__)) sdshdr5 {
|
||||
unsigned char flags; /* 3 lsb of type, and 5 msb of string length */
|
||||
char buf[];
|
||||
char buf[];
|
||||
};
|
||||
struct __attribute__ ((__packed__)) sdshdr8 {
|
||||
uint8_t len; /* used */
|
||||
uint8_t alloc; /* excluding the header and null terminator */
|
||||
struct __attribute__((__packed__)) sdshdr8 {
|
||||
uint8_t len; /* used */
|
||||
uint8_t alloc; /* excluding the header and null terminator */
|
||||
unsigned char flags; /* 3 lsb of type, 5 unused bits */
|
||||
char buf[];
|
||||
char buf[];
|
||||
};
|
||||
struct __attribute__ ((__packed__)) sdshdr16 {
|
||||
uint16_t len; /* used */
|
||||
uint16_t alloc; /* excluding the header and null terminator */
|
||||
struct __attribute__((__packed__)) sdshdr16 {
|
||||
uint16_t len; /* used */
|
||||
uint16_t alloc; /* excluding the header and null terminator */
|
||||
unsigned char flags; /* 3 lsb of type, 5 unused bits */
|
||||
char buf[];
|
||||
char buf[];
|
||||
};
|
||||
struct __attribute__ ((__packed__)) sdshdr32 {
|
||||
uint32_t len; /* used */
|
||||
uint32_t alloc; /* excluding the header and null terminator */
|
||||
struct __attribute__((__packed__)) sdshdr32 {
|
||||
uint32_t len; /* used */
|
||||
uint32_t alloc; /* excluding the header and null terminator */
|
||||
unsigned char flags; /* 3 lsb of type, 5 unused bits */
|
||||
char buf[];
|
||||
char buf[];
|
||||
};
|
||||
struct __attribute__ ((__packed__)) sdshdr64 {
|
||||
uint64_t len; /* used */
|
||||
uint64_t alloc; /* excluding the header and null terminator */
|
||||
struct __attribute__((__packed__)) sdshdr64 {
|
||||
uint64_t len; /* used */
|
||||
uint64_t alloc; /* excluding the header and null terminator */
|
||||
unsigned char flags; /* 3 lsb of type, 5 unused bits */
|
||||
char buf[];
|
||||
char buf[];
|
||||
};
|
||||
|
||||
#define SDS_TYPE_5 0
|
||||
#define SDS_TYPE_8 1
|
||||
#define SDS_TYPE_16 2
|
||||
#define SDS_TYPE_32 3
|
||||
#define SDS_TYPE_64 4
|
||||
#define SDS_TYPE_MASK 7
|
||||
#define SDS_TYPE_BITS 3
|
||||
#define SDS_HDR_VAR(T,s) struct sdshdr##T *sh = (struct sdshdr##T *)((s)-(sizeof(struct sdshdr##T)));
|
||||
#define SDS_HDR(T,s) ((struct sdshdr##T *)((s)-(sizeof(struct sdshdr##T))))
|
||||
#define SDS_TYPE_5_LEN(f) ((f)>>SDS_TYPE_BITS)
|
||||
#define SDS_TYPE_5 0
|
||||
#define SDS_TYPE_8 1
|
||||
#define SDS_TYPE_16 2
|
||||
#define SDS_TYPE_32 3
|
||||
#define SDS_TYPE_64 4
|
||||
#define SDS_TYPE_MASK 7
|
||||
#define SDS_TYPE_BITS 3
|
||||
#define SDS_HDR_VAR(T, s) struct sdshdr##T *sh = (struct sdshdr##T *)((s) - (sizeof(struct sdshdr##T)));
|
||||
#define SDS_HDR(T, s) ((struct sdshdr##T *)((s) - (sizeof(struct sdshdr##T))))
|
||||
#define SDS_TYPE_5_LEN(f) ((f) >> SDS_TYPE_BITS)
|
||||
|
||||
static inline size_t sdslen(const sds s) {
|
||||
unsigned char flags = s[-1];
|
||||
switch(flags&SDS_TYPE_MASK) {
|
||||
switch (flags & SDS_TYPE_MASK) {
|
||||
case SDS_TYPE_5:
|
||||
return SDS_TYPE_5_LEN(flags);
|
||||
case SDS_TYPE_8:
|
||||
return SDS_HDR(8,s)->len;
|
||||
return SDS_HDR(8, s)->len;
|
||||
case SDS_TYPE_16:
|
||||
return SDS_HDR(16,s)->len;
|
||||
return SDS_HDR(16, s)->len;
|
||||
case SDS_TYPE_32:
|
||||
return SDS_HDR(32,s)->len;
|
||||
return SDS_HDR(32, s)->len;
|
||||
case SDS_TYPE_64:
|
||||
return SDS_HDR(64,s)->len;
|
||||
return SDS_HDR(64, s)->len;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline size_t sdsavail(const sds s) {
|
||||
unsigned char flags = s[-1];
|
||||
switch(flags&SDS_TYPE_MASK) {
|
||||
switch (flags & SDS_TYPE_MASK) {
|
||||
case SDS_TYPE_5: {
|
||||
return 0;
|
||||
}
|
||||
case SDS_TYPE_8: {
|
||||
SDS_HDR_VAR(8,s);
|
||||
SDS_HDR_VAR(8, s);
|
||||
return sh->alloc - sh->len;
|
||||
}
|
||||
case SDS_TYPE_16: {
|
||||
SDS_HDR_VAR(16,s);
|
||||
SDS_HDR_VAR(16, s);
|
||||
return sh->alloc - sh->len;
|
||||
}
|
||||
case SDS_TYPE_32: {
|
||||
SDS_HDR_VAR(32,s);
|
||||
SDS_HDR_VAR(32, s);
|
||||
return sh->alloc - sh->len;
|
||||
}
|
||||
case SDS_TYPE_64: {
|
||||
SDS_HDR_VAR(64,s);
|
||||
SDS_HDR_VAR(64, s);
|
||||
return sh->alloc - sh->len;
|
||||
}
|
||||
}
|
||||
|
@ -133,49 +133,45 @@ static inline size_t sdsavail(const sds s) {
|
|||
|
||||
static inline void sdssetlen(sds s, size_t newlen) {
|
||||
unsigned char flags = s[-1];
|
||||
switch(flags&SDS_TYPE_MASK) {
|
||||
case SDS_TYPE_5:
|
||||
{
|
||||
unsigned char *fp = ((unsigned char*)s)-1;
|
||||
*fp = (unsigned char)(SDS_TYPE_5 | (newlen << SDS_TYPE_BITS));
|
||||
}
|
||||
break;
|
||||
switch (flags & SDS_TYPE_MASK) {
|
||||
case SDS_TYPE_5: {
|
||||
unsigned char *fp = ((unsigned char *)s) - 1;
|
||||
*fp = (unsigned char)(SDS_TYPE_5 | (newlen << SDS_TYPE_BITS));
|
||||
} break;
|
||||
case SDS_TYPE_8:
|
||||
SDS_HDR(8,s)->len = (uint8_t)newlen;
|
||||
SDS_HDR(8, s)->len = (uint8_t)newlen;
|
||||
break;
|
||||
case SDS_TYPE_16:
|
||||
SDS_HDR(16,s)->len = (uint16_t)newlen;
|
||||
SDS_HDR(16, s)->len = (uint16_t)newlen;
|
||||
break;
|
||||
case SDS_TYPE_32:
|
||||
SDS_HDR(32,s)->len = (uint32_t)newlen;
|
||||
SDS_HDR(32, s)->len = (uint32_t)newlen;
|
||||
break;
|
||||
case SDS_TYPE_64:
|
||||
SDS_HDR(64,s)->len = (uint64_t)newlen;
|
||||
SDS_HDR(64, s)->len = (uint64_t)newlen;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void sdsinclen(sds s, size_t inc) {
|
||||
unsigned char flags = s[-1];
|
||||
switch(flags&SDS_TYPE_MASK) {
|
||||
case SDS_TYPE_5:
|
||||
{
|
||||
unsigned char *fp = ((unsigned char*)s)-1;
|
||||
unsigned char newlen = SDS_TYPE_5_LEN(flags)+(unsigned char)inc;
|
||||
*fp = SDS_TYPE_5 | (newlen << SDS_TYPE_BITS);
|
||||
}
|
||||
break;
|
||||
switch (flags & SDS_TYPE_MASK) {
|
||||
case SDS_TYPE_5: {
|
||||
unsigned char *fp = ((unsigned char *)s) - 1;
|
||||
unsigned char newlen = SDS_TYPE_5_LEN(flags) + (unsigned char)inc;
|
||||
*fp = SDS_TYPE_5 | (newlen << SDS_TYPE_BITS);
|
||||
} break;
|
||||
case SDS_TYPE_8:
|
||||
SDS_HDR(8,s)->len += (uint8_t)inc;
|
||||
SDS_HDR(8, s)->len += (uint8_t)inc;
|
||||
break;
|
||||
case SDS_TYPE_16:
|
||||
SDS_HDR(16,s)->len += (uint16_t)inc;
|
||||
SDS_HDR(16, s)->len += (uint16_t)inc;
|
||||
break;
|
||||
case SDS_TYPE_32:
|
||||
SDS_HDR(32,s)->len += (uint32_t)inc;
|
||||
SDS_HDR(32, s)->len += (uint32_t)inc;
|
||||
break;
|
||||
case SDS_TYPE_64:
|
||||
SDS_HDR(64,s)->len += (uint64_t)inc;
|
||||
SDS_HDR(64, s)->len += (uint64_t)inc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -183,85 +179,84 @@ static inline void sdsinclen(sds s, size_t inc) {
|
|||
/* sdsalloc() = sdsavail() + sdslen() */
|
||||
static inline size_t sdsalloc(const sds s) {
|
||||
unsigned char flags = s[-1];
|
||||
switch(flags&SDS_TYPE_MASK) {
|
||||
switch (flags & SDS_TYPE_MASK) {
|
||||
case SDS_TYPE_5:
|
||||
return SDS_TYPE_5_LEN(flags);
|
||||
case SDS_TYPE_8:
|
||||
return SDS_HDR(8,s)->alloc;
|
||||
return SDS_HDR(8, s)->alloc;
|
||||
case SDS_TYPE_16:
|
||||
return SDS_HDR(16,s)->alloc;
|
||||
return SDS_HDR(16, s)->alloc;
|
||||
case SDS_TYPE_32:
|
||||
return SDS_HDR(32,s)->alloc;
|
||||
return SDS_HDR(32, s)->alloc;
|
||||
case SDS_TYPE_64:
|
||||
return SDS_HDR(64,s)->alloc;
|
||||
return SDS_HDR(64, s)->alloc;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void sdssetalloc(sds s, size_t newlen) {
|
||||
unsigned char flags = s[-1];
|
||||
switch(flags&SDS_TYPE_MASK) {
|
||||
switch (flags & SDS_TYPE_MASK) {
|
||||
case SDS_TYPE_5:
|
||||
/* Nothing to do, this type has no total allocation info. */
|
||||
break;
|
||||
case SDS_TYPE_8:
|
||||
SDS_HDR(8,s)->alloc = (uint8_t)newlen;
|
||||
SDS_HDR(8, s)->alloc = (uint8_t)newlen;
|
||||
break;
|
||||
case SDS_TYPE_16:
|
||||
SDS_HDR(16,s)->alloc = (uint16_t)newlen;
|
||||
SDS_HDR(16, s)->alloc = (uint16_t)newlen;
|
||||
break;
|
||||
case SDS_TYPE_32:
|
||||
SDS_HDR(32,s)->alloc = (uint32_t)newlen;
|
||||
SDS_HDR(32, s)->alloc = (uint32_t)newlen;
|
||||
break;
|
||||
case SDS_TYPE_64:
|
||||
SDS_HDR(64,s)->alloc = (uint64_t)newlen;
|
||||
SDS_HDR(64, s)->alloc = (uint64_t)newlen;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
sds sdsnewlen(const void *init, size_t initlen);
|
||||
sds sdsnew(const char *init);
|
||||
sds sdsempty(void);
|
||||
sds sdsdup(const sds s);
|
||||
sds sdsnewlen(const void *init, size_t initlen);
|
||||
sds sdsnew(const char *init);
|
||||
sds sdsempty(void);
|
||||
sds sdsdup(const sds s);
|
||||
void sdsfree(sds s);
|
||||
sds sdsgrowzero(sds s, size_t len);
|
||||
sds sdscatlen(sds s, const void *t, size_t len);
|
||||
sds sdscat(sds s, const char *t);
|
||||
sds sdscatsds(sds s, const sds t);
|
||||
sds sdscpylen(sds s, const char *t, size_t len);
|
||||
sds sdscpy(sds s, const char *t);
|
||||
sds sdsgrowzero(sds s, size_t len);
|
||||
sds sdscatlen(sds s, const void *t, size_t len);
|
||||
sds sdscat(sds s, const char *t);
|
||||
sds sdscatsds(sds s, const sds t);
|
||||
sds sdscpylen(sds s, const char *t, size_t len);
|
||||
sds sdscpy(sds s, const char *t);
|
||||
|
||||
sds sdscatvprintf(sds s, const char *fmt, va_list ap);
|
||||
#ifdef __GNUC__
|
||||
sds sdscatprintf(sds s, const char *fmt, ...)
|
||||
__attribute__((format(printf, 2, 3)));
|
||||
sds sdscatprintf(sds s, const char *fmt, ...) __attribute__((format(printf, 2, 3)));
|
||||
#else
|
||||
sds sdscatprintf(sds s, const char *fmt, ...);
|
||||
#endif
|
||||
|
||||
sds sdscatfmt(sds s, char const *fmt, ...);
|
||||
sds sdstrim(sds s, const char *cset);
|
||||
int sdsrange(sds s, ssize_t start, ssize_t end);
|
||||
sds sdscatfmt(sds s, char const *fmt, ...);
|
||||
sds sdstrim(sds s, const char *cset);
|
||||
int sdsrange(sds s, ssize_t start, ssize_t end);
|
||||
void sdsupdatelen(sds s);
|
||||
void sdsclear(sds s);
|
||||
int sdscmp(const sds s1, const sds s2);
|
||||
int sdscmp(const sds s1, const sds s2);
|
||||
sds *sdssplitlen(const char *s, int len, const char *sep, int seplen, int *count);
|
||||
void sdsfreesplitres(sds *tokens, int count);
|
||||
void sdstolower(sds s);
|
||||
void sdstoupper(sds s);
|
||||
sds sdsfromlonglong(long long value);
|
||||
sds sdscatrepr(sds s, const char *p, size_t len);
|
||||
sds sdsfromlonglong(long long value);
|
||||
sds sdscatrepr(sds s, const char *p, size_t len);
|
||||
sds *sdssplitargs(const char *line, int *argc);
|
||||
sds sdsmapchars(sds s, const char *from, const char *to, size_t setlen);
|
||||
sds sdsjoin(char **argv, int argc, char *sep);
|
||||
sds sdsjoinsds(sds *argv, int argc, const char *sep, size_t seplen);
|
||||
sds sdsmapchars(sds s, const char *from, const char *to, size_t setlen);
|
||||
sds sdsjoin(char **argv, int argc, char *sep);
|
||||
sds sdsjoinsds(sds *argv, int argc, const char *sep, size_t seplen);
|
||||
|
||||
/* Low level functions exposed to the user API */
|
||||
sds sdsMakeRoomFor(sds s, size_t addlen);
|
||||
void sdsIncrLen(sds s, int incr);
|
||||
sds sdsRemoveFreeSpace(sds s);
|
||||
sds sdsMakeRoomFor(sds s, size_t addlen);
|
||||
void sdsIncrLen(sds s, int incr);
|
||||
sds sdsRemoveFreeSpace(sds s);
|
||||
size_t sdsAllocSize(sds s);
|
||||
void *sdsAllocPtr(sds s);
|
||||
void *sdsAllocPtr(sds s);
|
||||
|
||||
/* Export the allocator used by SDS to the program using SDS.
|
||||
* Sometimes the program SDS is linked to, may use a different set of
|
||||
|
@ -269,7 +264,7 @@ void *sdsAllocPtr(sds s);
|
|||
* respectively free or allocate. */
|
||||
void *sds_malloc(size_t size);
|
||||
void *sds_realloc(void *ptr, size_t size);
|
||||
void sds_free(void *ptr);
|
||||
void sds_free(void *ptr);
|
||||
|
||||
#ifdef REDIS_TEST
|
||||
int sdsTest(int argc, char *argv[]);
|
||||
|
|
|
@ -39,6 +39,6 @@
|
|||
|
||||
#include "alloc.h"
|
||||
|
||||
#define s_malloc hi_malloc
|
||||
#define s_malloc hi_malloc
|
||||
#define s_realloc hi_realloc
|
||||
#define s_free hi_free
|
||||
#define s_free hi_free
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -212,20 +212,19 @@ typedef struct {
|
|||
utarray_inserta(dst, src, utarray_len(dst)); \
|
||||
} while (0)
|
||||
|
||||
#define utarray_erase(a, pos, len) \
|
||||
do { \
|
||||
if ((a)->icd.dtor) { \
|
||||
unsigned _ut_i; \
|
||||
for (_ut_i = 0; _ut_i < (len); _ut_i++) { \
|
||||
(a)->icd.dtor(utarray_eltptr(a, (pos) + _ut_i)); \
|
||||
} \
|
||||
} \
|
||||
if ((a)->i > ((pos) + (len))) { \
|
||||
memmove(_utarray_eltptr(a, pos), \
|
||||
_utarray_eltptr(a, (pos) + (len)), \
|
||||
((a)->i - ((pos) + (len))) * (a)->icd.sz); \
|
||||
} \
|
||||
(a)->i -= (len); \
|
||||
#define utarray_erase(a, pos, len) \
|
||||
do { \
|
||||
if ((a)->icd.dtor) { \
|
||||
unsigned _ut_i; \
|
||||
for (_ut_i = 0; _ut_i < (len); _ut_i++) { \
|
||||
(a)->icd.dtor(utarray_eltptr(a, (pos) + _ut_i)); \
|
||||
} \
|
||||
} \
|
||||
if ((a)->i > ((pos) + (len))) { \
|
||||
memmove( \
|
||||
_utarray_eltptr(a, pos), _utarray_eltptr(a, (pos) + (len)), ((a)->i - ((pos) + (len))) * (a)->icd.sz); \
|
||||
} \
|
||||
(a)->i -= (len); \
|
||||
} while (0)
|
||||
|
||||
#define utarray_renew(a, u) \
|
||||
|
@ -274,8 +273,9 @@ static void utarray_str_cpy(void *dst, const void *src) {
|
|||
}
|
||||
static void utarray_str_dtor(void *elt) {
|
||||
char **eltc = (char **)elt;
|
||||
if (*eltc != NULL)
|
||||
if (*eltc != NULL) {
|
||||
free(*eltc);
|
||||
}
|
||||
}
|
||||
static const UT_icd ut_str_icd UTARRAY_UNUSED = {sizeof(char *), NULL, utarray_str_cpy, utarray_str_dtor};
|
||||
static const UT_icd ut_int_icd UTARRAY_UNUSED = {sizeof(int), NULL, NULL, NULL};
|
||||
|
|
|
@ -226,9 +226,9 @@ typedef unsigned char uint8_t;
|
|||
(head)->hh.tbl->num_buckets = HASH_INITIAL_NUM_BUCKETS; \
|
||||
(head)->hh.tbl->log2_num_buckets = HASH_INITIAL_NUM_BUCKETS_LOG2; \
|
||||
(head)->hh.tbl->hho = (char *)(&(head)->hh) - (char *)(head); \
|
||||
(head)->hh.tbl->buckets = \
|
||||
(UT_hash_bucket *)uthash_malloc(HASH_INITIAL_NUM_BUCKETS * sizeof(struct UT_hash_bucket)); \
|
||||
(head)->hh.tbl->signature = HASH_SIGNATURE; \
|
||||
(head)->hh.tbl->buckets = (UT_hash_bucket *)uthash_malloc(HASH_INITIAL_NUM_BUCKETS \
|
||||
* sizeof(struct UT_hash_bucket)); \
|
||||
(head)->hh.tbl->signature = HASH_SIGNATURE; \
|
||||
if (!(head)->hh.tbl->buckets) { \
|
||||
HASH_RECORD_OOM(oomed); \
|
||||
uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \
|
||||
|
@ -523,10 +523,8 @@ typedef unsigned char uint8_t;
|
|||
_prev = NULL; \
|
||||
while (_thh) { \
|
||||
if (_prev != (char *)(_thh->hh_prev)) { \
|
||||
HASH_OOPS("%s: invalid hh_prev %p, actual %p\n", \
|
||||
(where), \
|
||||
(void *)_thh->hh_prev, \
|
||||
(void *)_prev); \
|
||||
HASH_OOPS( \
|
||||
"%s: invalid hh_prev %p, actual %p\n", (where), (void *)_thh->hh_prev, (void *)_prev); \
|
||||
} \
|
||||
_bkt_count++; \
|
||||
_prev = (char *)(_thh); \
|
||||
|
@ -887,9 +885,9 @@ typedef unsigned char uint8_t;
|
|||
uthash_free((tbl)->buckets, (tbl)->num_buckets * sizeof(struct UT_hash_bucket)); \
|
||||
(tbl)->num_buckets *= 2U; \
|
||||
(tbl)->log2_num_buckets++; \
|
||||
(tbl)->buckets = _he_new_buckets; \
|
||||
(tbl)->ineff_expands = \
|
||||
((tbl)->nonideal_items > ((tbl)->num_items >> 1)) ? ((tbl)->ineff_expands + 1U) : 0U; \
|
||||
(tbl)->buckets = _he_new_buckets; \
|
||||
(tbl)->ineff_expands = ((tbl)->nonideal_items > ((tbl)->num_items >> 1)) ? ((tbl)->ineff_expands + 1U) \
|
||||
: 0U; \
|
||||
if ((tbl)->ineff_expands > 1U) { \
|
||||
(tbl)->noexpand = 1; \
|
||||
uthash_noexpand_fyi(tbl); \
|
||||
|
|
|
@ -152,10 +152,11 @@ UTSTRING_UNUSED static void utstring_printf_va(UT_string *s, const char *fmt, va
|
|||
}
|
||||
|
||||
/* Else try again with more space. */
|
||||
if (n > -1)
|
||||
if (n > -1) {
|
||||
utstring_reserve(s, n + 1); /* exact */
|
||||
else
|
||||
} else {
|
||||
utstring_reserve(s, (s->n) * 2); /* 2x */
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef __GNUC__
|
||||
|
@ -227,8 +228,11 @@ UTSTRING_UNUSED static void _utstring_BuildTableR(const char *P_Needle, size_t P
|
|||
}
|
||||
|
||||
/* Search data from left to right. ( Multiple search mode. ) */
|
||||
UTSTRING_UNUSED static long _utstring_find(const char *P_Haystack, size_t P_HaystackLen, const char *P_Needle,
|
||||
size_t P_NeedleLen, long *P_KMP_Table) {
|
||||
UTSTRING_UNUSED static long _utstring_find(const char *P_Haystack,
|
||||
size_t P_HaystackLen,
|
||||
const char *P_Needle,
|
||||
size_t P_NeedleLen,
|
||||
long *P_KMP_Table) {
|
||||
long i, j;
|
||||
long V_FindPosition = -1;
|
||||
|
||||
|
@ -251,8 +255,11 @@ UTSTRING_UNUSED static long _utstring_find(const char *P_Haystack, size_t P_Hays
|
|||
}
|
||||
|
||||
/* Search data from right to left. ( Multiple search mode. ) */
|
||||
UTSTRING_UNUSED static long _utstring_findR(const char *P_Haystack, size_t P_HaystackLen, const char *P_Needle,
|
||||
size_t P_NeedleLen, long *P_KMP_Table) {
|
||||
UTSTRING_UNUSED static long _utstring_findR(const char *P_Haystack,
|
||||
size_t P_HaystackLen,
|
||||
const char *P_Needle,
|
||||
size_t P_NeedleLen,
|
||||
long *P_KMP_Table) {
|
||||
long i, j;
|
||||
long V_FindPosition = -1;
|
||||
|
||||
|
@ -278,7 +285,8 @@ UTSTRING_UNUSED static long _utstring_findR(const char *P_Haystack, size_t P_Hay
|
|||
/* Search data from left to right. ( One time search mode. ) */
|
||||
UTSTRING_UNUSED static long utstring_find(UT_string *s,
|
||||
long P_StartPosition, /* Start from 0. -1 means last position. */
|
||||
const char *P_Needle, size_t P_NeedleLen) {
|
||||
const char *P_Needle,
|
||||
size_t P_NeedleLen) {
|
||||
long V_StartPosition;
|
||||
long V_HaystackLen;
|
||||
long *V_KMP_Table;
|
||||
|
@ -310,7 +318,8 @@ UTSTRING_UNUSED static long utstring_find(UT_string *s,
|
|||
/* Search data from right to left. ( One time search mode. ) */
|
||||
UTSTRING_UNUSED static long utstring_findR(UT_string *s,
|
||||
long P_StartPosition, /* Start from 0. -1 means last position. */
|
||||
const char *P_Needle, size_t P_NeedleLen) {
|
||||
const char *P_Needle,
|
||||
size_t P_NeedleLen) {
|
||||
long V_StartPosition;
|
||||
long V_HaystackLen;
|
||||
long *V_KMP_Table;
|
||||
|
|
|
@ -12,11 +12,11 @@
|
|||
#define SRC_ZVECTOR_H_
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Requires standard C libraries:
|
||||
|
@ -32,7 +32,7 @@ extern "C"{
|
|||
#include "zvector_config.h"
|
||||
|
||||
// Declare required structs:
|
||||
typedef struct p_vector * vector;
|
||||
typedef struct p_vector *vector;
|
||||
|
||||
// Declare required enums:
|
||||
|
||||
|
@ -52,23 +52,24 @@ typedef struct p_vector * vector;
|
|||
* its reference will also be fully zeroed out before freeing it.
|
||||
*/
|
||||
enum ZVECT_PROPERTIES {
|
||||
ZV_NONE = 0, // Sets or Resets all vector's properties to 0.
|
||||
ZV_SEC_WIPE = 1 << 0, // Sets the vector for automatic Secure Wipe of items.
|
||||
ZV_BYREF = 1 << 1, // Sets the vector to store items by reference instead of copying them as per default.
|
||||
ZV_CIRCULAR = 1 << 2, // Sets the vector to be a circular vector (so it will not grow in capacity automatically). Elements will be overwritten as in typical circular buffers!
|
||||
ZV_NOLOCKING = 1 << 3, // This Property means the vector will not use mutexes, be careful using it!
|
||||
ZV_NONE = 0, // Sets or Resets all vector's properties to 0.
|
||||
ZV_SEC_WIPE = 1 << 0, // Sets the vector for automatic Secure Wipe of items.
|
||||
ZV_BYREF = 1 << 1, // Sets the vector to store items by reference instead of copying them as per default.
|
||||
ZV_CIRCULAR = 1
|
||||
<< 2, // Sets the vector to be a circular vector (so it will not grow in capacity automatically). Elements will be overwritten as in typical circular buffers!
|
||||
ZV_NOLOCKING = 1 << 3, // This Property means the vector will not use mutexes, be careful using it!
|
||||
};
|
||||
|
||||
enum ZVECT_ERR {
|
||||
ZVERR_VECTUNDEF = -1,
|
||||
ZVERR_IDXOUTOFBOUND = -2,
|
||||
ZVERR_OUTOFMEM = -3,
|
||||
ZVERR_VECTCORRUPTED = -4,
|
||||
ZVERR_RACECOND = -5,
|
||||
ZVERR_VECTTOOSMALL = -6,
|
||||
ZVERR_VECTDATASIZE = -7,
|
||||
ZVERR_VECTEMPTY = -8,
|
||||
ZVERR_OPNOTALLOWED = -9
|
||||
ZVERR_VECTUNDEF = -1,
|
||||
ZVERR_IDXOUTOFBOUND = -2,
|
||||
ZVERR_OUTOFMEM = -3,
|
||||
ZVERR_VECTCORRUPTED = -4,
|
||||
ZVERR_RACECOND = -5,
|
||||
ZVERR_VECTTOOSMALL = -6,
|
||||
ZVERR_VECTDATASIZE = -7,
|
||||
ZVERR_VECTEMPTY = -8,
|
||||
ZVERR_OPNOTALLOWED = -9
|
||||
};
|
||||
|
||||
/*****************************
|
||||
|
@ -137,7 +138,7 @@ bool vect_set_status(const vector v, zvect_index flag_id);
|
|||
|
||||
bool vect_clear_status(const vector v, zvect_index flag_id);
|
||||
|
||||
#if ( ZVECT_THREAD_SAFE == 1 )
|
||||
#if (ZVECT_THREAD_SAFE == 1)
|
||||
// Vector Thread Safe functions:
|
||||
|
||||
/*
|
||||
|
@ -201,10 +202,11 @@ zvect_retval vect_unlock(vector const v);
|
|||
* zvect_retval vect_lock_after_signal(const vector v);
|
||||
*/
|
||||
|
||||
zvect_retval vect_move_on_signal(vector const v1, vector v2,
|
||||
const zvect_index s2,
|
||||
const zvect_index e2,
|
||||
zvect_retval (*f2)(void *, void *));
|
||||
zvect_retval vect_move_on_signal(vector const v1,
|
||||
vector v2,
|
||||
const zvect_index s2,
|
||||
const zvect_index e2,
|
||||
zvect_retval (*f2)(void *, void *));
|
||||
|
||||
zvect_retval vect_send_signal(const vector v);
|
||||
|
||||
|
@ -214,7 +216,7 @@ zvect_retval vect_sem_wait(const vector v);
|
|||
|
||||
zvect_retval vect_sem_post(const vector v);
|
||||
|
||||
#endif // ( ZVECT_THREAD_SAFE == 1 )
|
||||
#endif // ( ZVECT_THREAD_SAFE == 1 )
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
// Vector Data Storage functions:
|
||||
|
@ -229,7 +231,7 @@ zvect_retval vect_sem_post(const vector v);
|
|||
* corresponds to the top of a
|
||||
* Stack.
|
||||
*/
|
||||
void vect_push(vector const v, const void *item);
|
||||
void vect_push(vector const v, const void *item);
|
||||
|
||||
/*
|
||||
* vect_pop(v) "pops" (returns) the element
|
||||
|
@ -290,7 +292,7 @@ void vect_add_front(vector const v, const void *item);
|
|||
* vect_pop(v)).
|
||||
*/
|
||||
void *vect_get(vector const v);
|
||||
#define vect_back(v) vect_get(v)
|
||||
#define vect_back(v) vect_get(v)
|
||||
|
||||
/*
|
||||
*
|
||||
|
@ -298,14 +300,14 @@ void *vect_get(vector const v);
|
|||
* 3 in the vector v.
|
||||
*/
|
||||
void *vect_get_at(vector const v, const zvect_index i);
|
||||
#define vect_at(v, x) vect_get_at(v, x)
|
||||
#define vect_at(v, x) vect_get_at(v, x)
|
||||
|
||||
/*
|
||||
* vect_get_front(v) will return the first element in
|
||||
* the vector v.
|
||||
*/
|
||||
void *vect_get_front(vector const v);
|
||||
#define vect_front(v) vect_get_front(v)
|
||||
#define vect_front(v) vect_get_front(v)
|
||||
|
||||
/*
|
||||
*vect_put allows you to REPLACE an item
|
||||
|
@ -458,7 +460,7 @@ void vect_rotate_right(vector const v, const zvect_index i);
|
|||
* pointers to your datastructures stored in the vector.
|
||||
*
|
||||
*/
|
||||
void vect_qsort(vector const v, int (*compare_func)(const void *, const void*));
|
||||
void vect_qsort(vector const v, int (*compare_func)(const void *, const void *));
|
||||
|
||||
/*
|
||||
* vect_bsearch is a function that allows to perform
|
||||
|
@ -479,11 +481,11 @@ void vect_qsort(vector const v, int (*compare_func)(const void *, const void*));
|
|||
* vect_bsearch(v, &i, my_compare);
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
extern "C" {
|
||||
#endif
|
||||
bool vect_bsearch(vector const v, const void *key, int (*f1)(const void *, const void *), zvect_index *item_index);
|
||||
bool vect_bsearch(vector const v, const void *key, int (*f1)(const void *, const void *), zvect_index *item_index);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
* vect_add_ordered allows the insertion of new items in
|
||||
|
@ -504,7 +506,7 @@ void vect_qsort(vector const v, int (*compare_func)(const void *, const void*));
|
|||
*/
|
||||
void vect_add_ordered(vector const v, const void *value, int (*f1)(const void *, const void *));
|
||||
|
||||
#endif // ZVECT_DMF_EXTENSIONS
|
||||
#endif // ZVECT_DMF_EXTENSIONS
|
||||
|
||||
#ifdef ZVECT_SFMD_EXTENSIONS
|
||||
// Single Function Multiple Data extensions:
|
||||
|
@ -591,8 +593,7 @@ void vect_copy(vector const v1, vector const v2, zvect_index start, zvect_index
|
|||
* you'll have such items "inserted"
|
||||
* inside v1.
|
||||
*/
|
||||
void vect_insert(vector const v1, vector const v2, const zvect_index s2,
|
||||
const zvect_index e2, const zvect_index s1);
|
||||
void vect_insert(vector const v1, vector const v2, const zvect_index s2, const zvect_index e2, const zvect_index s1);
|
||||
|
||||
/*
|
||||
* vect_move is a function that allows to move a specified
|
||||
|
@ -623,8 +624,11 @@ void vect_move(vector const v1, vector const v2, zvect_index start, zvect_index
|
|||
* the end of v1 if check_data returns
|
||||
* true.
|
||||
*/
|
||||
zvect_retval vect_move_if(vector const v1, vector v2, const zvect_index s2,
|
||||
const zvect_index e2, zvect_retval (*f2)(void *, void *));
|
||||
zvect_retval vect_move_if(vector const v1,
|
||||
vector v2,
|
||||
const zvect_index s2,
|
||||
const zvect_index e2,
|
||||
zvect_retval (*f2)(void *, void *));
|
||||
|
||||
/*
|
||||
* vect_merge is a function that merges together 2 vectors of
|
||||
|
@ -638,10 +642,10 @@ zvect_retval vect_move_if(vector const v1, vector v2, const zvect_index s2,
|
|||
*/
|
||||
void vect_merge(vector const v1, vector v2);
|
||||
|
||||
#endif // ZVECT_SFMD_EXTENSIONS
|
||||
#endif // ZVECT_SFMD_EXTENSIONS
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // SRC_ZVECTOR_H_
|
||||
#endif // SRC_ZVECTOR_H_
|
||||
|
|
|
@ -17,128 +17,122 @@
|
|||
|
||||
// Try to determine the Operating System being used:
|
||||
#if defined(__APPLE__) && defined(__MACH__)
|
||||
# define macOS
|
||||
#define macOS
|
||||
#endif
|
||||
|
||||
#if ( defined(__GNU__) || defined(__gnu_linux__) || \
|
||||
defined(__linux__) || defined(macOS) )
|
||||
# define OS_TYPE 1
|
||||
#elif ( defined(__WIN32__) || defined(WIN32) || defined(_WIN32) )
|
||||
# define OS_TYPE 2
|
||||
#if (defined(__GNU__) || defined(__gnu_linux__) || defined(__linux__) || defined(macOS))
|
||||
#define OS_TYPE 1
|
||||
#elif (defined(__WIN32__) || defined(WIN32) || defined(_WIN32))
|
||||
#define OS_TYPE 2
|
||||
#else
|
||||
# define OS_TYPE 0
|
||||
#define OS_TYPE 0
|
||||
#endif
|
||||
|
||||
// Try to determine compiler being used:
|
||||
#if defined(__GNUC__)
|
||||
# define compiler gcc
|
||||
# define ZVECT_COMPTYPE 1
|
||||
# define COMP_MAJRELEASE (__GNUC__)
|
||||
# define COMP_MINRELEASE (__GNUC_MINOR__)
|
||||
# define COMP_PATRELEASE (__GNUC_PATCHLEVEL__)
|
||||
#define compiler gcc
|
||||
#define ZVECT_COMPTYPE 1
|
||||
#define COMP_MAJRELEASE (__GNUC__)
|
||||
#define COMP_MINRELEASE (__GNUC_MINOR__)
|
||||
#define COMP_PATRELEASE (__GNUC_PATCHLEVEL__)
|
||||
#elif defined(_MSC_VER)
|
||||
# define compiler msc
|
||||
# define ZVECT_COMPTYPE 2
|
||||
# define COMP_MAJRELEASE (_MSC_VER)
|
||||
# define COMP_MINRELEASE 0
|
||||
# define COMP_PATRELEASE 0
|
||||
#define compiler msc
|
||||
#define ZVECT_COMPTYPE 2
|
||||
#define COMP_MAJRELEASE (_MSC_VER)
|
||||
#define COMP_MINRELEASE 0
|
||||
#define COMP_PATRELEASE 0
|
||||
#elif defined(__clang__)
|
||||
# define compiler clang
|
||||
# define ZVECT_COMPTYPE 3
|
||||
# define COMP_MAJRELEASE (__clang_major__)
|
||||
# define COMP_MINRELEASE (__clang_minor__)
|
||||
# define COMP_PATRELEASE (__clang_patchlevel__)
|
||||
#elif defined(__INTEL_COMPILER) || defined(__ICC) || \
|
||||
defined(__ECC) || defined(__ICL)
|
||||
#define compiler clang
|
||||
#define ZVECT_COMPTYPE 3
|
||||
#define COMP_MAJRELEASE (__clang_major__)
|
||||
#define COMP_MINRELEASE (__clang_minor__)
|
||||
#define COMP_PATRELEASE (__clang_patchlevel__)
|
||||
#elif defined(__INTEL_COMPILER) || defined(__ICC) || defined(__ECC) || defined(__ICL)
|
||||
// For intel c compiler please remember to specify:
|
||||
// /Qstd=c99 (on Windows)
|
||||
// -std=c99 on Linux and/or macOS
|
||||
# define compiler intelc
|
||||
# define ZVECT_COMPTYPE 4
|
||||
# define COMP_MAJRELEASE (__INTEL_COMPILER)
|
||||
# define COMP_MINRELEASE 0
|
||||
# define COMP_PATRELEASE 0
|
||||
#elif defined (__LCC__)
|
||||
# define compiler lcc
|
||||
# define ZVECT_COMPTYPE 5
|
||||
# define COMP_MAJRELEASE (__LCC)
|
||||
# define COMP_MINRELEASE 0
|
||||
# define COMP_PATRELEASE 0
|
||||
#elif defined(__NORCROFT_C__) || defined(__CC_NORCROFT) || \
|
||||
defined(__ARMCC_VERSION)
|
||||
#define compiler intelc
|
||||
#define ZVECT_COMPTYPE 4
|
||||
#define COMP_MAJRELEASE (__INTEL_COMPILER)
|
||||
#define COMP_MINRELEASE 0
|
||||
#define COMP_PATRELEASE 0
|
||||
#elif defined(__LCC__)
|
||||
#define compiler lcc
|
||||
#define ZVECT_COMPTYPE 5
|
||||
#define COMP_MAJRELEASE (__LCC)
|
||||
#define COMP_MINRELEASE 0
|
||||
#define COMP_PATRELEASE 0
|
||||
#elif defined(__NORCROFT_C__) || defined(__CC_NORCROFT) || defined(__ARMCC_VERSION)
|
||||
// For Norcroft C please remember to specify:
|
||||
// -c99
|
||||
# define compiler norcroftc
|
||||
# define ZVECT_COMPTYPE 6
|
||||
# define COMP_MAJRELEASE (__ARMCC_VERSION)
|
||||
#define compiler norcroftc
|
||||
#define ZVECT_COMPTYPE 6
|
||||
#define COMP_MAJRELEASE (__ARMCC_VERSION)
|
||||
#elif defined(_CRAYC)
|
||||
// For Cray C please remember to specify:
|
||||
// -hc99
|
||||
# define compiler crayc
|
||||
# define ZVECT_COMPTYPE 10
|
||||
# define COMP_MAJRELEASE (_RELEASE)
|
||||
# define COMP_MINRELEASE (_RELEASE_MINOR)
|
||||
# define COMP_PATRELEASE 0
|
||||
#define compiler crayc
|
||||
#define ZVECT_COMPTYPE 10
|
||||
#define COMP_MAJRELEASE (_RELEASE)
|
||||
#define COMP_MINRELEASE (_RELEASE_MINOR)
|
||||
#define COMP_PATRELEASE 0
|
||||
#elif defined(__HP_cc)
|
||||
// For HP CC please remember to specify:
|
||||
// -ansi -std=c99
|
||||
# define compiler hpc
|
||||
# define ZVECT_COMPTYPE 11
|
||||
# define COMP_MAJRELEASE 1
|
||||
# define COMP_MINRELEASE 21
|
||||
# define COMP_PATRELEASE 0
|
||||
#define compiler hpc
|
||||
#define ZVECT_COMPTYPE 11
|
||||
#define COMP_MAJRELEASE 1
|
||||
#define COMP_MINRELEASE 21
|
||||
#define COMP_PATRELEASE 0
|
||||
#elif defined(__IBMC__)
|
||||
// For IBM C please remember to specify:
|
||||
// C99 flags
|
||||
# define compiler ibmc
|
||||
# define ZVECT_COMPTYPE 12
|
||||
#define compiler ibmc
|
||||
#define ZVECT_COMPTYPE 12
|
||||
#elif defined(__TINYC__)
|
||||
# define compiler tinyc
|
||||
# define ZVECT_COMPTYPE 6
|
||||
# define COMP_MAJRELEASE 0
|
||||
# define COMP_MINRELEASE 0
|
||||
# define COMP_PATRELEASE 0
|
||||
#define compiler tinyc
|
||||
#define ZVECT_COMPTYPE 6
|
||||
#define COMP_MAJRELEASE 0
|
||||
#define COMP_MINRELEASE 0
|
||||
#define COMP_PATRELEASE 0
|
||||
#else
|
||||
# define compiler unknown
|
||||
# define ZVECT_COMPTYPE 0
|
||||
#define compiler unknown
|
||||
#define ZVECT_COMPTYPE 0
|
||||
#endif
|
||||
|
||||
// Try to determine CPU Architecture:
|
||||
#if defined(__aarch64__)
|
||||
# define CPU_TYPE ARM64
|
||||
# define Arch64
|
||||
#define CPU_TYPE ARM64
|
||||
#define Arch64
|
||||
#elif defined(__aarch32__)
|
||||
# define CPU_TYPE ARM32
|
||||
# define Arch32
|
||||
#elif defined(__amd64__) || defined(__x86_64__) || \
|
||||
defined(__ia64__) || defined(_M_IA64) || \
|
||||
defined(_M_AMD64) || defined(_M_X64)
|
||||
# define CPU_TYPE x86_64
|
||||
# define Arch64
|
||||
#define CPU_TYPE ARM32
|
||||
#define Arch32
|
||||
#elif defined(__amd64__) || defined(__x86_64__) || defined(__ia64__) || defined(_M_IA64) || defined(_M_AMD64) \
|
||||
|| defined(_M_X64)
|
||||
#define CPU_TYPE x86_64
|
||||
#define Arch64
|
||||
#else
|
||||
# define CPU_TYPE unknown
|
||||
# define Arch32
|
||||
#define CPU_TYPE unknown
|
||||
#define Arch32
|
||||
#endif
|
||||
|
||||
// Start setting up macros based on the platform we detected
|
||||
// above.
|
||||
|
||||
#if ( OS_TYPE == 1 )
|
||||
// We are on a Unix-like OS so we can use pthreads!
|
||||
# define MUTEX_TYPE 1
|
||||
# elif ( OS_TYPE == 2 ) && ( defined(__CYGWIN__) || \
|
||||
defined(__MINGW32__) || defined(__MINGW64__) )
|
||||
// We are on MS Windows using CIGWIN so we can use pthreads!
|
||||
# define MUTEX_TYPE 1
|
||||
# elif ( OS_TYPE == 2 ) && ( !defined(__CYGWIN__) && \
|
||||
!defined(__MINGW32__) && !defined(__MINGW64__) )
|
||||
// We are on MS Windows, so we need to use
|
||||
// Windows stuff:
|
||||
# define MUTEX_TYPE 2
|
||||
#if (OS_TYPE == 1)
|
||||
// We are on a Unix-like OS so we can use pthreads!
|
||||
#define MUTEX_TYPE 1
|
||||
#elif (OS_TYPE == 2) && (defined(__CYGWIN__) || defined(__MINGW32__) || defined(__MINGW64__))
|
||||
// We are on MS Windows using CIGWIN so we can use pthreads!
|
||||
#define MUTEX_TYPE 1
|
||||
#elif (OS_TYPE == 2) && (!defined(__CYGWIN__) && !defined(__MINGW32__) && !defined(__MINGW64__))
|
||||
// We are on MS Windows, so we need to use
|
||||
// Windows stuff:
|
||||
#define MUTEX_TYPE 2
|
||||
#else
|
||||
// I have no idea on which platform are we,
|
||||
// hence I have to use fake mutexes and go with the flow!
|
||||
# define MUTEX_TYPE 0
|
||||
// I have no idea on which platform are we,
|
||||
// hence I have to use fake mutexes and go with the flow!
|
||||
#define MUTEX_TYPE 0
|
||||
#endif
|
||||
|
||||
#endif // SRC_ZVECTOR_CHECKS_H_
|
||||
#endif // SRC_ZVECTOR_CHECKS_H_
|
||||
|
|
|
@ -19,10 +19,10 @@
|
|||
#include <stdbool.h>
|
||||
|
||||
// Data alignment configuration
|
||||
#if ( ZVECT_COMPTYPE == 1 )
|
||||
#define ZVECT_DATAALIGN __attribute__((aligned))
|
||||
#define ZVECT_PACKING __attribute__((__packed__))
|
||||
#define ZVECT_ALWAYSINLINE __attribute__ ((__always_inline__))
|
||||
#if (ZVECT_COMPTYPE == 1)
|
||||
#define ZVECT_DATAALIGN __attribute__((aligned))
|
||||
#define ZVECT_PACKING __attribute__((__packed__))
|
||||
#define ZVECT_ALWAYSINLINE __attribute__((__always_inline__))
|
||||
#else
|
||||
#define ZVECT_DATAALIGN
|
||||
#define ZVECT_PACKING
|
||||
|
@ -36,8 +36,9 @@
|
|||
// If you want a larger index you can
|
||||
// change it to, for example, uint64_t
|
||||
typedef uint32_t zvect_index;
|
||||
#define zvect_index_max 4294967295 // If you change zvect_index type make sure you update this value
|
||||
// it's the maximum number that can be stored in a zvect_index.
|
||||
#define zvect_index_max \
|
||||
4294967295 // If you change zvect_index type make sure you update this value \
|
||||
// it's the maximum number that can be stored in a zvect_index.
|
||||
|
||||
// Default vector return type for
|
||||
// error codes.
|
||||
|
@ -81,4 +82,4 @@ typedef int32_t zvect_retval;
|
|||
// Enable/Disable SFMD Extensions:
|
||||
#define ZVECT_SFMD_EXTENSIONS 1
|
||||
|
||||
#endif // SRC_ZVECTOR_CONFIG_H_
|
||||
#endif // SRC_ZVECTOR_CONFIG_H_
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -183,7 +183,10 @@ int str_to_ipaddr(const char *pIp, unsigned int *ipAddr) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
int get_nic_info(const char *pName, unsigned int *pIp, unsigned int *pNetmask, unsigned int *pGateway,
|
||||
int get_nic_info(const char *pName,
|
||||
unsigned int *pIp,
|
||||
unsigned int *pNetmask,
|
||||
unsigned int *pGateway,
|
||||
unsigned char *pMac) {
|
||||
int sock;
|
||||
struct ifreq ifr;
|
||||
|
@ -234,7 +237,7 @@ int get_nic_info(const char *pName, unsigned int *pIp, unsigned int *pNetmask, u
|
|||
return err;
|
||||
}
|
||||
|
||||
const char*get_cur_process_name() {
|
||||
const char *get_cur_process_name() {
|
||||
static char g_exeName[1024];
|
||||
|
||||
memset(g_exeName, 0, 1024);
|
||||
|
|
1014
srcs/libs/misc/sds.c
1014
srcs/libs/misc/sds.c
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -229,9 +229,9 @@ PMQ_DATA_ADD_USER decode_add_user_msg(const char *pStrJson, PMQ_DATA_ADD_USER *p
|
|||
int j;
|
||||
memset(pCurrent->pUser, 0, sizeof(ADD_USER_USER) * nUser);
|
||||
for (j = 0; j < nUser; j++) {
|
||||
PADD_USER_USER p = &pCurrent->pUser[j];
|
||||
cJSON *pJsonU = cJSON_GetArrayItem(puser, j);
|
||||
PADD_USER_USER pTmp = j2s_add_user(pJsonU);
|
||||
PADD_USER_USER p = &pCurrent->pUser[j];
|
||||
cJSON *pJsonU = cJSON_GetArrayItem(puser, j);
|
||||
PADD_USER_USER pTmp = j2s_add_user(pJsonU);
|
||||
|
||||
if (pTmp) {
|
||||
memcpy(p, pTmp, sizeof(ADD_USER_USER));
|
||||
|
|
|
@ -105,7 +105,7 @@ int mq_init(void) {
|
|||
return ERR_SUCCESS;
|
||||
}
|
||||
|
||||
void* get_mq_context() {
|
||||
void *get_mq_context() {
|
||||
return g_pContext;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
int http_svr_init() {
|
||||
configuration config;
|
||||
config.http_listen_address = (char*)config_get_http_server_addr();
|
||||
config.http_listen_address = (char *)config_get_http_server_addr();
|
||||
config.http_listen_port = config_get_http_server_port();
|
||||
config.thread_count = 0;
|
||||
config.parser = "http_parser";
|
||||
|
|
|
@ -54,7 +54,7 @@ typedef struct {
|
|||
unsigned int uRetryTimes;
|
||||
PHTTP_REQ_PARAMS pCurlItem;
|
||||
|
||||
UT_hash_handle hh;///< UT Hash handle
|
||||
UT_hash_handle hh; ///< UT Hash handle
|
||||
} CURL_HANDLE_TBL, *PCURL_HANDLE_TBL;
|
||||
|
||||
static uv_timer_t g_uvCurlTm;
|
||||
|
@ -229,10 +229,8 @@ static void checkMultiInfo(void) {
|
|||
pReq->errCode = 0;
|
||||
}
|
||||
|
||||
uv_fs_fdatasync(get_task_manager(),
|
||||
&pReq->uvFsDataSync,
|
||||
(uv_file)pReq->uvFsOpen.result,
|
||||
uvFsDataSyncCb);
|
||||
uv_fs_fdatasync(
|
||||
get_task_manager(), &pReq->uvFsDataSync, (uv_file)pReq->uvFsOpen.result, uvFsDataSyncCb);
|
||||
} else if (pReq->type == INET_HTTP_WEBSERVICE_POST) {
|
||||
if (pMsg->data.result != CURLE_OK) {
|
||||
if (pReq->onRspCb && pReq->isCancel == FALSE) {
|
||||
|
@ -402,13 +400,8 @@ static size_t writeDataCb(void *pData, size_t size, size_t nmemb, void *pParams)
|
|||
|
||||
pReq->uvFsBuf = uv_buf_init(pData, iMemSize);
|
||||
|
||||
wr = uv_fs_write(get_task_manager(),
|
||||
&pReq->uvFsWrite,
|
||||
(uv_file)pReq->uvFsOpen.result,
|
||||
&pReq->uvFsBuf,
|
||||
1,
|
||||
-1,
|
||||
NULL);
|
||||
wr = uv_fs_write(
|
||||
get_task_manager(), &pReq->uvFsWrite, (uv_file)pReq->uvFsOpen.result, &pReq->uvFsBuf, 1, -1, NULL);
|
||||
|
||||
if (wr > 0) {
|
||||
pReq->dlSize += wr;
|
||||
|
@ -440,10 +433,8 @@ static int progressCb(void *pData, double total, double now, double UNUSED(ulTot
|
|||
|
||||
if (pParams->onPrgCb) {
|
||||
if (pParams->type == INET_HTTP_DOWNLOAD_FILE) {
|
||||
pParams->onPrgCb(pParams->pReqUrl,
|
||||
pParams->pTaskUuid,
|
||||
(unsigned char)(now * 100.0 / total),
|
||||
pParams->pData);
|
||||
pParams->onPrgCb(
|
||||
pParams->pReqUrl, pParams->pTaskUuid, (unsigned char)(now * 100.0 / total), pParams->pData);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -554,8 +545,11 @@ static void onDlTimeoutCb(uv_timer_t *UNUSED(pufTimer)) {
|
|||
}
|
||||
}
|
||||
|
||||
const char *inet_download_file_async(const char *pURL, const char *pPath, on_http_response onRespCb,
|
||||
on_progress_changed onProgressCb, void *pData) {
|
||||
const char *inet_download_file_async(const char *pURL,
|
||||
const char *pPath,
|
||||
on_http_response onRespCb,
|
||||
on_progress_changed onProgressCb,
|
||||
void *pData) {
|
||||
CURLMcode ret;
|
||||
uuid_t msgId;
|
||||
char strMsgId[64];
|
||||
|
@ -614,12 +608,8 @@ const char *inet_download_file_async(const char *pURL, const char *pPath, on_htt
|
|||
|
||||
dzlog_debug("[%s]: File %s used temp path %s\n", pParams->pTaskUuid, pParams->sPath, pParams->sDlPath);
|
||||
|
||||
uv_fs_open(get_task_manager(),
|
||||
&pParams->uvFsOpen,
|
||||
pParams->sDlPath,
|
||||
O_RDWR | O_CREAT | O_TRUNC,
|
||||
S_IRUSR | S_IWUSR,
|
||||
NULL);
|
||||
uv_fs_open(
|
||||
get_task_manager(), &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_WRITEDATA, pParams);
|
||||
|
@ -631,8 +621,8 @@ const char *inet_download_file_async(const char *pURL, const char *pPath, on_htt
|
|||
curl_easy_setopt(pCurl, CURLOPT_PROGRESSDATA, pParams);
|
||||
|
||||
//curl_easy_setopt(pCurl, CURLOPT_TIMEOUT, 1800L); // Max download times (30 minutes)1800s
|
||||
curl_easy_setopt(pCurl, CURLOPT_LOW_SPEED_LIMIT, 10000L);// 10K bytes
|
||||
curl_easy_setopt(pCurl, CURLOPT_LOW_SPEED_TIME, 10L); // 30 seconds
|
||||
curl_easy_setopt(pCurl, CURLOPT_LOW_SPEED_LIMIT, 10000L); // 10K bytes
|
||||
curl_easy_setopt(pCurl, CURLOPT_LOW_SPEED_TIME, 10L); // 30 seconds
|
||||
|
||||
curl_easy_setopt(pCurl, CURLOPT_CONNECTTIMEOUT, 10L);
|
||||
//curl_easy_setopt(pCurl, CURLOPT_CONNECTTIMEOUT_MS, 10L);
|
||||
|
|
Loading…
Reference in New Issue