コード例 #1
0
ファイル: qentity.cpp プロジェクト: qpHalcy0n/Quad2012
BaseEntity::BaseEntity_Impl::BaseEntity_Impl()
{
    _components = std::vector<BaseComponent*>();
    _should_destroy = false;
    _position = vec3f(0.0f, 0.0f, 0.0f);
    _direction = vec4f(0.0f, 0.0f, -1.0f, 0.0f);
    _scale = vec3f(1.0f, 1.0f, 1.0f);
    _id = GetNextId();
}
コード例 #2
0
ファイル: Match.cpp プロジェクト: rigoz/qDB
Match::Match(std::string ref, Date date, std::string location)
{
	m_id = GetNextId();
	m_result.home = -1;
	m_result.guest = -1;
	m_referee = ref;
	m_date = date;
	m_location = location;
	m_closed = false;
}
コード例 #3
0
ファイル: Match.cpp プロジェクト: rigoz/qDB
Match::Match(const Match &mtc)
{
	if (this != &mtc)
	{
		m_id = GetNextId();
		m_result = mtc.m_result;
		m_referee = mtc.m_referee;
		m_date = mtc.m_date;
		m_location = mtc.m_location;
		m_closed = mtc.m_closed;
	}
}
コード例 #4
0
OP_STATUS
OpScopeHttpLogger::RequestComposed(void *id, Window *window)
{
	if (IsEnabled())
	{
		OpScopeHttpInfo *info = OP_NEW(OpScopeHttpInfo, (id, GetNextId(), window, NULL));
		RETURN_OOM_IF_NULL(info);
		info->Into(&requests);
	}

	return OpStatus::OK;
}
コード例 #5
0
LptaD3DTexture::TEXTURE_ID LptaD3DTextureManager::AddOrRetrieveTexture(const std::string &filename, 
    bool transparent, float alpha,
    const LptaD3DTexture::COLOR_KEYS &colorKeys)
{
    for (RESOURCES::const_iterator it = resources.begin(); it != resources.end(); ++it) {
        const lpta::LptaTexture &texture = it->second;
        if (texture.GetFilename() == filename) {
            return texture.GetId();
        }
    }
    LptaD3DTexture d3dTexture(d3ddev, GetNextId(), filename, alpha, colorKeys);
    AddResource(d3dTexture);
    return d3dTexture.GetId();
}
コード例 #6
0
static int
AddPlayer(DBProvider * pdb, const char *name)
{
    int id = GetPlayerId(pdb, name);
    if (id == -1) {             /* Add new player to database */
        id = GetNextId(pdb, "player");
        if (id != -1) {
            char *buf = g_strdup_printf("INSERT INTO player(player_id,name,notes) VALUES (%d, '%s', '')", id, name);
            if (!pdb->UpdateCommand(buf))
                id = -1;
            g_free(buf);
        }
    }
    return id;
}
コード例 #7
0
ファイル: LangDict.cpp プロジェクト: revelator/Revelation
/*
============
idLangDict::AddString
============
*/
const char *idLangDict::AddString( const char *str ) {
	if( ExcludeString( str ) ) {
		return str;
	}
	int c = args.Num();
	for( int j = 0; j < c; j++ ) {
		if( idStr::Cmp( args[j].value, str ) == 0 ) {
			return args[j].key;
		}
	}
	int id = GetNextId();
	idLangKeyValue kv;
	// _D3XP
	kv.key = va( "#str_%08i", id );
	// kv.key = va( "#str_%05i", id );
	kv.value = str;
	c = args.Append( kv );
	assert( kv.key.Cmpn( STRTABLE_ID, STRTABLE_ID_LENGTH ) == 0 );
	hash.Add( GetHashKey( kv.key ), c );
	return args[c].key;
}
コード例 #8
0
ファイル: runtime.c プロジェクト: esun9064/tsh
/* AddJob to a bgJobL, return id of added job */
int AddJob(pid_t pid, int status, char* commands, int done)
{
  int i = GetNextId();
  bgjobL* temp;
  if (done == 0)    //job is not done
    temp = bgjobs;
  else
    temp = donejobs;

  //allocate space for a new job and initialize new job
  bgjobL* newJob = malloc(sizeof(bgjobL));
  newJob->pid = pid;
  newJob->status = status;
  newJob->commands = (char*)malloc(500*sizeof(char));
  newJob->id = i;
  newJob->done = done;
  strcpy(newJob->commands, commands);
  newJob->next = NULL;

  //empty list
  if (temp == NULL)
  {
    if (done == 0)
      bgjobs = newJob;
    else
      donejobs = newJob;
    return i;
  }
  else
  {
    while(temp->next != NULL)
    {
      temp=temp->next;
    }
    temp->next = newJob;
    return i;
  }
}
コード例 #9
0
static void AddGames(DBProvider *pdb, int session_id, int player_id0, int player_id1)
{
	int gamenum = 0;
	listOLD *plGame, *pl = lMatch.plNext;
	while ((plGame = pl->p) != NULL)
	{
		int game_id = GetNextId(pdb, "game");
		moverecord *pmr = plGame->plNext->p;
		xmovegameinfo *pmgi = &pmr->g;
		char *buf = g_strdup_printf("INSERT INTO game(game_id, session_id, player_id0, player_id1, "
				"score_0, score_1, result, added, game_number, crawford) "
				"VALUES (%d, %d, %d, %d, %d, %d, %d, CURRENT_TIME, %d, %d )",
				game_id, session_id, player_id0, player_id1,
				pmgi->anScore[0], pmgi->anScore[1], pmgi->nPoints, ++gamenum, pmr->g.fCrawfordGame);

		if (pdb->UpdateCommand(buf))
		{
			AddStats(pdb, game_id, player_id0, 0, "gamestat", ms.nMatchTo, &(pmgi->sc));
			AddStats(pdb, game_id, player_id1, 1, "gamestat", ms.nMatchTo, &(pmgi->sc));
		}
		g_free(buf);
		pl = pl->plNext;
	}
}
コード例 #10
0
extern void CommandRelationalAddMatch(char *sz)
{
	DBProvider *pdb;
	char *buf, *buf2, *date;
	char warnings[1024] = "";
	int session_id, existing_id, player_id0, player_id1;
	char *arg = NULL;
	gboolean quiet = FALSE;

	arg = NextToken(&sz);
	if (arg)
		quiet = !strcmp(arg, "quiet");

	if (ListEmpty(&lMatch))
	{
		outputl( _("No match is being played.") );
		return;
	}

	/* Warn if match is not finished or fully analyzed */
	if (!quiet && !GameOver())
		strcat(warnings, _("The match is not finished\n"));
	if (!quiet && !MatchAnalysed())
		strcat(warnings, _("All of the match is not analyzed\n"));

	if (*warnings)
	{
		strcat(warnings, _("\nAdd match anyway?"));
		if (!GetInputYN(warnings))
			return;
	}

	if ((pdb = ConnectToDB(dbProviderType)) == NULL)
		return;

	existing_id = RelationalMatchExists(pdb);
	if (existing_id != -1)
	{
		if (!quiet && !GetInputYN(_("Match exists, overwrite?")))
			return;

		/* Remove any game stats and games */
		buf2 = g_strdup_printf("FROM game WHERE session_id = %d", existing_id);
		buf = g_strdup_printf("DELETE FROM gamestat WHERE game_id in (SELECT game_id %s)", buf2);
		pdb->UpdateCommand(buf);
		g_free(buf);
		buf = g_strdup_printf("DELETE %s", buf2);
		pdb->UpdateCommand(buf);
		g_free(buf);
		g_free(buf2);

		/* Remove any match stats and session */
		buf = g_strdup_printf("DELETE FROM matchstat WHERE session_id = %d", existing_id);
		pdb->UpdateCommand(buf);
		g_free(buf);
		buf = g_strdup_printf("DELETE FROM session WHERE session_id = %d", existing_id);
		pdb->UpdateCommand(buf);
		g_free(buf);
	}

	session_id = GetNextId(pdb, "session");
	player_id0 = AddPlayer(pdb, ap[0].szName);
	player_id1 = AddPlayer(pdb, ap[1].szName);
	if (session_id == -1 || player_id0 == -1 || player_id1 == -1)
	{
		outputl( _("Error adding match.") );
		return;
	}

	if( mi.nYear )
		date = g_strdup_printf("%04d-%02d-%02d", mi.nYear, mi.nMonth, mi.nDay);
	else
		date = NULL;

	buf = g_strdup_printf("INSERT INTO session(session_id, checksum, player_id0, player_id1, "
              "result, length, added, rating0, rating1, event, round, place, annotator, comment, date) "
              "VALUES (%d, '%s', %d, %d, %d, %d, CURRENT_TIMESTAMP, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",
				session_id, GetMatchCheckSum(), player_id0, player_id1,
				MatchResult(ms.nMatchTo), ms.nMatchTo, NS(mi.pchRating[0]), NS(mi.pchRating[1]),
				NS(mi.pchEvent), NS(mi.pchRound), NS(mi.pchPlace), NS(mi.pchAnnotator), NS(mi.pchComment), NS(date));

	updateStatisticsMatch ( &lMatch );

	if (pdb->UpdateCommand(buf))
	{
		if (AddStats(pdb, session_id, player_id0, 0, "matchstat", ms.nMatchTo, &scMatch) &&
			AddStats(pdb, session_id, player_id1, 1, "matchstat", ms.nMatchTo, &scMatch))
		{
			if (storeGameStats)
				AddGames(pdb, session_id, player_id0, player_id1);
			pdb->Commit();
		}
	}
	g_free(buf);
	g_free(date);
	pdb->Disconnect();
}
コード例 #11
0
static int AddStats(DBProvider * pdb, int gm_id, int player_id, int player,
		    const char *table, int nMatchTo, statcontext * sc)
{
	gchar *buf;
	GString *column, *value;
	int totalmoves, unforced;
	float errorcost, errorskill;
	float aaaar[3][2][2][2];
	float r;
	int ret;
	char tmpf[G_ASCII_DTOSTR_BUF_SIZE];

	int gms_id = GetNextId(pdb, table);
	if (gms_id == -1)
		return FALSE;

	totalmoves = sc->anTotalMoves[player];
	unforced = sc->anUnforcedMoves[player];

	getMWCFromError(sc, aaaar);
	errorskill = aaaar[CUBEDECISION][PERMOVE][player][NORMALISED];
	errorcost = aaaar[CUBEDECISION][PERMOVE][player][UNNORMALISED];

	column = g_string_new(NULL);
	value = g_string_new(NULL);


	if (strcmp("matchstat", table) == 0) {
		APPENDI("matchstat_id", gms_id);
		APPENDI("session_id", gm_id);
	} else {
		APPENDI("gamestat_id", gms_id);
		APPENDI("game_id", gm_id);
	}

	APPENDI("player_id", player_id);
	APPENDI("total_moves", totalmoves);
	APPENDI("unforced_moves", unforced);
	APPENDI("unmarked_moves", sc->anMoves[player][SKILL_NONE]);
	APPENDI("good_moves", 0);
	APPENDI("doubtful_moves", sc->anMoves[player][SKILL_DOUBTFUL]);
	APPENDI("bad_moves", sc->anMoves[player][SKILL_BAD]);
	APPENDI("very_bad_moves", sc->anMoves[player][SKILL_VERYBAD]);
	APPENDF("chequer_error_total_normalised",
		sc->arErrorCheckerplay[player][0]);
	APPENDF("chequer_error_total", sc->arErrorCheckerplay[player][1]);
	APPENDF("chequer_error_per_move_normalised",
		Ratio(sc->arErrorCheckerplay[player][0], unforced));
	APPENDF("chequer_error_per_move",
		Ratio(sc->arErrorCheckerplay[player][1], unforced));
	APPENDI("chequer_rating",
		GetRating(Ratio
			  (scMatch.arErrorCheckerplay[player][0],
			   unforced)));
	APPENDI("very_lucky_rolls", sc->anLuck[player][LUCK_VERYGOOD]);
	APPENDI("lucky_rolls", sc->anLuck[player][LUCK_GOOD]);
	APPENDI("unmarked_rolls", sc->anLuck[player][LUCK_NONE]);
	APPENDI("unlucky_rolls", sc->anLuck[player][LUCK_BAD]);
	APPENDI("very_unlucky_rolls", sc->anLuck[player][LUCK_VERYBAD]);
	APPENDF("luck_total_normalised", sc->arLuck[player][0]);
	APPENDF("luck_total", sc->arLuck[player][1]);
	APPENDF("luck_per_move_normalised",
		Ratio(sc->arLuck[player][0], totalmoves));
	APPENDF("luck_per_move", Ratio(sc->arLuck[player][1], totalmoves));
	APPENDI("luck_rating",
		getLuckRating(Ratio(sc->arLuck[player][0], totalmoves)));
	APPENDI("total_cube_decisions", sc->anTotalCube[player]);
	APPENDI("close_cube_decisions", sc->anCloseCube[player]);
	APPENDI("doubles", sc->anDouble[player]);
	APPENDI("takes", sc->anTake[player]);
	APPENDI("passes", sc->anPass[player]);
	APPENDI("missed_doubles_below_cp",
		sc->anCubeMissedDoubleDP[player]);
	APPENDI("missed_doubles_above_cp",
		sc->anCubeMissedDoubleTG[player]);
	APPENDI("wrong_doubles_below_dp", sc->anCubeWrongDoubleDP[player]);
	APPENDI("wrong_doubles_above_tg", sc->anCubeWrongDoubleTG[player]);
	APPENDI("wrong_takes", sc->anCubeWrongTake[player]);
	APPENDI("wrong_passes", sc->anCubeWrongPass[player]);
	APPENDF("error_missed_doubles_below_cp_normalised",
		sc->arErrorMissedDoubleDP[player][0]);
	APPENDF("error_missed_doubles_above_cp_normalised",
		sc->arErrorMissedDoubleTG[player][0]);
	APPENDF("error_wrong_doubles_below_dp_normalised",
		sc->arErrorWrongDoubleDP[player][0]);
	APPENDF("error_wrong_doubles_above_tg_normalised",
		sc->arErrorWrongDoubleTG[player][0]);
	APPENDF("error_wrong_takes_normalised",
		sc->arErrorWrongTake[player][0]);
	APPENDF("error_wrong_passes_normalised",
		sc->arErrorWrongPass[player][0]);
	APPENDF("error_missed_doubles_below_cp",
		sc->arErrorMissedDoubleDP[player][1]);
	APPENDF("error_missed_doubles_above_cp",
		sc->arErrorMissedDoubleTG[player][1]);
	APPENDF("error_wrong_doubles_below_dp",
		sc->arErrorWrongDoubleDP[player][1]);
	APPENDF("error_wrong_doubles_above_tg",
		sc->arErrorWrongDoubleTG[player][1]);
	APPENDF("error_wrong_takes", sc->arErrorWrongTake[player][1]);
	APPENDF("error_wrong_passes", sc->arErrorWrongPass[player][1]);
	APPENDF("cube_error_total_normalised",
		errorskill * sc->anCloseCube[player]);
	APPENDF("cube_error_total", errorcost * sc->anCloseCube[player]);
	APPENDF("cube_error_per_move_normalised", errorskill);
	APPENDF("cube_error_per_move", errorcost);
	APPENDI("cube_rating", GetRating(errorskill));;
	APPENDF("overall_error_total_normalised",
		errorskill * sc->anCloseCube[player] +
		sc->arErrorCheckerplay[player][0]);
	APPENDF("overall_error_total",
		errorcost * sc->anCloseCube[player] +
		sc->arErrorCheckerplay[player][1]);
	APPENDF("overall_error_per_move_normalised",
		Ratio(errorskill * sc->anCloseCube[player] +
		      sc->arErrorCheckerplay[player][0],
		      sc->anCloseCube[player] + unforced));
	APPENDF("overall_error_per_move",
		Ratio(errorcost * sc->anCloseCube[player] +
		      sc->arErrorCheckerplay[player][1],
		      sc->anCloseCube[player] + unforced));
	APPENDI("overall_rating",
		GetRating(Ratio
			  (errorskill * sc->anCloseCube[player] +
			   sc->arErrorCheckerplay[player][0],
			   sc->anCloseCube[player] + unforced)));
	APPENDF("actual_result", sc->arActualResult[player]);
	APPENDF("luck_adjusted_result", sc->arLuckAdj[player]);
	APPENDI("snowie_moves",
		totalmoves + scMatch.anTotalMoves[!player]);
	APPENDF("snowie_error_rate_per_move",
		Ratio(errorskill * scMatch.anCloseCube[player] +
		      scMatch.arErrorCheckerplay[player][0],
		      totalmoves + scMatch.anTotalMoves[!player]));
	/*time */
	APPENDI("time_penalties", 0);
	APPENDF("time_penalty_loss_normalised", 0.0);
	APPENDF("time_penalty_loss", 0.0);
	/* matches only */
	r = 0.5f + scMatch.arActualResult[player] -
	    scMatch.arLuck[player][1] + scMatch.arLuck[!player][1];
	if (nMatchTo && r > 0.0f && r < 1.0f)
		APPENDF("luck_based_fibs_rating_diff",
			relativeFibsRating(r, nMatchTo));
	if (nMatchTo && (scMatch.fCube || scMatch.fMoves)) {
		APPENDF("error_based_fibs_rating",
			absoluteFibsRating(aaaar[CHEQUERPLAY][PERMOVE]
					   [player][NORMALISED],
					   aaaar[CUBEDECISION][PERMOVE]
					   [player][NORMALISED], nMatchTo,
					   rRatingOffset));
		if (scMatch.anUnforcedMoves[player])
			APPENDF("chequer_rating_loss",
				absoluteFibsRatingChequer(aaaar
							  [CHEQUERPLAY]
							  [PERMOVE][player]
							  [NORMALISED],
							  nMatchTo));
		if (scMatch.anCloseCube[player])
			APPENDF("cube_rating_loss",
				absoluteFibsRatingCube(aaaar[CUBEDECISION]
						       [PERMOVE][player]
						       [NORMALISED],
						       nMatchTo));
	}

	/* for money sessions only */
	if (scMatch.fDice && !nMatchTo && scMatch.nGames > 1) {

		APPENDF("actual_advantage",
			scMatch.arActualResult[player] / scMatch.nGames);
		APPENDF("actual_advantage_ci",
			1.95996f * sqrt(scMatch.arVarianceActual[player] /
					scMatch.nGames));
		APPENDF("luck_adjusted_advantage",
			scMatch.arLuckAdj[player] / scMatch.nGames);
		APPENDF("luck_adjusted_advantage_ci",
			1.95996f * sqrt(scMatch.arVarianceLuckAdj[player] /
					scMatch.nGames));
	}

	g_string_truncate(column, column->len - 2);
	g_string_truncate(value, value->len - 2);
	buf = g_strdup_printf("INSERT INTO %s (%s) VALUES(%s)", table,
			      column->str, value->str);
	ret = pdb->UpdateCommand(buf);
	g_free(buf);
	g_string_free(column, TRUE);
	g_string_free(value, TRUE);
	return ret;
}
コード例 #12
0
LptaD3DVertexShaderManager::LptaD3DVertexShaderManager(LPDIRECT3DDEVICE9 d3ddev) : d3ddev(d3ddev)
{
    LPDIRECT3DVERTEXSHADER9 defaultShader = LoadAndCompile(defaultShaderProgram);
    this->SetNullResource(LptaD3DVertexShader(GetNextId(), defaultShader));
}
コード例 #13
0
ファイル: fsets.cpp プロジェクト: codegooglecom/wtfu
bool FilesSets::Save(const wxString& filename)
{
    wxXmlDocument *xmldoc = WXDEBUG_NEW wxXmlDocument();
    wxXmlNode *root = WXDEBUG_NEW wxXmlNode(NULL, wxXML_ELEMENT_NODE, wxT("sets"));
    wxXmlNode *set, *node, *set2;
    wxString value;
    wxString eol = wxT("\012");
    int id1, id2, id3;
    FilesSet *fset;
    NamesSet *nset;

//    root->AddChild(WXDEBUG_NEW wxXmlNode(NULL, wxXML_TEXT_NODE, wxEmptyString, eol));

    fset = GetLastFS(&id1);
    while ( (id1 > 0) && (id1 < GetNextId()) )
    {
        value.Empty();
        value.Printf(wxT("%d"), id1);
        set = WXDEBUG_NEW wxXmlNode(root, wxXML_ELEMENT_NODE, wxT("set"), wxEmptyString, WXDEBUG_NEW wxXmlProperty(wxT("id"), value));
//        set->AddChild(WXDEBUG_NEW wxXmlNode(NULL, wxXML_TEXT_NODE, wxEmptyString, eol));
        nset = fset->GetLastNS(&id2);
        while ( (id2 > 0) && (id2 < fset->GetNextNSId()) )
        {
            value.Empty();
            value.Printf(wxT("%d"), id2);
            set2 = WXDEBUG_NEW wxXmlNode(set, wxXML_ELEMENT_NODE, wxT("names-set"), wxEmptyString, WXDEBUG_NEW wxXmlProperty(wxT("id"), value));
//            set2->AddChild(WXDEBUG_NEW wxXmlNode(NULL, wxXML_TEXT_NODE, wxEmptyString, eol));
            value = nset->GetLastName(&id3);
            while ( (id3 > 0) && (id3 < nset->GetNextId()) )
            {
                node = WXDEBUG_NEW wxXmlNode(set2, wxXML_ELEMENT_NODE, wxT("item"));
                node->AddChild(WXDEBUG_NEW wxXmlNode(NULL, wxXML_TEXT_NODE, wxEmptyString, value));
                value.Empty();
                value.Printf(wxT("%d"), id3);
                node->SetProperties(WXDEBUG_NEW wxXmlProperty(wxT("id"), value));
//                set2->AddChild(WXDEBUG_NEW wxXmlNode(NULL, wxXML_TEXT_NODE, wxEmptyString, eol));
                value = nset->GetPrevName(&id3);
            }
            node = WXDEBUG_NEW wxXmlNode(set2, wxXML_ELEMENT_NODE, wxT("path"));
            node->AddChild(WXDEBUG_NEW wxXmlNode(NULL, wxXML_TEXT_NODE, wxEmptyString, nset->GetDir()));
//            set2->AddChild(WXDEBUG_NEW wxXmlNode(NULL, wxXML_TEXT_NODE, wxEmptyString, eol));
            node = WXDEBUG_NEW wxXmlNode(set2, wxXML_ELEMENT_NODE, wxT("title"));
            node->AddChild(WXDEBUG_NEW wxXmlNode(NULL, wxXML_TEXT_NODE, wxEmptyString, nset->GetTitle()));
//            set2->AddChild(WXDEBUG_NEW wxXmlNode(NULL, wxXML_TEXT_NODE, wxEmptyString, eol));
            nset = fset->GetPrevNS(&id2);
        }
//        set->AddChild(WXDEBUG_NEW wxXmlNode(NULL, wxXML_TEXT_NODE, wxEmptyString, eol));
        node = WXDEBUG_NEW wxXmlNode(set, wxXML_ELEMENT_NODE, wxT("files-set"));
        value.Empty();
        value.Printf(wxT("%d"), fset->GetMainId());
        node->AddChild(WXDEBUG_NEW wxXmlNode(NULL, wxXML_TEXT_NODE, wxEmptyString, value));
//        set->AddChild(WXDEBUG_NEW wxXmlNode(NULL, wxXML_TEXT_NODE, wxEmptyString, eol));
        node = WXDEBUG_NEW wxXmlNode(set, wxXML_ELEMENT_NODE, wxT("title"));
        node->AddChild(WXDEBUG_NEW wxXmlNode(NULL, wxXML_TEXT_NODE, wxEmptyString, fset->GetTitle()));
//        set->AddChild(WXDEBUG_NEW wxXmlNode(NULL, wxXML_TEXT_NODE, wxEmptyString, eol));
//        root->AddChild(WXDEBUG_NEW wxXmlNode(NULL, wxXML_TEXT_NODE, wxEmptyString, eol));
        fset = GetPrevFS(&id1);
    }
    xmldoc->SetRoot(root);

    bool rv = xmldoc->Save(filename, 1);

    delete(xmldoc);

    return rv;
}
コード例 #14
0
ファイル: logging.c プロジェクト: strm/cdt316-lab2
int LogHandler(char cmd, int id_in, varList **commands, int *id_out) {
	int ret = 0;
	FILE *post_file = NULL;
	FILE *pre_file = NULL;
	char *post_log = NULL;
	char *pre_log = NULL;
	int post_log_len = strlen(LOG_PATH) + strlen(LOG_POST_NAME) + strlen(DB_GLOBAL) + 1;
	int pre_log_len = strlen(LOG_PATH) + strlen(LOG_PRE_NAME) + strlen(DB_GLOBAL) + 1;

	post_log = (char *)malloc(sizeof(char *) * post_log_len);
	pre_log = (char *)malloc(sizeof(char *) * pre_log_len);

	strncpy(post_log, LOG_PATH, post_log_len);
	strncat(post_log, DB_GLOBAL, post_log_len);
	strncat(post_log, LOG_POST_NAME, post_log_len);

	strncpy(pre_log, LOG_PATH, pre_log_len);
	strncat(pre_log, DB_GLOBAL, pre_log_len);
	strncat(pre_log, LOG_PRE_NAME, pre_log_len);

	switch (cmd){
		case LOG_WRITE_PRE:
			debug_out(4, "log: In LOG_WRITE_PRE\n");
			pre_file = fopen(pre_log, "a");
			if(pre_file != NULL)
				debug_out(4, "log: Opened file '%s'\n", pre_log);
			else
			{
				debug_out(4, "log: Could not open file '%s'\n", pre_log);
				ret = -1;
				break;
			}
			WriteLogEntry(pre_file, id_in, *commands);
			debug_out(4, "log: logentry written to file\n");
			break;
		case LOG_WRITE_POST:
			debug_out(4, "log: In LOG_WRITE_POST\n");
			post_file = fopen(post_log, "a");
			if(post_file != NULL)
				debug_out(4, "log: Opened file '%s'\n", post_log);
			else {
				debug_out(4, "log: Could not open file '%s'\n", post_log);
				ret = -1;
				break;
			}
			WriteLogEntry(post_file, id_in, *commands);
			debug_out(4, "log: logentry written to file\n");
			break;
		case LOG_READ_POST:
			post_file = fopen(post_log, "r");
			if(post_file != NULL) {
				if(ReadLogEntry(&post_file, &id_in, commands) == -1) {
					*id_out = LOG_NO_ID;
					ret = -1;
				}
			}
			break;
		case LOG_READ_PRE:
			pre_file = fopen(pre_log, "r");
			if(pre_file != NULL) {
				if(ReadLogEntry(&pre_file, &id_in, commands) == -1) {
					*id_out = LOG_NO_ID;
					ret = -1;
				}
			}
			break;
		case LOG_LAST_ID:
			if(id_out != NULL) {
				ret = GetLastId(pre_log, post_log, id_out);
			}
			else
				ret = -1;
			break;
		case LOG_GET_NEXT_PRE_ID:
			if(id_out != NULL)
				*id_out = GetNextId(pre_log, id_in);
			else
				ret = -1;
			break;
		case LOG_GET_NEXT_POST_ID:
			if(id_out != NULL)
				*id_out = GetNextId(post_log, id_in);
			else
				ret = -1;
			break;
		case LOG_CHECK_ID:
			break;
		default:
			ret = -1;
			break;
	}
	if(pre_file) {
		fclose(pre_file);
	}
	if(post_file) {
		fclose(post_file);
	}

	return ret;
}