aboutsummaryrefslogtreecommitdiffstats
path: root/tests (follow)
Commit message (Collapse)AuthorAgeFilesLines
* core: Fix the "ignore" meta command of the argparser.Werner Koch2020-12-182-2/+6
| | | | | | | | | | | | | * src/argparse.c (_gpgrt_argparse): Factor some code out to ... (prepare_arg_return): new. (_gpgrt_argparse): No missing arg error in ignore sections. -- Options in an [ignore] section do not anymore lead to an error if an argument is missing. However, if the option is also in a force section the error is thrown. Signed-off-by: Werner Koch <[email protected]>
* New public function gpgrt_access.Werner Koch2020-10-191-0/+16
| | | | | | | | | | | | | | | | | | | | | | * src/gpg-error.h.in (gpgrt_access): New. * src/gpg-error.vers. src/gpg-error.def.in: Add new function. * src/sysutils.c (any8bitchar): New. (_gpgrt_access): New. * src/visibility.c (gpgrt_access): New. * src/spawn-w32.c (_gpgrt_spawn_process_detached): Use it. * src/argparse.c (try_versioned_conffile): Use it. * tests/t-stringutils.c (check_access): New simple test. -- This is basically a wrapper to allow handling of utf8 encoded file names on Windows. This also fixes the case for versioned config files in directories with non-ascii characters. The new test needs to be run manually on Windows using a directory with Unicode characters. GnuPG-bug-id: 5098
* w32: Support utf8 also for getcwd.Werner Koch2020-10-091-1/+98
| | | | | | | | | | | | * src/sysutils.c (_gpgrt_getcwd) [W32]: Implement utf-8 support. * src/w32-gettext.c (wchar_to_native): Factor some code out to .. (wchar_to_cp): new. (_gpgrt_wchar_to_utf8): New. * tests/t-stringutils.c: Include windows.h. (utf8_to_wchar): New. (wchar_to_utf8): New. (mygetcwd): Use wchar version for Windows. (main): New option --pwd.
* doc: Fix typos in commentsWerner Koch2020-10-081-4/+3
| | | | --
* core: Improve the echo and info meta commands of the arg parserWerner Koch2020-04-032-3/+10
| | | | | | | | | | | * src/argparse.c (handle_meta_echo): Substitue some vars. (handle_meta_user): Factor some code out to ... (assure_username): new. -- Yeah, that is not really needed but might sometimes be helpful. Signed-off-by: Werner Koch <[email protected]>
* core: Implement meta command [user] for the arg parser.Werner Koch2020-04-031-11/+19
| | | | | | | | | | | | | | | | | | | | * src/sysutils.c (_gpgrt_getusername): New. * src/argparse.c (struct _gpgrt_argparse_internal_s): New flags user_* and store the current user. (initialize): Free new malloced field. Clear new flags. (handle_meta_user): Implement. (handle_metacmd): Implement user sections. Remove "group" meta command. (_gpgrt_argparse): Implement user sections. (finish_read_sys): Reset new vars. -- Implementing group would be somewhat complicated and it is doubtful whether this really makes sense and is manageable for the admin. Note that we have not yet implemented this for Windows. Signed-off-by: Werner Koch <[email protected]>
* core: Add features for pretty printing the helpWerner Koch2020-03-061-0/+3
| | | | | | | | | | | | | | | | | | | | * src/gpg-error.h.in (ARGPARSE_OPT_HEADER): New. (ARGPARSE_OPT_VERBATIM): New. (ARGPARSE_verbatim): New. (ARGPARSE_header): New. * src/argparse.c (show_help): Implement them. -- These two macros are useful for custom help screens. In contrast to the ARGPARSE_group hack they do not need a short option number (we use 1 here as a surrogate) and not the "@" hack. Thus already translated strings can be used. ARGPARSE_header further allows to specify a symbolic name for the group and does some minor formatting. If such a symbolic name is given --dump-option-table also emits this as a pseudo option for consumption by GUIs which for example use tabs to group options. Signed-off-by: Werner Koch <[email protected]>
* core: New function gpgrt_reallocarray.Werner Koch2020-03-032-1/+142
| | | | | | | | | | | | | | | | | * src/init.c (_gpgrt_reallocarray): New. * src/visibility.c (gpgrt_reallocarray): New. * src/gpg-error.vers, src/gpg-error.def.in: Add new function. * src/gpg-error.h.in: Add new interface. * tests/t-malloc.c: New. * tests/Makefile.am (TESTS): Add new test. -- Note that this function is different from the glibc function because it has an extra parameter which allows to clear the new elements. A realloc after a calloc with forgotten memset after it is a common source of error, thus we introduce this slightly different function. Signed-off-by: Werner Koch <[email protected]>
* core: Allow returning of attributes from gpgrt_argparser.Werner Koch2020-03-021-1/+11
| | | | | | | | | | | | | | | | | | * src/gpg-error.h.in (ARGPARSE_FLAG_WITHATTR): New. (ARGPARSE_ATTR_FORCE): New. (ARGPARSE_ATTR_IGNORE): New. (ARGPARSE_TYPE_MASK): Moved from argparse.c to here. * src/argparse.c: Always use macros for constants. (_gpgrt_argparse): Handle ARGPARSE_FLAG_WITHATTR. (arg_parse): Ditto. * tests/t-argparse.c (main): Add commented test case. -- This is a ABI compatible hack to allow the ignore and force attributes as well as to return which option has been ignored in a user file or on the command line. Signed-off-by: Werner Koch <[email protected]>
* core: Implement meta commands for the argparser.Werner Koch2020-02-273-6/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/argparse.c (opttable_t): Add new flags forced, ignore, and explicit_ignore. (struct _gpgrt_argparse_internal_s): Change flags to bitflags. Add several flags to support meta commands. (initialize): Clear them. (handle_meta_user): Use the new verbose flag. (handle_meta_force): Implement. (handle_meta_ignore): Implement. (handle_meta_echo): Support "-echo". (handle_meta_verbose): New. (handle_metacmd): New meta command verbose. Add always flag and move the detection of unexpected meta commands to here. (_gpgrt_argparse): Make use of the ignore and forced meta commands. (finish_read_sys): New. (_gpgrt_argparser): Support the verbose flag. Call finish_read_sys. (arg_parse): Ignore non-explicit ignored and all forced options. * tests/t-argparse.c (main): Fix printing of the ARGPARSE_CONFFILE case. New option 'M'. * tests/t-argparse.conf, tests/etc/t-argparse.conf: Various changes to test the new meta commands. -- For the command line we print a diagnostic if an ignored or forced options is used. However, we do not ignore options which are only set via [ignore-all]. The rationale for the latter is that an administrator can't be be required to unignore all options used by all modes, of say gpgme. Documentation of the meta commands will for now be added to GnuPG. GnuPG-bug-id: 4788 Signed-off-by: Werner Koch <[email protected]>
* core: Add meta command handler stubs to argparse.c.Werner Koch2020-02-261-0/+4
| | | | | | | | | | | | | * src/argparse.c (handle_meta_user): New stub. (handle_meta_force): New stub. (handle_meta_ignore): New stub. (handle_meta_echo): New. (handle_metacmd): New. (_gpgrt_argparse): Call meta command handler. -- GnuPG-bug-id: 4788 Signed-off-by: Werner Koch <[email protected]>
* core: Add parser for meta commands to gpgrt_argparser.Werner Koch2020-02-253-14/+36
| | | | | | | | | | | | | | | | | | | | | * src/gpg-error.h.in (ARGPARSE_INVALID_META): New (ARGPARSE_UNKNOWN_META, ARGPARSE_UNEXPECTED_META): New. * src/argparse.c (struct _gpgrt_argparse_internal_s): Add flag insysconfig. (initialize): Init flag. Add error strings. (_gpgrt_argparser): Set that flag. (_gpgrt_argparse): Add parsing of meta commands. * tests/etc/t-argparse.conf: Add some test cases. * tests/t-argparse.conf: Ditto. * tests/t-argparse.c (main): Die only after printing all warnings. -- Noe that this is just the framework to add meta commands to the global config file. We also need to get away from fixes test config files and create them on the fly to that we are able to test also errors. GnuPG-bug-id: 4788
* core: Add a high level option/argument parser.Werner Koch2020-02-184-8/+80
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * gpg-error.h.in (GPGRT_CONFDIR_USER, GPGRT_CONFDIR_SYS): New consts. (ARGPARSE_FLAG_SYS, ARGPARSE_FLAG_USER, ARGPARSE_FLAG_VERBOSE) (ARGPARSE_NO_CONFFILE, ARGPARSE_CONFFILE, ARGPARSE_OPT_CONFFILE): New consts. (ARGPARSE_conffile, ARGPARSE_noconffile): New macros. (gpgrt_set_confdir): New func. (gpgrt_argparser): New func. * src/argparse.c (confdir): New var. (enum argparser_states): New. (struct _gpgrt_argparse_internal_s): Add a couple of new fields. (initialize): Init them. (any_opt_conffile): New. (_gpgrt_argparser): New. (_gpgrt_set_confdir): New. * src/visibility.c (gpgrt_argparser): New. (gpgrt_set_confdir): New. * src/gpg-error.def.in, src/gpg-error.vers: Add those functions. * tests/t-argparse.c (main): Reworked. * tests/etc/t-argparse.conf: New file. * tests/t-argparse.conf: New file. -- gpgrt_argparser is a high level version of gpgrt_argparse. It handles reading of configuration files internally and allows allows for a global configuration file. The design is so that it minimizes the work to replace the existing option parsing in gpg and friends by this one and to allow global configuration files for them. This is the just the basic code which should allow replacement of the parsers. A forthcoming patch will implement flags for options given in the global config file. GnuPG-bug-id: 4788 Signed-off-by: Werner Koch <[email protected]>
* core: Add gpgrt_fnameconcat and gpgrt_absfnameconcat.Werner Koch2020-02-183-1/+312
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/gpg-error.h.in (gpgrt_fnameconcat): New. (gpgrt_absfnameconcat): New. * src/visibility.c (gpgrt_fnameconcat, gpgrt_absfnameconcat): New. * src/stringutils.c: New file. (_gpgrt_vfnameconcat): New. (_gpgrt_fnameconcat, _gpgrt_absfnameconcat): New. * src/gpg-error.def.in: Add new functions. * src/gpg-error.vers: Ditto. * src/sysutils.c: Include pwd.h. (_gpgrt_getpwdir): New. * configure.ac: Test for pwd.h, getpwnam, getpwuid, and their _r variants. * src/Makefile.am (libgpg_error_la_SOURCES): Add new file. * tests/t-stringutils.c: New. * tests/t-common.h (xmalloc, xstrdup, xfree): New. (die): Kludge to avoid compiler warnings. -- The new functions are based on the code of make_filename from GnuPG. They have been written by me ages ago with only minor modifications by David Shaw. I re-license them from LGPL-3.0+ OR GPL-2.0+ to LGPL-2.1-or-later. Signed-off-by: Werner Koch <[email protected]>
* tests: Fix deallocation of buffer in t-b64.c.NIIBE Yutaka2019-09-181-0/+1
| | | | | | | * tests/t-b64.c (test_b64dec_string): De-allocate. GnuPG-bug-id: 4698 Signed-off-by: NIIBE Yutaka <[email protected]>
* tests: Fix a memory leak.NIIBE Yutaka2019-05-141-0/+1
| | | | | | | | | * tests/t-logging.c (check_log_info): Free LOGBUF. -- GnuPG-bug-id: 4498 Signed-off-by: NIIBE Yutaka <[email protected]>
* build: Build with LD_LIBRARY_PATH, use of DT_RPATH (2/2).NIIBE Yutaka2019-01-101-3/+3
| | | | | | | | | | | * configure.ac (LDADD_FOR_TESTS_KLUDGE): New for --disable-new-dtags. * tests/Makefile.am (LDADD): Use LDADD_FOR_TESTS_KLUDGE. (t_lock_LDADD, t_poll_LDADD): Use LDADD. -- GnuPG-bug-id: 4298 Signed-off-by: NIIBE Yutaka <[email protected]>
* estream: Use correct POSIX name THOUSEP.Werner Koch2018-12-121-0/+3
| | | | | | | | | | | * src/estream-printf.c: Replace HAVE_LANGINFO_THOUSANDS_SEP by HAVE_LANGINFO_THOUSEP. (pr_integer): Use THOUSEP. -- GnuPG-bug-id: 4286 Reported-by: miod Signed-off-by: Werner Koch <[email protected]>
* logging: Escape controls in string arguments of log_ functions.Werner Koch2018-12-061-0/+32
| | | | | | | | | | | | | | | | * src/logging.c (struct fmt_string_filter_s): New. (fmt_string_filter): New. (_gpgrt_logv_internal): Use the filter. -- This change has two advantages: a) There is no more need to first escape string arguments before passing them to a log function and b) you can't forget to do the escaping and thus attacks using diagnostic output to trick out users won't work. The drawback is that you see \n instead of a real LF and under Windows the backslash in file names are doubled. Signed-off-by: Werner Koch <[email protected]>
* core: Allow logging to an estream.Werner Koch2018-12-052-1/+218
| | | | | | | | | * src/logging.c (set_file_fd): Add and use new arg 'stream'. (_gpgrt_log_set_sink): Implement setting an estream sink. * tests/t-logging.c: New test. * tests/Makefile.am (TESTS): Add test. Signed-off-by: Werner Koch <[email protected]>
* tests: Check print arguments of t-common functions.Werner Koch2018-12-051-1/+6
| | | | | | | * tests/t-common.h: Include gpgrt.h instead of gpg-error.h. (die, fail, show): Add printf attributes. Signed-off-by: Werner Koch <[email protected]>
* core: New functions gpgrt_fprintf_sf anf gpgrt_fprintf_sf_unlocked.Werner Koch2018-11-261-0/+112
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/gpg-error.h.in (gpgrt_string_filter_t): New type. (gpgrt_fprintf_sf, gpgrt_fprintf_sf_unlocked): New. * src/gpg-error.vers, src/gpg-error.def.in: Add them. * src/visibility.c (gpgrt_fprintf_sf): New. (gpgrt_fprintf_sf_unlocked): New. * src/estream-printf.c (pr_string): Add and use args sf, sfvalue and string_no. (do_format): Add args sf and sfvalue. Keep a string format counter. (_gpgrt_estream_format): Add args sf and sfvalue. Change all callers to provide NULL for them. * src/estream.c (_gpgrt_vfprintf_unlocked, _gpgrt_vfprintf): Add sf and sfvalue and adjust all callers. (do_print_stream): Ditto. * tests/t-printf.c (stream_to_string): New. (struct sfstate_s): New. (string_filter): New. (check_fprintf_sf): New. (main): Call new test. -- The actual reason to implement these functions is to enhance the internal logging function with a filter to sanitized strings so that control values or other things can be quoted. Signed-off-by: Werner Koch <[email protected]>
* core: Add a limited version of gpgrt_ftruncate.Werner Koch2018-11-261-0/+1
| | | | | | | | | | | | | | | * src/gpg-error.h.in (gpgrt_ftruncate, es_ftruncate): New. * src/gpg-error.def.in, src/gpg-error.vers: Add gpgrt_ftruncate. * src/visibility.c (gpgrt_ftruncate): new. * src/gpgrt-int.h (COOKIE_IOCTL_TRUNCATE): New. * src/estream.c (func_mem_ioctl): Support new internal IOCTL. (_gpgrt_ftruncate): New. -- Right now the ftruncate works only on memory streams. Can easily be added to other stream times. Signed-off-by: Werner Koch <[email protected]>
* core: New API gpgrt_cmp_versionWerner Koch2018-11-151-7/+86
| | | | | | | | | | | | | | | | | | | | | * src/gpg-error.h.in: New API gpgrt_cmp_version. * src/visibility.c (gpgrt_cmp_version): New wrapper. * src/version.c (parse_version_string): Revamped. (do_cmp_version): New. (_gpgrt_cmp_version): New. (_gpg_error_check_version): Re-implemented using the new func. * tests/t-version.c: Include t-common.h. (t_gpgrt_cmp_version): New test. (main): Run new test. Change test for new version number to require a 2 level number. -- We have implementations of very similar functions in all out libs. Thus it makes sense to provide a generic version. This version is actually derived from the ftp-indexer.c we use for the gnupg website (see the gnupg-doc repo). Signed-off-by: Werner Koch <[email protected]>
* core: Remove outdated comments.Werner Koch2018-03-221-1/+2
| | | | --
* core: Add Base-64 encoder.Werner Koch2018-03-223-124/+374
| | | | | | | | | | | | | | | | | | | | | | | * src/b64enc.c: Change to fit into libgpg-error. * src/Makefile.am: Add b64enc.c * src/b64dec.c: Use xtrymalloc etc. Always use gpg_err_code_t. (_gpgrt_b64dec_start): Set decoder flag (_gpgrt_b64dec_finish): Check for conflict. (_gpgrt_b64state): Move to ... * src/gpgrt-int.h: here. Add new fields. * src/visibility.c (gpgrt_b64enc_start): New. (gpgrt_b64enc_write): New. (gpgrt_b64enc_finish): New. * src/gpg-error.vers, src/gpg-error.def.in: Add new functions. * src/gpg-error.h.in: Ditto. * src/visibility.h: Ditto. * tests/t-b64dec.c: Remove. * tests/t-b64.c: New. * tests/Makefile.am (TESTS): Replace t-b64dec by t-b64. -- Signed-off-by: Werner Koch <[email protected]>
* core: Add the group of argparse functions.Werner Koch2018-03-212-1/+127
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/visibility.c (gpgrt_argparse): New. (gpgrt_strusage): New. (gpgrt_set_strusage): New. (gpgrt_set_usage_outfnc): New. (gpgrt_set_fixed_string_mapper): New. * src/gpg-error.def.in, src/gpg-error.vers: Add new functions. * src/gpg-error.h.in: Add ARGPARSE macros from the former argparse.h. (gpgrt_argparse_t): New. (gpgrt_opt_t): New. * configure.ac (AH_BOTTOM): Request argparse macros. * src/Makefile.am (libgpg_error_la_SOURCES): Add argparse.c. * src/argparse.h: Remove. * src/argparse.c: Revamp to fit into libgpg-error. (_gpgrt_argparse): New. (_gpgrt_usage): Rename from usage. (_gpgrt_strusage): Rename from strusage. Define two new levels and templates for three common licenses. (_gpgrt_set_strusage): Rename from set_strusage. (_gpgrt_set_usage_outfnc): New. (_gpgrt_set_fixed_string_mapper): New. * tests/t-argparse.c: New. -- These functions are in use by GnuPG and other software for 20 years and it makes sense to have them always available instead of copying and maintaing the source in several projects. Note that there are minor changes in the API compared to GnuPG. Signed-off-by: Werner Koch <[email protected]>
* tests: New option --debug for t-poll.Werner Koch2017-02-281-0/+50
| | | | | | * tests/t-poll.c (test_poll): Add option. Signed-off-by: Werner Koch <[email protected]>
* Add Base64 decoder.NIIBE Yutaka2017-02-012-1/+124
| | | | | | | | | | | | | | | | * NEWS: Add interface changes. * src/Makefile.am (libgpg_error_la_SOURCES): Add b64dec.c. * src/b64dec.c: New. Taken from gpgme. Prefix function names with _gpgrt_. Change API a bit, not exposing the structure. * src/gpg-error.def.in: Export Base64 functions. * src/gpg-error.vers: Likewise. * src/visibility.c, src/visibility.h: Likewise. * src/gpg-error.h.in: Add Base64 struct and functions. * src/gpgrt-int.h: Add Base64 internal functions. * tests/Makefile.am (TESTS): Add t-b64dec. * tests/t-b64dec.c: New. Signed-off-by: NIIBE Yutaka <[email protected]>
* estream: Support 'es_poll' on Windows.Justus Winter2016-11-121-2/+2
| | | | | | | | | | | | | | | | | | | | | * src/Makefile.am (arch_sources): Add new file. * src/estream.c (O_NONBLOCK): Move to 'gpgrt-int.h'. (BUFFER_BLOCK_SIZE): Likewise. (BUFFER_UNREAD_SIZE): Likewise. (struct notify_list_s, notify_list_t): Likewise. (struct _gpgrt_stream_internal, estream_internal_t): Likewise. (X_POLLABLE): New macro. (parse_mode): Parse keyword 'pollable', emulate O_NONBLOCK using the same mechanism on Windows. (_gpgrt_poll): Use the new '_gpgrt_w32_poll' on Windows. * src/gpgrt-int.h (_gpgrt_functions_w32_pollable): New declaration. (_gpgrt_w32_pollable_create): New prototype. (_gpgrt_w32_poll): Likewise. * src/w32-estream.c: New file. This code is adapted from GPGME. * tests/t-poll.c (create_pipe): Create pollable streams. GnuPG-bug-id: 2731 Signed-off-by: Justus Winter <[email protected]>
* tests: Fix name of the test.Justus Winter2016-10-181-1/+1
| | | | | -- Signed-off-by: Justus Winter <[email protected]>
* Fix build without threadsYann E. MORIN2016-07-122-2/+6
| | | | | | | | | | | | | | | * src/gen-posix-lock-obj.c: properly guard inclusioin of pthread.h * tests/t-lock.c: likewise * tests/t-poll.c: likewise -- Although ./configure checks for thread support, gen-posix-lock-obj and two tests still include pthread.h unconditionally. Guard that inclusion using the same condition as all other uses of pthread-related code. Signed-off-by: "Yann E. MORIN" <[email protected]>
* tests: Fix rare deadlock condition in t-poll.Werner Koch2016-06-151-3/+6
| | | | | | | | * tests/t-poll.c (launch_thread): Use es_fileno before starting the thread. -- GnuPG-bug-id: 2257
* Convert http links to https where possible in the source.Daniel Kahn Gillmor2016-02-085-5/+5
| | | | | | | | | | | | | | | | -- * use https for bug reporting * in comments and docs, use https to refer to: - www.gnu.org - creativecommons.org - translationproject.org - mail.gnome.org - www.perl.org - www.ctan.org - www.cl.cam.ac.uk - www.ntg.nl - cygwin.com - www.ethnologue.com
* tests: Fix read past buffer.Justus Winter2015-12-031-1/+3
| | | | | | | | * tests/t-poll.c (test_poll): Fix read past buffer. -- Found using gcc and AddressSanitizer. Signed-off-by: Justus Winter <[email protected]>
* Fix typos found by codespell.Justus Winter2015-11-191-2/+2
| | | | | -- Signed-off-by: Justus Winter <[email protected]>
* estream: Add gpgrt_set_nonblock and gpgrt_poll.Werner Koch2015-09-253-1/+388
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * configure.ac (AC_CHECK_HEADERS): Add sys/select.h and sys/time.h. * src/estream.c: Include both header if available. (COOKIE_IOCTL_NONBLOCK): New. (struct estream_cookie_fd): Add field nonblock. (func_fd_create): Set nonblock from MODEFLAGS. (es_func_fd_ioctl): New. (parse_mode): Add modeflag "nonblock". (es_fill): Map EWOULDBLOCK to EAGAIN. Do not set error indicator for EAGAIN. (es_flush, es_seek, es_write_nbf): Map EWOULDBLOCK to EAGAIN. (do_fdopen): Call COOKIE_IOCTL_NONBLOCK. (_gpgrt_set_nonblock): New. (_gpgrt_get_nonblock): New. (_gpgrt_poll): New. * src/gpg-error.h.in (struct _gpgrt_poll_s): New. (gpgrt_poll_t, es_poll_t): New. (es_set_nonblock, es_get_nonblock, es_poll): New. * src/gpg-error.vers, src/gpg-error.def.in: Add gpgrt_set_nonblock, gpgrt_get_nonblock, and gpgrt_poll. * src/visibility.c (gpgrt_set_nonblock, gpgrt_get_nonblock): New. (gpgrt_poll): New. * tests/t-common.h (DIM): New. * tests/t-poll.c: New. * tests/Makefile.am (TESTS): Add t-poll. (t_poll_LDADD): New. -- The poll interface uses select(2) internally because that is more portable than poll(2). Signed-off-by: Werner Koch <[email protected]>
* Allow building with --disable-threads.Werner Koch2015-06-151-2/+9
| | | | | | | | | | | | | | | | | | | | * src/posix-lock-obj.h (LOCK_ABI_NOT_AVAILABLE): New. (LOCK_ABI_VERSION): Define depending on USE_POSIX_THREADS. (_gpgrt_lock_t) [!USE_POSIX_THREADS]: Do not define the union. * src/gen-posix-lock-obj.c: Take care of USE_POSIX_THREADS. * src/posix-lock.c (_gpgrt_lock_init, _gpgrt_lock_lock) (_gpgrt_lock_trylock, _gpgrt_lock_unlock) (_gpgrt_lock_destroy): Return success for a no-threads version. * tests/t-lock.c: Disable tests if threads are not available. * src/mkheader.c (main): Add NO-THREADS to the printed comment. * configure.ac: Show NO-TRHEADS in the final summary. -- Warning: Using --disable-threads creates a different ABI which we can't encode in the the cpu-vendor-os triplet. The run time checks should detect this and abort the process. Signed-off-by: Werner Koch <[email protected]>
* w32: Remove compiler warnings.Werner Koch2015-04-101-0/+1
| | | | | | | | | | | | | | * src/Makefile.am (pre_mkheader_cmds): Avoid make diagnostic about failed but ignored command. This confuses Emacs' compiler job parser. * tests/t-lock.c [W32]: Include time.h. * src/init.c: Reorganize Windows only code. (wchar_to_utf8, utf8_to_wchar): Remove unused functions. (_gpg_err_set_errno): Use only one copy for all platforms. -- Note that there is a still a problem for W64 pertaining to the use of an int to store a HANDLE. This will be fixed when we add a full abstraction layer for Windows file objects.
* build: Require automake 1.14.Werner Koch2015-01-051-1/+1
| | | | | | | * configure.ac (AM_INIT_AUTOMAKE): Add serial-tests. * tests/Makefile.am (INCLUDES): Replace by AM_CPPFLAGS. Signed-off-by: Werner Koch <[email protected]>
* Add test for the estream printf functionsWerner Koch2014-08-252-1/+430
| | | | | | | | | | | * tests/t-printf.c: New. * configure.ac: Check for vasprintf. -- These tests have been taken from Libestream and changed to be more portable. For example there is only va_start per function and the test return an error only for _GLIBC_ based systems because that is what we compare against.
* Implement symbol visibility.Werner Koch2014-08-252-4/+4
| | | | | | | | | | | | | * configure.ac: New option --enable-ld-version-script. (GPGRT_USE_VISIBILITY): New ac_define. (HAVE_LD_VERSION_SCRIPT): New am_conditional. * src/gpg-error.vers: New. * src/gpgrt-int.h: New. * src/visibility.c, src/visibility.h: New. Lot of changes to symbold names. -- This is only doe for the old API. The estream API needs to be added.
* Add missing redefine macros to cleanup the external symbols.Werner Koch2014-08-251-3/+6
|
* tests: Fix compiler warning.Werner Koch2014-08-101-1/+3
| | | | | | | | | * tests/t-lock.c: Include header vor getpid. (revision_thread): Init "i" to avoid compiler warning. -- GnuPG-bug-id: 1681 Note that the non-initialization of I did not harm.
* Improve logging in a test module.Daniel Kahn Gillmor2014-06-301-1/+1
| | | | * tests/t-version.c (main): Print program name.
* tests: Call srand for each thread under Windows.Werner Koch2014-01-241-0/+3
| | | | * tests/t-lock.c (accountant_thread) [W32]: Call srand.
* Add gpgrt_lock_ functions.Werner Koch2014-01-163-2/+424
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/gpg-error.h.in (GPGRT_LOCK_DEFINE): New. (gpgrt_lock_init): New. (gpgrt_lock_lock): New. (gpgrt_lock_unlock): New. (gpgrt_lock_destroy): New. (gpgrt_yield): New. * src/gpg-error.def.in: Add new functions. * m4/lock.m4, m4/threadlib.m4: New. Taken from current gnulib. * configure.ac: Call gl_LOCK. Check size of pthread_mutex_t. Add LIBTHREAD to GPG_ERROR_CONFIG_LIBS. * src/err-codes.h.in (GPG_ERR_INV_LOCK_OBJ): New. * src/gen-posix-lock-obj.c: New. * src/gen-w32-lock-obj.c: New. * src/lock.h, src/thread.h: New. * src/posix-lock-obj.h, src/w32-lock-obj.h: New. * src/posix-lock.c, src/w32-lock.c: New. * src/posix-thread.c, src/w32-thread.c: * src/w32-lock-obj-pub.in: New. * src/mkheader.c (include_file): Support build time include files. (write_special): Add keyword "include:lock-obj". * src/Makefile.am: (posix-lock-obj-pub.in): New rule. (noinst_PROGRAMS): Add gen-*-lock-obj helpers. * tests/t-common.h: New. * tests/t-lock.c: New. * tests/Makefile.am (t_lock_LDADD): Add new test. -- This patch introduces the gpgrt_ functions which will be extended over time to provide a library of commonly used code in GnuPG and Libgcrypt. Having them in a library named libgpg-error is a misnomer but this way we can achieve a smooth upgrade path. In contrasts to other GnuPG libraries, the gpgrt_ functions return a simple gpg_err_code_t and not gpg_error_t. The rationale for this is that a source of error identifier does not make sense here; it is better to use the source of error identifier of the caller. This can easily be achieved in a component by wrapping these function in a gpg_error macro/inline. There is no cross-compiling support for Posix platforms; the gen-posix-lock-obj tool must be run on the target system. Note that the gen-w32-lock-obj tool is not needed at build time but was used to figure out ABI definitions for Windows. Signed-off-by: Werner Koch <[email protected]>
* Add version macros and check function.Werner Koch2013-02-232-6/+104
| | | | | | | | | | | | | | | | | | | * configure.ac (VERSION_NUMBER): New ac_subst. (BUILD_FILEVERSION): Build on all platforms (BUILD_TIMESTAMP): Try to use an ISO string. * src/Makefile.am (extra-h.in): Add new version numbers. * src/versioninfo.rc.in: Update copyright year. * src/version.c: New. (gpg_error_check_version): New API. * src/gpg-error.h.in: Add gpg_error_check_version prototype. * src/gpg-error.def.in: Add gpg_error_check_version * tests/t-version.c: New. * tests/Makefile.am (TESTS): Add t-version.c * src/gpg-error-config.in: s/VERSION/PACKAGE_VERSION/. -- All other GnuPG libraries do this, thus we do it here as well.
* Add some code to build nativley under WindowsCE - not finished.Werner Koch2010-01-182-2/+9
|
* Ready for a new releaselibgpg-error-1.4Werner Koch2006-09-142-1/+85
|