From 13eb83bea655c3302c74a82d826d75bceb9232a2 Mon Sep 17 00:00:00 2001 From: Rozhuk Ivan Date: Mon, 8 Dec 2014 22:13:57 +0000 Subject: code cleanup around mir_snprintf git-svn-id: http://svn.miranda-ng.org/main/trunk@11285 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Xfire/src/Xfire_base.cpp | 36 ++++++++++++++++----------------- protocols/Xfire/src/Xfire_game.cpp | 2 +- protocols/Xfire/src/Xfire_icon_mng.cpp | 4 ++-- protocols/Xfire/src/Xfire_voicechat.cpp | 4 ++-- protocols/Xfire/src/addgamedialog.cpp | 14 ++++++------- protocols/Xfire/src/all_statusmsg.cpp | 4 ++-- protocols/Xfire/src/buddylist.cpp | 2 +- protocols/Xfire/src/iniupdater.cpp | 4 ++-- protocols/Xfire/src/main.cpp | 10 ++++----- protocols/Xfire/src/userdetails.cpp | 12 +++++------ 10 files changed, 46 insertions(+), 46 deletions(-) (limited to 'protocols/Xfire/src') diff --git a/protocols/Xfire/src/Xfire_base.cpp b/protocols/Xfire/src/Xfire_base.cpp index 602a198997..dd924bcff3 100644 --- a/protocols/Xfire/src/Xfire_base.cpp +++ b/protocols/Xfire/src/Xfire_base.cpp @@ -113,7 +113,7 @@ void Xfire_base::readStringfromDB(char*name, unsigned int dbid, char**to) return; //wert aus der dblesen - mir_snprintf(temp, 128, "%s_%i", name, dbid); + mir_snprintf(temp, SIZEOF(temp), "%s_%i", name, dbid); if (!db_get_s(NULL, protocolname, temp, &dbv)) { //string setzen @@ -131,7 +131,7 @@ void Xfire_base::readStringfromDB(char*name, unsigned int dbid, int id, char**to return; //wert aus der dblesen - mir_snprintf(temp, 128, "%s_%i_%i", name, dbid, id); + mir_snprintf(temp, SIZEOF(temp), "%s_%i_%i", name, dbid, id); if (!db_get_s(NULL, protocolname, temp, &dbv)) { //string setzen @@ -149,7 +149,7 @@ void Xfire_base::readUtf8StringfromDB(char*name, unsigned int dbid, char**to) return; //wert aus der dblesen - mir_snprintf(temp, 128, "%s_%i", name, dbid); + mir_snprintf(temp, SIZEOF(temp), "%s_%i", name, dbid); if (!db_get_utf(NULL, protocolname, temp, &dbv)) { //string setzen @@ -167,7 +167,7 @@ void Xfire_base::readUtf8StringfromDB(char*name, unsigned int dbid, int id, char return; //wert aus der dblesen - mir_snprintf(temp, 128, "%s_%i_%i", name, dbid, id); + mir_snprintf(temp, SIZEOF(temp), "%s_%i_%i", name, dbid, id); if (!db_get_utf(NULL, protocolname, temp, &dbv)) { //string setzen @@ -186,7 +186,7 @@ void Xfire_base::writeStringtoDB(char*name, unsigned int dbid, int id, char*val) return; //wert aus der dblesen - mir_snprintf(temp, 128, "%s_%i_%i", name, dbid, id); + mir_snprintf(temp, SIZEOF(temp), "%s_%i_%i", name, dbid, id); db_set_s(NULL, protocolname, temp, val); } @@ -198,7 +198,7 @@ void Xfire_base::writeStringtoDB(char*name, unsigned int dbid, char*val) return; //wert aus der dblesen - mir_snprintf(temp, 128, "%s_%i", name, dbid); + mir_snprintf(temp, SIZEOF(temp), "%s_%i", name, dbid); db_set_s(NULL, protocolname, temp, val); } @@ -210,7 +210,7 @@ void Xfire_base::writeUtf8StringtoDB(char*name, unsigned int dbid, int id, char* return; //wert aus der dblesen - mir_snprintf(temp, 128, "%s_%i_%i", name, dbid, id); + mir_snprintf(temp, SIZEOF(temp), "%s_%i_%i", name, dbid, id); db_set_utf(NULL, protocolname, temp, val); } @@ -222,7 +222,7 @@ void Xfire_base::writeUtf8StringtoDB(char*name, unsigned int dbid, char*val) return; //wert aus der dblesen - mir_snprintf(temp, 128, "%s_%i", name, dbid); + mir_snprintf(temp, SIZEOF(temp), "%s_%i", name, dbid); db_set_utf(NULL, protocolname, temp, val); } @@ -235,7 +235,7 @@ void Xfire_base::writeBytetoDB(char*name, unsigned int dbid, int val) return; //wert aus der dblesen - mir_snprintf(temp, 128, "%s_%i", name, dbid); + mir_snprintf(temp, SIZEOF(temp), "%s_%i", name, dbid); db_set_b(NULL, protocolname, temp, val); } @@ -247,7 +247,7 @@ void Xfire_base::writeWordtoDB(char*name, unsigned int dbid, int val) return; //wert aus der dblesen - mir_snprintf(temp, 128, "%s_%i", name, dbid); + mir_snprintf(temp, SIZEOF(temp), "%s_%i", name, dbid); db_set_w(NULL, protocolname, temp, val); } @@ -260,7 +260,7 @@ unsigned char Xfire_base::readBytefromDB(char*name, unsigned int dbid, int defau return 0; //wert aus der dblesen - mir_snprintf(temp, 128, "%s_%i", name, dbid); + mir_snprintf(temp, SIZEOF(temp), "%s_%i", name, dbid); return db_get_b(NULL, protocolname, temp, defaultval); } @@ -272,7 +272,7 @@ unsigned int Xfire_base::readWordfromDB(char*name, unsigned int dbid, int defaul return 0; //wert aus der dblesen - mir_snprintf(temp, 128, "%s_%i", name, dbid); + mir_snprintf(temp, SIZEOF(temp), "%s_%i", name, dbid); return db_get_w(NULL, protocolname, temp, defaultval); } @@ -284,7 +284,7 @@ BOOL Xfire_base::removeDBEntry(char*name, unsigned int dbid) return 0; //wert aus der dblesen - mir_snprintf(temp, 128, "%s_%i", name, dbid); + mir_snprintf(temp, SIZEOF(temp), "%s_%i", name, dbid); //eintrag entfernen if (!db_get(NULL, protocolname, temp, &dbv)) @@ -305,7 +305,7 @@ BOOL Xfire_base::removeDBEntry(char*name, unsigned int dbid, int id) return 0; //wert aus der dblesen - mir_snprintf(temp, 128, "%s_%i_%i", name, dbid, id); + mir_snprintf(temp, SIZEOF(temp), "%s_%i_%i", name, dbid, id); //eintrag entfernen if (!db_get(NULL, protocolname, temp, &dbv)) @@ -479,7 +479,7 @@ BOOL Xfire_base::getIniValue(unsigned int gameid, unsigned int subid, const char return FALSE; //kein pfad bug?!?! if (subid == 0) { - mir_snprintf(idstring, 15, "%d", gameid); + mir_snprintf(idstring, SIZEOF(idstring), "%d", gameid); if (xfire_GetPrivateProfileString(idstring, valname, "", out, sizeofout, path)) return TRUE; @@ -487,7 +487,7 @@ BOOL Xfire_base::getIniValue(unsigned int gameid, unsigned int subid, const char subid++; } - mir_snprintf(idstring, 15, "%d_%d", gameid, subid); + mir_snprintf(idstring, SIZEOF(idstring), "%d_%d", gameid, subid); if (xfire_GetPrivateProfileString(idstring, valname, "", out, sizeofout, path)) return TRUE; @@ -521,8 +521,8 @@ BOOL Xfire_base::getGamename(unsigned int gameid, char* out, int outsize){ { //customnamen laden, wenn vorhanden DBVARIANT dbv; - char dbstr[80] = ""; - mir_snprintf(dbstr, XFIRE_MAXSIZEOFGAMENAME, "customgamename_%d", gameid); + char dbstr[XFIRE_MAXSIZEOFGAMENAME]; + mir_snprintf(dbstr, SIZEOF(dbstr), "customgamename_%d", gameid); if (!db_get(NULL, protocolname, dbstr, &dbv)) { strncpy_s(out, outsize, dbv.pszVal, _TRUNCATE); db_free(&dbv); diff --git a/protocols/Xfire/src/Xfire_game.cpp b/protocols/Xfire/src/Xfire_game.cpp index 1486ecaf16..776a6493b7 100644 --- a/protocols/Xfire/src/Xfire_game.cpp +++ b/protocols/Xfire/src/Xfire_game.cpp @@ -57,7 +57,7 @@ BOOL Xfire_game::start_game(char*ip, unsigned int port, char*pw) { //port begrenzen port = port % 65535; //port in string wandeln - mir_snprintf(portstr, 6, "%d", port); + mir_snprintf(portstr, SIZEOF(portstr), "%d", port); str_replace(mynetworkparams, "%UA_GAME_HOST_NAME%", ip); str_replace(mynetworkparams, "%UA_GAME_HOST_PORT%", portstr); diff --git a/protocols/Xfire/src/Xfire_icon_mng.cpp b/protocols/Xfire/src/Xfire_icon_mng.cpp index 74028196f2..b469e44595 100644 --- a/protocols/Xfire/src/Xfire_icon_mng.cpp +++ b/protocols/Xfire/src/Xfire_icon_mng.cpp @@ -135,9 +135,9 @@ Xfire_icon_cache Xfire_icon_mng::LoadGameIcon(unsigned int gameid) { //dll konnte geladen werden if (hIconDll) { - char resourcename[255] = ""; + char resourcename[255]; //kurznamen des spiels uppercasen und .ICO anhängen - mir_snprintf(resourcename, 255, "XF_%s.ICO", shortname); + mir_snprintf(resourcename, SIZEOF(resourcename), "XF_%s.ICO", shortname); Xfire_base::strtoupper(resourcename); //versuche die resource zufinden diff --git a/protocols/Xfire/src/Xfire_voicechat.cpp b/protocols/Xfire/src/Xfire_voicechat.cpp index 66454c026e..1d970d05ce 100644 --- a/protocols/Xfire/src/Xfire_voicechat.cpp +++ b/protocols/Xfire/src/Xfire_voicechat.cpp @@ -141,7 +141,7 @@ void Xfire_voicechat::resetSendGameStatus2Packet(SendGameStatus2Packet* packet) //schreibt derzetigen status in die mirandadb für variables usw void Xfire_voicechat::writeToDatabase(SendGameStatus2Packet* packet) { //für sprintf - char temp[32] = ""; + char temp[32]; if (packet == NULL || packet->gameid == XFIREVOICECHAT_NOVOICE) { //einträge aus der db entfernen @@ -151,7 +151,7 @@ void Xfire_voicechat::writeToDatabase(SendGameStatus2Packet* packet) { return; } //ip speichern - mir_snprintf(temp, 32, "%d.%d.%d.%d:%d", (unsigned char)packet->ip[3], (unsigned char)packet->ip[2], (unsigned char)packet->ip[1], (unsigned char)packet->ip[0], packet->port); + mir_snprintf(temp, SIZEOF(temp), "%d.%d.%d.%d:%d", (unsigned char)packet->ip[3], (unsigned char)packet->ip[2], (unsigned char)packet->ip[1], (unsigned char)packet->ip[0], packet->port); db_set_s(NULL, protocolname, "VServerIP", temp); //namen jeh nach id schreiben switch (packet->gameid) { diff --git a/protocols/Xfire/src/addgamedialog.cpp b/protocols/Xfire/src/addgamedialog.cpp index be2fae8617..7d1aefb1c0 100644 --- a/protocols/Xfire/src/addgamedialog.cpp +++ b/protocols/Xfire/src/addgamedialog.cpp @@ -144,12 +144,12 @@ static void FillGameList(LPVOID hwndDlg) { if (z2 != zahlbuffer2) { listentry.gameid = MAKELONG(gameid, atoi(zahlbuffer2)); - mir_snprintf(gameidtemp, 10, "%d_%d", gameid, atoi(zahlbuffer2)); + mir_snprintf(gameidtemp, SIZEOF(gameidtemp), "%d_%d", gameid, atoi(zahlbuffer2)); } else { listentry.gameid = gameid; - mir_snprintf(gameidtemp, 10, "%d", gameid); + mir_snprintf(gameidtemp, SIZEOF(gameidtemp), "%d", gameid); } @@ -345,13 +345,13 @@ INT_PTR CALLBACK DlgAddGameProc(HWND hwndDlg, int gameid2 = HIWORD(gameids); if (gameid2 != 0) - mir_snprintf(gameidtemp, 10, "%d_%d", gameid1, gameid2); + mir_snprintf(gameidtemp, SIZEOF(gameidtemp), "%d_%d", gameid1, gameid2); else - mir_snprintf(gameidtemp, 10, "%d", gameid1); + mir_snprintf(gameidtemp, SIZEOF(gameidtemp), "%d", gameid1); //spielnamen holen if (xfire_GetPrivateProfileString(gameidtemp, "LongName", "", ret, 512, inipath)) { - mir_snprintf(gameidtemp, 10, "%d", gameid1); + mir_snprintf(gameidtemp, SIZEOF(gameidtemp), "%d", gameid1); //einige felder vorbelegen SetDlgItemTextA(hPage, IDC_ADD_NAME, ret); @@ -389,9 +389,9 @@ INT_PTR CALLBACK DlgAddGameProc(HWND hwndDlg, char ret[512]; if (gameid2 != 0) - mir_snprintf(gameidtemp, 10, "%d_%d", gameid1, gameid2); + mir_snprintf(gameidtemp, SIZEOF(gameidtemp), "%d_%d", gameid1, gameid2); else - mir_snprintf(gameidtemp, 10, "%d", gameid1); + mir_snprintf(gameidtemp, SIZEOF(gameidtemp), "%d", gameid1); //neuen gameeintrag anlegen Xfire_game* newgame = new Xfire_game(); diff --git a/protocols/Xfire/src/all_statusmsg.cpp b/protocols/Xfire/src/all_statusmsg.cpp index e542806744..46ec481c85 100644 --- a/protocols/Xfire/src/all_statusmsg.cpp +++ b/protocols/Xfire/src/all_statusmsg.cpp @@ -63,8 +63,8 @@ BOOL BackupStatusMsg() { statusid = CallProtoService(temp[i]->szModuleName, PS_GETSTATUS, 0, 0); XFireLog("Get Status of %s ...", temp[i]->szModuleName); - char ttemp[128] = ""; - mir_snprintf(ttemp, 128, "%s%s", temp[i]->szModuleName, PS_SETAWAYMSG); + char ttemp[128]; + mir_snprintf(ttemp, SIZEOF(ttemp), "%s%s", temp[i]->szModuleName, PS_SETAWAYMSG); //xfire wird geskipped, offline prots und invs prots auch, und locked status prots auch if (!temp[i]->bIsEnabled || statusid == ID_STATUS_INVISIBLE || statusid == ID_STATUS_OFFLINE || !mir_strcmpi(temp[i]->szModuleName, protocolname) || !ServiceExists(ttemp) || db_get_b(NULL, temp[i]->szModuleName, "LockMainStatus", 0) == 1) diff --git a/protocols/Xfire/src/buddylist.cpp b/protocols/Xfire/src/buddylist.cpp index 315c3e2a6e..ac3bfbf608 100644 --- a/protocols/Xfire/src/buddylist.cpp +++ b/protocols/Xfire/src/buddylist.cpp @@ -146,7 +146,7 @@ namespace xfirelib { /* ## buddies im miranda verarbietn */ char temp[255]; char * dummy; - mir_snprintf(temp,255,"Clan_%d",entry->clanid); + mir_snprintf(temp,SIZEOF(temp),"Clan_%d",entry->clanid); DBVARIANT dbv; if (!db_get(NULL,protocolname,temp,&dbv)) diff --git a/protocols/Xfire/src/iniupdater.cpp b/protocols/Xfire/src/iniupdater.cpp index 2f8ebe6ea9..f5f1e97aeb 100644 --- a/protocols/Xfire/src/iniupdater.cpp +++ b/protocols/Xfire/src/iniupdater.cpp @@ -61,7 +61,7 @@ void UpdateMyXFireIni(LPVOID dummy) { strcat(file2, "xfire_games.ini"); strcat(file3, "xfire_games.old"); - mir_snprintf(request, 1024, "%s%d", INI_URLREQUEST, getfilesize(file2)); + mir_snprintf(request, SIZEOF(request), "%s%d", INI_URLREQUEST, getfilesize(file2)); if (CheckWWWContent(request)) { @@ -101,7 +101,7 @@ void UpdateMyIcons(LPVOID dummy) { strcat(file2, "icons.dll"); strcat(file3, "icons.old"); - mir_snprintf(request, 1024, "%s%d", ICO_URLREQUEST, getfilesize(file2)); + mir_snprintf(request, SIZEOF(request), "%s%d", ICO_URLREQUEST, getfilesize(file2)); if (CheckWWWContent(request)) { diff --git a/protocols/Xfire/src/main.cpp b/protocols/Xfire/src/main.cpp index 748e007aaa..99be8112ac 100644 --- a/protocols/Xfire/src/main.cpp +++ b/protocols/Xfire/src/main.cpp @@ -3081,13 +3081,13 @@ INT_PTR SearchAddtoList(WPARAM wParam, LPARAM lParam) void CreateGroup(char*grpn, char*field) { DBVARIANT dbv; - char* grp[255]; + char grp[255]; int val = db_get_b(NULL, protocolname, field, 0); if (val == 0) { - strcpy_s((char*)grp, 255, grpn);//((char*)clan->name[i].c_str()); + strcpy_s(grp, SIZEOF(grp), grpn);//((char*)clan->name[i].c_str()); } else { @@ -3097,12 +3097,12 @@ void CreateGroup(char*grpn, char*field) { db_get_s(NULL, "CListGroups", temp, &dbv); if (dbv.pszVal != NULL) { - mir_snprintf((char*)grp, 255, "%s\\%s", &dbv.pszVal[1], (char*)grpn); + mir_snprintf(grp, SIZEOF(grp), "%s\\%s", &dbv.pszVal[1], grpn); db_free(&dbv); } else //gruppe existiert nciht mehr, auf root alles legen { - strcpy_s((char*)grp, 255, grpn); + strcpy_s(grp, SIZEOF(grp), grpn); db_set_b(NULL, protocolname, field, 0); } } @@ -3126,7 +3126,7 @@ void CreateGroup(char*grpn, char*field) { db_free(&dbv); } strcpy_s(group, 255, "D"); - strcat_s(group, 255, (char*)grp); + strcat_s(group, 255, grp); group[0] = 1 | GROUPF_EXPANDED; mir_snprintf(temp, SIZEOF(temp), "%d", i + 1); db_set_s(NULL, "CListGroups", temp, group); diff --git a/protocols/Xfire/src/userdetails.cpp b/protocols/Xfire/src/userdetails.cpp index 5134172a2c..7f23afb3c7 100644 --- a/protocols/Xfire/src/userdetails.cpp +++ b/protocols/Xfire/src/userdetails.cpp @@ -380,30 +380,30 @@ char status[256]=""; char game[512]=""; if (!db_get(hContact,"ContactPhoto","File",&dbv)) { -mir_snprintf(img,256,"",dbv.pszVal); +mir_snprintf(img,SIZEOF(img),"",dbv.pszVal); db_free(&dbv); } if (!db_get(hContact,protocolname,"Username",&dbv)) { -mir_snprintf(username,256,"Username: %s
",dbv.pszVal); +mir_snprintf(username,SIZEOF(username),"Username: %s
",dbv.pszVal); db_free(&dbv); } if (!db_get(hContact,protocolname,"Nick",&dbv)) { -mir_snprintf(nick,256,"Nick: %s
",dbv.pszVal); +mir_snprintf(nick,SIZEOF(nick),"Nick: %s
",dbv.pszVal); db_free(&dbv); } if (!db_get(hContact,protocolname,"XStatusMsg",&dbv)) { -mir_snprintf(status,256,"Status: %s
",dbv.pszVal); +mir_snprintf(status,SIZEOF(status),"Status: %s
",dbv.pszVal); db_free(&dbv); } if (!db_get(hContact,protocolname,"RGame",&dbv)) { -mir_snprintf(game,512,"
Spiel
%s
",dbv.pszVal); +mir_snprintf(game,SIZEOF(game),"
Spiel
%s
",dbv.pszVal); db_free(&dbv); } -mir_snprintf(profil,2056,"mshtml:
%s%s%s%s
%s%s
",img,username,nick,status,game); +mir_snprintf(profil,SIZEOF(profil),"mshtml:
%s%s%s%s
%s%s
",img,username,nick,status,game); HWND hWnd = ::CreateWindow("AtlAxWin", profil, WS_CHILD|WS_VISIBLE, 0, 0, 334, 249, hwndDlg, NULL, ::GetModuleHandle(NULL), NULL); -- cgit v1.2.3