Move set_program_name and init_nls to host_init. On windows
fix in this fuction console and argument charset as well.
This commit is contained in:
parent
4cd3c4fec7
commit
ae5540d3d4
24 changed files with 282 additions and 78 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2013-10-13 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
Move set_program_name and init_nls to host_init. On windows
|
||||||
|
fix in this fuction console and argument charset as well.
|
||||||
|
|
||||||
2013-10-12 Andrey Borzenkov <arvidjaar@gmail.com>
|
2013-10-12 Andrey Borzenkov <arvidjaar@gmail.com>
|
||||||
|
|
||||||
Fix inconsistent use of GRUB_CRYPTODISK_ENABLE and
|
Fix inconsistent use of GRUB_CRYPTODISK_ENABLE and
|
||||||
|
|
|
@ -162,6 +162,7 @@ program = {
|
||||||
common = util/grub-mkimage.c;
|
common = util/grub-mkimage.c;
|
||||||
common = util/resolve.c;
|
common = util/resolve.c;
|
||||||
common = grub-core/kern/emu/argp_common.c;
|
common = grub-core/kern/emu/argp_common.c;
|
||||||
|
common = grub-core/osdep/init.c;
|
||||||
|
|
||||||
common = grub-core/kern/arm/dl_helper.c;
|
common = grub-core/kern/arm/dl_helper.c;
|
||||||
|
|
||||||
|
@ -182,6 +183,7 @@ program = {
|
||||||
|
|
||||||
common = util/grub-mkrelpath.c;
|
common = util/grub-mkrelpath.c;
|
||||||
common = grub-core/kern/emu/argp_common.c;
|
common = grub-core/kern/emu/argp_common.c;
|
||||||
|
common = grub-core/osdep/init.c;
|
||||||
|
|
||||||
ldadd = libgrubmods.a;
|
ldadd = libgrubmods.a;
|
||||||
ldadd = libgrubgcry.a;
|
ldadd = libgrubgcry.a;
|
||||||
|
@ -196,6 +198,7 @@ program = {
|
||||||
|
|
||||||
common = util/grub-script-check.c;
|
common = util/grub-script-check.c;
|
||||||
common = grub-core/kern/emu/argp_common.c;
|
common = grub-core/kern/emu/argp_common.c;
|
||||||
|
common = grub-core/osdep/init.c;
|
||||||
|
|
||||||
ldadd = libgrubmods.a;
|
ldadd = libgrubmods.a;
|
||||||
ldadd = libgrubgcry.a;
|
ldadd = libgrubgcry.a;
|
||||||
|
@ -209,6 +212,7 @@ program = {
|
||||||
mansection = 1;
|
mansection = 1;
|
||||||
|
|
||||||
common = util/grub-editenv.c;
|
common = util/grub-editenv.c;
|
||||||
|
common = grub-core/osdep/init.c;
|
||||||
|
|
||||||
ldadd = libgrubmods.a;
|
ldadd = libgrubmods.a;
|
||||||
ldadd = libgrubgcry.a;
|
ldadd = libgrubgcry.a;
|
||||||
|
@ -224,6 +228,7 @@ program = {
|
||||||
common = util/grub-mkpasswd-pbkdf2.c;
|
common = util/grub-mkpasswd-pbkdf2.c;
|
||||||
common = grub-core/kern/emu/argp_common.c;
|
common = grub-core/kern/emu/argp_common.c;
|
||||||
common = grub-core/osdep/random.c;
|
common = grub-core/osdep/random.c;
|
||||||
|
common = grub-core/osdep/init.c;
|
||||||
|
|
||||||
ldadd = libgrubmods.a;
|
ldadd = libgrubmods.a;
|
||||||
ldadd = libgrubgcry.a;
|
ldadd = libgrubgcry.a;
|
||||||
|
@ -246,6 +251,7 @@ program = {
|
||||||
common = util/grub-fstest.c;
|
common = util/grub-fstest.c;
|
||||||
common = grub-core/kern/emu/hostfs.c;
|
common = grub-core/kern/emu/hostfs.c;
|
||||||
common = grub-core/disk/host.c;
|
common = grub-core/disk/host.c;
|
||||||
|
common = grub-core/osdep/init.c;
|
||||||
|
|
||||||
ldadd = libgrubmods.a;
|
ldadd = libgrubmods.a;
|
||||||
ldadd = libgrubgcry.a;
|
ldadd = libgrubgcry.a;
|
||||||
|
@ -274,18 +280,18 @@ program = {
|
||||||
name = grub-mkfont;
|
name = grub-mkfont;
|
||||||
mansection = 1;
|
mansection = 1;
|
||||||
common = util/grub-mkfont.c;
|
common = util/grub-mkfont.c;
|
||||||
common = grub-core/unidata.c;
|
|
||||||
common = grub-core/kern/emu/argp_common.c;
|
common = grub-core/kern/emu/argp_common.c;
|
||||||
common = grub-core/kern/emu/misc.c;
|
common = grub-core/osdep/init.c;
|
||||||
common = util/misc.c;
|
|
||||||
common = grub-core/gnulib/progname.c;
|
|
||||||
|
|
||||||
cflags = '$(freetype_cflags)';
|
cflags = '$(freetype_cflags)';
|
||||||
cppflags = '-DGRUB_MKFONT=1';
|
cppflags = '-DGRUB_MKFONT=1';
|
||||||
|
|
||||||
|
ldadd = libgrubmods.a;
|
||||||
|
ldadd = libgrubgcry.a;
|
||||||
|
ldadd = libgrubkern.a;
|
||||||
ldadd = grub-core/gnulib/libgnu.a;
|
ldadd = grub-core/gnulib/libgnu.a;
|
||||||
ldadd = '$(freetype_libs)';
|
ldadd = '$(freetype_libs)';
|
||||||
ldadd = '$(LIBINTL)';
|
ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
|
||||||
condition = COND_GRUB_MKFONT;
|
condition = COND_GRUB_MKFONT;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -296,6 +302,7 @@ program = {
|
||||||
common = util/grub-probe.c;
|
common = util/grub-probe.c;
|
||||||
common = grub-core/osdep/ofpath.c;
|
common = grub-core/osdep/ofpath.c;
|
||||||
common = grub-core/kern/emu/argp_common.c;
|
common = grub-core/kern/emu/argp_common.c;
|
||||||
|
common = grub-core/osdep/init.c;
|
||||||
|
|
||||||
ldadd = libgrubmods.a;
|
ldadd = libgrubmods.a;
|
||||||
ldadd = libgrubgcry.a;
|
ldadd = libgrubgcry.a;
|
||||||
|
@ -311,6 +318,7 @@ program = {
|
||||||
common = util/grub-setup.c;
|
common = util/grub-setup.c;
|
||||||
common = grub-core/kern/emu/argp_common.c;
|
common = grub-core/kern/emu/argp_common.c;
|
||||||
common = grub-core/lib/reed_solomon.c;
|
common = grub-core/lib/reed_solomon.c;
|
||||||
|
common = grub-core/osdep/init.c;
|
||||||
|
|
||||||
ldadd = libgrubmods.a;
|
ldadd = libgrubmods.a;
|
||||||
ldadd = libgrubkern.a;
|
ldadd = libgrubkern.a;
|
||||||
|
@ -328,6 +336,7 @@ program = {
|
||||||
common = grub-core/kern/emu/argp_common.c;
|
common = grub-core/kern/emu/argp_common.c;
|
||||||
common = grub-core/lib/reed_solomon.c;
|
common = grub-core/lib/reed_solomon.c;
|
||||||
common = grub-core/osdep/ofpath.c;
|
common = grub-core/osdep/ofpath.c;
|
||||||
|
common = grub-core/osdep/init.c;
|
||||||
|
|
||||||
ldadd = libgrubmods.a;
|
ldadd = libgrubmods.a;
|
||||||
ldadd = libgrubkern.a;
|
ldadd = libgrubkern.a;
|
||||||
|
@ -343,6 +352,7 @@ program = {
|
||||||
mansection = 8;
|
mansection = 8;
|
||||||
common = util/ieee1275/grub-ofpathname.c;
|
common = util/ieee1275/grub-ofpathname.c;
|
||||||
common = grub-core/osdep/ofpath.c;
|
common = grub-core/osdep/ofpath.c;
|
||||||
|
common = grub-core/osdep/init.c;
|
||||||
|
|
||||||
ldadd = libgrubmods.a;
|
ldadd = libgrubmods.a;
|
||||||
ldadd = libgrubgcry.a;
|
ldadd = libgrubgcry.a;
|
||||||
|
@ -357,6 +367,7 @@ program = {
|
||||||
|
|
||||||
common = util/grub-mklayout.c;
|
common = util/grub-mklayout.c;
|
||||||
common = grub-core/kern/emu/argp_common.c;
|
common = grub-core/kern/emu/argp_common.c;
|
||||||
|
common = grub-core/osdep/init.c;
|
||||||
|
|
||||||
ldadd = libgrubmods.a;
|
ldadd = libgrubmods.a;
|
||||||
ldadd = libgrubgcry.a;
|
ldadd = libgrubgcry.a;
|
||||||
|
@ -904,6 +915,7 @@ program = {
|
||||||
common = util/grub-menulst2cfg.c;
|
common = util/grub-menulst2cfg.c;
|
||||||
common = grub-core/lib/legacy_parse.c;
|
common = grub-core/lib/legacy_parse.c;
|
||||||
common = grub-core/lib/i386/pc/vesa_modes_table.c;
|
common = grub-core/lib/i386/pc/vesa_modes_table.c;
|
||||||
|
common = grub-core/osdep/init.c;
|
||||||
|
|
||||||
ldadd = libgrubmods.a;
|
ldadd = libgrubmods.a;
|
||||||
ldadd = libgrubgcry.a;
|
ldadd = libgrubgcry.a;
|
||||||
|
@ -918,6 +930,7 @@ program = {
|
||||||
|
|
||||||
common = util/grub-glue-efi.c;
|
common = util/grub-glue-efi.c;
|
||||||
common = grub-core/kern/emu/argp_common.c;
|
common = grub-core/kern/emu/argp_common.c;
|
||||||
|
common = grub-core/osdep/init.c;
|
||||||
|
|
||||||
ldadd = libgrubmods.a;
|
ldadd = libgrubmods.a;
|
||||||
ldadd = libgrubgcry.a;
|
ldadd = libgrubgcry.a;
|
||||||
|
@ -934,6 +947,7 @@ program = {
|
||||||
common = grub-core/kern/emu/argp_common.c;
|
common = grub-core/kern/emu/argp_common.c;
|
||||||
common = grub-core/kern/emu/hostfs.c;
|
common = grub-core/kern/emu/hostfs.c;
|
||||||
common = grub-core/disk/host.c;
|
common = grub-core/disk/host.c;
|
||||||
|
common = grub-core/osdep/init.c;
|
||||||
|
|
||||||
ldadd = libgrubmods.a;
|
ldadd = libgrubmods.a;
|
||||||
ldadd = libgrubgcry.a;
|
ldadd = libgrubgcry.a;
|
||||||
|
|
|
@ -180,7 +180,7 @@ main (int argc, char *argv[])
|
||||||
};
|
};
|
||||||
volatile int hold = 0;
|
volatile int hold = 0;
|
||||||
|
|
||||||
set_program_name (argv[0]);
|
grub_util_host_init (&argc, &argv);
|
||||||
|
|
||||||
dir = xstrdup (DEFAULT_DIRECTORY);
|
dir = xstrdup (DEFAULT_DIRECTORY);
|
||||||
|
|
||||||
|
|
33
grub-core/osdep/basic/init.c
Normal file
33
grub-core/osdep/basic/init.c
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
/*
|
||||||
|
* GRUB -- GRand Unified Bootloader
|
||||||
|
* Copyright (C) 2013 Free Software Foundation, Inc.
|
||||||
|
*
|
||||||
|
* GRUB is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* GRUB is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
#include <config-util.h>
|
||||||
|
|
||||||
|
#include <grub/util/misc.h>
|
||||||
|
|
||||||
|
#include "progname.h"
|
||||||
|
|
||||||
|
void
|
||||||
|
grub_util_host_init (int *argc __attribute__ ((unused)),
|
||||||
|
char ***argv)
|
||||||
|
{
|
||||||
|
set_program_name ((*argv)[0]);
|
||||||
|
|
||||||
|
grub_util_init_nls ();
|
||||||
|
}
|
5
grub-core/osdep/init.c
Normal file
5
grub-core/osdep/init.c
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
#if defined (__MINGW32__)
|
||||||
|
#include "windows/init.c"
|
||||||
|
#else
|
||||||
|
#include "basic/init.c"
|
||||||
|
#endif
|
|
@ -49,24 +49,6 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <winioctl.h>
|
#include <winioctl.h>
|
||||||
|
|
||||||
char *
|
|
||||||
grub_util_tchar_to_utf8 (LPCTSTR in)
|
|
||||||
{
|
|
||||||
#if SIZEOF_TCHAR == 1
|
|
||||||
return xstrdup (path);
|
|
||||||
#elif SIZEOF_TCHAR == 2
|
|
||||||
size_t ssz;
|
|
||||||
for (ssz = 0; in[ssz]; ssz++);
|
|
||||||
|
|
||||||
size_t tsz = GRUB_MAX_UTF8_PER_UTF16 * ssz + 1;
|
|
||||||
grub_uint8_t *ret = xmalloc (tsz);
|
|
||||||
*grub_utf16_to_utf8 (ret, in, ssz) = '\0';
|
|
||||||
return (char *) ret;
|
|
||||||
#else
|
|
||||||
#error "Unsupported TCHAR size"
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#if SIZEOF_TCHAR == 1
|
#if SIZEOF_TCHAR == 1
|
||||||
#define tcsnicmp strncasecmp
|
#define tcsnicmp strncasecmp
|
||||||
#define tclen strlen
|
#define tclen strlen
|
||||||
|
|
|
@ -48,6 +48,51 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <winioctl.h>
|
#include <winioctl.h>
|
||||||
|
|
||||||
|
#if SIZEOF_TCHAR == 1
|
||||||
|
|
||||||
|
LPTSTR
|
||||||
|
grub_util_utf8_to_tchar (const char *in)
|
||||||
|
{
|
||||||
|
return xstrdup (in);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
grub_util_tchar_to_utf8 (LPCTSTR in)
|
||||||
|
{
|
||||||
|
return xstrdup (in);
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif SIZEOF_TCHAR == 2
|
||||||
|
|
||||||
|
LPTSTR
|
||||||
|
grub_util_utf8_to_tchar (const char *in)
|
||||||
|
{
|
||||||
|
LPTSTR ret;
|
||||||
|
size_t ssz = strlen (in);
|
||||||
|
size_t tsz = 2 * (GRUB_MAX_UTF16_PER_UTF8 * ssz + 1);
|
||||||
|
ret = xmalloc (tsz);
|
||||||
|
tsz = grub_utf8_to_utf16 (ret, tsz,
|
||||||
|
(const grub_uint8_t *) in, ssz, NULL);
|
||||||
|
ret[tsz] = 0;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
grub_util_tchar_to_utf8 (LPCTSTR in)
|
||||||
|
{
|
||||||
|
size_t ssz;
|
||||||
|
for (ssz = 0; in[ssz]; ssz++);
|
||||||
|
|
||||||
|
size_t tsz = GRUB_MAX_UTF8_PER_UTF16 * ssz + 1;
|
||||||
|
grub_uint8_t *ret = xmalloc (tsz);
|
||||||
|
*grub_utf16_to_utf8 (ret, in, ssz) = '\0';
|
||||||
|
return (char *) ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
#error "Unsupported TCHAR size"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __CYGWIN__
|
#ifdef __CYGWIN__
|
||||||
LPTSTR
|
LPTSTR
|
||||||
grub_util_get_windows_path (const char *path)
|
grub_util_get_windows_path (const char *path)
|
||||||
|
@ -64,28 +109,20 @@ grub_util_get_windows_path (const char *path)
|
||||||
LPTSTR
|
LPTSTR
|
||||||
grub_util_get_windows_path (const char *path)
|
grub_util_get_windows_path (const char *path)
|
||||||
{
|
{
|
||||||
char *fpa;
|
LPTSTR fpa;
|
||||||
const char *fp;
|
LPTSTR tpath;
|
||||||
LPTSTR ret;
|
|
||||||
|
|
||||||
fp = fpa = xmalloc (PATH_MAX);
|
tpath = grub_util_utf8_to_tchar (path);
|
||||||
if (!_fullpath (fpa, path, PATH_MAX))
|
|
||||||
fp = path;
|
|
||||||
#if SIZEOF_TCHAR == 1
|
|
||||||
ret = xstrdup (fp);
|
|
||||||
#elif SIZEOF_TCHAR == 2
|
|
||||||
size_t ssz = strlen (fp);
|
|
||||||
size_t tsz = 2 * (GRUB_MAX_UTF16_PER_UTF8 * ssz + 1);
|
|
||||||
ret = xmalloc (tsz);
|
|
||||||
tsz = grub_utf8_to_utf16 (ret, tsz, (const grub_uint8_t *) fp, ssz, NULL);
|
|
||||||
ret[tsz] = 0;
|
|
||||||
#else
|
|
||||||
#error SIZEOF_TCHAR
|
|
||||||
#error "Unsupported TCHAR size"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
fpa = xmalloc (PATH_MAX * sizeof (fpa[0]));
|
||||||
|
if (!_wfullpath (fpa, tpath, PATH_MAX))
|
||||||
|
{
|
||||||
free (fpa);
|
free (fpa);
|
||||||
return ret;
|
return tpath;
|
||||||
|
}
|
||||||
|
|
||||||
|
free (tpath);
|
||||||
|
return fpa;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
143
grub-core/osdep/windows/init.c
Normal file
143
grub-core/osdep/windows/init.c
Normal file
|
@ -0,0 +1,143 @@
|
||||||
|
/*
|
||||||
|
* GRUB -- GRand Unified Bootloader
|
||||||
|
* Copyright (C) 2013 Free Software Foundation, Inc.
|
||||||
|
*
|
||||||
|
* GRUB is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* GRUB is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
#include <config-util.h>
|
||||||
|
#include <grub/util/misc.h>
|
||||||
|
#include <grub/osdep/hostfile.h>
|
||||||
|
#include <grub/util/windows.h>
|
||||||
|
|
||||||
|
#include <wincon.h>
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
#include <grub/util/misc.h>
|
||||||
|
|
||||||
|
#include "progname.h"
|
||||||
|
|
||||||
|
struct grub_windows_console_font_infoex {
|
||||||
|
ULONG cbSize;
|
||||||
|
DWORD nFont;
|
||||||
|
COORD dwFontSize;
|
||||||
|
UINT FontFamily;
|
||||||
|
UINT FontWeight;
|
||||||
|
WCHAR FaceName[LF_FACESIZE];
|
||||||
|
};
|
||||||
|
|
||||||
|
static int
|
||||||
|
check_is_raster (HMODULE kernel32, HANDLE hnd)
|
||||||
|
{
|
||||||
|
CONSOLE_FONT_INFO console_font_info;
|
||||||
|
BOOL (WINAPI * func_GetCurrentConsoleFont) (HANDLE, BOOL,
|
||||||
|
PCONSOLE_FONT_INFO);
|
||||||
|
|
||||||
|
func_GetCurrentConsoleFont = (void *)
|
||||||
|
GetProcAddress (kernel32, "GetCurrentConsoleFont");
|
||||||
|
|
||||||
|
if (!func_GetCurrentConsoleFont)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
if (!func_GetCurrentConsoleFont (hnd, FALSE, &console_font_info))
|
||||||
|
return 1;
|
||||||
|
return console_font_info.nFont < 12;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
set_console_unicode_font (void)
|
||||||
|
{
|
||||||
|
BOOL (WINAPI * func_SetCurrentConsoleFontEx) (HANDLE, BOOL,
|
||||||
|
struct grub_windows_console_font_infoex *);
|
||||||
|
BOOL (WINAPI * func_SetConsoleFont)(HANDLE, DWORD);
|
||||||
|
HMODULE kernel32;
|
||||||
|
HANDLE out_handle = GetStdHandle (STD_OUTPUT_HANDLE);
|
||||||
|
HANDLE err_handle = GetStdHandle (STD_ERROR_HANDLE);
|
||||||
|
int out_raster, err_raster;
|
||||||
|
|
||||||
|
kernel32 = GetModuleHandle(TEXT("kernel32.dll"));
|
||||||
|
if (!kernel32)
|
||||||
|
return;
|
||||||
|
|
||||||
|
out_raster = check_is_raster (kernel32, out_handle);
|
||||||
|
err_raster = check_is_raster (kernel32, err_handle);
|
||||||
|
|
||||||
|
if (!out_raster && !err_raster)
|
||||||
|
return;
|
||||||
|
|
||||||
|
func_SetCurrentConsoleFontEx = (void *) GetProcAddress (kernel32, "SetCurrentConsoleFontEx");
|
||||||
|
|
||||||
|
/* Newer windows versions. */
|
||||||
|
if (func_SetCurrentConsoleFontEx)
|
||||||
|
{
|
||||||
|
struct grub_windows_console_font_infoex new_console_font_info;
|
||||||
|
new_console_font_info.cbSize = sizeof (new_console_font_info);
|
||||||
|
new_console_font_info.nFont = 12;
|
||||||
|
new_console_font_info.dwFontSize.X = 7;
|
||||||
|
new_console_font_info.dwFontSize.Y = 12;
|
||||||
|
new_console_font_info.FontFamily = FF_DONTCARE;
|
||||||
|
new_console_font_info.FontWeight = 400;
|
||||||
|
memcpy (new_console_font_info.FaceName, TEXT("Lucida Console"),
|
||||||
|
sizeof (TEXT("Lucida Console")));
|
||||||
|
if (out_raster)
|
||||||
|
func_SetCurrentConsoleFontEx (out_handle, FALSE,
|
||||||
|
&new_console_font_info);
|
||||||
|
if (err_raster)
|
||||||
|
func_SetCurrentConsoleFontEx (err_handle, FALSE,
|
||||||
|
&new_console_font_info);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Fallback for older versions. */
|
||||||
|
func_SetConsoleFont = (void *) GetProcAddress (kernel32, "SetConsoleFont");
|
||||||
|
if (func_SetConsoleFont)
|
||||||
|
{
|
||||||
|
if (out_raster)
|
||||||
|
func_SetConsoleFont (out_handle, 12);
|
||||||
|
if (err_raster)
|
||||||
|
func_SetConsoleFont (err_handle, 12);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
grub_util_host_init (int *argc __attribute__ ((unused)),
|
||||||
|
char ***argv)
|
||||||
|
{
|
||||||
|
SetConsoleOutputCP (CP_UTF8);
|
||||||
|
SetConsoleCP (CP_UTF8);
|
||||||
|
|
||||||
|
set_console_unicode_font ();
|
||||||
|
|
||||||
|
#if SIZEOF_TCHAR == 1
|
||||||
|
|
||||||
|
#elif SIZEOF_TCHAR == 2
|
||||||
|
LPWSTR tcmdline = GetCommandLineW ();
|
||||||
|
int i;
|
||||||
|
LPWSTR *targv;
|
||||||
|
|
||||||
|
targv = CommandLineToArgvW (tcmdline, argc);
|
||||||
|
*argv = xmalloc ((*argc + 1) * sizeof (argv[0]));
|
||||||
|
|
||||||
|
for (i = 0; i < *argc; i++)
|
||||||
|
(*argv)[i] = grub_util_tchar_to_utf8 (targv[i]);
|
||||||
|
(*argv)[i] = NULL;
|
||||||
|
#else
|
||||||
|
#error "Unsupported TCHAR size"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
set_program_name ((*argv)[0]);
|
||||||
|
|
||||||
|
grub_util_init_nls ();
|
||||||
|
}
|
|
@ -45,4 +45,6 @@ char *canonicalize_file_name (const char *path);
|
||||||
|
|
||||||
void grub_util_init_nls (void);
|
void grub_util_init_nls (void);
|
||||||
|
|
||||||
|
void grub_util_host_init (int *argc, char ***argv);
|
||||||
|
|
||||||
#endif /* ! GRUB_UTIL_MISC_HEADER */
|
#endif /* ! GRUB_UTIL_MISC_HEADER */
|
||||||
|
|
|
@ -274,6 +274,8 @@ main (int argc, char *argv[])
|
||||||
char *command;
|
char *command;
|
||||||
int curindex, arg_count;
|
int curindex, arg_count;
|
||||||
|
|
||||||
|
grub_util_host_init (&argc, &argv);
|
||||||
|
|
||||||
set_program_name (argv[0]);
|
set_program_name (argv[0]);
|
||||||
|
|
||||||
grub_util_init_nls ();
|
grub_util_init_nls ();
|
||||||
|
|
|
@ -733,9 +733,7 @@ main (int argc, char *argv[])
|
||||||
const char *default_root;
|
const char *default_root;
|
||||||
char *alloc_root;
|
char *alloc_root;
|
||||||
|
|
||||||
set_program_name (argv[0]);
|
grub_util_host_init (&argc, &argv);
|
||||||
|
|
||||||
grub_util_init_nls ();
|
|
||||||
|
|
||||||
args = xmalloc (argc * sizeof (args[0]));
|
args = xmalloc (argc * sizeof (args[0]));
|
||||||
|
|
||||||
|
|
|
@ -168,7 +168,7 @@ main (int argc, char *argv[])
|
||||||
FILE *in32, *in64, *out;
|
FILE *in32, *in64, *out;
|
||||||
struct arguments arguments;
|
struct arguments arguments;
|
||||||
|
|
||||||
set_program_name (argv[0]);
|
grub_util_host_init (&argc, &argv);
|
||||||
|
|
||||||
/* Check for options. */
|
/* Check for options. */
|
||||||
memset (&arguments, 0, sizeof (struct arguments));
|
memset (&arguments, 0, sizeof (struct arguments));
|
||||||
|
|
|
@ -37,6 +37,8 @@ main (int argc, char **argv)
|
||||||
int suffixlen = 0;
|
int suffixlen = 0;
|
||||||
const char *out_fname = 0;
|
const char *out_fname = 0;
|
||||||
|
|
||||||
|
grub_util_host_init (&argc, &argv);
|
||||||
|
|
||||||
if (argc >= 2 && argv[1][0] == '-')
|
if (argc >= 2 && argv[1][0] == '-')
|
||||||
{
|
{
|
||||||
fprintf (stdout, _("Usage: %s [INFILE [OUTFILE]]\n"), argv[0]);
|
fprintf (stdout, _("Usage: %s [INFILE [OUTFILE]]\n"), argv[0]);
|
||||||
|
|
|
@ -1155,11 +1155,9 @@ main (int argc, char *argv[])
|
||||||
struct arguments arguments;
|
struct arguments arguments;
|
||||||
|
|
||||||
#ifndef GRUB_BUILD
|
#ifndef GRUB_BUILD
|
||||||
set_program_name (argv[0]);
|
grub_util_host_init (&argc, &argv);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
grub_util_init_nls ();
|
|
||||||
|
|
||||||
memset (&arguments, 0, sizeof (struct arguments));
|
memset (&arguments, 0, sizeof (struct arguments));
|
||||||
arguments.file_format = PF2;
|
arguments.file_format = PF2;
|
||||||
arguments.files_max = argc + 1;
|
arguments.files_max = argc + 1;
|
||||||
|
|
|
@ -2025,9 +2025,7 @@ main (int argc, char *argv[])
|
||||||
FILE *fp = stdout;
|
FILE *fp = stdout;
|
||||||
struct arguments arguments;
|
struct arguments arguments;
|
||||||
|
|
||||||
set_program_name (argv[0]);
|
grub_util_host_init (&argc, &argv);
|
||||||
|
|
||||||
grub_util_init_nls ();
|
|
||||||
|
|
||||||
memset (&arguments, 0, sizeof (struct arguments));
|
memset (&arguments, 0, sizeof (struct arguments));
|
||||||
arguments.comp = COMPRESSION_AUTO;
|
arguments.comp = COMPRESSION_AUTO;
|
||||||
|
|
|
@ -471,7 +471,7 @@ main (int argc, char *argv[])
|
||||||
FILE *in, *out;
|
FILE *in, *out;
|
||||||
struct arguments arguments;
|
struct arguments arguments;
|
||||||
|
|
||||||
set_program_name (argv[0]);
|
grub_util_host_init (&argc, &argv);
|
||||||
|
|
||||||
/* Check for options. */
|
/* Check for options. */
|
||||||
memset (&arguments, 0, sizeof (struct arguments));
|
memset (&arguments, 0, sizeof (struct arguments));
|
||||||
|
|
|
@ -119,9 +119,7 @@ main (int argc, char *argv[])
|
||||||
char pass1[GRUB_AUTH_MAX_PASSLEN];
|
char pass1[GRUB_AUTH_MAX_PASSLEN];
|
||||||
char pass2[GRUB_AUTH_MAX_PASSLEN];
|
char pass2[GRUB_AUTH_MAX_PASSLEN];
|
||||||
|
|
||||||
set_program_name (argv[0]);
|
grub_util_host_init (&argc, &argv);
|
||||||
|
|
||||||
grub_util_init_nls ();
|
|
||||||
|
|
||||||
/* Check for options. */
|
/* Check for options. */
|
||||||
if (argp_parse (&argp, argc, argv, 0, 0, &arguments) != 0)
|
if (argp_parse (&argp, argc, argv, 0, 0, &arguments) != 0)
|
||||||
|
|
|
@ -82,9 +82,7 @@ main (int argc, char *argv[])
|
||||||
char *relpath;
|
char *relpath;
|
||||||
struct arguments arguments;
|
struct arguments arguments;
|
||||||
|
|
||||||
set_program_name (argv[0]);
|
grub_util_host_init (&argc, &argv);
|
||||||
|
|
||||||
grub_util_init_nls ();
|
|
||||||
|
|
||||||
memset (&arguments, 0, sizeof (struct arguments));
|
memset (&arguments, 0, sizeof (struct arguments));
|
||||||
|
|
||||||
|
|
|
@ -541,9 +541,7 @@ main (int argc, char *argv[])
|
||||||
const char *default_root;
|
const char *default_root;
|
||||||
char *alloc_root;
|
char *alloc_root;
|
||||||
|
|
||||||
set_program_name (argv[0]);
|
grub_util_host_init (&argc, &argv);
|
||||||
|
|
||||||
grub_util_init_nls ();
|
|
||||||
|
|
||||||
fuse_args = xrealloc (fuse_args, (fuse_argc + 2) * sizeof (fuse_args[0]));
|
fuse_args = xrealloc (fuse_args, (fuse_argc + 2) * sizeof (fuse_args[0]));
|
||||||
fuse_args[fuse_argc] = xstrdup (argv[0]);
|
fuse_args[fuse_argc] = xstrdup (argv[0]);
|
||||||
|
|
|
@ -910,9 +910,7 @@ main (int argc, char *argv[])
|
||||||
char delim;
|
char delim;
|
||||||
struct arguments arguments;
|
struct arguments arguments;
|
||||||
|
|
||||||
set_program_name (argv[0]);
|
grub_util_host_init (&argc, &argv);
|
||||||
|
|
||||||
grub_util_init_nls ();
|
|
||||||
|
|
||||||
memset (&arguments, 0, sizeof (struct arguments));
|
memset (&arguments, 0, sizeof (struct arguments));
|
||||||
arguments.device_max = argc + 1;
|
arguments.device_max = argc + 1;
|
||||||
|
|
|
@ -208,9 +208,7 @@ main (int argc, char *argv[])
|
||||||
ieee1275_palette[cptr].b = 0;
|
ieee1275_palette[cptr].b = 0;
|
||||||
ieee1275_palette[cptr].a = 0xff;
|
ieee1275_palette[cptr].a = 0xff;
|
||||||
|
|
||||||
set_program_name (argv[0]);
|
grub_util_host_init (&argc, &argv);
|
||||||
|
|
||||||
grub_util_init_nls ();
|
|
||||||
|
|
||||||
/* Check for options. */
|
/* Check for options. */
|
||||||
memset (&arguments, 0, sizeof (struct arguments));
|
memset (&arguments, 0, sizeof (struct arguments));
|
||||||
|
|
|
@ -146,8 +146,7 @@ main (int argc, char *argv[])
|
||||||
int found_input = 0, found_cmd = 0;
|
int found_input = 0, found_cmd = 0;
|
||||||
struct grub_script *script = NULL;
|
struct grub_script *script = NULL;
|
||||||
|
|
||||||
set_program_name (argv[0]);
|
grub_util_host_init (&argc, &argv);
|
||||||
grub_util_init_nls ();
|
|
||||||
|
|
||||||
memset (&ctx.arguments, 0, sizeof (struct arguments));
|
memset (&ctx.arguments, 0, sizeof (struct arguments));
|
||||||
|
|
||||||
|
|
|
@ -1138,9 +1138,7 @@ main (int argc, char *argv[])
|
||||||
char *dest_dev = NULL;
|
char *dest_dev = NULL;
|
||||||
struct arguments arguments;
|
struct arguments arguments;
|
||||||
|
|
||||||
set_program_name (argv[0]);
|
grub_util_host_init (&argc, &argv);
|
||||||
|
|
||||||
grub_util_init_nls ();
|
|
||||||
|
|
||||||
/* Default option values. */
|
/* Default option values. */
|
||||||
memset (&arguments, 0, sizeof (struct arguments));
|
memset (&arguments, 0, sizeof (struct arguments));
|
||||||
|
|
|
@ -32,9 +32,7 @@ int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
char *of_path;
|
char *of_path;
|
||||||
|
|
||||||
set_program_name (argv[0]);
|
grub_util_host_init (&argc, &argv);
|
||||||
|
|
||||||
grub_util_init_nls ();
|
|
||||||
|
|
||||||
if (argc != 2 || strcmp (argv[1], "--help") == 0)
|
if (argc != 2 || strcmp (argv[1], "--help") == 0)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue