From 03e3e4ebe0fee7bbe8014014b77a21d22cc090a8 Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@4f64403b-2f21-0410-a795-97e2b3489a10> Date: Tue, 6 Apr 2010 00:55:48 +0000 Subject: Fixed translation issue Removed unneeded/duplicated code (thus shaved few more kb from the dll) git-svn-id: https://server.scottellis.com.au/svn/mim_plugs@496 4f64403b-2f21-0410-a795-97e2b3489a10 --- updater/conf_dialog.cpp | 12 +-- updater/extern.cpp | 8 +- updater/icons.cpp | 2 +- updater/options.cpp | 8 +- updater/resource.h | 2 +- updater/services.cpp | 32 ++++--- updater/socket.cpp | 16 ++-- updater/updater.cpp | 4 +- updater/updater.dsp | 8 +- updater/updater_9.vcproj | 219 +++-------------------------------------------- updater/utils.cpp | 52 ++--------- updater/utils.h | 3 - updater/xmldata.cpp | 24 +++--- 13 files changed, 77 insertions(+), 313 deletions(-) (limited to 'updater') diff --git a/updater/conf_dialog.cpp b/updater/conf_dialog.cpp index 9c6bdba..cbd6887 100644 --- a/updater/conf_dialog.cpp +++ b/updater/conf_dialog.cpp @@ -70,23 +70,23 @@ INT_PTR CALLBACK DlgProcConfirm(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP lvI.mask = LVIF_TEXT | LVIF_PARAM;// | LVIF_IMAGE; lvI.iSubItem = 0; lvI.lParam = (LPARAM)&todo[i]; - lvI.pszText = TranslateTS(temp_str = GetTString(todo[i].update.szComponentName)); + lvI.pszText = (temp_str = GetTString(todo[i].update.szComponentName)); lvI.iItem = ListView_InsertItem(GetDlgItem(hwndDlg, IDC_LIST_UPDATES), &lvI); - free(temp_str); + mir_free(temp_str); lvI.mask = LVIF_TEXT;// | LVIF_IMAGE; lvI.iSubItem = 1; //lvI.pszText = LPSTR_TEXTCALLBACK; //i->newVersion; - lvI.pszText = TranslateTS(temp_str = GetTString(((UpdateInternal *)lvI.lParam)->newVersion)); + lvI.pszText = (temp_str = GetTString(((UpdateInternal *)lvI.lParam)->newVersion)); ListView_SetItem(GetDlgItem(hwndDlg, IDC_LIST_UPDATES), &lvI); - free(temp_str); + mir_free(temp_str); lvI.iSubItem = 2; //lvI.pszText = LPSTR_TEXTCALLBACK; //i->newVersion; - lvI.pszText = TranslateTS(temp_str = GetTString((char *)((UpdateInternal *)lvI.lParam)->update.pbVersion)); + lvI.pszText = (temp_str = GetTString((char *)((UpdateInternal *)lvI.lParam)->update.pbVersion)); ListView_SetItem(GetDlgItem(hwndDlg, IDC_LIST_UPDATES), &lvI); - free(temp_str); + mir_free(temp_str); //MessageBox(0, i->newVersion, //"Version", MB_OK); //i->update.szComponentName, MB_OK); diff --git a/updater/extern.cpp b/updater/extern.cpp index 565ba63..629d1eb 100644 --- a/updater/extern.cpp +++ b/updater/extern.cpp @@ -23,7 +23,7 @@ int ExternProcess(bool restart) { // write data to file for external process to use HANDLE hDatFile = CreateFile(data_filename, GENERIC_WRITE, FILE_SHARE_WRITE, 0, CREATE_ALWAYS, 0, 0); if(hDatFile == INVALID_HANDLE_VALUE) { - //MessageBox(0, Translate("Could not create data file for restart."), Translate("Error"), MB_OK | MB_ICONERROR); + //MessageBox(0, TranslateT("Could not create data file for restart."), TranslateT("Error"), MB_OK | MB_ICONERROR); ShowError(TranslateT("Could not create data file for restart")); return 1; } @@ -88,7 +88,7 @@ int ExternProcess(bool restart) { /* if(!CallService(MS_SYSTEM_OKTOEXIT,0,0)) { DeleteFile(data_filename); - MessageBox(0, Translate("Miranda's not 'OK TO EXIT'."), Translate("Error"), MB_OK | MB_ICONERROR); + MessageBox(0, TranslateT("Miranda's not 'OK TO EXIT'."), TranslateT("Error"), MB_OK | MB_ICONERROR); return; } */ @@ -454,8 +454,8 @@ void CALLBACK ExternalUpdate(HWND hwnd, HINSTANCE hInstance, LPSTR lpszCmdLine, #endif TCHAR szArgs[MAX_PATH], *temp_str; //wsprintf(szArgs, "\"%s\" \"%s\"", db_path, db_name); - mir_sntprintf(szArgs, SIZEOF(szArgs), _T("\"%s\" \"%s\""), mir_exe, temp_str = GetTStringACP(db_path)); // includes name, dummy instead of executable? - free(temp_str); + mir_sntprintf(szArgs, SIZEOF(szArgs), _T("\"%s\" \"%s\""), mir_exe, temp_str = mir_a2t(db_path)); // includes name, dummy instead of executable? + mir_free(temp_str); //wsprintf(szArgs, "\"%s\"", db_name); diff --git a/updater/icons.cpp b/updater/icons.cpp index a8349c5..9b8c3b5 100644 --- a/updater/icons.cpp +++ b/updater/icons.cpp @@ -78,7 +78,7 @@ void InitIcons(void) for (i = 0; i < sizeof(iconList) / sizeof(IconStruct); ++i) { - sid.pszDescription = Translate(iconList[i].szDescr); + sid.pszDescription = iconList[i].szDescr; sid.pszName = iconList[i].szName; sid.iDefaultIndex = -iconList[i].defIconID; CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid); diff --git a/updater/options.cpp b/updater/options.cpp index 847a66f..f753997 100644 --- a/updater/options.cpp +++ b/updater/options.cpp @@ -17,7 +17,7 @@ void add_restart_menu_item() { menu.flags = CMIM_ALL; menu.hIcon = LoadIconEx(I_RSTRT); - menu.pszName = Translate("Restart"); + menu.pszName = "Restart"; menu.pszService= MS_UPDATE_MENURESTART; menu.position = 2000099900; hMainMenuItemRestart = (HANDLE)CallService(MS_CLIST_ADDMAINMENUITEM,0,(LPARAM)&menu); @@ -31,7 +31,7 @@ void add_update_and_exit_menu_item() { menu.flags = CMIM_ALL; menu.hIcon = LoadIconEx(I_CHKUPDEXT); - menu.pszName = Translate("Update and Exit"); + menu.pszName = "Update and Exit"; menu.pszService= MS_UPDATE_MENUUPDATEANDEXIT; menu.position = 2000099901; hMainMenuItemUpdateAndExit = (HANDLE)CallService(MS_CLIST_ADDMAINMENUITEM,0,(LPARAM)&menu); @@ -62,9 +62,9 @@ static int EnumerateFuncFillList(char *szComponentName, UpdateOptions *update_op lvI.lParam = (update_options->enabled ? 1 : 0) + (update_options->use_beta ? 2 : 0) + (update_options->fixed ? 4 : 0); lvI.iSubItem = 0; - lvI.pszText = TranslateTS(temp_str = GetTString(szComponentName)); + lvI.pszText = (temp_str = GetTString(szComponentName)); lvI.iItem = ListView_InsertItem(GetDlgItem(hwndDlg, IDC_LST_REGISTERED), &lvI); - free(temp_str); + mir_free(temp_str); lvI.mask = LVIF_TEXT; lvI.iSubItem = 1; diff --git a/updater/resource.h b/updater/resource.h index d8252f5..35617cc 100644 --- a/updater/resource.h +++ b/updater/resource.h @@ -50,12 +50,12 @@ #define IDC_BTN_SELECTDLLS2 1030 #define IDC_BTN_SELECTINV 1030 #define IDC_BTN_SELECTALL 1031 -#define IDC_STATIC -1 // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NO_MFC 1 #define _APS_NEXT_RESOURCE_VALUE 129 #define _APS_NEXT_COMMAND_VALUE 40001 #define _APS_NEXT_CONTROL_VALUE 1030 diff --git a/updater/services.cpp b/updater/services.cpp index 4b232b1..b5c8a88 100644 --- a/updater/services.cpp +++ b/updater/services.cpp @@ -63,11 +63,11 @@ bool DownloadUpdates(UpdateList &todo, FilenameMap *map, bool dlls_only) { } if(download) { - mir_sntprintf(msg, SIZEOF(msg), TranslateT("Downloading plugin: %s"), TranslateTS(temp_str = GetTString(todo[index].update.szComponentName))); - free(temp_str); + mir_sntprintf(msg, SIZEOF(msg), TranslateT("Downloading plugin: %s"), (temp_str = GetTString(todo[index].update.szComponentName))); + mir_free(temp_str); } else { - mir_sntprintf(msg, SIZEOF(msg), TranslateT("Skipping plugin: %s"), TranslateTS(temp_str = GetTString(todo[index].update.szComponentName))); - free(temp_str); + mir_sntprintf(msg, SIZEOF(msg), TranslateT("Skipping plugin: %s"), (temp_str = GetTString(todo[index].update.szComponentName))); + mir_free(temp_str); } if(!use_popup) { @@ -227,11 +227,11 @@ void CheckForUpdatesWorker(void *param) { for(index = 0; index < count; index++) { if(update_list2[index].update_options.enabled) { - mir_sntprintf(msg, SIZEOF(msg), TranslateT("Checking plugin: %s"), TranslateTS(temp_str = GetTString(update_list2[index].update.szComponentName))); - free(temp_str); + mir_sntprintf(msg, SIZEOF(msg), TranslateT("Checking plugin: %s"), (temp_str = GetTString(update_list2[index].update.szComponentName))); + mir_free(temp_str); } else { - mir_sntprintf(msg, SIZEOF(msg), TranslateT("Skipping plugin: %s"), TranslateTS(temp_str = GetTString(update_list2[index].update.szComponentName))); - free(temp_str); + mir_sntprintf(msg, SIZEOF(msg), TranslateT("Skipping plugin: %s"), (temp_str = GetTString(update_list2[index].update.szComponentName))); + mir_free(temp_str); } if(!use_popup) { @@ -414,13 +414,13 @@ void SaveUpdateOptions(char *szComponentName, UpdateOptions *update_options) { INT_PTR SetUpdateOptions(WPARAM wParam, LPARAM lParam) { char *szComponentName = (char *)wParam; UpdateOptions *uo = (UpdateOptions *)lParam; - TCHAR *temp1 = 0, *temp2 = 0; + TCHAR *temp1 = 0; bool found = false; EnterCriticalSection(&list_cs); for (int i=0; iresultCode); ShowError(buff); - char *ts = GetAString(buff); + char *ts = mir_t2a(buff); NLog(ts); - free(ts); + mir_free(ts); } CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)resp); @@ -186,9 +186,9 @@ bool GetFile(char *url, TCHAR *temp_folder, char *plugin_name, char *version, bo FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 0, err, 0, buff + len, 512 - len, 0); ShowError(buff); - char *ts = GetAString(buff); + char *ts = mir_t2a(buff); NLog(ts); - free(ts); + mir_free(ts); } } diff --git a/updater/updater.cpp b/updater/updater.cpp index d2ee45a..db25aad 100644 --- a/updater/updater.cpp +++ b/updater/updater.cpp @@ -67,8 +67,8 @@ void InitNetlib() { NETLIBUSER nl_user = {0}; nl_user.cbSize = sizeof(nl_user); nl_user.szSettingsModule = MODULE; - nl_user.flags = NUF_OUTGOING | NUF_HTTPCONNS; - nl_user.szDescriptiveName = Translate("Updater connection"); + nl_user.flags = NUF_OUTGOING | NUF_HTTPCONNS | NUF_TCHAR; + nl_user.ptszDescriptiveName = TranslateT("Updater connection"); hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nl_user); } diff --git a/updater/updater.dsp b/updater/updater.dsp index b5baf79..fb19bbb 100644 --- a/updater/updater.dsp +++ b/updater/updater.dsp @@ -45,7 +45,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 1 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "UPDATER_EXPORTS" /YX /FD /c -# ADD CPP /nologo /MT /W3 /GX /O1 /I "../../include" /I "../../../include" /I "zbin" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "UPDATER_EXPORTS" /FR /YX /FD /c +# ADD CPP /nologo /MT /W3 /GX /O1 /I "../../include" /I "../../../include" /I "zbin" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BZ_NO_STDIO" /D "UPDATER_EXPORTS" /FR /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "NDEBUG" @@ -72,7 +72,7 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "UPDATER_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../../include" /I "../../../include" /I "zbin" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "UPDATER_EXPORTS" /FR /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../../include" /I "../../../include" /I "zbin" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BZ_NO_STDIO" /D "UPDATER_EXPORTS" /FR /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" @@ -99,7 +99,7 @@ LINK32=link.exe # PROP Ignore_Export_Lib 1 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O1 /I "../../include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "UPDATER_EXPORTS" /FR /YX /FD /c -# ADD CPP /nologo /MD /W3 /O1 /I "../../../include" /I "." /I "zbin" /I "../../include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /D "_UNICODE" /D "UNICODE" /FR /YX /FD /c +# ADD CPP /nologo /MD /W3 /O1 /I "../../../include" /I "." /I "zbin" /I "../../include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /D "BZ_NO_STDIO" /D "_UNICODE" /D "UNICODE" /FR /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0xc09 /d "NDEBUG" @@ -128,7 +128,7 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../../include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "UPDATER_EXPORTS" /FR /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../../include" /I "../../../include" /I "zbin" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "UPDATER_EXPORTS" /D "_UNICODE" /D "UNICODE" /FR /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../../include" /I "../../../include" /I "zbin" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BZ_NO_STDIO" /D "UPDATER_EXPORTS" /D "_UNICODE" /D "UNICODE" /FR /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0xc09 /d "_DEBUG" diff --git a/updater/updater_9.vcproj b/updater/updater_9.vcproj index 7feb7e6..80262eb 100644 --- a/updater/updater_9.vcproj +++ b/updater/updater_9.vcproj @@ -52,7 +52,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="zbin;../../include;..\..\..\include" - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UPDATER_EXPORTS;UNICODE" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;BZ_NO_STDIO;UPDATER_EXPORTS;UNICODE" BasicRuntimeChecks="3" RuntimeLibrary="3" PrecompiledHeaderThrough="common.h" @@ -146,7 +146,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="zbin;../../include;..\..\..\include" - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;UPDATER_EXPORTS;_CRT_SECURE_NO_WARNINGS" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;BZ_NO_STDIO;UPDATER_EXPORTS;_CRT_SECURE_NO_WARNINGS" BasicRuntimeChecks="3" RuntimeLibrary="3" PrecompiledHeaderThrough="common.h" @@ -242,7 +242,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="zbin;../../include;..\..\..\include" - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;UPDATER_EXPORTS" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;BZ_NO_STDIO;UPDATER_EXPORTS" BasicRuntimeChecks="3" RuntimeLibrary="3" PrecompiledHeaderThrough="common.h" @@ -336,7 +336,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="zbin;../../include;..\..\..\include" - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;UPDATER_EXPORTS" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;BZ_NO_STDIO;UPDATER_EXPORTS" BasicRuntimeChecks="3" RuntimeLibrary="3" PrecompiledHeaderThrough="common.h" @@ -435,7 +435,7 @@ EnableIntrinsicFunctions="true" FavorSizeOrSpeed="2" AdditionalIncludeDirectories="zbin;../../include;..\..\..\include" - PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;UPDATER_EXPORTS;UNICODE" + PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;BZ_NO_STDIO;UPDATER_EXPORTS;UNICODE" StringPooling="true" RuntimeLibrary="2" BufferSecurityCheck="false" @@ -537,7 +537,7 @@ EnableIntrinsicFunctions="true" FavorSizeOrSpeed="2" AdditionalIncludeDirectories="zbin;../../include;..\..\..\include" - PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;UPDATER_EXPORTS;_CRT_SECURE_NO_WARNINGS" + PreprocessorDefinitions="BZ_NO_STDIO;WIN32;NDEBUG;_WINDOWS;_USRDLL;UPDATER_EXPORTS;_CRT_SECURE_NO_WARNINGS" StringPooling="true" ExceptionHandling="0" RuntimeLibrary="2" @@ -638,7 +638,7 @@ EnableIntrinsicFunctions="true" FavorSizeOrSpeed="2" AdditionalIncludeDirectories="zbin;../../include;..\..\..\include" - PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;UPDATER_EXPORTS" + PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;BZ_NO_STDIO;UPDATER_EXPORTS" StringPooling="true" RuntimeLibrary="2" BufferSecurityCheck="false" @@ -741,7 +741,7 @@ EnableIntrinsicFunctions="true" FavorSizeOrSpeed="2" AdditionalIncludeDirectories="zbin;../../include;..\..\..\include" - PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;UPDATER_EXPORTS" + PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;BZ_NO_STDIO;UPDATER_EXPORTS" StringPooling="true" RuntimeLibrary="2" BufferSecurityCheck="false" @@ -2223,7 +2223,6 @@ > @@ -2277,7 +2273,6 @@ > @@ -2287,7 +2282,6 @@ > @@ -2304,92 +2298,8 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -2559,7 +2385,7 @@ > @@ -2583,7 +2409,6 @@ > @@ -2637,7 +2459,6 @@ > @@ -2647,7 +2468,6 @@ > @@ -2671,7 +2491,6 @@ > @@ -2725,7 +2541,6 @@ > @@ -2735,7 +2550,6 @@ > @@ -2759,7 +2573,6 @@ > @@ -2823,7 +2633,6 @@ > diff --git a/updater/utils.cpp b/updater/utils.cpp index 5be5897..daed5a8 100644 --- a/updater/utils.cpp +++ b/updater/utils.cpp @@ -94,53 +94,11 @@ bool CreatePath(const TCHAR *path) { */ } -// must 'free' return val -TCHAR *GetTString(const char *asc) { - if(!asc) return 0; - -#ifdef _UNICODE - wchar_t *ret; - int code_page = CP_ACP; - if(ServiceExists(MS_LANGPACK_GETCODEPAGE)) code_page = CallService(MS_LANGPACK_GETCODEPAGE, 0, 0); - int size = MultiByteToWideChar(code_page, MB_PRECOMPOSED, asc, -1, 0, 0); - ret = (wchar_t *)malloc(sizeof(wchar_t) * size); - MultiByteToWideChar(code_page, MB_PRECOMPOSED, asc, -1, ret, size); - return ret; -#else - return _strdup(asc); -#endif -} - -TCHAR *GetTStringACP(const char *asc) { - if(!asc) return 0; - -#ifdef _UNICODE - wchar_t *ret; - - int size = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, asc, -1, 0, 0); - ret = (wchar_t *)malloc(sizeof(wchar_t) * size); - MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, asc, -1, ret, size); - return ret; -#else - return _strdup(asc); -#endif -} - -char *GetAString(const TCHAR *t) { - if(!t) return 0; - -#ifdef _UNICODE - char *ret; - - int code_page = CP_ACP; - if(ServiceExists(MS_LANGPACK_GETCODEPAGE)) code_page = CallService(MS_LANGPACK_GETCODEPAGE, 0, 0); - int size = WideCharToMultiByte(code_page, 0, t, -1, 0, 0, 0, 0); - ret = (char *)malloc(size); - WideCharToMultiByte(code_page, 0, t, -1, ret, size, 0, 0); - return ret; -#else - return _strdup(t); -#endif +// must 'mir_free' return val +TCHAR *GetTString(const char *asc) +{ + if (!asc) return NULL; + return (TCHAR*)CallService(MS_LANGPACK_PCHARTOTCHAR, 0, (LPARAM)asc); } void RemoveFolder(const TCHAR *src_folder) { diff --git a/updater/utils.h b/updater/utils.h index 0a46518..28dfa1e 100644 --- a/updater/utils.h +++ b/updater/utils.h @@ -12,9 +12,6 @@ bool CreatePath(const TCHAR *path); // must 'free' return val TCHAR *GetTString(const char *asc); // use system default codepage - called from external process where langpack codepage is not (easily) accessible -TCHAR *GetTStringACP(const char *asc); - -char *GetAString(const TCHAR *t); void RemoveFolder(const TCHAR *src_folder); diff --git a/updater/xmldata.cpp b/updater/xmldata.cpp index bffba57..46c4449 100644 --- a/updater/xmldata.cpp +++ b/updater/xmldata.cpp @@ -28,7 +28,7 @@ bool OldXMLDataExists(const Category cat) { _tcscat(xml_data_filename, _T("\\")); _tcscat(xml_data_filename, ts = GetTString(category_files[cat])); _tcscat(xml_data_filename, _T(".xml")); - free(ts); + mir_free(ts); HANDLE hDataFile = CreateFile(xml_data_filename, 0, 0, 0, OPEN_EXISTING, 0, 0); if(hDataFile != INVALID_HANDLE_VALUE) { @@ -48,7 +48,7 @@ long OldXMLDataAge(const Category cat) { _tcscat(xml_data_filename, _T("\\")); _tcscat(xml_data_filename, ts = GetTString(category_files[cat])); _tcscat(xml_data_filename, _T(".xml")); - free(ts); + mir_free(ts); HANDLE hDataFile = CreateFile(xml_data_filename, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0); if(hDataFile != INVALID_HANDLE_VALUE) { @@ -84,7 +84,7 @@ bool LoadOldXMLData(const Category cat, bool update_age) { _tcscat(xml_data_filename, _T("\\")); _tcscat(xml_data_filename, ts = GetTString(category_files[cat])); _tcscat(xml_data_filename, _T(".xml")); - free(ts); + mir_free(ts); if(pData[cat]) free(pData[cat]); pData[cat] = 0; @@ -132,7 +132,7 @@ bool SaveXMLData(const Category cat) { _tcscat(xml_data_filename, _T("\\")); _tcscat(xml_data_filename, ts = GetTString(category_files[cat])); _tcscat(xml_data_filename, _T(".xml")); - free(ts); + mir_free(ts); if(!CreatePath(options.data_folder)) { return false; @@ -152,6 +152,8 @@ bool SaveXMLData(const Category cat) { return false; } +extern "C" void bz_internal_error ( int errcode ){} + bool bz2_decompress_xml(char *in_data, int in_data_length, BYTE **pDat, int *data_length) { const int BLOCKSIZE = 1024 * 100; @@ -215,7 +217,7 @@ bool bz2_decompress_xml(char *in_data, int in_data_length, BYTE **pDat, int *dat bool UpdateXMLData(const Category cat, const char *redirect_url /*= 0*/, int recurse_count /*=0*/) { if(recurse_count > MAX_REDIRECT_RECURSE) { - PUShowMessage(Translate("Updater: Error getting data - too many redirects"), SM_WARNING); + PUShowMessageT(TranslateT("Updater: Error getting data - too many redirects"), SM_WARNING); return false; } @@ -278,13 +280,13 @@ bool UpdateXMLData(const Category cat, const char *redirect_url /*= 0*/, int rec int len = mir_sntprintf(buff, SIZEOF(buff), TranslateT("Failed to download XML data: ")); FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 0, err, 0, buff + len, 512 - len, 0); ShowError(buff); - //MessageBox(0, buff + len, Translate("Updater: Error Downloading XML Data"), MB_OK | MB_ICONWARNING); - char *ts = GetAString(buff); + //MessageBox(0, buff + len, TranslateT("Updater: Error Downloading XML Data"), MB_OK | MB_ICONWARNING); + char *ts = mir_t2a(buff); NLog(ts); - free(ts); + mir_free(ts); } else { ShowError(TranslateT("Failed to download XML data - Response is NULL")); - //MessageBox(0, "Error downloading XML data...\nResponse is NULL"), Translate("Updater Error"), MB_OK | MB_ICONWARNING); + //MessageBox(0, TranslateT("Error downloading XML data...\nResponse is NULL"), Translate("Updater Error"), MB_OK | MB_ICONWARNING); NLog("Failed to download XML data - Response is NULL"); } return LoadOldXMLData(cat, false); @@ -322,9 +324,9 @@ bool UpdateXMLData(const Category cat, const char *redirect_url /*= 0*/, int rec mir_sntprintf(buff, SIZEOF(buff), TranslateT("Failed to download XML data - Invalid response, code %d"), resp->resultCode); ShowError(buff); - char *ts = GetAString(buff); + char *ts = mir_t2a(buff); NLog(ts); - free(ts); + mir_free(ts); CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)resp); resp = 0; return LoadOldXMLData(cat, false); -- cgit v1.2.3