Exemple #1
0
BOOL CPubThread::AddTimestamp(LPSTR str, LPCTSTR tmpl)
{
	if ( str == NULL || tmpl == NULL ) return FALSE;

	DWORD i = 0, x = 0;
	char dst[ CWF_STRSIZE ];

	CWinTime	time;

	// Find timestamp point
	DWORD p = MAXDWORD, f;
	for ( f = 0; str[ f ] != 0 && str[ f ] != '$'; f++ )
		if ( str[ f ] == '.' ) p = f;

	// Will we append?
	BOOL bAppend = ( str[ f ] != '$' );
	if ( bAppend && p == MAXDWORD ) p = strlen( str );

	while ( str[ i ] != 0 )
	{
		if ( str[ i ] == '$' || ( bAppend && i == p ) )
		{
			if ( bAppend ) dst[ x++ ] = ' ';
			if ( bAppend ) dst[ x++ ] = '(';

			// Insert timestamp
			time.GetString( &dst[ x ], tmpl );

			// adjust to new length
			x += strlen( &dst[ x ] );					

			if ( bAppend ) { dst[ x++ ] = ')'; dst[ x++ ] = '.'; }

		} // end if

		// Just copy the character
		else dst[ x++ ] = str[ i ];

		// Next character
		i++;

	} // end while

	// NULL terminate
	dst[ x ] = 0;

	// Copy the thing
	strcpy( str, dst );

	return TRUE;
}
Exemple #2
0
BOOL CReg::SaveRegFile(CPipe *pipe, LPCTSTR pKey, LPCTSTR pHeader)
{_STTEX();
	if ( pipe == NULL ) return FALSE;

	// Write tag
	pipe->Write( "REGEDIT4\r\n" );

	// Write header
	if ( pHeader == NULL ) pipe->Write( ";\r\n; WheresJames Software (www.wheresjames.com)\r\n" );
	else if ( *pHeader ) pipe->Write( pHeader );

	// If header
	if ( pHeader == NULL || *pHeader )
	{	
		pipe->Write( "\r\n; Created - " );

		{ // Write time and date
			char msg[ 512 ];

			CWinTime wt;

			wt.GetString( msg, "%W, %B %d, %Y - %h:%m:%s %A" );

			pipe->Write( msg );

		} // end write time and date

		pipe->Write ( "\r\n;\r\n" );

	} // end if

	if ( pKey != NULL )
	{	LPREGKEY prk = (LPREGKEY)Find( pKey );
		if ( prk != NULL ) SaveRegKey( pipe, prk );
	} // end if

	else
	{
		// Save each key
		LPREGKEY prk = NULL;
		while ( ( prk = (LPREGKEY)GetNext( prk ) ) != NULL )
			SaveRegKey( pipe, prk );

	} // end else

	return TRUE;
}
Exemple #3
0
// wjr 11/10/06...
BOOL CStackReport::ErrorLog(CReg *pReg, CErrLog* pErrLog )
{_STT();
	if( !pReg || !pErrLog )
		return E_INVALIDARG;

	CTlLocalLock ll( *pErrLog );
	if ( !ll.IsLocked() ) return FALSE;

	// Reset object
	pReg->Destroy();

	int	iId = 1;
	char szMsg[ 256 ] = "";
	LPERRORITEMINFO pEii = NULL;
	while ( ( pEii = (LPERRORITEMINFO)pErrLog->GetNext( pEii ) ) != NULL )
	{
		wsprintf( szMsg, "Error %d", iId++ );

		CRKey *pRk = pReg->GetKey( szMsg );
		if ( pRk )
		{
			CWinTime wt;
			wt.SetUnixTime( pEii->dwTime );
			wt.GetString( szMsg, "%w %b %D %Y - %g:%m:%s" );

			// Save the time.
			pRk->Set( "time", szMsg );
			
			// Save function info if present.
			if( pEii->sFile && pEii->sFunction )
			{
				if( pEii->sFile->ptr() && pEii->sFunction->ptr() )
				{
					try
					{
						char* pStr = NULL;
						wsprintf( szMsg, "%s::%s", pEii->sFile->ptr(), pEii->sFunction->ptr() );
						// Parse out the path
						int ch = '\\';
						pStr = strrchr( szMsg, ch );

						if( pStr )
						{
							pStr++; // dump the "\".
							pRk->Set( "function", pStr );
						}

						// Save the file info
						// wjr 1/9/07...
						wsprintf( szMsg, "%s", pEii->sFile->ptr() );
						pRk->Set( "file", szMsg );
						// ...wjr 1/9/07
			
					}
					catch(...)
					{
						ASSERT(0);
					}

				}
			}
			
			// Save the message
			pRk->Set( "message", pEii->cpkey );

			// Save the error code
			CWin32::GetSystemErrorMsg( pEii->dwCode, szMsg );
			pRk->Set( "code", szMsg );

			// wjr 1/9/07...
			// Save the line
			pRk->Set( "line", pEii->dwLine );

			// Save the severity
			pRk->Set( "severity", pEii->dwSeverity );

			// Save the raw time data
			pRk->Set( "timedata", pEii->dwTime );
			// ...wjr 1/9/07

		} // end if

	} // end while

	return TRUE;
}