* g10.c (i18n_init) [W32]: Pass registry key to gettext

initialization.
* gpgv.c (i18n_init) [W32]: Ditto.

* simple-gettext.c (set_gettext_file): Use MO files depending on
the installation directory.  Add new arg REGKEY.
This commit is contained in:
Werner Koch 2005-01-20 11:42:03 +00:00
parent b2d67e8039
commit 5bda87bd6e
19 changed files with 350 additions and 143 deletions

View File

@ -1,3 +1,7 @@
2005-01-18 Werner Koch <wk@g10code.com>
* configure.ac (HAVE_W32_SYSTEM): Define it.
2005-01-18 David Shaw <dshaw@grover.jabberwocky.com>
* NEWS: Note --rfc2440-text import/export-unusable-sigs and
@ -8,6 +12,8 @@
2005-01-17 Werner Koch <wk@g10code.com>
* README: Updated for SHA1 checksums.
* configure.ac: Make --without-included-zlib work as
expected. Reported by Norihiko Murase. Same for
--without-included-regex.

9
NEWS
View File

@ -1,6 +1,15 @@
Noteworthy changes in version 1.4.1
-------------------------------------------------
* [W32] The algorithm for the default home directory changed:
First we look at the environment variable GNUPGHOME, if this one
is not set, we check whether the registry entry
HKCU\Software\GNU\GnuPG:HomeDir has been set and if this fails
we use a GnuPG directory below the standard application data
directory (APPDATA) of the current user. Only in the case that
this directory cannot be determined, the old default of c:\gnupg
will be used. The option --homedir still overrides all of them.
* New --rfc2440-text option which controls how text is handled in
signatures. This is in response to some problems seen with
certain PGP/MIME mail clients and GnuPG version 1.4.0. More

9
README
View File

@ -54,7 +54,8 @@
this. Don't skip it - this is an important step!
2) Unpack the tarball. With GNU tar you can do it this way:
"tar xzvf gnupg-x.y.z.tar.gz"
"tar xzvf gnupg-x.y.z.tar.gz". If got a bzip2 compressed
tarball you need to use: "tar xjvf gnupg-x.y.z.tar.bz2".
3) "cd gnupg-x.y.z"
@ -104,13 +105,13 @@
b) If you don't have any of the above programs, you have to verify
the MD5 checksum:
the SHA1 checksum:
$ md5sum gnupg-x.y.z.tar.gz
$ sha1sum gnupg-x.y.z.tar.gz
This should yield an output _similar_ to this:
fd9351b26b3189c1d577f0970f9dcadc gnupg-x.y.z.tar.gz
fd9351b26b3189c1d577f0970f9dcadc1234abcd gnupg-x.y.z.tar.gz
Now check that this checksum is _exactly_ the same as the one
published via the announcement list and probably via Usenet.

View File

@ -455,6 +455,8 @@ case "${host}" in
[because the Unix gettext has too much overhead on
MingW32 systems and these systems lack Posix functions,
we use a simplified version of gettext])
AC_DEFINE(HAVE_W32_SYSTEM,1,
[Defined if we run on a W32 API based system])
have_dosish_system=yes
need_dlopen=no
try_gettext="no"

View File

@ -1,3 +1,7 @@
2005-01-18 Werner Koch <wk@g10code.com>
* gnupg-w32.reg: Remove the entry for the home directory.
2004-12-16 Werner Koch <wk@g10code.com>
* TRANSLATE: Add a note on how to send translations.

View File

@ -7,6 +7,9 @@ http://www.gnupg.org/docs-mls.html for a list of mailing lists. In
particular the list gnupg-users@gnupg.org might be useful to answer
questions - but please read the FAQ first.
Note: Due to the use of the NSIS installer, the information below are
mostly out of date.
Installation instructions:
--------------------------
1. Unpack the ZIP archive (alright, you already did this).
@ -40,11 +43,6 @@ Internationalization support:
(Example: "copy fr.mo c:\gnu\locale\fr\gnupg.mo")
4. Done.
Currently we only support the Codepages 437, 850 und Latin1. If you have
problems, either delete the gnupg.mo file or don't set the environment
variable
How to build it from the source:
--------------------------------

View File

@ -1,13 +1,5 @@
REGEDIT4
[HKEY_LOCAL_MACHINE\Software\GNU]
[HKEY_LOCAL_MACHINE\Software\GNU\GNUPG]
[HKEY_LOCAL_MACHINE\Software\GNU\GNUPG]
"HomeDir"="C:\\GnuPG"
"gpgProgram"="C:\\GnuPG\\gpg.exe"
[HKEY_CURRENT_USER\Control Panel\Mingw32]

View File

@ -1,5 +1,15 @@
2005-01-20 Werner Koch <wk@g10code.com>
* g10.c (i18n_init) [W32]: Pass registry key to gettext
initialization.
* gpgv.c (i18n_init) [W32]: Ditto.
2005-01-18 Werner Koch <wk@g10code.com>
* misc.c (default_homedir): New. Taken from gnupg 1.9.15.
* g10.c (main): Use it.
* gpgv.c (main): Ditto.
* keylist.c (public_key_list): Do a trustdb staleness check before
opening the keyring.
(secret_key_list): Ditto.

View File

@ -1,6 +1,6 @@
/* g10.c - The GnuPG utility (main for gpg)
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003
* 2004 Free Software Foundation, Inc.
* 2004, 2005 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
@ -839,7 +839,7 @@ static void
i18n_init(void)
{
#ifdef USE_SIMPLE_GETTEXT
set_gettext_file( PACKAGE );
set_gettext_file (PACKAGE, "Software\\GNU\\GnuPG");
#else
#ifdef ENABLE_NLS
setlocale( LC_ALL, "" );
@ -1673,14 +1673,7 @@ main( int argc, char **argv )
set_screen_dimensions();
opt.keyid_format=KF_SHORT;
opt.rfc2440_text=1;
#if defined (_WIN32)
set_homedir ( read_w32_registry_string( NULL,
"Software\\GNU\\GnuPG", "HomeDir" ));
#else
set_homedir ( getenv("GNUPGHOME") );
#endif
if( !*opt.homedir )
set_homedir ( GNUPG_HOMEDIR );
set_homedir ( default_homedir () );
#ifdef ENABLE_CARD_SUPPORT
# ifdef _WIN32

View File

@ -1,5 +1,6 @@
/* gpgv.c - The GnuPG signature verify utility
* Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
* Copyright (C) 1998, 1999, 2000, 2001, 2002,
* 2005 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
@ -112,7 +113,7 @@ static void
i18n_init(void)
{
#ifdef USE_SIMPLE_GETTEXT
set_gettext_file( PACKAGE );
set_gettext_file (PACKAGE, "Software\\GNU\\GnuPG");
#else
#ifdef ENABLE_NLS
setlocale( LC_ALL, "" );
@ -141,14 +142,8 @@ main( int argc, char **argv )
opt.trust_model = TM_ALWAYS;
opt.batch = 1;
#if defined (_WIN32)
opt.homedir = read_w32_registry_string( NULL, "Software\\GNU\\GnuPG", "HomeDir" );
#else
opt.homedir = getenv("GNUPGHOME");
#endif
if( !opt.homedir || !*opt.homedir ) {
opt.homedir = GNUPG_HOMEDIR;
}
opt.homedir = default_homedir ();
tty_no_terminal(1);
tty_batchmode(1);
disable_dotlock();

View File

@ -122,6 +122,9 @@ char *argsplit(char *string);
int parse_options(char *str,unsigned int *options,
struct parse_options *opts,int noisy);
char *default_homedir (void);
/*-- helptext.c --*/
void display_online_help( const char *keyword );

View File

@ -1,6 +1,6 @@
/* misc.c - miscellaneous functions
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003,
* 2004 Free Software Foundation, Inc.
* 2004, 2005 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
@ -40,7 +40,19 @@
#ifdef _WIN32
#include <time.h>
#include <process.h>
#include <windows.h>
#include <shlobj.h>
#ifndef CSIDL_APPDATA
#define CSIDL_APPDATA 0x001a
#endif
#ifndef CSIDL_LOCAL_APPDATA
#define CSIDL_LOCAL_APPDATA 0x001c
#endif
#ifndef CSIDL_FLAG_CREATE
#define CSIDL_FLAG_CREATE 0x8000
#endif
#endif /*_WIN32*/
#include "util.h"
#include "main.h"
#include "photoid.h"
@ -49,6 +61,8 @@
#include "cardglue.h"
#ifdef ENABLE_SELINUX_HACKS
/* A object and a global variable to keep track of files marked as
secured. */
@ -1002,3 +1016,46 @@ parse_options(char *str,unsigned int *options,
return 1;
}
/* Set up the default home directory. The usual --homedir option
should be parsed later. */
char *
default_homedir (void)
{
char *dir;
dir = getenv("GNUPGHOME");
#ifdef HAVE_W32_SYSTEM
if (!dir || !*dir)
dir = read_w32_registry_string (NULL, "Software\\GNU\\GnuPG", "HomeDir");
if (!dir || !*dir)
{
char path[MAX_PATH];
/* It might be better to use LOCAL_APPDATA because this is
defined as "non roaming" and thus more likely to be kept
locally. For private keys this is desired. However, given
that many users copy private keys anyway forth and back,
using a system roaming serives might be better than to let
them do it manually. A security conscious user will anyway
use the registry entry to have better control. */
if (SHGetFolderPath(NULL, CSIDL_APPDATA|CSIDL_FLAG_CREATE,
NULL, 0, path) >= 0)
{
char *tmp = xmalloc (strlen (path) + 6 +1);
strcpy (stpcpy (tmp, path), "\\gnupg");
dir = tmp;
/* Try to create the directory if it does not yet
exists. */
if (access (dir, F_OK))
CreateDirectory (dir, NULL);
}
}
#endif /*HAVE_W32_SYSTEM*/
if (!dir || !*dir)
dir = GNUPG_HOMEDIR;
return dir;
}

View File

@ -22,7 +22,7 @@
#define G10_I18N_H
#ifdef USE_SIMPLE_GETTEXT
int set_gettext_file( const char *filename );
int set_gettext_file( const char *filename, const char *regkey );
const char *gettext( const char *msgid );
#define _(a) gettext (a)

View File

@ -96,8 +96,13 @@ for i in ${srcdir}/po/*.po; do
done
if makensis -version >/dev/null 2>&1 ; then
echo "invokin installer as:"
echo makensis -v3 -nocd -DVERSION="${version}" \
-DPROD_VERSION="${prod_version}" \
-DGNUPG_SRCDIR="${srcdir}" ${srcdir}/scripts/w32installer.nsi
makensis -v3 -nocd -DVERSION="${version}" \
-DPROD_VERSION="${prod_version}" ${srcdir}/scripts/w32installer.nsi
-DPROD_VERSION="${prod_version}" \
-DGNUPG_SRCDIR="${srcdir}" ${srcdir}/scripts/w32installer.nsi
echo "Installer created" >&2
else
zip -9 "gnupg-w32cli-${version}.zip" *

View File

@ -1,4 +1,5 @@
; w32installer.nsi - W32 Installer definition -*- lisp -*-
; w32installer.nsi -*- mode: lisp; coding: latin-1; -*-
; W32 Installer script
; Copyright (C) 2005 Free Software Foundation, Inc.
;
; This file is free software; as a special exception the author gives
@ -17,11 +18,8 @@
; TODO:
; - Display credit for the installer
; - Provide the location of the corresponding source
; - Check for iconv.dll and optionalkly install or download it.
; - Allow inclusion of the source into the installer.
; - Translate all strings
; - Setup the home directory and check for old (c:/gnupg located)
; versions of the program
; We use the modern UI.
!include "MUI.nsh"
@ -35,11 +33,10 @@ OutFile "gnupg-w32cli-${VERSION}.exe"
InstallDir "$PROGRAMFILES\GNU\GnuPG"
InstallDirRegKey HKCU "Software\GNU\GnuPG" ""
InstallDirRegKey HKLM "Software\GNU\GnuPG" "Install Directory"
SetCompressor lzma
ReserveFile "COPYING.txt"
VIProductVersion "${PROD_VERSION}"
VIAddVersionKey "ProductName" "GNU Privacy Guard (${VERSION})"
@ -62,7 +59,7 @@ VIAddVersionKey "FileVersion" "${PROD_VERSION}"
; Interface Settings
; ------------------
!define MUI_ABORTWARNING
;;;!define MUI_ABORTWARNING
!define MUI_FINISHPAGE_NOAUTOCLOSE
!define MUI_UNFINISHPAGE_NOAUTOCLOSE
@ -95,15 +92,18 @@ VIAddVersionKey "FileVersion" "${PROD_VERSION}"
!insertmacro MUI_PAGE_LICENSE "COPYING.txt"
;;Page custom PageSelectOptions
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!define MUI_FINISHPAGE_SHOWREADME "README.txt"
!define MUI_FINISHPAGE_SHOWREADME_TEXT "$(T_ShowReadme)"
!define MUI_FINISHPAGE_LINK "Goto the GnuPG website"
!define MUI_FINISHPAGE_LINK_LOCATION "http://www.gnupg.org"
!define MUI_FINISHPAGE_LINK \
"Visit the GnuPG website for latest news and support"
!define MUI_FINISHPAGE_LINK_LOCATION "http://www.gnupg.org/"
!insertmacro MUI_PAGE_FINISH
@ -122,9 +122,17 @@ VIAddVersionKey "FileVersion" "${PROD_VERSION}"
; Installer Sections
; ------------------
;InstType "full"
;InstType "minimal"
!insertmacro MUI_RESERVEFILE_LANGDLL
;;!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
;;ReserveFile "w32inst-opt.ini"
ReserveFile "COPYING.txt"
;----------------------
Section "Base" SecBase
; SectionIn 1 2 RO
@ -132,26 +140,41 @@ Section "Base" SecBase
SetOutPath "$INSTDIR"
File "README.txt"
File "README.W32"
File "COPYING.txt"
File "gpg.exe"
File "gpgkeys_finger.exe"
File "gpgkeys_hkp.exe"
File "gpgkeys_http.exe"
File "gpgkeys_ldap.exe"
File "*.mo"
WriteRegStr HKCU "Software\GNU\GnuPG" "" $INSTDIR
SetOutPath "$INSTDIR\Doc"
File "README.txt"
File "README.W32"
File "COPYING.txt"
Call InstallIconv
WriteRegStr HKLM "Software\GNU\GnuPG" "Install Directory" $INSTDIR
WriteUninstaller "$INSTDIR\Uninstall.exe"
SectionEnd ; Section Base
;----------------------
Section "NLS" SecNLS
; SectionIn 1
SetOutPath "$INSTDIR\gnupg.nls"
File "*.mo"
SectionEnd ; Section NLS
;------------------------
Section "Tools" SecTools
; SectionIn 1
SetOutPath "$INSTDIR"
File "gpgsplit.exe"
File "gpgv.exe"
@ -161,6 +184,8 @@ SectionEnd ; Section Tools
Section "Documentation" SecDoc
; SectionIn 1
SetOutPath "$INSTDIR\Doc"
File "gnupg.man"
File "gpg.man"
File "gpgv.man"
@ -174,76 +199,52 @@ SectionEnd ; Section Documentation
!ifdef WITH_SOURCE
Section "Source" SecSource
; Note that we include the uncompressed tarball because this allows
; far better compression results for the distribution. We might
; want to compress it again after installation.
File "gnupg-1.4.0.tar"
SetOutPath "$INSTDIR\Src"
; Note that we include the uncompressed tarball because this allows
; far better compression results for the distribution. We might
; want to compress it again after installation.
File "gnupg-1.4.0.tar"
SectionEnd ; Section Source
!endif
;----------------------
Section "-Finish"
ClearErrors
GetDllVersion "iconv.dll" $R0 $R1
IfErrors 0 +3
MessageBox MB_OK \
"iconv.dll is not installed.$\r$\n \
It is highy suggested to install \
this DLL to help with character set conversion.$\r$\n$\r$\n \
See http://www.gnupg.org/download/iconv.html for instructions."
Return
IntOp $R2 $R0 / 0x00010000
IntOp $R3 $R0 & 0x0000FFFF
IntOp $R4 $R1 / 0x00010000
IntOp $R5 $R1 & 0x0000FFFF
StrCpy $0 "$R2.$R3.$R4.$R5"
DetailPrint "iconv.dll version is $0"
IntCmp $R2 1 0 IconvTooOld
IntCmp $R3 9 0 IconvTooOld
goto +3
IconvTooOld:
MessageBox MB_OK \
"The installed iconv.dll is too old.$\r$\n \
We require at least version 1.9.0.0 (installed: $0).$\r$\n \
It is highly suggested to install an updated DLL to help \
with character set conversion.$\r$\n$\r$\n \
See http://www.gnupg.org/download/iconv.html for instructions."
SectionEnd
;------------------
Section "Uninstall"
Delete "$INSTDIR\README.txt"
Delete "$INSTDIR\README.W32"
Delete "$INSTDIR\COPYING.txt"
Delete "$INSTDIR\gpg.exe"
Delete "$INSTDIR\gpgkeys_finger.exe"
Delete "$INSTDIR\gpgkeys_hkp.exe"
Delete "$INSTDIR\gpgkeys_http.exe"
Delete "$INSTDIR\gpgkeys_ldap.exe"
Delete "$INSTDIR\*.mo"
Delete "$INSTDIR\Doc\README.txt"
Delete "$INSTDIR\Doc\README.W32"
Delete "$INSTDIR\Doc\COPYING.txt"
Delete "$INSTDIR\iconv.dll"
Delete "$INSTDIR\gnupg.nls\*.mo"
Delete "$INSTDIR\gpgsplit.exe"
Delete "$INSTDIR\gpgv.exe"
Delete "$INSTDIR\gnupg.man"
Delete "$INSTDIR\gpg.man"
Delete "$INSTDIR\gpgv.man"
Delete "$INSTDIR\NEWS.txt"
Delete "$INSTDIR\FAQ.txt"
Delete "$INSTDIR\Doc\gnupg.man"
Delete "$INSTDIR\Doc\gpg.man"
Delete "$INSTDIR\Doc\gpgv.man"
Delete "$INSTDIR\Doc\NEWS.txt"
Delete "$INSTDIR\Doc\FAQ.txt"
Delete "$INSTDIR\Uninstall.exe"
RMDir "$INSTDIR\Doc"
RMDir "$INSTDIR\Src"
RMDir "$INSTDIR\gnupg.nls"
RMDir "$INSTDIR"
DeleteRegKey /ifempty HKCU "Software\GNU\GnuPG"
DeleteRegValue HKLM "Software\GNU\GnuPG" "Install Directory"
DeleteRegKey /ifempty HKLM "Software\GNU\GnuPG"
SectionEnd ; Uninstall
@ -256,6 +257,9 @@ Function .onInit
!insertmacro MUI_LANGDLL_DISPLAY
; !insertmacro MUI_INSTALLOPTIONS_EXTRACT_AS \
; "${GNUPG_SRCDIR}/scripts/w32inst-opt.ini" "w32inst-opt.ini"
FunctionEnd
@ -266,6 +270,53 @@ Function un.onInit
FunctionEnd
;;Function PageSelectOptions
;;
;; ; Setup a default for the langage to install. Take it form the registry
;;
;; !insertmacro MUI_HEADER_TEXT "Install Options" "Languages"
;; !insertmacro MUI_INSTALLOPTIONS_DISPLAY "w32inst-opt.ini"
;;
;; ; Save away the language to install
;;
;;FunctionEnd
;;
; Install iconv.dll if it has not been installed on the system.
Function InstallIconv
; First delete a iconv DLL already installed in the target directory.
; This is required to detect a meanwhile globally installed dll.
Delete "$INSTDIR\iconv.dll"
ClearErrors
GetDllVersion "iconv.dll" $R0 $R1
IfErrors 0 +3
DetailPrint "iconv.dll is not installed."
goto InstallIconv
IntOp $R2 $R0 / 0x00010000
IntOp $R3 $R0 & 0x0000FFFF
IntOp $R4 $R1 / 0x00010000
IntOp $R5 $R1 & 0x0000FFFF
StrCpy $0 "$R2.$R3.$R4.$R5"
DetailPrint "iconv.dll version is $0"
IntCmp $R2 1 0 IconvTooOld
IntCmp $R3 9 0 IconvTooOld
return
IconvTooOld:
DetailPrint "The installed iconv.dll is too old."
InstallIconv:
SetOutPath "$INSTDIR"
File "iconv.dll"
FunctionEnd
; ------------
; Descriptions
; ------------
@ -275,10 +326,12 @@ LangString T_About ${LANG_ENGLISH} \
"GnuPG is GNU's tool for secure communication and data storage. \
It can be used to encrypt data and to create digital signatures. \
It includes an advanced key management facility and is compliant \
with the proposed OpenPGP Internet standard as described in RFC2440."
with the proposed OpenPGP Internet standard as described in RFC2440. \
\r\n\r\nThis is GnuPG version ${VERSION}"
LangString T_About ${LANG_GERMAN} \
"GnuPG is das Werzeug aus dem GNU Projekt zur sicheren Kommunikation \
sowie zum sicheren Speichern von Daten."
sowie zum sicheren Speichern von Daten. \
\r\n\r\nThis is GnuPG version ${VERSION}"
LangString T_ShowReadme ${LANG_ENGLISH} "Show the README file"
LangString T_ShowReadme ${LANG_GERMAN} "Die README Datei anzeigen"
@ -288,6 +341,11 @@ LangString DESC_SecBase ${LANG_ENGLISH} \
LangString DESC_SecBase ${LANG_GERMAN} \
"Die Basis Dateien zur Benutzung des OpenPGP Protokolls"
Langstring DESC_SecNLS ${LANG_ENGLISH} \
"Support for languages other than English"
LangString DESC_SecNLS ${LANG_GERMAN} \
"Unterstützung für weitere Sprachen neben Englisch"
LangString DESC_SecTools ${LANG_ENGLISH} \
"Extra tools like gpgv and gpgsplit"
LangString DESC_SecTools ${LANG_GERMAN} \
@ -300,6 +358,7 @@ LangString DESC_SecDoc ${LANG_GERMAN} \
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SecBase} $(DESC_SecBase)
!insertmacro MUI_DESCRIPTION_TEXT ${SecNLS} $(DESC_SecNLS)
!insertmacro MUI_DESCRIPTION_TEXT ${SecTools} $(DESC_SecTools)
!insertmacro MUI_DESCRIPTION_TEXT ${SecDoc} $(DESC_SecDoc)
!insertmacro MUI_FUNCTION_DESCRIPTION_END

View File

@ -1,3 +1,16 @@
2005-01-20 Werner Koch <wk@g10code.com>
* simple-gettext.c (set_gettext_file): Use MO files depending on
the installation directory. Add new arg REGKEY.
2005-01-18 Werner Koch <wk@g10code.com>
* argparse.c (default_strusage): Changed default copyright year to
2005.
* strgutil.c (handle_iconv_error): Print error messages only once.
(native_to_utf8, utf8_to_native): Ditto.
2005-01-11 Werner Koch <wk@g10code.com>
* strgutil.c (set_native_charset) [W32]: Use the alias table from

View File

@ -914,7 +914,7 @@ default_strusage( int level )
switch( level ) {
case 11: p = "foo"; break;
case 13: p = "0.0"; break;
case 14: p = "Copyright (C) 2004 Free Software Foundation, Inc."; break;
case 14: p = "Copyright (C) 2005 Free Software Foundation, Inc."; break;
case 15: p =
"This program comes with ABSOLUTELY NO WARRANTY.\n"
"This is free software, and you are welcome to redistribute it\n"

View File

@ -1,5 +1,6 @@
/* simple-gettext.c - a simplified version of gettext.
* Copyright (C) 1995, 1996, 1997, 1999 Free Software Foundation, Inc.
* Copyright (C) 1995, 1996, 1997, 1999,
* 2005 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
@ -231,13 +232,14 @@ load_domain( const char *filename )
/****************
* Set the file used for translations. Pass a NULL to disable
* translation. A new filename may be set at anytime.
* WARNING: After changing the filename you should not access any data
* retrieved by gettext().
* Set the file used for translations. Pass a NULL to disable
* translation. A new filename may be set at anytime. If REGKEY is
* not NULL, the function tries to selected the language the registry
* key "Lang" below that key. WARNING: After changing the filename you
* should not access any data retrieved by gettext().
*/
int
set_gettext_file( const char *filename )
set_gettext_file ( const char *filename, const char *regkey )
{
struct loaded_domain *domain = NULL;
@ -252,30 +254,57 @@ set_gettext_file( const char *filename )
/* absolute path - use it as is */
domain = load_domain( filename );
}
else { /* relative path - append ".mo" and get dir from the environment */
char *buf = NULL;
char *dir;
else if (regkey) { /* Standard. */
char *instdir, *langid, *fname;
char *p;
dir = read_w32_registry_string( NULL,
"Control Panel\\Mingw32\\NLS",
"MODir" );
if( dir && (buf=malloc(strlen(dir)+strlen(filename)+1+3+1)) ) {
strcpy(stpcpy(stpcpy(stpcpy( buf, dir),"\\"), filename),".mo");
/* Better make sure that we don't mix forward and
backward slashes. It seems that some Windoze
versions don't accept this. */
for (p=buf; *p; p++)
{
if (*p == '/')
*p = '\\';
}
domain = load_domain( buf );
free(buf);
}
free(dir);
instdir = read_w32_registry_string ("HKEY_LOCAL_MACHINE",
regkey,
"Install Directory");
if (!instdir)
return -1;
langid = read_w32_registry_string (NULL, /* HKCU then HKLM */
regkey,
"Lang");
if (!langid) {
free (instdir);
return -1;
}
/* Strip stuff after a dot in case the user tried to enter
* the entire locale synatcs as usual for POSIX. */
p = strchr (langid, '.');
if (p)
*p = 0;
/* Build the key: "<instdir>/<domain>.nls/<langid>.mo" We
use a directory below the installation directory with
the domain included in case the software has been
insalled with other software altogether at the same
place. */
fname = malloc (strlen (instdir) + 1 + strlen (filename) + 5
+ strlen (langid) + 3 + 1);
if (!fname) {
free (instdir);
free (langid);
return -1;
}
strcpy (stpcpy (stpcpy (stpcpy (stpcpy ( stpcpy (fname,
instdir),"\\"), filename), ".nls\\"), langid), ".mo");
free (instdir);
free (langid);
/* Better make sure that we don't mix forward and
backward slashes. It seems that some Windoze
versions don't accept this. */
for (p=fname; *p; p++) {
if (*p == '/')
*p = '\\';
}
domain = load_domain (fname);
free(fname);
}
if( !domain )
if (!domain)
return -1;
}

View File

@ -1,6 +1,6 @@
/* strgutil.c - string utilities
* Copyright (C) 1994, 1998, 1999, 2000, 2001,
* 2003 Free Software Foundation, Inc.
* 2003, 2004, 2005 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
@ -453,10 +453,33 @@ static void
handle_iconv_error (const char *to, const char *from, int use_fallback)
{
if (errno == EINVAL)
log_info (_("conversion from `%s' to `%s' not available\n"),
from, to);
{
static int shown1, shown2;
int x;
if (to && !strcmp (to, "utf-8"))
{
x = shown1;
shown1 = 1;
}
else
{
x = shown2;
shown2 = 1;
}
if (!x)
log_info (_("conversion from `%s' to `%s' not available\n"),
from, to);
}
else
log_info (_("iconv_open failed: %s\n"), strerror (errno));
{
static int shown;
if (!shown)
log_info (_("iconv_open failed: %s\n"), strerror (errno));
shown = 1;
}
if (use_fallback)
{
@ -706,8 +729,12 @@ native_to_utf8( const char *string )
if ( iconv (cd, (ICONV_CONST char **)&inptr, &inbytes,
&outptr, &outbytes) == (size_t)-1)
{
log_info (_("conversion from `%s' to `%s' failed: %s\n"),
active_charset_name, "utf-8", strerror (errno));
static int shown;
if (!shown)
log_info (_("conversion from `%s' to `%s' failed: %s\n"),
active_charset_name, "utf-8", strerror (errno));
shown = 1;
/* We don't do any conversion at all but use the strings as is. */
strcpy (buffer, string);
}
@ -980,8 +1007,12 @@ utf8_to_native( const char *string, size_t length, int delim )
outbuf = outptr = m_alloc (outbytes);
if ( iconv (cd, (ICONV_CONST char **)&inptr, &inbytes,
&outptr, &outbytes) == (size_t)-1) {
log_info (_("conversion from `%s' to `%s' failed: %s\n"),
"utf-8", active_charset_name, strerror (errno));
static int shown;
if (!shown)
log_info (_("conversion from `%s' to `%s' failed: %s\n"),
"utf-8", active_charset_name, strerror (errno));
shown = 1;
/* Didn't worked out. Temporary disable the use of
* iconv and fall back to our old code. */
m_free (buffer);