[HOSTNAME]

Unicodify and add localization support.
Patch by Lee Schroeder, simplified by me.

CORE-7142 #resolve #comment Committed in revision r58893, thanks!

[REGEDIT]
"Neutralize" common resources.

svn path=/trunk/; revision=58893
This commit is contained in:
Hermès Bélusca-Maïto 2013-04-29 23:49:52 +00:00
parent ec8ff3a906
commit 6cdfa4a25c
8 changed files with 93 additions and 36 deletions

View file

@ -1,6 +1,6 @@
add_executable(hostname hostname.c hostname.rc)
set_module_type(hostname win32cui)
add_importlibs(hostname msvcrt kernel32)
set_module_type(hostname win32cui UNICODE)
add_importlibs(hostname user32 msvcrt kernel32)
add_cd_file(TARGET hostname DESTINATION reactos/system32 FOR all)

View file

@ -23,38 +23,52 @@
* PROGRAMMER: Emanuele Aliberti (ea@reactos.com)
*/
#include <stdio.h>
#include <stdlib.h>
//#include <string.h>
#include <conio.h>
#include <windef.h>
#include <winbase.h>
#include <winuser.h>
int main (int argc, char ** argv)
#include "resource.h"
int wmain(int argc, WCHAR* argv[])
{
if (1 == argc)
{
TCHAR ComputerName [MAX_COMPUTERNAME_LENGTH + 1];
DWORD ComputerNameSize = sizeof ComputerName / sizeof ComputerName[0];
WCHAR Msg[100];
ZeroMemory (ComputerName, sizeof ComputerName );
if (GetComputerName(ComputerName, & ComputerNameSize))
{
printf ("%s\n", ComputerName);
return EXIT_SUCCESS;
}
fprintf (stderr, "%s: Win32 error %lu.\n",
argv[0], GetLastError());
return EXIT_FAILURE;
}else{
if (0 == strcmp(argv[1],"-s"))
{
fprintf(stderr,"%s: -s not supported.\n",argv[0]);
return EXIT_FAILURE;
}else{
printf("Print the current host's name.\n\nhostname\n");
}
}
return EXIT_SUCCESS;
if (1 == argc)
{
WCHAR ComputerName[MAX_COMPUTERNAME_LENGTH + 1] = L"";
DWORD ComputerNameSize = sizeof(ComputerName) / sizeof(ComputerName[0]);
if (!GetComputerName(ComputerName, &ComputerNameSize))
{
/* Fail in case of error */
LoadStringW(GetModuleHandle(NULL), IDS_ERROR, Msg, 100);
_cwprintf(L"%s %lu.\n", Msg, GetLastError());
return 1;
}
/* Print out the computer's name */
_cwprintf(L"%s\n", ComputerName);
}
else
{
if ((wcsicmp(argv[1], L"-s") == 0) || (wcsicmp(argv[1], L"/s") == 0))
{
/* The program doesn't allow the user to set the computer's name */
LoadStringW(GetModuleHandle(NULL), IDS_NOSET, Msg, 100);
_cwprintf(L"%s\n", Msg);
return 1;
}
else
{
/* Let the user know what the program does */
LoadStringW(GetModuleHandle(NULL), IDS_USAGE, Msg, 100);
_cwprintf(L"\n%s\n\n", Msg);
}
}
return 0;
}
/* EOF */

View file

@ -1,4 +1,12 @@
#define REACTOS_STR_FILE_DESCRIPTION "Win32 Get local host name\0"
#define REACTOS_STR_INTERNAL_NAME "hostname\0"
#define REACTOS_STR_ORIGINAL_FILENAME "hostname.exe\0"
#include <windef.h>
#include "resource.h"
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"
#include <reactos/version.rc>
#include "rsrc.rc"

View file

@ -0,0 +1,8 @@
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
STRINGTABLE DISCARDABLE
BEGIN
IDS_USAGE, "Print the current host's name.\n\nhostname"
IDS_NOSET, "hostname -s is not supported."
IDS_ERROR, "Win32 error"
END

View file

@ -0,0 +1,8 @@
LANGUAGE LANG_FRENCH, SUBLANG_NEUTRAL
STRINGTABLE DISCARDABLE
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"
END

View file

@ -0,0 +1,8 @@
#ifndef RESOURCE_H
#define RESOURCE_H
#define IDS_USAGE 0
#define IDS_NOSET 1
#define IDS_ERROR 2
#endif /* RESOURCE_H */

View file

@ -0,0 +1,11 @@
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
// UTF-8
#pragma code_page(65001)
#ifdef LANGUAGE_EN_US
#include "lang/en-US.rc"
#endif
#ifdef LANGUAGE_FR_FR
#include "lang/fr-FR.rc"
#endif

View file

@ -24,12 +24,12 @@
#include "resource.h"
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS Registry Explorer\0"
#define REACTOS_STR_INTERNAL_NAME "regedit\0"
#define REACTOS_STR_ORIGINAL_FILENAME "regedit.exe\0"
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS Registry Explorer"
#define REACTOS_STR_INTERNAL_NAME "regedit"
#define REACTOS_STR_ORIGINAL_FILENAME "regedit.exe"
#include <reactos/version.rc>
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
#include "rsrc.rc"