aboutsummaryrefslogtreecommitdiffstats
path: root/src/gpgrt-int.h (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* core: Add logging API.Werner Koch2017-11-171-0/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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 <[email protected]>
* New configure options and macros for internal use.Werner Koch2017-11-171-9/+109
| | | | | | | | | | | | | * configure.ac: Add option --enable-log-clock. * configure.ac: Add option --enable-werror. * src/sysutils.c: New. * src/Makefile.am (libgpg_error_la_SOURCES): Add sysutils.c * src/gpgrt-int.h: Add internal i18n macros and hacks to make working with sockets easier. (es_stdin, es_stdout, es_stderr): New internal macros. (snprintf): New macro. Signed-off-by: Werner Koch <[email protected]>
* Improve tracing of estream.Werner Koch2017-02-281-15/+26
| | | | | | | | | | | | * src/gpgrt-int.h (trace_errno): Add new parameter. Adjust all users. * src/init.c (trace_fp, trace_with_errno, trace_missing_lf) (trace_prefix_done): New vars. (_gpgrt_internal_trace_begin): Add arg WITH_ERRNO. Open a trace file on first use. Init new vars. (print_internal_trace_prefix): New. * src/estream.c, src/w32-estream.c: Improve tracing. Signed-off-by: Werner Koch <[email protected]>
* Add a tracing framework.Werner Koch2017-02-261-0/+44
| | | | | | | | | | | | | | | | | | | | * src/init.c (trace_save_errno, trace_arg_module) (trace_arg_file, trace_arg_line): New module vars. (do_internal_trace): New. (_gpgrt_internal_trace_printf): New. (_gpgrt_internal_trace): New. (_gpgrt_internal_trace_errno): New. (_gpgrt_internal_trace_end): New. * src/gpgrt-int.h (trace): New macro. (trace_errno): New macro. (trace_start): New macro. (trace_append): New macro. (trace_finish): New macro. -- We want to be abale to use libgpg-error also with pre-c99 compilers and thus we can use the __VA_ARGS__ but resort to the common macro trick.
* Rename internal functions of estream.Werner Koch2017-02-261-1/+1
| | | | | | | | | | | | | | | | | | | | * src/estream.c (_gpgrt_es_init): Rename to _gpgrt_estream_init. (es_fill): Rename to fill_stream. (es_fflush): Rename to flush_stream. (es_deinitialize): Rename to deinit_stream_obj. (es_create): Rename to create_stream (es_read_nbf): Rename to do_read_nbf. (es_read_lbf): Rename to do_read_lbf. (es_read_fbf): Rename to do_read_fbf. (es_peek): Rename to peek_stream. (es_skip): Rename to skip_stream. (es_print): Rename to do_print_stream. -- The use of the "es_" was confusing. Avoid that. Signed-off-by: Werner Koch <[email protected]>
* Add Base64 decoder.NIIBE Yutaka2017-02-011-0/+6
| | | | | | | | | | | | | | | | * 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: Minor portability fix.Werner Koch2016-11-121-1/+1
| | | | | | | | | | -- A trailing comma in an enum is not groked by all compilers. Binary operation should have their own parentheses to make it clear that a binary operator was meant. Signed-off-by: Werner Koch <[email protected]>
* estream: Support 'es_poll' on Windows.Justus Winter2016-11-121-0/+74
| | | | | | | | | | | | | | | | | | | | | * 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]>
* estream: Track the kind of backend used.Justus Winter2016-11-121-0/+11
| | | | | | | | | * src/estream.c (struct _gpgrt_stream_internal): Add 'kind'. (init_stream_obj): New parameter 'kind', initialize field. (es_create): New parameter 'kind'. Update all callers. * src/gpgrt-int.h (gpgrt_stream_backend_kind_t): New type. Signed-off-by: Justus Winter <[email protected]>
* estream: Rework how the cookie functions are handled.Justus Winter2016-11-121-0/+20
| | | | | | | | | | | | | | | | | | | | | | * src/estream.c (cookie_ioctl_function_t): Move to 'gpgrt-int.h', along with the macros for the IOCTL numbers. (estream_functions_mem): Use the new type and add the ioctl function. (estream_functions_fd): Likewise. (estream_functions_w32): Likewise. (estream_functions_fp): Likewise. (init_stream_object): Use the new type, and also initialize 'func_ioctl'. (es_create): Use the new type. (_gpgrt_fopen): Adapt. (_gpgrt_mopen): Likewise. (_gpgrt_fopenmem): Likewise. (_gpgrt_fopencookie): Likewise. (_gpgrt_fdopen): Likewise. (_gpgrt_fpopen): Likewise. (do_w32open): Likewise. * src/gpgrt-int.h (struct cookie_io_functions_s): New type. Signed-off-by: Justus Winter <[email protected]>
* Add new interface gpgrt_get_syscall_clamp.Werner Koch2016-11-121-0/+1
| | | | | | | | | | | | | * src/visibility.c (gpgrt_get_syscall_clamp): New. * src/gpg-error.vers, src/gpg-error.def.in: Add function. * src/gpg-error.h.in: Ditto. * src/estream.c (_gpgrt_get_syscall_clamp): New. -- This function can be used by other libraries to set their own system clamp functions. Signed-off-by: Werner Koch <[email protected]>
* Convert http links to https where possible in the source.Daniel Kahn Gillmor2016-02-081-1/+1
| | | | | | | | | | | | | | | | -- * 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
* estream: Add gpgrt_set_nonblock and gpgrt_poll.Werner Koch2015-09-251-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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]>
* Add new public macros for GCC attributes.Werner Koch2015-07-241-4/+4
| | | | | | | | | | * src/gpg-error.h.in (GPGRT_GCC_VERSION): New. (GPGRT_ATTR_NORETURN, GPGRT_ATTR_PRINTF, GPGRT_ATTR_NR_PRINTF): New. (GPGRT_ATTR_FORMAT_ARG, GPGRT_ATTR_SENTINEL): New. (GPGRT_ATTR_USED, GPGRT_ATTR_UNUSED, GPGRT_ATTR_DEPRECATED): New. (GPGRT_ATTR_PURE, GPGRT_ATTR_MALLOC): New. (GPGRT_HAVE_MACRO_FUNCTION, GPGRT_HAVE_PRAGMA_GCC_PUSH): New. (_GPGRT_GCC_A_PRINTF): Replace GPGRT_ATTR_PRINTF.
* Change gpgrt_pending{,_unlocked} to macros.Werner Koch2014-10-031-2/+2
| | | | | | | | | | | | | | | | | | | | * src/gpg-error.h.in (gpgrt_pending): Change to a macro. (gpgrt_pending_unlocked): Change to a macro. (_gpgrt_pending, _gpgrt_pending_unlocked): New private functions. * src/visibility.c, src/visibility.h: Change accordingly. * src/gpg-error.vers, src/gpg-error.def.in: Ditto. * src/estream.c (_gpgrt_pending_unlocked): Rename to _gpgrt__pending_unlocked. (_gpgrt_pending): Rename to _gpgrt__pending. -- The function are supposed to be used with gprt_getc and thus we need to avoid the function call overhead. We may want to change them to inline functions, though. gpgrt_pending is changed to a macro with the idea that we eventually can export the samestream flags and thus avoid the function call overhead in the samethread case too.
* Add GPG_ERR_BOGUS_STRING and an experimental gpgrt_pending.Werner Koch2014-10-021-0/+2
| | | | | | | | | * src/visibility.c (gpgrt_pending, gpgrt_pending_unlocked): New. * src/estream.c (_gpgrt_pending, _gpgrt_pending_unlocked): New. (check_pending): new. (check_pending_fbf, check_pending_nbf): New. (es_func_mem_read, es_func_fd_read, es_func_w32_read) (es_func_fp_read, es_fill): Take care of the special 0 value for SIZE.
* Fix a prototypeWerner Koch2014-09-121-2/+2
| | | | * src/gpgrt-int.h: s/off_t/gpgrt_off_t/.
* Fix problems with ssize_t and off_t.Werner Koch2014-09-111-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | * configure.ac (AC_SYS_LARGEFILE): New. (AC_CHECK_HEADERS): Check for stdint.h. (AC_CHECK_SIZEOF): Add for int, long and long long. (REPLACEMENT_FOR_OFF_T): New ac_define. * src/mkheader.c (have_stdint_h, have_w32_system, have_w64_system) (replacement_for_off_type, stdint_h_included): New. (xfree, xstrdup): New. (parse_config_h): New. (write_special): Support "define:gpgrt_off_t", "define:gpgrt_ssize_t", "api_ssize_t" tags. (main): Add config.h arg. Call parse_config_h. Fix substitute code. * src/Makefile.am (gpg-error.h): Pass config.h to mkheader. * src/gpg-error.h.in: Include definitions for gpgrt_ssize_t and gpgrt_off_t. Let mkheader insert ssize_t keywords. Chnage all off_t to gpgrt_off_t. * src/estream.c: Change all off_t to gpgrt_off_t. Chnage all ssize_t to gpgrt_ssize_t. * src/visibility.c (gpgrt_fseeko): Use gpgrt_off_t. (gpgrt_ftello): Ditto. (gpgrt_getline): Use gpgrt_ssize_t. (gpgrt_read_line): Ditto.
* Add gpgrt_set_alloc_func.Werner Koch2014-08-261-1/+6
| | | | | | | | | | | | | * src/visibility.c (gpgrt_set_alloc_func): New. * configure.ac (_ESTREAM_PRINTF_REALLOC): Define. (_ESTREAM_PRINTF_EXTRA_INCLUDE): Define. * src/estream.c (mem_alloc, mem_realloc, mem_free): Simplify. (_gpgrt_free): Remove. * src/init.c (custom_realloc): New var. (_gpgrt_set_alloc_func): New. (_gpgrt_realloc, _gpgrt_malloc, _gpgrt_free): New. * src/visibility.h (gpg_err_deinit): Mark as visible.
* Export missing init functions.Werner Koch2014-08-261-0/+2
| | | | | | | | | | | | | | | | | * src/gpg-error.h.in (gpgrt_init): New macro. (gpgrt_check_version): New prototype. * src/init.c (_gpg_err_init): Rename from gpg_err_init. (_gpg_err_deinit): Rename from gpg_err_deinit. * src/visibility.c (gpg_err_init): New. (gpg_err_deinit): New. (gpgrt_check_version): New. * src/gpg-error.vers (gpg_err_init, gpg_err_deinit): Add missing symbols. (gpgrt_check_version): New. * src/gpg-error.def.in (gpg_err_init, gpg_err_deinit): Add missing symbols. (gpgrt_check_version): New. * src/gpg-error.c (main): Use gpgrt_init macro.
* Replace locking code in estream functions.Werner Koch2014-08-251-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | * src/posix-lock.c: Add weak program for pthread_mutex_trylock. (_gpgrt_lock_trylock): New. * src/w32-lock.c (_gpgrt_lock_init): Add missing return statement. (_gpgrt_lock_trylock): New. * src/visibility.c (gpgrt_set_syscall_clamp): New. (gpgrt_lock_trylock): New. (gpgrt_vsnprintf): Fix symbol name. * src/init.c (DllMain): Mark unused arg. * src/estream.c: Replace npth mutexes by our own locks. Replace yeild macro by _gpgrt_yield. (pre_syscall_func, post_syscall_func): New. (do_deinit): Clear both new vars. (es_func_fd_read, es_func_fd_write): Call pre and post syscall functions instead of the former SYSCALL macros. (es_func_w32_read, es_func_w32_write): Ditto. (es_func_fd_seek, es_func_w32_seek, es_func_fp_read) (es_func_fp_write, es_func_fp_seek, es_func_fp_destroy): Bracket syscalls with the pre- and post-syscall fucntions. (do_npth_read, do_npth_write): Remove. (_gpgrt_es_init): Remove call to mutex init. It is now statically initialized. (_gpgrt_set_syscall_clamp): New. (es_create): Destroy stream lock on error. (do_close): Destroy stream lock.
* Finish inclusion of estream into the API.Werner Koch2014-08-251-0/+145
|
* Implement symbol visibility.Werner Koch2014-08-251-0/+49
* 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.