コード例 #1
0
ファイル: Simulator.cpp プロジェクト: rs20/HelloWorld
int Simulator::handleAll()
{
	if (handleConfiguration())
		return -1;
	if (handleScore())
		return -1;
	if (handleAlgorithms())
		return -1;
	if (handleHouses())
		return -1;
	handleThreads();
	if (handleVideo())
		return -1;
	return 0;
}
コード例 #2
0
ファイル: Debugger.cpp プロジェクト: patrickmortensen/Elektro
void Debugger::loadSettings() {
	FILE* pFile = fopen(DebugPrefs, "r");
	int size = 1024, pos;
	int c;
	char *buffer = (char*)malloc(sizeof(char)*size);

	int confSizeA = 128;
	int confSizeB = 128;
	//finish dynamic memory allocation for debugruntimeconfig method
	char** conf = (char**)malloc(sizeof(char*)*2);

	conf[0] = (char*)malloc(sizeof(char)*confSizeA);
	conf[1] = (char*)malloc(sizeof(char)*confSizeB);
	
	if(pFile == NULL) {
		Log(WARNING, "Failed to open Debugger Preferences.");
		Log(INFO, "Checking if Debugger Preferences exist.");
		if(settingsExist()) {
			Log(_ERROR_, "Cannot access Debugger Preferences but file does exist.");
			Log(WARNING, "Is another application using this file? (Shouldn't be!)");
		} else {
			Log(INFO, "Debugger Preferences file does not exist, generating.");
			newSettings();
		}
	} else {
		do {
			pos = 0;
			do {
				c = fgetc(pFile);
				if(c!=EOF) buffer[pos++] = (char)c;
				if(pos >= size - 1) {
					size *= 2;
					buffer = (char*)realloc(buffer, size);
				}
			} while (c != EOF && c != '\n');
			buffer[pos]=0;
			//Log(buffer);
			//Each line from the file gets handled here.
			conf = handleConfiguration(buffer);
			setDebuggerRuntimeConfig(conf);
		} while (c != EOF);
		fclose(pFile);
	}
	free(buffer);
}