[svn] GnuPG - r5288 - in trunk: . agent common g10 g13 jnlib kbx keyserver po scd sm tools

svn author wk cvs at cvs.gnupg.org
Wed Mar 10 13:25:00 CET 2010


Author: wk
Date: 2010-03-10 13:24:58 +0100 (Wed, 10 Mar 2010)
New Revision: 5288

Added:
   trunk/common/ChangeLog.jnlib
   trunk/common/README.jnlib
   trunk/common/argparse.c
   trunk/common/argparse.h
   trunk/common/dotlock.c
   trunk/common/dotlock.h
   trunk/common/dynload.h
   trunk/common/estream-printf.c
   trunk/common/estream-printf.h
   trunk/common/estream.c
   trunk/common/estream.h
   trunk/common/libjnlib-config.h
   trunk/common/logging.c
   trunk/common/logging.h
   trunk/common/mischelp.c
   trunk/common/mischelp.h
   trunk/common/stringhelp.c
   trunk/common/stringhelp.h
   trunk/common/strlist.c
   trunk/common/strlist.h
   trunk/common/t-stringhelp.c
   trunk/common/t-support.c
   trunk/common/t-support.h
   trunk/common/t-timestuff.c
   trunk/common/t-w32-reg.c
   trunk/common/types.h
   trunk/common/utf8conv.c
   trunk/common/utf8conv.h
   trunk/common/w32-afunix.c
   trunk/common/w32-afunix.h
   trunk/common/w32-reg.c
   trunk/common/w32help.h
   trunk/common/xmalloc.c
   trunk/common/xmalloc.h
Removed:
   trunk/common/estream-printf.c
   trunk/common/estream-printf.h
   trunk/common/estream.c
   trunk/common/estream.h
   trunk/jnlib/ChangeLog
   trunk/jnlib/Makefile.am
   trunk/jnlib/README
   trunk/jnlib/argparse.c
   trunk/jnlib/argparse.h
   trunk/jnlib/dotlock.c
   trunk/jnlib/dotlock.h
   trunk/jnlib/dynload.h
   trunk/jnlib/libjnlib-config.h
   trunk/jnlib/logging.c
   trunk/jnlib/logging.h
   trunk/jnlib/mischelp.c
   trunk/jnlib/mischelp.h
   trunk/jnlib/stringhelp.c
   trunk/jnlib/stringhelp.h
   trunk/jnlib/strlist.c
   trunk/jnlib/strlist.h
   trunk/jnlib/t-stringhelp.c
   trunk/jnlib/t-support.c
   trunk/jnlib/t-support.h
   trunk/jnlib/t-timestuff.c
   trunk/jnlib/t-w32-reg.c
   trunk/jnlib/types.h
   trunk/jnlib/utf8conv.c
   trunk/jnlib/utf8conv.h
   trunk/jnlib/w32-afunix.c
   trunk/jnlib/w32-afunix.h
   trunk/jnlib/w32-reg.c
   trunk/jnlib/w32help.h
   trunk/jnlib/xmalloc.c
   trunk/jnlib/xmalloc.h
Modified:
   trunk/ChangeLog
   trunk/Makefile.am
   trunk/acinclude.m4
   trunk/agent/ChangeLog
   trunk/agent/Makefile.am
   trunk/agent/command-ssh.c
   trunk/agent/minip12.c
   trunk/agent/protect-tool.c
   trunk/agent/trustlist.c
   trunk/common/ChangeLog
   trunk/common/Makefile.am
   trunk/common/audit.h
   trunk/common/exechelp.c
   trunk/common/exechelp.h
   trunk/common/http.h
   trunk/common/i18n.h
   trunk/common/init.c
   trunk/common/iobuf.c
   trunk/common/localename.c
   trunk/common/simple-pwquery.c
   trunk/common/simple-pwquery.h
   trunk/common/sysutils.h
   trunk/common/ttyio.c
   trunk/common/util.h
   trunk/common/xasprintf.c
   trunk/configure.ac
   trunk/g10/ChangeLog
   trunk/g10/Makefile.am
   trunk/g10/main.h
   trunk/g10/packet.h
   trunk/g10/rmd160.c
   trunk/g13/Makefile.am
   trunk/kbx/ChangeLog
   trunk/kbx/Makefile.am
   trunk/kbx/kbxutil.c
   trunk/kbx/keybox-defs.h
   trunk/kbx/keybox-dump.c
   trunk/kbx/keybox-init.c
   trunk/kbx/keybox-search.c
   trunk/keyserver/Makefile.am
   trunk/po/POTFILES.in
   trunk/scd/ChangeLog
   trunk/scd/Makefile.am
   trunk/sm/ChangeLog
   trunk/sm/Makefile.am
   trunk/sm/gpgsm.h
   trunk/tools/ChangeLog
   trunk/tools/Makefile.am
Log:
Merged jnlib into common.


[The diff below has been truncated]

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2010-03-09 12:50:48 UTC (rev 5287)
+++ trunk/ChangeLog	2010-03-10 12:24:58 UTC (rev 5288)
@@ -1,3 +1,12 @@
+2010-03-10  Werner Koch  <wk at g10code.com>
+
+	* jnlib/: Move all code to common/.
+	* Makefile.am (SUBDIRS): Remove jnlib.
+	* configure.ac (AC_CONFIG_FILES): Remove jnlib/Makefile.
+
+	* configure.ac (AM_PATH_LIBASSUAN): Remove double test.
+	* acinclude.m4 (GNUPG_CHECK_ENDIAN): Remove bogus warning.
+
 2010-03-09  Werner Koch  <wk at g10code.com>
 
 	* configure.ac: Add option --disable-ccid-driver.

Modified: trunk/agent/ChangeLog
===================================================================
--- trunk/agent/ChangeLog	2010-03-09 12:50:48 UTC (rev 5287)
+++ trunk/agent/ChangeLog	2010-03-10 12:24:58 UTC (rev 5288)
@@ -1,3 +1,9 @@
+2010-03-10  Werner Koch  <wk at g10code.com>
+
+	* Makefile.am (common_libs): Remove libjnlib.a.
+
+	* trustlist.c, protect-tool.c, command-ssh.c: Remove estream.h.
+
 2010-02-17  Werner Koch  <wk at g10code.com>
 
 	* call-pinentry.c (start_pinentry): Always free OPTSTR.  Send

Modified: trunk/common/ChangeLog
===================================================================
--- trunk/common/ChangeLog	2010-03-09 12:50:48 UTC (rev 5287)
+++ trunk/common/ChangeLog	2010-03-10 12:24:58 UTC (rev 5288)
@@ -1,5 +1,32 @@
+2010-03-10  Werner Koch  <wk at g10code.com>
+
+	* util.h: Replace jnlib path part by common.
+	(snprintf): Use the replacement macro on all platforms.
+
+	* Makefile.am (jnlib_sources): New.
+	(libcommon_a_SOURCES, libcommonpth_a_SOURCES): Add jnlib_sources.
+	(jnlib_tests): New.
+	(noinst_PROGRAMS, TESTS): Add jnlib_tests.
+	(t_common_ldadd): Remove libjnlib.a.
+
+	* README.jnlib, ChangeLog.jnlib, libjnlib-config.h, argparse.c
+	* argparse.h, dotlock.c, dotlock.h, dynload.h, logging.c
+	* logging.h, mischelp.c, mischelp.h, stringhelp.c, stringhelp.h
+	* strlist.c, strlist.h, types.h, utf8conv.c, utf8conv.h
+	* w32-afunix.c, w32-afunix.h, w32-reg.c, w32help.h, xmalloc.c
+	* xmalloc.h, t-stringhelp.c, t-support.c, t-support.h
+	* t-timestuff.c, t-w32-reg.c: Move from jnlib to here.
+
+	* init.c: Remove "estream.h".
+	* util.h: Include "estream.h".
+
+	* xasprintf.c, ttyio.c: Remove "estream-printf.h".
+
 2010-03-08  Werner Koch  <wk at g10code.com>
 
+	* exechelp.c [!HAVE_SIGNAL_H]: Do not include signal.h.
+	(DETACHED_PROCESS, CREATE_NEW_PROCESS_GROUP) [W32CE]: Provide stubs.
+
 	* iobuf.h (iobuf_ioctl_t): New.  Use the new macros instead of the
 	hard wired values.
 	* iobuf.c (iobuf_append): Remove.

Copied: trunk/common/ChangeLog.jnlib (from rev 5274, trunk/jnlib/ChangeLog)
===================================================================
--- trunk/common/ChangeLog.jnlib	                        (rev 0)
+++ trunk/common/ChangeLog.jnlib	2010-03-10 12:24:58 UTC (rev 5288)
@@ -0,0 +1,769 @@
+2010-03-10  Werner Koch  <wk at g10code.com>
+
+	See gnupg/common/ChangeLog for newer changes.
+
+	JNLIB has been merged into GnuPG's common directory.  README.jnlib
+	list the files making up JNLIB.
+
+	* README: Rename to README.jnlib
+	* ChangeLog: Rename to ChangeLog.jnlib.
+	* Makefile.am: Remove.
+
+2010-03-01  Werner Koch  <wk at g10code.com>
+
+	* t-w32-reg.c: New.
+
+	* w32-reg.c (read_w32_registry_string)
+	(write_w32_registry_string): Support W32CE.
+
+2010-02-26  Werner Koch  <wk at g10code.com>
+
+	* t-timestuff.c: New.
+
+	* dynload.h (dlopen, dlsym) [W32CE]: Map to wchar_t.
+
+	* mischelp.c (_jnlib_free): New.
+	(same_file_p) [W32CE]: Map to wchar_t.
+
+	* utf8conv.c (set_native_charset) [W32CE]: Do not use
+	GetConsoleOutputCP.
+	(wchar_to_utf8, utf8_to_wchar) [W32]: New.
+
+	* Makefile.am (t_jnlib_ldadd) [W32CE]: Add gpg-error.
+
+	* t-support.h (getenv) [HAVE_GETENV]: Add getenv stub.
+	[W32CE]: Include gpg-error.h
+	* t-support.c (gpg_err_code_from_errno)
+	(gpg_err_code_from_syserror) [GPG_ERROR_H]: Do not build.
+
+	* t-stringhelp.c (gethome) [!HAVE_GETPWUID]: Keep result of getenv.
+
+	* dotlock.c [!HAVE_SIGNAL_H]: Don't include signal.h.
+	(create_dotlock) [W32CE]: Map filename top wchar_t.
+
+	* libjnlib-config.h [USE_SIMPLE_GETTEXT]: Include gpg-error.h and
+	remove w32help.h.
+	(jnlib_set_errno): New.  Use it everywhere to set ERRNO.
+	(getenv) [!HAVE_GETENV]: New.
+	(getpid) [W32E]: New.
+
+	* stringhelp.c (get_pwdir) [!HAVE_PWD_H]: Mark unused args.
+	(w32_strerror) [W32CE]: Use a simple implementation.
+
+	* w32help.h [USE_SIMPLE_GETTEXT]: Remove all definitions; we are
+	now using the gpg-error included implementation.
+	* w32-gettext.c: Remove.
+
+	* mischelp.c (same_file_p): Fix bug in case the second file can't
+	be opened.
+
+2009-10-19  Werner Koch  <wk at g10code.com>
+
+	* strlist.c (add_to_strlist_try): New.
+
+2009-09-22  Werner Koch  <wk at g10code.com>
+
+	* dotlock.h (DOTLOCK): Rename to dotlock_t.  Change all users.
+
+2009-08-26  Werner Koch  <wk at g10code.com>
+
+	* stringhelp.c (do_make_filename): Factor some code out to ..
+	(get_pwdir): .. new.
+
+2009-08-26  Werner Koch  <wk at g10code.com>
+
+	* stringhelp.c [HAVE_PWD_H]: Include pwd.h.
+	(do_make_filename): New.
+	(make_filename, make_filename_try): Implement using the new
+	function.
+	* t-stringhelp.c (test_make_filename_try): New.
+	* t-support.c (gcry_strdup): Fix.
+
+	* stringhelp.h (make_filename, make_filename_try): Add sentinel
+	attribute.
+
+2009-08-25  Werner Koch  <wk at g10code.com>
+
+	* stringhelp.c: Include errno.h.
+	(do_strconcat): New.
+	(strconcat, xstrconcat): New.
+	* types.h (GNUPG_GCC_A_SENTINEL): New.
+	* t-stringhelp.c (test_strconcat, test_xstrconcat): New.
+	(main): Run them.
+
+2009-07-07  Werner Koch  <wk at g10code.com>
+
+	* stringhelp.c (make_filename_try): Use jnlib_malloc.
+
+	* dotlock.c (read_lockfile): Replace jnlib_xmalloc by jnlib_malloc.
+
+2009-06-04  Werner Koch  <wk at g10code.com>
+
+	* mischelp.h: Include SUN_LEN etc also for W32.
+
+2009-05-19  Werner Koch  <wk at g10code.com>
+
+	* mischelp.h: Define PF_LOCAL, AF_LOCAL and SUN_LEN if requested.
+	* logging.c (fun_writer): Use SUN_LEN to fix a Mac OS X freeze.
+
+2009-03-25  Werner Koch  <wk at g10code.com>
+
+	* logging.c (fun_closer): Never close fd 2.
+	(set_file_fd): Close logstream early.
+
+2009-02-25  Werner Koch  <wk at g10code.com>
+
+	* logging.c (get_tid_callback): New.
+	(do_logv): Use it.
+	(log_set_get_tid_callback): New.
+
+2009-01-22  Werner Koch  <wk at g10code.com>
+
+	* t-support.c (gpg_err_code_from_errno)
+	(gpg_err_code_from_syserror): New.
+
+2008-11-20  Werner Koch  <wk at g10code.com>
+
+	* argparse.c (arg_parse): Fix last change.
+
+2008-11-11  Werner Koch  <wk at g10code.com>
+
+	* argparse.h: Add a bunch of macros and constants.
+	* argparse.c: Use the new macros.  Re-indent the code.  Change
+	license back to LGPL 2.1.
+
+2008-11-04  Werner Koch  <wk at g10code.com>
+
+	* w32-gettext.c: Merged with code from libgpg-error and rewrote
+	most parts.
+
+	* Makefile.am (AM_CFLAGS): Add -DJNLIB_IN_JNLIB.
+
+2008-10-29  Werner Koch  <wk at g10code.com>
+
+	* stringhelp.c (make_filename): Implement using macros. Factor some
+	code out to ..
+	(change_slashes): New.
+	(make_filename_try): New.
+
+	* w32-gettext.c (gettext): Return if no domain is loaded.
+	Reported by Tom Pegios.
+
+2008-10-28  Werner Koch  <wk at g10code.com>
+
+	* w32-gettext.c (gettext): Try the binary search if the string was
+	not found in the hash table.
+
+2008-10-20  Werner Koch  <wk at g10code.com>
+
+	* w32-afunix.c (_w32_sock_connect): Mark ADDRLEN as unused.
+
+	* dotlock.c (release_dotlock): Do not mix declaration and code.
+
+	* stringhelp.c (make_basename): Silent gcc warning about unused arg.
+	* argparse.c (store_alias): Ditto.
+	(find_long_option):
+
+2008-10-15  Werner Koch  <wk at g10code.com>
+
+	* logging.c (do_logv) [W32]: Flush the log stream.
+
+2008-09-29  Werner Koch  <wk at g10code.com>
+
+	* argparse.c (ARGERR_): Use constants for error values.
+	(optfile_parse): Prettify.  Replace xmalloc and xrealloc by malloc
+	and realloc.
+	* libjnlib-config.h (jnlib_strdup, jnlib_realloc): New.
+
+2008-06-26  Werner Koch  <wk at g10code.com>
+
+	* stringhelp.c (print_sanitized_buffer2): Loose check for control
+	characters to better cope with utf-8.  The range 0x80..0x9f is
+	nowadays not anymore accidently used for control charaters.
+
+2008-06-13  Werner Koch  <wk at g10code.com>
+
+	* dotlock.c: Reformat code and implement locking for W32.
+	(create_dotlock): Use snprintf.
+
+2008-06-11  Werner Koch  <wk at g10code.com>
+
+	* utf8conv.c: Remove useless variable ACTIVE_CHARSET.  Suggested
+	by Petr Uzel.
+
+2008-05-26  Werner Koch  <wk at g10code.com>
+
+	* argparse.c (usage): Make sure to print a trailing LF for usage(1).
+
+2008-04-08  Werner Koch  <wk at g10code.com>
+
+	* w32-gettext.c (gettext_select_utf8): New.
+	(get_string): Support switching encodings.
+	(load_domain): Allocate space for DATA_NATIVE.
+
+2008-03-25  Werner Koch  <wk at g10code.com>
+
+	* w32-gettext.c (_nl_locale_name): New.  Taken from
+	../common/localename and GNU gettext's localename.c.
+	(set_gettext_file): Rewritten.
+	(gettext_localename): New.
+
+2008-03-17  Werner Koch  <wk at g10code.com>
+
+	* logging.c (my_funopen_hook_size_t): New.
+	(fun_writer): Use it to cope with fopencookie/funopen differences.
+	* dotlock.c (read_lockfile): Initialize PID.  Reported by Stéphane
+	Corthésy.
+
+2008-02-22  Werner Koch  <wk at g10code.com>
+
+	* argparse.c (strusage): Set copyright year to 2008.
+
+2007-11-19  Werner Koch  <wk at g10code.com>
+
+	* stringhelp.c (percent_escape): Factor code out to
+	(do_percent_escape): .. new.
+	(try_percent_escape): New.
+
+2007-10-01  Werner Koch  <wk at g10code.com>
+
+	* w32-afunix.c: Only keep the client related code.
+	(read_port_and_nonce): New.  Taken from Assuan.
+	(_w32_sock_connect): Rewritten.
+
+2007-08-29  Werner Koch  <wk at g10code.com>
+
+	* argparse.c (initialize): Make strings translatable and remove
+	extra LF.
+
+2007-08-24  Werner Koch  <wk at g10code.com>
+
+	* mischelp.c (same_file_p): New.
+	(libjnlib_dummy_mischelp_func): Remove as we now always have one
+	function.
+
+2007-08-09  Werner Koch  <wk at g10code.com>
+
+	* argparse.c (show_help): Expand the @EMAIL@ macro in the package
+	bug reporting address.
+
+2007-08-02  Werner Koch  <wk at g10code.com>
+
+	* t-stringhelp.c (test_compare_filenames): New.
+
+	* stringhelp.c (compare_filenames) [HAVE_DRIVE_LETTERS]: Fixed
+	comparison to take slash and backslash in account.
+	(make_filename): Avoid mixing / and \.
+
+2007-07-04  Werner Koch  <wk at g10code.com>
+
+	* utf8conv.c (load_libiconv): Remove URL from translatble string.
+
+	Switched JNLIB from LGPLv2.1 to LGPLv3.
+
+2007-07-01  Werner Koch  <wk at g10code.com>
+
+	* argparse.c (strusage): Use id 10 for the license string;
+	default to GPL3+.  Change long note to version 3 or later.
+	(show_version): Print the license info.
+
+2007-06-19  Werner Koch  <wk at g10code.com>
+
+	* Makefile.am: Add support for regression tests.
+	* t-support.h, t-support.c: New.
+	* t-stringhelp.c: New.
+
+	* stringhelp.c (percent_escape): Add arg EXTRA to make it a more
+	general function.  Changed all callers.
+
+2007-06-18  Werner Koch  <wk at g10code.com>
+
+	* w32-afunix.c (_w32_sock_bind): Changed to properly detect an
+	already used socket.
+
+2007-06-18  Marcus Brinkmann  <marcus at g10code.de>
+
+	* stringhelp.h (percent_escape): New prototype.
+	* stringhelp.c (percent_escape): New function.
+
+2007-06-11  Werner Koch  <wk at g10code.com>
+
+	* utf8conv.c (jnlib_iconv_open, jnlib_iconv, jnlib_iconv_close): New.
+
+2007-06-06  Werner Koch  <wk at g10code.com>
+
+	* w32help.h: New.
+	* w32-gettext.c: New.  Taken from gnupg 1.4, added ngettext,
+	changed to use jnlib malloc functions and put under the LGPL.
+	* w32-reg.c: New.  Taken from../common/w32reg.c and changed to
+	LGPL.  Changed API to use the jnlib malloc functions.
+	* Makefile.am (libjnlib_a_SOURCES) [!W32]: Do not build the w32
+	specific modules.
+
+	* dotlock.c: Include stringhelp.h for stpcpy prototype.
+
+2007-06-04  Werner Koch  <wk at g10code.com>
+
+	* dynload.h: New.  Taken from ../common and changed to LGPL.
+
+	* utf8conv.c (load_libiconv): New.  Taken from GnuPG 1.4
+
+2007-05-30  Werner Koch  <wk at g10code.com>
+
+	* w32-pth.h, w32-pth.c: Remove.
+
+2007-04-25  Werner Koch  <wk at g10code.com>
+
+	* argparse.c (long_opt_strlen): Fixed for utf-8.
+
+2007-03-07  Werner Koch  <wk at g10code.com>
+
+	* argparse.c (strusage): Set copyright year to 2007.
+
+2007-01-25  Werner Koch  <wk at g10code.com>
+
+	* stringhelp.c (utf8_charcount): New.
+
+2006-11-29  Werner Koch  <wk at g10code.com>
+
+	* utf8conv.c (set_native_charset) [HAVE_W32_SYSTEM]: Fixed typo in
+	macro name.
+
+2006-11-15  Werner Koch  <wk at g10code.com>
+
+	* logging.c (my_funopen_hook_ret_t): New.
+	(fun_writer): Use it.
+
+2006-10-19  Werner Koch  <wk at g10code.com>
+
+	* stringhelp.c (memrchr) [!HAVE_MEMRCHR]: Provide a replacement.
+
+2006-09-27  Werner Koch  <wk at g10code.com>
+
+	* mischelp.c: New.
+	(timegm): Copied from gnupg 1.4, changed from GPL to LGPL.  Fixed
+	a memory leak.
+
+	* stringhelp.h (isascii): New.
+
+	* stringhelp.c (strsep): New. Copied from gnupg 1.4.5
+	util/strgutil.c.
+
+	* strlist.h (STRLIST): Removed deprecated typedef.
+
+	* types.h: Made cpp commands work with old compilers.  Also shows
+	up nicer with Emacs' font locking.
+
+	* w32-afunix.c (_w32_sock_connect): Set ERRNO for an invalid port.
+
+        Changed license from GPL to LGPL.  Note that all code has either
+	been written by me, David, employees of g10 Code or taken from
+	glibc.
+
+	* libjnlib-config.h, stringhelp.c, stringhelp.h:
+	* strlist.c, strlist.h,	utf8conv.c, utf8conv.h:
+	* argparse.c, argparse.h, logging.c, logging.h:
+	* dotlock.c, dotlock.h, types.h, mischelp.h:
+        * xmalloc.c, xmalloc.h, w32-pth.c, w32-pth.h:
+	* w32-afunix.c, w32-afunix.h: Tagged them to be long to jnlib
+	which is a part of GnuPG but also used by other projetcs.
+
+2006-09-22  Werner Koch  <wk at g10code.com>
+
+	* utf8conv.c: Reworked to match the gnupg 1.4.5 code.  This now
+	requires iconv support but this is reasonable for all modern
+	systems.
+
+2006-08-29  Werner Koch  <wk at g10code.com>
+
+	* logging.c (do_logv): Emit a missing LF for fatal errors.
+
+2006-06-28  Werner Koch  <wk at g10code.com>
+
+	* dotlock.c (make_dotlock, release_dotlock, read_lockfile)
+	(maybe_deadlock, destroy_dotlock, create_dotlock): Re-indented.
+	(create_dotlock): Repalces some log_fatal by log_error as it was
+	not intended that they should terminate.  Write the nodename to
+	the locking file. Code cleanups.
+	(read_lockfile): Reworked to read the node name.
+	(make_dotlock): Test for identical node name and delete lock stale
+	file.
+	(release_dotlock): Likewise.
+
+2006-05-23  Werner Koch  <wk at g10code.com>
+
+	* libjnlib-config.h (JNLIB_NEED_UTF8CONV): Fixed typo in name.
+
+	* dotlock.c (release_dotlock): Don't act if we don't have any
+	locks at all.
+	(destroy_dotlock): New.  From 1.4.3.
+	(dotlock_remove_lockfiles): Make use of destroy function.
+
+2006-05-19  Werner Koch  <wk at g10code.com>
+
+	* strlist.c (append_to_strlist2): Enabled.
+
+	* stringhelp.c (print_sanitized_buffer2): New.  Changed the rules
+	to match the behaviour of print_string2 from gnupg 1.4.3.
+	(print_sanitized_buffer): Use the new function.
+	(print_sanitized_string2): New.
+	(hextobyte): New.  Taken from gpg 1.4.3.
+
+2006-04-28  Werner Koch  <wk at g10code.com>
+
+	* stringhelp.c (print_sanitized_buffer): Fix bug where the count
+	got wrong for the \xNN representation.
+	(sanitize_buffer): Fix bug where some control characters lose part
+	of their \xNN representation.
+
+2006-04-20  Werner Koch  <wk at g10code.com>
+
+	* stringhelp.c (make_basename): New arg INPUTPATH for future
+	riscos compatibility.
+
+2006-04-18  Werner Koch  <wk at g10code.com>
+
+	* libjnlib-config.h (JNLIB_NEED_UTF8CONF): Defined.
+	* strlist.c (add_to_strlist2) [JNLIB_NEED_UTF8CONV]: Enabled.
+
+2005-06-15  Werner Koch  <wk at g10code.com>
+
+	* stringhelp.c (sanitize_buffer): Make P a void*.
+	(ascii_memistr, memistr): Ditto.
+	(ascii_memcasecmp): Ditto.
+	* logging.c (writen): Use void * for arg BUFFER.
+	* stringhelp.c (memistr): Fixed unsigned/signed pointer conflict.
+	(ascii_memistr): Ditto.
+	(ascii_memcasemem): Ditto.
+	* utf8conv.c (utf8_to_native): Ditto.
+	(utf8_to_native): Ditto.
+	* argparse.c (show_version): Removed non-required cast.
+
+2005-01-19  Werner Koch  <wk at g10code.com>
+
+	* logging.c (fun_writer): Don't fallback to stderr. Print to
+	stderr only if connected to a tty.
+
+2004-12-20  Werner Koch  <wk at g10code.com>
+
+	* w32-pth.c (do_pth_event_free): The events are hold in a ring
+	buffer.  Adjust for that.
+	(do_pth_event_body): Ditto.
+	(pth_event_isolate): Ditto.
+	(do_pth_wait): Ditto.
+	(_pth_event_count): Renamed to ..
+	(event_count): .. and adjusted as above.
+	(pth_init): Define 3 debug levels and change all debug calls to
+	make use of them.  This makes the moule now silent.
+
+2004-12-19  Werner Koch  <wk at g10code.com>
+
+	* w32-pth.c (pth_init): Enable debugging depending on env var.
+	(pth_self): New.
+	(pth_mutex_release, pth_mutex_acquire): Implemented directly using
+	the W32 API.
+
+2004-12-18  Werner Koch  <wk at g10code.com>
+
+	* w32-pth.c (pth_init): Reverse return values.  Use TRUE and FALSE
+	constants.
+	(pth_kill, pth_mutex_acquire, pth_attr_set, pth_join, pth_cancel):
+	Ditto.
+
+2004-12-15  Werner Koch  <wk at g10code.com>
+
+	* logging.c [W32]: Don't include unavailable headers.
+
+2004-12-14  Werner Koch  <wk at g10code.com>
+
+	* w32-pth.c (_pth_strerror): Renamed to ...
+	(w32_strerror): .. this. And let callers provide a buffer.
+	(spawn_helper_thread): Removed HD arg and hardwire the stack size
+	to 32k.
+	(do_pth_wait): Removed use of ATTR; not needed for the helper
+	threads.
+	(helper_thread): Renamed to ..
+	(launch_thread): .. this.  Release handle if not joinable.
+	(struct pth_priv_hd_s): Renamed to ...
+	(struct thread_info_s): .. this.  Add member JOINABLE and TH.
+
+2004-12-14  Timo Schulz  <twoaday at g10code.com>
+
+	* w32-pth.c (pth_kill): Just release the crit section if
+	pth_init was really called. And set all handles to NULL.
+	(_pth_strerror): New.
+	(do_pth_wait): Before we enter the loop we check if there
+	are too much events in the ring.
+
+2004-12-14  Werner Koch  <wk at g10code.com>
+
+	* w32-pth.h (pth_event_occured): Removed macro.
+	* w32-pth.c: Fixed license statement; its under the LGPL.
+	(enter_pth, leave_pth): Use them to bracket almost all public
+	functions.
+
+2004-12-13  Timo Schulz  <twoaday at g10code.com>
+
+	* w32-pth.c (enter_pth, leave_pth): New.
+	(pth_init): Initialize global mutex section.
+	(pth_kill): Release global mutex section.
+	(helper_thread): New.
+	(pth_spawn): Make sure only one thread is running.
+
+2004-12-13  Werner Koch  <wk at g10code.com>
+
+	* stringhelp.c (w32_strerror) [W32]: New.
+
+	* w32-pth.c, w32-pth.h: Added real code written by Timo	Schulz.
+	Not finished, though.
+
+2004-12-07  Werner Koch  <wk at g10code.com>
+
+	* w32-pth.c, w32-pth.h: New.
+
+2004-11-26  Werner Koch  <wk at g10code.com>
+
+	* logging.c [_WIN32]: Don't include socket headers.
+
+2004-11-30  Timo Schulz  <ts at g10code.com>
+
+	* w32-afunix.c: New. AF_UNIX emulation for W32.
+	* w32-afunix.h: Likewise.
+
+2004-11-22  Werner Koch  <wk at g10code.com>
+
+	* logging.c (log_test_fd): Add test on LOGSTREAM.  Reported by
+	Barry Schwartz.
+
+2004-11-18  Werner Koch  <wk at g10code.com>
+
+	* logging.c: Explicitly include sys/stat.h for the S_I* constants.
+
+2004-10-21  Werner Koch  <wk at g10code.com>
+
+	* logging.c (do_logv): Use set_log_stream to setup a default.
+	(log_set_file): Factored code out to ..
+	(set_file_fd): .. New function to allow using a file descriptor.
+	(log_set_fd): Make use of new fucntion.
+	(fun_writer): Reworked.
+
+2004-08-18  Werner Koch  <wk at g10code.de>
+
+	* stringhelp.c (print_sanitized_utf8_string): Actually implement
+	it.
+
+2004-06-21  Werner Koch  <wk at g10code.com>
+
+	* logging.c (log_set_file): Do not close an old logstream if it
+	used to be stderr or stdout.
+
+2004-05-05  Werner Koch  <wk at gnupg.org>
+
+	* logging.c (log_set_file): Oops, don't close if LOGSTREAM is NULL.
+
+2004-04-30  Werner Koch  <wk at gnupg.org>
+
+	* logging.c (log_set_file): Make sure the log stream will be
+	closed even if the stderr fileno will be assigned to a new socket.
+
+2004-04-16  Werner Koch  <wk at gnupg.org>
+
+	* logging.h (JNLIB_LOG_WITH_PREFIX): Add constants for the flag
+	values.
+	* logging.c (log_set_prefix): New flag DETACHED.
+	(fun_writer): Take care of this flag.
+	(log_test_fd): New.
+
+2004-02-18  Werner Koch  <wk at gnupg.org>
+
+	* stringhelp.c (print_sanitized_buffer): Don't care about
+	non-ASCII characaters.
+	(sanitize_buffer): Ditto.
+
+2004-02-12  Werner Koch  <wk at gnupg.org>
+
+	* Makefile.am: Replaced INCLUDES by AM_CPPFLAGS.
+
+2004-01-05  Werner Koch  <wk at gnupg.org>
+
+	* argparse.c (strusage): Changed default copyright year to 2004.
+
+2003-12-17  Werner Koch  <wk at gnupg.org>
+
+	* argparse.c (initialize): Replaced use of non-literal format
+	args.  Suggested by Florian Weimer.
+
+2003-12-16  Werner Koch  <wk at gnupg.org>
+
+	* logging.c (writen, fun_writer, fun_closer): New.
+	(log_set_file): Add feature to log to a socket.
+	(log_set_file, do_logv): Force printing with prefix and pid.
+
+2003-11-13  Werner Koch  <wk at gnupg.org>
+
+	* strlist.c (strlist_copy): New.
+
+	* dotlock.c: Define DIRSEP_C et al. if not defined.
+
+2003-11-06  Werner Koch  <wk at gnupg.org>
+
+	* strlist.h (strlist_t): New. STRLIST is now deprecated.
+
+2003-06-18  Werner Koch  <wk at gnupg.org>
+
+	* strlist.c (strlist_pop): New.
+
+	* dotlock.c (dotlock_remove_lockfiles): Prefixed with dotlock_ and
+	made global.
+
+2003-06-17  Werner Koch  <wk at gnupg.org>
+
+	* stringhelp.c (length_sans_trailing_chars)
+	(length_sans_trailing_ws): New.
+
+	* logging.c (log_inc_errorcount): New.
+
+	* stringhelp.c (print_sanitized_utf8_buffer): Implement utf8
+	conversion.
+	(sanitize_buffer): New. Based on gnupg 1.3.2 make_printable_string.
+
+	* dotlock.c: Updated to match the version from 1.3.2
+	* utf8conv.c: New.  Code taken from strgutil.c of gnupg 1.3.2.
+	* utf8conv.h: New.
+
+2003-06-16  Werner Koch  <wk at gnupg.org>
+
+	* logging.c (do_logv): Hack to optionally suppress a leading space.
+
+	* stringhelp.c (ascii_strncasecmp): New.  Taken from gnupg 1.3.
+	(ascii_memistr): New. Taken from gnupg 1.3
+
+2003-06-13  Werner Koch  <wk at gnupg.org>
+
+	* mischelp.h (wipememory2,wipememory): New. Taken from GnuPG 1.3.2.
+
+2002-06-04  Werner Koch  <wk at gnupg.org>
+
+	* stringhelp.c (print_sanitized_utf8_string): New.  No real
+	implementation for now.
+	(print_sanitized_utf8_buffer): Ditto.
+
+2002-04-04  Werner Koch  <wk at gnupg.org>
+
+	* logging.c (log_get_prefix): New.
+
+2002-03-15  Werner Koch  <wk at gnupg.org>
+
+	* argparse.c (optfile_parse): Fixed missing argument handling.
+
+2002-02-25  Werner Koch  <wk at gnupg.org>
+
+	* stringhelp.c (ascii_memcasemem): New.
+
+2002-02-14  Werner Koch  <wk at gnupg.org>
+
+	* Makefile.am (INCLUDES): Add cflags for libgcrypt.
+
+2002-02-07  Werner Koch  <wk at gnupg.org>
+
+	* logging.c (log_set_fd): New.
+
+	* stringhelp.c (print_sanitized_buffer): New.
+	(print_sanitized_string): New.
+
+2002-01-24  Werner Koch  <wk at gnupg.org>
+
+	* argparse.c (strusage): Set default copyright notice year to 2002.
+
+	Fixed the copyright notice of this file, as it has always been
+	part of GnuPG and therefore belongs to the FSF.
+
+2001-11-01  Marcus Brinkmann  <marcus at g10code.de>
+
+	* logging.c (log_printf): Do not initialize ARG_PTR with 0, we
+	don't know the correct type.  Instead, run va_start and va_end
+	unconditionally.
+	Reported by Jose Carlos Garcia Sogo <jsogo at debian.org>.
+
+2002-01-19  Werner Koch  <wk at gnupg.org>
+
+	* logging.c (log_get_stream): New.
+
+2001-12-05  Werner Koch  <wk at gnupg.org>
+
+	* logging.c (log_set_prefix): New.
+	(do_logv): Include prefix and pid only if enabled. Print time only
+	when explicitly enabled.
+	(log_logv): New.
+	* logging.h: Include log_logv() only when requested.
+
+2001-11-06  Werner Koch  <wk at gnupg.org>
+
+	* strlist.c, strlist.h: New. Taken from pgnupg/util/strgutil.c
+
+2001-08-30  Werner Koch  <wk at gnupg.org>
+
+	* logging.c (log_printf): Don't pass NULL instead of arg_ptr.
+
+2001-07-19  Werner Koch  <wk at gnupg.org>
+
+	* stringhelp.c (ascii_memistr,ascii_isupper,ascii_islower,
+	ascii_toupper,ascii_tolower, ascii_strcasecmp, ascii_memcasecmp): New.
+
+2000-07-26 10:02:51  Werner Koch  (wk at habibti.openit.de)
+
+	* stringhelp.c.: Add stdarg.h
+	* argparse.h: s/ulong/unsigned long/ although this should be defined
+        by types.h.
+
+2000-06-28 19:40:23  Werner Koch  (wk at habibti.openit.de)
+
+	* Makefile.am: Replaced second logging.c by .h
+
+2000-05-24 08:58:15  Werner Koch  (wk at habibti.openit.de)
+
+	* logging.c (log_get_errorcount): New.
+
+2000-05-24 08:44:47  Werner Koch  (wk at habibti.openit.de)
+
+	* stringhelp.c: Added a few filename related helper functions.
+
+2000-05-11 18:04:43  Werner Koch  (wk at habibti.openit.de)
+
+	* xmalloc.c (xstrcat2): Replaced stpcpy to quickly address W32
+	problems.
+
+2000-05-02 19:43:38  Werner Koch  (wk at habibti.openit.de)
+
+	* xmalloc.c (xstrcat2): New.
+
+Mon Jan 24 13:04:28 CET 2000  Werner Koch  <wk at gnupg.de>
+
+	* README: New.
+	* Makefile.am: new.
+	* argparse.c, argparse.h, logging.c, logging.h:
+	* mischelp.h, stringhelp.c, stringhelp.h, xmalloc.c:
+	* xmalloc.h, dotlock.c: Moved from ../util to here.
+	* dotlock.h: New.
+	* libjnlib-config.h: New.
+
+	* logging.c (log_set_file): New.
+	(log_printf): New.
+	(do_logv): Add kludge to insert LFs.
+
+
+     ***********************************************************
+     * Please note that JNLIB is maintained as part of GnuPG.  *
+     * You may find it source-copied in other packages.        *
+     ***********************************************************
+
+ Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
+	   2010 Free Software Foundation, Inc.
+
+ This file is free software; as a special exception the author gives
+ unlimited permission to copy and/or distribute it, with or without
+ 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.


Modified: trunk/g10/ChangeLog
===================================================================
--- trunk/g10/ChangeLog	2010-03-09 12:50:48 UTC (rev 5287)
+++ trunk/g10/ChangeLog	2010-03-10 12:24:58 UTC (rev 5288)
@@ -1,3 +1,9 @@
+2010-03-10  Werner Koch  <wk at g10code.com>
+
+	* Makefile.am (needed_libs): Remove libjnlib.a.
+
+	* main.h: Remove "estream.h".
+
 2010-03-08  Werner Koch  <wk at g10code.com>
 
 	* main.h: Include "estream.h"

Modified: trunk/kbx/ChangeLog
===================================================================
--- trunk/kbx/ChangeLog	2010-03-09 12:50:48 UTC (rev 5287)
+++ trunk/kbx/ChangeLog	2010-03-10 12:24:58 UTC (rev 5288)
@@ -1,3 +1,10 @@
+2010-03-10  Werner Koch  <wk at g10code.com>
+
+	* Makefile.am (kbxutil_LDADD, $(PROGRAMS)): Remove libjnlib.a.
+
+	* keybox-search.c, keybox-init.c, keybox-defs.h, kbxutil.c:
+	Replace "jnlib" include file part by "common".
+
 2010-03-08  Werner Koch  <wk at g10code.com>
 
 	Use macros for iobuf_ioctl commands.

Modified: trunk/scd/ChangeLog
===================================================================
--- trunk/scd/ChangeLog	2010-03-09 12:50:48 UTC (rev 5287)
+++ trunk/scd/ChangeLog	2010-03-10 12:24:58 UTC (rev 5288)
@@ -1,3 +1,7 @@
+2010-03-10  Werner Koch  <wk at g10code.com>
+
+	* Makefile.am (scdaemon_LDADD): Remove libjnlib.a.
+
 2009-12-15  Werner Koch  <wk at g10code.com>
 
 	* iso7816.c (do_generate_keypair): s/readonly/read_only/ because

Modified: trunk/sm/ChangeLog
===================================================================
--- trunk/sm/ChangeLog	2010-03-09 12:50:48 UTC (rev 5287)
+++ trunk/sm/ChangeLog	2010-03-10 12:24:58 UTC (rev 5288)
@@ -1,3 +1,9 @@
+2010-03-10  Werner Koch  <wk at g10code.com>
+
+	* Makefile.am (common_libs): Remove libjnlib.a.  Change order.
+
+	* gpgsm.h: Remove "estream.h".
+
 2010-03-08  Werner Koch  <wk at g10code.com>
 
 	* certreqgen.c (gpgsm_genkey): Change OUT_FP to an estream_t

Modified: trunk/tools/ChangeLog
===================================================================
--- trunk/tools/ChangeLog	2010-03-09 12:50:48 UTC (rev 5287)
+++ trunk/tools/ChangeLog	2010-03-10 12:24:58 UTC (rev 5288)
@@ -1,3 +1,7 @@
+2010-03-10  Werner Koch  <wk at g10code.com>
+
+	* Makefile.am (common_libs): Remove libjnlib.a.
+
 2010-03-08  Werner Koch  <wk at g10code.com>
 
 	* no-libgcrypt.c (gcry_create_nonce): New.

Modified: trunk/Makefile.am
===================================================================
--- trunk/Makefile.am	2010-03-09 12:50:48 UTC (rev 5287)
+++ trunk/Makefile.am	2010-03-10 12:24:58 UTC (rev 5288)
@@ -76,7 +76,7 @@
 tests = tests
 endif
 
-SUBDIRS = m4 gl include jnlib common ${kbx} \
+SUBDIRS = m4 gl include common ${kbx} \
  ${gpg} ${keyserver} ${sm} ${agent} ${scd} ${g13} ${tools} po ${doc} ${tests}
 
 dist_doc_DATA = README

Modified: trunk/acinclude.m4
===================================================================
--- trunk/acinclude.m4	2010-03-09 12:50:48 UTC (rev 5287)
+++ trunk/acinclude.m4	2010-03-10 12:24:58 UTC (rev 5288)
@@ -103,6 +103,7 @@
 AC_DEFUN([GNUPG_CHECK_ENDIAN],
   [
     tmp_assumed_endian=big
+    tmp_assume_warn=""
     if test "$cross_compiling" = yes; then
       case "$host_cpu" in
          i@<:@345678@:>@* )
@@ -111,7 +112,6 @@
          *)
             ;;
       esac
-      AC_MSG_WARN(cross compiling; assuming $tmp_assumed_endian endianess)
     fi
     AC_MSG_CHECKING(endianess)
     AC_CACHE_VAL(gnupg_cv_c_endian,
@@ -141,10 +141,11 @@
               gnupg_cv_c_endian=little,
               gnupg_cv_c_endian=big,
               gnupg_cv_c_endian=$tmp_assumed_endian
+              tmp_assumed_warn=" (assumed)"
             )
         fi
       ])
-    AC_MSG_RESULT([$gnupg_cv_c_endian])
+    AC_MSG_RESULT([${gnupg_cv_c_endian}${tmp_assumed_warn}])
     if test "$gnupg_cv_c_endian" = little; then
       AC_DEFINE(LITTLE_ENDIAN_HOST,1,
                 [Defined if the host has little endian byte ordering])

Modified: trunk/agent/Makefile.am
===================================================================
--- trunk/agent/Makefile.am	2010-03-09 12:50:48 UTC (rev 5287)
+++ trunk/agent/Makefile.am	2010-03-10 12:24:58 UTC (rev 5288)
@@ -45,8 +45,8 @@
 	call-scd.c \
 	learncard.c
 
-common_libs = $(libcommon) ../jnlib/libjnlib.a ../gl/libgnu.a
-commonpth_libs = $(libcommonpth) ../jnlib/libjnlib.a ../gl/libgnu.a
+common_libs = $(libcommon) ../gl/libgnu.a
+commonpth_libs = $(libcommonpth) ../gl/libgnu.a
 pwquery_libs = ../common/libsimple-pwquery.a
 
 #if HAVE_W32_SYSTEM

Modified: trunk/agent/command-ssh.c
===================================================================
--- trunk/agent/command-ssh.c	2010-03-09 12:50:48 UTC (rev 5287)
+++ trunk/agent/command-ssh.c	2010-03-10 12:24:58 UTC (rev 5288)
@@ -32,7 +32,6 @@
 
 #include "agent.h"
 
-#include "estream.h"
 #include "i18n.h"
 
 

Modified: trunk/agent/minip12.c
===================================================================
--- trunk/agent/minip12.c	2010-03-09 12:50:48 UTC (rev 5287)
+++ trunk/agent/minip12.c	2010-03-10 12:24:58 UTC (rev 5288)
@@ -32,8 +32,8 @@
 #include <unistd.h>
 #endif
 
-#include "../jnlib/logging.h"
-#include "../jnlib/utf8conv.h"
+#include "../common/logging.h"
+#include "../common/utf8conv.h"
 #include "minip12.h"
 
 #ifndef DIM
@@ -2354,7 +2354,7 @@
 
 /*
 Local Variables:
-compile-command: "gcc -Wall -O0 -g -DTEST=1 -o minip12 minip12.c ../jnlib/libjnlib.a -L /usr/local/lib -lgcrypt -lgpg-error"
+compile-command: "gcc -Wall -O0 -g -DTEST=1 -o minip12 minip12.c ../common/libcommon.a -L /usr/local/lib -lgcrypt -lgpg-error"
 End:
 */
 #endif /* TEST */

Modified: trunk/agent/protect-tool.c
===================================================================
--- trunk/agent/protect-tool.c	2010-03-09 12:50:48 UTC (rev 5287)
+++ trunk/agent/protect-tool.c	2010-03-10 12:24:58 UTC (rev 5288)
@@ -44,7 +44,6 @@
 #include "i18n.h"
 #include "get-passphrase.h"
 #include "sysutils.h"
-#include "estream.h"
 
 
 enum cmd_and_opt_values 

Modified: trunk/agent/trustlist.c
===================================================================
--- trunk/agent/trustlist.c	2010-03-09 12:50:48 UTC (rev 5287)
+++ trunk/agent/trustlist.c	2010-03-10 12:24:58 UTC (rev 5288)
@@ -31,7 +31,6 @@
 #include "agent.h"
 #include <assuan.h> /* fixme: need a way to avoid assuan calls here */
 #include "i18n.h"
-#include "estream.h"
 
 
 /* A structure to store the information from the trust file. */

Property changes on: trunk/common/ChangeLog.jnlib
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:mergeinfo
   + 
Name: svn:eol-style
   + native

Modified: trunk/common/Makefile.am
===================================================================
--- trunk/common/Makefile.am	2010-03-09 12:50:48 UTC (rev 5287)
+++ trunk/common/Makefile.am	2010-03-10 12:24:58 UTC (rev 5288)
@@ -1,5 +1,5 @@
 # Makefile for common gnupg modules
-# Copyright (C) 2001, 2003, 2007 Free Software Foundation, Inc.
+# Copyright (C) 2001, 2003, 2007, 2010 Free Software Foundation, Inc.
 #
 # This file is part of GnuPG.
 #
@@ -19,11 +19,11 @@
 ## Process this file with automake to produce Makefile.in
 
 EXTRA_DIST = mkstrtable.awk exaudit.awk exstatus.awk \
-             audit-events.h status-codes.h
+             audit-events.h status-codes.h README.jnlib ChangeLog.jnlib
 
 noinst_LIBRARIES = libcommon.a libcommonpth.a libsimple-pwquery.a libgpgrl.a
-noinst_PROGRAMS = $(module_tests) $(module_maint_tests)
-TESTS = $(module_tests)
+noinst_PROGRAMS = $(jnlib_tests) $(module_tests) $(module_maint_tests)
+TESTS = $(jnlib_tests) $(module_tests)
 
 BUILT_SOURCES = audit-events.h status-codes.h
 
@@ -35,9 +35,26 @@
 
 include $(top_srcdir)/am/cmacros.am
 
+jnlib_sources = \
+	libjnlib-config.h \
+	types.h dynload.h w32help.h \
+	stringhelp.c stringhelp.h \
+	strlist.c strlist.h \
+	utf8conv.c utf8conv.h \
+	argparse.c argparse.h \
+	logging.c logging.h  \
+	dotlock.c dotlock.h  \
+        mischelp.c mischelp.h
+
+if HAVE_W32_SYSTEM
+jnlib_sources += w32-reg.c w32-afunix.c w32-afunix.h
+endif
+
+
 common_sources = \
 	common-defs.h \
 	util.h i18n.c i18n.h \
+	estream.c estream.h estream-printf.c estream-printf.h \
 	status.c status.h\
 	openpgpdefs.h \
 	gc-opt-flags.h \
@@ -62,7 +79,6 @@
 	asshelp.c asshelp.h \
 	exechelp.c exechelp.h \
 	signal.c \
-	estream.c estream.h estream-printf.c estream-printf.h \
 	audit.c audit.h \
 	srv.h \
 	dns-cert.c dns-cert.h \
@@ -78,13 +94,13 @@
         get-passphrase.c get-passphrase.h
 
 
-libcommon_a_SOURCES = $(common_sources) $(without_pth_sources)
+libcommon_a_SOURCES = $(jnlib_sources) $(common_sources) $(without_pth_sources)
 if USE_DNS_SRV
 libcommon_a_SOURCES += srv.c
 endif
 libcommon_a_CFLAGS = $(AM_CFLAGS) $(LIBASSUAN_CFLAGS) -DWITHOUT_GNU_PTH=1
 
-libcommonpth_a_SOURCES = $(common_sources)
+libcommonpth_a_SOURCES = $(jnlib_sources) $(common_sources)
 if USE_DNS_SRV
 libcommonpth_a_SOURCES += srv.c
 endif
@@ -121,13 +137,32 @@
 #
 # Module tests
 #
+t_jnlib_src = t-support.c t-support.h 
+jnlib_tests = t-stringhelp t-timestuff
+if HAVE_W32_SYSTEM
+jnlib_tests += t-w32-reg
+endif
 module_tests = t-convert t-percent t-gettime t-sysutils t-sexputil t-exechelp \
 	       t-session-env
 module_maint_tests = t-helpfile t-b64
 
-t_common_ldadd = libcommon.a ../jnlib/libjnlib.a ../gl/libgnu.a \
+
+t_common_ldadd = libcommon.a ../gl/libgnu.a \
                  $(LIBGCRYPT_LIBS) $(GPG_ERROR_LIBS) $(LIBINTL) $(LIBICONV)
 
+# jnlib tests
+t_stringhelp_SOURCES = t-stringhelp.c $(t_jnlib_src)
+t_stringhelp_LDADD = $(t_common_ldadd)
+
+t_timestuff_SOURCES = t-timestuff.c $(t_jnlib_src)
+t_timestuff_LDADD = $(t_common_ldadd)
+
+if HAVE_W32_SYSTEM
+t_w32_reg_SOURCES = t-w32-reg.c $(t_jnlib_src)
+t_w32_reg_LDADD   = $(t_common_ldadd)
+endif
+
+# common tests
 t_convert_LDADD = $(t_common_ldadd)
 t_percent_LDADD = $(t_common_ldadd)
 t_gettime_LDADD = $(t_common_ldadd)
@@ -138,3 +173,6 @@
 t_exechelp_LDADD = $(t_common_ldadd)
 t_session_env_LDADD = $(t_common_ldadd)
 
+
+
+

Copied: trunk/common/README.jnlib (from rev 5272, trunk/jnlib/README)
===================================================================
--- trunk/common/README.jnlib	                        (rev 0)
+++ trunk/common/README.jnlib	2010-03-10 12:24:58 UTC (rev 5288)
@@ -0,0 +1,101 @@
+JNLIB - This is a collection of utility function which are too small
+to put into a library.  The code here is licensed under the LGPL.
+
+libjnlib-config.h should be be modified for each project to make these
+functions fit into the software. Mainly these are memory functions in
+case you need another allocator.
+
+Files which make up jnlib:
+    README.jnlib
+    ChangeLog.jnlib
+    libjnlib-config.h
+    argparse.c
+    argparse.h
+    dotlock.c
+    dotlock.h
+    dynload.h
+    logging.c
+    logging.h
+    mischelp.c
+    mischelp.h
+    stringhelp.c
+    stringhelp.h
+    strlist.c
+    strlist.h
+    types.h
+    utf8conv.c
+    utf8conv.h
+    w32-afunix.c
+    w32-afunix.h
+    w32-reg.c
+    w32help.h
+    xmalloc.c
+    xmalloc.h
+    t-stringhelp.c
+    t-support.c
+    t-support.h
+    t-timestuff.c
+    t-w32-reg.c
+
+
+Here is a template Makefile.am for these jnlib modules:
+===8<==================================================
+EXTRA_DIST = README
+noinst_PROGRAMS = $(module_tests)
+TESTS = $(module_tests)
+
+AM_CPPFLAGS = -I$(top_srcdir)/intl
+
+# We need libgcrypt because libjnlib-config includes gcrypt.h
+AM_CFLAGS = $(LIBGCRYPT_CFLAGS)
+
+noinst_LIBRARIES = libjnlib.a
+
+libjnlib_a_SOURCES = \
+	libjnlib-config.h \
+	stringhelp.c stringhelp.h \
+	strlist.c strlist.h \
+	utf8conv.c utf8conv.h \
+	argparse.c argparse.h \
+	logging.c logging.h  \
+	dotlock.c dotlock.h  \
+	types.h mischelp.c mischelp.h dynload.h w32help.h \
+        xmalloc.c xmalloc.h       
+
+if HAVE_W32_SYSTEM
+libjnlib_a_SOURCES += w32-reg.c w32-afunix.c w32-afunix.h
+endif
+
+#
+# Module tests.
+#
+# These tests should only be used at the canonical location of jnlib
+# which is the GnuPG package.  The reason for this is that t-support.c
+# defines replacements for the actual used memory allocation functions
+# so that there is no dependency on libgcrypt.
+#
+module_tests = t-stringhelp t-timestuff
+if HAVE_W32_SYSTEM
+module_tests += t-w32-reg
+endif
+
+t_jnlib_src = t-support.c t-support.h 
+t_jnlib_ldadd = libjnlib.a $(LIBINTL) $(LIBICONV)
+# For W32 we need libgpg-error because it provides gettext.
+if HAVE_W32_SYSTEM
+t_jnlib_ldadd += $(GPG_ERROR_LIBS)
+endif
+
+t_stringhelp_SOURCES = t-stringhelp.c $(t_jnlib_src)
+t_stringhelp_LDADD = $(t_jnlib_ldadd)
+
+t_timestuff_SOURCES = t-timestuff.c $(t_jnlib_src)
+t_timestuff_LDADD = $(t_jnlib_ldadd)
+
+if HAVE_W32_SYSTEM
+t_w32_reg_SOURCES = t-w32-reg.c $(t_jnlib_src)
+t_w32_reg_LDADD   = $(t_jnlib_ldadd)
+endif
+==>8===================================================
+
+


Property changes on: trunk/common/README.jnlib
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:mergeinfo
   + 
Name: svn:eol-style
   + native

Copied: trunk/common/argparse.c (from rev 5272, trunk/jnlib/argparse.c)
===================================================================
--- trunk/common/argparse.c	                        (rev 0)
+++ trunk/common/argparse.c	2010-03-10 12:24:58 UTC (rev 5288)
@@ -0,0 +1,1205 @@
+/* [argparse.c wk 17.06.97] Argument Parser for option handling
+ * Copyright (C) 1998, 1999, 2000, 2001, 2006
+ *               2007, 2008  Free Software Foundation, Inc.
+ *
+ * This file is part of JNLIB.
+ *
+ * JNLIB is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JNLIB is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <string.h>
+
+#include "libjnlib-config.h"
+#include "mischelp.h"
+#include "stringhelp.h"
+#include "logging.h"
+#ifdef JNLIB_NEED_UTF8CONV
+#include "utf8conv.h"
+#endif
+#include "argparse.h"
+
+
+
+/*********************************
+ * @Summary arg_parse
+ *  #include <wk/lib.h>
+ *
+ *  typedef struct {
+ *	char *argc;		  pointer to argc (value subject to change)
+ *	char ***argv;		  pointer to argv (value subject to change)
+ *	unsigned flags; 	  Global flags (DO NOT CHANGE)
+ *	int err;		  print error about last option
+ *				  1 = warning, 2 = abort
+ *	int r_opt;		  return option
+ *	int r_type;		  type of return value (0 = no argument found)
+ *	union {
+ *	    int   ret_int;
+ *	    long  ret_long
+ *	    ulong ret_ulong;
+ *	    char *ret_str;
+ *	} r;			  Return values
+ *	struct {
+ *	    int idx;
+ *	    const char *last;
+ *	    void *aliases;
+ *	} internal;		  DO NOT CHANGE
+ *  } ARGPARSE_ARGS;
+ *
+ *  typedef struct {
+ *	int	    short_opt;
+ *	const char *long_opt;
+ *	unsigned flags;
+ *  } ARGPARSE_OPTS;
+ *
+ *  int arg_parse( ARGPARSE_ARGS *arg, ARGPARSE_OPTS *opts );
+ *
+ * @Description
+ *  This is my replacement for getopt(). See the example for a typical usage.
+ *  Global flags are:
+ *     Bit 0 : Do not remove options form argv
+ *     Bit 1 : Do not stop at last option but return other args
+ *	       with r_opt set to -1.
+ *     Bit 2 : Assume options and real args are mixed.
+ *     Bit 3 : Do not use -- to stop option processing.
+ *     Bit 4 : Do not skip the first arg.
+ *     Bit 5 : allow usage of long option with only one dash
+ *     Bit 6 : ignore --version
+ *     all other bits must be set to zero, this value is modified by the
+ *     function, so assume this is write only.
+ *  Local flags (for each option):
+ *     Bit 2-0 : 0 = does not take an argument
+ *		 1 = takes int argument
+ *		 2 = takes string argument
+ *		 3 = takes long argument
+ *		 4 = takes ulong argument
+ *     Bit 3 : argument is optional (r_type will the be set to 0)
+ *     Bit 4 : allow 0x etc. prefixed values.
+ *     Bit 7 : this is a command and not an option
+ *  You stop the option processing by setting opts to NULL, the function will
+ *  then return 0.
+ * @Return Value
+ *   Returns the args.r_opt or 0 if ready
+ *   r_opt may be -2/-7 to indicate an unknown option/command.
+ * @See Also
+ *   ArgExpand
+ * @Notes
+ *  You do not need to process the options 'h', '--help' or '--version'
+ *  because this function includes standard help processing; but if you
+ *  specify '-h', '--help' or '--version' you have to do it yourself.
+ *  The option '--' stops argument processing; if bit 1 is set the function
+ *  continues to return normal arguments.
+ *  To process float args or unsigned args you must use a string args and do
+ *  the conversion yourself.
+ * @Example
+ *
+ *     ARGPARSE_OPTS opts[] = {
+ *     { 'v', "verbose",   0 },
+ *     { 'd', "debug",     0 },
+ *     { 'o', "output",    2 },
+ *     { 'c', "cross-ref", 2|8 },
+ *     { 'm', "my-option", 1|8 },
+ *     { 500, "have-no-short-option-for-this-long-option", 0 },
+ *     {0} };
+ *     ARGPARSE_ARGS pargs = { &argc, &argv, 0 }
+ *
+ *     while( ArgParse( &pargs, &opts) ) {
+ *	   switch( pargs.r_opt ) {
+ *	     case 'v': opt.verbose++; break;
+ *	     case 'd': opt.debug++; break;
+ *	     case 'o': opt.outfile = pargs.r.ret_str; break;
+ *	     case 'c': opt.crf = pargs.r_type? pargs.r.ret_str:"a.crf"; break;
+ *	     case 'm': opt.myopt = pargs.r_type? pargs.r.ret_int : 1; break;
+ *	     case 500: opt.a_long_one++;  break
+ *	     default : pargs.err = 1; break; -- force warning output --
+ *	   }
+ *     }
+ *     if( argc > 1 )
+ *	   log_fatal( "Too many args");
+ *
+ */
+
+typedef struct alias_def_s *ALIAS_DEF;
+struct alias_def_s {
+    ALIAS_DEF next;
+    char *name;   /* malloced buffer with name, \0, value */
+    const char *value; /* ptr into name */
+};
+
+static const char *(*strusage_handler)( int ) = NULL;
+
+static int  set_opt_arg(ARGPARSE_ARGS *arg, unsigned flags, char *s);
+static void show_help(ARGPARSE_OPTS *opts, unsigned flags);
+static void show_version(void);
+
+
+static void
+initialize( ARGPARSE_ARGS *arg, const char *filename, unsigned *lineno )
+{
+  if( !(arg->flags & (1<<15)) ) 
+    { 
+      /* Initialize this instance. */
+      arg->internal.idx = 0;
+      arg->internal.last = NULL;
+      arg->internal.inarg = 0;
+      arg->internal.stopped = 0;
+      arg->internal.aliases = NULL;
+      arg->internal.cur_alias = NULL;
+      arg->err = 0;
+      arg->flags |= 1<<15; /* Mark as initialized.  */
+      if ( *arg->argc < 0 )
+        jnlib_log_bug ("invalid argument for arg_parsee\n");
+    }
+  
+  
+  if (arg->err)
+    {
+      /* Last option was erroneous.  */
+      const char *s;
+      
+      if (filename)
+        {
+          if ( arg->r_opt == ARGPARSE_UNEXPECTED_ARG )
+            s = _("argument not expected");
+          else if ( arg->r_opt == ARGPARSE_READ_ERROR )
+            s = _("read error");
+          else if ( arg->r_opt == ARGPARSE_KEYWORD_TOO_LONG )
+            s = _("keyword too long");
+          else if ( arg->r_opt == ARGPARSE_MISSING_ARG )
+            s = _("missing argument");
+          else if ( arg->r_opt == ARGPARSE_INVALID_COMMAND )
+            s = _("invalid command");
+          else if ( arg->r_opt == ARGPARSE_INVALID_ALIAS )
+            s = _("invalid alias definition");
+          else if ( arg->r_opt == ARGPARSE_OUT_OF_CORE )
+            s = _("out of core");
+          else
+            s = _("invalid option");
+          jnlib_log_error ("%s:%u: %s\n", filename, *lineno, s);
+	}
+      else 
+        {
+          s = arg->internal.last? arg->internal.last:"[??]";
+            
+          if ( arg->r_opt == ARGPARSE_MISSING_ARG )
+            jnlib_log_error (_("missing argument for option \"%.50s\"\n"), s);
+          else if ( arg->r_opt == ARGPARSE_UNEXPECTED_ARG )
+            jnlib_log_error (_("option \"%.50s\" does not expect an "
+                               "argument\n"), s );
+          else if ( arg->r_opt == ARGPARSE_INVALID_COMMAND )
+            jnlib_log_error (_("invalid command \"%.50s\"\n"), s);
+          else if ( arg->r_opt == ARGPARSE_AMBIGUOUS_OPTION )
+            jnlib_log_error (_("option \"%.50s\" is ambiguous\n"), s);
+          else if ( arg->r_opt == ARGPARSE_AMBIGUOUS_OPTION )
+            jnlib_log_error (_("command \"%.50s\" is ambiguous\n"),s );
+          else if ( arg->r_opt == ARGPARSE_OUT_OF_CORE )
+            jnlib_log_error ("%s\n", _("out of core\n"));
+          else
+            jnlib_log_error (_("invalid option \"%.50s\"\n"), s);
+	}
+      if ( arg->err != 1 )
+        exit (2);
+      arg->err = 0;
+    }
+
+  /* Zero out the return value union.  */
+  arg->r.ret_str = NULL;
+  arg->r.ret_long = 0;
+}
+
+
+static void
+store_alias( ARGPARSE_ARGS *arg, char *name, char *value )
+{
+    /* TODO: replace this dummy function with a rea one
+     * and fix the probelms IRIX has with (ALIAS_DEV)arg..
+     * used as lvalue
+     */
+  (void)arg;
+  (void)name;
+  (void)value;
+#if 0
+    ALIAS_DEF a = jnlib_xmalloc( sizeof *a );
+    a->name = name;
+    a->value = value;
+    a->next = (ALIAS_DEF)arg->internal.aliases;
+    (ALIAS_DEF)arg->internal.aliases = a;
+#endif
+}
+
+/****************
+ * Get options from a file.
+ * Lines starting with '#' are comment lines.
+ * Syntax is simply a keyword and the argument.
+ * Valid keywords are all keywords from the long_opt list without
+ * the leading dashes. The special keywords "help", "warranty" and "version"
+ * are not valid here.
+ * The special keyword "alias" may be used to store alias definitions,
+ * which are later expanded like long options.
+ * Caller must free returned strings.
+ * If called with FP set to NULL command line args are parse instead.
+ *
+ * Q: Should we allow the syntax
+ *     keyword = value
+ *    and accept for boolean options a value of 1/0, yes/no or true/false?
+ * Note: Abbreviation of options is here not allowed.
+ */
+int
+optfile_parse (FILE *fp, const char *filename, unsigned *lineno,
+	       ARGPARSE_ARGS *arg, ARGPARSE_OPTS *opts)
+{
+  int state, i, c;
+  int idx=0;
+  char keyword[100];
+  char *buffer = NULL;
+  size_t buflen = 0;
+  int in_alias=0;
+  
+  if (!fp) /* Divert to to arg_parse() in this case.  */
+    return arg_parse (arg, opts);
+  
+  initialize (arg, filename, lineno);
+
+  /* Find the next keyword.  */
+  state = i = 0;
+  for (;;)
+    {
+      c = getc (fp);
+      if (c == '\n' || c== EOF )
+        {
+          if ( c != EOF )
+            ++*lineno;
+          if (state == -1)
+            break;
+          else if (state == 2)
+            {
+              keyword[i] = 0;
+              for (i=0; opts[i].short_opt; i++ )
+                {
+                  if (opts[i].long_opt && !strcmp (opts[i].long_opt, keyword))
+                    break;
+                }
+              idx = i;
+              arg->r_opt = opts[idx].short_opt;
+              if (!opts[idx].short_opt )
+                arg->r_opt = ((opts[idx].flags & ARGPARSE_OPT_COMMAND)
+                              ? ARGPARSE_INVALID_COMMAND
+                              : ARGPARSE_INVALID_OPTION);
+              else if (!(opts[idx].flags & 7)) 
+                arg->r_type = 0; /* Does not take an arg. */
+              else if ((opts[idx].flags & 8) )  
+                arg->r_type = 0; /* Arg is optional.  */
+              else
+                arg->r_opt = ARGPARSE_MISSING_ARG;
+
+              break;
+	    }
+          else if (state == 3)
+            {	
+              /* No argument found.  */
+              if (in_alias)
+                arg->r_opt = ARGPARSE_MISSING_ARG;
+              else if (!(opts[idx].flags & 7)) 
+                arg->r_type = 0; /* Does not take an arg. */
+              else if ((opts[idx].flags & 8))  
+                arg->r_type = 0; /* No optional argument. */
+              else
+                arg->r_opt = ARGPARSE_MISSING_ARG;
+
+              break;
+	    }
+          else if (state == 4)
+            {
+              /* Has an argument. */
+              if (in_alias) 
+                {
+                  if (!buffer)
+                    arg->r_opt = ARGPARSE_UNEXPECTED_ARG;
+                  else 
+                    {
+                      char *p;
+                      
+                      buffer[i] = 0;
+                      p = strpbrk (buffer, " \t");
+                      if (p)
+                        {
+                          *p++ = 0;
+                          trim_spaces (p);
+			}
+                      if (!p || !*p)
+                        {
+                          jnlib_free (buffer);
+                          arg->r_opt = ARGPARSE_INVALID_ALIAS;
+                        }
+                      else
+                        {
+                          store_alias (arg, buffer, p);
+                        }
+		    }
+		}
+              else if (!(opts[idx].flags & 7))
+                arg->r_opt = ARGPARSE_UNEXPECTED_ARG;
+              else
+                {
+                  char *p;
+
+                  if (!buffer)
+                    {
+                      keyword[i] = 0;
+                      buffer = jnlib_strdup (keyword);
+                      if (!buffer)
+                        arg->r_opt = ARGPARSE_OUT_OF_CORE;
+		    }
+                  else
+                    buffer[i] = 0;
+                  
+                  if (buffer)
+                    {
+                      trim_spaces (buffer);
+                      p = buffer;
+                      if (*p == '"')
+                        { 
+                          /* Remove quotes. */
+                          p++;
+                          if (*p && p[strlen(p)-1] == '\"' )
+                            p[strlen(p)-1] = 0;
+                        }
+                      if (!set_opt_arg (arg, opts[idx].flags, p))
+			jnlib_free(buffer);
+                    }
+                }
+              break;
+            }
+          else if (c == EOF)
+            {
+              if (ferror (fp))
+                arg->r_opt = ARGPARSE_READ_ERROR;
+              else
+                arg->r_opt = 0; /* EOF. */
+              break;
+            }
+          state = 0;
+          i = 0;
+        }
+      else if (state == -1)
+        ; /* Skip. */
+      else if (state == 0 && isascii (c) && isspace(c))
+        ; /* Skip leading white space.  */
+      else if (state == 0 && c == '#' )
+        state = 1;	/* Start of a comment.  */
+      else if (state == 1)
+        ; /* Skip comments. */
+      else if (state == 2 && isascii (c) && isspace(c))
+        {
+          /* Check keyword.  */
+          keyword[i] = 0;
+          for (i=0; opts[i].short_opt; i++ )
+            if (opts[i].long_opt && !strcmp (opts[i].long_opt, keyword))
+              break;
+          idx = i;
+          arg->r_opt = opts[idx].short_opt;
+          if (!opts[idx].short_opt)
+            {
+              if (!strcmp (keyword, "alias"))
+                {
+                  in_alias = 1;
+                  state = 3;
+                }
+              else 
+                {
+                  arg->r_opt = ((opts[idx].flags & ARGPARSE_OPT_COMMAND)
+                                ? ARGPARSE_INVALID_COMMAND
+                                : ARGPARSE_INVALID_OPTION);
+                  state = -1; /* Skip rest of line and leave.  */
+                }
+            }
+          else
+            state = 3;
+        }
+      else if (state == 3)
+        {
+          /* Skip leading spaces of the argument.  */
+          if (!isascii (c) || !isspace(c))
+            {
+              i = 0;
+              keyword[i++] = c;
+              state = 4;
+            }
+        }
+      else if (state == 4)
+        { 
+          /* Collect the argument. */
+          if (buffer)
+            {
+              if (i < buflen-1)
+                buffer[i++] = c;
+              else 
+                {
+                  char *tmp;
+                  size_t tmplen = buflen + 50;
+
+                  tmp = jnlib_realloc (buffer, tmplen);
+                  if (tmp)
+                    {
+                      buflen = tmplen;
+                      buffer = tmp;
+                      buffer[i++] = c;
+                    }
+                  else
+                    {
+                      jnlib_free (buffer);
+                      arg->r_opt = ARGPARSE_OUT_OF_CORE;
+                      break;
+                    }
+                }
+            }
+          else if (i < DIM(keyword)-1)
+            keyword[i++] = c;
+          else 
+            {
+              size_t tmplen = DIM(keyword) + 50;
+              buffer = jnlib_malloc (tmplen);
+              if (buffer)
+                {
+                  buflen = tmplen;
+                  memcpy(buffer, keyword, i);
+                  buffer[i++] = c;
+                }
+              else
+                {
+                  arg->r_opt = ARGPARSE_OUT_OF_CORE;
+                  break;
+                }
+            }
+        }
+      else if (i >= DIM(keyword)-1)
+        {
+          arg->r_opt = ARGPARSE_KEYWORD_TOO_LONG;
+          state = -1; /* Skip rest of line and leave.  */
+        }
+      else 
+        {
+          keyword[i++] = c;
+          state = 2;
+        }
+    }
+  
+  return arg->r_opt;
+}
+
+
+
+static int
+find_long_option( ARGPARSE_ARGS *arg,
+		  ARGPARSE_OPTS *opts, const char *keyword )
+{
+    int i;
+    size_t n;
+
+    (void)arg;
+
+    /* Would be better if we can do a binary search, but it is not
+       possible to reorder our option table because we would mess
+       up our help strings - What we can do is: Build a nice option
+       lookup table wehn this function is first invoked */
+    if( !*keyword )
+	return -1;
+    for(i=0; opts[i].short_opt; i++ )
+	if( opts[i].long_opt && !strcmp( opts[i].long_opt, keyword) )
+	    return i;
+#if 0
+    {
+	ALIAS_DEF a;
+	/* see whether it is an alias */
+	for( a = args->internal.aliases; a; a = a->next ) {
+	    if( !strcmp( a->name, keyword) ) {
+		/* todo: must parse the alias here */
+		args->internal.cur_alias = a;
+		return -3; /* alias available */
+	    }
+	}
+    }
+#endif
+    /* not found, see whether it is an abbreviation */
+    /* aliases may not be abbreviated */
+    n = strlen( keyword );
+    for(i=0; opts[i].short_opt; i++ ) {
+	if( opts[i].long_opt && !strncmp( opts[i].long_opt, keyword, n ) ) {
+	    int j;
+	    for(j=i+1; opts[j].short_opt; j++ ) {
+		if( opts[j].long_opt
+		    && !strncmp( opts[j].long_opt, keyword, n ) )
+		    return -2;	/* abbreviation is ambiguous */
+	    }
+	    return i;
+	}
+    }
+    return -1;
+}
+
+int
+arg_parse( ARGPARSE_ARGS *arg, ARGPARSE_OPTS *opts)
+{
+  int idx;
+  int argc;
+  char **argv;
+  char *s, *s2;
+  int i;
+  
+  initialize( arg, NULL, NULL );
+  argc = *arg->argc;
+  argv = *arg->argv;
+  idx = arg->internal.idx;
+
+  if (!idx && argc && !(arg->flags & ARGPARSE_FLAG_ARG0))
+    {
+      /* Skip the first argument.  */
+      argc--; argv++; idx++;
+    }
+  
+ next_one:
+  if (!argc) 
+    { 
+      /* No more args.  */
+      arg->r_opt = 0;
+      goto leave; /* Ready. */
+    }
+
+  s = *argv;
+  arg->internal.last = s;
+
+  if (arg->internal.stopped && (arg->flags & ARGPARSE_FLAG_ALL)) 
+    {
+      arg->r_opt = ARGPARSE_IS_ARG;  /* Not an option but an argument.  */
+      arg->r_type = 2;
+      arg->r.ret_str = s;
+      argc--; argv++; idx++; /* set to next one */
+    }
+  else if( arg->internal.stopped ) 
+    {
+      arg->r_opt = 0;
+      goto leave; /* Ready.  */
+    }
+  else if ( *s == '-' && s[1] == '-' )
+    {
+      /* Long option.  */
+      char *argpos;
+      
+      arg->internal.inarg = 0;
+      if (!s[2] && !(arg->flags & ARGPARSE_FLAG_NOSTOP))
+        { 
+          /* Stop option processing.  */
+          arg->internal.stopped = 1;
+          argc--; argv++; idx++;
+          goto next_one;
+	}
+
+      argpos = strchr( s+2, '=' );
+      if ( argpos )
+        *argpos = 0;
+      i = find_long_option ( arg, opts, s+2 );
+      if ( argpos )
+        *argpos = '=';
+
+      if ( i < 0 && !strcmp ( "help", s+2) )
+        show_help (opts, arg->flags);
+      else if ( i < 0 && !strcmp ( "version", s+2) )
+        {
+          if (!(arg->flags & ARGPARSE_FLAG_NOVERSION))
+            {
+              show_version ();
+              exit(0);
+            }
+	}
+      else if ( i < 0 && !strcmp( "warranty", s+2))
+        {
+          puts ( strusage (16) );
+          exit (0);
+	}
+      else if ( i < 0 && !strcmp( "dump-options", s+2) )
+        {
+          for (i=0; opts[i].short_opt; i++ )
+            {
+              if ( opts[i].long_opt )
+                printf ("--%s\n", opts[i].long_opt);
+	    }
+          fputs ("--dump-options\n--help\n--version\n--warranty\n", stdout);
+          exit (0);
+	}
+      
+      if ( i == -2 )
+        arg->r_opt = ARGPARSE_AMBIGUOUS_OPTION;
+      else if ( i == -1 )
+        {
+          arg->r_opt = ARGPARSE_INVALID_OPTION;
+          arg->r.ret_str = s+2;
+	}
+      else
+        arg->r_opt = opts[i].short_opt;
+      if ( i < 0 )
+        ;
+      else if ( (opts[i].flags & 0x07) )
+        {
+          if ( argpos )
+            {
+              s2 = argpos+1;
+              if ( !*s2 )
+                s2 = NULL;
+	    }
+          else
+            s2 = argv[1];
+          if ( !s2 && (opts[i].flags & ARGPARSE_OPT_OPTIONAL) )
+            {
+              arg->r_type = ARGPARSE_TYPE_NONE; /* Argument is optional.  */
+	    }
+          else if ( !s2 )
+            {
+              arg->r_opt = ARGPARSE_MISSING_ARG;
+	    }
+          else if ( !argpos && *s2 == '-' 
+                    && (opts[i].flags & ARGPARSE_OPT_OPTIONAL) ) 
+            {
+              /* The argument is optional and the next seems to be an
+                 option.  We do not check this possible option but
+                 assume no argument */
+              arg->r_type = ARGPARSE_TYPE_NONE;
+	    }
+          else 
+            {
+              set_opt_arg (arg, opts[i].flags, s2);
+              if ( !argpos ) 
+                {
+                  argc--; argv++; idx++; /* Skip one.  */
+		}
+	    }
+	}
+      else
+        { 
+          /* Does not take an argument. */
+          if ( argpos )
+            arg->r_type = ARGPARSE_UNEXPECTED_ARG; 
+          else
+            arg->r_type = 0;
+	}
+      argc--; argv++; idx++; /* Set to next one.  */
+    }
+    else if ( (*s == '-' && s[1]) || arg->internal.inarg ) 
+      {
+        /* Short option.  */
+	int dash_kludge = 0;
+
+	i = 0;
+	if ( !arg->internal.inarg ) 
+          {
+	    arg->internal.inarg++;
+	    if ( (arg->flags & ARGPARSE_FLAG_ONEDASH) )
+              {
+                for (i=0; opts[i].short_opt; i++ )
+                  if ( opts[i].long_opt && !strcmp (opts[i].long_opt, s+1))
+                    {
+                      dash_kludge = 1;
+                      break;
+		    }
+              }
+          }
+	s += arg->internal.inarg;
+
+	if (!dash_kludge )
+          {
+	    for (i=0; opts[i].short_opt; i++ )
+              if ( opts[i].short_opt == *s )
+                break;
+          }
+        
+	if ( !opts[i].short_opt && ( *s == 'h' || *s == '?' ) )
+          show_help (opts, arg->flags);
+
+	arg->r_opt = opts[i].short_opt;
+	if (!opts[i].short_opt )
+          {
+	    arg->r_opt = (opts[i].flags & ARGPARSE_OPT_COMMAND)?
+              ARGPARSE_INVALID_COMMAND:ARGPARSE_INVALID_OPTION;
+	    arg->internal.inarg++; /* Point to the next arg.  */
+	    arg->r.ret_str = s;
+          }
+	else if ( (opts[i].flags & 7) )
+          {
+	    if ( s[1] && !dash_kludge )
+              {
+		s2 = s+1;
+		set_opt_arg (arg, opts[i].flags, s2);
+              }
+	    else
+              {
+		s2 = argv[1];
+		if ( !s2 && (opts[i].flags & ARGPARSE_OPT_OPTIONAL) )
+                  {
+		    arg->r_type = ARGPARSE_TYPE_NONE;
+                  }
+		else if ( !s2 )
+                  {
+		    arg->r_opt = ARGPARSE_MISSING_ARG;
+                  }
+		else if ( *s2 == '-' && s2[1]
+                          && (opts[i].flags & ARGPARSE_OPT_OPTIONAL) )
+                  {
+		    /* The argument is optional and the next seems to
+	               be an option.  We do not check this possible
+	               option but assume no argument.  */
+		    arg->r_type = ARGPARSE_TYPE_NONE;
+                  }
+		else
+                  {
+		    set_opt_arg (arg, opts[i].flags, s2);
+		    argc--; argv++; idx++; /* Skip one.  */
+                  }
+              }
+	    s = "x"; /* This is so that !s[1] yields false.  */
+          }
+	else
+          {
+            /* Does not take an argument.  */
+	    arg->r_type = ARGPARSE_TYPE_NONE;
+	    arg->internal.inarg++; /* Point to the next arg.  */
+          }
+	if ( !s[1] || dash_kludge )
+          {
+            /* No more concatenated short options.  */
+	    arg->internal.inarg = 0;
+	    argc--; argv++; idx++;
+          }
+      }
+  else if ( arg->flags & ARGPARSE_FLAG_MIXED )
+    {
+      arg->r_opt = ARGPARSE_IS_ARG;
+      arg->r_type = 2;
+      arg->r.ret_str = s;
+      argc--; argv++; idx++; /* Set to next one.  */
+    }
+  else
+    {
+      arg->internal.stopped = 1; /* Stop option processing.  */
+      goto next_one;
+    }
+
+ leave:
+  *arg->argc = argc;
+  *arg->argv = argv;
+  arg->internal.idx = idx;
+  return arg->r_opt;
+}
+
+
+
+static int
+set_opt_arg(ARGPARSE_ARGS *arg, unsigned flags, char *s)
+{
+  int base = (flags & 16)? 0 : 10;
+
+  switch ( (arg->r_type = (flags & 7)) )
+    {
+    case ARGPARSE_TYPE_INT:
+      arg->r.ret_int = (int)strtol(s,NULL,base);
+      return 0;
+    case ARGPARSE_TYPE_LONG:
+      arg->r.ret_long= strtol(s,NULL,base);
+      return 0;
+    case ARGPARSE_TYPE_ULONG:
+      arg->r.ret_ulong= strtoul(s,NULL,base);
+      return 0;
+    case ARGPARSE_TYPE_STRING:
+    default:
+      arg->r.ret_str = s;
+      return 1;
+    }
+}
+
+
+static size_t
+long_opt_strlen( ARGPARSE_OPTS *o )
+{
+  size_t n = strlen (o->long_opt);
+
+  if ( o->description && *o->description == '|' ) 
+    {
+      const char *s;
+#ifdef JNLIB_NEED_UTF8CONV
+      int is_utf8 = is_native_utf8 ();
+#endif
+        
+      s=o->description+1;
+      if ( *s != '=' )
+        n++;
+      /* For a (mostly) correct length calculation we exclude
+         continuation bytes (10xxxxxx) if we are on a native utf8
+         terminal. */
+      for (; *s && *s != '|'; s++ )
+#ifdef JNLIB_NEED_UTF8CONV
+        if ( is_utf8 && (*s&0xc0) != 0x80 )
+#endif
+          n++;
+    }
+  return n;
+}
+
+
+/****************
+ * Print formatted help. The description string has some special
+ * meanings:
+ *  - A description string which is "@" suppresses help output for
+ *    this option
+ *  - a description,ine which starts with a '@' and is followed by
+ *    any other characters is printed as is; this may be used for examples
+ *    ans such.
+ *  - A description which starts with a '|' outputs the string between this
+ *    bar and the next one as arguments of the long option.
+ */
+static void
+show_help (ARGPARSE_OPTS *opts, unsigned int flags)
+{
+  const char *s;
+  
+  show_version ();
+  putchar ('\n');
+  s = strusage(41);
+  puts (s);
+  if ( opts[0].description )
+    {
+      /* Auto format the option description.  */
+      int i,j, indent;
+
+      /* Get max. length of long options.  */
+      for (i=indent=0; opts[i].short_opt; i++ )
+        {
+          if ( opts[i].long_opt )
+            if ( !opts[i].description || *opts[i].description != '@' )
+              if ( (j=long_opt_strlen(opts+i)) > indent && j < 35 )
+                indent = j;
+	}
+
+      /* Example: " -v, --verbose   Viele Sachen ausgeben" */
+      indent += 10;
+      if ( *opts[0].description != '@' )
+        puts ("Options:");
+      for (i=0; opts[i].short_opt; i++ )
+        {
+          s = _( opts[i].description );
+          if ( s && *s== '@' && !s[1] ) /* Hide this line.  */
+            continue;
+          if ( s && *s == '@' )  /* Unindented comment only line.  */
+            { 
+              for (s++; *s; s++ ) 
+                {
+                  if ( *s == '\n' )
+                    {
+                      if( s[1] )
+                        putchar('\n');
+		    }
+                  else
+                    putchar(*s);
+		}
+              putchar('\n');
+              continue;
+	    }
+
+          j = 3;
+          if ( opts[i].short_opt < 256 )
+            {
+              printf (" -%c", opts[i].short_opt);
+              if ( !opts[i].long_opt ) 
+                {
+                  if (s && *s == '|' ) 
+                    {
+                      putchar (' '); j++;
+                      for (s++ ; *s && *s != '|'; s++, j++ )
+                        putchar (*s);
+                      if ( *s )
+                        s++;
+		    }
+		}
+	    }
+          else
+            fputs("   ", stdout);
+          if ( opts[i].long_opt ) 
+            {
+              j += printf ("%c --%s", opts[i].short_opt < 256?',':' ',
+                           opts[i].long_opt );
+              if (s && *s == '|' ) 
+                {
+                  if ( *++s != '=' )
+                    {
+                      putchar(' ');
+                      j++;
+		    }
+                  for ( ; *s && *s != '|'; s++, j++ )
+                    putchar(*s);
+                  if ( *s )
+                    s++;
+		}
+              fputs ("   ", stdout);
+              j += 3;
+	    }
+          for (;j < indent; j++ )
+            putchar(' ');
+          if ( s )
+            {
+              if ( *s && j > indent )
+                {
+                  putchar('\n');
+                  for (j=0;j < indent; j++ )
+                    putchar (' ');
+		}
+              for (; *s; s++ )
+                {
+                  if ( *s == '\n' )
+                    {
+                      if ( s[1] ) 
+                        {
+                          putchar ('\n');
+                          for (j=0; j < indent; j++ )
+                            putchar (' ');
+			}
+		    }
+                  else
+                    putchar (*s);
+		}
+	    }
+          putchar ('\n');
+	}
+	if ( (flags & ARGPARSE_FLAG_ONEDASH) )
+	    puts ("\n(A single dash may be used instead of the double ones)");
+    }
+  if ( (s=strusage(19)) )
+    { 
+      /* bug reports to ... */
+      char *s2;
+      
+      putchar('\n');
+      s2 = strstr (s, "@EMAIL@");
+      if (s2)
+        {
+          if (s2-s)
+            fwrite (s, s2-s, 1, stdout);
+#ifdef PACKAGE_BUGREPORT
+          fputs (PACKAGE_BUGREPORT, stdout);
+#else
+          fputs ("bug at example.org", stdout);
+#endif
+          s2 += 7;
+          if (*s2)
+            fputs (s2, stdout);
+        }
+      else
+        fputs(s, stdout);
+    }
+  fflush(stdout);
+  exit(0);
+}
+
+static void
+show_version ()
+{
+  const char *s;
+  int i;
+
+  /* Version line.  */
+  fputs (strusage (11), stdout);
+  if ((s=strusage (12)))
+    printf (" (%s)", s );
+  printf (" %s\n", strusage (13) );
+  /* Additional version lines. */
+  for (i=20; i < 30; i++)
+    if ((s=strusage (i)))
+      printf ("%s\n", s );
+  /* Copyright string.  */
+  if( (s=strusage (14)) )
+    printf("%s\n", s );
+  /* Licence string.  */
+  if( (s=strusage (10)) )
+    printf("%s\n", s );
+  /* Copying conditions. */
+  if ( (s=strusage(15)) )
+    fputs (s, stdout);
+  /* Thanks. */
+  if ((s=strusage(18)))
+    fputs (s, stdout);
+  /* Additional program info. */
+  for (i=30; i < 40; i++ )
+    if ( (s=strusage (i)) )
+      fputs (s, stdout);
+  fflush (stdout);
+}
+
+
+void
+usage (int level)
+{
+  const char *p;
+
+  if (!level)
+    {
+      fprintf(stderr,"%s %s; %s\n", strusage(11), strusage(13), strusage (14));
+      fflush (stderr);
+    }
+  else if (level == 1)
+    {
+      p = strusage (40);
+      fputs (p, stderr);
+      if (*p && p[strlen(p)] != '\n')
+        putc ('\n', stderr);
+      exit (2);
+    }
+  else if (level == 2) 
+    {
+      puts (strusage(41));
+      exit (0);
+    }
+}
+
+/* Level
+ *     0: Print copyright string to stderr
+ *     1: Print a short usage hint to stderr and terminate
+ *     2: Print a long usage hint to stdout and terminate
+ *    10: Return license info string
+ *    11: Return the name of the program
+ *    12: Return optional name of package which includes this program.
+ *    13: version  string
+ *    14: copyright string
+ *    15: Short copying conditions (with LFs)
+ *    16: Long copying conditions (with LFs)
+ *    17: Optional printable OS name
+ *    18: Optional thanks list (with LFs)
+ *    19: Bug report info
+ *20..29: Additional lib version strings.
+ *30..39: Additional program info (with LFs)
+ *    40: short usage note (with LF)
+ *    41: long usage note (with LF)
+ */
+const char *
+strusage( int level )
+{
+  const char *p = strusage_handler? strusage_handler(level) : NULL;
+  
+  if ( p )
+    return p;
+  
+  switch ( level )
+    {
+    case 10: p = ("License GPLv3+: GNU GPL version 3 or later "
+                  "<http://gnu.org/licenses/gpl.html>");
+      break;
+    case 11: p = "foo"; break;
+    case 13: p = "0.0"; break;
+    case 14: p = "Copyright (C) 2010 Free Software Foundation, Inc."; break;
+    case 15: p =
+"This is free software: you are free to change and redistribute it.\n"
+"There is NO WARRANTY, to the extent permitted by law.\n";
+      break;
+    case 16: p =
+"This is free software; you can redistribute it and/or modify\n"
+"it under the terms of the GNU General Public License as published by\n"
+"the Free Software Foundation; either version 3 of the License, or\n"
+"(at your option) any later version.\n\n"
+"It is distributed in the hope that it will be useful,\n"
+"but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
+"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n"




More information about the Gnupg-commits mailing list