diff options
Diffstat (limited to 'plugins/Dbx_mmap_SA')
-rw-r--r-- | plugins/Dbx_mmap_SA/Dbtool/cleaning.cpp | 2 | ||||
-rw-r--r-- | plugins/Dbx_mmap_SA/Dbtool/dbtool.h | 17 | ||||
-rw-r--r-- | plugins/Dbx_mmap_SA/Dbtool/dbtool_sa_10.vcxproj.filters | 3 | ||||
-rw-r--r-- | plugins/Dbx_mmap_SA/Dbtool/encryption.cpp | 2 | ||||
-rw-r--r-- | plugins/Dbx_mmap_SA/Dbtool/eventchain.cpp | 2 | ||||
-rw-r--r-- | plugins/Dbx_mmap_SA/Dbtool/fileaccess.cpp | 2 | ||||
-rw-r--r-- | plugins/Dbx_mmap_SA/Dbtool/finished.cpp | 2 | ||||
-rw-r--r-- | plugins/Dbx_mmap_SA/Dbtool/langpack.cpp | 388 | ||||
-rw-r--r-- | plugins/Dbx_mmap_SA/Dbtool/main.cpp | 2 | ||||
-rw-r--r-- | plugins/Dbx_mmap_SA/Dbtool/openerror.cpp | 2 | ||||
-rw-r--r-- | plugins/Dbx_mmap_SA/Dbtool/progress.cpp | 2 | ||||
-rw-r--r-- | plugins/Dbx_mmap_SA/Dbtool/selectdb.cpp | 2 | ||||
-rw-r--r-- | plugins/Dbx_mmap_SA/Dbtool/utf.cpp | 376 | ||||
-rw-r--r-- | plugins/Dbx_mmap_SA/Dbtool/wizard.cpp | 5 | ||||
-rw-r--r-- | plugins/Dbx_mmap_SA/commonheaders.h | 3 | ||||
-rw-r--r-- | plugins/Dbx_mmap_SA/dialogs.cpp | 2 |
16 files changed, 13 insertions, 799 deletions
diff --git a/plugins/Dbx_mmap_SA/Dbtool/cleaning.cpp b/plugins/Dbx_mmap_SA/Dbtool/cleaning.cpp index efbbde1640..a16a11e7ac 100644 --- a/plugins/Dbx_mmap_SA/Dbtool/cleaning.cpp +++ b/plugins/Dbx_mmap_SA/Dbtool/cleaning.cpp @@ -29,7 +29,7 @@ INT_PTR CALLBACK CleaningDlgProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM lPa EnableWindow(GetDlgItem(hdlg,IDC_ERASEHISTORY),!opts.bAggressive);
CheckDlgButton(hdlg,IDC_MARKREAD,opts.bMarkRead);
CheckDlgButton(hdlg,IDC_CONVERTUTF,opts.bConvertUtf);
- TranslateDialog(hdlg);
+ TranslateDialogDefault(hdlg);
return TRUE;
case WZN_PAGECHANGING:
opts.bEraseHistory=IsDlgButtonChecked(hdlg,IDC_ERASEHISTORY)&&!opts.bAggressive;
diff --git a/plugins/Dbx_mmap_SA/Dbtool/dbtool.h b/plugins/Dbx_mmap_SA/Dbtool/dbtool.h index 63b6b4ccf1..dd6af38cd5 100644 --- a/plugins/Dbx_mmap_SA/Dbtool/dbtool.h +++ b/plugins/Dbx_mmap_SA/Dbtool/dbtool.h @@ -34,9 +34,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <time.h>
#include <win2k.h>
-//#include <newpluginapi.h> // Only needed to keep m_database.h happy
-#define CallService(a,b,c) 1
-
#include "m_database.h"
#include "database.h" // Note: This is a copy of database.h from the Miranda IM v0.3 tree.
// Remember to update this when releasing new dbtool versions.
@@ -104,18 +101,4 @@ DWORD ConvertModuleNameOfs(DWORD ofsOld); void FreeModuleChain();
extern BOOL bEncrypted;
-int TranslateDialog(HWND hwndDlg);
-void LoadLangPackModule(void);
-void UnloadLangPackModule(void);
-
-char* LangPackTranslateString(const char *szEnglish, const int W);
-__inline LPSTR Translate(LPSTR source)
-{ return ( LPSTR )LangPackTranslateString( source, 0 );
-}
-
-#define TranslateT(s) (TCHAR*)LangPackTranslateString((LPCSTR)_T(s),1)
-#define TranslateTS(s) (TCHAR*)LangPackTranslateString((LPCSTR)s,1)
-
-char* Utf8DecodeCP(char* str, int codepage, wchar_t** ucs2);
-char* Utf8EncodeUcs2(const wchar_t* src);
bool is_utf8_string(const char* str);
diff --git a/plugins/Dbx_mmap_SA/Dbtool/dbtool_sa_10.vcxproj.filters b/plugins/Dbx_mmap_SA/Dbtool/dbtool_sa_10.vcxproj.filters index 202d0b374d..1c054474cd 100644 --- a/plugins/Dbx_mmap_SA/Dbtool/dbtool_sa_10.vcxproj.filters +++ b/plugins/Dbx_mmap_SA/Dbtool/dbtool_sa_10.vcxproj.filters @@ -24,9 +24,6 @@ <ClCompile Include="disk.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="langpack.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
diff --git a/plugins/Dbx_mmap_SA/Dbtool/encryption.cpp b/plugins/Dbx_mmap_SA/Dbtool/encryption.cpp index 3d00d70880..4f5c0a18b6 100644 --- a/plugins/Dbx_mmap_SA/Dbtool/encryption.cpp +++ b/plugins/Dbx_mmap_SA/Dbtool/encryption.cpp @@ -230,7 +230,7 @@ BOOL CALLBACK DlgStdInProc(HWND hDlg, UINT uMsg,WPARAM wParam,LPARAM lParam) {
HWND hwndCtrl;
// if(pluginLink && ServiceExists(MS_LANGPACK_TRANSLATEDIALOG))
- TranslateDialog(hDlg);
+ TranslateDialogDefault(hDlg);
if(lParam && !wrongPass) SetDlgItemTextA(hDlg, IDC_DBNAME, (LPCSTR)lParam);
if(wrongPass)
diff --git a/plugins/Dbx_mmap_SA/Dbtool/eventchain.cpp b/plugins/Dbx_mmap_SA/Dbtool/eventchain.cpp index 2b9ba5098a..3c9e37668a 100644 --- a/plugins/Dbx_mmap_SA/Dbtool/eventchain.cpp +++ b/plugins/Dbx_mmap_SA/Dbtool/eventchain.cpp @@ -49,7 +49,7 @@ static void ConvertOldEvent( DBEvent*& dbei ) }
if ( msglenW > 0 && msglenW <= msglen ) {
- char* utf8str = Utf8EncodeUcs2(( WCHAR* )&dbei->blob[ msglen ] );
+ char* utf8str = Utf8EncodeW(( WCHAR* )&dbei->blob[ msglen ] );
dbei->cbBlob = (DWORD)strlen( utf8str )+1;
dbei->flags |= DBEF_UTF;
if (offsetof(DBEvent,blob)+dbei->cbBlob > memsize) {
diff --git a/plugins/Dbx_mmap_SA/Dbtool/fileaccess.cpp b/plugins/Dbx_mmap_SA/Dbtool/fileaccess.cpp index 2fdd16c082..d904daf5b9 100644 --- a/plugins/Dbx_mmap_SA/Dbtool/fileaccess.cpp +++ b/plugins/Dbx_mmap_SA/Dbtool/fileaccess.cpp @@ -29,7 +29,7 @@ INT_PTR CALLBACK FileAccessDlgProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM l CheckDlgButton(hdlg,IDC_BACKUP,opts.bBackup);
CheckDlgButton(hdlg,IDC_AGGRESSIVE,opts.bAggressive);
SendMessage(hdlg,WM_COMMAND,MAKEWPARAM(IDC_CHECKONLY,BN_CLICKED),0);
- TranslateDialog(hdlg);
+ TranslateDialogDefault(hdlg);
return TRUE;
case WZN_PAGECHANGING:
opts.bCheckOnly=IsDlgButtonChecked(hdlg,IDC_CHECKONLY);
diff --git a/plugins/Dbx_mmap_SA/Dbtool/finished.cpp b/plugins/Dbx_mmap_SA/Dbtool/finished.cpp index 1716f72dd4..08d0f5c893 100644 --- a/plugins/Dbx_mmap_SA/Dbtool/finished.cpp +++ b/plugins/Dbx_mmap_SA/Dbtool/finished.cpp @@ -36,7 +36,7 @@ INT_PTR CALLBACK FinishedDlgProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM lPa SetDlgItemText(hdlg,IDC_BACKUPFILE,opts.backupFilename);
}
else ShowWindow(GetDlgItem(hdlg,IDC_STBACKUP),FALSE);
- TranslateDialog(hdlg);
+ TranslateDialogDefault(hdlg);
return TRUE;
case WM_LAUNCHMIRANDA:
if(IsDlgButtonChecked(hdlg,IDC_LAUNCHMIRANDA)) {
diff --git a/plugins/Dbx_mmap_SA/Dbtool/langpack.cpp b/plugins/Dbx_mmap_SA/Dbtool/langpack.cpp deleted file mode 100644 index 7f2627cd11..0000000000 --- a/plugins/Dbx_mmap_SA/Dbtool/langpack.cpp +++ /dev/null @@ -1,388 +0,0 @@ -/*
-
-Miranda IM: the free IM client for Microsoft* Windows*
-
-Copyright 2000-2011 Miranda ICQ/IM project,
-all portions of this codebase are copyrighted to the people
-listed in contributors.txt.
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-#include "dbtool.h"
-
-struct LangPackEntry {
- unsigned linePos;
- DWORD englishHash;
- char *english; //not currently used, the hash does everything
- char *local;
- wchar_t *wlocal;
-};
-
-struct LangPackStruct {
- TCHAR filename[MAX_PATH];
- char language[64];
- char lastModifiedUsing[64];
- char authors[256];
- char authorEmail[128];
- struct LangPackEntry *entry;
- int entryCount;
- LCID localeID;
- UINT defaultANSICp;
-} static langPack;
-
-static void TrimString(char *str)
-{
- size_t start, len = strlen(str);
- while(str[0] && (unsigned char)str[len-1] <= ' ') str[--len] = 0;
- for (start = 0; str[start] && (unsigned char)str[start] <= ' '; start++);
- memmove(str, str + start, len - start + 1);
-}
-
-static void TrimStringSimple(char *str)
-{
- size_t len = strlen(str);
- if (str[len-1] == '\n') str[--len] = '\0';
- if (str[len-1] == '\r') str[len-1] = '\0';
-}
-
-static int IsEmpty(char *str)
-{
- int i = 0;
-
- while (str[i])
- {
- if (str[i] != ' ' && str[i] != '\r' && str[i] != '\n')
- return 0;
- i++;
- }
- return 1;
-}
-
-void ConvertBackslashes(char *str, UINT fileCp)
-{
- char *pstr;
- for (pstr = str; *pstr; pstr = CharNextExA(fileCp, pstr, 0))
- {
- if ( *pstr == '\\' )
- {
- switch( pstr[1] )
- {
- case 'n': *pstr = '\n'; break;
- case 't': *pstr = '\t'; break;
- case 'r': *pstr = '\r'; break;
- default: *pstr = pstr[1]; break;
- }
- memmove(pstr+1, pstr+2, strlen(pstr+2) + 1);
- }
- }
-}
-
-#ifdef _DEBUG
-#pragma optimize( "gt", on )
-#endif
-
-// MurmurHash2
-unsigned int __fastcall hash(const void * key, unsigned int len)
-{
- // 'm' and 'r' are mixing constants generated offline.
- // They're not really 'magic', they just happen to work well.
- const unsigned int m = 0x5bd1e995;
- const int r = 24;
-
- // Initialize the hash to a 'random' value
- unsigned int h = len;
-
- // Mix 4 bytes at a time into the hash
- const unsigned char * data = (const unsigned char *)key;
-
- while(len >= 4)
- {
- unsigned int k = *(unsigned int *)data;
-
- k *= m;
- k ^= k >> r;
- k *= m;
-
- h *= m;
- h ^= k;
-
- data += 4;
- len -= 4;
- }
-
- // Handle the last few bytes of the input array
- switch(len)
- {
- case 3: h ^= data[2] << 16;
- case 2: h ^= data[1] << 8;
- case 1: h ^= data[0];
- h *= m;
- };
-
- // Do a few final mixes of the hash to ensure the last few
- // bytes are well-incorporated.
- h ^= h >> 13;
- h *= m;
- h ^= h >> 15;
-
- return h;
-}
-
-unsigned int __fastcall hashstrW(const char * key)
-{
- if (key == NULL) return 0;
- const unsigned int len = (unsigned int)wcslen((const wchar_t*)key);
- char* buf = (char*)alloca(len + 1);
- for (unsigned i = 0; i <= len ; ++i)
- buf[i] = key[i << 1];
- return hash(buf, len);
-}
-
-__inline unsigned int hashstr(const char * key)
-{
- if (key == NULL) return 0;
- const unsigned int len = (unsigned int)strlen((const char*)key);
- return hash(key, len);
-}
-
-#ifdef _DEBUG
-#pragma optimize( "", on )
-#endif
-
-static int SortLangPackHashesProc(struct LangPackEntry *arg1,struct LangPackEntry *arg2)
-{
- if(arg1->englishHash<arg2->englishHash) return -1;
- if(arg1->englishHash>arg2->englishHash) return 1;
- /* both source strings of the same hash (may not be the same string thou) put
- the one that was written first to be found first */
- if(arg1->linePos<arg2->linePos) return -1;
- if(arg1->linePos>arg2->linePos) return 1;
- return 0;
-}
-
-
-static int SortLangPackHashesProc2(struct LangPackEntry *arg1,struct LangPackEntry *arg2)
-{
- if(arg1->englishHash<arg2->englishHash) return -1;
- if(arg1->englishHash>arg2->englishHash) return 1;
- return 0;
-}
-
-static int LoadLangPack(const TCHAR *szLangPack)
-{
- FILE *fp;
- char line[4096] = "";
- char *pszColon;
- char *pszLine;
- int entriesAlloced;
- int startOfLine=0;
- unsigned int linePos=1;
- LCID langID;
- UINT fileCp = CP_ACP;
-
- lstrcpy(langPack.filename,szLangPack);
- fp = _tfopen(szLangPack,_T("rt"));
- if(fp==NULL) return 1;
- fgets(line,sizeof(line),fp);
- size_t lineLen = strlen(line);
- if (lineLen >= 3 && line[0]=='\xef' && line[1]=='\xbb' && line[2]=='\xbf')
- {
- fileCp = CP_UTF8;
- memmove(line, line + 3, lineLen - 2);
- }
- TrimString(line);
- if(lstrcmpA(line,"Miranda Language Pack Version 1")) {fclose(fp); return 2;}
- //headers
- while(!feof(fp)) {
- startOfLine=ftell(fp);
- if(fgets(line,sizeof(line),fp)==NULL) break;
- TrimString(line);
- if(IsEmpty(line) || line[0]==';' || line[0]==0) continue;
- if(line[0]=='[') break;
- pszColon=strchr(line,':');
- if(pszColon==NULL) {fclose(fp); return 3;}
- *pszColon=0;
- if (!lstrcmpA(line,"Language")) {_snprintf(langPack.language,sizeof(langPack.language),"%s",pszColon+1); TrimString(langPack.language);}
- else if (!lstrcmpA(line,"Last-Modified-Using")) {_snprintf(langPack.lastModifiedUsing,sizeof(langPack.lastModifiedUsing),"%s",pszColon+1); TrimString(langPack.lastModifiedUsing);}
- else if (!lstrcmpA(line,"Authors")) {_snprintf(langPack.authors,sizeof(langPack.authors),"%s",pszColon+1); TrimString(langPack.authors);}
- else if (!lstrcmpA(line,"Author-email")) {_snprintf(langPack.authorEmail,sizeof(langPack.authorEmail),"%s",pszColon+1); TrimString(langPack.authorEmail);}
- else if (!lstrcmpA(line, "Locale")) {
- char szBuf[20], *stopped;
-
- TrimString(pszColon + 1);
- langID = (USHORT)strtol(pszColon + 1, &stopped, 16);
- langPack.localeID = MAKELCID(langID, 0);
- GetLocaleInfoA(langPack.localeID, LOCALE_IDEFAULTANSICODEPAGE, szBuf, 10);
- szBuf[5] = 0; // codepages have max. 5 digits
- langPack.defaultANSICp = atoi(szBuf);
- if (fileCp == CP_ACP)
- fileCp = langPack.defaultANSICp;
- }
- }
-
- //body
- fseek(fp,startOfLine,SEEK_SET);
- entriesAlloced=0;
- while(!feof(fp)) {
- if(fgets(line,sizeof(line),fp)==NULL) break;
- if(IsEmpty(line) || line[0]==';' || line[0]==0) continue;
- TrimStringSimple(line);
- ConvertBackslashes(line, fileCp);
- if(line[0]=='[' && line[lstrlenA(line)-1]==']') {
- if(langPack.entryCount && langPack.entry[langPack.entryCount-1].local==NULL) {
- if(langPack.entry[langPack.entryCount-1].english!=NULL) free(langPack.entry[langPack.entryCount-1].english);
- langPack.entryCount--;
- }
- pszLine = line+1;
- line[lstrlenA(line)-1]='\0';
- TrimStringSimple(line);
- if (++langPack.entryCount>entriesAlloced) {
- entriesAlloced+=128;
- langPack.entry=(struct LangPackEntry*)realloc(langPack.entry,sizeof(struct LangPackEntry)*entriesAlloced);
- }
- langPack.entry[langPack.entryCount-1].english=NULL;
- langPack.entry[langPack.entryCount-1].englishHash=hashstr(pszLine);
- langPack.entry[langPack.entryCount-1].local=NULL;
- langPack.entry[langPack.entryCount-1].wlocal = NULL;
- langPack.entry[langPack.entryCount-1].linePos=linePos++;
- }
- else if(langPack.entryCount) {
- struct LangPackEntry* E = &langPack.entry[langPack.entryCount-1];
-
- if(E->local==NULL) {
- E->local = _strdup(line);
- if (fileCp == CP_UTF8)
- Utf8DecodeCP(E->local, langPack.defaultANSICp, NULL);
-
- {
- int iNeeded = MultiByteToWideChar(fileCp, 0, line, -1, 0, 0);
- E->wlocal = (wchar_t *)malloc((iNeeded+1) * sizeof(wchar_t));
- MultiByteToWideChar(fileCp, 0, line, -1, E->wlocal, iNeeded);
- }
- }
- else {
- size_t iOldLenA = strlen(E->local);
- E->local = (char*)realloc(E->local, iOldLenA + strlen(line) + 2);
- strcat(E->local, "\n");
- strcat(E->local, line);
- if (fileCp == CP_UTF8)
- Utf8DecodeCP(E->local + iOldLenA + 1, langPack.defaultANSICp, NULL);
- {
- int iNeeded = MultiByteToWideChar(fileCp, 0, line, -1, 0, 0);
- size_t iOldLen = wcslen(E->wlocal);
- E->wlocal = (wchar_t*)realloc(E->wlocal, ( sizeof(wchar_t) * ( iOldLen + iNeeded + 2)));
- wcscat(E->wlocal, L"\n");
- MultiByteToWideChar(fileCp, 0, line, -1, E->wlocal + iOldLen+1, iNeeded);
- }
- }
- }
- }
- fclose(fp);
-
- qsort(langPack.entry,langPack.entryCount,sizeof(LangPackEntry),(int(*)(const void*,const void*))SortLangPackHashesProc);
-
- return 0;
-}
-
-char *LangPackTranslateString(const char *szEnglish, const int W)
-{
- struct LangPackEntry key,*entry;
-
- if ( langPack.entryCount == 0 || szEnglish == NULL ) return (char*)szEnglish;
-
- key.englishHash = W ? hashstrW(szEnglish) : hashstr(szEnglish);
- entry=(struct LangPackEntry*)bsearch(&key,langPack.entry,langPack.entryCount,sizeof(struct LangPackEntry),(int(*)(const void*,const void*))SortLangPackHashesProc2);
- if(entry==NULL) return (char*)szEnglish;
- while(entry>langPack.entry)
- {
- entry--;
- if(entry->englishHash!=key.englishHash) {
- entry++;
- return W ? (char *)entry->wlocal : entry->local;
- }
- }
- return W ? (char *)entry->wlocal : entry->local;
-}
-
-#define FLAGS 1
-
-static void TranslateWindow( HWND hwnd )
-{
- TCHAR title[2048];
- GetWindowText(hwnd, title, SIZEOF( title ));
- {
- TCHAR* result = ( TCHAR* )LangPackTranslateString(( char* )title, FLAGS );
- if ( result != title )
- SetWindowText(hwnd, result );
-} }
-
-static BOOL CALLBACK TranslateDialogEnumProc(HWND hwnd,LPARAM lParam)
-{
- TCHAR szClass[32];
- int id = GetDlgCtrlID( hwnd );
-
- GetClassName(hwnd,szClass,SIZEOF(szClass));
- if (!lstrcmpi(szClass,_T("static")) || !lstrcmpi(szClass,_T("hyperlink")) || !lstrcmpi(szClass,_T("button")) || !lstrcmpi(szClass,_T("MButtonClass")))
- TranslateWindow(hwnd);
- else if (!lstrcmpi(szClass,_T("edit"))) {
- if ( GetWindowLongPtr(hwnd,GWL_STYLE)&ES_READONLY)
- TranslateWindow(hwnd);
- }
- return TRUE;
-}
-
-int TranslateDialog( HWND hwndDlg )
-{
- TranslateWindow( hwndDlg );
- EnumChildWindows( hwndDlg,TranslateDialogEnumProc,0);
- return 0;
-}
-
-void LoadLangPackModule(void)
-{
- HANDLE hFind;
- TCHAR szSearch[MAX_PATH], *str2, szLangPack[MAX_PATH];
- WIN32_FIND_DATA fd;
-
- GetModuleFileName(GetModuleHandle(NULL),szSearch,MAX_PATH);
- str2 = _tcsrchr(szSearch, '\\');
- if (str2) *str2 = 0; else str2 = szSearch;
- _tcscat(szSearch, _T("\\langpack_*.txt"));
- hFind = FindFirstFile(szSearch, &fd);
- if (hFind != INVALID_HANDLE_VALUE)
- {
- FindClose(hFind);
-
- _tcscpy(str2 + 1, fd.cFileName);
- _tcscpy(szLangPack, szSearch);
- LoadLangPack(szLangPack);
- }
-}
-
-void UnloadLangPackModule(void)
-{
- for (int i = 0; i < langPack.entryCount; i++) {
- free(langPack.entry[i].english);
- free(langPack.entry[i].local);
- free(langPack.entry[i].wlocal);
- }
- if (langPack.entryCount) {
- free(langPack.entry);
- langPack.entry=0;
- langPack.entryCount=0;
- }
-}
-
diff --git a/plugins/Dbx_mmap_SA/Dbtool/main.cpp b/plugins/Dbx_mmap_SA/Dbtool/main.cpp index 014881e34d..bdfb5ce706 100644 --- a/plugins/Dbx_mmap_SA/Dbtool/main.cpp +++ b/plugins/Dbx_mmap_SA/Dbtool/main.cpp @@ -19,13 +19,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "dbtool.h"
HINSTANCE hInst;
+int hLangpack=0;
DbToolOptions opts = {0};
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
hInst=hInstance;
- LoadLangPackModule();
InitCommonControls();
DialogBox(hInst,MAKEINTRESOURCE(IDD_WIZARD),NULL,WizardDlgProc);
return 0;
diff --git a/plugins/Dbx_mmap_SA/Dbtool/openerror.cpp b/plugins/Dbx_mmap_SA/Dbtool/openerror.cpp index 292d688be7..1fa2964c20 100644 --- a/plugins/Dbx_mmap_SA/Dbtool/openerror.cpp +++ b/plugins/Dbx_mmap_SA/Dbtool/openerror.cpp @@ -31,7 +31,7 @@ INT_PTR CALLBACK OpenErrorDlgProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM lP }
if(opts.error==ERROR_SHARING_VIOLATION) ShowWindow(GetDlgItem(hdlg,IDC_INUSE),SW_SHOW);
SetWindowLongPtr( GetDlgItem( hdlg, IDC_FILE ), GWL_STYLE, GetWindowLongPtr( GetDlgItem( hdlg, IDC_FILE ), GWL_STYLE ) | SS_PATHELLIPSIS );
- TranslateDialog( hdlg );
+ TranslateDialogDefault( hdlg );
SetDlgItemText( hdlg, IDC_FILE, opts.filename );
return TRUE;
case WM_COMMAND:
diff --git a/plugins/Dbx_mmap_SA/Dbtool/progress.cpp b/plugins/Dbx_mmap_SA/Dbtool/progress.cpp index caca179482..5ddb8bd985 100644 --- a/plugins/Dbx_mmap_SA/Dbtool/progress.cpp +++ b/plugins/Dbx_mmap_SA/Dbtool/progress.cpp @@ -104,7 +104,7 @@ INT_PTR CALLBACK ProgressDlgProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM lPa manualAbort=0;
hEventRun=CreateEvent(NULL,TRUE,TRUE,NULL);
hEventAbort=CreateEvent(NULL,TRUE,FALSE,NULL);
- TranslateDialog(hdlg);
+ TranslateDialogDefault(hdlg);
_beginthread(WorkerThread,0,NULL);
return TRUE;
case WM_MEASUREITEM:
diff --git a/plugins/Dbx_mmap_SA/Dbtool/selectdb.cpp b/plugins/Dbx_mmap_SA/Dbtool/selectdb.cpp index 9b1a08640e..9db3517816 100644 --- a/plugins/Dbx_mmap_SA/Dbtool/selectdb.cpp +++ b/plugins/Dbx_mmap_SA/Dbtool/selectdb.cpp @@ -209,7 +209,7 @@ INT_PTR CALLBACK SelectDbDlgProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM lPa CloseHandle( opts.hFile );
opts.hFile = NULL;
}
- TranslateDialog( hdlg );
+ TranslateDialogDefault( hdlg );
return TRUE;
}
diff --git a/plugins/Dbx_mmap_SA/Dbtool/utf.cpp b/plugins/Dbx_mmap_SA/Dbtool/utf.cpp index 157d5d00f5..c56db053d8 100644 --- a/plugins/Dbx_mmap_SA/Dbtool/utf.cpp +++ b/plugins/Dbx_mmap_SA/Dbtool/utf.cpp @@ -26,382 +26,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "dbtool.h"
-/* number of following bytes in sequence based on first byte value (for bytes above 0x7f) */
-static const char utf8_length[128] =
-{
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x80-0x8f */
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x90-0x9f */
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xa0-0xaf */
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xb0-0xbf */
- 0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 0xc0-0xcf */
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 0xd0-0xdf */
- 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, /* 0xe0-0xef */
- 3,3,3,3,3,0,0,0,0,0,0,0,0,0,0,0 /* 0xf0-0xff */
-};
-
-/* first byte mask depending on UTF-8 sequence length */
-static const unsigned char utf8_mask[4] = { 0x7f, 0x1f, 0x0f, 0x07 };
-
-/* minimum Unicode value depending on UTF-8 sequence length */
-static const unsigned int utf8_minval[4] = { 0x0, 0x80, 0x800, 0x10000 };
-
-
-/* get the next char value taking surrogates into account */
-static unsigned int getSurrogateValue(const wchar_t *src, unsigned int srclen)
-{
- if (src[0] >= 0xd800 && src[0] <= 0xdfff) /* surrogate pair */
- {
- if (src[0] > 0xdbff || /* invalid high surrogate */
- srclen <= 1 || /* missing low surrogate */
- src[1] < 0xdc00 || src[1] > 0xdfff) /* invalid low surrogate */
- return 0;
- return 0x10000 + ((src[0] & 0x3ff) << 10) + (src[1] & 0x3ff);
- }
- return src[0];
-}
-
-/* query necessary dst length for src string */
-static int Ucs2toUtf8Len(const wchar_t *src, unsigned int srclen)
-{
- int len;
- unsigned int val;
-
- for (len = 0; srclen; srclen--, src++)
- {
- if (*src < 0x80) /* 0x00-0x7f: 1 byte */
- {
- len++;
- continue;
- }
- if (*src < 0x800) /* 0x80-0x7ff: 2 bytes */
- {
- len += 2;
- continue;
- }
- if (!(val = getSurrogateValue(src, srclen)))
- {
- return -2;
- }
- if (val < 0x10000) /* 0x800-0xffff: 3 bytes */
- len += 3;
- else /* 0x10000-0x10ffff: 4 bytes */
- {
- len += 4;
- src++;
- srclen--;
- }
- }
- return len;
-}
-
-int Ucs2toUtf8Len(const wchar_t *src)
-{
- if ( src == 0 )
- return 0;
-
- return Ucs2toUtf8Len( src, (int)wcslen( src ));
-}
-
-/* wide char to UTF-8 string conversion */
-/* return -1 on dst buffer overflow, -2 on invalid input char */
-int Ucs2toUtf8(const wchar_t *src, int srclen, char *dst, int dstlen)
-{
- int len;
-
- for (len = dstlen; srclen; srclen--, src++)
- {
- WCHAR ch = *src;
- unsigned int val;
-
- if (ch < 0x80) /* 0x00-0x7f: 1 byte */
- {
- if (!len--) return -1; /* overflow */
- *dst++ = ch;
- continue;
- }
-
- if (ch < 0x800) /* 0x80-0x7ff: 2 bytes */
- {
- if ((len -= 2) < 0) return -1; /* overflow */
- dst[1] = 0x80 | (ch & 0x3f);
- ch >>= 6;
- dst[0] = 0xc0 | ch;
- dst += 2;
- continue;
- }
-
- if (!(val = getSurrogateValue(src, srclen)))
- {
- return -2;
- }
-
- if (val < 0x10000) /* 0x800-0xffff: 3 bytes */
- {
- if ((len -= 3) < 0) return -1; /* overflow */
- dst[2] = 0x80 | (val & 0x3f);
- val >>= 6;
- dst[1] = 0x80 | (val & 0x3f);
- val >>= 6;
- dst[0] = 0xe0 | val;
- dst += 3;
- }
- else /* 0x10000-0x10ffff: 4 bytes */
- {
- if ((len -= 4) < 0) return -1; /* overflow */
- dst[3] = 0x80 | (val & 0x3f);
- val >>= 6;
- dst[2] = 0x80 | (val & 0x3f);
- val >>= 6;
- dst[1] = 0x80 | (val & 0x3f);
- val >>= 6;
- dst[0] = 0xf0 | val;
- dst += 4;
- src++;
- srclen--;
- }
- }
- return dstlen - len;
-}
-
-/* helper for the various utf8 mbstowcs functions */
-static unsigned int decodeUtf8Char(unsigned char ch, const char **str, const char *strend)
-{
- unsigned int len = utf8_length[ch-0x80];
- unsigned int res = ch & utf8_mask[len];
- const char *end = *str + len;
-
- if (end > strend) return ~0;
- switch(len)
- {
- case 3:
- if ((ch = end[-3] ^ 0x80) >= 0x40) break;
- res = (res << 6) | ch;
- (*str)++;
- case 2:
- if ((ch = end[-2] ^ 0x80) >= 0x40) break;
- res = (res << 6) | ch;
- (*str)++;
- case 1:
- if ((ch = end[-1] ^ 0x80) >= 0x40) break;
- res = (res << 6) | ch;
- (*str)++;
- if (res < utf8_minval[len]) break;
- return res;
- }
- return ~0;
-}
-
-/* query necessary dst length for src string */
-static inline int Utf8toUcs2Len(const char *src, int srclen)
-{
- int ret = 0;
- unsigned int res;
- const char *srcend = src + srclen;
-
- while (src < srcend)
- {
- unsigned char ch = *src++;
- if (ch < 0x80) /* special fast case for 7-bit ASCII */
- {
- ret++;
- continue;
- }
- if ((res = decodeUtf8Char(ch, &src, srcend)) <= 0x10ffff)
- {
- if (res > 0xffff) ret++;
- ret++;
- }
- else return -2; /* bad char */
- /* otherwise ignore it */
- }
- return ret;
-}
-
-/* UTF-8 to wide char string conversion */
-/* return -1 on dst buffer overflow, -2 on invalid input char */
-int Utf8toUcs2(const char *src, int srclen, wchar_t *dst, int dstlen)
-{
- unsigned int res;
- const char *srcend = src + srclen;
- wchar_t *dstend = dst + dstlen;
-
- while ((dst < dstend) && (src < srcend))
- {
- unsigned char ch = *src++;
- if (ch < 0x80) /* special fast case for 7-bit ASCII */
- {
- *dst++ = ch;
- continue;
- }
- if ((res = decodeUtf8Char(ch, &src, srcend)) <= 0xffff)
- {
- *dst++ = res;
- }
- else if (res <= 0x10ffff) /* we need surrogates */
- {
- if (dst == dstend - 1) return -1; /* overflow */
- res -= 0x10000;
- *dst++ = 0xd800 | (res >> 10);
- *dst++ = 0xdc00 | (res & 0x3ff);
- }
- else return -2; /* bad char */
- /* otherwise ignore it */
- }
- if (src < srcend) return -1; /* overflow */
- return dstlen - (dstend - dst);
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// Utf8Decode - converts UTF8-encoded string to the UCS2/MBCS format
-
-char* Utf8DecodeCP(char* str, int codepage, wchar_t** ucs2)
-{
- int len;
- bool needs_free = false;
- wchar_t* tempBuf = NULL;
- if ( ucs2 )
- *ucs2 = NULL;
-
- if (str == NULL)
- return NULL;
-
- len = (int)strlen(str);
-
- if (len < 2) {
- if (ucs2 != NULL) {
- *ucs2 = tempBuf = (wchar_t*)malloc((len + 1) * sizeof(wchar_t));
- MultiByteToWideChar(codepage, 0, str, len, tempBuf, len);
- tempBuf[len] = 0;
- }
- return str;
- }
-
- int destlen = Utf8toUcs2Len(str, len);
- if (destlen < 0)
- return NULL;
-
- if (ucs2 == NULL) {
- __try
- {
- tempBuf = (wchar_t*)alloca((destlen + 1) * sizeof(wchar_t));
- }
- __except(EXCEPTION_EXECUTE_HANDLER)
- {
- tempBuf = NULL;
- needs_free = true;
- }
- }
-
- if ( tempBuf == NULL ) {
- tempBuf = (wchar_t*)malloc((destlen + 1) * sizeof(wchar_t));
- if ( tempBuf == NULL )
- return NULL;
- }
-
- Utf8toUcs2(str, len, tempBuf, destlen);
- tempBuf[destlen] = 0;
- WideCharToMultiByte(codepage, 0, tempBuf, -1, str, len + 1, "?", NULL);
-
- if (ucs2)
- *ucs2 = tempBuf;
- else if (needs_free)
- free(tempBuf);
-
- return str;
-}
-
-wchar_t* Utf8DecodeUcs2(const char* str)
-{
- if (str == NULL)
- return NULL;
-
- int len = (int)strlen(str);
-
- int destlen = Utf8toUcs2Len(str, len);
- if (destlen < 0) return NULL;
-
- wchar_t* ucs2 = (wchar_t*)malloc((destlen + 1) * sizeof(wchar_t));
- if (ucs2 == NULL) return NULL;
-
- if (Utf8toUcs2(str, len, ucs2, destlen) >= 0)
- {
- ucs2[destlen] = 0;
- return ucs2;
- }
-
- free(ucs2);
-
- return NULL;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// Utf8Encode - converts MBCS string to the UTF8-encoded format
-
-char* Utf8EncodeCP(const char* src, int codepage)
-{
- int len;
- bool needs_free = false;
- char* result = NULL;
- wchar_t* tempBuf;
-
- if (src == NULL)
- return NULL;
-
- len = (int)strlen(src);
-
- __try
- {
- tempBuf = (wchar_t*)alloca((len + 1) * sizeof(wchar_t));
- }
- __except(EXCEPTION_EXECUTE_HANDLER)
- {
- tempBuf = (wchar_t*)malloc((len + 1) * sizeof(wchar_t));
- if (tempBuf == NULL) return NULL;
- needs_free = true;
- }
-
- len = MultiByteToWideChar(codepage, 0, src, -1, tempBuf, len + 1);
-
- int destlen = Ucs2toUtf8Len(tempBuf, len);
- if (destlen >= 0)
- {
- result = (char*)malloc(destlen + 1);
- if (result)
- {
- Ucs2toUtf8(tempBuf, len, result, destlen);
- result[destlen] = 0;
- }
- }
-
- if (needs_free)
- free(tempBuf);
-
- return result;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// Utf8Encode - converts UCS2 string to the UTF8-encoded format
-
-char* Utf8EncodeUcs2(const wchar_t* src)
-{
- if (src == NULL)
- return NULL;
-
- int len = (int)wcslen(src);
-
- int destlen = Ucs2toUtf8Len(src, len);
- if (destlen < 0) return NULL;
-
- char* result = (char*)malloc(destlen + 1);
- if (result == NULL)
- return NULL;
-
- Ucs2toUtf8(src, len, result, destlen);
- result[destlen] = 0;
-
- return result;
-}
-
bool is_utf8_string(const char* str)
{
int expect_bytes = 0, utf_found = 0;
diff --git a/plugins/Dbx_mmap_SA/Dbtool/wizard.cpp b/plugins/Dbx_mmap_SA/Dbtool/wizard.cpp index ab3c46f360..8f3a9d5ca8 100644 --- a/plugins/Dbx_mmap_SA/Dbtool/wizard.cpp +++ b/plugins/Dbx_mmap_SA/Dbtool/wizard.cpp @@ -97,7 +97,7 @@ INT_PTR CALLBACK WizardDlgProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM lPara SendMessage(hdlg,WM_SETICON,ICON_SMALL,(LPARAM)LoadIcon(hInst,MAKEINTRESOURCE(IDI_DBTOOL)));
hdlgPage=NULL;
SendMessage(hdlg,WZM_GOTOPAGE,IDD_WELCOME,(LPARAM)WelcomeDlgProc);
- TranslateDialog(hdlg);
+ TranslateDialogDefault(hdlg);
return TRUE;
case WZM_GOTOPAGE:
if(hdlgPage!=NULL) DestroyWindow(hdlgPage);
@@ -106,7 +106,7 @@ INT_PTR CALLBACK WizardDlgProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM lPara EnableWindow(GetDlgItem(hdlg,IDCANCEL),TRUE);
SetDlgItemText(hdlg,IDCANCEL,TranslateT("Cancel"));
hdlgPage=CreateDialog(hInst,MAKEINTRESOURCE(wParam),hdlg,(DLGPROC)lParam);
- TranslateDialog(hdlgPage);
+ TranslateDialogDefault(hdlgPage);
SetWindowPos(hdlgPage,0,0,0,0,0,SWP_NOZORDER|SWP_NOSIZE);
ShowWindow(hdlgPage,SW_SHOW);
break;
@@ -129,7 +129,6 @@ INT_PTR CALLBACK WizardDlgProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM lPara if (opts.hOutFile)
CloseHandle(opts.hOutFile);
DestroyWindow(hdlgPage);
- UnloadLangPackModule();
if(hBoldFont!=NULL) DeleteObject(hBoldFont);
if(hEmfHeaderLogo!=NULL) DeleteEnhMetaFile(hEmfHeaderLogo);
break;
diff --git a/plugins/Dbx_mmap_SA/commonheaders.h b/plugins/Dbx_mmap_SA/commonheaders.h index 6d5dcd8d21..065fc3ab3e 100644 --- a/plugins/Dbx_mmap_SA/commonheaders.h +++ b/plugins/Dbx_mmap_SA/commonheaders.h @@ -29,8 +29,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. //windows headers
#include <windows.h>
-
+#include <shlobj.h>
#include <commctrl.h>
+
#include <stdio.h>
#include <string.h>
#include <time.h>
diff --git a/plugins/Dbx_mmap_SA/dialogs.cpp b/plugins/Dbx_mmap_SA/dialogs.cpp index ffa0516fae..d8878a2dd1 100644 --- a/plugins/Dbx_mmap_SA/dialogs.cpp +++ b/plugins/Dbx_mmap_SA/dialogs.cpp @@ -4,8 +4,6 @@ #include <m_options.h>
#include <m_icolib.h>
-#include <shlobj.h>
-
#define MS_DB_CHANGEPASSWORD "DB/ChangePassword"
extern char encryptKey[255];
|