https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3055afce81f5f6683bd22…
commit 3055afce81f5f6683bd22a361610d9c9d8deb34a
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Sun Apr 29 19:33:49 2018 +0200
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Sun Apr 29 19:36:13 2018 +0200
[MODE] Improve the way the DOS device statuses are enumerated via the "mode"
command (without parameters).
---
base/applications/cmdutils/mode/lang/de-DE.rc | 13 +-
base/applications/cmdutils/mode/lang/en-US.rc | 13 +-
base/applications/cmdutils/mode/lang/ro-RO.rc | 13 +-
base/applications/cmdutils/mode/lang/ru-RU.rc | 13 +-
base/applications/cmdutils/mode/lang/tr-TR.rc | 13 +-
base/applications/cmdutils/mode/lang/zh-CN.rc | 13 +-
base/applications/cmdutils/mode/mode.c | 192 ++++++++++++++------------
base/applications/cmdutils/mode/resource.h | 17 +--
8 files changed, 152 insertions(+), 135 deletions(-)
diff --git a/base/applications/cmdutils/mode/lang/de-DE.rc
b/base/applications/cmdutils/mode/lang/de-DE.rc
index 883bc567ae..5355ac86e8 100644
--- a/base/applications/cmdutils/mode/lang/de-DE.rc
+++ b/base/applications/cmdutils/mode/lang/de-DE.rc
@@ -14,13 +14,13 @@ Codepagestatus: MODE CON[:] CP [/STATUS]\n\
Anzeigemodus: MODE CON[:] [COLS=c] [LINES=n]\n\
Tastaturwiederholrate: MODE CON[:] [RATE=r DELAY=d]\n"
- IDS_QUERY_SERIAL_FOUND " Serieller Anschluss gefunden - %s\n"
- IDS_QUERY_PRINTER_FOUND " Drucker gefunden - %s\n"
- IDS_QUERY_PARALLEL_FOUND " Paralleler Anschluss gefunden - %s\n"
- IDS_QUERY_DOSDEV_FOUND " Found DOS device - %s\n"
- // IDS_QUERY_MISC_FOUND " Found other device - %s\n"
+ IDS_QUERY_SERIAL_FOUND "Serieller Anschluss gefunden - %s\n"
+ IDS_QUERY_PRINTER_FOUND "Drucker gefunden - %s\n"
+ IDS_QUERY_PARALLEL_FOUND "Paralleler Anschluss gefunden - %s\n"
+ IDS_QUERY_DOSDEV_FOUND "Found DOS device - %s\n"
+ // IDS_QUERY_MISC_FOUND "Found other device - %s\n"
- // IDS_QUERY_DEVICE_FOUND " Found %s device - %s\n"
+ // IDS_QUERY_DEVICE_FOUND "Found %s device - %s\n"
// IDS_SERIAL "serial"
// IDS_PRINTER "parallel"
// IDS_OTHER "other"
@@ -59,6 +59,7 @@ BEGIN
IDS_ERROR_SET_PARALLEL_STATE "ERROR: SetParallelState(%d) - DefineDosDevice(%s)
(0x%lx)\n"
IDS_ERROR_INVALID_PARAMETER "Unzulässiger Parameter - %s\n"
IDS_ERROR_ILLEGAL_DEVICE_NAME "Unzulässiger Gerätename - %s (0x%lx)\n"
+ IDS_ERROR_DEVICE_NOT_AVAILABLE "The device %s is not currently
available.\n"
IDS_ERROR_STATUS_GET_DEVICE "Failed to get the status for device %s:\n"
IDS_ERROR_STATUS_SET_DEVICE "Failed to set the status for device %s:\n"
IDS_ERROR_TIMEOUT_GET_DEVICE "Failed to get the timeout for device %s:\n"
diff --git a/base/applications/cmdutils/mode/lang/en-US.rc
b/base/applications/cmdutils/mode/lang/en-US.rc
index 9663215a3b..ce84d5d0e5 100644
--- a/base/applications/cmdutils/mode/lang/en-US.rc
+++ b/base/applications/cmdutils/mode/lang/en-US.rc
@@ -14,13 +14,13 @@ Code page status: MODE CON[:] CP [/STATUS]\n\
Display mode: MODE CON[:] [COLS=c] [LINES=n]\n\
Typematic rate: MODE CON[:] [RATE=r DELAY=d]\n"
- IDS_QUERY_SERIAL_FOUND " Found serial device - %s\n"
- IDS_QUERY_PRINTER_FOUND " Found printer device - %s\n"
- IDS_QUERY_PARALLEL_FOUND " Found parallel device - %s\n"
- IDS_QUERY_DOSDEV_FOUND " Found DOS device - %s\n"
- // IDS_QUERY_MISC_FOUND " Found other device - %s\n"
+ IDS_QUERY_SERIAL_FOUND "Found serial device - %s\n"
+ IDS_QUERY_PRINTER_FOUND "Found printer device - %s\n"
+ IDS_QUERY_PARALLEL_FOUND "Found parallel device - %s\n"
+ IDS_QUERY_DOSDEV_FOUND "Found DOS device - %s\n"
+ // IDS_QUERY_MISC_FOUND "Found other device - %s\n"
- // IDS_QUERY_DEVICE_FOUND " Found %s device - %s\n"
+ // IDS_QUERY_DEVICE_FOUND "Found %s device - %s\n"
// IDS_SERIAL "serial"
// IDS_PRINTER "parallel"
// IDS_OTHER "other"
@@ -59,6 +59,7 @@ BEGIN
IDS_ERROR_SET_PARALLEL_STATE "ERROR: SetParallelState(%d) - DefineDosDevice(%s)
(0x%lx)\n"
IDS_ERROR_INVALID_PARAMETER "Invalid parameter - %s\n"
IDS_ERROR_ILLEGAL_DEVICE_NAME "Illegal device name - %s (0x%lx)\n"
+ IDS_ERROR_DEVICE_NOT_AVAILABLE "The device %s is not currently
available.\n"
IDS_ERROR_STATUS_GET_DEVICE "Failed to get the status for device %s:\n"
IDS_ERROR_STATUS_SET_DEVICE "Failed to set the status for device %s:\n"
IDS_ERROR_TIMEOUT_GET_DEVICE "Failed to get the timeout for device %s:\n"
diff --git a/base/applications/cmdutils/mode/lang/ro-RO.rc
b/base/applications/cmdutils/mode/lang/ro-RO.rc
index 6f92acd9db..767e215a6c 100644
--- a/base/applications/cmdutils/mode/lang/ro-RO.rc
+++ b/base/applications/cmdutils/mode/lang/ro-RO.rc
@@ -22,13 +22,13 @@ Modul de afișare:\n\
Rata de repetiție la menținerea unei taste apăsate:\n\
MODE CON[:] [RATE=r DELAY=d]\n"
- IDS_QUERY_SERIAL_FOUND " Depistat dispozitiv la portul serial - %s\n"
- IDS_QUERY_PRINTER_FOUND " Depistat dispozitiv de imprimare - %s\n"
- IDS_QUERY_PARALLEL_FOUND " Depistat dispozitiv la portul paralel -
%s\n"
- IDS_QUERY_DOSDEV_FOUND " Depistat dispozitiv de tip DOS - %s\n"
- // IDS_QUERY_MISC_FOUND " Found other device - %s\n"
+ IDS_QUERY_SERIAL_FOUND "Depistat dispozitiv la portul serial - %s\n"
+ IDS_QUERY_PRINTER_FOUND "Depistat dispozitiv de imprimare - %s\n"
+ IDS_QUERY_PARALLEL_FOUND "Depistat dispozitiv la portul paralel - %s\n"
+ IDS_QUERY_DOSDEV_FOUND "Depistat dispozitiv de tip DOS - %s\n"
+ // IDS_QUERY_MISC_FOUND "Found other device - %s\n"
- // IDS_QUERY_DEVICE_FOUND " Found %s device - %s\n"
+ // IDS_QUERY_DEVICE_FOUND "Found %s device - %s\n"
// IDS_SERIAL "serial"
// IDS_PRINTER "parallel"
// IDS_OTHER "other"
@@ -67,6 +67,7 @@ BEGIN
IDS_ERROR_SET_PARALLEL_STATE "EROARE: SetParallelState(%d) - DefineDosDevice(%s)
(0x%lx)\n"
IDS_ERROR_INVALID_PARAMETER "Parametru nevalid - %s\n"
IDS_ERROR_ILLEGAL_DEVICE_NAME "Nume eronat de dispozitiv - %s (0x%lx)\n"
+ IDS_ERROR_DEVICE_NOT_AVAILABLE "The device %s is not currently
available.\n"
IDS_ERROR_STATUS_GET_DEVICE "Nu poate fi determinată starea dispozitivului
%s:\n"
IDS_ERROR_STATUS_SET_DEVICE "Nu poate fi schimbată starea pentru dispozitivul
%s:\n"
IDS_ERROR_TIMEOUT_GET_DEVICE "Failed to get the timeout for device %s:\n"
diff --git a/base/applications/cmdutils/mode/lang/ru-RU.rc
b/base/applications/cmdutils/mode/lang/ru-RU.rc
index 7ef70b2368..81d2190c7d 100644
--- a/base/applications/cmdutils/mode/lang/ru-RU.rc
+++ b/base/applications/cmdutils/mode/lang/ru-RU.rc
@@ -14,13 +14,13 @@ BEGIN
Режим работы экрана: MODE CON[:] [COLS=c] [LINES=n]\n\
Ввод с клавиатуры: MODE CON[:] [RATE=r DELAY=d]\n"
- IDS_QUERY_SERIAL_FOUND " Найдено последовательное устройство - %s\n"
- IDS_QUERY_PRINTER_FOUND " Найдено устройство печати - %s\n"
- IDS_QUERY_PARALLEL_FOUND " Найдено параллельное устройство - %s\n"
- IDS_QUERY_DOSDEV_FOUND " Найдено устройство DOS - %s\n"
- // IDS_QUERY_MISC_FOUND " Найдено другое устройство - %s\n"
+ IDS_QUERY_SERIAL_FOUND "Найдено последовательное устройство - %s\n"
+ IDS_QUERY_PRINTER_FOUND "Найдено устройство печати - %s\n"
+ IDS_QUERY_PARALLEL_FOUND "Найдено параллельное устройство - %s\n"
+ IDS_QUERY_DOSDEV_FOUND "Найдено устройство DOS - %s\n"
+ // IDS_QUERY_MISC_FOUND "Найдено другое устройство - %s\n"
- // IDS_QUERY_DEVICE_FOUND " Найдено %s устройство - %s\n"
+ // IDS_QUERY_DEVICE_FOUND "Найдено %s устройство - %s\n"
// IDS_SERIAL "последовательное"
// IDS_PRINTER "параллельное"
// IDS_OTHER "другое"
@@ -59,6 +59,7 @@ BEGIN
IDS_ERROR_SET_PARALLEL_STATE "ОШИБКА: SetParallelState(%d) - DefineDosDevice(%s)
(0x%lx)\n"
IDS_ERROR_INVALID_PARAMETER "Неверный параметр - %s\n"
IDS_ERROR_ILLEGAL_DEVICE_NAME "Недопустимое имя устройства - %s (0x%lx)\n"
+ IDS_ERROR_DEVICE_NOT_AVAILABLE "The device %s is not currently
available.\n"
IDS_ERROR_STATUS_GET_DEVICE "Не удалось получить состояние устройства
%s:\n"
IDS_ERROR_STATUS_SET_DEVICE "Не удалось установить состояние устройства
%s:\n"
IDS_ERROR_TIMEOUT_GET_DEVICE "Failed to get the timeout for device %s:\n"
diff --git a/base/applications/cmdutils/mode/lang/tr-TR.rc
b/base/applications/cmdutils/mode/lang/tr-TR.rc
index aa919dac56..31cfe37bfd 100644
--- a/base/applications/cmdutils/mode/lang/tr-TR.rc
+++ b/base/applications/cmdutils/mode/lang/tr-TR.rc
@@ -16,13 +16,13 @@ Kod sayfası durumu: MODE CON[:] CP [/STATUS]\n\
Görüntü kipi: MODE CON[:] [COLS=c] [LINES=n]\n\
Yineleme hızı: MODE CON[:] [RATE=r DELAY=d]\n"
- IDS_QUERY_SERIAL_FOUND " Dizilik aygıt bulundu - %s\n"
- IDS_QUERY_PRINTER_FOUND " Yazıcı aygıtı bulundu - %s\n"
- IDS_QUERY_PARALLEL_FOUND " Koşut aygıt bulundu - %s\n"
- IDS_QUERY_DOSDEV_FOUND " DOS aygıtı bulundu - %s\n"
- // IDS_QUERY_MISC_FOUND " Başka aygıt bulundu - %s\n"
+ IDS_QUERY_SERIAL_FOUND "Dizilik aygıt bulundu - %s\n"
+ IDS_QUERY_PRINTER_FOUND "Yazıcı aygıtı bulundu - %s\n"
+ IDS_QUERY_PARALLEL_FOUND "Koşut aygıt bulundu - %s\n"
+ IDS_QUERY_DOSDEV_FOUND "DOS aygıtı bulundu - %s\n"
+ // IDS_QUERY_MISC_FOUND "Başka aygıt bulundu - %s\n"
- // IDS_QUERY_DEVICE_FOUND " %s aygıtı bulundu - %s\n"
+ // IDS_QUERY_DEVICE_FOUND "%s aygıtı bulundu - %s\n"
// IDS_SERIAL "dizilik"
// IDS_PRINTER "koşut"
// IDS_OTHER "başka"
@@ -61,6 +61,7 @@ BEGIN
IDS_ERROR_SET_PARALLEL_STATE "YANLIŞLIK: SetParallelState(%d) -
DefineDosDevice(%s) (0x%lx)\n"
IDS_ERROR_INVALID_PARAMETER "Geçersiz değişken - %s\n"
IDS_ERROR_ILLEGAL_DEVICE_NAME "Geçersiz aygıt adı - %s (0x%lx)\n"
+ IDS_ERROR_DEVICE_NOT_AVAILABLE "The device %s is not currently
available.\n"
IDS_ERROR_STATUS_GET_DEVICE "%s: aygıtının durumu alınamıyor\n"
IDS_ERROR_STATUS_SET_DEVICE "%s: aygıtının durumu ayarlanamıyor\n"
IDS_ERROR_TIMEOUT_GET_DEVICE "Failed to get the timeout for device %s:\n"
diff --git a/base/applications/cmdutils/mode/lang/zh-CN.rc
b/base/applications/cmdutils/mode/lang/zh-CN.rc
index 99bf6f6802..7e8e841dcd 100644
--- a/base/applications/cmdutils/mode/lang/zh-CN.rc
+++ b/base/applications/cmdutils/mode/lang/zh-CN.rc
@@ -14,13 +14,13 @@ BEGIN
显示模式: MODE CON[:] [COLS=c] [LINES=n]\n\
敲击速率: MODE CON[:] [RATE=r DELAY=d]\n"
- IDS_QUERY_SERIAL_FOUND " 发现串口设备 - %s\n"
- IDS_QUERY_PRINTER_FOUND " 发现打印设备 - %s\n"
- IDS_QUERY_PARALLEL_FOUND " 发现并口设备 - %s\n"
- IDS_QUERY_DOSDEV_FOUND " 发现 DOS 设备 - %s\n"
- // IDS_QUERY_MISC_FOUND " 发现其他设备 - %s\n"
+ IDS_QUERY_SERIAL_FOUND "发现串口设备 - %s\n"
+ IDS_QUERY_PRINTER_FOUND "发现打印设备 - %s\n"
+ IDS_QUERY_PARALLEL_FOUND "发现并口设备 - %s\n"
+ IDS_QUERY_DOSDEV_FOUND "发现 DOS 设备 - %s\n"
+ // IDS_QUERY_MISC_FOUND "发现其他设备 - %s\n"
- // IDS_QUERY_DEVICE_FOUND " 发现 %s 设备 - %s\n"
+ // IDS_QUERY_DEVICE_FOUND "发现 %s 设备 - %s\n"
// IDS_SERIAL "串口"
// IDS_PRINTER "并口"
// IDS_OTHER "其他"
@@ -59,6 +59,7 @@ BEGIN
IDS_ERROR_SET_PARALLEL_STATE "错误: SetParallelState(%d) - DefineDosDevice(%s)
(0x%lx)\n"
IDS_ERROR_INVALID_PARAMETER "无效参数 - %s\n"
IDS_ERROR_ILLEGAL_DEVICE_NAME "非法设备名 - %s (0x%lx)\n"
+ IDS_ERROR_DEVICE_NOT_AVAILABLE "The device %s is not currently
available.\n"
IDS_ERROR_STATUS_GET_DEVICE "无法获得设备 %s: 的状态\n"
IDS_ERROR_STATUS_SET_DEVICE "无法设置设备 %s: 的状态\n"
IDS_ERROR_TIMEOUT_GET_DEVICE "Failed to get the timeout for device %s:\n"
diff --git a/base/applications/cmdutils/mode/mode.c
b/base/applications/cmdutils/mode/mode.c
index f571549dfb..054564e3dd 100644
--- a/base/applications/cmdutils/mode/mode.c
+++ b/base/applications/cmdutils/mode/mode.c
@@ -29,6 +29,7 @@
*/
#include <stdio.h>
+#include <stdlib.h>
#include <windef.h>
#include <winbase.h>
@@ -40,7 +41,6 @@
#include "resource.h"
#define MAX_PORTNAME_LEN 20
-#define MAX_COMPORT_NUM 10
#define ASSERT(a)
@@ -72,76 +72,6 @@ UnderlinedResPrintf(
ConStreamWrite(Stream, szMsgBuffer, Len);
}
-int QueryDevices(VOID)
-{
- PWSTR Buffer, ptr;
- DWORD dwLen = MAX_PATH;
-
- /* Pre-allocate a buffer for QueryDosDeviceW() */
- Buffer = HeapAlloc(GetProcessHeap(), 0, dwLen * sizeof(WCHAR));
- if (Buffer == NULL)
- {
- /* We failed, bail out */
- ConPuts(StdErr, L"ERROR: Not enough memory\n");
- return 0;
- }
-
- for (;;)
- {
- *Buffer = UNICODE_NULL;
- if (QueryDosDeviceW(NULL, Buffer, dwLen))
- break;
-
- if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
- {
- /* We failed, bail out */
- ConPrintf(StdErr, L"ERROR: QueryDosDeviceW(...) failed: 0x%lx\n",
GetLastError());
- HeapFree(GetProcessHeap(), 0, Buffer);
- return 0;
- }
-
- /* The buffer was too small, try to re-allocate it */
- dwLen *= 2;
- ptr = HeapReAlloc(GetProcessHeap(), 0, Buffer, dwLen * sizeof(WCHAR));
- if (ptr == NULL)
- {
- /* We failed, bail out */
- ConPuts(StdErr, L"ERROR: Not enough memory\n");
- HeapFree(GetProcessHeap(), 0, Buffer);
- return 0;
- }
- Buffer = ptr;
- }
-
- for (ptr = Buffer; *ptr != UNICODE_NULL; ptr += wcslen(ptr) + 1)
- {
- if (wcsstr(ptr, L"COM"))
- {
- ConResPrintf(StdOut, IDS_QUERY_SERIAL_FOUND, ptr);
- }
- else if (wcsstr(ptr, L"PRN"))
- {
- ConResPrintf(StdOut, IDS_QUERY_PRINTER_FOUND, ptr);
- }
- else if (wcsstr(ptr, L"LPT"))
- {
- ConResPrintf(StdOut, IDS_QUERY_PARALLEL_FOUND, ptr);
- }
- else if (wcsstr(ptr, L"AUX") || wcsstr(ptr, L"NUL"))
- {
- ConResPrintf(StdOut, IDS_QUERY_DOSDEV_FOUND, ptr);
- }
- else
- {
- // ConResPrintf(StdOut, IDS_QUERY_MISC_FOUND, ptr);
- }
- }
-
- /* Free the buffer and return success */
- HeapFree(GetProcessHeap(), 0, Buffer);
- return 1;
-}
-
int ShowParallelStatus(INT nPortNum)
{
WCHAR buffer[250];
@@ -174,6 +104,7 @@ int ShowParallelStatus(INT nPortNum)
{
ConPrintf(StdErr, L"ERROR: QueryDosDeviceW(%s) failed: 0x%lx\n",
szPortName, GetLastError());
}
+ ConPuts(StdOut, L"\n");
return 1;
}
@@ -251,6 +182,8 @@ int ShowConsoleStatus(VOID)
ConResPrintf(StdOut, IDS_CONSOLE_KBD_DELAY, dwKbdDelay);
}
ConResPrintf(StdOut, IDS_CONSOLE_CODEPAGE, GetConsoleOutputCP());
+ ConPuts(StdOut, L"\n");
+
return 0;
}
@@ -261,6 +194,8 @@ int ShowConsoleCPStatus(VOID)
ConPuts(StdOut, L"\n");
ConResPrintf(StdOut, IDS_CONSOLE_CODEPAGE, GetConsoleOutputCP());
+ ConPuts(StdOut, L"\n");
+
return 0;
}
@@ -364,6 +299,7 @@ ResizeTextConsole(
/* Update the console screen buffer information */
GetConsoleScreenBufferInfo(hConOut, pcsbi);
+
return TRUE;
}
@@ -570,7 +506,11 @@ SerialPortQuery(INT nPortNum, LPDCB pDCB, LPCOMMTIMEOUTS
pCommTimeouts, BOOL bWr
if (hPort == INVALID_HANDLE_VALUE)
{
- ConResPrintf(StdErr, IDS_ERROR_ILLEGAL_DEVICE_NAME, szPortName, GetLastError());
+ DWORD dwLastError = GetLastError();
+ if (dwLastError == ERROR_ACCESS_DENIED)
+ ConResPrintf(StdErr, IDS_ERROR_DEVICE_NOT_AVAILABLE, szPortName);
+ else
+ ConResPrintf(StdErr, IDS_ERROR_ILLEGAL_DEVICE_NAME, szPortName,
dwLastError);
return FALSE;
}
@@ -654,6 +594,8 @@ int ShowSerialStatus(INT nPortNum)
control_strings[dcb.fDsrSensitivity ? 1 : 0]);
ConResPrintf(StdOut, IDS_COM_STATUS_DTR_CIRCUIT, control_strings[dcb.fDtrControl]);
ConResPrintf(StdOut, IDS_COM_STATUS_RTS_CIRCUIT, control_strings[dcb.fRtsControl]);
+ ConPuts(StdOut, L"\n");
+
return 0;
}
@@ -1108,24 +1050,100 @@ int SetSerialState(INT nPortNum, IN PCWSTR ArgStr)
static PCWSTR
FindPortNum(PCWSTR argStr, PINT PortNum)
{
- *PortNum = -1;
+ PWSTR endptr = NULL;
- if (*argStr >= L'0' && *argStr <= L'9')
+ *PortNum = wcstol(argStr, &endptr, 10);
+ if (endptr == argStr)
{
- *PortNum = *argStr - L'0';
- argStr++;
- if (*argStr >= L'0' && *argStr <= L'9')
+ *PortNum = -1;
+ return NULL;
+ }
+
+ return endptr;
+}
+
+int EnumerateDevices(VOID)
+{
+ PWSTR Buffer, ptr;
+ PCWSTR argStr;
+ DWORD dwLen = MAX_PATH;
+ INT nPortNum;
+
+ /* Pre-allocate a buffer for QueryDosDeviceW() */
+ Buffer = HeapAlloc(GetProcessHeap(), 0, dwLen * sizeof(WCHAR));
+ if (Buffer == NULL)
+ {
+ /* We failed, bail out */
+ ConPuts(StdErr, L"ERROR: Not enough memory\n");
+ return 0;
+ }
+
+ for (;;)
+ {
+ *Buffer = UNICODE_NULL;
+ if (QueryDosDeviceW(NULL, Buffer, dwLen))
+ break;
+
+ if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
+ {
+ /* We failed, bail out */
+ ConPrintf(StdErr, L"ERROR: QueryDosDeviceW(...) failed: 0x%lx\n",
GetLastError());
+ HeapFree(GetProcessHeap(), 0, Buffer);
+ return 0;
+ }
+
+ /* The buffer was too small, try to re-allocate it */
+ dwLen *= 2;
+ ptr = HeapReAlloc(GetProcessHeap(), 0, Buffer, dwLen * sizeof(WCHAR));
+ if (ptr == NULL)
{
- *PortNum *= 10;
- *PortNum += *argStr - L'0';
+ /* We failed, bail out */
+ ConPuts(StdErr, L"ERROR: Not enough memory\n");
+ HeapFree(GetProcessHeap(), 0, Buffer);
+ return 0;
}
+ Buffer = ptr;
}
- else
+
+ for (ptr = Buffer; *ptr != UNICODE_NULL; ptr += wcslen(ptr) + 1)
{
- return NULL;
+ if (_wcsnicmp(ptr, L"COM", 3) == 0)
+ {
+ argStr = FindPortNum(ptr+3, &nPortNum);
+ if (!argStr || *argStr || nPortNum == -1)
+ continue;
+
+ // ConResPrintf(StdOut, IDS_QUERY_SERIAL_FOUND, ptr);
+ ShowSerialStatus(nPortNum);
+ }
+ else if (_wcsicmp(ptr, L"PRN") == 0)
+ {
+ ConResPrintf(StdOut, IDS_QUERY_PRINTER_FOUND, ptr);
+ }
+ else if (_wcsnicmp(ptr, L"LPT", 3) == 0)
+ {
+ argStr = FindPortNum(ptr+3, &nPortNum);
+ if (!argStr || *argStr || nPortNum == -1)
+ continue;
+
+ // ConResPrintf(StdOut, IDS_QUERY_PARALLEL_FOUND, ptr);
+ ShowParallelStatus(nPortNum);
+ }
+ else if (_wcsicmp(ptr, L"AUX") == 0 || _wcsicmp(ptr, L"NUL")
== 0)
+ {
+ ConResPrintf(StdOut, IDS_QUERY_DOSDEV_FOUND, ptr);
+ }
+ else
+ {
+ // ConResPrintf(StdOut, IDS_QUERY_MISC_FOUND, ptr);
+ }
}
- return argStr;
+ ShowConsoleStatus();
+
+ /* Free the buffer and return success */
+ HeapFree(GetProcessHeap(), 0, Buffer);
+ return 1;
}
int wmain(int argc, WCHAR* argv[])
@@ -1273,15 +1291,7 @@ int wmain(int argc, WCHAR* argv[])
}
show_status:
- QueryDevices();
-/*
- ShowParallelStatus(1);
- for (nPortNum = 0; nPortNum < MAX_COMPORT_NUM; nPortNum++)
- {
- ShowSerialStatus(nPortNum + 1);
- }
- ShowConsoleStatus();
-*/
+ EnumerateDevices();
goto Quit;
invalid_parameter:
diff --git a/base/applications/cmdutils/mode/resource.h
b/base/applications/cmdutils/mode/resource.h
index c54e8ac31e..2916e47c2c 100644
--- a/base/applications/cmdutils/mode/resource.h
+++ b/base/applications/cmdutils/mode/resource.h
@@ -38,13 +38,14 @@
#define IDS_ERROR_SET_PARALLEL_STATE 26
#define IDS_ERROR_INVALID_PARAMETER 27
#define IDS_ERROR_ILLEGAL_DEVICE_NAME 28
-#define IDS_ERROR_STATUS_GET_DEVICE 29
-#define IDS_ERROR_STATUS_SET_DEVICE 30
-#define IDS_ERROR_TIMEOUT_GET_DEVICE 31
-#define IDS_ERROR_TIMEOUT_SET_DEVICE 32
-#define IDS_ERROR_INVALID_PARITY_BITS 33
-#define IDS_ERROR_INVALID_STOP_BITS 34
-#define IDS_ERROR_NO_MEMORY 35
-#define IDS_ERROR_SCREEN_LINES_COL 36
+#define IDS_ERROR_DEVICE_NOT_AVAILABLE 29
+#define IDS_ERROR_STATUS_GET_DEVICE 30
+#define IDS_ERROR_STATUS_SET_DEVICE 31
+#define IDS_ERROR_TIMEOUT_GET_DEVICE 32
+#define IDS_ERROR_TIMEOUT_SET_DEVICE 33
+#define IDS_ERROR_INVALID_PARITY_BITS 34
+#define IDS_ERROR_INVALID_STOP_BITS 35
+#define IDS_ERROR_NO_MEMORY 36
+#define IDS_ERROR_SCREEN_LINES_COL 37
#endif /* RESOURCE_H */