summaryrefslogtreecommitdiff
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
* tests: Use -no-fast-install LDFLAGS for Windows.NIIBE Yutaka2023-05-121-0/+4
| | | | | | | | * tests/Makefile.am [HAVE_W32_SYSTEM] (AM_LDFLAGS): Conditionalize. -- Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* Add more tests for t-printf and t-strerror.pengyi2022-12-132-1/+29
| | | | | | | | | | | | | | * tests/t-printf.c (check_fwrite): New. (main): Add check_fwrite. * tests/t-strerror.c (main): Add three more cases to LIST. -- The string in check_fwrite is from the Gateless Gate, for people who want to discuss "Niente". --- gniibe Co-authored-by: NIIBE Yutaka <gniibe@fsij.org> Signed-off-by: "pengyi" <pengyi37@huawei.com>
* Remove Windows CE support.NIIBE Yutaka2022-06-281-7/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * contrib/*: Remove. * Makefile.am: Remove contrib. * autogen.sh: Remove Windows CE support. * configure.ac (have_w32ce_system): Remove. * src/Makefile.am [HAVE_W32CE_SYSTEM] (extra_cppflags): Remove. (gpg_extra_headers): Remove. (EXTRA_DIST): Remove mkw32errmap.c and w32ce-add.h (BUILT_SOURCES): Remove mkw32errmap.map.c. (tmp_files): Remove mkw32errmap.tab.h mkw32errmap.map.c (CLEANFILES): Likewise. * src/estream-printf.c [HAVE_W32CE_SYSTEM]: Remove. * src/estream.c [HAVE_W32CE_SYSTEM]: Remove. * src/gpg-error.def.in [HAVE_W32CE_SYSTEM]: Remove. * src/gpgrt-int.h: Fix comment. * src/init.c [HAVE_W32CE_SYSTEM]: Remove. * src/init.h [HAVE_W32CE_SYSTEM]: Remove. * src/mkheader.c: Remove Windows CE support. * src/mkw32errmap.c, src/w32ce-add.h: Remove. * src/spawn-posix.c [HAVE_W32CE_SYSTEM]: Remove. * src/spawn-w32.c [HAVE_W32CE_SYSTEM]: Remove. * src/sysutils.c [HAVE_W32CE_SYSTEM]: Remove. * src/w32-estream.c [HAVE_W32CE_SYSTEM]: Remove. * src/w32-reg.c [HAVE_W32CE_SYSTEM]: Remove. * tests/Makefile.am [HAVE_W32CE_SYSTEM]: Remove. -- GnuPG-bug-id: 5912 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* tests,w32: Use CreatePipe and es_sysopen.NIIBE Yutaka2021-11-291-4/+21
| | | | | | | | | | | * tests/t-poll.c (create_pipe): Use CreatePipe. -- Since POSIX pipe with file descriptor is not supported on Windows as pollable, use Win32 Pipe instead. Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* build,tests: Run t-lock-single-posix only on platforms supported.NIIBE Yutaka2021-11-251-2/+1
| | | | | | | | | | | * configure.ac (HAVE_LOCK_OPTIMIZATION): New. * tests/Makefile.am: Use HAVE_LOCK_OPTIMIZATION for t-lock-single-posix. -- GnuPG-bug-id: 5699 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* argparse: Add more system variables.Werner Koch2021-11-031-3/+8
| | | | | | | * src/argparse.c (get_var): Fix "_windows", add "_gpgrtversion" and "strusageN". (handle_meta_if): Avoid evaluating inactive branches. * tests/t-argparse.conf: Add a few other outputs.
* argparse: Add support to read values from the Windows Registry.Werner Koch2021-10-313-5/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/argparse.c (struct variable_s): New. (struct _gpgrt_argparse_internal_s): New fields expand, if_cond, if_active and vartbl. (deinitialize): Free vartbl. (initialize): Clear new vars. (get_var): New. (substitute_vars): New. (set_variable): New. (handle_meta_if): New. (handle_meta_let): New. (handle_meta_getenv): New. (handle_meta_echo): Re-implement in terms of variabale substitution. (handle_meta_expand): New. (handle_metacmd): Add new meta commands. (_gpgrt_argparse): Expand values if enabled. (_gpgrt_argparse): Take care of conditions. (_gpgrt_argparser): Reset some state at the end of a file. * tests/etc/t-argparse.conf: Adjust for changed system variables. * tests/t-argparse.c (my_strusage): Add a value for a version test. (main): Add new option "street". * tests/t-argparse.conf: A couple if additions for the new conditions. -- The whole thing is actually only for here for doing this [let tkey HKLM\Foo\Bar\GnuPG:trusted-key-1] [if $tkey] trusted-key $tkey [fi] But we are hackers and tend to make things more complicated^Wflexible. Documentation will be done eventually. Signed-off-by: Werner Koch <wk@gnupg.org>
* tests: Add a test for locking when single thread.NIIBE Yutaka2021-08-262-0/+170
| | | | | | | | | | * tests/Makefile.am (TESTS): Add t-lock-single-posix. * tests/t-lock-single-posix.c: New. -- GnuPG-bug-id: 5547 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* build,tests: Fix leaks of memory or file pointer.Jakub Jelen2021-04-122-0/+3
| | | | | | | | | | | | * src/mkheader.c (parse_config_h): Close FP. * tests/t-b64.c (test_b64enc_string): Free STATE. (test_b64dec_string): Free BUFFER. * tests/t-syserror.c (main): Close FP. -- GnuPG-bug-id: 5381 Signed-off-by: Jakub Jelen <jjelen@redhat.com>
* 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 <wk@gnupg.org>
* 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 <wk@gnupg.org>
* 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 <wk@gnupg.org>
* 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 <wk@gnupg.org>
* 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 <wk@gnupg.org>
* 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 <wk@gnupg.org>
* 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 <wk@gnupg.org>
* 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 <wk@gnupg.org>
* 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 <wk@gnupg.org>
* 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 <wk@gnupg.org>
* 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 <gniibe@fsij.org>
* 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 <gniibe@fsij.org>
* 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 <gniibe@fsij.org>
* 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 <wk@gnupg.org>
* 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 <wk@gnupg.org>
* 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 <wk@gnupg.org>
* 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 <wk@gnupg.org>
* 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 <wk@gnupg.org>
* 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 <wk@gnupg.org>
* 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 <wk@gnupg.org>
* 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 <wk@gnupg.org>
* 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 <wk@gnupg.org>
* 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 <wk@gnupg.org>
* 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 <gniibe@fsij.org>
* 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 <justus@g10code.com>
* tests: Fix name of the test.Justus Winter2016-10-181-1/+1
| | | | | -- Signed-off-by: Justus Winter <justus@g10code.com>
* 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" <yann.morin.1998@free.fr>
* 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 <justus@g10code.com>
* Fix typos found by codespell.Justus Winter2015-11-191-2/+2
| | | | | -- Signed-off-by: Justus Winter <justus@g10code.com>
* 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 <wk@gnupg.org>
* 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 <wk@gnupg.org>
* 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 <wk@gnupg.org>
* 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.