fast/Platform/stdafx.cpp

96 lines
2.1 KiB
C++
Raw Normal View History

2025-01-20 10:30:01 +08:00
// stdafx.cpp : ֻ<><D6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>׼<EFBFBD><D7BC><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>Դ<EFBFBD>ļ<EFBFBD>
// Vcs-Client.pch <20><><EFBFBD><EFBFBD>ΪԤ<CEAA><D4A4><EFBFBD><EFBFBD>ͷ
// stdafx.obj <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԥ<EFBFBD><D4A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
#include "stdafx.h"
#define MIN_XYZ_VALUE (-999999)
float* g_xys = new float[3000 * 3000 * 2];
int g_xyz_flag = 0;
#define Q_R 1500
#define X0 1500
#define Y0 1500
inline float abs_m(float lf)
{
if (lf < 0) lf *= -1;
return lf;
}
CString g_strSavePath = "";
CString g_strCurTime = "";
void LogOutToFile(const char* fmt, ...)
{
static CRITICAL_SECTION stCritical;
static BOOL bInit = FALSE;
static CString strLogPath;
if (FALSE == bInit)
{
bInit = TRUE;
GetModuleFileName(NULL, strLogPath.GetBuffer(2048), 2047);
strLogPath.ReleaseBuffer();
strLogPath = strLogPath.Left(strLogPath.ReverseFind('\\'));
strLogPath += "\\log\\runtime.log";
InitializeCriticalSection(&stCritical);
}
EnterCriticalSection(&stCritical);
va_list ap;
va_start(ap, fmt);
char pBuffer[800] = "";
if (vsnprintf_s(pBuffer, 796, _TRUNCATE, fmt, ap) > 0)
{
if (strlen(pBuffer) == 0 || pBuffer[strlen(pBuffer) - 1] != '\n')
{
pBuffer[strlen(pBuffer) + 1] = '\0';//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>׷<EFBFBD><D7B7>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊԭ<CEAA><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>޸<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>з<EFBFBD>
pBuffer[strlen(pBuffer)] = '\n';
}
}
va_end(ap);
TRACE("%s\n", pBuffer);
FILE* pFile = NULL;
fopen_s(&pFile, strLogPath.GetBuffer(), "ab+");
if (NULL != pFile)
{
char acTime[32] = { 0 };
SYSTEMTIME stTime;
GetLocalTime(&stTime);
sprintf_s(acTime, 32, "[%02d-%02d %02d:%02d:%02d.%03d] ", stTime.wMonth, stTime.wDay, stTime.wHour, stTime.wMinute, stTime.wSecond, stTime.wMilliseconds);
fwrite(acTime, 1, strlen(acTime), pFile);
fwrite(pBuffer, 1, strlen(pBuffer), pFile);
fwrite("\r\n", 1, strlen("\r\n"), pFile);
fclose(pFile);
}
LeaveCriticalSection(&stCritical);
}
int g_nMsgIdx = 998;
string _UnicodeToUtf8(CString Unicodestr)
{
wchar_t* unicode = Unicodestr.AllocSysString();
int len;
len = WideCharToMultiByte(CP_UTF8, 0, unicode, -1, NULL, 0, NULL, NULL);
char *szUtf8 = (char*)malloc(len + 1);
memset(szUtf8, 0, len + 1);
WideCharToMultiByte(CP_UTF8, 0, unicode, -1, szUtf8, len, NULL, NULL);
string result = szUtf8;
free(szUtf8);
return result;
}