https://git.reactos.org/?p=reactos.git;a=commitdiff;h=cce12eb9edd212bfe47ce…
commit cce12eb9edd212bfe47ce3af64f9a05d24ebc731
Author: Yukinari Mitsu <bimy1280163(a)gn.iwasaki.ac.jp>
AuthorDate: Tue Jul 4 19:04:44 2023 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Tue Jul 4 13:04:44 2023 +0300
[SERVMAN] Respect the user-selected export format (#5394)
- Use either tab or comma separator depending on user's selection.
- Skip adding a separator after the last table cell.
CORE-19001
---
base/applications/mscutils/servman/export.c | 20 +++++++++++++++-----
base/applications/mscutils/servman/precomp.h | 1 +
2 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/base/applications/mscutils/servman/export.c
b/base/applications/mscutils/servman/export.c
index 53bf8633019..f8cc61dd970 100644
--- a/base/applications/mscutils/servman/export.c
+++ b/base/applications/mscutils/servman/export.c
@@ -34,11 +34,17 @@ GetTextFromListView(PMAIN_WND_INFO Info,
static BOOL
SaveServicesToFile(PMAIN_WND_INFO Info,
- LPCWSTR pszFileName)
+ LPCWSTR pszFileName,
+ DWORD nFormat)
{
HANDLE hFile;
BOOL bSuccess = FALSE;
+ if (!nFormat || nFormat > 2)
+ {
+ return bSuccess;
+ }
+
hFile = CreateFileW(pszFileName,
GENERIC_WRITE,
0,
@@ -51,7 +57,7 @@ SaveServicesToFile(PMAIN_WND_INFO Info,
{
WCHAR LVText[500];
WCHAR newl[2] = {L'\r', L'\n'};
- WCHAR tab = L'\t';
+ WCHAR seps[2] = {L'\t', L','};
DWORD dwTextLength, dwWritten;
INT NumListedServ = 0;
INT i, k;
@@ -60,7 +66,7 @@ SaveServicesToFile(PMAIN_WND_INFO Info,
for (i=0; i < NumListedServ; i++)
{
- for (k=0; k<5; k++)
+ for (k=0; k < LVMAX; k++)
{
dwTextLength = GetTextFromListView(Info,
LVText,
@@ -73,9 +79,13 @@ SaveServicesToFile(PMAIN_WND_INFO Info,
sizeof(WCHAR) * dwTextLength,
&dwWritten,
NULL);
+ }
+ if (k < LVMAX - 1)
+ {
+ /* Do not add separator after the last table cell */
WriteFile(hFile,
- &tab,
+ &seps[nFormat-1],
sizeof(WCHAR),
&dwWritten,
NULL);
@@ -113,7 +123,7 @@ VOID ExportFile(PMAIN_WND_INFO Info)
if(GetSaveFileName(&ofn))
{
- if (SaveServicesToFile(Info, szFileName))
+ if (SaveServicesToFile(Info, szFileName, ofn.nFilterIndex))
return;
}
diff --git a/base/applications/mscutils/servman/precomp.h
b/base/applications/mscutils/servman/precomp.h
index d070bbc4dc3..af5cbbe276b 100644
--- a/base/applications/mscutils/servman/precomp.h
+++ b/base/applications/mscutils/servman/precomp.h
@@ -31,6 +31,7 @@
#define LVSTATUS 2
#define LVSTARTUP 3
#define LVLOGONAS 4
+#define LVMAX 5
#define IMAGE_UNKNOWN 0
#define IMAGE_SERVICE 1