From 7cf19d055929bbaa37b7195a0abe442a7f20b512 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Fri, 22 Aug 2025 14:43:48 +0200 Subject: common: Add a wrapper around the W32 OutputDebugString function. * common/sysutils.c (output_debug_string): New. --- common/sysutils.c | 22 ++++++++++++++++++++++ common/sysutils.h | 2 ++ 2 files changed, 24 insertions(+) diff --git a/common/sysutils.c b/common/sysutils.c index 2bacae2ea..2e39d4737 100644 --- a/common/sysutils.c +++ b/common/sysutils.c @@ -2007,3 +2007,25 @@ open_stream_nc (gnupg_fd_t fd, const char *mode) return es_sysopen_nc (&syshd, mode); } + + +/* Debug helper to track down problems with logging under Windows. */ +void +output_debug_string (const char *format, ...) +{ +#ifdef HAVE_W32_SYSTEM + char *buf; + va_list arg_ptr; + + va_start (arg_ptr, format); + buf = gpgrt_vbsprintf (format, arg_ptr); + va_end (arg_ptr); + if (buf) + OutputDebugStringA (buf); + else + OutputDebugStringA ("vbsprintf failed"); + gpgrt_free (buf); +#else + (void)format; +#endif +} diff --git a/common/sysutils.h b/common/sysutils.h index 9a90d1018..c832c7932 100644 --- a/common/sysutils.h +++ b/common/sysutils.h @@ -121,6 +121,8 @@ int gnupg_inotify_has_name (int fd, const char *name); estream_t open_stream_nc (gnupg_fd_t fd, const char *mode); +void output_debug_string (const char *format, ...) GPGRT_ATTR_PRINTF(1,2); + #ifdef HAVE_W32_SYSTEM int gnupg_w32_set_errno (int ec); void *w32_get_user_sid (void); -- cgit v1.2.3