Commit 751f8e3d authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

hostname: Use GetComputerNameW to get hostname.

parent d0798a74
......@@ -11434,6 +11434,12 @@ msgid "Error: Invalid option '%c'.\n"
msgstr "خطأ: خيار عير سليم '%c'.\n"
#: hostname.rc:32
#, fuzzy
#| msgid "Error: Could not find process \"%1\".\n"
msgid "Error: Could not get hostname: %u.\n"
msgstr "خطأ : لم يتم العثور على العملية \"%1\".\n"
#: hostname.rc:33
msgid ""
"Error: Setting the system hostname is not possible with the hostname "
"utility.\n"
......
......@@ -10923,6 +10923,10 @@ msgid "Error: Invalid option '%c'.\n"
msgstr ""
#: hostname.rc:32
msgid "Error: Could not get hostname: %u.\n"
msgstr ""
#: hostname.rc:33
msgid ""
"Error: Setting the system hostname is not possible with the hostname "
"utility.\n"
......
......@@ -11182,6 +11182,12 @@ msgid "Error: Invalid option '%c'.\n"
msgstr "Error: L'opció '%c' no és vàlida.\n"
#: hostname.rc:32
#, fuzzy
#| msgid "Error: Could not find process \"%1\".\n"
msgid "Error: Could not get hostname: %u.\n"
msgstr "Error: No s'ha pogut trobar el procés \"%1\".\n"
#: hostname.rc:33
msgid ""
"Error: Setting the system hostname is not possible with the hostname "
"utility.\n"
......
......@@ -10959,6 +10959,12 @@ msgid "Error: Invalid option '%c'.\n"
msgstr "Chyba: neplatná volba „%c“.\n"
#: hostname.rc:32
#, fuzzy
#| msgid "Error: Could not find process \"%1\".\n"
msgid "Error: Could not get hostname: %u.\n"
msgstr "Chyba: Nelze nalézt proces „%1“.\n"
#: hostname.rc:33
msgid ""
"Error: Setting the system hostname is not possible with the hostname "
"utility.\n"
......
......@@ -11347,6 +11347,12 @@ msgid "Error: Invalid option '%c'.\n"
msgstr "Fejl: Ugyldig valgmulighed '%c'.\n"
#: hostname.rc:32
#, fuzzy
#| msgid "Error: Could not find process \"%1\".\n"
msgid "Error: Could not get hostname: %u.\n"
msgstr "Fejl: Kunne ikke finde processen «%1».\n"
#: hostname.rc:33
msgid ""
"Error: Setting the system hostname is not possible with the hostname "
"utility.\n"
......
......@@ -11135,6 +11135,12 @@ msgid "Error: Invalid option '%c'.\n"
msgstr "Fehler: Ungültige Option '%c'.\n"
#: hostname.rc:32
#, fuzzy
#| msgid "Error: Could not find process \"%1\".\n"
msgid "Error: Could not get hostname: %u.\n"
msgstr "Fehler: Prozess \"%1\" konnte nicht gefunden werden.\n"
#: hostname.rc:33
msgid ""
"Error: Setting the system hostname is not possible with the hostname "
"utility.\n"
......
......@@ -10726,6 +10726,10 @@ msgid "Error: Invalid option '%c'.\n"
msgstr ""
#: hostname.rc:32
msgid "Error: Could not get hostname: %u.\n"
msgstr ""
#: hostname.rc:33
msgid ""
"Error: Setting the system hostname is not possible with the hostname "
"utility.\n"
......
......@@ -11054,6 +11054,10 @@ msgid "Error: Invalid option '%c'.\n"
msgstr "Error: Invalid option '%c'.\n"
#: hostname.rc:32
msgid "Error: Could not get hostname: %u.\n"
msgstr "Error: Could not get hostname: %u.\n"
#: hostname.rc:33
msgid ""
"Error: Setting the system hostname is not possible with the hostname "
"utility.\n"
......
......@@ -11054,6 +11054,10 @@ msgid "Error: Invalid option '%c'.\n"
msgstr "Error: Invalid option '%c'.\n"
#: hostname.rc:32
msgid "Error: Could not get hostname: %u.\n"
msgstr "Error: Could not get hostname: %u.\n"
#: hostname.rc:33
msgid ""
"Error: Setting the system hostname is not possible with the hostname "
"utility.\n"
......
......@@ -10677,6 +10677,10 @@ msgid "Error: Invalid option '%c'.\n"
msgstr ""
#: hostname.rc:32
msgid "Error: Could not get hostname: %u.\n"
msgstr ""
#: hostname.rc:33
msgid ""
"Error: Setting the system hostname is not possible with the hostname "
"utility.\n"
......
......@@ -11419,6 +11419,12 @@ msgid "Error: Invalid option '%c'.\n"
msgstr "Error: Opción '%c' inválida.\n"
#: hostname.rc:32
#, fuzzy
#| msgid "Error: Could not find process \"%1\".\n"
msgid "Error: Could not get hostname: %u.\n"
msgstr "Error: No se pudo encontrar el proceso \"%1\".\n"
#: hostname.rc:33
msgid ""
"Error: Setting the system hostname is not possible with the hostname "
"utility.\n"
......
......@@ -10711,6 +10711,10 @@ msgid "Error: Invalid option '%c'.\n"
msgstr ""
#: hostname.rc:32
msgid "Error: Could not get hostname: %u.\n"
msgstr ""
#: hostname.rc:33
msgid ""
"Error: Setting the system hostname is not possible with the hostname "
"utility.\n"
......
......@@ -11032,6 +11032,12 @@ msgid "Error: Invalid option '%c'.\n"
msgstr "Virhe: Virheellinen valinta '%c'.\n"
#: hostname.rc:32
#, fuzzy
#| msgid "Error: Could not find process \"%1\".\n"
msgid "Error: Could not get hostname: %u.\n"
msgstr "Virhe: Prosessia \"%1\" ei löytynyt.\n"
#: hostname.rc:33
msgid ""
"Error: Setting the system hostname is not possible with the hostname "
"utility.\n"
......
......@@ -11320,6 +11320,12 @@ msgid "Error: Invalid option '%c'.\n"
msgstr "Erreur : option « %c » invalide.\n"
#: hostname.rc:32
#, fuzzy
#| msgid "Error: Could not find process \"%1\".\n"
msgid "Error: Could not get hostname: %u.\n"
msgstr "Erreur : processus « %1 » introuvable.\n"
#: hostname.rc:33
msgid ""
"Error: Setting the system hostname is not possible with the hostname "
"utility.\n"
......
......@@ -11114,6 +11114,12 @@ msgid "Error: Invalid option '%c'.\n"
msgstr "Error: Invalid option '%c'.\n"
#: hostname.rc:32
#, fuzzy
#| msgid "Error: Could not find process \"%1\".\n"
msgid "Error: Could not get hostname: %u.\n"
msgstr "Error: Could not find process \"%1\".\n"
#: hostname.rc:33
msgid ""
"Error: Setting the system hostname is not possible with the hostname "
"utility.\n"
......
......@@ -10537,6 +10537,10 @@ msgid "Error: Invalid option '%c'.\n"
msgstr ""
#: hostname.rc:32
msgid "Error: Could not get hostname: %u.\n"
msgstr ""
#: hostname.rc:33
msgid ""
"Error: Setting the system hostname is not possible with the hostname "
"utility.\n"
......
......@@ -10905,6 +10905,10 @@ msgid "Error: Invalid option '%c'.\n"
msgstr "Greška: Neispravna opcija '%c'.\n"
#: hostname.rc:32
msgid "Error: Could not get hostname: %u.\n"
msgstr ""
#: hostname.rc:33
msgid ""
"Error: Setting the system hostname is not possible with the hostname "
"utility.\n"
......
......@@ -11338,6 +11338,12 @@ msgid "Error: Invalid option '%c'.\n"
msgstr "Hiba: Érvénytelen opció '%c'.\n"
#: hostname.rc:32
#, fuzzy
#| msgid "Error: Could not find process \"%1\".\n"
msgid "Error: Could not get hostname: %u.\n"
msgstr "Hiba: A \"%1\" folyamat nem található.\n"
#: hostname.rc:33
msgid ""
"Error: Setting the system hostname is not possible with the hostname "
"utility.\n"
......
......@@ -11420,6 +11420,12 @@ msgid "Error: Invalid option '%c'.\n"
msgstr "Errore: opzione non valida '%c'.\n"
#: hostname.rc:32
#, fuzzy
#| msgid "Error: Could not find process \"%1\".\n"
msgid "Error: Could not get hostname: %u.\n"
msgstr "Errore: processo non trovato \"%1\".\n"
#: hostname.rc:33
msgid ""
"Error: Setting the system hostname is not possible with the hostname "
"utility.\n"
......
......@@ -11041,6 +11041,12 @@ msgid "Error: Invalid option '%c'.\n"
msgstr "エラー: 無効なオプション '%c'。\n"
#: hostname.rc:32
#, fuzzy
#| msgid "Error: Could not find process \"%1\".\n"
msgid "Error: Could not get hostname: %u.\n"
msgstr "エラー: プロセス(%1)が見つかりません。\n"
#: hostname.rc:33
msgid ""
"Error: Setting the system hostname is not possible with the hostname "
"utility.\n"
......
......@@ -11232,6 +11232,12 @@ msgid "Error: Invalid option '%c'.\n"
msgstr "오류: 올바르지 않은 옵션 '%c'.\n"
#: hostname.rc:32
#, fuzzy
#| msgid "Error: Could not find process \"%1\".\n"
msgid "Error: Could not get hostname: %u.\n"
msgstr "오류: 프로세스 \"%1\"를 찾을 수 없습니다.\n"
#: hostname.rc:33
msgid ""
"Error: Setting the system hostname is not possible with the hostname "
"utility.\n"
......
......@@ -11060,6 +11060,12 @@ msgid "Error: Invalid option '%c'.\n"
msgstr "Klaida: netinkamas parametras „%c“.\n"
#: hostname.rc:32
#, fuzzy
#| msgid "Error: Could not find process \"%1\".\n"
msgid "Error: Could not get hostname: %u.\n"
msgstr "Klaida: nepavyko rasti proceso „%1“.\n"
#: hostname.rc:33
msgid ""
"Error: Setting the system hostname is not possible with the hostname "
"utility.\n"
......
......@@ -10537,6 +10537,10 @@ msgid "Error: Invalid option '%c'.\n"
msgstr ""
#: hostname.rc:32
msgid "Error: Could not get hostname: %u.\n"
msgstr ""
#: hostname.rc:33
msgid ""
"Error: Setting the system hostname is not possible with the hostname "
"utility.\n"
......
......@@ -11054,6 +11054,12 @@ msgid "Error: Invalid option '%c'.\n"
msgstr "Feil: \"%c\" er et ugyldig valg.\n"
#: hostname.rc:32
#, fuzzy
#| msgid "Error: Could not find process \"%1\".\n"
msgid "Error: Could not get hostname: %u.\n"
msgstr "Feil: Klarte ikke finne prosessen \"%1\".\n"
#: hostname.rc:33
msgid ""
"Error: Setting the system hostname is not possible with the hostname "
"utility.\n"
......
......@@ -11383,6 +11383,12 @@ msgid "Error: Invalid option '%c'.\n"
msgstr "Fout: Ongeldige optie '%c'.\n"
#: hostname.rc:32
#, fuzzy
#| msgid "Error: Could not find process \"%1\".\n"
msgid "Error: Could not get hostname: %u.\n"
msgstr "Fout: Kon proces \"%1\" niet vinden.\n"
#: hostname.rc:33
msgid ""
"Error: Setting the system hostname is not possible with the hostname "
"utility.\n"
......
......@@ -10537,6 +10537,10 @@ msgid "Error: Invalid option '%c'.\n"
msgstr ""
#: hostname.rc:32
msgid "Error: Could not get hostname: %u.\n"
msgstr ""
#: hostname.rc:33
msgid ""
"Error: Setting the system hostname is not possible with the hostname "
"utility.\n"
......
......@@ -10537,6 +10537,10 @@ msgid "Error: Invalid option '%c'.\n"
msgstr ""
#: hostname.rc:32
msgid "Error: Could not get hostname: %u.\n"
msgstr ""
#: hostname.rc:33
msgid ""
"Error: Setting the system hostname is not possible with the hostname "
"utility.\n"
......
......@@ -11126,6 +11126,12 @@ msgid "Error: Invalid option '%c'.\n"
msgstr "Błąd: Nieprawidłowa opcja '%c'.\n"
#: hostname.rc:32
#, fuzzy
#| msgid "Error: Could not find process \"%1\".\n"
msgid "Error: Could not get hostname: %u.\n"
msgstr "Błąd: Nie można znaleźć procesu \"%1\".\n"
#: hostname.rc:33
msgid ""
"Error: Setting the system hostname is not possible with the hostname "
"utility.\n"
......
......@@ -11251,6 +11251,12 @@ msgid "Error: Invalid option '%c'.\n"
msgstr "Erro: Opção inválida '%c'.\n"
#: hostname.rc:32
#, fuzzy
#| msgid "Error: Could not find process \"%1\".\n"
msgid "Error: Could not get hostname: %u.\n"
msgstr "Erro: Não foi possível encontrar o processo \"%1\".\n"
#: hostname.rc:33
msgid ""
"Error: Setting the system hostname is not possible with the hostname "
"utility.\n"
......
......@@ -11097,6 +11097,12 @@ msgid "Error: Invalid option '%c'.\n"
msgstr "Erro: opção inválida '%c'.\n"
#: hostname.rc:32
#, fuzzy
#| msgid "Error: Could not find process \"%1\".\n"
msgid "Error: Could not get hostname: %u.\n"
msgstr "Erro: Incapaz de encontrar o processo \"%1\".\n"
#: hostname.rc:33
msgid ""
"Error: Setting the system hostname is not possible with the hostname "
"utility.\n"
......
......@@ -10618,6 +10618,10 @@ msgid "Error: Invalid option '%c'.\n"
msgstr ""
#: hostname.rc:32
msgid "Error: Could not get hostname: %u.\n"
msgstr ""
#: hostname.rc:33
msgid ""
"Error: Setting the system hostname is not possible with the hostname "
"utility.\n"
......
......@@ -11204,6 +11204,12 @@ msgid "Error: Invalid option '%c'.\n"
msgstr "Eroare: Opțiune nevalidă „%c”.\n"
#: hostname.rc:32
#, fuzzy
#| msgid "Error: Could not find process \"%1\".\n"
msgid "Error: Could not get hostname: %u.\n"
msgstr "Eroare: Procesul „%1” nu a putut fi găsit.\n"
#: hostname.rc:33
msgid ""
"Error: Setting the system hostname is not possible with the hostname "
"utility.\n"
......
......@@ -11055,6 +11055,12 @@ msgid "Error: Invalid option '%c'.\n"
msgstr "Ошибка: неверная опция «%c».\n"
#: hostname.rc:32
#, fuzzy
#| msgid "Error: Could not find process \"%1\".\n"
msgid "Error: Could not get hostname: %u.\n"
msgstr "Ошибка: не удалось найти Процесс «%1».\n"
#: hostname.rc:33
msgid ""
"Error: Setting the system hostname is not possible with the hostname "
"utility.\n"
......
......@@ -10813,6 +10813,12 @@ msgid "Error: Invalid option '%c'.\n"
msgstr ""
#: hostname.rc:32
#, fuzzy
#| msgid "Error: Could not find process \"%1\".\n"
msgid "Error: Could not get hostname: %u.\n"
msgstr "Chyba: Nemôžno nájsť proces \"%1\".\n"
#: hostname.rc:33
msgid ""
"Error: Setting the system hostname is not possible with the hostname "
"utility.\n"
......
......@@ -11369,6 +11369,12 @@ msgid "Error: Invalid option '%c'.\n"
msgstr "Napaka: neveljavna možnost '%c'.\n"
#: hostname.rc:32
#, fuzzy
#| msgid "Error: Could not find process \"%1\".\n"
msgid "Error: Could not get hostname: %u.\n"
msgstr "Napaka: ni mogoče najti opravila \"%1\".\n"
#: hostname.rc:33
msgid ""
"Error: Setting the system hostname is not possible with the hostname "
"utility.\n"
......
......@@ -11153,6 +11153,10 @@ msgid "Error: Invalid option '%c'.\n"
msgstr "Неисправна синтакса"
#: hostname.rc:32
msgid "Error: Could not get hostname: %u.\n"
msgstr ""
#: hostname.rc:33
msgid ""
"Error: Setting the system hostname is not possible with the hostname "
"utility.\n"
......
......@@ -11275,6 +11275,10 @@ msgid "Error: Invalid option '%c'.\n"
msgstr "Neispravna sintaksa"
#: hostname.rc:32
msgid "Error: Could not get hostname: %u.\n"
msgstr ""
#: hostname.rc:33
msgid ""
"Error: Setting the system hostname is not possible with the hostname "
"utility.\n"
......
......@@ -11089,6 +11089,12 @@ msgid "Error: Invalid option '%c'.\n"
msgstr "Fel: Flaggan '%c' är ogiltig.\n"
#: hostname.rc:32
#, fuzzy
#| msgid "Error: Could not find process \"%1\".\n"
msgid "Error: Could not get hostname: %u.\n"
msgstr "Fel: Kunde inte hitta processen \"%1\".\n"
#: hostname.rc:33
msgid ""
"Error: Setting the system hostname is not possible with the hostname "
"utility.\n"
......
......@@ -10537,6 +10537,10 @@ msgid "Error: Invalid option '%c'.\n"
msgstr ""
#: hostname.rc:32
msgid "Error: Could not get hostname: %u.\n"
msgstr ""
#: hostname.rc:33
msgid ""
"Error: Setting the system hostname is not possible with the hostname "
"utility.\n"
......
......@@ -10757,6 +10757,10 @@ msgid "Error: Invalid option '%c'.\n"
msgstr ""
#: hostname.rc:32
msgid "Error: Could not get hostname: %u.\n"
msgstr ""
#: hostname.rc:33
msgid ""
"Error: Setting the system hostname is not possible with the hostname "
"utility.\n"
......
......@@ -11105,6 +11105,12 @@ msgid "Error: Invalid option '%c'.\n"
msgstr "Hata: '%c' geçersiz seçenek.\n"
#: hostname.rc:32
#, fuzzy
#| msgid "Error: Could not find process \"%1\".\n"
msgid "Error: Could not get hostname: %u.\n"
msgstr "Hata: \"%1\" işlemi bulunamıyor.\n"
#: hostname.rc:33
msgid ""
"Error: Setting the system hostname is not possible with the hostname "
"utility.\n"
......
......@@ -11132,6 +11132,12 @@ msgid "Error: Invalid option '%c'.\n"
msgstr "Помилка: невірний параметр '%c'.\n"
#: hostname.rc:32
#, fuzzy
#| msgid "Error: Could not find process \"%1\".\n"
msgid "Error: Could not get hostname: %u.\n"
msgstr "Помилка: Не вдалось знайти процес \"%1\".\n"
#: hostname.rc:33
msgid ""
"Error: Setting the system hostname is not possible with the hostname "
"utility.\n"
......
......@@ -10682,6 +10682,10 @@ msgid "Error: Invalid option '%c'.\n"
msgstr ""
#: hostname.rc:32
msgid "Error: Could not get hostname: %u.\n"
msgstr ""
#: hostname.rc:33
msgid ""
"Error: Setting the system hostname is not possible with the hostname "
"utility.\n"
......
......@@ -10470,6 +10470,10 @@ msgid "Error: Invalid option '%c'.\n"
msgstr ""
#: hostname.rc:32
msgid "Error: Could not get hostname: %u.\n"
msgstr ""
#: hostname.rc:33
msgid ""
"Error: Setting the system hostname is not possible with the hostname "
"utility.\n"
......
......@@ -10847,6 +10847,12 @@ msgid "Error: Invalid option '%c'.\n"
msgstr "错误:无效的选项 '%c'。\n"
#: hostname.rc:32
#, fuzzy
#| msgid "Error: Could not find process \"%1\".\n"
msgid "Error: Could not get hostname: %u.\n"
msgstr "错误:找不到进程 \"%1\"。\n"
#: hostname.rc:33
msgid ""
"Error: Setting the system hostname is not possible with the hostname "
"utility.\n"
......
......@@ -11344,6 +11344,12 @@ msgid "Error: Invalid option '%c'.\n"
msgstr "錯誤:無效的選項 %c。\n"
#: hostname.rc:32
#, fuzzy
#| msgid "Error: Could not find process \"%1\".\n"
msgid "Error: Could not get hostname: %u.\n"
msgstr "錯誤:找不到行程 %1。\n"
#: hostname.rc:33
msgid ""
"Error: Setting the system hostname is not possible with the hostname "
"utility.\n"
......
MODULE = hostname.exe
APPMODE = -mconsole -municode
EXTRALIBS = $(SOCKET_LIBS)
DELAYIMPORTS = user32
C_SRCS = hostname.c
......
......@@ -19,16 +19,7 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "wine/port.h"
#include <stdarg.h>
#if defined(__MINGW32__) || defined (_MSC_VER)
#include <winsock2.h>
#elif defined(HAVE_UNISTD_H)
#include <unistd.h>
#endif
#include <windef.h>
#include <winbase.h>
#include <wincon.h>
......@@ -109,17 +100,23 @@ static int hostname_message(int msg)
return hostname_printfW(formatW, msg_buffer);
}
static void display_computer_name(void)
static int display_computer_name(void)
{
static const WCHAR fmtW[] = {'%','s','\r','\n',0};
char nameA[256];
WCHAR nameW[256];
WCHAR name[MAX_COMPUTERNAME_LENGTH + 1];
DWORD size = ARRAY_SIZE(name);
BOOL ret;
gethostname(nameA, sizeof(nameA));
MultiByteToWideChar(CP_UNIXCP, 0, nameA, sizeof(nameA), nameW, ARRAY_SIZE(nameW));
ret = GetComputerNameW(name, &size);
if (!ret)
{
hostname_message_printfW(STRING_CANNOT_GET_HOSTNAME, GetLastError());
return 1;
}
hostname_printfW(fmtW, nameW);
hostname_printfW(fmtW, name);
return 0;
}
int wmain(int argc, WCHAR *argv[])
......@@ -163,7 +160,5 @@ int wmain(int argc, WCHAR *argv[])
}
}
display_computer_name();
return 0;
return display_computer_name();
}
......@@ -23,4 +23,5 @@
/* Translation IDs. */
#define STRING_USAGE 101
#define STRING_INVALID_OPTION 102
#define STRING_CANNOT_SET_HOSTNAME 103
#define STRING_CANNOT_GET_HOSTNAME 103
#define STRING_CANNOT_SET_HOSTNAME 104
......@@ -28,5 +28,6 @@ STRINGTABLE
{
STRING_USAGE, "Usage: hostname\n"
STRING_INVALID_OPTION, "Error: Invalid option '%c'.\n"
STRING_CANNOT_GET_HOSTNAME, "Error: Could not get hostname: %u.\n"
STRING_CANNOT_SET_HOSTNAME, "Error: Setting the system hostname is not possible with the hostname utility.\n"
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment