summaryrefslogtreecommitdiff
path: root/tools/dbtool
diff options
context:
space:
mode:
Diffstat (limited to 'tools/dbtool')
-rw-r--r--tools/dbtool/cleaning.cpp2
-rw-r--r--tools/dbtool/dbtool.h19
-rw-r--r--tools/dbtool/dbtool_10.vcxproj.filters3
-rw-r--r--tools/dbtool/eventchain.cpp2
-rw-r--r--tools/dbtool/fileaccess.cpp2
-rw-r--r--tools/dbtool/finished.cpp2
-rw-r--r--tools/dbtool/main.cpp4
-rw-r--r--tools/dbtool/openerror.cpp2
-rw-r--r--tools/dbtool/progress.cpp2
-rw-r--r--tools/dbtool/selectdb.cpp2
-rw-r--r--tools/dbtool/utf.cpp376
-rw-r--r--tools/dbtool/wizard.cpp5
12 files changed, 12 insertions, 409 deletions
diff --git a/tools/dbtool/cleaning.cpp b/tools/dbtool/cleaning.cpp
index efbbde1640..a16a11e7ac 100644
--- a/tools/dbtool/cleaning.cpp
+++ b/tools/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/tools/dbtool/dbtool.h b/tools/dbtool/dbtool.h
index 6bc7591392..c674445a39 100644
--- a/tools/dbtool/dbtool.h
+++ b/tools/dbtool/dbtool.h
@@ -33,10 +33,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <commctrl.h>
#include <time.h>
-//#include <newpluginapi.h> // Only needed to keep m_database.h happy
-#define CallService(a,b,c) 1
-
-#include "../../include/m_database.h"
+#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.
#include "resource.h"
@@ -105,19 +102,5 @@ int SignatureValid(DWORD ofs,DWORD signature);
DWORD ConvertModuleNameOfs(DWORD ofsOld);
void FreeModuleChain();
-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/tools/dbtool/dbtool_10.vcxproj.filters b/tools/dbtool/dbtool_10.vcxproj.filters
index 1a3e2bf55e..a3aa9aa299 100644
--- a/tools/dbtool/dbtool_10.vcxproj.filters
+++ b/tools/dbtool/dbtool_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/tools/dbtool/eventchain.cpp b/tools/dbtool/eventchain.cpp
index 8760363287..8d319a5201 100644
--- a/tools/dbtool/eventchain.cpp
+++ b/tools/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/tools/dbtool/fileaccess.cpp b/tools/dbtool/fileaccess.cpp
index 2fdd16c082..d904daf5b9 100644
--- a/tools/dbtool/fileaccess.cpp
+++ b/tools/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/tools/dbtool/finished.cpp b/tools/dbtool/finished.cpp
index 7457d8b7d4..03e4004268 100644
--- a/tools/dbtool/finished.cpp
+++ b/tools/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/tools/dbtool/main.cpp b/tools/dbtool/main.cpp
index 014881e34d..fb4657fc53 100644
--- a/tools/dbtool/main.cpp
+++ b/tools/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();
+ hInst = hInstance;
InitCommonControls();
DialogBox(hInst,MAKEINTRESOURCE(IDD_WIZARD),NULL,WizardDlgProc);
return 0;
diff --git a/tools/dbtool/openerror.cpp b/tools/dbtool/openerror.cpp
index 292d688be7..1fa2964c20 100644
--- a/tools/dbtool/openerror.cpp
+++ b/tools/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/tools/dbtool/progress.cpp b/tools/dbtool/progress.cpp
index 4b7d7979b4..67c463ec77 100644
--- a/tools/dbtool/progress.cpp
+++ b/tools/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/tools/dbtool/selectdb.cpp b/tools/dbtool/selectdb.cpp
index 5bfd817cf5..761d3af1d0 100644
--- a/tools/dbtool/selectdb.cpp
+++ b/tools/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/tools/dbtool/utf.cpp b/tools/dbtool/utf.cpp
index 157d5d00f5..c56db053d8 100644
--- a/tools/dbtool/utf.cpp
+++ b/tools/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/tools/dbtool/wizard.cpp b/tools/dbtool/wizard.cpp
index 49e20b9e2e..10c711cd0f 100644
--- a/tools/dbtool/wizard.cpp
+++ b/tools/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;