mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 11:53:21 +00:00
[MODE] Improve the way the DOS device statuses are enumerated via the "mode" command (without parameters).
This commit is contained in:
parent
37deb7593e
commit
3055afce81
8 changed files with 155 additions and 138 deletions
|
@ -14,13 +14,13 @@ Codepagestatus: MODE CON[:] CP [/STATUS]\n\
|
||||||
Anzeigemodus: MODE CON[:] [COLS=c] [LINES=n]\n\
|
Anzeigemodus: MODE CON[:] [COLS=c] [LINES=n]\n\
|
||||||
Tastaturwiederholrate: MODE CON[:] [RATE=r DELAY=d]\n"
|
Tastaturwiederholrate: MODE CON[:] [RATE=r DELAY=d]\n"
|
||||||
|
|
||||||
IDS_QUERY_SERIAL_FOUND " Serieller Anschluss gefunden - %s\n"
|
IDS_QUERY_SERIAL_FOUND "Serieller Anschluss gefunden - %s\n"
|
||||||
IDS_QUERY_PRINTER_FOUND " Drucker gefunden - %s\n"
|
IDS_QUERY_PRINTER_FOUND "Drucker gefunden - %s\n"
|
||||||
IDS_QUERY_PARALLEL_FOUND " Paralleler Anschluss gefunden - %s\n"
|
IDS_QUERY_PARALLEL_FOUND "Paralleler Anschluss gefunden - %s\n"
|
||||||
IDS_QUERY_DOSDEV_FOUND " Found DOS device - %s\n"
|
IDS_QUERY_DOSDEV_FOUND "Found DOS device - %s\n"
|
||||||
// IDS_QUERY_MISC_FOUND " Found other 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_SERIAL "serial"
|
||||||
// IDS_PRINTER "parallel"
|
// IDS_PRINTER "parallel"
|
||||||
// IDS_OTHER "other"
|
// IDS_OTHER "other"
|
||||||
|
@ -59,6 +59,7 @@ BEGIN
|
||||||
IDS_ERROR_SET_PARALLEL_STATE "ERROR: SetParallelState(%d) - DefineDosDevice(%s) (0x%lx)\n"
|
IDS_ERROR_SET_PARALLEL_STATE "ERROR: SetParallelState(%d) - DefineDosDevice(%s) (0x%lx)\n"
|
||||||
IDS_ERROR_INVALID_PARAMETER "Unzulässiger Parameter - %s\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_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_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_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"
|
IDS_ERROR_TIMEOUT_GET_DEVICE "Failed to get the timeout for device %s:\n"
|
||||||
|
|
|
@ -14,13 +14,13 @@ Code page status: MODE CON[:] CP [/STATUS]\n\
|
||||||
Display mode: MODE CON[:] [COLS=c] [LINES=n]\n\
|
Display mode: MODE CON[:] [COLS=c] [LINES=n]\n\
|
||||||
Typematic rate: MODE CON[:] [RATE=r DELAY=d]\n"
|
Typematic rate: MODE CON[:] [RATE=r DELAY=d]\n"
|
||||||
|
|
||||||
IDS_QUERY_SERIAL_FOUND " Found serial device - %s\n"
|
IDS_QUERY_SERIAL_FOUND "Found serial device - %s\n"
|
||||||
IDS_QUERY_PRINTER_FOUND " Found printer device - %s\n"
|
IDS_QUERY_PRINTER_FOUND "Found printer device - %s\n"
|
||||||
IDS_QUERY_PARALLEL_FOUND " Found parallel device - %s\n"
|
IDS_QUERY_PARALLEL_FOUND "Found parallel device - %s\n"
|
||||||
IDS_QUERY_DOSDEV_FOUND " Found DOS device - %s\n"
|
IDS_QUERY_DOSDEV_FOUND "Found DOS device - %s\n"
|
||||||
// IDS_QUERY_MISC_FOUND " Found other 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_SERIAL "serial"
|
||||||
// IDS_PRINTER "parallel"
|
// IDS_PRINTER "parallel"
|
||||||
// IDS_OTHER "other"
|
// IDS_OTHER "other"
|
||||||
|
@ -59,6 +59,7 @@ BEGIN
|
||||||
IDS_ERROR_SET_PARALLEL_STATE "ERROR: SetParallelState(%d) - DefineDosDevice(%s) (0x%lx)\n"
|
IDS_ERROR_SET_PARALLEL_STATE "ERROR: SetParallelState(%d) - DefineDosDevice(%s) (0x%lx)\n"
|
||||||
IDS_ERROR_INVALID_PARAMETER "Invalid parameter - %s\n"
|
IDS_ERROR_INVALID_PARAMETER "Invalid parameter - %s\n"
|
||||||
IDS_ERROR_ILLEGAL_DEVICE_NAME "Illegal device name - %s (0x%lx)\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_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_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"
|
IDS_ERROR_TIMEOUT_GET_DEVICE "Failed to get the timeout for device %s:\n"
|
||||||
|
|
|
@ -22,13 +22,13 @@ Modul de afișare:\n\
|
||||||
Rata de repetiție la menținerea unei taste apăsate:\n\
|
Rata de repetiție la menținerea unei taste apăsate:\n\
|
||||||
MODE CON[:] [RATE=r DELAY=d]\n"
|
MODE CON[:] [RATE=r DELAY=d]\n"
|
||||||
|
|
||||||
IDS_QUERY_SERIAL_FOUND " Depistat dispozitiv la portul serial - %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_PRINTER_FOUND "Depistat dispozitiv de imprimare - %s\n"
|
||||||
IDS_QUERY_PARALLEL_FOUND " Depistat dispozitiv la portul paralel - %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_DOSDEV_FOUND "Depistat dispozitiv de tip DOS - %s\n"
|
||||||
// IDS_QUERY_MISC_FOUND " Found other 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_SERIAL "serial"
|
||||||
// IDS_PRINTER "parallel"
|
// IDS_PRINTER "parallel"
|
||||||
// IDS_OTHER "other"
|
// IDS_OTHER "other"
|
||||||
|
@ -67,6 +67,7 @@ BEGIN
|
||||||
IDS_ERROR_SET_PARALLEL_STATE "EROARE: SetParallelState(%d) - DefineDosDevice(%s) (0x%lx)\n"
|
IDS_ERROR_SET_PARALLEL_STATE "EROARE: SetParallelState(%d) - DefineDosDevice(%s) (0x%lx)\n"
|
||||||
IDS_ERROR_INVALID_PARAMETER "Parametru nevalid - %s\n"
|
IDS_ERROR_INVALID_PARAMETER "Parametru nevalid - %s\n"
|
||||||
IDS_ERROR_ILLEGAL_DEVICE_NAME "Nume eronat de dispozitiv - %s (0x%lx)\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_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_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"
|
IDS_ERROR_TIMEOUT_GET_DEVICE "Failed to get the timeout for device %s:\n"
|
||||||
|
|
|
@ -14,13 +14,13 @@ BEGIN
|
||||||
Режим работы экрана: MODE CON[:] [COLS=c] [LINES=n]\n\
|
Режим работы экрана: MODE CON[:] [COLS=c] [LINES=n]\n\
|
||||||
Ввод с клавиатуры: MODE CON[:] [RATE=r DELAY=d]\n"
|
Ввод с клавиатуры: MODE CON[:] [RATE=r DELAY=d]\n"
|
||||||
|
|
||||||
IDS_QUERY_SERIAL_FOUND " Найдено последовательное устройство - %s\n"
|
IDS_QUERY_SERIAL_FOUND "Найдено последовательное устройство - %s\n"
|
||||||
IDS_QUERY_PRINTER_FOUND " Найдено устройство печати - %s\n"
|
IDS_QUERY_PRINTER_FOUND "Найдено устройство печати - %s\n"
|
||||||
IDS_QUERY_PARALLEL_FOUND " Найдено параллельное устройство - %s\n"
|
IDS_QUERY_PARALLEL_FOUND "Найдено параллельное устройство - %s\n"
|
||||||
IDS_QUERY_DOSDEV_FOUND " Найдено устройство DOS - %s\n"
|
IDS_QUERY_DOSDEV_FOUND "Найдено устройство DOS - %s\n"
|
||||||
// IDS_QUERY_MISC_FOUND " Найдено другое устройство - %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_SERIAL "последовательное"
|
||||||
// IDS_PRINTER "параллельное"
|
// IDS_PRINTER "параллельное"
|
||||||
// IDS_OTHER "другое"
|
// IDS_OTHER "другое"
|
||||||
|
@ -59,6 +59,7 @@ BEGIN
|
||||||
IDS_ERROR_SET_PARALLEL_STATE "ОШИБКА: SetParallelState(%d) - DefineDosDevice(%s) (0x%lx)\n"
|
IDS_ERROR_SET_PARALLEL_STATE "ОШИБКА: SetParallelState(%d) - DefineDosDevice(%s) (0x%lx)\n"
|
||||||
IDS_ERROR_INVALID_PARAMETER "Неверный параметр - %s\n"
|
IDS_ERROR_INVALID_PARAMETER "Неверный параметр - %s\n"
|
||||||
IDS_ERROR_ILLEGAL_DEVICE_NAME "Недопустимое имя устройства - %s (0x%lx)\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_GET_DEVICE "Не удалось получить состояние устройства %s:\n"
|
||||||
IDS_ERROR_STATUS_SET_DEVICE "Не удалось установить состояние устройства %s:\n"
|
IDS_ERROR_STATUS_SET_DEVICE "Не удалось установить состояние устройства %s:\n"
|
||||||
IDS_ERROR_TIMEOUT_GET_DEVICE "Failed to get the timeout for device %s:\n"
|
IDS_ERROR_TIMEOUT_GET_DEVICE "Failed to get the timeout for device %s:\n"
|
||||||
|
|
|
@ -16,13 +16,13 @@ Kod sayfası durumu: MODE CON[:] CP [/STATUS]\n\
|
||||||
Görüntü kipi: MODE CON[:] [COLS=c] [LINES=n]\n\
|
Görüntü kipi: MODE CON[:] [COLS=c] [LINES=n]\n\
|
||||||
Yineleme hızı: MODE CON[:] [RATE=r DELAY=d]\n"
|
Yineleme hızı: MODE CON[:] [RATE=r DELAY=d]\n"
|
||||||
|
|
||||||
IDS_QUERY_SERIAL_FOUND " Dizilik 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_PRINTER_FOUND "Yazıcı aygıtı bulundu - %s\n"
|
||||||
IDS_QUERY_PARALLEL_FOUND " Koşut 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_DOSDEV_FOUND "DOS aygıtı bulundu - %s\n"
|
||||||
// IDS_QUERY_MISC_FOUND " Başka 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_SERIAL "dizilik"
|
||||||
// IDS_PRINTER "koşut"
|
// IDS_PRINTER "koşut"
|
||||||
// IDS_OTHER "başka"
|
// 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_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_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_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_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_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"
|
IDS_ERROR_TIMEOUT_GET_DEVICE "Failed to get the timeout for device %s:\n"
|
||||||
|
|
|
@ -14,13 +14,13 @@ BEGIN
|
||||||
显示模式: MODE CON[:] [COLS=c] [LINES=n]\n\
|
显示模式: MODE CON[:] [COLS=c] [LINES=n]\n\
|
||||||
敲击速率: MODE CON[:] [RATE=r DELAY=d]\n"
|
敲击速率: MODE CON[:] [RATE=r DELAY=d]\n"
|
||||||
|
|
||||||
IDS_QUERY_SERIAL_FOUND " 发现串口设备 - %s\n"
|
IDS_QUERY_SERIAL_FOUND "发现串口设备 - %s\n"
|
||||||
IDS_QUERY_PRINTER_FOUND " 发现打印设备 - %s\n"
|
IDS_QUERY_PRINTER_FOUND "发现打印设备 - %s\n"
|
||||||
IDS_QUERY_PARALLEL_FOUND " 发现并口设备 - %s\n"
|
IDS_QUERY_PARALLEL_FOUND "发现并口设备 - %s\n"
|
||||||
IDS_QUERY_DOSDEV_FOUND " 发现 DOS 设备 - %s\n"
|
IDS_QUERY_DOSDEV_FOUND "发现 DOS 设备 - %s\n"
|
||||||
// IDS_QUERY_MISC_FOUND " 发现其他设备 - %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_SERIAL "串口"
|
||||||
// IDS_PRINTER "并口"
|
// IDS_PRINTER "并口"
|
||||||
// IDS_OTHER "其他"
|
// IDS_OTHER "其他"
|
||||||
|
@ -59,6 +59,7 @@ BEGIN
|
||||||
IDS_ERROR_SET_PARALLEL_STATE "错误: SetParallelState(%d) - DefineDosDevice(%s) (0x%lx)\n"
|
IDS_ERROR_SET_PARALLEL_STATE "错误: SetParallelState(%d) - DefineDosDevice(%s) (0x%lx)\n"
|
||||||
IDS_ERROR_INVALID_PARAMETER "无效参数 - %s\n"
|
IDS_ERROR_INVALID_PARAMETER "无效参数 - %s\n"
|
||||||
IDS_ERROR_ILLEGAL_DEVICE_NAME "非法设备名 - %s (0x%lx)\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_GET_DEVICE "无法获得设备 %s: 的状态\n"
|
||||||
IDS_ERROR_STATUS_SET_DEVICE "无法设置设备 %s: 的状态\n"
|
IDS_ERROR_STATUS_SET_DEVICE "无法设置设备 %s: 的状态\n"
|
||||||
IDS_ERROR_TIMEOUT_GET_DEVICE "Failed to get the timeout for device %s:\n"
|
IDS_ERROR_TIMEOUT_GET_DEVICE "Failed to get the timeout for device %s:\n"
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <windef.h>
|
#include <windef.h>
|
||||||
#include <winbase.h>
|
#include <winbase.h>
|
||||||
|
@ -40,7 +41,6 @@
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
|
|
||||||
#define MAX_PORTNAME_LEN 20
|
#define MAX_PORTNAME_LEN 20
|
||||||
#define MAX_COMPORT_NUM 10
|
|
||||||
|
|
||||||
#define ASSERT(a)
|
#define ASSERT(a)
|
||||||
|
|
||||||
|
@ -72,76 +72,6 @@ UnderlinedResPrintf(
|
||||||
ConStreamWrite(Stream, szMsgBuffer, Len);
|
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)
|
int ShowParallelStatus(INT nPortNum)
|
||||||
{
|
{
|
||||||
WCHAR buffer[250];
|
WCHAR buffer[250];
|
||||||
|
@ -174,6 +104,7 @@ int ShowParallelStatus(INT nPortNum)
|
||||||
{
|
{
|
||||||
ConPrintf(StdErr, L"ERROR: QueryDosDeviceW(%s) failed: 0x%lx\n", szPortName, GetLastError());
|
ConPrintf(StdErr, L"ERROR: QueryDosDeviceW(%s) failed: 0x%lx\n", szPortName, GetLastError());
|
||||||
}
|
}
|
||||||
|
ConPuts(StdOut, L"\n");
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -251,6 +182,8 @@ int ShowConsoleStatus(VOID)
|
||||||
ConResPrintf(StdOut, IDS_CONSOLE_KBD_DELAY, dwKbdDelay);
|
ConResPrintf(StdOut, IDS_CONSOLE_KBD_DELAY, dwKbdDelay);
|
||||||
}
|
}
|
||||||
ConResPrintf(StdOut, IDS_CONSOLE_CODEPAGE, GetConsoleOutputCP());
|
ConResPrintf(StdOut, IDS_CONSOLE_CODEPAGE, GetConsoleOutputCP());
|
||||||
|
ConPuts(StdOut, L"\n");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,6 +194,8 @@ int ShowConsoleCPStatus(VOID)
|
||||||
ConPuts(StdOut, L"\n");
|
ConPuts(StdOut, L"\n");
|
||||||
|
|
||||||
ConResPrintf(StdOut, IDS_CONSOLE_CODEPAGE, GetConsoleOutputCP());
|
ConResPrintf(StdOut, IDS_CONSOLE_CODEPAGE, GetConsoleOutputCP());
|
||||||
|
ConPuts(StdOut, L"\n");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -364,6 +299,7 @@ ResizeTextConsole(
|
||||||
|
|
||||||
/* Update the console screen buffer information */
|
/* Update the console screen buffer information */
|
||||||
GetConsoleScreenBufferInfo(hConOut, pcsbi);
|
GetConsoleScreenBufferInfo(hConOut, pcsbi);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -570,7 +506,11 @@ SerialPortQuery(INT nPortNum, LPDCB pDCB, LPCOMMTIMEOUTS pCommTimeouts, BOOL bWr
|
||||||
|
|
||||||
if (hPort == INVALID_HANDLE_VALUE)
|
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;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -654,6 +594,8 @@ int ShowSerialStatus(INT nPortNum)
|
||||||
control_strings[dcb.fDsrSensitivity ? 1 : 0]);
|
control_strings[dcb.fDsrSensitivity ? 1 : 0]);
|
||||||
ConResPrintf(StdOut, IDS_COM_STATUS_DTR_CIRCUIT, control_strings[dcb.fDtrControl]);
|
ConResPrintf(StdOut, IDS_COM_STATUS_DTR_CIRCUIT, control_strings[dcb.fDtrControl]);
|
||||||
ConResPrintf(StdOut, IDS_COM_STATUS_RTS_CIRCUIT, control_strings[dcb.fRtsControl]);
|
ConResPrintf(StdOut, IDS_COM_STATUS_RTS_CIRCUIT, control_strings[dcb.fRtsControl]);
|
||||||
|
ConPuts(StdOut, L"\n");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1108,24 +1050,100 @@ int SetSerialState(INT nPortNum, IN PCWSTR ArgStr)
|
||||||
static PCWSTR
|
static PCWSTR
|
||||||
FindPortNum(PCWSTR argStr, PINT PortNum)
|
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 *= 10;
|
|
||||||
*PortNum += *argStr - L'0';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
|
*PortNum = -1;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return argStr;
|
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)
|
||||||
|
{
|
||||||
|
/* 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 (_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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ShowConsoleStatus();
|
||||||
|
|
||||||
|
/* Free the buffer and return success */
|
||||||
|
HeapFree(GetProcessHeap(), 0, Buffer);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int wmain(int argc, WCHAR* argv[])
|
int wmain(int argc, WCHAR* argv[])
|
||||||
|
@ -1273,15 +1291,7 @@ int wmain(int argc, WCHAR* argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
show_status:
|
show_status:
|
||||||
QueryDevices();
|
EnumerateDevices();
|
||||||
/*
|
|
||||||
ShowParallelStatus(1);
|
|
||||||
for (nPortNum = 0; nPortNum < MAX_COMPORT_NUM; nPortNum++)
|
|
||||||
{
|
|
||||||
ShowSerialStatus(nPortNum + 1);
|
|
||||||
}
|
|
||||||
ShowConsoleStatus();
|
|
||||||
*/
|
|
||||||
goto Quit;
|
goto Quit;
|
||||||
|
|
||||||
invalid_parameter:
|
invalid_parameter:
|
||||||
|
|
|
@ -38,13 +38,14 @@
|
||||||
#define IDS_ERROR_SET_PARALLEL_STATE 26
|
#define IDS_ERROR_SET_PARALLEL_STATE 26
|
||||||
#define IDS_ERROR_INVALID_PARAMETER 27
|
#define IDS_ERROR_INVALID_PARAMETER 27
|
||||||
#define IDS_ERROR_ILLEGAL_DEVICE_NAME 28
|
#define IDS_ERROR_ILLEGAL_DEVICE_NAME 28
|
||||||
#define IDS_ERROR_STATUS_GET_DEVICE 29
|
#define IDS_ERROR_DEVICE_NOT_AVAILABLE 29
|
||||||
#define IDS_ERROR_STATUS_SET_DEVICE 30
|
#define IDS_ERROR_STATUS_GET_DEVICE 30
|
||||||
#define IDS_ERROR_TIMEOUT_GET_DEVICE 31
|
#define IDS_ERROR_STATUS_SET_DEVICE 31
|
||||||
#define IDS_ERROR_TIMEOUT_SET_DEVICE 32
|
#define IDS_ERROR_TIMEOUT_GET_DEVICE 32
|
||||||
#define IDS_ERROR_INVALID_PARITY_BITS 33
|
#define IDS_ERROR_TIMEOUT_SET_DEVICE 33
|
||||||
#define IDS_ERROR_INVALID_STOP_BITS 34
|
#define IDS_ERROR_INVALID_PARITY_BITS 34
|
||||||
#define IDS_ERROR_NO_MEMORY 35
|
#define IDS_ERROR_INVALID_STOP_BITS 35
|
||||||
#define IDS_ERROR_SCREEN_LINES_COL 36
|
#define IDS_ERROR_NO_MEMORY 36
|
||||||
|
#define IDS_ERROR_SCREEN_LINES_COL 37
|
||||||
|
|
||||||
#endif /* RESOURCE_H */
|
#endif /* RESOURCE_H */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue