Пример #1
0
bool
TreeviewSampleApp::OnInit()
{    
  bool ok = true;

#if wxUSE_XPM
  wxImage::AddHandler(new wxXPMHandler);
#endif
#if wxUSE_LIBPNG
  wxImage::AddHandler(new wxPNGHandler);
#endif
#if wxUSE_LIBJPEG
  wxImage::AddHandler(new wxJPEGHandler);
#endif
#if wxUSE_GIF
  wxImage::AddHandler(new wxGIFHandler);
#endif

  ok = InitializeDatabase();
  if (ok)
  {
    m_mainFrameWindow = new TreeviewSample(&m_db, NULL);
    m_mainFrameWindow->Show(true);
    SetTopWindow(m_mainFrameWindow);
  }

  return ok;
}
Пример #2
0
// init global/static in single thread mode during server startup
DWORD
VMCAInitialize(
    BOOL overrideLogLevel,
    BOOL overrideLogType
    )
{
    DWORD dwError = 0;

    dwError = VMCACommonInit();
    BAIL_ON_VMCA_ERROR(dwError);

    dwError = InitializeLog(FALSE, FALSE);
    BAIL_ON_VMCA_ERROR(dwError);

    dwError = InitializeEventLog();
    BAIL_ON_VMCA_ERROR(dwError);

    dwError = InitializeDatabase();
    BAIL_ON_VMCA_ERROR(dwError);

    // Don't bail on Error , this just sets up the current state
    dwError = VMCASrvInitCA();

    dwError = VMCASrvDirSyncInit();
    BAIL_ON_VMCA_ERROR(dwError);

    dwError = VMCARPCInit();
    BAIL_ON_VMCA_ERROR(dwError);

error:

    return dwError;
}
Пример #3
0
/*===========================================================================
 *
 *  Name	 :  	DoIt
 *
 *  Purpose	 :		Actually execute the actions specified by the dialog box.
 *
 *  Return value :  TRUE - action completed
 *					FALSE - chose to abort option by not erasing the database or
 *							chose to cancel the import process by hitting cancel
 *							on progress bar box.
 *
 *  Special notes:  
 *
 *  Implicit Input :	dialog box options set by running ImportAllDialogBox prior
 *						to executing this function
 *  Implicit Input/Output:
 *  Implicit Output:
 *
 *  date    /	author	revision
 *  -----------------	--------
 *  16-Mar-1996 SFK		Created
 *	15-Oct-1996 SFK		Broke function apart from main import routine.
 *	21-Jan-1999 SFK		Added bClearIfRequested functionality for case of
 *						automated input with multiple disks
 *
===========================================================================*/
static BOOL DoIt(BOOL bPrompt, BOOL bClearIfRequested)
{   

	int status;
	CGFmtStr szAllPaths;
	unsigned int uiNumPaths;

	SetCurrentDrive();	
	if (gllbDialogParmsOk != TRUE) return(FALSE);		// have not yet setup the parameters


   /* ------------------------------------------------------------------
	*   Initialize the database if requested by the setting in the dialog box.
	* ----------------------------------------------------------------*/
	if ((gllbAllInitDB) && (bClearIfRequested)) {
		status = InitializeDatabase(bPrompt);
		if (status != TRUE) return(FALSE); 	
	}		

   /* ------------------------------------------------------------------
	*   Import all the files in the specified directory(s) into the database.
	* ----------------------------------------------------------------*/
	if (gllbIncludeSubfolders == TRUE) {
		status = DetermineAllDirectories(gllszPaths, &szAllPaths, &uiNumPaths);
		if (status == TRUE) {
			status = InputAllFiles((char *)szAllPaths.Get_sz(), gllszWildCards, gllbAllOverwrite, FALSE);
		}
		else {
			if (uiNumPaths > 0) status = InputAllFiles(gllszPaths, gllszWildCards, gllbAllOverwrite, FALSE); 
		}
	}
	else {
		if ((gllbAllInitDB) && (bClearIfRequested)) {
			status = InitializeDatabase(bPrompt);
			if (status != TRUE) return(FALSE); 	
		}		
		status = InputAllFiles(gllszPaths, gllszWildCards, gllbAllOverwrite, FALSE); 
	}
	
	SaveDatabaseNow();	// save the database after the import is complete 
	UpdateGraphData(FALSE); // if the graph is displayed, update its data now.
	
	if (status == CANCELED) return(FALSE);
	return(TRUE);
}
Пример #4
0
int main()
{
	InitializeDatabase();
	fopen_s(&f, "testResults.html", "wt");
	addPrefixToReport();
	initializeTests();
	runTests();
	fclose(f);
	CloseDatabase();
	if (!ok) return -1;
	return 0;
}
Пример #5
0
/*
 * Initialize vmafdd components
 */
DWORD
VmAfdInit(
    VOID
    )
{
    DWORD dwError = 0;

    InitializeGlobals(&gVmafdGlobals);

    dwError = VmAfdVmDirClientInit();
    BAIL_ON_VMAFD_ERROR(dwError);

    dwError = VmAfdLogInitialize(
                    gVmafdGlobals.pszLogFile,
                    gVmafdGlobals.dwMaxOldLogs,
                    gVmafdGlobals.dwMaxLogSize);
    BAIL_ON_VMAFD_ERROR(dwError);

    dwError = InitializeResourceLimit();
    BAIL_ON_VMAFD_ERROR(dwError);

    dwError = VmAfCfgInit();
    BAIL_ON_VMAFD_ERROR(dwError);

    dwError = InitializeDatabase();
    BAIL_ON_VMAFD_ERROR(dwError);

    dwError = InitializeSystemStores();
    BAIL_ON_VMAFD_ERROR (dwError);

    dwError = VmAfdOpenSSLInit();
    BAIL_ON_VMAFD_ERROR (dwError);

    if (gVmafdGlobals.bEnableRPC)
    {
      dwError = VmAfdRpcServerInit();
      BAIL_ON_VMAFD_ERROR(dwError);
    }

    dwError = VmAfdIpcServerInit();
    BAIL_ON_VMAFD_ERROR (dwError);

    // One of the decisions is not  to check return value to prevent failure of AFD because of SL
    dwError = VmAfdSuperLoggingInit(&(gVmafdGlobals.pLogger));
    BAIL_ON_VMAFD_ERROR (dwError);

error:

    return dwError;
}
Пример #6
0
int mythplugin_init(const char *libversion)
{
    if (!gCoreContext->TestPluginVersion("mythweather", libversion,
                                    MYTH_BINARY_VERSION))
        return -1;

    gCoreContext->ActivateSettingsCache(false);
    InitializeDatabase();
    gCoreContext->ActivateSettingsCache(true);

    setupKeys();

    if (gCoreContext->GetBoolSetting("weatherbackgroundfetch", false))
    {
        srcMan = new SourceManager();
        srcMan->startTimers();
        srcMan->doUpdate();
    }

    return 0;
}
Пример #7
0
DWORD
EventLogInitialize(
    )
{
    DWORD dwError = 0;

    dwError = InitializeDatabase();
    BAIL_ON_VMEVENT_ERROR(dwError);

#ifndef _WIN32
    // Construct SD for the EventLog-Service resources (to be access controlled)
    dwError = ConstructSDForEventLogServ(
			&gEventLogServerGlobals.gSecurityDescriptor
			);
    BAIL_ON_VMEVENT_ERROR(dwError);
#endif
//    dwError = EventLogRPCInit();
//    BAIL_ON_VMEVENT_ERROR(dwError);

error:

    return dwError;
}
Пример #8
0
size_t GameDatabase::SaveGame(const Game &game, 
							  const StringPairArray &rulesets, 
							  const StringPairArray& options,
							  const ISerialize& stats, 
							  const bool reload)
{
	wxString file = FilePath::Data(DataFileGames);
	wxString keyfile = FilePath::Data(DataFileGameKeys);

	// Save the game.
	wxFile gamedb;
	gamedb.Open(file, wxFile::write_append);
	wxFileOutputStream x(gamedb);
	wxDataOutputStream games(x);

	// Move to the end.
	gamedb.SeekEnd();

	// Get the starting position
	wxUint32 pos = gamedb.Tell();

	// Write out the rulesets loaded.
	games << (wxUint32) rulesets.size();
	GameDatabase::StringPairArray::const_iterator it, itEnd = rulesets.end();
	for(it = rulesets.begin(); it != itEnd; ++it)
	{
		games << it->first;
		games << it->second;
	}

	// options data
	games << (wxUint32) options.size();

	itEnd = options.end();
	for(it = options.begin(); it != itEnd; ++it)
	{
		games << it->first;
		games << it->second;
	}

	// Write out the game.
	game.save(games);

	// Stats must always go at the end so we can ignore them while loading if
	// desired.
	stats.save(games);
		
	// Close the file.
	gamedb.Close();

	// Now update the key file.
	wxFile keydb;
	keydb.Open(keyfile, wxFile::write_append);
	wxFileOutputStream y(keydb);
	wxDataOutputStream keys(y);

	// Move to the end
	keydb.SeekEnd();

	// Write the offset
	keys << pos;

	wxUint32 keyLength;
	keyLength = keydb.Length();

	// Flush it.
	keydb.Close();

	if(true == reload)
	{
		InitializeDatabase();
	}

	// Calculate the number of games.
	size_t index = (keyLength / sizeof(size_t)) - 1;
	return index;
}
Пример #9
0
//---------------------------- PRIVATE          -----------------------------//
GameDatabase::GameDatabase()
{
	InitializeDatabase();
}
Пример #10
0
void GameDatabase::DeleteGame(const size_t index, const bool reload)
{
	wxString file = FilePath::Data(DataFileGames);
	wxString keyfile = FilePath::Data(DataFileGameKeys);

	size_t size = NumGames();

	// If there's only one game in the file, just delete the files.
	if(1 == size)
	{
		wxRemoveFile(file);
		wxRemoveFile(keyfile);
	}
	else
	{
		// If this is not the last game in the file, we'll have to extricate 
		// it.
		if(index != (size - 1))
		{
			// Get two temp file names to use for the atomic deletion.
			wxString tempfile, tempkeyfile;
			tempfile = wxFileName::CreateTempFileName(swGame);
			tempkeyfile = wxFileName::CreateTempFileName(swKeys);

			wxFileInputStream db(file);
			wxFileOutputStream tempdb(tempfile);
			wxFileOutputStream tempkey(tempkeyfile);

			size_t totalLength = db.GetSize();
			size_t offset = 0;

			// Run through all the games in the db and save them to a temp file, 
			// except for the one being deleted, then copy that temp file to the 
			// desired  file.
			for(size_t i = 0; i < size; i++)
			{
				//calculate the size of this data chunk
				size_t chunk;

				if(i < (size - 1))
				{
					chunk = mOffsets[i + 1] - mOffsets[i];
				}
				else
				{
					chunk = totalLength - mOffsets[i];
				}

				// Just copy raw data instead of loading and adding.
				boost::scoped_array<wxUint8> bytes(new wxUint8[chunk]);
				db.Read(bytes.get(), chunk);

				// Skip the one we're deleting.
				if(i != index) 
				{
					tempdb.Write(bytes.get(), chunk);
					tempkey.Write(&offset, 4);

					offset += chunk;
				}
			}
			// Copy the temp files onto the real files.
			wxCopyFile(tempfile, file);
			wxCopyFile(tempkeyfile, keyfile);
		}
		// Otherwise, we can just truncate the file.
		else
		{
			wxFile in(file, wxFile::read);
			size_t chunk = mOffsets[index];

			boost::scoped_array<wxUint8> bytes(new wxUint8[chunk]);
			in.Read(bytes.get(), chunk);
			in.Close();

			// Now just write them back out.
			wxFile out(file, wxFile::write);
			out.Write(bytes.get(), chunk);
			out.Close();

			// Repeat with the key file.
			in.Open(keyfile, wxFile::read);
			chunk = in.Length() - sizeof(size_t);
			bytes.reset(new wxUint8[chunk]);
			in.Read(bytes.get(), chunk);
			in.Close();

			out.Open(keyfile, wxFile::write);
			out.Write(bytes.get(), chunk);
			out.Close();
		}
	}

	if(true == reload)
	{
		InitializeDatabase();
	}
}
Пример #11
0
//---------------------------- PRIVATE          -----------------------------//
MapDatabase::MapDatabase()
{
	InitializeDatabase();
}