Commit ddf1ff2f authored by Alexandre Julliard's avatar Alexandre Julliard

include: Make wine_dbg_printf() into an inline function.

parent f2e6f05f
......@@ -74,6 +74,20 @@ static void release_temp_buffer( char *ptr, size_t size )
info->str_pos = ptr + size;
}
/* add a string to the output buffer */
static int append_output( struct debug_info *info, const char *str, size_t len )
{
if (len >= sizeof(info->output) - (info->out_pos - info->output))
{
fprintf( stderr, "wine_dbg_output: debugstr buffer overflow (contents: '%s')\n", info->output );
info->out_pos = info->output;
abort();
}
memcpy( info->out_pos, str, len );
info->out_pos += len;
return len;
}
/***********************************************************************
* __wine_dbg_strdup (NTDLL.@)
*/
......@@ -89,6 +103,26 @@ const char * __cdecl __wine_dbg_strdup( const char *str )
}
/***********************************************************************
* __wine_dbg_output (NTDLL.@)
*/
int __cdecl __wine_dbg_output( const char *str )
{
struct debug_info *info = get_info();
const char *end = strrchr( str, '\n' );
int ret = 0;
if (end)
{
ret += append_output( info, str, end + 1 - str );
write( 2, info->output, info->out_pos - info->output );
info->out_pos = info->output;
str = end + 1;
}
if (*str) ret += append_output( info, str, strlen( str ));
return ret;
}
/***********************************************************************
* NTDLL_dbg_vprintf
*/
static int NTDLL_dbg_vprintf( const char *format, va_list args )
......
......@@ -1506,6 +1506,7 @@
@ cdecl __wine_make_process_system()
# Debugging
@ cdecl -norelay __wine_dbg_output(str)
@ cdecl -norelay __wine_dbg_strdup(str)
# Virtual memory
......
......@@ -162,6 +162,7 @@ extern int __wine_dbg_set_channel_flags( struct __wine_debug_channel *channel,
extern void __wine_dbg_set_functions( const struct __wine_debug_functions *new_funcs,
struct __wine_debug_functions *old_funcs, size_t size );
extern const char * __cdecl __wine_dbg_strdup( const char *str );
extern int __cdecl __wine_dbg_output( const char *str );
/*
* Exported definitions and macros
......@@ -171,7 +172,6 @@ extern const char * __cdecl __wine_dbg_strdup( const char *str );
quotes. The string will be valid for some time, but not indefinitely
as strings are re-used. */
extern int wine_dbg_printf( const char *format, ... ) __WINE_PRINTF_ATTR(1,2);
extern int wine_dbg_log( enum __wine_debug_class cls, struct __wine_debug_channel *ch, const char *func,
const char *format, ... ) __WINE_PRINTF_ATTR(4,5);
......@@ -199,6 +199,18 @@ static inline const char * __wine_dbg_cdecl wine_dbg_sprintf( const char *format
return __wine_dbg_strdup( buffer );
}
static int __wine_dbg_cdecl wine_dbg_printf( const char *format, ... ) __WINE_PRINTF_ATTR(1,2);
static inline int __wine_dbg_cdecl wine_dbg_printf( const char *format, ... )
{
char buffer[1024];
__wine_dbg_va_list args;
__wine_dbg_va_start( args, format );
vsnprintf( buffer, sizeof(buffer), format, args );
__wine_dbg_va_end( args );
return __wine_dbg_output( buffer );
}
static inline const char *wine_dbgstr_an( const char *str, int n )
{
static const char hex[16] = "0123456789abcdef";
......
......@@ -31,6 +31,7 @@
#endif
#define wine_dbg_sprintf wine_dbg_sprintf_inline
#define wine_dbg_printf wine_dbg_printf_inline
#define wine_dbgstr_an wine_dbgstr_an_inline
#define wine_dbgstr_wn wine_dbgstr_wn_inline
#include "wine/debug.h"
......@@ -217,6 +218,7 @@ static void debug_init(void)
}
/* varargs wrapper for funcs.dbg_vprintf */
#undef wine_dbg_printf
int wine_dbg_printf( const char *format, ... )
{
int ret;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment