void _LogFooter(void)
{
    char   szLibPath [ PS_MAX_PATH ];
#if defined (WIN32)
    GetModuleFileNameA(NULL, szLibPath, PS_MAX_PATH);
#elif defined (_LINUX)

    if (program_invocation_name[0] == '/')
    {
        // file contains full path already, so don't append path
        sprintf_s(szLibPath, PS_MAX_PATH, "%s", program_invocation_name);
    }
    else
    {
        char currentDir[PS_MAX_PATH];
        getcwd(currentDir, PS_MAX_PATH);
        sprintf_s(szLibPath, PS_MAX_PATH, "%s/%s", currentDir, program_invocation_name);
    }

#endif
    _Log(logRAW,  "App : %s\n", szLibPath);
    _Log(logRAW,  "PID: %i\n", osGetCurrentProcessId());
    _Log(logRAW,  "Time: %s\n", GetTimeStr().asCharArray());
    _Log(logRAW, "--------------THE END------------------\n");
}
Esempio n. 2
0
BOOL CEmailThread::SocketCallback(CAsyncWinSock *pSocket, DWORD dwUser, WPARAM wParam, LPARAM lParam)
{
	CEmailThread *pEmail = (CEmailThread*)dwUser;
	if ( pEmail == NULL ) return FALSE;	

	long	lNetworkEvents = (long)wParam;
	int		*iErrorCodes = (int*)lParam;

	if ( ( lNetworkEvents & FD_CONNECT ) != 0 )
	{
		if ( iErrorCodes[ FD_CONNECT_BIT ] != 0 )
		{	char msg[ CWF_STRSIZE ];
			if ( !CAsyncWinSock::GetErrorMsg( msg, iErrorCodes[ FD_CONNECT_BIT ], FALSE ) )
				strcpy( msg, "Unknown Error" );
			_Log( MB_ICONERROR, "E-mail", msg );
			pEmail->m_smtp.ThreadCloseSocket();
		} // end if
	} // end if

	else if ( ( lNetworkEvents & FD_CLOSE ) != 0 )
	{
		if ( iErrorCodes[ FD_CONNECT_BIT ] != 0 )
		{	char msg[ CWF_STRSIZE ];
			if ( !CAsyncWinSock::GetErrorMsg( msg, iErrorCodes[ FD_CONNECT_BIT ], FALSE ) )
				strcpy( msg, "Unknown Error" );
			_Log( MB_ICONERROR, "E-mail", msg );
		} // end if
		pEmail->m_smtp.ThreadCloseSocket();
	} // end if

	return TRUE;
}
Esempio n. 3
0
BOOL CPubThread::FtpImage(LPCTSTR pServer, CFtp *pFtp, LPBYTE buf, DWORD size, LPCTSTR pPath)
{
	// Sanity checks
	if ( pServer == NULL || pFtp == NULL || buf == NULL || size == 0 || pPath == NULL )
		return FALSE;

	// Is the FTP already working?
	if ( pFtp->IsConnecting() || pFtp->IsConnected() )
		return FALSE;

	// Reset the FTP object
	pFtp->Destroy();
	
	// Ensure we have server information
	HGROUP hGroup = FTPSERVERS().FindGroup( pServer );
	if ( hGroup == NULL )
	{	_Log( MB_ICONERROR, pServer, "FTP server information not found" );
		return FALSE;
	} // end if

	char user[ CWF_STRSIZE ];
	char password[ CWF_STRSIZE ];
	char addr[ CWF_STRSIZE ];
	char folder[ CWF_STRSIZE ];
	DWORD port = 21;
	DWORD passive = 1;

	strcpy( addr, FTPSERVERS().GetSz( hGroup, "Address" ) );
	strcpy( folder, FTPSERVERS().GetSz( hGroup, "Folder" ) );
	strcpy( user, FTPSERVERS().GetSz( hGroup, "Username" ) );
	strcpy( password, FTPSERVERS().GetSz( hGroup, "Password" ) );
	port = FTPSERVERS().GetDword( hGroup, "Port", 21 );
	passive = FTPSERVERS().GetDword( hGroup, "Passive", 1 );

	// Set passive FTP mode
	pFtp->SetPassiveMode( passive != 0 );

	// Connect to server
	pFtp->SetUsernamePassword( user, password );
	if ( !pFtp->Connect( addr, port ) ) return FALSE;

	// Build full path to remote file
	CWinFile::WebBuildPath( folder, folder, pPath );

	// Upload file
	pFtp->AutoClose( TRUE );
	if ( !pFtp->Upload( buf, size, folder ) )
	{	_Log( MB_ICONERROR, addr, "Upload error" );
		return FALSE;
	} // end if

	// Inform user
	char msg[ CWF_STRSIZE ];
	wsprintf( msg, "Uploading %s to %s", folder, addr );
	FRAME()->SetStatus( msg );

	return TRUE;
}
Esempio n. 4
0
BOOL CPubThread::Email(LPPUBINFO ppi)
{
	if ( ppi == NULL || ppi->pemi == NULL ) return FALSE;

	// Inform user
	char msg[ CWF_STRSIZE ];
	wsprintf( msg, "Emailing %s to %s", ppi->pub_fname, ppi->pemi->to );
	FRAME()->SetStatus( msg );

	// Get FTP object
	CEmailThread *pEmail = ppi->pemail;
	if ( pEmail == NULL )
	{	_Log( MB_ICONERROR, ppi->str, "Invalid object." );
		return FALSE;
	} // end if

	HGROUP hGroup = EMAILSERVERS().FindGroup( ppi->str );
	if ( hGroup == NULL ) 
	{	_Log( MB_ICONERROR, ppi->str, "Email Server information not found." );
		return FALSE;
	} // end if

	CString server = (LPCTSTR)EMAILSERVERS().GetValuePtr( hGroup, "Address" );
	CString username = (LPCTSTR)EMAILSERVERS().GetValuePtr( hGroup, "Username" );
	CString password = (LPCTSTR)EMAILSERVERS().GetValuePtr( hGroup, "Password" );

	DWORD login = 0;
	EMAILSERVERS().GetValue( hGroup, "Login", &login );

	DWORD authdetect = 1;
	EMAILSERVERS().GetValue( hGroup, "AuthDetect", &authdetect );

	DWORD authtype = 0;
	EMAILSERVERS().GetValue( hGroup, "AuthType", &authtype );

	// Is it an avi file
	if ( *ppi->avicachefile != 0 )

		// E-mail the AVI
		return pEmail->Email(	NULL, ppi->avicachefile,
								ppi->pemi->to, ppi->pemi->from,
								ppi->pemi->subject, ppi->pub_fname,
								server, username, password, 
								ppi->pemi->body, login, 
								authdetect, authtype );


	// E-mail image
	return pEmail->Email(	ppi->img, NULL,
							ppi->pemi->to, ppi->pemi->from,
							ppi->pemi->subject, ppi->pub_fname,
							server, username, password, 
							ppi->pemi->body, login, 
							authdetect, authtype );

}
Esempio n. 5
0
BOOL CDlgImgView::SaveImg()
{
	CWinImg img, *pimg = &img;

	if ( m_bCapture )
	{
		char title[ CWF_STRSIZE ];
		GetWindowText( title, sizeof( title ) );
		if ( !IMGLIST().GetImage( title, &img ) )
		{	_Log( MB_ICONERROR, "Error loading image", title );
			return FALSE;
		} // end if
		
	} // end if

	else
	{
		pimg = m_img.GetImg();
		if ( pimg == NULL || !pimg->IsValid() )
		{	_Log( MB_ICONERROR, "Save Image", "Image not available" );
			return FALSE;
		} // end if

	} // end else

	// Get the file name
	char filename[ CWF_STRSIZE ] = { 0 };
	if ( !CWinFile::GetSaveFileName(	filename, "Save Image As",
										"All Images (*.bmp;*.jpg;*.jpeg;*.png;*.ico;*.tif;*.tiff;*.tga;*.pcx;*.wmf;*.emf;*.jp2)\x0*.bmp;*.jpg;*.jpeg;*.png;*.ico;*.tif;*.tiff;*.tga;*.pcx;*.wmf;*.emf;*.jp2\x0"
										"Windows Bitmap (*.bmp;*.dib)\x0*.bmp;*.dib\x0"
										"JPEG (*.jpg;*.jpeg)\x0*.jpg;*.jpeg\x0"
										"Portable Network Graphic (*.png)\x0*.png\x0"
										"Icon (*.ico)\x0*.ico\x0"
										"Tagged Image File (*.tif; *.tiff)\x0*.tif;*.tiff\x0"
										"Targa (*.tga)\x0*.tga\x0"
										"PC Paintbrush (*.pcx)\x0*.pcx\x0"
										"Windows Metafile (*.wmf;*.emf)\x0*.wmf;*.emf\x0"
										"JPEG 2000 (*.jp2)\x0*.jp2\x0"
										"All Files (*.*)\x0*.*\x0",
										"jpg",
									 GetSafeHwnd() ) ) return FALSE;

	// Save the image
	FRAME()->SetQuality( pimg );
	if ( !pimg->Save( filename ) )
	{	_Log( MB_ICONERROR, "Error saving image", pimg->GetLastError() );
		return FALSE;
	} // end if

	return TRUE;
}
Esempio n. 6
0
owl_section_handle OWLENTRY OWLSectionInit( owl_file_handle file, const char *name, owl_section_type type, owl_alignment align ) {
//********************************************************************************************************************************

    owl_section_handle          section;

    section = _ClientAlloc( file, sizeof( owl_section_info ) );
    section->file = file;
    section->name = OWLStringAdd( file->string_table, name );
    section->type = type;
    section->align = align;
    section->buffer = ( type & OWL_SEC_ATTR_BSS ) ? NULL : OWLBufferInit( file );
    section->linenum_buffer = NULL;
    section->num_linenums = 0;
    section->size = 0;
    section->location = 0;
    section->first_reloc = NULL;
    section->last_reloc = NULL;
    section->num_relocs = 0;
    section->comdat_sym = NULL;
    section->comdat_dep = NULL;
    addSection( file, section );
    addSectionSymbol( section, name );
    _Log(( file, "OWLSectionInit( %x, '%s', %x, %x ) -> %x\n", file, name, type, align, section ));
    return( section );
}
Esempio n. 7
0
    void Log2File(const char* section, const char* key, const char* msg, va_list& ap, int nFileType = 0)
    {
        char szTmp[MAX_LOG_BUFF_SIZE];
        memset(szTmp, 0, MAX_LOG_BUFF_SIZE * sizeof(char));

        _Log(szTmp, section, key, msg, ap);

        if(g_logger.IsSetPath())
        {

            if(g_logger_mutex == NULL)
            {
                g_logger.NewLine(nFileType) << szTmp << EndLine;
            }
            else
            {
                //dbmgr的多线程日志要加锁
                CMutexGuard gm(*g_logger_mutex);
                g_logger.NewLine(nFileType) << szTmp << EndLine;
            }

        }
        else
        {
            printf("%s\n", szTmp);
        }
    }
Esempio n. 8
0
BOOL CPubThread::OnNfCallback(DWORD dwUser, WPARAM wParam, LPARAM lParam)
{
	CNetFile *pNf = (CNetFile*)lParam;

	switch( wParam )
	{
		case NETFILE_DS_ERROR :
		{	
			if ( pNf != NULL ) 
			{	_Log( MB_ICONERROR, pNf->GetUrl(), "Cannot connect to FTP server" ); }
			else { _Log( MB_ICONERROR, "FTP", "Cannot connect to FTP server" ); }

		} break;

	} // end switch

	return TRUE;
}
Esempio n. 9
0
void OWLENTRY OWLSectionFini( owl_section_handle section ) {
//**********************************************************

    // while user may be done with this section, we can't trash
    // it until we are ready to write the entire file

    /* unused parameters */ (void)section;

    _Log(( section->file, "OWLSectionFini( %x )\n", section ));
}
Esempio n. 10
0
//----------------------------------------------------------
void Con::Log(char* msg, ...)
{
	char buffer[BufferSize];

	va_list args;
	va_start(args, msg);
	vsnprintf(buffer, BufferSize, msg, args);
	va_end(args);

	_Log(buffer);
}
Esempio n. 11
0
    void Log2Console(const char* section, const char* key, const char* msg, va_list& ap, int nFileType = 0)
    {
        char szTmp[MAX_LOG_BUFF_SIZE];
        _Log(szTmp, section, key, msg, ap);

#ifdef _DEBUG_VERSION_
        printf("%s\n", szTmp);
#else
        if(g_logger.IsSetPath())
        {
            g_logger.NewLine(nFileType) << szTmp << EndLine;
            printf("%s\n", szTmp);
        }
        else
        {
            printf("%s\n", szTmp);
        }
#endif
    }
Esempio n. 12
0
void OWLENTRY OWLSectionFree( owl_section_handle section ) {
//**********************************************************

    owl_file_handle     file;

    file = section->file;
    deleteSection( file, section );
    if( section->buffer != NULL ) {
        OWLBufferFini( section->buffer );
    }
    if( section->linenum_buffer != NULL ) {
        OWLBufferFini( section->linenum_buffer );
    }
    if( section->first_reloc != NULL ) {
        freeRelocs( file, section->first_reloc );
    }
    _ClientFree( file, section );
    _Log(( file, "OWLSectionFree( %x )\n", section ));
}
Esempio n. 13
0
BOOL CPubThread::Disk(LPPUBINFO ppi)
{
	if ( ppi == NULL ) return FALSE;

	// Is it an avi file
	if ( *ppi->avicachefile != 0 )
	{
		// Build target filename
		char fname[ CWF_STRSIZE ];
		CWinFile::BuildPath( fname, ppi->path, ppi->pub_fname );

		// Copy the file
		if ( !MoveFile( ppi->avicachefile, fname ) )
			CopyFile( ppi->avicachefile, fname, FALSE );

	} // end if

	else
	{
		CWinImg img;

		// Get the image
		if ( !IMGLIST().GetImage( ppi->img, &img ) )
		{	_Log( MB_ICONERROR, ppi->img, "Invalid image." );
			return FALSE;
		} // end if

		// Inform user
		char msg[ CWF_STRSIZE ];
		wsprintf( msg, "Saving %s to %s", ppi->pub_fname, ppi->path );
		FRAME()->SetStatus( msg );

		char fname[ CWF_STRSIZE ];
		CWinFile::BuildPath( fname, ppi->path, ppi->pub_fname );
		
		// Save the file
		if ( !img.Save( fname ) )
		{	_Log( MB_ICONERROR, ppi->img, img.GetLastError() );
		} // end if

	} // end else

	// Punt if no thumbnail
	if ( ( ppi->f1 & PUBF1_THUMBNAIL ) == 0 ) return TRUE;

	// Is it an avi file
	if ( *ppi->thmavicachefile != 0 )
	{
		// Build target filename
		char fname[ CWF_STRSIZE ];
		CWinFile::BuildPath( fname, ppi->path, ppi->pub_tfname );

		// Copy the file
		if ( !MoveFile( ppi->thmavicachefile, fname ) )
			CopyFile( ppi->thmavicachefile, fname, FALSE );

	} // end if

	else
	{
		CWinImg img;

		// Get thumbnail
		GetThumbnail( ppi, &img, img.GetWidth(), img.GetHeight() );

		// Build thumbnail path
		char fname[ CWF_STRSIZE ];
		CWinFile::BuildPath( fname, ppi->path, ppi->pub_tfname );
		
		// Save thumbnail
		if ( !img.Save( fname ) )
		{	_Log( MB_ICONERROR, ppi->img, img.GetLastError() );
		} // end if

	} // end else

	return TRUE;
}
Esempio n. 14
0
void OWLENTRY OWLComdatDep( owl_section_handle section, owl_section_handle dep ) {
//*********************************************************************************************

    _Log(( section->file, "OWLComdatDep( %x, %x )\n", section, dep ));
    section->comdat_dep = dep;
}
Esempio n. 15
0
BOOL CPubThread::FtpImage(LPCTSTR pServer, CNetFile *pNf, LPBYTE buf, DWORD size, LPCTSTR pPath)
{
	// Sanity checks
	if ( pServer == NULL || pNf == NULL || buf == NULL || size == 0 || pPath == NULL )
		return FALSE;

	// Is the FTP already working?
	if ( pNf->IsWorking() ) return FALSE;
	pNf->Destroy();
	
	// Ensure we have server information
	HGROUP hGroup = FTPSERVERS().FindGroup( pServer );
	if ( hGroup == NULL ) return FALSE;

	char user[ CWF_STRSIZE ];
	char password[ CWF_STRSIZE ];
	char addr[ CWF_STRSIZE ];
	char folder[ CWF_STRSIZE ];
	DWORD port = 21;
	DWORD passive = 1;

	// Get server information
	strcpy( addr, FTPSERVERS().GetSz( hGroup, "Address" ) );
	strcpy( folder, FTPSERVERS().GetSz( hGroup, "Folder" ) );
	strcpy( user, FTPSERVERS().GetSz( hGroup, "Username" ) );
	strcpy( password, FTPSERVERS().GetSz( hGroup, "Password" ) );
	port = FTPSERVERS().GetDword( hGroup, "Port", 21 );
	passive = FTPSERVERS().GetDword( hGroup, "Passive", 1 );

//	FTPSERVERS().GetValue( hGroup, "Address", addr, sizeof( addr ) );
//	FTPSERVERS().GetValue( hGroup, "Folder", folder, sizeof( folder ) );
//	FTPSERVERS().GetValue( hGroup, "Port", &port );
//	FTPSERVERS().GetValue( hGroup, "Username", user, sizeof( user ) );
//	FTPSERVERS().GetValue( hGroup, "Password", password, sizeof( password ) );
//	FTPSERVERS().GetValue( hGroup, "Passive", &passive );

	char connect[ CWF_STRSIZE * 2 ];
	strcpy( connect, "ftp://" );
	strcat( connect, addr );
	CWinFile::WebBuildPath( connect, connect, folder );
	CWinFile::WebBuildPath( connect, connect, pPath );

	// Connect to server
	pNf->SetUsernamePassword( user, password );

	// Set callback
	pNf->SetCallback( CPubThread::OnNfCallback, (DWORD)this );

	// Upload the data
	if ( !pNf->Upload( connect, buf, size, passive != 0 ) )
	{	_Log( MB_ICONERROR, connect, "Upload error" );
		return FALSE;
	} // end if

	// Inform user
	char msg[ CWF_STRSIZE ];
	wsprintf( msg, "Uploading %s", connect );
	FRAME()->SetStatus( msg );

	return TRUE;
}
Esempio n. 16
0
BOOL CPubThread::DoThread(LPVOID pData)
{
	DWORD enablepublishing = 0;
	CFG().GetValue( "Settings", "EnablePublishing", &enablepublishing );

	// Punt if publishing is disabled
	if ( !enablepublishing )
	{	m_bReset = TRUE;
		Sleep( 1000 ); return TRUE;
	} // end if

	DWORD tickcount = GetTickCount();
	
	SYSTEMTIME	st;
	GetSystemTime( &st );

	// Calculate seconds offset
	DWORD seconds = ( st.wHour * 60 * 60 ) + ( st.wMinute * 60 ) + st.wSecond;

	// Process each job
	LPPUBINFO ppi = NULL;
	while ( ( ppi = (LPPUBINFO)PUBLIST().GetNext( ppi ) ) != NULL )
	{
		try
		{
			// Is publishing on hold?
			if ( ppi->bHold ) continue;

			// Image information
			LPPUBIMGINFO ppii = NULL;

			// Are we doing any avi capturing?
			if ( ( ppi->f1 & ( PUBF1_AVI | PUBF1_THMAVI ) ) != 0 )
			{
				// Update AVI's
				if ( ( ppi->f1 & PUBF1_AVICAPMOTION ) == 0 || IsMotion( ppi ) )
				{
					// Check for avi
					if ( ( ppi->f1 & PUBF1_AVI ) != 0 )
					{
						// Time to capture?
						if (	( ppi->f1 & PUBF1_AVICAPMOTION ) != 0 || 
								ppi->avitimeout < tickcount )
						{
							ppii = IMGLIST().FindByName( ppi->img );
							if ( ppii != NULL )
							{
								// Refresh the image
								IMGLIST().Update( ppii, TRUE );

								// Wait for next frame
								if ( ppi->capframes < 1 ) ppi->capframes = 1;
								if ( ppi->capseconds < 1 ) ppi->capseconds = 1;
								long delay = ( ppi->capseconds * 1000 ) / ppi->capframes;
								ppi->avitimeout = tickcount + delay;

								// Write out a frame of the avi
								WriteAviFrame( ppi, ppi->avi, ppii, ppi->pub_fname );
							
							} // end if

						} // end if

					} // end if

					// Check for thumbnail avi
					if ( ( ppi->f1 & PUBF1_THMAVI ) != 0 )
					{
						// Time to capture?
						if (	( ppi->f1 & PUBF1_AVICAPMOTION ) != 0 || 
								ppi->thmavitimeout < tickcount )
						{
							// Get image if we don't already have it
							if ( ppii == NULL )
							{	ppii = IMGLIST().FindByName( ppi->img );
								IMGLIST().Update( ppii, TRUE );
							} // end if

							if ( ppii != NULL )
							{
								// Wait for next frame
								if ( ppi->capframes < 1 ) ppi->capframes = 1;
								if ( ppi->capseconds < 1 ) ppi->capseconds = 1;
								long delay = ( ppi->capseconds * 1000 ) / ppi->capframes;
								ppi->thmavitimeout = tickcount + delay;

								// Write out a frame of the avi
								WriteAviFrame( ppi, ppi->thmavi, ppii, ppi->pub_tfname );

							} // end if

						} // end if

					} // end if

				} // end if

			} // end if

			// Are we detecting motion?
			if ( ( ppi->f1 & PUBF1_MOTION ) != 0 )
			{
				if ( IsMotion( ppi ) )
				{
					// Save motion time
					if ( ppi->motioninterval == 0 ) ppi->motioninterval = 30;
					ppi->nextmotion = GetTickCount() + ( ppi->motioninterval * 1000 );

					// Get current file name
					GetFileName( ppi );

					// Refresh the image
					if ( ppii == NULL ) IMGLIST().Update( ppi->img, TRUE );

					// Handle avi
					if ( ( ppi->f1 & PUBF1_AVI ) != 0 )
					{
						if ( ppi->avi->IsOpen() )
						{
							// Save avi filename
							strcpy( ppi->avicachefile, ppi->avi->GetFileName() );
							ppi->avi->Close();

							// Save thumbnail avi filename
							strcpy( ppi->thmavicachefile, ppi->thmavi->GetFileName() );
							ppi->thmavi->Close();

						} // end if

					} // end if

					// Handle thumbnail avi
					if ( ( ppi->f1 & PUBF1_THMAVI ) != 0 )
					{
						if ( ppi->thmavi->IsOpen() )
						{
							// Save avi filename
							strcpy( ppi->thmavicachefile, ppi->thmavi->GetFileName() );
							ppi->thmavi->Close();

							// Save thumbnail avi filename
							strcpy( ppi->thmavicachefile, ppi->thmavi->GetFileName() );
							ppi->thmavi->Close();

						} // end if

					} // end if

					BOOL bPublished = FALSE;

					// Check for FTP
					if ( ppi->type == PUBTYPE_FTP ) bPublished = Ftp( ppi );

					// Check for Email
					else if ( ppi->type == PUBTYPE_EMAIL ) bPublished = Email( ppi );

					// Check for Disk
					else if ( ppi->type == PUBTYPE_DISK ) bPublished = Disk( ppi );

					if ( bPublished )
					{
						// Inform FRAME
						if ( ppi->type == PUBTYPE_FTP ) FRAME()->SetEvent( 2 );
						else if ( ppi->type == PUBTYPE_EMAIL ) FRAME()->SetEvent( 3 );
						else if ( ppi->type == PUBTYPE_DISK ) FRAME()->SetEvent( 4 );

						// Play sound if needed
						if ( ( ppi->f1 & PUBF1_PLAYSOUND ) != 0 )
						{	if ( *ppi->snd ) PLAYSOUND( ppi->snd );
							else PLAYSOUND( IDW_CAMERA );
						} // end if

					} // end if

					// Ensure cache files are gone
					if ( *ppi->avicachefile != 0 )
					{	CWinFile::Delete( ppi->avicachefile );
						*ppi->avicachefile = 0;
					} // end if
					if ( *ppi->thmavicachefile != 0 )
					{	CWinFile::Delete( ppi->thmavicachefile );
						*ppi->thmavicachefile = 0;
					} // end if

				} // end if

			} // end if

			// Has an interval been specified?
			else if ( ppi->interval != 0 )
			{
				// Set interval first time
				if ( m_bReset || ppi->timeout == 0 ) 
					ppi->timeout = tickcount + ( ppi->interval * 1000 );

				// Have we timed out?			
				BOOL publish = ppi->timeout < tickcount;

				// Do we want to sync to the system clock?
				if ( !publish && ( ppi->f1 & PUBF1_SYNCTOCLOCK ) != 0 ) 
				{
					// Is it a new second?
					if ( seconds != ppi->lasttime )
					{
						// Record last pub time
						ppi->lasttime = seconds;

						// Is it time to publish?
						if ( !( seconds % ppi->interval ) ) publish = TRUE;

					} // end if

				} // end if

				if ( publish )
				{
					// Record next timeout interval
					ppi->timeout = tickcount + ( ppi->interval * 1000 );

					// Record last pub time
					ppi->lasttime = seconds;
					
					// Get current file name
					GetFileName( ppi );

					// Refresh the image
					if ( ppii == NULL ) IMGLIST().Update( ppi->img, TRUE );

					// Handle avi
					if ( ( ppi->f1 & PUBF1_AVI ) != 0 )
					{
						if ( ppi->avi->IsOpen() )
						{
							// Save avi filename
							strcpy( ppi->avicachefile, ppi->avi->GetFileName() );
							ppi->avi->Close();

							// Save thumbnail avi filename
							strcpy( ppi->thmavicachefile, ppi->thmavi->GetFileName() );
							ppi->thmavi->Close();

						} // end if

						// Punt if no avi
						else return TRUE;

					} // end if

					// Handle thumbnail avi
					if ( ( ppi->f1 & PUBF1_THMAVI ) != 0 )
					{
						if ( ppi->thmavi->IsOpen() )
						{
							// Save avi filename
							strcpy( ppi->thmavicachefile, ppi->thmavi->GetFileName() );
							ppi->thmavi->Close();

							// Save thumbnail avi filename
							strcpy( ppi->thmavicachefile, ppi->thmavi->GetFileName() );
							ppi->thmavi->Close();

						} // end if

					} // end if

					BOOL bPublished = FALSE;

					// Check for FTP
					if ( ppi->type == PUBTYPE_FTP ) bPublished = Ftp( ppi );

					// Check for Email
					else if ( ppi->type == PUBTYPE_EMAIL ) bPublished = Email( ppi );

					// Check for Disk
					else if ( ppi->type == PUBTYPE_DISK ) bPublished = Disk( ppi );

					if ( bPublished )
					{
						// Inform FRAME
						if ( ppi->type == PUBTYPE_FTP ) FRAME()->SetEvent( 2 );
						else if ( ppi->type == PUBTYPE_EMAIL ) FRAME()->SetEvent( 3 );
						else if ( ppi->type == PUBTYPE_DISK ) FRAME()->SetEvent( 4 );

						// Play sound if needed
						if ( ( ppi->f1 & PUBF1_PLAYSOUND ) != 0 )
						{	if ( *ppi->snd ) PLAYSOUND( ppi->snd );
							else PLAYSOUND( IDW_CAMERA );
						} // end if

					} // end if

					// Ensure cache files are gone
					if ( *ppi->avicachefile != 0 )
					{	CWinFile::Delete( ppi->avicachefile );
						*ppi->avicachefile = 0;
					} // end if
					if ( *ppi->thmavicachefile != 0 )
					{	CWinFile::Delete( ppi->thmavicachefile );
						*ppi->thmavicachefile = 0;
					} // end if

				} // end if

			} // end if

		} // end try

		// Try to return to a normal life if we can...
		catch( ... ) 
		{	_Log( MB_ICONERROR, "PublishThread()", "Assert" );	
			ASSERT( 0 ); 
		}
	
	} // end while

	m_bReset = FALSE;

	Sleep( 100 );

	return TRUE;
}
Esempio n. 17
0
BOOL CPubThread::Ftp( LPPUBINFO ppi )
{
	if ( ppi == NULL ) return FALSE;

	// Ensure ftp server
	HGROUP hGroup = FTPSERVERS().FindGroup( ppi->str );
	if ( hGroup == NULL )
	{	_Log( MB_ICONERROR, ppi->str, "FTP Server information not found" );	
		return FALSE;
	} // end if

	BOOL bPublished = FALSE;
	LPBYTE buf = NULL;
	DWORD size = 0;
	TMem< BYTE > temp;
	CWinImg img;

	// Is it an avi file
	if ( *ppi->avicachefile != 0 )
	{
		CWinFile wf;
		if ( wf.OpenExisting( ppi->avicachefile ) )
		{	size = wf.Size();
			if ( size && temp.allocate( size ) && wf.Read( temp.ptr(), temp.size() ) )
				buf = (LPBYTE)temp.ptr();
		} // end if
		
	} // end if
	else
	{
		// Get the image
		if ( !IMGLIST().GetImage( ppi->img, &img ) )
		{	_Log( MB_ICONERROR, ppi->img, "Image not found" );	
			return FALSE;
		} // end if

		// Set jpeg quality
		FRAME()->SetQuality( &img );

		// Encode the file
		if ( !img.Encode( &buf, &size, ppi->pub_fname ) ) 
		{	_Log( MB_ICONERROR, ppi->img, img.GetLastError() );	
			return FALSE;
		} // end if

	} // end else

	// Want Win32 interface?
	if ( FTPSERVERS().GetDword( hGroup, "Rename", FALSE ) )
	{
		// Create FTP object if needed
		if ( ppi->pftp == NULL ) ppi->pftp = new CFtp();
		if ( ppi->pftp == NULL )
		{	_Log( MB_ICONERROR, "Ftp()", "Out of memory" );	
			return FALSE;
		} // end if

		// Is the FTP already working?
		if ( !ppi->pftp->IsConnecting() && !ppi->pftp->IsConnected() )
		{

			// Copy the memory
			if ( ppi->mem == NULL || !ppi->mem->put( buf, size ) )
			{	_Log( MB_ICONERROR, "Ftp()", "Memory error" );	
				return FALSE;
			} // end if

			// Upload the data
			bPublished = FtpImage( ppi->str, ppi->pftp, *ppi->mem, ppi->mem->size(), ppi->pub_fname );
		} // end if

	} // end if

	else 
	{
		// Create FTP object if needed
		if ( ppi->pw32ftp == NULL ) ppi->pw32ftp = new CNetFile();
		if ( ppi->pw32ftp == NULL )
		{	_Log( MB_ICONERROR, "Ftp()", "Out of memory" );	
			return FALSE;
		} // end if

		// Use Windows interface
		bPublished = FtpImage( ppi->str, ppi->pw32ftp, buf, size, ppi->pub_fname );

	} // end else

	// Punt if no thumbnail
	if ( ( ppi->f1 & PUBF1_THUMBNAIL ) == 0 ) return bPublished;

	// Load image if we haven't already
	if ( !img.IsValid() )
	{
		// Get the image
		if ( !IMGLIST().GetImage( ppi->img, &img ) )
		{	_Log( MB_ICONERROR, ppi->img, "Image not found" );	
			return FALSE;
		} // end if

		// Set jpeg quality
		FRAME()->SetQuality( &img );

		// Encode the file
		if ( !img.Encode( &buf, &size, ppi->pub_fname ) ) 
		{	_Log( MB_ICONERROR, ppi->img, img.GetLastError() );	
			return FALSE;
		} // end if

	} // end if

	// Get the thumbnail image
	if ( !GetThumbnail( ppi, &img, img.GetWidth(), img.GetHeight() ) )
		return FALSE;

	// Set jpeg quality
	FRAME()->SetQuality( &img );

	// Encode the thumbnail file
	if ( !img.Encode( &buf, &size, ppi->pub_tfname ) ) return FALSE;

	// Want Win32 interface?
	if ( FTPSERVERS().GetDword( hGroup, "Rename", FALSE ) )
	{
		// Create FTP object if needed
		if ( ppi->pftpthm == NULL ) ppi->pftpthm = new CFtp();
		if ( ppi->pftpthm == NULL )
		{	_Log( MB_ICONERROR, "Ftp()", "Out of memory" );	
			return FALSE;
		} // end if

		// Is the FTP already working?
		if ( !ppi->pftpthm->IsConnecting() && !ppi->pftpthm->IsConnected() )
		{
			// Copy the memory
			if ( ppi->tnmem == NULL || !ppi->tnmem->put( buf, size ) )
			{	_Log( MB_ICONERROR, "Ftp()", "Memory error" );
				return FALSE;
			} // end if

			// Upload the data
			FtpImage( ppi->str, ppi->pftpthm, *ppi->tnmem, ppi->tnmem->size(), ppi->pub_tfname );

		} // end if

	} // end if

	else 
	{
		// Create FTP object if needed
		if ( ppi->pw32ftpthm == NULL ) ppi->pw32ftp = new CNetFile();
		if ( ppi->pw32ftpthm == NULL )
		{	_Log( MB_ICONERROR, "Ftp()", "Memory error" );
			return FALSE;
		} // end if

		// Use Windows interface
		FtpImage( ppi->str, ppi->pw32ftpthm, buf, size, ppi->pub_tfname );

	} // end else

	return bPublished;
}
Esempio n. 18
0
void _LogLine(char *Str)
{
	_Log(Str);
	_Log("\n");
}
Esempio n. 19
0
	void load_text_file( vector<_Log>& logs, string filename ){
		logs.clear();

		ifstream textfile;

		char c;
		string temp_string;

		int linenum = 0;

		textfile.open( filename.c_str() );

		while( textfile.good() )
		{
			logs.push_back( _Log() );
			goto skip2;

			skip:
			logs[linenum].clear();

			skip2:

			// =================================
			// FIRST PARAMETER : image_path
			// =================================

			c = textfile.get();

			while ( textfile.good() && c != '|' ) {
				if( c == '\n' ) goto skip;

				logs[linenum].image_path += c;
				c = textfile.get();
			}

			// =====================================
			// SECOND PARAMETER : image_alignment
			// =====================================

			c = textfile.get();

			temp_string.clear();
			while( textfile.good() && c != '|' ){
				if( c == '\n' ) goto skip;

				temp_string += c;
				c = textfile.get();
			}

			logs[linenum].align = parseInt( temp_string );

			// =====================================
			// THIRD PARAMETER : sound_path
			// =====================================

			c = textfile.get();

			while ( textfile.good() && c != '|' ) {
				if( c == '\n' ) goto skip;

				logs[linenum].sound_path += c;
				c = textfile.get();
			}

			// =====================================
			// FOURTH PARAMETER : name
			// =====================================

			c = textfile.get();

			while ( textfile.good() && c != ':' ) {
				if( c == '\n' )	goto skip;

				logs[linenum].name += c;
				c = textfile.get();
			}

			// =====================================
			// FIFTH PARAMETER : log_text
			// =====================================

			c = textfile.get();

			while ( textfile.good() && c != '\n' ) {
				logs[linenum].text += c;
				c = textfile.get();
			}

			logs[linenum].clean();

			linenum++;
		}

		textfile.close();
	}
Esempio n. 20
0
void _LogTrace(enum LogTraceType traceType, const char* fmt, ...)
{
    // check to see if logging of trace messages is enabled,
    // if not, don't process the call.
    if (((logTRACE - logERROR) > SG_GET_INT(OptionLogLevel)) && (s_LogConsole == false))
    {
        return;
    }

    int nSize;
    int nLen = 0;
    bool truncated = false;
    char traceString[PS_LOG_MAX_LENGTH] = "";

    switch (traceType)
    {
        case traceENTER:

            if (truncated == false)
            {
                nSize = _snprintf_s(&traceString[nLen], PS_LOG_MAX_LENGTH - nLen, _TRUNCATE, "Enter: %s() ", s_LogFunction);

                if ((truncated = (nSize == -1)) == false)
                {
                    nLen += nSize;
                }
            }

            break;

        case traceEXIT:
            logIndent -= PS_LOG_INDENT_SIZE;

            if (logIndent < 0)
            {
                logIndent = 0;
            }

            truncated = (nLen == PS_LOG_MAX_LENGTH);

            if (truncated == false)
            {
                nSize = _snprintf_s(&traceString[nLen], PS_LOG_MAX_LENGTH - nLen, _TRUNCATE, "Exit : %s() ", s_LogFunction);

                if ((truncated = (nSize == -1)) == false)
                {
                    nLen += nSize;
                }
            }

            break;

        case traceMESSAGE:
            // do nothing
            break;

        default:
            break;
    }

    // Add the actual Log Message
    if (truncated == false)
    {
        va_list arg_ptr;
        va_start(arg_ptr, fmt);

        nSize = vsnprintf_s(&traceString[nLen], PS_LOG_MAX_LENGTH - nLen, _TRUNCATE, fmt, arg_ptr);

        if ((truncated = (nSize == -1)) == false)
        {
            nLen += nSize;
        }

        va_end(arg_ptr);
        /*lint -esym(438,arg_ptr) suppress lint warning for variable not used after assignment */
    }

    // For trace messages - force a "\n" at the end
    if (truncated == false)
    {
        nSize = _snprintf_s(&traceString[nLen], PS_LOG_MAX_LENGTH - nLen, _TRUNCATE, "\n");

        if ((truncated = (nSize == -1)) == false)
        {
            nLen += nSize;
        }
    }

    /*lint -esym(438,nLen) suppress lint warning for variable not used after assignment */
    /*lint -esym(438,truncated) suppress lint warning for variable not used after assignment */

    _Log(logTRACE, traceString);

    // log the ENTER message at the previous depth
    // and indent the upcoming messages
    if (traceType == traceENTER)
    {
        logIndent += PS_LOG_INDENT_SIZE;
    }
}
Esempio n. 21
0
File: LOG.C Progetto: Justme0/CLIB
double (log)(double x)
	{	/* compute ln(x) */
	return (_Log(x, 0));
	}