summaryrefslogtreecommitdiff
path: root/src/gpg-error.h.in
Commit message (Collapse)AuthorAgeFilesLines
* core: New error codes for PUKs and reset codes.Werner Koch2023-04-061-1/+1
| | | | | | | | * src/err-codes.h.in (GPG_ERR_BAD_PUK): New (GPG_ERR_NO_RESET_CODE, GPG_ERR_BAD_RESET_CODE): New. -- Also updated the German translation
* Revert "spawn: Expose spawn functions."NIIBE Yutaka2022-11-151-1/+3
| | | | | | | | | | | This reverts commit 43c1e85fe29a52a9debc068d97c5860a4694b821. -- It's a bit early to expose these functions. GnuPG-bug-id: 6249 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* spawn: Introduce gpgrt_process_t and use it for spawn API.NIIBE Yutaka2022-11-041-10/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * configure.ac (AC_FUNC_FORK): No use. * src/gpg-error.h.in (@define:gpgrt_process_t@): New. (@define:pid_t@): Remove. (gpgrt_spawn_process, gpgrt_spawn_process_fd): Use gpgrt_process_t. (gpgrt_wait_process, gpgrt_wait_processes): Likewise. (gpgrt_kill_process, gpgrt_release_process): Likewise. * src/gpgrt-int.h (_gpgrt_spawn_process): Likewise. (_gpgrt_spawn_process_fd): Likewise. (_gpgrt_wait_process, _gpgrt_wait_processes): Likewise. (_gpgrt_kill_process, _gpgrt_release_process): Likewise. * src/mkheader.c (write_special): Handle @define:gpgrt_process_t@. Remove handling of @define:pid_t@. * src/spawn-posix.c (_gpgrt_spawn_process): Use gpgrt_process_t. (_gpgrt_spawn_process_fd): Likewise. (_gpgrt_wait_process, _gpgrt_wait_processes): Likewise. (_gpgrt_kill_process, _gpgrt_release_process): Likewise. * src/spawn-w32.c (_gpgrt_spawn_process): Use gpgrt_process_t. (_gpgrt_spawn_process_fd): Likewise. (_gpgrt_wait_process, _gpgrt_wait_processes): Likewise. (_gpgrt_kill_process, _gpgrt_release_process): Likewise. -- GnuPG-bug-id: 6249 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* spawn: Fix spawn_cb of gpgrt_spawn_process_fd.NIIBE Yutaka2022-10-311-3/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/gpg-error.def.in (gpgrt_close_all_fds): New. * src/gpg-error.vers (gpgrt_close_all_fds): New. * src/gpg-error.h.in (GPGRT_SPAWN_INHERIT_FILE): New. (gpgrt_spawn_process_fd): SPAWN_CB having return value. * src/gpgrt-int.h (_gpgrt_spawn_process_fd): SPAWN_CB change. * src/spawn-posix.c (_gpgrt_close_all_fds): Rename from close_all_fds, and export it. (do_exec): Support the case not closing fds. (_gpgrt_spawn_process_fd): Handle return value of SPAWN_CB to determine closing all fds or not. * src/spawn-w32.c (_gpgrt_spawn_process_fd): Run SPAWN_CB. (_gpgrt_close_all_fds): New. * src/visibility.c (gpgrt_close_all_fds): New. * src/visibility.h (gpgrt_close_all_fds): New. -- Now, we have the API of gpgrt_spawn_process_fd for POSIX and Windows. Giving portable semantics for spawning a process is difficult, and it is still difficult for users to writing a function for SPAWN_CB with portability, but gpgrt_spawn_process_fd gives the feature of spawning a process. GnuPG-bug-id: 6249 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* spawn: Expose spawn functions.NIIBE Yutaka2022-10-271-7/+1
| | | | | | | | | | | | | * src/gpg-error.def.in: Update. * src/gpg-error.vers: Update. * src/gpg-error.h.in: Add declarations. * src/visibility.c: Add implementations. * src/visibility.h: Expose them. -- GnuPG-bug-id: 6249 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* gpgrt_spawn_process, gpgrt_spawn_process_fd: Change the API.NIIBE Yutaka2022-10-201-2/+3
| | | | | | | | | | | | | | | | | | | | * src/gpg-error.h.in (gpgrt_spawn_process): Remove PREEXEC argument. (gpgrt_spawn_process_fd): Add AFTER_FORK_CB and AFTER_FORK_CB_ARG. * src/gpgrt-int.h (_gpgrt_spawn_process): Remove PREEXEC argument. (_gpgrt_spawn_process_fd): Add AFTER_FORK_CB and AFTER_FORK_CB_ARG. * src/spawn-posix.c (do_exec): Remove PREEXEC argument. (_gpgrt_spawn_process): Remove PREEXEC argument. (_gpgrt_spawn_process_fd): Add AFTER_FORK_CB and AFTER_FORK_CB_ARG. (_gpgrt_spawn_process_detached): Follow the change of do_exec. * src/spawn-w32.c (_gpgrt_spawn_process): Remove PREEXEC argument. (_gpgrt_spawn_process_fd): Add AFTER_FORK_CB and AFTER_FORK_CB_ARG. * src/visibility.c (gpgrt_spawn_process): Remove PREEXEC argument. (gpgrt_spawn_process_fd): Add AFTER_FORK_CB and AFTER_FORK_CB_ARG. -- GnuPG-bug-id: 6249 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* spawn: Update changes from gnupg.NIIBE Yutaka2022-10-191-0/+3
| | | | | | | | | | | | | | | | | | | * src/gpg-error.h.in (GPGRT_SPAWN_KEEP_STDIN): New. (GPGRT_SPAWN_KEEP_STDOUT, GPGRT_SPAWN_KEEP_STDERR): New. * src/gpgrt-int.h: Add comment. * src/spawn-posix.c (do_exec): Add the argument FLAGS. (_gpgrt_spawn_process): Add FLAGS. (_gpgrt_spawn_process_fd): Follow the change. (_gpgrt_spawn_process_detached): Likewise. * src/spawn-w32.c (_gpgrt_spawn_process): Handle FLAGS. -- This commit imports GnuPG master commit of: 6d6438a361d25f3b269f702e017f5e39fd1f5c38 GnuPG-bug-id: 6249 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* w32: Add ES_SYSHD_SOCK support for gpgrt_sysopen.NIIBE Yutaka2022-04-041-1/+1
| | | | | | | | | | | | | | | | * src/mkheader.c (write_special): Support @SOCKET_t@ substitution. * src/gpgrt-int.h (gpgrt_stream_backend_kind_t): Add BACKEND_SOCK. * src/gpg-error.h.in (struct _gpgrt_syshd): Use @SOCKET_t@. * src/estream.c [HAVE_W32_SYSTEM] (estream_cookie_sock_t): New. [HAVE_W32_SYSTEM] (func_sock_create, func_sock_read): New. [HAVE_W32_SYSTEM] (func_sock_write, func_sock_seek): New. [HAVE_W32_SYSTEM] (func_sock_destroy, func_sock_ioctl): New. [HAVE_W32_SYSTEM] (estream_functions_sock, do_sockopen): New. [HAVE_W32_SYSTEM] (do_sysopen): Call do_sockopen. -- Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* Release 1.44libgpg-error-1.44gpgrt-1.44Werner Koch2022-01-271-1/+2
| | | | * configure.ac: Bump LT version to C32/A32/R2.
* New public function gpgrt_access.Werner Koch2020-10-191-0/+3
| | | | | | | | | | | | | | | | | | | | | | * 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
* estream: Add gpgrt_fcancelWerner Koch2020-06-261-0/+1
| | | | | | | | | | | | * src/estream.c (do_close): Add arg 'cancel_mode' and chnage all callers. (_gpgrt_fcancel): New. * src/gpg-error.def.in, src/gpg-error.vers: Add function. * src/visibility.c (gpgrt_fcancel): New. * src/gpg-error.h.in (gpgrt_fcancel): New. -- Signed-off-by: Werner Koch <wk@gnupg.org>
* core: Tweak the printing of headers in the --help output.Werner Koch2020-03-061-1/+2
| | | | | | | * src/argparse.c (show_help): Do not print empty sections between headers. Signed-off-by: Werner Koch <wk@gnupg.org>
* core: Add features for pretty printing the helpWerner Koch2020-03-061-3/+18
| | | | | | | | | | | | | | | | | | | | * 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-031-0/+1
| | | | | | | | | | | | | | | | | * 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-2/+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: Add parser for meta commands to gpgrt_argparser.Werner Koch2020-02-251-0/+3
| | | | | | | | | | | | | | | | | | | | | * 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: New flag ARGPARSE_FLAG_USERVERS to try versioned config files.Werner Koch2020-02-251-0/+1
| | | | | | | | | | | | * src/gpg-error.h.in (ARGPARSE_FLAG_USERVERS): New. * src/argparse.c: Include unistd.h. (try_versioned_conffile): New. (_gpgrt_argparser): Use it. -- This is neded to bring the versioned config files back to gpg. Signed-off-by: Werner Koch <wk@gnupg.org>
* core: New pseudo option ARGPARSE_PERMISSION_ERROR.Werner Koch2020-02-251-0/+1
| | | | | | | | | | | * src/gpg-error.h.in (ARGPARSE_PERMISSION_ERROR): New. * src/argparse.c (initialize): Add code to print this error. -- We need this option to reject certain config files if we detect a permission problem. Signed-off-by: Werner Koch <wk@gnupg.org>
* core: Add a high level option/argument parser.Werner Koch2020-02-181-3/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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-181-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* New error codes for SQLiteWerner Koch2019-12-131-0/+7
| | | | | | | * src/err-codes.h.in: Add GPG_ERR_SQL_ codes. * src/gpg-error.h.in (gpg_err_code_from_sqlite): New. Signed-off-by: Werner Koch <wk@gnupg.org>
* Release 1.34libgpg-error-1.34gpgrt-1.34Werner Koch2019-01-161-1/+1
| | | | | | * configure.ac: Bump LT version to C26/A26/R0. Signed-off-by: Werner Koch <wk@gnupg.org>
* core: New functions gpgrt_abort and gpgrt_add_emergency_cleanup.Werner Koch2019-01-041-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | * src/init.c (emergency_cleanup_list): New gloabl var. (_gpgrt_add_emergency_cleanup): New. (_gpgrt_abort): New. Repalce all calls to abort by this. Also replace all assert by either log_assert or a stderr output followed by a _gpgrt_abort. (run_emergency_cleanup): New. * src/visibility.c (gpgrt_add_emergency_cleanup): New public API. (gpgrt_abort): New public API. -- Libgcrypt uses its own assert function which makes sure to terminate the secure memory. This is safe as log as an assert is triggered internally in Libgcrypt. GnuPG runs emergency cleanup handlers right before log_fatal etc to tell Libgcrypt to terminate the secure memory. With the move of the logging function to gpgrt in gnupg 2.3 this did not anymore. Thus we now provide a mechanism in gpgrt to do right that. Eventually Libgcrypt can also make use of this. What this does not handle are calls to abort or failed asserts in external libraries or in libc. We can't do anything about it in a library because a library may not setup signal handlers. Signed-off-by: Werner Koch <wk@gnupg.org>
* Fix gpgrt_ftruncate declaration.Marcus Brinkmann2018-12-051-1/+1
|
* core: New functions gpgrt_fprintf_sf anf gpgrt_fprintf_sf_unlocked.Werner Koch2018-11-261-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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/+2
| | | | | | | | | | | | | | | * 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-0/+9
| | | | | | | | | | | | | | | | | | | | | * 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>
* Remove leftover debug output from gpg-error.Werner Koch2018-07-051-2/+2
| | | | | | | | | * src/gpg-error.c (main): Remove a log_debug. -- Also a few typo fixes. Signed-off-by: Werner Koch <wk@gnupg.org>
* core: Fix problem with C11 and stdnoreturn.h.Werner Koch2018-05-301-3/+3
| | | | | | | | | * src/gpg-error.h.in (GPGRT_ATTR_NORETURN): Use gcc specific symbol name __noreturn__. -- GnuPG-bug-id: 4002 Signed-off-by: Werner Koch <wk@gnupg.org>
* doc: Beautify comments in gpg-error.h.Werner Koch2018-04-111-74/+84
| | | | | | -- Signed-off-by: Werner Koch <wk@gnupg.org>
* core: Finalize the API for argparse.Werner Koch2018-04-111-6/+2
| | | | | | | | | | | | | | | | | | | | | | | | | * src/gpg-error.h.in (ARGPARSE_end): Simplify. * src/argparse.c (_gpgrt_argparse_internal_s): Add field opts. (deinitialize): Release new field. (initialize): Add arg opts and create a copy of the option list. Add the internal options. (_gpgrt_argparse): Rename arg opts to opts_orig and set new local var opts. Adjust all references to opts. (find_long_option): Adjust for chnaged type of OPTS. Re-indent. (arg_parse): Remove internal option assignment. Rename arg opts to opts_orig and set new local var opts. Adjust all references to opts. (show_help): Adjust all references to opts. -- The old ARGPARSE_end maro was a bit cumbersome and does not allow to chnage the number of internal options. Thus this somewhat larger chnage to keep the internal options out of the API. Note that with this change the internal options now also work in a option file and not just on the command line; that does not make much sense but is probably less surprising. Signed-off-by: Werner Koch <wk@gnupg.org>
* core: Add Base-64 encoder.Werner Koch2018-03-221-4/+10
| | | | | | | | | | | | | | | | | | | | | | | * 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 public function gpgrt_usage.Werner Koch2018-03-211-0/+1
| | | | | | * src/visibility.c (gpgrt_usage): New. Signed-off-by: Werner Koch <wk@gnupg.org>
* core: Add the group of argparse functions.Werner Koch2018-03-211-0/+181
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* core: Fix building on W64Werner Koch2018-03-141-0/+1
| | | | | | | | | | | | | * src/w32-add.h: Remove hack to define pid_t. * src/gpg-error.h.in: Eval macro to define pid_t. * src/mkheader.c (have_sys_types_h, sys_types_h_included): New. (parse_config_h): Test for sys/types.h. (write_special): Protect inclusion of sys/types.h. Define new macro 'define:pid_t'. -- Regression-due-to: 1865c0ba1769b407a3c504f1ab0a4278704a9fc1 Signed-off-by: Werner Koch <wk@gnupg.org>
* build: Update copyright notices and remove gpgscm from the release.Werner Koch2018-03-131-1/+1
| | | | | | -- Signed-off-by: Werner Koch <wk@gnupg.org>
* core: Fix regression due to not exporting the process API.Werner Koch2018-03-131-2/+2
| | | | | | | -- Fixes-commit: 0e503cae75cb1a6aa257228a65941b7630ff35d6 Signed-off-by: Werner Koch <wk@gnupg.org>
* core: Remove accidently committed time function API.Werner Koch2018-03-121-31/+0
| | | | | | -- Fixes-commit: f9a33a7f7e44a644ff4e31f7e9f1c2c1ec1f8eee
* core: Do not export the process APIWerner Koch2018-03-121-1/+4
| | | | | | | | | -- We may need to change the API and thus we better wait before publishing this new interface. Signed-off-by: Werner Koch <wk@gnupg.org>
* core: Avoid using estream_t in the public API.Werner Koch2017-12-111-4/+33
| | | | | | | | | | * src/gpg-error.h.in: Always use gpgrt_stream-t. -- estream_t can only be used if GPGRT_ENABLE_ES_MACROS is defined. Fixes-commit: 1865c0ba1769b407a3c504f1ab0a4278704a9fc1 Signed-off-by: Werner Koch <wk@gnupg.org>
* core: Rename the gpgrt_log_levels enum values.Werner Koch2017-12-081-9/+9
| | | | | | | | | | | * src/gpg-error.h.in (gprt_log_levels): Rename to GPGRT_LOGLVL. -- Explicitly naming them and not distinguishing them from the other log constants is a Good Thing anyway. It also helps against the symbol name clash with the GPGRT enum values from gnupg's logging module. Signed-off-by: Werner Koch <wk@gnupg.org>
* core: Implement the spawn functions.Werner Koch2017-11-291-0/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/gpg-error.h.in (GPGRT_SPAWN_NONBLOCK): New const. (GPGRT_SPAWN_RUN_ASFW): New const. (GPGRT_SPAWN_DETACHED): New const. (gpgrt_make_pipe): New function. (gpgrt_create_pipe): New macro. (gpgrt_create_inbound_pipe): New macro. (gpgrt_create_outbound_pipe): New macro. (gpgrt_spawn_process): New function. (gpgrt_spawn_process_fd): New function. (gpgrt_spawn_process_detached): New function. (gpgrt_wait_process): New function. (gpgrt_wait_processes): New function. (gpgrt_kill_process): New function. (gpgrt_release_process): New function. * src/gpg-error.def.in, src/gpg-error.vers: Add new functions. * src/visibility.c, src/visibility.h: Add wrappers for new functions. * src/spawn-posix.c: Rework to better fit the use in gpgrt. Rename all public function with a _gpgrt prefix. * src/spawn-w32.c: Ditto. * src/gpgrt-int.h: Likewise. * src/Makefile.am (arch_sources): Add spawn-posix.c and spawn-w32.c. * src/w32-add.h: Add pid_t typedef as a temporary hack. * configure.ac: Check for signal.h and getrlimit. (AC_FUNC_FORK): New. -- This does build but porting the tests and further changes are required. Don't assume that the API for the new fucntions is stable. Signed-off-by: Werner Koch <wk@gnupg.org>
* core: Change new functions to return gpg_err_code_t.Werner Koch2017-11-281-3/+4
| | | | | | | | | | | | | | | | * src/gpg-error.h.in (gpgrt_sentenv, gpgrt_mkdir, gpgrt_chdir): Change return type to gpg_err_code_t. * src/sysutils.c (_gpgrt_setenv): Implement that. (_gpgrt_mkdir): Ditto. (_gpgrt_chdir): Ditto. * gpgscm/ffi.c (do_setenv, do_mkdir): Adjust for this change. -- The functions are already a bit different and thus it is useful to let them return a gpg-error style error code and don't let the user implement that for each call. Signed-off-by: Werner Koch <wk@gnupg.org>
* core: New API functions gpgrt_mkdir, gpgrt_chdir, gpgrt_getcwd.Werner Koch2017-11-281-0/+9
| | | | | | | | | | | | | | | | | | | | | | * src/gpg-error.h.in (gpgrt_mkdir, gpgrt_chdir, gpgrt_getcwd): New. * src/visibility.c, src/visibility.h: Add wrappers. * src/gpg-error.vers, src/gpg-error.def.in: Add them. * src/sysutils.c (modestr_to_mode): New. (_gpgrt_mkdir, _gpgrt_chdir, _gpgrt_getcwd): New. * m4/gnupg-misc.m4: New. * m4/Makefile.am (EXTRA_DIST): Add new M4 file. * configure.ac: Call new GNUPG_FUNC_MKDIR_TAKES_ONE_ARG. (AC_CHECK_FUNCS): Add stat. -- The code has been taken from GnuPG. _gpgrt_mkdir was originally written by me as gnupg_mkdir and here relicensed to LGPLv2.1+. _gpgrt_getcwd was originally written by in 2007 and also here relicensed to LGPLv2.1. The new M4 macro was also written by me for use in in GnuPG; it has been taken from GnUPG's acinclude.m4, moved to its own file here, and relicensed to FSFULLR. Signed-off-by: Werner Koch <wk@gnupg.org>
* core: New API functions gpgrt_getenv and gpgrt_setenv.Werner Koch2017-11-281-0/+13
| | | | | | | | | | | | | | | | | | | * src/gpg-error.h.in (gpgrt_getenv, gpgrt_setenv): New. (gpgrt_unsetenv): New macro. * src/gpg-error.vers, src/gpg-error.def.in: Add them. * src/visibility.c (gpgrt_getenv, gpgrt_setenv): New. * src/visibility.h: Add them. * src/sysutils.c: Include string.h and on Windows windows.h. (_gpgrt_getenv): New. (_gpgrt_setenv): New. -- These functions are wrappers to cope with Windows problems. The code is similar to what we have in GnuPG but not identical. Requires better testing. Signed-off-by: Werner Koch <wk@gnupg.org>
* core: Add new macro log_assert to the API.Werner Koch2017-11-271-2/+13
| | | | | | * src/gpg-error.h.in (log_assert): New macro. Signed-off-by: Werner Koch <wk@gnupg.org>
* core: Do not use the estream_t alias in gpg-error.h.Werner Koch2017-11-221-2/+2
| | | | | | | | | * src/gpg-error.h.in: Use gpgrt_stream_t in prototypes. -- estream_t is not necessary enabled so to keep the namespace clean. Signed-off-by: Werner Koch <wk@gnupg.org>
* core: New API functions gpgrt_strdup and gpgrt_strconcat.Werner Koch2017-11-171-0/+2
| | | | | | | | | | | | | | | * src/visibility.c (gpgrt_strdup): New API fucntion. (gpgrt_strconcat): New API fucntion. * src/visibility.h: Add corresponding macros. * src/gpg-error.def.in: Add them. * src/gpg-error.vers: Add them. * src/gpgrt-int.h (DIM): New macro. * src/init.c (_gpgrt_strdup): New. (_gpgrt_strconcat_core): New. (_gpgrt_strconcat): New. -- Signed-off-by: Werner Koch <wk@gnupg.org>
* core: New API functions gpgrt_malloc, gpgrt_calloc, and gpgrt_realloc.Werner Koch2017-11-171-1/+11
| | | | | | | | | | | | | * src/visibility.c (gpgrt_realloc): New API function. (gpgrt_malloc): New API function. (gpgrt_calloc): New API function. * src/visibility.h: Add corresponding macros. * src/gpg-error.def.in: Add them. * src/gpg-error.vers: Add them. * src/init.c (_gpgrt_calloc): New. * src/gpg-error.h.in: Add prototypes. Signed-off-by: Werner Koch <wk@gnupg.org>
* core: Add logging API.Werner Koch2017-11-171-4/+118
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/visibility.c (gpgrt_get_errorcount): New API. (gpgrt_inc_errorcount): New API. (gpgrt_log_set_sink): New API. (gpgrt_log_set_socket_dir_cb): New API. (gpgrt_log_set_pid_suffix_cb): New API. (gpgrt_log_set_prefix): New API. (gpgrt_log_get_prefix): New API. (gpgrt_log_test_fd): New API. (gpgrt_log_get_fd): New API. (gpgrt_log_get_stream): New API. (gpgrt_log): New API. (gpgrt_logv): New API. (gpgrt_logv_prefix): New API. (gpgrt_log_string): New API. (gpgrt_log_info): New API. (gpgrt_log_error): New API. (gpgrt_log_fatal): New API. (gpgrt_log_bug): New API. (gpgrt_log_debug): New API. (gpgrt_log_debug_string): New API. (gpgrt_log_printf): New API. (gpgrt_log_flush): New API. (gpgrt_log_printhex): New API. (gpgrt_log_clock): New API. (_gpgrt_log_assert): New function for the ABI. * src/visibility.h: Add corresponding macros. * src/gpg-error.def.in: Add new functions. * src/gpg-error.vers: Add new functions. * src/gpg-error.h.in (GPGRT_LOG_WITH_PREFIX): New constant. (GPGRT_LOG_WITH_TIME): New constant. (GPGRT_LOG_WITH_PID): New constant. (GPGRT_LOG_RUN_DETACHED): New constant. (GPGRT_LOG_NO_REGISTRY): New constant. (GPGRT_LOG_BEGIN): New enum value. (GPGRT_LOG_CONT): New enum value. (GPGRT_LOG_INFO): New enum value. (GPGRT_LOG_WARN): New enum value. (GPGRT_LOG_ERROR): New enum value. (GPGRT_LOG_FATAL): New enum value. (GPGRT_LOG_BUG): New enum value. (GPGRT_LOG_DEBUG): New enum value. (log_get_errorcount, log_inc_errorcount, log_set_file, log_set_fd) (log_set_stream, log_set_socket_dir_cb, log_set_pid_suffix_cb) (log_set_prefix, log_get_prefix, log_test_fd, log_get_fd) (log_get_stream, log_log, log_logv, log_logv_prefix, log_string) (log_bug, log_fatal, log_error, log_info, log_debug, log_debug_string) (log_printf, log_printhex, log_clock) (log_flush) [GPGRT_ENABLE_LOG_MACROS]: New wrapper macros. (gpgrt_assert): New macro. * src/gpgrt-int.h: Add prototypes for logging.c. (gpgrt_assert): Redefine for internal use. * src/logging.h: Remove. * src/logging.c: Include gpgrt-int.h instead of the stuff from GnuPG. Use _gpgrt malloc funcsions and the internal versions of the estream functions. Rename all public fucntions with a _gpgrt_ prefix. (print_prefix): Return the printed length. (_gpgrt_logv_internal): Ditto. (_gpgrt_log_printhex): Change order of args and turn into a printf like function. (_gpgrt_logv_printhex): New. Take the core of the former log_printhex. (_gpgrt_log_clock): Turn into a printf like functions. (_gpgrt_logv_clock): New. Take the core of the former log_clock. -- This logging API is a slightly modified version of what we are using in GnuPG. Signed-off-by: Werner Koch <wk@gnupg.org>