BOOL CloseDebugLog()
{
	if( !g_bLogging ) return FALSE;

	FILE * fdebug = _tfopen( g_lpszLogFileName, TEXT( "ab" ) );
	if( fdebug == NULL )
	{
		Sleep( 3000UL );
		fdebug = _tfopen( g_lpszLogFileName, TEXT( "ab" ) );
	}

	if( fdebug == NULL )
	{
		MessageBox( NULL, TEXT( "CloseDebugLog() failed." ),
			APP_NAME, MB_ICONEXCLAMATION | MB_OK );
		return FALSE;
	}

	_fputts( TEXT( "\r\n\r\n" ), fdebug );
	SYSTEMTIME st;
	GetLocalTime( &st );
	TCHAR lpszTime[ 1024 ];
	wsprintf( lpszTime, TEXT( "[ %04d-%02d-%02d %02d:%02d:%02d.%03d ] " ),
		st.wYear, st.wMonth, st.wDay,
		st.wHour, st.wMinute, st.wSecond, st.wMilliseconds );
	_fputts( lpszTime, fdebug );
	_fputts( TEXT( "-------- END --------\r\n\r\n\r\n" ), fdebug );
	return fclose( fdebug );
}
예제 #2
0
/**
* In Unix systems which have a syslog facility the msg is stored there.
* The environment varibale <code>GLOBALPLATFORM_DEBUG</code> must be set to enable the logging.
* With the environment varibale <code>GLOBALPLATFORM_LOGFILE</code> an explicit log file name can
* be set. If a no log file name has been set impilictly <code>/tmp/GlobalPlatform.log</code>
* or <code>C:\TEMP\GlobalPlatform.log</code> under Windows will be used. If a log file name
* is given the syslog if available will not be used.
* \param msg The formatted message which will be stored.
* \prama ... Variable argument list
*/
void log_Log(LPTSTR msg, ...)
{
    va_list args;
    FILE *fp;
    time_t t;
    struct tm *time_s;
    TCHAR format[256];

    if (_tgetenv(_T("GLOBALPLATFORM_DEBUG")))
    {
    #ifdef HAVE_VSYSLOG
    if (getenv("GLOBALPLATFORM_LOGFILE")) {
	goto filelog;
    }
    else {
		va_start(args, msg);
		vsyslog(LOG_USER | LOG_DEBUG, msg, args);
		va_end(args);
		return;
    }
filelog:
    #endif // HAVE_VSYSLOG
    if (_tgetenv(_T("GLOBALPLATFORM_LOGFILE")))
        fp = _tfopen(_tgetenv(_T("GLOBALPLATFORM_LOGFILE")), _T("a"));
    else
        fp = _tfopen(LOG_FILENAME, _T("a"));

    if (!fp)
    {
	fp = stderr;
	_ftprintf(fp, _T("Error, could not open log file: %s\n"), LOG_FILENAME);
    }
    time(&t);
    time_s = localtime(&t);

    _sntprintf(format, 256, _T("%.2d/%.2d %.2d:%.2d:%.2d %s"),
			time_s->tm_mday,
			time_s->tm_mon+1,
			time_s->tm_hour,
			time_s->tm_min,
			time_s->tm_sec,
			msg);

    va_start(args, msg);
    _vftprintf(fp, format, args);
    va_end(args);

    #ifdef WIN32
    _fputts(_T("\r\n"), fp);
    #else
    _fputts(_T("\n"), fp);
    #endif // WIN32

    fflush(fp); /* Fixme: more accurate, but slows logging */

    if (fp != stderr)
        fclose(fp);
    }
}
예제 #3
0
void MeshDump::DumpAdjacencyBuffer(ID3DXBaseMesh* mesh) {
    _fputts(_T("Adjacency Buffer:\n-----------------\n"), m_DumpStream);
    // three enttries per face
    std::vector<DWORD> adjBuf(mesh->GetNumFaces() * 3);
    mesh->GenerateAdjacency(0.0f, &adjBuf[0]);
    for (DWORD i = 0; i < mesh->GetNumFaces(); i++)
        _ftprintf_s(m_DumpStream, _T("Triangle's adjacent to triangle %d: %d, %d, %d\n"), i, adjBuf[i * 3], adjBuf[i * 3 + 1], adjBuf[i * 3 + 2]);
    _fputts(_T("\n"), m_DumpStream);
}
예제 #4
0
// 基类 ID3DXBaseMesh 没有 LockAttributeBuffer/UnlockAttributeBuffer 方法
void MeshDump::DumpAttributeBuffer(ID3DXMesh* mesh) {
    _fputts(_T("Attribute Buffer:\n-----------------\n"), m_DumpStream);
    DWORD* attrBuf = NULL;
    mesh->LockAttributeBuffer(0, &attrBuf);
    // an attribute for each face
    for (DWORD i = 0; i < mesh->GetNumFaces(); i++)
        _ftprintf_s(m_DumpStream, _T("Triangle lives in subset %d: %d\n"), i, attrBuf[i]);
    mesh->UnlockAttributeBuffer();
    _fputts(_T("\n"), m_DumpStream);
}
예제 #5
0
void MeshDump::DumpIndex(ID3DXBaseMesh* mesh) {
    _fputts(_T("Index:\n--------\n"), m_DumpStream);
    WORD* idx = NULL;
    mesh->LockIndexBuffer(0, (void**) &idx);
    if (idx == NULL)
        return;
    for (DWORD i = 0; i < mesh->GetNumFaces(); i++)
        _ftprintf_s(m_DumpStream, _T("Triangle %d: %d, %d, %d\n"), i, idx[i * 3], idx[i * 3 + 1], idx[i * 3 + 2]);
    mesh->UnlockIndexBuffer();
    _fputts(_T("\n"), m_DumpStream);
}
예제 #6
0
UINT WINAPI OutputThreadFunction(LPVOID lpParam)
{
	WaitForSingleObject(gSynString.hEvent, INFINITE);
	WaitForSingleObject(gSynString.hMutex, INFINITE);

	_fputts(_T("Output string: "), stdout);
	_fputts(gSynString.string, stdout);

	ReleaseMutex(gSynString.hMutex);

	return 0;
}
예제 #7
0
/** Saves the internal xml nodes to the specified xml file.
*
* \param[in] pszPath - path to the file the data should be written to
*
* \note Function overwrites the contents of a file
*/
void ini_cfg::save(const tchar_t* pszPath)
{
	FILE* pFile=_tfopen(pszPath, _t("wb"));
	if(pFile == NULL)
		THROW(icpf::exception::format(_t("Cannot open the file ") TSTRFMT _t(" for writing."), pszPath), 0, errno, 0);

	// put BOM into the file

#if(defined(_WIN32) || defined(_WIN64))
	// utf-16le
	const uint_t uiBOM=0x0000feff;
	const uint_t uiCount=2;
#else
	// utf-8
	const uint_t uiBOM=0x00bfbbef;
	const uint_t uiCount=3;
#endif


	try
	{
		// write bom, check if itAttr succeeded
		if(fwrite(&uiBOM, 1, uiCount, pFile) != uiCount)
			THROW(_t("Cannot write the BOM to the file '") TSTRFMT _t("'"), 0, errno, 0);

		// and write
		tstring_t strLine;
		for(ini_storage::iterator iterSections = m_pMainNode->begin(); iterSections != m_pMainNode->end(); iterSections++)
		{
			strLine = _t("[") + (*iterSections).first + _t("]") + ENDL;
			if(_fputts(strLine.c_str(), pFile) == TEOF)
				THROW(_t("Cannot put section name"), 0, errno, 0);
			for(attr_storage::iterator iterAttribute = (*iterSections).second.begin(); iterAttribute != (*iterSections).second.end(); iterAttribute++)
			{
				strLine = (*iterAttribute).first + _t("=") + (*iterAttribute).second + ENDL;
				if(_fputts(strLine.c_str(), pFile) == TEOF)
					THROW(_t("Cannot put attribute"), 0, errno, 0);
			}

			if(_fputts(ENDL, pFile) == TEOF)
				THROW(_t("Cannot put end-of-line marker into the file"), 0, errno, 0);
		}
	}
	catch(...)
	{
		fclose(pFile);
		throw;
	}

	// close the file
	fclose(pFile);
}
예제 #8
0
void MeshDump::DumpVertex(ID3DXBaseMesh* mesh) {
    _fputts(_T("Vertex:\n---------\n"), m_DumpStream);
    Vertex* v = NULL;
    DWORD FVF = mesh->GetFVF();
    mesh->LockVertexBuffer(0, (void**) &v);
    size_t sz = Vertex::Size(FVF);
    v->DumpFVF(m_DumpStream, FVF);
    for (DWORD i = 0; i < mesh->GetNumVertices(); i++) {
        _ftprintf_s(m_DumpStream, _T("Vertex %d:"), i);
        Vertex::Data(v, i, sz)->Dump(m_DumpStream, FVF);
    }

    mesh->UnlockVertexBuffer();
    _fputts(_T("\n"), m_DumpStream);
}
예제 #9
0
int _tmain(int argc, _TCHAR* argv[])
{
	_tsetlocale(LC_ALL, _T("korean"));

	DWORD isExit;

	if (argc >= 2)
	{
		tokenNum = argc - 1;
		for (int i = 1; i < argc; i++)
		{
			_tcscpy(cmdTokenList[i - 1], argv[i]);
		}
		CmdProcessing();
	}


	while (1)
	{
		if (!Tokenize())
		{
			continue;
		}
		isExit = CmdProcessing();
		if (isExit == TRUE)
		{
			_fputts(_T("명령어 처리를 종료합니다. \n"), stdout);
			break;
		}
		tokenNum = 0;
	}

	return 0;
}
예제 #10
0
int _tmain(int argc, TCHAR * argv[])
{
	// 한글 입력을 가능케 하기 위해.
	_tsetlocale(LC_ALL, _T("Korean"));

	if (argc >= 2)  // 매개변수 전달인자가 있는 경우.
	{
		for (int i = 1; i<argc; i++)
			_tcscpy_s(cmdTokenList[i - 1], argv[i]);

		CmdProcessing(argc - 1);
	}

	int isExit = NULL;
	while (1)
	{
		int tokenNum = CmdReadTokenize();
		if (tokenNum == 0) //Enter 입력시 처리를 위해...
			continue;

		isExit = CmdProcessing(tokenNum);
		if (isExit == TRUE)
		{
			_fputts(_T("명령어 처리를 종료합니다. \n"), stdout);
			break;
		}
	}

	return 0;
}
예제 #11
0
파일: regproc.c 프로젝트: Moteesh/reactos
/******************************************************************************
 * Prints string str to file
 */
void REGPROC_export_string(FILE *file, TCHAR *str)
{
    size_t len = _tcslen(str);
    size_t i;

    /* escaping characters */
    for (i = 0; i < len; i++) {
        TCHAR c = str[i];
        switch (c) {
        //case _T('\\'): _fputts(_T("\\\\"), file); break;
        case _T('\"'): _fputts(_T("\\\""), file); break;
        case _T('\n'): _fputts(_T("\\\n"), file); break;
        default:       _fputtc(c, file);          break;
        }
    }
}
예제 #12
0
int CmdProcessing(void)
{
	_fputts(_T("Best command prompt>> "), stdout);
	_getts(cmdString);

	TCHAR * token = _tcstok(cmdString, seps);

	int tokenNum = 0;
	while (token != NULL)
	{
		_tcscpy(
			cmdTokenList[tokenNum++], StrLower(token)
			);
		token = _tcstok(NULL, seps);
	}

	if (!_tcscmp(cmdTokenList[0], _T("exit")))
	{
		return TRUE;
	}
	else if (!_tcscmp(cmdTokenList[0], _T("추가 되는 명령어 1")))
	{
	}
	else if (!_tcscmp(cmdTokenList[0], _T("추가 되는 명령어 2")))
	{
	}
	else
	{
		_tprintf(ERROR_CMD, cmdTokenList[0]);
	}

	return 0;
}
예제 #13
0
void CGenreTable::Save( CUString strFileName )
{
	FILE* pFile = NULL;
	TCHAR lpszLine[ 255 ] = { '\0',};
	int i = 0;

    CUStringConvert strCnv;
	
    pFile = CDexOpenFile( strFileName, _W( "w" ) );

	if ( NULL != pFile )
	{
		for ( i = 0 ; i < (int)v_Entries.size(); i++ )
		{
			if ( CanBeModified( i ) )
			{
				CUString strLine;
                CUStringConvert strCnv;

				GENRETABLEENTRY newEntry = v_Entries[i] ;

				strLine.Format( _W( "%d\t%s\t%s\n" ), newEntry.nID3V1ID, (LPCWSTR)newEntry.strGenre, (LPCWSTR)newEntry.strCDDBGenre );

				_fputts( strCnv.ToT( strLine ), pFile );
			}
		}

		fclose( pFile );
	}
}
예제 #14
0
void CStdioFile::WriteString( LPCTSTR lpsz )
/******************************************/
{
    if( _fputts( lpsz, m_pStream ) == _TEOF ) {
        CFileException::ThrowErrno( errno, m_strFileName );
    }
}
예제 #15
0
//----------------------------- FUNCTION -------------------------------------*
/*static*/ void
    printTrc(LPCTSTR pszLine)
/*>>>>
print trace string to output device

I   pszLine:    line to output

Result
  void
<<<<*/
{
    assert(s_pszTraceFile != NULL);
    if (s_pszTraceFile == NULL) {
        return;
    }
    // check if open
    if (s_hfTrc == NULL) {
        s_hfTrc = _tfopen(s_pszTraceFile, _T("a+"));
        s_bNewLine = TRUE;
    }
    
    // now write if trace file is open:
    if (s_hfTrc != NULL) {
        _fputts(pszLine, s_hfTrc);
        fflush(s_hfTrc);
    }
}
예제 #16
0
bool CProperties::SaveToFile(LPCTSTR pszFileName) const
{
  CreatePathToFile(pszFileName);
  FILE *f=_tfopen(pszFileName,_T("w") MODE_TEXT);
  if(f){
    for(int i=ar.size()-1;i>=0;--i){
      const CProperty &p=ar[i];
      String str(p.strName);
      str+=_TCHAR('=');
      switch(p.Type){
        case CProperties::CProperty::Integer:
        case CProperties::CProperty::Bool:
        case CProperties::CProperty::Char:
        case CProperties::CProperty::Short:
          str+=String::SFormat(_T("%u"),p.GetValue());
          break;
        case CProperties::CProperty::Float:
        case CProperties::CProperty::Double:
        case CProperties::CProperty::szString:
        case CProperties::CProperty::Void:
          str+=p.GetStringValue();
          break;
      }
      str+=_TCHAR('\n');
      _fputts(str,f);
    }
    fclose(f);
  }
  return (0!=f);
}
예제 #17
0
파일: portother.c 프로젝트: nucleron/yaplc
void
vMBPortLog( eMBPortLogLevel eLevel, const TCHAR * szModule, const TCHAR * szFmt, ... )
{
    TCHAR    szBuf[512];
    int      i;
    va_list         args;
    static const LPTSTR arszLevel2Str[] =
    { _T( "DEBUG" ), _T( "INFO" ), _T( "WARN" ), _T( "ERROR" ) };

    i = _sntprintf_s( szBuf, _countof(szBuf) , _TRUNCATE, _T( "%s: %s: " ),
                      arszLevel2Str[eLevel], szModule );

    if( i != 0 )
    {
        va_start( args, szFmt );
        i += _vsntprintf_s( &szBuf[i], _countof(szBuf) - i, _TRUNCATE, szFmt, args );
        va_end( args );
    }

    if( i != 0 )
    {
        if( eLevel == MB_LOG_DEBUG )
        {
            OutputDebugString( szBuf );
        }
        else
        {
            _fputts( szBuf, stderr );
        }
    }

}
예제 #18
0
파일: output.c 프로젝트: aspt/diff_tools
/**
*   Print line to report file and stdout.
*   stdout output truncated to fit to screen
*/
static void my_puts(TCHAR * line)
{
#if !defined(UNICODE) && defined(_WIN32)
    CharToOem(line, line);  // Convert file names - TODO: does it need? CharToOem() called in GAUGE_puts
#endif
    if (g_report_file)
    {
#ifdef UNICODE
        char * ansi = GAUGE_unicode2ansi(line);
        if (ansi)
        {
            fputs(ansi, g_report_file);
            free(ansi);
        }
#else
        _fputts(line, g_report_file);
#endif
        fflush(g_report_file);
    }
    if (g_report_file != stdout)
    {
        unsigned int screen_width = GAUGE_screen_width();
        if (_tcslen(line) > screen_width)
        {
            line[screen_width] = 0;
            line[screen_width - 1] = '>';
        }
        GAUGE_puts(line, stdout);
    }
}
예제 #19
0
void CRecorder::DumpState(FILE *fp)
{
	m_Engine->DumpStallInfo(fp, m_Name, m_StallInfo);
	_fputts(_T("  In: "), fp);
	if (m_Frame != NULL)
		_ftprintf(fp, _T("[%d(%d)] "), m_Frame->Idx, m_Frame->RefCount);
	m_InputQueue.DumpState(fp);
}
예제 #20
0
파일: filetxt.cpp 프로젝트: Rupan/winscp
void CStdioFile::WriteString(LPCTSTR lpsz)
{
	ASSERT(lpsz != NULL);
	ASSERT(m_pStream != NULL);

	if (_fputts(lpsz, m_pStream) == _TEOF)
		AfxThrowFileException(CFileException::diskFull, _doserrno, m_strFileName);
}
예제 #21
0
파일: hosts_tool.cpp 프로젝트: Ailea/hosts
void NormalEntry(){
	SYSTEMTIME st={0,0,0,0,0,0,0,0};
	FILE * fp=NULL,*_=NULL;
	GetLocalTime(&st);
	_tprintf(_T("    LICENSE:MIT LICENSE\n%s\n    Copyright (C) 2016 @Too-Naive\n"),welcomeShow);
	_tprintf(_T("    Project website:%s\n"),objectwebsite);
	_tprintf(_T("    Bug report:sweheartiii[at]hotmail.com \n\t       Or open new issue\n\n\n"));
	_tprintf(_T("    Start replace hosts file:\n    Step1:Get System Driver..."));
	try {
		if (!GetEnvironmentVariable(_T("SystemRoot"),buf3,BUFSIZ))
			THROWERR(_T("GetEnvironmentVariable() Error!\n\tCannot get system path!"));
		_stprintf(buf1,_T("%s\\system32\\drivers\\etc\\hosts"),buf3);
		_stprintf(buf2,_T("%s\\system32\\drivers\\etc\\hosts.%04d%02d%02d.%02d%02d%02d"),
		buf3,st.wYear,st.wMonth,st.wDay,st.wHour,st.wMinute,st.wSecond);
		_tprintf(_T("\t\tDone.\n    Step2:Download hosts file..."));
		for (int _count=0;!Func_Download(hostsfile,DownLocated);
			_count++,_tprintf(pWait),Sleep(5000),_tprintf(_T("\tDownload hosts file...")))
			if (_count>2) for (_count=0,_tprintf(_T("\tDownload hosts file..."));
								!Func_Download(hostsfile,DownLocated);_count++,Sleep(5000))
									if (_count>2) THROWERR(_T("DownLoad hosts file Error!"));
		_tprintf(_T("\t100%%\n    Step3:Change Line Endings..."));
		if (!((fp=_tfopen(DownLocated,_T("r"))) && (_=_tfopen(ChangeCTLR,_T("w")))))
			THROWERR(_T("Open file Error!"));
		while (!feof(fp)){
			_fgetts(szline,1000,fp);
			_fputts(szline,_);
		}
		fclose(fp);fclose(_);
		fp=NULL,_=NULL;
		if (!DeleteFile(DownLocated));
		if (Func_CheckDiff(ChangeCTLR,buf1)){
			_tprintf(_T("\t100%%\n\n    diff exited with value 0(0x00)\n    Finish:Hosts file Not update.\n\n"));
			DeleteFile(ChangeCTLR);
			system("pause");
			return ;
		}
		else {
			_tprintf(_T("\t100%%\n    Step4:Copy Backup File..."));
			if (!SetFileAttributes(buf1,FILE_ATTRIBUTE_NORMAL)); //for avoid CopyFile failed.
			if (!CopyFile(buf1,buf2,FALSE))
				THROWERR(_T("CopyFile() Error on copy a backup file"));
			_tprintf(_T("\t\t100%%\n    Step5:Replace Default Hosts File..."));
			if (!CopyFile(ChangeCTLR,buf1,FALSE))
				THROWERR(_T("CopyFile() Error on copy hosts file to system path"));
			if (!DeleteFile(ChangeCTLR));
			_tprintf(_T("Replace File Successfully\n"));

		}
	}
	catch(expection runtimeerr){
		_tprintf(_T("\nFatal Error:\n%s (GetLastError():%ld)\n\
Please contact the application's support team for more information.\n"),runtimeerr.Message,GetLastError());
		_tprintf(_T("\n[Debug Message]\n%s\n%s\n%s\n"),buf1,buf2,buf3);
		abort();
	}
	MessageBox(NULL,_T("Hosts File Set Success!"),_T("Congratulations!"),MB_ICONINFORMATION|MB_SETFOREGROUND);
	return ;
}
예제 #22
0
void FormatToStream(_In_ FILE * stream, _In_ DWORD fmt,...)
/*++

Routine Description:

    Format text to stream using a particular msg-id fmt
    Used for displaying localizable messages

Arguments:

    stream              - file stream to output to, stdout or stderr
    fmt                 - message id
    ...                 - parameters %1...

Return Value:

    none

--*/
{
    va_list arglist;
    LPTSTR locbuffer = NULL;
    DWORD count;

    va_start(arglist, fmt);
    count = FormatMessage(FORMAT_MESSAGE_FROM_HMODULE|FORMAT_MESSAGE_ALLOCATE_BUFFER,
                          NULL,
                          fmt,
                          0,              // LANGID
                          (LPTSTR) &locbuffer,
                          0,              // minimum size of buffer
                          &arglist);

    if(locbuffer) {
        if(count) {
            int c;
            int back = 0;
            //
            // strip any trailing "\r\n"s and replace by a single "\n"
            //
            while(((c = *CharPrev(locbuffer,locbuffer+count)) == TEXT('\r')) ||
                  (c == TEXT('\n'))) {
                count--;
                back++;
            }
            if(back) {
                locbuffer[count++] = TEXT('\n');
                locbuffer[count] = TEXT('\0');
            }
            //
            // now write to apropriate stream
            //
            _fputts(locbuffer,stream);
        }
        LocalFree(locbuffer);
    }
}
예제 #23
0
void _log_(LPCTSTR txt)
{
    FmtString msg(TEXT("%s\n"), txt);

    if (g_Globals._log)
        _fputts(msg, g_Globals._log);

    OutputDebugString(msg);
}
예제 #24
0
int _tmain(int argc, TCHAR* argv[])
{
	HANDLE hThread[2];
	DWORD dwThreadID[2];

	gSynString.hEvent = CreateEvent(
		NULL, TRUE, FALSE, NULL);

	gSynString.hMutex = CreateMutex(
		NULL, FALSE, NULL);
	
	if (gSynString.hEvent == NULL || gSynString.hMutex == NULL)
	{
		_tprintf(_T("kernel object creation error\n"), stdout);
		return -1;
	}

	hThread[0] = (HANDLE)_beginthreadex(
		NULL, 0,
		OutputThreadFunction,
		NULL, 0,
		(UINT*)&dwThreadID[0]
		);

	hThread[1] = (HANDLE)_beginthreadex(
		NULL, 0,
		CountThreadFunction,
		NULL, 0,
		(UINT*)&dwThreadID[1]
		);

	if (hThread[0] == 0 || hThread[1] == 0)
	{
		_tprintf(_T("Thread creation error\n"), stdout);
		return -1;
	}

	_fputts(_T("Insert string: "), stdout);
	_fgetts(gSynString.string, 30, stdin);

	SetEvent(gSynString.hEvent);

	WaitForMultipleObjects(
		2,
		hThread,
		TRUE,
		INFINITE
		);

	CloseHandle(gSynString.hEvent);
	CloseHandle(gSynString.hMutex);
	CloseHandle(hThread[0]);
	CloseHandle(hThread[1]);

	return 0;
}
예제 #25
0
void CRipInfoDB::DeleteTrack( int nTrack )
{
	// Open file for append
	m_pFile = CDexOpenFile( m_strFileName, _W( "r" ) );
    CUStringConvert strCnv;

	if ( NULL != m_pFile )
	{
        fclose( m_pFile );

        CDexCopyFile( m_strFileName, m_strFileName + _W( ".bak") );

        CString test( GetLastErrorString() );

        m_pFile = CDexOpenFile( m_strFileName + _W( ".bak"), _W( "r" ) );
		FILE* pFileOut = CDexOpenFile( m_strFileName, _W( "w+" ) );

		while( ( !feof( m_pFile ) )  && ( pFileOut != NULL ) )
		{
			TCHAR	lpszLine[ 1024 ] = {'\0',};
			int		nCurrentTrack;

			// Clear string
			memset( lpszLine, 0x00, sizeof( lpszLine ) );

			// Read the next line from the file
			_fgetts( lpszLine, sizeof( lpszLine ), m_pFile );

			nCurrentTrack= _ttoi( &lpszLine[ 1 ] );

			if ( nCurrentTrack != nTrack )
			{
				_fputts( lpszLine, pFileOut );
			}
		}

		fclose( m_pFile );
		m_pFile = NULL;
		fclose( pFileOut );

		m_pFile = NULL;


        //::DeleteFile( strCnv.ToT( m_strFileName ) );
        //::CopyFile( strCnv.ToT( CUString( m_strFileName + _T( ".bak") ) ) , strCnv.ToT( m_strFileName ), FALSE );
        CDexDeleteFile( m_strFileName + _W( ".bak") );
	}

    if ( m_pFile )
    {
        fclose( m_pFile );
		m_pFile = NULL;
    }

}
예제 #26
0
int main(int argc, char **argv)
{
  // this open and parse the XML file:  
  XMLNode xMainNode=XMLNode::openFileHelper("PMMLModelUnicode.xml",_T("PMML"));

  // this prints "RANK For <you>":
  XMLNode xNode=xMainNode.getChildNode(_T("Header"));  
  printf("Application Name is: '%S'\n", xNode.getChildNode(_T("Application")).getAttribute(_T("name")));

  // this prints "Hello World!"
  printf("Text inside Header tag is :'%S'\n", xNode.getText());
  
  // this gets the number of "NumericPredictor" tags:  
  xNode=xMainNode.getChildNode(_T("RegressionModel")).getChildNode(_T("RegressionTable")); 
  int n=xNode.nChildNode(_T("NumericPredictor"));

  // this prints the "coefficient" value for all the "NumericPredictor" tags:
  int iterator=0;
  for (int i=0; i<n; i++)
    printf("coeff %i=%S\n",i+1,xNode.getChildNode(_T("NumericPredictor"),&iterator).getAttribute(_T("coefficient")));

  // this create a file named "testUnicode.xml" based on the content of the first "Extension" tag of the XML file:  
  TCHAR *t=xMainNode.getChildNode(_T("Extension")).createXMLString(true,&i); 
  FILE *f=fopen("testUnicode.xml","wb");
  _fputts(_T("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"),f);
  fwrite(t,sizeof(TCHAR),i,f);
  printf("%S",t);
  fclose(f);
  free(t);

  // compare these 4 lines ...
  t=stringDup(xMainNode.getAttribute(_T("version")));       // get version number
  xMainNode=XMLNode::emptyXMLNode;                          // free from memory the top of the xml Tree
  printf("PMML Version :%S\n",t);                           // print version number
  free(t);                                                  // free version number

  // ... with the following 3 lines (currently commented, because of error):
  //  t=xMainNode.getAttribute(_T("version"));      // get version number (note that there is no 'stringDup')
  //  xMainNode=XMLNode::emptyXMLNode;              // free from memory the top of the xml Tree AND the version number inside 't' var
  //  printf("PMML Version :%S\n",t);               // since the version number in 't' has been free'd this will not work

  // We create in memory from scratch the following XML structure:
  //  <?xml version="1.0"?>
  //      <body> Hello "universe". </body>
  // ... and we transform it into a standard C string that is printed on screen.
  xNode=XMLNode::createXMLTopNode();
  XMLNode xn=xNode.addChild(stringDup(_T("xml")),TRUE); xn.addAttribute(stringDup(_T("version")),stringDup(_T("1.0")));
  xn=xn.addChild(stringDup(_T("body")));  xn.addText(stringDup(_T("Hello \"universe\"!")));
  t=xNode.createXMLString(true);
  printf("XMLString created from scratch:\n%S",t);
  free(t);

  return 0;
}
예제 #27
0
파일: ansicon.c 프로젝트: voxik/ansicon
void print_error( LPCTSTR name, BOOL title )
{
  LPTSTR errmsg;

  FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER,
		 NULL, GetLastError(), 0, (LPTSTR)(LPVOID)&errmsg, 0, NULL );
  if (!title)
    _tprintf( TEXT("ANSICON: %s: "), name );
  _fputts( errmsg, stdout );
  LocalFree( errmsg );
}
예제 #28
0
파일: hosts_tool.cpp 프로젝트: Ailea/hosts
DWORD __stdcall HostThread(LPVOID){
	SYSTEMTIME st={0,0,0,0,0,0,0,0};
	FILE * fp=NULL,*_=NULL;
	Func_SetErrorFile(_T("c:\\Hosts_Tool_log.log"),_T("a+"));
	if (!GetEnvironmentVariable(_T("SystemRoot"),buf3,BUFSIZ))
		THROWERR(_T("GetEnvironmentVariable() Error!\n\tCannot get system path!"));
	_stprintf(buf1,_T("%s\\system32\\drivers\\etc\\hosts"),buf3);
	while (1){
		Sleep(60000);//Waiting for network
		GetLocalTime(&st);
		_stprintf(buf2,_T("%s\\system32\\drivers\\etc\\hosts.%04d%02d%02d.%02d%02d%02d"),
		buf3,st.wYear,st.wMonth,st.wDay,st.wHour,st.wMinute,st.wSecond);
		Func_FastPMNTS(_T("Open log file.\n"));
		Func_FastPMNTS(_T("LICENSE:MIT LICENSE\n"));
		Func_FastPMNSS(_T("Copyright (C) 2016 Too-Naive\n"));
		Func_FastPMNSS(_T("Bug report:sweheartiii[at]hotmail.com\n"));
		Func_FastPMNSS(_T("           Or open new issue.(https://github.com/racaljk/hosts)\n"));
		Func_FastPMNTS(_T("Start replace hosts file.\n"));
		try {
			for (int _count=0;!Func_Download(hostsfile,DownLocated);_count++,Sleep(30000))
				if (_count>2) for (_count=0;!Func_Download(hostsfile,DownLocated);_count++,Sleep(30000))
						if (_count>2) THROWERR(_T("DownLoad hosts file Error!"));
			if (!((fp=_tfopen(DownLocated,_T("r"))) && (_=_tfopen(ChangeCTLR,_T("w")))))
				THROWERR(_T("Open file Error!"));
			while (!feof(fp)){
				_fgetts(szline,1000,fp);
				_fputts(szline,_);
			}
			fclose(fp);fclose(_);
			fp=NULL,_=NULL;
			if (!DeleteFile(DownLocated));
			if (Func_CheckDiff(ChangeCTLR,buf1)){
				Func_FastPMNTS(_T("Finish:Hosts file Not update.\n"));
				DeleteFile(ChangeCTLR);
			}
			else {
				if (!SetFileAttributes(buf1,FILE_ATTRIBUTE_NORMAL)); //for avoid CopyFile failed.
				if (!CopyFile(buf1,buf2,FALSE))
					THROWERR(_T("CopyFile() Error on copy a backup file"));
				if (!CopyFile(ChangeCTLR,buf1,FALSE))
					THROWERR(_T("CopyFile() Error on copy hosts file to system path"));
				if (!DeleteFile(ChangeCTLR));
				Func_FastPMNTS(_T("Replace File Successfully\n"));
			}
		}
		catch(expection runtimeerr){
			Func_FastPMNTS(_T("Fatal Error:\n"));
			Func_FastPMNSS(_T("%s (GetLastError():%ld)\n"),runtimeerr.Message,GetLastError());
			Func_FastPMNSS(_T("Please contact the application's support team for more information.\n"));
		}
		Sleep(29*60000);
	}
	return GetLastError();
}
예제 #29
0
파일: KTestCommon.cpp 프로젝트: viticm/pap2
int KTestCommon::ModifyVersionFile(const TCHAR cszFilePath[], const TCHAR cszVersion[])
{
	int nResult  = false;
	int nRetCode = false;
	FILE*  pVerFile = NULL;
	TCHAR* pszRet   = NULL;
	size_t uLength = 0;
	long lOffset = 0L;
	TCHAR szBuffer[MAX_PATH];

	ASSERT(cszFilePath);
	ASSERT(cszVersion);

	//修改版本信息文件中的版本号,用于测试需要
	nRetCode = _tfopen_s(&pVerFile, cszFilePath, _T("r+"));
	KGLOG_PROCESS_ERROR(nRetCode == 0);
	uLength = _tcslen(PRODUCT_VERSION_KEY);
	while (TRUE)
	{
		pszRet = _fgetts(szBuffer, sizeof(szBuffer) / sizeof(TCHAR), pVerFile);
		if (!pszRet)
		{
			nRetCode = ferror(pVerFile);
			KGLOG_PROCESS_ERROR(nRetCode == 0);
			KG_PROCESS_SUCCESS(nRetCode == 0);
		}
		szBuffer[sizeof(szBuffer) / sizeof(TCHAR) - 1] = _T('\0');
		if (szBuffer[0] != _T('#'))
		{
			nRetCode = _tcsncicmp(szBuffer, PRODUCT_VERSION_KEY, uLength);
			if (!nRetCode && szBuffer[uLength] == _T('='))
			{
				lOffset += (long)uLength + 1;
				nRetCode = fseek(pVerFile, lOffset, SEEK_SET); 
				KGLOG_PROCESS_ERROR(nRetCode == 0);
				nRetCode = _fputts(cszVersion, pVerFile);
				KGLOG_PROCESS_ERROR(nRetCode != EOF && nRetCode != WEOF);
				KG_PROCESS_SUCCESS(true);
			}
		}
		lOffset += (long)_tcslen(szBuffer) + 1;
	}

Exit1:
	nResult = true;
Exit0:
	if (pVerFile)
	{
		fclose(pVerFile);
		pVerFile = NULL;
	}
	return nResult;
}
예제 #30
0
void MeshDump::DumpAttributeTable(ID3DXBaseMesh* mesh) {
    _fputts(_T("Attribute Table:\n----------------\n"), m_DumpStream);
    // number of entries in the attribute table
    DWORD numEntries = 0;
    mesh->GetAttributeTable(0, &numEntries);
    if (numEntries == 0)
        return;
    std::vector<D3DXATTRIBUTERANGE> table(numEntries);
    mesh->GetAttributeTable(&table[0], &numEntries);
    for (DWORD i = 0; i < numEntries; i++)
        _ftprintf_s(m_DumpStream,
                    _T("Entry %d\n-----------\n")
                    _T("Subset ID:    %d\n")
                    _T("Face Start:   %d\n")
                    _T("Face Count:   %d\n")
                    _T("Vertex Start: %d\n")
                    _T("Vertex Count: %d\n\n"),
                    i, table[i].AttribId, table[i].FaceStart, table[i].FaceCount, table[i].VertexStart, table[i].VertexCount);

    _fputts(_T("\n"), m_DumpStream);
}