فهرست منبع

新增宏:SAFESTR

sat23 4 سال پیش
والد
کامیت
5b06b7353c
1فایلهای تغییر یافته به همراه47 افزوده شده و 46 حذف شده
  1. 47 46
      CTSManager/CTSManager/Database.cpp

+ 47 - 46
CTSManager/CTSManager/Database.cpp

@@ -2,6 +2,7 @@
 #include "Database.h"
 
 #define CHECKDB if (m_pConn == NULL || !m_bConnected) return FALSE
+#define SAFESTR(str) ( str == NULL ? _T("") : str)
 
 char* CDatabase::m_spImage = NULL;
 CDatabase::CDatabase():m_pConn(NULL), m_pError(NULL), m_bConnected(FALSE)
@@ -351,9 +352,9 @@ BOOL CDatabase::QuerySoc(std::vector<STSOC>& vtSoc)
 	MYSQL_ROW row;
 	while ((row = mysql_fetch_row(pData)) != NULL) {
 		STSOC soc;
-		soc.name = row[0];
-		soc.provider = row[1];
-		soc.note = row[2];
+		soc.name = SAFESTR(row[0]);
+		soc.provider = SAFESTR(row[1]);
+		soc.note = SAFESTR(row[2]);
 		vtSoc.push_back(soc);
 	}
 
@@ -463,11 +464,11 @@ BOOL CDatabase::QueryBrand(std::vector<STBrand>& vtBrand)
 	MYSQL_ROW row;
 	while ((row = mysql_fetch_row(pData)) != NULL) {
 		STBrand brand;
-		brand.name = row[0];
-		brand.fav_cfg = row[1];
-		brand.local_cfg = row[2];
-		brand.apps_cfg = row[3];
-		brand.note = row[4];
+		brand.name = SAFESTR(row[0]);
+		brand.fav_cfg = SAFESTR(row[1]);
+		brand.local_cfg = SAFESTR(row[2]);
+		brand.apps_cfg = SAFESTR(row[3]);
+		brand.note = SAFESTR(row[4]);
 		vtBrand.push_back(brand);
 	}
 
@@ -629,9 +630,9 @@ BOOL CDatabase::QueryQuarter(std::vector<STQuarter>& vtQuarter)
 	MYSQL_ROW row;
 	while ((row = mysql_fetch_row(pData)) != NULL) {
 		STQuarter quarter;
-		quarter.name = row[0];
-		quarter.scp = row[1] == NULL ? _T("") : row[1];
-		quarter.note = row[2] == NULL ? _T("") : row[2];
+		quarter.name = SAFESTR(row[0]);
+		quarter.scp = SAFESTR(row[1]);
+		quarter.note = SAFESTR(row[2]);
 		vtQuarter.push_back(quarter);
 	}
 
@@ -763,24 +764,24 @@ BOOL CDatabase::QueryQBrand(std::vector<STQbrand>& vtQBrand)
 	MYSQL_ROW row;
 	while ((row = mysql_fetch_row(pData)) != NULL) {
 		STQbrand QBrand;
-		QBrand.soc = row[0];
-		QBrand.quarter = row[1];
-		QBrand.brand = row[2];
-		QBrand.whitelist = row[3];
-		QBrand.version = row[4];
-		QBrand.oemkey = row[5];
-		QBrand.approved = row[6];
-		QBrand.approveddate = row[7];
-		QBrand.fingerprint = row[8];
-		QBrand.builddate = row[9];
-		QBrand.gtvs = row[10];
-		QBrand.note = row[11];
-		QBrand.apps_cfg = row[12];
-		QBrand.fav_cfg = row[13];
-		QBrand.local_cfg = row[14];
-		QBrand.ftpdir = row[15];
-		QBrand.codedir = row[16];
-		QBrand.status = row[17];
+		QBrand.soc = SAFESTR(row[0]);
+		QBrand.quarter = SAFESTR(row[1]);
+		QBrand.brand = SAFESTR(row[2]);
+		QBrand.whitelist = SAFESTR(row[3]);
+		QBrand.version = SAFESTR(row[4]);
+		QBrand.oemkey = SAFESTR(row[5]);
+		QBrand.approved = SAFESTR(row[6]);
+		QBrand.approveddate = SAFESTR(row[7]);
+		QBrand.fingerprint = SAFESTR(row[8]);
+		QBrand.builddate = SAFESTR(row[9]);
+		QBrand.gtvs = SAFESTR(row[10]);
+		QBrand.note = SAFESTR(row[11]);
+		QBrand.apps_cfg = SAFESTR(row[12]);
+		QBrand.fav_cfg = SAFESTR(row[13]);
+		QBrand.local_cfg = SAFESTR(row[14]);
+		QBrand.ftpdir = SAFESTR(row[15]);
+		QBrand.codedir = SAFESTR(row[16]);
+		QBrand.status = SAFESTR(row[17]);
 		vtQBrand.push_back(QBrand);
 	}
 
@@ -939,9 +940,9 @@ BOOL CDatabase::QueryUser(std::vector<STUser>& vtUser)
 	MYSQL_ROW row;
 	while ((row = mysql_fetch_row(pData)) != NULL) {
 		STUser stUser;
-		stUser.user = row[0];
-		stUser.password = row[1];
-		stUser.permission = row[2];
+		stUser.user = SAFESTR(row[0]);
+		stUser.password = SAFESTR(row[1]);
+		stUser.permission = SAFESTR(row[2]);
 		vtUser.push_back(stUser);
 	}
 
@@ -1051,12 +1052,12 @@ BOOL CDatabase::QueryServer(std::vector<STServer>& vtServer)
 	MYSQL_ROW row;
 	while ((row = mysql_fetch_row(pData)) != NULL) {
 		STServer server;
-		server.name = row[0];
-		server.ip = row[1];
-		server.type = row[2];
-		server.user = row[3];
-		server.password = row[4];
-		server.note = row[5];
+		server.name = SAFESTR(row[0]);
+		server.ip = SAFESTR(row[1]);
+		server.type = SAFESTR(row[2]);
+		server.user = SAFESTR(row[3]);
+		server.password = SAFESTR(row[4]);
+		server.note = SAFESTR(row[5]);
 		vtServer.push_back(server);
 	}
 
@@ -1155,14 +1156,14 @@ BOOL CDatabase::QueryBranch(std::vector<STBranch>& vtBranch)
 	MYSQL_ROW row;
 	while ((row = mysql_fetch_row(pData)) != NULL) {
 		STBranch stBranch;
-		stBranch.name = row[0];
-		stBranch.quarter = row[1];
-		stBranch.address = row[2];
-		stBranch.provider = row[3];
-		stBranch.chip = row[4];
-		stBranch.type = row[5];
-		stBranch.status = row[6];
-		stBranch.note = row[7];
+		stBranch.name = SAFESTR(row[0]);
+		stBranch.quarter = SAFESTR(row[1]);
+		stBranch.address = SAFESTR(row[2]);
+		stBranch.provider = SAFESTR(row[3]);
+		stBranch.chip = SAFESTR(row[4]);
+		stBranch.type = SAFESTR(row[5]);
+		stBranch.status = SAFESTR(row[6]);
+		stBranch.note = SAFESTR(row[7]);
 		vtBranch.push_back(stBranch);
 	}