Browse Source

Z991239-1387 #comment other: Linux下解析广告策略功能优化

陈礼鹏80274480 4 years ago
parent
commit
b92a3aec48

+ 1 - 1
Module/mod_localmediaplay/AdvertBase/AdvertBase.cpp

@@ -1,4 +1,4 @@
-#include "stdafx.h"
+#include "../stdafx.h"
 #include "AdvertBase.h"
 
 

+ 383 - 1
Module/mod_localmediaplay/AdvertManage/BaseFun.cpp

@@ -13,6 +13,11 @@
 #endif // RVC_OS_WIN
 
 
+#ifndef RVC_MAX_INI_LEN
+#define RVC_MAX_INI_LEN 1024*16
+#endif // !RVC_MAX_INI_LEN
+
+
 bool Unzip2Folder(BSTR lpZipFile, BSTR lpFolder)
 {
 #ifdef RVC_OS_WIN
@@ -373,4 +378,381 @@ bool getUniqueDir(string path, string &dirName)
 		return true;
 	}
 	return false;
-}
+}
+
+
+
+UINT GetPrivateProfileIntEx(LPCSTR lpAppName,LPCSTR lpKeyName,INT nDefault,LPCSTR lpFileName)
+{
+	char lpReturnedString[MAX_PATH] = { 0 };
+	DWORD nRet = GetPrivateProfileStringEx(
+		lpAppName,
+		lpKeyName,
+		"",
+		lpReturnedString,
+		sizeof(lpReturnedString),
+		lpFileName
+	);
+
+	if (nRet == 0) {
+		return nDefault;
+	}
+		
+	return atoi(lpReturnedString);
+}
+
+BOOL WritePrivateProfileStringEx(LPCSTR lpAppName,LPCSTR lpKeyName,LPCSTR lpString,LPCSTR lpFileName)
+{
+	FILE* fp = NULL;
+	static char szLine[RVC_MAX_INI_LEN] = { 0 };
+	static char tmpstr[RVC_MAX_INI_LEN] = { 0 };
+	memset(szLine, 0, sizeof(szLine));
+	memset(tmpstr, 0, sizeof(tmpstr));
+	int rtnval;
+	int i = 0;
+	int secFlag = 0;
+
+	if ((fp = fopen(lpFileName, "rw+")) == NULL){
+		return FALSE;
+	}
+
+	int lineLen = 0;//整行长度      
+	int orgEqualPos = 0;//=号在原行中的位置
+	int equalPos = 0; //=号在去空格后的位置
+	strcpy(tmpstr, "[");
+	strcat(tmpstr, lpAppName);
+	strcat(tmpstr, "]");
+	int endFlag;
+	while (!feof(fp))
+	{
+
+		rtnval = fgetc(fp);
+		if (rtnval == EOF){
+			//最后一行可能无换行符号   	
+			rtnval = '\n';
+			endFlag = 1;
+		}
+		//注释行    
+		if ('#' == rtnval || ';' == rtnval)
+		{
+			fgets(szLine, sizeof(szLine), fp);
+			//reset 
+			i = 0;
+			lineLen = 0;
+			orgEqualPos = 0;
+			equalPos = 0;
+			memset(szLine, 0, sizeof(szLine));
+			continue;
+		}
+		else if ('/' == rtnval)
+		{
+			szLine[i++] = rtnval;
+			lineLen++;
+			if ('/' == (rtnval = fgetc(fp))) //注释行
+			{
+				fgets(szLine, sizeof(szLine), fp);
+				//reset 
+				i = 0;
+				lineLen = 0;
+				orgEqualPos = 0;
+				equalPos = 0;
+				memset(szLine, 0, sizeof(szLine));
+				continue;
+			}
+		}
+
+		if (rtnval != ' ' && rtnval != '\t')
+		{
+			szLine[i++] = rtnval;   //去掉空格和tab后的字符串
+			if (rtnval == '=')
+			{
+				orgEqualPos = lineLen;
+				equalPos = i - 1;
+			}
+
+		}
+
+		lineLen++; //字符
+
+		if (rtnval == '\n'){
+			szLine[--i] = '\0';
+			if (szLine[--i] == '\r')
+				szLine[i--] = '\0';
+
+			if ((equalPos != 0) && (secFlag == 1))
+			{
+				szLine[equalPos] = '\0';
+				if (strcasecmp(szLine, lpKeyName) == 0)
+				{
+					//找到key对应变量
+					int leftPos = ftell(fp);
+					int writePos = leftPos - lineLen + orgEqualPos + 1;
+					fseek(fp, 0, SEEK_END);
+					int leftLen = ftell(fp) - leftPos;
+					char* pLeft = new char[leftLen];
+					fseek(fp, leftPos, SEEK_SET);
+					fread(pLeft, leftLen, 1, fp);
+					fseek(fp, writePos, SEEK_SET);
+					fwrite(lpString, strlen(lpString), 1, fp);
+					fwrite("\n", sizeof(char), 1, fp);
+					fwrite(pLeft, leftLen, 1, fp);
+					delete[]pLeft;
+					pLeft = 0;
+					fclose(fp);
+					return TRUE;
+				}
+			}
+
+			else
+			{
+				if (strcasecmp(tmpstr, szLine) == 0)
+				{
+					//找到section    
+					secFlag = 1;
+				}
+				else if (secFlag == 1 && szLine[0] == '[' && szLine[i] == ']')
+				{//进入下个section了,说明没找到
+					int leftPos = ftell(fp) - lineLen;
+					int writePos = leftPos;
+					fseek(fp, 0, SEEK_END);
+					int leftLen = ftell(fp) - leftPos;
+					char* pLeft = new char[leftLen];
+					fseek(fp, leftPos, SEEK_SET);
+					fread(pLeft, leftLen, 1, fp);
+					fseek(fp, writePos, SEEK_SET);
+					fwrite("\n", sizeof(char), 1, fp);
+					fwrite(lpKeyName, strlen(lpKeyName), 1, fp);
+					fwrite("=", sizeof(char), 1, fp);
+					fwrite(lpString, strlen(lpString), 1, fp);
+					fwrite("\n", sizeof(char), 1, fp);
+					fwrite(pLeft, leftLen, 1, fp);
+					delete[]pLeft;
+					pLeft = 0;
+					fclose(fp);
+					return TRUE;
+				}
+			}
+			//reset 
+			if (endFlag == 1)
+				break;
+			i = 0;
+			lineLen = 0;
+			orgEqualPos = 0;
+			equalPos = 0;
+			memset(szLine, 0, sizeof(szLine));
+		}
+	}
+	//到文件尾了	
+	if (secFlag)
+	{//必须有section
+		fseek(fp, 0, SEEK_END);
+		fwrite("\n", sizeof(char), 1, fp);
+		fwrite(lpKeyName, strlen(lpKeyName), 1, fp);
+		fwrite("=", sizeof(char), 1, fp);
+		fwrite(lpString, strlen(lpString), 1, fp);
+		fwrite("\n", sizeof(char), 1, fp);
+	}
+	fclose(fp);
+	return TRUE;
+}
+
+DWORD GetPrivateProfileStringEx(LPCSTR lpAppName, LPCSTR lpKeyName, LPCSTR lpDefault, LPSTR lpReturnedString, DWORD nSize, LPCSTR lpFileName)
+{
+	FILE* fp = NULL;
+	static char szLine[RVC_MAX_INI_LEN] = { 0 };
+	static char tmpstr[RVC_MAX_INI_LEN] = { 0 };
+	int rtnval;
+	int i = 0;
+	int secFlag = 0;
+
+	if ((fp = fopen(lpFileName, "r")) == NULL){
+		Dbg("have no such file[%s]", lpFileName);
+		return -1;
+	}
+
+	int equalPos = 0; //=号在去空格后的位置
+	strcpy(tmpstr, "[");
+	strcat(tmpstr, lpAppName);
+	strcat(tmpstr, "]");
+	int endFlag = 0;
+	while (!feof(fp))
+	{
+		rtnval = fgetc(fp);
+		if (rtnval == EOF){
+			//最后一行可能无换行符号     	
+			rtnval = '\n';
+			endFlag = 1;
+		}
+		//注释行    
+		if ('#' == rtnval || ';' == rtnval)
+		{
+			fgets(szLine, sizeof(szLine), fp);
+			//reset 
+			i = 0;
+			equalPos = 0;
+			memset(szLine, 0, sizeof(szLine));
+			continue;
+		}
+		else if ('/' == rtnval)
+		{
+			szLine[i++] = rtnval;
+			if ('/' == (rtnval = fgetc(fp))) //注释行
+			{
+				fgets(szLine, sizeof(szLine), fp);
+				//reset 
+				i = 0;
+				equalPos = 0;
+				memset(szLine, 0, sizeof(szLine));
+				continue;
+			}
+		}
+
+		if (rtnval != ' ' && rtnval != '\t')
+		{
+			szLine[i++] = rtnval;   //去掉空格和tab后的字符串
+			if (rtnval == '=')
+			{
+				equalPos = i - 1;
+			}
+		}
+
+		if (rtnval == '\n'){
+			szLine[--i] = '\0';
+
+			if (szLine[--i] == '\r')
+				szLine[i--] = '\0';
+
+			if ((equalPos != 0) && (secFlag == 1))
+			{
+				szLine[equalPos] = '\0'; //=号变0
+				if (strcasecmp(szLine, lpKeyName) == 0)
+				{
+					//找到key对应变量 
+					strncpy(lpReturnedString, szLine + equalPos + 1, nSize - 1);
+					lpReturnedString[nSize - 1] = '\0';
+					fclose(fp);
+					return 1;
+				}
+			}
+			else
+			{
+				if (strcasecmp(tmpstr, szLine) == 0)
+				{
+					//找到section    
+					secFlag = 1;
+				}
+				else if (secFlag == 1 && szLine[0] == '[' && szLine[i] == ']')
+				{//进入下个section了,说明没找到
+					break;
+				}
+			}
+
+			if (endFlag == 1)
+				break;
+			//reset 
+			i = 0;
+			equalPos = 0;
+			memset(szLine, 0, sizeof(szLine));
+
+		}
+	}
+	fclose(fp);
+	//没找到则用默认
+	strncpy(lpReturnedString, lpDefault, nSize - 1);
+	lpReturnedString[nSize - 1] = '\0';
+
+	return 0;
+}
+
+
+DWORD GetPrivateProfileSectionEx(LPCSTR lpAppName, LPSTR lpReturnedString, DWORD nSize, LPCSTR lpFileName)
+{
+	//由于项目中未使用,暂未实现
+	assert(0);
+	return 0;
+}
+
+
+DWORD GetPrivateProfileSectionNamesEx(LPSTR lpszReturnBuffer, DWORD nSize, LPCSTR lpFileName)
+{
+	FILE* fp = NULL;
+	static char szLine[RVC_MAX_INI_LEN] = { 0 };
+	static char tmpstr[RVC_MAX_INI_LEN] = { 0 };
+	int rPos = 0;
+
+	memset(lpszReturnBuffer, 0, nSize);
+	int rtnval;
+	int i = 0;
+	int endFlag;
+
+	if ((fp = fopen(lpFileName, "r")) == NULL){
+		return -1;
+	}
+
+	while (!feof(fp))
+	{
+		rtnval = fgetc(fp);
+		if (rtnval == EOF){
+			//最后一行可能无换行符号    	
+			rtnval = '\n';
+			endFlag = 1;
+		}
+		//注释行    
+		if ('#' == rtnval || ';' == rtnval)
+		{
+			fgets(szLine, sizeof(szLine), fp);
+			//reset 
+			i = 0;
+			memset(szLine, 0, sizeof(szLine));
+			continue;
+		}
+		else if ('/' == rtnval)
+		{
+			szLine[i++] = rtnval;
+			if ('/' == (rtnval = fgetc(fp))) //注释行
+			{
+				fgets(szLine, sizeof(szLine), fp);
+				//reset 
+				i = 0;
+				memset(szLine, 0, sizeof(szLine));
+				continue;
+			}
+		}
+
+		if (rtnval != ' ' && rtnval != '\t')
+		{
+			szLine[i++] = rtnval;   //去掉空格和tab后的字符串
+
+		}
+
+		if (rtnval == '\n')
+		{
+			szLine[--i] = '\0';
+			if (szLine[--i] == '\r')
+				szLine[i--] = '\0';
+
+			if (szLine[0] == '[' && szLine[i] == ']')
+			{
+				//找到section    
+				for (int j = 1; j < i && rPos < nSize - 1; j++)
+					lpszReturnBuffer[rPos++] = szLine[j];
+				lpszReturnBuffer[rPos++] = '\0';
+				if (rPos >= nSize)
+				{
+					break;
+				}
+			}
+
+			if (endFlag == 1)
+				break;
+
+			//reset 
+			i = 0;
+			memset(szLine, 0, sizeof(szLine));
+
+		}
+	}
+	lpszReturnBuffer[rPos] = '\0';
+	fclose(fp);
+	return 0;
+}

+ 43 - 1
Module/mod_localmediaplay/AdvertManage/BaseFun.h

@@ -1,6 +1,7 @@
 #include <vector>
 #include <string>
 #include "fileutil.h"
+#include "SpBase.h"
 
 #ifdef _WIN32
 #include <windows.h>
@@ -18,4 +19,45 @@ bool removeDir(const string &filePaht);
 void Wchar_tToString(std::string& szDst, wchar_t *wchar);
 void StringToWstring(std::wstring& szDst, std::string str);
 void stopForDebug();
-bool getUniqueDir(string path, string &dirName);//获取路径中唯一的一个文件夹名,失败返回false
+bool getUniqueDir(string path, string &dirName);//获取路径中唯一的一个文件夹名,失败返回false
+
+
+UINT
+GetPrivateProfileIntEx(
+	LPCSTR lpAppName,
+	LPCSTR lpKeyName,
+	INT nDefault,
+	LPCSTR lpFileName
+);
+
+BOOL
+WritePrivateProfileStringEx(
+	LPCSTR lpAppName,
+	LPCSTR lpKeyName,
+	LPCSTR lpString,
+	LPCSTR lpFileName
+);
+DWORD
+GetPrivateProfileStringEx(
+	LPCSTR lpAppName,
+	LPCSTR lpKeyName,
+	LPCSTR lpDefault,
+	LPSTR lpReturnedString,
+	DWORD nSize,
+	LPCSTR lpFileName
+);
+
+DWORD
+GetPrivateProfileSectionEx(
+	LPCSTR lpAppName,
+	LPSTR lpReturnedString,
+	DWORD nSize,
+	LPCSTR lpFileName
+);
+
+DWORD
+GetPrivateProfileSectionNamesEx(
+	LPSTR lpszReturnBuffer,
+	DWORD nSize,
+	LPCSTR lpFileName
+);

+ 28 - 9
Module/mod_localmediaplay/AdvertManage/MediaManage.cpp

@@ -2,7 +2,7 @@
 #include "mediaManage.h"
 #include <set>
 #include <algorithm>
-#include "SpBase.h"
+
 
 
 #ifdef RVC_OS_WIN
@@ -173,21 +173,40 @@ void mediaManage::InitResourceListByLocal()
 
 	vector<ResourceParse> headList, branchList, networkList, allList;
 
-	if (!checkFileExist(headFile))
+	if (!checkFileExist(headFile)) {
 		Dbg("head config %s not exist!", headFile.c_str());
-	else if (!parseResourceIni(headFile.c_str(), headList))
+	}
+	else if (!parseResourceIni(headFile.c_str(), headList)) {
 		Dbg("parse head config %s fail!", headFile.c_str());
+	}
+	else
+	{
+		Dbg("parse head config %s success!", headFile.c_str());
+	}
 
-	if (!checkFileExist(branchFile))
-		Dbg("network  config %s not exist!", networkFile.c_str());
-	else if (!parseResourceIni(branchFile.c_str(), branchList))
+	if (!checkFileExist(branchFile)) {
+		Dbg("branch config %s not exist!", branchFile.c_str());
+	}
+	else if (!parseResourceIni(branchFile.c_str(), branchList)) {
 		Dbg("parse branch config %s fail!", branchFile.c_str());
+	}
+	else
+	{
+		Dbg("parse branch config %s success!", branchFile.c_str());
+	}
+
 
-	if (!checkFileExist(networkFile))
+	if (!checkFileExist(networkFile)) {
 		Dbg("network config %s not exist!", networkFile.c_str());
-	else if (!parseResourceIni(networkFile.c_str(), networkList))
+	}
+	else if (!parseResourceIni(networkFile.c_str(), networkList)) {
 		Dbg("parse network config %s fail!", networkFile.c_str());
-
+	}
+	else
+	{
+		Dbg("parse network config %s success!", networkFile.c_str());
+	}
+		
 	m_localList.clear();
 #ifdef RVC_OS_WIN
 	for each (auto i in headList)

+ 46 - 21
Module/mod_localmediaplay/AdvertManage/resourceIniParse.cpp

@@ -18,33 +18,35 @@ int ReadInterger(LPCTSTR szSection, LPCTSTR szKey, LPCTSTR szFileName, int iDefa
 #ifdef RVC_OS_WIN
 	return GetPrivateProfileInt(szSection, szKey, iDefaultValue, szFileName);
 #else
-	return 0;
+	return GetPrivateProfileIntEx(szSection, szKey, iDefaultValue, szFileName);
 #endif 
 }
 
 bool ReadBoolean(LPCTSTR szSection, LPCTSTR szKey, LPCTSTR szFileName, bool bDefaultValue)
 {
-	TCHAR szResult[255] = {0};
-	TCHAR szDefault[255] = {0};
+	TCHAR szResult[MAX_PATH] = {0};
+	TCHAR szDefault[MAX_PATH] = {0};
 	bool bolResult = false;
 	
 #ifdef RVC_OS_WIN
 	_stprintf_s(szDefault, _T("%s"), bDefaultValue ? _T("True") : _T("False"));
-	GetPrivateProfileString(szSection, szKey, (LPCTSTR)szDefault, szResult, 255, szFileName);
+	GetPrivateProfileString(szSection, szKey, (LPCTSTR)szDefault, szResult, MAX_PATH, szFileName);
 	bolResult = (_tcscmp(szResult, _T("True")) == 0 || _tcscmp(szResult, _T("true")) == 0) ? true : false;
 #else
-
+	snprintf(szDefault, MAX_PATH, "%s", bDefaultValue ? "True" : "False");
+	GetPrivateProfileStringEx(szSection, szKey, (LPCTSTR)szDefault, szResult, MAX_PATH, szFileName);
+	bolResult = (strcmp(szResult, "True") == 0 || strcmp(szResult, "true") == 0) ? true : false;
 #endif 
 	return bolResult;
 }
 
 string ReadString(LPCTSTR szSection, LPCTSTR szKey, LPCTSTR szFileName, LPCTSTR strDefaultValue)
 {
-	TCHAR  tempResult[512] = {0};
+	TCHAR  tempResult[MAX_PATH*2] = {0};
 #ifdef RVC_OS_WIN
-	GetPrivateProfileString(szSection, szKey, strDefaultValue, tempResult, 512, szFileName);
+	GetPrivateProfileString(szSection, szKey, strDefaultValue, tempResult, MAX_PATH * 2, szFileName);
 #else
-
+	GetPrivateProfileStringEx(szSection, szKey, strDefaultValue, tempResult, MAX_PATH * 2, szFileName);
 #endif 
 
 	return string(tempResult);
@@ -52,23 +54,25 @@ string ReadString(LPCTSTR szSection, LPCTSTR szKey, LPCTSTR szFileName, LPCTSTR
 
 void WriteBoolean(LPCTSTR szSection, LPCTSTR szKey, BOOL szBool, LPCTSTR szFileName)
 {
-	TCHAR szDefault[255] = {0};
+	TCHAR szDefault[MAX_PATH] = {0};
 #ifdef RVC_OS_WIN
 	_stprintf_s(szDefault, _T("%d"), szBool);
 	WritePrivateProfileString(szSection, szKey, szDefault, szFileName);
 #else
-
+	snprintf(szDefault, MAX_PATH, "%d", szBool);
+	WritePrivateProfileStringEx(szSection, szKey, szDefault, szFileName);
 #endif 
 }
 
 void WriteInt(LPCTSTR szSection, LPCTSTR szKey, INT szInt, LPCTSTR szFileName)
 {
-	TCHAR szDefault[255] = {0};
+	TCHAR szDefault[MAX_PATH] = {0};
 #ifdef RVC_OS_WIN
 	_stprintf_s(szDefault, _T("%d"), szInt);
 	WritePrivateProfileString(szSection, szKey, szDefault, szFileName);
 #else
-
+	snprintf(szDefault, MAX_PATH, "%d", szInt);
+	WritePrivateProfileStringEx(szSection, szKey, szDefault, szFileName);
 #endif 
 }
 
@@ -77,7 +81,7 @@ void WriteString(LPCTSTR szSection, LPCTSTR szKey, LPCTSTR szString, LPCTSTR szF
 #ifdef RVC_OS_WIN
 	WritePrivateProfileString(szSection, szKey, szString, szFileName);
 #else
-
+	WritePrivateProfileStringEx(szSection, szKey, szString, szFileName);
 #endif 
 }
 
@@ -99,7 +103,12 @@ bool checkInPlayTime(string playTime, bool checkCurTime)
 	t_beginHour = t_beginMin = t_endHour = t_endMin = 0;
 	try
 	{
+#ifdef RVC_OS_WIN
 		sscanf_s(playTime.c_str(), "%d:%d-%d:%d", &t_beginHour, &t_beginMin, &t_endHour, &t_endMin);
+#else
+		sscanf(playTime.c_str(), "%d:%d-%d:%d", &t_beginHour, &t_beginMin, &t_endHour, &t_endMin);
+#endif // RVC_OS_WIN
+
 		long curTime = local->tm_hour * 3600 + local->tm_min * 60 + local->tm_sec;
 		long beginTime = t_beginHour * 3600 + t_beginMin * 60;
 		long endTime = t_endHour * 3600 + t_endMin * 60 + 60;
@@ -122,7 +131,7 @@ bool checkInPlayTime(string playTime, bool checkCurTime)
 bool checkInVaildTime(string vaildTime, bool checkCurData)
 {
 	//get localTime
-	struct tm* local;
+	struct tm* local = NULL;
 	time_t t;
 	
 #ifdef RVC_OS_WIN
@@ -138,20 +147,30 @@ bool checkInVaildTime(string vaildTime, bool checkCurData)
 	try {
 		for (vector<string>::iterator i = dateList.begin(); i != dateList.end(); i++)
 		{
-			tm beginData, endData;
+			tm beginData = { 0 }, endData = {0};
 			int tempYear, tempMon, tempDay, tempYear2, tempMon2, tempDay2;
 			tempYear = tempMon = tempDay = tempYear2 = tempMon2 = tempDay2 = 0;
-			ZeroMemory(&beginData, sizeof(tm));
-			ZeroMemory(&endData, sizeof(tm));
+			//ZeroMemory(&beginData, sizeof(tm));
+			//ZeroMemory(&endData, sizeof(tm));
 			if (-1 == i->find('-'))	//µ¥ÈÕÆÚ
 			{
+#ifdef RVC_OS_WIN
 				sscanf_s(i->c_str(), "%d/%d/%d", &tempYear, &tempMon, &tempDay);
+#else
+				sscanf(i->c_str(), "%d/%d/%d", &tempYear, &tempMon, &tempDay);
+#endif // RVC_OS_WIN
+
+				
 				if (checkCurData && (local->tm_year + 1900 == tempYear) && (local->tm_mon + 1 == tempMon) && (local->tm_mday == tempDay))
 					return true;//find the data
 			}
 			else
 			{
+#ifdef RVC_OS_WIN
 				sscanf_s(i->c_str(), "%d/%d/%d-%d/%d/%d", &tempYear, &tempMon, &tempDay, &tempYear2, &tempMon2, &tempDay2);
+#else
+				sscanf(i->c_str(), "%d/%d/%d-%d/%d/%d", &tempYear, &tempMon, &tempDay, &tempYear2, &tempMon2, &tempDay2);
+#endif // RVC_OS_WIN
 
 				beginData.tm_year = tempYear - 1900;
 				beginData.tm_mon = tempMon - 1;
@@ -185,15 +204,21 @@ bool parseResourceIni(LPCTSTR filePath, vector<ResourceParse> &ret)
 #ifdef RVC_OS_WIN
 	if (INVALID_FILE_ATTRIBUTES == GetFileAttributes(filePath))
 	{
-		return FALSE;
+		return false;
 	}
 #else
 	struct stat buf;
-	if (stat(filePath, &buf))
+	if (stat(filePath, &buf)){
+		return false;
+	}
+	else
 	{
-		return FALSE;
+		if (!S_ISREG(buf.st_mode)) {
+			return false;
+		}
 	}
 #endif
+	
 
 	ret.clear();
 	int mediaNum = ReadInterger(SECTION_GENERAL, GENERAL_MEDIANUM, filePath, 0);
@@ -205,7 +230,7 @@ bool parseResourceIni(LPCTSTR filePath, vector<ResourceParse> &ret)
 #ifdef RVC_OS_WIN
 		_stprintf_s(sectionMedia, _T("%s%d"), SECTION_MEDIA, i);
 #else
-		sprintf_s(sectionMedia, 30, "%s%d", SECTION_MEDIA, i);
+		snprintf(sectionMedia, 30, "%s%d", SECTION_MEDIA, i);
 #endif // RVC_OS_WIN
 
 		ResourceParse curResource;

+ 8 - 5
Module/mod_localmediaplay/mod_localmediaplay.cpp

@@ -44,6 +44,8 @@ void* queryMedia(void* param)
 		curEntity->m_mediaManage.InitResourceListByLocal();
 		Sleep(3600 * 1000);
 	}
+
+	return 0;
 }
 #endif // RVC_OS_WIN
 
@@ -141,7 +143,7 @@ void CLocalMediaPlayEntity::loadDefaultMedia()
 	m_Videos.clear();
 #endif // RVC_OS_WIN
 
-	// ��ȡ����ý���Ŀ¼
+	// 读取LocalMediaPlay.ini中的配置
 	CSimpleStringA strRootPath;
 	ErrorCodeEnum Error = Error_Succeed;
 	Error = GetFunction()->GetPath("ADData", strRootPath);
@@ -466,7 +468,7 @@ int CLocalMediaPlayEntity::GetPlayerIcoPath(char* strPath, size_t uLen)
 	if (NULL == strPath) {
 		return iRet;
 	}
-	CSimpleStringA csBinPath, csBackslash("/");
+	CSimpleStringA csBinPath;
 	ErrorCodeEnum eErrPath = GetFunction()->GetPath("Bin", csBinPath);
 	if (eErrPath != Error_Succeed) {
 		Dbg("GetBasePath failed (%d).", eErrPath);
@@ -474,7 +476,7 @@ int CLocalMediaPlayEntity::GetPlayerIcoPath(char* strPath, size_t uLen)
 	}
 
 	CSimpleStringA szIcoName("rvc_media_player_64px.bmp");
-	szIcoName = csBinPath + csBackslash + szIcoName;
+	szIcoName = csBinPath + SPLIT_SLASH_STR + szIcoName;
 	//Dbg("media player ico full path is %s.", szIcoName.GetData());
 
 	if (uLen > szIcoName.GetLength()) {
@@ -552,7 +554,7 @@ ErrorCodeEnum CLocalMediaPlayEntity::__OnStart(ErrorCodeEnum preOperationError)
 #else
 	int err = pthread_create(&m_scanThreadId, NULL, queryMedia, this);
 	if (0 == err){
-		Dbg("create queryMedia thread success, %d.", m_scanThreadId);
+		Dbg("create queryMedia thread success, %lu.", m_scanThreadId);
 	}
 	else{
 		Dbg("create queryMedia thread failed.");
@@ -791,6 +793,7 @@ void* StartMediaPlayFunc(void* param)
 	{
 		vector<ResourceParse> curParse;
 		entity->m_mediaManage.GetPlayListByLocal(curParse);
+		Dbg("curParse.size() = %d.", curParse.size());
 		if (0 == curParse.size())
 		{
 			int64_t playThreadId  = 0;
@@ -1004,6 +1007,7 @@ void CLocalMediaPlayEntity::StartAudio(const char *pAudioNames)
 	m_lastPlayAudio = pAudioNames;
 	audioPlayThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)& CheckAudioThread, this, 0, NULL);
 #else
+
 	if (m_pMediaAudioPlayer->checkIsPlay()) {
 		Dbg("aurrent is playing, wait for it.");
 		//m_pMediaAudioPlayer->Close();
@@ -1280,7 +1284,6 @@ void CLocalMediaPlaySession::Handle_StartPlayVideo(SpReqAnsContext<PlayService_S
 void CLocalMediaPlaySession::Handle_StartPlayAudio(SpReqAnsContext<PlayService_StartPlayAudio_Req, PlayService_StartPlayAudio_Ans>::Pointer ctx)
 {
 	CSimpleStringA AudioNames = CSimpleStringW2A(ctx->Req.AudioNames);
-
 	CSimpleStringA UpdateState = "";
 	ErrorCodeEnum Error = m_pEntity->GetFunction()->GetSysVar("UpdateState", UpdateState);
 	if (Error == Error_Succeed && "1" == UpdateState)

+ 3 - 2
Other/libmediaplayer/player.cpp

@@ -183,12 +183,13 @@ CMediaPlayer::CMediaPlayer(CMediaHostApi* pHostApi)
 	m_piconpath = NULL;
 	
 	if (NULL != m_hostapi){
-		m_hostapi->Debug("new CMediaPlayer success!");
 		char str_iconpath[MAX_PATH] = {0};
 		if (0 == pHostApi->GetMediaPlayerIcoPath(str_iconpath, MAX_PATH)){
 			m_piconpath = av_strdup(str_iconpath);
 		}
-		
+	}
+	else {
+		m_hostapi->Debug("new CMediaPlayer failed!");
 	}
 }
 

+ 4 - 1
Other/libpictureplayer/CPicturePlayer.cpp

@@ -50,12 +50,15 @@ CPicturePlayer::CPicturePlayer(CPicHostApi* pHostApi)
 	}
 	m_pHostApi = pHostApi;
 	if (NULL != m_pHostApi){
-		m_pHostApi->PicDebug("new CPicturePlayer success!");
 		char strIcoPath[MAX_PATH] = { 0 };
 		if (0 == pHostApi->GetPicPlayerIcoPath(strIcoPath, MAX_PATH)) {
 			m_stricopath = rvc_strdup(strIcoPath);
 		}
 	}
+	else
+	{
+		m_pHostApi->PicDebug("new CPicturePlayer failed!");
+	}
 
 	for (int inum = 0; inum < MAX_DISPLAYNUM; inum++){
 		memset(&m_dispalymode[inum], 0, sizeof(SDL_DisplayMode));