OCT 1. 更新格式化代码

This commit is contained in:
huangxin 2022-12-02 14:42:15 +08:00
parent f82cb95c05
commit abd393322d
35 changed files with 6334 additions and 6149 deletions

View File

@ -2,6 +2,7 @@
Language: Cpp Language: Cpp
AccessModifierOffset: -4 AccessModifierOffset: -4
InsertBraces: true InsertBraces: true
AlignArrayOfStructures: Left
AlignAfterOpenBracket: Align AlignAfterOpenBracket: Align
AlignConsecutiveMacros: Consecutive AlignConsecutiveMacros: Consecutive
AlignConsecutiveAssignments: Consecutive AlignConsecutiveAssignments: Consecutive
@ -26,8 +27,9 @@ AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: MultiLine AlwaysBreakTemplateDeclarations: MultiLine
AttributeMacros: AttributeMacros:
- __capability - __capability
- __unused
BinPackArguments: false BinPackArguments: false
BinPackParameters: true BinPackParameters: false
BraceWrapping: BraceWrapping:
AfterCaseLabel: false AfterCaseLabel: false
AfterClass: false AfterClass: false
@ -57,7 +59,7 @@ BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true BreakStringLiterals: true
ColumnLimit: 140 ColumnLimit: 120
CommentPragmas: '^ IWYU pragma:' CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: true CompactNamespaces: true
ConstructorInitializerAllOnOneLineOrOnePerLine: true ConstructorInitializerAllOnOneLineOrOnePerLine: true
@ -174,7 +176,7 @@ SpaceAroundPointerQualifiers: Default
SpaceBeforeRangeBasedForLoopColon: true SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyBlock: false SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 0 SpacesBeforeTrailingComments: 4
SpacesInAngles: false SpacesInAngles: false
SpacesInConditionalStatement: false SpacesInConditionalStatement: false
SpacesInContainerLiterals: false SpacesInContainerLiterals: false
@ -199,3 +201,6 @@ WhitespaceSensitiveMacros:
- BOOST_PP_STRINGIZE - BOOST_PP_STRINGIZE
- NS_SWIFT_NAME - NS_SWIFT_NAME
- CF_SWIFT_NAME - CF_SWIFT_NAME
TypenameMacros:
- CONFIG_ITEM
- PCONFIG_ITEM

View File

@ -47,7 +47,7 @@ IF (USED_SQLITE)
-DSQLITE_HAVE_ZLIB=1 -DSQLITE_TEMP_STORE=2") -DSQLITE_HAVE_ZLIB=1 -DSQLITE_TEMP_STORE=2")
ENDIF () ENDIF ()
ADD_DEFINITIONS(-DBUILD_VERSION="${GIT_VERSION}" ${COMMON_DEFINE}) ADD_DEFINITIONS(-DBUILD_VERSION= "${GIT_VERSION}" ${COMMON_DEFINE})
LINK_LIBRARIES(${COMMON_LIBS}) LINK_LIBRARIES(${COMMON_LIBS})
ADD_LIBRARY(${LIB_PROJECT_TARGET} ${C_SRC} ${C_HEADS}) ADD_LIBRARY(${LIB_PROJECT_TARGET} ${C_SRC} ${C_HEADS})

File diff suppressed because it is too large Load Diff

View File

@ -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_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_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); 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); 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); 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); 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); 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); 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); 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, ARG_EXTERN struct arg_rex *arg_rex0(const char *shortopts,
const char *datatype, int flags, const char *glossary); const char *longopts,
ARG_EXTERN struct arg_rex *arg_rex1(const char *shortopts, const char *longopts, const char *pattern, const char *pattern,
const char *datatype, int flags, const char *glossary); const char *datatype,
ARG_EXTERN struct arg_rex *arg_rexn(const char *shortopts, const char *longopts, const char *pattern, int flags,
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,
const char *glossary); const char *glossary);
ARG_EXTERN struct arg_file *arg_file1(const char *shortopts, const char *longopts, const char *datatype, 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); 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, ARG_EXTERN struct arg_file *arg_file0(const char *shortopts,
const char *datatype, const char *glossary); const char *longopts,
ARG_EXTERN struct arg_date *arg_date1(const char *shortopts, const char *longopts, const char *format, const char *datatype,
const char *datatype, const char *glossary); const char *glossary);
ARG_EXTERN struct arg_date *arg_daten(const char *shortopts, const char *longopts, const char *format, ARG_EXTERN struct arg_file *arg_file1(const char *shortopts,
const char *datatype, int mincount, int maxcount, const char *glossary); 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_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); ARG_EXTERN struct arg_end *arg_end(int maxerrors);
@ -242,14 +302,20 @@ ARG_EXTERN struct arg_end *arg_end(int maxerrors);
/**** other functions *******************************************/ /**** other functions *******************************************/
ARG_EXTERN int arg_nullcheck(void **argtable); ARG_EXTERN int arg_nullcheck(void **argtable);
ARG_EXTERN int arg_parse(int argc, char **argv, 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); const char *suffix);
ARG_EXTERN void arg_print_syntax(FILE *fp, void **argtable, 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_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(FILE *fp, void **argtable, const char *format);
ARG_EXTERN void arg_print_glossary_gnu(FILE *fp, void **argtable); 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_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); const char *suffix);
ARG_EXTERN void arg_print_syntax_ds(arg_dstr_t ds, void **argtable, 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); ARG_EXTERN void arg_print_syntaxv_ds(arg_dstr_t ds, void **argtable, const char *suffix);
@ -285,8 +351,13 @@ 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_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_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 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, ARG_EXTERN int arg_make_syntax_err_help_msg(arg_dstr_t ds,
struct arg_end *end, int *exitcode); 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_name(const char *name);
ARG_EXTERN void arg_set_module_version(int major, int minor, int patch, const char *tag); ARG_EXTERN void arg_set_module_version(int major, int minor, int patch, const char *tag);

View File

@ -38,8 +38,8 @@ typedef struct __ARG_TBL_INFO {
static PARG_TBL_INFO g_pArgTbl = NULL; static PARG_TBL_INFO g_pArgTbl = NULL;
static unsigned int g_nArgTbl = 0; static unsigned int g_nArgTbl = 0;
static const char *g_toolsKey[][2] = { static const char *g_toolsKey[][2] = {
{"cfg_all", "get all configuration information"}, {"cfg_all", "get all configuration information" },
{"mem_info", "show the memory alloc information"}, {"mem_info", "show the memory alloc information" },
{"sys_info", "show the system and hardware information"}, {"sys_info", "show the system and hardware information"},
}; };

View File

@ -17,7 +17,7 @@ const vector config_get_dhcp_replication_svr() {
} }
#endif #endif
const char* config_get_http_server_addr() { const char *config_get_http_server_addr() {
return cfg_get_string_value(CFG_HTTP_SVR_ADDR); return cfg_get_string_value(CFG_HTTP_SVR_ADDR);
} }

View File

@ -77,7 +77,11 @@ 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, int evp_add_crypto_task(CRYPTO_TYPE type,
unsigned char *pInBuf,
unsigned int iSize,
unsigned char *pOutBuf,
char *pKey,
on_evp_crypto onEvpCryptCb) { on_evp_crypto onEvpCryptCb) {
uv_work_t *puvWork = NULL; uv_work_t *puvWork = NULL;
PCRYPT_TASK_PARAMS pTask = NULL; PCRYPT_TASK_PARAMS pTask = NULL;

View File

@ -92,7 +92,10 @@ int hash_digest_file(HASH_TYPE hashType, const char *pFileName, char **pHashValu
* @param pHashValue * @param pHashValue
* @return * @return
*/ */
int hash_digest_mem(HASH_TYPE hashType, const unsigned char *pBuf, unsigned int iBufLen, unsigned char **pHashValue, int hash_digest_mem(HASH_TYPE hashType,
const unsigned char *pBuf,
unsigned int iBufLen,
unsigned char **pHashValue,
unsigned int *pOutSize) { unsigned int *pOutSize) {
EVP_MD_CTX *pCtx; EVP_MD_CTX *pCtx;

View File

@ -110,8 +110,12 @@ static int sha1prng_for_aes_key(const char *pKey, unsigned char *pShaPrng16) {
} \ } \
} while (0) } while (0)
int symmetric_decrypto(AES_TYPE algorithmType, unsigned char *pInBuf, unsigned int inSize, unsigned char **pOutBuf, int symmetric_decrypto(AES_TYPE algorithmType,
int *pOutSize, const char *pKey) { unsigned char *pInBuf,
unsigned int inSize,
unsigned char **pOutBuf,
int *pOutSize,
const char *pKey) {
int enBytes = 0; int enBytes = 0;
EVP_CIPHER_CTX *pCtx; EVP_CIPHER_CTX *pCtx;
unsigned char *pAesBuf; unsigned char *pAesBuf;
@ -180,8 +184,12 @@ int symmetric_decrypto(AES_TYPE algorithmType, unsigned char *pInBuf, unsigned i
return ERR_SUCCESS; return ERR_SUCCESS;
} }
int symmetric_encrypto(AES_TYPE algorithmType, unsigned char *pInBuf, unsigned int inSize, unsigned char **pOutBuf, int symmetric_encrypto(AES_TYPE algorithmType,
int *pOutSize, const char *pKey) { unsigned char *pInBuf,
unsigned int inSize,
unsigned char **pOutBuf,
int *pOutSize,
const char *pKey) {
int enBytes = 0; int enBytes = 0;
unsigned char *pAesBuf; unsigned char *pAesBuf;
EVP_CIPHER_CTX *pCtx; EVP_CIPHER_CTX *pCtx;

View File

@ -141,7 +141,7 @@
/* Enable large inode numbers on Mac OS X 10.5. */ /* Enable large inode numbers on Mac OS X 10.5. */
#ifndef _DARWIN_USE_64_BIT_INODE #ifndef _DARWIN_USE_64_BIT_INODE
# define _DARWIN_USE_64_BIT_INODE 1 #define _DARWIN_USE_64_BIT_INODE 1
#endif #endif
/* Number of bits in a file offset, on hosts where this is settable. */ /* Number of bits in a file offset, on hosts where this is settable. */

View File

@ -137,4 +137,4 @@ const vector config_get_dhcp_replication_svr();
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif//DAEMON_AGENT_INCLUDE_CONFIG_H #endif //DAEMON_AGENT_INCLUDE_CONFIG_H

View File

@ -38,16 +38,27 @@ typedef enum {
HASH_TYPE_SHA256 = 2, HASH_TYPE_SHA256 = 2,
} HASH_TYPE; } HASH_TYPE;
typedef void (*on_evp_crypto)(CRYPTO_TYPE type, const unsigned char *pData, unsigned int iSize, typedef void (*on_evp_crypto)(CRYPTO_TYPE type,
const unsigned char *pSrcData, int iError); const unsigned char *pData,
unsigned int iSize,
const unsigned char *pSrcData,
int iError);
//***************************************************** //*****************************************************
// AES // AES
//***************************************************** //*****************************************************
int symmetric_encrypto(AES_TYPE algorithmType, unsigned char *pInBuf, unsigned int inSize, unsigned char **pOutBuf, int symmetric_encrypto(AES_TYPE algorithmType,
int *pOutSize, const char *pKey); unsigned char *pInBuf,
int symmetric_decrypto(AES_TYPE algorithmType, unsigned char *pInBuf, unsigned int inSize, unsigned char **pOutBuf, unsigned int inSize,
int *pOutSize, const char *pKey); 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 // BASE64
//***************************************************** //*****************************************************
@ -62,13 +73,20 @@ unsigned char *base64_decode(const char *pBase64, unsigned int *pOutSize);
// MD5 // MD5
//***************************************************** //*****************************************************
int hash_digest_file(HASH_TYPE hashType, const char *pFileName, char **pHashValue); 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, int hash_digest_mem(HASH_TYPE hashType,
const unsigned char *pBuf,
unsigned int iBufLen,
unsigned char **pHashValue,
unsigned int *pOutSize); unsigned int *pOutSize);
//***************************************************** //*****************************************************
// Async Engine // Async Engine
//***************************************************** //*****************************************************
int evp_add_crypto_task(CRYPTO_TYPE type, unsigned char *pInBuf, unsigned int iSize, unsigned char *pOutBuf, char *pKey, int evp_add_crypto_task(CRYPTO_TYPE type,
unsigned char *pInBuf,
unsigned int iSize,
unsigned char *pOutBuf,
char *pKey,
on_evp_crypto onEvpCryptCb); on_evp_crypto onEvpCryptCb);
void evp_system_init(void); void evp_system_init(void);
@ -76,4 +94,4 @@ void evp_system_init(void);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif//DAEMON_AGENT_CRYPTO_CRYPTO_H #endif //DAEMON_AGENT_CRYPTO_CRYPTO_H

View File

@ -10,15 +10,25 @@ extern "C" {
int inet_api_init(void); int inet_api_init(void);
typedef void (*on_http_response)(void *pData, unsigned int size, const char *pReqUrl, const char *pDlPath, typedef void (*on_http_response)(void *pData,
const char *pTaskUuid, int iFinished, void *pUserData); unsigned int size,
typedef void (*on_progress_changed)(const char *pReqUrl, const char *pTaskUuid, unsigned char uPercent, 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); void *pUserData);
const char *inet_download_file_async(const char *pURL, const char *pPath, on_http_response onRespCb, const char *inet_download_file_async(const char *pURL,
on_progress_changed onProgressCb, void *pData); const char *pPath,
on_http_response onRespCb,
on_progress_changed onProgressCb,
void *pData);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif//DAEMON_AGENT_NETWORD_INET_MISC_H #endif //DAEMON_AGENT_NETWORD_INET_MISC_H

View File

@ -50,10 +50,13 @@ int copy_file(const char *pSrc, const char *pDest);
char *bin2hex(char *p, const unsigned char *cp, unsigned int count); char *bin2hex(char *p, const unsigned char *cp, unsigned int count);
int shell_with_output(const char *pCmd, char **pResult); int shell_with_output(const char *pCmd, char **pResult);
int str_to_mac(const char *str, unsigned char mac[6]); 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); unsigned char *pMac);
int str_to_ipaddr(const char *pIp, unsigned int *ipAddr); int str_to_ipaddr(const char *pIp, unsigned int *ipAddr);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif//DAEMON_AGENT_MISC_MISC_H #endif //DAEMON_AGENT_MISC_MISC_H

View File

@ -24,8 +24,7 @@
#define cJSON__h #define cJSON__h
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C" {
{
#endif #endif
#if !defined(__WINDOWS__) && (defined(WIN32) || defined(WIN64) || defined(_MSC_VER) || defined(_WIN32)) #if !defined(__WINDOWS__) && (defined(WIN32) || defined(WIN64) || defined(_MSC_VER) || defined(_WIN32))
@ -71,7 +70,7 @@ then using the CJSON_API_VISIBILITY flag to "export" the same symbols the way CJ
#define CJSON_CDECL #define CJSON_CDECL
#define CJSON_STDCALL #define CJSON_STDCALL
#if (defined(__GNUC__) || defined(__SUNPRO_CC) || defined (__SUNPRO_C)) && defined(CJSON_API_VISIBILITY) #if (defined(__GNUC__) || defined(__SUNPRO_CC) || defined(__SUNPRO_C)) && defined(CJSON_API_VISIBILITY)
#define CJSON_PUBLIC(type) __attribute__((visibility("default"))) type #define CJSON_PUBLIC(type) __attribute__((visibility("default"))) type
#else #else
#define CJSON_PUBLIC(type) type #define CJSON_PUBLIC(type) type
@ -100,8 +99,7 @@ then using the CJSON_API_VISIBILITY flag to "export" the same symbols the way CJ
#define cJSON_StringIsConst 512 #define cJSON_StringIsConst 512
/* The cJSON structure: */ /* The cJSON structure: */
typedef struct cJSON typedef struct cJSON {
{
/* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */ /* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */
struct cJSON *next; struct cJSON *next;
struct cJSON *prev; struct cJSON *prev;
@ -122,11 +120,10 @@ typedef struct cJSON
char *string; char *string;
} cJSON; } cJSON;
typedef struct cJSON_Hooks 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. */ /* 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 *malloc_fn)(size_t sz);
void (CJSON_CDECL *free_fn)(void *ptr); void(CJSON_CDECL *free_fn)(void *ptr);
} cJSON_Hooks; } cJSON_Hooks;
typedef int cJSON_bool; typedef int cJSON_bool;
@ -138,10 +135,10 @@ typedef int cJSON_bool;
#endif #endif
/* returns the version of cJSON as a string */ /* 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 */ /* 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. */ /* 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. */ /* 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); 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. */ /* 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(). */ /* 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_PUBLIC(cJSON *) cJSON_ParseWithLengthOpts(const char *value, size_t buffer_length, const char **return_parse_end, cJSON_bool require_null_terminated); 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. */ /* Render a cJSON entity to text for transfer/storage. */
CJSON_PUBLIC(char *) cJSON_Print(const cJSON *item); 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); 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. */ /* 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 */ /* 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. */ /* Delete a cJSON entity and all subentities. */
CJSON_PUBLIC(void) cJSON_Delete(cJSON *item); 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. */ /* Retrieve item number "index" from array "array". Returns NULL if unsuccessful. */
CJSON_PUBLIC(cJSON *) cJSON_GetArrayItem(const cJSON *array, int index); CJSON_PUBLIC(cJSON *) cJSON_GetArrayItem(const cJSON *array, int index);
/* Get item "string" from object. Case insensitive. */ /* Get item "string" from object. Case insensitive. */
CJSON_PUBLIC(cJSON *) cJSON_GetObjectItem(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 *) cJSON_GetObjectItemCaseSensitive(const cJSON *const object, const char *const string);
CJSON_PUBLIC(cJSON_bool) cJSON_HasObjectItem(const cJSON *object, const char *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. */ /* 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); CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void);
/* Check item type and return its value */ /* Check item type and return its value */
CJSON_PUBLIC(char *) cJSON_GetStringValue(const cJSON * const item); CJSON_PUBLIC(char *) cJSON_GetStringValue(const cJSON *const item);
CJSON_PUBLIC(double) cJSON_GetNumberValue(const cJSON * const item); CJSON_PUBLIC(double) cJSON_GetNumberValue(const cJSON *const item);
/* These functions check the type of an item */ /* These functions check the type of an item */
CJSON_PUBLIC(cJSON_bool) cJSON_IsInvalid(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_IsFalse(const cJSON *const item);
CJSON_PUBLIC(cJSON_bool) cJSON_IsTrue(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_IsBool(const cJSON *const item);
CJSON_PUBLIC(cJSON_bool) cJSON_IsNull(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_IsNumber(const cJSON *const item);
CJSON_PUBLIC(cJSON_bool) cJSON_IsString(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_IsArray(const cJSON *const item);
CJSON_PUBLIC(cJSON_bool) cJSON_IsObject(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_IsRaw(const cJSON *const item);
/* These calls create a cJSON item of the appropriate type. */ /* These calls create a cJSON item of the appropriate type. */
CJSON_PUBLIC(cJSON *) cJSON_CreateNull(void); 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); CJSON_PUBLIC(cJSON_bool) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item);
/* Remove/Detach items from Arrays/Objects. */ /* 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(cJSON *) cJSON_DetachItemFromArray(cJSON *array, int which);
CJSON_PUBLIC(void) cJSON_DeleteItemFromArray(cJSON *array, int which); CJSON_PUBLIC(void) cJSON_DeleteItemFromArray(cJSON *array, int which);
CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObject(cJSON *object, const char *string); 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); CJSON_PUBLIC(void) cJSON_DeleteItemFromObjectCaseSensitive(cJSON *object, const char *string);
/* Update array items. */ /* 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_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON * const item, cJSON * replacement); 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_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_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_ReplaceItemInObjectCaseSensitive(cJSON *object, const char *string, cJSON *newitem);
/* Duplicate a cJSON item */ /* Duplicate a cJSON item */
CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse); 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. */ * 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. /* 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) */ * 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. /* 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, * 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. /* Helper functions for creating and adding items to an object at the same time.
* They return the added item or NULL on failure. */ * 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_AddNullToObject(cJSON *const object, const char *const name);
CJSON_PUBLIC(cJSON*) cJSON_AddTrueToObject(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_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_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_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_PUBLIC(cJSON*) cJSON_AddRawToObject(cJSON * const object, const char * const name, const char * const raw); cJSON_AddStringToObject(cJSON *const object, const char *const name, const char *const string);
CJSON_PUBLIC(cJSON*) cJSON_AddObjectToObject(cJSON * const object, const char * const name); CJSON_PUBLIC(cJSON *) cJSON_AddRawToObject(cJSON *const object, const char *const name, const char *const raw);
CJSON_PUBLIC(cJSON*) cJSON_AddArrayToObject(cJSON * const object, const char * const name); 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. */ /* 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)) #define cJSON_SetIntValue(object, number) ((object) ? (object)->valueint = (object)->valuedouble = (number) : (number))
/* helper for the cJSON_SetNumberValue macro */ /* helper for the cJSON_SetNumberValue macro */
CJSON_PUBLIC(double) cJSON_SetNumberHelper(cJSON *object, double number); 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 */ /* 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 */ /* 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 */ /* malloc/free objects using the malloc/free functions that have been set with cJSON_InitHooks */
CJSON_PUBLIC(void *) cJSON_malloc(size_t size); CJSON_PUBLIC(void *) cJSON_malloc(size_t size);

View File

@ -220,22 +220,14 @@ 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(to_struct, \ S2J_STRUCT_ARRAY_GET_ELEMENT_EX( \
array_item_##_element, \ to_struct, array_item_##_element, type, _element, index_##_element, _defval); \
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(to_struct, \ S2J_STRUCT_ARRAY_GET_ELEMENT_EX( \
array_##_element, \ to_struct, array_##_element, type, _element, index_##_element, _defval); \
type, \
_element, \
index_##_element, \
_defval); \
} \ } \
} \ } \
} else { \ } else { \

View File

@ -40,10 +40,10 @@ extern "C" {
/* Structure pointing to our actually configured allocators */ /* Structure pointing to our actually configured allocators */
typedef struct hiredisAllocFuncs { typedef struct hiredisAllocFuncs {
void *(*mallocFn)(size_t); void *(*mallocFn)(size_t);
void *(*callocFn)(size_t,size_t); void *(*callocFn)(size_t, size_t);
void *(*reallocFn)(void*,size_t); void *(*reallocFn)(void *, size_t);
char *(*strdupFn)(const char*); char *(*strdupFn)(const char *);
void (*freeFn)(void*); void (*freeFn)(void *);
} hiredisAllocFuncs; } hiredisAllocFuncs;
hiredisAllocFuncs hiredisSetAllocators(hiredisAllocFuncs *ha); hiredisAllocFuncs hiredisSetAllocators(hiredisAllocFuncs *ha);

View File

@ -33,7 +33,7 @@
#ifndef __SDS_H #ifndef __SDS_H
#define __SDS_H #define __SDS_H
#define SDS_MAX_PREALLOC (1024*1024) #define SDS_MAX_PREALLOC (1024 * 1024)
#ifdef _MSC_VER #ifdef _MSC_VER
#define __attribute__(x) #define __attribute__(x)
typedef long long ssize_t; typedef long long ssize_t;
@ -48,29 +48,29 @@ typedef char *sds;
/* Note: sdshdr5 is never used, we just access the flags byte directly. /* Note: sdshdr5 is never used, we just access the flags byte directly.
* However is here to document the layout of type 5 SDS strings. */ * 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 */ unsigned char flags; /* 3 lsb of type, and 5 msb of string length */
char buf[]; char buf[];
}; };
struct __attribute__ ((__packed__)) sdshdr8 { struct __attribute__((__packed__)) sdshdr8 {
uint8_t len; /* used */ uint8_t len; /* used */
uint8_t alloc; /* excluding the header and null terminator */ uint8_t alloc; /* excluding the header and null terminator */
unsigned char flags; /* 3 lsb of type, 5 unused bits */ unsigned char flags; /* 3 lsb of type, 5 unused bits */
char buf[]; char buf[];
}; };
struct __attribute__ ((__packed__)) sdshdr16 { struct __attribute__((__packed__)) sdshdr16 {
uint16_t len; /* used */ uint16_t len; /* used */
uint16_t alloc; /* excluding the header and null terminator */ uint16_t alloc; /* excluding the header and null terminator */
unsigned char flags; /* 3 lsb of type, 5 unused bits */ unsigned char flags; /* 3 lsb of type, 5 unused bits */
char buf[]; char buf[];
}; };
struct __attribute__ ((__packed__)) sdshdr32 { struct __attribute__((__packed__)) sdshdr32 {
uint32_t len; /* used */ uint32_t len; /* used */
uint32_t alloc; /* excluding the header and null terminator */ uint32_t alloc; /* excluding the header and null terminator */
unsigned char flags; /* 3 lsb of type, 5 unused bits */ unsigned char flags; /* 3 lsb of type, 5 unused bits */
char buf[]; char buf[];
}; };
struct __attribute__ ((__packed__)) sdshdr64 { struct __attribute__((__packed__)) sdshdr64 {
uint64_t len; /* used */ uint64_t len; /* used */
uint64_t alloc; /* excluding the header and null terminator */ uint64_t alloc; /* excluding the header and null terminator */
unsigned char flags; /* 3 lsb of type, 5 unused bits */ unsigned char flags; /* 3 lsb of type, 5 unused bits */
@ -84,47 +84,47 @@ struct __attribute__ ((__packed__)) sdshdr64 {
#define SDS_TYPE_64 4 #define SDS_TYPE_64 4
#define SDS_TYPE_MASK 7 #define SDS_TYPE_MASK 7
#define SDS_TYPE_BITS 3 #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_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_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_LEN(f) ((f) >> SDS_TYPE_BITS)
static inline size_t sdslen(const sds s) { static inline size_t sdslen(const sds s) {
unsigned char flags = s[-1]; unsigned char flags = s[-1];
switch(flags&SDS_TYPE_MASK) { switch (flags & SDS_TYPE_MASK) {
case SDS_TYPE_5: case SDS_TYPE_5:
return SDS_TYPE_5_LEN(flags); return SDS_TYPE_5_LEN(flags);
case SDS_TYPE_8: case SDS_TYPE_8:
return SDS_HDR(8,s)->len; return SDS_HDR(8, s)->len;
case SDS_TYPE_16: case SDS_TYPE_16:
return SDS_HDR(16,s)->len; return SDS_HDR(16, s)->len;
case SDS_TYPE_32: case SDS_TYPE_32:
return SDS_HDR(32,s)->len; return SDS_HDR(32, s)->len;
case SDS_TYPE_64: case SDS_TYPE_64:
return SDS_HDR(64,s)->len; return SDS_HDR(64, s)->len;
} }
return 0; return 0;
} }
static inline size_t sdsavail(const sds s) { static inline size_t sdsavail(const sds s) {
unsigned char flags = s[-1]; unsigned char flags = s[-1];
switch(flags&SDS_TYPE_MASK) { switch (flags & SDS_TYPE_MASK) {
case SDS_TYPE_5: { case SDS_TYPE_5: {
return 0; return 0;
} }
case SDS_TYPE_8: { case SDS_TYPE_8: {
SDS_HDR_VAR(8,s); SDS_HDR_VAR(8, s);
return sh->alloc - sh->len; return sh->alloc - sh->len;
} }
case SDS_TYPE_16: { case SDS_TYPE_16: {
SDS_HDR_VAR(16,s); SDS_HDR_VAR(16, s);
return sh->alloc - sh->len; return sh->alloc - sh->len;
} }
case SDS_TYPE_32: { case SDS_TYPE_32: {
SDS_HDR_VAR(32,s); SDS_HDR_VAR(32, s);
return sh->alloc - sh->len; return sh->alloc - sh->len;
} }
case SDS_TYPE_64: { case SDS_TYPE_64: {
SDS_HDR_VAR(64,s); SDS_HDR_VAR(64, s);
return sh->alloc - sh->len; 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) { static inline void sdssetlen(sds s, size_t newlen) {
unsigned char flags = s[-1]; unsigned char flags = s[-1];
switch(flags&SDS_TYPE_MASK) { switch (flags & SDS_TYPE_MASK) {
case SDS_TYPE_5: case SDS_TYPE_5: {
{ unsigned char *fp = ((unsigned char *)s) - 1;
unsigned char *fp = ((unsigned char*)s)-1;
*fp = (unsigned char)(SDS_TYPE_5 | (newlen << SDS_TYPE_BITS)); *fp = (unsigned char)(SDS_TYPE_5 | (newlen << SDS_TYPE_BITS));
} } break;
break;
case SDS_TYPE_8: case SDS_TYPE_8:
SDS_HDR(8,s)->len = (uint8_t)newlen; SDS_HDR(8, s)->len = (uint8_t)newlen;
break; break;
case SDS_TYPE_16: case SDS_TYPE_16:
SDS_HDR(16,s)->len = (uint16_t)newlen; SDS_HDR(16, s)->len = (uint16_t)newlen;
break; break;
case SDS_TYPE_32: case SDS_TYPE_32:
SDS_HDR(32,s)->len = (uint32_t)newlen; SDS_HDR(32, s)->len = (uint32_t)newlen;
break; break;
case SDS_TYPE_64: case SDS_TYPE_64:
SDS_HDR(64,s)->len = (uint64_t)newlen; SDS_HDR(64, s)->len = (uint64_t)newlen;
break; break;
} }
} }
static inline void sdsinclen(sds s, size_t inc) { static inline void sdsinclen(sds s, size_t inc) {
unsigned char flags = s[-1]; unsigned char flags = s[-1];
switch(flags&SDS_TYPE_MASK) { switch (flags & SDS_TYPE_MASK) {
case SDS_TYPE_5: case SDS_TYPE_5: {
{ unsigned char *fp = ((unsigned char *)s) - 1;
unsigned char *fp = ((unsigned char*)s)-1; unsigned char newlen = SDS_TYPE_5_LEN(flags) + (unsigned char)inc;
unsigned char newlen = SDS_TYPE_5_LEN(flags)+(unsigned char)inc;
*fp = SDS_TYPE_5 | (newlen << SDS_TYPE_BITS); *fp = SDS_TYPE_5 | (newlen << SDS_TYPE_BITS);
} } break;
break;
case SDS_TYPE_8: case SDS_TYPE_8:
SDS_HDR(8,s)->len += (uint8_t)inc; SDS_HDR(8, s)->len += (uint8_t)inc;
break; break;
case SDS_TYPE_16: case SDS_TYPE_16:
SDS_HDR(16,s)->len += (uint16_t)inc; SDS_HDR(16, s)->len += (uint16_t)inc;
break; break;
case SDS_TYPE_32: case SDS_TYPE_32:
SDS_HDR(32,s)->len += (uint32_t)inc; SDS_HDR(32, s)->len += (uint32_t)inc;
break; break;
case SDS_TYPE_64: case SDS_TYPE_64:
SDS_HDR(64,s)->len += (uint64_t)inc; SDS_HDR(64, s)->len += (uint64_t)inc;
break; break;
} }
} }
@ -183,38 +179,38 @@ static inline void sdsinclen(sds s, size_t inc) {
/* sdsalloc() = sdsavail() + sdslen() */ /* sdsalloc() = sdsavail() + sdslen() */
static inline size_t sdsalloc(const sds s) { static inline size_t sdsalloc(const sds s) {
unsigned char flags = s[-1]; unsigned char flags = s[-1];
switch(flags&SDS_TYPE_MASK) { switch (flags & SDS_TYPE_MASK) {
case SDS_TYPE_5: case SDS_TYPE_5:
return SDS_TYPE_5_LEN(flags); return SDS_TYPE_5_LEN(flags);
case SDS_TYPE_8: case SDS_TYPE_8:
return SDS_HDR(8,s)->alloc; return SDS_HDR(8, s)->alloc;
case SDS_TYPE_16: case SDS_TYPE_16:
return SDS_HDR(16,s)->alloc; return SDS_HDR(16, s)->alloc;
case SDS_TYPE_32: case SDS_TYPE_32:
return SDS_HDR(32,s)->alloc; return SDS_HDR(32, s)->alloc;
case SDS_TYPE_64: case SDS_TYPE_64:
return SDS_HDR(64,s)->alloc; return SDS_HDR(64, s)->alloc;
} }
return 0; return 0;
} }
static inline void sdssetalloc(sds s, size_t newlen) { static inline void sdssetalloc(sds s, size_t newlen) {
unsigned char flags = s[-1]; unsigned char flags = s[-1];
switch(flags&SDS_TYPE_MASK) { switch (flags & SDS_TYPE_MASK) {
case SDS_TYPE_5: case SDS_TYPE_5:
/* Nothing to do, this type has no total allocation info. */ /* Nothing to do, this type has no total allocation info. */
break; break;
case SDS_TYPE_8: case SDS_TYPE_8:
SDS_HDR(8,s)->alloc = (uint8_t)newlen; SDS_HDR(8, s)->alloc = (uint8_t)newlen;
break; break;
case SDS_TYPE_16: case SDS_TYPE_16:
SDS_HDR(16,s)->alloc = (uint16_t)newlen; SDS_HDR(16, s)->alloc = (uint16_t)newlen;
break; break;
case SDS_TYPE_32: case SDS_TYPE_32:
SDS_HDR(32,s)->alloc = (uint32_t)newlen; SDS_HDR(32, s)->alloc = (uint32_t)newlen;
break; break;
case SDS_TYPE_64: case SDS_TYPE_64:
SDS_HDR(64,s)->alloc = (uint64_t)newlen; SDS_HDR(64, s)->alloc = (uint64_t)newlen;
break; break;
} }
} }
@ -233,8 +229,7 @@ sds sdscpy(sds s, const char *t);
sds sdscatvprintf(sds s, const char *fmt, va_list ap); sds sdscatvprintf(sds s, const char *fmt, va_list ap);
#ifdef __GNUC__ #ifdef __GNUC__
sds sdscatprintf(sds s, const char *fmt, ...) sds sdscatprintf(sds s, const char *fmt, ...) __attribute__((format(printf, 2, 3)));
__attribute__((format(printf, 2, 3)));
#else #else
sds sdscatprintf(sds s, const char *fmt, ...); sds sdscatprintf(sds s, const char *fmt, ...);
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@ -30,341 +30,357 @@
** libraries! ** libraries!
*/ */
struct sqlite3_api_routines { struct sqlite3_api_routines {
void * (*aggregate_context)(sqlite3_context*,int nBytes); void *(*aggregate_context)(sqlite3_context *, int nBytes);
int (*aggregate_count)(sqlite3_context*); int (*aggregate_count)(sqlite3_context *);
int (*bind_blob)(sqlite3_stmt*,int,const void*,int n,void(*)(void*)); int (*bind_blob)(sqlite3_stmt *, int, const void *, int n, void (*)(void *));
int (*bind_double)(sqlite3_stmt*,int,double); int (*bind_double)(sqlite3_stmt *, int, double);
int (*bind_int)(sqlite3_stmt*,int,int); int (*bind_int)(sqlite3_stmt *, int, int);
int (*bind_int64)(sqlite3_stmt*,int,sqlite_int64); int (*bind_int64)(sqlite3_stmt *, int, sqlite_int64);
int (*bind_null)(sqlite3_stmt*,int); int (*bind_null)(sqlite3_stmt *, int);
int (*bind_parameter_count)(sqlite3_stmt*); int (*bind_parameter_count)(sqlite3_stmt *);
int (*bind_parameter_index)(sqlite3_stmt*,const char*zName); int (*bind_parameter_index)(sqlite3_stmt *, const char *zName);
const char * (*bind_parameter_name)(sqlite3_stmt*,int); const char *(*bind_parameter_name)(sqlite3_stmt *, int);
int (*bind_text)(sqlite3_stmt*,int,const char*,int n,void(*)(void*)); int (*bind_text)(sqlite3_stmt *, int, const char *, int n, void (*)(void *));
int (*bind_text16)(sqlite3_stmt*,int,const void*,int,void(*)(void*)); int (*bind_text16)(sqlite3_stmt *, int, const void *, int, void (*)(void *));
int (*bind_value)(sqlite3_stmt*,int,const sqlite3_value*); int (*bind_value)(sqlite3_stmt *, int, const sqlite3_value *);
int (*busy_handler)(sqlite3*,int(*)(void*,int),void*); int (*busy_handler)(sqlite3 *, int (*)(void *, int), void *);
int (*busy_timeout)(sqlite3*,int ms); int (*busy_timeout)(sqlite3 *, int ms);
int (*changes)(sqlite3*); int (*changes)(sqlite3 *);
int (*close)(sqlite3*); int (*close)(sqlite3 *);
int (*collation_needed)(sqlite3*,void*,void(*)(void*,sqlite3*, int (*collation_needed)(sqlite3 *, void *, void (*)(void *, sqlite3 *, int eTextRep, const char *));
int eTextRep,const char*)); int (*collation_needed16)(sqlite3 *, void *, void (*)(void *, sqlite3 *, int eTextRep, const void *));
int (*collation_needed16)(sqlite3*,void*,void(*)(void*,sqlite3*, const void *(*column_blob)(sqlite3_stmt *, int iCol);
int eTextRep,const void*)); int (*column_bytes)(sqlite3_stmt *, int iCol);
const void * (*column_blob)(sqlite3_stmt*,int iCol); int (*column_bytes16)(sqlite3_stmt *, int iCol);
int (*column_bytes)(sqlite3_stmt*,int iCol); int (*column_count)(sqlite3_stmt *pStmt);
int (*column_bytes16)(sqlite3_stmt*,int iCol); const char *(*column_database_name)(sqlite3_stmt *, int);
int (*column_count)(sqlite3_stmt*pStmt); const void *(*column_database_name16)(sqlite3_stmt *, int);
const char * (*column_database_name)(sqlite3_stmt*,int); const char *(*column_decltype)(sqlite3_stmt *, int i);
const void * (*column_database_name16)(sqlite3_stmt*,int); const void *(*column_decltype16)(sqlite3_stmt *, int);
const char * (*column_decltype)(sqlite3_stmt*,int i); double (*column_double)(sqlite3_stmt *, int iCol);
const void * (*column_decltype16)(sqlite3_stmt*,int); int (*column_int)(sqlite3_stmt *, int iCol);
double (*column_double)(sqlite3_stmt*,int iCol); sqlite_int64 (*column_int64)(sqlite3_stmt *, int iCol);
int (*column_int)(sqlite3_stmt*,int iCol); const char *(*column_name)(sqlite3_stmt *, int);
sqlite_int64 (*column_int64)(sqlite3_stmt*,int iCol); const void *(*column_name16)(sqlite3_stmt *, int);
const char * (*column_name)(sqlite3_stmt*,int); const char *(*column_origin_name)(sqlite3_stmt *, int);
const void * (*column_name16)(sqlite3_stmt*,int); const void *(*column_origin_name16)(sqlite3_stmt *, int);
const char * (*column_origin_name)(sqlite3_stmt*,int); const char *(*column_table_name)(sqlite3_stmt *, int);
const void * (*column_origin_name16)(sqlite3_stmt*,int); const void *(*column_table_name16)(sqlite3_stmt *, int);
const char * (*column_table_name)(sqlite3_stmt*,int); const unsigned char *(*column_text)(sqlite3_stmt *, int iCol);
const void * (*column_table_name16)(sqlite3_stmt*,int); const void *(*column_text16)(sqlite3_stmt *, int iCol);
const unsigned char * (*column_text)(sqlite3_stmt*,int iCol); int (*column_type)(sqlite3_stmt *, int iCol);
const void * (*column_text16)(sqlite3_stmt*,int iCol); sqlite3_value *(*column_value)(sqlite3_stmt *, int iCol);
int (*column_type)(sqlite3_stmt*,int iCol); void *(*commit_hook)(sqlite3 *, int (*)(void *), void *);
sqlite3_value* (*column_value)(sqlite3_stmt*,int iCol); int (*complete)(const char *sql);
void * (*commit_hook)(sqlite3*,int(*)(void*),void*); int (*complete16)(const void *sql);
int (*complete)(const char*sql); int (
int (*complete16)(const void*sql); *create_collation)(sqlite3 *, const char *, int, void *, int (*)(void *, int, const void *, int, const void *));
int (*create_collation)(sqlite3*,const char*,int,void*, int (*create_collation16)(sqlite3 *,
int(*)(void*,int,const void*,int,const void*)); const void *,
int (*create_collation16)(sqlite3*,const void*,int,void*, int,
int(*)(void*,int,const void*,int,const void*)); void *,
int (*create_function)(sqlite3*,const char*,int,int,void*, int (*)(void *, int, const void *, int, const void *));
void (*xFunc)(sqlite3_context*,int,sqlite3_value**), int (*create_function)(sqlite3 *,
void (*xStep)(sqlite3_context*,int,sqlite3_value**), const char *,
void (*xFinal)(sqlite3_context*)); int,
int (*create_function16)(sqlite3*,const void*,int,int,void*, int,
void (*xFunc)(sqlite3_context*,int,sqlite3_value**), void *,
void (*xStep)(sqlite3_context*,int,sqlite3_value**), void (*xFunc)(sqlite3_context *, int, sqlite3_value **),
void (*xFinal)(sqlite3_context*)); void (*xStep)(sqlite3_context *, int, sqlite3_value **),
int (*create_module)(sqlite3*,const char*,const sqlite3_module*,void*); void (*xFinal)(sqlite3_context *));
int (*data_count)(sqlite3_stmt*pStmt); int (*create_function16)(sqlite3 *,
sqlite3 * (*db_handle)(sqlite3_stmt*); const void *,
int (*declare_vtab)(sqlite3*,const char*); int,
int,
void *,
void (*xFunc)(sqlite3_context *, int, sqlite3_value **),
void (*xStep)(sqlite3_context *, int, sqlite3_value **),
void (*xFinal)(sqlite3_context *));
int (*create_module)(sqlite3 *, const char *, const sqlite3_module *, void *);
int (*data_count)(sqlite3_stmt *pStmt);
sqlite3 *(*db_handle)(sqlite3_stmt *);
int (*declare_vtab)(sqlite3 *, const char *);
int (*enable_shared_cache)(int); int (*enable_shared_cache)(int);
int (*errcode)(sqlite3*db); int (*errcode)(sqlite3 *db);
const char * (*errmsg)(sqlite3*); const char *(*errmsg)(sqlite3 *);
const void * (*errmsg16)(sqlite3*); const void *(*errmsg16)(sqlite3 *);
int (*exec)(sqlite3*,const char*,sqlite3_callback,void*,char**); int (*exec)(sqlite3 *, const char *, sqlite3_callback, void *, char **);
int (*expired)(sqlite3_stmt*); int (*expired)(sqlite3_stmt *);
int (*finalize)(sqlite3_stmt*pStmt); int (*finalize)(sqlite3_stmt *pStmt);
void (*free)(void*); void (*free)(void *);
void (*free_table)(char**result); void (*free_table)(char **result);
int (*get_autocommit)(sqlite3*); int (*get_autocommit)(sqlite3 *);
void * (*get_auxdata)(sqlite3_context*,int); void *(*get_auxdata)(sqlite3_context *, int);
int (*get_table)(sqlite3*,const char*,char***,int*,int*,char**); int (*get_table)(sqlite3 *, const char *, char ***, int *, int *, char **);
int (*global_recover)(void); int (*global_recover)(void);
void (*interruptx)(sqlite3*); void (*interruptx)(sqlite3 *);
sqlite_int64 (*last_insert_rowid)(sqlite3*); sqlite_int64 (*last_insert_rowid)(sqlite3 *);
const char * (*libversion)(void); const char *(*libversion)(void);
int (*libversion_number)(void); int (*libversion_number)(void);
void *(*malloc)(int); void *(*malloc)(int);
char * (*mprintf)(const char*,...); char *(*mprintf)(const char *, ...);
int (*open)(const char*,sqlite3**); int (*open)(const char *, sqlite3 **);
int (*open16)(const void*,sqlite3**); int (*open16)(const void *, sqlite3 **);
int (*prepare)(sqlite3*,const char*,int,sqlite3_stmt**,const char**); int (*prepare)(sqlite3 *, const char *, int, sqlite3_stmt **, const char **);
int (*prepare16)(sqlite3*,const void*,int,sqlite3_stmt**,const void**); int (*prepare16)(sqlite3 *, const void *, int, sqlite3_stmt **, const void **);
void * (*profile)(sqlite3*,void(*)(void*,const char*,sqlite_uint64),void*); void *(*profile)(sqlite3 *, void (*)(void *, const char *, sqlite_uint64), void *);
void (*progress_handler)(sqlite3*,int,int(*)(void*),void*); void (*progress_handler)(sqlite3 *, int, int (*)(void *), void *);
void *(*realloc)(void*,int); void *(*realloc)(void *, int);
int (*reset)(sqlite3_stmt*pStmt); int (*reset)(sqlite3_stmt *pStmt);
void (*result_blob)(sqlite3_context*,const void*,int,void(*)(void*)); void (*result_blob)(sqlite3_context *, const void *, int, void (*)(void *));
void (*result_double)(sqlite3_context*,double); void (*result_double)(sqlite3_context *, double);
void (*result_error)(sqlite3_context*,const char*,int); void (*result_error)(sqlite3_context *, const char *, int);
void (*result_error16)(sqlite3_context*,const void*,int); void (*result_error16)(sqlite3_context *, const void *, int);
void (*result_int)(sqlite3_context*,int); void (*result_int)(sqlite3_context *, int);
void (*result_int64)(sqlite3_context*,sqlite_int64); void (*result_int64)(sqlite3_context *, sqlite_int64);
void (*result_null)(sqlite3_context*); void (*result_null)(sqlite3_context *);
void (*result_text)(sqlite3_context*,const char*,int,void(*)(void*)); void (*result_text)(sqlite3_context *, const char *, int, void (*)(void *));
void (*result_text16)(sqlite3_context*,const void*,int,void(*)(void*)); void (*result_text16)(sqlite3_context *, const void *, int, void (*)(void *));
void (*result_text16be)(sqlite3_context*,const void*,int,void(*)(void*)); void (*result_text16be)(sqlite3_context *, const void *, int, void (*)(void *));
void (*result_text16le)(sqlite3_context*,const void*,int,void(*)(void*)); void (*result_text16le)(sqlite3_context *, const void *, int, void (*)(void *));
void (*result_value)(sqlite3_context*,sqlite3_value*); void (*result_value)(sqlite3_context *, sqlite3_value *);
void * (*rollback_hook)(sqlite3*,void(*)(void*),void*); void *(*rollback_hook)(sqlite3 *, void (*)(void *), void *);
int (*set_authorizer)(sqlite3*,int(*)(void*,int,const char*,const char*, int (*set_authorizer)(sqlite3 *,
const char*,const char*),void*); int (*)(void *, int, const char *, const char *, const char *, const char *),
void (*set_auxdata)(sqlite3_context*,int,void*,void (*)(void*)); void *);
char * (*xsnprintf)(int,char*,const char*,...); void (*set_auxdata)(sqlite3_context *, int, void *, void (*)(void *));
int (*step)(sqlite3_stmt*); char *(*xsnprintf)(int, char *, const char *, ...);
int (*table_column_metadata)(sqlite3*,const char*,const char*,const char*, int (*step)(sqlite3_stmt *);
char const**,char const**,int*,int*,int*); int (*table_column_metadata)(sqlite3 *,
const char *,
const char *,
const char *,
char const **,
char const **,
int *,
int *,
int *);
void (*thread_cleanup)(void); void (*thread_cleanup)(void);
int (*total_changes)(sqlite3*); int (*total_changes)(sqlite3 *);
void * (*trace)(sqlite3*,void(*xTrace)(void*,const char*),void*); void *(*trace)(sqlite3 *, void (*xTrace)(void *, const char *), void *);
int (*transfer_bindings)(sqlite3_stmt*,sqlite3_stmt*); int (*transfer_bindings)(sqlite3_stmt *, sqlite3_stmt *);
void * (*update_hook)(sqlite3*,void(*)(void*,int ,char const*,char const*, void *(*update_hook)(sqlite3 *, void (*)(void *, int, char const *, char const *, sqlite_int64), void *);
sqlite_int64),void*); void *(*user_data)(sqlite3_context *);
void * (*user_data)(sqlite3_context*); const void *(*value_blob)(sqlite3_value *);
const void * (*value_blob)(sqlite3_value*); int (*value_bytes)(sqlite3_value *);
int (*value_bytes)(sqlite3_value*); int (*value_bytes16)(sqlite3_value *);
int (*value_bytes16)(sqlite3_value*); double (*value_double)(sqlite3_value *);
double (*value_double)(sqlite3_value*); int (*value_int)(sqlite3_value *);
int (*value_int)(sqlite3_value*); sqlite_int64 (*value_int64)(sqlite3_value *);
sqlite_int64 (*value_int64)(sqlite3_value*); int (*value_numeric_type)(sqlite3_value *);
int (*value_numeric_type)(sqlite3_value*); const unsigned char *(*value_text)(sqlite3_value *);
const unsigned char * (*value_text)(sqlite3_value*); const void *(*value_text16)(sqlite3_value *);
const void * (*value_text16)(sqlite3_value*); const void *(*value_text16be)(sqlite3_value *);
const void * (*value_text16be)(sqlite3_value*); const void *(*value_text16le)(sqlite3_value *);
const void * (*value_text16le)(sqlite3_value*); int (*value_type)(sqlite3_value *);
int (*value_type)(sqlite3_value*); char *(*vmprintf)(const char *, va_list);
char *(*vmprintf)(const char*,va_list);
/* Added ??? */ /* Added ??? */
int (*overload_function)(sqlite3*, const char *zFuncName, int nArg); int (*overload_function)(sqlite3 *, const char *zFuncName, int nArg);
/* Added by 3.3.13 */ /* Added by 3.3.13 */
int (*prepare_v2)(sqlite3*,const char*,int,sqlite3_stmt**,const char**); int (*prepare_v2)(sqlite3 *, const char *, int, sqlite3_stmt **, const char **);
int (*prepare16_v2)(sqlite3*,const void*,int,sqlite3_stmt**,const void**); int (*prepare16_v2)(sqlite3 *, const void *, int, sqlite3_stmt **, const void **);
int (*clear_bindings)(sqlite3_stmt*); int (*clear_bindings)(sqlite3_stmt *);
/* Added by 3.4.1 */ /* Added by 3.4.1 */
int (*create_module_v2)(sqlite3*,const char*,const sqlite3_module*,void*, int (*create_module_v2)(sqlite3 *, const char *, const sqlite3_module *, void *, void (*xDestroy)(void *));
void (*xDestroy)(void *));
/* Added by 3.5.0 */ /* Added by 3.5.0 */
int (*bind_zeroblob)(sqlite3_stmt*,int,int); int (*bind_zeroblob)(sqlite3_stmt *, int, int);
int (*blob_bytes)(sqlite3_blob*); int (*blob_bytes)(sqlite3_blob *);
int (*blob_close)(sqlite3_blob*); int (*blob_close)(sqlite3_blob *);
int (*blob_open)(sqlite3*,const char*,const char*,const char*,sqlite3_int64, int (*blob_open)(sqlite3 *, const char *, const char *, const char *, sqlite3_int64, int, sqlite3_blob **);
int,sqlite3_blob**); int (*blob_read)(sqlite3_blob *, void *, int, int);
int (*blob_read)(sqlite3_blob*,void*,int,int); int (*blob_write)(sqlite3_blob *, const void *, int, int);
int (*blob_write)(sqlite3_blob*,const void*,int,int); int (*create_collation_v2)(sqlite3 *,
int (*create_collation_v2)(sqlite3*,const char*,int,void*, const char *,
int(*)(void*,int,const void*,int,const void*), int,
void(*)(void*)); void *,
int (*file_control)(sqlite3*,const char*,int,void*); int (*)(void *, int, const void *, int, const void *),
void (*)(void *));
int (*file_control)(sqlite3 *, const char *, int, void *);
sqlite3_int64 (*memory_highwater)(int); sqlite3_int64 (*memory_highwater)(int);
sqlite3_int64 (*memory_used)(void); sqlite3_int64 (*memory_used)(void);
sqlite3_mutex *(*mutex_alloc)(int); sqlite3_mutex *(*mutex_alloc)(int);
void (*mutex_enter)(sqlite3_mutex*); void (*mutex_enter)(sqlite3_mutex *);
void (*mutex_free)(sqlite3_mutex*); void (*mutex_free)(sqlite3_mutex *);
void (*mutex_leave)(sqlite3_mutex*); void (*mutex_leave)(sqlite3_mutex *);
int (*mutex_try)(sqlite3_mutex*); int (*mutex_try)(sqlite3_mutex *);
int (*open_v2)(const char*,sqlite3**,int,const char*); int (*open_v2)(const char *, sqlite3 **, int, const char *);
int (*release_memory)(int); int (*release_memory)(int);
void (*result_error_nomem)(sqlite3_context*); void (*result_error_nomem)(sqlite3_context *);
void (*result_error_toobig)(sqlite3_context*); void (*result_error_toobig)(sqlite3_context *);
int (*sleep)(int); int (*sleep)(int);
void (*soft_heap_limit)(int); void (*soft_heap_limit)(int);
sqlite3_vfs *(*vfs_find)(const char*); sqlite3_vfs *(*vfs_find)(const char *);
int (*vfs_register)(sqlite3_vfs*,int); int (*vfs_register)(sqlite3_vfs *, int);
int (*vfs_unregister)(sqlite3_vfs*); int (*vfs_unregister)(sqlite3_vfs *);
int (*xthreadsafe)(void); int (*xthreadsafe)(void);
void (*result_zeroblob)(sqlite3_context*,int); void (*result_zeroblob)(sqlite3_context *, int);
void (*result_error_code)(sqlite3_context*,int); void (*result_error_code)(sqlite3_context *, int);
int (*test_control)(int, ...); int (*test_control)(int, ...);
void (*randomness)(int,void*); void (*randomness)(int, void *);
sqlite3 *(*context_db_handle)(sqlite3_context*); sqlite3 *(*context_db_handle)(sqlite3_context *);
int (*extended_result_codes)(sqlite3*,int); int (*extended_result_codes)(sqlite3 *, int);
int (*limit)(sqlite3*,int,int); int (*limit)(sqlite3 *, int, int);
sqlite3_stmt *(*next_stmt)(sqlite3*,sqlite3_stmt*); sqlite3_stmt *(*next_stmt)(sqlite3 *, sqlite3_stmt *);
const char *(*sql)(sqlite3_stmt*); const char *(*sql)(sqlite3_stmt *);
int (*status)(int,int*,int*,int); int (*status)(int, int *, int *, int);
int (*backup_finish)(sqlite3_backup*); int (*backup_finish)(sqlite3_backup *);
sqlite3_backup *(*backup_init)(sqlite3*,const char*,sqlite3*,const char*); sqlite3_backup *(*backup_init)(sqlite3 *, const char *, sqlite3 *, const char *);
int (*backup_pagecount)(sqlite3_backup*); int (*backup_pagecount)(sqlite3_backup *);
int (*backup_remaining)(sqlite3_backup*); int (*backup_remaining)(sqlite3_backup *);
int (*backup_step)(sqlite3_backup*,int); int (*backup_step)(sqlite3_backup *, int);
const char *(*compileoption_get)(int); const char *(*compileoption_get)(int);
int (*compileoption_used)(const char*); int (*compileoption_used)(const char *);
int (*create_function_v2)(sqlite3*,const char*,int,int,void*, int (*create_function_v2)(sqlite3 *,
void (*xFunc)(sqlite3_context*,int,sqlite3_value**), const char *,
void (*xStep)(sqlite3_context*,int,sqlite3_value**), int,
void (*xFinal)(sqlite3_context*), int,
void(*xDestroy)(void*)); void *,
int (*db_config)(sqlite3*,int,...); void (*xFunc)(sqlite3_context *, int, sqlite3_value **),
sqlite3_mutex *(*db_mutex)(sqlite3*); void (*xStep)(sqlite3_context *, int, sqlite3_value **),
int (*db_status)(sqlite3*,int,int*,int*,int); void (*xFinal)(sqlite3_context *),
int (*extended_errcode)(sqlite3*); void (*xDestroy)(void *));
void (*log)(int,const char*,...); int (*db_config)(sqlite3 *, int, ...);
sqlite3_mutex *(*db_mutex)(sqlite3 *);
int (*db_status)(sqlite3 *, int, int *, int *, int);
int (*extended_errcode)(sqlite3 *);
void (*log)(int, const char *, ...);
sqlite3_int64 (*soft_heap_limit64)(sqlite3_int64); sqlite3_int64 (*soft_heap_limit64)(sqlite3_int64);
const char *(*sourceid)(void); const char *(*sourceid)(void);
int (*stmt_status)(sqlite3_stmt*,int,int); int (*stmt_status)(sqlite3_stmt *, int, int);
int (*strnicmp)(const char*,const char*,int); int (*strnicmp)(const char *, const char *, int);
int (*unlock_notify)(sqlite3*,void(*)(void**,int),void*); int (*unlock_notify)(sqlite3 *, void (*)(void **, int), void *);
int (*wal_autocheckpoint)(sqlite3*,int); int (*wal_autocheckpoint)(sqlite3 *, int);
int (*wal_checkpoint)(sqlite3*,const char*); int (*wal_checkpoint)(sqlite3 *, const char *);
void *(*wal_hook)(sqlite3*,int(*)(void*,sqlite3*,const char*,int),void*); void *(*wal_hook)(sqlite3 *, int (*)(void *, sqlite3 *, const char *, int), void *);
int (*blob_reopen)(sqlite3_blob*,sqlite3_int64); int (*blob_reopen)(sqlite3_blob *, sqlite3_int64);
int (*vtab_config)(sqlite3*,int op,...); int (*vtab_config)(sqlite3 *, int op, ...);
int (*vtab_on_conflict)(sqlite3*); int (*vtab_on_conflict)(sqlite3 *);
/* Version 3.7.16 and later */ /* Version 3.7.16 and later */
int (*close_v2)(sqlite3*); int (*close_v2)(sqlite3 *);
const char *(*db_filename)(sqlite3*,const char*); const char *(*db_filename)(sqlite3 *, const char *);
int (*db_readonly)(sqlite3*,const char*); int (*db_readonly)(sqlite3 *, const char *);
int (*db_release_memory)(sqlite3*); int (*db_release_memory)(sqlite3 *);
const char *(*errstr)(int); const char *(*errstr)(int);
int (*stmt_busy)(sqlite3_stmt*); int (*stmt_busy)(sqlite3_stmt *);
int (*stmt_readonly)(sqlite3_stmt*); int (*stmt_readonly)(sqlite3_stmt *);
int (*stricmp)(const char*,const char*); int (*stricmp)(const char *, const char *);
int (*uri_boolean)(const char*,const char*,int); int (*uri_boolean)(const char *, const char *, int);
sqlite3_int64 (*uri_int64)(const char*,const char*,sqlite3_int64); sqlite3_int64 (*uri_int64)(const char *, const char *, sqlite3_int64);
const char *(*uri_parameter)(const char*,const char*); const char *(*uri_parameter)(const char *, const char *);
char *(*xvsnprintf)(int,char*,const char*,va_list); char *(*xvsnprintf)(int, char *, const char *, va_list);
int (*wal_checkpoint_v2)(sqlite3*,const char*,int,int*,int*); int (*wal_checkpoint_v2)(sqlite3 *, const char *, int, int *, int *);
/* Version 3.8.7 and later */ /* Version 3.8.7 and later */
int (*auto_extension)(void(*)(void)); int (*auto_extension)(void (*)(void));
int (*bind_blob64)(sqlite3_stmt*,int,const void*,sqlite3_uint64, int (*bind_blob64)(sqlite3_stmt *, int, const void *, sqlite3_uint64, void (*)(void *));
void(*)(void*)); int (*bind_text64)(sqlite3_stmt *, int, const char *, sqlite3_uint64, void (*)(void *), unsigned char);
int (*bind_text64)(sqlite3_stmt*,int,const char*,sqlite3_uint64, int (*cancel_auto_extension)(void (*)(void));
void(*)(void*),unsigned char); int (*load_extension)(sqlite3 *, const char *, const char *, char **);
int (*cancel_auto_extension)(void(*)(void));
int (*load_extension)(sqlite3*,const char*,const char*,char**);
void *(*malloc64)(sqlite3_uint64); void *(*malloc64)(sqlite3_uint64);
sqlite3_uint64 (*msize)(void*); sqlite3_uint64 (*msize)(void *);
void *(*realloc64)(void*,sqlite3_uint64); void *(*realloc64)(void *, sqlite3_uint64);
void (*reset_auto_extension)(void); void (*reset_auto_extension)(void);
void (*result_blob64)(sqlite3_context*,const void*,sqlite3_uint64, void (*result_blob64)(sqlite3_context *, const void *, sqlite3_uint64, void (*)(void *));
void(*)(void*)); void (*result_text64)(sqlite3_context *, const char *, sqlite3_uint64, void (*)(void *), unsigned char);
void (*result_text64)(sqlite3_context*,const char*,sqlite3_uint64, int (*strglob)(const char *, const char *);
void(*)(void*), unsigned char);
int (*strglob)(const char*,const char*);
/* Version 3.8.11 and later */ /* Version 3.8.11 and later */
sqlite3_value *(*value_dup)(const sqlite3_value*); sqlite3_value *(*value_dup)(const sqlite3_value *);
void (*value_free)(sqlite3_value*); void (*value_free)(sqlite3_value *);
int (*result_zeroblob64)(sqlite3_context*,sqlite3_uint64); int (*result_zeroblob64)(sqlite3_context *, sqlite3_uint64);
int (*bind_zeroblob64)(sqlite3_stmt*, int, sqlite3_uint64); int (*bind_zeroblob64)(sqlite3_stmt *, int, sqlite3_uint64);
/* Version 3.9.0 and later */ /* Version 3.9.0 and later */
unsigned int (*value_subtype)(sqlite3_value*); unsigned int (*value_subtype)(sqlite3_value *);
void (*result_subtype)(sqlite3_context*,unsigned int); void (*result_subtype)(sqlite3_context *, unsigned int);
/* Version 3.10.0 and later */ /* Version 3.10.0 and later */
int (*status64)(int,sqlite3_int64*,sqlite3_int64*,int); int (*status64)(int, sqlite3_int64 *, sqlite3_int64 *, int);
int (*strlike)(const char*,const char*,unsigned int); int (*strlike)(const char *, const char *, unsigned int);
int (*db_cacheflush)(sqlite3*); int (*db_cacheflush)(sqlite3 *);
/* Version 3.12.0 and later */ /* Version 3.12.0 and later */
int (*system_errno)(sqlite3*); int (*system_errno)(sqlite3 *);
/* Version 3.14.0 and later */ /* Version 3.14.0 and later */
int (*trace_v2)(sqlite3*,unsigned,int(*)(unsigned,void*,void*,void*),void*); int (*trace_v2)(sqlite3 *, unsigned, int (*)(unsigned, void *, void *, void *), void *);
char *(*expanded_sql)(sqlite3_stmt*); char *(*expanded_sql)(sqlite3_stmt *);
/* Version 3.18.0 and later */ /* Version 3.18.0 and later */
void (*set_last_insert_rowid)(sqlite3*,sqlite3_int64); void (*set_last_insert_rowid)(sqlite3 *, sqlite3_int64);
/* Version 3.20.0 and later */ /* Version 3.20.0 and later */
int (*prepare_v3)(sqlite3*,const char*,int,unsigned int, int (*prepare_v3)(sqlite3 *, const char *, int, unsigned int, sqlite3_stmt **, const char **);
sqlite3_stmt**,const char**); int (*prepare16_v3)(sqlite3 *, const void *, int, unsigned int, sqlite3_stmt **, const void **);
int (*prepare16_v3)(sqlite3*,const void*,int,unsigned int, int (*bind_pointer)(sqlite3_stmt *, int, void *, const char *, void (*)(void *));
sqlite3_stmt**,const void**); void (*result_pointer)(sqlite3_context *, void *, const char *, void (*)(void *));
int (*bind_pointer)(sqlite3_stmt*,int,void*,const char*,void(*)(void*)); void *(*value_pointer)(sqlite3_value *, const char *);
void (*result_pointer)(sqlite3_context*,void*,const char*,void(*)(void*)); int (*vtab_nochange)(sqlite3_context *);
void *(*value_pointer)(sqlite3_value*,const char*); int (*value_nochange)(sqlite3_value *);
int (*vtab_nochange)(sqlite3_context*); const char *(*vtab_collation)(sqlite3_index_info *, int);
int (*value_nochange)(sqlite3_value*);
const char *(*vtab_collation)(sqlite3_index_info*,int);
/* Version 3.24.0 and later */ /* Version 3.24.0 and later */
int (*keyword_count)(void); int (*keyword_count)(void);
int (*keyword_name)(int,const char**,int*); int (*keyword_name)(int, const char **, int *);
int (*keyword_check)(const char*,int); int (*keyword_check)(const char *, int);
sqlite3_str *(*str_new)(sqlite3*); sqlite3_str *(*str_new)(sqlite3 *);
char *(*str_finish)(sqlite3_str*); char *(*str_finish)(sqlite3_str *);
void (*str_appendf)(sqlite3_str*, const char *zFormat, ...); void (*str_appendf)(sqlite3_str *, const char *zFormat, ...);
void (*str_vappendf)(sqlite3_str*, const char *zFormat, va_list); void (*str_vappendf)(sqlite3_str *, const char *zFormat, va_list);
void (*str_append)(sqlite3_str*, const char *zIn, int N); void (*str_append)(sqlite3_str *, const char *zIn, int N);
void (*str_appendall)(sqlite3_str*, const char *zIn); void (*str_appendall)(sqlite3_str *, const char *zIn);
void (*str_appendchar)(sqlite3_str*, int N, char C); void (*str_appendchar)(sqlite3_str *, int N, char C);
void (*str_reset)(sqlite3_str*); void (*str_reset)(sqlite3_str *);
int (*str_errcode)(sqlite3_str*); int (*str_errcode)(sqlite3_str *);
int (*str_length)(sqlite3_str*); int (*str_length)(sqlite3_str *);
char *(*str_value)(sqlite3_str*); char *(*str_value)(sqlite3_str *);
/* Version 3.25.0 and later */ /* Version 3.25.0 and later */
int (*create_window_function)(sqlite3*,const char*,int,int,void*, int (*create_window_function)(sqlite3 *,
void (*xStep)(sqlite3_context*,int,sqlite3_value**), const char *,
void (*xFinal)(sqlite3_context*), int,
void (*xValue)(sqlite3_context*), int,
void (*xInv)(sqlite3_context*,int,sqlite3_value**), void *,
void(*xDestroy)(void*)); void (*xStep)(sqlite3_context *, int, sqlite3_value **),
void (*xFinal)(sqlite3_context *),
void (*xValue)(sqlite3_context *),
void (*xInv)(sqlite3_context *, int, sqlite3_value **),
void (*xDestroy)(void *));
/* Version 3.26.0 and later */ /* Version 3.26.0 and later */
const char *(*normalized_sql)(sqlite3_stmt*); const char *(*normalized_sql)(sqlite3_stmt *);
/* Version 3.28.0 and later */ /* Version 3.28.0 and later */
int (*stmt_isexplain)(sqlite3_stmt*); int (*stmt_isexplain)(sqlite3_stmt *);
int (*value_frombind)(sqlite3_value*); int (*value_frombind)(sqlite3_value *);
/* Version 3.30.0 and later */ /* Version 3.30.0 and later */
int (*drop_modules)(sqlite3*,const char**); int (*drop_modules)(sqlite3 *, const char **);
/* Version 3.31.0 and later */ /* Version 3.31.0 and later */
sqlite3_int64 (*hard_heap_limit64)(sqlite3_int64); sqlite3_int64 (*hard_heap_limit64)(sqlite3_int64);
const char *(*uri_key)(const char*,int); const char *(*uri_key)(const char *, int);
const char *(*filename_database)(const char*); const char *(*filename_database)(const char *);
const char *(*filename_journal)(const char*); const char *(*filename_journal)(const char *);
const char *(*filename_wal)(const char*); const char *(*filename_wal)(const char *);
/* Version 3.32.0 and later */ /* Version 3.32.0 and later */
char *(*create_filename)(const char*,const char*,const char*, char *(*create_filename)(const char *, const char *, const char *, int, const char **);
int,const char**); void (*free_filename)(char *);
void (*free_filename)(char*); sqlite3_file *(*database_file_object)(const char *);
sqlite3_file *(*database_file_object)(const char*);
/* Version 3.34.0 and later */ /* Version 3.34.0 and later */
int (*txn_state)(sqlite3*,const char*); int (*txn_state)(sqlite3 *, const char *);
/* Version 3.36.1 and later */ /* Version 3.36.1 and later */
sqlite3_int64 (*changes64)(sqlite3*); sqlite3_int64 (*changes64)(sqlite3 *);
sqlite3_int64 (*total_changes64)(sqlite3*); sqlite3_int64 (*total_changes64)(sqlite3 *);
/* Version 3.37.0 and later */ /* Version 3.37.0 and later */
int (*autovacuum_pages)(sqlite3*, int (*autovacuum_pages)(sqlite3 *,
unsigned int(*)(void*,const char*,unsigned int,unsigned int,unsigned int), unsigned int (*)(void *, const char *, unsigned int, unsigned int, unsigned int),
void*, void(*)(void*)); void *,
void (*)(void *));
/* Version 3.38.0 and later */ /* Version 3.38.0 and later */
int (*error_offset)(sqlite3*); int (*error_offset)(sqlite3 *);
int (*vtab_rhs_value)(sqlite3_index_info*,int,sqlite3_value**); int (*vtab_rhs_value)(sqlite3_index_info *, int, sqlite3_value **);
int (*vtab_distinct)(sqlite3_index_info*); int (*vtab_distinct)(sqlite3_index_info *);
int (*vtab_in)(sqlite3_index_info*,int,int); int (*vtab_in)(sqlite3_index_info *, int, int);
int (*vtab_in_first)(sqlite3_value*,sqlite3_value**); int (*vtab_in_first)(sqlite3_value *, sqlite3_value **);
int (*vtab_in_next)(sqlite3_value*,sqlite3_value**); int (*vtab_in_next)(sqlite3_value *, sqlite3_value **);
/* Version 3.39.0 and later */ /* Version 3.39.0 and later */
int (*deserialize)(sqlite3*,const char*,unsigned char*, int (*deserialize)(sqlite3 *, const char *, unsigned char *, sqlite3_int64, sqlite3_int64, unsigned);
sqlite3_int64,sqlite3_int64,unsigned); unsigned char *(*serialize)(sqlite3 *, const char *, sqlite3_int64 *, unsigned int);
unsigned char *(*serialize)(sqlite3*,const char *,sqlite3_int64*, const char *(*db_name)(sqlite3 *, int);
unsigned int);
const char *(*db_name)(sqlite3*,int);
}; };
/* /*
** This is the function signature used for all extension entry points. It ** This is the function signature used for all extension entry points. It
** is also defined in the file "loadext.c". ** is also defined in the file "loadext.c".
*/ */
typedef int (*sqlite3_loadext_entry)( typedef int (*sqlite3_loadext_entry)(sqlite3 *db, /* Handle to the sqlitecipher. */
sqlite3 *db, /* Handle to the sqlitecipher. */
char **pzErrMsg, /* Used to set error string on failure. */ char **pzErrMsg, /* Used to set error string on failure. */
const sqlite3_api_routines *pThunk /* Extension API function pointers. */ const sqlite3_api_routines *pThunk /* Extension API function pointers. */
); );
@ -684,18 +700,17 @@ typedef int (*sqlite3_loadext_entry)(
#endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */ #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
/* This case when the file really is being compiled as a loadable /* This case when the file really is being compiled as a loadable
** extension */ ** extension */
# define SQLITE_EXTENSION_INIT1 const sqlite3_api_routines *sqlite3_api=0; #define SQLITE_EXTENSION_INIT1 const sqlite3_api_routines *sqlite3_api = 0;
# define SQLITE_EXTENSION_INIT2(v) sqlite3_api=v; #define SQLITE_EXTENSION_INIT2(v) sqlite3_api = v;
# define SQLITE_EXTENSION_INIT3 \ #define SQLITE_EXTENSION_INIT3 extern const sqlite3_api_routines *sqlite3_api;
extern const sqlite3_api_routines *sqlite3_api;
#else #else
/* This case when the file is being statically linked into the /* This case when the file is being statically linked into the
** application */ ** application */
# define SQLITE_EXTENSION_INIT1 /*no-op*/ #define SQLITE_EXTENSION_INIT1 /*no-op*/
# define SQLITE_EXTENSION_INIT2(v) (void)v; /* unused parameter */ #define SQLITE_EXTENSION_INIT2(v) (void)v; /* unused parameter */
# define SQLITE_EXTENSION_INIT3 /*no-op*/ #define SQLITE_EXTENSION_INIT3 /*no-op*/
#endif #endif
#endif /* SQLITE3EXT_H */ #endif /* SQLITE3EXT_H */

View File

@ -221,9 +221,8 @@ typedef struct {
} \ } \
} \ } \
if ((a)->i > ((pos) + (len))) { \ if ((a)->i > ((pos) + (len))) { \
memmove(_utarray_eltptr(a, pos), \ memmove( \
_utarray_eltptr(a, (pos) + (len)), \ _utarray_eltptr(a, pos), _utarray_eltptr(a, (pos) + (len)), ((a)->i - ((pos) + (len))) * (a)->icd.sz); \
((a)->i - ((pos) + (len))) * (a)->icd.sz); \
} \ } \
(a)->i -= (len); \ (a)->i -= (len); \
} while (0) } while (0)
@ -274,8 +273,9 @@ static void utarray_str_cpy(void *dst, const void *src) {
} }
static void utarray_str_dtor(void *elt) { static void utarray_str_dtor(void *elt) {
char **eltc = (char **)elt; char **eltc = (char **)elt;
if (*eltc != NULL) if (*eltc != NULL) {
free(*eltc); 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_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}; static const UT_icd ut_int_icd UTARRAY_UNUSED = {sizeof(int), NULL, NULL, NULL};

View File

@ -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 = \ (head)->hh.tbl->buckets = (UT_hash_bucket *)uthash_malloc(HASH_INITIAL_NUM_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,10 +523,8 @@ 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("%s: invalid hh_prev %p, actual %p\n", \ HASH_OOPS( \
(where), \ "%s: invalid hh_prev %p, actual %p\n", (where), (void *)_thh->hh_prev, (void *)_prev); \
(void *)_thh->hh_prev, \
(void *)_prev); \
} \ } \
_bkt_count++; \ _bkt_count++; \
_prev = (char *)(_thh); \ _prev = (char *)(_thh); \
@ -888,8 +886,8 @@ typedef unsigned char uint8_t;
(tbl)->num_buckets *= 2U; \ (tbl)->num_buckets *= 2U; \
(tbl)->log2_num_buckets++; \ (tbl)->log2_num_buckets++; \
(tbl)->buckets = _he_new_buckets; \ (tbl)->buckets = _he_new_buckets; \
(tbl)->ineff_expands = \ (tbl)->ineff_expands = ((tbl)->nonideal_items > ((tbl)->num_items >> 1)) ? ((tbl)->ineff_expands + 1U) \
((tbl)->nonideal_items > ((tbl)->num_items >> 1)) ? ((tbl)->ineff_expands + 1U) : 0U; \ : 0U; \
if ((tbl)->ineff_expands > 1U) { \ if ((tbl)->ineff_expands > 1U) { \
(tbl)->noexpand = 1; \ (tbl)->noexpand = 1; \
uthash_noexpand_fyi(tbl); \ uthash_noexpand_fyi(tbl); \

View File

@ -152,11 +152,12 @@ UTSTRING_UNUSED static void utstring_printf_va(UT_string *s, const char *fmt, va
} }
/* Else try again with more space. */ /* Else try again with more space. */
if (n > -1) if (n > -1) {
utstring_reserve(s, n + 1); /* exact */ utstring_reserve(s, n + 1); /* exact */
else } else {
utstring_reserve(s, (s->n) * 2); /* 2x */ utstring_reserve(s, (s->n) * 2); /* 2x */
} }
}
} }
#ifdef __GNUC__ #ifdef __GNUC__
/* support printf format checking (2=the format string, 3=start of varargs) */ /* support printf format checking (2=the format string, 3=start of varargs) */
@ -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. ) */ /* 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, UTSTRING_UNUSED static long _utstring_find(const char *P_Haystack,
size_t P_NeedleLen, long *P_KMP_Table) { size_t P_HaystackLen,
const char *P_Needle,
size_t P_NeedleLen,
long *P_KMP_Table) {
long i, j; long i, j;
long V_FindPosition = -1; 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. ) */ /* 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, UTSTRING_UNUSED static long _utstring_findR(const char *P_Haystack,
size_t P_NeedleLen, long *P_KMP_Table) { size_t P_HaystackLen,
const char *P_Needle,
size_t P_NeedleLen,
long *P_KMP_Table) {
long i, j; long i, j;
long V_FindPosition = -1; 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. ) */ /* Search data from left to right. ( One time search mode. ) */
UTSTRING_UNUSED static long utstring_find(UT_string *s, UTSTRING_UNUSED static long utstring_find(UT_string *s,
long P_StartPosition, /* Start from 0. -1 means last position. */ 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_StartPosition;
long V_HaystackLen; long V_HaystackLen;
long *V_KMP_Table; 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. ) */ /* Search data from right to left. ( One time search mode. ) */
UTSTRING_UNUSED static long utstring_findR(UT_string *s, UTSTRING_UNUSED static long utstring_findR(UT_string *s,
long P_StartPosition, /* Start from 0. -1 means last position. */ 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_StartPosition;
long V_HaystackLen; long V_HaystackLen;
long *V_KMP_Table; long *V_KMP_Table;

View File

@ -12,11 +12,11 @@
#define SRC_ZVECTOR_H_ #define SRC_ZVECTOR_H_
#if defined(_MSC_VER) && (_MSC_VER >= 1020) #if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once #pragma once
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C"{ extern "C" {
#endif #endif
// Requires standard C libraries: // Requires standard C libraries:
@ -32,7 +32,7 @@ extern "C"{
#include "zvector_config.h" #include "zvector_config.h"
// Declare required structs: // Declare required structs:
typedef struct p_vector * vector; typedef struct p_vector *vector;
// Declare required enums: // Declare required enums:
@ -55,7 +55,8 @@ enum ZVECT_PROPERTIES {
ZV_NONE = 0, // Sets or Resets all vector's properties to 0. 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_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_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_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_NOLOCKING = 1 << 3, // This Property means the vector will not use mutexes, be careful using it!
}; };
@ -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); 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: // Vector Thread Safe functions:
/* /*
@ -201,7 +202,8 @@ zvect_retval vect_unlock(vector const v);
* zvect_retval vect_lock_after_signal(const vector v); * zvect_retval vect_lock_after_signal(const vector v);
*/ */
zvect_retval vect_move_on_signal(vector const v1, vector v2, zvect_retval vect_move_on_signal(vector const v1,
vector v2,
const zvect_index s2, const zvect_index s2,
const zvect_index e2, const zvect_index e2,
zvect_retval (*f2)(void *, void *)); zvect_retval (*f2)(void *, void *));
@ -229,7 +231,7 @@ zvect_retval vect_sem_post(const vector v);
* corresponds to the top of a * corresponds to the top of a
* Stack. * 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 * vect_pop(v) "pops" (returns) the element
@ -458,7 +460,7 @@ void vect_rotate_right(vector const v, const zvect_index i);
* pointers to your datastructures stored in the vector. * 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 * 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); * vect_bsearch(v, &i, my_compare);
*/ */
#ifdef __cplusplus #ifdef __cplusplus
extern "C"{ extern "C" {
#endif #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 #ifdef __cplusplus
} }
#endif #endif
/* /*
* vect_add_ordered allows the insertion of new items in * vect_add_ordered allows the insertion of new items in
@ -591,8 +593,7 @@ void vect_copy(vector const v1, vector const v2, zvect_index start, zvect_index
* you'll have such items "inserted" * you'll have such items "inserted"
* inside v1. * inside v1.
*/ */
void vect_insert(vector const v1, vector const v2, const zvect_index s2, void vect_insert(vector const v1, vector const v2, const zvect_index s2, const zvect_index e2, const zvect_index s1);
const zvect_index e2, const zvect_index s1);
/* /*
* vect_move is a function that allows to move a specified * 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 * the end of v1 if check_data returns
* true. * true.
*/ */
zvect_retval vect_move_if(vector const v1, vector v2, const zvect_index s2, zvect_retval vect_move_if(vector const v1,
const zvect_index e2, zvect_retval (*f2)(void *, void *)); 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 * vect_merge is a function that merges together 2 vectors of

View File

@ -17,128 +17,122 @@
// Try to determine the Operating System being used: // Try to determine the Operating System being used:
#if defined(__APPLE__) && defined(__MACH__) #if defined(__APPLE__) && defined(__MACH__)
# define macOS #define macOS
#endif #endif
#if ( defined(__GNU__) || defined(__gnu_linux__) || \ #if (defined(__GNU__) || defined(__gnu_linux__) || defined(__linux__) || defined(macOS))
defined(__linux__) || defined(macOS) ) #define OS_TYPE 1
# define OS_TYPE 1 #elif (defined(__WIN32__) || defined(WIN32) || defined(_WIN32))
#elif ( defined(__WIN32__) || defined(WIN32) || defined(_WIN32) ) #define OS_TYPE 2
# define OS_TYPE 2
#else #else
# define OS_TYPE 0 #define OS_TYPE 0
#endif #endif
// Try to determine compiler being used: // Try to determine compiler being used:
#if defined(__GNUC__) #if defined(__GNUC__)
# define compiler gcc #define compiler gcc
# define ZVECT_COMPTYPE 1 #define ZVECT_COMPTYPE 1
# define COMP_MAJRELEASE (__GNUC__) #define COMP_MAJRELEASE (__GNUC__)
# define COMP_MINRELEASE (__GNUC_MINOR__) #define COMP_MINRELEASE (__GNUC_MINOR__)
# define COMP_PATRELEASE (__GNUC_PATCHLEVEL__) #define COMP_PATRELEASE (__GNUC_PATCHLEVEL__)
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
# define compiler msc #define compiler msc
# define ZVECT_COMPTYPE 2 #define ZVECT_COMPTYPE 2
# define COMP_MAJRELEASE (_MSC_VER) #define COMP_MAJRELEASE (_MSC_VER)
# define COMP_MINRELEASE 0 #define COMP_MINRELEASE 0
# define COMP_PATRELEASE 0 #define COMP_PATRELEASE 0
#elif defined(__clang__) #elif defined(__clang__)
# define compiler clang #define compiler clang
# define ZVECT_COMPTYPE 3 #define ZVECT_COMPTYPE 3
# define COMP_MAJRELEASE (__clang_major__) #define COMP_MAJRELEASE (__clang_major__)
# define COMP_MINRELEASE (__clang_minor__) #define COMP_MINRELEASE (__clang_minor__)
# define COMP_PATRELEASE (__clang_patchlevel__) #define COMP_PATRELEASE (__clang_patchlevel__)
#elif defined(__INTEL_COMPILER) || defined(__ICC) || \ #elif defined(__INTEL_COMPILER) || defined(__ICC) || defined(__ECC) || defined(__ICL)
defined(__ECC) || defined(__ICL)
// For intel c compiler please remember to specify: // For intel c compiler please remember to specify:
// /Qstd=c99 (on Windows) // /Qstd=c99 (on Windows)
// -std=c99 on Linux and/or macOS // -std=c99 on Linux and/or macOS
# define compiler intelc #define compiler intelc
# define ZVECT_COMPTYPE 4 #define ZVECT_COMPTYPE 4
# define COMP_MAJRELEASE (__INTEL_COMPILER) #define COMP_MAJRELEASE (__INTEL_COMPILER)
# define COMP_MINRELEASE 0 #define COMP_MINRELEASE 0
# define COMP_PATRELEASE 0 #define COMP_PATRELEASE 0
#elif defined (__LCC__) #elif defined(__LCC__)
# define compiler lcc #define compiler lcc
# define ZVECT_COMPTYPE 5 #define ZVECT_COMPTYPE 5
# define COMP_MAJRELEASE (__LCC) #define COMP_MAJRELEASE (__LCC)
# define COMP_MINRELEASE 0 #define COMP_MINRELEASE 0
# define COMP_PATRELEASE 0 #define COMP_PATRELEASE 0
#elif defined(__NORCROFT_C__) || defined(__CC_NORCROFT) || \ #elif defined(__NORCROFT_C__) || defined(__CC_NORCROFT) || defined(__ARMCC_VERSION)
defined(__ARMCC_VERSION)
// For Norcroft C please remember to specify: // For Norcroft C please remember to specify:
// -c99 // -c99
# define compiler norcroftc #define compiler norcroftc
# define ZVECT_COMPTYPE 6 #define ZVECT_COMPTYPE 6
# define COMP_MAJRELEASE (__ARMCC_VERSION) #define COMP_MAJRELEASE (__ARMCC_VERSION)
#elif defined(_CRAYC) #elif defined(_CRAYC)
// For Cray C please remember to specify: // For Cray C please remember to specify:
// -hc99 // -hc99
# define compiler crayc #define compiler crayc
# define ZVECT_COMPTYPE 10 #define ZVECT_COMPTYPE 10
# define COMP_MAJRELEASE (_RELEASE) #define COMP_MAJRELEASE (_RELEASE)
# define COMP_MINRELEASE (_RELEASE_MINOR) #define COMP_MINRELEASE (_RELEASE_MINOR)
# define COMP_PATRELEASE 0 #define COMP_PATRELEASE 0
#elif defined(__HP_cc) #elif defined(__HP_cc)
// For HP CC please remember to specify: // For HP CC please remember to specify:
// -ansi -std=c99 // -ansi -std=c99
# define compiler hpc #define compiler hpc
# define ZVECT_COMPTYPE 11 #define ZVECT_COMPTYPE 11
# define COMP_MAJRELEASE 1 #define COMP_MAJRELEASE 1
# define COMP_MINRELEASE 21 #define COMP_MINRELEASE 21
# define COMP_PATRELEASE 0 #define COMP_PATRELEASE 0
#elif defined(__IBMC__) #elif defined(__IBMC__)
// For IBM C please remember to specify: // For IBM C please remember to specify:
// C99 flags // C99 flags
# define compiler ibmc #define compiler ibmc
# define ZVECT_COMPTYPE 12 #define ZVECT_COMPTYPE 12
#elif defined(__TINYC__) #elif defined(__TINYC__)
# define compiler tinyc #define compiler tinyc
# define ZVECT_COMPTYPE 6 #define ZVECT_COMPTYPE 6
# define COMP_MAJRELEASE 0 #define COMP_MAJRELEASE 0
# define COMP_MINRELEASE 0 #define COMP_MINRELEASE 0
# define COMP_PATRELEASE 0 #define COMP_PATRELEASE 0
#else #else
# define compiler unknown #define compiler unknown
# define ZVECT_COMPTYPE 0 #define ZVECT_COMPTYPE 0
#endif #endif
// Try to determine CPU Architecture: // Try to determine CPU Architecture:
#if defined(__aarch64__) #if defined(__aarch64__)
# define CPU_TYPE ARM64 #define CPU_TYPE ARM64
# define Arch64 #define Arch64
#elif defined(__aarch32__) #elif defined(__aarch32__)
# define CPU_TYPE ARM32 #define CPU_TYPE ARM32
# define Arch32 #define Arch32
#elif defined(__amd64__) || defined(__x86_64__) || \ #elif defined(__amd64__) || defined(__x86_64__) || defined(__ia64__) || defined(_M_IA64) || defined(_M_AMD64) \
defined(__ia64__) || defined(_M_IA64) || \ || defined(_M_X64)
defined(_M_AMD64) || defined(_M_X64) #define CPU_TYPE x86_64
# define CPU_TYPE x86_64 #define Arch64
# define Arch64
#else #else
# define CPU_TYPE unknown #define CPU_TYPE unknown
# define Arch32 #define Arch32
#endif #endif
// Start setting up macros based on the platform we detected // Start setting up macros based on the platform we detected
// above. // above.
#if ( OS_TYPE == 1 ) #if (OS_TYPE == 1)
// We are on a Unix-like OS so we can use pthreads! // We are on a Unix-like OS so we can use pthreads!
# define MUTEX_TYPE 1 #define MUTEX_TYPE 1
# elif ( OS_TYPE == 2 ) && ( defined(__CYGWIN__) || \ #elif (OS_TYPE == 2) && (defined(__CYGWIN__) || defined(__MINGW32__) || defined(__MINGW64__))
defined(__MINGW32__) || defined(__MINGW64__) ) // We are on MS Windows using CIGWIN so we can use pthreads!
// We are on MS Windows using CIGWIN so we can use pthreads! #define MUTEX_TYPE 1
# define MUTEX_TYPE 1 #elif (OS_TYPE == 2) && (!defined(__CYGWIN__) && !defined(__MINGW32__) && !defined(__MINGW64__))
# elif ( OS_TYPE == 2 ) && ( !defined(__CYGWIN__) && \ // We are on MS Windows, so we need to use
!defined(__MINGW32__) && !defined(__MINGW64__) ) // Windows stuff:
// We are on MS Windows, so we need to use #define MUTEX_TYPE 2
// Windows stuff:
# define MUTEX_TYPE 2
#else #else
// I have no idea on which platform are we, // I have no idea on which platform are we,
// hence I have to use fake mutexes and go with the flow! // hence I have to use fake mutexes and go with the flow!
# define MUTEX_TYPE 0 #define MUTEX_TYPE 0
#endif #endif
#endif // SRC_ZVECTOR_CHECKS_H_ #endif // SRC_ZVECTOR_CHECKS_H_

View File

@ -19,10 +19,10 @@
#include <stdbool.h> #include <stdbool.h>
// Data alignment configuration // Data alignment configuration
#if ( ZVECT_COMPTYPE == 1 ) #if (ZVECT_COMPTYPE == 1)
#define ZVECT_DATAALIGN __attribute__((aligned)) #define ZVECT_DATAALIGN __attribute__((aligned))
#define ZVECT_PACKING __attribute__((__packed__)) #define ZVECT_PACKING __attribute__((__packed__))
#define ZVECT_ALWAYSINLINE __attribute__ ((__always_inline__)) #define ZVECT_ALWAYSINLINE __attribute__((__always_inline__))
#else #else
#define ZVECT_DATAALIGN #define ZVECT_DATAALIGN
#define ZVECT_PACKING #define ZVECT_PACKING
@ -36,7 +36,8 @@
// If you want a larger index you can // If you want a larger index you can
// change it to, for example, uint64_t // change it to, for example, uint64_t
typedef uint32_t zvect_index; typedef uint32_t zvect_index;
#define zvect_index_max 4294967295 // If you change zvect_index type make sure you update this value #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. // it's the maximum number that can be stored in a zvect_index.
// Default vector return type for // Default vector return type for

File diff suppressed because it is too large Load Diff

View File

@ -183,7 +183,10 @@ int str_to_ipaddr(const char *pIp, unsigned int *ipAddr) {
return ret; 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) { unsigned char *pMac) {
int sock; int sock;
struct ifreq ifr; struct ifreq ifr;
@ -234,7 +237,7 @@ int get_nic_info(const char *pName, unsigned int *pIp, unsigned int *pNetmask, u
return err; return err;
} }
const char*get_cur_process_name() { const char *get_cur_process_name() {
static char g_exeName[1024]; static char g_exeName[1024];
memset(g_exeName, 0, 1024); memset(g_exeName, 0, 1024);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -105,7 +105,7 @@ int mq_init(void) {
return ERR_SUCCESS; return ERR_SUCCESS;
} }
void* get_mq_context() { void *get_mq_context() {
return g_pContext; return g_pContext;
} }

View File

@ -8,7 +8,7 @@
int http_svr_init() { int http_svr_init() {
configuration config; 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.http_listen_port = config_get_http_server_port();
config.thread_count = 0; config.thread_count = 0;
config.parser = "http_parser"; config.parser = "http_parser";

View File

@ -54,7 +54,7 @@ typedef struct {
unsigned int uRetryTimes; unsigned int uRetryTimes;
PHTTP_REQ_PARAMS pCurlItem; PHTTP_REQ_PARAMS pCurlItem;
UT_hash_handle hh;///< UT Hash handle UT_hash_handle hh; ///< UT Hash handle
} CURL_HANDLE_TBL, *PCURL_HANDLE_TBL; } CURL_HANDLE_TBL, *PCURL_HANDLE_TBL;
static uv_timer_t g_uvCurlTm; static uv_timer_t g_uvCurlTm;
@ -229,10 +229,8 @@ static void checkMultiInfo(void) {
pReq->errCode = 0; pReq->errCode = 0;
} }
uv_fs_fdatasync(get_task_manager(), uv_fs_fdatasync(
&pReq->uvFsDataSync, get_task_manager(), &pReq->uvFsDataSync, (uv_file)pReq->uvFsOpen.result, uvFsDataSyncCb);
(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) {
@ -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); pReq->uvFsBuf = uv_buf_init(pData, iMemSize);
wr = uv_fs_write(get_task_manager(), wr = uv_fs_write(
&pReq->uvFsWrite, get_task_manager(), &pReq->uvFsWrite, (uv_file)pReq->uvFsOpen.result, &pReq->uvFsBuf, 1, -1, NULL);
(uv_file)pReq->uvFsOpen.result,
&pReq->uvFsBuf,
1,
-1,
NULL);
if (wr > 0) { if (wr > 0) {
pReq->dlSize += wr; pReq->dlSize += wr;
@ -440,10 +433,8 @@ 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->pReqUrl, pParams->onPrgCb(
pParams->pTaskUuid, pParams->pReqUrl, pParams->pTaskUuid, (unsigned char)(now * 100.0 / total), pParams->pData);
(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, const char *inet_download_file_async(const char *pURL,
on_progress_changed onProgressCb, void *pData) { const char *pPath,
on_http_response onRespCb,
on_progress_changed onProgressCb,
void *pData) {
CURLMcode ret; CURLMcode ret;
uuid_t msgId; uuid_t msgId;
char strMsgId[64]; 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); dzlog_debug("[%s]: File %s used temp path %s\n", pParams->pTaskUuid, pParams->sPath, pParams->sDlPath);
uv_fs_open(get_task_manager(), uv_fs_open(
&pParams->uvFsOpen, get_task_manager(), &pParams->uvFsOpen, pParams->sDlPath, O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR, NULL);
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);
@ -631,7 +621,7 @@ 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_PROGRESSDATA, pParams);
//curl_easy_setopt(pCurl, CURLOPT_TIMEOUT, 1800L); // Max download times (30 minutes)1800s //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_LIMIT, 10000L); // 10K bytes
curl_easy_setopt(pCurl, CURLOPT_LOW_SPEED_TIME, 10L); // 30 seconds curl_easy_setopt(pCurl, CURLOPT_LOW_SPEED_TIME, 10L); // 30 seconds
curl_easy_setopt(pCurl, CURLOPT_CONNECTTIMEOUT, 10L); curl_easy_setopt(pCurl, CURLOPT_CONNECTTIMEOUT, 10L);