Merge branch 'develop' of http://192.168.1.10:3000/PowerDA_TerminalDev/dcapp into develop
# Conflicts: # CMakeLists.txt resolved by develop version # datacenter/bizService/F-GetVersion.cpp resolved by develop version # datacenter/bizService/F-GetVersion.h resolved by develop version # datacenter/src/datacenter.cpp resolved by develop version
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* @Description: file content
|
||||
* @Author: why
|
||||
* @version:
|
||||
* @Date: 2025-02-28 14:24:09
|
||||
* @LastEditors: why
|
||||
* @LastEditTime: 2025-02-28 16:31:18
|
||||
*/
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "bizservice.h"
|
||||
#include "sqlite3/sqlite3.h"
|
||||
#include "F_Tool.h"
|
||||
class DeleteData:public IBizService,public Tool{
|
||||
public:
|
||||
void Init(initparam_t *param);
|
||||
int HandleMsg(const msg_t msg, msg_t &outMsg,handparam_t *param = NULL);
|
||||
std::string GetFID();
|
||||
DeleteData();
|
||||
~DeleteData();
|
||||
private:
|
||||
handparam_t * handpara;
|
||||
initparam_t * initpara;
|
||||
std::vector<std::string> topic;//0:dst 1:src 2:sid 3:fid
|
||||
int SQLBatch_exc(sqlite3 *db,std::vector<std::string> &sql_list,std::vector<int> &result);
|
||||
};
|
||||
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
* @Description: file content
|
||||
* @Author: why
|
||||
* @version:
|
||||
* @Date: 2025-02-28 14:24:59
|
||||
* @LastEditors: why
|
||||
* @LastEditTime: 2025-02-28 17:56:47
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <chrono>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <ctime>
|
||||
#include "json.hpp"
|
||||
#include "F_DeleteData.h"
|
||||
#include "bizservice.h"
|
||||
#include "sqlite3/sqlite3.h"
|
||||
using namespace std;
|
||||
using json = nlohmann::json ;// for convenience
|
||||
typedef unsigned char BYTE;
|
||||
|
||||
typedef struct topic{
|
||||
|
||||
std::string src;
|
||||
std::string des;
|
||||
std::string sid;
|
||||
std::string fid;
|
||||
} topic_type;
|
||||
|
||||
REGISTER_BIZSERVICE(DeleteData);
|
||||
|
||||
DeleteData::DeleteData(void){
|
||||
handpara = nullptr;
|
||||
initpara = nullptr;
|
||||
}
|
||||
|
||||
DeleteData::~DeleteData(void){
|
||||
}
|
||||
|
||||
void DeleteData::Init(initparam_t *param){
|
||||
initpara = param;
|
||||
}
|
||||
|
||||
static std::string search_table_db(int afn,unsigned int dataid){
|
||||
std::string table;
|
||||
return table;
|
||||
}
|
||||
|
||||
std::string DeleteData::GetFID(){
|
||||
std::string value("F-DeleteData");
|
||||
return value;
|
||||
}
|
||||
int DeleteData::SQLBatch_exc(sqlite3 *db,std::vector<std::string> &sql_list,std::vector<int> &result){
|
||||
char *errMsg = nullptr;
|
||||
const char *sql;
|
||||
int rc;
|
||||
int resp = 0;
|
||||
// 开启事务
|
||||
if (sqlite3_exec(db, "BEGIN TRANSACTION;", nullptr, nullptr, &errMsg) != SQLITE_OK) {
|
||||
std::cerr << "事务开启失败: " << errMsg << std::endl;
|
||||
sqlite3_free(errMsg);
|
||||
return -1;
|
||||
}
|
||||
// 执行批量插入操作
|
||||
sqlite3_stmt *stmt;
|
||||
int idx = 0;
|
||||
int count = 0;
|
||||
for(const auto &k:sql_list){
|
||||
std::cout << "cmd:"<<k.c_str()<<std::endl;
|
||||
if (sqlite3_prepare_v2(db, k.c_str(), -1, &stmt, nullptr) != SQLITE_OK) {
|
||||
std::cerr << "准备语句失败: " << sqlite3_errmsg(db) << std::endl;
|
||||
continue;
|
||||
}
|
||||
rc = sqlite3_step(stmt);
|
||||
|
||||
|
||||
if (rc != SQLITE_DONE) {
|
||||
std::cerr << "插入失败: " << sqlite3_errmsg(db) << std::endl;
|
||||
result[idx] = -1;
|
||||
}else
|
||||
result[idx] = 0; //SUCCESS
|
||||
|
||||
sqlite3_reset(stmt); // 重置语句
|
||||
}
|
||||
// 提交事务
|
||||
if (sqlite3_exec(db, "COMMIT;", nullptr, nullptr, &errMsg) != SQLITE_OK) {
|
||||
std::cerr << "事务提交失败: " << errMsg << std::endl;
|
||||
sqlite3_free(errMsg);
|
||||
resp = -1;
|
||||
}
|
||||
// 清理
|
||||
sqlite3_finalize(stmt);
|
||||
return resp;
|
||||
}
|
||||
|
||||
|
||||
int DeleteData::HandleMsg(const msg_t msg, msg_t &outMsg,handparam_t *param){
|
||||
|
||||
topic.clear();
|
||||
topic_split(msg.topic,'/',topic);
|
||||
json value,resp;
|
||||
int ret = 0;
|
||||
int afn_flag = 0, update_flag = 0;;
|
||||
std::vector<std::string> sql_list;
|
||||
std::vector<int> result;
|
||||
sql_list.clear();
|
||||
result.clear();
|
||||
std::string table_name ;
|
||||
try{
|
||||
value = json::parse(msg.payload);
|
||||
}
|
||||
catch(const std::exception &e){
|
||||
std::cout << "topic "<<msg.topic.c_str()<<" prase error:"<<e.what();
|
||||
return -1;//format fail
|
||||
}
|
||||
if(!value.is_object())return -1;
|
||||
if(value.contains("token")){
|
||||
resp["token"] = value["token"];
|
||||
}
|
||||
if(value.contains("time")){
|
||||
;// value["time"]
|
||||
}
|
||||
|
||||
std::stringstream ss;
|
||||
//table_name =search_table_db(afn,dataid);
|
||||
table_name = "frozen";
|
||||
ss << "delete from " <<table_name.c_str()<<";";
|
||||
printf("DeleteData sql:%s \n",ss.str().c_str());
|
||||
sql_list.push_back(ss.str());
|
||||
ss.clear();
|
||||
ret = SQLBatch_exc((sqlite3*)handpara,sql_list,result);
|
||||
resp_process:
|
||||
resp["time"]=now_to_string();
|
||||
resp["ack"]="true";
|
||||
ss << "/"<<topic[1].c_str()<<"/"<<topic[0].c_str()<<"/"\
|
||||
<<topic[2].c_str()<<"/"<<topic[3].c_str();
|
||||
outMsg.topic = ss.str();
|
||||
outMsg.timestamp = time(NULL);;
|
||||
outMsg.payload = resp.dump();
|
||||
std::cout << "resp DeleteData payload:"<<resp.dump().c_str()<<std::endl;
|
||||
return 1;
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
* @Description: file content
|
||||
* @Author: why
|
||||
* @version:
|
||||
* @Date: 2025-02-28 14:24:59
|
||||
* @LastEditors: why
|
||||
* @LastEditTime: 2025-02-28 17:56:39
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <chrono>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <ctime>
|
||||
#include "json.hpp"
|
||||
#include "F_FormatData.h"
|
||||
#include "bizservice.h"
|
||||
#include "sqlite3/sqlite3.h"
|
||||
using namespace std;
|
||||
using json = nlohmann::json ;// for convenience
|
||||
typedef unsigned char BYTE;
|
||||
|
||||
typedef struct topic{
|
||||
|
||||
std::string src;
|
||||
std::string des;
|
||||
std::string sid;
|
||||
std::string fid;
|
||||
} topic_type;
|
||||
|
||||
REGISTER_BIZSERVICE(FormatData);
|
||||
|
||||
FormatData::FormatData(void){
|
||||
handpara = nullptr;
|
||||
initpara = nullptr;
|
||||
}
|
||||
|
||||
FormatData::~FormatData(void){
|
||||
}
|
||||
|
||||
void FormatData::Init(initparam_t *param){
|
||||
initpara = param;
|
||||
}
|
||||
|
||||
static std::string search_table_db(int afn,unsigned int dataid){
|
||||
std::string table;
|
||||
return table;
|
||||
}
|
||||
|
||||
std::string FormatData::GetFID(){
|
||||
std::string value("F-FormatData");
|
||||
return value;
|
||||
}
|
||||
int FormatData::SQLBatch_exc(sqlite3 *db,std::vector<std::string> &sql_list,std::vector<int> &result){
|
||||
char *errMsg = nullptr;
|
||||
const char *sql;
|
||||
int rc;
|
||||
int resp = 0;
|
||||
// 开启事务
|
||||
if (sqlite3_exec(db, "BEGIN TRANSACTION;", nullptr, nullptr, &errMsg) != SQLITE_OK) {
|
||||
std::cerr << "事务开启失败: " << errMsg << std::endl;
|
||||
sqlite3_free(errMsg);
|
||||
return -1;
|
||||
}
|
||||
// 执行批量插入操作
|
||||
sqlite3_stmt *stmt;
|
||||
int idx = 0;
|
||||
int count = 0;
|
||||
for(const auto &k:sql_list){
|
||||
std::cout << "cmd:"<<k.c_str()<<std::endl;
|
||||
if (sqlite3_prepare_v2(db, k.c_str(), -1, &stmt, nullptr) != SQLITE_OK) {
|
||||
std::cerr << "准备语句失败: " << sqlite3_errmsg(db) << std::endl;
|
||||
continue;
|
||||
}
|
||||
rc = sqlite3_step(stmt);
|
||||
|
||||
|
||||
if (rc != SQLITE_DONE) {
|
||||
std::cerr << "插入失败: " << sqlite3_errmsg(db) << std::endl;
|
||||
result[idx] = -1;
|
||||
}else
|
||||
result[idx] = 0; //SUCCESS
|
||||
|
||||
sqlite3_reset(stmt); // 重置语句
|
||||
}
|
||||
// 提交事务
|
||||
if (sqlite3_exec(db, "COMMIT;", nullptr, nullptr, &errMsg) != SQLITE_OK) {
|
||||
std::cerr << "事务提交失败: " << errMsg << std::endl;
|
||||
sqlite3_free(errMsg);
|
||||
resp = -1;
|
||||
}
|
||||
// 清理
|
||||
sqlite3_finalize(stmt);
|
||||
return resp;
|
||||
}
|
||||
|
||||
|
||||
int FormatData::HandleMsg(const msg_t msg, msg_t &outMsg,handparam_t *param){
|
||||
|
||||
topic.clear();
|
||||
topic_split(msg.topic,'/',topic);
|
||||
json value,resp;
|
||||
int ret = 0;
|
||||
int afn_flag = 0, update_flag = 0;;
|
||||
std::vector<std::string> sql_list;
|
||||
std::vector<int> result;
|
||||
sql_list.clear();
|
||||
result.clear();
|
||||
std::string table_name ;
|
||||
try{
|
||||
value = json::parse(msg.payload);
|
||||
}
|
||||
catch(const std::exception &e){
|
||||
std::cout << "topic "<<msg.topic.c_str()<<" prase error:"<<e.what();
|
||||
return -1;//format fail
|
||||
}
|
||||
if(!value.is_object())return -1;
|
||||
if(value.contains("token")){
|
||||
resp["token"] = value["token"];
|
||||
}
|
||||
if(value.contains("time")){
|
||||
;// value["time"]
|
||||
}
|
||||
|
||||
std::stringstream ss;
|
||||
//table_name =search_table_db(afn,dataid);
|
||||
table_name = "frozen";
|
||||
ss << "delete from " <<table_name.c_str()<<";";
|
||||
printf("FormatData sql:%s \n",ss.str().c_str());
|
||||
sql_list.push_back(ss.str());
|
||||
ss.clear();
|
||||
ret = SQLBatch_exc((sqlite3*)handpara,sql_list,result);
|
||||
resp_process:
|
||||
resp["time"]=now_to_string();
|
||||
resp["ack"]="true";
|
||||
|
||||
ss << "/"<<topic[1].c_str()<<"/"<<topic[0].c_str()<<"/"\
|
||||
<<topic[2].c_str()<<"/"<<topic[3].c_str();
|
||||
outMsg.topic = ss.str();
|
||||
outMsg.timestamp = time(NULL);;
|
||||
outMsg.payload = resp.dump();
|
||||
std::cout << "resp FormatData payload:"<<resp.dump().c_str()<<std::endl;
|
||||
return 1;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* @Description: file content
|
||||
* @Author: why
|
||||
* @version:
|
||||
* @Date: 2025-02-28 14:24:09
|
||||
* @LastEditors: why
|
||||
* @LastEditTime: 2025-02-28 16:14:50
|
||||
*/
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "bizservice.h"
|
||||
#include "sqlite3/sqlite3.h"
|
||||
#include "F_Tool.h"
|
||||
class FormatData:public IBizService,public Tool{
|
||||
public:
|
||||
void Init(initparam_t *param);
|
||||
int HandleMsg(const msg_t msg, msg_t &outMsg,handparam_t *param = NULL);
|
||||
std::string GetFID();
|
||||
FormatData();
|
||||
~FormatData();
|
||||
private:
|
||||
handparam_t * handpara;
|
||||
initparam_t * initpara;
|
||||
std::vector<std::string> topic;//0:dst 1:src 2:sid 3:fid
|
||||
int SQLBatch_exc(sqlite3 *db,std::vector<std::string> &sql_list,std::vector<int> &result);
|
||||
};
|
||||
@@ -0,0 +1,171 @@
|
||||
/*
|
||||
* @Description: file content
|
||||
* @Author: why
|
||||
* @version:
|
||||
* @Date: 2025-02-28 08:22:32
|
||||
* @LastEditors: why
|
||||
* @LastEditTime: 2025-02-28 17:56:31
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <chrono>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <ctime>
|
||||
#include "json.hpp"
|
||||
#include "F_GetSaveCount.h"
|
||||
#include "bizservice.h"
|
||||
#include "sqlite3/sqlite3.h"
|
||||
using namespace std;
|
||||
using json = nlohmann::json ;// for convenience
|
||||
typedef unsigned char BYTE;
|
||||
|
||||
typedef struct topic{
|
||||
|
||||
std::string src;
|
||||
std::string des;
|
||||
std::string sid;
|
||||
std::string fid;
|
||||
} topic_type;
|
||||
|
||||
REGISTER_BIZSERVICE(GetSaveCount);
|
||||
|
||||
int GetSaveCount::SQLBatch_exc(sqlite3 *db,std::vector<std::string> &sql_list,std::vector<int> &result){
|
||||
char *errMsg = nullptr;
|
||||
const char *sql;
|
||||
int rc;
|
||||
int resp = 0;
|
||||
// 开启事务
|
||||
if (sqlite3_exec(db, "BEGIN TRANSACTION;", nullptr, nullptr, &errMsg) != SQLITE_OK) {
|
||||
std::cerr << "事务开启失败: " << errMsg << std::endl;
|
||||
sqlite3_free(errMsg);
|
||||
return -1;
|
||||
}
|
||||
// 执行批量插入操作
|
||||
sqlite3_stmt *stmt;
|
||||
int idx = 0;
|
||||
int count = 0;
|
||||
for(const auto &k:sql_list){
|
||||
std::cout << "cmd:"<<k.c_str()<<std::endl;
|
||||
if (sqlite3_prepare_v2(db, k.c_str(), -1, &stmt, nullptr) != SQLITE_OK) {
|
||||
std::cerr << "准备语句失败: " << sqlite3_errmsg(db) << std::endl;
|
||||
continue;
|
||||
}
|
||||
rc = sqlite3_step(stmt);
|
||||
while(rc == SQLITE_ROW){
|
||||
result[idx] = sqlite3_column_int(stmt, 0); // For integer columns use sqlite3_column_int()
|
||||
|
||||
}
|
||||
/*
|
||||
if (rc != SQLITE_DONE) {
|
||||
std::cerr << "插入失败: " << sqlite3_errmsg(db) << std::endl;
|
||||
result[idx] = "-1";
|
||||
}else
|
||||
result[idx] = "0"; //SUCCESS
|
||||
*/
|
||||
sqlite3_reset(stmt); // 重置语句
|
||||
}
|
||||
// 提交事务
|
||||
if (sqlite3_exec(db, "COMMIT;", nullptr, nullptr, &errMsg) != SQLITE_OK) {
|
||||
std::cerr << "事务提交失败: " << errMsg << std::endl;
|
||||
sqlite3_free(errMsg);
|
||||
resp = -1;
|
||||
}
|
||||
// 清理
|
||||
sqlite3_finalize(stmt);
|
||||
return resp;
|
||||
}
|
||||
|
||||
GetSaveCount::GetSaveCount(void){
|
||||
handpara = nullptr;
|
||||
initpara = nullptr;
|
||||
}
|
||||
|
||||
GetSaveCount::~GetSaveCount(void){
|
||||
}
|
||||
|
||||
void GetSaveCount::Init(initparam_t *param){
|
||||
initpara = param;
|
||||
}
|
||||
std::string GetSaveCount::GetFID(){
|
||||
std::string value("F-GetSaveCount");
|
||||
return value;
|
||||
|
||||
}
|
||||
int GetSaveCount::HandleMsg(const msg_t msg, msg_t &outMsg,handparam_t *param){
|
||||
|
||||
topic.clear();
|
||||
topic_split(msg.topic,'/',topic);
|
||||
json value,resp;
|
||||
int ret = 0;
|
||||
int afn_flag = 0, update_flag = 0;;
|
||||
std::vector<std::string> sql_list;
|
||||
std::vector<int> result;
|
||||
sql_list.clear();
|
||||
result.clear();
|
||||
std::string table_name ;
|
||||
try{
|
||||
value = json::parse(msg.payload);
|
||||
}
|
||||
catch(const std::exception &e){
|
||||
std::cout << "topic "<<msg.topic.c_str()<<" prase error:"<<e.what();
|
||||
return -1;//format fail
|
||||
}
|
||||
if(!value.is_object())return -1;
|
||||
if(value.contains("token")){
|
||||
resp["token"] = value["token"];
|
||||
}
|
||||
if(value.contains("time")){
|
||||
;// value["time"]
|
||||
}
|
||||
if(value.contains("data")){
|
||||
json subvalue = value["data"];
|
||||
int afn = 0;
|
||||
int dataid = 0;
|
||||
decode_blob(&dataid,4, subvalue["dataid"].get<std::string>().c_str());
|
||||
decode_blob(&afn,4,subvalue["afn"].get<std::string>().c_str());
|
||||
std::stringstream ss;
|
||||
//table_name =search_table_db(afn,dataid);
|
||||
table_name = "frozen";
|
||||
int choice = std::stoi(subvalue["choice"].get<std::string>());
|
||||
time_t from = 0,to = time(NULL);
|
||||
std::string colum("");
|
||||
switch(choice){
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
colum = "createdtime";
|
||||
from = std::stoi(subvalue["from"].get<std::string>());
|
||||
to = std::stoi(subvalue["to"].get<std::string>());
|
||||
break;
|
||||
case 2:
|
||||
colum = "frozentime";
|
||||
from = std::stoi(subvalue["from"].get<std::string>());
|
||||
to = std::stoi(subvalue["to"].get<std::string>());
|
||||
break;
|
||||
default:
|
||||
return -1;//illegal
|
||||
|
||||
}
|
||||
ss << "seletc count (*) from " <<table_name.c_str()\
|
||||
<<"where dataid = '"<<subvalue["dataid"].get<std::string>().c_str()<<"' and"\
|
||||
<<"metid = "<< std::stoi(subvalue["metid"].get<std::string>())<<" and"\
|
||||
<<colum.c_str() <<" >= "<< from<<" and " <<colum.c_str() <<" <= "<< to<<";";
|
||||
printf("getcount sql:%s \n",ss.str().c_str());
|
||||
sql_list.push_back(ss.str());
|
||||
ss.clear();
|
||||
}
|
||||
ret = SQLBatch_exc((sqlite3*)handpara,sql_list,result);
|
||||
resp_process:
|
||||
resp["time"]=now_to_string();
|
||||
resp["data"]["savecount"]=result[0];
|
||||
|
||||
std::stringstream ss;
|
||||
ss << "/"<<topic[1].c_str()<<"/"<<topic[0].c_str()<<"/"\
|
||||
<<topic[2].c_str()<<"/"<<topic[3].c_str();
|
||||
outMsg.topic = ss.str();
|
||||
outMsg.timestamp = time(NULL);;
|
||||
outMsg.payload = resp.dump();
|
||||
std::cout << "resp UpdateRecord payload:"<<resp.dump().c_str()<<std::endl;
|
||||
return 1;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* @Description: file content
|
||||
* @Author: why
|
||||
* @version:
|
||||
* @Date: 2025-02-28 08:20:54
|
||||
* @LastEditors: why
|
||||
* @LastEditTime: 2025-02-28 14:34:34
|
||||
*/
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "bizservice.h"
|
||||
#include "sqlite3/sqlite3.h"
|
||||
#include "F_Tool.h"
|
||||
class GetSaveCount : public IBizService,public Tool
|
||||
{
|
||||
public:
|
||||
void Init(initparam_t *param);
|
||||
int HandleMsg(const msg_t msg,msg_t &outMsg, handparam_t *param);
|
||||
std::string GetFID();
|
||||
GetSaveCount();
|
||||
~GetSaveCount();
|
||||
private:
|
||||
handparam_t * handpara;
|
||||
initparam_t * initpara;
|
||||
std::vector<std::string> topic;//0:dst 1:src 2:sid 3:fid
|
||||
int SQLBatch_exc(sqlite3 *db,std::vector<std::string> &sql_list,std::vector<int> &result);
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
/*
|
||||
* @Description: file content
|
||||
* @Author: why
|
||||
* @version:
|
||||
* @Date: 2025-02-28 14:24:59
|
||||
* @LastEditors: why
|
||||
* @LastEditTime: 2025-02-28 17:55:48
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <chrono>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <ctime>
|
||||
#include "json.hpp"
|
||||
#include "F_GetSupportNum.h"
|
||||
#include "bizservice.h"
|
||||
#include "sqlite3/sqlite3.h"
|
||||
using namespace std;
|
||||
using json = nlohmann::json ;// for convenience
|
||||
typedef unsigned char BYTE;
|
||||
|
||||
typedef struct topic{
|
||||
|
||||
std::string src;
|
||||
std::string des;
|
||||
std::string sid;
|
||||
std::string fid;
|
||||
} topic_type;
|
||||
|
||||
REGISTER_BIZSERVICE(GetSupportNum);
|
||||
|
||||
GetSupportNum::GetSupportNum(void){
|
||||
handpara = nullptr;
|
||||
initpara = nullptr;
|
||||
}
|
||||
|
||||
GetSupportNum::~GetSupportNum(void){
|
||||
}
|
||||
|
||||
void GetSupportNum::Init(initparam_t *param){
|
||||
initpara = param;
|
||||
}
|
||||
|
||||
static std::string search_table_db(int afn,unsigned int dataid){
|
||||
std::string table;
|
||||
return table;
|
||||
}
|
||||
|
||||
std::string GetSupportNum::GetFID(){
|
||||
std::string value("F-GetSupportNum");
|
||||
return value;
|
||||
}
|
||||
int GetSupportNum::SQLBatch_exc(sqlite3 *db,std::vector<std::string> &sql_list,std::vector<int> &result){
|
||||
char *errMsg = nullptr;
|
||||
const char *sql;
|
||||
int rc;
|
||||
int resp = 0;
|
||||
// 开启事务
|
||||
if (sqlite3_exec(db, "BEGIN TRANSACTION;", nullptr, nullptr, &errMsg) != SQLITE_OK) {
|
||||
std::cerr << "事务开启失败: " << errMsg << std::endl;
|
||||
sqlite3_free(errMsg);
|
||||
return -1;
|
||||
}
|
||||
// 执行批量插入操作
|
||||
sqlite3_stmt *stmt;
|
||||
int idx = 0;
|
||||
int count = 0;
|
||||
for(const auto &k:sql_list){
|
||||
std::cout << "cmd:"<<k.c_str()<<std::endl;
|
||||
if (sqlite3_prepare_v2(db, k.c_str(), -1, &stmt, nullptr) != SQLITE_OK) {
|
||||
std::cerr << "准备语句失败: " << sqlite3_errmsg(db) << std::endl;
|
||||
continue;
|
||||
}
|
||||
rc = sqlite3_step(stmt);
|
||||
while(rc == SQLITE_ROW){
|
||||
result[idx] = sqlite3_column_int(stmt, 0); // For integer columns use sqlite3_column_int()
|
||||
|
||||
}
|
||||
/*
|
||||
if (rc != SQLITE_DONE) {
|
||||
std::cerr << "插入失败: " << sqlite3_errmsg(db) << std::endl;
|
||||
result[idx] = "-1";
|
||||
}else
|
||||
result[idx] = "0"; //SUCCESS
|
||||
*/
|
||||
sqlite3_reset(stmt); // 重置语句
|
||||
}
|
||||
// 提交事务
|
||||
if (sqlite3_exec(db, "COMMIT;", nullptr, nullptr, &errMsg) != SQLITE_OK) {
|
||||
std::cerr << "事务提交失败: " << errMsg << std::endl;
|
||||
sqlite3_free(errMsg);
|
||||
resp = -1;
|
||||
}
|
||||
// 清理
|
||||
sqlite3_finalize(stmt);
|
||||
return resp;
|
||||
}
|
||||
|
||||
|
||||
int GetSupportNum::HandleMsg(const msg_t msg, msg_t &outMsg,handparam_t *param){
|
||||
|
||||
topic.clear();
|
||||
topic_split(msg.topic,'/',topic);
|
||||
json value,resp;
|
||||
int ret = 0;
|
||||
int afn_flag = 0, update_flag = 0;;
|
||||
std::vector<std::string> sql_list;
|
||||
std::vector<int> result;
|
||||
sql_list.clear();
|
||||
result.clear();
|
||||
std::string table_name ;
|
||||
try{
|
||||
value = json::parse(msg.payload);
|
||||
}
|
||||
catch(const std::exception &e){
|
||||
std::cout << "topic "<<msg.topic.c_str()<<" prase error:"<<e.what();
|
||||
return -1;//format fail
|
||||
}
|
||||
if(!value.is_object())return -1;
|
||||
if(value.contains("token")){
|
||||
resp["token"] = value["token"];
|
||||
}
|
||||
if(value.contains("time")){
|
||||
;// value["time"]
|
||||
}
|
||||
if(value.contains("data")){
|
||||
json subvalue = value["data"];
|
||||
int afn = 0;
|
||||
int dataid = 0;
|
||||
decode_blob(&dataid,4, subvalue["dataid"].get<std::string>().c_str());
|
||||
decode_blob(&afn,4,subvalue["afn"].get<std::string>().c_str());
|
||||
std::stringstream ss;
|
||||
//table_name =search_table_db(afn,dataid);
|
||||
table_name = "frozen";
|
||||
ss << "seletc count (*) from " <<table_name.c_str()\
|
||||
<<"where dataid = '"<<subvalue["dataid"].get<std::string>().c_str()<<"' and"\
|
||||
<<"metid = "<< std::stoi(subvalue["metid"].get<std::string>())<<";";
|
||||
printf("getsupportnum sql:%s \n",ss.str().c_str());
|
||||
sql_list.push_back(ss.str());
|
||||
ss.clear();
|
||||
}
|
||||
ret = SQLBatch_exc((sqlite3*)handpara,sql_list,result);
|
||||
resp_process:
|
||||
resp["time"]=now_to_string();
|
||||
resp["data"]["support"]=62;
|
||||
|
||||
std::stringstream ss;
|
||||
ss << "/"<<topic[1].c_str()<<"/"<<topic[0].c_str()<<"/"\
|
||||
<<topic[2].c_str()<<"/"<<topic[3].c_str();
|
||||
outMsg.topic = ss.str();
|
||||
outMsg.timestamp = time(NULL);;
|
||||
outMsg.payload = resp.dump();
|
||||
std::cout << "resp UpdateRecord payload:"<<resp.dump().c_str()<<std::endl;
|
||||
return 1;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* @Description: file content
|
||||
* @Author: why
|
||||
* @version:
|
||||
* @Date: 2025-02-28 14:24:09
|
||||
* @LastEditors: why
|
||||
* @LastEditTime: 2025-02-28 14:48:56
|
||||
*/
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "bizservice.h"
|
||||
#include "sqlite3/sqlite3.h"
|
||||
#include "F_Tool.h"
|
||||
class GetSupportNum:public IBizService,public Tool{
|
||||
public:
|
||||
void Init(initparam_t *param);
|
||||
int HandleMsg(const msg_t msg, msg_t &outMsg,handparam_t *param = NULL);
|
||||
std::string GetFID();
|
||||
GetSupportNum();
|
||||
~GetSupportNum();
|
||||
private:
|
||||
handparam_t * handpara;
|
||||
initparam_t * initpara;
|
||||
std::vector<std::string> topic;//0:dst 1:src 2:sid 3:fid
|
||||
int SQLBatch_exc(sqlite3 *db,std::vector<std::string> &sql_list,std::vector<int> &result);
|
||||
};
|
||||
@@ -0,0 +1,278 @@
|
||||
/*
|
||||
* @Description: file content
|
||||
* @Author: why
|
||||
* @version:
|
||||
* @Date: 2025-02-21 14:03:54
|
||||
* @LastEditors: why
|
||||
* @LastEditTime: 2025-02-28 17:55:37
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <chrono>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <ctime>
|
||||
#include "json.hpp"
|
||||
#include "F_InsertRecord.h"
|
||||
#include "bizservice.h"
|
||||
#include "sqlite3/sqlite3.h"
|
||||
using namespace std;
|
||||
using json = nlohmann::json ;// for convenience
|
||||
typedef unsigned char BYTE;
|
||||
|
||||
typedef struct topic{
|
||||
|
||||
std::string src;
|
||||
std::string des;
|
||||
std::string sid;
|
||||
std::string fid;
|
||||
} topic_type;
|
||||
|
||||
REGISTER_BIZSERVICE(InsertRecord);
|
||||
|
||||
InsertRecord::InsertRecord(void){
|
||||
handpara = nullptr;
|
||||
initpara = nullptr;
|
||||
}
|
||||
|
||||
InsertRecord::~InsertRecord(void){
|
||||
}
|
||||
|
||||
void InsertRecord::Init(initparam_t *param){
|
||||
initpara = param;
|
||||
}
|
||||
void hexstr_to_str(void *dst, const void *src, int src_len)
|
||||
{
|
||||
int i;
|
||||
BYTE low, high, ch;
|
||||
BYTE *dst_ptr = (BYTE *) dst;
|
||||
const BYTE *src_ptr = (const BYTE *) src;
|
||||
|
||||
for (i = 0; i < src_len / 2; i++)
|
||||
{
|
||||
ch = *src_ptr++;
|
||||
if (ch >= '0' && ch <= '9')
|
||||
high = ch - '0';
|
||||
else if (ch >= 'A' && ch <= 'F')
|
||||
high = ch - 'A' + 10;
|
||||
else if (ch >= 'a' && ch <= 'f')
|
||||
high = ch - 'a' + 10;
|
||||
else
|
||||
break;
|
||||
ch = *src_ptr++;
|
||||
if (ch >= '0' && ch <= '9')
|
||||
low = ch - '0';
|
||||
else if (ch >= 'A' && ch <= 'F')
|
||||
low = ch - 'A' + 10;
|
||||
else if (ch >= 'a' && ch <= 'f')
|
||||
low = ch - 'a' + 10;
|
||||
else
|
||||
break;
|
||||
*dst_ptr++ = high * 16 + low; //hex
|
||||
}
|
||||
}
|
||||
|
||||
void str_to_hexstr(void *dst, const void *src, int src_len)
|
||||
{
|
||||
int i;
|
||||
BYTE low, high, ch;
|
||||
char *dst_ptr = (char *) dst;
|
||||
const char *src_ptr = (const char *) src;
|
||||
const char *str = "0123456789abcdef";
|
||||
|
||||
for (i = 0; i < src_len; i++)
|
||||
{
|
||||
ch = *src_ptr++;
|
||||
high = (ch >> 4) & 0x0f;
|
||||
low = ch & 0x0f;
|
||||
*dst_ptr++ = str[high];
|
||||
*dst_ptr++ = str[low];
|
||||
}
|
||||
}
|
||||
int encode_blob(void *dst, int max_len, const void *src, int src_len)
|
||||
{
|
||||
int dst_len = 0;
|
||||
|
||||
// may be changed to base64 encode
|
||||
if (max_len >= src_len * 2 + 1)
|
||||
{
|
||||
dst_len = src_len * 2;
|
||||
str_to_hexstr(dst, src, src_len);
|
||||
}
|
||||
((BYTE *) dst)[dst_len] = 0x00;
|
||||
return dst_len;
|
||||
}
|
||||
|
||||
int decode_blob(void *dst, int max_len, const void *src)
|
||||
{
|
||||
// may be changed to base64 decode
|
||||
int src_len, dst_len = 0;
|
||||
|
||||
src_len = strlen((char *) src);
|
||||
if (max_len >= src_len / 2)
|
||||
{
|
||||
dst_len = src_len / 2;
|
||||
hexstr_to_str(dst, src, src_len);
|
||||
}
|
||||
return dst_len;
|
||||
}
|
||||
std::string InsertRecord::now_to_string() {
|
||||
// 获取系统时钟时间点
|
||||
auto time_now = std::chrono::system_clock::now();
|
||||
|
||||
// 将时间点转成time_t类型的值 (秒)
|
||||
std::time_t tt = std::chrono::system_clock::to_time_t(time_now);
|
||||
|
||||
// 转换成tm结构体形式
|
||||
struct tm* ptm = gmtime(&tt); // 或者 localtime(&tt) 如果想要本地时间
|
||||
ptm->tm_hour += 8; //utc -> cst
|
||||
// 计算出毫秒部分
|
||||
long milliseconds = std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
time_now.time_since_epoch()
|
||||
).count() % 1000;
|
||||
|
||||
char buffer[40];
|
||||
strftime(buffer, sizeof(buffer), "%Y-%m-%dT%H:%M:%S", ptm);
|
||||
|
||||
// 添加上毫秒和时区信息
|
||||
sprintf(buffer + strlen(buffer), ".%03ld+0800", milliseconds);
|
||||
|
||||
return std::string(buffer);
|
||||
}
|
||||
time_t InsertRecord::string_to_now(std::string stamp) {
|
||||
struct tm tm={};
|
||||
std::istringstream ss(stamp);
|
||||
ss >> std::get_time(&tm,"%Y-%m-%dT%H:%M:%S");
|
||||
if(ss.fail()){
|
||||
return -1;
|
||||
}
|
||||
return mktime(&tm);
|
||||
}
|
||||
|
||||
int InsertRecord::SQLBatch_exc(std::vector<std::string> &sql_list,std::vector<std::string> &result){
|
||||
sqlite3 *db = (sqlite3 *)handpara;
|
||||
char *errMsg = nullptr;
|
||||
const char *sql;
|
||||
int rc;
|
||||
int resp = 0;
|
||||
// 开启事务
|
||||
if (sqlite3_exec(db, "BEGIN TRANSACTION;", nullptr, nullptr, &errMsg) != SQLITE_OK) {
|
||||
std::cerr << "事务开启失败: " << errMsg << std::endl;
|
||||
sqlite3_free(errMsg);
|
||||
return -1;
|
||||
}
|
||||
// 执行批量插入操作
|
||||
sqlite3_stmt *stmt;
|
||||
int idx = 0;
|
||||
for(const auto &k:sql_list){
|
||||
std::cout << "cmd:"<<k.c_str()<<std::endl;
|
||||
if (sqlite3_prepare_v2(db, k.c_str(), -1, &stmt, nullptr) != SQLITE_OK) {
|
||||
std::cerr << "准备语句失败: " << sqlite3_errmsg(db) << std::endl;
|
||||
continue;
|
||||
}
|
||||
rc = sqlite3_step(stmt);
|
||||
if (rc != SQLITE_DONE) {
|
||||
std::cerr << "插入失败: " << sqlite3_errmsg(db) << std::endl;
|
||||
result[idx] = "-1";
|
||||
}else
|
||||
result[idx] = "0"; //SUCCESS
|
||||
sqlite3_reset(stmt); // 重置语句
|
||||
}
|
||||
// 提交事务
|
||||
if (sqlite3_exec(db, "COMMIT;", nullptr, nullptr, &errMsg) != SQLITE_OK) {
|
||||
std::cerr << "事务提交失败: " << errMsg << std::endl;
|
||||
sqlite3_free(errMsg);
|
||||
resp = -1;
|
||||
}
|
||||
// 清理
|
||||
sqlite3_finalize(stmt);
|
||||
return resp;
|
||||
}
|
||||
int InsertRecord::HandleMsg(const msg_t msg, msg_t &outMsg,handparam_t *param){
|
||||
|
||||
topic.clear();
|
||||
topic_split(msg.topic,'/');
|
||||
json value,resp;
|
||||
int ret = 0;
|
||||
int afn_flag = 0;
|
||||
std::vector<std::string> sql_list;
|
||||
std::vector<std::string> result;
|
||||
sql_list.clear();
|
||||
result.clear();
|
||||
std::string table_name("dayfrozen");
|
||||
try{
|
||||
value = json::parse(msg.payload);
|
||||
}
|
||||
catch(const std::exception &e){
|
||||
std::cout << "topic "<<msg.topic.c_str()<<" parse error:"<<e.what();
|
||||
return -1;//format fail
|
||||
}
|
||||
printf("insert request:%s \n",msg.payload.c_str());
|
||||
if(!value.is_object())return -1;
|
||||
if(value.contains("token")){
|
||||
resp["token"] = value["token"];
|
||||
}
|
||||
if(value.contains("time")){
|
||||
;// value["time"]
|
||||
}
|
||||
if(value.contains("data") && value["data"].contains("dataarray")){
|
||||
json subvalue = value["data"]["dataarray"];
|
||||
if(subvalue.is_array()){
|
||||
int idx = 0;
|
||||
for(const auto &k:subvalue){
|
||||
std::stringstream ss;
|
||||
if(k["afn"].get<std::string>() != "0D"){
|
||||
afn_flag = -1;
|
||||
continue;
|
||||
}
|
||||
//根据afn/idclass 确定数据库表位置 待添加
|
||||
ss << "insert into " <<table_name.c_str() <<" (idx,metid,dataid,frozentime,createdtime,source,crcaux,databuff) values ("\
|
||||
<< 0 << ","\
|
||||
<<std::stoi(k["metid"].get<std::string>())<<","\
|
||||
<<k["dataid"].get<std::string>().c_str()<<","\
|
||||
<<string_to_now(k["frozentime"].get<std::string>())<<","\
|
||||
<<time(NULL)<<","\
|
||||
<<std::stoi(k["crcaux"].get<std::string>())<<","\
|
||||
<<k["databuff"].get<std::string>().c_str()<<");";
|
||||
printf("insert sql:%s \n",ss.str().c_str());
|
||||
sql_list.push_back(ss.str());
|
||||
ss.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
// ret = SQLBatch_exc(sql_list,result);
|
||||
resp["time"]=now_to_string();
|
||||
if(ret == -1 || afn_flag == -1)
|
||||
resp["ack"]="false";
|
||||
else if(ret == 0)
|
||||
resp["ack"]="true";
|
||||
|
||||
resp["data"]["dataidex"]=result;
|
||||
std::stringstream ss;
|
||||
ss << "/"<<topic[1].c_str()<<"/"<<topic[0].c_str()<<"/"\
|
||||
<<topic[2].c_str()<<"/"<<topic[3].c_str();
|
||||
outMsg.topic = ss.str();
|
||||
outMsg.timestamp = time(NULL);
|
||||
outMsg.payload = resp.dump();
|
||||
std::cout << "resp InsertRecord payload:"<<resp.dump().c_str()<<std::endl;
|
||||
return 1;
|
||||
}
|
||||
std::string InsertRecord::GetFID(){
|
||||
std::string value("F-InsertRecord");
|
||||
return value;
|
||||
|
||||
}
|
||||
void InsertRecord::topic_split(const std::string& str, char delimiter) {
|
||||
std::string token; // 临时存储每个子字符串
|
||||
std::istringstream tokenStream(str); // 使用字符串流处理输入字符串
|
||||
// 按分隔符逐个读取子字符串
|
||||
while (std::getline(tokenStream, token, delimiter)) {
|
||||
topic.push_back(token); // 将子字符串添加到结果中
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* @Description: file content
|
||||
* @Author: why
|
||||
* @version:
|
||||
* @Date: 2025-02-21 14:04:30
|
||||
* @LastEditors: why
|
||||
* @LastEditTime: 2025-02-26 15:13:26
|
||||
*/
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "bizservice.h"
|
||||
class InsertRecord : public IBizService
|
||||
{
|
||||
public:
|
||||
void Init(initparam_t *param);
|
||||
int HandleMsg(const msg_t msg,msg_t &outMsg, handparam_t *param);
|
||||
std::string GetFID();
|
||||
InsertRecord();
|
||||
~InsertRecord();
|
||||
private:
|
||||
handparam_t * handpara;
|
||||
initparam_t * initpara;
|
||||
std::vector<std::string> topic;//0:dst 1:src 2:sid 3:fid
|
||||
void topic_split(const std::string& str, char delimiter);
|
||||
int SQLBatch_exc(std::vector<std::string> &sql_list,std::vector<std::string> &result);
|
||||
std::string now_to_string();
|
||||
time_t string_to_now(std::string stamp);
|
||||
};
|
||||
@@ -0,0 +1,158 @@
|
||||
/*
|
||||
* @Description: file content
|
||||
* @Author: why
|
||||
* @version:
|
||||
* @Date: 2025-02-28 14:24:59
|
||||
* @LastEditors: why
|
||||
* @LastEditTime: 2025-02-28 17:56:12
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <chrono>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <ctime>
|
||||
#include "json.hpp"
|
||||
#include "F_SetSupportNum.h"
|
||||
#include "bizservice.h"
|
||||
#include "sqlite3/sqlite3.h"
|
||||
using namespace std;
|
||||
using json = nlohmann::json ;// for convenience
|
||||
typedef unsigned char BYTE;
|
||||
|
||||
typedef struct topic{
|
||||
|
||||
std::string src;
|
||||
std::string des;
|
||||
std::string sid;
|
||||
std::string fid;
|
||||
} topic_type;
|
||||
|
||||
REGISTER_BIZSERVICE(SetSupportNum);
|
||||
|
||||
SetSupportNum::SetSupportNum(void){
|
||||
handpara = nullptr;
|
||||
initpara = nullptr;
|
||||
}
|
||||
|
||||
SetSupportNum::~SetSupportNum(void){
|
||||
}
|
||||
|
||||
void SetSupportNum::Init(initparam_t *param){
|
||||
initpara = param;
|
||||
}
|
||||
|
||||
static std::string search_table_db(int afn,unsigned int dataid){
|
||||
std::string table;
|
||||
return table;
|
||||
}
|
||||
|
||||
std::string SetSupportNum::GetFID(){
|
||||
std::string value("F-SetSupportNum");
|
||||
return value;
|
||||
}
|
||||
int SetSupportNum::SQLBatch_exc(sqlite3 *db,std::vector<std::string> &sql_list,std::vector<int> &result){
|
||||
char *errMsg = nullptr;
|
||||
const char *sql;
|
||||
int rc;
|
||||
int resp = 0;
|
||||
// 开启事务
|
||||
if (sqlite3_exec(db, "BEGIN TRANSACTION;", nullptr, nullptr, &errMsg) != SQLITE_OK) {
|
||||
std::cerr << "事务开启失败: " << errMsg << std::endl;
|
||||
sqlite3_free(errMsg);
|
||||
return -1;
|
||||
}
|
||||
// 执行批量插入操作
|
||||
sqlite3_stmt *stmt;
|
||||
int idx = 0;
|
||||
int count = 0;
|
||||
for(const auto &k:sql_list){
|
||||
std::cout << "cmd:"<<k.c_str()<<std::endl;
|
||||
if (sqlite3_prepare_v2(db, k.c_str(), -1, &stmt, nullptr) != SQLITE_OK) {
|
||||
std::cerr << "准备语句失败: " << sqlite3_errmsg(db) << std::endl;
|
||||
continue;
|
||||
}
|
||||
rc = sqlite3_step(stmt);
|
||||
while(rc == SQLITE_ROW){
|
||||
result[idx] = sqlite3_column_int(stmt, 0); // For integer columns use sqlite3_column_int()
|
||||
|
||||
}
|
||||
/*
|
||||
if (rc != SQLITE_DONE) {
|
||||
std::cerr << "插入失败: " << sqlite3_errmsg(db) << std::endl;
|
||||
result[idx] = "-1";
|
||||
}else
|
||||
result[idx] = "0"; //SUCCESS
|
||||
*/
|
||||
sqlite3_reset(stmt); // 重置语句
|
||||
}
|
||||
// 提交事务
|
||||
if (sqlite3_exec(db, "COMMIT;", nullptr, nullptr, &errMsg) != SQLITE_OK) {
|
||||
std::cerr << "事务提交失败: " << errMsg << std::endl;
|
||||
sqlite3_free(errMsg);
|
||||
resp = -1;
|
||||
}
|
||||
// 清理
|
||||
sqlite3_finalize(stmt);
|
||||
return resp;
|
||||
}
|
||||
|
||||
|
||||
int SetSupportNum::HandleMsg(const msg_t msg, msg_t &outMsg,handparam_t *param){
|
||||
|
||||
topic.clear();
|
||||
topic_split(msg.topic,'/',topic);
|
||||
json value,resp;
|
||||
int ret = 0;
|
||||
int afn_flag = 0, update_flag = 0;;
|
||||
std::vector<std::string> sql_list;
|
||||
std::vector<int> result;
|
||||
sql_list.clear();
|
||||
result.clear();
|
||||
std::string table_name ;
|
||||
try{
|
||||
value = json::parse(msg.payload);
|
||||
}
|
||||
catch(const std::exception &e){
|
||||
std::cout << "topic "<<msg.topic.c_str()<<" prase error:"<<e.what();
|
||||
return -1;//format fail
|
||||
}
|
||||
if(!value.is_object())return -1;
|
||||
if(value.contains("token")){
|
||||
resp["token"] = value["token"];
|
||||
}
|
||||
if(value.contains("time")){
|
||||
;// value["time"]
|
||||
}
|
||||
/*
|
||||
if(value.contains("data")){
|
||||
json subvalue = value["data"];
|
||||
int afn = 0;
|
||||
int dataid = 0;
|
||||
decode_blob(&dataid,4, subvalue["dataid"].get<std::string>().c_str());
|
||||
decode_blob(&afn,4,subvalue["afn"].get<std::string>().c_str());
|
||||
std::stringstream ss;
|
||||
//table_name =search_table_db(afn,dataid);
|
||||
table_name = "frozen";
|
||||
ss << "seletc count (*) from " <<table_name.c_str()\
|
||||
<<"where dataid = '"<<subvalue["dataid"].get<std::string>().c_str()<<"' and"\
|
||||
<<"metid = "<< std::stoi(subvalue["metid"].get<std::string>())<<";";
|
||||
printf("getsupportnum sql:%s \n",ss.str().c_str());
|
||||
sql_list.push_back(ss.str());
|
||||
ss.clear();
|
||||
}
|
||||
ret = SQLBatch_exc((sqlite3*)handpara,sql_list,result);
|
||||
*/
|
||||
resp_process:
|
||||
resp["time"]=now_to_string();
|
||||
resp["ack"]="true";
|
||||
|
||||
std::stringstream ss;
|
||||
ss << "/"<<topic[1].c_str()<<"/"<<topic[0].c_str()<<"/"\
|
||||
<<topic[2].c_str()<<"/"<<topic[3].c_str();
|
||||
outMsg.topic = ss.str();
|
||||
outMsg.timestamp = time(NULL);;
|
||||
outMsg.payload = resp.dump();
|
||||
std::cout << "resp UpdateRecord payload:"<<resp.dump().c_str()<<std::endl;
|
||||
return 1;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* @Description: file content
|
||||
* @Author: why
|
||||
* @version:
|
||||
* @Date: 2025-02-28 14:24:09
|
||||
* @LastEditors: why
|
||||
* @LastEditTime: 2025-02-28 15:00:24
|
||||
*/
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "bizservice.h"
|
||||
#include "sqlite3/sqlite3.h"
|
||||
#include "F_Tool.h"
|
||||
class SetSupportNum:public IBizService,public Tool{
|
||||
public:
|
||||
void Init(initparam_t *param);
|
||||
int HandleMsg(const msg_t msg, msg_t &outMsg,handparam_t *param = NULL);
|
||||
std::string GetFID();
|
||||
SetSupportNum();
|
||||
~SetSupportNum();
|
||||
private:
|
||||
handparam_t * handpara;
|
||||
initparam_t * initpara;
|
||||
std::vector<std::string> topic;//0:dst 1:src 2:sid 3:fid
|
||||
int SQLBatch_exc(sqlite3 *db,std::vector<std::string> &sql_list,std::vector<int> &result);
|
||||
};
|
||||
@@ -0,0 +1,126 @@
|
||||
#include <iostream>
|
||||
#include <chrono>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <ctime>
|
||||
#include "json.hpp"
|
||||
#include "F_tool.h"
|
||||
typedef unsigned char BYTE;
|
||||
void Tool::hexstr_to_str(void *dst, const void *src, int src_len)
|
||||
{
|
||||
int i;
|
||||
BYTE low, high, ch;
|
||||
BYTE *dst_ptr = (BYTE *) dst;
|
||||
const BYTE *src_ptr = (const BYTE *) src;
|
||||
|
||||
for (i = 0; i < src_len / 2; i++)
|
||||
{
|
||||
ch = *src_ptr++;
|
||||
if (ch >= '0' && ch <= '9')
|
||||
high = ch - '0';
|
||||
else if (ch >= 'A' && ch <= 'F')
|
||||
high = ch - 'A' + 10;
|
||||
else if (ch >= 'a' && ch <= 'f')
|
||||
high = ch - 'a' + 10;
|
||||
else
|
||||
break;
|
||||
ch = *src_ptr++;
|
||||
if (ch >= '0' && ch <= '9')
|
||||
low = ch - '0';
|
||||
else if (ch >= 'A' && ch <= 'F')
|
||||
low = ch - 'A' + 10;
|
||||
else if (ch >= 'a' && ch <= 'f')
|
||||
low = ch - 'a' + 10;
|
||||
else
|
||||
break;
|
||||
*dst_ptr++ = high * 16 + low; //hex
|
||||
}
|
||||
}
|
||||
|
||||
void Tool::str_to_hexstr(void *dst, const void *src, int src_len)
|
||||
{
|
||||
int i;
|
||||
BYTE low, high, ch;
|
||||
char *dst_ptr = (char *) dst;
|
||||
const char *src_ptr = (const char *) src;
|
||||
const char *str = "0123456789abcdef";
|
||||
|
||||
for (i = 0; i < src_len; i++)
|
||||
{
|
||||
ch = *src_ptr++;
|
||||
high = (ch >> 4) & 0x0f;
|
||||
low = ch & 0x0f;
|
||||
*dst_ptr++ = str[high];
|
||||
*dst_ptr++ = str[low];
|
||||
}
|
||||
}
|
||||
int Tool::encode_blob(void *dst, int max_len, const void *src, int src_len)
|
||||
{
|
||||
int dst_len = 0;
|
||||
|
||||
// may be changed to base64 encode
|
||||
if (max_len >= src_len * 2 + 1)
|
||||
{
|
||||
dst_len = src_len * 2;
|
||||
str_to_hexstr(dst, src, src_len);
|
||||
}
|
||||
((BYTE *) dst)[dst_len] = 0x00;
|
||||
return dst_len;
|
||||
}
|
||||
|
||||
int Tool::decode_blob(void *dst, int max_len, const void *src)
|
||||
{
|
||||
// may be changed to base64 decode
|
||||
int src_len, dst_len = 0;
|
||||
|
||||
src_len = strlen((char *) src);
|
||||
std::cout << "decode_blob src len "<< src_len<<std::endl;
|
||||
if (max_len >= src_len / 2)
|
||||
{
|
||||
dst_len = src_len / 2;
|
||||
hexstr_to_str(dst, src, src_len);
|
||||
}
|
||||
return dst_len;
|
||||
}
|
||||
void Tool::topic_split(const std::string& str, char delimiter,std::vector<std::string>& topic) {
|
||||
std::string token; // 临时存储每个子字符串
|
||||
std::istringstream tokenStream(str); // 使用字符串流处理输入字符串
|
||||
// 按分隔符逐个读取子字符串
|
||||
while (std::getline(tokenStream, token, delimiter)) {
|
||||
topic.push_back(token); // 将子字符串添加到结果中
|
||||
}
|
||||
|
||||
}
|
||||
std::string Tool::now_to_string() {
|
||||
// 获取系统时钟时间点
|
||||
auto time_now = std::chrono::system_clock::now();
|
||||
|
||||
// 将时间点转成time_t类型的值 (秒)
|
||||
std::time_t tt = std::chrono::system_clock::to_time_t(time_now);
|
||||
|
||||
// 转换成tm结构体形式
|
||||
struct tm* ptm = gmtime(&tt); // 或者 localtime(&tt) 如果想要本地时间
|
||||
ptm->tm_hour += 8; //utc -> cst
|
||||
// 计算出毫秒部分
|
||||
long milliseconds = std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
time_now.time_since_epoch()
|
||||
).count() % 1000;
|
||||
|
||||
char buffer[40];
|
||||
strftime(buffer, sizeof(buffer), "%Y-%m-%dT%H:%M:%S", ptm);
|
||||
|
||||
// 添加上毫秒和时区信息
|
||||
sprintf(buffer + strlen(buffer), ".%03ld+0800", milliseconds);
|
||||
|
||||
return std::string(buffer);
|
||||
}
|
||||
time_t Tool::string_to_now(std::string stamp) {
|
||||
struct tm tm={};
|
||||
std::istringstream ss(stamp);
|
||||
ss >> std::get_time(&tm,"%Y-%m-%dT%H:%M:%S");
|
||||
if(ss.fail()){
|
||||
return -1;
|
||||
}
|
||||
return mktime(&tm);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* @Description: file content
|
||||
* @Author: why
|
||||
* @version:
|
||||
* @Date: 2025-02-28 14:32:55
|
||||
* @LastEditors: why
|
||||
* @LastEditTime: 2025-02-28 16:28:59
|
||||
*/
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
class Tool{
|
||||
public :
|
||||
void topic_split(const std::string& str, char delimiter,std::vector<std::string>&topic);//0:dst 1:src 2:sid 3:fid
|
||||
std::string now_to_string();
|
||||
time_t string_to_now(std::string stamp);
|
||||
void hexstr_to_str(void *dst, const void *src, int src_len);
|
||||
void str_to_hexstr(void *dst, const void *src, int src_len);
|
||||
int encode_blob(void *dst, int max_len, const void *src, int src_len);
|
||||
int decode_blob(void *dst, int max_len, const void *src);
|
||||
//std::map<usigned int ,std::map<int,std::string>> Directionary;
|
||||
Tool(){};
|
||||
~Tool(){};
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,281 @@
|
||||
/*
|
||||
* @Description: file content
|
||||
* @Author: why
|
||||
* @version:
|
||||
* @Date: 2025-02-25 11:02:37
|
||||
* @LastEditors: why
|
||||
* @LastEditTime: 2025-02-28 17:56:00
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <chrono>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <ctime>
|
||||
#include "json.hpp"
|
||||
#include "F_UpdateRecord.h"
|
||||
#include "sqlite3/sqlite3.h"
|
||||
|
||||
using namespace std;
|
||||
using json = nlohmann::json; // for convenience
|
||||
typedef unsigned char BYTE;
|
||||
typedef struct topic{
|
||||
|
||||
std::string src;
|
||||
std::string des;
|
||||
std::string sid;
|
||||
std::string fid;
|
||||
} topic_type;
|
||||
REGISTER_BIZSERVICE(UpdateRecord);
|
||||
UpdateRecord::UpdateRecord(void){
|
||||
handpara = nullptr;
|
||||
initpara = nullptr;
|
||||
}
|
||||
static void hexstr_to_str(void *dst, const void *src, int src_len)
|
||||
{
|
||||
int i;
|
||||
BYTE low, high, ch;
|
||||
BYTE *dst_ptr = (BYTE *) dst;
|
||||
const BYTE *src_ptr = (const BYTE *) src;
|
||||
|
||||
for (i = 0; i < src_len / 2; i++)
|
||||
{
|
||||
ch = *src_ptr++;
|
||||
if (ch >= '0' && ch <= '9')
|
||||
high = ch - '0';
|
||||
else if (ch >= 'A' && ch <= 'F')
|
||||
high = ch - 'A' + 10;
|
||||
else if (ch >= 'a' && ch <= 'f')
|
||||
high = ch - 'a' + 10;
|
||||
else
|
||||
break;
|
||||
ch = *src_ptr++;
|
||||
if (ch >= '0' && ch <= '9')
|
||||
low = ch - '0';
|
||||
else if (ch >= 'A' && ch <= 'F')
|
||||
low = ch - 'A' + 10;
|
||||
else if (ch >= 'a' && ch <= 'f')
|
||||
low = ch - 'a' + 10;
|
||||
else
|
||||
break;
|
||||
*dst_ptr++ = high * 16 + low; //hex
|
||||
}
|
||||
}
|
||||
|
||||
static void str_to_hexstr(void *dst, const void *src, int src_len)
|
||||
{
|
||||
int i;
|
||||
BYTE low, high, ch;
|
||||
char *dst_ptr = (char *) dst;
|
||||
const char *src_ptr = (const char *) src;
|
||||
const char *str = "0123456789abcdef";
|
||||
|
||||
for (i = 0; i < src_len; i++)
|
||||
{
|
||||
ch = *src_ptr++;
|
||||
high = (ch >> 4) & 0x0f;
|
||||
low = ch & 0x0f;
|
||||
*dst_ptr++ = str[high];
|
||||
*dst_ptr++ = str[low];
|
||||
}
|
||||
}
|
||||
static int encode_blob(void *dst, int max_len, const void *src, int src_len)
|
||||
{
|
||||
int dst_len = 0;
|
||||
|
||||
// may be changed to base64 encode
|
||||
if (max_len >= src_len * 2 + 1)
|
||||
{
|
||||
dst_len = src_len * 2;
|
||||
str_to_hexstr(dst, src, src_len);
|
||||
}
|
||||
((BYTE *) dst)[dst_len] = 0x00;
|
||||
return dst_len;
|
||||
}
|
||||
|
||||
static int decode_blob(void *dst, int max_len, const void *src)
|
||||
{
|
||||
// may be changed to base64 decode
|
||||
int src_len, dst_len = 0;
|
||||
|
||||
src_len = strlen((char *) src);
|
||||
std::cout << "decode_blob src len "<< src_len<<std::endl;
|
||||
if (max_len >= src_len / 2)
|
||||
{
|
||||
dst_len = src_len / 2;
|
||||
hexstr_to_str(dst, src, src_len);
|
||||
}
|
||||
return dst_len;
|
||||
}
|
||||
UpdateRecord::~UpdateRecord(void){
|
||||
}
|
||||
std::string search_table_db(int afn,unsigned int dataid){
|
||||
std::string table;
|
||||
return table;
|
||||
}
|
||||
void UpdateRecord::Init(initparam_t *param){
|
||||
initpara = param;
|
||||
}
|
||||
std::string UpdateRecord::now_to_string() {
|
||||
// 获取系统时钟时间点
|
||||
auto time_now = std::chrono::system_clock::now();
|
||||
|
||||
// 将时间点转成time_t类型的值 (秒)
|
||||
std::time_t tt = std::chrono::system_clock::to_time_t(time_now);
|
||||
|
||||
// 转换成tm结构体形式
|
||||
struct tm* ptm = gmtime(&tt); // 或者 localtime(&tt) 如果想要本地时间
|
||||
ptm->tm_hour += 8; //utc -> cst
|
||||
// 计算出毫秒部分
|
||||
long milliseconds = std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
time_now.time_since_epoch()
|
||||
).count() % 1000;
|
||||
|
||||
char buffer[40];
|
||||
strftime(buffer, sizeof(buffer), "%Y-%m-%dT%H:%M:%S", ptm);
|
||||
|
||||
// 添加上毫秒和时区信息
|
||||
sprintf(buffer + strlen(buffer), ".%03ld+0800", milliseconds);
|
||||
|
||||
return std::string(buffer);
|
||||
}
|
||||
time_t UpdateRecord::string_to_now(std::string stamp) {
|
||||
struct tm t;
|
||||
std::istringstream ss(stamp);
|
||||
ss >> std::get_time(&t,"%Y-%m-%dT%H:%M:%S");
|
||||
if(ss.fail())return -1;
|
||||
return mktime(&t);
|
||||
}
|
||||
|
||||
int UpdateRecord::SQLBatch_exc(std::vector<std::string> &sql_list,std::vector<std::string> &result){
|
||||
|
||||
sqlite3 *db = (sqlite3 *)handpara;
|
||||
char *errMsg = nullptr;
|
||||
const char *sql;
|
||||
int rc;
|
||||
int resp = 0;
|
||||
// 开启事务
|
||||
if (sqlite3_exec(db, "BEGIN TRANSACTION;", nullptr, nullptr, &errMsg) != SQLITE_OK) {
|
||||
std::cerr << "事务开启失败: " << errMsg << std::endl;
|
||||
sqlite3_free(errMsg);
|
||||
return -1;
|
||||
}
|
||||
// 执行批量插入操作
|
||||
sqlite3_stmt *stmt;
|
||||
int idx = 0;
|
||||
for(const auto &k:sql_list){
|
||||
std::cout << "cmd:"<<k.c_str()<<std::endl;
|
||||
if (sqlite3_prepare_v2(db, k.c_str(), -1, &stmt, nullptr) != SQLITE_OK) {
|
||||
std::cerr << "准备语句失败: " << sqlite3_errmsg(db) << std::endl;
|
||||
continue;
|
||||
}
|
||||
rc = sqlite3_step(stmt);
|
||||
if (rc != SQLITE_DONE) {
|
||||
std::cerr << "插入失败: " << sqlite3_errmsg(db) << std::endl;
|
||||
result[idx] = "-1";
|
||||
}else
|
||||
result[idx] = "0"; //SUCCESS
|
||||
sqlite3_reset(stmt); // 重置语句
|
||||
}
|
||||
// 提交事务
|
||||
if (sqlite3_exec(db, "COMMIT;", nullptr, nullptr, &errMsg) != SQLITE_OK) {
|
||||
std::cerr << "事务提交失败: " << errMsg << std::endl;
|
||||
sqlite3_free(errMsg);
|
||||
resp = -1;
|
||||
}
|
||||
// 清理
|
||||
sqlite3_finalize(stmt);
|
||||
return resp;
|
||||
}
|
||||
|
||||
int UpdateRecord::HandleMsg(const msg_t msg, msg_t &outMsg,handparam_t *param){
|
||||
|
||||
topic.clear();
|
||||
topic_split(msg.topic,'/');
|
||||
json value,resp;
|
||||
int ret = 0;
|
||||
int afn_flag = 0, update_flag = 0;;
|
||||
std::vector<std::string> sql_list;
|
||||
std::vector<std::string> result;
|
||||
sql_list.clear();
|
||||
result.clear();
|
||||
std::string table_name ;
|
||||
try{
|
||||
value = json::parse(msg.payload);
|
||||
}
|
||||
catch(const std::exception &e){
|
||||
std::cout << "topic "<<msg.topic.c_str()<<" prase error:"<<e.what();
|
||||
return -1;//format fail
|
||||
}
|
||||
if(!value.is_object())return -1;
|
||||
if(value.contains("token")){
|
||||
resp["token"] = value["token"];
|
||||
}
|
||||
if(value.contains("time")){
|
||||
;// value["time"]
|
||||
}
|
||||
if(value.contains("data")){
|
||||
json subvalue = value["data"];
|
||||
int afn = 0;
|
||||
int dataid = 0;
|
||||
decode_blob(&dataid,4, subvalue["dataid"].get<std::string>().c_str());
|
||||
decode_blob(&afn,4,subvalue["afn"].get<std::string>().c_str());
|
||||
std::stringstream ss;
|
||||
//table_name =search_table_db(afn,dataid);
|
||||
table_name = "frozen";
|
||||
std::cout << "afn:"<<afn<<std::endl;
|
||||
if(!(afn==0x0d | afn==0x0e |afn == 0x12 |afn == 0x13))
|
||||
{
|
||||
afn_flag = -1;
|
||||
goto resp_process;
|
||||
}
|
||||
if(std::stoi(subvalue["updatetype"].get<std::string>()) !=1){
|
||||
update_flag = -1;
|
||||
goto resp_process;
|
||||
}
|
||||
std::cout << __func__<<","<<__LINE__<<std::endl;
|
||||
ss << "replace into " <<table_name.c_str() <<" (idx,metid,dataid,frozentime,createdtime,source,crcaux,databuff) values ("\
|
||||
<< 0 << ","\
|
||||
<<std::stoi(subvalue["metid"].get<std::string>())<<","\
|
||||
<<subvalue["dataid"].get<std::string>().c_str()<<","\
|
||||
<<string_to_now(subvalue["updatefilter"].get<std::string>())<<","\
|
||||
<<time(NULL)<<","\
|
||||
<<std::stoi(subvalue["crcaux"].get<std::string>())<<","\
|
||||
<<subvalue["databuff"].get<std::string>().c_str()<<");";
|
||||
printf("update sql:%s \n",ss.str().c_str());
|
||||
sql_list.push_back(ss.str());
|
||||
ss.clear();
|
||||
|
||||
}
|
||||
ret = SQLBatch_exc(sql_list,result);
|
||||
resp_process:
|
||||
resp["time"]=now_to_string();
|
||||
if(ret == -1 || afn_flag == -1 || update_flag == -1)
|
||||
resp["ack"]="false";
|
||||
else if(ret == 0)
|
||||
resp["ack"]="true";
|
||||
|
||||
resp["data"]["dataidex"]=result;
|
||||
|
||||
std::stringstream ss;
|
||||
ss << "/"<<topic[1].c_str()<<"/"<<topic[0].c_str()<<"/"\
|
||||
<<topic[2].c_str()<<"/"<<topic[3].c_str();
|
||||
outMsg.topic = ss.str();
|
||||
outMsg.timestamp = time(NULL);;
|
||||
outMsg.payload = resp.dump();
|
||||
std::cout << "resp UpdateRecord payload:"<<resp.dump().c_str()<<std::endl;
|
||||
return 1;
|
||||
}
|
||||
std::string UpdateRecord::GetFID(){
|
||||
std::string tmp("F-UpdateRecord");
|
||||
return tmp;
|
||||
}
|
||||
void UpdateRecord::topic_split(const std::string& str, char delimiter) {
|
||||
std::string token; // 临时存储每个子字符串
|
||||
std::istringstream tokenStream(str); // 使用字符串流处理输入字符串
|
||||
// 按分隔符逐个读取子字符串
|
||||
while (std::getline(tokenStream, token, delimiter)) {
|
||||
topic.push_back(token); // 将子字符串添加到结果中
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* @Description: file content
|
||||
* @Author: why
|
||||
* @version:
|
||||
* @Date: 2025-02-25 11:03:17
|
||||
* @LastEditors: why
|
||||
* @LastEditTime: 2025-02-27 11:13:51
|
||||
*/
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "bizservice.h"
|
||||
class UpdateRecord:public IBizService {
|
||||
public:
|
||||
void Init(initparam_t *param);
|
||||
int HandleMsg(const msg_t msg, msg_t &outMsg,handparam_t *param = NULL);
|
||||
std::string GetFID();
|
||||
UpdateRecord();
|
||||
~UpdateRecord();
|
||||
private:
|
||||
handparam_t * handpara;
|
||||
initparam_t * initpara;
|
||||
std::vector<std::string> topic;//0:dst 1:src 2:sid 3:fid
|
||||
void topic_split(const std::string& str, char delimiter);
|
||||
int SQLBatch_exc(std::vector<std::string> &sql_list,std::vector<std::string> &result);
|
||||
std::string now_to_string();
|
||||
time_t string_to_now(std::string stamp);
|
||||
};
|
||||
@@ -0,0 +1,45 @@
|
||||
|
||||
#include <vector>
|
||||
#include <queue>
|
||||
#include <mutex>
|
||||
#include <condition_variable>
|
||||
|
||||
class ConnectionPool {
|
||||
public:
|
||||
ConnectionPool(size_t poolSize) : maxPoolSize(poolSize) {
|
||||
for (size_t i = 0; i < maxPoolSize; ++i) {
|
||||
connections.push(new Database());
|
||||
}
|
||||
}
|
||||
|
||||
~ConnectionPool() {
|
||||
while (!connections.empty()) {
|
||||
delete connections.front();
|
||||
connections.pop();
|
||||
}
|
||||
}
|
||||
|
||||
Database* getConnection() {
|
||||
std::unique_lock<std::mutex> lock(mutex);
|
||||
while (connections.empty()) {
|
||||
condition.wait(lock);
|
||||
}
|
||||
Database* conn = connections.front();
|
||||
connections.pop();
|
||||
std::cout << "Pool " << __func__ << " ok" << std::endl;
|
||||
return conn;
|
||||
}
|
||||
|
||||
void returnConnection(Database* conn) {
|
||||
std::unique_lock<std::mutex> lock(mutex);
|
||||
connections.push(conn);
|
||||
condition.notify_one();
|
||||
std::cout << "Pool " << __func__ << " ok" << std::endl;
|
||||
}
|
||||
|
||||
private:
|
||||
std::queue<Database*> connections; // 连接队列
|
||||
size_t maxPoolSize; // 最大连接池大小
|
||||
std::mutex mutex; // 互斥锁
|
||||
std::condition_variable condition; // 条件变量
|
||||
};
|
||||
@@ -0,0 +1,208 @@
|
||||
/**
|
||||
* @文件路径: \dcapp\datacenter\inc\Database.h
|
||||
* @作者名称: zjp
|
||||
* @文件版本: V1.0.0
|
||||
* @创建日期: 2025-02-21 15:16:45
|
||||
* @简要说明:
|
||||
* @编辑时间: 2025-02-28 10:01:15
|
||||
* @Copyright: 2025 Shenzhen ShenBao Electrical instruments CO.,LTD. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <sqlite3.h>
|
||||
#include <iostream>
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
#include <sys/stat.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
#define DBNAME "test.db"
|
||||
#define FILEBACKUP "/opt/bak/bak.sql"
|
||||
#define CMDBACKUP_HIS "mv /opt/bak/bak.sql /opt/bak/bak.sql.bak"
|
||||
|
||||
class Database
|
||||
{
|
||||
public:
|
||||
Database()
|
||||
{
|
||||
if (sqlite3_open(DBNAME, &db) != SQLITE_OK)
|
||||
{
|
||||
std::cout << "Error opening database: " << sqlite3_errmsg(db) << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
~Database()
|
||||
{
|
||||
if (db)
|
||||
{
|
||||
sqlite3_close(db);
|
||||
}
|
||||
}
|
||||
|
||||
int ExecSQL(std::string sql)
|
||||
{
|
||||
char *errmsg;
|
||||
int nResult = sqlite3_exec(db, sql.c_str(), 0, 0, &errmsg);
|
||||
if (nResult != SQLITE_OK)
|
||||
{
|
||||
// sqlite3_close(db);
|
||||
cout << errmsg << " code:" << nResult << endl;
|
||||
sqlite3_free(errmsg);
|
||||
return (-1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int Query(string sql, int *nRow, int *nCol, char ***pResult)
|
||||
{
|
||||
char *errmsg;
|
||||
int nResult = sqlite3_get_table(db, sql.c_str(), pResult, nRow, nCol, &errmsg);
|
||||
if (nResult != SQLITE_OK)
|
||||
{
|
||||
// sqlite3_close(db);
|
||||
cout << errmsg << " code:" << nResult << endl;
|
||||
sqlite3_free(errmsg);
|
||||
return (-1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DbOpen(const string dbFilePath)
|
||||
{
|
||||
if (sqlite3_open(dbFilePath.c_str(), &db) != SQLITE_OK)
|
||||
{
|
||||
std::cout << "Error opening database." << std::endl;
|
||||
sqlite3_close(db);
|
||||
return (-1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
sqlite3 *GetHandle(void)
|
||||
{
|
||||
return db;
|
||||
}
|
||||
|
||||
int DbClose(void)
|
||||
{
|
||||
if (sqlite3_close(db) != SQLITE_OK)
|
||||
{
|
||||
std::cout << "Error closing database." << std::endl;
|
||||
return (-1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
int BackupParam(void) // 备份参数
|
||||
{
|
||||
int rtn = -1;
|
||||
std::cout << "start backup database..." << std::endl;
|
||||
|
||||
system(CMDBACKUP_HIS);
|
||||
|
||||
// system("./sqlite shb3104.db '.dump f_param' > /opt/bak.sql");
|
||||
// system("./sqlite shb3104.db '.dump f_param_def' >> /opt/bak.sql");
|
||||
|
||||
struct stat statbuf;
|
||||
if (stat(FILEBACKUP, &statbuf) == 0)
|
||||
{
|
||||
if (statbuf.st_size > 0) // 备份参数失败
|
||||
{
|
||||
std::cout << "backup param ok" << std::endl;
|
||||
rtn = 0;
|
||||
}
|
||||
}
|
||||
return rtn;
|
||||
}
|
||||
|
||||
int CheckTablesCount(void) // 检查表的总数量
|
||||
{
|
||||
int ret = 0;
|
||||
char sql[512];
|
||||
sqlite3_stmt *stmt;
|
||||
|
||||
snprintf(sql, sizeof(sql), "SELECT count(*) FROM sqlite_master WHERE type='table' AND name in ('Users','tbl_data');");
|
||||
|
||||
if (sqlite3_prepare(db, sql, -1, &stmt, NULL) == SQLITE_OK)
|
||||
{
|
||||
if (sqlite3_step(stmt) == SQLITE_ROW)
|
||||
{
|
||||
const unsigned char *result = sqlite3_column_text(stmt, 0);
|
||||
if (!result)
|
||||
ret = atoi((const char *)result);
|
||||
}
|
||||
}
|
||||
sqlite3_finalize(stmt);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int CheckDatabase(void) // 执行整个库的完全性检查
|
||||
{
|
||||
int rtn = -1;
|
||||
sqlite3_stmt *integrity = NULL;
|
||||
|
||||
if (sqlite3_prepare_v2(db, "PRAGMA quick_check;", -1, &integrity, NULL) == SQLITE_OK)
|
||||
{
|
||||
while (sqlite3_step(integrity) == SQLITE_ROW)
|
||||
{
|
||||
const unsigned char *result = sqlite3_column_text(integrity, 0);
|
||||
if (result && strcmp((const char *)result, (const char *)"ok") == 0)
|
||||
{
|
||||
rtn = 0;
|
||||
std::cout << __func__ << " ok" << std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
sqlite3_finalize(integrity);
|
||||
}
|
||||
return rtn;
|
||||
}
|
||||
|
||||
void ReCreate(void) // 重建数据
|
||||
{
|
||||
int flag_bak = 0;
|
||||
struct stat statbuf;
|
||||
char *zErrMsg = 0;
|
||||
int rc;
|
||||
|
||||
if (stat(FILEBACKUP, &statbuf) == 0)
|
||||
{
|
||||
if (statbuf.st_size > 0) // 备份参数失败
|
||||
{
|
||||
flag_bak = 1;
|
||||
}
|
||||
}
|
||||
|
||||
DbClose(); // 关闭现有连接
|
||||
system("sync");
|
||||
DbOpen(DBNAME);
|
||||
|
||||
// 从备份文件中读取SQL命令并执行
|
||||
std::ifstream backupFile(FILEBACKUP);
|
||||
std::stringstream buffer;
|
||||
buffer << backupFile.rdbuf();
|
||||
std::string sqlCommands = buffer.str();
|
||||
rc = sqlite3_exec(db, sqlCommands.c_str(), NULL, 0, &zErrMsg);
|
||||
if (rc != SQLITE_OK)
|
||||
{
|
||||
std::cerr << "SQL错误: " << zErrMsg << std::endl;
|
||||
sqlite3_free(zErrMsg);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "数据库恢复成功" << std::endl;
|
||||
}
|
||||
|
||||
DbClose(); // 关闭现有连接
|
||||
system("sync");
|
||||
|
||||
// system("reboot");
|
||||
return;
|
||||
}
|
||||
|
||||
private:
|
||||
sqlite3 *db;
|
||||
};
|
||||
@@ -15,6 +15,9 @@
|
||||
#include "mqttClient.h"
|
||||
#include "queue.h"
|
||||
|
||||
#define POOLSIZE 10
|
||||
|
||||
|
||||
class DataCenter : public IService
|
||||
{
|
||||
public:
|
||||
@@ -63,6 +66,7 @@ private:
|
||||
MessageQueue mQueue_In; // 输入队列
|
||||
MessageQueue mQueue_Out; // 输出队列
|
||||
CMqttClient *objmqttClient;
|
||||
|
||||
};
|
||||
|
||||
#endif // _DCAPP_DATACENTER_DATACENTER_H_
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,638 @@
|
||||
/*
|
||||
** 2006 June 7
|
||||
**
|
||||
** The author disclaims copyright to this source code. In place of
|
||||
** a legal notice, here is a blessing:
|
||||
**
|
||||
** May you do good and not evil.
|
||||
** May you find forgiveness for yourself and forgive others.
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
*************************************************************************
|
||||
** This header file defines the SQLite interface for use by
|
||||
** shared libraries that want to be imported as extensions into
|
||||
** an SQLite instance. Shared libraries that intend to be loaded
|
||||
** as extensions by SQLite should #include this file instead of
|
||||
** sqlite3.h.
|
||||
*/
|
||||
#ifndef SQLITE3EXT_H
|
||||
#define SQLITE3EXT_H
|
||||
#include "sqlite3.h"
|
||||
|
||||
/*
|
||||
** The following structure holds pointers to all of the SQLite API
|
||||
** routines.
|
||||
**
|
||||
** WARNING: In order to maintain backwards compatibility, add new
|
||||
** interfaces to the end of this structure only. If you insert new
|
||||
** interfaces in the middle of this structure, then older different
|
||||
** versions of SQLite will not be able to load each other's shared
|
||||
** libraries!
|
||||
*/
|
||||
struct sqlite3_api_routines {
|
||||
void * (*aggregate_context)(sqlite3_context*,int nBytes);
|
||||
int (*aggregate_count)(sqlite3_context*);
|
||||
int (*bind_blob)(sqlite3_stmt*,int,const void*,int n,void(*)(void*));
|
||||
int (*bind_double)(sqlite3_stmt*,int,double);
|
||||
int (*bind_int)(sqlite3_stmt*,int,int);
|
||||
int (*bind_int64)(sqlite3_stmt*,int,sqlite_int64);
|
||||
int (*bind_null)(sqlite3_stmt*,int);
|
||||
int (*bind_parameter_count)(sqlite3_stmt*);
|
||||
int (*bind_parameter_index)(sqlite3_stmt*,const char*zName);
|
||||
const char * (*bind_parameter_name)(sqlite3_stmt*,int);
|
||||
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_value)(sqlite3_stmt*,int,const sqlite3_value*);
|
||||
int (*busy_handler)(sqlite3*,int(*)(void*,int),void*);
|
||||
int (*busy_timeout)(sqlite3*,int ms);
|
||||
int (*changes)(sqlite3*);
|
||||
int (*close)(sqlite3*);
|
||||
int (*collation_needed)(sqlite3*,void*,void(*)(void*,sqlite3*,
|
||||
int eTextRep,const char*));
|
||||
int (*collation_needed16)(sqlite3*,void*,void(*)(void*,sqlite3*,
|
||||
int eTextRep,const void*));
|
||||
const void * (*column_blob)(sqlite3_stmt*,int iCol);
|
||||
int (*column_bytes)(sqlite3_stmt*,int iCol);
|
||||
int (*column_bytes16)(sqlite3_stmt*,int iCol);
|
||||
int (*column_count)(sqlite3_stmt*pStmt);
|
||||
const char * (*column_database_name)(sqlite3_stmt*,int);
|
||||
const void * (*column_database_name16)(sqlite3_stmt*,int);
|
||||
const char * (*column_decltype)(sqlite3_stmt*,int i);
|
||||
const void * (*column_decltype16)(sqlite3_stmt*,int);
|
||||
double (*column_double)(sqlite3_stmt*,int iCol);
|
||||
int (*column_int)(sqlite3_stmt*,int iCol);
|
||||
sqlite_int64 (*column_int64)(sqlite3_stmt*,int iCol);
|
||||
const char * (*column_name)(sqlite3_stmt*,int);
|
||||
const void * (*column_name16)(sqlite3_stmt*,int);
|
||||
const char * (*column_origin_name)(sqlite3_stmt*,int);
|
||||
const void * (*column_origin_name16)(sqlite3_stmt*,int);
|
||||
const char * (*column_table_name)(sqlite3_stmt*,int);
|
||||
const void * (*column_table_name16)(sqlite3_stmt*,int);
|
||||
const unsigned char * (*column_text)(sqlite3_stmt*,int iCol);
|
||||
const void * (*column_text16)(sqlite3_stmt*,int iCol);
|
||||
int (*column_type)(sqlite3_stmt*,int iCol);
|
||||
sqlite3_value* (*column_value)(sqlite3_stmt*,int iCol);
|
||||
void * (*commit_hook)(sqlite3*,int(*)(void*),void*);
|
||||
int (*complete)(const char*sql);
|
||||
int (*complete16)(const void*sql);
|
||||
int (*create_collation)(sqlite3*,const char*,int,void*,
|
||||
int(*)(void*,int,const void*,int,const void*));
|
||||
int (*create_collation16)(sqlite3*,const void*,int,void*,
|
||||
int(*)(void*,int,const void*,int,const void*));
|
||||
int (*create_function)(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_function16)(sqlite3*,const void*,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 (*errcode)(sqlite3*db);
|
||||
const char * (*errmsg)(sqlite3*);
|
||||
const void * (*errmsg16)(sqlite3*);
|
||||
int (*exec)(sqlite3*,const char*,sqlite3_callback,void*,char**);
|
||||
int (*expired)(sqlite3_stmt*);
|
||||
int (*finalize)(sqlite3_stmt*pStmt);
|
||||
void (*free)(void*);
|
||||
void (*free_table)(char**result);
|
||||
int (*get_autocommit)(sqlite3*);
|
||||
void * (*get_auxdata)(sqlite3_context*,int);
|
||||
int (*get_table)(sqlite3*,const char*,char***,int*,int*,char**);
|
||||
int (*global_recover)(void);
|
||||
void (*interruptx)(sqlite3*);
|
||||
sqlite_int64 (*last_insert_rowid)(sqlite3*);
|
||||
const char * (*libversion)(void);
|
||||
int (*libversion_number)(void);
|
||||
void *(*malloc)(int);
|
||||
char * (*mprintf)(const char*,...);
|
||||
int (*open)(const char*,sqlite3**);
|
||||
int (*open16)(const void*,sqlite3**);
|
||||
int (*prepare)(sqlite3*,const char*,int,sqlite3_stmt**,const char**);
|
||||
int (*prepare16)(sqlite3*,const void*,int,sqlite3_stmt**,const void**);
|
||||
void * (*profile)(sqlite3*,void(*)(void*,const char*,sqlite_uint64),void*);
|
||||
void (*progress_handler)(sqlite3*,int,int(*)(void*),void*);
|
||||
void *(*realloc)(void*,int);
|
||||
int (*reset)(sqlite3_stmt*pStmt);
|
||||
void (*result_blob)(sqlite3_context*,const void*,int,void(*)(void*));
|
||||
void (*result_double)(sqlite3_context*,double);
|
||||
void (*result_error)(sqlite3_context*,const char*,int);
|
||||
void (*result_error16)(sqlite3_context*,const void*,int);
|
||||
void (*result_int)(sqlite3_context*,int);
|
||||
void (*result_int64)(sqlite3_context*,sqlite_int64);
|
||||
void (*result_null)(sqlite3_context*);
|
||||
void (*result_text)(sqlite3_context*,const char*,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_text16le)(sqlite3_context*,const void*,int,void(*)(void*));
|
||||
void (*result_value)(sqlite3_context*,sqlite3_value*);
|
||||
void * (*rollback_hook)(sqlite3*,void(*)(void*),void*);
|
||||
int (*set_authorizer)(sqlite3*,int(*)(void*,int,const char*,const char*,
|
||||
const char*,const char*),void*);
|
||||
void (*set_auxdata)(sqlite3_context*,int,void*,void (*)(void*));
|
||||
char * (*xsnprintf)(int,char*,const char*,...);
|
||||
int (*step)(sqlite3_stmt*);
|
||||
int (*table_column_metadata)(sqlite3*,const char*,const char*,const char*,
|
||||
char const**,char const**,int*,int*,int*);
|
||||
void (*thread_cleanup)(void);
|
||||
int (*total_changes)(sqlite3*);
|
||||
void * (*trace)(sqlite3*,void(*xTrace)(void*,const char*),void*);
|
||||
int (*transfer_bindings)(sqlite3_stmt*,sqlite3_stmt*);
|
||||
void * (*update_hook)(sqlite3*,void(*)(void*,int ,char const*,char const*,
|
||||
sqlite_int64),void*);
|
||||
void * (*user_data)(sqlite3_context*);
|
||||
const void * (*value_blob)(sqlite3_value*);
|
||||
int (*value_bytes)(sqlite3_value*);
|
||||
int (*value_bytes16)(sqlite3_value*);
|
||||
double (*value_double)(sqlite3_value*);
|
||||
int (*value_int)(sqlite3_value*);
|
||||
sqlite_int64 (*value_int64)(sqlite3_value*);
|
||||
int (*value_numeric_type)(sqlite3_value*);
|
||||
const unsigned char * (*value_text)(sqlite3_value*);
|
||||
const void * (*value_text16)(sqlite3_value*);
|
||||
const void * (*value_text16be)(sqlite3_value*);
|
||||
const void * (*value_text16le)(sqlite3_value*);
|
||||
int (*value_type)(sqlite3_value*);
|
||||
char *(*vmprintf)(const char*,va_list);
|
||||
/* Added ??? */
|
||||
int (*overload_function)(sqlite3*, const char *zFuncName, int nArg);
|
||||
/* Added by 3.3.13 */
|
||||
int (*prepare_v2)(sqlite3*,const char*,int,sqlite3_stmt**,const char**);
|
||||
int (*prepare16_v2)(sqlite3*,const void*,int,sqlite3_stmt**,const void**);
|
||||
int (*clear_bindings)(sqlite3_stmt*);
|
||||
/* Added by 3.4.1 */
|
||||
int (*create_module_v2)(sqlite3*,const char*,const sqlite3_module*,void*,
|
||||
void (*xDestroy)(void *));
|
||||
/* Added by 3.5.0 */
|
||||
int (*bind_zeroblob)(sqlite3_stmt*,int,int);
|
||||
int (*blob_bytes)(sqlite3_blob*);
|
||||
int (*blob_close)(sqlite3_blob*);
|
||||
int (*blob_open)(sqlite3*,const char*,const char*,const char*,sqlite3_int64,
|
||||
int,sqlite3_blob**);
|
||||
int (*blob_read)(sqlite3_blob*,void*,int,int);
|
||||
int (*blob_write)(sqlite3_blob*,const void*,int,int);
|
||||
int (*create_collation_v2)(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_used)(void);
|
||||
sqlite3_mutex *(*mutex_alloc)(int);
|
||||
void (*mutex_enter)(sqlite3_mutex*);
|
||||
void (*mutex_free)(sqlite3_mutex*);
|
||||
void (*mutex_leave)(sqlite3_mutex*);
|
||||
int (*mutex_try)(sqlite3_mutex*);
|
||||
int (*open_v2)(const char*,sqlite3**,int,const char*);
|
||||
int (*release_memory)(int);
|
||||
void (*result_error_nomem)(sqlite3_context*);
|
||||
void (*result_error_toobig)(sqlite3_context*);
|
||||
int (*sleep)(int);
|
||||
void (*soft_heap_limit)(int);
|
||||
sqlite3_vfs *(*vfs_find)(const char*);
|
||||
int (*vfs_register)(sqlite3_vfs*,int);
|
||||
int (*vfs_unregister)(sqlite3_vfs*);
|
||||
int (*xthreadsafe)(void);
|
||||
void (*result_zeroblob)(sqlite3_context*,int);
|
||||
void (*result_error_code)(sqlite3_context*,int);
|
||||
int (*test_control)(int, ...);
|
||||
void (*randomness)(int,void*);
|
||||
sqlite3 *(*context_db_handle)(sqlite3_context*);
|
||||
int (*extended_result_codes)(sqlite3*,int);
|
||||
int (*limit)(sqlite3*,int,int);
|
||||
sqlite3_stmt *(*next_stmt)(sqlite3*,sqlite3_stmt*);
|
||||
const char *(*sql)(sqlite3_stmt*);
|
||||
int (*status)(int,int*,int*,int);
|
||||
int (*backup_finish)(sqlite3_backup*);
|
||||
sqlite3_backup *(*backup_init)(sqlite3*,const char*,sqlite3*,const char*);
|
||||
int (*backup_pagecount)(sqlite3_backup*);
|
||||
int (*backup_remaining)(sqlite3_backup*);
|
||||
int (*backup_step)(sqlite3_backup*,int);
|
||||
const char *(*compileoption_get)(int);
|
||||
int (*compileoption_used)(const char*);
|
||||
int (*create_function_v2)(sqlite3*,const char*,int,int,void*,
|
||||
void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
|
||||
void (*xStep)(sqlite3_context*,int,sqlite3_value**),
|
||||
void (*xFinal)(sqlite3_context*),
|
||||
void(*xDestroy)(void*));
|
||||
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);
|
||||
const char *(*sourceid)(void);
|
||||
int (*stmt_status)(sqlite3_stmt*,int,int);
|
||||
int (*strnicmp)(const char*,const char*,int);
|
||||
int (*unlock_notify)(sqlite3*,void(*)(void**,int),void*);
|
||||
int (*wal_autocheckpoint)(sqlite3*,int);
|
||||
int (*wal_checkpoint)(sqlite3*,const char*);
|
||||
void *(*wal_hook)(sqlite3*,int(*)(void*,sqlite3*,const char*,int),void*);
|
||||
int (*blob_reopen)(sqlite3_blob*,sqlite3_int64);
|
||||
int (*vtab_config)(sqlite3*,int op,...);
|
||||
int (*vtab_on_conflict)(sqlite3*);
|
||||
/* Version 3.7.16 and later */
|
||||
int (*close_v2)(sqlite3*);
|
||||
const char *(*db_filename)(sqlite3*,const char*);
|
||||
int (*db_readonly)(sqlite3*,const char*);
|
||||
int (*db_release_memory)(sqlite3*);
|
||||
const char *(*errstr)(int);
|
||||
int (*stmt_busy)(sqlite3_stmt*);
|
||||
int (*stmt_readonly)(sqlite3_stmt*);
|
||||
int (*stricmp)(const char*,const char*);
|
||||
int (*uri_boolean)(const char*,const char*,int);
|
||||
sqlite3_int64 (*uri_int64)(const char*,const char*,sqlite3_int64);
|
||||
const char *(*uri_parameter)(const char*,const char*);
|
||||
char *(*xvsnprintf)(int,char*,const char*,va_list);
|
||||
int (*wal_checkpoint_v2)(sqlite3*,const char*,int,int*,int*);
|
||||
/* Version 3.8.7 and later */
|
||||
int (*auto_extension)(void(*)(void));
|
||||
int (*bind_blob64)(sqlite3_stmt*,int,const void*,sqlite3_uint64,
|
||||
void(*)(void*));
|
||||
int (*bind_text64)(sqlite3_stmt*,int,const char*,sqlite3_uint64,
|
||||
void(*)(void*),unsigned char);
|
||||
int (*cancel_auto_extension)(void(*)(void));
|
||||
int (*load_extension)(sqlite3*,const char*,const char*,char**);
|
||||
void *(*malloc64)(sqlite3_uint64);
|
||||
sqlite3_uint64 (*msize)(void*);
|
||||
void *(*realloc64)(void*,sqlite3_uint64);
|
||||
void (*reset_auto_extension)(void);
|
||||
void (*result_blob64)(sqlite3_context*,const void*,sqlite3_uint64,
|
||||
void(*)(void*));
|
||||
void (*result_text64)(sqlite3_context*,const char*,sqlite3_uint64,
|
||||
void(*)(void*), unsigned char);
|
||||
int (*strglob)(const char*,const char*);
|
||||
/* Version 3.8.11 and later */
|
||||
sqlite3_value *(*value_dup)(const sqlite3_value*);
|
||||
void (*value_free)(sqlite3_value*);
|
||||
int (*result_zeroblob64)(sqlite3_context*,sqlite3_uint64);
|
||||
int (*bind_zeroblob64)(sqlite3_stmt*, int, sqlite3_uint64);
|
||||
/* Version 3.9.0 and later */
|
||||
unsigned int (*value_subtype)(sqlite3_value*);
|
||||
void (*result_subtype)(sqlite3_context*,unsigned int);
|
||||
/* Version 3.10.0 and later */
|
||||
int (*status64)(int,sqlite3_int64*,sqlite3_int64*,int);
|
||||
int (*strlike)(const char*,const char*,unsigned int);
|
||||
int (*db_cacheflush)(sqlite3*);
|
||||
/* Version 3.12.0 and later */
|
||||
int (*system_errno)(sqlite3*);
|
||||
/* Version 3.14.0 and later */
|
||||
int (*trace_v2)(sqlite3*,unsigned,int(*)(unsigned,void*,void*,void*),void*);
|
||||
char *(*expanded_sql)(sqlite3_stmt*);
|
||||
/* Version 3.18.0 and later */
|
||||
void (*set_last_insert_rowid)(sqlite3*,sqlite3_int64);
|
||||
/* Version 3.20.0 and later */
|
||||
int (*prepare_v3)(sqlite3*,const char*,int,unsigned int,
|
||||
sqlite3_stmt**,const char**);
|
||||
int (*prepare16_v3)(sqlite3*,const void*,int,unsigned int,
|
||||
sqlite3_stmt**,const void**);
|
||||
int (*bind_pointer)(sqlite3_stmt*,int,void*,const char*,void(*)(void*));
|
||||
void (*result_pointer)(sqlite3_context*,void*,const char*,void(*)(void*));
|
||||
void *(*value_pointer)(sqlite3_value*,const char*);
|
||||
int (*vtab_nochange)(sqlite3_context*);
|
||||
int (*value_nochange)(sqlite3_value*);
|
||||
const char *(*vtab_collation)(sqlite3_index_info*,int);
|
||||
/* Version 3.24.0 and later */
|
||||
int (*keyword_count)(void);
|
||||
int (*keyword_name)(int,const char**,int*);
|
||||
int (*keyword_check)(const char*,int);
|
||||
sqlite3_str *(*str_new)(sqlite3*);
|
||||
char *(*str_finish)(sqlite3_str*);
|
||||
void (*str_appendf)(sqlite3_str*, const char *zFormat, ...);
|
||||
void (*str_vappendf)(sqlite3_str*, const char *zFormat, va_list);
|
||||
void (*str_append)(sqlite3_str*, const char *zIn, int N);
|
||||
void (*str_appendall)(sqlite3_str*, const char *zIn);
|
||||
void (*str_appendchar)(sqlite3_str*, int N, char C);
|
||||
void (*str_reset)(sqlite3_str*);
|
||||
int (*str_errcode)(sqlite3_str*);
|
||||
int (*str_length)(sqlite3_str*);
|
||||
char *(*str_value)(sqlite3_str*);
|
||||
/* Version 3.25.0 and later */
|
||||
int (*create_window_function)(sqlite3*,const char*,int,int,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 */
|
||||
const char *(*normalized_sql)(sqlite3_stmt*);
|
||||
/* Version 3.28.0 and later */
|
||||
int (*stmt_isexplain)(sqlite3_stmt*);
|
||||
int (*value_frombind)(sqlite3_value*);
|
||||
/* Version 3.30.0 and later */
|
||||
int (*drop_modules)(sqlite3*,const char**);
|
||||
};
|
||||
|
||||
/*
|
||||
** This is the function signature used for all extension entry points. It
|
||||
** is also defined in the file "loadext.c".
|
||||
*/
|
||||
typedef int (*sqlite3_loadext_entry)(
|
||||
sqlite3 *db, /* Handle to the database. */
|
||||
char **pzErrMsg, /* Used to set error string on failure. */
|
||||
const sqlite3_api_routines *pThunk /* Extension API function pointers. */
|
||||
);
|
||||
|
||||
/*
|
||||
** The following macros redefine the API routines so that they are
|
||||
** redirected through the global sqlite3_api structure.
|
||||
**
|
||||
** This header file is also used by the loadext.c source file
|
||||
** (part of the main SQLite library - not an extension) so that
|
||||
** it can get access to the sqlite3_api_routines structure
|
||||
** definition. But the main library does not want to redefine
|
||||
** the API. So the redefinition macros are only valid if the
|
||||
** SQLITE_CORE macros is undefined.
|
||||
*/
|
||||
#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
|
||||
#define sqlite3_aggregate_context sqlite3_api->aggregate_context
|
||||
#ifndef SQLITE_OMIT_DEPRECATED
|
||||
#define sqlite3_aggregate_count sqlite3_api->aggregate_count
|
||||
#endif
|
||||
#define sqlite3_bind_blob sqlite3_api->bind_blob
|
||||
#define sqlite3_bind_double sqlite3_api->bind_double
|
||||
#define sqlite3_bind_int sqlite3_api->bind_int
|
||||
#define sqlite3_bind_int64 sqlite3_api->bind_int64
|
||||
#define sqlite3_bind_null sqlite3_api->bind_null
|
||||
#define sqlite3_bind_parameter_count sqlite3_api->bind_parameter_count
|
||||
#define sqlite3_bind_parameter_index sqlite3_api->bind_parameter_index
|
||||
#define sqlite3_bind_parameter_name sqlite3_api->bind_parameter_name
|
||||
#define sqlite3_bind_text sqlite3_api->bind_text
|
||||
#define sqlite3_bind_text16 sqlite3_api->bind_text16
|
||||
#define sqlite3_bind_value sqlite3_api->bind_value
|
||||
#define sqlite3_busy_handler sqlite3_api->busy_handler
|
||||
#define sqlite3_busy_timeout sqlite3_api->busy_timeout
|
||||
#define sqlite3_changes sqlite3_api->changes
|
||||
#define sqlite3_close sqlite3_api->close
|
||||
#define sqlite3_collation_needed sqlite3_api->collation_needed
|
||||
#define sqlite3_collation_needed16 sqlite3_api->collation_needed16
|
||||
#define sqlite3_column_blob sqlite3_api->column_blob
|
||||
#define sqlite3_column_bytes sqlite3_api->column_bytes
|
||||
#define sqlite3_column_bytes16 sqlite3_api->column_bytes16
|
||||
#define sqlite3_column_count sqlite3_api->column_count
|
||||
#define sqlite3_column_database_name sqlite3_api->column_database_name
|
||||
#define sqlite3_column_database_name16 sqlite3_api->column_database_name16
|
||||
#define sqlite3_column_decltype sqlite3_api->column_decltype
|
||||
#define sqlite3_column_decltype16 sqlite3_api->column_decltype16
|
||||
#define sqlite3_column_double sqlite3_api->column_double
|
||||
#define sqlite3_column_int sqlite3_api->column_int
|
||||
#define sqlite3_column_int64 sqlite3_api->column_int64
|
||||
#define sqlite3_column_name sqlite3_api->column_name
|
||||
#define sqlite3_column_name16 sqlite3_api->column_name16
|
||||
#define sqlite3_column_origin_name sqlite3_api->column_origin_name
|
||||
#define sqlite3_column_origin_name16 sqlite3_api->column_origin_name16
|
||||
#define sqlite3_column_table_name sqlite3_api->column_table_name
|
||||
#define sqlite3_column_table_name16 sqlite3_api->column_table_name16
|
||||
#define sqlite3_column_text sqlite3_api->column_text
|
||||
#define sqlite3_column_text16 sqlite3_api->column_text16
|
||||
#define sqlite3_column_type sqlite3_api->column_type
|
||||
#define sqlite3_column_value sqlite3_api->column_value
|
||||
#define sqlite3_commit_hook sqlite3_api->commit_hook
|
||||
#define sqlite3_complete sqlite3_api->complete
|
||||
#define sqlite3_complete16 sqlite3_api->complete16
|
||||
#define sqlite3_create_collation sqlite3_api->create_collation
|
||||
#define sqlite3_create_collation16 sqlite3_api->create_collation16
|
||||
#define sqlite3_create_function sqlite3_api->create_function
|
||||
#define sqlite3_create_function16 sqlite3_api->create_function16
|
||||
#define sqlite3_create_module sqlite3_api->create_module
|
||||
#define sqlite3_create_module_v2 sqlite3_api->create_module_v2
|
||||
#define sqlite3_data_count sqlite3_api->data_count
|
||||
#define sqlite3_db_handle sqlite3_api->db_handle
|
||||
#define sqlite3_declare_vtab sqlite3_api->declare_vtab
|
||||
#define sqlite3_enable_shared_cache sqlite3_api->enable_shared_cache
|
||||
#define sqlite3_errcode sqlite3_api->errcode
|
||||
#define sqlite3_errmsg sqlite3_api->errmsg
|
||||
#define sqlite3_errmsg16 sqlite3_api->errmsg16
|
||||
#define sqlite3_exec sqlite3_api->exec
|
||||
#ifndef SQLITE_OMIT_DEPRECATED
|
||||
#define sqlite3_expired sqlite3_api->expired
|
||||
#endif
|
||||
#define sqlite3_finalize sqlite3_api->finalize
|
||||
#define sqlite3_free sqlite3_api->free
|
||||
#define sqlite3_free_table sqlite3_api->free_table
|
||||
#define sqlite3_get_autocommit sqlite3_api->get_autocommit
|
||||
#define sqlite3_get_auxdata sqlite3_api->get_auxdata
|
||||
#define sqlite3_get_table sqlite3_api->get_table
|
||||
#ifndef SQLITE_OMIT_DEPRECATED
|
||||
#define sqlite3_global_recover sqlite3_api->global_recover
|
||||
#endif
|
||||
#define sqlite3_interrupt sqlite3_api->interruptx
|
||||
#define sqlite3_last_insert_rowid sqlite3_api->last_insert_rowid
|
||||
#define sqlite3_libversion sqlite3_api->libversion
|
||||
#define sqlite3_libversion_number sqlite3_api->libversion_number
|
||||
#define sqlite3_malloc sqlite3_api->malloc
|
||||
#define sqlite3_mprintf sqlite3_api->mprintf
|
||||
#define sqlite3_open sqlite3_api->open
|
||||
#define sqlite3_open16 sqlite3_api->open16
|
||||
#define sqlite3_prepare sqlite3_api->prepare
|
||||
#define sqlite3_prepare16 sqlite3_api->prepare16
|
||||
#define sqlite3_prepare_v2 sqlite3_api->prepare_v2
|
||||
#define sqlite3_prepare16_v2 sqlite3_api->prepare16_v2
|
||||
#define sqlite3_profile sqlite3_api->profile
|
||||
#define sqlite3_progress_handler sqlite3_api->progress_handler
|
||||
#define sqlite3_realloc sqlite3_api->realloc
|
||||
#define sqlite3_reset sqlite3_api->reset
|
||||
#define sqlite3_result_blob sqlite3_api->result_blob
|
||||
#define sqlite3_result_double sqlite3_api->result_double
|
||||
#define sqlite3_result_error sqlite3_api->result_error
|
||||
#define sqlite3_result_error16 sqlite3_api->result_error16
|
||||
#define sqlite3_result_int sqlite3_api->result_int
|
||||
#define sqlite3_result_int64 sqlite3_api->result_int64
|
||||
#define sqlite3_result_null sqlite3_api->result_null
|
||||
#define sqlite3_result_text sqlite3_api->result_text
|
||||
#define sqlite3_result_text16 sqlite3_api->result_text16
|
||||
#define sqlite3_result_text16be sqlite3_api->result_text16be
|
||||
#define sqlite3_result_text16le sqlite3_api->result_text16le
|
||||
#define sqlite3_result_value sqlite3_api->result_value
|
||||
#define sqlite3_rollback_hook sqlite3_api->rollback_hook
|
||||
#define sqlite3_set_authorizer sqlite3_api->set_authorizer
|
||||
#define sqlite3_set_auxdata sqlite3_api->set_auxdata
|
||||
#define sqlite3_snprintf sqlite3_api->xsnprintf
|
||||
#define sqlite3_step sqlite3_api->step
|
||||
#define sqlite3_table_column_metadata sqlite3_api->table_column_metadata
|
||||
#define sqlite3_thread_cleanup sqlite3_api->thread_cleanup
|
||||
#define sqlite3_total_changes sqlite3_api->total_changes
|
||||
#define sqlite3_trace sqlite3_api->trace
|
||||
#ifndef SQLITE_OMIT_DEPRECATED
|
||||
#define sqlite3_transfer_bindings sqlite3_api->transfer_bindings
|
||||
#endif
|
||||
#define sqlite3_update_hook sqlite3_api->update_hook
|
||||
#define sqlite3_user_data sqlite3_api->user_data
|
||||
#define sqlite3_value_blob sqlite3_api->value_blob
|
||||
#define sqlite3_value_bytes sqlite3_api->value_bytes
|
||||
#define sqlite3_value_bytes16 sqlite3_api->value_bytes16
|
||||
#define sqlite3_value_double sqlite3_api->value_double
|
||||
#define sqlite3_value_int sqlite3_api->value_int
|
||||
#define sqlite3_value_int64 sqlite3_api->value_int64
|
||||
#define sqlite3_value_numeric_type sqlite3_api->value_numeric_type
|
||||
#define sqlite3_value_text sqlite3_api->value_text
|
||||
#define sqlite3_value_text16 sqlite3_api->value_text16
|
||||
#define sqlite3_value_text16be sqlite3_api->value_text16be
|
||||
#define sqlite3_value_text16le sqlite3_api->value_text16le
|
||||
#define sqlite3_value_type sqlite3_api->value_type
|
||||
#define sqlite3_vmprintf sqlite3_api->vmprintf
|
||||
#define sqlite3_vsnprintf sqlite3_api->xvsnprintf
|
||||
#define sqlite3_overload_function sqlite3_api->overload_function
|
||||
#define sqlite3_prepare_v2 sqlite3_api->prepare_v2
|
||||
#define sqlite3_prepare16_v2 sqlite3_api->prepare16_v2
|
||||
#define sqlite3_clear_bindings sqlite3_api->clear_bindings
|
||||
#define sqlite3_bind_zeroblob sqlite3_api->bind_zeroblob
|
||||
#define sqlite3_blob_bytes sqlite3_api->blob_bytes
|
||||
#define sqlite3_blob_close sqlite3_api->blob_close
|
||||
#define sqlite3_blob_open sqlite3_api->blob_open
|
||||
#define sqlite3_blob_read sqlite3_api->blob_read
|
||||
#define sqlite3_blob_write sqlite3_api->blob_write
|
||||
#define sqlite3_create_collation_v2 sqlite3_api->create_collation_v2
|
||||
#define sqlite3_file_control sqlite3_api->file_control
|
||||
#define sqlite3_memory_highwater sqlite3_api->memory_highwater
|
||||
#define sqlite3_memory_used sqlite3_api->memory_used
|
||||
#define sqlite3_mutex_alloc sqlite3_api->mutex_alloc
|
||||
#define sqlite3_mutex_enter sqlite3_api->mutex_enter
|
||||
#define sqlite3_mutex_free sqlite3_api->mutex_free
|
||||
#define sqlite3_mutex_leave sqlite3_api->mutex_leave
|
||||
#define sqlite3_mutex_try sqlite3_api->mutex_try
|
||||
#define sqlite3_open_v2 sqlite3_api->open_v2
|
||||
#define sqlite3_release_memory sqlite3_api->release_memory
|
||||
#define sqlite3_result_error_nomem sqlite3_api->result_error_nomem
|
||||
#define sqlite3_result_error_toobig sqlite3_api->result_error_toobig
|
||||
#define sqlite3_sleep sqlite3_api->sleep
|
||||
#define sqlite3_soft_heap_limit sqlite3_api->soft_heap_limit
|
||||
#define sqlite3_vfs_find sqlite3_api->vfs_find
|
||||
#define sqlite3_vfs_register sqlite3_api->vfs_register
|
||||
#define sqlite3_vfs_unregister sqlite3_api->vfs_unregister
|
||||
#define sqlite3_threadsafe sqlite3_api->xthreadsafe
|
||||
#define sqlite3_result_zeroblob sqlite3_api->result_zeroblob
|
||||
#define sqlite3_result_error_code sqlite3_api->result_error_code
|
||||
#define sqlite3_test_control sqlite3_api->test_control
|
||||
#define sqlite3_randomness sqlite3_api->randomness
|
||||
#define sqlite3_context_db_handle sqlite3_api->context_db_handle
|
||||
#define sqlite3_extended_result_codes sqlite3_api->extended_result_codes
|
||||
#define sqlite3_limit sqlite3_api->limit
|
||||
#define sqlite3_next_stmt sqlite3_api->next_stmt
|
||||
#define sqlite3_sql sqlite3_api->sql
|
||||
#define sqlite3_status sqlite3_api->status
|
||||
#define sqlite3_backup_finish sqlite3_api->backup_finish
|
||||
#define sqlite3_backup_init sqlite3_api->backup_init
|
||||
#define sqlite3_backup_pagecount sqlite3_api->backup_pagecount
|
||||
#define sqlite3_backup_remaining sqlite3_api->backup_remaining
|
||||
#define sqlite3_backup_step sqlite3_api->backup_step
|
||||
#define sqlite3_compileoption_get sqlite3_api->compileoption_get
|
||||
#define sqlite3_compileoption_used sqlite3_api->compileoption_used
|
||||
#define sqlite3_create_function_v2 sqlite3_api->create_function_v2
|
||||
#define sqlite3_db_config sqlite3_api->db_config
|
||||
#define sqlite3_db_mutex sqlite3_api->db_mutex
|
||||
#define sqlite3_db_status sqlite3_api->db_status
|
||||
#define sqlite3_extended_errcode sqlite3_api->extended_errcode
|
||||
#define sqlite3_log sqlite3_api->log
|
||||
#define sqlite3_soft_heap_limit64 sqlite3_api->soft_heap_limit64
|
||||
#define sqlite3_sourceid sqlite3_api->sourceid
|
||||
#define sqlite3_stmt_status sqlite3_api->stmt_status
|
||||
#define sqlite3_strnicmp sqlite3_api->strnicmp
|
||||
#define sqlite3_unlock_notify sqlite3_api->unlock_notify
|
||||
#define sqlite3_wal_autocheckpoint sqlite3_api->wal_autocheckpoint
|
||||
#define sqlite3_wal_checkpoint sqlite3_api->wal_checkpoint
|
||||
#define sqlite3_wal_hook sqlite3_api->wal_hook
|
||||
#define sqlite3_blob_reopen sqlite3_api->blob_reopen
|
||||
#define sqlite3_vtab_config sqlite3_api->vtab_config
|
||||
#define sqlite3_vtab_on_conflict sqlite3_api->vtab_on_conflict
|
||||
/* Version 3.7.16 and later */
|
||||
#define sqlite3_close_v2 sqlite3_api->close_v2
|
||||
#define sqlite3_db_filename sqlite3_api->db_filename
|
||||
#define sqlite3_db_readonly sqlite3_api->db_readonly
|
||||
#define sqlite3_db_release_memory sqlite3_api->db_release_memory
|
||||
#define sqlite3_errstr sqlite3_api->errstr
|
||||
#define sqlite3_stmt_busy sqlite3_api->stmt_busy
|
||||
#define sqlite3_stmt_readonly sqlite3_api->stmt_readonly
|
||||
#define sqlite3_stricmp sqlite3_api->stricmp
|
||||
#define sqlite3_uri_boolean sqlite3_api->uri_boolean
|
||||
#define sqlite3_uri_int64 sqlite3_api->uri_int64
|
||||
#define sqlite3_uri_parameter sqlite3_api->uri_parameter
|
||||
#define sqlite3_uri_vsnprintf sqlite3_api->xvsnprintf
|
||||
#define sqlite3_wal_checkpoint_v2 sqlite3_api->wal_checkpoint_v2
|
||||
/* Version 3.8.7 and later */
|
||||
#define sqlite3_auto_extension sqlite3_api->auto_extension
|
||||
#define sqlite3_bind_blob64 sqlite3_api->bind_blob64
|
||||
#define sqlite3_bind_text64 sqlite3_api->bind_text64
|
||||
#define sqlite3_cancel_auto_extension sqlite3_api->cancel_auto_extension
|
||||
#define sqlite3_load_extension sqlite3_api->load_extension
|
||||
#define sqlite3_malloc64 sqlite3_api->malloc64
|
||||
#define sqlite3_msize sqlite3_api->msize
|
||||
#define sqlite3_realloc64 sqlite3_api->realloc64
|
||||
#define sqlite3_reset_auto_extension sqlite3_api->reset_auto_extension
|
||||
#define sqlite3_result_blob64 sqlite3_api->result_blob64
|
||||
#define sqlite3_result_text64 sqlite3_api->result_text64
|
||||
#define sqlite3_strglob sqlite3_api->strglob
|
||||
/* Version 3.8.11 and later */
|
||||
#define sqlite3_value_dup sqlite3_api->value_dup
|
||||
#define sqlite3_value_free sqlite3_api->value_free
|
||||
#define sqlite3_result_zeroblob64 sqlite3_api->result_zeroblob64
|
||||
#define sqlite3_bind_zeroblob64 sqlite3_api->bind_zeroblob64
|
||||
/* Version 3.9.0 and later */
|
||||
#define sqlite3_value_subtype sqlite3_api->value_subtype
|
||||
#define sqlite3_result_subtype sqlite3_api->result_subtype
|
||||
/* Version 3.10.0 and later */
|
||||
#define sqlite3_status64 sqlite3_api->status64
|
||||
#define sqlite3_strlike sqlite3_api->strlike
|
||||
#define sqlite3_db_cacheflush sqlite3_api->db_cacheflush
|
||||
/* Version 3.12.0 and later */
|
||||
#define sqlite3_system_errno sqlite3_api->system_errno
|
||||
/* Version 3.14.0 and later */
|
||||
#define sqlite3_trace_v2 sqlite3_api->trace_v2
|
||||
#define sqlite3_expanded_sql sqlite3_api->expanded_sql
|
||||
/* Version 3.18.0 and later */
|
||||
#define sqlite3_set_last_insert_rowid sqlite3_api->set_last_insert_rowid
|
||||
/* Version 3.20.0 and later */
|
||||
#define sqlite3_prepare_v3 sqlite3_api->prepare_v3
|
||||
#define sqlite3_prepare16_v3 sqlite3_api->prepare16_v3
|
||||
#define sqlite3_bind_pointer sqlite3_api->bind_pointer
|
||||
#define sqlite3_result_pointer sqlite3_api->result_pointer
|
||||
#define sqlite3_value_pointer sqlite3_api->value_pointer
|
||||
/* Version 3.22.0 and later */
|
||||
#define sqlite3_vtab_nochange sqlite3_api->vtab_nochange
|
||||
#define sqlite3_value_nochange sqlite3_api->value_nochange
|
||||
#define sqlite3_vtab_collation sqlite3_api->vtab_collation
|
||||
/* Version 3.24.0 and later */
|
||||
#define sqlite3_keyword_count sqlite3_api->keyword_count
|
||||
#define sqlite3_keyword_name sqlite3_api->keyword_name
|
||||
#define sqlite3_keyword_check sqlite3_api->keyword_check
|
||||
#define sqlite3_str_new sqlite3_api->str_new
|
||||
#define sqlite3_str_finish sqlite3_api->str_finish
|
||||
#define sqlite3_str_appendf sqlite3_api->str_appendf
|
||||
#define sqlite3_str_vappendf sqlite3_api->str_vappendf
|
||||
#define sqlite3_str_append sqlite3_api->str_append
|
||||
#define sqlite3_str_appendall sqlite3_api->str_appendall
|
||||
#define sqlite3_str_appendchar sqlite3_api->str_appendchar
|
||||
#define sqlite3_str_reset sqlite3_api->str_reset
|
||||
#define sqlite3_str_errcode sqlite3_api->str_errcode
|
||||
#define sqlite3_str_length sqlite3_api->str_length
|
||||
#define sqlite3_str_value sqlite3_api->str_value
|
||||
/* Version 3.25.0 and later */
|
||||
#define sqlite3_create_window_function sqlite3_api->create_window_function
|
||||
/* Version 3.26.0 and later */
|
||||
#define sqlite3_normalized_sql sqlite3_api->normalized_sql
|
||||
/* Version 3.28.0 and later */
|
||||
#define sqlite3_stmt_isexplain sqlite3_api->isexplain
|
||||
#define sqlite3_value_frombind sqlite3_api->frombind
|
||||
/* Version 3.30.0 and later */
|
||||
#define sqlite3_drop_modules sqlite3_api->drop_modules
|
||||
#endif /* !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
|
||||
** extension */
|
||||
# define SQLITE_EXTENSION_INIT1 const sqlite3_api_routines *sqlite3_api=0;
|
||||
# define SQLITE_EXTENSION_INIT2(v) sqlite3_api=v;
|
||||
# define SQLITE_EXTENSION_INIT3 \
|
||||
extern const sqlite3_api_routines *sqlite3_api;
|
||||
#else
|
||||
/* This case when the file is being statically linked into the
|
||||
** application */
|
||||
# define SQLITE_EXTENSION_INIT1 /*no-op*/
|
||||
# define SQLITE_EXTENSION_INIT2(v) (void)v; /* unused parameter */
|
||||
# define SQLITE_EXTENSION_INIT3 /*no-op*/
|
||||
#endif
|
||||
|
||||
#endif /* SQLITE3EXT_H */
|
||||
Binary file not shown.
@@ -0,0 +1,41 @@
|
||||
# libsqlite3.la - a libtool library file
|
||||
# Generated by libtool (GNU libtool) 2.4.6 Debian-2.4.6-2
|
||||
#
|
||||
# Please DO NOT delete this file!
|
||||
# It is necessary for linking the library.
|
||||
|
||||
# The name that we can dlopen(3).
|
||||
dlname='libsqlite3.so.0'
|
||||
|
||||
# Names of this library.
|
||||
library_names='libsqlite3.so.0.8.6 libsqlite3.so.0 libsqlite3.so'
|
||||
|
||||
# The name of the static archive.
|
||||
old_library='libsqlite3.a'
|
||||
|
||||
# Linker flags that cannot go in dependency_libs.
|
||||
inherited_linker_flags=''
|
||||
|
||||
# Libraries that this one depends upon.
|
||||
dependency_libs=' -lm -ldl -lpthread'
|
||||
|
||||
# Names of additional weak libraries provided by this library
|
||||
weak_library_names=''
|
||||
|
||||
# Version information for libsqlite3.
|
||||
current=8
|
||||
age=8
|
||||
revision=6
|
||||
|
||||
# Is this an already installed library?
|
||||
installed=yes
|
||||
|
||||
# Should we warn about portability when linking against -modules?
|
||||
shouldnotlink=no
|
||||
|
||||
# Files to dlopen/dlpreopen
|
||||
dlopen=''
|
||||
dlpreopen=''
|
||||
|
||||
# Directory that this library needs to be installed in:
|
||||
libdir='/mnt/hgfs/ubuntu16.04_workspace/workspace/sqlite/pc/lib'
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user