summaryrefslogtreecommitdiff
path: root/protocols/Gadu-Gadu/src/import.cpp
diff options
context:
space:
mode:
authorGoraf <22941576+Goraf@users.noreply.github.com>2018-01-20 16:25:13 +0100
committerGoraf <22941576+Goraf@users.noreply.github.com>2018-01-20 16:37:39 +0100
commit087173d06f4848f19d186b6902d399ce9b7225e1 (patch)
tree0cb2330486f445a2fa56c6da3a2d7ee983df6f52 /protocols/Gadu-Gadu/src/import.cpp
parentde12828fb9051fba1db1e4573cff56ee83ab6b1f (diff)
Gadu-Gadu: code cleaning
Diffstat (limited to 'protocols/Gadu-Gadu/src/import.cpp')
-rw-r--r--protocols/Gadu-Gadu/src/import.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/protocols/Gadu-Gadu/src/import.cpp b/protocols/Gadu-Gadu/src/import.cpp
index ed405fb0f0..076af51c6b 100644
--- a/protocols/Gadu-Gadu/src/import.cpp
+++ b/protocols/Gadu-Gadu/src/import.cpp
@@ -120,6 +120,7 @@ char *strndup(char *str, int c)
char *ret = (char*)malloc(c + 1);
ret[c] = 0;
strncpy(ret, str, c);
+
return ret;
}
@@ -342,14 +343,14 @@ INT_PTR GGPROTO::remove_server(WPARAM, LPARAM)
INT_PTR GGPROTO::import_text(WPARAM, LPARAM)
{
wchar_t str[MAX_PATH];
- wchar_t filter[512], *pfilter;
+ wchar_t filter[512];
struct _stat st;
OPENFILENAME ofn = { 0 };
ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
wcsncpy(filter, TranslateT("Text files"), _countof(filter));
mir_wstrncat(filter, L" (*.txt)", _countof(filter) - mir_wstrlen(filter));
- pfilter = filter + mir_wstrlen(filter) + 1;
+ wchar_t *pfilter = filter + mir_wstrlen(filter) + 1;
if (pfilter >= filter + _countof(filter))
return 0;
@@ -415,33 +416,38 @@ INT_PTR GGPROTO::import_text(WPARAM, LPARAM)
INT_PTR GGPROTO::export_text(WPARAM, LPARAM)
{
- wchar_t str[MAX_PATH];
- OPENFILENAME ofn = { 0 };
- wchar_t filter[512], *pfilter;
+ wchar_t str[MAX_PATH];
wcsncpy(str, TranslateT("contacts"), _countof(str));
mir_wstrncat(str, L".txt", _countof(str) - mir_wstrlen(str));
- ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
+ wchar_t filter[512];
wcsncpy(filter, TranslateT("Text files"), _countof(filter));
mir_wstrncat(filter, L" (*.txt)", _countof(filter) - mir_wstrlen(filter));
- pfilter = filter + mir_wstrlen(filter) + 1;
+ wchar_t *pfilter = filter + mir_wstrlen(filter) + 1;
if (pfilter >= filter + _countof(filter))
return 0;
+
wcsncpy(pfilter, L"*.TXT", _countof(filter) - (pfilter - filter));
pfilter = pfilter + mir_wstrlen(pfilter) + 1;
if (pfilter >= filter + _countof(filter))
return 0;
+
wcsncpy(pfilter, TranslateT("All Files"), _countof(filter) - (pfilter - filter));
mir_wstrncat(pfilter, L" (*)", _countof(filter) - (pfilter - filter) - mir_wstrlen(pfilter));
pfilter = pfilter + mir_wstrlen(pfilter) + 1;
if (pfilter >= filter + _countof(filter))
return 0;
+
wcsncpy(pfilter, L"*", _countof(filter) - (pfilter - filter));
pfilter = pfilter + mir_wstrlen(pfilter) + 1;
if (pfilter >= filter + _countof(filter))
return 0;
+
*pfilter = '\0';
+
+ OPENFILENAME ofn = { 0 };
+ ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
ofn.lpstrFilter = filter;
ofn.lpstrFile = str;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY;