diff --git a/.clang-format b/.clang-format index 01acca0..15d226d 100644 --- a/.clang-format +++ b/.clang-format @@ -57,7 +57,7 @@ BreakConstructorInitializersBeforeComma: false BreakConstructorInitializers: BeforeColon BreakAfterJavaFieldAnnotations: false BreakStringLiterals: true -ColumnLimit: 120 +ColumnLimit: 140 CommentPragmas: '^ IWYU pragma:' CompactNamespaces: true ConstructorInitializerAllOnOneLineOrOnePerLine: true diff --git a/CMakeLists.txt b/CMakeLists.txt index 7fc2644..3e6514f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,14 @@ PROJECT(vCPE_project) OPTION(VCPE_AGENT "Enable vCPE agent test application" OFF) OPTION(USED_LWIP "PPPoE for vCPE" OFF) -OPTION(USED_OPENDHCPD "DHCP server for vCPE" OFF) +OPTION(USED_OPENDHCPD "DHCP server for vCPE" ON) +OPTION(USED_OPENDHCPDDNS "DHCP And DNS server for vCPE" OFF) + + +OPTION(USED_REDIS "Add redis database support for vCPE" OFF) +OPTION(USED_MYSQL "Add mysql database support for vCPE" OFF) +OPTION(USED_SQLITE "Add sqlite3 database support for vCPE" ON) + SET(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:/usr/local/lib/pkgconfig") SET(URI_HOME "${CMAKE_SOURCE_DIR}/libs") @@ -20,7 +27,6 @@ else () SET(GIT_VERSION ${GIT_TAG}) endif () - MESSAGE("Version: " ${GIT_VERSION}) if (USED_LWIP) @@ -35,9 +41,6 @@ if (USED_OPENDHCPDDNS) LIST(APPEND COMMON_DEFINE "-DOPENDHCPDDNS_ON") endif () -ADD_SUBDIRECTORY(srcs) -ADD_SUBDIRECTORY(srcs/libs) - if (VCPE_AGENT) MESSAGE("Select Option VCPE_AGENT") endif () @@ -46,6 +49,10 @@ if (USED_LWIP) MESSAGE("Select Option USED_LWIP") endif () +if (USED_SQLITE) + MESSAGE("Select Option USED_SQLITE") +endif () + if (USED_OPENDHCPD) MESSAGE("Select Option USED_OPENDHCPD") ADD_SUBDIRECTORY(srcs/open_dhcp) @@ -60,8 +67,6 @@ if (USED_LWIP OR VCPE_AGENT) ADD_SUBDIRECTORY(srcs/lwip) endif () -ADD_SUBDIRECTORY(srcs/httpserver) -ADD_SUBDIRECTORY(srcs/database) - - -MESSAGE("COMMON_DEFINE: " ${COMMON_DEFINE}) \ No newline at end of file +ADD_SUBDIRECTORY(srcs) +ADD_SUBDIRECTORY(srcs/libs) +ADD_SUBDIRECTORY(srcs/httpserver) \ No newline at end of file diff --git a/config/vcpe.cfg b/config/vcpe.cfg index 834c0cf..5be5fff 100644 --- a/config/vcpe.cfg +++ b/config/vcpe.cfg @@ -39,6 +39,9 @@ application: mysql_user = "root"; # mysql 用户名 mysql_passwd = "AES@5/BQyUIfVxgV9BZAz/D3Rg=="; # mysql 数据库密码 mysql_database = "test"; # mysql 数据库名称 + + sqlite_dbname = "vcpe.db"; # sqlite3 数据库文件名 + sqlite_passwd = "test123"; # sqlite3 数据库密码 }; # MQ 相关配置 diff --git a/srcs/database/CMakeLists.txt b/srcs/database/CMakeLists.txt deleted file mode 100644 index 078db26..0000000 --- a/srcs/database/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 3.10 FATAL_ERROR) - -PROJECT(SQLITE_project C) - -INCLUDE_DIRECTORIES(./include) - -FILE(GLOB_RECURSE SQLITE_HEADS ./include/*.h) - -AUX_SOURCE_DIRECTORY(. SQLITE_SRC) - - -ADD_DEFINITIONS(-DSQLITE_HAS_CODEC -DSQLCIPHER_CRYPTO_OPENSSL -DSQLITE_OS_UNIX=1) -ADD_DEFINITIONS(-D_HAVE_SQLITE_CONFIG_H -DBUILD_sqlite -DNDEBUG -DSQLITE_THREADSAFE=1) -ADD_DEFINITIONS(-DSQLITE_ENABLE_MATH_FUNCTIONS -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT) -ADD_DEFINITIONS(-DSQLITE_ENABLE_MATH_FUNCTIONS -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT) -ADD_DEFINITIONS( -DSQLITE_HAVE_ZLIB=1 -DSQLITE_TEMP_STORE=2) - -ADD_LIBRARY(SQLITE_project STATIC ${SQLITE_SRC} ${SQLITE_HEADS}) -TARGET_LINK_LIBRARIES(SQLITE_project -lm -ldl -lz -lcrypto -lpthread) \ No newline at end of file diff --git a/srcs/libs/CMakeLists.txt b/srcs/libs/CMakeLists.txt index 2ed13b6..a900f99 100644 --- a/srcs/libs/CMakeLists.txt +++ b/srcs/libs/CMakeLists.txt @@ -14,7 +14,6 @@ AUX_SOURCE_DIRECTORY(json C_SRC) AUX_SOURCE_DIRECTORY(args C_SRC) AUX_SOURCE_DIRECTORY(init C_SRC) AUX_SOURCE_DIRECTORY(misc C_SRC) -AUX_SOURCE_DIRECTORY(../database C_SRC) AUX_SOURCE_DIRECTORY(banner C_SRC) AUX_SOURCE_DIRECTORY(configure C_SRC) AUX_SOURCE_DIRECTORY(network C_SRC) @@ -23,10 +22,30 @@ AUX_SOURCE_DIRECTORY(mq C_SRC) AUX_SOURCE_DIRECTORY(cmdline C_SRC) AUX_SOURCE_DIRECTORY(crypto C_SRC) AUX_SOURCE_DIRECTORY(hardware C_SRC) +AUX_SOURCE_DIRECTORY(database/sqlite3 C_SRC) + +if (USED_REDIS) + ADD_DEFINITIONS(-DUSED_REDIS) +endif () + +if (USED_SQLITE) + ADD_DEFINITIONS(-DUSED_SQLITE) +endif () + +if (USED_MYSQL) + ADD_DEFINITIONS(-DUSED_MYSQL) +endif () SET(CMAKE_C_STANDARD 99) SET_SOURCE_FILES_PROPERTIES(misc/zvector.c PROPERTIES COMPILE_FLAGS "-Wall -Wextra -flto") +SET_SOURCE_FILES_PROPERTIES(database/sqlite3/sqlite3.c PROPERTIES + COMPILE_FLAGS "-DSQLITE_HAS_CODEC \ +-DSQLCIPHER_CRYPTO_OPENSSL -DSQLITE_OS_UNIX=1 \ +-D_HAVE_SQLITE_CONFIG_H -DBUILD_sqlite -DNDEBUG -DSQLITE_THREADSAFE=1 \ +-DSQLITE_ENABLE_MATH_FUNCTIONS -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT \ +-DSQLITE_ENABLE_MATH_FUNCTIONS -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT \ +-DSQLITE_HAVE_ZLIB=1 -DSQLITE_TEMP_STORE=2") ADD_DEFINITIONS(-DBUILD_VERSION="${GIT_VERSION}" ${COMMON_DEFINE}) diff --git a/srcs/libs/configure/config.c b/srcs/libs/configure/config.c index af5b4c6..ec1d7e7 100644 --- a/srcs/libs/configure/config.c +++ b/srcs/libs/configure/config.c @@ -15,61 +15,20 @@ #include "crypto.h" #include "hardware.h" +typedef struct { + CONFIG_ITEM_ID cfgId; + const char *cfgPath; + CONFIG_VALUE_TYPE valType; + const char *defValue; + const char *readme; + const char *pStrId; +} CFG_ITEM, *PCFG_ITEM; + #define CFG_INT_VALUE(p) (p->value.longValue) #define CFG_BOOL_VALUE(p) (p->value.longValue == FALSE ? FALSE : TRUE) #define CFG_FLOAT_VALUE(p) (p->value.floatValue) #define CFG_STRING_VALUE(p) (p->value.strValue) -#define ADD_CFG_ITEM(id, key, type, defVal, desc) add_new_cfg_item(id, key, type, defVal, #id, desc) - -// clang-format off -#define ADD_DEFAULT_CONFIGURATION_ITEMS() \ -do { \ - ADD_CFG_ITEM(CFG_DIRECTORY, "application.system.config_file_path", VALUE_TYPE_STRING, ".", "Configuration files location path"); \ - ADD_CFG_ITEM(CFG_CURL_CA_PATH, "application.system.ssl_ca_file_path", VALUE_TYPE_STRING, "~/.ssh/ca.crt", "Libcurl access HTTPS CA File"); \ - ADD_CFG_ITEM(CFG_BANNER_SHOW, "application.system.show_banner", VALUE_TYPE_BOOL, "1", "Enable/Disable show banner"); \ - ADD_CFG_ITEM(CFG_HARDWARE_WATCH, "application.system.system_info_watch", VALUE_TYPE_BOOL, "1", "Monitor cpu, memory, disk, fan, temperature ..."); \ - ADD_CFG_ITEM(CFG_HARDWARE_REFRESH, "application.system.system_info_refresh", VALUE_TYPE_INTEGRAL, "10", "Monitor hardware information upgrade frequency"); \ - /* 系统监控设备相配置 */ \ - ADD_CFG_ITEM(CFG_WATCH_CPU, "application.watch_params.cpu", VALUE_TYPE_BOOL, "1", "Monitor cpu information"); \ - ADD_CFG_ITEM(CFG_WATCH_MEMORY, "application.watch_params.memory", VALUE_TYPE_BOOL, "1", "Monitor memory information"); \ - ADD_CFG_ITEM(CFG_WATCH_DISK, "application.watch_params.disk", VALUE_TYPE_BOOL, "1", "Monitor disk partition information"); \ - ADD_CFG_ITEM(CFG_WATCH_SENSOR, "application.watch_params.sensor", VALUE_TYPE_BOOL, "1", "Sensor information refresh frequency"); \ - /* 系统监控设备刷频率 */ \ - ADD_CFG_ITEM(CFG_CPU_REFRESH, "application.watch_params.cpu_refresh", VALUE_TYPE_INTEGRAL, "10", "CPU information refresh frequency"); \ - ADD_CFG_ITEM(CFG_MEM_REFRESH, "application.watch_params.mem_refresh", VALUE_TYPE_INTEGRAL, "10", "Memory information refresh frequency"); \ - ADD_CFG_ITEM(CFG_DISK_REFRESH, "application.watch_params.disk_refresh", VALUE_TYPE_INTEGRAL, "10", "Disk information refresh frequency"); \ - ADD_CFG_ITEM(CFG_SENSOR_REFRESH, "application.watch_params.sensor_refresh", VALUE_TYPE_INTEGRAL, "10", "Sensor information refresh frequency"); \ - /* 数据库相配置 */ \ - /* Redis配置 */ \ - ADD_CFG_ITEM(CFG_DB_REDIS_SERVER, "application.database.redis_server", VALUE_TYPE_STRING, "127.0.0.1", "Redis database server ip address"); \ - ADD_CFG_ITEM(CFG_DB_REDIS_PORT, "application.database.redis_port", VALUE_TYPE_INTEGRAL, "6379", "Redis database server port"); \ - ADD_CFG_ITEM(CFG_DB_REDIS_PASSWD, "application.database.redis_passwd", VALUE_TYPE_STRING, "", "Redis database server password"); \ - /* MySQL配置 */ \ - ADD_CFG_ITEM(CFG_DB_MYSQL_SERVER, "application.database.mysql_server", VALUE_TYPE_STRING, "127.0.0.1", "MySQL database server ip address"); \ - ADD_CFG_ITEM(CFG_DB_MYSQL_PORT, "application.database.mysql_port", VALUE_TYPE_INTEGRAL, "3306", "MySQL database server port"); \ - ADD_CFG_ITEM(CFG_DB_MYSQL_USER, "application.database.mysql_user", VALUE_TYPE_STRING, "", "MySQL database user name"); \ - ADD_CFG_ITEM(CFG_DB_MYSQL_PASSWD, "application.database.mysql_passwd", VALUE_TYPE_STRING, "", "MySQL database server password"); \ - ADD_CFG_ITEM(CFG_DB_MYSQL_DB_NAME, "application.database.mysql_database", VALUE_TYPE_STRING, ".main", "MySQL database used"); \ - /* 消息队列相配置 */ \ - /* ZeroMq配置 */ \ - ADD_CFG_ITEM(CFG_MQ_SVR_PORT, "application.zero_mq.svr_port", VALUE_TYPE_INTEGRAL, "6278", "ZeroMQ server port"); \ - ADD_CFG_ITEM(CFG_MQ_DATA_PATH, "application.zero_mq.agent_addr", VALUE_TYPE_STRING, "ipc:///tmp/msg_fifo0", "ZeroMQ Agent data path"); \ - /* vxLan 隧道配置 */ \ - ADD_CFG_ITEM(CFG_VXLAN_NIC_NAME, "application.vxlan_wan.nic", VALUE_TYPE_STRING, "", "Network card name to send data"); \ - ADD_CFG_ITEM(CFG_VXLAN_SUPPORT, "application.vxlan_wan.enable", VALUE_TYPE_BOOL, "1", "Is support vxLan tune"); \ - ADD_CFG_ITEM(CFG_VXLAN_PEER_IP, "application.vxlan_wan.peer_ip", VALUE_TYPE_STRING, "", "vxLan peer ip address"); \ - ADD_CFG_ITEM(CFG_VXLAN_PEER_MAC, "application.vxlan_wan.peer_mac", VALUE_TYPE_STRING, "", "vxLan peer mac address"); \ - ADD_CFG_ITEM(CFG_VXLAN_PKG_FILTER, "application.vxlan_wan.pkg_filter", VALUE_TYPE_STRING, "", "vxLan package filter"); \ - /*HTTP Server 配置*/ \ - ADD_CFG_ITEM(CFG_HTTP_SVR_ADDR, "application.http_svr.listen_addr", VALUE_TYPE_STRING, "0.0.0.0", "Network address to listen on"); \ - ADD_CFG_ITEM(CFG_HTTP_SVR_PORT, "application.http_svr.listen_port", VALUE_TYPE_INTEGRAL, "6789", "Network port to listen on"); \ - ADD_CFG_ITEM(CFG_HTTP_SVR_TCP_NODELAY, "application.http_svr.tcp_nodelay", VALUE_TYPE_BOOL, "1", "TCP delay switch"); \ - ADD_CFG_ITEM(CFG_DHCP_LISTEN_ON, "application.dhcp_server.listen_on", VALUE_TYPE_ARRAY_STR, "", "DHCP listen interface"); \ - ADD_CFG_ITEM(CFG_DHCP_REPLICATION_SVR, "application.dhcp_server.replication", VALUE_TYPE_ARRAY_STR, "", "DHCP replication server master and secondary"); \ - ADD_CFG_ITEM(CFG_DHCP_RANGE_SET, "application.dhcp_server.range_set", VALUE_TYPE_ARRAY_OBJ, "", "DHCP IP pool"); \ -} while (0)// clang-format on - typedef union { long long longValue; char *strValue; @@ -95,6 +54,64 @@ static const char *g_cfgFilePath; static const char *g_pCfgKey = NULL; PCONFIG_ITEM g_pConfigItem = NULL; +#define DEF_CFG_ITEM(id, key, type, defVal, desc) \ + { .cfgId = (id), .cfgPath = (key), .valType = (type), .defValue = (defVal), .readme = (desc), .pStrId = (#id) } + +static CFG_ITEM g_cfgItem[] = { + DEF_CFG_ITEM(CFG_DIRECTORY, "system.config_file_path", VAL_STR, ".", "Configuration files location path"), + DEF_CFG_ITEM(CFG_CURL_CA_PATH, "system.ssl_ca_file_path", VAL_STR, "~/.ssh/ca.crt", "Libcurl access HTTPS CA File"), + DEF_CFG_ITEM(CFG_BANNER_SHOW, "system.show_banner", VAL_BOOL, "1", "Enable/Disable show banner"), + DEF_CFG_ITEM(CFG_HARDWARE_WATCH, "system.system_info_watch", VAL_BOOL, "1", "Monitor cpu, memory, disk, fan, temperature ..."), + DEF_CFG_ITEM(CFG_HARDWARE_REFRESH, "system.system_info_refresh", VAL_INT, "10", "Monitor hardware information upgrade frequency"), + /* 系统监控设备相配置 */ + DEF_CFG_ITEM(CFG_WATCH_CPU, "watch_params.cpu", VAL_BOOL, "1", "Monitor cpu information"), + DEF_CFG_ITEM(CFG_WATCH_MEMORY, "watch_params.memory", VAL_BOOL, "1", "Monitor memory information"), + DEF_CFG_ITEM(CFG_WATCH_DISK, "watch_params.disk", VAL_BOOL, "1", "Monitor disk partition information"), + DEF_CFG_ITEM(CFG_WATCH_SENSOR, "watch_params.sensor", VAL_BOOL, "1", "Sensor information refresh frequency"), + /* 系统监控设备刷频率 */ + DEF_CFG_ITEM(CFG_CPU_REFRESH, "watch_params.cpu_refresh", VAL_INT, "10", "CPU information refresh frequency"), + DEF_CFG_ITEM(CFG_MEM_REFRESH, "watch_params.mem_refresh", VAL_INT, "10", "Memory information refresh frequency"), + DEF_CFG_ITEM(CFG_DISK_REFRESH, "watch_params.disk_refresh", VAL_INT, "10", "Disk information refresh frequency"), + DEF_CFG_ITEM(CFG_SENSOR_REFRESH, "watch_params.sensor_refresh", VAL_INT, "10", "Sensor information refresh frequency"), + /* 数据库相配置 */ + /* Redis配置 */ +#ifdef USED_REDIS + DEF_CFG_ITEM(CFG_DB_REDIS_SERVER, "database.redis_server", VAL_STR, "127.0.0.1", "Redis database server ip address"), + DEF_CFG_ITEM(CFG_DB_REDIS_PORT, "database.redis_port", VAL_INT, "6379", "Redis database server port"), + DEF_CFG_ITEM(CFG_DB_REDIS_PASSWD, "database.redis_passwd", VAL_STR, "", "Redis database server password"), +#endif +/* MySQL配置 */ +#ifdef USED_MYSQL + DEF_CFG_ITEM(CFG_DB_MYSQL_SERVER, "database.mysql_server", VAL_STR, "127.0.0.1", "MySQL database server ip address"), + DEF_CFG_ITEM(CFG_DB_MYSQL_PORT, "database.mysql_port", VAL_INT, "3306", "MySQL database server port"), + DEF_CFG_ITEM(CFG_DB_MYSQL_USER, "database.mysql_user", VAL_STR, "", "MySQL database user name"), + DEF_CFG_ITEM(CFG_DB_MYSQL_PASSWD, "database.mysql_passwd", VAL_STR, "", "MySQL database server password"), + DEF_CFG_ITEM(CFG_DB_MYSQL_DB_NAME, "database.mysql_database", VAL_STR, ".main", "MySQL database used"), +#endif + /* SQLite3配置 */ +#ifdef USED_SQLITE + DEF_CFG_ITEM(CFG_DB_SQLITE_DB_NAME, "database.sqlite_dbname", VAL_STR, "", "SQLite3 database file name"), + DEF_CFG_ITEM(CFG_DB_SQLITE_PASSWD, "database.sqlite_passwd", VAL_STR, ".main", "SQLite3 database password"), +#endif + /* 消息队列相配置 */ + /* ZeroMq配置 */ + DEF_CFG_ITEM(CFG_MQ_SVR_PORT, "zero_mq.svr_port", VAL_INT, "6278", "ZeroMQ server port"), + DEF_CFG_ITEM(CFG_MQ_DATA_PATH, "zero_mq.agent_addr", VAL_STR, "ipc:///tmp/msg_fifo0", "ZeroMQ Agent data path"), + /* vxLan 隧道配置 */ + DEF_CFG_ITEM(CFG_VXLAN_NIC_NAME, "vxlan_wan.nic", VAL_STR, "", "Network card name to send data"), + DEF_CFG_ITEM(CFG_VXLAN_SUPPORT, "vxlan_wan.enable", VAL_BOOL, "1", "Is support vxLan tune"), + DEF_CFG_ITEM(CFG_VXLAN_PEER_IP, "vxlan_wan.peer_ip", VAL_STR, "", "vxLan peer ip address"), + DEF_CFG_ITEM(CFG_VXLAN_PEER_MAC, "vxlan_wan.peer_mac", VAL_STR, "", "vxLan peer mac address"), + DEF_CFG_ITEM(CFG_VXLAN_PKG_FILTER, "vxlan_wan.pkg_filter", VAL_STR, "", "vxLan package filter"), + /*HTTP Server 配置*/ + DEF_CFG_ITEM(CFG_HTTP_SVR_ADDR, "http_svr.listen_addr", VAL_STR, "0.0.0.0", "Network address to listen on"), + DEF_CFG_ITEM(CFG_HTTP_SVR_PORT, "http_svr.listen_port", VAL_INT, "6789", "Network port to listen on"), + DEF_CFG_ITEM(CFG_HTTP_SVR_TCP_NODELAY, "http_svr.tcp_nodelay", VAL_BOOL, "1", "TCP delay switch"), + DEF_CFG_ITEM(CFG_DHCP_LISTEN_ON, "dhcp_server.listen_on", VAL_ARRAY_STR, "", "DHCP listen interface"), + DEF_CFG_ITEM(CFG_DHCP_REPLICATION_SVR, "dhcp_server.replication", VAL_ARRAY_STR, "", "DHCP replication server configure"), + DEF_CFG_ITEM(CFG_DHCP_RANGE_SET, "dhcp_server.range_set", VAL_ARRAY_OBJ, "", "DHCP IP pool"), +}; + static int cfg_is_upgrade(PCONFIG_ITEM pItem) { if (pItem->isChanged) { @@ -128,8 +145,7 @@ static const char *load_string_value(const char *pKeyName) { return NULL; } - if (symmetric_decrypto(AES128_ECB_PKCS7PADDING_SHA1PRNG, pBuf, bufSize, &buf, &outSize, pKey) - != ERR_SUCCESS) { + if (symmetric_decrypto(AES128_ECB_PKCS7PADDING_SHA1PRNG, pBuf, bufSize, &buf, &outSize, pKey) != ERR_SUCCESS) { free((void *)pKey); free(pBuf); return NULL; @@ -207,9 +223,8 @@ static int cmp_dhcp_obj(const void *a, const void *b) { POBJ_DHCP_RNG pV1 = (POBJ_DHCP_RNG)a; POBJ_DHCP_RNG pV2 = (POBJ_DHCP_RNG)b; - if (strcmp(pV1->rangAddr, pV2->rangAddr) == 0 && strcmp(pV1->subnet, pV2->subnet) == 0 - && strcmp(pV1->dnsSvr, pV2->dnsSvr) == 0 && strcmp(pV1->gateway, pV2->gateway) == 0 - && pV1->lease == pV2->lease) { + if (strcmp(pV1->rangAddr, pV2->rangAddr) == 0 && strcmp(pV1->subnet, pV2->subnet) == 0 && strcmp(pV1->dnsSvr, pV2->dnsSvr) == 0 + && strcmp(pV1->gateway, pV2->gateway) == 0 && pV1->lease == pV2->lease) { return 0; } @@ -271,13 +286,13 @@ static int load_array_obj(const char *pKeyName, PCONFIG_ITEM pValue) { static int setConfigItemValue(PCONFIG_ITEM pItem, const char *pValue) { errno = 0; - if (pItem->valType == VALUE_TYPE_STRING) { + if (pItem->valType == VAL_STR) { if (pItem->value.strValue != NULL) { free(pItem->value.strValue); } pItem->value.strValue = strdup(pValue); - } else if (pItem->valType == VALUE_TYPE_INTEGRAL || pItem->valType == VALUE_TYPE_BOOL) { + } else if (pItem->valType == VAL_INT || pItem->valType == VAL_BOOL) { char *pOver; long long val = strtoll(pValue, &pOver, 10); @@ -286,7 +301,7 @@ static int setConfigItemValue(PCONFIG_ITEM pItem, const char *pValue) { } pItem->value.longValue = val; - } else if (pItem->valType == VALUE_TYPE_FLOAT) { + } else if (pItem->valType == VAL_FLOAT) { char *pOver; long double val = strtold(pValue, &pOver); @@ -295,9 +310,9 @@ static int setConfigItemValue(PCONFIG_ITEM pItem, const char *pValue) { } pItem->value.floatValue = val; - } else if (pItem->valType == VALUE_TYPE_ARRAY_STR) { + } else if (pItem->valType == VAL_ARRAY_STR) { pItem->value.array = vect_create(128, 512, ZV_SEC_WIPE); - } else if (pItem->valType == VALUE_TYPE_ARRAY_OBJ) { + } else if (pItem->valType == VAL_ARRAY_OBJ) { pItem->value.array = vect_create(128, sizeof(OBJ_DHCP_RNG), ZV_SEC_WIPE); } else { return -ERR_UN_SUPPORT; @@ -306,8 +321,8 @@ static int setConfigItemValue(PCONFIG_ITEM pItem, const char *pValue) { return ERR_SUCCESS; } -static int add_new_cfg_item(CONFIG_ITEM_ID id, const char *pKey, CONFIG_VALUE_TYPE valType, const char *pDefVal, - const char *pStrId, const char *pDesc) { +static int add_new_cfg_item(CONFIG_ITEM_ID id, const char *pKey, CONFIG_VALUE_TYPE valType, const char *pDefVal, const char *pStrId, + const char *pDesc) { PCONFIG_ITEM pItem; int ret; @@ -361,10 +376,7 @@ static void refreshCfgFileCb() { int cfgUpgrade = FALSE; if (!config_read_file(&g_cfgContent, g_cfgFilePath)) { - dzlog_error("%s:%d - %s\n", - config_error_file(&g_cfgContent), - config_error_line(&g_cfgContent), - config_error_text(&g_cfgContent)); + dzlog_error("%s:%d - %s\n", config_error_file(&g_cfgContent), config_error_line(&g_cfgContent), config_error_text(&g_cfgContent)); return; } @@ -372,10 +384,12 @@ static void refreshCfgFileCb() { char *pStr; long long iVal; double fVal; + sds realKey = sdsnew("application."); + realKey = sdscat(realKey, pItem->pcfgKey); switch (pItem->valType) { - case VALUE_TYPE_STRING: - pStr = (char *)load_string_value(pItem->pcfgKey); + case VAL_STR: + pStr = (char *)load_string_value(realKey); if (pStr) { if (strcmp(pItem->value.strValue, pStr) != 0) { if (pItem->value.strValue != NULL) { @@ -389,8 +403,8 @@ static void refreshCfgFileCb() { free(pStr); } break; - case VALUE_TYPE_BOOL: - iVal = load_boolean_value(pItem->pcfgKey); + case VAL_BOOL: + iVal = load_boolean_value(realKey); if (iVal != DEFAULT_INTEGRAL_ERR_VALUE) { if (pItem->value.longValue != iVal) { @@ -400,8 +414,8 @@ static void refreshCfgFileCb() { } break; - case VALUE_TYPE_INTEGRAL: - iVal = load_integral_value(pItem->pcfgKey); + case VAL_INT: + iVal = load_integral_value(realKey); if (iVal != DEFAULT_INTEGRAL_ERR_VALUE) { if (pItem->value.longValue != iVal) { @@ -411,8 +425,8 @@ static void refreshCfgFileCb() { } break; - case VALUE_TYPE_FLOAT: - fVal = load_float_value(pItem->pcfgKey); + case VAL_FLOAT: + fVal = load_float_value(realKey); if (fVal != DEFAULT_INTEGRAL_ERR_VALUE) { if (pItem->value.floatValue != fVal) { @@ -422,12 +436,12 @@ static void refreshCfgFileCb() { } break; - case VALUE_TYPE_ARRAY_STR: - load_array_str(pItem->pcfgKey, pItem); + case VAL_ARRAY_STR: + load_array_str(realKey, pItem); break; - case VALUE_TYPE_ARRAY_OBJ: - load_array_obj(pItem->pcfgKey, pItem); + case VAL_ARRAY_OBJ: + load_array_obj(realKey, pItem); break; default: @@ -437,6 +451,8 @@ static void refreshCfgFileCb() { if (pItem->isChanged) { cfgUpgrade = TRUE; } + + sdsfree(realKey); } if (cfgUpgrade) { @@ -472,27 +488,17 @@ const char *config_item_dump_fmt(const char *titleMessage) { memset(tmp2, 0, 256); sprintf(tmp2, "%s%s", cfg_is_upgrade(pItem) ? "*" : " ", pItem->pStrId); switch (pItem->valType) { - case VALUE_TYPE_BOOL: - s = sdscatprintf(s, - "|%4d | %-25s | %-45s | %-64s |\n", - pItem->cfgId, - tmp2, - pItem->pcfgKey, - CFG_BOOL_VALUE(pItem) ? "True" : "False"); - break; - case VALUE_TYPE_INTEGRAL: + case VAL_BOOL: s = sdscatprintf( - s, "|%4d | %-25s | %-45s | %-64lld |\n", pItem->cfgId, tmp2, pItem->pcfgKey, CFG_INT_VALUE(pItem)); + s, "|%4d | %-25s | %-45s | %-64s |\n", pItem->cfgId, tmp2, pItem->pcfgKey, CFG_BOOL_VALUE(pItem) ? "True" : "False"); break; - case VALUE_TYPE_FLOAT: - s = sdscatprintf(s, - "|%4d | %-25s | %-45s | %-64Lf |\n", - pItem->cfgId, - tmp2, - pItem->pcfgKey, - CFG_FLOAT_VALUE(pItem)); + case VAL_INT: + s = sdscatprintf(s, "|%4d | %-25s | %-45s | %-64lld |\n", pItem->cfgId, tmp2, pItem->pcfgKey, CFG_INT_VALUE(pItem)); break; - case VALUE_TYPE_STRING: + case VAL_FLOAT: + s = sdscatprintf(s, "|%4d | %-25s | %-45s | %-64Lf |\n", pItem->cfgId, tmp2, pItem->pcfgKey, CFG_FLOAT_VALUE(pItem)); + break; + case VAL_STR: tmp = sdsempty(); tmp = sdscatprintf(tmp, "\"%s\"", CFG_STRING_VALUE(pItem)); if (sdslen(tmp) > 63) { @@ -502,7 +508,7 @@ const char *config_item_dump_fmt(const char *titleMessage) { s = sdscatprintf(s, "|%4d | %-25s | %-45s | %-64s |\n", pItem->cfgId, tmp2, pItem->pcfgKey, tmp); sdsfree(tmp); break; - case VALUE_TYPE_ARRAY_STR: + case VAL_ARRAY_STR: tmp = sdsempty(); tmp = sdscat(tmp, "["); for (i = 0; i < vect_size(pItem->value.array); i++) { @@ -521,7 +527,7 @@ const char *config_item_dump_fmt(const char *titleMessage) { s = sdscatprintf(s, "|%4d | %-25s | %-45s | %-64s |\n", pItem->cfgId, tmp2, pItem->pcfgKey, tmp); sdsfree(tmp); break; - case VALUE_TYPE_ARRAY_OBJ: + case VAL_ARRAY_OBJ: for (i = 0; i < vect_size(pItem->value.array); i++) { POBJ_DHCP_RNG p = (POBJ_DHCP_RNG)vect_get_at(pItem->value.array, i); if (!p) { @@ -579,28 +585,28 @@ void config_item_dump(const char *titleMessage) { dzlog_info("================== %s ===================\n", titleMessage == NULL ? "" : titleMessage); HASH_ITER(hh, g_pConfigItem, pItem, pTmp) { switch (pItem->valType) { - case VALUE_TYPE_BOOL: + case VAL_BOOL: dzlog_info("%s%-25s: [%-45s] = %s\n", cfg_is_upgrade(pItem) ? "*" : " ", pItem->pStrId, pItem->pcfgKey, CFG_BOOL_VALUE(pItem) ? "True" : "False"); break; - case VALUE_TYPE_INTEGRAL: + case VAL_INT: dzlog_info("%s%-25s: [%-45s] = %lld\n", cfg_is_upgrade(pItem) ? "*" : " ", pItem->pStrId, pItem->pcfgKey, CFG_INT_VALUE(pItem)); break; - case VALUE_TYPE_FLOAT: + case VAL_FLOAT: dzlog_info("%s%-25s: [%-45s] = %Lf\n", cfg_is_upgrade(pItem) ? "*" : " ", pItem->pStrId, pItem->pcfgKey, CFG_FLOAT_VALUE(pItem)); break; - case VALUE_TYPE_STRING: + case VAL_STR: dzlog_info("%s%-25s: [%-45s] = \"%s\"\n", cfg_is_upgrade(pItem) ? "*" : " ", pItem->pStrId, @@ -665,6 +671,8 @@ const vector cfg_get_vector(CONFIG_ITEM_ID id) { } int init_config_system(const char *pCfgFile, const char *pKey) { + int i; + if (!file_exists(pCfgFile)) { dzlog_error("Configuration file [%s] not exists\n", pCfgFile); return -ERR_FILE_NOT_EXISTS; @@ -676,7 +684,14 @@ int init_config_system(const char *pCfgFile, const char *pKey) { config_init(&g_cfgContent); - ADD_DEFAULT_CONFIGURATION_ITEMS(); + for (i = 0; i < ARRAY_SIZE(g_cfgItem); i++) { + add_new_cfg_item(g_cfgItem[i].cfgId, + g_cfgItem[i].cfgPath, + g_cfgItem[i].valType, + g_cfgItem[i].defValue, + g_cfgItem[i].pStrId, + g_cfgItem[i].readme); + } // clang-format on refreshCfgFileCb(); @@ -688,8 +703,8 @@ void uninit_config_system() { PCONFIG_ITEM pItem, pTmp; HASH_ITER(hh, g_pConfigItem, pItem, pTmp) { switch (pItem->valType) { - case VALUE_TYPE_ARRAY_STR: - case VALUE_TYPE_ARRAY_OBJ: + case VAL_ARRAY_STR: + case VAL_ARRAY_OBJ: vect_destroy(pItem->value.array); break; default: diff --git a/srcs/libs/configure/config_help.c b/srcs/libs/configure/config_help.c index 9a100db..083c462 100644 --- a/srcs/libs/configure/config_help.c +++ b/srcs/libs/configure/config_help.c @@ -99,6 +99,7 @@ unsigned int cfg_get_sensor_refresh_period() { return cfg_get_integral_value(CFG_SENSOR_REFRESH); } +#ifdef USED_REDIS const char *cfg_get_redis_server() { return cfg_get_string_value(CFG_DB_REDIS_SERVER); } @@ -110,7 +111,9 @@ int cfg_get_redis_port() { const char *cfg_get_redis_passwd() { return cfg_get_string_value(CFG_DB_REDIS_PASSWD); } +#endif +#ifdef USED_MYSQL const char *cfg_get_mysql_server() { return cfg_get_string_value(CFG_DB_MYSQL_SERVER); } @@ -130,6 +133,7 @@ const char *cfg_get_mysql_passwd() { const char *cfg_get_mysql_database() { return cfg_get_string_value(CFG_DB_MYSQL_DB_NAME); } +#endif int cfg_get_zero_mq_port() { return (unsigned short)cfg_get_integral_value(CFG_MQ_SVR_PORT); diff --git a/srcs/database/config.h b/srcs/libs/database/sqlite3/config.h similarity index 100% rename from srcs/database/config.h rename to srcs/libs/database/sqlite3/config.h diff --git a/srcs/database/sqlite3.c b/srcs/libs/database/sqlite3/sqlite3.c similarity index 100% rename from srcs/database/sqlite3.c rename to srcs/libs/database/sqlite3/sqlite3.c diff --git a/srcs/libs/include/config.h b/srcs/libs/include/config.h index b8acc56..01e480f 100644 --- a/srcs/libs/include/config.h +++ b/srcs/libs/include/config.h @@ -21,49 +21,57 @@ typedef struct { } OBJ_DHCP_RNG, *POBJ_DHCP_RNG; typedef enum { - VALUE_TYPE_INTEGRAL = 0, - VALUE_TYPE_FLOAT = 1, - VALUE_TYPE_STRING = 2, - VALUE_TYPE_BOOL = 3, - VALUE_TYPE_ARRAY_STR = 4, - VALUE_TYPE_ARRAY_OBJ = 5, + VAL_INT = 0, + VAL_FLOAT = 1, + VAL_STR = 2, + VAL_BOOL = 3, + VAL_ARRAY_STR = 4, + VAL_ARRAY_OBJ = 5, } CONFIG_VALUE_TYPE; typedef enum { - CFG_DIRECTORY = 0, - CFG_CURL_CA_PATH = 1, - CFG_BANNER_SHOW = 2, - CFG_HARDWARE_WATCH = 3, - CFG_HARDWARE_REFRESH = 4, - CFG_WATCH_CPU = 5, - CFG_WATCH_MEMORY = 6, - CFG_WATCH_DISK = 7, - CFG_WATCH_SENSOR = 8, - CFG_CPU_REFRESH = 9, - CFG_MEM_REFRESH = 10, - CFG_DISK_REFRESH = 11, - CFG_SENSOR_REFRESH = 12, - CFG_DB_REDIS_SERVER = 13, - CFG_DB_REDIS_PORT = 14, - CFG_DB_REDIS_PASSWD = 15, - CFG_DB_MYSQL_SERVER = 16, - CFG_DB_MYSQL_PORT = 17, - CFG_DB_MYSQL_USER = 18, - CFG_DB_MYSQL_PASSWD = 19, - CFG_DB_MYSQL_DB_NAME = 20, - CFG_MQ_SVR_PORT = 21, - CFG_MQ_DATA_PATH = 22, - CFG_VXLAN_NIC_NAME = 23, - CFG_VXLAN_SUPPORT = 24, - CFG_VXLAN_PEER_IP = 25, - CFG_VXLAN_PEER_MAC = 26, - CFG_VXLAN_PKG_FILTER = 27, - CFG_HTTP_SVR_ADDR = 29, - CFG_HTTP_SVR_PORT = 30, - CFG_HTTP_SVR_TCP_NODELAY = 31, - CFG_DHCP_LISTEN_ON = 32, - CFG_DHCP_REPLICATION_SVR = 33, - CFG_DHCP_RANGE_SET = 34, + CFG_DIRECTORY, + CFG_CURL_CA_PATH, + CFG_BANNER_SHOW, + CFG_HARDWARE_WATCH, + CFG_HARDWARE_REFRESH, + CFG_WATCH_CPU, + CFG_WATCH_MEMORY, + CFG_WATCH_DISK, + CFG_WATCH_SENSOR, + CFG_CPU_REFRESH, + CFG_MEM_REFRESH, + CFG_DISK_REFRESH, + CFG_SENSOR_REFRESH, +#ifdef USED_REDIS + CFG_DB_REDIS_SERVER, + CFG_DB_REDIS_PORT, + CFG_DB_REDIS_PASSWD, +#endif +#ifdef USED_MYSQL + CFG_DB_MYSQL_SERVER, + CFG_DB_MYSQL_PORT, + CFG_DB_MYSQL_USER, + CFG_DB_MYSQL_PASSWD, + CFG_DB_MYSQL_DB_NAME, +#endif +#ifdef USED_SQLITE + CFG_DB_SQLITE_DB_NAME, + CFG_DB_SQLITE_PASSWD, +#endif + CFG_MQ_SVR_PORT, + CFG_MQ_DATA_PATH, + CFG_VXLAN_NIC_NAME, + CFG_VXLAN_SUPPORT, + CFG_VXLAN_PEER_IP, + CFG_VXLAN_PEER_MAC, + CFG_VXLAN_PKG_FILTER, + CFG_HTTP_SVR_ADDR, + CFG_HTTP_SVR_PORT, + CFG_HTTP_SVR_TCP_NODELAY, + CFG_DHCP_LISTEN_ON, + CFG_DHCP_REPLICATION_SVR, + CFG_DHCP_RANGE_SET, CONFIG_ITEM_ID_MAX } CONFIG_ITEM_ID; @@ -83,16 +91,20 @@ unsigned int cfg_get_cpu_refresh_period(); unsigned int cfg_get_mem_refresh_period(); unsigned int cfg_get_disk_refresh_period(); unsigned int cfg_get_sensor_refresh_period(); -const char *cfg_get_redis_server(); -int cfg_get_redis_port(); -const char *cfg_get_redis_passwd(); -const char *cfg_get_mysql_server(); -int cfg_get_mysql_port(); -const char *cfg_get_mysql_user(); -const char *cfg_get_mysql_passwd(); -const char *cfg_get_mysql_database(); -int cfg_get_zero_mq_port(); -const char *cfg_get_zero_mq_data_path(); +#ifdef USED_REDIS +const char *cfg_get_redis_server(); +int cfg_get_redis_port(); +const char *cfg_get_redis_passwd(); +#endif +#ifdef USED_MYSQL +const char *cfg_get_mysql_server(); +int cfg_get_mysql_port(); +const char *cfg_get_mysql_user(); +const char *cfg_get_mysql_passwd(); +const char *cfg_get_mysql_database(); +#endif +int cfg_get_zero_mq_port(); +const char *cfg_get_zero_mq_data_path(); const char *cfg_get_string_value(CONFIG_ITEM_ID id); const vector cfg_get_vector(CONFIG_ITEM_ID id); diff --git a/srcs/database/include/sqlite3.h b/srcs/libs/include/sqlite3/sqlite3.h similarity index 93% rename from srcs/database/include/sqlite3.h rename to srcs/libs/include/sqlite3/sqlite3.h index 4934b79..cf1af62 100644 --- a/srcs/database/include/sqlite3.h +++ b/srcs/libs/include/sqlite3/sqlite3.h @@ -257,9 +257,9 @@ SQLITE_API int sqlite3_threadsafe(void); /* ** CAPI3REF: Database Connection Handle -** KEYWORDS: {database connection} {database connections} +** KEYWORDS: {sqlitecipher connection} {sqlitecipher connections} ** -** Each open SQLite database is represented by a pointer to an instance of +** Each open SQLite sqlitecipher is represented by a pointer to an instance of ** the opaque structure named "sqlite3". It is useful to think of an sqlite3 ** pointer as an object. The [sqlite3_open()], [sqlite3_open16()], and ** [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()] @@ -326,14 +326,14 @@ typedef sqlite_uint64 sqlite3_uint64; ** [prepared statements], [sqlite3_blob_close | close] all [BLOB handles], and ** [sqlite3_backup_finish | finish] all [sqlite3_backup] objects associated ** with the [sqlite3] object prior to attempting to close the object. -** ^If the database connection is associated with unfinalized prepared +** ^If the sqlitecipher connection is associated with unfinalized prepared ** statements, BLOB handlers, and/or unfinished sqlite3_backup objects then -** sqlite3_close() will leave the database connection open and return +** sqlite3_close() will leave the sqlitecipher connection open and return ** [SQLITE_BUSY]. ^If sqlite3_close_v2() is called with unfinalized prepared ** statements, unclosed BLOB handlers, and/or unfinished sqlite3_backups, -** it returns [SQLITE_OK] regardless, but instead of deallocating the database -** connection immediately, it marks the database connection as an unusable -** "zombie" and makes arrangements to automatically deallocate the database +** it returns [SQLITE_OK] regardless, but instead of deallocating the sqlitecipher +** connection immediately, it marks the sqlitecipher connection as an unusable +** "zombie" and makes arrangements to automatically deallocate the sqlitecipher ** connection after all prepared statements are finalized, all BLOB handles ** are closed, and all backups have finished. The sqlite3_close_v2() interface ** is intended for use with host languages that are garbage collected, and @@ -371,7 +371,7 @@ typedef int (*sqlite3_callback)(void*,int,char**, char**); ** ** ^The sqlite3_exec() interface runs zero or more UTF-8 encoded, ** semicolon-separate SQL statements passed into its 2nd argument, -** in the context of the [database connection] passed in as its 1st +** in the context of the [sqlitecipher connection] passed in as its 1st ** argument. ^If the callback function of the 3rd argument to ** sqlite3_exec() is not NULL, then it is invoked for each result row ** coming out of the evaluated SQL statements. ^The 4th argument to @@ -408,22 +408,22 @@ typedef int (*sqlite3_callback)(void*,int,char**, char**); ** ** ^If the 2nd parameter to sqlite3_exec() is a NULL pointer, a pointer ** to an empty string, or a pointer that contains only whitespace and/or -** SQL comments, then no SQL statements are evaluated and the database +** SQL comments, then no SQL statements are evaluated and the sqlitecipher ** is not changed. ** ** Restrictions: ** **
Originally this option disabled all triggers. ^(However, since ** SQLite version 3.35.0, TEMP triggers are still allowed even if ** this option is off. So, in other words, this option now only disables -** triggers in the main database schema or in the schemas of ATTACH-ed +** triggers in the main sqlitecipher schema or in the schemas of ATTACH-ed ** databases.)^
Originally this option disabled all views. ^(However, since ** SQLite version 3.35.0, TEMP views are still allowed even if ** this option is off. So, in other words, this option now only disables -** views in the main database schema or in the schemas of ATTACH-ed +** views in the main sqlitecipher schema or in the schemas of ATTACH-ed ** databases.)^ ** ** [[SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER]] @@ -2230,19 +2230,19 @@ struct sqlite3_mem_methods { ** ** ** [[SQLITE_DBCONFIG_MAINDBNAME]]
Note that when the SQLITE_DBCONFIG_LEGACY_FILE_FORMAT setting is on, ** the [VACUUM] command will fail with an obscure error when attempting to @@ -2440,12 +2440,12 @@ SQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff); ** ** ^The sqlite3_last_insert_rowid(D) interface usually returns the [rowid] of ** the most recent successful [INSERT] into a rowid table or [virtual table] -** on database connection D. ^Inserts into [WITHOUT ROWID] tables are not +** on sqlitecipher connection D. ^Inserts into [WITHOUT ROWID] tables are not ** recorded. ^If no successful [INSERT]s into rowid tables have ever occurred -** on the database connection D, then sqlite3_last_insert_rowid(D) returns +** on the sqlitecipher connection D, then sqlite3_last_insert_rowid(D) returns ** zero. ** -** As well as being set automatically as rows are inserted into database +** As well as being set automatically as rows are inserted into sqlitecipher ** tables, the value returned by this function may be set explicitly by ** [sqlite3_set_last_insert_rowid()] ** @@ -2480,7 +2480,7 @@ SQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff); ** [last_insert_rowid() SQL function]. ** ** If a separate thread performs a new [INSERT] on the same -** database connection while the [sqlite3_last_insert_rowid()] +** sqlitecipher connection while the [sqlite3_last_insert_rowid()] ** function is running and thus changes the last insert [rowid], ** then the value returned by [sqlite3_last_insert_rowid()] is ** unpredictable and might not equal either the old or the new @@ -2494,7 +2494,7 @@ SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*); ** ** The sqlite3_set_last_insert_rowid(D, R) method allows the application to ** set the value returned by calling sqlite3_last_insert_rowid(D) to R -** without inserting a row into the database. +** without inserting a row into the sqlitecipher. */ SQLITE_API void sqlite3_set_last_insert_rowid(sqlite3*,sqlite3_int64); @@ -2504,7 +2504,7 @@ SQLITE_API void sqlite3_set_last_insert_rowid(sqlite3*,sqlite3_int64); ** ** ^These functions return the number of rows modified, inserted or ** deleted by the most recently completed INSERT, UPDATE or DELETE -** statement on the database connection specified by the only parameter. +** statement on the sqlitecipher connection specified by the only parameter. ** The two functions are identical except for the type of the return value ** and that if the number of rows modified by the most recent INSERT, UPDATE ** or DELETE is greater than the maximum value supported by type "int", then @@ -2545,7 +2545,7 @@ SQLITE_API void sqlite3_set_last_insert_rowid(sqlite3*,sqlite3_int64); ** program, the value returned reflects the number of rows modified by the ** previous INSERT, UPDATE or DELETE statement within the same trigger. ** -** If a separate thread makes changes on the same database connection +** If a separate thread makes changes on the same sqlitecipher connection ** while [sqlite3_changes()] is running then the value returned ** is unpredictable and not meaningful. ** @@ -2566,7 +2566,7 @@ SQLITE_API sqlite3_int64 sqlite3_changes64(sqlite3*); ** ** ^These functions return the total number of rows inserted, modified or ** deleted by all [INSERT], [UPDATE] or [DELETE] statements completed -** since the database connection was opened, including those executed as +** since the sqlitecipher connection was opened, including those executed as ** part of trigger programs. The two functions are identical except for the ** type of the return value and that if the number of rows modified by the ** connection exceeds the maximum value supported by type "int", then @@ -2580,13 +2580,13 @@ SQLITE_API sqlite3_int64 sqlite3_changes64(sqlite3*); ** are not counted. ** ** The [sqlite3_total_changes(D)] interface only reports the number -** of rows that changed due to SQL statement run against database -** connection D. Any changes by other database connections are ignored. -** To detect changes against a database file from other database +** of rows that changed due to SQL statement run against sqlitecipher +** connection D. Any changes by other sqlitecipher connections are ignored. +** To detect changes against a sqlitecipher file from other sqlitecipher ** connections use the [PRAGMA data_version] command or the ** [SQLITE_FCNTL_DATA_VERSION] [file control]. ** -** If a separate thread makes changes on the same database connection +** If a separate thread makes changes on the same sqlitecipher connection ** while [sqlite3_total_changes()] is running then the value ** returned is unpredictable and not meaningful. ** @@ -2606,15 +2606,15 @@ SQLITE_API sqlite3_int64 sqlite3_total_changes64(sqlite3*); ** CAPI3REF: Interrupt A Long-Running Query ** METHOD: sqlite3 ** -** ^This function causes any pending database operation to abort and +** ^This function causes any pending sqlitecipher operation to abort and ** return at its earliest opportunity. This routine is typically ** called in response to a user action such as pressing "Cancel" ** or Ctrl-C where the user wants a long query operation to halt ** immediately. ** ** ^It is safe to call this routine from a thread different from the -** thread that is currently running the database operation. But it -** is not safe to call this routine with a [database connection] that +** thread that is currently running the sqlitecipher operation. But it +** is not safe to call this routine with a [sqlitecipher connection] that ** is closed or might close before sqlite3_interrupt() returns. ** ** ^If an SQL operation is very nearly finished at the time when @@ -2627,7 +2627,7 @@ SQLITE_API sqlite3_int64 sqlite3_total_changes64(sqlite3*); ** will be rolled back automatically. ** ** ^The sqlite3_interrupt(D) call is in effect until all currently running -** SQL statements on [database connection] D complete. ^Any new SQL statements +** SQL statements on [sqlitecipher connection] D complete. ^Any new SQL statements ** that are started after the sqlite3_interrupt() call and before the ** running statement count reaches zero are interrupted as if they had been ** running prior to the sqlite3_interrupt() call. ^New SQL statements @@ -2682,8 +2682,8 @@ SQLITE_API int sqlite3_complete16(const void *sql); ** ** ^The sqlite3_busy_handler(D,X,P) routine sets a callback function X ** that might be invoked with argument P whenever -** an attempt is made to access a database table associated with -** [database connection] D when another thread +** an attempt is made to access a sqlitecipher table associated with +** [sqlitecipher connection] D when another thread ** or process has the table locked. ** The sqlite3_busy_handler() interface is used to implement ** [sqlite3_busy_timeout()] and [PRAGMA busy_timeout]. @@ -2697,10 +2697,10 @@ SQLITE_API int sqlite3_complete16(const void *sql); ** the busy handler callback is the number of times that the busy handler has ** been invoked previously for the same locking event. ^If the ** busy callback returns 0, then no additional attempts are made to -** access the database and [SQLITE_BUSY] is returned +** access the sqlitecipher and [SQLITE_BUSY] is returned ** to the application. ** ^If the callback returns non-zero, then another attempt -** is made to access the database and the cycle repeats. +** is made to access the sqlitecipher and the cycle repeats. ** ** The presence of a busy handler does not guarantee that it will be invoked ** when there is lock contention. ^If SQLite determines that invoking the busy @@ -2721,17 +2721,17 @@ SQLITE_API int sqlite3_complete16(const void *sql); ** ^The default busy callback is NULL. ** ** ^(There can only be a single busy handler defined for each -** [database connection]. Setting a new busy handler clears any +** [sqlitecipher connection]. Setting a new busy handler clears any ** previously set handler.)^ ^Note that calling [sqlite3_busy_timeout()] ** or evaluating [PRAGMA busy_timeout=N] will change the ** busy handler and thus clear any previously set busy handler. ** ** The busy callback should not take any actions which modify the -** database connection that invoked the busy handler. In other words, +** sqlitecipher connection that invoked the busy handler. In other words, ** the busy handler is not reentrant. Any such actions ** result in undefined behavior. ** -** A busy handler must not close the database connection +** A busy handler must not close the sqlitecipher connection ** or [prepared statement] that invoked the busy handler. */ SQLITE_API int sqlite3_busy_handler(sqlite3*,int(*)(void*,int),void*); @@ -2751,7 +2751,7 @@ SQLITE_API int sqlite3_busy_handler(sqlite3*,int(*)(void*,int),void*); ** turns off all busy handlers. ** ** ^(There can only be a single busy handler for a particular -** [database connection] at any given moment. If another busy handler +** [sqlitecipher connection] at any given moment. If another busy handler ** was defined (using [sqlite3_busy_handler()]) prior to calling ** this routine, that other busy handler is cleared.)^ ** @@ -2833,7 +2833,7 @@ SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms); ** [sqlite3_errmsg()]. */ SQLITE_API int sqlite3_get_table( - sqlite3 *db, /* An open database */ + sqlite3 *db, /* An open sqlitecipher */ const char *zSql, /* SQL to be evaluated */ char ***pazResult, /* Results of the query */ int *pnRow, /* Number of result rows written here */ @@ -3024,7 +3024,7 @@ SQLITE_API void sqlite3_randomness(int N, void *P); ** KEYWORDS: {authorizer callback} ** ** ^This routine registers an authorizer callback with a particular -** [database connection], supplied in the first argument. +** [sqlitecipher connection], supplied in the first argument. ** ^The authorizer callback is invoked as SQL statements are being compiled ** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()], ** [sqlite3_prepare_v3()], [sqlite3_prepare16()], [sqlite3_prepare16_v2()], @@ -3073,28 +3073,28 @@ SQLITE_API void sqlite3_randomness(int N, void *P); ** An authorizer is used when [sqlite3_prepare | preparing] ** SQL statements from an untrusted source, to ensure that the SQL statements ** do not try to access data they are not allowed to see, or that they do not -** try to execute malicious statements that damage the database. For +** try to execute malicious statements that damage the sqlitecipher. For ** example, an application may allow a user to enter arbitrary -** SQL queries for evaluation by a database. But the application does +** SQL queries for evaluation by a sqlitecipher. But the application does ** not want the user to be able to make arbitrary changes to the -** database. An authorizer could then be put in place while the +** sqlitecipher. An authorizer could then be put in place while the ** user-entered SQL is being [sqlite3_prepare | prepared] that ** disallows everything except [SELECT] statements. ** ** Applications that need to process SQL from untrusted sources ** might also consider lowering resource limits using [sqlite3_limit()] -** and limiting database size using the [max_page_count] [PRAGMA] +** and limiting sqlitecipher size using the [max_page_count] [PRAGMA] ** in addition to using an authorizer. ** -** ^(Only a single authorizer can be in place on a database connection +** ^(Only a single authorizer can be in place on a sqlitecipher connection ** at a time. Each call to sqlite3_set_authorizer overrides the ** previous call.)^ ^Disable the authorizer by installing a NULL callback. ** The authorizer is disabled by default. ** ** The authorizer callback must not do anything that will modify -** the database connection that invoked the authorizer callback. +** the sqlitecipher connection that invoked the authorizer callback. ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their -** database connections for the meaning of "modify" in this paragraph. +** sqlitecipher connections for the meaning of "modify" in this paragraph. ** ** ^When [sqlite3_prepare_v2()] is used to prepare a statement, the ** statement might be re-prepared during [sqlite3_step()] due to a @@ -3141,7 +3141,7 @@ SQLITE_API int sqlite3_set_authorizer( ** authorized. The 3rd and 4th parameters to the authorization ** callback function will be parameters or NULL depending on which of these ** codes is used as the second parameter. ^(The 5th parameter to the -** authorizer callback is the name of the database ("main", "temp", +** authorizer callback is the name of the sqlitecipher ("main", "temp", ** etc.) if applicable.)^ ^The 6th parameter to the authorizer callback ** is the name of the inner-most trigger or view that is responsible for ** the access attempt or NULL if this access attempt is directly from @@ -3266,9 +3266,9 @@ SQLITE_API SQLITE_DEPRECATED void *sqlite3_profile(sqlite3*, ** X argument is unused. ** ** [[SQLITE_TRACE_CLOSE]]
** -** But because the [SELECT] statement does not change the database file +** But because the [SELECT] statement does not change the sqlitecipher file ** directly, sqlite3_stmt_readonly() would still return true.)^ ** ** ^Transaction control statements such as [BEGIN], [COMMIT], [ROLLBACK], ** [SAVEPOINT], and [RELEASE] cause sqlite3_stmt_readonly() to return true, -** since the statements themselves do not actually modify the database but +** since the statements themselves do not actually modify the sqlitecipher but ** rather they control the timing of when other statements modify the -** database. ^The [ATTACH] and [DETACH] statements also cause +** sqlitecipher. ^The [ATTACH] and [DETACH] statements also cause ** sqlite3_stmt_readonly() to return true since, while those statements -** change the configuration of a database connection, they do not make -** changes to the content of the database files on disk. +** change the configuration of a sqlitecipher connection, they do not make +** changes to the content of the sqlitecipher files on disk. ** ^The sqlite3_stmt_readonly() interface returns true for [BEGIN] since ** [BEGIN] merely sets internal flags, but the [BEGIN|BEGIN IMMEDIATE] and -** [BEGIN|BEGIN EXCLUSIVE] commands do touch the database and so +** [BEGIN|BEGIN EXCLUSIVE] commands do touch the sqlitecipher and so ** sqlite3_stmt_readonly() returns false for those commands. ** ** ^This routine returns false if there is any possibility that the -** statement might change the database file. ^A false return does -** not guarantee that the statement will change the database file. +** statement might change the sqlitecipher file. ^A false return does +** not guarantee that the statement will change the sqlitecipher file. ** ^For example, an UPDATE statement might have a WHERE clause that ** makes it a no-op, but the sqlite3_stmt_readonly() result would still ** be false. ^Similarly, a CREATE TABLE IF NOT EXISTS statement is a @@ -4317,7 +4317,7 @@ SQLITE_API int sqlite3_stmt_isexplain(sqlite3_stmt *pStmt); ** object, then the behavior is undefined and probably undesirable. ** ** This interface can be used in combination [sqlite3_next_stmt()] -** to locate all prepared statements associated with a database +** to locate all prepared statements associated with a sqlitecipher ** connection that are in need of being reset. This can be used, ** for example, in diagnostic routines to search for prepared ** statements that are holding a transaction open. @@ -4329,7 +4329,7 @@ SQLITE_API int sqlite3_stmt_busy(sqlite3_stmt*); ** KEYWORDS: {protected sqlite3_value} {unprotected sqlite3_value} ** ** SQLite uses the sqlite3_value object to represent all values -** that can be stored in a database table. SQLite uses dynamic typing +** that can be stored in a sqlitecipher table. SQLite uses dynamic typing ** for the values it stores. ^Values stored in sqlite3_value objects ** can be integers, floating point values, strings, BLOBs, or NULL. ** @@ -4665,12 +4665,12 @@ SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N); ** CAPI3REF: Source Of Data In A Query Result ** METHOD: sqlite3_stmt ** -** ^These routines provide a means to determine the database, table, and +** ^These routines provide a means to determine the sqlitecipher, table, and ** table column that is the origin of a particular result column in ** [SELECT] statement. -** ^The name of the database or table or column can be returned as +** ^The name of the sqlitecipher or table or column can be returned as ** either a UTF-8 or UTF-16 string. ^The _database_ routines return -** the database name, the _table_ routines return the table name, and +** the sqlitecipher name, the _table_ routines return the table name, and ** the origin_ routines return the column name. ** ^The returned string is valid until the [prepared statement] is destroyed ** using [sqlite3_finalize()] or until the statement is automatically @@ -4679,7 +4679,7 @@ SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N); ** again in a different encoding. ** ** ^The names returned are the original un-aliased names of the -** database, table, and column. +** sqlitecipher, table, and column. ** ** ^The first argument to these interfaces is a [prepared statement]. ** ^These functions return information about the Nth result column returned by @@ -4689,7 +4689,7 @@ SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N); ** ^If the Nth column returned by the statement is an expression or ** subquery and is not a column value, then all of these functions return ** NULL. ^These routines might also return NULL if a memory allocation error -** occurs. ^Otherwise, they return the name of the attached database, table, +** occurs. ^Otherwise, they return the name of the attached sqlitecipher, table, ** or column that query result column was extracted from. ** ** ^As with all other SQLite APIs, those whose names end with "16" return @@ -4722,7 +4722,7 @@ SQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt*,int); ** expression or subquery, then a NULL pointer is returned. ** ^The returned string is always UTF-8 encoded. ** -** ^(For example, given the database schema: +** ^(For example, given the sqlitecipher schema: ** ** CREATE TABLE t1(c1 VARIANT); ** @@ -4766,8 +4766,8 @@ SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int); ** ^With the "v2" interface, any of the other [result codes] or ** [extended result codes] might be returned as well. ** -** ^[SQLITE_BUSY] means that the database engine was unable to acquire the -** database locks it needs to do its job. ^If the statement is a [COMMIT] +** ^[SQLITE_BUSY] means that the sqlitecipher engine was unable to acquire the +** sqlitecipher locks it needs to do its job. ^If the statement is a [COMMIT] ** or occurs outside of an explicit transaction, then you can retry the ** statement. If the statement is not a [COMMIT] and occurs within an ** explicit transaction then you should rollback the transaction before @@ -4796,7 +4796,7 @@ SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int); ** Perhaps it was called on a [prepared statement] that has ** already been [sqlite3_finalize | finalized] or on one that had ** previously returned [SQLITE_ERROR] or [SQLITE_DONE]. Or it could -** be the case that the same database connection is being used by two or +** be the case that the same sqlitecipher connection is being used by two or ** more threads at the same moment in time. ** ** For all versions of SQLite up to and including 3.6.23.1, a call to @@ -4981,7 +4981,7 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt); ** ** ^Strings returned by sqlite3_column_text16() always have the endianness ** which is native to the platform, regardless of the text encoding set -** for the database. +** for the sqlitecipher. ** ** Warning: ^The object returned by [sqlite3_column_value()] is an ** [unprotected sqlite3_value] object. In a multithreaded environment, @@ -5091,7 +5091,7 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt); ** Valid SQL NULL returns can be distinguished from out-of-memory errors ** by invoking the [sqlite3_errcode()] immediately after the suspect ** return value is obtained and before any -** other SQLite interface is called on the same [database connection]. +** other SQLite interface is called on the same [sqlitecipher connection]. */ SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol); SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol); @@ -5174,10 +5174,10 @@ SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt); ** is similar, but allows the user to supply the extra callback functions ** needed by [aggregate window functions]. ** -** ^The first parameter is the [database connection] to which the SQL -** function is to be added. ^If an application uses more than one database +** ^The first parameter is the [sqlitecipher connection] to which the SQL +** function is to be added. ^If an application uses more than one sqlitecipher ** connection then application-defined SQL functions must be added -** to each database connection separately. +** to each sqlitecipher connection separately. ** ** ^The second parameter is the name of the SQL function to be created or ** redefined. ^The length of the name is limited to 255 bytes in a UTF-8 @@ -5223,12 +5223,12 @@ SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt); ** For best security, the [SQLITE_DIRECTONLY] flag is recommended for ** all application-defined SQL functions that do not need to be ** used inside of triggers, view, CHECK constraints, or other elements of -** the database schema. This flags is especially recommended for SQL +** the sqlitecipher schema. This flags is especially recommended for SQL ** functions that have side effects or reveal internal application state. ** Without this flag, an attacker might be able to modify the schema of -** a database file to include invocations of the function with parameters +** a sqlitecipher file to include invocations of the function with parameters ** chosen by the attacker, which the application will then execute when -** the database file is opened and read. +** the sqlitecipher file is opened and read. ** ** ^(The fifth parameter is an arbitrary pointer. The implementation of the ** function can gain access to this pointer using [sqlite3_user_data()].)^ @@ -5256,7 +5256,7 @@ SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt); ** ^(If the final parameter to sqlite3_create_function_v2() or ** sqlite3_create_window_function() is not NULL, then it is destructor for ** the application data pointer. The destructor is invoked when the function -** is deleted, either by being overloaded or when the database connection +** is deleted, either by being overloaded or when the sqlitecipher connection ** closes.)^ ^The destructor is also invoked if the call to ** sqlite3_create_function_v2() fails. ^When the destructor callback is ** invoked, it is passed a single argument which is a copy of the application @@ -5269,7 +5269,7 @@ SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt); ** SQL function is used. ^A function implementation with a non-negative ** nArg parameter is a better match than a function implementation with ** a negative nArg. ^A function where the preferred text encoding -** matches the database encoding is a better +** matches the sqlitecipher encoding is a better ** match than a function where the encoding is different. ** ^A function where the encoding difference is between UTF16le and UTF16be ** is a closer match than a function where the encoding difference is @@ -5279,7 +5279,7 @@ SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt); ** ** ^An application-defined function is permitted to call other ** SQLite interfaces. However, such calls must not -** close the database connection nor finalize or reset the prepared +** close the sqlitecipher connection nor finalize or reset the prepared ** statement in which the function is running. */ SQLITE_API int sqlite3_create_function( @@ -5555,7 +5555,7 @@ SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int6 ** Valid SQL NULL returns can be distinguished from out-of-memory errors ** by invoking the [sqlite3_errcode()] immediately after the suspect ** return value is obtained and before any -** other SQLite interface is called on the same [database connection]. +** other SQLite interface is called on the same [sqlitecipher connection]. */ SQLITE_API const void *sqlite3_value_blob(sqlite3_value*); SQLITE_API double sqlite3_value_double(sqlite3_value*); @@ -5668,7 +5668,7 @@ SQLITE_API void *sqlite3_user_data(sqlite3_context*); ** METHOD: sqlite3_context ** ** ^The sqlite3_context_db_handle() interface returns a copy of -** the pointer to the [database connection] (the 1st parameter) +** the pointer to the [sqlitecipher connection] (the 1st parameter) ** of the [sqlite3_create_function()] ** and [sqlite3_create_function16()] routines that originally ** registered the application defined function. @@ -5943,7 +5943,7 @@ SQLITE_API void sqlite3_result_subtype(sqlite3_context*,unsigned int); ** METHOD: sqlite3 ** ** ^These functions add, remove, or modify a [collation] associated -** with the [database connection] specified as the first argument. +** with the [sqlitecipher connection] specified as the first argument. ** ** ^The name of the collation is a UTF-8 string ** for sqlite3_create_collation() and sqlite3_create_collation_v2() @@ -6006,7 +6006,7 @@ SQLITE_API void sqlite3_result_subtype(sqlite3_context*,unsigned int); ** the collating function is deleted. ** ^Collating functions are deleted when they are overridden by later ** calls to the collation creation functions or when the -** [database connection] is closed using [sqlite3_close()]. +** [sqlitecipher connection] is closed using [sqlite3_close()]. ** ** ^The xDestroy callback is not called if the ** sqlite3_create_collation_v2() function fails. Applications that invoke @@ -6046,9 +6046,9 @@ SQLITE_API int sqlite3_create_collation16( ** CAPI3REF: Collation Needed Callbacks ** METHOD: sqlite3 ** -** ^To avoid having to register all collation sequences before a database +** ^To avoid having to register all collation sequences before a sqlitecipher ** can be used, a single callback function may be registered with the -** [database connection] to be invoked whenever an undefined collation +** [sqlitecipher connection] to be invoked whenever an undefined collation ** sequence is required. ** ** ^If the function is registered using the sqlite3_collation_needed() API, @@ -6059,7 +6059,7 @@ SQLITE_API int sqlite3_create_collation16( ** ** ^(When the callback is invoked, the first argument passed is a copy ** of the second argument to sqlite3_collation_needed() or -** sqlite3_collation_needed16(). The second argument is the database +** sqlite3_collation_needed16(). The second argument is the sqlitecipher ** connection. The third argument is one of [SQLITE_UTF8], [SQLITE_UTF16BE], ** or [SQLITE_UTF16LE], indicating the most desirable form of the collation ** sequence function required. The fourth parameter is the name of the @@ -6083,7 +6083,7 @@ SQLITE_API int sqlite3_collation_needed16( /* BEGIN SQLCIPHER */ #ifdef SQLITE_HAS_CODEC /* -** Specify the key for an encrypted database. This routine should be +** Specify the key for an encrypted sqlitecipher. This routine should be ** called right after sqlite3_open(). ** ** The code to implement this API is not available in the public release @@ -6095,29 +6095,29 @@ SQLITE_API int sqlite3_key( ); SQLITE_API int sqlite3_key_v2( sqlite3 *db, /* Database to be rekeyed */ - const char *zDbName, /* Name of the database */ + const char *zDbName, /* Name of the sqlitecipher */ const void *pKey, int nKey /* The key */ ); /* -** Change the key on an open database. If the current database is not +** Change the key on an open sqlitecipher. If the current sqlitecipher is not ** encrypted, this routine will encrypt it. If pNew==0 or nNew==0, the -** database is decrypted. +** sqlitecipher is decrypted. ** ** The code to implement this API is not available in the public release ** of SQLite. */ /* SQLCipher usage note: - If the current database is plaintext SQLCipher will NOT encrypt it. - If the current database is encrypted and pNew==0 or nNew==0, SQLCipher + If the current sqlitecipher is plaintext SQLCipher will NOT encrypt it. + If the current sqlitecipher is encrypted and pNew==0 or nNew==0, SQLCipher will NOT decrypt it. - This routine will ONLY work on an already encrypted database in order + This routine will ONLY work on an already encrypted sqlitecipher in order to change the key. Conversion from plaintext-to-encrypted or encrypted-to-plaintext should - use an ATTACHed database and the sqlcipher_export() convenience function + use an ATTACHed sqlitecipher and the sqlcipher_export() convenience function as per the SQLCipher Documentation. */ SQLITE_API int sqlite3_rekey( @@ -6126,12 +6126,12 @@ SQLITE_API int sqlite3_rekey( ); SQLITE_API int sqlite3_rekey_v2( sqlite3 *db, /* Database to be rekeyed */ - const char *zDbName, /* Name of the database */ + const char *zDbName, /* Name of the sqlitecipher */ const void *pKey, int nKey /* The new key */ ); /* -** Specify the activation key for a SEE database. Unless +** Specify the activation key for a SEE sqlitecipher. Unless ** activated, none of the SEE routines will work. */ SQLITE_API void sqlite3_activate_see( @@ -6142,7 +6142,7 @@ SQLITE_API void sqlite3_activate_see( #ifdef SQLITE_ENABLE_CEROD /* -** Specify the activation key for a CEROD database. Unless +** Specify the activation key for a CEROD sqlitecipher. Unless ** activated, none of the CEROD routines will work. */ SQLITE_API void sqlite3_activate_cerod( @@ -6188,7 +6188,7 @@ SQLITE_API int sqlite3_sleep(int); ** ** It is not safe to read or modify this variable in more than one ** thread at a time. It is not safe to read or modify this variable -** if a [database connection] is being used at the same time in a separate +** if a [sqlitecipher connection] is being used at the same time in a separate ** thread. ** It is intended that this variable be set once ** as part of process initialization and before any SQLite interface @@ -6207,7 +6207,7 @@ SQLITE_API int sqlite3_sleep(int); ** Except when requested by the [temp_store_directory pragma], SQLite ** does not free the memory that sqlite3_temp_directory points to. If ** the application wants that memory to be freed, it must do -** so itself, taking care to only do so after all [database connection] +** so itself, taking care to only do so after all [sqlitecipher connection] ** objects have been destroyed. ** ** Note to Windows Runtime users: The temporary directory must be set @@ -6231,21 +6231,21 @@ SQLITE_API SQLITE_EXTERN char *sqlite3_temp_directory; ** CAPI3REF: Name Of The Folder Holding Database Files ** ** ^(If this global variable is made to point to a string which is -** the name of a folder (a.k.a. directory), then all database files +** the name of a folder (a.k.a. directory), then all sqlitecipher files ** specified with a relative pathname and created or accessed by ** SQLite when using a built-in windows [sqlite3_vfs | VFS] will be assumed ** to be relative to that directory.)^ ^If this variable is a NULL -** pointer, then SQLite assumes that all database files specified +** pointer, then SQLite assumes that all sqlitecipher files specified ** with a relative pathname are relative to the current directory ** for the process. Only the windows VFS makes use of this global ** variable; it is ignored by the unix VFS. ** -** Changing the value of this variable while a database connection is -** open can result in a corrupt database. +** Changing the value of this variable while a sqlitecipher connection is +** open can result in a corrupt sqlitecipher. ** ** It is not safe to read or modify this variable in more than one ** thread at a time. It is not safe to read or modify this variable -** if a [database connection] is being used at the same time in a separate +** if a [sqlitecipher connection] is being used at the same time in a separate ** thread. ** It is intended that this variable be set once ** as part of process initialization and before any SQLite interface @@ -6305,7 +6305,7 @@ SQLITE_API int sqlite3_win32_set_directory16(unsigned long type, const void *zVa ** METHOD: sqlite3 ** ** ^The sqlite3_get_autocommit() interface returns non-zero or -** zero if the given database connection is or is not in autocommit mode, +** zero if the given sqlitecipher connection is or is not in autocommit mode, ** respectively. ^Autocommit mode is on by default. ** ^Autocommit mode is disabled by a [BEGIN] statement. ** ^Autocommit mode is re-enabled by a [COMMIT] or [ROLLBACK]. @@ -6317,7 +6317,7 @@ SQLITE_API int sqlite3_win32_set_directory16(unsigned long type, const void *zVa ** find out whether SQLite automatically rolled back the transaction after ** an error is to use this function. ** -** If another thread changes the autocommit status of the database +** If another thread changes the autocommit status of the sqlitecipher ** connection while this routine is running, then the return value ** is undefined. */ @@ -6327,9 +6327,9 @@ SQLITE_API int sqlite3_get_autocommit(sqlite3*); ** CAPI3REF: Find The Database Handle Of A Prepared Statement ** METHOD: sqlite3_stmt ** -** ^The sqlite3_db_handle interface returns the [database connection] handle -** to which a [prepared statement] belongs. ^The [database connection] -** returned by sqlite3_db_handle is the same [database connection] +** ^The sqlite3_db_handle interface returns the [sqlitecipher connection] handle +** to which a [prepared statement] belongs. ^The [sqlitecipher connection] +** returned by sqlite3_db_handle is the same [sqlitecipher connection] ** that was the first argument ** to the [sqlite3_prepare_v2()] call (or its variants) that was used to ** create the statement in the first place. @@ -6341,8 +6341,8 @@ SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*); ** METHOD: sqlite3 ** ** ^The sqlite3_db_name(D,N) interface returns a pointer to the schema name -** for the N-th database on database connection D, or a NULL pointer of N is -** out of range. An N value of 0 means the main database file. An N of 1 is +** for the N-th sqlitecipher on sqlitecipher connection D, or a NULL pointer of N is +** out of range. An N value of 0 means the main sqlitecipher file. An N of 1 is ** the "temp" schema. Larger values of N correspond to various ATTACH-ed ** databases. ** @@ -6352,7 +6352,7 @@ SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*); ** [sqlite3_serialize()] or [sqlite3_deserialize()], even operations that ** occur on a different thread. Applications that need to ** remember the string long-term should make their own copy. Applications that -** are accessing the same database connection simultaneously on multiple +** are accessing the same sqlitecipher connection simultaneously on multiple ** threads should mutex-protect calls to this API and should make their own ** private copy of the result prior to releasing the mutex. */ @@ -6363,19 +6363,19 @@ SQLITE_API const char *sqlite3_db_name(sqlite3 *db, int N); ** METHOD: sqlite3 ** ** ^The sqlite3_db_filename(D,N) interface returns a pointer to the filename -** associated with database N of connection D. -** ^If there is no attached database N on the database -** connection D, or if database N is a temporary or in-memory database, then +** associated with sqlitecipher N of connection D. +** ^If there is no attached sqlitecipher N on the sqlitecipher +** connection D, or if sqlitecipher N is a temporary or in-memory sqlitecipher, then ** this function will return either a NULL pointer or an empty string. ** ** ^The string value returned by this routine is owned and managed by -** the database connection. ^The value will be valid until the database N -** is [DETACH]-ed or until the database connection closes. +** the sqlitecipher connection. ^The value will be valid until the sqlitecipher N +** is [DETACH]-ed or until the sqlitecipher connection closes. ** ** ^The filename returned by this function is the output of the ** xFullPathname method of the [VFS]. ^In other words, the filename ** will be an absolute pathname, even if the filename used -** to open the database originally was a URI or relative pathname. +** to open the sqlitecipher originally was a URI or relative pathname. ** ** If the filename pointer returned by this routine is not NULL, then it ** can be used as the filename input parameter to these routines: @@ -6391,22 +6391,22 @@ SQLITE_API const char *sqlite3_db_name(sqlite3 *db, int N); SQLITE_API const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName); /* -** CAPI3REF: Determine if a database is read-only +** CAPI3REF: Determine if a sqlitecipher is read-only ** METHOD: sqlite3 ** -** ^The sqlite3_db_readonly(D,N) interface returns 1 if the database N +** ^The sqlite3_db_readonly(D,N) interface returns 1 if the sqlitecipher N ** of connection D is read-only, 0 if it is read/write, or -1 if N is not -** the name of a database on connection D. +** the name of a sqlitecipher on connection D. */ SQLITE_API int sqlite3_db_readonly(sqlite3 *db, const char *zDbName); /* -** CAPI3REF: Determine the transaction state of a database +** CAPI3REF: Determine the transaction state of a sqlitecipher ** METHOD: sqlite3 ** ** ^The sqlite3_txn_state(D,S) interface returns the current -** [transaction state] of schema S in database connection D. ^If S is NULL, -** then the highest transaction state of any schema on database connection D +** [transaction state] of schema S in sqlitecipher connection D. ^If S is NULL, +** then the highest transaction state of any schema on sqlitecipher connection D ** is returned. Transaction states are (in order of lowest to highest): **** SELECT eval('DELETE FROM t1') FROM t2; **
^If there are multiple ATTACH-ed database files that are being +**
^If there are multiple ATTACH-ed sqlitecipher files that are being ** modified as part of a transaction commit, then the autovacuum pages ** callback is invoked separately for each file. ** **
The callback is not reentrant. The callback function should ** not attempt to invoke any other SQLite interface. If it does, bad -** things may happen, including segmentation faults and corrupt database +** things may happen, including segmentation faults and corrupt sqlitecipher ** files. The callback function should be a simple function that ** does some arithmetic on its input parameters and returns a result. ** ** ^The X parameter to sqlite3_autovacuum_pages(D,C,P,X) is an optional ** destructor for the P parameter. ^If X is not NULL, then X(P) is -** invoked whenever the database connection closes or when the callback +** invoked whenever the sqlitecipher connection closes or when the callback ** is overwritten by another invocation of sqlite3_autovacuum_pages(). ** -**
^There is only one autovacuum pages callback per database connection. +**
^There is only one autovacuum pages callback per sqlitecipher connection. ** ^Each call to the sqlite3_autovacuum_pages() interface overrides all -** previous invocations for that database connection. ^If the callback +** previous invocations for that sqlitecipher connection. ^If the callback ** argument (C) to sqlite3_autovacuum_pages(D,C,P,X) is a NULL pointer, ** then the autovacuum steps callback is cancelled. The return value ** from sqlite3_autovacuum_pages() is normally SQLITE_OK, but might @@ -6588,11 +6588,11 @@ SQLITE_API int sqlite3_autovacuum_pages( ** METHOD: sqlite3 ** ** ^The sqlite3_update_hook() interface registers a callback function -** with the [database connection] identified by the first argument +** with the [sqlitecipher connection] identified by the first argument ** to be invoked whenever a row is updated, inserted or deleted in ** a [rowid table]. ** ^Any callback set by a previous call to this function -** for the same database connection is overridden. +** for the same sqlitecipher connection is overridden. ** ** ^The second argument is a pointer to the function to invoke when a ** row is updated, inserted or deleted in a rowid table. @@ -6602,7 +6602,7 @@ SQLITE_API int sqlite3_autovacuum_pages( ** or [SQLITE_UPDATE], depending on the operation that caused the callback ** to be invoked. ** ^The third and fourth arguments to the callback contain pointers to the -** database and table name containing the affected row. +** sqlitecipher and table name containing the affected row. ** ^The final callback parameter is the [rowid] of the row. ** ^In the case of an update, this is the [rowid] after the update takes place. ** @@ -6618,15 +6618,15 @@ SQLITE_API int sqlite3_autovacuum_pages( ** release of SQLite. ** ** The update hook implementation must not do anything that will modify -** the database connection that invoked the update hook. Any actions -** to modify the database connection must be deferred until after the +** the sqlitecipher connection that invoked the update hook. Any actions +** to modify the sqlitecipher connection must be deferred until after the ** completion of the [sqlite3_step()] call that triggered the update hook. ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their -** database connections for the meaning of "modify" in this paragraph. +** sqlitecipher connections for the meaning of "modify" in this paragraph. ** ** ^The sqlite3_update_hook(D,C,P) function ** returns the P argument from the previous call -** on the same [database connection] D, or NULL for +** on the same [sqlitecipher connection] D, or NULL for ** the first call on D. ** ** See also the [sqlite3_commit_hook()], [sqlite3_rollback_hook()], @@ -6641,9 +6641,9 @@ SQLITE_API void *sqlite3_update_hook( /* ** CAPI3REF: Enable Or Disable Shared Pager Cache ** -** ^(This routine enables or disables the sharing of the database cache -** and schema data structures between [database connection | connections] -** to the same database. Sharing is enabled if the argument is true +** ^(This routine enables or disables the sharing of the sqlitecipher cache +** and schema data structures between [sqlitecipher connection | connections] +** to the same sqlitecipher. Sharing is enabled if the argument is true ** and disabled if the argument is false.)^ ** ** ^Cache sharing is enabled and disabled for an entire process. @@ -6653,7 +6653,7 @@ SQLITE_API void *sqlite3_update_hook( ** ** ^(The cache sharing mode set by this interface effects all subsequent ** calls to [sqlite3_open()], [sqlite3_open_v2()], and [sqlite3_open16()]. -** Existing database connections continue to use the sharing mode +** Existing sqlitecipher connections continue to use the sharing mode ** that was in effect at the time they were opened.)^ ** ** ^(This routine returns [SQLITE_OK] if shared cache was enabled or disabled @@ -6664,12 +6664,12 @@ SQLITE_API void *sqlite3_update_hook( ** continues to be provided for historical compatibility, but its use is ** discouraged. Any use of shared cache is discouraged. If shared cache ** must be used, it is recommended that shared cache only be enabled for -** individual database connections using the [sqlite3_open_v2()] interface +** individual sqlitecipher connections using the [sqlite3_open_v2()] interface ** with the [SQLITE_OPEN_SHAREDCACHE] flag. ** ** Note: This method is disabled on MacOS X 10.7 and iOS version 5.0 ** and will always return SQLITE_MISUSE. On those systems, -** shared cache mode should be enabled per-database connection via +** shared cache mode should be enabled per-sqlitecipher connection via ** [sqlite3_open_v2()] with [SQLITE_OPEN_SHAREDCACHE]. ** ** This interface is threadsafe on processors where writing a @@ -6684,7 +6684,7 @@ SQLITE_API int sqlite3_enable_shared_cache(int); ** ** ^The sqlite3_release_memory() interface attempts to free N bytes ** of heap memory by deallocating non-essential memory allocations -** held by the database library. Memory used to cache database +** held by the sqlitecipher library. Memory used to cache sqlitecipher ** pages to improve performance is an example of non-essential memory. ** ^sqlite3_release_memory() returns the number of bytes actually freed, ** which might be more or less than the amount requested. @@ -6700,7 +6700,7 @@ SQLITE_API int sqlite3_release_memory(int); ** METHOD: sqlite3 ** ** ^The sqlite3_db_release_memory(D) interface attempts to free as much heap -** memory as possible from database connection D. Unlike the +** memory as possible from sqlitecipher connection D. Unlike the ** [sqlite3_release_memory()] interface, this interface is in effect even ** when the [SQLITE_ENABLE_MEMORY_MANAGEMENT] compile-time option is ** omitted. @@ -6713,7 +6713,7 @@ SQLITE_API int sqlite3_db_release_memory(sqlite3*); ** CAPI3REF: Impose A Limit On Heap Size ** ** These interfaces impose limits on the amount of heap memory that will be -** by all database connections within a single process. +** by all sqlitecipher connections within a single process. ** ** ^The sqlite3_soft_heap_limit64() interface sets and/or queries the ** soft limit on the amount of heap memory that may be allocated by SQLite. @@ -6793,8 +6793,8 @@ SQLITE_API SQLITE_DEPRECATED void sqlite3_soft_heap_limit(int N); ** METHOD: sqlite3 ** ** ^(The sqlite3_table_column_metadata(X,D,T,C,....) routine returns -** information about column C of table T in database D -** on [database connection] X.)^ ^The sqlite3_table_column_metadata() +** information about column C of table T in sqlitecipher D +** on [sqlitecipher connection] X.)^ ^The sqlite3_table_column_metadata() ** interface returns SQLITE_OK and fills in the non-NULL pointers in ** the final five arguments with appropriate values if the specified ** column exists. ^The sqlite3_table_column_metadata() interface returns @@ -6807,10 +6807,10 @@ SQLITE_API SQLITE_DEPRECATED void sqlite3_soft_heap_limit(int N); ** undefined behavior. ** ** ^The column is identified by the second, third and fourth parameters to -** this function. ^(The second parameter is either the name of the database -** (i.e. "main", "temp", or an attached database) containing the specified +** this function. ^(The second parameter is either the name of the sqlitecipher +** (i.e. "main", "temp", or an attached sqlitecipher) containing the specified ** table or NULL.)^ ^If it is NULL, then all attached databases are searched -** for the table using the same algorithm used by the database engine to +** for the table using the same algorithm used by the sqlitecipher engine to ** resolve unqualified table references. ** ** ^The third and fourth parameters to this function are the table and column @@ -6853,7 +6853,7 @@ SQLITE_API SQLITE_DEPRECATED void sqlite3_soft_heap_limit(int N); ** auto increment: 0 ** )^ ** -** ^This function causes all database schemas to be read from disk and +** ^This function causes all sqlitecipher schemas to be read from disk and ** parsed, if that has not already been done, and returns an error if ** any errors are encountered while loading the schema. */ @@ -6914,7 +6914,7 @@ SQLITE_API int sqlite3_table_column_metadata( ** See also the [load_extension() SQL function]. */ SQLITE_API int sqlite3_load_extension( - sqlite3 *db, /* Load the extension into this database connection */ + sqlite3 *db, /* Load the extension into this sqlitecipher connection */ const char *zFile, /* Name of the shared library containing extension */ const char *zProc, /* Entry point. Derived from zFile if 0 */ char **pzErrMsg /* Put error message here if not 0 */ @@ -6951,9 +6951,9 @@ SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff); ** CAPI3REF: Automatically Load Statically Linked Extensions ** ** ^This interface causes the xEntryPoint() function to be invoked for -** each new [database connection] that is created. The idea here is that +** each new [sqlitecipher connection] that is created. The idea here is that ** xEntryPoint() is the entry point for a statically linked [SQLite extension] -** that is to be automatically loaded into all new database connections. +** that is to be automatically loaded into all new sqlitecipher connections. ** ** ^(Even though the function prototype shows that xEntryPoint() takes ** no arguments and returns void, SQLite invokes xEntryPoint() with three @@ -6978,7 +6978,7 @@ SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff); ** ** ^Calling sqlite3_auto_extension(X) with an entry point X that is already ** on the list of automatic extensions is a harmless no-op. ^No entry point -** will be called more than once for each database connection that is opened. +** will be called more than once for each sqlitecipher connection that is opened. ** ** See also: [sqlite3_reset_auto_extension()] ** and [sqlite3_cancel_auto_extension()] @@ -7034,9 +7034,9 @@ typedef struct sqlite3_module sqlite3_module; ** instance of this structure and passing a pointer to that instance ** to [sqlite3_create_module()] or [sqlite3_create_module_v2()]. ** ^The registration remains valid until it is replaced by a different -** module or until the [database connection] closes. The content +** module or until the [sqlitecipher connection] closes. The content ** of this structure must not change while it is registered with -** any database connection. +** any sqlitecipher connection. */ struct sqlite3_module { int iVersion; @@ -7159,10 +7159,10 @@ struct sqlite3_module { ** SQLite also assumes that if a call to the xUpdate() method is made as ** part of the same statement to delete or update a virtual table row and the ** implementation returns SQLITE_CONSTRAINT, then there is no need to rollback -** any database changes. In other words, if the xUpdate() returns -** SQLITE_CONSTRAINT, the database contents must be exactly as they were +** any sqlitecipher changes. In other words, if the xUpdate() returns +** SQLITE_CONSTRAINT, the sqlitecipher contents must be exactly as they were ** before xUpdate was called. By contrast, if SQLITE_INDEX_SCAN_UNIQUE is not -** set and xUpdate returns SQLITE_CONSTRAINT, any database changes made by +** set and xUpdate returns SQLITE_CONSTRAINT, any sqlitecipher changes made by ** the xUpdate method are automatically rolled back by SQLite. ** ** IMPORTANT: The estimatedRows field was added to the sqlite3_index_info @@ -7284,7 +7284,7 @@ struct sqlite3_index_info { ** creating a new [virtual table] using the module and before using a ** preexisting [virtual table] for the module. ** -** ^The module name is registered on the [database connection] specified +** ^The module name is registered on the [sqlitecipher connection] specified ** by the first parameter. ^The name of the module is given by the ** second parameter. ^The third parameter is a pointer to ** the implementation of the [virtual table module]. ^The fourth @@ -7326,7 +7326,7 @@ SQLITE_API int sqlite3_create_module_v2( ** METHOD: sqlite3 ** ** ^The sqlite3_drop_modules(D,L) interface removes all virtual -** table modules from database connection D except those named on list L. +** table modules from sqlitecipher connection D except those named on list L. ** The L parameter must be either NULL or a pointer to an array of pointers ** to strings where the array is terminated by a single NULL pointer. ** ^If the L parameter is NULL, then all virtual table modules are removed. @@ -7444,18 +7444,18 @@ typedef struct sqlite3_blob sqlite3_blob; ** CONSTRUCTOR: sqlite3_blob ** ** ^(This interfaces opens a [BLOB handle | handle] to the BLOB located -** in row iRow, column zColumn, table zTable in database zDb; +** in row iRow, column zColumn, table zTable in sqlitecipher zDb; ** in other words, the same BLOB that would be selected by: ** **
** SELECT zColumn FROM zDb.zTable WHERE [rowid] = iRow; **)^ ** -** ^(Parameter zDb is not the filename that contains the database, but -** rather the symbolic name of the database. For attached databases, this is +** ^(Parameter zDb is not the filename that contains the sqlitecipher, but +** rather the symbolic name of the sqlitecipher. For attached databases, this is ** the name that appears after the AS keyword in the [ATTACH] statement. -** For the main database file, the database name is "main". For TEMP -** tables, the database name is "temp".)^ +** For the main sqlitecipher file, the sqlitecipher name is "main". For TEMP +** tables, the sqlitecipher name is "temp".)^ ** ** ^If the flags parameter is non-zero, then the BLOB is opened for read ** and write access. ^If the flags parameter is zero, the BLOB is opened for @@ -7470,7 +7470,7 @@ typedef struct sqlite3_blob sqlite3_blob; ** This function fails with SQLITE_ERROR if any of the following are true: **