Author: hbelusca Date: Mon Apr 29 23:49:52 2013 New Revision: 58893
URL: http://svn.reactos.org/svn/reactos?rev=58893&view=rev Log: [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.
Added: trunk/reactos/base/applications/cmdutils/hostname/lang/ (with props) trunk/reactos/base/applications/cmdutils/hostname/lang/en-US.rc (with props) trunk/reactos/base/applications/cmdutils/hostname/lang/fr-FR.rc (with props) trunk/reactos/base/applications/cmdutils/hostname/resource.h (with props) trunk/reactos/base/applications/cmdutils/hostname/rsrc.rc (with props) Modified: trunk/reactos/base/applications/cmdutils/hostname/CMakeLists.txt trunk/reactos/base/applications/cmdutils/hostname/hostname.c trunk/reactos/base/applications/cmdutils/hostname/hostname.rc trunk/reactos/base/applications/regedit/regedit.rc
Modified: trunk/reactos/base/applications/cmdutils/hostname/CMakeLists.txt URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils/... ============================================================================== --- trunk/reactos/base/applications/cmdutils/hostname/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/base/applications/cmdutils/hostname/CMakeLists.txt [iso-8859-1] Mon Apr 29 23:49:52 2013 @@ -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)
Modified: trunk/reactos/base/applications/cmdutils/hostname/hostname.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils/... ============================================================================== --- trunk/reactos/base/applications/cmdutils/hostname/hostname.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/cmdutils/hostname/hostname.c [iso-8859-1] Mon Apr 29 23:49:52 2013 @@ -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 */
Modified: trunk/reactos/base/applications/cmdutils/hostname/hostname.rc URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils/... ============================================================================== --- trunk/reactos/base/applications/cmdutils/hostname/hostname.rc [iso-8859-1] (original) +++ trunk/reactos/base/applications/cmdutils/hostname/hostname.rc [iso-8859-1] Mon Apr 29 23:49:52 2013 @@ -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"
Propchange: trunk/reactos/base/applications/cmdutils/hostname/lang/ ------------------------------------------------------------------------------ --- bugtraq:logregex (added) +++ bugtraq:logregex Mon Apr 29 23:49:52 2013 @@ -1,0 +1,2 @@ +([Ii]ssue|[Bb]ug)s? #?(\d+)(,? ?#?(\d+))*(,? ?(and |or )?#?(\d+))? +(\d+)
Propchange: trunk/reactos/base/applications/cmdutils/hostname/lang/ ------------------------------------------------------------------------------ bugtraq:message = See issue #%BUGID% for more details.
Propchange: trunk/reactos/base/applications/cmdutils/hostname/lang/ ------------------------------------------------------------------------------ bugtraq:url = http://www.reactos.org/bugzilla/show_bug.cgi?id=%BUGID%
Propchange: trunk/reactos/base/applications/cmdutils/hostname/lang/ ------------------------------------------------------------------------------ tsvn:logminsize = 10
Added: trunk/reactos/base/applications/cmdutils/hostname/lang/en-US.rc URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils/... ============================================================================== --- trunk/reactos/base/applications/cmdutils/hostname/lang/en-US.rc (added) +++ trunk/reactos/base/applications/cmdutils/hostname/lang/en-US.rc [iso-8859-1] Mon Apr 29 23:49:52 2013 @@ -1,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
Propchange: trunk/reactos/base/applications/cmdutils/hostname/lang/en-US.rc ------------------------------------------------------------------------------ svn:eol-style = native
Added: trunk/reactos/base/applications/cmdutils/hostname/lang/fr-FR.rc URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils/... ============================================================================== --- trunk/reactos/base/applications/cmdutils/hostname/lang/fr-FR.rc (added) +++ trunk/reactos/base/applications/cmdutils/hostname/lang/fr-FR.rc [iso-8859-1] Mon Apr 29 23:49:52 2013 @@ -1,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
Propchange: trunk/reactos/base/applications/cmdutils/hostname/lang/fr-FR.rc ------------------------------------------------------------------------------ svn:eol-style = native
Added: trunk/reactos/base/applications/cmdutils/hostname/resource.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils/... ============================================================================== --- trunk/reactos/base/applications/cmdutils/hostname/resource.h (added) +++ trunk/reactos/base/applications/cmdutils/hostname/resource.h [iso-8859-1] Mon Apr 29 23:49:52 2013 @@ -1,0 +1,8 @@ +#ifndef RESOURCE_H +#define RESOURCE_H + +#define IDS_USAGE 0 +#define IDS_NOSET 1 +#define IDS_ERROR 2 + +#endif /* RESOURCE_H */
Propchange: trunk/reactos/base/applications/cmdutils/hostname/resource.h ------------------------------------------------------------------------------ svn:eol-style = native
Added: trunk/reactos/base/applications/cmdutils/hostname/rsrc.rc URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils/... ============================================================================== --- trunk/reactos/base/applications/cmdutils/hostname/rsrc.rc (added) +++ trunk/reactos/base/applications/cmdutils/hostname/rsrc.rc [iso-8859-1] Mon Apr 29 23:49:52 2013 @@ -1,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
Propchange: trunk/reactos/base/applications/cmdutils/hostname/rsrc.rc ------------------------------------------------------------------------------ svn:eol-style = native
Modified: trunk/reactos/base/applications/regedit/regedit.rc URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/regedit/r... ============================================================================== --- trunk/reactos/base/applications/regedit/regedit.rc [iso-8859-1] (original) +++ trunk/reactos/base/applications/regedit/regedit.rc [iso-8859-1] Mon Apr 29 23:49:52 2013 @@ -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"