char* file_buf = NULL;
fopen_s(&fp, conf,"rb");
if( fp ){
fseek(fp,0,SEEK_END);
len = ftell(fp);
fseek(fp,0,SEEK_SET);
if( len ){
file_buf = (char*)malloc(len+1);
fread(file_buf,1,len,fp);
file_buf[len] = '\0';
data = file_buf;
}
fclose(fp);
}
const char* str;
int cnt;
int id;
ulong wbit;
}xxxxx[]={
{"1",1,1,0x00000001},
{"2",2,2,0x00000002},
{"3",3,3,0x00000003},
{"4",4,4,0x00000004,
{"5",5,5,0x00000005
};
int WritetoLog(
LPCTSTR lpszPath, // Ope Logging file path name
LPCTSTR lpszModuleName, // Module name
LPCTSTR lpszMsg, // Message string
LPCTSTR lpszFileName, // parse file name
int iLine, // error line number
UINT uMsgType) // Message type
{
int iRet = TSPT_OK;
TCHAR szOpeLogFileNew[_MAX_FNAME] ;
TCHAR szOpeLogFileOld[_MAX_FNAME] ;
FILE *fpLog;
int iFilePos;
// Make the Ope Logging full file name
iRet = MakeOpeLogFile(lpszPath, TSPT_OPE_FILE_NEW, szOpeLogFileNew);
// Create the logging directory.
if(iRet == TSPT_OK)
{
if(!CreateDirectory(lpszPath, NULL))
{
if(GetLastError() != ERROR_ALREADY_EXISTS)
{
iRet = TSPT_NG;
sprintf(g_szMsg, TSPT_ERR_CREATE_DIR_ERR, lpszPath);
}
}
}
// Write the message into the Ope Logging file
if(iRet == TSPT_OK)
{
EnterCriticalSection(&g_csLtsWriteFile);
if((fpLog = _tfopen(szOpeLogFileNew, _T("a"))) != NULL)
{
// Write the header message into the Ope Logging file
fseek(fpLog, 0, SEEK_END);
iFilePos = ftell(fpLog);
if(iFilePos >= TSPT_OPE_MAX_LEN)
{
fclose(fpLog);
iRet = MakeOpeLogFile(lpszPath, TSPT_OPE_FILE_OLD, szOpeLogFileOld);
if(iRet != TSPT_OK)
{
iRet = TSPT_NG;
sprintf(g_szMsg, TSPT_ERR_OPEN_FILE_ERR, szOpeLogFileOld);
return iRet;
}
CopyFile(szOpeLogFileNew, szOpeLogFileOld, FALSE);
if((fpLog = _tfopen(szOpeLogFileNew, _T("w"))) == NULL)
{
iRet = TSPT_NG;
sprintf(g_szMsg, TSPT_ERR_OPEN_FILE_ERR, szOpeLogFileNew);
return iRet;
}
}
// Write the message into the Ope Logging file
if(iRet == TSPT_OK)
{
if(WriteMsg(fpLog, lpszModuleName, lpszFileName, iLine,
(LPTSTR)lpszMsg, uMsgType) != TSPT_OK)
{
iRet = TSPT_NG;
sprintf(g_szMsg, TSPT_ERR_MSG_WRITE_ERR, szOpeLogFileNew);
}
}
fclose(fpLog);
}
else
{
iRet = TSPT_NG;
sprintf(g_szMsg, TSPT_ERR_OPEN_FILE_ERR, szOpeLogFileNew);
}
LeaveCriticalSection(&g_csLtsWriteFile);
}
return iRet ;
}
LPCTSTR lpszPath,
LPCTSTR lpszExtName,
LPTSTR lpszOpeLogFileName)
{
int iRet = TSPT_OK;
_TCHAR szDate[TSPT_OPE_DATE_LEN+1];
SYSTEMTIME local_time;
// Get current system time
GetLocalTime(&local_time);
_stprintf(szDate, _T("%04u%02u%02u"),
local_time.wYear,
local_time.wMonth,
local_time.wDay);
// Make the Ope Logging file name
_tcscpy(lpszOpeLogFileName, lpszPath);
if(*(lpszOpeLogFileName + _tcslen(lpszOpeLogFileName) - 1) != '\\')
_tcscat(lpszOpeLogFileName, "\\");
_tcscat(lpszOpeLogFileName, lpszExtName);
return iRet ;
}
int WriteMsg(
FILE *fpLog,
LPCTSTR lpszModuleName,
LPCTSTR lpszFileName,
int iLine,
LPCTSTR lpszMsg,
UINT uMsgType)
{
SYSTEMTIME local_time;
_TCHAR szType[TSPT_OPE_TYPE_LEN+1];
_TCHAR szTime[TSPT_OPE_TIME_LEN+1];
_TCHAR szMsgBuf[TSPT_MSG_LEN];
int iRet = TSPT_OK;
// Make the message type
switch(uMsgType)
{
case TSPT_OPE_MSG_TYPE_BEGIN:
_tcscpy(szType, TSPT_OPE_MSG_BEGIN);
break;
case TSPT_OPE_MSG_TYPE_WARNING:
_tcscpy(szType, TSPT_OPE_MSG_WARNING);
break;
case TSPT_OPE_MSG_TYPE_ERROR:
_tcscpy(szType, TSPT_OPE_MSG_ERROR);
break;
case TSPT_OPE_MSG_TYPE_END:
_tcscpy(szType, TSPT_OPE_MSG_END);
break;
case TSPT_OPE_MSG_TYPE_INFO:
break;
default:
iRet = TSPT_NG;
}
if(iRet == TSPT_OK)
{
// Make the current time
GetLocalTime(&local_time);
_stprintf(szTime, _T("%04u/%02u/%02u %02u:%02u:%02u"),
local_time.wYear,
local_time.wMonth,
local_time.wDay,
local_time.wHour,
local_time.wMinute,
local_time.wSecond);
if(uMsgType == TSPT_OPE_MSG_TYPE_INFO)
{
if(strlen(lpszFileName) > 0)
{
_stprintf(szMsgBuf, "%s %s(%s) %s\n", szTime, lpszModuleName, lpszFileName, lpszMsg);
}
else
{
_stprintf(szMsgBuf, "%s %s %s %s\n", szTime, lpszModuleName, lpszFileName, lpszMsg);
}
}
else if(uMsgType == TSPT_OPE_MSG_TYPE_BEGIN ||
uMsgType == TSPT_OPE_MSG_TYPE_END)
{
_stprintf(szMsgBuf, "%s %s %s\n", szTime, lpszModuleName, szType);
}
else
{
// Make the message string
if(lpszFileName == NULL || !strcmp(lpszFileName, ""))
{
_stprintf(szMsgBuf, "%s %s %s丗%s\n",
szTime, lpszModuleName, szType, lpszMsg);
}
else
{
if(iLine != 0)
{
_stprintf(szMsgBuf, "%s %s(%s:%4d) %s丗%s\n",
szTime, lpszModuleName, lpszFileName, iLine, szType, lpszMsg);
}
else
{
_stprintf(szMsgBuf, "%s %s(%s) %s丗%s\n",
szTime, lpszModuleName, lpszFileName, szType, lpszMsg);
}
}
}
// Write the message into the Ope Logging file
if(_ftprintf(fpLog, "%s", szMsgBuf) < 0)
{
iRet = TSPT_NG;
}
}
return iRet;
}
int xxxxxx::GetStartRow(Range &usedRane, int nRowCnt, int nColumnCnt)
{
Range range;
int i=0,j=0;
Font font;
for(i=1; i<=nRowCnt; i++)
{
for(j=1; j<=nColumnCnt; j++)
{
COleVariant vt;
vt = usedRane.GetItem(COleVariant((short)i),COleVariant((short)j));
range = vt.pdispVal;
font = range.GetFont();
if(IsStrikethrough(font))
{
continue;
}
vt.ChangeType(VT_BSTR,NULL);
CString strVal = vt.bstrVal;
TrimString(strVal);
if(!strVal.Compare(IDS_SERVERNAME))
{
range.ReleaseDispatch();
font.ReleaseDispatch();
return i;
}
}
}
range.ReleaseDispatch();
font.ReleaseDispatch();
return i;
}