mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
First batch of changes to support W32CE.
Note that jnlib/w32-reg.c is not yet ready.
This commit is contained in:
parent
0e018d7144
commit
2cf687cb3e
73
ChangeLog
73
ChangeLog
@ -1,8 +1,15 @@
|
||||
2010-02-26 Werner Koch <wk@g10code.com>
|
||||
|
||||
* gl/mkdtemp.c (__set_errno) [W32CE]: Use gpg_err_set_errno.
|
||||
* gl/setenv.c (__set_errno) [W32CE]: Ditto.
|
||||
* gl/unsetenv.c (__set_errno) [W32CE]: Ditto.
|
||||
|
||||
* configure.ac (HAVE_W32CE_SYSTEM): New ac_define and
|
||||
am_conditional.
|
||||
* autogen.sh: New option --build-w32ce.
|
||||
(signal.h, getenv): Check for them.
|
||||
|
||||
* autogen.sh: New option --build-w32ce. Remove obsolete option
|
||||
--without-included-gettext.
|
||||
|
||||
2009-12-08 Werner Koch <wk@g10code.com>
|
||||
|
||||
@ -412,7 +419,7 @@
|
||||
2006-09-18 Werner Koch <wk@g10code.com>
|
||||
|
||||
Released 1.9.23.
|
||||
|
||||
|
||||
* configure.ac (--enable-agent-only): Donot build tools and doc
|
||||
(--disable-tools,--disable-doc): New.
|
||||
* Makefile.am (SUBDIRS): Allow to conditional build tools and doc.
|
||||
@ -421,7 +428,7 @@
|
||||
|
||||
Replaced all call gpg_error_from_errno(errno) by
|
||||
gpg_error_from_syserror().
|
||||
|
||||
|
||||
* configure.ac: Build gpg by default.
|
||||
(GNUPG_SYS_SO_PEERCRED): Removed.
|
||||
|
||||
@ -436,7 +443,7 @@
|
||||
2006-09-06 Werner Koch <wk@g10code.com>
|
||||
|
||||
* configure.ac: Define _ASSUAN_ONLY_GPG_ERRORS. Require Assuan
|
||||
0.9 and libgpg-error 1.4
|
||||
0.9 and libgpg-error 1.4.
|
||||
|
||||
2006-08-31 Werner Koch <wk@g10code.com>
|
||||
|
||||
@ -478,7 +485,7 @@
|
||||
|
||||
2006-07-03 Werner Koch <wk@g10code.com>
|
||||
|
||||
* configure.ac: Test for ksba_dn_teststr.
|
||||
* configure.ac: Test for ksba_dn_teststr.
|
||||
|
||||
2006-06-30 Werner Koch <wk@g10code.com>
|
||||
|
||||
@ -486,7 +493,7 @@
|
||||
* Makefile.am (SUBDIRS): Include keyserver/.
|
||||
* configure.ac: Include keyserver/.
|
||||
(FAKE_CURL, GPGKEYS_CURL): New.
|
||||
|
||||
|
||||
2006-06-20 Werner Koch <wk@g10code.com>
|
||||
|
||||
Released 1.9.21.
|
||||
@ -540,7 +547,7 @@
|
||||
2005-08-01 Werner Koch <wk@g10code.com>
|
||||
|
||||
Released 1.9.18.
|
||||
|
||||
|
||||
* configure.ac: Require libksba 0.9.12 to match new features in gpgsm.
|
||||
|
||||
2005-06-20 Werner Koch <wk@g10code.com>
|
||||
@ -577,7 +584,7 @@
|
||||
2005-04-21 Werner Koch <wk@g10code.com>
|
||||
|
||||
Released 1.9.16.
|
||||
|
||||
|
||||
* configure.ac: Do not build gpg by default.
|
||||
|
||||
2005-04-20 Werner Koch <wk@g10code.com>
|
||||
@ -592,7 +599,7 @@
|
||||
2005-04-15 Marcus Brinkmann <marcus@g10code.de>
|
||||
|
||||
* configure.ac: Check for /usr/bin/shred and define SHRED.
|
||||
|
||||
|
||||
* configure.ac: Add --enable-symcryptrun, disabled by default.
|
||||
Define automake variable BUILD_SYMCRYPTRUN.
|
||||
Check for openpty -lutil, define LIBUTIL_LIBS.
|
||||
@ -635,8 +642,8 @@
|
||||
2004-12-20 Werner Koch <wk@g10code.com>
|
||||
|
||||
* configure.ac: Add PATHSEP_C and PATHSEP_S. For W32 let all
|
||||
directories default to c:/gnupg. Require libassuan 0.6.9.
|
||||
|
||||
directories default to c:/gnupg. Require libassuan 0.6.9.
|
||||
|
||||
2004-12-18 Werner Koch <wk@g10code.com>
|
||||
|
||||
* configure.ac (AH_BOTTOM): Define EXEEXT_S.
|
||||
@ -666,7 +673,7 @@
|
||||
|
||||
* configure.ac: Replace strsep. Replaced use of "target" by
|
||||
"host".
|
||||
|
||||
|
||||
2004-10-22 Werner Koch <wk@g10code.com>
|
||||
|
||||
Released 1.9.12.
|
||||
@ -689,7 +696,7 @@
|
||||
|
||||
* configure.ac: Build Makefile for tests/pkits. New option
|
||||
--with-pkits-tests.
|
||||
|
||||
|
||||
2004-08-05 Werner Koch <wk@g10code.de>
|
||||
|
||||
* configure.ac: Changed tests for libusb to also suuport the
|
||||
@ -754,7 +761,7 @@
|
||||
2004-03-06 Werner Koch <wk@gnupg.org>
|
||||
|
||||
Released 1.9.6.
|
||||
|
||||
|
||||
* configure.ac: Check the Libgcrypt API.
|
||||
|
||||
2004-02-25 Werner Koch <wk@gnupg.org>
|
||||
@ -842,7 +849,7 @@
|
||||
2003-11-17 Werner Koch <wk@gnupg.org>
|
||||
|
||||
Release 1.9.2.
|
||||
|
||||
|
||||
* configure.ac: Requires now libassuan 0.6.1.
|
||||
|
||||
2003-10-31 Werner Koch <wk@gnupg.org>
|
||||
@ -858,12 +865,12 @@
|
||||
|
||||
2003-10-01 Werner Koch <wk@gnupg.org>
|
||||
|
||||
* configure.ac (AH_BOTTOM): Define GNUPG_MAJOR_VERSION.
|
||||
* configure.ac (AH_BOTTOM): Define GNUPG_MAJOR_VERSION.
|
||||
|
||||
2003-09-23 Werner Koch <wk@gnupg.org>
|
||||
|
||||
Merged most of David Shaw's changes in 1.3 since 2003-06-03.
|
||||
|
||||
|
||||
* configure.ac: Drop all TIGER/192 support.
|
||||
(uint64_t): Check for UINT64_C to go along with uint64_t.
|
||||
(getaddrinfo): Check for it.
|
||||
@ -877,7 +884,7 @@
|
||||
2003-09-06 Werner Koch <wk@gnupg.org>
|
||||
|
||||
Released 1.9.1.
|
||||
|
||||
|
||||
* configure.ac: Require newer versions of some libraries.
|
||||
|
||||
2003-09-02 Werner Koch <wk@gnupg.org>
|
||||
@ -898,9 +905,9 @@
|
||||
2003-08-05 Werner Koch <wk@gnupg.org>
|
||||
|
||||
Released 1.9.0.
|
||||
|
||||
|
||||
* configure.ac (GNUPG_DEFAULT_HONMEDIR): Changed back to ~/.gnupg.
|
||||
|
||||
|
||||
2003-07-31 Werner Koch <wk@gnupg.org>
|
||||
|
||||
* Makefile.am (DISTCLEANFILES): Add g10defs.h
|
||||
@ -923,7 +930,7 @@
|
||||
|
||||
* configure.ac: Build a limited version of scdaemon if libopensc
|
||||
is not available.
|
||||
|
||||
|
||||
* configure.ac (ALL_LINUGAS): Removed.
|
||||
|
||||
* Makefile.am (ACLOCAL_AMFLAGS): New.
|
||||
@ -945,10 +952,10 @@
|
||||
|
||||
2003-01-09 Werner Koch <wk@gnupg.org>
|
||||
|
||||
* configure.ac (GNUPG_PROTECT_TOOL): New option --with-protect-tool.
|
||||
* configure.ac (GNUPG_PROTECT_TOOL): New option --with-protect-tool.
|
||||
(NEED_KSBA_VERSION): Does now require 0.4.6.
|
||||
|
||||
* README: Noted where to find gpg-protect-tool.
|
||||
* README: Noted where to find gpg-protect-tool.
|
||||
|
||||
2002-10-31 Neal H. Walfield <neal@g10code.de>
|
||||
|
||||
@ -1004,7 +1011,7 @@
|
||||
2002-08-10 Werner Koch <wk@gnupg.org>
|
||||
|
||||
Released 0.3.10.
|
||||
|
||||
|
||||
* configure.ac (NEED_LIBKSBA_VERSION): Require 0.4.4. Add support
|
||||
for gettext.
|
||||
|
||||
@ -1015,7 +1022,7 @@
|
||||
2002-07-01 Werner Koch <wk@gnupg.org>
|
||||
|
||||
Released 0.3.9.
|
||||
|
||||
|
||||
* README: Short note on how to export in pkcs-12 format.
|
||||
|
||||
2002-06-29 Werner Koch <wk@gnupg.org>
|
||||
@ -1032,7 +1039,7 @@
|
||||
2002-06-25 Werner Koch <wk@gnupg.org>
|
||||
|
||||
Released 0.3.8.
|
||||
|
||||
|
||||
* configure.ac (NEED_LIBGCRYPT_VERSION): Set to 1.1.8.
|
||||
|
||||
2002-06-12 Werner Koch <wk@gnupg.org>
|
||||
@ -1050,7 +1057,7 @@
|
||||
2002-05-14 Werner Koch <wk@gnupg.org>
|
||||
|
||||
* doc/: New
|
||||
* configure.ac, Makefile.am: Added doc/
|
||||
* configure.ac, Makefile.am: Added doc/.
|
||||
|
||||
2002-05-03 Werner Koch <wk@gnupg.org>
|
||||
|
||||
@ -1067,9 +1074,9 @@
|
||||
2002-04-15 Werner Koch <wk@gnupg.org>
|
||||
|
||||
Released 0.3.5.
|
||||
|
||||
|
||||
* NEWS: Started to describe release notes.
|
||||
|
||||
|
||||
* configure.ac (NEED_LIBKSBA_VERSION, NEED_LIBGCRYPT_VERSION): Defined
|
||||
|
||||
2002-04-01 Werner Koch <wk@gnupg.org>
|
||||
@ -1154,9 +1161,9 @@
|
||||
|
||||
* configure.ac (HAVE_JNLIB_LOGGING): always define it.
|
||||
|
||||
|
||||
Copyright 2001, 2002, 2003, 2004, 2005, 2006,
|
||||
2007 Free Software Foundation, Inc.
|
||||
|
||||
Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007.
|
||||
2010 Free Software Foundation, Inc.
|
||||
|
||||
This file is free software; as a special exception the author gives
|
||||
unlimited permission to copy and/or distribute it, with or without
|
||||
@ -1165,5 +1172,5 @@
|
||||
This file is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
|
||||
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
|
||||
|
||||
|
2
NEWS
2
NEWS
@ -21,6 +21,8 @@ Noteworthy changes in version 2.1.x (under development)
|
||||
* New and changed passphrases are now created with an iteration count
|
||||
requiring about 100ms of CPU work.
|
||||
|
||||
* Ported to Windows CE.
|
||||
|
||||
|
||||
Noteworthy changes in version 2.0.13 (2009-09-04)
|
||||
-------------------------------------------------
|
||||
|
@ -123,8 +123,7 @@ if [ "$myhost" = "w32" ]; then
|
||||
--with-zlib=${w32root} \
|
||||
--with-regex=${w32root} \
|
||||
--with-pth-prefix=${w32root} \
|
||||
--with-adns=${w32root} \
|
||||
--without-included-gettext "$@"
|
||||
--with-adns=${w32root} "$@"
|
||||
rc=$?
|
||||
exit $rc
|
||||
fi
|
||||
|
11
configure.ac
11
configure.ac
@ -918,6 +918,9 @@ AC_SUBST(GPGKEYS_MAILTO)
|
||||
# Construct a printable name of the OS
|
||||
#
|
||||
case "${host}" in
|
||||
*-mingw32ce*)
|
||||
PRINTABLE_OS_NAME="W32CE"
|
||||
;;
|
||||
*-mingw32*)
|
||||
PRINTABLE_OS_NAME="MingW32"
|
||||
;;
|
||||
@ -1089,9 +1092,11 @@ AC_CHECK_TYPES([struct sigaction, sigset_t],,,[#include <signal.h>])
|
||||
#
|
||||
# These are needed by libjnlib - fixme: we should use a jnlib.m4
|
||||
# Note: We already checked pwd.h.
|
||||
AC_CHECK_FUNCS([memicmp stpcpy strsep strlwr strtoul memmove stricmp strtol])
|
||||
AC_CHECK_FUNCS([memrchr isascii timegm getrusage setrlimit stat setlocale])
|
||||
AC_CHECK_FUNCS([flockfile funlockfile fopencookie funopen getpwnam getpwuid])
|
||||
AC_CHECK_HEADERS([signal.h])
|
||||
AC_CHECK_FUNCS([memicmp stpcpy strsep strlwr strtoul memmove stricmp strtol \
|
||||
memrchr isascii timegm getrusage setrlimit stat setlocale \
|
||||
flockfile funlockfile fopencookie funopen getpwnam getpwuid \
|
||||
getenv ])
|
||||
|
||||
#
|
||||
# gnulib checks
|
||||
|
@ -29,6 +29,10 @@ MAINTAINERCLEANFILES =
|
||||
|
||||
AM_CPPFLAGS =
|
||||
|
||||
if HAVE_W32CE_SYSTEM
|
||||
AM_CFLAGS = $(GPG_ERROR_CFLAGS)
|
||||
endif
|
||||
|
||||
## begin gnulib module alloca-opt
|
||||
|
||||
BUILT_SOURCES += $(ALLOCA_H)
|
||||
|
@ -23,7 +23,12 @@
|
||||
|
||||
#include <errno.h>
|
||||
#ifndef __set_errno
|
||||
# define __set_errno(Val) errno = (Val)
|
||||
# ifdef HAVE_W32CE_SYSTEM
|
||||
# include <gpg-error.h>
|
||||
# define __set_errno(Val) gpg_err_set_errno ((Val))
|
||||
# else
|
||||
# define __set_errno(Val) errno = (Val)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
|
@ -21,7 +21,12 @@
|
||||
|
||||
#include <errno.h>
|
||||
#ifndef __set_errno
|
||||
# define __set_errno(ev) ((errno) = (ev))
|
||||
# ifdef HAVE_W32CE_SYSTEM
|
||||
# include <gpg-error.h>
|
||||
# define __set_errno(ev) gpg_err_set_errno ((ev))
|
||||
# else
|
||||
# define __set_errno(ev) ((errno) = (ev))
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
@ -18,7 +18,12 @@
|
||||
|
||||
#include <errno.h>
|
||||
#if !_LIBC
|
||||
# define __set_errno(ev) ((errno) = (ev))
|
||||
# ifdef HAVE_W32CE_SYSTEM
|
||||
# include <gpg-error.h>
|
||||
# define __set_errno(ev) gpg_err_set_errno ((ev))
|
||||
# else
|
||||
# define __set_errno(ev) ((errno) = (ev))
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
@ -1,3 +1,44 @@
|
||||
2010-02-26 Werner Koch <wk@g10code.com>
|
||||
|
||||
* t-timestuff.c: New.
|
||||
|
||||
* dynload.h (dlopen, dlsym) [W32CE]: Map to wchar_t.
|
||||
|
||||
* mischelp.c (_jnlib_free): New.
|
||||
(same_file_p) [W32CE]: Map to wchar_t.
|
||||
|
||||
* utf8conv.c (set_native_charset) [W32CE]: Do not use
|
||||
GetConsoleOutputCP.
|
||||
(wchar_to_utf8, utf8_to_wchar) [W32]: New.
|
||||
|
||||
* Makefile.am (t_jnlib_ldadd) [W32CE]: Add gpg-error.
|
||||
|
||||
* t-support.h (getenv) [HAVE_GETENV]: Add getenv stub.
|
||||
[W32CE]: Include gpg-error.h
|
||||
* t-support.c (gpg_err_code_from_errno)
|
||||
(gpg_err_code_from_syserror) [GPG_ERROR_H]: Do not build.
|
||||
|
||||
* t-stringhelp.c (gethome) [!HAVE_GETPWUID]: Keep result of getenv.
|
||||
|
||||
* dotlock.c [!HAVE_SIGNAL_H]: Don't include signal.h.
|
||||
(create_dotlock) [W32CE]: Map filename top wchar_t.
|
||||
|
||||
* libjnlib-config.h [USE_SIMPLE_GETTEXT]: Include gpg-error.h and
|
||||
remove w32help.h.
|
||||
(jnlib_set_errno): New. Use it everywhere to set ERRNO.
|
||||
(getenv) [!HAVE_GETENV]: New.
|
||||
(getpid) [W32E]: New.
|
||||
|
||||
* stringhelp.c (get_pwdir) [!HAVE_PWD_H]: Mark unused args.
|
||||
(w32_strerror) [W32CE]: Use a simple implementation.
|
||||
|
||||
* w32help.h [USE_SIMPLE_GETTEXT]: Remove all definitions; we are
|
||||
now using the gpg-error included implementation.
|
||||
* w32-gettext.c: Remove.
|
||||
|
||||
* mischelp.c (same_file_p): Fix bug in case the second file can't
|
||||
be opened.
|
||||
|
||||
2009-10-19 Werner Koch <wk@g10code.com>
|
||||
|
||||
* strlist.c (add_to_strlist_try): New.
|
||||
@ -696,10 +737,10 @@ Mon Jan 24 13:04:28 CET 2000 Werner Koch <wk@gnupg.de>
|
||||
***********************************************************
|
||||
* Please note that JNLIB is maintained as part of GnuPG. *
|
||||
* You may find it source-copied in other packages. *
|
||||
***********************************************************
|
||||
|
||||
Copyright 2000, 2001, 2002, 2003, 2004,
|
||||
2005, 2006, 2007, 2008 Free Software Foundation, Inc.
|
||||
***********************************************************
|
||||
|
||||
Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
|
||||
2010 Free Software Foundation, Inc.
|
||||
|
||||
This file is free software; as a special exception the author gives
|
||||
unlimited permission to copy and/or distribute it, with or without
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Makefile for the JNLIB part of GnuPG
|
||||
# Copyright (C) 1999, 2000, 2001, 2004,
|
||||
# 2006 Feee Software Soundation, Inc.
|
||||
# Copyright (C) 1999, 2000, 2001, 2004, 2006,
|
||||
# 2010 Feee Software Soundation, Inc.
|
||||
#
|
||||
# This file is part of JNLIB.
|
||||
#
|
||||
@ -44,7 +44,7 @@ libjnlib_a_SOURCES = \
|
||||
types.h mischelp.c mischelp.h dynload.h w32help.h
|
||||
|
||||
if HAVE_W32_SYSTEM
|
||||
libjnlib_a_SOURCES += w32-reg.c w32-afunix.c w32-afunix.h w32-gettext.c
|
||||
libjnlib_a_SOURCES += w32-reg.c w32-afunix.c w32-afunix.h
|
||||
endif
|
||||
|
||||
|
||||
@ -60,11 +60,19 @@ endif
|
||||
# defines replacements for the actual used memory allocation functions
|
||||
# so that there is no dependency on libgcrypt.
|
||||
#
|
||||
module_tests = t-stringhelp
|
||||
module_tests = t-stringhelp t-timestuff
|
||||
|
||||
t_jnlib_src = t-support.c t-support.h
|
||||
t_jnlib_ldadd = libjnlib.a $(LIBINTL) $(LIBICONV)
|
||||
# For W32 we need libgpg-error because it provides gettext.
|
||||
if HAVE_W32_SYSTEM
|
||||
t_jnlib_ldadd += $(GPG_ERROR_LIBS)
|
||||
endif
|
||||
|
||||
t_stringhelp_SOURCES = t-stringhelp.c $(t_jnlib_src)
|
||||
t_stringhelp_LDADD = $(t_jnlib_ldadd)
|
||||
|
||||
t_timestuff_SOURCES = t-timestuff.c $(t_jnlib_src)
|
||||
t_timestuff_LDADD = $(t_jnlib_ldadd)
|
||||
|
||||
|
||||
|
@ -35,11 +35,14 @@
|
||||
#include <sys/time.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
#ifdef HAVE_SIGNAL_H
|
||||
# include <signal.h>
|
||||
#endif
|
||||
|
||||
#include "libjnlib-config.h"
|
||||
#include "stringhelp.h"
|
||||
#include "dotlock.h"
|
||||
#include "utf8conv.h"
|
||||
|
||||
#if !defined(DIRSEP_C) && !defined(EXTSEP_C) \
|
||||
&& !defined(DIRSEP_S) && !defined(EXTSEP_S)
|
||||
@ -222,7 +225,7 @@ create_dotlock (const char *file_to_lock)
|
||||
|
||||
do
|
||||
{
|
||||
errno = 0;
|
||||
jnlib_set_errno (0);
|
||||
fd = open (h->tname, O_WRONLY|O_CREAT|O_EXCL,
|
||||
S_IRUSR|S_IRGRP|S_IROTH|S_IWUSR );
|
||||
}
|
||||
@ -301,10 +304,23 @@ create_dotlock (const char *file_to_lock)
|
||||
would not stop as expected but spin til until Windows crashes.
|
||||
Our solution is to keep the lock file open; that does not
|
||||
harm. */
|
||||
h->lockhd = CreateFile (h->lockname,
|
||||
GENERIC_READ|GENERIC_WRITE,
|
||||
FILE_SHARE_READ|FILE_SHARE_WRITE,
|
||||
NULL, OPEN_ALWAYS, 0, NULL);
|
||||
{
|
||||
#ifdef HAVE_W32CE_SYSTEM
|
||||
wchar_t *wname = utf8_to_wchar (h->lockname);
|
||||
|
||||
h->lockhd = INVALID_HANDLE_VALUE;
|
||||
if (wname)
|
||||
h->lockhd = CreateFile (wname,
|
||||
#else
|
||||
h->lockhd = CreateFile (h->lockname,
|
||||
#endif
|
||||
GENERIC_READ|GENERIC_WRITE,
|
||||
FILE_SHARE_READ|FILE_SHARE_WRITE,
|
||||
NULL, OPEN_ALWAYS, 0, NULL);
|
||||
#ifdef HAVE_W32CE_SYSTEM
|
||||
jnlib_free (wname);
|
||||
#endif
|
||||
}
|
||||
if (h->lockhd == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
log_error (_("can't create `%s': %s\n"), h->lockname, w32_strerror (-1));
|
||||
@ -613,7 +629,7 @@ read_lockfile (dotlock_t h, int *same_node )
|
||||
h->lockname, strerror(errno) );
|
||||
if (buffer != buffer_space)
|
||||
jnlib_free (buffer);
|
||||
errno = e; /* Need to return ERRNO here. */
|
||||
jnlib_set_errno (e); /* Need to return ERRNO here. */
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -630,7 +646,7 @@ read_lockfile (dotlock_t h, int *same_node )
|
||||
close (fd);
|
||||
if (buffer != buffer_space)
|
||||
jnlib_free (buffer);
|
||||
errno = 0; /* Do not return an inappropriate ERRNO. */
|
||||
jnlib_set_errno (0); /* Do not return an inappropriate ERRNO. */
|
||||
return -1;
|
||||
}
|
||||
p += res;
|
||||
@ -644,7 +660,7 @@ read_lockfile (dotlock_t h, int *same_node )
|
||||
log_info ("invalid size of lockfile `%s'", h->lockname );
|
||||
if (buffer != buffer_space)
|
||||
jnlib_free (buffer);
|
||||
errno = 0; /* Better don't return an inappropriate ERRNO. */
|
||||
jnlib_set_errno (0); /* Better don't return an inappropriate ERRNO. */
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -660,7 +676,7 @@ read_lockfile (dotlock_t h, int *same_node )
|
||||
log_error ("invalid pid %d in lockfile `%s'", pid, h->lockname );
|
||||
if (buffer != buffer_space)
|
||||
jnlib_free (buffer);
|
||||
errno = 0;
|
||||
jnlib_set_errno (0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* dynload.h - Wrapper functions for run-time dynamic loading
|
||||
* Copyright (C) 2003 Free Software Foundation, Inc.
|
||||
* Copyright (C) 2003, 2010 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of JNLIB.
|
||||
*
|
||||
@ -24,13 +24,21 @@
|
||||
# include <dlfcn.h>
|
||||
#else
|
||||
# include <windows.h>
|
||||
|
||||
# include "utf8conv.h"
|
||||
# include "mischelp.h"
|
||||
# define RTLD_LAZY 0
|
||||
|
||||
static inline void *
|
||||
dlopen (const char * name, int flag)
|
||||
dlopen (const char *name, int flag)
|
||||
{
|
||||
void * hd = LoadLibrary (name);
|
||||
void *hd;
|
||||
#ifdef HAVE_W32CE_SYSTEM
|
||||
wchar_t *wname = utf8_to_wchar (name);
|
||||
hd = wname? LoadLibrary (wname) : NULL;
|
||||
_jnlib_free (wname);
|
||||
#else
|
||||
hd = LoadLibrary (name);
|
||||
#endif
|
||||
(void)flag;
|
||||
return hd;
|
||||
}
|
||||
@ -40,7 +48,13 @@ dlsym (void *hd, const char *sym)
|
||||
{
|
||||
if (hd && sym)
|
||||
{
|
||||
void * fnc = GetProcAddress (hd, sym);
|
||||
#ifdef HAVE_W32CE_SYSTEM
|
||||
wchar_t *wsym = utf8_to_wchar (sym);
|
||||
void *fnc = wsym? GetProcAddress (hd, wsym) : NULL;
|
||||
_jnlib_free (wsym);
|
||||
#else
|
||||
void *fnc = GetProcAddress (hd, sym);
|
||||
#endif
|
||||
if (!fnc)
|
||||
return NULL;
|
||||
return fnc;
|
||||
@ -53,7 +67,7 @@ static inline const char *
|
||||
dlerror (void)
|
||||
{
|
||||
static char buf[32];
|
||||
sprintf (buf, "ec=%lu", GetLastError ());
|
||||
snprintf (buf, sizeof buf, "ec=%lu", GetLastError ());
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@
|
||||
|
||||
/* Gettext stuff */
|
||||
#ifdef USE_SIMPLE_GETTEXT
|
||||
# include "w32help.h"
|
||||
# include <gpg-error.h>
|
||||
# define _(a) gettext (a)
|
||||
# define N_(a) (a)
|
||||
|
||||
@ -80,5 +80,20 @@
|
||||
#define jnlib_log_fatal log_fatal
|
||||
#define jnlib_log_bug log_bug
|
||||
|
||||
/* Wrapper to set ERRNO. */
|
||||
#ifdef HAVE_W32CE_SYSTEM
|
||||
# define jnlib_set_errno(e) gpg_err_set_errno ((e))
|
||||
#else
|
||||
# define jnlib_set_errno(e) do { errno = (e); } while (0)
|
||||
#endif
|
||||
|
||||
/* Dummy replacement for getenv. */
|
||||
#ifndef HAVE_GETENV
|
||||
#define getenv(a) (NULL)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_W32CE_SYSTEM
|
||||
#define getpid() GetCurrentProcessId ()
|
||||
#endif
|
||||
|
||||
#endif /*LIBJNUTIL_CONFIG_H*/
|
||||
|
@ -29,12 +29,24 @@
|
||||
# include <sys/stat.h>
|
||||
# include <unistd.h>
|
||||
#endif /*!HAVE_W32_SYSTEM*/
|
||||
#include <errno.h>
|
||||
|
||||
#include "libjnlib-config.h"
|
||||
#include "stringhelp.h"
|
||||
#include "utf8conv.h"
|
||||
#include "mischelp.h"
|
||||
|
||||
|
||||
/* Because we can't use our jnlib_free macro in inline functions we
|
||||
provide this wrapper. */
|
||||
void
|
||||
_jnlib_free (void *p)
|
||||
{
|
||||
if (p)
|
||||
jnlib_free (p);
|
||||
}
|
||||
|
||||
|
||||
/* Check whether the files NAME1 and NAME2 are identical. This is for
|
||||
example achieved by comparing the inode numbers of the files. */
|
||||
int
|
||||
@ -50,14 +62,36 @@ same_file_p (const char *name1, const char *name2)
|
||||
#ifdef HAVE_W32_SYSTEM
|
||||
HANDLE file1, file2;
|
||||
BY_HANDLE_FILE_INFORMATION info1, info2;
|
||||
|
||||
|
||||
#ifdef HAVE_W32CE_SYSTEM
|
||||
{
|
||||
wchar_t *wname = utf8_to_wchar (name1);
|
||||
if (wname)
|
||||
file1 = CreateFile (wname, 0, 0, NULL, OPEN_EXISTING, 0, NULL);
|
||||
else
|
||||
file1 = INVALID_HANDLE_VALUE;
|
||||
jnlib_free (wname);
|
||||
}
|
||||
#else
|
||||
file1 = CreateFile (name1, 0, 0, NULL, OPEN_EXISTING, 0, NULL);
|
||||
#endif
|
||||
if (file1 == INVALID_HANDLE_VALUE)
|
||||
yes = 0; /* If we can't open the file, it is not the same. */
|
||||
else
|
||||
{
|
||||
#ifdef HAVE_W32CE_SYSTEM
|
||||
{
|
||||
wchar_t *wname = utf8_to_wchar (name2);
|
||||
if (wname)
|
||||
file2 = CreateFile (wname, 0, 0, NULL, OPEN_EXISTING, 0, NULL);
|
||||
else
|
||||
file2 = INVALID_HANDLE_VALUE;
|
||||
jnlib_free (wname);
|
||||
}
|
||||
#else
|
||||
file2 = CreateFile (name2, 0, 0, NULL, OPEN_EXISTING, 0, NULL);
|
||||
if (file1 == INVALID_HANDLE_VALUE)
|
||||
#endif
|
||||
if (file2 == INVALID_HANDLE_VALUE)
|
||||
yes = 0; /* If we can't open the file, it is not the same. */
|
||||
else
|
||||
{
|
||||
@ -87,7 +121,7 @@ same_file_p (const char *name1, const char *name2)
|
||||
and get back a time_t. It differs from mktime() in that it handles
|
||||
the case where the struct tm is UTC and the local environment isn't.
|
||||
|
||||
Note, that this replacement implementaion is not thread-safe!
|
||||
Note, that this replacement implementation might not be thread-safe!
|
||||
|
||||
Some BSDs don't handle the putenv("foo") case properly, so we use
|
||||
unsetenv if the platform has it to remove environment variables.
|
||||
@ -96,6 +130,35 @@ same_file_p (const char *name1, const char *name2)
|
||||
time_t
|
||||
timegm (struct tm *tm)
|
||||
{
|
||||
#ifdef HAVE_W32_SYSTEM
|
||||
/* This one is thread safe. */
|
||||
SYSTEMTIME st;
|
||||
FILETIME ft;
|
||||
unsigned long long cnsecs;
|
||||
|
||||
st.wYear = tm->tm_year + 1900;
|
||||
st.wMonth = tm->tm_mon + 1;
|
||||
st.wDay = tm->tm_mday;
|
||||
st.wHour = tm->tm_hour;
|
||||
st.wMinute = tm->tm_min;
|
||||
st.wSecond = tm->tm_sec;
|
||||
st.wMilliseconds = 0; /* Not available. */
|
||||
st.wDayOfWeek = 0; /* Ignored. */
|
||||
|
||||
/* System time is UTC thus the conversion is pretty easy. */
|
||||
if (!SystemTimeToFileTime (&st, &ft))
|
||||
{
|
||||
jnlib_set_errno (EINVAL);
|
||||
return (time_t)(-1);
|
||||
}
|
||||
|
||||
cnsecs = (((unsigned long long)ft.dwHighDateTime << 32)
|
||||
| ft.dwLowDateTime);
|
||||
cnsecs -= 116444736000000000ULL; /* The filetime epoch is 1601-01-01. */
|
||||
return (time_t)(cnsecs / 10000000ULL);
|
||||
|
||||
#else /* (Non thread safe implementation!) */
|
||||
|
||||
time_t answer;
|
||||
char *zone;
|
||||
|
||||
@ -128,6 +191,7 @@ timegm (struct tm *tm)
|
||||
|
||||
tzset();
|
||||
return answer;
|
||||
#endif
|
||||
}
|
||||
#endif /*!HAVE_TIMEGM*/
|
||||
|
||||
|
@ -22,6 +22,10 @@
|
||||
#define LIBJNLIB_MISCHHELP_H
|
||||
|
||||
|
||||
/* Because we can't use the internal jnlib_free macro in inline
|
||||
functions we provide a wrapper fucntion as well. */
|
||||
void _jnlib_free (void *p);
|
||||
|
||||
/* Check whether the files NAME1 and NAME2 are identical. This is for
|
||||
example achieved by comparing the inode numbers of the files. */
|
||||
int same_file_p (const char *name1, const char *name2);
|
||||
|
@ -346,6 +346,10 @@ get_pwdir (int xmode, const char *name)
|
||||
else
|
||||
result = jnlib_strdup (pwd->pw_dir);
|
||||
}
|
||||
#else /*!HAVE_PWD_H*/
|
||||
/* No support at all. */
|
||||
(void)xmode;
|
||||
(void)name;
|
||||
#endif /*HAVE_PWD_H*/
|
||||
return result;
|
||||
}
|
||||
@ -369,7 +373,7 @@ do_make_filename (int xmode, const char *first_part, va_list arg_ptr)
|
||||
{
|
||||
if (xmode)
|
||||
BUG ();
|
||||
errno = EINVAL;
|
||||
jnlib_set_errno (EINVAL);
|
||||
return NULL;
|
||||
}
|
||||
argc++;
|
||||
@ -738,9 +742,15 @@ w32_strerror (int ec)
|
||||
|
||||
if (ec == -1)
|
||||
ec = (int)GetLastError ();
|
||||
#ifdef HAVE_W32CE_SYSTEM
|
||||
/* There is only a wchar_t FormatMessage. It does not make much
|
||||
sense to play the conversion game; we print only the code. */
|
||||
snprintf (strerr, sizeof strerr, "ec=%d", (int)GetLastError ());
|
||||
#else
|
||||
FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL, ec,
|
||||
MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
strerr, DIM (strerr)-1, NULL);
|
||||
#endif
|
||||
return strerr;
|
||||
}
|
||||
#endif /*HAVE_W32_SYSTEM*/
|
||||
@ -1076,7 +1086,7 @@ do_strconcat (const char *s1, va_list arg_ptr)
|
||||
needed += strlen (argv[argc]);
|
||||
if (argc >= DIM (argv)-1)
|
||||
{
|
||||
errno = EINVAL;
|
||||
jnlib_set_errno (EINVAL);
|
||||
return NULL;
|
||||
}
|
||||
argc++;
|
||||
|
@ -43,9 +43,9 @@ gethome (void)
|
||||
{
|
||||
char *home = getenv("HOME");
|
||||
|
||||
#if defined(HAVE_GETPWUID) && defined(HAVE_PWD_H)
|
||||
if(home)
|
||||
home_buffer = xstrdup (home);
|
||||
#if defined(HAVE_GETPWUID) && defined(HAVE_PWD_H)
|
||||
else
|
||||
{
|
||||
struct passwd *pwd;
|
||||
|
@ -120,6 +120,7 @@ gcry_free (void *a)
|
||||
require functions called from these inline fucntions. Although we
|
||||
do not use gpg-error, gpg-error.h may get included via gcrypt.h if
|
||||
it happens to be used used in libjnlib-config.h. */
|
||||
#ifndef GPG_ERROR_H /* Don't do this if gpg-error.h has been included. */
|
||||
int
|
||||
gpg_err_code_from_errno (int err)
|
||||
{
|
||||
@ -127,17 +128,20 @@ gpg_err_code_from_errno (int err)
|
||||
assert (!"stub function");
|
||||
return -1;
|
||||
}
|
||||
#endif /*GPG_ERROR_H*/
|
||||
|
||||
|
||||
/* Retrieve the error code directly from the ERRNO variable. This
|
||||
returns GPG_ERR_UNKNOWN_ERRNO if the system error is not mapped
|
||||
(report this) and GPG_ERR_MISSING_ERRNO if ERRNO has the value 0. */
|
||||
#ifndef GPG_ERROR_H /* Don't do this if gpg-error.h has been included. */
|
||||
int
|
||||
gpg_err_code_from_syserror (void)
|
||||
{
|
||||
assert (!"stub function");
|
||||
return -1;
|
||||
}
|
||||
#endif /*GPG_ERROR_H*/
|
||||
|
||||
|
||||
|
||||
|
@ -24,7 +24,17 @@
|
||||
#error The regression tests should not include with gcrypt.h
|
||||
#endif
|
||||
|
||||
/* Repalcement prototypes. */
|
||||
#ifdef HAVE_W32CE_SYSTEM
|
||||
#include <gpg-error.h> /* Defines strerror. */
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef HAVE_GETENV
|
||||
# define getenv(a) (NULL)
|
||||
#endif
|
||||
|
||||
|
||||
/* Replacement prototypes. */
|
||||
void *gcry_xmalloc (size_t n);
|
||||
void *gcry_xcalloc (size_t n, size_t m);
|
||||
void *gcry_xrealloc (void *a, size_t n);
|
||||
|
145
jnlib/t-timestuff.c
Normal file
145
jnlib/t-timestuff.c
Normal file
@ -0,0 +1,145 @@
|
||||
/* t-timestuff.c - Regression tests for time functions
|
||||
* Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of JNLIB.
|
||||
*
|
||||
* JNLIB is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as
|
||||
* published by the Free Software Foundation; either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* JNLIB 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "mischelp.h"
|
||||
|
||||
#include "t-support.h"
|
||||
|
||||
|
||||
static int
|
||||
cmp_time_s (struct tm *a, struct tm *b)
|
||||
{
|
||||
if (a->tm_year != b->tm_year
|
||||
|| a->tm_mon != b->tm_mon
|
||||
|| a->tm_mday != b->tm_mday
|
||||
|| a->tm_hour != b->tm_hour
|
||||
|| a->tm_min != b->tm_min
|
||||
|| a->tm_sec != b->tm_sec
|
||||
|| a->tm_wday != b->tm_wday
|
||||
|| a->tm_yday != b->tm_yday
|
||||
|| !a->tm_isdst != !b->tm_isdst)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
test_timegm (void)
|
||||
{
|
||||
static struct {
|
||||
int year, mon, mday, hour, min, sec;
|
||||
} tvalues[] = {
|
||||
{ -1 },
|
||||
{ -2, 1 },
|
||||
{ -2, 2 },
|
||||
{ -2, 86399 },
|
||||
{ -2, 86400 },
|
||||
{ -2, 0x7ffffffe },
|
||||
{ -2, 0x7fffffff },
|
||||
/* Note: Because we use mktime below we can only start with the
|
||||
day after Epoch. */
|
||||
{ 1970, 1, 2, 0, 0 , 1},
|
||||
{ 1970, 1, 2, 0, 0 , 2},
|
||||
{ 1970, 1, 2, 12, 0 , 0},
|
||||
{ 1970, 1, 2, 23, 59 , 59},
|
||||
{ 1999, 12, 31, 23, 59 , 59},
|
||||
{ 2000, 1, 1, 0, 0, 0},
|
||||
{ 2000, 1, 1, 0, 0, 1},
|
||||
{ 2010, 12, 31, 23, 59 , 59},
|
||||
{ 2010, 1, 1, 0, 0, 0},
|
||||
{ 2010, 1, 1, 0, 0, 1},
|
||||
/* The date below is about the last time mktime works in CET on
|
||||
Windows XP; this is a somewhat strange because 32 bit Unices
|
||||
will happily work along for another month until they reach the
|
||||
end of all ticks on 20380119T031408 (unless Uli takes
|
||||
compassion on us and changes time_t to a u64). */
|
||||
{ 2037, 12, 18, 23, 59, 59}
|
||||
|
||||
};
|
||||
int tidx;
|
||||
time_t now, atime, counter;
|
||||
struct tm tbuf, tbuf2, *tp;
|
||||
|
||||
counter = 0;
|
||||
for (tidx=0; tidx < DIM (tvalues); tidx++)
|
||||
{
|
||||
if (tvalues[tidx].year == -1)
|
||||
{
|
||||
now = time (NULL);
|
||||
}
|
||||
else if (tvalues[tidx].year == -2)
|
||||
{
|
||||
now = tvalues[tidx].mon;
|
||||
}
|
||||
else
|
||||
{
|
||||
memset (&tbuf, 0, sizeof tbuf);
|
||||
tbuf.tm_year = tvalues[tidx].year - 1900;
|
||||
tbuf.tm_mon = tvalues[tidx].mon;
|
||||
tbuf.tm_mday = tvalues[tidx].mday;
|
||||
tbuf.tm_hour = tvalues[tidx].hour;
|
||||
tbuf.tm_min = tvalues[tidx].min;
|
||||
tbuf.tm_sec = tvalues[tidx].sec;
|
||||
now = mktime (&tbuf);
|
||||
}
|
||||
if (now == (time_t)(-1))
|
||||
fail (tidx);
|
||||
|
||||
tp = gmtime (&now);
|
||||
if (!tp)
|
||||
fail (tidx);
|
||||
tbuf = *tp;
|
||||
tbuf2 = tbuf;
|
||||
atime = timegm (&tbuf);
|
||||
if (atime == (time_t)(-1))
|
||||
fail (tidx);
|
||||
if (atime != now)
|
||||
fail (tidx);
|
||||
|
||||
tp = gmtime (&atime);
|
||||
if (!tp)
|
||||
fail (tidx);
|
||||
if (cmp_time_s (tp, &tbuf))
|
||||
fail (tidx);
|
||||
if (cmp_time_s (tp, &tbuf2))
|
||||
fail (tidx);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
|
||||
test_timegm ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* utf8conf.c - UTF8 character set conversion
|
||||
* Copyright (C) 1994, 1998, 1999, 2000, 2001,
|
||||
* 2003, 2006, 2008 Free Software Foundation, Inc.
|
||||
* Copyright (C) 1994, 1998, 1999, 2000, 2001, 2003, 2006,
|
||||
* 2008, 2010 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of JNLIB.
|
||||
*
|
||||
@ -50,12 +50,12 @@ static int use_iconv; /* iconv comversion fucntions required. */
|
||||
#ifdef HAVE_W32_SYSTEM
|
||||
typedef void *iconv_t;
|
||||
#ifndef ICONV_CONST
|
||||
#define ICONV_CONST const
|
||||
#define ICONV_CONST
|
||||
#endif
|
||||
static iconv_t (* __stdcall iconv_open) (const char *tocode,
|
||||
const char *fromcode);
|
||||
static size_t (* __stdcall iconv) (iconv_t cd,
|
||||
const char **inbuf, size_t *inbytesleft,
|
||||
char **inbuf, size_t *inbytesleft,
|
||||
char **outbuf, size_t *outbytesleft);
|
||||
static int (* __stdcall iconv_close) (iconv_t cd);
|
||||
|
||||
@ -166,8 +166,10 @@ set_native_charset (const char *newset)
|
||||
different one for console input. Not sure how to cope with
|
||||
that. If the console Code page is not known we fall back to
|
||||
the system code page. */
|
||||
#ifndef HAVE_W32CE_SYSTEM
|
||||
cpno = GetConsoleOutputCP ();
|
||||
if (!cpno)
|
||||
#endif
|
||||
cpno = GetACP ();
|
||||
sprintf (codepage, "CP%u", cpno );
|
||||
/* Resolve alias. We use a long string string and not the usual
|
||||
@ -736,3 +738,76 @@ jnlib_iconv_close (jnlib_iconv_t cd)
|
||||
|
||||
return iconv_close ((iconv_t)cd);
|
||||
}
|
||||
|
||||
|
||||
#ifdef HAVE_W32_SYSTEM
|
||||
/* Return a malloced string encoded in UTF-8 from the wide char input
|
||||
string STRING. Caller must free this value. Returns NULL and sets
|
||||
ERRNO on failure. Calling this function with STRING set to NULL is
|
||||
not defined. */
|
||||
char *
|
||||
wchar_to_utf8 (const wchar_t *string)
|
||||
{
|
||||
int n;
|
||||
char *result;
|
||||
|
||||
n = WideCharToMultiByte (CP_UTF8, 0, string, -1, NULL, 0, NULL, NULL);
|
||||
if (n < 0)
|
||||
{
|
||||
jnlib_set_errno (EINVAL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
result = jnlib_malloc (n+1);
|
||||
if (!result)
|
||||
return NULL;
|
||||
|
||||
n = WideCharToMultiByte (CP_UTF8, 0, string, -1, result, n, NULL, NULL);
|
||||
if (n < 0)
|
||||
{
|
||||
jnlib_free (result);
|
||||
jnlib_set_errno (EINVAL);
|
||||
result = NULL;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/* Return a malloced wide char string from an UTF-8 encoded input
|
||||
string STRING. Caller must free this value. Returns NULL and sets
|
||||
ERRNO on failure. Calling this function with STRING set to NULL is
|
||||
not defined. */
|
||||
wchar_t *
|
||||
utf8_to_wchar (const char *string)
|
||||
{
|
||||
int n;
|
||||
size_t nbytes;
|
||||
wchar_t *result;
|
||||
|
||||
n = MultiByteToWideChar (CP_UTF8, 0, string, -1, NULL, 0);
|
||||
if (n < 0)
|
||||
{
|
||||
jnlib_set_errno (EINVAL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
nbytes = (size_t)(n+1) * sizeof(*result);
|
||||
if (nbytes / sizeof(*result) != (n+1))
|
||||
{
|
||||
jnlib_set_errno (ENOMEM);
|
||||
return NULL;
|
||||
}
|
||||
result = malloc (nbytes);
|
||||
if (!result)
|
||||
return NULL;
|
||||
|
||||
n = MultiByteToWideChar (CP_UTF8, 0, string, -1, result, n);
|
||||
if (n < 0)
|
||||
{
|
||||
free (result);
|
||||
jnlib_set_errno (EINVAL);
|
||||
result = NULL;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
#endif /*HAVE_W32_SYSTEM*/
|
||||
|
@ -36,6 +36,10 @@ size_t jnlib_iconv (jnlib_iconv_t cd, const char **inbuf, size_t *inbytesleft,
|
||||
char **outbuf, size_t *outbytesleft);
|
||||
int jnlib_iconv_close (jnlib_iconv_t cd);
|
||||
|
||||
#ifdef HAVE_W32_SYSTEM
|
||||
char *wchar_to_utf8 (const wchar_t *string);
|
||||
wchar_t *utf8_to_wchar (const char *string);
|
||||
#endif /*HAVE_W32_SYSTEM*/
|
||||
|
||||
|
||||
#endif /*LIBJNLIB_UTF8CONF_H*/
|
||||
|
@ -51,14 +51,15 @@ read_port_and_nonce (const char *fname, unsigned short *port, char *nonce)
|
||||
fclose (fp);
|
||||
if (!nread)
|
||||
{
|
||||
errno = ENOFILE;
|
||||
#warning remove this file
|
||||
jnlib_set_errno (EIO);
|
||||
return -1;
|
||||
}
|
||||
buffer[nread] = 0;
|
||||
aval = atoi (buffer);
|
||||
if (aval < 1 || aval > 65535)
|
||||
{
|
||||
errno = EINVAL;
|
||||
jnlib_set_errno (EINVAL);
|
||||
return -1;
|
||||
}
|
||||
*port = (unsigned int)aval;
|
||||
@ -66,7 +67,7 @@ read_port_and_nonce (const char *fname, unsigned short *port, char *nonce)
|
||||
;
|
||||
if (*p != '\n' || nread != 17)
|
||||
{
|
||||
errno = EINVAL;
|
||||
jnlib_set_errno (EINVAL);
|
||||
return -1;
|
||||
}
|
||||
p++; nread--;
|
||||
@ -126,7 +127,7 @@ _w32_sock_connect (int sockfd, struct sockaddr *addr, int addrlen)
|
||||
ret = send (sockfd, nonce, 16, 0);
|
||||
if (ret >= 0 && ret != 16)
|
||||
{
|
||||
errno = EIO;
|
||||
jnlib_set_errno (EIO);
|
||||
ret = -1;
|
||||
}
|
||||
}
|
||||
|
1710
jnlib/w32-gettext.c
1710
jnlib/w32-gettext.c
File diff suppressed because it is too large
Load Diff
@ -27,15 +27,6 @@ char *read_w32_registry_string (const char *root,
|
||||
int write_w32_registry_string (const char *root, const char *dir,
|
||||
const char *name, const char *value);
|
||||
|
||||
#ifdef USE_SIMPLE_GETTEXT
|
||||
char *bindtextdomain (const char *domainname, const char *dirname);
|
||||
const char *gettext (const char *msgid );
|
||||
const char *ngettext (const char *msgid1, const char *msgid2,
|
||||
unsigned long int n);
|
||||
const char *gettext_localename (void);
|
||||
void gettext_select_utf8 (int value);
|
||||
#endif /*USE_SIMPLE_GETTEXT*/
|
||||
|
||||
|
||||
#endif /*HAVE_W32_SYSTEM*/
|
||||
#endif /*LIBJNLIB_MISCHELP_H*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user