# HG changeset patch # User Andre Heinecke # Date 1396968751 0 # Node ID b1059360a0c727125cd9c66ef66055fc05035fae # Parent 18b31e2498a3aa16b7cc480be9ddf5c8bee82df7 Debugprintf with output debug string on windows. Makes debugging with redirectred input easier diff -r 18b31e2498a3 -r b1059360a0c7 cinst/nssstore_win.c --- a/cinst/nssstore_win.c Tue Apr 08 14:50:31 2014 +0000 +++ b/cinst/nssstore_win.c Tue Apr 08 14:52:31 2014 +0000 @@ -9,6 +9,7 @@ #include #include #include +#include #include "logging.h" #include "util.h" @@ -20,12 +21,11 @@ #define PRINTLASTERROR(msg) \ char *my_error = getLastErrorMsg(); \ if (my_error) { \ - DEBUGMSG(msg " :"); \ - DEBUGMSG(my_error); \ + DEBUGPRINTF(msg " : %s\n", my_error); \ ERRORPRINTF(msg" : %s\n", my_error); \ free (my_error); \ } \ - DEBUGMSG ("Failed to get error information\n"); + DEBUGPRINTF ("Failed to get error information\n"); /**@brief Write strv of instructions to a handle * diff -r 18b31e2498a3 -r b1059360a0c7 common/logging.h --- a/common/logging.h Tue Apr 08 14:50:31 2014 +0000 +++ b/common/logging.h Tue Apr 08 14:52:31 2014 +0000 @@ -51,29 +51,21 @@ * Prints to stderr if DEBUGOUTPUT is defined. */ #ifdef DEBUGOUTPUT -#define DEBUGPRINTF(fmt, ...) fprintf(stderr, DEBUGPREFIX "DEBUG: " fmt, ##__VA_ARGS__); -#else -#define DEBUGPRINTF(fmt, ...) -#endif - -/** - * @def DEBUGMSG(msg) - * @brief Prints a static debug message - * - * If DEBUGOUTPUT is defined this. Prints a debug message - * to stdout on Unix systems. On Windows OutputDebugString is used. - */ -#ifdef DEBUGOUTPUT -# ifdef WIN32 -# define DEBUGMSG(msg) OutputDebugString (msg); -# else -# define DEBUGMSG(msg) printf (DEBUGPREFIX "DEBUG: " msg "\n"); -# endif +# ifndef WIN32 +# define DEBUGPRINTF(fmt, ...) fprintf(stderr, DEBUGPREFIX "DEBUG: " fmt, ##__VA_ARGS__); +# else /* WIN32 */ +# define DEBUGPRINTF(fmt, ...) \ + { \ + char buf[512]; \ + snprintf(buf, 511, "DEBUG: " fmt, ##__VA_ARGS__); \ + buf[511] = '\0'; \ + OutputDebugStringA(buf); \ + } +# endif /* WIN32 */ #else # define DEBUGPRINTF(fmt, ...) #endif - /** * @def ERRORPRINTF(fmt, ...) * @brief Debug printf