summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am215
-rw-r--r--src/Makefile.in915
-rw-r--r--src/README47
-rw-r--r--src/code-from-errno.c69
-rw-r--r--src/code-to-errno.c42
-rw-r--r--src/err-codes.h536
-rw-r--r--src/err-codes.h.in301
-rw-r--r--src/err-sources.h82
-rw-r--r--src/err-sources.h.in58
-rw-r--r--src/errnos.in172
-rw-r--r--src/gettext.h76
-rw-r--r--src/gpg-error-config.in84
-rw-r--r--src/gpg-error.c454
-rw-r--r--src/gpg-error.def.in29
-rw-r--r--src/gpg-error.h678
-rw-r--r--src/gpg-error.h.in274
-rw-r--r--src/gpg-error.m465
-rw-r--r--src/init.c425
-rw-r--r--src/init.h70
-rw-r--r--src/mkerrcodes.awk99
-rw-r--r--src/mkerrcodes.c78
-rw-r--r--src/mkerrcodes1.awk96
-rw-r--r--src/mkerrcodes2.awk134
-rw-r--r--src/mkerrnos.awk104
-rw-r--r--src/mkheader.awk218
-rw-r--r--src/mkstrtable.awk189
-rw-r--r--src/mkw32errmap.c178
-rw-r--r--src/strerror-sym.c56
-rw-r--r--src/strerror.c169
-rw-r--r--src/strsource-sym.c43
-rw-r--r--src/strsource.c37
-rw-r--r--src/versioninfo.rc.in52
-rw-r--r--src/w32-add.h40
-rw-r--r--src/w32-gettext.c1905
-rw-r--r--src/w32ce-add.h8
35 files changed, 7998 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644
index 0000000..518a4c0
--- /dev/null
+++ b/src/Makefile.am
@@ -0,0 +1,215 @@
+# Makefile.am for libgpg-error.
+# Copyright (C) 2003, 2004 g10 Code GmbH
+#
+# This file is part of libgpg-error.
+#
+# libgpg-error 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 2.1 of the
+# License, or (at your option) any later version.
+#
+# libgpg-error 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, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+
+# We distribute the generated sources err-sources.h and err-codes.h,
+# because they are needed to build the po directory, and they don't
+# depend on the configuration anyway.
+
+
+if HAVE_W32CE_SYSTEM
+gpg_extra_headers = gpg-extra/errno.h
+extra_cppflags = -idirafter gpg-extra
+else
+gpg_extra_headers =
+extra_cppflags =
+endif
+
+localedir = $(datadir)/locale
+bin_PROGRAMS = gpg-error
+lib_LTLIBRARIES = libgpg-error.la
+include_HEADERS = gpg-error.h
+bin_SCRIPTS = gpg-error-config
+m4datadir = $(datadir)/aclocal
+m4data_DATA = gpg-error.m4
+
+EXTRA_DIST = mkstrtable.awk err-sources.h.in err-codes.h.in \
+ mkerrnos.awk errnos.in README \
+ mkerrcodes.awk mkerrcodes1.awk mkerrcodes2.awk mkerrcodes.c \
+ mkheader.awk gpg-error.h.in mkw32errmap.c w32-add.h w32ce-add.h \
+ err-sources.h err-codes.h gpg-error-config.in gpg-error.m4 \
+ gpg-error.def.in versioninfo.rc.in
+
+BUILT_SOURCES = err-sources.h err-codes.h code-to-errno.h code-from-errno.h \
+ err-sources-sym.h err-codes-sym.h errnos-sym.h gpg-error.h \
+ gpg-error.def extra-h.in mkw32errmap.map.c
+
+tmp_files = _mkerrcodes.h _gpg-error.def.h mkw32errmap.tab.h mkw32errmap.map.c
+
+CLEANFILES = err-sources.h err-codes.h code-to-errno.h code-from-errno.h \
+ gpg-error.h mkerrcodes mkerrcodes.h gpg-error.def mkw32errmap.tab.h \
+ mkw32errmap.map.c err-sources-sym.h err-codes-sym.h errnos-sym.h \
+ gpg-extra/errno.h extra-h.in $(tmp_files)
+
+if HAVE_W32_SYSTEM
+arch_sources = w32-gettext.c
+
+RCCOMPILE = $(RC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ -DLOCALEDIR=\"$(localedir)\" $(AM_CPPFLAGS) $(CPPFLAGS)
+LTRCCOMPILE = $(LIBTOOL) --mode=compile --tag=RC $(RCCOMPILE)
+
+SUFFIXES = .rc .lo
+
+.rc.lo:
+ $(LTRCCOMPILE) -i "$<" -o "$@"
+
+gpg_error_res = versioninfo.lo
+no_undefined = -no-undefined
+export_symbols = -export-symbols gpg-error.def
+
+install-def-file: gpg-error.def
+ $(INSTALL) gpg-error.def $(DESTDIR)$(libdir)/gpg-error.def
+
+uninstall-def-file:
+ -rm $(DESTDIR)$(libdir)/gpg-error.def
+
+libgpg_error_la_DEPENDENCIES = $(gpg_error_res) gpg-error.def
+intllibs =
+
+else
+arch_sources =
+gpg_error_res =
+no_undefined =
+export_symbols =
+install-def-file:
+uninstall-def-file:
+
+intllibs = @LTLIBINTL@
+
+endif
+
+
+libgpg_error_la_LDFLAGS = -version-info \
+ @LIBGPG_ERROR_LT_CURRENT@:@LIBGPG_ERROR_LT_REVISION@:@LIBGPG_ERROR_LT_AGE@ \
+ $(no_undefined) $(export_symbols)
+
+libgpg_error_la_SOURCES = gpg-error.h gettext.h $(arch_sources) \
+ init.c init.h strsource.c strerror.c code-to-errno.c code-from-errno.c
+
+# Note that RCCOMPILE needs the same defines as ..._la_CPPFLAGS but
+# without the extra_cppflags because they may include am -idirafter
+# which is not supported by the RC compiler.
+libgpg_error_la_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\" $(extra_cppflags)
+libgpg_error_la_LIBADD = $(gpg_error_res) $(intllibs)
+
+gpg_error_SOURCES = strsource-sym.c strerror-sym.c gpg-error.c
+gpg_error_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\" $(extra_cppflags)
+gpg_error_LDADD = ./libgpg-error.la @LTLIBINTL@
+
+# We build err-sources.h and err-codes.h in the source directory.
+# This is needed because gettext does only look into the source
+# directory to find the files listed in po/POTFILE.in. To make these
+# rules work we also need to depend on Makefile.am and not on the
+# generated files Makefile.in or Makefile.
+$(srcdir)/err-sources.h: Makefile.am mkstrtable.awk err-sources.h.in
+ $(AWK) -f $(srcdir)/mkstrtable.awk -v textidx=3 \
+ $(srcdir)/err-sources.h.in >$@
+
+err-sources-sym.h: Makefile mkstrtable.awk err-sources.h.in
+ $(AWK) -f $(srcdir)/mkstrtable.awk -v textidx=2 -v nogettext=1 \
+ $(srcdir)/err-sources.h.in >$@
+
+$(srcdir)/err-codes.h: Makefile.am mkstrtable.awk err-codes.h.in
+ $(AWK) -f $(srcdir)/mkstrtable.awk -v textidx=3 \
+ $(srcdir)/err-codes.h.in >$@
+
+err-codes-sym.h: Makefile mkstrtable.awk err-codes.h.in
+ $(AWK) -f $(srcdir)/mkstrtable.awk -v textidx=2 -v nogettext=1 \
+ $(srcdir)/err-codes.h.in >$@
+
+code-to-errno.h: Makefile mkerrnos.awk errnos.in
+ $(AWK) -f $(srcdir)/mkerrnos.awk $(srcdir)/errnos.in >$@
+
+# It is correct to use $(CPP). We want the host's idea of the error codes.
+mkerrcodes.h: Makefile mkerrcodes.awk $(gpg_extra_headers)
+ $(AWK) -f $(srcdir)/mkerrcodes1.awk $(srcdir)/errnos.in >_$@
+ $(CPP) $(extra_cppflags) _$@ | grep GPG_ERR_ | \
+ $(AWK) -f $(srcdir)/mkerrcodes.awk >$@
+ -rm _$@
+
+if HAVE_W32CE_SYSTEM
+# It is correct to use $(CPP). We want the host's idea of the error codes.
+mkw32errmap.tab.h: Makefile mkw32errmap.c
+ $(CPP) -DRESOLVE_MACROS $(srcdir)/mkw32errmap.c | \
+ grep '{&mkw32errmap_marker' >$@
+mkw32errmap.map.c: mkw32errmap
+ ./mkw32errmap --map > $@
+gpg-extra/errno.h: mkw32errmap
+ -$(MKDIR_P) gpg-extra
+ ./mkw32errmap > $@
+else
+mkw32errmap.map.c:
+ echo "/*dummy*/" > $@
+endif
+
+# We use CC proper for preprocessing thus we have to convince it that
+# the data is really to be preprocessed.
+gpg-error.def: Makefile gpg-error.def.in
+ cat $(srcdir)/gpg-error.def.in >_$@.h
+ $(CPP) $(DEFAULT_INCLUDES) $(INCLUDES) $(extra_cppflags) _$@.h | \
+ grep -v '^#' >$@
+ -rm _$@.h
+
+# It is correct to use $(CC_FOR_BUILD) here. We want to run the
+# program at build time.
+mkerrcodes: mkerrcodes.c mkerrcodes.h Makefile
+ $(CC_FOR_BUILD) -I. -I$(srcdir) -o $@ $(srcdir)/mkerrcodes.c
+
+if HAVE_W32CE_SYSTEM
+# It is correct to use $(CC_FOR_BUILD) here. We want to run the
+# program at build time.
+mkw32errmap: mkw32errmap.c mkw32errmap.tab.h Makefile
+ $(CC_FOR_BUILD) -I. -I$(srcdir) -o $@ $(srcdir)/mkw32errmap.c
+endif
+
+code-from-errno.h: mkerrcodes Makefile
+ ./mkerrcodes | $(AWK) -f $(srcdir)/mkerrcodes2.awk >$@
+
+errnos-sym.h: Makefile mkstrtable.awk errnos.in
+ $(AWK) -f $(srcdir)/mkstrtable.awk -v textidx=2 -v nogettext=1 \
+ -v prefix=GPG_ERR_ -v namespace=errnos_ \
+ $(srcdir)/errnos.in >$@
+
+extra-h.in: Makefile w32-add.h w32ce-add.h
+ -rm extra-h.in
+if HAVE_W32_SYSTEM
+ cat $(srcdir)/w32-add.h >>extra-h.in
+endif
+if HAVE_W32CE_SYSTEM
+ cat $(srcdir)/w32ce-add.h >>extra-h.in
+endif
+ echo EOF >>extra-h.in
+
+gpg-error.h: Makefile mkheader.awk err-sources.h.in err-codes.h.in \
+ errnos.in extra-h.in gpg-error.h.in
+ $(AWK) -f $(srcdir)/mkheader.awk \
+ $(srcdir)/err-sources.h.in \
+ $(srcdir)/err-codes.h.in \
+ $(srcdir)/errnos.in \
+ extra-h.in \
+ $(srcdir)/gpg-error.h.in > $@
+
+
+install-data-local:
+if HAVE_W32CE_SYSTEM
+ -$(MKDIR_P) "$(DESTDIR)$(includedir)/gpg-extra"
+ $(INSTALL_DATA) gpg-extra/errno.h \
+ "$(DESTDIR)$(includedir)/gpg-extra/errno.h"
+else
+ :
+endif
diff --git a/src/Makefile.in b/src/Makefile.in
new file mode 100644
index 0000000..c7fe92c
--- /dev/null
+++ b/src/Makefile.in
@@ -0,0 +1,915 @@
+# Makefile.in generated by automake 1.10.2 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program 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.
+
+@SET_MAKE@
+
+# Makefile.am for libgpg-error.
+# Copyright (C) 2003, 2004 g10 Code GmbH
+#
+# This file is part of libgpg-error.
+#
+# libgpg-error 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 2.1 of the
+# License, or (at your option) any later version.
+#
+# libgpg-error 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, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+
+# We distribute the generated sources err-sources.h and err-codes.h,
+# because they are needed to build the po directory, and they don't
+# depend on the configuration anyway.
+
+
+
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+bin_PROGRAMS = gpg-error$(EXEEXT)
+@HAVE_W32_SYSTEM_FALSE@libgpg_error_la_DEPENDENCIES = \
+@HAVE_W32_SYSTEM_FALSE@ $(am__DEPENDENCIES_1) \
+@HAVE_W32_SYSTEM_FALSE@ $(am__DEPENDENCIES_2)
+subdir = src
+DIST_COMMON = README $(include_HEADERS) $(srcdir)/Makefile.am \
+ $(srcdir)/Makefile.in $(srcdir)/gpg-error-config.in \
+ $(srcdir)/versioninfo.rc.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/autobuild.m4 \
+ $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/iconv.m4 \
+ $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \
+ $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libtool.m4 \
+ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
+ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
+ $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/po.m4 \
+ $(top_srcdir)/m4/progtest.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES = gpg-error-config versioninfo.rc
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
+am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" \
+ "$(DESTDIR)$(bindir)" "$(DESTDIR)$(m4datadir)" \
+ "$(DESTDIR)$(includedir)"
+libLTLIBRARIES_INSTALL = $(INSTALL)
+LTLIBRARIES = $(lib_LTLIBRARIES)
+@HAVE_W32_SYSTEM_TRUE@am__DEPENDENCIES_1 = versioninfo.lo
+am__DEPENDENCIES_2 =
+am__libgpg_error_la_SOURCES_DIST = gpg-error.h gettext.h w32-gettext.c \
+ init.c init.h strsource.c strerror.c code-to-errno.c \
+ code-from-errno.c
+@HAVE_W32_SYSTEM_TRUE@am__objects_1 = libgpg_error_la-w32-gettext.lo
+am_libgpg_error_la_OBJECTS = $(am__objects_1) libgpg_error_la-init.lo \
+ libgpg_error_la-strsource.lo libgpg_error_la-strerror.lo \
+ libgpg_error_la-code-to-errno.lo \
+ libgpg_error_la-code-from-errno.lo
+libgpg_error_la_OBJECTS = $(am_libgpg_error_la_OBJECTS)
+libgpg_error_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(libgpg_error_la_LDFLAGS) $(LDFLAGS) -o $@
+binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
+PROGRAMS = $(bin_PROGRAMS)
+am_gpg_error_OBJECTS = gpg_error-strsource-sym.$(OBJEXT) \
+ gpg_error-strerror-sym.$(OBJEXT) gpg_error-gpg-error.$(OBJEXT)
+gpg_error_OBJECTS = $(am_gpg_error_OBJECTS)
+gpg_error_DEPENDENCIES = ./libgpg-error.la
+binSCRIPT_INSTALL = $(INSTALL_SCRIPT)
+SCRIPTS = $(bin_SCRIPTS)
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(libgpg_error_la_SOURCES) $(gpg_error_SOURCES)
+DIST_SOURCES = $(am__libgpg_error_la_SOURCES_DIST) \
+ $(gpg_error_SOURCES)
+m4dataDATA_INSTALL = $(INSTALL_DATA)
+DATA = $(m4data_DATA)
+includeHEADERS_INSTALL = $(INSTALL_HEADER)
+HEADERS = $(include_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BUILD_FILEVERSION = @BUILD_FILEVERSION@
+BUILD_TIMESTAMP = @BUILD_TIMESTAMP@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CC_FOR_BUILD = @CC_FOR_BUILD@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@
+GMSGFMT = @GMSGFMT@
+GMSGFMT_015 = @GMSGFMT_015@
+GPG_ERROR_CONFIG_CFLAGS = @GPG_ERROR_CONFIG_CFLAGS@
+GPG_ERROR_CONFIG_ISUBDIRAFTER = @GPG_ERROR_CONFIG_ISUBDIRAFTER@
+GPG_ERROR_CONFIG_LIBS = @GPG_ERROR_CONFIG_LIBS@
+GREP = @GREP@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+INTLLIBS = @INTLLIBS@
+INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBGPG_ERROR_LT_AGE = @LIBGPG_ERROR_LT_AGE@
+LIBGPG_ERROR_LT_CURRENT = @LIBGPG_ERROR_LT_CURRENT@
+LIBGPG_ERROR_LT_REVISION = @LIBGPG_ERROR_LT_REVISION@
+LIBICONV = @LIBICONV@
+LIBINTL = @LIBINTL@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBICONV = @LTLIBICONV@
+LTLIBINTL = @LTLIBINTL@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MSGFMT = @MSGFMT@
+MSGFMT_015 = @MSGFMT_015@
+MSGMERGE = @MSGMERGE@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+POSUB = @POSUB@
+RANLIB = @RANLIB@
+RC = @RC@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+USE_NLS = @USE_NLS@
+VERSION = @VERSION@
+XGETTEXT = @XGETTEXT@
+XGETTEXT_015 = @XGETTEXT_015@
+XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = $(datadir)/locale
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+@HAVE_W32CE_SYSTEM_FALSE@gpg_extra_headers =
+@HAVE_W32CE_SYSTEM_TRUE@gpg_extra_headers = gpg-extra/errno.h
+@HAVE_W32CE_SYSTEM_FALSE@extra_cppflags =
+@HAVE_W32CE_SYSTEM_TRUE@extra_cppflags = -idirafter gpg-extra
+lib_LTLIBRARIES = libgpg-error.la
+include_HEADERS = gpg-error.h
+bin_SCRIPTS = gpg-error-config
+m4datadir = $(datadir)/aclocal
+m4data_DATA = gpg-error.m4
+EXTRA_DIST = mkstrtable.awk err-sources.h.in err-codes.h.in \
+ mkerrnos.awk errnos.in README \
+ mkerrcodes.awk mkerrcodes1.awk mkerrcodes2.awk mkerrcodes.c \
+ mkheader.awk gpg-error.h.in mkw32errmap.c w32-add.h w32ce-add.h \
+ err-sources.h err-codes.h gpg-error-config.in gpg-error.m4 \
+ gpg-error.def.in versioninfo.rc.in
+
+BUILT_SOURCES = err-sources.h err-codes.h code-to-errno.h code-from-errno.h \
+ err-sources-sym.h err-codes-sym.h errnos-sym.h gpg-error.h \
+ gpg-error.def extra-h.in mkw32errmap.map.c
+
+tmp_files = _mkerrcodes.h _gpg-error.def.h mkw32errmap.tab.h mkw32errmap.map.c
+CLEANFILES = err-sources.h err-codes.h code-to-errno.h code-from-errno.h \
+ gpg-error.h mkerrcodes mkerrcodes.h gpg-error.def mkw32errmap.tab.h \
+ mkw32errmap.map.c err-sources-sym.h err-codes-sym.h errnos-sym.h \
+ gpg-extra/errno.h extra-h.in $(tmp_files)
+
+@HAVE_W32_SYSTEM_FALSE@arch_sources =
+@HAVE_W32_SYSTEM_TRUE@arch_sources = w32-gettext.c
+@HAVE_W32_SYSTEM_TRUE@RCCOMPILE = $(RC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+@HAVE_W32_SYSTEM_TRUE@ -DLOCALEDIR=\"$(localedir)\" $(AM_CPPFLAGS) $(CPPFLAGS)
+
+@HAVE_W32_SYSTEM_TRUE@LTRCCOMPILE = $(LIBTOOL) --mode=compile --tag=RC $(RCCOMPILE)
+@HAVE_W32_SYSTEM_TRUE@SUFFIXES = .rc .lo
+@HAVE_W32_SYSTEM_FALSE@gpg_error_res =
+@HAVE_W32_SYSTEM_TRUE@gpg_error_res = versioninfo.lo
+@HAVE_W32_SYSTEM_FALSE@no_undefined =
+@HAVE_W32_SYSTEM_TRUE@no_undefined = -no-undefined
+@HAVE_W32_SYSTEM_FALSE@export_symbols =
+@HAVE_W32_SYSTEM_TRUE@export_symbols = -export-symbols gpg-error.def
+@HAVE_W32_SYSTEM_TRUE@libgpg_error_la_DEPENDENCIES = $(gpg_error_res) gpg-error.def
+@HAVE_W32_SYSTEM_FALSE@intllibs = @LTLIBINTL@
+@HAVE_W32_SYSTEM_TRUE@intllibs =
+libgpg_error_la_LDFLAGS = -version-info \
+ @LIBGPG_ERROR_LT_CURRENT@:@LIBGPG_ERROR_LT_REVISION@:@LIBGPG_ERROR_LT_AGE@ \
+ $(no_undefined) $(export_symbols)
+
+libgpg_error_la_SOURCES = gpg-error.h gettext.h $(arch_sources) \
+ init.c init.h strsource.c strerror.c code-to-errno.c code-from-errno.c
+
+
+# Note that RCCOMPILE needs the same defines as ..._la_CPPFLAGS but
+# without the extra_cppflags because they may include am -idirafter
+# which is not supported by the RC compiler.
+libgpg_error_la_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\" $(extra_cppflags)
+libgpg_error_la_LIBADD = $(gpg_error_res) $(intllibs)
+gpg_error_SOURCES = strsource-sym.c strerror-sym.c gpg-error.c
+gpg_error_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\" $(extra_cppflags)
+gpg_error_LDADD = ./libgpg-error.la @LTLIBINTL@
+all: $(BUILT_SOURCES)
+ $(MAKE) $(AM_MAKEFLAGS) all-am
+
+.SUFFIXES:
+.SUFFIXES: .rc .lo .c .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --gnu src/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+gpg-error-config: $(top_builddir)/config.status $(srcdir)/gpg-error-config.in
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+versioninfo.rc: $(top_builddir)/config.status $(srcdir)/versioninfo.rc.in
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+install-libLTLIBRARIES: $(lib_LTLIBRARIES)
+ @$(NORMAL_INSTALL)
+ test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)"
+ @list='$(lib_LTLIBRARIES)'; for p in $$list; do \
+ if test -f $$p; then \
+ f=$(am__strip_dir) \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(libdir)/$$f'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(libdir)/$$f"; \
+ else :; fi; \
+ done
+
+uninstall-libLTLIBRARIES:
+ @$(NORMAL_UNINSTALL)
+ @list='$(lib_LTLIBRARIES)'; for p in $$list; do \
+ p=$(am__strip_dir) \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$p'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$p"; \
+ done
+
+clean-libLTLIBRARIES:
+ -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
+ @list='$(lib_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+libgpg-error.la: $(libgpg_error_la_OBJECTS) $(libgpg_error_la_DEPENDENCIES)
+ $(libgpg_error_la_LINK) -rpath $(libdir) $(libgpg_error_la_OBJECTS) $(libgpg_error_la_LIBADD) $(LIBS)
+install-binPROGRAMS: $(bin_PROGRAMS)
+ @$(NORMAL_INSTALL)
+ test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ if test -f $$p \
+ || test -f $$p1 \
+ ; then \
+ f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
+ else :; fi; \
+ done
+
+uninstall-binPROGRAMS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
+ rm -f "$(DESTDIR)$(bindir)/$$f"; \
+ done
+
+clean-binPROGRAMS:
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f $$p $$f"; \
+ rm -f $$p $$f ; \
+ done
+gpg-error$(EXEEXT): $(gpg_error_OBJECTS) $(gpg_error_DEPENDENCIES)
+ @rm -f gpg-error$(EXEEXT)
+ $(LINK) $(gpg_error_OBJECTS) $(gpg_error_LDADD) $(LIBS)
+install-binSCRIPTS: $(bin_SCRIPTS)
+ @$(NORMAL_INSTALL)
+ test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
+ @list='$(bin_SCRIPTS)'; for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ if test -f $$d$$p; then \
+ f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \
+ echo " $(binSCRIPT_INSTALL) '$$d$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+ $(binSCRIPT_INSTALL) "$$d$$p" "$(DESTDIR)$(bindir)/$$f"; \
+ else :; fi; \
+ done
+
+uninstall-binSCRIPTS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(bin_SCRIPTS)'; for p in $$list; do \
+ f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \
+ echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
+ rm -f "$(DESTDIR)$(bindir)/$$f"; \
+ done
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gpg_error-gpg-error.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gpg_error-strerror-sym.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gpg_error-strsource-sym.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgpg_error_la-code-from-errno.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgpg_error_la-code-to-errno.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgpg_error_la-init.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgpg_error_la-strerror.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgpg_error_la-strsource.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgpg_error_la-w32-gettext.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+libgpg_error_la-w32-gettext.lo: w32-gettext.c
+@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgpg_error_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libgpg_error_la-w32-gettext.lo -MD -MP -MF $(DEPDIR)/libgpg_error_la-w32-gettext.Tpo -c -o libgpg_error_la-w32-gettext.lo `test -f 'w32-gettext.c' || echo '$(srcdir)/'`w32-gettext.c
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libgpg_error_la-w32-gettext.Tpo $(DEPDIR)/libgpg_error_la-w32-gettext.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='w32-gettext.c' object='libgpg_error_la-w32-gettext.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgpg_error_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libgpg_error_la-w32-gettext.lo `test -f 'w32-gettext.c' || echo '$(srcdir)/'`w32-gettext.c
+
+libgpg_error_la-init.lo: init.c
+@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgpg_error_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libgpg_error_la-init.lo -MD -MP -MF $(DEPDIR)/libgpg_error_la-init.Tpo -c -o libgpg_error_la-init.lo `test -f 'init.c' || echo '$(srcdir)/'`init.c
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libgpg_error_la-init.Tpo $(DEPDIR)/libgpg_error_la-init.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='init.c' object='libgpg_error_la-init.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgpg_error_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libgpg_error_la-init.lo `test -f 'init.c' || echo '$(srcdir)/'`init.c
+
+libgpg_error_la-strsource.lo: strsource.c
+@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgpg_error_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libgpg_error_la-strsource.lo -MD -MP -MF $(DEPDIR)/libgpg_error_la-strsource.Tpo -c -o libgpg_error_la-strsource.lo `test -f 'strsource.c' || echo '$(srcdir)/'`strsource.c
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libgpg_error_la-strsource.Tpo $(DEPDIR)/libgpg_error_la-strsource.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='strsource.c' object='libgpg_error_la-strsource.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgpg_error_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libgpg_error_la-strsource.lo `test -f 'strsource.c' || echo '$(srcdir)/'`strsource.c
+
+libgpg_error_la-strerror.lo: strerror.c
+@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgpg_error_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libgpg_error_la-strerror.lo -MD -MP -MF $(DEPDIR)/libgpg_error_la-strerror.Tpo -c -o libgpg_error_la-strerror.lo `test -f 'strerror.c' || echo '$(srcdir)/'`strerror.c
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libgpg_error_la-strerror.Tpo $(DEPDIR)/libgpg_error_la-strerror.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='strerror.c' object='libgpg_error_la-strerror.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgpg_error_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libgpg_error_la-strerror.lo `test -f 'strerror.c' || echo '$(srcdir)/'`strerror.c
+
+libgpg_error_la-code-to-errno.lo: code-to-errno.c
+@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgpg_error_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libgpg_error_la-code-to-errno.lo -MD -MP -MF $(DEPDIR)/libgpg_error_la-code-to-errno.Tpo -c -o libgpg_error_la-code-to-errno.lo `test -f 'code-to-errno.c' || echo '$(srcdir)/'`code-to-errno.c
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libgpg_error_la-code-to-errno.Tpo $(DEPDIR)/libgpg_error_la-code-to-errno.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='code-to-errno.c' object='libgpg_error_la-code-to-errno.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgpg_error_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libgpg_error_la-code-to-errno.lo `test -f 'code-to-errno.c' || echo '$(srcdir)/'`code-to-errno.c
+
+libgpg_error_la-code-from-errno.lo: code-from-errno.c
+@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgpg_error_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libgpg_error_la-code-from-errno.lo -MD -MP -MF $(DEPDIR)/libgpg_error_la-code-from-errno.Tpo -c -o libgpg_error_la-code-from-errno.lo `test -f 'code-from-errno.c' || echo '$(srcdir)/'`code-from-errno.c
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libgpg_error_la-code-from-errno.Tpo $(DEPDIR)/libgpg_error_la-code-from-errno.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='code-from-errno.c' object='libgpg_error_la-code-from-errno.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgpg_error_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libgpg_error_la-code-from-errno.lo `test -f 'code-from-errno.c' || echo '$(srcdir)/'`code-from-errno.c
+
+gpg_error-strsource-sym.o: strsource-sym.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gpg_error_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT gpg_error-strsource-sym.o -MD -MP -MF $(DEPDIR)/gpg_error-strsource-sym.Tpo -c -o gpg_error-strsource-sym.o `test -f 'strsource-sym.c' || echo '$(srcdir)/'`strsource-sym.c
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/gpg_error-strsource-sym.Tpo $(DEPDIR)/gpg_error-strsource-sym.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='strsource-sym.c' object='gpg_error-strsource-sym.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gpg_error_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o gpg_error-strsource-sym.o `test -f 'strsource-sym.c' || echo '$(srcdir)/'`strsource-sym.c
+
+gpg_error-strsource-sym.obj: strsource-sym.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gpg_error_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT gpg_error-strsource-sym.obj -MD -MP -MF $(DEPDIR)/gpg_error-strsource-sym.Tpo -c -o gpg_error-strsource-sym.obj `if test -f 'strsource-sym.c'; then $(CYGPATH_W) 'strsource-sym.c'; else $(CYGPATH_W) '$(srcdir)/strsource-sym.c'; fi`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/gpg_error-strsource-sym.Tpo $(DEPDIR)/gpg_error-strsource-sym.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='strsource-sym.c' object='gpg_error-strsource-sym.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gpg_error_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o gpg_error-strsource-sym.obj `if test -f 'strsource-sym.c'; then $(CYGPATH_W) 'strsource-sym.c'; else $(CYGPATH_W) '$(srcdir)/strsource-sym.c'; fi`
+
+gpg_error-strerror-sym.o: strerror-sym.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gpg_error_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT gpg_error-strerror-sym.o -MD -MP -MF $(DEPDIR)/gpg_error-strerror-sym.Tpo -c -o gpg_error-strerror-sym.o `test -f 'strerror-sym.c' || echo '$(srcdir)/'`strerror-sym.c
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/gpg_error-strerror-sym.Tpo $(DEPDIR)/gpg_error-strerror-sym.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='strerror-sym.c' object='gpg_error-strerror-sym.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gpg_error_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o gpg_error-strerror-sym.o `test -f 'strerror-sym.c' || echo '$(srcdir)/'`strerror-sym.c
+
+gpg_error-strerror-sym.obj: strerror-sym.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gpg_error_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT gpg_error-strerror-sym.obj -MD -MP -MF $(DEPDIR)/gpg_error-strerror-sym.Tpo -c -o gpg_error-strerror-sym.obj `if test -f 'strerror-sym.c'; then $(CYGPATH_W) 'strerror-sym.c'; else $(CYGPATH_W) '$(srcdir)/strerror-sym.c'; fi`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/gpg_error-strerror-sym.Tpo $(DEPDIR)/gpg_error-strerror-sym.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='strerror-sym.c' object='gpg_error-strerror-sym.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gpg_error_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o gpg_error-strerror-sym.obj `if test -f 'strerror-sym.c'; then $(CYGPATH_W) 'strerror-sym.c'; else $(CYGPATH_W) '$(srcdir)/strerror-sym.c'; fi`
+
+gpg_error-gpg-error.o: gpg-error.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gpg_error_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT gpg_error-gpg-error.o -MD -MP -MF $(DEPDIR)/gpg_error-gpg-error.Tpo -c -o gpg_error-gpg-error.o `test -f 'gpg-error.c' || echo '$(srcdir)/'`gpg-error.c
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/gpg_error-gpg-error.Tpo $(DEPDIR)/gpg_error-gpg-error.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='gpg-error.c' object='gpg_error-gpg-error.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gpg_error_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o gpg_error-gpg-error.o `test -f 'gpg-error.c' || echo '$(srcdir)/'`gpg-error.c
+
+gpg_error-gpg-error.obj: gpg-error.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gpg_error_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT gpg_error-gpg-error.obj -MD -MP -MF $(DEPDIR)/gpg_error-gpg-error.Tpo -c -o gpg_error-gpg-error.obj `if test -f 'gpg-error.c'; then $(CYGPATH_W) 'gpg-error.c'; else $(CYGPATH_W) '$(srcdir)/gpg-error.c'; fi`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/gpg_error-gpg-error.Tpo $(DEPDIR)/gpg_error-gpg-error.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='gpg-error.c' object='gpg_error-gpg-error.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gpg_error_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o gpg_error-gpg-error.obj `if test -f 'gpg-error.c'; then $(CYGPATH_W) 'gpg-error.c'; else $(CYGPATH_W) '$(srcdir)/gpg-error.c'; fi`
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+install-m4dataDATA: $(m4data_DATA)
+ @$(NORMAL_INSTALL)
+ test -z "$(m4datadir)" || $(MKDIR_P) "$(DESTDIR)$(m4datadir)"
+ @list='$(m4data_DATA)'; for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ f=$(am__strip_dir) \
+ echo " $(m4dataDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(m4datadir)/$$f'"; \
+ $(m4dataDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(m4datadir)/$$f"; \
+ done
+
+uninstall-m4dataDATA:
+ @$(NORMAL_UNINSTALL)
+ @list='$(m4data_DATA)'; for p in $$list; do \
+ f=$(am__strip_dir) \
+ echo " rm -f '$(DESTDIR)$(m4datadir)/$$f'"; \
+ rm -f "$(DESTDIR)$(m4datadir)/$$f"; \
+ done
+install-includeHEADERS: $(include_HEADERS)
+ @$(NORMAL_INSTALL)
+ test -z "$(includedir)" || $(MKDIR_P) "$(DESTDIR)$(includedir)"
+ @list='$(include_HEADERS)'; for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ f=$(am__strip_dir) \
+ echo " $(includeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(includedir)/$$f'"; \
+ $(includeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(includedir)/$$f"; \
+ done
+
+uninstall-includeHEADERS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(include_HEADERS)'; for p in $$list; do \
+ f=$(am__strip_dir) \
+ echo " rm -f '$(DESTDIR)$(includedir)/$$f'"; \
+ rm -f "$(DESTDIR)$(includedir)/$$f"; \
+ done
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: $(BUILT_SOURCES)
+ $(MAKE) $(AM_MAKEFLAGS) check-am
+all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(SCRIPTS) $(DATA) \
+ $(HEADERS)
+install-binPROGRAMS: install-libLTLIBRARIES
+
+installdirs:
+ for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(m4datadir)" "$(DESTDIR)$(includedir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: $(BUILT_SOURCES)
+ $(MAKE) $(AM_MAKEFLAGS) install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+ -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+ -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
+clean: clean-am
+
+clean-am: clean-binPROGRAMS clean-generic clean-libLTLIBRARIES \
+ clean-libtool mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am: install-data-local install-includeHEADERS \
+ install-m4dataDATA
+
+install-dvi: install-dvi-am
+
+install-exec-am: install-binPROGRAMS install-binSCRIPTS \
+ install-libLTLIBRARIES
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-binPROGRAMS uninstall-binSCRIPTS \
+ uninstall-includeHEADERS uninstall-libLTLIBRARIES \
+ uninstall-m4dataDATA
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
+ clean-generic clean-libLTLIBRARIES clean-libtool ctags \
+ distclean distclean-compile distclean-generic \
+ distclean-libtool distclean-tags distdir dvi dvi-am html \
+ html-am info info-am install install-am install-binPROGRAMS \
+ install-binSCRIPTS install-data install-data-am \
+ install-data-local install-dvi install-dvi-am install-exec \
+ install-exec-am install-html install-html-am \
+ install-includeHEADERS install-info install-info-am \
+ install-libLTLIBRARIES install-m4dataDATA install-man \
+ install-pdf install-pdf-am install-ps install-ps-am \
+ install-strip installcheck installcheck-am installdirs \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+ pdf pdf-am ps ps-am tags uninstall uninstall-am \
+ uninstall-binPROGRAMS uninstall-binSCRIPTS \
+ uninstall-includeHEADERS uninstall-libLTLIBRARIES \
+ uninstall-m4dataDATA
+
+
+@HAVE_W32_SYSTEM_TRUE@.rc.lo:
+@HAVE_W32_SYSTEM_TRUE@ $(LTRCCOMPILE) -i "$<" -o "$@"
+
+@HAVE_W32_SYSTEM_TRUE@install-def-file: gpg-error.def
+@HAVE_W32_SYSTEM_TRUE@ $(INSTALL) gpg-error.def $(DESTDIR)$(libdir)/gpg-error.def
+
+@HAVE_W32_SYSTEM_TRUE@uninstall-def-file:
+@HAVE_W32_SYSTEM_TRUE@ -rm $(DESTDIR)$(libdir)/gpg-error.def
+@HAVE_W32_SYSTEM_FALSE@install-def-file:
+@HAVE_W32_SYSTEM_FALSE@uninstall-def-file:
+
+# We build err-sources.h and err-codes.h in the source directory.
+# This is needed because gettext does only look into the source
+# directory to find the files listed in po/POTFILE.in. To make these
+# rules work we also need to depend on Makefile.am and not on the
+# generated files Makefile.in or Makefile.
+$(srcdir)/err-sources.h: Makefile.am mkstrtable.awk err-sources.h.in
+ $(AWK) -f $(srcdir)/mkstrtable.awk -v textidx=3 \
+ $(srcdir)/err-sources.h.in >$@
+
+err-sources-sym.h: Makefile mkstrtable.awk err-sources.h.in
+ $(AWK) -f $(srcdir)/mkstrtable.awk -v textidx=2 -v nogettext=1 \
+ $(srcdir)/err-sources.h.in >$@
+
+$(srcdir)/err-codes.h: Makefile.am mkstrtable.awk err-codes.h.in
+ $(AWK) -f $(srcdir)/mkstrtable.awk -v textidx=3 \
+ $(srcdir)/err-codes.h.in >$@
+
+err-codes-sym.h: Makefile mkstrtable.awk err-codes.h.in
+ $(AWK) -f $(srcdir)/mkstrtable.awk -v textidx=2 -v nogettext=1 \
+ $(srcdir)/err-codes.h.in >$@
+
+code-to-errno.h: Makefile mkerrnos.awk errnos.in
+ $(AWK) -f $(srcdir)/mkerrnos.awk $(srcdir)/errnos.in >$@
+
+# It is correct to use $(CPP). We want the host's idea of the error codes.
+mkerrcodes.h: Makefile mkerrcodes.awk $(gpg_extra_headers)
+ $(AWK) -f $(srcdir)/mkerrcodes1.awk $(srcdir)/errnos.in >_$@
+ $(CPP) $(extra_cppflags) _$@ | grep GPG_ERR_ | \
+ $(AWK) -f $(srcdir)/mkerrcodes.awk >$@
+ -rm _$@
+
+# It is correct to use $(CPP). We want the host's idea of the error codes.
+@HAVE_W32CE_SYSTEM_TRUE@mkw32errmap.tab.h: Makefile mkw32errmap.c
+@HAVE_W32CE_SYSTEM_TRUE@ $(CPP) -DRESOLVE_MACROS $(srcdir)/mkw32errmap.c | \
+@HAVE_W32CE_SYSTEM_TRUE@ grep '{&mkw32errmap_marker' >$@
+@HAVE_W32CE_SYSTEM_TRUE@mkw32errmap.map.c: mkw32errmap
+@HAVE_W32CE_SYSTEM_TRUE@ ./mkw32errmap --map > $@
+@HAVE_W32CE_SYSTEM_TRUE@gpg-extra/errno.h: mkw32errmap
+@HAVE_W32CE_SYSTEM_TRUE@ -$(MKDIR_P) gpg-extra
+@HAVE_W32CE_SYSTEM_TRUE@ ./mkw32errmap > $@
+@HAVE_W32CE_SYSTEM_FALSE@mkw32errmap.map.c:
+@HAVE_W32CE_SYSTEM_FALSE@ echo "/*dummy*/" > $@
+
+# We use CC proper for preprocessing thus we have to convince it that
+# the data is really to be preprocessed.
+gpg-error.def: Makefile gpg-error.def.in
+ cat $(srcdir)/gpg-error.def.in >_$@.h
+ $(CPP) $(DEFAULT_INCLUDES) $(INCLUDES) $(extra_cppflags) _$@.h | \
+ grep -v '^#' >$@
+ -rm _$@.h
+
+# It is correct to use $(CC_FOR_BUILD) here. We want to run the
+# program at build time.
+mkerrcodes: mkerrcodes.c mkerrcodes.h Makefile
+ $(CC_FOR_BUILD) -I. -I$(srcdir) -o $@ $(srcdir)/mkerrcodes.c
+
+# It is correct to use $(CC_FOR_BUILD) here. We want to run the
+# program at build time.
+@HAVE_W32CE_SYSTEM_TRUE@mkw32errmap: mkw32errmap.c mkw32errmap.tab.h Makefile
+@HAVE_W32CE_SYSTEM_TRUE@ $(CC_FOR_BUILD) -I. -I$(srcdir) -o $@ $(srcdir)/mkw32errmap.c
+
+code-from-errno.h: mkerrcodes Makefile
+ ./mkerrcodes | $(AWK) -f $(srcdir)/mkerrcodes2.awk >$@
+
+errnos-sym.h: Makefile mkstrtable.awk errnos.in
+ $(AWK) -f $(srcdir)/mkstrtable.awk -v textidx=2 -v nogettext=1 \
+ -v prefix=GPG_ERR_ -v namespace=errnos_ \
+ $(srcdir)/errnos.in >$@
+
+extra-h.in: Makefile w32-add.h w32ce-add.h
+ -rm extra-h.in
+@HAVE_W32_SYSTEM_TRUE@ cat $(srcdir)/w32-add.h >>extra-h.in
+@HAVE_W32CE_SYSTEM_TRUE@ cat $(srcdir)/w32ce-add.h >>extra-h.in
+ echo EOF >>extra-h.in
+
+gpg-error.h: Makefile mkheader.awk err-sources.h.in err-codes.h.in \
+ errnos.in extra-h.in gpg-error.h.in
+ $(AWK) -f $(srcdir)/mkheader.awk \
+ $(srcdir)/err-sources.h.in \
+ $(srcdir)/err-codes.h.in \
+ $(srcdir)/errnos.in \
+ extra-h.in \
+ $(srcdir)/gpg-error.h.in > $@
+
+install-data-local:
+@HAVE_W32CE_SYSTEM_TRUE@ -$(MKDIR_P) "$(DESTDIR)$(includedir)/gpg-extra"
+@HAVE_W32CE_SYSTEM_TRUE@ $(INSTALL_DATA) gpg-extra/errno.h \
+@HAVE_W32CE_SYSTEM_TRUE@ "$(DESTDIR)$(includedir)/gpg-extra/errno.h"
+@HAVE_W32CE_SYSTEM_FALSE@ :
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/README b/src/README
new file mode 100644
index 0000000..c415983
--- /dev/null
+++ b/src/README
@@ -0,0 +1,47 @@
+Notes on the source code
+========================
+
+The mechanism to generate the system error codes is delicate and
+fragile, but it's the best I could come up with that supports
+cross-compilation and dynamic self-configuration. Here is how it
+works:
+
+1. Generate list of supported system error codes.
+
+mkerrcodes1.awk generates a list of supported system error codes from
+errnos.in. Each entry in the list is protected with #ifdef/#endif,
+and contains a GPG_ERR_* marker. The list is stored in "_mkerrcodes.h".
+
+2. The HOST cpp is run on _mkerrcodes.h. This evaluates the known
+system error macros to something (may be a number, maybe a constant
+expression as on the GNU/Hurd), suppressing the unknown ones. The
+output is piped into step 3.
+
+3. The cpp output is filtered with grep for only those lines which
+contain a GPG_ERR_* marker. The output is piped into step 4.
+
+4. The filtered output is processed by mkerrcodes.awk, which produces
+a table of constant expressions plus GPG_ERR_* code string symbols in
+a format suitable for the C program mkerrcodes.c. At this point we
+are crossing our fingers that the constant expressions produced by the
+system do not contain GPG_ERR_* markers. The output is stored in
+mkerrcodes.h.
+
+5. The file mkerrcodes.h is included by mkerrcodes.c, which is
+compiled to a binary executable on the BUILD system. At this point we
+are crossing our fingers that the constant expressions produced by the
+system do not depend on the build platform anymore. The output is
+post-processed by mkerrcodes2.awk and stored in "code-from-errno.h",
+which is subsequently used in the library.
+
+-- Marcus
+
+ Copyright 2006 g10 Code GmbH
+
+ This file is free software; as a special exception the author gives
+ unlimited permission to copy and/or distribute it, with or without
+ modifications, as long as this notice is preserved.
+
+ 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.
diff --git a/src/code-from-errno.c b/src/code-from-errno.c
new file mode 100644
index 0000000..96fcf20
--- /dev/null
+++ b/src/code-from-errno.c
@@ -0,0 +1,69 @@
+/* code-from-errno.c - Mapping errnos to error codes.
+ Copyright (C) 2003 g10 Code GmbH
+
+ This file is part of libgpg-error.
+
+ libgpg-error 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 2.1 of
+ the License, or (at your option) any later version.
+
+ libgpg-error 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 libgpg-error; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA. */
+
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <errno.h>
+
+#include <gpg-error.h>
+
+#include "code-from-errno.h"
+
+/* Retrieve the error code for the system error ERR. This returns
+ GPG_ERR_UNKNOWN_ERRNO if the system error is not mapped (report
+ this). */
+gpg_err_code_t
+gpg_err_code_from_errno (int err)
+{
+ int idx;
+
+ if (!err)
+ return GPG_ERR_NO_ERROR;
+
+ idx = errno_to_idx (err);
+
+ if (idx < 0)
+ return GPG_ERR_UNKNOWN_ERRNO;
+
+ return GPG_ERR_SYSTEM_ERROR | err_code_from_index[idx];
+}
+
+
+/* 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. */
+gpg_err_code_t
+gpg_err_code_from_syserror (void)
+{
+ int err = errno;
+ int idx;
+
+ if (!err)
+ return GPG_ERR_MISSING_ERRNO;
+
+ idx = errno_to_idx (err);
+
+ if (idx < 0)
+ return GPG_ERR_UNKNOWN_ERRNO;
+
+ return GPG_ERR_SYSTEM_ERROR | err_code_from_index[idx];
+}
diff --git a/src/code-to-errno.c b/src/code-to-errno.c
new file mode 100644
index 0000000..5873aad
--- /dev/null
+++ b/src/code-to-errno.c
@@ -0,0 +1,42 @@
+/* code-to-errno.c - Mapping error codes to errnos.
+ Copyright (C) 2003 g10 Code GmbH
+
+ This file is part of libgpg-error.
+
+ libgpg-error 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 2.1 of
+ the License, or (at your option) any later version.
+
+ libgpg-error 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 libgpg-error; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA. */
+
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <gpg-error.h>
+
+#include "code-to-errno.h"
+
+/* Retrieve the system error for the error code CODE. This returns 0
+ if CODE is not a system error code. */
+int
+gpg_err_code_to_errno (gpg_err_code_t code)
+{
+ if (!(code & GPG_ERR_SYSTEM_ERROR))
+ return 0;
+ code &= ~GPG_ERR_SYSTEM_ERROR;
+
+ if (code < sizeof (err_code_to_errno) / sizeof (err_code_to_errno[0]))
+ return err_code_to_errno[code];
+ else
+ return 0;
+}
diff --git a/src/err-codes.h b/src/err-codes.h
new file mode 100644
index 0000000..619ca02
--- /dev/null
+++ b/src/err-codes.h
@@ -0,0 +1,536 @@
+/* Output of mkstrtable.awk. DO NOT EDIT. */
+
+/* err-codes.h - List of error codes and their description.
+ Copyright (C) 2003, 2004 g10 Code GmbH
+
+ This file is part of libgpg-error.
+
+ libgpg-error 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 2.1 of
+ the License, or (at your option) any later version.
+
+ libgpg-error 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 libgpg-error; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA. */
+
+
+/* The purpose of this complex string table is to produce
+ optimal code with a minimum of relocations. */
+
+static const char msgstr[] =
+ gettext_noop ("Success") "\0"
+ gettext_noop ("General error") "\0"
+ gettext_noop ("Unknown packet") "\0"
+ gettext_noop ("Unknown version in packet") "\0"
+ gettext_noop ("Invalid public key algorithm") "\0"
+ gettext_noop ("Invalid digest algorithm") "\0"
+ gettext_noop ("Bad public key") "\0"
+ gettext_noop ("Bad secret key") "\0"
+ gettext_noop ("Bad signature") "\0"
+ gettext_noop ("No public key") "\0"
+ gettext_noop ("Checksum error") "\0"
+ gettext_noop ("Bad passphrase") "\0"
+ gettext_noop ("Invalid cipher algorithm") "\0"
+ gettext_noop ("Keyring open") "\0"
+ gettext_noop ("Invalid packet") "\0"
+ gettext_noop ("Invalid armor") "\0"
+ gettext_noop ("No user ID") "\0"
+ gettext_noop ("No secret key") "\0"
+ gettext_noop ("Wrong secret key used") "\0"
+ gettext_noop ("Bad session key") "\0"
+ gettext_noop ("Unknown compression algorithm") "\0"
+ gettext_noop ("Number is not prime") "\0"
+ gettext_noop ("Invalid encoding method") "\0"
+ gettext_noop ("Invalid encryption scheme") "\0"
+ gettext_noop ("Invalid signature scheme") "\0"
+ gettext_noop ("Invalid attribute") "\0"
+ gettext_noop ("No value") "\0"
+ gettext_noop ("Not found") "\0"
+ gettext_noop ("Value not found") "\0"
+ gettext_noop ("Syntax error") "\0"
+ gettext_noop ("Bad MPI value") "\0"
+ gettext_noop ("Invalid passphrase") "\0"
+ gettext_noop ("Invalid signature class") "\0"
+ gettext_noop ("Resources exhausted") "\0"
+ gettext_noop ("Invalid keyring") "\0"
+ gettext_noop ("Trust DB error") "\0"
+ gettext_noop ("Bad certificate") "\0"
+ gettext_noop ("Invalid user ID") "\0"
+ gettext_noop ("Unexpected error") "\0"
+ gettext_noop ("Time conflict") "\0"
+ gettext_noop ("Keyserver error") "\0"
+ gettext_noop ("Wrong public key algorithm") "\0"
+ gettext_noop ("Tribute to D. A.") "\0"
+ gettext_noop ("Weak encryption key") "\0"
+ gettext_noop ("Invalid key length") "\0"
+ gettext_noop ("Invalid argument") "\0"
+ gettext_noop ("Syntax error in URI") "\0"
+ gettext_noop ("Invalid URI") "\0"
+ gettext_noop ("Network error") "\0"
+ gettext_noop ("Unknown host") "\0"
+ gettext_noop ("Selftest failed") "\0"
+ gettext_noop ("Data not encrypted") "\0"
+ gettext_noop ("Data not processed") "\0"
+ gettext_noop ("Unusable public key") "\0"
+ gettext_noop ("Unusable secret key") "\0"
+ gettext_noop ("Invalid value") "\0"
+ gettext_noop ("Bad certificate chain") "\0"
+ gettext_noop ("Missing certificate") "\0"
+ gettext_noop ("No data") "\0"
+ gettext_noop ("Bug") "\0"
+ gettext_noop ("Not supported") "\0"
+ gettext_noop ("Invalid operation code") "\0"
+ gettext_noop ("Timeout") "\0"
+ gettext_noop ("Internal error") "\0"
+ gettext_noop ("EOF (gcrypt)") "\0"
+ gettext_noop ("Invalid object") "\0"
+ gettext_noop ("Provided object is too short") "\0"
+ gettext_noop ("Provided object is too large") "\0"
+ gettext_noop ("Missing item in object") "\0"
+ gettext_noop ("Not implemented") "\0"
+ gettext_noop ("Conflicting use") "\0"
+ gettext_noop ("Invalid cipher mode") "\0"
+ gettext_noop ("Invalid flag") "\0"
+ gettext_noop ("Invalid handle") "\0"
+ gettext_noop ("Result truncated") "\0"
+ gettext_noop ("Incomplete line") "\0"
+ gettext_noop ("Invalid response") "\0"
+ gettext_noop ("No agent running") "\0"
+ gettext_noop ("agent error") "\0"
+ gettext_noop ("Invalid data") "\0"
+ gettext_noop ("Unspecific Assuan server fault") "\0"
+ gettext_noop ("General Assuan error") "\0"
+ gettext_noop ("Invalid session key") "\0"
+ gettext_noop ("Invalid S-expression") "\0"
+ gettext_noop ("Unsupported algorithm") "\0"
+ gettext_noop ("No pinentry") "\0"
+ gettext_noop ("pinentry error") "\0"
+ gettext_noop ("Bad PIN") "\0"
+ gettext_noop ("Invalid name") "\0"
+ gettext_noop ("Bad data") "\0"
+ gettext_noop ("Invalid parameter") "\0"
+ gettext_noop ("Wrong card") "\0"
+ gettext_noop ("No dirmngr") "\0"
+ gettext_noop ("dirmngr error") "\0"
+ gettext_noop ("Certificate revoked") "\0"
+ gettext_noop ("No CRL known") "\0"
+ gettext_noop ("CRL too old") "\0"
+ gettext_noop ("Line too long") "\0"
+ gettext_noop ("Not trusted") "\0"
+ gettext_noop ("Operation cancelled") "\0"
+ gettext_noop ("Bad CA certificate") "\0"
+ gettext_noop ("Certificate expired") "\0"
+ gettext_noop ("Certificate too young") "\0"
+ gettext_noop ("Unsupported certificate") "\0"
+ gettext_noop ("Unknown S-expression") "\0"
+ gettext_noop ("Unsupported protection") "\0"
+ gettext_noop ("Corrupted protection") "\0"
+ gettext_noop ("Ambiguous name") "\0"
+ gettext_noop ("Card error") "\0"
+ gettext_noop ("Card reset required") "\0"
+ gettext_noop ("Card removed") "\0"
+ gettext_noop ("Invalid card") "\0"
+ gettext_noop ("Card not present") "\0"
+ gettext_noop ("No PKCS15 application") "\0"
+ gettext_noop ("Not confirmed") "\0"
+ gettext_noop ("Configuration error") "\0"
+ gettext_noop ("No policy match") "\0"
+ gettext_noop ("Invalid index") "\0"
+ gettext_noop ("Invalid ID") "\0"
+ gettext_noop ("No SmartCard daemon") "\0"
+ gettext_noop ("SmartCard daemon error") "\0"
+ gettext_noop ("Unsupported protocol") "\0"
+ gettext_noop ("Bad PIN method") "\0"
+ gettext_noop ("Card not initialized") "\0"
+ gettext_noop ("Unsupported operation") "\0"
+ gettext_noop ("Wrong key usage") "\0"
+ gettext_noop ("Nothing found") "\0"
+ gettext_noop ("Wrong blob type") "\0"
+ gettext_noop ("Missing value") "\0"
+ gettext_noop ("Hardware problem") "\0"
+ gettext_noop ("PIN blocked") "\0"
+ gettext_noop ("Conditions of use not satisfied") "\0"
+ gettext_noop ("PINs are not synced") "\0"
+ gettext_noop ("Invalid CRL") "\0"
+ gettext_noop ("BER error") "\0"
+ gettext_noop ("Invalid BER") "\0"
+ gettext_noop ("Element not found") "\0"
+ gettext_noop ("Identifier not found") "\0"
+ gettext_noop ("Invalid tag") "\0"
+ gettext_noop ("Invalid length") "\0"
+ gettext_noop ("Invalid key info") "\0"
+ gettext_noop ("Unexpected tag") "\0"
+ gettext_noop ("Not DER encoded") "\0"
+ gettext_noop ("No CMS object") "\0"
+ gettext_noop ("Invalid CMS object") "\0"
+ gettext_noop ("Unknown CMS object") "\0"
+ gettext_noop ("Unsupported CMS object") "\0"
+ gettext_noop ("Unsupported encoding") "\0"
+ gettext_noop ("Unsupported CMS version") "\0"
+ gettext_noop ("Unknown algorithm") "\0"
+ gettext_noop ("Invalid crypto engine") "\0"
+ gettext_noop ("Public key not trusted") "\0"
+ gettext_noop ("Decryption failed") "\0"
+ gettext_noop ("Key expired") "\0"
+ gettext_noop ("Signature expired") "\0"
+ gettext_noop ("Encoding problem") "\0"
+ gettext_noop ("Invalid state") "\0"
+ gettext_noop ("Duplicated value") "\0"
+ gettext_noop ("Missing action") "\0"
+ gettext_noop ("ASN.1 module not found") "\0"
+ gettext_noop ("Invalid OID string") "\0"
+ gettext_noop ("Invalid time") "\0"
+ gettext_noop ("Invalid CRL object") "\0"
+ gettext_noop ("Unsupported CRL version") "\0"
+ gettext_noop ("Invalid certificate object") "\0"
+ gettext_noop ("Unknown name") "\0"
+ gettext_noop ("A locale function failed") "\0"
+ gettext_noop ("Not locked") "\0"
+ gettext_noop ("Protocol violation") "\0"
+ gettext_noop ("Invalid MAC") "\0"
+ gettext_noop ("Invalid request") "\0"
+ gettext_noop ("Unknown extension") "\0"
+ gettext_noop ("Unknown critical extension") "\0"
+ gettext_noop ("Locked") "\0"
+ gettext_noop ("Unknown option") "\0"
+ gettext_noop ("Unknown command") "\0"
+ gettext_noop ("Not operational") "\0"
+ gettext_noop ("No passphrase given") "\0"
+ gettext_noop ("No PIN given") "\0"
+ gettext_noop ("Not enabled") "\0"
+ gettext_noop ("No crypto engine") "\0"
+ gettext_noop ("Missing key") "\0"
+ gettext_noop ("Too many objects") "\0"
+ gettext_noop ("Limit reached") "\0"
+ gettext_noop ("Not initialized") "\0"
+ gettext_noop ("Missing issuer certificate") "\0"
+ gettext_noop ("Operation fully cancelled") "\0"
+ gettext_noop ("Operation not yet finished") "\0"
+ gettext_noop ("Buffer too short") "\0"
+ gettext_noop ("Invalid length specifier in S-expression") "\0"
+ gettext_noop ("String too long in S-expression") "\0"
+ gettext_noop ("Unmatched parentheses in S-expression") "\0"
+ gettext_noop ("S-expression not canonical") "\0"
+ gettext_noop ("Bad character in S-expression") "\0"
+ gettext_noop ("Bad quotation in S-expression") "\0"
+ gettext_noop ("Zero prefix in S-expression") "\0"
+ gettext_noop ("Nested display hints in S-expression") "\0"
+ gettext_noop ("Unmatched display hints") "\0"
+ gettext_noop ("Unexpected reserved punctuation in S-expression") "\0"
+ gettext_noop ("Bad hexadecimal character in S-expression") "\0"
+ gettext_noop ("Odd hexadecimal numbers in S-expression") "\0"
+ gettext_noop ("Bad octal character in S-expression") "\0"
+ gettext_noop ("General IPC error") "\0"
+ gettext_noop ("IPC accept call failed") "\0"
+ gettext_noop ("IPC connect call failed") "\0"
+ gettext_noop ("Invalid IPC response") "\0"
+ gettext_noop ("Invalid value passed to IPC") "\0"
+ gettext_noop ("Incomplete line passed to IPC") "\0"
+ gettext_noop ("Line passed to IPC too long") "\0"
+ gettext_noop ("Nested IPC commands") "\0"
+ gettext_noop ("No data callback in IPC") "\0"
+ gettext_noop ("No inquire callback in IPC") "\0"
+ gettext_noop ("Not an IPC server") "\0"
+ gettext_noop ("Not an IPC client") "\0"
+ gettext_noop ("Problem starting IPC server") "\0"
+ gettext_noop ("IPC read error") "\0"
+ gettext_noop ("IPC write error") "\0"
+ gettext_noop ("Too much data for IPC layer") "\0"
+ gettext_noop ("Unexpected IPC command") "\0"
+ gettext_noop ("Unknown IPC command") "\0"
+ gettext_noop ("IPC syntax error") "\0"
+ gettext_noop ("IPC call has been cancelled") "\0"
+ gettext_noop ("No input source for IPC") "\0"
+ gettext_noop ("No output source for IPC") "\0"
+ gettext_noop ("IPC parameter error") "\0"
+ gettext_noop ("Unknown IPC inquire") "\0"
+ gettext_noop ("User defined error code 1") "\0"
+ gettext_noop ("User defined error code 2") "\0"
+ gettext_noop ("User defined error code 3") "\0"
+ gettext_noop ("User defined error code 4") "\0"
+ gettext_noop ("User defined error code 5") "\0"
+ gettext_noop ("User defined error code 6") "\0"
+ gettext_noop ("User defined error code 7") "\0"
+ gettext_noop ("User defined error code 8") "\0"
+ gettext_noop ("User defined error code 9") "\0"
+ gettext_noop ("User defined error code 10") "\0"
+ gettext_noop ("User defined error code 11") "\0"
+ gettext_noop ("User defined error code 12") "\0"
+ gettext_noop ("User defined error code 13") "\0"
+ gettext_noop ("User defined error code 14") "\0"
+ gettext_noop ("User defined error code 15") "\0"
+ gettext_noop ("User defined error code 16") "\0"
+ gettext_noop ("System error w/o errno") "\0"
+ gettext_noop ("Unknown system error") "\0"
+ gettext_noop ("End of file") "\0"
+ gettext_noop ("Unknown error code");
+
+static const int msgidx[] =
+ {
+ 0,
+ 8,
+ 22,
+ 37,
+ 63,
+ 92,
+ 117,
+ 132,
+ 147,
+ 161,
+ 175,
+ 190,
+ 205,
+ 230,
+ 243,
+ 258,
+ 272,
+ 283,
+ 297,
+ 319,
+ 335,
+ 365,
+ 385,
+ 409,
+ 435,
+ 460,
+ 478,
+ 487,
+ 497,
+ 513,
+ 526,
+ 540,
+ 559,
+ 583,
+ 603,
+ 619,
+ 634,
+ 650,
+ 666,
+ 683,
+ 697,
+ 713,
+ 740,
+ 757,
+ 777,
+ 796,
+ 813,
+ 833,
+ 845,
+ 859,
+ 872,
+ 888,
+ 907,
+ 926,
+ 946,
+ 966,
+ 980,
+ 1002,
+ 1022,
+ 1030,
+ 1034,
+ 1048,
+ 1071,
+ 1079,
+ 1094,
+ 1107,
+ 1122,
+ 1151,
+ 1180,
+ 1203,
+ 1219,
+ 1235,
+ 1255,
+ 1268,
+ 1283,
+ 1300,
+ 1316,
+ 1333,
+ 1350,
+ 1362,
+ 1375,
+ 1406,
+ 1427,
+ 1447,
+ 1468,
+ 1490,
+ 1502,
+ 1517,
+ 1525,
+ 1538,
+ 1547,
+ 1565,
+ 1576,
+ 1587,
+ 1601,
+ 1621,
+ 1634,
+ 1646,
+ 1660,
+ 1672,
+ 1692,
+ 1711,
+ 1731,
+ 1753,
+ 1777,
+ 1798,
+ 1821,
+ 1842,
+ 1857,
+ 1868,
+ 1888,
+ 1901,
+ 1914,
+ 1931,
+ 1953,
+ 1967,
+ 1987,
+ 2003,
+ 2017,
+ 2028,
+ 2048,
+ 2071,
+ 2092,
+ 2107,
+ 2128,
+ 2150,
+ 2166,
+ 2180,
+ 2196,
+ 2210,
+ 2227,
+ 2239,
+ 2271,
+ 2291,
+ 2303,
+ 2313,
+ 2325,
+ 2343,
+ 2364,
+ 2376,
+ 2391,
+ 2408,
+ 2423,
+ 2439,
+ 2453,
+ 2472,
+ 2491,
+ 2514,
+ 2535,
+ 2559,
+ 2577,
+ 2599,
+ 2622,
+ 2640,
+ 2652,
+ 2670,
+ 2687,
+ 2701,
+ 2718,
+ 2733,
+ 2756,
+ 2775,
+ 2788,
+ 2807,
+ 2831,
+ 2858,
+ 2871,
+ 2896,
+ 2907,
+ 2926,
+ 2938,
+ 2954,
+ 2972,
+ 2999,
+ 3006,
+ 3021,
+ 3037,
+ 3053,
+ 3073,
+ 3086,
+ 3098,
+ 3115,
+ 3127,
+ 3144,
+ 3158,
+ 3174,
+ 3201,
+ 3227,
+ 3254,
+ 3271,
+ 3312,
+ 3344,
+ 3382,
+ 3409,
+ 3439,
+ 3469,
+ 3497,
+ 3534,
+ 3558,
+ 3606,
+ 3648,
+ 3688,
+ 3724,
+ 3742,
+ 3765,
+ 3789,
+ 3810,
+ 3838,
+ 3868,
+ 3896,
+ 3916,
+ 3940,
+ 3967,
+ 3985,
+ 4003,
+ 4031,
+ 4046,
+ 4062,
+ 4090,
+ 4113,
+ 4133,
+ 4150,
+ 4178,
+ 4202,
+ 4227,
+ 4247,
+ 4267,
+ 4293,
+ 4319,
+ 4345,
+ 4371,
+ 4397,
+ 4423,
+ 4449,
+ 4475,
+ 4501,
+ 4528,
+ 4555,
+ 4582,
+ 4609,
+ 4636,
+ 4663,
+ 4690,
+ 4713,
+ 4734,
+ 4746
+ };
+
+static inline int
+msgidxof (int code)
+{
+ return (0 ? 0
+ : ((code >= 0) && (code <= 185)) ? (code - 0)
+ : ((code >= 198) && (code <= 213)) ? (code - 12)
+ : ((code >= 257) && (code <= 271)) ? (code - 55)
+ : ((code >= 273) && (code <= 281)) ? (code - 56)
+ : ((code >= 1024) && (code <= 1039)) ? (code - 798)
+ : ((code >= 16381) && (code <= 16383)) ? (code - 16139)
+ : 16384 - 16139);
+}
diff --git a/src/err-codes.h.in b/src/err-codes.h.in
new file mode 100644
index 0000000..501c5e2
--- /dev/null
+++ b/src/err-codes.h.in
@@ -0,0 +1,301 @@
+# err-codes.h.in - List of error codes and their description input file.
+/* err-codes.h - List of error codes and their description.
+ Copyright (C) 2003, 2004 g10 Code GmbH
+
+ This file is part of libgpg-error.
+
+ libgpg-error 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 2.1 of
+ the License, or (at your option) any later version.
+
+ libgpg-error 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 libgpg-error; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA. */
+
+# Everything up to the first line that starts with a number in the
+# first column is copied into the output verbatim. Then, empty lines
+# are ignored. Other lines must have an error code number, followed
+# by one or more <tab> characters, followed by the error code symbol,
+# followed by one or more <tab> characters, followed by the error
+# message. Trailing whitespace is removed. The error codes should be
+# sorted. The last line should not have a number, but only a <tab>,
+# followed by a dummy field, followed by a <tab>, followed by a
+# description for error codes that are not in the list.
+
+0 GPG_ERR_NO_ERROR Success
+1 GPG_ERR_GENERAL General error
+2 GPG_ERR_UNKNOWN_PACKET Unknown packet
+3 GPG_ERR_UNKNOWN_VERSION Unknown version in packet
+4 GPG_ERR_PUBKEY_ALGO Invalid public key algorithm
+5 GPG_ERR_DIGEST_ALGO Invalid digest algorithm
+6 GPG_ERR_BAD_PUBKEY Bad public key
+7 GPG_ERR_BAD_SECKEY Bad secret key
+8 GPG_ERR_BAD_SIGNATURE Bad signature
+9 GPG_ERR_NO_PUBKEY No public key
+10 GPG_ERR_CHECKSUM Checksum error
+11 GPG_ERR_BAD_PASSPHRASE Bad passphrase
+12 GPG_ERR_CIPHER_ALGO Invalid cipher algorithm
+13 GPG_ERR_KEYRING_OPEN Keyring open
+14 GPG_ERR_INV_PACKET Invalid packet
+15 GPG_ERR_INV_ARMOR Invalid armor
+16 GPG_ERR_NO_USER_ID No user ID
+17 GPG_ERR_NO_SECKEY No secret key
+18 GPG_ERR_WRONG_SECKEY Wrong secret key used
+19 GPG_ERR_BAD_KEY Bad session key
+20 GPG_ERR_COMPR_ALGO Unknown compression algorithm
+21 GPG_ERR_NO_PRIME Number is not prime
+22 GPG_ERR_NO_ENCODING_METHOD Invalid encoding method
+23 GPG_ERR_NO_ENCRYPTION_SCHEME Invalid encryption scheme
+24 GPG_ERR_NO_SIGNATURE_SCHEME Invalid signature scheme
+25 GPG_ERR_INV_ATTR Invalid attribute
+26 GPG_ERR_NO_VALUE No value
+27 GPG_ERR_NOT_FOUND Not found
+28 GPG_ERR_VALUE_NOT_FOUND Value not found
+29 GPG_ERR_SYNTAX Syntax error
+30 GPG_ERR_BAD_MPI Bad MPI value
+31 GPG_ERR_INV_PASSPHRASE Invalid passphrase
+32 GPG_ERR_SIG_CLASS Invalid signature class
+33 GPG_ERR_RESOURCE_LIMIT Resources exhausted
+34 GPG_ERR_INV_KEYRING Invalid keyring
+35 GPG_ERR_TRUSTDB Trust DB error
+36 GPG_ERR_BAD_CERT Bad certificate
+37 GPG_ERR_INV_USER_ID Invalid user ID
+38 GPG_ERR_UNEXPECTED Unexpected error
+39 GPG_ERR_TIME_CONFLICT Time conflict
+40 GPG_ERR_KEYSERVER Keyserver error
+41 GPG_ERR_WRONG_PUBKEY_ALGO Wrong public key algorithm
+42 GPG_ERR_TRIBUTE_TO_D_A Tribute to D. A.
+43 GPG_ERR_WEAK_KEY Weak encryption key
+44 GPG_ERR_INV_KEYLEN Invalid key length
+45 GPG_ERR_INV_ARG Invalid argument
+46 GPG_ERR_BAD_URI Syntax error in URI
+47 GPG_ERR_INV_URI Invalid URI
+48 GPG_ERR_NETWORK Network error
+49 GPG_ERR_UNKNOWN_HOST Unknown host
+50 GPG_ERR_SELFTEST_FAILED Selftest failed
+51 GPG_ERR_NOT_ENCRYPTED Data not encrypted
+52 GPG_ERR_NOT_PROCESSED Data not processed
+53 GPG_ERR_UNUSABLE_PUBKEY Unusable public key
+54 GPG_ERR_UNUSABLE_SECKEY Unusable secret key
+55 GPG_ERR_INV_VALUE Invalid value
+56 GPG_ERR_BAD_CERT_CHAIN Bad certificate chain
+57 GPG_ERR_MISSING_CERT Missing certificate
+58 GPG_ERR_NO_DATA No data
+59 GPG_ERR_BUG Bug
+60 GPG_ERR_NOT_SUPPORTED Not supported
+61 GPG_ERR_INV_OP Invalid operation code
+62 GPG_ERR_TIMEOUT Timeout
+63 GPG_ERR_INTERNAL Internal error
+64 GPG_ERR_EOF_GCRYPT EOF (gcrypt)
+65 GPG_ERR_INV_OBJ Invalid object
+66 GPG_ERR_TOO_SHORT Provided object is too short
+67 GPG_ERR_TOO_LARGE Provided object is too large
+68 GPG_ERR_NO_OBJ Missing item in object
+69 GPG_ERR_NOT_IMPLEMENTED Not implemented
+70 GPG_ERR_CONFLICT Conflicting use
+71 GPG_ERR_INV_CIPHER_MODE Invalid cipher mode
+72 GPG_ERR_INV_FLAG Invalid flag
+73 GPG_ERR_INV_HANDLE Invalid handle
+74 GPG_ERR_TRUNCATED Result truncated
+75 GPG_ERR_INCOMPLETE_LINE Incomplete line
+76 GPG_ERR_INV_RESPONSE Invalid response
+77 GPG_ERR_NO_AGENT No agent running
+78 GPG_ERR_AGENT agent error
+79 GPG_ERR_INV_DATA Invalid data
+80 GPG_ERR_ASSUAN_SERVER_FAULT Unspecific Assuan server fault
+81 GPG_ERR_ASSUAN General Assuan error
+82 GPG_ERR_INV_SESSION_KEY Invalid session key
+83 GPG_ERR_INV_SEXP Invalid S-expression
+84 GPG_ERR_UNSUPPORTED_ALGORITHM Unsupported algorithm
+85 GPG_ERR_NO_PIN_ENTRY No pinentry
+86 GPG_ERR_PIN_ENTRY pinentry error
+87 GPG_ERR_BAD_PIN Bad PIN
+88 GPG_ERR_INV_NAME Invalid name
+89 GPG_ERR_BAD_DATA Bad data
+90 GPG_ERR_INV_PARAMETER Invalid parameter
+91 GPG_ERR_WRONG_CARD Wrong card
+92 GPG_ERR_NO_DIRMNGR No dirmngr
+93 GPG_ERR_DIRMNGR dirmngr error
+94 GPG_ERR_CERT_REVOKED Certificate revoked
+95 GPG_ERR_NO_CRL_KNOWN No CRL known
+96 GPG_ERR_CRL_TOO_OLD CRL too old
+97 GPG_ERR_LINE_TOO_LONG Line too long
+98 GPG_ERR_NOT_TRUSTED Not trusted
+99 GPG_ERR_CANCELED Operation cancelled
+100 GPG_ERR_BAD_CA_CERT Bad CA certificate
+101 GPG_ERR_CERT_EXPIRED Certificate expired
+102 GPG_ERR_CERT_TOO_YOUNG Certificate too young
+103 GPG_ERR_UNSUPPORTED_CERT Unsupported certificate
+104 GPG_ERR_UNKNOWN_SEXP Unknown S-expression
+105 GPG_ERR_UNSUPPORTED_PROTECTION Unsupported protection
+106 GPG_ERR_CORRUPTED_PROTECTION Corrupted protection
+107 GPG_ERR_AMBIGUOUS_NAME Ambiguous name
+108 GPG_ERR_CARD Card error
+109 GPG_ERR_CARD_RESET Card reset required
+110 GPG_ERR_CARD_REMOVED Card removed
+111 GPG_ERR_INV_CARD Invalid card
+112 GPG_ERR_CARD_NOT_PRESENT Card not present
+113 GPG_ERR_NO_PKCS15_APP No PKCS15 application
+114 GPG_ERR_NOT_CONFIRMED Not confirmed
+115 GPG_ERR_CONFIGURATION Configuration error
+116 GPG_ERR_NO_POLICY_MATCH No policy match
+117 GPG_ERR_INV_INDEX Invalid index
+118 GPG_ERR_INV_ID Invalid ID
+119 GPG_ERR_NO_SCDAEMON No SmartCard daemon
+120 GPG_ERR_SCDAEMON SmartCard daemon error
+121 GPG_ERR_UNSUPPORTED_PROTOCOL Unsupported protocol
+122 GPG_ERR_BAD_PIN_METHOD Bad PIN method
+123 GPG_ERR_CARD_NOT_INITIALIZED Card not initialized
+124 GPG_ERR_UNSUPPORTED_OPERATION Unsupported operation
+125 GPG_ERR_WRONG_KEY_USAGE Wrong key usage
+126 GPG_ERR_NOTHING_FOUND Nothing found
+127 GPG_ERR_WRONG_BLOB_TYPE Wrong blob type
+128 GPG_ERR_MISSING_VALUE Missing value
+129 GPG_ERR_HARDWARE Hardware problem
+130 GPG_ERR_PIN_BLOCKED PIN blocked
+131 GPG_ERR_USE_CONDITIONS Conditions of use not satisfied
+132 GPG_ERR_PIN_NOT_SYNCED PINs are not synced
+133 GPG_ERR_INV_CRL Invalid CRL
+134 GPG_ERR_BAD_BER BER error
+135 GPG_ERR_INV_BER Invalid BER
+136 GPG_ERR_ELEMENT_NOT_FOUND Element not found
+137 GPG_ERR_IDENTIFIER_NOT_FOUND Identifier not found
+138 GPG_ERR_INV_TAG Invalid tag
+139 GPG_ERR_INV_LENGTH Invalid length
+140 GPG_ERR_INV_KEYINFO Invalid key info
+141 GPG_ERR_UNEXPECTED_TAG Unexpected tag
+142 GPG_ERR_NOT_DER_ENCODED Not DER encoded
+143 GPG_ERR_NO_CMS_OBJ No CMS object
+144 GPG_ERR_INV_CMS_OBJ Invalid CMS object
+145 GPG_ERR_UNKNOWN_CMS_OBJ Unknown CMS object
+146 GPG_ERR_UNSUPPORTED_CMS_OBJ Unsupported CMS object
+147 GPG_ERR_UNSUPPORTED_ENCODING Unsupported encoding
+148 GPG_ERR_UNSUPPORTED_CMS_VERSION Unsupported CMS version
+149 GPG_ERR_UNKNOWN_ALGORITHM Unknown algorithm
+150 GPG_ERR_INV_ENGINE Invalid crypto engine
+151 GPG_ERR_PUBKEY_NOT_TRUSTED Public key not trusted
+152 GPG_ERR_DECRYPT_FAILED Decryption failed
+153 GPG_ERR_KEY_EXPIRED Key expired
+154 GPG_ERR_SIG_EXPIRED Signature expired
+155 GPG_ERR_ENCODING_PROBLEM Encoding problem
+156 GPG_ERR_INV_STATE Invalid state
+157 GPG_ERR_DUP_VALUE Duplicated value
+158 GPG_ERR_MISSING_ACTION Missing action
+159 GPG_ERR_MODULE_NOT_FOUND ASN.1 module not found
+160 GPG_ERR_INV_OID_STRING Invalid OID string
+161 GPG_ERR_INV_TIME Invalid time
+162 GPG_ERR_INV_CRL_OBJ Invalid CRL object
+163 GPG_ERR_UNSUPPORTED_CRL_VERSION Unsupported CRL version
+164 GPG_ERR_INV_CERT_OBJ Invalid certificate object
+165 GPG_ERR_UNKNOWN_NAME Unknown name
+166 GPG_ERR_LOCALE_PROBLEM A locale function failed
+167 GPG_ERR_NOT_LOCKED Not locked
+168 GPG_ERR_PROTOCOL_VIOLATION Protocol violation
+169 GPG_ERR_INV_MAC Invalid MAC
+170 GPG_ERR_INV_REQUEST Invalid request
+171 GPG_ERR_UNKNOWN_EXTN Unknown extension
+172 GPG_ERR_UNKNOWN_CRIT_EXTN Unknown critical extension
+173 GPG_ERR_LOCKED Locked
+174 GPG_ERR_UNKNOWN_OPTION Unknown option
+175 GPG_ERR_UNKNOWN_COMMAND Unknown command
+176 GPG_ERR_NOT_OPERATIONAL Not operational
+177 GPG_ERR_NO_PASSPHRASE No passphrase given
+178 GPG_ERR_NO_PIN No PIN given
+179 GPG_ERR_NOT_ENABLED Not enabled
+180 GPG_ERR_NO_ENGINE No crypto engine
+181 GPG_ERR_MISSING_KEY Missing key
+182 GPG_ERR_TOO_MANY Too many objects
+183 GPG_ERR_LIMIT_REACHED Limit reached
+184 GPG_ERR_NOT_INITIALIZED Not initialized
+185 GPG_ERR_MISSING_ISSUER_CERT Missing issuer certificate
+# 186 to 197 are free to be used.
+
+198 GPG_ERR_FULLY_CANCELED Operation fully cancelled
+199 GPG_ERR_UNFINISHED Operation not yet finished
+200 GPG_ERR_BUFFER_TOO_SHORT Buffer too short
+
+# Error codes pertaining to S-expressions.
+
+201 GPG_ERR_SEXP_INV_LEN_SPEC Invalid length specifier in S-expression
+202 GPG_ERR_SEXP_STRING_TOO_LONG String too long in S-expression
+203 GPG_ERR_SEXP_UNMATCHED_PAREN Unmatched parentheses in S-expression
+204 GPG_ERR_SEXP_NOT_CANONICAL S-expression not canonical
+205 GPG_ERR_SEXP_BAD_CHARACTER Bad character in S-expression
+206 GPG_ERR_SEXP_BAD_QUOTATION Bad quotation in S-expression
+207 GPG_ERR_SEXP_ZERO_PREFIX Zero prefix in S-expression
+208 GPG_ERR_SEXP_NESTED_DH Nested display hints in S-expression
+209 GPG_ERR_SEXP_UNMATCHED_DH Unmatched display hints
+210 GPG_ERR_SEXP_UNEXPECTED_PUNC Unexpected reserved punctuation in S-expression
+211 GPG_ERR_SEXP_BAD_HEX_CHAR Bad hexadecimal character in S-expression
+212 GPG_ERR_SEXP_ODD_HEX_NUMBERS Odd hexadecimal numbers in S-expression
+213 GPG_ERR_SEXP_BAD_OCT_CHAR Bad octal character in S-expression
+
+# 214 to 254 are free to be used. 255 and 256 are RFU.
+
+# Error codes pertaining to the Assuan IPC interface
+257 GPG_ERR_ASS_GENERAL General IPC error
+258 GPG_ERR_ASS_ACCEPT_FAILED IPC accept call failed
+259 GPG_ERR_ASS_CONNECT_FAILED IPC connect call failed
+260 GPG_ERR_ASS_INV_RESPONSE Invalid IPC response
+261 GPG_ERR_ASS_INV_VALUE Invalid value passed to IPC
+262 GPG_ERR_ASS_INCOMPLETE_LINE Incomplete line passed to IPC
+263 GPG_ERR_ASS_LINE_TOO_LONG Line passed to IPC too long
+264 GPG_ERR_ASS_NESTED_COMMANDS Nested IPC commands
+265 GPG_ERR_ASS_NO_DATA_CB No data callback in IPC
+266 GPG_ERR_ASS_NO_INQUIRE_CB No inquire callback in IPC
+267 GPG_ERR_ASS_NOT_A_SERVER Not an IPC server
+268 GPG_ERR_ASS_NOT_A_CLIENT Not an IPC client
+269 GPG_ERR_ASS_SERVER_START Problem starting IPC server
+270 GPG_ERR_ASS_READ_ERROR IPC read error
+271 GPG_ERR_ASS_WRITE_ERROR IPC write error
+# reserved
+273 GPG_ERR_ASS_TOO_MUCH_DATA Too much data for IPC layer
+274 GPG_ERR_ASS_UNEXPECTED_CMD Unexpected IPC command
+275 GPG_ERR_ASS_UNKNOWN_CMD Unknown IPC command
+276 GPG_ERR_ASS_SYNTAX IPC syntax error
+277 GPG_ERR_ASS_CANCELED IPC call has been cancelled
+278 GPG_ERR_ASS_NO_INPUT No input source for IPC
+279 GPG_ERR_ASS_NO_OUTPUT No output source for IPC
+280 GPG_ERR_ASS_PARAMETER IPC parameter error
+281 GPG_ERR_ASS_UNKNOWN_INQUIRE Unknown IPC inquire
+
+# 282 to 299 are reserved for future assuan codes.
+
+# 300 to 1023 are free to be used.
+
+# For free use by non-GnuPG components.
+1024 GPG_ERR_USER_1 User defined error code 1
+1025 GPG_ERR_USER_2 User defined error code 2
+1026 GPG_ERR_USER_3 User defined error code 3
+1027 GPG_ERR_USER_4 User defined error code 4
+1028 GPG_ERR_USER_5 User defined error code 5
+1029 GPG_ERR_USER_6 User defined error code 6
+1030 GPG_ERR_USER_7 User defined error code 7
+1031 GPG_ERR_USER_8 User defined error code 8
+1032 GPG_ERR_USER_9 User defined error code 9
+1033 GPG_ERR_USER_10 User defined error code 10
+1034 GPG_ERR_USER_11 User defined error code 11
+1035 GPG_ERR_USER_12 User defined error code 12
+1036 GPG_ERR_USER_13 User defined error code 13
+1037 GPG_ERR_USER_14 User defined error code 14
+1038 GPG_ERR_USER_15 User defined error code 15
+1039 GPG_ERR_USER_16 User defined error code 16
+
+# 1040 to 16380 are free to be used.
+
+16381 GPG_ERR_MISSING_ERRNO System error w/o errno
+16382 GPG_ERR_UNKNOWN_ERRNO Unknown system error
+16383 GPG_ERR_EOF End of file
+
+# 16384 - 32767 are reserved for future extensions.
+
+# GPG_SYSTEM_ERROR | (141 to 32767) are to be used for system errors.
+
+ GPG_ERR_CODE_DIM Unknown error code
diff --git a/src/err-sources.h b/src/err-sources.h
new file mode 100644
index 0000000..0fcc551
--- /dev/null
+++ b/src/err-sources.h
@@ -0,0 +1,82 @@
+/* Output of mkstrtable.awk. DO NOT EDIT. */
+
+/* err-sources.h - List of error sources and their description.
+ Copyright (C) 2003, 2004 g10 Code GmbH
+
+ This file is part of libgpg-error.
+
+ libgpg-error 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 2.1 of
+ the License, or (at your option) any later version.
+
+ libgpg-error 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 libgpg-error; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA. */
+
+
+/* The purpose of this complex string table is to produce
+ optimal code with a minimum of relocations. */
+
+static const char msgstr[] =
+ gettext_noop ("Unspecified source") "\0"
+ gettext_noop ("gcrypt") "\0"
+ gettext_noop ("GnuPG") "\0"
+ gettext_noop ("GpgSM") "\0"
+ gettext_noop ("GPG Agent") "\0"
+ gettext_noop ("Pinentry") "\0"
+ gettext_noop ("SCD") "\0"
+ gettext_noop ("GPGME") "\0"
+ gettext_noop ("Keybox") "\0"
+ gettext_noop ("KSBA") "\0"
+ gettext_noop ("Dirmngr") "\0"
+ gettext_noop ("GSTI") "\0"
+ gettext_noop ("GPA") "\0"
+ gettext_noop ("Kleopatra") "\0"
+ gettext_noop ("G13") "\0"
+ gettext_noop ("Any source") "\0"
+ gettext_noop ("User defined source 1") "\0"
+ gettext_noop ("User defined source 2") "\0"
+ gettext_noop ("User defined source 3") "\0"
+ gettext_noop ("User defined source 4") "\0"
+ gettext_noop ("Unknown source");
+
+static const int msgidx[] =
+ {
+ 0,
+ 19,
+ 26,
+ 32,
+ 38,
+ 48,
+ 57,
+ 61,
+ 67,
+ 74,
+ 79,
+ 87,
+ 92,
+ 96,
+ 106,
+ 110,
+ 121,
+ 143,
+ 165,
+ 187,
+ 209
+ };
+
+static inline int
+msgidxof (int code)
+{
+ return (0 ? 0
+ : ((code >= 0) && (code <= 14)) ? (code - 0)
+ : ((code >= 31) && (code <= 35)) ? (code - 16)
+ : 36 - 16);
+}
diff --git a/src/err-sources.h.in b/src/err-sources.h.in
new file mode 100644
index 0000000..d200fc6
--- /dev/null
+++ b/src/err-sources.h.in
@@ -0,0 +1,58 @@
+# err-sources.h.in - List of error sources and their description input file.
+/* err-sources.h - List of error sources and their description.
+ Copyright (C) 2003, 2004 g10 Code GmbH
+
+ This file is part of libgpg-error.
+
+ libgpg-error 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 2.1 of
+ the License, or (at your option) any later version.
+
+ libgpg-error 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 libgpg-error; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA. */
+
+# Everything up to the first line that starts with a number in the
+# first column is copied into the output verbatim. Then, empty lines
+# are ignored. Other lines must have an error source number, followed
+# by one or more <tab> characters, followed by the error source
+# symbol, followed by one or more <tab> characters, followed by the
+# error source name. Trailing whitespace is removed. The error
+# sources should be sorted. The last line should not have a number,
+# but only a <tab>, followed by a description for error sources that
+# are not in the list.
+
+0 GPG_ERR_SOURCE_UNKNOWN Unspecified source
+1 GPG_ERR_SOURCE_GCRYPT gcrypt
+2 GPG_ERR_SOURCE_GPG GnuPG
+3 GPG_ERR_SOURCE_GPGSM GpgSM
+4 GPG_ERR_SOURCE_GPGAGENT GPG Agent
+5 GPG_ERR_SOURCE_PINENTRY Pinentry
+6 GPG_ERR_SOURCE_SCD SCD
+7 GPG_ERR_SOURCE_GPGME GPGME
+8 GPG_ERR_SOURCE_KEYBOX Keybox
+9 GPG_ERR_SOURCE_KSBA KSBA
+10 GPG_ERR_SOURCE_DIRMNGR Dirmngr
+11 GPG_ERR_SOURCE_GSTI GSTI
+12 GPG_ERR_SOURCE_GPA GPA
+13 GPG_ERR_SOURCE_KLEO Kleopatra
+14 GPG_ERR_SOURCE_G13 G13
+
+# 15 to 30 are free to be used.
+
+31 GPG_ERR_SOURCE_ANY Any source
+32 GPG_ERR_SOURCE_USER_1 User defined source 1
+33 GPG_ERR_SOURCE_USER_2 User defined source 2
+34 GPG_ERR_SOURCE_USER_3 User defined source 3
+35 GPG_ERR_SOURCE_USER_4 User defined source 4
+
+# 36 to 255 are free to be used.
+
+ GPG_ERR_SOURCE_DIM Unknown source
diff --git a/src/errnos.in b/src/errnos.in
new file mode 100644
index 0000000..0688047
--- /dev/null
+++ b/src/errnos.in
@@ -0,0 +1,172 @@
+# errnos.h.in - List of system error values input file.
+/* errnos.h - List of system error values.
+ Copyright (C) 2003, 2004 g10 Code GmbH
+
+ This file is part of libgpg-error.
+
+ libgpg-error 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 2.1 of
+ the License, or (at your option) any later version.
+
+ libgpg-error 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 libgpg-error; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA. */
+
+# Everything up to the first line that starts with a number in the
+# first column is copied into the output verbatim. Then, empty lines
+# are ignored. Other lines must have an error code number, followed
+# by one or more <tab> characters, followed by the error name.
+#
+# IMPORTANT: For now, the numbering must be consecutive. Some of the
+# scripts (notably mkerrnos.h) do not deal correctly with a numbering
+# that is out of order or has gaps.
+
+
+0 E2BIG
+1 EACCES
+2 EADDRINUSE
+3 EADDRNOTAVAIL
+4 EADV
+5 EAFNOSUPPORT
+6 EAGAIN
+7 EALREADY
+8 EAUTH
+9 EBACKGROUND
+10 EBADE
+11 EBADF
+12 EBADFD
+13 EBADMSG
+14 EBADR
+15 EBADRPC
+16 EBADRQC
+17 EBADSLT
+18 EBFONT
+19 EBUSY
+20 ECANCELED
+21 ECHILD
+22 ECHRNG
+23 ECOMM
+24 ECONNABORTED
+25 ECONNREFUSED
+26 ECONNRESET
+27 ED
+28 EDEADLK
+29 EDEADLOCK
+30 EDESTADDRREQ
+31 EDIED
+32 EDOM
+33 EDOTDOT
+34 EDQUOT
+35 EEXIST
+36 EFAULT
+37 EFBIG
+38 EFTYPE
+39 EGRATUITOUS
+40 EGREGIOUS
+41 EHOSTDOWN
+42 EHOSTUNREACH
+43 EIDRM
+44 EIEIO
+45 EILSEQ
+46 EINPROGRESS
+47 EINTR
+48 EINVAL
+49 EIO
+50 EISCONN
+51 EISDIR
+52 EISNAM
+53 EL2HLT
+54 EL2NSYNC
+55 EL3HLT
+56 EL3RST
+57 ELIBACC
+58 ELIBBAD
+59 ELIBEXEC
+60 ELIBMAX
+61 ELIBSCN
+62 ELNRNG
+63 ELOOP
+64 EMEDIUMTYPE
+65 EMFILE
+66 EMLINK
+67 EMSGSIZE
+68 EMULTIHOP
+69 ENAMETOOLONG
+70 ENAVAIL
+71 ENEEDAUTH
+72 ENETDOWN
+73 ENETRESET
+74 ENETUNREACH
+75 ENFILE
+76 ENOANO
+77 ENOBUFS
+78 ENOCSI
+79 ENODATA
+80 ENODEV
+81 ENOENT
+82 ENOEXEC
+83 ENOLCK
+84 ENOLINK
+85 ENOMEDIUM
+86 ENOMEM
+87 ENOMSG
+88 ENONET
+89 ENOPKG
+90 ENOPROTOOPT
+91 ENOSPC
+92 ENOSR
+93 ENOSTR
+94 ENOSYS
+95 ENOTBLK
+96 ENOTCONN
+97 ENOTDIR
+98 ENOTEMPTY
+99 ENOTNAM
+100 ENOTSOCK
+101 ENOTSUP
+102 ENOTTY
+103 ENOTUNIQ
+104 ENXIO
+105 EOPNOTSUPP
+106 EOVERFLOW
+107 EPERM
+108 EPFNOSUPPORT
+109 EPIPE
+110 EPROCLIM
+111 EPROCUNAVAIL
+112 EPROGMISMATCH
+113 EPROGUNAVAIL
+114 EPROTO
+115 EPROTONOSUPPORT
+116 EPROTOTYPE
+117 ERANGE
+118 EREMCHG
+119 EREMOTE
+120 EREMOTEIO
+121 ERESTART
+122 EROFS
+123 ERPCMISMATCH
+124 ESHUTDOWN
+125 ESOCKTNOSUPPORT
+126 ESPIPE
+127 ESRCH
+128 ESRMNT
+129 ESTALE
+130 ESTRPIPE
+131 ETIME
+132 ETIMEDOUT
+133 ETOOMANYREFS
+134 ETXTBSY
+135 EUCLEAN
+136 EUNATCH
+137 EUSERS
+138 EWOULDBLOCK
+139 EXDEV
+140 EXFULL \ No newline at end of file
diff --git a/src/gettext.h b/src/gettext.h
new file mode 100644
index 0000000..aba29db
--- /dev/null
+++ b/src/gettext.h
@@ -0,0 +1,76 @@
+/* Convenience header for conditional use of GNU <libintl.h>.
+ Copyright (C) 1995-1998, 2000-2002 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ USA. */
+
+#ifndef _LIBGETTEXT_H
+#define _LIBGETTEXT_H 1
+
+/* NLS can be disabled through the configure --disable-nls option. */
+#if ENABLE_NLS
+
+#if HAVE_W32_SYSTEM
+ /* We have a gettext implementation in gpg-error.h which get
+ included anyway. */
+#else /*!HAVE_W32_SYSTEM*/
+ /* Get declarations of GNU message catalog functions. */
+# include <libintl.h>
+#endif /*!HAVE_W32_SYSTEM*/
+
+#else /*!ENABLE_NLS*/
+
+/* Solaris /usr/include/locale.h includes /usr/include/libintl.h, which
+ chokes if dcgettext is defined as a macro. So include it now, to make
+ later inclusions of <locale.h> a NOP. We don't include <libintl.h>
+ as well because people using "gettext.h" will not include <libintl.h>,
+ and also including <libintl.h> would fail on SunOS 4, whereas <locale.h>
+ is OK. */
+#if defined(__sun)
+# include <locale.h>
+#endif
+
+/* Disabled NLS.
+ The casts to 'const char *' serve the purpose of producing warnings
+ for invalid uses of the value returned from these functions.
+ On pre-ANSI systems without 'const', the config.h file is supposed to
+ contain "#define const". */
+# define gettext(Msgid) ((const char *) (Msgid))
+# define dgettext(Domainname, Msgid) ((const char *) (Msgid))
+# define dcgettext(Domainname, Msgid, Category) ((const char *) (Msgid))
+# define ngettext(Msgid1, Msgid2, N) \
+ ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
+# define dngettext(Domainname, Msgid1, Msgid2, N) \
+ ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
+# define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \
+ ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
+# define textdomain(Domainname) ((const char *) (Domainname))
+# define bindtextdomain(Domainname, Dirname) ((const char *) (Dirname))
+# define bind_textdomain_codeset(Domainname, Codeset) ((const char *) (Codeset))
+
+#endif /*!ENABLE_NLS*/
+
+/* A pseudo function call that serves as a marker for the automated
+ extraction of messages, but does not call gettext(). The run-time
+ translation is done at a different place in the code.
+ The argument, String, should be a literal string. Concatenated strings
+ and other string expressions won't work.
+ The macro's expansion is not parenthesized, so that it is suitable as
+ initializer for static 'char[]' or 'const char[]' variables. */
+#define gettext_noop(String) String
+
+
+
+#endif /* _LIBGETTEXT_H */
diff --git a/src/gpg-error-config.in b/src/gpg-error-config.in
new file mode 100644
index 0000000..4be0343
--- /dev/null
+++ b/src/gpg-error-config.in
@@ -0,0 +1,84 @@
+#!/bin/sh
+# Copyright (C) 1999, 2002, 2003 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
+# modifications, as long as this notice is preserved.
+#
+# 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.
+
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+includedir=@includedir@
+libdir=@libdir@
+isubdirafter="@GPG_ERROR_CONFIG_ISUBDIRAFTER@"
+
+output=""
+
+usage()
+{
+ cat <<EOF
+Usage: gpg-error-config [OPTIONS]
+Options:
+ [--prefix]
+ [--exec-prefix]
+ [--version]
+ [--libs]
+ [--cflags]
+EOF
+ exit $1
+}
+
+if test $# -eq 0; then
+ usage 1 1>&2
+fi
+
+while test $# -gt 0; do
+ case "$1" in
+ -*=*)
+ optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'`
+ ;;
+ *)
+ optarg=
+ ;;
+ esac
+
+ case $1 in
+ --prefix)
+ output="$output $prefix"
+ ;;
+ --exec-prefix)
+ output="$output $exec_prefix"
+ ;;
+ --version)
+ echo "@VERSION@"
+ exit 0
+ ;;
+ --cflags)
+ if test "x$includedir" != "x/usr/include" -a "x$includedir" != "x/include"; then
+ output="$output -I$includedir"
+ fi
+ # Note: -idirafter is a gcc extension. It is only used on
+ # systems where gcc is the only compiler we support.
+ for i in $isubdirafter; do
+ output="$output -idirafter ${includedir}/${i}"
+ done
+ output="$output @GPG_ERROR_CONFIG_CFLAGS@"
+ ;;
+ --libs)
+ if test "x$libdir" != "x/usr/lib" -a "x$libdir" != "x/lib"; then
+ output="$output -L$libdir"
+ fi
+ output="$output @GPG_ERROR_CONFIG_LIBS@"
+ ;;
+ *)
+ usage 1 1>&2
+ ;;
+ esac
+ shift
+done
+
+echo $output
diff --git a/src/gpg-error.c b/src/gpg-error.c
new file mode 100644
index 0000000..fa868ae
--- /dev/null
+++ b/src/gpg-error.c
@@ -0,0 +1,454 @@
+/* gpg-error.c - Determining gpg-error error codes.
+ Copyright (C) 2004 g10 Code GmbH
+
+ This file is part of libgpg-error.
+
+ libgpg-error 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 2.1 of
+ the License, or (at your option) any later version.
+
+ libgpg-error 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 libgpg-error; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA. */
+
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <limits.h>
+#include <stdio.h>
+
+#ifdef HAVE_LOCALE_H
+# include <locale.h>
+#endif
+#ifdef ENABLE_NLS
+#ifdef HAVE_W32_SYSTEM
+# include "gettext.h"
+#else
+# include <libintl.h>
+#endif
+# define _(a) gettext (a)
+# ifdef gettext_noop
+# define N_(a) gettext_noop (a)
+# else
+# define N_(a) (a)
+# endif
+#else
+# define _(a) (a)
+# define N_(a) (a)
+#endif
+
+#include <gpg-error.h>
+
+
+#if HAVE_W32_SYSTEM
+/* The implementation follows below. */
+static char *get_locale_dir (void);
+static void drop_locale_dir (char *locale_dir);
+#else
+#define get_locale_dir() LOCALEDIR
+#define drop_locale_dir(dir)
+#endif
+
+static void
+i18n_init (void)
+{
+#ifdef ENABLE_NLS
+ char *locale_dir;
+
+#ifdef HAVE_LC_MESSAGES
+ setlocale (LC_TIME, "");
+ setlocale (LC_MESSAGES, "");
+#else
+# ifndef HAVE_W32_SYSTEM
+ setlocale (LC_ALL, "" );
+# endif
+#endif
+
+ /* Note that for this program we would only need the textdomain call
+ because libgpg-error already initializes itself to its locale dir
+ (via gpg_err_init or a constructor). However this is only done
+ for the static standard locale and thus if the above setlocale
+ calls select a different locale the bindtext below will do
+ something else. */
+
+ locale_dir = get_locale_dir ();
+ if (locale_dir)
+ {
+ bindtextdomain (PACKAGE, locale_dir);
+ drop_locale_dir (locale_dir);
+ }
+ textdomain (PACKAGE);
+#endif
+}
+
+
+#ifdef HAVE_W32_SYSTEM
+
+#include <windows.h>
+
+
+static char *
+get_locale_dir (void)
+{
+ static wchar_t moddir[MAX_PATH+5];
+ char *result, *p;
+ int nbytes;
+
+ if (!GetModuleFileNameW (NULL, moddir, MAX_PATH))
+ *moddir = 0;
+
+#define SLDIR "\\share\\locale"
+ if (*moddir)
+ {
+ nbytes = WideCharToMultiByte (CP_UTF8, 0, moddir, -1, NULL, 0, NULL, NULL);
+ if (nbytes < 0)
+ return NULL;
+
+ result = malloc (nbytes + strlen (SLDIR) + 1);
+ if (result)
+ {
+ nbytes = WideCharToMultiByte (CP_UTF8, 0, moddir, -1,
+ result, nbytes, NULL, NULL);
+ if (nbytes < 0)
+ {
+ free (result);
+ result = NULL;
+ }
+ else
+ {
+ p = strrchr (result, '\\');
+ if (p)
+ *p = 0;
+ /* If we are installed below "bin" strip that part and
+ use the top directory instead. */
+ p = strrchr (result, '\\');
+ if (p && !strcmp (p+1, "bin"))
+ *p = 0;
+ /* Append the static part. */
+ strcat (result, SLDIR);
+ }
+ }
+ }
+ else /* Use the old default value. */
+ {
+ result = malloc (10 + strlen (SLDIR) + 1);
+ if (result)
+ {
+ strcpy (result, "c:\\gnupg");
+ strcat (result, SLDIR);
+ }
+ }
+#undef SLDIR
+ return result;
+}
+
+
+static void
+drop_locale_dir (char *locale_dir)
+{
+ free (locale_dir);
+}
+
+#endif /* HAVE_W32_SYSTEM */
+
+
+const char *gpg_strerror_sym (gpg_error_t err);
+const char *gpg_strsource_sym (gpg_error_t err);
+
+
+static int
+get_err_from_number (char *str, gpg_error_t *err)
+{
+ unsigned long nr;
+ char *tail;
+
+ gpg_err_set_errno (0);
+ nr = strtoul (str, &tail, 0);
+ if (errno)
+ return 0;
+
+ if (nr > UINT_MAX)
+ return 0;
+
+ if (*tail)
+ {
+ unsigned long cnr = strtoul (tail + 1, &tail, 0);
+ if (errno || *tail)
+ return 0;
+
+ if (nr >= GPG_ERR_SOURCE_DIM || cnr >= GPG_ERR_CODE_DIM)
+ return 0;
+
+ nr = gpg_err_make (nr, cnr);
+ }
+
+ *err = (unsigned int) nr;
+ return 1;
+}
+
+
+static int
+get_err_from_symbol_one (char *str, gpg_error_t *err,
+ int *have_source, int *have_code)
+{
+ static const char src_prefix[] = "GPG_ERR_SOURCE_";
+ static const char code_prefix[] = "GPG_ERR_";
+
+ if (!strncasecmp (src_prefix, str, sizeof (src_prefix) - 1))
+ {
+ gpg_err_source_t src;
+
+ if (*have_source)
+ return 0;
+ *have_source = 1;
+ str += sizeof (src_prefix) - 1;
+
+ for (src = 0; src < GPG_ERR_SOURCE_DIM; src++)
+ {
+ const char *src_sym;
+
+ src_sym = gpg_strsource_sym (src << GPG_ERR_SOURCE_SHIFT);
+ if (src_sym && !strcasecmp (str, src_sym + sizeof (src_prefix) - 1))
+ {
+ *err |= src << GPG_ERR_SOURCE_SHIFT;
+ return 1;
+ }
+ }
+ }
+ else if (!strncasecmp (code_prefix, str, sizeof (code_prefix) - 1))
+ {
+ gpg_err_code_t code;
+
+ if (*have_code)
+ return 0;
+ *have_code = 1;
+ str += sizeof (code_prefix) - 1;
+
+ for (code = 0; code < GPG_ERR_CODE_DIM; code++)
+ {
+ const char *code_sym = gpg_strerror_sym (code);
+ if (code_sym
+ && !strcasecmp (str, code_sym + sizeof (code_prefix) - 1))
+ {
+ *err |= code;
+ return 1;
+ }
+ }
+ }
+ return 0;
+}
+
+
+static int
+get_err_from_symbol (char *str, gpg_error_t *err)
+{
+ char *str2 = str;
+ int have_source = 0;
+ int have_code = 0;
+ int ret;
+ char *saved_pos = NULL;
+ char saved_char;
+
+ *err = 0;
+ while (*str2 && ((*str2 >= 'A' && *str2 <= 'Z')
+ || (*str2 >= '0' && *str2 <= '9')
+ || *str2 == '_'))
+ str2++;
+ if (*str2)
+ {
+ saved_pos = str2;
+ saved_char = *str2;
+ *str2 = '\0';
+ str2++;
+ }
+ else
+ str2 = NULL;
+
+ ret = get_err_from_symbol_one (str, err, &have_source, &have_code);
+ if (ret && str2)
+ ret = get_err_from_symbol_one (str2, err, &have_source, &have_code);
+
+ if (saved_pos)
+ *saved_pos = saved_char;
+ return ret;
+}
+
+
+static int
+get_err_from_str_one (char *str, gpg_error_t *err,
+ int *have_source, int *have_code)
+{
+ gpg_err_source_t src;
+ gpg_err_code_t code;
+
+ for (src = 0; src < GPG_ERR_SOURCE_DIM; src++)
+ {
+ const char *src_str = gpg_strsource (src << GPG_ERR_SOURCE_SHIFT);
+ if (src_str && !strcasecmp (str, src_str))
+ {
+ if (*have_source)
+ return 0;
+
+ *have_source = 1;
+ *err |= src << GPG_ERR_SOURCE_SHIFT;
+ return 1;
+ }
+ }
+
+ for (code = 0; code < GPG_ERR_CODE_DIM; code++)
+ {
+ const char *code_str = gpg_strerror (code);
+ if (code_str && !strcasecmp (str, code_str))
+ {
+ if (*have_code)
+ return 0;
+
+ *have_code = 1;
+ *err |= code;
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+
+static int
+get_err_from_str (char *str, gpg_error_t *err)
+{
+ char *str2 = str;
+ int have_source = 0;
+ int have_code = 0;
+ int ret;
+ char *saved_pos = NULL;
+ char saved_char;
+
+ *err = 0;
+ ret = get_err_from_str_one (str, err, &have_source, &have_code);
+ if (ret)
+ return ret;
+
+ while (*str2 && ((*str2 >= 'A' && *str2 <= 'Z')
+ || (*str2 >= 'a' && *str2 <= 'z')
+ || (*str2 >= '0' && *str2 <= '9')
+ || *str2 == '_'))
+ str2++;
+ if (*str2)
+ {
+ saved_pos = str2;
+ saved_char = *str2;
+ *((char *) str2) = '\0';
+ str2++;
+ while (*str2 && !((*str2 >= 'A' && *str2 <= 'Z')
+ || (*str2 >= 'a' && *str2 <= 'z')
+ || (*str2 >= '0' && *str2 <= '9')
+ || *str2 == '_'))
+ str2++;
+ }
+ else
+ str2 = NULL;
+
+ ret = get_err_from_str_one (str, err, &have_source, &have_code);
+ if (ret && str2)
+ ret = get_err_from_str_one (str2, err, &have_source, &have_code);
+
+ if (saved_pos)
+ *saved_pos = saved_char;
+ return ret;
+}
+
+
+
+int
+main (int argc, char *argv[])
+{
+ int i = 1;
+ int listmode = 0;
+ const char *source_sym;
+ const char *error_sym;
+ gpg_error_t err;
+
+#ifndef GPG_ERR_INITIALIZED
+ gpg_err_init ();
+#endif
+
+ i18n_init ();
+
+
+ if (argc == 1)
+ {
+ fprintf (stderr, _("Usage: %s GPG-ERROR [...]\n"),
+ strrchr (argv[0],'/')? (strrchr (argv[0], '/')+1): argv[0]);
+ exit (1);
+ }
+ else if (argc == 2 && !strcmp (argv[1], "--version"))
+ {
+ fputs ("gpg-error (" PACKAGE_NAME ") " PACKAGE_VERSION "\n", stdout);
+ exit (0);
+ }
+ else if (argc == 2 && !strcmp (argv[1], "--list"))
+ {
+ listmode = 1;
+ }
+
+
+ if (listmode)
+ {
+ for (i=0; i < GPG_ERR_SOURCE_DIM; i++)
+ {
+ /* We use error code 1 because gpg_err_make requires a
+ non-zero error code. */
+ err = gpg_err_make (i, 1);
+ err -= 1;
+ source_sym = gpg_strsource_sym (err);
+ if (source_sym)
+ printf ("%u = (%u, -) = (%s, -) = (%s, -)\n",
+ err, gpg_err_source (err),
+ source_sym, gpg_strsource (err));
+ }
+ for (i=0; i < GPG_ERR_CODE_DIM; i++)
+ {
+ err = gpg_err_make (GPG_ERR_SOURCE_UNKNOWN, i);
+ error_sym = gpg_strerror_sym (err);
+ if (error_sym)
+ printf ("%u = (-, %u) = (-, %s) = (-, %s)\n",
+ err, gpg_err_code (err),
+ error_sym, gpg_strerror (err));
+ }
+
+ i = argc; /* Don't run the usual stuff. */
+ }
+ while (i < argc)
+ {
+ if (get_err_from_number (argv[i], &err)
+ || get_err_from_symbol (argv[i], &err)
+ || get_err_from_str (argv[i], &err))
+ {
+ source_sym = gpg_strsource_sym (err);
+ error_sym = gpg_strerror_sym (err);
+
+ printf ("%u = (%u, %u) = (%s, %s) = (%s, %s)\n",
+ err, gpg_err_source (err), gpg_err_code (err),
+ source_sym ? source_sym : "-", error_sym ? error_sym : "-",
+ gpg_strsource (err), gpg_strerror (err));
+ }
+ else
+ fprintf (stderr, _("%s: warning: could not recognize %s\n"),
+ argv[0], argv[i]);
+ i++;
+ }
+
+ exit (0);
+}
diff --git a/src/gpg-error.def.in b/src/gpg-error.def.in
new file mode 100644
index 0000000..cbabd57
--- /dev/null
+++ b/src/gpg-error.def.in
@@ -0,0 +1,29 @@
+/* gpg-error.def.in - Exported symbols
+ * Needs to be processed by CPP.
+ */
+
+#include <config.h>
+
+EXPORTS
+ gpg_strerror @1
+ gpg_strerror_r @2
+ gpg_strsource @3
+ gpg_err_code_from_errno @4
+ gpg_err_code_to_errno @5
+ gpg_err_init @6
+ gpg_err_code_from_syserror @7
+ gpg_err_set_errno @8
+#ifdef HAVE_W32CE_SYSTEM
+ _gpg_w32ce_get_errno @9
+ _gpg_w32ce_strerror @10
+#endif
+#ifdef HAVE_W32_SYSTEM
+ _gpg_w32_bindtextdomain @11
+ _gpg_w32_textdomain @12
+ _gpg_w32_gettext @13
+ _gpg_w32_dgettext @14
+ _gpg_w32_dngettext @15
+ _gpg_w32_gettext_localename @16
+ _gpg_w32_gettext_use_utf8 @17
+#endif
+ gpg_err_deinit @18
diff --git a/src/gpg-error.h b/src/gpg-error.h
new file mode 100644
index 0000000..6a0f08b
--- /dev/null
+++ b/src/gpg-error.h
@@ -0,0 +1,678 @@
+/* Output of mkheader.awk. DO NOT EDIT. -*- buffer-read-only: t -*- */
+
+/* gpg-error.h - Public interface to libgpg-error.
+ Copyright (C) 2003, 2004, 2010 g10 Code GmbH
+
+ This file is part of libgpg-error.
+
+ libgpg-error 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 2.1 of
+ the License, or (at your option) any later version.
+
+ libgpg-error 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/>.
+ */
+
+
+#ifndef GPG_ERROR_H
+#define GPG_ERROR_H 1
+
+#include <stddef.h>
+
+#ifdef __GNUC__
+#define GPG_ERR_INLINE __inline__
+#elif __STDC_VERSION__ >= 199901L
+#define GPG_ERR_INLINE inline
+#else
+#ifndef GPG_ERR_INLINE
+#define GPG_ERR_INLINE
+#endif
+#endif
+
+
+#ifdef __cplusplus
+extern "C" {
+#if 0 /* just to make Emacs auto-indent happy */
+}
+#endif
+#endif /* __cplusplus */
+
+/* The GnuPG project consists of many components. Error codes are
+ exchanged between all components. The common error codes and their
+ user-presentable descriptions are kept into a shared library to
+ allow adding new error codes and components without recompiling any
+ of the other components. The interface will not change in a
+ backward incompatible way.
+
+ An error code together with an error source build up an error
+ value. As the error value is been passed from one component to
+ another, it preserver the information about the source and nature
+ of the error.
+
+ A component of the GnuPG project can define the following macros to
+ tune the behaviour of the library:
+
+ GPG_ERR_SOURCE_DEFAULT: Define to an error source of type
+ gpg_err_source_t to make that source the default for gpg_error().
+ Otherwise GPG_ERR_SOURCE_UNKNOWN is used as default.
+
+ GPG_ERR_ENABLE_GETTEXT_MACROS: Define to provide macros to map the
+ internal gettext API to standard names. This has only an effect on
+ Windows platforms. */
+
+
+/* The error source type gpg_err_source_t.
+
+ Where as the Poo out of a welle small
+ Taketh his firste springing and his sours.
+ --Chaucer. */
+
+/* Only use free slots, never change or reorder the existing
+ entries. */
+typedef enum
+ {
+ GPG_ERR_SOURCE_UNKNOWN = 0,
+ GPG_ERR_SOURCE_GCRYPT = 1,
+ GPG_ERR_SOURCE_GPG = 2,
+ GPG_ERR_SOURCE_GPGSM = 3,
+ GPG_ERR_SOURCE_GPGAGENT = 4,
+ GPG_ERR_SOURCE_PINENTRY = 5,
+ GPG_ERR_SOURCE_SCD = 6,
+ GPG_ERR_SOURCE_GPGME = 7,
+ GPG_ERR_SOURCE_KEYBOX = 8,
+ GPG_ERR_SOURCE_KSBA = 9,
+ GPG_ERR_SOURCE_DIRMNGR = 10,
+ GPG_ERR_SOURCE_GSTI = 11,
+ GPG_ERR_SOURCE_GPA = 12,
+ GPG_ERR_SOURCE_KLEO = 13,
+ GPG_ERR_SOURCE_G13 = 14,
+ GPG_ERR_SOURCE_ANY = 31,
+ GPG_ERR_SOURCE_USER_1 = 32,
+ GPG_ERR_SOURCE_USER_2 = 33,
+ GPG_ERR_SOURCE_USER_3 = 34,
+ GPG_ERR_SOURCE_USER_4 = 35,
+
+ /* This is one more than the largest allowed entry. */
+ GPG_ERR_SOURCE_DIM = 128
+ } gpg_err_source_t;
+
+
+/* The error code type gpg_err_code_t. */
+
+/* Only use free slots, never change or reorder the existing
+ entries. */
+typedef enum
+ {
+ GPG_ERR_NO_ERROR = 0,
+ GPG_ERR_GENERAL = 1,
+ GPG_ERR_UNKNOWN_PACKET = 2,
+ GPG_ERR_UNKNOWN_VERSION = 3,
+ GPG_ERR_PUBKEY_ALGO = 4,
+ GPG_ERR_DIGEST_ALGO = 5,
+ GPG_ERR_BAD_PUBKEY = 6,
+ GPG_ERR_BAD_SECKEY = 7,
+ GPG_ERR_BAD_SIGNATURE = 8,
+ GPG_ERR_NO_PUBKEY = 9,
+ GPG_ERR_CHECKSUM = 10,
+ GPG_ERR_BAD_PASSPHRASE = 11,
+ GPG_ERR_CIPHER_ALGO = 12,
+ GPG_ERR_KEYRING_OPEN = 13,
+ GPG_ERR_INV_PACKET = 14,
+ GPG_ERR_INV_ARMOR = 15,
+ GPG_ERR_NO_USER_ID = 16,
+ GPG_ERR_NO_SECKEY = 17,
+ GPG_ERR_WRONG_SECKEY = 18,
+ GPG_ERR_BAD_KEY = 19,
+ GPG_ERR_COMPR_ALGO = 20,
+ GPG_ERR_NO_PRIME = 21,
+ GPG_ERR_NO_ENCODING_METHOD = 22,
+ GPG_ERR_NO_ENCRYPTION_SCHEME = 23,
+ GPG_ERR_NO_SIGNATURE_SCHEME = 24,
+ GPG_ERR_INV_ATTR = 25,
+ GPG_ERR_NO_VALUE = 26,
+ GPG_ERR_NOT_FOUND = 27,
+ GPG_ERR_VALUE_NOT_FOUND = 28,
+ GPG_ERR_SYNTAX = 29,
+ GPG_ERR_BAD_MPI = 30,
+ GPG_ERR_INV_PASSPHRASE = 31,
+ GPG_ERR_SIG_CLASS = 32,
+ GPG_ERR_RESOURCE_LIMIT = 33,
+ GPG_ERR_INV_KEYRING = 34,
+ GPG_ERR_TRUSTDB = 35,
+ GPG_ERR_BAD_CERT = 36,
+ GPG_ERR_INV_USER_ID = 37,
+ GPG_ERR_UNEXPECTED = 38,
+ GPG_ERR_TIME_CONFLICT = 39,
+ GPG_ERR_KEYSERVER = 40,
+ GPG_ERR_WRONG_PUBKEY_ALGO = 41,
+ GPG_ERR_TRIBUTE_TO_D_A = 42,
+ GPG_ERR_WEAK_KEY = 43,
+ GPG_ERR_INV_KEYLEN = 44,
+ GPG_ERR_INV_ARG = 45,
+ GPG_ERR_BAD_URI = 46,
+ GPG_ERR_INV_URI = 47,
+ GPG_ERR_NETWORK = 48,
+ GPG_ERR_UNKNOWN_HOST = 49,
+ GPG_ERR_SELFTEST_FAILED = 50,
+ GPG_ERR_NOT_ENCRYPTED = 51,
+ GPG_ERR_NOT_PROCESSED = 52,
+ GPG_ERR_UNUSABLE_PUBKEY = 53,
+ GPG_ERR_UNUSABLE_SECKEY = 54,
+ GPG_ERR_INV_VALUE = 55,
+ GPG_ERR_BAD_CERT_CHAIN = 56,
+ GPG_ERR_MISSING_CERT = 57,
+ GPG_ERR_NO_DATA = 58,
+ GPG_ERR_BUG = 59,
+ GPG_ERR_NOT_SUPPORTED = 60,
+ GPG_ERR_INV_OP = 61,
+ GPG_ERR_TIMEOUT = 62,
+ GPG_ERR_INTERNAL = 63,
+ GPG_ERR_EOF_GCRYPT = 64,
+ GPG_ERR_INV_OBJ = 65,
+ GPG_ERR_TOO_SHORT = 66,
+ GPG_ERR_TOO_LARGE = 67,
+ GPG_ERR_NO_OBJ = 68,
+ GPG_ERR_NOT_IMPLEMENTED = 69,
+ GPG_ERR_CONFLICT = 70,
+ GPG_ERR_INV_CIPHER_MODE = 71,
+ GPG_ERR_INV_FLAG = 72,
+ GPG_ERR_INV_HANDLE = 73,
+ GPG_ERR_TRUNCATED = 74,
+ GPG_ERR_INCOMPLETE_LINE = 75,
+ GPG_ERR_INV_RESPONSE = 76,
+ GPG_ERR_NO_AGENT = 77,
+ GPG_ERR_AGENT = 78,
+ GPG_ERR_INV_DATA = 79,
+ GPG_ERR_ASSUAN_SERVER_FAULT = 80,
+ GPG_ERR_ASSUAN = 81,
+ GPG_ERR_INV_SESSION_KEY = 82,
+ GPG_ERR_INV_SEXP = 83,
+ GPG_ERR_UNSUPPORTED_ALGORITHM = 84,
+ GPG_ERR_NO_PIN_ENTRY = 85,
+ GPG_ERR_PIN_ENTRY = 86,
+ GPG_ERR_BAD_PIN = 87,
+ GPG_ERR_INV_NAME = 88,
+ GPG_ERR_BAD_DATA = 89,
+ GPG_ERR_INV_PARAMETER = 90,
+ GPG_ERR_WRONG_CARD = 91,
+ GPG_ERR_NO_DIRMNGR = 92,
+ GPG_ERR_DIRMNGR = 93,
+ GPG_ERR_CERT_REVOKED = 94,
+ GPG_ERR_NO_CRL_KNOWN = 95,
+ GPG_ERR_CRL_TOO_OLD = 96,
+ GPG_ERR_LINE_TOO_LONG = 97,
+ GPG_ERR_NOT_TRUSTED = 98,
+ GPG_ERR_CANCELED = 99,
+ GPG_ERR_BAD_CA_CERT = 100,
+ GPG_ERR_CERT_EXPIRED = 101,
+ GPG_ERR_CERT_TOO_YOUNG = 102,
+ GPG_ERR_UNSUPPORTED_CERT = 103,
+ GPG_ERR_UNKNOWN_SEXP = 104,
+ GPG_ERR_UNSUPPORTED_PROTECTION = 105,
+ GPG_ERR_CORRUPTED_PROTECTION = 106,
+ GPG_ERR_AMBIGUOUS_NAME = 107,
+ GPG_ERR_CARD = 108,
+ GPG_ERR_CARD_RESET = 109,
+ GPG_ERR_CARD_REMOVED = 110,
+ GPG_ERR_INV_CARD = 111,
+ GPG_ERR_CARD_NOT_PRESENT = 112,
+ GPG_ERR_NO_PKCS15_APP = 113,
+ GPG_ERR_NOT_CONFIRMED = 114,
+ GPG_ERR_CONFIGURATION = 115,
+ GPG_ERR_NO_POLICY_MATCH = 116,
+ GPG_ERR_INV_INDEX = 117,
+ GPG_ERR_INV_ID = 118,
+ GPG_ERR_NO_SCDAEMON = 119,
+ GPG_ERR_SCDAEMON = 120,
+ GPG_ERR_UNSUPPORTED_PROTOCOL = 121,
+ GPG_ERR_BAD_PIN_METHOD = 122,
+ GPG_ERR_CARD_NOT_INITIALIZED = 123,
+ GPG_ERR_UNSUPPORTED_OPERATION = 124,
+ GPG_ERR_WRONG_KEY_USAGE = 125,
+ GPG_ERR_NOTHING_FOUND = 126,
+ GPG_ERR_WRONG_BLOB_TYPE = 127,
+ GPG_ERR_MISSING_VALUE = 128,
+ GPG_ERR_HARDWARE = 129,
+ GPG_ERR_PIN_BLOCKED = 130,
+ GPG_ERR_USE_CONDITIONS = 131,
+ GPG_ERR_PIN_NOT_SYNCED = 132,
+ GPG_ERR_INV_CRL = 133,
+ GPG_ERR_BAD_BER = 134,
+ GPG_ERR_INV_BER = 135,
+ GPG_ERR_ELEMENT_NOT_FOUND = 136,
+ GPG_ERR_IDENTIFIER_NOT_FOUND = 137,
+ GPG_ERR_INV_TAG = 138,
+ GPG_ERR_INV_LENGTH = 139,
+ GPG_ERR_INV_KEYINFO = 140,
+ GPG_ERR_UNEXPECTED_TAG = 141,
+ GPG_ERR_NOT_DER_ENCODED = 142,
+ GPG_ERR_NO_CMS_OBJ = 143,
+ GPG_ERR_INV_CMS_OBJ = 144,
+ GPG_ERR_UNKNOWN_CMS_OBJ = 145,
+ GPG_ERR_UNSUPPORTED_CMS_OBJ = 146,
+ GPG_ERR_UNSUPPORTED_ENCODING = 147,
+ GPG_ERR_UNSUPPORTED_CMS_VERSION = 148,
+ GPG_ERR_UNKNOWN_ALGORITHM = 149,
+ GPG_ERR_INV_ENGINE = 150,
+ GPG_ERR_PUBKEY_NOT_TRUSTED = 151,
+ GPG_ERR_DECRYPT_FAILED = 152,
+ GPG_ERR_KEY_EXPIRED = 153,
+ GPG_ERR_SIG_EXPIRED = 154,
+ GPG_ERR_ENCODING_PROBLEM = 155,
+ GPG_ERR_INV_STATE = 156,
+ GPG_ERR_DUP_VALUE = 157,
+ GPG_ERR_MISSING_ACTION = 158,
+ GPG_ERR_MODULE_NOT_FOUND = 159,
+ GPG_ERR_INV_OID_STRING = 160,
+ GPG_ERR_INV_TIME = 161,
+ GPG_ERR_INV_CRL_OBJ = 162,
+ GPG_ERR_UNSUPPORTED_CRL_VERSION = 163,
+ GPG_ERR_INV_CERT_OBJ = 164,
+ GPG_ERR_UNKNOWN_NAME = 165,
+ GPG_ERR_LOCALE_PROBLEM = 166,
+ GPG_ERR_NOT_LOCKED = 167,
+ GPG_ERR_PROTOCOL_VIOLATION = 168,
+ GPG_ERR_INV_MAC = 169,
+ GPG_ERR_INV_REQUEST = 170,
+ GPG_ERR_UNKNOWN_EXTN = 171,
+ GPG_ERR_UNKNOWN_CRIT_EXTN = 172,
+ GPG_ERR_LOCKED = 173,
+ GPG_ERR_UNKNOWN_OPTION = 174,
+ GPG_ERR_UNKNOWN_COMMAND = 175,
+ GPG_ERR_NOT_OPERATIONAL = 176,
+ GPG_ERR_NO_PASSPHRASE = 177,
+ GPG_ERR_NO_PIN = 178,
+ GPG_ERR_NOT_ENABLED = 179,
+ GPG_ERR_NO_ENGINE = 180,
+ GPG_ERR_MISSING_KEY = 181,
+ GPG_ERR_TOO_MANY = 182,
+ GPG_ERR_LIMIT_REACHED = 183,
+ GPG_ERR_NOT_INITIALIZED = 184,
+ GPG_ERR_MISSING_ISSUER_CERT = 185,
+ GPG_ERR_FULLY_CANCELED = 198,
+ GPG_ERR_UNFINISHED = 199,
+ GPG_ERR_BUFFER_TOO_SHORT = 200,
+ GPG_ERR_SEXP_INV_LEN_SPEC = 201,
+ GPG_ERR_SEXP_STRING_TOO_LONG = 202,
+ GPG_ERR_SEXP_UNMATCHED_PAREN = 203,
+ GPG_ERR_SEXP_NOT_CANONICAL = 204,
+ GPG_ERR_SEXP_BAD_CHARACTER = 205,
+ GPG_ERR_SEXP_BAD_QUOTATION = 206,
+ GPG_ERR_SEXP_ZERO_PREFIX = 207,
+ GPG_ERR_SEXP_NESTED_DH = 208,
+ GPG_ERR_SEXP_UNMATCHED_DH = 209,
+ GPG_ERR_SEXP_UNEXPECTED_PUNC = 210,
+ GPG_ERR_SEXP_BAD_HEX_CHAR = 211,
+ GPG_ERR_SEXP_ODD_HEX_NUMBERS = 212,
+ GPG_ERR_SEXP_BAD_OCT_CHAR = 213,
+ GPG_ERR_ASS_GENERAL = 257,
+ GPG_ERR_ASS_ACCEPT_FAILED = 258,
+ GPG_ERR_ASS_CONNECT_FAILED = 259,
+ GPG_ERR_ASS_INV_RESPONSE = 260,
+ GPG_ERR_ASS_INV_VALUE = 261,
+ GPG_ERR_ASS_INCOMPLETE_LINE = 262,
+ GPG_ERR_ASS_LINE_TOO_LONG = 263,
+ GPG_ERR_ASS_NESTED_COMMANDS = 264,
+ GPG_ERR_ASS_NO_DATA_CB = 265,
+ GPG_ERR_ASS_NO_INQUIRE_CB = 266,
+ GPG_ERR_ASS_NOT_A_SERVER = 267,
+ GPG_ERR_ASS_NOT_A_CLIENT = 268,
+ GPG_ERR_ASS_SERVER_START = 269,
+ GPG_ERR_ASS_READ_ERROR = 270,
+ GPG_ERR_ASS_WRITE_ERROR = 271,
+ GPG_ERR_ASS_TOO_MUCH_DATA = 273,
+ GPG_ERR_ASS_UNEXPECTED_CMD = 274,
+ GPG_ERR_ASS_UNKNOWN_CMD = 275,
+ GPG_ERR_ASS_SYNTAX = 276,
+ GPG_ERR_ASS_CANCELED = 277,
+ GPG_ERR_ASS_NO_INPUT = 278,
+ GPG_ERR_ASS_NO_OUTPUT = 279,
+ GPG_ERR_ASS_PARAMETER = 280,
+ GPG_ERR_ASS_UNKNOWN_INQUIRE = 281,
+ GPG_ERR_USER_1 = 1024,
+ GPG_ERR_USER_2 = 1025,
+ GPG_ERR_USER_3 = 1026,
+ GPG_ERR_USER_4 = 1027,
+ GPG_ERR_USER_5 = 1028,
+ GPG_ERR_USER_6 = 1029,
+ GPG_ERR_USER_7 = 1030,
+ GPG_ERR_USER_8 = 1031,
+ GPG_ERR_USER_9 = 1032,
+ GPG_ERR_USER_10 = 1033,
+ GPG_ERR_USER_11 = 1034,
+ GPG_ERR_USER_12 = 1035,
+ GPG_ERR_USER_13 = 1036,
+ GPG_ERR_USER_14 = 1037,
+ GPG_ERR_USER_15 = 1038,
+ GPG_ERR_USER_16 = 1039,
+ GPG_ERR_MISSING_ERRNO = 16381,
+ GPG_ERR_UNKNOWN_ERRNO = 16382,
+ GPG_ERR_EOF = 16383,
+
+ /* The following error codes are used to map system errors. */
+#define GPG_ERR_SYSTEM_ERROR (1 << 15)
+ GPG_ERR_E2BIG = GPG_ERR_SYSTEM_ERROR | 0,
+ GPG_ERR_EACCES = GPG_ERR_SYSTEM_ERROR | 1,
+ GPG_ERR_EADDRINUSE = GPG_ERR_SYSTEM_ERROR | 2,
+ GPG_ERR_EADDRNOTAVAIL = GPG_ERR_SYSTEM_ERROR | 3,
+ GPG_ERR_EADV = GPG_ERR_SYSTEM_ERROR | 4,
+ GPG_ERR_EAFNOSUPPORT = GPG_ERR_SYSTEM_ERROR | 5,
+ GPG_ERR_EAGAIN = GPG_ERR_SYSTEM_ERROR | 6,
+ GPG_ERR_EALREADY = GPG_ERR_SYSTEM_ERROR | 7,
+ GPG_ERR_EAUTH = GPG_ERR_SYSTEM_ERROR | 8,
+ GPG_ERR_EBACKGROUND = GPG_ERR_SYSTEM_ERROR | 9,
+ GPG_ERR_EBADE = GPG_ERR_SYSTEM_ERROR | 10,
+ GPG_ERR_EBADF = GPG_ERR_SYSTEM_ERROR | 11,
+ GPG_ERR_EBADFD = GPG_ERR_SYSTEM_ERROR | 12,
+ GPG_ERR_EBADMSG = GPG_ERR_SYSTEM_ERROR | 13,
+ GPG_ERR_EBADR = GPG_ERR_SYSTEM_ERROR | 14,
+ GPG_ERR_EBADRPC = GPG_ERR_SYSTEM_ERROR | 15,
+ GPG_ERR_EBADRQC = GPG_ERR_SYSTEM_ERROR | 16,
+ GPG_ERR_EBADSLT = GPG_ERR_SYSTEM_ERROR | 17,
+ GPG_ERR_EBFONT = GPG_ERR_SYSTEM_ERROR | 18,
+ GPG_ERR_EBUSY = GPG_ERR_SYSTEM_ERROR | 19,
+ GPG_ERR_ECANCELED = GPG_ERR_SYSTEM_ERROR | 20,
+ GPG_ERR_ECHILD = GPG_ERR_SYSTEM_ERROR | 21,
+ GPG_ERR_ECHRNG = GPG_ERR_SYSTEM_ERROR | 22,
+ GPG_ERR_ECOMM = GPG_ERR_SYSTEM_ERROR | 23,
+ GPG_ERR_ECONNABORTED = GPG_ERR_SYSTEM_ERROR | 24,
+ GPG_ERR_ECONNREFUSED = GPG_ERR_SYSTEM_ERROR | 25,
+ GPG_ERR_ECONNRESET = GPG_ERR_SYSTEM_ERROR | 26,
+ GPG_ERR_ED = GPG_ERR_SYSTEM_ERROR | 27,
+ GPG_ERR_EDEADLK = GPG_ERR_SYSTEM_ERROR | 28,
+ GPG_ERR_EDEADLOCK = GPG_ERR_SYSTEM_ERROR | 29,
+ GPG_ERR_EDESTADDRREQ = GPG_ERR_SYSTEM_ERROR | 30,
+ GPG_ERR_EDIED = GPG_ERR_SYSTEM_ERROR | 31,
+ GPG_ERR_EDOM = GPG_ERR_SYSTEM_ERROR | 32,
+ GPG_ERR_EDOTDOT = GPG_ERR_SYSTEM_ERROR | 33,
+ GPG_ERR_EDQUOT = GPG_ERR_SYSTEM_ERROR | 34,
+ GPG_ERR_EEXIST = GPG_ERR_SYSTEM_ERROR | 35,
+ GPG_ERR_EFAULT = GPG_ERR_SYSTEM_ERROR | 36,
+ GPG_ERR_EFBIG = GPG_ERR_SYSTEM_ERROR | 37,
+ GPG_ERR_EFTYPE = GPG_ERR_SYSTEM_ERROR | 38,
+ GPG_ERR_EGRATUITOUS = GPG_ERR_SYSTEM_ERROR | 39,
+ GPG_ERR_EGREGIOUS = GPG_ERR_SYSTEM_ERROR | 40,
+ GPG_ERR_EHOSTDOWN = GPG_ERR_SYSTEM_ERROR | 41,
+ GPG_ERR_EHOSTUNREACH = GPG_ERR_SYSTEM_ERROR | 42,
+ GPG_ERR_EIDRM = GPG_ERR_SYSTEM_ERROR | 43,
+ GPG_ERR_EIEIO = GPG_ERR_SYSTEM_ERROR | 44,
+ GPG_ERR_EILSEQ = GPG_ERR_SYSTEM_ERROR | 45,
+ GPG_ERR_EINPROGRESS = GPG_ERR_SYSTEM_ERROR | 46,
+ GPG_ERR_EINTR = GPG_ERR_SYSTEM_ERROR | 47,
+ GPG_ERR_EINVAL = GPG_ERR_SYSTEM_ERROR | 48,
+ GPG_ERR_EIO = GPG_ERR_SYSTEM_ERROR | 49,
+ GPG_ERR_EISCONN = GPG_ERR_SYSTEM_ERROR | 50,
+ GPG_ERR_EISDIR = GPG_ERR_SYSTEM_ERROR | 51,
+ GPG_ERR_EISNAM = GPG_ERR_SYSTEM_ERROR | 52,
+ GPG_ERR_EL2HLT = GPG_ERR_SYSTEM_ERROR | 53,
+ GPG_ERR_EL2NSYNC = GPG_ERR_SYSTEM_ERROR | 54,
+ GPG_ERR_EL3HLT = GPG_ERR_SYSTEM_ERROR | 55,
+ GPG_ERR_EL3RST = GPG_ERR_SYSTEM_ERROR | 56,
+ GPG_ERR_ELIBACC = GPG_ERR_SYSTEM_ERROR | 57,
+ GPG_ERR_ELIBBAD = GPG_ERR_SYSTEM_ERROR | 58,
+ GPG_ERR_ELIBEXEC = GPG_ERR_SYSTEM_ERROR | 59,
+ GPG_ERR_ELIBMAX = GPG_ERR_SYSTEM_ERROR | 60,
+ GPG_ERR_ELIBSCN = GPG_ERR_SYSTEM_ERROR | 61,
+ GPG_ERR_ELNRNG = GPG_ERR_SYSTEM_ERROR | 62,
+ GPG_ERR_ELOOP = GPG_ERR_SYSTEM_ERROR | 63,
+ GPG_ERR_EMEDIUMTYPE = GPG_ERR_SYSTEM_ERROR | 64,
+ GPG_ERR_EMFILE = GPG_ERR_SYSTEM_ERROR | 65,
+ GPG_ERR_EMLINK = GPG_ERR_SYSTEM_ERROR | 66,
+ GPG_ERR_EMSGSIZE = GPG_ERR_SYSTEM_ERROR | 67,
+ GPG_ERR_EMULTIHOP = GPG_ERR_SYSTEM_ERROR | 68,
+ GPG_ERR_ENAMETOOLONG = GPG_ERR_SYSTEM_ERROR | 69,
+ GPG_ERR_ENAVAIL = GPG_ERR_SYSTEM_ERROR | 70,
+ GPG_ERR_ENEEDAUTH = GPG_ERR_SYSTEM_ERROR | 71,
+ GPG_ERR_ENETDOWN = GPG_ERR_SYSTEM_ERROR | 72,
+ GPG_ERR_ENETRESET = GPG_ERR_SYSTEM_ERROR | 73,
+ GPG_ERR_ENETUNREACH = GPG_ERR_SYSTEM_ERROR | 74,
+ GPG_ERR_ENFILE = GPG_ERR_SYSTEM_ERROR | 75,
+ GPG_ERR_ENOANO = GPG_ERR_SYSTEM_ERROR | 76,
+ GPG_ERR_ENOBUFS = GPG_ERR_SYSTEM_ERROR | 77,
+ GPG_ERR_ENOCSI = GPG_ERR_SYSTEM_ERROR | 78,
+ GPG_ERR_ENODATA = GPG_ERR_SYSTEM_ERROR | 79,
+ GPG_ERR_ENODEV = GPG_ERR_SYSTEM_ERROR | 80,
+ GPG_ERR_ENOENT = GPG_ERR_SYSTEM_ERROR | 81,
+ GPG_ERR_ENOEXEC = GPG_ERR_SYSTEM_ERROR | 82,
+ GPG_ERR_ENOLCK = GPG_ERR_SYSTEM_ERROR | 83,
+ GPG_ERR_ENOLINK = GPG_ERR_SYSTEM_ERROR | 84,
+ GPG_ERR_ENOMEDIUM = GPG_ERR_SYSTEM_ERROR | 85,
+ GPG_ERR_ENOMEM = GPG_ERR_SYSTEM_ERROR | 86,
+ GPG_ERR_ENOMSG = GPG_ERR_SYSTEM_ERROR | 87,
+ GPG_ERR_ENONET = GPG_ERR_SYSTEM_ERROR | 88,
+ GPG_ERR_ENOPKG = GPG_ERR_SYSTEM_ERROR | 89,
+ GPG_ERR_ENOPROTOOPT = GPG_ERR_SYSTEM_ERROR | 90,
+ GPG_ERR_ENOSPC = GPG_ERR_SYSTEM_ERROR | 91,
+ GPG_ERR_ENOSR = GPG_ERR_SYSTEM_ERROR | 92,
+ GPG_ERR_ENOSTR = GPG_ERR_SYSTEM_ERROR | 93,
+ GPG_ERR_ENOSYS = GPG_ERR_SYSTEM_ERROR | 94,
+ GPG_ERR_ENOTBLK = GPG_ERR_SYSTEM_ERROR | 95,
+ GPG_ERR_ENOTCONN = GPG_ERR_SYSTEM_ERROR | 96,
+ GPG_ERR_ENOTDIR = GPG_ERR_SYSTEM_ERROR | 97,
+ GPG_ERR_ENOTEMPTY = GPG_ERR_SYSTEM_ERROR | 98,
+ GPG_ERR_ENOTNAM = GPG_ERR_SYSTEM_ERROR | 99,
+ GPG_ERR_ENOTSOCK = GPG_ERR_SYSTEM_ERROR | 100,
+ GPG_ERR_ENOTSUP = GPG_ERR_SYSTEM_ERROR | 101,
+ GPG_ERR_ENOTTY = GPG_ERR_SYSTEM_ERROR | 102,
+ GPG_ERR_ENOTUNIQ = GPG_ERR_SYSTEM_ERROR | 103,
+ GPG_ERR_ENXIO = GPG_ERR_SYSTEM_ERROR | 104,
+ GPG_ERR_EOPNOTSUPP = GPG_ERR_SYSTEM_ERROR | 105,
+ GPG_ERR_EOVERFLOW = GPG_ERR_SYSTEM_ERROR | 106,
+ GPG_ERR_EPERM = GPG_ERR_SYSTEM_ERROR | 107,
+ GPG_ERR_EPFNOSUPPORT = GPG_ERR_SYSTEM_ERROR | 108,
+ GPG_ERR_EPIPE = GPG_ERR_SYSTEM_ERROR | 109,
+ GPG_ERR_EPROCLIM = GPG_ERR_SYSTEM_ERROR | 110,
+ GPG_ERR_EPROCUNAVAIL = GPG_ERR_SYSTEM_ERROR | 111,
+ GPG_ERR_EPROGMISMATCH = GPG_ERR_SYSTEM_ERROR | 112,
+ GPG_ERR_EPROGUNAVAIL = GPG_ERR_SYSTEM_ERROR | 113,
+ GPG_ERR_EPROTO = GPG_ERR_SYSTEM_ERROR | 114,
+ GPG_ERR_EPROTONOSUPPORT = GPG_ERR_SYSTEM_ERROR | 115,
+ GPG_ERR_EPROTOTYPE = GPG_ERR_SYSTEM_ERROR | 116,
+ GPG_ERR_ERANGE = GPG_ERR_SYSTEM_ERROR | 117,
+ GPG_ERR_EREMCHG = GPG_ERR_SYSTEM_ERROR | 118,
+ GPG_ERR_EREMOTE = GPG_ERR_SYSTEM_ERROR | 119,
+ GPG_ERR_EREMOTEIO = GPG_ERR_SYSTEM_ERROR | 120,
+ GPG_ERR_ERESTART = GPG_ERR_SYSTEM_ERROR | 121,
+ GPG_ERR_EROFS = GPG_ERR_SYSTEM_ERROR | 122,
+ GPG_ERR_ERPCMISMATCH = GPG_ERR_SYSTEM_ERROR | 123,
+ GPG_ERR_ESHUTDOWN = GPG_ERR_SYSTEM_ERROR | 124,
+ GPG_ERR_ESOCKTNOSUPPORT = GPG_ERR_SYSTEM_ERROR | 125,
+ GPG_ERR_ESPIPE = GPG_ERR_SYSTEM_ERROR | 126,
+ GPG_ERR_ESRCH = GPG_ERR_SYSTEM_ERROR | 127,
+ GPG_ERR_ESRMNT = GPG_ERR_SYSTEM_ERROR | 128,
+ GPG_ERR_ESTALE = GPG_ERR_SYSTEM_ERROR | 129,
+ GPG_ERR_ESTRPIPE = GPG_ERR_SYSTEM_ERROR | 130,
+ GPG_ERR_ETIME = GPG_ERR_SYSTEM_ERROR | 131,
+ GPG_ERR_ETIMEDOUT = GPG_ERR_SYSTEM_ERROR | 132,
+ GPG_ERR_ETOOMANYREFS = GPG_ERR_SYSTEM_ERROR | 133,
+ GPG_ERR_ETXTBSY = GPG_ERR_SYSTEM_ERROR | 134,
+ GPG_ERR_EUCLEAN = GPG_ERR_SYSTEM_ERROR | 135,
+ GPG_ERR_EUNATCH = GPG_ERR_SYSTEM_ERROR | 136,
+ GPG_ERR_EUSERS = GPG_ERR_SYSTEM_ERROR | 137,
+ GPG_ERR_EWOULDBLOCK = GPG_ERR_SYSTEM_ERROR | 138,
+ GPG_ERR_EXDEV = GPG_ERR_SYSTEM_ERROR | 139,
+ GPG_ERR_EXFULL = GPG_ERR_SYSTEM_ERROR | 140,
+
+ /* This is one more than the largest allowed entry. */
+ GPG_ERR_CODE_DIM = 65536
+ } gpg_err_code_t;
+
+
+/* The error value type gpg_error_t. */
+
+/* We would really like to use bit-fields in a struct, but using
+ structs as return values can cause binary compatibility issues, in
+ particular if you want to do it effeciently (also see
+ -freg-struct-return option to GCC). */
+typedef unsigned int gpg_error_t;
+
+/* We use the lowest 16 bits of gpg_error_t for error codes. The 16th
+ bit indicates system errors. */
+#define GPG_ERR_CODE_MASK (GPG_ERR_CODE_DIM - 1)
+
+/* Bits 17 to 24 are reserved. */
+
+/* We use the upper 7 bits of gpg_error_t for error sources. */
+#define GPG_ERR_SOURCE_MASK (GPG_ERR_SOURCE_DIM - 1)
+#define GPG_ERR_SOURCE_SHIFT 24
+
+/* The highest bit is reserved. It shouldn't be used to prevent
+ potential negative numbers when transmitting error values as
+ text. */
+
+
+/* GCC feature test. */
+#undef _GPG_ERR_HAVE_CONSTRUCTOR
+#if __GNUC__
+#define _GPG_ERR_GCC_VERSION (__GNUC__ * 10000 \
+ + __GNUC_MINOR__ * 100 \
+ + __GNUC_PATCHLEVEL__)
+
+#if _GPG_ERR_GCC_VERSION > 30100
+#define _GPG_ERR_CONSTRUCTOR __attribute__ ((__constructor__))
+#define _GPG_ERR_HAVE_CONSTRUCTOR
+#endif
+#endif
+
+#ifndef _GPG_ERR_CONSTRUCTOR
+#define _GPG_ERR_CONSTRUCTOR
+#endif
+
+
+/* Initialization function. */
+
+/* Initialize the library. This function should be run early. */
+gpg_error_t gpg_err_init (void) _GPG_ERR_CONSTRUCTOR;
+
+/* If this is defined, the library is already initialized by the
+ constructor and does not need to be initialized explicitely. */
+#undef GPG_ERR_INITIALIZED
+#ifdef _GPG_ERR_HAVE_CONSTRUCTOR
+#define GPG_ERR_INITIALIZED 1
+#endif
+
+/* See the source on how to use the deinit function; it is usually not
+ required. */
+void gpg_err_deinit (int mode);
+
+
+/* Constructor and accessor functions. */
+
+/* Construct an error value from an error code and source. Within a
+ subsystem, use gpg_error. */
+static GPG_ERR_INLINE gpg_error_t
+gpg_err_make (gpg_err_source_t source, gpg_err_code_t code)
+{
+ return code == GPG_ERR_NO_ERROR ? GPG_ERR_NO_ERROR
+ : (((source & GPG_ERR_SOURCE_MASK) << GPG_ERR_SOURCE_SHIFT)
+ | (code & GPG_ERR_CODE_MASK));
+}
+
+
+/* The user should define GPG_ERR_SOURCE_DEFAULT before including this
+ file to specify a default source for gpg_error. */
+#ifndef GPG_ERR_SOURCE_DEFAULT
+#define GPG_ERR_SOURCE_DEFAULT GPG_ERR_SOURCE_UNKNOWN
+#endif
+
+static GPG_ERR_INLINE gpg_error_t
+gpg_error (gpg_err_code_t code)
+{
+ return gpg_err_make (GPG_ERR_SOURCE_DEFAULT, code);
+}
+
+
+/* Retrieve the error code from an error value. */
+static GPG_ERR_INLINE gpg_err_code_t
+gpg_err_code (gpg_error_t err)
+{
+ return (gpg_err_code_t) (err & GPG_ERR_CODE_MASK);
+}
+
+
+/* Retrieve the error source from an error value. */
+static GPG_ERR_INLINE gpg_err_source_t
+gpg_err_source (gpg_error_t err)
+{
+ return (gpg_err_source_t) ((err >> GPG_ERR_SOURCE_SHIFT)
+ & GPG_ERR_SOURCE_MASK);
+}
+
+
+/* String functions. */
+
+/* Return a pointer to a string containing a description of the error
+ code in the error value ERR. This function is not thread-safe. */
+const char *gpg_strerror (gpg_error_t err);
+
+/* Return the error string for ERR in the user-supplied buffer BUF of
+ size BUFLEN. This function is, in contrast to gpg_strerror,
+ thread-safe if a thread-safe strerror_r() function is provided by
+ the system. If the function succeeds, 0 is returned and BUF
+ contains the string describing the error. If the buffer was not
+ large enough, ERANGE is returned and BUF contains as much of the
+ beginning of the error string as fits into the buffer. */
+int gpg_strerror_r (gpg_error_t err, char *buf, size_t buflen);
+
+/* Return a pointer to a string containing a description of the error
+ source in the error value ERR. */
+const char *gpg_strsource (gpg_error_t err);
+
+
+/* Mapping of system errors (errno). */
+
+/* Retrieve the error code for the system error ERR. This returns
+ GPG_ERR_UNKNOWN_ERRNO if the system error is not mapped (report
+ this). */
+gpg_err_code_t gpg_err_code_from_errno (int err);
+
+
+/* Retrieve the system error for the error code CODE. This returns 0
+ if CODE is not a system error code. */
+int gpg_err_code_to_errno (gpg_err_code_t code);
+
+
+/* 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. */
+gpg_err_code_t gpg_err_code_from_syserror (void);
+
+
+/* Set the ERRNO variable. This function is the preferred way to set
+ ERRNO due to peculiarities on WindowsCE. */
+void gpg_err_set_errno (int err);
+
+
+/* Self-documenting convenience functions. */
+
+static GPG_ERR_INLINE gpg_error_t
+gpg_err_make_from_errno (gpg_err_source_t source, int err)
+{
+ return gpg_err_make (source, gpg_err_code_from_errno (err));
+}
+
+
+static GPG_ERR_INLINE gpg_error_t
+gpg_error_from_errno (int err)
+{
+ return gpg_error (gpg_err_code_from_errno (err));
+}
+
+static GPG_ERR_INLINE gpg_error_t
+gpg_error_from_syserror (void)
+{
+ return gpg_error (gpg_err_code_from_syserror ());
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* GPG_ERROR_H */
diff --git a/src/gpg-error.h.in b/src/gpg-error.h.in
new file mode 100644
index 0000000..ae1be21
--- /dev/null
+++ b/src/gpg-error.h.in
@@ -0,0 +1,274 @@
+/* gpg-error.h - Public interface to libgpg-error.
+ Copyright (C) 2003, 2004, 2010 g10 Code GmbH
+
+ This file is part of libgpg-error.
+
+ libgpg-error 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 2.1 of
+ the License, or (at your option) any later version.
+
+ libgpg-error 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/>.
+ */
+
+
+#ifndef GPG_ERROR_H
+#define GPG_ERROR_H 1
+
+#include <stddef.h>
+
+#ifdef __GNUC__
+#define GPG_ERR_INLINE __inline__
+#elif __STDC_VERSION__ >= 199901L
+#define GPG_ERR_INLINE inline
+#else
+#ifndef GPG_ERR_INLINE
+#define GPG_ERR_INLINE
+#endif
+#endif
+
+
+#ifdef __cplusplus
+extern "C" {
+#if 0 /* just to make Emacs auto-indent happy */
+}
+#endif
+#endif /* __cplusplus */
+
+/* The GnuPG project consists of many components. Error codes are
+ exchanged between all components. The common error codes and their
+ user-presentable descriptions are kept into a shared library to
+ allow adding new error codes and components without recompiling any
+ of the other components. The interface will not change in a
+ backward incompatible way.
+
+ An error code together with an error source build up an error
+ value. As the error value is been passed from one component to
+ another, it preserver the information about the source and nature
+ of the error.
+
+ A component of the GnuPG project can define the following macros to
+ tune the behaviour of the library:
+
+ GPG_ERR_SOURCE_DEFAULT: Define to an error source of type
+ gpg_err_source_t to make that source the default for gpg_error().
+ Otherwise GPG_ERR_SOURCE_UNKNOWN is used as default.
+
+ GPG_ERR_ENABLE_GETTEXT_MACROS: Define to provide macros to map the
+ internal gettext API to standard names. This has only an effect on
+ Windows platforms. */
+
+
+/* The error source type gpg_err_source_t.
+
+ Where as the Poo out of a welle small
+ Taketh his firste springing and his sours.
+ --Chaucer. */
+
+/* Only use free slots, never change or reorder the existing
+ entries. */
+typedef enum
+ {
+@include err-sources.h.in
+
+ /* This is one more than the largest allowed entry. */
+ GPG_ERR_SOURCE_DIM = 128
+ } gpg_err_source_t;
+
+
+/* The error code type gpg_err_code_t. */
+
+/* Only use free slots, never change or reorder the existing
+ entries. */
+typedef enum
+ {
+@include err-codes.h.in
+
+ /* The following error codes are used to map system errors. */
+#define GPG_ERR_SYSTEM_ERROR (1 << 15)
+@include errnos.in
+
+ /* This is one more than the largest allowed entry. */
+ GPG_ERR_CODE_DIM = 65536
+ } gpg_err_code_t;
+
+
+/* The error value type gpg_error_t. */
+
+/* We would really like to use bit-fields in a struct, but using
+ structs as return values can cause binary compatibility issues, in
+ particular if you want to do it effeciently (also see
+ -freg-struct-return option to GCC). */
+typedef unsigned int gpg_error_t;
+
+/* We use the lowest 16 bits of gpg_error_t for error codes. The 16th
+ bit indicates system errors. */
+#define GPG_ERR_CODE_MASK (GPG_ERR_CODE_DIM - 1)
+
+/* Bits 17 to 24 are reserved. */
+
+/* We use the upper 7 bits of gpg_error_t for error sources. */
+#define GPG_ERR_SOURCE_MASK (GPG_ERR_SOURCE_DIM - 1)
+#define GPG_ERR_SOURCE_SHIFT 24
+
+/* The highest bit is reserved. It shouldn't be used to prevent
+ potential negative numbers when transmitting error values as
+ text. */
+
+
+/* GCC feature test. */
+#undef _GPG_ERR_HAVE_CONSTRUCTOR
+#if __GNUC__
+#define _GPG_ERR_GCC_VERSION (__GNUC__ * 10000 \
+ + __GNUC_MINOR__ * 100 \
+ + __GNUC_PATCHLEVEL__)
+
+#if _GPG_ERR_GCC_VERSION > 30100
+#define _GPG_ERR_CONSTRUCTOR __attribute__ ((__constructor__))
+#define _GPG_ERR_HAVE_CONSTRUCTOR
+#endif
+#endif
+
+#ifndef _GPG_ERR_CONSTRUCTOR
+#define _GPG_ERR_CONSTRUCTOR
+#endif
+
+
+/* Initialization function. */
+
+/* Initialize the library. This function should be run early. */
+gpg_error_t gpg_err_init (void) _GPG_ERR_CONSTRUCTOR;
+
+/* If this is defined, the library is already initialized by the
+ constructor and does not need to be initialized explicitely. */
+#undef GPG_ERR_INITIALIZED
+#ifdef _GPG_ERR_HAVE_CONSTRUCTOR
+#define GPG_ERR_INITIALIZED 1
+#endif
+
+/* See the source on how to use the deinit function; it is usually not
+ required. */
+void gpg_err_deinit (int mode);
+
+
+/* Constructor and accessor functions. */
+
+/* Construct an error value from an error code and source. Within a
+ subsystem, use gpg_error. */
+static GPG_ERR_INLINE gpg_error_t
+gpg_err_make (gpg_err_source_t source, gpg_err_code_t code)
+{
+ return code == GPG_ERR_NO_ERROR ? GPG_ERR_NO_ERROR
+ : (((source & GPG_ERR_SOURCE_MASK) << GPG_ERR_SOURCE_SHIFT)
+ | (code & GPG_ERR_CODE_MASK));
+}
+
+
+/* The user should define GPG_ERR_SOURCE_DEFAULT before including this
+ file to specify a default source for gpg_error. */
+#ifndef GPG_ERR_SOURCE_DEFAULT
+#define GPG_ERR_SOURCE_DEFAULT GPG_ERR_SOURCE_UNKNOWN
+#endif
+
+static GPG_ERR_INLINE gpg_error_t
+gpg_error (gpg_err_code_t code)
+{
+ return gpg_err_make (GPG_ERR_SOURCE_DEFAULT, code);
+}
+
+
+/* Retrieve the error code from an error value. */
+static GPG_ERR_INLINE gpg_err_code_t
+gpg_err_code (gpg_error_t err)
+{
+ return (gpg_err_code_t) (err & GPG_ERR_CODE_MASK);
+}
+
+
+/* Retrieve the error source from an error value. */
+static GPG_ERR_INLINE gpg_err_source_t
+gpg_err_source (gpg_error_t err)
+{
+ return (gpg_err_source_t) ((err >> GPG_ERR_SOURCE_SHIFT)
+ & GPG_ERR_SOURCE_MASK);
+}
+
+
+/* String functions. */
+
+/* Return a pointer to a string containing a description of the error
+ code in the error value ERR. This function is not thread-safe. */
+const char *gpg_strerror (gpg_error_t err);
+
+/* Return the error string for ERR in the user-supplied buffer BUF of
+ size BUFLEN. This function is, in contrast to gpg_strerror,
+ thread-safe if a thread-safe strerror_r() function is provided by
+ the system. If the function succeeds, 0 is returned and BUF
+ contains the string describing the error. If the buffer was not
+ large enough, ERANGE is returned and BUF contains as much of the
+ beginning of the error string as fits into the buffer. */
+int gpg_strerror_r (gpg_error_t err, char *buf, size_t buflen);
+
+/* Return a pointer to a string containing a description of the error
+ source in the error value ERR. */
+const char *gpg_strsource (gpg_error_t err);
+
+
+/* Mapping of system errors (errno). */
+
+/* Retrieve the error code for the system error ERR. This returns
+ GPG_ERR_UNKNOWN_ERRNO if the system error is not mapped (report
+ this). */
+gpg_err_code_t gpg_err_code_from_errno (int err);
+
+
+/* Retrieve the system error for the error code CODE. This returns 0
+ if CODE is not a system error code. */
+int gpg_err_code_to_errno (gpg_err_code_t code);
+
+
+/* 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. */
+gpg_err_code_t gpg_err_code_from_syserror (void);
+
+
+/* Set the ERRNO variable. This function is the preferred way to set
+ ERRNO due to peculiarities on WindowsCE. */
+void gpg_err_set_errno (int err);
+
+@include extra-h.in
+
+/* Self-documenting convenience functions. */
+
+static GPG_ERR_INLINE gpg_error_t
+gpg_err_make_from_errno (gpg_err_source_t source, int err)
+{
+ return gpg_err_make (source, gpg_err_code_from_errno (err));
+}
+
+
+static GPG_ERR_INLINE gpg_error_t
+gpg_error_from_errno (int err)
+{
+ return gpg_error (gpg_err_code_from_errno (err));
+}
+
+static GPG_ERR_INLINE gpg_error_t
+gpg_error_from_syserror (void)
+{
+ return gpg_error (gpg_err_code_from_syserror ());
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* GPG_ERROR_H */
diff --git a/src/gpg-error.m4 b/src/gpg-error.m4
new file mode 100644
index 0000000..9d96d16
--- /dev/null
+++ b/src/gpg-error.m4
@@ -0,0 +1,65 @@
+# gpg-error.m4 - autoconf macro to detect libgpg-error.
+# Copyright (C) 2002, 2003, 2004 g10 Code GmbH
+#
+# This file is free software; as a special exception the author gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved.
+#
+# 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.
+
+dnl AM_PATH_GPG_ERROR([MINIMUM-VERSION,
+dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
+dnl Test for libgpg-error and define GPG_ERROR_CFLAGS and GPG_ERROR_LIBS
+dnl
+AC_DEFUN([AM_PATH_GPG_ERROR],
+[ AC_ARG_WITH(gpg-error-prefix,
+ AC_HELP_STRING([--with-gpg-error-prefix=PFX],
+ [prefix where GPG Error is installed (optional)]),
+ gpg_error_config_prefix="$withval", gpg_error_config_prefix="")
+ if test x$gpg_error_config_prefix != x ; then
+ if test x${GPG_ERROR_CONFIG+set} != xset ; then
+ GPG_ERROR_CONFIG=$gpg_error_config_prefix/bin/gpg-error-config
+ fi
+ fi
+
+ AC_PATH_PROG(GPG_ERROR_CONFIG, gpg-error-config, no)
+ min_gpg_error_version=ifelse([$1], ,0.0,$1)
+ AC_MSG_CHECKING(for GPG Error - version >= $min_gpg_error_version)
+ ok=no
+ if test "$GPG_ERROR_CONFIG" != "no" ; then
+ req_major=`echo $min_gpg_error_version | \
+ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
+ req_minor=`echo $min_gpg_error_version | \
+ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
+ gpg_error_config_version=`$GPG_ERROR_CONFIG $gpg_error_config_args --version`
+ major=`echo $gpg_error_config_version | \
+ sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
+ minor=`echo $gpg_error_config_version | \
+ sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
+ if test "$major" -gt "$req_major"; then
+ ok=yes
+ else
+ if test "$major" -eq "$req_major"; then
+ if test "$minor" -ge "$req_minor"; then
+ ok=yes
+ fi
+ fi
+ fi
+ fi
+ if test $ok = yes; then
+ GPG_ERROR_CFLAGS=`$GPG_ERROR_CONFIG $gpg_error_config_args --cflags`
+ GPG_ERROR_LIBS=`$GPG_ERROR_CONFIG $gpg_error_config_args --libs`
+ AC_MSG_RESULT([yes ($gpg_error_config_version)])
+ ifelse([$2], , :, [$2])
+ else
+ GPG_ERROR_CFLAGS=""
+ GPG_ERROR_LIBS=""
+ AC_MSG_RESULT(no)
+ ifelse([$3], , :, [$3])
+ fi
+ AC_SUBST(GPG_ERROR_CFLAGS)
+ AC_SUBST(GPG_ERROR_LIBS)
+])
+
diff --git a/src/init.c b/src/init.c
new file mode 100644
index 0000000..91abcb0
--- /dev/null
+++ b/src/init.c
@@ -0,0 +1,425 @@
+/* init.c - Initialize the GnuPG error library.
+ Copyright (C) 2005, 2010 g10 Code GmbH
+
+ This file is part of libgpg-error.
+
+ libgpg-error 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 2.1 of
+ the License, or (at your option) any later version.
+
+ libgpg-error 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/>.
+ */
+
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+
+#include <gpg-error.h>
+
+#include "gettext.h"
+#include "init.h"
+
+#ifdef HAVE_W32CE_SYSTEM
+# include "mkw32errmap.map.c" /* Generated map_w32codes () */
+#endif
+
+
+/* Locale directory support. */
+
+#if HAVE_W32_SYSTEM
+
+#include <windows.h>
+
+static int tls_index = TLS_OUT_OF_INDEXES; /* Index for the TLS functions. */
+
+static char *get_locale_dir (void);
+static void drop_locale_dir (char *locale_dir);
+
+#else /*!HAVE_W32_SYSTEM*/
+
+#define get_locale_dir() LOCALEDIR
+#define drop_locale_dir(dir)
+
+#endif /*!HAVE_W32_SYSTEM*/
+
+
+static void
+real_init (void)
+{
+#ifdef ENABLE_NLS
+ char *locale_dir;
+
+ /* We only have to bind our locale directory to our text domain. */
+ locale_dir = get_locale_dir ();
+ if (locale_dir)
+ {
+ bindtextdomain (PACKAGE, locale_dir);
+ drop_locale_dir (locale_dir);
+ }
+#endif
+}
+
+/* Initialize the library. This function should be run early. */
+gpg_error_t
+gpg_err_init (void)
+{
+#ifdef HAVE_W32_SYSTEM
+# ifdef DLL_EXPORT
+ /* We always have a constructor and thus this function is called
+ automatically. Due to the way the C init code of mingw works,
+ the constructors are called before our DllMain function is
+ called. The problem with that is that the TLS has not been setup
+ and w32-gettext.c requires TLS. To solve this we do nothing here
+ but call the actual init code from our DllMain. */
+# else /*!DLL_EXPORT*/
+ /* Note that if the TLS is actually used, we can't release the TLS
+ as there is no way to know when a thread terminates (i.e. no
+ thread-specific-atexit). You are really better off to use the
+ DLL! */
+ if (tls_index == TLS_OUT_OF_INDEXES)
+ {
+ tls_index = TlsAlloc ();
+ if (tls_index == TLS_OUT_OF_INDEXES)
+ {
+ /* No way to continue - commit suicide. */
+ abort ();
+ }
+ _gpg_w32__init_gettext_module ();
+ real_init ();
+ }
+# endif /*!DLL_EXPORT*/
+#else
+ real_init ();
+#endif
+ return 0;
+}
+
+
+/* Deinitialize libgpg-error. This function is only used in special
+ circumstances. No gpg-error function should be used after this
+ function has been called. A value of 0 passed for MODE
+ deinitializes the entire libgpg-error, a value of 1 releases
+ resources allocated for the current thread and only that thread may
+ not anymore access libgpg-error after such a call. Under Windows
+ this function may be called from the DllMain function of a DLL
+ which statically links to libgpg-error. */
+void
+gpg_err_deinit (int mode)
+{
+#if defined (HAVE_W32_SYSTEM) && !defined(DLL_EXPORT)
+ struct tls_space_s *tls;
+
+ tls = TlsGetValue (tls_index);
+ if (tls)
+ {
+ TlsSetValue (tls_index, NULL);
+ LocalFree (tls);
+ }
+
+ if (mode == 0)
+ {
+ TlsFree (tls_index);
+ tls_index = TLS_OUT_OF_INDEXES;
+ }
+#else
+ (void)mode;
+#endif
+}
+
+
+
+#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 on
+ failure. Caller may use GetLastError to get the actual error
+ number. The result of calling this function with STRING set to
+ NULL is not defined. */
+static char *
+wchar_to_utf8 (const wchar_t *string)
+{
+ int n;
+ char *result;
+
+ /* Note, that CP_UTF8 is not defined in Windows versions earlier
+ than NT. */
+ n = WideCharToMultiByte (CP_UTF8, 0, string, -1, NULL, 0, NULL, NULL);
+ if (n < 0)
+ return NULL;
+
+ result = malloc (n+1);
+ if (result)
+ {
+ n = WideCharToMultiByte (CP_UTF8, 0, string, -1, result, n, NULL, NULL);
+ if (n < 0)
+ {
+ free (result);
+ 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 on
+ failure. Caller may use GetLastError to get the actual error
+ number. The result of calling this function with STRING set to
+ NULL is not defined. */
+static wchar_t *
+utf8_to_wchar (const char *string)
+{
+ int n;
+ wchar_t *result;
+
+ n = MultiByteToWideChar (CP_UTF8, 0, string, -1, NULL, 0);
+ if (n < 0)
+ return NULL;
+
+ result = malloc ((n+1) * sizeof *result);
+ if (result)
+ {
+ n = MultiByteToWideChar (CP_UTF8, 0, string, -1, result, n);
+ if (n < 0)
+ {
+ free (result);
+ result = NULL;
+ }
+ return NULL;
+ }
+ return result;
+}
+
+
+static char *
+get_locale_dir (void)
+{
+ static wchar_t moddir[MAX_PATH+5];
+ char *result, *p;
+ int nbytes;
+
+ if (!GetModuleFileNameW (NULL, moddir, MAX_PATH))
+ *moddir = 0;
+
+#define SLDIR "\\share\\locale"
+ if (*moddir)
+ {
+ nbytes = WideCharToMultiByte (CP_UTF8, 0, moddir, -1, NULL, 0, NULL, NULL);
+ if (nbytes < 0)
+ return NULL;
+
+ result = malloc (nbytes + strlen (SLDIR) + 1);
+ if (result)
+ {
+ nbytes = WideCharToMultiByte (CP_UTF8, 0, moddir, -1,
+ result, nbytes, NULL, NULL);
+ if (nbytes < 0)
+ {
+ free (result);
+ result = NULL;
+ }
+ else
+ {
+ p = strrchr (result, '\\');
+ if (p)
+ *p = 0;
+ /* If we are installed below "bin" strip that part and
+ use the top directory instead.
+
+ Background: Under Windows we don't install GnuPG
+ below bin/ but in the top directory with only share/,
+ lib/, and etc/ below it. One of the reasons is to
+ keep the the length of the filenames at bay so not to
+ increase the limited length of the PATH envvar.
+ Another and more important reason, however, is that
+ the very first GPG versions on W32 were installed
+ into a flat directory structure and for best
+ compatibility with these versions we didn't changed
+ that later. For WindowsCE we can right away install
+ it under bin, though. The hack with detection of the
+ bin directory part allows us to eventually migrate to
+ such a directory layout under plain Windows without
+ the need to change libgpg-error. */
+ p = strrchr (result, '\\');
+ if (p && !strcmp (p+1, "bin"))
+ *p = 0;
+ /* Append the static part. */
+ strcat (result, SLDIR);
+ }
+ }
+ }
+ else /* Use the old default value. */
+ {
+ result = malloc (10 + strlen (SLDIR) + 1);
+ if (result)
+ {
+ strcpy (result, "c:\\gnupg");
+ strcat (result, SLDIR);
+ }
+ }
+#undef SLDIR
+ return result;
+}
+
+
+static void
+drop_locale_dir (char *locale_dir)
+{
+ free (locale_dir);
+}
+
+
+/* Return the tls object. This function is guaranteed to return a
+ valid non-NULL object. */
+struct tls_space_s *
+get_tls (void)
+{
+ struct tls_space_s *tls;
+
+ tls = TlsGetValue (tls_index);
+ if (!tls)
+ {
+ /* Called by a thread which existed before this DLL was loaded.
+ Allocate the space. */
+ tls = LocalAlloc (LPTR, sizeof *tls);
+ if (!tls)
+ {
+ /* No way to continue - commit suicide. */
+ abort ();
+ }
+ tls->gt_use_utf8 = 0;
+ TlsSetValue (tls_index, tls);
+ }
+
+ return tls;
+}
+
+
+/* Return the value of the ERRNO variable. This needs to be a
+ function so that we can have a per-thread ERRNO. This is used only
+ on WindowsCE because that OS misses an errno. */
+#ifdef HAVE_W32CE_SYSTEM
+int
+_gpg_w32ce_get_errno (void)
+{
+ return map_w32codes ( GetLastError () );
+}
+#endif /*HAVE_W32CE_SYSTEM*/
+
+
+/* Replacement strerror function for WindowsCE. */
+#ifdef HAVE_W32CE_SYSTEM
+char *
+_gpg_w32ce_strerror (int err)
+{
+ struct tls_space_s *tls = get_tls ();
+ wchar_t tmpbuf[STRBUFFER_SIZE];
+ int n;
+
+ if (err == -1)
+ err = _gpg_w32ce_get_errno ();
+
+ /* Note: On a German HTC Touch Pro2 device I also tried
+ LOCALE_USER_DEFAULT and LOCALE_SYSTEM_DEFAULT - both returned
+ English messages. */
+ if (FormatMessageW (FORMAT_MESSAGE_FROM_SYSTEM, NULL, err,
+ MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),
+ tmpbuf, STRBUFFER_SIZE -1,
+ NULL))
+ {
+ n = WideCharToMultiByte (CP_UTF8, 0, tmpbuf, -1,
+ tls->strerror_buffer,
+ sizeof tls->strerror_buffer -1,
+ NULL, NULL);
+ }
+ else
+ n = -1;
+
+ if (n < 0)
+ snprintf (tls->strerror_buffer, sizeof tls->strerror_buffer -1,
+ "[w32err=%d]", err);
+ return tls->strerror_buffer;
+}
+#endif /*HAVE_W32CE_SYSTEM*/
+
+
+void
+gpg_err_set_errno (int err)
+{
+#ifdef HAVE_W32CE_SYSTEM
+ SetLastError (err);
+#else /*!HAVE_W32CE_SYSTEM*/
+ errno = err;
+#endif /*!HAVE_W32CE_SYSTEM*/
+}
+
+
+/* Entry point called by the DLL loader. */
+#ifdef DLL_EXPORT
+int WINAPI
+DllMain (HINSTANCE hinst, DWORD reason, LPVOID reserved)
+{
+ struct tls_space_s *tls;
+ (void)reserved;
+
+ switch (reason)
+ {
+ case DLL_PROCESS_ATTACH:
+ tls_index = TlsAlloc ();
+ if (tls_index == TLS_OUT_OF_INDEXES)
+ return FALSE;
+ /* falltru. */
+ case DLL_THREAD_ATTACH:
+ tls = LocalAlloc (LPTR, sizeof *tls);
+ if (!tls)
+ return FALSE;
+ tls->gt_use_utf8 = 0;
+ TlsSetValue (tls_index, tls);
+ if (reason == DLL_PROCESS_ATTACH)
+ {
+ real_init ();
+ }
+ break;
+
+ case DLL_THREAD_DETACH:
+ tls = TlsGetValue (tls_index);
+ if (tls)
+ LocalFree (tls);
+ break;
+
+ case DLL_PROCESS_DETACH:
+ tls = TlsGetValue (tls_index);
+ if (tls)
+ LocalFree (tls);
+ TlsFree (tls_index);
+ break;
+
+ default:
+ break;
+ }
+
+ return TRUE;
+}
+#endif /*DLL_EXPORT*/
+
+#else /*!HAVE_W32_SYSTEM*/
+
+void
+gpg_err_set_errno (int err)
+{
+ errno = err;
+}
+
+#endif /*!HAVE_W32_SYSTEM*/
diff --git a/src/init.h b/src/init.h
new file mode 100644
index 0000000..0a31fd7
--- /dev/null
+++ b/src/init.h
@@ -0,0 +1,70 @@
+/* init.h - Declarations for init.c
+ Copyright (C) 2010 g10 Code GmbH
+
+ This file is part of libgpg-error.
+
+ libgpg-error 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 2.1 of
+ the License, or (at your option) any later version.
+
+ libgpg-error 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/>.
+ */
+
+#ifndef INIT_H
+#define INIT_H
+
+#if HAVE_W32_SYSTEM
+
+/* Forward declaration - defined in w32-gettext.c. */
+struct loaded_domain;
+
+/* An item for a linked list of loaded domains. */
+struct domainlist_s
+{
+ struct domainlist_s *next;
+ char *dname; /* Directory name for the mo file. */
+ char *fname; /* File name for the MO file. */
+ int load_failed; /* True if loading the domain failed. */
+ struct loaded_domain *domain; /* NULL if not loaded. Never changed
+ once set to non-NULL. */
+ char name[1]; /* Name of the domain. Never changed
+ once set. */
+};
+
+
+
+/* 119 bytes for an error message should be enough. With this size we
+ can assume that the allocation does not take up more than 128 bytes
+ per thread. Note that this is only used for W32CE. */
+#define STRBUFFER_SIZE 120
+
+/* The TLS space definition. */
+struct tls_space_s
+{
+ /* Flag used by w32-gettext. */
+ int gt_use_utf8;
+
+#ifdef HAVE_W32CE_SYSTEM
+ char strerror_buffer[STRBUFFER_SIZE];
+#endif
+};
+
+/* Return the TLS. */
+struct tls_space_s *get_tls (void);
+
+
+/* Explicit constructor for w32-gettext.c */
+#ifndef DLL_EXPORT
+void _gpg_w32__init_gettext_module (void);
+#endif
+
+#endif /*HAVE_W32_SYSTEM*/
+
+#endif /*INIT_H*/
diff --git a/src/mkerrcodes.awk b/src/mkerrcodes.awk
new file mode 100644
index 0000000..46d436c
--- /dev/null
+++ b/src/mkerrcodes.awk
@@ -0,0 +1,99 @@
+# mkerrcodes.awk
+# Copyright (C) 2004, 2005 g10 Code GmbH
+#
+# This program 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 2 of
+# the License, or (at your option) any later version.
+#
+# This program 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 this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+#
+# As a special exception, g10 Code GmbH gives unlimited permission to
+# copy, distribute and modify the C source files that are the output
+# of mkerrcodes.awk. You need not follow the terms of the GNU General
+# Public License when using or distributing such scripts, even though
+# portions of the text of mkerrcodes.awk appear in them. The GNU
+# General Public License (GPL) does govern all other use of the material
+# that constitutes the mkerrcodes.awk program.
+#
+# Certain portions of the mkerrcodes.awk source text are designed to be
+# copied (in certain cases, depending on the input) into the output of
+# mkerrcodes.awk. We call these the "data" portions. The rest of the
+# mkerrcodes.awk source text consists of comments plus executable code
+# that decides which of the data portions to output in any given case.
+# We call these comments and executable code the "non-data" portions.
+# mkerrcodes.h never copies any of the non-data portions into its output.
+#
+# This special exception to the GPL applies to versions of mkerrcodes.awk
+# released by g10 Code GmbH. When you make and distribute a modified version
+# of mkerrcodes.awk, you may extend this special exception to the GPL to
+# apply to your modified version as well, *unless* your modified version
+# has the potential to copy into its output some of the text that was the
+# non-data portion of the version that you started with. (In other words,
+# unless your change moves or copies text from the non-data portions to the
+# data portions.) If your modification has such potential, you must delete
+# any notice of this special exception to the GPL from your modified version.
+
+# This script outputs an intermediate file that contains the following output:
+# static struct
+# {
+# int err;
+# const char *err_sym;
+# } err_table[] =
+# {
+# { 7, "GPG_ERR_E2BIG" },
+# [...]
+# };
+#
+# The input file is a list of possible system errors, followed by a GPG_ERR_* name:
+#
+# 7 GPG_ERR_E2BIG
+#
+# Comments (starting with # and ending at the end of the line) are removed,
+# as is trailing whitespace.
+
+BEGIN {
+ FS="[ \t]+GPG_ERR_";
+ print "/* Output of mkerrcodes.awk. DO NOT EDIT. */";
+ print "";
+ header = 1;
+}
+
+/^#/ { next; }
+
+header {
+ if (! /^[ \t]*$/)
+ {
+ header = 0;
+
+ print "static struct";
+ print " {";
+ print " int err;";
+ print " const char *err_sym;";
+ print " } err_table[] = ";
+ print "{";
+ }
+ else
+ print;
+}
+
+!header {
+ sub (/\#.+/, "");
+ sub (/[ ]+$/, ""); # Strip trailing space and tab characters.
+
+ if (/^$/)
+ next;
+
+ print " { " $1 ", \"GPG_ERR_" $2 "\" },";
+}
+
+END {
+ print "};";
+}
diff --git a/src/mkerrcodes.c b/src/mkerrcodes.c
new file mode 100644
index 0000000..29c1cc2
--- /dev/null
+++ b/src/mkerrcodes.c
@@ -0,0 +1,78 @@
+/* mkerrcodes.c - Generate list of system error values.
+ Copyright (C) 2004 g10 Code GmbH
+
+ This file is part of libgpg-error.
+
+ libgpg-error 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 2.1 of
+ the License, or (at your option) any later version.
+
+ libgpg-error 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 libgpg-error; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA. */
+
+/* This file must not include config.h, as that is for the host
+ system, while this file will be run on the build system. */
+
+#include <stdio.h>
+
+#include "mkerrcodes.h"
+
+static const char header[] =
+"/* errnos.h - List of system error values.\n"
+" Copyright (C) 2004 g10 Code GmbH\n"
+" This file is part of libgpg-error.\n"
+"\n"
+" libgpg-error is free software; you can redistribute it and/or\n"
+" modify it under the terms of the GNU Lesser General Public License\n"
+" as published by the Free Software Foundation; either version 2.1 of\n"
+" the License, or (at your option) any later version.\n"
+"\n"
+" libgpg-error is distributed in the hope that it will be useful, but\n"
+" WITHOUT ANY WARRANTY; without even the implied warranty of\n"
+" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n"
+" Lesser General Public License for more details.\n"
+"\n"
+" You should have received a copy of the GNU Lesser General Public\n"
+" License along with libgpg-error; if not, write to the Free\n"
+" Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA\n"
+" 02111-1307, USA. */\n"
+"\n";
+
+int
+main (int argc, char **argv)
+{
+ int sorted;
+ int i;
+
+ printf ("%s", header);
+ do
+ {
+ sorted = 1;
+ for (i = 0; i < sizeof (err_table) / sizeof (err_table[0]) - 1; i++)
+ if (err_table[i].err > err_table[i + 1].err)
+ {
+ int err = err_table[i].err;
+ const char *err_sym = err_table[i].err_sym;
+
+ err_table[i].err = err_table[i + 1].err;
+ err_table[i].err_sym = err_table[i + 1].err_sym;
+ err_table[i + 1].err = err;
+ err_table[i + 1].err_sym = err_sym;
+ sorted = 0;
+ }
+ }
+ while (!sorted);
+
+ for (i = 0; i < sizeof (err_table) / sizeof (err_table[0]); i++)
+ printf ("%i\t%s\n", err_table[i].err, err_table[i].err_sym);
+
+ return 0;
+}
diff --git a/src/mkerrcodes1.awk b/src/mkerrcodes1.awk
new file mode 100644
index 0000000..a771a73
--- /dev/null
+++ b/src/mkerrcodes1.awk
@@ -0,0 +1,96 @@
+# mkerrcodes.awk
+# Copyright (C) 2003, 2004 g10 Code GmbH
+#
+# This program 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 2 of
+# the License, or (at your option) any later version.
+#
+# This program 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 this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+#
+# As a special exception, g10 Code GmbH gives unlimited permission to
+# copy, distribute and modify the C source files that are the output
+# of mkerrcodes.awk. You need not follow the terms of the GNU General
+# Public License when using or distributing such scripts, even though
+# portions of the text of mkerrcodes.awk appear in them. The GNU
+# General Public License (GPL) does govern all other use of the material
+# that constitutes the mkerrcodes.awk program.
+#
+# Certain portions of the mkerrcodes.awk source text are designed to be
+# copied (in certain cases, depending on the input) into the output of
+# mkerrcodes.awk. We call these the "data" portions. The rest of the
+# mkerrcodes.awk source text consists of comments plus executable code
+# that decides which of the data portions to output in any given case.
+# We call these comments and executable code the "non-data" portions.
+# mkerrcodes.h never copies any of the non-data portions into its output.
+#
+# This special exception to the GPL applies to versions of mkerrcodes.awk
+# released by g10 Code GmbH. When you make and distribute a modified version
+# of mkerrcodes.awk, you may extend this special exception to the GPL to
+# apply to your modified version as well, *unless* your modified version
+# has the potential to copy into its output some of the text that was the
+# non-data portion of the version that you started with. (In other words,
+# unless your change moves or copies text from the non-data portions to the
+# data portions.) If your modification has such potential, you must delete
+# any notice of this special exception to the GPL from your modified version.
+
+# This script outputs an intermediate file that contains the following block
+# for each error value symbol in the input file (example for EINVAL):
+#
+# #ifdef EINVAL
+# EINVAL GPG_ERR_EINVAL
+# #endif
+#
+# The input file is a list of possible system errors in the column errnoidx
+# (defaults to 2).
+#
+# Comments (starting with # and ending at the end of the line) are removed,
+# as is trailing whitespace.
+
+BEGIN {
+ FS="[\t]+";
+ header = 1;
+ if (errnoidx == 0)
+ errnoidx = 2;
+
+ print "/* Output of mkerrcodes.awk. DO NOT EDIT. */";
+ print "";
+}
+
+/^#/ { next; }
+
+header {
+ if ($1 ~ /^[0-9]/)
+ {
+ print "#include <errno.h>";
+ print "#ifdef _WIN32";
+ print "#include <winsock2.h>";
+ print "#endif";
+ print "";
+ header = 0;
+ }
+ else
+ print;
+}
+
+!header {
+ sub (/\#.+/, "");
+ sub (/[ ]+$/, ""); # Strip trailing space and tab characters.
+
+ if (/^$/)
+ next;
+
+ print "#ifdef " $errnoidx;
+ print $errnoidx "\tGPG_ERR_" $errnoidx;
+ print "#endif";
+ print "#ifdef WSA" $errnoidx;
+ print "WSA" $errnoidx "\tGPG_ERR_" $errnoidx;
+ print "#endif";
+}
diff --git a/src/mkerrcodes2.awk b/src/mkerrcodes2.awk
new file mode 100644
index 0000000..ea58503
--- /dev/null
+++ b/src/mkerrcodes2.awk
@@ -0,0 +1,134 @@
+# mkstrtable.awk
+# Copyright (C) 2003 g10 Code GmbH
+#
+# This program 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 2 of
+# the License, or (at your option) any later version.
+#
+# This program 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 this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+#
+# As a special exception, g10 Code GmbH gives unlimited permission to
+# copy, distribute and modify the C source files that are the output
+# of mkerrcodes2.awk. You need not follow the terms of the GNU General
+# Public License when using or distributing such scripts, even though
+# portions of the text of mkerrcodes2.awk appear in them. The GNU
+# General Public License (GPL) does govern all other use of the material
+# that constitutes the mkerrcodes2.awk program.
+#
+# Certain portions of the mkerrcodes2.awk source text are designed to be
+# copied (in certain cases, depending on the input) into the output of
+# mkerrcodes2.awk. We call these the "data" portions. The rest of the
+# mkerrcodes2.awk source text consists of comments plus executable code
+# that decides which of the data portions to output in any given case.
+# We call these comments and executable code the "non-data" portions.
+# mkstrtable.h never copies any of the non-data portions into its output.
+#
+# This special exception to the GPL applies to versions of mkerrcodes2.awk
+# released by g10 Code GmbH. When you make and distribute a modified version
+# of mkerrcodes2.awk, you may extend this special exception to the GPL to
+# apply to your modified version as well, *unless* your modified version
+# has the potential to copy into its output some of the text that was the
+# non-data portion of the version that you started with. (In other words,
+# unless your change moves or copies text from the non-data portions to the
+# data portions.) If your modification has such potential, you must delete
+# any notice of this special exception to the GPL from your modified version.
+
+# This script outputs a source file that does define the following
+# symbols:
+#
+# static const char msgstr[];
+# A string containing all messages in the list.
+#
+# static const int msgidx[];
+# A list of index numbers, one for each message, that points to the
+# beginning of the string in msgstr.
+#
+# msgidxof (code);
+# A macro that maps code numbers to idx numbers. If a DEFAULT MESSAGE
+# is provided (see below), its index will be returned for unknown codes.
+# Otherwise -1 is returned for codes that do not appear in the list.
+# You can lookup the message with code CODE with:
+# msgstr + msgidx[msgidxof (code)].
+#
+# The input file has the following format:
+# CODE1 MESSAGE1 (Code number, <tab>, message string)
+# CODE2 MESSAGE2 (Code number, <tab>, message string)
+# ...
+# CODEn MESSAGEn (Code number, <tab>, message string)
+# DEFAULT MESSAGE (<tab>, fall-back message string)
+#
+# Comments (starting with # and ending at the end of the line) are removed,
+# as is trailing whitespace. The last line is optional; if no DEFAULT
+# MESSAGE is given, msgidxof will return the number -1 for unknown
+# index numbers.
+
+BEGIN {
+# msg holds the number of messages.
+ msg = 0;
+ print "/* Output of mkerrcodes2.awk. DO NOT EDIT. */";
+ print "";
+ header = 1;
+}
+
+/^#/ { next; }
+
+header {
+ if ($1 ~ /^[0123456789]+$/)
+ {
+ print "static const int err_code_from_index[] = {";
+ header = 0;
+ }
+ else
+ print;
+}
+
+!header {
+ sub (/\#.+/, "");
+ sub (/[ ]+$/, ""); # Strip trailing space and tab characters.
+
+ if (/^$/)
+ next;
+
+# Print the string msgstr line by line. We delay output by one line to be able
+# to treat the last line differently (see END).
+ print " " $2 ",";
+
+# Remember the error value and index of each error code.
+ code[msg] = $1;
+ pos[msg] = $2;
+ msg++;
+}
+END {
+ print "};";
+ print "";
+ print "#define errno_to_idx(code) (0 ? -1 \\";
+
+# Gather the ranges.
+ skip = code[0];
+ start = code[0];
+ stop = code[0];
+ for (i = 1; i < msg; i++)
+ {
+ if (code[i] == stop + 1)
+ stop++;
+ else
+ {
+ print " : ((code >= " start ") && (code <= " stop ")) ? (code - " \
+ skip ") \\";
+ skip += code[i] - stop - 1;
+ start = code[i];
+ stop = code[i];
+ }
+ }
+ print " : ((code >= " start ") && (code <= " stop ")) ? (code - " \
+ skip ") \\";
+ print " : -1)";
+}
diff --git a/src/mkerrnos.awk b/src/mkerrnos.awk
new file mode 100644
index 0000000..f79df66
--- /dev/null
+++ b/src/mkerrnos.awk
@@ -0,0 +1,104 @@
+# mkerrnos.awk
+# Copyright (C) 2003, 2004 g10 Code GmbH
+#
+# This program 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 2 of
+# the License, or (at your option) any later version.
+#
+# This program 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 this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+#
+# As a special exception, g10 Code GmbH gives unlimited permission to
+# copy, distribute and modify the C source files that are the output
+# of mkerrnos.awk. You need not follow the terms of the GNU General
+# Public License when using or distributing such scripts, even though
+# portions of the text of mkerrnos.awk appear in them. The GNU
+# General Public License (GPL) does govern all other use of the material
+# that constitutes the mkerrnos.awk program.
+#
+# Certain portions of the mkerrnos.awk source text are designed to be
+# copied (in certain cases, depending on the input) into the output of
+# mkerrnos.awk. We call these the "data" portions. The rest of the
+# mkerrnos.awk source text consists of comments plus executable code
+# that decides which of the data portions to output in any given case.
+# We call these comments and executable code the "non-data" portions.
+# mkerrnos.h never copies any of the non-data portions into its output.
+#
+# This special exception to the GPL applies to versions of mkerrnos.awk
+# released by g10 Code GmbH. When you make and distribute a modified version
+# of mkerrnos.awk, you may extend this special exception to the GPL to
+# apply to your modified version as well, *unless* your modified version
+# has the potential to copy into its output some of the text that was the
+# non-data portion of the version that you started with. (In other words,
+# unless your change moves or copies text from the non-data portions to the
+# data portions.) If your modification has such potential, you must delete
+# any notice of this special exception to the GPL from your modified version.
+
+# This script outputs a source file that does define the following
+# symbols:
+#
+# static const int err_code_to_errno[];
+# A mapping of gpg_err_code_t numbers to system errno. The index of an
+# error code in the table can be obtained after removing the system error
+# code indication bit.
+#
+# The input file is a list of possible system errors in the column errnoidx
+# (defaults to 2).
+#
+# Comments (starting with # and ending at the end of the line) are removed,
+# as is trailing whitespace.
+
+BEGIN {
+ FS="[\t]+";
+ header = 1;
+ if (errnoidx == 0)
+ errnoidx = 2;
+
+ print "/* Output of mkerrnos.awk. DO NOT EDIT. */";
+ print "";
+}
+
+/^#/ { next; }
+
+header {
+ if ($1 ~ /^[0-9]/)
+ {
+ print "#include <errno.h>";
+ print "#ifdef _WIN32";
+ print "#include <winsock2.h>";
+ print "#endif";
+ print "";
+ print "static const int err_code_to_errno [] = {";
+ header = 0;
+ }
+ else
+ print;
+}
+
+!header {
+ sub (/\#.+/, "");
+ sub (/[ ]+$/, ""); # Strip trailing space and tab characters.
+
+ if (/^$/)
+ next;
+
+ print "#ifdef " $errnoidx;
+ print " " $errnoidx ",";
+ print "#else";
+ print "#ifdef WSA" $errnoidx;
+ print " WSA" $errnoidx ",";
+ print "#else";
+ print " 0,";
+ print "#endif";
+ print "#endif";
+}
+END {
+ print "};";
+}
diff --git a/src/mkheader.awk b/src/mkheader.awk
new file mode 100644
index 0000000..0ff08f9
--- /dev/null
+++ b/src/mkheader.awk
@@ -0,0 +1,218 @@
+# mkheader.awk
+# Copyright (C) 2003, 2004 g10 Code GmbH
+#
+# This program 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 2 of
+# the License, or (at your option) any later version.
+#
+# This program 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 this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+#
+# As a special exception, g10 Code GmbH gives unlimited permission to
+# copy, distribute and modify the C source files that are the output
+# of mkheader.awk. You need not follow the terms of the GNU General
+# Public License when using or distributing such scripts, even though
+# portions of the text of mkheader.awk appear in them. The GNU
+# General Public License (GPL) does govern all other use of the material
+# that constitutes the mkheader.awk program.
+#
+# Certain portions of the mkheader.awk source text are designed to be
+# copied (in certain cases, depending on the input) into the output of
+# mkheader.awk. We call these the "data" portions. The rest of the
+# mkheader.awk source text consists of comments plus executable code
+# that decides which of the data portions to output in any given case.
+# We call these comments and executable code the "non-data" portions.
+# mkheader.h never copies any of the non-data portions into its output.
+#
+# This special exception to the GPL applies to versions of mkheader.awk
+# released by g10 Code GmbH. When you make and distribute a modified version
+# of mkheader.awk, you may extend this special exception to the GPL to
+# apply to your modified version as well, *unless* your modified version
+# has the potential to copy into its output some of the text that was the
+# non-data portion of the version that you started with. (In other words,
+# unless your change moves or copies text from the non-data portions to the
+# data portions.) If your modification has such potential, you must delete
+# any notice of this special exception to the GPL from your modified version.
+
+# This script processes gpg-error.h.in in an awful way.
+# Its input is, one after another, the content of the err-sources.h.in file,
+# the err-codes.h.in file, the errnos.in file, and then gpg-error.h.in.
+# There is nothing fancy about this.
+#
+# An alternative would be to use getline to get the content of the first three files,
+# but then we need to pre-process gpg-error.h.in with configure to get
+# at the full path of the files in @srcdir@.
+
+BEGIN {
+ FS = "[\t]+";
+# sources_nr holds the number of error sources.
+ sources_nr = 0;
+# codes_nr holds the number of error codes.
+ codes_nr = 0;
+# errnos_nr holds the number of system errors.
+ errnos_nr = 0;
+# extra_nr holds the number of extra lines to be included.
+ extra_nr = 0
+
+# These variables walk us through our input.
+ sources_header = 1;
+ sources_body = 0;
+ between_sources_and_codes = 0;
+ codes_body = 0;
+ between_codes_and_errnos = 0;
+ errnos_body = 0;
+ extra_body = 0;
+ gpg_error_h = 0;
+
+ print "/* Output of mkheader.awk. DO NOT EDIT. -*- buffer-read-only: t -*- */";
+ print "";
+
+}
+
+
+sources_header {
+ if ($1 ~ /^[0123456789]+$/)
+ {
+ sources_header = 0;
+ sources_body = 1;
+ }
+}
+
+sources_body {
+ sub (/\#.+/, "");
+ sub (/[ ]+$/, ""); # Strip trailing space and tab characters.
+
+ if (/^$/)
+ next;
+
+ if ($1 == "")
+ {
+ sources_body = 0;
+ between_sources_and_codes = 1;
+ }
+ else
+ {
+# Remember the error source number and symbol of each error source.
+ sources_idx[sources_nr] = $1;
+ sources_sym[sources_nr] = $2;
+ sources_nr++;
+ }
+}
+
+between_sources_and_codes {
+ if ($1 ~ /^[0123456789]+$/)
+ {
+ between_sources_and_codes = 0;
+ codes_body = 1;
+ }
+}
+
+codes_body {
+ sub (/\#.+/, "");
+ sub (/[ ]+$/, ""); # Strip trailing space and tab characters.
+
+ if (/^$/)
+ next;
+
+ if ($1 == "")
+ {
+ codes_body = 0;
+ between_codes_and_errnos = 1;
+ }
+ else
+ {
+# Remember the error code number and symbol of each error source.
+ codes_idx[codes_nr] = $1;
+ codes_sym[codes_nr] = $2;
+ codes_nr++;
+ }
+}
+
+between_codes_and_errnos {
+ if ($1 ~ /^[0-9]/)
+ {
+ between_codes_and_errnos = 0;
+ errnos_body = 1;
+ }
+}
+
+errnos_body {
+ sub (/\#.+/, "");
+ sub (/[ ]+$/, ""); # Strip trailing space and tab characters.
+
+ if (/^$/)
+ next;
+
+ if ($1 !~ /^[0-9]/)
+ {
+# Note that this assumes that extra_body.in doesn't start with a digit.
+ errnos_body = 0;
+ extra_body = 1;
+ }
+ else
+ {
+ errnos_idx[errnos_nr] = "GPG_ERR_SYSTEM_ERROR | " $1;
+ errnos_sym[errnos_nr] = "GPG_ERR_" $2;
+ errnos_nr++;
+ }
+}
+
+extra_body {
+ if (/^##/)
+ next
+
+ if (/^EOF/)
+ {
+ extra_body = 0;
+ gpg_error_h = 1;
+ next;
+ }
+ else
+ {
+ extra_line[extra_nr] = $0;
+ extra_nr++;
+ }
+}
+
+gpg_error_h {
+ if ($0 ~ /^@include err-sources/)
+ {
+ for (i = 0; i < sources_nr; i++)
+ {
+ print " " sources_sym[i] " = " sources_idx[i] ",";
+# print "#define " sources_sym[i] " (" sources_idx[i] ")";
+ }
+ }
+ else if ($0 ~ /^@include err-codes/)
+ {
+ for (i = 0; i < codes_nr; i++)
+ {
+ print " " codes_sym[i] " = " codes_idx[i] ",";
+# print "#define " codes_sym[i] " (" codes_idx[i] ")";
+ }
+ }
+ else if ($0 ~ /^@include errnos/)
+ {
+ for (i = 0; i < errnos_nr; i++)
+ {
+ print " " errnos_sym[i] " = " errnos_idx[i] ",";
+# print "#define " errnos_sym[i] " (" errnos_idx[i] ")";
+ }
+ }
+ else if ($0 ~ /^@include extra-h.in/)
+ {
+ for (i = 0; i < extra_nr; i++)
+ {
+ print extra_line[i];
+ }
+ }
+ else
+ print;
+}
diff --git a/src/mkstrtable.awk b/src/mkstrtable.awk
new file mode 100644
index 0000000..d97e150
--- /dev/null
+++ b/src/mkstrtable.awk
@@ -0,0 +1,189 @@
+# mkstrtable.awk
+# Copyright (C) 2003, 2004, 2008 g10 Code GmbH
+#
+# This program 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 2 of
+# the License, or (at your option) any later version.
+#
+# This program 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 this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+#
+# As a special exception, g10 Code GmbH gives unlimited permission to
+# copy, distribute and modify the C source files that are the output
+# of mkstrtable.awk. You need not follow the terms of the GNU General
+# Public License when using or distributing such scripts, even though
+# portions of the text of mkstrtable.awk appear in them. The GNU
+# General Public License (GPL) does govern all other use of the material
+# that constitutes the mkstrtable.awk program.
+#
+# Certain portions of the mkstrtable.awk source text are designed to be
+# copied (in certain cases, depending on the input) into the output of
+# mkstrtable.awk. We call these the "data" portions. The rest of the
+# mkstrtable.awk source text consists of comments plus executable code
+# that decides which of the data portions to output in any given case.
+# We call these comments and executable code the "non-data" portions.
+# mkstrtable.h never copies any of the non-data portions into its output.
+#
+# This special exception to the GPL applies to versions of mkstrtable.awk
+# released by g10 Code GmbH. When you make and distribute a modified version
+# of mkstrtable.awk, you may extend this special exception to the GPL to
+# apply to your modified version as well, *unless* your modified version
+# has the potential to copy into its output some of the text that was the
+# non-data portion of the version that you started with. (In other words,
+# unless your change moves or copies text from the non-data portions to the
+# data portions.) If your modification has such potential, you must delete
+# any notice of this special exception to the GPL from your modified version.
+
+# This script outputs a source file that does define the following
+# symbols:
+#
+# static const char msgstr[];
+# A string containing all messages in the list.
+#
+# static const int msgidx[];
+# A list of index numbers, one for each message, that points to the
+# beginning of the string in msgstr.
+#
+# msgidxof (code);
+# A macro that maps code numbers to idx numbers. If a DEFAULT MESSAGE
+# is provided (see below), its index will be returned for unknown codes.
+# Otherwise -1 is returned for codes that do not appear in the list.
+# You can lookup the message with code CODE with:
+# msgstr + msgidx[msgidxof (code)].
+#
+# The input file has the following format:
+# CODE1 ... MESSAGE1 (code nr, <tab>, something, <tab>, msg)
+# CODE2 ... MESSAGE2 (code nr, <tab>, something, <tab>, msg)
+# ...
+# CODEn ... MESSAGEn (code nr, <tab>, something, <tab>, msg)
+# ... DEFAULT-MESSAGE (<tab>, something, <tab>, fall-back msg)
+#
+# Comments (starting with # and ending at the end of the line) are removed,
+# as is trailing whitespace. The last line is optional; if no DEFAULT
+# MESSAGE is given, msgidxof will return the number -1 for unknown
+# index numbers.
+#
+# The field to be used is specified with the variable "textidx" on
+# the command line. It defaults to 2.
+#
+# The variable nogettext can be set to 1 to suppress gettext markers.
+#
+# The variable prefix can be used to prepend a string to each message.
+#
+# The variable namespace can be used to prepend a string to each
+# variable and macro name.
+
+BEGIN {
+ FS = "[\t]+";
+# cpos holds the current position in the message string.
+ cpos = 0;
+# msg holds the number of messages.
+ msg = 0;
+ print "/* Output of mkstrtable.awk. DO NOT EDIT. */";
+ print "";
+ header = 1;
+ if (textidx == 0)
+ textidx = 2;
+# nogettext can be set to 1 to suppress gettext noop markers.
+}
+
+/^#/ { next; }
+
+header {
+ if ($1 ~ /^[0123456789]+$/)
+ {
+ print "/* The purpose of this complex string table is to produce";
+ print " optimal code with a minimum of relocations. */";
+ print "";
+ print "static const char " namespace "msgstr[] = ";
+ header = 0;
+ }
+ else
+ print;
+}
+
+!header {
+ sub (/\#.+/, "");
+ sub (/[ ]+$/, ""); # Strip trailing space and tab characters.
+
+ if (/^$/)
+ next;
+
+# Print the string msgstr line by line. We delay output by one line to be able
+# to treat the last line differently (see END).
+ if (last_msgstr)
+ {
+ if (nogettext)
+ print " \"" last_msgstr "\" \"\\0\"";
+ else
+ print " gettext_noop (\"" last_msgstr "\") \"\\0\"";
+ }
+ last_msgstr = prefix $textidx;
+
+# Remember the error code and msgidx of each error message.
+ code[msg] = $1;
+ pos[msg] = cpos;
+ cpos += length (last_msgstr) + 1;
+ msg++;
+
+ if ($1 == "")
+ {
+ has_default = 1;
+ exit;
+ }
+}
+END {
+ if (has_default)
+ coded_msgs = msg - 1;
+ else
+ coded_msgs = msg;
+
+ if (nogettext)
+ print " \"" last_msgstr "\";";
+ else
+ print " gettext_noop (\"" last_msgstr "\");";
+ print "";
+ print "static const int " namespace "msgidx[] =";
+ print " {";
+ for (i = 0; i < coded_msgs; i++)
+ print " " pos[i] ",";
+ print " " pos[coded_msgs];
+ print " };";
+ print "";
+ print "static inline int";
+ print namespace "msgidxof (int code)";
+ print "{";
+ print " return (0 ? 0";
+
+# Gather the ranges.
+ skip = code[0];
+ start = code[0];
+ stop = code[0];
+ for (i = 1; i < coded_msgs; i++)
+ {
+ if (code[i] == stop + 1)
+ stop++;
+ else
+ {
+ print " : ((code >= " start ") && (code <= " stop ")) ? (code - " \
+ skip ")";
+ skip += code[i] - stop - 1;
+ start = code[i];
+ stop = code[i];
+ }
+ }
+ print " : ((code >= " start ") && (code <= " stop ")) ? (code - " \
+ skip ")";
+ if (has_default)
+ print " : " stop + 1 " - " skip ");";
+ else
+ print " : -1);";
+ print "}";
+}
diff --git a/src/mkw32errmap.c b/src/mkw32errmap.c
new file mode 100644
index 0000000..68d0f05
--- /dev/null
+++ b/src/mkw32errmap.c
@@ -0,0 +1,178 @@
+/* mkw32errmap.c - Generate mapping sources for Windows.
+ Copyright (C) 2010 g10 Code GmbH
+
+ This file is part of libgpg-error.
+
+ libgpg-error 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 2.1 of
+ the License, or (at your option) any later version.
+
+ libgpg-error 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/>.
+ */
+
+#ifdef RESOLVE_MACROS
+# include <winerror.h>
+#endif
+#include <stdio.h>
+#include <stdlib.h>
+
+static const char header_gpg_extra_errno_h[] =
+ "/* errno.h - WindowsCE errno.h substitute\n"
+ " Copyright (C) 2010 g10 Code GmbH\n"
+ "\n"
+ " This file is free software; as a special exception the author gives\n"
+ " unlimited permission to copy and/or distribute it, with or without\n"
+ " modifications, as long as this notice is preserved.\n"
+ "\n"
+ " This file is distributed in the hope that it will be useful, but\n"
+ " WITHOUT ANY WARRANTY, to the extent permitted by law; without even\n"
+ " the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n"
+ " PURPOSE.\n"
+ "\n"
+ " +++ Do not edit! File has been generated by mkw32errmap.c +++\n"
+ "\n"
+ " This file is intended to be used with ming32ce-gcc to implement an\n"
+ " errno substitute under WindowsCE. It must be included via gcc's\n"
+ " -idirafter option. The gpg-error-config script emits the\n"
+ " appropriate option snippet. The actual implementation of the errno\n"
+ " related functions are part of libgpg-error. A separate header file\n"
+ " is required because errno.h is often included before gpg-error.h.\n"
+ " */\n"
+ "\n"
+ "#ifndef _GPG_ERROR_EXTRA_ERRNO_H\n"
+ "#define _GPG_ERROR_EXTRA_ERRNO_H\n"
+ "\n"
+ "/* Due to peculiarities in W32 we can't implement ERRNO as an\n"
+ " writable lvalue. This also allows us to easily find places\n"
+ " where ERRNO is being written to. See also gpg_err_set_errno. */\n"
+ "int _gpg_w32ce_get_errno (void);\n"
+ "#define errno (_gpg_w32ce_get_errno ())\n"
+ "\n";
+static const char footer_gpg_extra_errno_h[] =
+ "\n"
+ "#endif /*_GPG_ERROR_EXTRA_ERRNO_H*/\n";
+
+
+/* The table below is used in two modes. First we run the host
+ preprocessor over it to generate a new include file. This include
+ file has the same content but the Windows error macros are
+ resolved. This is so that we don't need to include winerror.h into
+ the generated errno.h. The mkw32errmap_marker variable is only
+ here to have something to grep for after preprocessing. */
+static int mkw32errmap_marker;
+struct table_s
+{
+ int *dummy;
+ const char *name;
+ int w32code;
+ int w32code2;
+};
+
+struct table_s table[] =
+ {
+#ifdef RESOLVE_MACROS
+#define X(a,b,c) \
+ {&mkw32errmap_marker, (a), (b), (c)}
+ X( "EPERM", ERROR_CANNOT_MAKE , 0 ),
+ X( "ENOENT", ERROR_FILE_NOT_FOUND , ERROR_PATH_NOT_FOUND ),
+ X( "EINTR", ERROR_INVALID_AT_INTERRUPT_TIME , 0 ),
+ X( "EIO", ERROR_IO_DEVICE , 0 ),
+ X( "ENXIO", ERROR_FILE_INVALID , 0 ),
+ X( "EBADF", ERROR_INVALID_HANDLE , 0 ),
+ X( "EAGAIN", ERROR_MORE_DATA , WSAEWOULDBLOCK ),
+
+ X( "ENOMEM", ERROR_NOT_ENOUGH_MEMORY , 0 ),
+ X( "EACCES", ERROR_ACCESS_DENIED , 0 ),
+ X( "EFAULT", ERROR_PROCESS_ABORTED , 0 ),
+ X( "EBUSY", ERROR_BUSY , 0 ),
+ X( "EEXIST", ERROR_FILE_EXISTS , WSAEADDRINUSE ),
+
+ X( "EXDEV", ERROR_NOT_SAME_DEVICE , 0 ),
+ X( "ENODEV", ERROR_BAD_DEVICE , ERROR_DEV_NOT_EXIST ),
+
+ X( "ENOTDIR",ERROR_DIRECTORY , 0 ),
+ X( "EINVAL", ERROR_INVALID_PARAMETER , 0 ),
+ X( "ENFILE", ERROR_NO_MORE_FILES , 0 ),
+ X( "EMFILE", ERROR_TOO_MANY_OPEN_FILES , 0 ),
+ X( "ENOSPC", ERROR_DISK_FULL , 0 ),
+ X( "EROFS", ERROR_WRITE_PROTECT , 0 ),
+ X( "EPIPE", ERROR_BROKEN_PIPE , 0 ),
+ X( "ERANGE", ERROR_ARITHMETIC_OVERFLOW , 0 ),
+ X( "EDEADLOCK",ERROR_POSSIBLE_DEADLOCK , 0 ),
+ X( "ENAMETOOLONG", ERROR_FILENAME_EXCED_RANGE, 0 ),
+ X( "ENOLCK", ERROR_SHARING_BUFFER_EXCEEDED , 0 ),
+ X( "ENOSYS", ERROR_NOT_SUPPORTED , 0 ),
+ X( "ENOTEMPTY",ERROR_DIR_NOT_EMPTY , 0 ),
+ X( "ESPIPE", ERROR_SEEK_ON_DEVICE , 0 ),
+#if 0 /* FIXME: Find appropriate mappings. */
+ X( "EILSEQ", ),
+ X( "EDOM", ),
+ X( "EMLINK", ),
+ X( "ESRCH", ), /* No such process */
+ X( "E2BIG", ), /* Arg list too long */
+ X( "ENOEXEC", ), /* Exec format error */
+ X( "ECHILD", ), /* No child processes */
+ X( "EISDIR", ), /* Is a directory */
+ X( "ENOTTY", ), /* Inappropriate I/O control operation */
+ X( "EFBIG", ), /* File too large */
+#endif
+#undef X
+#else /*!RESOLVE_MACROS*/
+# include "mkw32errmap.tab.h"
+#endif /*!RESOLVE_MACROS*/
+ { NULL, 0 }
+ };
+
+
+
+static int
+compare_table (const void *a_v, const void *b_v)
+{
+ const struct table_s *a = a_v;
+ const struct table_s *b = b_v;
+
+ return (a->w32code - b->w32code);
+}
+
+
+int
+main (int argc, char **argv)
+{
+ int idx;
+
+ for (idx=0; table[idx].name; idx++)
+ ;
+ qsort (table, idx, sizeof *table, compare_table);
+
+ if (argc == 2 && !strcmp (argv[1], "--map"))
+ {
+ fputs ("static int\n"
+ "map_w32codes (int err)\n"
+ "{\n"
+ " switch (err)\n"
+ " {\n", stdout );
+ for (idx=0; table[idx].name; idx++)
+ if (table[idx].w32code2)
+ printf (" case %d: return %d;\n",
+ table[idx].w32code2, table[idx].w32code);
+ fputs (" default: return err;\n"
+ " }\n"
+ "}\n", stdout);
+ }
+ else
+ {
+ fputs (header_gpg_extra_errno_h, stdout);
+ for (idx=0; table[idx].name; idx++)
+ printf ("#define %-12s %5d\n", table[idx].name, table[idx].w32code);
+ fputs (footer_gpg_extra_errno_h, stdout);
+ }
+
+ return 0;
+}
diff --git a/src/strerror-sym.c b/src/strerror-sym.c
new file mode 100644
index 0000000..3d79f40
--- /dev/null
+++ b/src/strerror-sym.c
@@ -0,0 +1,56 @@
+/* strerror-sym.c - Describing an error code with its symbol name.
+ Copyright (C) 2003, 2004 g10 Code GmbH
+
+ This file is part of libgpg-error.
+
+ libgpg-error 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 2.1 of
+ the License, or (at your option) any later version.
+
+ libgpg-error 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 libgpg-error; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA. */
+
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stddef.h>
+
+#include <gpg-error.h>
+
+#include "err-codes-sym.h"
+#include "errnos-sym.h"
+
+/* Return a pointer to a string containing the name of the symbol of
+ the error code in the error value ERR. Returns NULL if the error
+ code is not known. */
+const char *
+gpg_strerror_sym (gpg_error_t err)
+{
+ gpg_err_code_t code = gpg_err_code (err);
+
+ if (code & GPG_ERR_SYSTEM_ERROR)
+ {
+ int idx;
+
+ code &= ~GPG_ERR_SYSTEM_ERROR;
+ idx = errnos_msgidxof (code);
+ if (idx >= 0)
+ return errnos_msgstr + errnos_msgidx[idx];
+ else
+ return NULL;
+ }
+
+ if (msgidxof (code) == msgidxof (GPG_ERR_CODE_DIM))
+ return NULL;
+
+ return msgstr + msgidx[msgidxof (code)];
+}
diff --git a/src/strerror.c b/src/strerror.c
new file mode 100644
index 0000000..dc56040
--- /dev/null
+++ b/src/strerror.c
@@ -0,0 +1,169 @@
+/* strerror.c - Describing an error code.
+ Copyright (C) 2003 g10 Code GmbH
+
+ This file is part of libgpg-error.
+
+ libgpg-error 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 2.1 of
+ the License, or (at your option) any later version.
+
+ libgpg-error 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 libgpg-error; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA. */
+
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+
+#include <gpg-error.h>
+
+#include "gettext.h"
+#include "err-codes.h"
+
+/* Return a pointer to a string containing a description of the error
+ code in the error value ERR. This function is not thread-safe. */
+const char *
+gpg_strerror (gpg_error_t err)
+{
+ gpg_err_code_t code = gpg_err_code (err);
+
+ if (code & GPG_ERR_SYSTEM_ERROR)
+ {
+ int no = gpg_err_code_to_errno (code);
+ if (no)
+ return strerror (no);
+ else
+ code = GPG_ERR_UNKNOWN_ERRNO;
+ }
+ return dgettext (PACKAGE, msgstr + msgidx[msgidxof (code)]);
+}
+
+
+#ifdef HAVE_STRERROR_R
+#ifdef STRERROR_R_CHAR_P
+/* The GNU C library and probably some other systems have this weird
+ variant of strerror_r. */
+
+/* Return a dynamically allocated string in *STR describing the system
+ error NO. If this call succeeds, return 1. If this call fails due
+ to a resource shortage, set *STR to NULL and return 1. If this
+ call fails because the error number is not valid, don't set *STR
+ and return 0. */
+static int
+system_strerror_r (int no, char *buf, size_t buflen)
+{
+ char *errstr;
+
+ errstr = strerror_r (no, buf, buflen);
+ if (errstr != buf)
+ {
+ size_t errstr_len = strlen (errstr) + 1;
+ size_t cpy_len = errstr_len < buflen ? errstr_len : buflen;
+ memcpy (buf, errstr, cpy_len);
+
+ return cpy_len == errstr_len ? 0 : ERANGE;
+ }
+ else
+ {
+ /* We can not tell if the buffer was large enough, but we can
+ try to make a guess. */
+ if (strlen (buf) + 1 >= buflen)
+ return ERANGE;
+
+ return 0;
+ }
+}
+
+#else /* STRERROR_R_CHAR_P */
+/* Now the POSIX version. */
+
+static int
+system_strerror_r (int no, char *buf, size_t buflen)
+{
+ return strerror_r (no, buf, buflen);
+}
+
+#endif /* STRERROR_R_CHAR_P */
+
+#else /* HAVE_STRERROR_H */
+/* Without strerror_r(), we can still provide a non-thread-safe
+ version. Maybe we are even lucky and the system's strerror() is
+ already thread-safe. */
+
+static int
+system_strerror_r (int no, char *buf, size_t buflen)
+{
+ char *errstr = strerror (no);
+
+ if (!errstr)
+ {
+ int saved_errno = errno;
+
+ if (saved_errno != EINVAL)
+ snprintf (buf, buflen, "strerror failed: %i\n", errno);
+ return saved_errno;
+ }
+ else
+ {
+ size_t errstr_len = strlen (errstr) + 1;
+ size_t cpy_len = errstr_len < buflen ? errstr_len : buflen;
+ memcpy (buf, errstr, cpy_len);
+ return cpy_len == errstr_len ? 0 : ERANGE;
+ }
+}
+#endif
+
+
+/* Return the error string for ERR in the user-supplied buffer BUF of
+ size BUFLEN. This function is, in contrast to gpg_strerror,
+ thread-safe if a thread-safe strerror_r() function is provided by
+ the system. If the function succeeds, 0 is returned and BUF
+ contains the string describing the error. If the buffer was not
+ large enough, ERANGE is returned and BUF contains as much of the
+ beginning of the error string as fits into the buffer. */
+int
+gpg_strerror_r (gpg_error_t err, char *buf, size_t buflen)
+{
+ gpg_err_code_t code = gpg_err_code (err);
+ const char *errstr;
+ size_t errstr_len;
+ size_t cpy_len;
+
+ if (code & GPG_ERR_SYSTEM_ERROR)
+ {
+ int no = gpg_err_code_to_errno (code);
+ if (no)
+ {
+ int system_err = system_strerror_r (no, buf, buflen);
+
+ if (system_err != EINVAL)
+ {
+ if (buflen)
+ buf[buflen - 1] = '\0';
+ return system_err;
+ }
+ }
+ code = GPG_ERR_UNKNOWN_ERRNO;
+ }
+
+ errstr = dgettext (PACKAGE, msgstr + msgidx[msgidxof (code)]);
+ errstr_len = strlen (errstr) + 1;
+ cpy_len = errstr_len < buflen ? errstr_len : buflen;
+ memcpy (buf, errstr, cpy_len);
+ if (buflen)
+ buf[buflen - 1] = '\0';
+
+ return cpy_len == errstr_len ? 0 : ERANGE;
+}
diff --git a/src/strsource-sym.c b/src/strsource-sym.c
new file mode 100644
index 0000000..a191310
--- /dev/null
+++ b/src/strsource-sym.c
@@ -0,0 +1,43 @@
+/* strsource-sym.c - Describing an error source with its symbol name.
+ Copyright (C) 2003, 2004 g10 Code GmbH
+
+ This file is part of libgpg-error.
+
+ libgpg-error 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 2.1 of
+ the License, or (at your option) any later version.
+
+ libgpg-error 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 libgpg-error; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA. */
+
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stddef.h>
+
+#include <gpg-error.h>
+
+#include "err-sources-sym.h"
+
+/* Return a pointer to a string containing the name of the symbol of
+ the error source in the error value ERR. Returns NULL if the error
+ code is not known. */
+const char *
+gpg_strsource_sym (gpg_error_t err)
+{
+ gpg_err_source_t source = gpg_err_source (err);
+
+ if (msgidxof (source) == msgidxof (GPG_ERR_SOURCE_DIM))
+ return NULL;
+
+ return msgstr + msgidx[msgidxof (source)];
+}
diff --git a/src/strsource.c b/src/strsource.c
new file mode 100644
index 0000000..66d783c
--- /dev/null
+++ b/src/strsource.c
@@ -0,0 +1,37 @@
+/* strsource.c - Describing an error source.
+ Copyright (C) 2003 g10 Code GmbH
+
+ This file is part of libgpg-error.
+
+ libgpg-error 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 2.1 of
+ the License, or (at your option) any later version.
+
+ libgpg-error 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 libgpg-error; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA. */
+
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <gpg-error.h>
+
+#include "gettext.h"
+#include "err-sources.h"
+
+/* Return a pointer to a string containing a description of the error
+ source in the error value ERR. */
+const char *
+gpg_strsource (gpg_error_t err)
+{
+ gpg_err_source_t source = gpg_err_source (err);
+ return dgettext (PACKAGE, msgstr + msgidx[msgidxof (source)]);
+}
diff --git a/src/versioninfo.rc.in b/src/versioninfo.rc.in
new file mode 100644
index 0000000..3384adc
--- /dev/null
+++ b/src/versioninfo.rc.in
@@ -0,0 +1,52 @@
+/* versioninfo.rc.in - for libgpg-error
+ * Copyright (C) 2005 g10 Code GmbH
+ *
+ * This file is free software; as a special exception the author gives
+ * unlimited permission to copy and/or distribute it, with or without
+ * modifications, as long as this notice is preserved.
+ *
+ * This program 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.
+ */
+
+/* This file is processed by configure to create versioninfo.rc */
+
+#line __LINE__ "versioninfo.rc.in"
+
+#include <afxres.h>
+
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION @BUILD_FILEVERSION@
+ PRODUCTVERSION @BUILD_FILEVERSION@
+ FILEFLAGSMASK 0x3fL
+#ifdef _DEBUG
+ FILEFLAGS 0x21L
+#else
+ FILEFLAGS 0x20L
+#endif
+ FILEOS 0x40004L
+ FILETYPE 0x1L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "Comments", "Provided under the terms of the GNU Lesser General Public License.\0"
+ VALUE "CompanyName", "g10 Code GmbH\0"
+ VALUE "FileDescription", "libgpg-error - Common error codes\0"
+ VALUE "FileVersion", "@VERSION@\0"
+ VALUE "InternalName", "libgpg-error\0"
+ VALUE "LegalCopyright", "Copyright © 2005 g10 Code GmbH\0"
+ VALUE "LegalTrademarks", "\0"
+ VALUE "OriginalFilename", "libgpg-error.dll\0"
+ VALUE "PrivateBuild", "\0"
+ VALUE "ProductName", "libgpg-error\0"
+ VALUE "ProductVersion", "@VERSION@\0"
+ VALUE "SpecialBuild", "@BUILD_TIMESTAMP@\0"
+ END
+ END
+END
+
diff --git a/src/w32-add.h b/src/w32-add.h
new file mode 100644
index 0000000..02848ac
--- /dev/null
+++ b/src/w32-add.h
@@ -0,0 +1,40 @@
+## w32-add.h - Snippet to be be included into gpg-error.h.
+## Comments are indicated by a double hash mark. Due to a
+## peculiarity of the script the first used line must not
+## start with a hash mark.
+
+/* Decide whether to use the format_arg attribute. */
+#if _GPG_ERR_GCC_VERSION > 20800
+# define _GPG_ERR_ATTR_FORMAT_ARG(a) __attribute__ ((__format_arg__ (a)))
+#else
+# define _GPG_ERR_ATTR_FORMAT_ARG(a)
+#endif
+
+/* A lean gettext implementation based on GNU style mo files which are
+ required to be encoded in UTF-8. There is a limit on 65534 entries
+ to save some RAM. Only Germanic plural rules are supported. */
+const char *_gpg_w32_bindtextdomain (const char *domainname,
+ const char *dirname);
+const char *_gpg_w32_textdomain (const char *domainname);
+const char *_gpg_w32_gettext (const char *msgid)
+ _GPG_ERR_ATTR_FORMAT_ARG (1);
+const char *_gpg_w32_dgettext (const char *domainname, const char *msgid)
+ _GPG_ERR_ATTR_FORMAT_ARG (2);
+const char *_gpg_w32_dngettext (const char *domainname, const char *msgid1,
+ const char *msgid2, unsigned long int n)
+ _GPG_ERR_ATTR_FORMAT_ARG (2) _GPG_ERR_ATTR_FORMAT_ARG (3);
+const char *_gpg_w32_gettext_localename (void);
+int _gpg_w32_gettext_use_utf8 (int value);
+
+#ifdef GPG_ERR_ENABLE_GETTEXT_MACROS
+# define bindtextdomain(a,b) _gpg_w32_bindtextdomain ((a), (b))
+# define textdomain(a) _gpg_w32_textdomain ((a))
+# define gettext(a) _gpg_w32_gettext ((a))
+# define dgettext(a,b) _gpg_w32_dgettext ((a), (b))
+# define ngettext(a,b,c) _gpg_w32_dngettext (NULL, (a), (b), (c))
+# define dngettext(a,b,c,d) _gpg_w32_dngettext ((a), (b), (c), (d))
+# define gettext_localename() _gpg_w32_gettext_localename ()
+# define gettext_use_utf8(a) _gpg_w32_gettext_use_utf8 (a)
+#endif /*GPG_ERR_ENABLE_GETTEXT_MACROS*/
+
+
diff --git a/src/w32-gettext.c b/src/w32-gettext.c
new file mode 100644
index 0000000..ca4fbbd
--- /dev/null
+++ b/src/w32-gettext.c
@@ -0,0 +1,1905 @@
+/* w32-gettext.h - A simple gettext implementation for Windows targets.
+ Copyright (C) 1995, 1996, 1997, 1999, 2005, 2007,
+ 2008, 2010 Free Software Foundation, Inc.
+
+ This file is part of libgpg-error.
+
+ libgpg-error 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 2.1 of
+ the License, or (at your option) any later version.
+
+ libgpg-error 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/>.
+ */
+
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+#if !defined (_WIN32) && !defined (__CYGWIN32__)
+# error This module may only be build for Windows or Cygwin32
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <ctype.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <stdint.h>
+#ifndef HAVE_W32CE_SYSTEM
+# include <locale.h>
+#endif /*HAVE_W32CE_SYSTEM*/
+#include <windows.h>
+
+#ifdef JNLIB_IN_JNLIB
+#include "libjnlib-config.h"
+#endif
+
+#ifndef jnlib_malloc
+# define jnlib_malloc(a) malloc ((a))
+# define jnlib_calloc(a,b) calloc ((a), (b))
+# define jnlib_free(a) free ((a))
+# define jnlib_xstrdup(a) not_used
+#endif /*!jnlib_malloc*/
+
+#include "init.h"
+
+
+
+/* localname.c from gettext BEGIN. */
+
+/* Determine the current selected locale.
+ Copyright (C) 1995-1999, 2000-2003 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ USA. */
+
+/* Written by Ulrich Drepper <drepper@gnu.org>, 1995. */
+/* Win32 code written by Tor Lillqvist <tml@iki.fi>. */
+/* Renamed _nl_locale_name, removed unsed args, removed include files,
+ non-W32 code and changed comments <wk@gnupg.org>. */
+
+/* Mingw headers don't have latest language and sublanguage codes. */
+#ifndef LANG_AFRIKAANS
+#define LANG_AFRIKAANS 0x36
+#endif
+#ifndef LANG_ALBANIAN
+#define LANG_ALBANIAN 0x1c
+#endif
+#ifndef LANG_AMHARIC
+#define LANG_AMHARIC 0x5e
+#endif
+#ifndef LANG_ARABIC
+#define LANG_ARABIC 0x01
+#endif
+#ifndef LANG_ARMENIAN
+#define LANG_ARMENIAN 0x2b
+#endif
+#ifndef LANG_ASSAMESE
+#define LANG_ASSAMESE 0x4d
+#endif
+#ifndef LANG_AZERI
+#define LANG_AZERI 0x2c
+#endif
+#ifndef LANG_BASQUE
+#define LANG_BASQUE 0x2d
+#endif
+#ifndef LANG_BELARUSIAN
+#define LANG_BELARUSIAN 0x23
+#endif
+#ifndef LANG_BENGALI
+#define LANG_BENGALI 0x45
+#endif
+#ifndef LANG_BURMESE
+#define LANG_BURMESE 0x55
+#endif
+#ifndef LANG_CAMBODIAN
+#define LANG_CAMBODIAN 0x53
+#endif
+#ifndef LANG_CATALAN
+#define LANG_CATALAN 0x03
+#endif
+#ifndef LANG_CHEROKEE
+#define LANG_CHEROKEE 0x5c
+#endif
+#ifndef LANG_DIVEHI
+#define LANG_DIVEHI 0x65
+#endif
+#ifndef LANG_EDO
+#define LANG_EDO 0x66
+#endif
+#ifndef LANG_ESTONIAN
+#define LANG_ESTONIAN 0x25
+#endif
+#ifndef LANG_FAEROESE
+#define LANG_FAEROESE 0x38
+#endif
+#ifndef LANG_FARSI
+#define LANG_FARSI 0x29
+#endif
+#ifndef LANG_FRISIAN
+#define LANG_FRISIAN 0x62
+#endif
+#ifndef LANG_FULFULDE
+#define LANG_FULFULDE 0x67
+#endif
+#ifndef LANG_GAELIC
+#define LANG_GAELIC 0x3c
+#endif
+#ifndef LANG_GALICIAN
+#define LANG_GALICIAN 0x56
+#endif
+#ifndef LANG_GEORGIAN
+#define LANG_GEORGIAN 0x37
+#endif
+#ifndef LANG_GUARANI
+#define LANG_GUARANI 0x74
+#endif
+#ifndef LANG_GUJARATI
+#define LANG_GUJARATI 0x47
+#endif
+#ifndef LANG_HAUSA
+#define LANG_HAUSA 0x68
+#endif
+#ifndef LANG_HAWAIIAN
+#define LANG_HAWAIIAN 0x75
+#endif
+#ifndef LANG_HEBREW
+#define LANG_HEBREW 0x0d
+#endif
+#ifndef LANG_HINDI
+#define LANG_HINDI 0x39
+#endif
+#ifndef LANG_IBIBIO
+#define LANG_IBIBIO 0x69
+#endif
+#ifndef LANG_IGBO
+#define LANG_IGBO 0x70
+#endif
+#ifndef LANG_INDONESIAN
+#define LANG_INDONESIAN 0x21
+#endif
+#ifndef LANG_INUKTITUT
+#define LANG_INUKTITUT 0x5d
+#endif
+#ifndef LANG_KANNADA
+#define LANG_KANNADA 0x4b
+#endif
+#ifndef LANG_KANURI
+#define LANG_KANURI 0x71
+#endif
+#ifndef LANG_KASHMIRI
+#define LANG_KASHMIRI 0x60
+#endif
+#ifndef LANG_KAZAK
+#define LANG_KAZAK 0x3f
+#endif
+#ifndef LANG_KONKANI
+#define LANG_KONKANI 0x57
+#endif
+#ifndef LANG_KYRGYZ
+#define LANG_KYRGYZ 0x40
+#endif
+#ifndef LANG_LAO
+#define LANG_LAO 0x54
+#endif
+#ifndef LANG_LATIN
+#define LANG_LATIN 0x76
+#endif
+#ifndef LANG_LATVIAN
+#define LANG_LATVIAN 0x26
+#endif
+#ifndef LANG_LITHUANIAN
+#define LANG_LITHUANIAN 0x27
+#endif
+#ifndef LANG_MACEDONIAN
+#define LANG_MACEDONIAN 0x2f
+#endif
+#ifndef LANG_MALAY
+#define LANG_MALAY 0x3e
+#endif
+#ifndef LANG_MALAYALAM
+#define LANG_MALAYALAM 0x4c
+#endif
+#ifndef LANG_MALTESE
+#define LANG_MALTESE 0x3a
+#endif
+#ifndef LANG_MANIPURI
+#define LANG_MANIPURI 0x58
+#endif
+#ifndef LANG_MARATHI
+#define LANG_MARATHI 0x4e
+#endif
+#ifndef LANG_MONGOLIAN
+#define LANG_MONGOLIAN 0x50
+#endif
+#ifndef LANG_NEPALI
+#define LANG_NEPALI 0x61
+#endif
+#ifndef LANG_ORIYA
+#define LANG_ORIYA 0x48
+#endif
+#ifndef LANG_OROMO
+#define LANG_OROMO 0x72
+#endif
+#ifndef LANG_PAPIAMENTU
+#define LANG_PAPIAMENTU 0x79
+#endif
+#ifndef LANG_PASHTO
+#define LANG_PASHTO 0x63
+#endif
+#ifndef LANG_PUNJABI
+#define LANG_PUNJABI 0x46
+#endif
+#ifndef LANG_RHAETO_ROMANCE
+#define LANG_RHAETO_ROMANCE 0x17
+#endif
+#ifndef LANG_SAAMI
+#define LANG_SAAMI 0x3b
+#endif
+#ifndef LANG_SANSKRIT
+#define LANG_SANSKRIT 0x4f
+#endif
+#ifndef LANG_SERBIAN
+#define LANG_SERBIAN 0x1a
+#endif
+#ifndef LANG_SINDHI
+#define LANG_SINDHI 0x59
+#endif
+#ifndef LANG_SINHALESE
+#define LANG_SINHALESE 0x5b
+#endif
+#ifndef LANG_SLOVAK
+#define LANG_SLOVAK 0x1b
+#endif
+#ifndef LANG_SOMALI
+#define LANG_SOMALI 0x77
+#endif
+#ifndef LANG_SORBIAN
+#define LANG_SORBIAN 0x2e
+#endif
+#ifndef LANG_SUTU
+#define LANG_SUTU 0x30
+#endif
+#ifndef LANG_SWAHILI
+#define LANG_SWAHILI 0x41
+#endif
+#ifndef LANG_SYRIAC
+#define LANG_SYRIAC 0x5a
+#endif
+#ifndef LANG_TAGALOG
+#define LANG_TAGALOG 0x64
+#endif
+#ifndef LANG_TAJIK
+#define LANG_TAJIK 0x28
+#endif
+#ifndef LANG_TAMAZIGHT
+#define LANG_TAMAZIGHT 0x5f
+#endif
+#ifndef LANG_TAMIL
+#define LANG_TAMIL 0x49
+#endif
+#ifndef LANG_TATAR
+#define LANG_TATAR 0x44
+#endif
+#ifndef LANG_TELUGU
+#define LANG_TELUGU 0x4a
+#endif
+#ifndef LANG_THAI
+#define LANG_THAI 0x1e
+#endif
+#ifndef LANG_TIBETAN
+#define LANG_TIBETAN 0x51
+#endif
+#ifndef LANG_TIGRINYA
+#define LANG_TIGRINYA 0x73
+#endif
+#ifndef LANG_TSONGA
+#define LANG_TSONGA 0x31
+#endif
+#ifndef LANG_TSWANA
+#define LANG_TSWANA 0x32
+#endif
+#ifndef LANG_TURKMEN
+#define LANG_TURKMEN 0x42
+#endif
+#ifndef LANG_UKRAINIAN
+#define LANG_UKRAINIAN 0x22
+#endif
+#ifndef LANG_URDU
+#define LANG_URDU 0x20
+#endif
+#ifndef LANG_UZBEK
+#define LANG_UZBEK 0x43
+#endif
+#ifndef LANG_VENDA
+#define LANG_VENDA 0x33
+#endif
+#ifndef LANG_VIETNAMESE
+#define LANG_VIETNAMESE 0x2a
+#endif
+#ifndef LANG_WELSH
+#define LANG_WELSH 0x52
+#endif
+#ifndef LANG_XHOSA
+#define LANG_XHOSA 0x34
+#endif
+#ifndef LANG_YI
+#define LANG_YI 0x78
+#endif
+#ifndef LANG_YIDDISH
+#define LANG_YIDDISH 0x3d
+#endif
+#ifndef LANG_YORUBA
+#define LANG_YORUBA 0x6a
+#endif
+#ifndef LANG_ZULU
+#define LANG_ZULU 0x35
+#endif
+#ifndef SUBLANG_ARABIC_SAUDI_ARABIA
+#define SUBLANG_ARABIC_SAUDI_ARABIA 0x01
+#endif
+#ifndef SUBLANG_ARABIC_IRAQ
+#define SUBLANG_ARABIC_IRAQ 0x02
+#endif
+#ifndef SUBLANG_ARABIC_EGYPT
+#define SUBLANG_ARABIC_EGYPT 0x03
+#endif
+#ifndef SUBLANG_ARABIC_LIBYA
+#define SUBLANG_ARABIC_LIBYA 0x04
+#endif
+#ifndef SUBLANG_ARABIC_ALGERIA
+#define SUBLANG_ARABIC_ALGERIA 0x05
+#endif
+#ifndef SUBLANG_ARABIC_MOROCCO
+#define SUBLANG_ARABIC_MOROCCO 0x06
+#endif
+#ifndef SUBLANG_ARABIC_TUNISIA
+#define SUBLANG_ARABIC_TUNISIA 0x07
+#endif
+#ifndef SUBLANG_ARABIC_OMAN
+#define SUBLANG_ARABIC_OMAN 0x08
+#endif
+#ifndef SUBLANG_ARABIC_YEMEN
+#define SUBLANG_ARABIC_YEMEN 0x09
+#endif
+#ifndef SUBLANG_ARABIC_SYRIA
+#define SUBLANG_ARABIC_SYRIA 0x0a
+#endif
+#ifndef SUBLANG_ARABIC_JORDAN
+#define SUBLANG_ARABIC_JORDAN 0x0b
+#endif
+#ifndef SUBLANG_ARABIC_LEBANON
+#define SUBLANG_ARABIC_LEBANON 0x0c
+#endif
+#ifndef SUBLANG_ARABIC_KUWAIT
+#define SUBLANG_ARABIC_KUWAIT 0x0d
+#endif
+#ifndef SUBLANG_ARABIC_UAE
+#define SUBLANG_ARABIC_UAE 0x0e
+#endif
+#ifndef SUBLANG_ARABIC_BAHRAIN
+#define SUBLANG_ARABIC_BAHRAIN 0x0f
+#endif
+#ifndef SUBLANG_ARABIC_QATAR
+#define SUBLANG_ARABIC_QATAR 0x10
+#endif
+#ifndef SUBLANG_AZERI_LATIN
+#define SUBLANG_AZERI_LATIN 0x01
+#endif
+#ifndef SUBLANG_AZERI_CYRILLIC
+#define SUBLANG_AZERI_CYRILLIC 0x02
+#endif
+#ifndef SUBLANG_BENGALI_INDIA
+#define SUBLANG_BENGALI_INDIA 0x01
+#endif
+#ifndef SUBLANG_BENGALI_BANGLADESH
+#define SUBLANG_BENGALI_BANGLADESH 0x02
+#endif
+#ifndef SUBLANG_CHINESE_MACAU
+#define SUBLANG_CHINESE_MACAU 0x05
+#endif
+#ifndef SUBLANG_ENGLISH_SOUTH_AFRICA
+#define SUBLANG_ENGLISH_SOUTH_AFRICA 0x07
+#endif
+#ifndef SUBLANG_ENGLISH_JAMAICA
+#define SUBLANG_ENGLISH_JAMAICA 0x08
+#endif
+#ifndef SUBLANG_ENGLISH_CARIBBEAN
+#define SUBLANG_ENGLISH_CARIBBEAN 0x09
+#endif
+#ifndef SUBLANG_ENGLISH_BELIZE
+#define SUBLANG_ENGLISH_BELIZE 0x0a
+#endif
+#ifndef SUBLANG_ENGLISH_TRINIDAD
+#define SUBLANG_ENGLISH_TRINIDAD 0x0b
+#endif
+#ifndef SUBLANG_ENGLISH_ZIMBABWE
+#define SUBLANG_ENGLISH_ZIMBABWE 0x0c
+#endif
+#ifndef SUBLANG_ENGLISH_PHILIPPINES
+#define SUBLANG_ENGLISH_PHILIPPINES 0x0d
+#endif
+#ifndef SUBLANG_ENGLISH_INDONESIA
+#define SUBLANG_ENGLISH_INDONESIA 0x0e
+#endif
+#ifndef SUBLANG_ENGLISH_HONGKONG
+#define SUBLANG_ENGLISH_HONGKONG 0x0f
+#endif
+#ifndef SUBLANG_ENGLISH_INDIA
+#define SUBLANG_ENGLISH_INDIA 0x10
+#endif
+#ifndef SUBLANG_ENGLISH_MALAYSIA
+#define SUBLANG_ENGLISH_MALAYSIA 0x11
+#endif
+#ifndef SUBLANG_ENGLISH_SINGAPORE
+#define SUBLANG_ENGLISH_SINGAPORE 0x12
+#endif
+#ifndef SUBLANG_FRENCH_LUXEMBOURG
+#define SUBLANG_FRENCH_LUXEMBOURG 0x05
+#endif
+#ifndef SUBLANG_FRENCH_MONACO
+#define SUBLANG_FRENCH_MONACO 0x06
+#endif
+#ifndef SUBLANG_FRENCH_WESTINDIES
+#define SUBLANG_FRENCH_WESTINDIES 0x07
+#endif
+#ifndef SUBLANG_FRENCH_REUNION
+#define SUBLANG_FRENCH_REUNION 0x08
+#endif
+#ifndef SUBLANG_FRENCH_CONGO
+#define SUBLANG_FRENCH_CONGO 0x09
+#endif
+#ifndef SUBLANG_FRENCH_SENEGAL
+#define SUBLANG_FRENCH_SENEGAL 0x0a
+#endif
+#ifndef SUBLANG_FRENCH_CAMEROON
+#define SUBLANG_FRENCH_CAMEROON 0x0b
+#endif
+#ifndef SUBLANG_FRENCH_COTEDIVOIRE
+#define SUBLANG_FRENCH_COTEDIVOIRE 0x0c
+#endif
+#ifndef SUBLANG_FRENCH_MALI
+#define SUBLANG_FRENCH_MALI 0x0d
+#endif
+#ifndef SUBLANG_FRENCH_MOROCCO
+#define SUBLANG_FRENCH_MOROCCO 0x0e
+#endif
+#ifndef SUBLANG_FRENCH_HAITI
+#define SUBLANG_FRENCH_HAITI 0x0f
+#endif
+#ifndef SUBLANG_GERMAN_LUXEMBOURG
+#define SUBLANG_GERMAN_LUXEMBOURG 0x04
+#endif
+#ifndef SUBLANG_GERMAN_LIECHTENSTEIN
+#define SUBLANG_GERMAN_LIECHTENSTEIN 0x05
+#endif
+#ifndef SUBLANG_KASHMIRI_INDIA
+#define SUBLANG_KASHMIRI_INDIA 0x02
+#endif
+#ifndef SUBLANG_MALAY_MALAYSIA
+#define SUBLANG_MALAY_MALAYSIA 0x01
+#endif
+#ifndef SUBLANG_MALAY_BRUNEI_DARUSSALAM
+#define SUBLANG_MALAY_BRUNEI_DARUSSALAM 0x02
+#endif
+#ifndef SUBLANG_NEPALI_INDIA
+#define SUBLANG_NEPALI_INDIA 0x02
+#endif
+#ifndef SUBLANG_PUNJABI_INDIA
+#define SUBLANG_PUNJABI_INDIA 0x01
+#endif
+#ifndef SUBLANG_ROMANIAN_ROMANIA
+#define SUBLANG_ROMANIAN_ROMANIA 0x01
+#endif
+#ifndef SUBLANG_SERBIAN_LATIN
+#define SUBLANG_SERBIAN_LATIN 0x02
+#endif
+#ifndef SUBLANG_SERBIAN_CYRILLIC
+#define SUBLANG_SERBIAN_CYRILLIC 0x03
+#endif
+#ifndef SUBLANG_SINDHI_INDIA
+#define SUBLANG_SINDHI_INDIA 0x00
+#endif
+#ifndef SUBLANG_SINDHI_PAKISTAN
+#define SUBLANG_SINDHI_PAKISTAN 0x01
+#endif
+#ifndef SUBLANG_SPANISH_GUATEMALA
+#define SUBLANG_SPANISH_GUATEMALA 0x04
+#endif
+#ifndef SUBLANG_SPANISH_COSTA_RICA
+#define SUBLANG_SPANISH_COSTA_RICA 0x05
+#endif
+#ifndef SUBLANG_SPANISH_PANAMA
+#define SUBLANG_SPANISH_PANAMA 0x06
+#endif
+#ifndef SUBLANG_SPANISH_DOMINICAN_REPUBLIC
+#define SUBLANG_SPANISH_DOMINICAN_REPUBLIC 0x07
+#endif
+#ifndef SUBLANG_SPANISH_VENEZUELA
+#define SUBLANG_SPANISH_VENEZUELA 0x08
+#endif
+#ifndef SUBLANG_SPANISH_COLOMBIA
+#define SUBLANG_SPANISH_COLOMBIA 0x09
+#endif
+#ifndef SUBLANG_SPANISH_PERU
+#define SUBLANG_SPANISH_PERU 0x0a
+#endif
+#ifndef SUBLANG_SPANISH_ARGENTINA
+#define SUBLANG_SPANISH_ARGENTINA 0x0b
+#endif
+#ifndef SUBLANG_SPANISH_ECUADOR
+#define SUBLANG_SPANISH_ECUADOR 0x0c
+#endif
+#ifndef SUBLANG_SPANISH_CHILE
+#define SUBLANG_SPANISH_CHILE 0x0d
+#endif
+#ifndef SUBLANG_SPANISH_URUGUAY
+#define SUBLANG_SPANISH_URUGUAY 0x0e
+#endif
+#ifndef SUBLANG_SPANISH_PARAGUAY
+#define SUBLANG_SPANISH_PARAGUAY 0x0f
+#endif
+#ifndef SUBLANG_SPANISH_BOLIVIA
+#define SUBLANG_SPANISH_BOLIVIA 0x10
+#endif
+#ifndef SUBLANG_SPANISH_EL_SALVADOR
+#define SUBLANG_SPANISH_EL_SALVADOR 0x11
+#endif
+#ifndef SUBLANG_SPANISH_HONDURAS
+#define SUBLANG_SPANISH_HONDURAS 0x12
+#endif
+#ifndef SUBLANG_SPANISH_NICARAGUA
+#define SUBLANG_SPANISH_NICARAGUA 0x13
+#endif
+#ifndef SUBLANG_SPANISH_PUERTO_RICO
+#define SUBLANG_SPANISH_PUERTO_RICO 0x14
+#endif
+#ifndef SUBLANG_SWEDISH_FINLAND
+#define SUBLANG_SWEDISH_FINLAND 0x02
+#endif
+#ifndef SUBLANG_TAMAZIGHT_ARABIC
+#define SUBLANG_TAMAZIGHT_ARABIC 0x01
+#endif
+#ifndef SUBLANG_TAMAZIGHT_LATIN
+#define SUBLANG_TAMAZIGHT_LATIN 0x02
+#endif
+#ifndef SUBLANG_TIGRINYA_ETHIOPIA
+#define SUBLANG_TIGRINYA_ETHIOPIA 0x00
+#endif
+#ifndef SUBLANG_TIGRINYA_ERITREA
+#define SUBLANG_TIGRINYA_ERITREA 0x01
+#endif
+#ifndef SUBLANG_URDU_PAKISTAN
+#define SUBLANG_URDU_PAKISTAN 0x01
+#endif
+#ifndef SUBLANG_URDU_INDIA
+#define SUBLANG_URDU_INDIA 0x02
+#endif
+#ifndef SUBLANG_UZBEK_LATIN
+#define SUBLANG_UZBEK_LATIN 0x01
+#endif
+#ifndef SUBLANG_UZBEK_CYRILLIC
+#define SUBLANG_UZBEK_CYRILLIC 0x02
+#endif
+
+/* Return an XPG style locale name
+ language[_territory[.codeset]][@modifier].
+ Don't even bother determining the codeset; it's not useful in this
+ context, because message catalogs are not specific to a single
+ codeset. The result must not be freed; it is statically
+ allocated. */
+static const char *
+my_nl_locale_name (const char *categoryname)
+{
+ const char *retval;
+ LCID lcid;
+ LANGID langid;
+ int primary, sub;
+
+ /* Let the user override the system settings through environment
+ variables, as on POSIX systems. */
+#ifndef HAVE_W32CE_SYSTEM
+ retval = getenv ("LC_ALL");
+ if (retval != NULL && retval[0] != '\0')
+ return retval;
+ retval = getenv (categoryname);
+ if (retval != NULL && retval[0] != '\0')
+ return retval;
+ retval = getenv ("LANG");
+ if (retval != NULL && retval[0] != '\0')
+ return retval;
+#endif /*!HAVE_W32CE_SYSTEM*/
+
+ /* Use native Win32 API locale ID. */
+#ifdef HAVE_W32CE_SYSTEM
+ lcid = GetSystemDefaultLCID ();
+#else
+ lcid = GetThreadLocale ();
+#endif
+
+ /* Strip off the sorting rules, keep only the language part. */
+ langid = LANGIDFROMLCID (lcid);
+
+ /* Split into language and territory part. */
+ primary = PRIMARYLANGID (langid);
+ sub = SUBLANGID (langid);
+
+ /* Dispatch on language.
+ See also http://www.unicode.org/unicode/onlinedat/languages.html .
+ For details about languages, see http://www.ethnologue.com/ . */
+ switch (primary)
+ {
+ case LANG_AFRIKAANS: return "af_ZA";
+ case LANG_ALBANIAN: return "sq_AL";
+ case LANG_AMHARIC: return "am_ET";
+ case LANG_ARABIC:
+ switch (sub)
+ {
+ case SUBLANG_ARABIC_SAUDI_ARABIA: return "ar_SA";
+ case SUBLANG_ARABIC_IRAQ: return "ar_IQ";
+ case SUBLANG_ARABIC_EGYPT: return "ar_EG";
+ case SUBLANG_ARABIC_LIBYA: return "ar_LY";
+ case SUBLANG_ARABIC_ALGERIA: return "ar_DZ";
+ case SUBLANG_ARABIC_MOROCCO: return "ar_MA";
+ case SUBLANG_ARABIC_TUNISIA: return "ar_TN";
+ case SUBLANG_ARABIC_OMAN: return "ar_OM";
+ case SUBLANG_ARABIC_YEMEN: return "ar_YE";
+ case SUBLANG_ARABIC_SYRIA: return "ar_SY";
+ case SUBLANG_ARABIC_JORDAN: return "ar_JO";
+ case SUBLANG_ARABIC_LEBANON: return "ar_LB";
+ case SUBLANG_ARABIC_KUWAIT: return "ar_KW";
+ case SUBLANG_ARABIC_UAE: return "ar_AE";
+ case SUBLANG_ARABIC_BAHRAIN: return "ar_BH";
+ case SUBLANG_ARABIC_QATAR: return "ar_QA";
+ }
+ return "ar";
+ case LANG_ARMENIAN: return "hy_AM";
+ case LANG_ASSAMESE: return "as_IN";
+ case LANG_AZERI:
+ switch (sub)
+ {
+ /* FIXME: Adjust this when Azerbaijani locales appear on Unix. */
+ case SUBLANG_AZERI_LATIN: return "az_AZ@latin";
+ case SUBLANG_AZERI_CYRILLIC: return "az_AZ@cyrillic";
+ }
+ return "az";
+ case LANG_BASQUE:
+ return "eu"; /* Ambiguous: could be "eu_ES" or "eu_FR". */
+ case LANG_BELARUSIAN: return "be_BY";
+ case LANG_BENGALI:
+ switch (sub)
+ {
+ case SUBLANG_BENGALI_INDIA: return "bn_IN";
+ case SUBLANG_BENGALI_BANGLADESH: return "bn_BD";
+ }
+ return "bn";
+ case LANG_BULGARIAN: return "bg_BG";
+ case LANG_BURMESE: return "my_MM";
+ case LANG_CAMBODIAN: return "km_KH";
+ case LANG_CATALAN: return "ca_ES";
+ case LANG_CHEROKEE: return "chr_US";
+ case LANG_CHINESE:
+ switch (sub)
+ {
+ case SUBLANG_CHINESE_TRADITIONAL: return "zh_TW";
+ case SUBLANG_CHINESE_SIMPLIFIED: return "zh_CN";
+ case SUBLANG_CHINESE_HONGKONG: return "zh_HK";
+ case SUBLANG_CHINESE_SINGAPORE: return "zh_SG";
+ case SUBLANG_CHINESE_MACAU: return "zh_MO";
+ }
+ return "zh";
+ case LANG_CROATIAN: /* LANG_CROATIAN == LANG_SERBIAN
+ * What used to be called Serbo-Croatian
+ * should really now be two separate
+ * languages because of political reasons.
+ * (Says tml, who knows nothing about Serbian
+ * or Croatian.)
+ * (I can feel those flames coming already.)
+ */
+ switch (sub)
+ {
+ case SUBLANG_DEFAULT: return "hr_HR";
+ case SUBLANG_SERBIAN_LATIN: return "sr_CS";
+ case SUBLANG_SERBIAN_CYRILLIC: return "sr_CS@cyrillic";
+ }
+ return "hr";
+ case LANG_CZECH: return "cs_CZ";
+ case LANG_DANISH: return "da_DK";
+ case LANG_DIVEHI: return "div_MV";
+ case LANG_DUTCH:
+ switch (sub)
+ {
+ case SUBLANG_DUTCH: return "nl_NL";
+ case SUBLANG_DUTCH_BELGIAN: /* FLEMISH, VLAAMS */ return "nl_BE";
+ }
+ return "nl";
+ case LANG_EDO: return "bin_NG";
+ case LANG_ENGLISH:
+ switch (sub)
+ {
+ /* SUBLANG_ENGLISH_US == SUBLANG_DEFAULT. Heh. I thought
+ * English was the language spoken in England.
+ * Oh well.
+ */
+ case SUBLANG_ENGLISH_US: return "en_US";
+ case SUBLANG_ENGLISH_UK: return "en_GB";
+ case SUBLANG_ENGLISH_AUS: return "en_AU";
+ case SUBLANG_ENGLISH_CAN: return "en_CA";
+ case SUBLANG_ENGLISH_NZ: return "en_NZ";
+ case SUBLANG_ENGLISH_EIRE: return "en_IE";
+ case SUBLANG_ENGLISH_SOUTH_AFRICA: return "en_ZA";
+ case SUBLANG_ENGLISH_JAMAICA: return "en_JM";
+ case SUBLANG_ENGLISH_CARIBBEAN: return "en_GD"; /* Grenada? */
+ case SUBLANG_ENGLISH_BELIZE: return "en_BZ";
+ case SUBLANG_ENGLISH_TRINIDAD: return "en_TT";
+ case SUBLANG_ENGLISH_ZIMBABWE: return "en_ZW";
+ case SUBLANG_ENGLISH_PHILIPPINES: return "en_PH";
+ case SUBLANG_ENGLISH_INDONESIA: return "en_ID";
+ case SUBLANG_ENGLISH_HONGKONG: return "en_HK";
+ case SUBLANG_ENGLISH_INDIA: return "en_IN";
+ case SUBLANG_ENGLISH_MALAYSIA: return "en_MY";
+ case SUBLANG_ENGLISH_SINGAPORE: return "en_SG";
+ }
+ return "en";
+ case LANG_ESTONIAN: return "et_EE";
+ case LANG_FAEROESE: return "fo_FO";
+ case LANG_FARSI: return "fa_IR";
+ case LANG_FINNISH: return "fi_FI";
+ case LANG_FRENCH:
+ switch (sub)
+ {
+ case SUBLANG_FRENCH: return "fr_FR";
+ case SUBLANG_FRENCH_BELGIAN: /* WALLOON */ return "fr_BE";
+ case SUBLANG_FRENCH_CANADIAN: return "fr_CA";
+ case SUBLANG_FRENCH_SWISS: return "fr_CH";
+ case SUBLANG_FRENCH_LUXEMBOURG: return "fr_LU";
+ case SUBLANG_FRENCH_MONACO: return "fr_MC";
+ case SUBLANG_FRENCH_WESTINDIES: return "fr"; /* Caribbean? */
+ case SUBLANG_FRENCH_REUNION: return "fr_RE";
+ case SUBLANG_FRENCH_CONGO: return "fr_CG";
+ case SUBLANG_FRENCH_SENEGAL: return "fr_SN";
+ case SUBLANG_FRENCH_CAMEROON: return "fr_CM";
+ case SUBLANG_FRENCH_COTEDIVOIRE: return "fr_CI";
+ case SUBLANG_FRENCH_MALI: return "fr_ML";
+ case SUBLANG_FRENCH_MOROCCO: return "fr_MA";
+ case SUBLANG_FRENCH_HAITI: return "fr_HT";
+ }
+ return "fr";
+ case LANG_FRISIAN: return "fy_NL";
+ case LANG_FULFULDE: return "ful_NG";
+ case LANG_GAELIC:
+ switch (sub)
+ {
+ case 0x01: /* SCOTTISH */ return "gd_GB";
+ case 0x02: /* IRISH */ return "ga_IE";
+ }
+ return "C";
+ case LANG_GALICIAN: return "gl_ES";
+ case LANG_GEORGIAN: return "ka_GE";
+ case LANG_GERMAN:
+ switch (sub)
+ {
+ case SUBLANG_GERMAN: return "de_DE";
+ case SUBLANG_GERMAN_SWISS: return "de_CH";
+ case SUBLANG_GERMAN_AUSTRIAN: return "de_AT";
+ case SUBLANG_GERMAN_LUXEMBOURG: return "de_LU";
+ case SUBLANG_GERMAN_LIECHTENSTEIN: return "de_LI";
+ }
+ return "de";
+ case LANG_GREEK: return "el_GR";
+ case LANG_GUARANI: return "gn_PY";
+ case LANG_GUJARATI: return "gu_IN";
+ case LANG_HAUSA: return "ha_NG";
+ case LANG_HAWAIIAN:
+ /* FIXME: Do they mean Hawaiian ("haw_US", 1000 speakers)
+ or Hawaii Creole English ("cpe_US", 600000 speakers)? */
+ return "cpe_US";
+ case LANG_HEBREW: return "he_IL";
+ case LANG_HINDI: return "hi_IN";
+ case LANG_HUNGARIAN: return "hu_HU";
+ case LANG_IBIBIO: return "nic_NG";
+ case LANG_ICELANDIC: return "is_IS";
+ case LANG_IGBO: return "ibo_NG";
+ case LANG_INDONESIAN: return "id_ID";
+ case LANG_INUKTITUT: return "iu_CA";
+ case LANG_ITALIAN:
+ switch (sub)
+ {
+ case SUBLANG_ITALIAN: return "it_IT";
+ case SUBLANG_ITALIAN_SWISS: return "it_CH";
+ }
+ return "it";
+ case LANG_JAPANESE: return "ja_JP";
+ case LANG_KANNADA: return "kn_IN";
+ case LANG_KANURI: return "kau_NG";
+ case LANG_KASHMIRI:
+ switch (sub)
+ {
+ case SUBLANG_DEFAULT: return "ks_PK";
+ case SUBLANG_KASHMIRI_INDIA: return "ks_IN";
+ }
+ return "ks";
+ case LANG_KAZAK: return "kk_KZ";
+ case LANG_KONKANI:
+ /* FIXME: Adjust this when such locales appear on Unix. */
+ return "kok_IN";
+ case LANG_KOREAN: return "ko_KR";
+ case LANG_KYRGYZ: return "ky_KG";
+ case LANG_LAO: return "lo_LA";
+ case LANG_LATIN: return "la_VA";
+ case LANG_LATVIAN: return "lv_LV";
+ case LANG_LITHUANIAN: return "lt_LT";
+ case LANG_MACEDONIAN: return "mk_MK";
+ case LANG_MALAY:
+ switch (sub)
+ {
+ case SUBLANG_MALAY_MALAYSIA: return "ms_MY";
+ case SUBLANG_MALAY_BRUNEI_DARUSSALAM: return "ms_BN";
+ }
+ return "ms";
+ case LANG_MALAYALAM: return "ml_IN";
+ case LANG_MALTESE: return "mt_MT";
+ case LANG_MANIPURI:
+ /* FIXME: Adjust this when such locales appear on Unix. */
+ return "mni_IN";
+ case LANG_MARATHI: return "mr_IN";
+ case LANG_MONGOLIAN:
+ return "mn"; /* Ambiguous: could be "mn_CN" or "mn_MN". */
+ case LANG_NEPALI:
+ switch (sub)
+ {
+ case SUBLANG_DEFAULT: return "ne_NP";
+ case SUBLANG_NEPALI_INDIA: return "ne_IN";
+ }
+ return "ne";
+ case LANG_NORWEGIAN:
+ switch (sub)
+ {
+ case SUBLANG_NORWEGIAN_BOKMAL: return "no_NO";
+ case SUBLANG_NORWEGIAN_NYNORSK: return "nn_NO";
+ }
+ return "no";
+ case LANG_ORIYA: return "or_IN";
+ case LANG_OROMO: return "om_ET";
+ case LANG_PAPIAMENTU: return "pap_AN";
+ case LANG_PASHTO:
+ return "ps"; /* Ambiguous: could be "ps_PK" or "ps_AF". */
+ case LANG_POLISH: return "pl_PL";
+ case LANG_PORTUGUESE:
+ switch (sub)
+ {
+ case SUBLANG_PORTUGUESE: return "pt_PT";
+ /* Hmm. SUBLANG_PORTUGUESE_BRAZILIAN == SUBLANG_DEFAULT.
+ Same phenomenon as SUBLANG_ENGLISH_US == SUBLANG_DEFAULT. */
+ case SUBLANG_PORTUGUESE_BRAZILIAN: return "pt_BR";
+ }
+ return "pt";
+ case LANG_PUNJABI:
+ switch (sub)
+ {
+ case SUBLANG_PUNJABI_INDIA: return "pa_IN"; /* Gurmukhi script */
+ }
+ return "pa";
+ case LANG_RHAETO_ROMANCE: return "rm_CH";
+ case LANG_ROMANIAN:
+ switch (sub)
+ {
+ case SUBLANG_ROMANIAN_ROMANIA: return "ro_RO";
+ }
+ return "ro";
+ case LANG_RUSSIAN:
+ return "ru"; /* Ambiguous: could be "ru_RU" or "ru_UA" or "ru_MD". */
+ case LANG_SAAMI: /* actually Northern Sami */ return "se_NO";
+ case LANG_SANSKRIT: return "sa_IN";
+ case LANG_SINDHI:
+ switch (sub)
+ {
+ case SUBLANG_SINDHI_INDIA: return "sd_IN";
+ case SUBLANG_SINDHI_PAKISTAN: return "sd_PK";
+ }
+ return "sd";
+ case LANG_SINHALESE: return "si_LK";
+ case LANG_SLOVAK: return "sk_SK";
+ case LANG_SLOVENIAN: return "sl_SI";
+ case LANG_SOMALI: return "so_SO";
+ case LANG_SORBIAN:
+ /* FIXME: Adjust this when such locales appear on Unix. */
+ return "wen_DE";
+ case LANG_SPANISH:
+ switch (sub)
+ {
+ case SUBLANG_SPANISH: return "es_ES";
+ case SUBLANG_SPANISH_MEXICAN: return "es_MX";
+ case SUBLANG_SPANISH_MODERN:
+ return "es_ES@modern"; /* not seen on Unix */
+ case SUBLANG_SPANISH_GUATEMALA: return "es_GT";
+ case SUBLANG_SPANISH_COSTA_RICA: return "es_CR";
+ case SUBLANG_SPANISH_PANAMA: return "es_PA";
+ case SUBLANG_SPANISH_DOMINICAN_REPUBLIC: return "es_DO";
+ case SUBLANG_SPANISH_VENEZUELA: return "es_VE";
+ case SUBLANG_SPANISH_COLOMBIA: return "es_CO";
+ case SUBLANG_SPANISH_PERU: return "es_PE";
+ case SUBLANG_SPANISH_ARGENTINA: return "es_AR";
+ case SUBLANG_SPANISH_ECUADOR: return "es_EC";
+ case SUBLANG_SPANISH_CHILE: return "es_CL";
+ case SUBLANG_SPANISH_URUGUAY: return "es_UY";
+ case SUBLANG_SPANISH_PARAGUAY: return "es_PY";
+ case SUBLANG_SPANISH_BOLIVIA: return "es_BO";
+ case SUBLANG_SPANISH_EL_SALVADOR: return "es_SV";
+ case SUBLANG_SPANISH_HONDURAS: return "es_HN";
+ case SUBLANG_SPANISH_NICARAGUA: return "es_NI";
+ case SUBLANG_SPANISH_PUERTO_RICO: return "es_PR";
+ }
+ return "es";
+ case LANG_SUTU: return "bnt_TZ"; /* or "st_LS" or "nso_ZA"? */
+ case LANG_SWAHILI: return "sw_KE";
+ case LANG_SWEDISH:
+ switch (sub)
+ {
+ case SUBLANG_DEFAULT: return "sv_SE";
+ case SUBLANG_SWEDISH_FINLAND: return "sv_FI";
+ }
+ return "sv";
+ case LANG_SYRIAC: return "syr_TR"; /* An extinct language. */
+ case LANG_TAGALOG: return "tl_PH";
+ case LANG_TAJIK: return "tg_TJ";
+ case LANG_TAMAZIGHT:
+ switch (sub)
+ {
+ /* FIXME: Adjust this when Tamazight locales appear on Unix. */
+ case SUBLANG_TAMAZIGHT_ARABIC: return "ber_MA@arabic";
+ case SUBLANG_TAMAZIGHT_LATIN: return "ber_MA@latin";
+ }
+ return "ber_MA";
+ case LANG_TAMIL:
+ return "ta"; /* Ambiguous: could be "ta_IN" or "ta_LK" or "ta_SG". */
+ case LANG_TATAR: return "tt_RU";
+ case LANG_TELUGU: return "te_IN";
+ case LANG_THAI: return "th_TH";
+ case LANG_TIBETAN: return "bo_CN";
+ case LANG_TIGRINYA:
+ switch (sub)
+ {
+ case SUBLANG_TIGRINYA_ETHIOPIA: return "ti_ET";
+ case SUBLANG_TIGRINYA_ERITREA: return "ti_ER";
+ }
+ return "ti";
+ case LANG_TSONGA: return "ts_ZA";
+ case LANG_TSWANA: return "tn_BW";
+ case LANG_TURKISH: return "tr_TR";
+ case LANG_TURKMEN: return "tk_TM";
+ case LANG_UKRAINIAN: return "uk_UA";
+ case LANG_URDU:
+ switch (sub)
+ {
+ case SUBLANG_URDU_PAKISTAN: return "ur_PK";
+ case SUBLANG_URDU_INDIA: return "ur_IN";
+ }
+ return "ur";
+ case LANG_UZBEK:
+ switch (sub)
+ {
+ case SUBLANG_UZBEK_LATIN: return "uz_UZ";
+ case SUBLANG_UZBEK_CYRILLIC: return "uz_UZ@cyrillic";
+ }
+ return "uz";
+ case LANG_VENDA:
+ /* FIXME: It's not clear whether Venda has the ISO 639-2 two-letter code
+ "ve" or not.
+ http://www.loc.gov/standards/iso639-2/englangn.html has it, but
+ http://lcweb.loc.gov/standards/iso639-2/codechanges.html doesn't, */
+ return "ven_ZA"; /* or "ve_ZA"? */
+ case LANG_VIETNAMESE: return "vi_VN";
+ case LANG_WELSH: return "cy_GB";
+ case LANG_XHOSA: return "xh_ZA";
+ case LANG_YI: return "sit_CN";
+ case LANG_YIDDISH: return "yi_IL";
+ case LANG_YORUBA: return "yo_NG";
+ case LANG_ZULU: return "zu_ZA";
+ default: return "C";
+ }
+}
+
+/* localname.c from gettext END. */
+
+
+
+/* Support functions. */
+
+static __inline__ uint32_t
+do_swap_u32 (uint32_t i)
+{
+ return (i << 24) | ((i & 0xff00) << 8) | ((i >> 8) & 0xff00) | (i >> 24);
+}
+
+#define SWAPIT(flag, data) ((flag) ? do_swap_u32(data) : (data))
+
+
+/* We assume to have `unsigned long int' value with at least 32 bits. */
+#define HASHWORDBITS 32
+
+/* The so called `hashpjw' function by P.J. Weinberger
+ [see Aho/Sethi/Ullman, COMPILERS: Principles, Techniques and Tools,
+ 1986, 1987 Bell Telephone Laboratories, Inc.] */
+static __inline__ unsigned long
+hash_string( const char *str_param )
+{
+ unsigned long int hval, g;
+ const char *str = str_param;
+
+ hval = 0;
+ while (*str != '\0')
+ {
+ hval <<= 4;
+ hval += (unsigned long int) *str++;
+ g = hval & ((unsigned long int) 0xf << (HASHWORDBITS - 4));
+ if (g != 0)
+ {
+ hval ^= g >> (HASHWORDBITS - 8);
+ hval ^= g;
+ }
+ }
+ return hval;
+}
+
+
+/* Generic message catalog and gettext stuff. */
+
+/* The magic number of the GNU message catalog format. */
+#define MAGIC 0x950412de
+#define MAGIC_SWAPPED 0xde120495
+
+/* Revision number of the currently used .mo (binary) file format. */
+#define MO_REVISION_NUMBER 0
+
+
+/* Header for binary .mo file format. */
+struct mo_file_header
+{
+ /* The magic number. */
+ uint32_t magic;
+ /* The revision number of the file format. */
+ uint32_t revision;
+ /* The number of strings pairs. */
+ uint32_t nstrings;
+ /* Offset of table with start offsets of original strings. */
+ uint32_t orig_tab_offset;
+ /* Offset of table with start offsets of translation strings. */
+ uint32_t trans_tab_offset;
+ /* Size of hashing table. */
+ uint32_t hash_tab_size;
+ /* Offset of first hashing entry. */
+ uint32_t hash_tab_offset;
+};
+
+
+struct string_desc
+{
+ /* Length of addressed string. */
+ uint32_t length;
+ /* Offset of string in file. */
+ uint32_t offset;
+};
+
+
+struct overflow_space_s
+{
+ struct overflow_space_s *next;
+ uint32_t idx;
+ uint32_t length;
+ char d[1];
+};
+
+struct loaded_domain
+{
+ char *data;
+ char *data_native; /* Data mapped to the native version of the
+ string. (Allocated along with DATA). */
+ int must_swap;
+ uint16_t nstrings; /* Number of strings. */
+ uint16_t *mapped; /* Array of mapping indicators:
+ 0 := Not mapped (original utf8).
+ 1 := Mapped to native encoding in overflow space.
+ >=2 := Mapped to native encoding. The value
+ gives the length of the mapped string.
+ Because the terminating nul is included
+ in the length and an empty string is
+ not allowed, values are always > 1. */
+ struct overflow_space_s *overflow_space;
+ struct string_desc *orig_tab;
+ struct string_desc *trans_tab;
+ uint32_t hash_size;
+ uint32_t *hash_tab;
+};
+
+
+/* The list of domains we we are aware of. This list is protected by
+ the criticla section DOMAINLIST_ACCESS_CS. */
+static struct domainlist_s *domainlist;
+
+/* A critical section to guard access to the domainlist. */
+static CRITICAL_SECTION domainlist_access_cs;
+
+/* The name of the current domain. This is a malloced string. This
+ is a gobal variable which is not thread-safe. */
+static char *current_domainname;
+
+
+
+/* Constructor for this module. This can only be used if we are a
+ DLL. IF used as a static lib we can't control the process set; for
+ example it might be used with a main module which is not build with
+ mingw and thus does not know how to call the constructors. */
+#ifdef DLL_EXPORT
+static void module_init (void) __attribute__ ((__constructor__));
+#endif
+static void
+module_init (void)
+{
+ static int init_done;
+
+ if (!init_done)
+ {
+ InitializeCriticalSection (&domainlist_access_cs);
+ init_done = 1;
+ }
+}
+
+#ifndef DLL_EXPORT
+void
+_gpg_w32__init_gettext_module (void)
+{
+ module_init ();
+}
+#endif
+
+
+/* Free the domain data. */
+static void
+free_domain (struct loaded_domain *domain)
+{
+ struct overflow_space_s *os, *os2;
+
+ jnlib_free (domain->data);
+ jnlib_free (domain->mapped);
+ for (os = domain->overflow_space; os; os = os2)
+ {
+ os2 = os->next;
+ jnlib_free (os);
+ }
+ jnlib_free (domain);
+}
+
+
+static struct loaded_domain *
+load_domain (const char *filename)
+{
+ FILE *fp;
+ size_t size;
+ struct stat st;
+ struct mo_file_header *data = NULL;
+ struct loaded_domain *domain = NULL;
+ size_t to_read;
+ char *read_ptr;
+
+ fp = fopen (filename, "rb");
+ if (!fp)
+ {
+ return NULL;
+ }
+ if (fstat (fileno (fp), &st)
+ || (size = (size_t) st.st_size) != st.st_size
+ || size < sizeof (struct mo_file_header))
+ {
+ fclose (fp);
+ return NULL;
+ }
+
+ data = (2*size <= size)? NULL : jnlib_malloc (2*size);
+ if (!data)
+ {
+ fclose (fp);
+ return NULL;
+ }
+
+ to_read = size;
+ read_ptr = (char *) data;
+ do
+ {
+ long int nb = fread (read_ptr, 1, to_read, fp);
+ if (nb < to_read)
+ {
+ fclose (fp);
+ jnlib_free (data);
+ return NULL;
+ }
+ read_ptr += nb;
+ to_read -= nb;
+ }
+ while (to_read > 0);
+ fclose (fp);
+
+ /* Using the magic number we can test whether it really is a message
+ catalog file. */
+ if (data->magic != MAGIC && data->magic != MAGIC_SWAPPED)
+ {
+ /* The magic number is wrong: not a message catalog file. */
+ jnlib_free (data);
+ return NULL;
+ }
+
+ domain = jnlib_calloc (1, sizeof *domain);
+ if (!domain)
+ {
+ jnlib_free (data);
+ return NULL;
+ }
+ domain->data = (char *) data;
+ domain->data_native = (char *) data + size;
+ domain->must_swap = data->magic != MAGIC;
+
+ /* Fill in the information about the available tables. */
+ switch (SWAPIT (domain->must_swap, data->revision))
+ {
+ case MO_REVISION_NUMBER:
+ {
+ uint32_t nstrings;
+
+ /* Because we use 16 bit values for the mapping array, we
+ can't support more that 65534 strings (65535 would be okay,
+ but it is often used as a special value). A PO file with
+ that many translations is very unlikely given that GnuPG
+ with its very large number of strings has only about 1600
+ strings + variants. */
+ nstrings = SWAPIT (domain->must_swap, data->nstrings);
+ if (nstrings > 65534)
+ goto bailout;
+ domain->nstrings = nstrings;
+ domain->orig_tab = (struct string_desc *)
+ ((char *) data + SWAPIT (domain->must_swap, data->orig_tab_offset));
+ domain->trans_tab = (struct string_desc *)
+ ((char *) data + SWAPIT (domain->must_swap, data->trans_tab_offset));
+ domain->hash_size = SWAPIT (domain->must_swap, data->hash_tab_size);
+ domain->hash_tab = (uint32_t *)
+ ((char *) data + SWAPIT (domain->must_swap, data->hash_tab_offset));
+ }
+ break;
+
+ default: /* This is an invalid revision. */
+ goto bailout;
+ }
+
+ /* Allocate an array to keep track of code page mappings. */
+ domain->mapped = jnlib_calloc (domain->nstrings, sizeof *domain->mapped);
+ if (domain->mapped)
+ return domain; /* Okay. */
+
+ bailout:
+ jnlib_free (data);
+ jnlib_free (domain);
+ return NULL;
+}
+
+
+/* Return a malloced wide char string from an UTF-8 encoded input
+ string STRING. Caller must free this value. On failure returns
+ NULL. The result of calling this function with STRING set to NULL
+ is not defined. */
+static wchar_t *
+utf8_to_wchar (const char *string, size_t length, size_t *retlen)
+{
+ int n;
+ wchar_t *result;
+ size_t nbytes;
+
+ n = MultiByteToWideChar (CP_UTF8, 0, string, length, NULL, 0);
+ if (n < 0 || (n+1) <= 0)
+ return NULL;
+
+ nbytes = (size_t)(n+1) * sizeof(*result);
+ if (nbytes / sizeof(*result) != (n+1))
+ {
+ gpg_err_set_errno (ENOMEM);
+ return NULL;
+ }
+ result = jnlib_malloc (nbytes);
+ if (!result)
+ return NULL;
+
+ n = MultiByteToWideChar (CP_UTF8, 0, string, length, result, n);
+ if (n < 0)
+ {
+ jnlib_free (result);
+ return NULL;
+ }
+ *retlen = n;
+ return result;
+}
+
+
+/* Return a malloced string encoded in UTF-8 from the wide char input
+ string STRING. Caller must free this value. On failure returns
+ NULL. The result of calling this function with STRING set to NULL
+ is not defined. */
+static char *
+wchar_to_native (const wchar_t *string, size_t length, size_t *retlen)
+{
+ int n;
+ char *result;
+
+ n = WideCharToMultiByte (CP_ACP, 0, string, length, NULL, 0, NULL, NULL);
+ if (n < 0 || (n+1) <= 0)
+ return NULL;
+
+ result = jnlib_malloc (n+1);
+ if (!result)
+ return NULL;
+
+ n = WideCharToMultiByte (CP_ACP, 0, string, length, result, n, NULL, NULL);
+ if (n < 0)
+ {
+ jnlib_free (result);
+ return NULL;
+ }
+ *retlen = n;
+ return result;
+}
+
+
+/* Convert UTF8 to the native codepage. Caller must free the return value. */
+static char *
+utf8_to_native (const char *string, size_t length, size_t *retlen)
+{
+ wchar_t *wstring;
+ char *result;
+ size_t newlen;
+
+ wstring = utf8_to_wchar (string, length, &newlen);
+ if (wstring)
+ {
+ result = wchar_to_native (wstring, newlen, &newlen);
+ jnlib_free (wstring);
+ }
+ else
+ result = NULL;
+ *retlen = result? newlen : 0;
+ return result;
+}
+
+
+
+
+/* Specify that the DOMAINNAME message catalog will be found
+ in DIRNAME rather than in the system locale data base. */
+const char *
+_gpg_w32_bindtextdomain (const char *domainname, const char *dirname)
+{
+ const char *catval_full;
+ char *catval;
+ char *fname;
+ const char *retvalue;
+
+ if (!dirname)
+ {
+ struct domainlist_s *dl;
+
+ retvalue = NULL;
+ EnterCriticalSection (&domainlist_access_cs);
+ {
+ for (dl = domainlist; dl; dl = dl->next)
+ if (!strcmp (dl->name, domainname))
+ {
+ retvalue = dl->dname;
+ break;
+ }
+ }
+ LeaveCriticalSection (&domainlist_access_cs);
+ return retvalue;
+ }
+
+ /* DIRNAME is "$INSTALLDIR\share\locale". */
+
+ /* First find out the category value. */
+ catval = NULL;
+ catval_full = my_nl_locale_name ("LC_MESSAGES");
+
+ /* Normally we would have to loop over all returned locales and
+ search for the right file. See gettext intl/dcigettext.c for all
+ the gory details. Here, we only support the basic category, and
+ ignore everything else. */
+ if (catval_full)
+ {
+ char *p;
+
+ catval = jnlib_malloc (strlen (catval_full) + 1);
+ if (catval)
+ {
+ strcpy (catval, catval_full);
+ p = strchr (catval, '_');
+ if (p)
+ *p = '\0';
+ }
+ }
+ if (!catval)
+ return NULL;
+
+ /* Now build the filename string. The complete filename is this:
+ DIRNAME + \ + CATVAL + \LC_MESSAGES\ + DOMAINNAME + .mo */
+ {
+ int len = (strlen (dirname) + 1 + strlen (catval) + 13
+ + strlen (domainname) + 3 + 1);
+ char *p;
+
+ fname = jnlib_malloc (len);
+ if (!fname)
+ {
+ jnlib_free (catval);
+ return NULL;
+ }
+
+ p = fname;
+ strcpy (p, dirname);
+ p += strlen (dirname);
+ *(p++) = '\\';
+ strcpy (p, catval);
+ p += strlen (catval);
+ strcpy (p, "\\LC_MESSAGES\\");
+ p += 13;
+ strcpy (p, domainname);
+ p += strlen (domainname);
+ strcpy (p, ".mo");
+ }
+
+ jnlib_free (catval);
+
+ /* Store the domain information in the domainlist. */
+ {
+ struct domainlist_s *item, *dl;
+ char *rel_ptr1 = NULL;
+ char *rel_ptr2 = NULL;
+
+ item = jnlib_calloc (1, sizeof *dl + strlen (domainname));
+ if (!item)
+ {
+ jnlib_free (fname);
+ return NULL;
+ }
+ strcpy (item->name, domainname);
+ item->dname = jnlib_malloc (strlen (dirname) +1);
+ if(!item->dname)
+ {
+ jnlib_free (item);
+ jnlib_free (fname);
+ return NULL;
+ }
+ strcpy (item->dname, dirname);
+ retvalue = item->dname;
+
+ EnterCriticalSection (&domainlist_access_cs);
+ {
+ for (dl = domainlist; dl; dl = dl->next)
+ if (!strcmp (dl->name, domainname))
+ break;
+ if (!dl) /* First time called for this domainname. */
+ {
+ item->fname = fname;
+ fname = NULL;
+ item->next = domainlist;
+ domainlist = item;
+ item = NULL;
+ }
+ else /* Update only. */
+ {
+ rel_ptr1 = dl->fname;
+ dl->fname = fname;
+ fname = NULL;
+ rel_ptr2 = dl->dname;
+ dl->dname = item->dname;
+ item->dname = NULL;
+ }
+ }
+ LeaveCriticalSection (&domainlist_access_cs);
+
+ jnlib_free (item);
+ jnlib_free (rel_ptr1);
+ jnlib_free (rel_ptr2);
+ }
+
+ return retvalue;
+}
+
+
+
+
+static const char *
+get_plural (const char *data, size_t datalen, unsigned long nplural)
+{
+ const char *p;
+ int idx;
+
+ /* We only support the Germanic rule. */
+ idx = (nplural == 1? 0 : 1);
+
+ for (; idx; idx--)
+ {
+ p = strchr (data, 0) + 1;
+ if (p >= data+datalen)
+ return "ERROR in GETTEXT (bad plural entry)";
+ datalen -= (p-data);
+ data = p;
+ }
+ return data;
+}
+
+
+static const char*
+get_string (struct loaded_domain *domain, uint32_t idx,
+ int use_plural, unsigned long nplural)
+{
+ struct tls_space_s *tls = get_tls ();
+ struct overflow_space_s *os;
+ const char *trans; /* Pointer to the translated entry. */
+ size_t translen; /* Length of that entry. */
+
+ if (idx > 65534)
+ return "ERROR in GETTEXT (too many strings)";
+
+ if (tls->gt_use_utf8)
+ {
+ trans = (domain->data
+ + SWAPIT(domain->must_swap, domain->trans_tab[idx].offset));
+ translen = SWAPIT(domain->must_swap, domain->trans_tab[idx].length);
+ }
+ else if (!domain->mapped[idx])
+ {
+ /* Not yet mapped. Map from utf-8 to native encoding now. */
+ const char *p_utf8;
+ size_t plen_utf8, buflen;
+ char *buf;
+
+ p_utf8 = (domain->data
+ + SWAPIT(domain->must_swap, domain->trans_tab[idx].offset));
+ plen_utf8 = SWAPIT(domain->must_swap, domain->trans_tab[idx].length);
+
+ buf = utf8_to_native (p_utf8, plen_utf8, &buflen);
+ if (!buf)
+ {
+ trans = "ERROR in GETTEXT MALLOC";
+ translen = 0;
+ }
+ else if (buflen <= plen_utf8 && buflen > 1)
+ {
+ /* Copy into the DATA_NATIVE area. */
+ char *p_tmp;
+
+ p_tmp = (domain->data_native
+ + SWAPIT(domain->must_swap, domain->trans_tab[idx].offset));
+ memcpy (p_tmp, buf, buflen);
+ domain->mapped[idx] = buflen;
+ trans = p_tmp;
+ translen = buflen;
+ }
+ else
+ {
+ /* There is not enough space for the translation (or for
+ whatever reason an empty string is used): Store it in the
+ overflow_space and mark that in the mapped array.
+ Because UTF-8 strings are in general shorter than the
+ Windows 2 byte encodings, we expect that this won't
+ happen too often (if at all) and thus we use a linked
+ list to manage this space. */
+ os = jnlib_malloc (sizeof *os + buflen);
+ if (os)
+ {
+ os->idx = idx;
+ memcpy (os->d, buf, buflen);
+ os->length = buflen;
+ os->next = domain->overflow_space;
+ domain->overflow_space = os;
+ domain->mapped[idx] = 1;
+ trans = os->d;
+ translen = os->length;
+ }
+ else
+ {
+ trans = "ERROR in GETTEXT MALLOC";
+ translen = 0;
+ }
+ }
+ jnlib_free (buf);
+ }
+ else if (domain->mapped[idx] == 1)
+ {
+ /* The translated string is in the overflow_space. */
+ for (os=domain->overflow_space; os; os = os->next)
+ if (os->idx == idx)
+ break;
+ if (os)
+ {
+ trans = os->d;
+ translen = os->length;
+ }
+ else
+ {
+ trans = "ERROR in GETTEXT (overflow space)\n";
+ translen = 0;
+ }
+ }
+ else
+ {
+ trans = (domain->data_native
+ + SWAPIT(domain->must_swap, domain->trans_tab[idx].offset));
+ translen = domain->mapped[idx];
+ }
+
+ if (use_plural && translen)
+ return get_plural (trans, translen, nplural);
+ else
+ return trans;
+}
+
+
+static const char *
+do_gettext (const char *domainname,
+ const char *msgid, const char *msgid2, unsigned long nplural)
+{
+ struct domainlist_s *dl;
+ struct loaded_domain *domain;
+ int load_failed;
+ uint32_t top, bottom, nstr;
+ char *filename;
+
+ if (!domainname)
+ domainname = current_domainname? current_domainname : "";
+
+ /* FIXME: The whole locking stuff is a bit questionable because
+ gettext does not claim to be thread-safe. We need to investigate
+ this further. */
+
+ load_failed = 0;
+ domain = NULL;
+ filename = NULL;
+ EnterCriticalSection (&domainlist_access_cs);
+ {
+ for (dl = domainlist; dl; dl = dl->next)
+ if (!strcmp (dl->name, domainname))
+ {
+ load_failed = dl->load_failed;
+ domain = dl->domain;
+ break;
+ }
+ if (dl && !domain && !load_failed && dl->fname)
+ {
+ filename = jnlib_malloc (strlen (dl->fname) + 1);
+ if (filename)
+ strcpy (filename, dl->fname);
+ }
+ }
+ LeaveCriticalSection (&domainlist_access_cs);
+ if (!dl)
+ goto not_found; /* DOMAINNAME not bound. */
+ if (filename)
+ {
+ /* No attempt so far to load the MO file. Try now. */
+ int updated = 0;
+
+ domain = load_domain (filename);
+ jnlib_free (filename);
+ filename = NULL;
+ EnterCriticalSection (&domainlist_access_cs);
+ {
+ for (dl = domainlist; dl; dl = dl->next)
+ if (!strcmp (dl->name, domainname))
+ {
+ if (domain)
+ dl->domain = domain;
+ else
+ dl->load_failed = 1;
+ updated = 1;
+ break;
+ }
+ }
+ LeaveCriticalSection (&domainlist_access_cs);
+ if (!updated)
+ {
+ /* Ooops - lost the domain. */
+ free_domain (domain);
+ domain = NULL;
+ }
+ }
+
+ if (!domain)
+ goto not_found; /* No MO file. */
+
+ /* First try to use the hash table. */
+ if (domain->hash_size > 2 && domain->hash_tab)
+ {
+ /* Use the hashing table. */
+ uint32_t len = strlen (msgid);
+ uint32_t hash_val = hash_string (msgid);
+ uint32_t idx = hash_val % domain->hash_size;
+ uint32_t incr = 1 + (hash_val % (domain->hash_size - 2));
+
+ while ( (nstr = SWAPIT (domain->must_swap, domain->hash_tab[idx])) )
+ {
+ nstr--;
+ if (nstr < domain->nstrings
+ && SWAPIT(domain->must_swap,
+ domain->orig_tab[nstr].length) >= len
+ && !strcmp (msgid, (domain->data
+ + SWAPIT(domain->must_swap,
+ domain->orig_tab[nstr].offset))))
+ {
+ return get_string (domain, nstr, !!msgid2, nplural);
+ }
+
+ if (idx >= domain->hash_size - incr)
+ idx -= domain->hash_size - incr;
+ else
+ idx += incr;
+ }
+ }
+
+ /* Now we try the default method: binary search in the sorted array
+ of messages. */
+ bottom = 0;
+ top = domain->nstrings;
+ while (bottom < top)
+ {
+ int cmp_val;
+
+ nstr = (bottom + top) / 2;
+ cmp_val = strcmp (msgid, (domain->data
+ + SWAPIT(domain->must_swap,
+ domain->orig_tab[nstr].offset)));
+ if (cmp_val < 0)
+ top = nstr;
+ else if (cmp_val > 0)
+ bottom = nstr + 1;
+ else
+ {
+ return get_string (domain, nstr, !!msgid2, nplural);
+ }
+ }
+
+ not_found:
+ /* We use the standard Germanic rule if plural has been requested. */
+ return msgid2? (nplural == 1? msgid : msgid2) : msgid;
+}
+
+
+const char *
+_gpg_w32_textdomain (const char *domainname)
+{
+ char *string;
+
+ if (!domainname)
+ {
+ if (!current_domainname)
+ gpg_err_set_errno (0);
+ }
+ else
+ {
+ string = malloc (strlen (domainname) + 1);
+ if (!string)
+ return NULL;
+ strcpy (string, domainname);
+ current_domainname = string;
+ }
+ return current_domainname;
+}
+
+
+/* A direct implementation of gettext instead of a macro calling
+ dngettext. This is so that the caller does not need to push dummy
+ values on the stack. The used domain is the first one registered
+ with bindtextdomain. */
+const char *
+_gpg_w32_gettext (const char *msgid)
+{
+ return do_gettext (NULL, msgid, NULL, 0);
+}
+
+
+/* A direct implementation of dgettext instead of a macro calling
+ dngettext. This is so that the caller does not need to push dummy
+ values on the stack. */
+const char *
+_gpg_w32_dgettext (const char *domainname, const char *msgid)
+{
+ return do_gettext (domainname, msgid, NULL, 0);
+}
+
+
+/* Our implementation of dngettext. This is the most genereic
+ function we have; a macro implements ngettext. */
+const char *
+_gpg_w32_dngettext (const char *domainname, const char *msgid1,
+ const char *msgid2, unsigned long int n)
+{
+ /* We use the simple Germanic plural rule. */
+ return do_gettext (domainname, msgid1, msgid2, n);
+}
+
+
+/* Return the locale name as used by gettext. The return value will
+ never be NULL. */
+const char *
+_gpg_w32_gettext_localename (void)
+{
+ const char *s;
+
+ s = my_nl_locale_name ("LC_MESSAGES");
+ return s? s:"";
+}
+
+
+/* With a VALUE of 1 switch the gettext functions into utf8 mode.
+ That is the strings are returned without translation to the native
+ charset. A VALUE of 0 switches back to translated strings. A VALUE
+ of -1 returns the current value. */
+int
+_gpg_w32_gettext_use_utf8 (int value)
+{
+ struct tls_space_s *tls = get_tls ();
+ int last = tls->gt_use_utf8;
+ if (value != -1)
+ tls->gt_use_utf8 = value;
+ return last;
+}
+
+
+#ifdef TEST
+int
+main (int argc, char **argv)
+{
+ const char atext1[] =
+ "Warning: You have entered an insecure passphrase.%%0A"
+ "A passphrase should be at least %u character long.";
+ const char atext2[] =
+ "Warning: You have entered an insecure passphrase.%%0A"
+ "A passphrase should be at least %u characters long.";
+
+ if (argc)
+ {
+ argc--;
+ argv++;
+ }
+
+ _gpg_err_w32_bindtextdomain ("gnupg2", "c:/programme/gnu/gnupg/share/locale");
+
+ printf ("locale is `%s'\n", _gpg_err_w32_gettext_localename ());
+ fputs ("text with N=1:\n", stdout);
+ fputs (_gpg_err_w32_ngettext (atext1, atext2, 1), stdout);
+ fputs ("\n\ntext with N=2:\n", stdout);
+ fputs (_gpg_err_w32_ngettext (atext1, atext2, 2), stdout);
+ fputs ("\nready\n", stdout);
+
+ return 0;
+}
+/*
+ * Local Variables:
+ * compile-command: "i586-mingw32msvc-gcc -DTEST -Wall -g w32-gettext.c"
+ * End:
+ */
+#endif /*TEST*/
diff --git a/src/w32ce-add.h b/src/w32ce-add.h
new file mode 100644
index 0000000..c6207bb
--- /dev/null
+++ b/src/w32ce-add.h
@@ -0,0 +1,8 @@
+## w32ce-add.h - Snippet to be be included into gpg-error.h.
+## (Comments are indicated by a double hash mark)
+
+/* Substitute for strerror - this one is thread safe. */
+char *_gpg_w32ce_strerror (int err);
+#ifdef GPG_ERR_ENABLE_ERRNO_MACROS
+# define strerror(a) _gpg_w32ce_strerror (a)
+#endif