summaryrefslogtreecommitdiff
path: root/src/gpg-error.h.in
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2018-11-26 20:22:24 +0100
committerWerner Koch <wk@gnupg.org>2018-11-26 20:22:24 +0100
commitbd8668c120ac0f725edb092b2c4ca49ffdb78ed2 (patch)
treeffeea782e9dc6435822f3b3f1c950c7222ff93b9 /src/gpg-error.h.in
parentffb49b72f132d954a3d9fa11e45803c36a62fd25 (diff)
downloadlibgpg-error-bd8668c120ac0f725edb092b2c4ca49ffdb78ed2.tar.gz
core: New functions gpgrt_fprintf_sf anf gpgrt_fprintf_sf_unlocked.
* 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>
Diffstat (limited to 'src/gpg-error.h.in')
-rw-r--r--src/gpg-error.h.in14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/gpg-error.h.in b/src/gpg-error.h.in
index c0ac0eb..cb32c48 100644
--- a/src/gpg-error.h.in
+++ b/src/gpg-error.h.in
@@ -644,6 +644,11 @@ typedef struct _gpgrt_poll_s gpgrt_poll_t;
typedef struct _gpgrt_poll_s es_poll_t;
#endif
+/* The type of the string filter function as used by fprintf_sf et al. */
+typedef char *(*gpgrt_string_filter_t) (const char *s, int n, void *opaque);
+
+
+
gpgrt_stream_t gpgrt_fopen (const char *_GPGRT__RESTRICT path,
const char *_GPGRT__RESTRICT mode);
gpgrt_stream_t gpgrt_mopen (void *_GPGRT__RESTRICT data,
@@ -783,6 +788,15 @@ int gpgrt_fprintf_unlocked (gpgrt_stream_t _GPGRT__RESTRICT stream,
const char *_GPGRT__RESTRICT format, ...)
GPGRT_ATTR_PRINTF(2,3);
+int gpgrt_fprintf_sf (gpgrt_stream_t _GPGRT__RESTRICT stream,
+ gpgrt_string_filter_t sf, void *sfvalue,
+ const char *_GPGRT__RESTRICT format,
+ ...) GPGRT_ATTR_PRINTF(4,5);
+int gpgrt_fprintf_sf_unlocked (gpgrt_stream_t _GPGRT__RESTRICT stream,
+ gpgrt_string_filter_t sf, void *sfvalue,
+ const char *_GPGRT__RESTRICT format,
+ ...) GPGRT_ATTR_PRINTF(4,5);
+
int gpgrt_printf (const char *_GPGRT__RESTRICT format, ...)
GPGRT_ATTR_PRINTF(1,2);
int gpgrt_printf_unlocked (const char *_GPGRT__RESTRICT format, ...)