diff --git a/.gitignore b/.gitignore
index 5ea512d..09a3bc2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
/3rdPartner/frp_0.56.0_linux_arm.tar.gz
/3rdPartner/go1.22.1.linux-armv6l.tar.gz
/appRelease/test.release
+/sdk/include/SQLiteCpp
diff --git a/applications/WebConfigure/cgiCommon/cgiCommon.sln b/applications/WebConfigure/cgiCommon/cgiCommon.sln
index e8e7f9d..1dd6e37 100644
--- a/applications/WebConfigure/cgiCommon/cgiCommon.sln
+++ b/applications/WebConfigure/cgiCommon/cgiCommon.sln
@@ -5,6 +5,10 @@ VisualStudioVersion = 16.0.34301.259
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cgiCommon", "cgiCommon.vcxproj", "{EC275930-0379-4487-8C30-EAFE2C124618}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libopdb", "..\..\library\libopdb\libopdb.vcxproj", "{E8431BFC-D508-428C-AC1D-A64539C5FC18}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jsondemo2", "..\..\examples\jsondemo2\jsondemo2.vcxproj", "{A7EA55C7-9DC1-4903-9470-66F3BF247D28}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|ARM = Debug|ARM
@@ -41,6 +45,42 @@ Global
{EC275930-0379-4487-8C30-EAFE2C124618}.Release|x86.ActiveCfg = Release|x86
{EC275930-0379-4487-8C30-EAFE2C124618}.Release|x86.Build.0 = Release|x86
{EC275930-0379-4487-8C30-EAFE2C124618}.Release|x86.Deploy.0 = Release|x86
+ {E8431BFC-D508-428C-AC1D-A64539C5FC18}.Debug|ARM.ActiveCfg = Debug|ARM
+ {E8431BFC-D508-428C-AC1D-A64539C5FC18}.Debug|ARM.Build.0 = Debug|ARM
+ {E8431BFC-D508-428C-AC1D-A64539C5FC18}.Debug|ARM.Deploy.0 = Debug|ARM
+ {E8431BFC-D508-428C-AC1D-A64539C5FC18}.Debug|ARM64.ActiveCfg = Debug|ARM64
+ {E8431BFC-D508-428C-AC1D-A64539C5FC18}.Debug|ARM64.Build.0 = Debug|ARM64
+ {E8431BFC-D508-428C-AC1D-A64539C5FC18}.Debug|ARM64.Deploy.0 = Debug|ARM64
+ {E8431BFC-D508-428C-AC1D-A64539C5FC18}.Debug|x64.ActiveCfg = Debug|x64
+ {E8431BFC-D508-428C-AC1D-A64539C5FC18}.Debug|x64.Build.0 = Debug|x64
+ {E8431BFC-D508-428C-AC1D-A64539C5FC18}.Debug|x64.Deploy.0 = Debug|x64
+ {E8431BFC-D508-428C-AC1D-A64539C5FC18}.Debug|x86.ActiveCfg = Debug|x86
+ {E8431BFC-D508-428C-AC1D-A64539C5FC18}.Debug|x86.Build.0 = Debug|x86
+ {E8431BFC-D508-428C-AC1D-A64539C5FC18}.Debug|x86.Deploy.0 = Debug|x86
+ {E8431BFC-D508-428C-AC1D-A64539C5FC18}.Release|ARM.ActiveCfg = Release|ARM
+ {E8431BFC-D508-428C-AC1D-A64539C5FC18}.Release|ARM.Build.0 = Release|ARM
+ {E8431BFC-D508-428C-AC1D-A64539C5FC18}.Release|ARM.Deploy.0 = Release|ARM
+ {E8431BFC-D508-428C-AC1D-A64539C5FC18}.Release|ARM64.ActiveCfg = Release|ARM64
+ {E8431BFC-D508-428C-AC1D-A64539C5FC18}.Release|ARM64.Build.0 = Release|ARM64
+ {E8431BFC-D508-428C-AC1D-A64539C5FC18}.Release|ARM64.Deploy.0 = Release|ARM64
+ {E8431BFC-D508-428C-AC1D-A64539C5FC18}.Release|x64.ActiveCfg = Release|x64
+ {E8431BFC-D508-428C-AC1D-A64539C5FC18}.Release|x64.Build.0 = Release|x64
+ {E8431BFC-D508-428C-AC1D-A64539C5FC18}.Release|x64.Deploy.0 = Release|x64
+ {E8431BFC-D508-428C-AC1D-A64539C5FC18}.Release|x86.ActiveCfg = Release|x86
+ {E8431BFC-D508-428C-AC1D-A64539C5FC18}.Release|x86.Build.0 = Release|x86
+ {E8431BFC-D508-428C-AC1D-A64539C5FC18}.Release|x86.Deploy.0 = Release|x86
+ {A7EA55C7-9DC1-4903-9470-66F3BF247D28}.Debug|ARM.ActiveCfg = Debug|Win32
+ {A7EA55C7-9DC1-4903-9470-66F3BF247D28}.Debug|ARM64.ActiveCfg = Debug|Win32
+ {A7EA55C7-9DC1-4903-9470-66F3BF247D28}.Debug|x64.ActiveCfg = Debug|x64
+ {A7EA55C7-9DC1-4903-9470-66F3BF247D28}.Debug|x64.Build.0 = Debug|x64
+ {A7EA55C7-9DC1-4903-9470-66F3BF247D28}.Debug|x86.ActiveCfg = Debug|Win32
+ {A7EA55C7-9DC1-4903-9470-66F3BF247D28}.Debug|x86.Build.0 = Debug|Win32
+ {A7EA55C7-9DC1-4903-9470-66F3BF247D28}.Release|ARM.ActiveCfg = Release|Win32
+ {A7EA55C7-9DC1-4903-9470-66F3BF247D28}.Release|ARM64.ActiveCfg = Release|Win32
+ {A7EA55C7-9DC1-4903-9470-66F3BF247D28}.Release|x64.ActiveCfg = Release|x64
+ {A7EA55C7-9DC1-4903-9470-66F3BF247D28}.Release|x64.Build.0 = Release|x64
+ {A7EA55C7-9DC1-4903-9470-66F3BF247D28}.Release|x86.ActiveCfg = Release|Win32
+ {A7EA55C7-9DC1-4903-9470-66F3BF247D28}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/applications/WebConfigure/cgiCommon/cgiCommon.vcxproj b/applications/WebConfigure/cgiCommon/cgiCommon.vcxproj
index 2456ef5..57fc77f 100644
--- a/applications/WebConfigure/cgiCommon/cgiCommon.vcxproj
+++ b/applications/WebConfigure/cgiCommon/cgiCommon.vcxproj
@@ -82,7 +82,7 @@
D:\My Documents\汇珏网络\15. EMS\projects\sdk\include
- D:\My Documents\汇珏网络\15. EMS\projects\sdk\include;D:\My Documents\汇珏网络\15. EMS\projects\sdk\include\cgicc;D:\My Documents\汇珏网络\15. EMS\projects\sdk\include\hv;D:\My Documents\汇珏网络\15. EMS\projects\sdk\include\nlohmann;$(IncludePath)
+ D:\My Documents\汇珏网络\15. EMS\projects\emsApplication\sdk\include\;D:\My Documents\汇珏网络\15. EMS\projects\emsApplication\sdk\include\cgicc;D:\My Documents\汇珏网络\15. EMS\projects\emsApplication\sdk\include\hv;D:\My Documents\汇珏网络\15. EMS\projects\emsApplication\sdk\include\nlohmann;D:\My Documents\汇珏网络\15. EMS\projects\emsApplication\sdk\include\sodium;D:\My Documents\汇珏网络\15. EMS\projects\emsApplication\sdk\include\spdlog;D:\My Documents\汇珏网络\15. EMS\projects\emsApplication\sdk\include\zmqpp;$(IncludePath)
diff --git a/applications/WebConfigure/cgiCommon/handleLoginRequest.cpp b/applications/WebConfigure/cgiCommon/handleLoginRequest.cpp
index 30c246d..abda9cb 100644
--- a/applications/WebConfigure/cgiCommon/handleLoginRequest.cpp
+++ b/applications/WebConfigure/cgiCommon/handleLoginRequest.cpp
@@ -6,6 +6,7 @@
#include
#include
+#include
#include "handleHeader.h"
using namespace cgicc;
@@ -43,7 +44,7 @@ void handleLoginRequest(cgicc::Cgicc& cgi)
std::cout << "
\n";
// ¼...
- // ֤ɹ
+
std::cout << "
\n";
std::cout << username.c_str() << std::endl;
diff --git a/applications/library/libopdb/libopdb.vcxproj b/applications/library/libopdb/libopdb.vcxproj
index 13ff1e7..0ce8ac1 100644
--- a/applications/library/libopdb/libopdb.vcxproj
+++ b/applications/library/libopdb/libopdb.vcxproj
@@ -77,6 +77,9 @@
D:\My Documents\汇珏网络\15. EMS\projects\sdk\include;$(IncludePath)
+
+ D:\My Documents\汇珏网络\15. EMS\projects\emsApplication\sdk\include;$(IncludePath)
+
@@ -89,7 +92,11 @@
-
+
+
+ D:\My Documents\汇珏网络\15. EMS\projects\emsApplication\sdk\include;%(AdditionalIncludeDirectories)
+
+
\ No newline at end of file
diff --git a/applications/library/libopdb/opdatabase.cpp b/applications/library/libopdb/opdatabase.cpp
index 02e203a..8a55819 100644
--- a/applications/library/libopdb/opdatabase.cpp
+++ b/applications/library/libopdb/opdatabase.cpp
@@ -2,6 +2,8 @@
#include
#include
#include
+#include "openjson.h"
+
OpDatabase::OpDatabase()
:m_pSqliteDb(nullptr)
@@ -58,12 +60,20 @@ void OpDatabase::InsertMessage(const std::string& ts, const std::string& msg_typ
}
}
-bool OpDatabase::QueryUser(const std::string& uname, const std::string& passwd)
+bool OpDatabase::QueryUser(const std::string& uname, const std::string& passwd, std::string& resultJson)
{
const char* queryDataSQL = "SELECT * FROM tbl_user WHERE uid=?;";
sqlite3_stmt * statement;
+ bool ret = false;
- if (sqlite3_prepare_v2(m_pSqliteDb, queryDataSQL, -1, &statement, nullptr) == SQLITE_OK)
+ int rc = sqlite3_prepare_v2(m_pSqliteDb, queryDataSQL, -1, &statement, nullptr);
+ if (rc != SQLITE_OK)
+ {
+ hloge("SQL error: %s ", sqlite3_errmsg(m_pSqliteDb));
+ return ret;
+ }
+
+ if ( rc == SQLITE_OK)
{
//
sqlite3_bind_text(statement, 1, uname.c_str(), -1, SQLITE_STATIC);
@@ -71,27 +81,34 @@ bool OpDatabase::QueryUser(const std::string& uname, const std::string& passwd)
// ִ
if (sqlite3_step(statement) != SQLITE_DONE)
{
- hlogw("Error query user %s", uname.c_str());
+ hloge("Error query user %s", uname.c_str());
}
else
{
+ OpenJson json;
+ auto& nodeRoot = json["users"];
+ size_t i = 0;
//
while (sqlite3_step(statement) == SQLITE_ROW)
{
- hlogi("Userid: %s", sqlite3_column_text(statement, 0));
- hlogi("UserName: %s", sqlite3_column_text(statement, 1));
- hlogi("UserSalt: %s", sqlite3_column_text(statement, 2));
- hlogi("UserPasswd: %s", sqlite3_column_text(statement, 3));
+ auto& node = nodeRoot[i];
+ node["id"] = sqlite3_column_text(statement, 0);
+ node["user"] = sqlite3_column_text(statement, 1);
+ node["salt"] = sqlite3_column_text(statement, 2);
+ node["passwd"] = sqlite3_column_text(statement, 3);
}
+
+ resultJson = json.encode();
+ ret = true;
}
// ͷԴ
sqlite3_finalize(statement);
- return true;
+ return ret;
}
- return false;
+ return ret;
}
diff --git a/applications/library/libopdb/opdatabase.h b/applications/library/libopdb/opdatabase.h
index faed5a7..edc5ce5 100644
--- a/applications/library/libopdb/opdatabase.h
+++ b/applications/library/libopdb/opdatabase.h
@@ -12,7 +12,7 @@ public:
void CloseDatabase();
bool OpenDatabase(const std::string& db_file_path);
void InsertMessage(const std::string& ts, const std::string& msg_type, const std::string& fsu, const std::string& content,int topic,int dev_id);
- bool QueryUser(const std::string& uname, const std::string& passwd);
+ bool QueryUser(const std::string& uname, const std::string& passwd, std::string& resultJson);
protected:
sqlite3* m_pSqliteDb;
private:
diff --git a/sdk/include/cppconn/build_config.h b/sdk/include/cppconn/build_config.h
new file mode 100644
index 0000000..f912807
--- /dev/null
+++ b/sdk/include/cppconn/build_config.h
@@ -0,0 +1,49 @@
+/*
+ Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+
+ The MySQL Connector/C++ is licensed under the terms of the GPLv2
+ , like most
+ MySQL Connectors. There are special exceptions to the terms and
+ conditions of the GPLv2 as it is applied to this software, see the
+ FLOSS License Exception
+ .
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#ifndef _SQL_BUILD_CONFIG_H_
+#define _SQL_BUILD_CONFIG_H_
+
+#ifndef CPPCONN_PUBLIC_FUNC
+
+#if defined(_WIN32)
+ // mysqlcppconn_EXPORTS is added by cmake and defined for dynamic lib build only
+ #ifdef mysqlcppconn_EXPORTS
+ #define CPPCONN_PUBLIC_FUNC __declspec(dllexport)
+ #else
+ // this is for static build
+ #ifdef CPPCONN_LIB_BUILD
+ #define CPPCONN_PUBLIC_FUNC
+ #else
+ // this is for clients using dynamic lib
+ #define CPPCONN_PUBLIC_FUNC __declspec(dllimport)
+ #endif
+ #endif
+#else
+ #define CPPCONN_PUBLIC_FUNC
+#endif
+
+#endif //#ifndef CPPCONN_PUBLIC_FUNC
+
+#endif //#ifndef _SQL_BUILD_CONFIG_H_
diff --git a/sdk/include/cppconn/config.h b/sdk/include/cppconn/config.h
new file mode 100644
index 0000000..f197a02
--- /dev/null
+++ b/sdk/include/cppconn/config.h
@@ -0,0 +1,90 @@
+/*
+ Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+
+ The MySQL Connector/C++ is licensed under the terms of the GPL
+ , like most
+ MySQL Connectors. There are special exceptions to the terms and
+ conditions of the GPL as it is applied to this software, see the
+ FLOSS License Exception
+ .
+*/
+
+// libmysql defines HAVE_STRTOUL (on win), so we have to follow different pattern in definitions names
+// to avoid annoying warnings.
+
+#define HAVE_FUNCTION_STRTOLD 1
+#define HAVE_FUNCTION_STRTOLL 1
+#define HAVE_FUNCTION_STRTOL 1
+#define HAVE_FUNCTION_STRTOULL 1
+
+#define HAVE_FUNCTION_STRTOUL 1
+
+#define HAVE_FUNCTION_STRTOIMAX 1
+#define HAVE_FUNCTION_STRTOUMAX 1
+
+#define HAVE_STDINT_H 1
+#define HAVE_INTTYPES_H 1
+
+#define HAVE_INT8_T 1
+#define HAVE_UINT8_T 1
+#define HAVE_INT16_T 1
+#define HAVE_UINT16_T 1
+#define HAVE_INT32_T 1
+#define HAVE_UINT32_T 1
+#define HAVE_INT32_T 1
+#define HAVE_UINT32_T 1
+#define HAVE_INT64_T 1
+#define HAVE_UINT64_T 1
+/* #undef HAVE_MS_INT8 */
+/* #undef HAVE_MS_UINT8 */
+/* #undef HAVE_MS_INT16 */
+/* #undef HAVE_MS_UINT16 */
+/* #undef HAVE_MS_INT32 */
+/* #undef HAVE_MS_UINT32 */
+/* #undef HAVE_MS_INT64 */
+/* #undef HAVE_MS_UINT64 */
+
+
+#ifdef HAVE_STDINT_H
+#include
+#endif
+
+#ifdef HAVE_INTTYPES_H
+#include
+#endif
+
+#if defined(_WIN32)
+#ifndef CPPCONN_DONT_TYPEDEF_MS_TYPES_TO_C99_TYPES
+
+#if !defined(HAVE_INT8_T) && defined(HAVE_MS_INT8)
+typedef __int8 int8_t;
+#endif
+
+#ifdef HAVE_MS_UINT8
+typedef unsigned __int8 uint8_t;
+#endif
+#ifdef HAVE_MS_INT16
+typedef __int16 int16_t;
+#endif
+
+#ifdef HAVE_MS_UINT16
+typedef unsigned __int16 uint16_t;
+#endif
+
+#ifdef HAVE_MS_INT32
+typedef __int32 int32_t;
+#endif
+
+#ifdef HAVE_MS_UINT32
+typedef unsigned __int32 uint32_t;
+#endif
+
+#ifdef HAVE_MS_INT64
+typedef __int64 int64_t;
+#endif
+#ifdef HAVE_MS_UINT64
+typedef unsigned __int64 uint64_t;
+#endif
+
+#endif // CPPCONN_DONT_TYPEDEF_MS_TYPES_TO_C99_TYPES
+#endif // _WIN32
diff --git a/sdk/include/cppconn/connection.h b/sdk/include/cppconn/connection.h
new file mode 100644
index 0000000..aab4e9a
--- /dev/null
+++ b/sdk/include/cppconn/connection.h
@@ -0,0 +1,155 @@
+/*
+ Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+
+ The MySQL Connector/C++ is licensed under the terms of the GPLv2
+ , like most
+ MySQL Connectors. There are special exceptions to the terms and
+ conditions of the GPLv2 as it is applied to this software, see the
+ FLOSS License Exception
+ .
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#ifndef _SQL_CONNECTION_H_
+#define _SQL_CONNECTION_H_
+
+#include