mirror of
https://github.com/reactos/reactos.git
synced 2026-06-02 09:20:43 +08:00
[HOSTNAME] Update translated messages; use ConUtils for output
In particular:
- `IDS_NOSET`: When the user tries `hostname -s ...`, tell them that for
changing the computer host's name, one has to go in the "Computer Name"
tab in the "System" control panel applet.
NOTE: You may observe that Windows' hostname says instead,
"Use the Network Control Panel Applet to set hostname."
This piece of information is wrong since Windows 2000. Indeed:
* From NT 3.1 to NT 4, one had to change the host's name via the
"Network" control panel applet; the message was accurate back then.
* Since Windows 2000, one changes the computer's host name via the
"Network Identification" (Win2000) / "Computer Name" (WinXP and above)
tab of the "System" properties Control Panel applet.
* In addition, the ony "Network" feature in the Control Panel is the
"Network Connections" special folder and doesn't deal with the host name.
- Use the ConUtils library for uniform output (on console or redirected)
of localized string resources/messages. Supersedes PR #8739.
- Improve output of last-errors by showing their description, only
falling back to showing the error number if no description exists.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
|
||||
add_executable(hostname hostname.c hostname.rc)
|
||||
set_module_type(hostname win32cui UNICODE)
|
||||
add_importlibs(hostname user32 msvcrt kernel32)
|
||||
target_link_libraries(hostname conutils)
|
||||
add_importlibs(hostname msvcrt kernel32)
|
||||
add_cd_file(TARGET hostname DESTINATION reactos/system32 FOR all)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* PROJECT: ReactOS Hostname Command
|
||||
* LICENSE: LGPL-2.1+ (https://spdx.org/licenses/LGPL-2.1+)
|
||||
* LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
|
||||
* PURPOSE: Retrieves the current DNS host name of the computer.
|
||||
* COPYRIGHT: Copyright 2005-2019 Emanuele Aliberti (ea@reactos.com)
|
||||
* Copyright 2019 Hermes Belusca-Maito
|
||||
* COPYRIGHT: Copyright 2005 Emanuele Aliberti <ea@reactos.com>
|
||||
* Copyright 2019-2026 Hermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
@@ -11,13 +11,35 @@
|
||||
|
||||
#include <windef.h>
|
||||
#include <winbase.h>
|
||||
#include <winuser.h>
|
||||
|
||||
#include <conutils.h>
|
||||
|
||||
#include "resource.h"
|
||||
|
||||
static VOID
|
||||
PrintError(
|
||||
_In_opt_ PCWSTR Message,
|
||||
_In_ DWORD dwError)
|
||||
{
|
||||
INT Len;
|
||||
|
||||
if (dwError == ERROR_SUCCESS)
|
||||
return;
|
||||
|
||||
if (IS_INTRESOURCE(Message))
|
||||
ConResPuts(StdErr, PtrToUlong(Message));
|
||||
else // if (Message)
|
||||
ConPuts(StdErr, Message);
|
||||
Len = ConMsgPuts(StdErr, FORMAT_MESSAGE_FROM_SYSTEM,
|
||||
NULL, dwError, LANG_USER_DEFAULT);
|
||||
if (Len <= 0) /* Fall back in case the error is not defined */
|
||||
ConPrintf(StdErr, L"%lu\n", dwError);
|
||||
}
|
||||
|
||||
int wmain(int argc, WCHAR* argv[])
|
||||
{
|
||||
WCHAR Msg[100];
|
||||
/* Initialize the Console Standard Streams */
|
||||
ConInitStdStreams();
|
||||
|
||||
if (argc == 1)
|
||||
{
|
||||
@@ -36,11 +58,9 @@ int wmain(int argc, WCHAR* argv[])
|
||||
bSuccess = GetComputerNameExW(ComputerNameDnsHostname, HostName, &HostNameSize);
|
||||
}
|
||||
|
||||
/* Print out the host name */
|
||||
if (bSuccess)
|
||||
{
|
||||
/* Print out the host name */
|
||||
wprintf(L"%s\n", HostName);
|
||||
}
|
||||
ConPrintf(StdOut, L"%s\n", HostName);
|
||||
|
||||
/* If a larger buffer has been allocated, free it */
|
||||
if (HostName && (HostName != LocalHostName))
|
||||
@@ -49,8 +69,7 @@ int wmain(int argc, WCHAR* argv[])
|
||||
if (!bSuccess)
|
||||
{
|
||||
/* Fail in case of error */
|
||||
LoadStringW(GetModuleHandle(NULL), IDS_ERROR, Msg, _countof(Msg));
|
||||
wprintf(L"%s %lu.\n", Msg, GetLastError());
|
||||
PrintError(MAKEINTRESOURCEW(IDS_ERROR), GetLastError());
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -59,15 +78,13 @@ int wmain(int argc, WCHAR* argv[])
|
||||
if ((_wcsicmp(argv[1], L"-s") == 0) || (_wcsicmp(argv[1], L"/s") == 0))
|
||||
{
|
||||
/* The program doesn't allow the user to set the host name */
|
||||
LoadStringW(GetModuleHandle(NULL), IDS_NOSET, Msg, _countof(Msg));
|
||||
wprintf(L"%s\n", Msg);
|
||||
ConResPuts(StdErr, IDS_NOSET);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Let the user know what the program does */
|
||||
LoadStringW(GetModuleHandle(NULL), IDS_USAGE, Msg, _countof(Msg));
|
||||
wprintf(L"\n%s\n\n", Msg);
|
||||
ConResPuts(StdOut, IDS_USAGE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
|
||||
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
|
||||
|
||||
#define REACTOS_STR_FILE_DESCRIPTION "Host name application"
|
||||
#define REACTOS_STR_INTERNAL_NAME "hostname"
|
||||
#define REACTOS_STR_ORIGINAL_FILENAME "hostname.exe"
|
||||
#define REACTOS_STR_FILE_DESCRIPTION "Host name application"
|
||||
#define REACTOS_STR_INTERNAL_NAME "hostname"
|
||||
#define REACTOS_STR_ORIGINAL_FILENAME "hostname.exe"
|
||||
#include <reactos/version.rc>
|
||||
|
||||
/* UTF-8 */
|
||||
|
||||
@@ -7,7 +7,7 @@ LANGUAGE LANG_CZECH, SUBLANG_DEFAULT
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_USAGE "Vypíše současný název hostitele.\n\nhostname"
|
||||
IDS_NOSET "hostname -s není podporováno."
|
||||
IDS_ERROR "Win32 chyba"
|
||||
IDS_USAGE "\nVypíše současný název hostitele.\n\nhostname\n"
|
||||
IDS_NOSET "sethostname: Open the ""Computer Name"" tab in the ""System"" Control Panel applet\nto change the host name.\nhostname -s není podporováno.\n"
|
||||
IDS_ERROR "Chyba: "
|
||||
END
|
||||
|
||||
@@ -2,7 +2,7 @@ LANGUAGE LANG_GERMAN, SUBLANG_NEUTRAL
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_USAGE "Zeigt den Computernamen an.\n\nhostname"
|
||||
IDS_NOSET "Der Befehl hostname -s wird nicht unterstützt."
|
||||
IDS_ERROR "Win32-Fehler"
|
||||
IDS_USAGE "\nZeigt den Computernamen an.\n\nhostname\n"
|
||||
IDS_NOSET "sethostname: Open the ""Computer Name"" tab in the ""System"" Control Panel applet\nto change the host name.\nDer Befehl hostname -s wird nicht unterstützt.\n"
|
||||
IDS_ERROR "Fehler: "
|
||||
END
|
||||
|
||||
@@ -2,7 +2,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_USAGE "Print the current host's name.\n\nhostname"
|
||||
IDS_NOSET "hostname -s is not supported."
|
||||
IDS_ERROR "Win32 error"
|
||||
IDS_USAGE "\nPrint the current host's name.\n\nhostname\n"
|
||||
IDS_NOSET "sethostname: Open the ""Computer Name"" tab in the ""System"" Control Panel applet\nto change the host name.\nhostname -s is not supported.\n"
|
||||
IDS_ERROR "Error: "
|
||||
END
|
||||
|
||||
@@ -2,7 +2,7 @@ LANGUAGE LANG_ESTONIAN, SUBLANG_DEFAULT
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_USAGE "Trükib praeguse hosti nime.\n\nhostname"
|
||||
IDS_NOSET "hostname -s ei ole toetatud."
|
||||
IDS_ERROR "Win32 tõrge"
|
||||
IDS_USAGE "\nTrükib praeguse hosti nime.\n\nhostname\n"
|
||||
IDS_NOSET "sethostname: Open the ""Computer Name"" tab in the ""System"" Control Panel applet\nto change the host name.\nhostname -s ei ole toetatud.\n"
|
||||
IDS_ERROR "Tõrge: "
|
||||
END
|
||||
|
||||
@@ -2,7 +2,7 @@ LANGUAGE LANG_FRENCH, SUBLANG_NEUTRAL
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_USAGE "Affiche le nom de l'hôte actuel.\n\nhostname"
|
||||
IDS_NOSET "hostname -s n'est pas pris en charge."
|
||||
IDS_ERROR "Erreur Win32"
|
||||
IDS_USAGE "\nAffiche le nom de l'hôte actuel.\n\nhostname\n"
|
||||
IDS_NOSET "sethostname: Ouvrez l'onglet ""Nom de l'ordinateur"" de l'élément ""Système""\ndu Panneau de configuration pour modifier le nom de l'hôte.\nhostname -s n'est pas pris en charge.\n"
|
||||
IDS_ERROR "Erreur : "
|
||||
END
|
||||
|
||||
@@ -2,7 +2,7 @@ LANGUAGE LANG_ITALIAN, SUBLANG_NEUTRAL
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_USAGE "Stampa il nome dell'host attuale.\n\nhostname"
|
||||
IDS_NOSET "hostname -s non è supportato."
|
||||
IDS_ERROR "errore Win32"
|
||||
IDS_USAGE "\nStampa il nome dell'host attuale.\n\nhostname\n"
|
||||
IDS_NOSET "sethostname: Open the ""Computer Name"" tab in the ""System"" Control Panel applet\nto change the host name.\nhostname -s non è supportato.\n"
|
||||
IDS_ERROR "Errore: "
|
||||
END
|
||||
|
||||
@@ -2,7 +2,7 @@ LANGUAGE LANG_POLISH, SUBLANG_DEFAULT
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_USAGE "Wyświetla obecną nazwę komputera.\n\nhostname"
|
||||
IDS_NOSET "Opcja hostname -s nie jest wspierana."
|
||||
IDS_ERROR "Błąd Win32"
|
||||
IDS_USAGE "\nWyświetla obecną nazwę komputera.\n\nhostname\n"
|
||||
IDS_NOSET "sethostname: Open the ""Computer Name"" tab in the ""System"" Control Panel applet\nto change the host name.\nOpcja hostname -s nie jest wspierana.\n"
|
||||
IDS_ERROR "Błąd: "
|
||||
END
|
||||
|
||||
@@ -4,7 +4,7 @@ LANGUAGE LANG_ROMANIAN, SUBLANG_NEUTRAL
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_USAGE "Tipărește numele gazdei curente.\n\nhostname"
|
||||
IDS_NOSET "hostname -s nu este acceptat."
|
||||
IDS_ERROR "Eroare Win32"
|
||||
IDS_USAGE "\nTipărește numele gazdei curente.\n\nhostname\n"
|
||||
IDS_NOSET "sethostname: Open the ""Computer Name"" tab in the ""System"" Control Panel applet\nto change the host name.\nhostname -s nu este acceptat.\n"
|
||||
IDS_ERROR "Eroare: "
|
||||
END
|
||||
|
||||
@@ -2,7 +2,7 @@ LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_USAGE "Печать имени текущего узла.\n\nhostname"
|
||||
IDS_NOSET "hostname -s не поддерживается."
|
||||
IDS_ERROR "Ошибка Win32"
|
||||
IDS_USAGE "\nПечать имени текущего узла.\n\nhostname\n"
|
||||
IDS_NOSET "sethostname: Open the ""Computer Name"" tab in the ""System"" Control Panel applet\nto change the host name.\nhostname -s не поддерживается.\n"
|
||||
IDS_ERROR "Ошибка: "
|
||||
END
|
||||
|
||||
@@ -9,7 +9,7 @@ LANGUAGE LANG_SLOVAK, SUBLANG_DEFAULT
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_USAGE "Vypíše súčasný názov hostiteľa.\n\nhostname"
|
||||
IDS_NOSET "hostname -s nie je podporovaný."
|
||||
IDS_ERROR "Chyba Win32"
|
||||
IDS_USAGE "\nVypíše súčasný názov hostiteľa.\n\nhostname\n"
|
||||
IDS_NOSET "sethostname: Open the ""Computer Name"" tab in the ""System"" Control Panel applet\nto change the host name.\nhostname -s nie je podporovaný.\n"
|
||||
IDS_ERROR "Chyba: "
|
||||
END
|
||||
|
||||
@@ -6,7 +6,7 @@ LANGUAGE LANG_ALBANIAN, SUBLANG_NEUTRAL
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_USAGE "Print emrin e strehuesit aktual.\n\nhostname"
|
||||
IDS_NOSET "Strehuesi nuk është i mbështetur."
|
||||
IDS_ERROR "Win32 error"
|
||||
IDS_USAGE "\nPrint emrin e strehuesit aktual.\n\nhostname\n"
|
||||
IDS_NOSET "sethostname: Open the ""Computer Name"" tab in the ""System"" Control Panel applet\nto change the host name.\nStrehuesi nuk është i mbështetur.\n"
|
||||
IDS_ERROR "Error: "
|
||||
END
|
||||
|
||||
@@ -4,7 +4,7 @@ LANGUAGE LANG_TURKISH, SUBLANG_DEFAULT
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_USAGE "Şimdiki anabilgisayarın adını yazdırır.\n\nhostname"
|
||||
IDS_NOSET "hostname -s desteklenmiyor."
|
||||
IDS_ERROR "Win32 hatası"
|
||||
IDS_USAGE "\nŞimdiki anabilgisayarın adını yazdırır.\n\nhostname\n"
|
||||
IDS_NOSET "sethostname: Open the ""Computer Name"" tab in the ""System"" Control Panel applet\nto change the host name.\nhostname -s desteklenmiyor.\n"
|
||||
IDS_ERROR "Hatası: "
|
||||
END
|
||||
|
||||
@@ -4,7 +4,7 @@ LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_USAGE "打印当前主机名。\n\nhostname"
|
||||
IDS_NOSET "hostname -s 不受支持。"
|
||||
IDS_ERROR "Win32 错误"
|
||||
IDS_USAGE "\n打印当前主机名。\n\nhostname\n"
|
||||
IDS_NOSET "sethostname: Open the ""Computer Name"" tab in the ""System"" Control Panel applet\nto change the host name.\nhostname -s 不受支持。\n"
|
||||
IDS_ERROR "错误: "
|
||||
END
|
||||
|
||||
@@ -10,7 +10,7 @@ LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_TRADITIONAL
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_USAGE "列印目前主機的名稱。\n\nhostname"
|
||||
IDS_NOSET "不支援 hostname -s。"
|
||||
IDS_ERROR "Win32 錯誤"
|
||||
IDS_USAGE "\n列印目前主機的名稱。\n\nhostname\n"
|
||||
IDS_NOSET "sethostname: Open the ""Computer Name"" tab in the ""System"" Control Panel applet\nto change the host name.\n不支援 hostname -s。\n"
|
||||
IDS_ERROR "錯誤: "
|
||||
END
|
||||
|
||||
Reference in New Issue
Block a user