From 5e742f04e3d2cdd91d635207b8054d75e78f9eb6 Mon Sep 17 00:00:00 2001 From: Marcelo Roberto Jimenez Date: Fri, 25 Apr 2008 13:32:05 +0000 Subject: [PATCH] Added thread id's to the UpnpPrintf debug messages. git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@350 119443c7-1b9e-41f8-b6fc-b9c35fce742c --- ChangeLog | 4 ++++ THANKS | 1 + upnp/src/api/upnpdebug.c | 33 +++++++++++++++++++++++---------- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 30aedb6..ecdb408 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,10 @@ Version 1.6.6 ******************************************************************************* +2008-04-24 Marcelo Jimenez + * Added thread id's to the UpnpPrintf debug messages. Thanks to + Charles Nepveu for the idea. + 2008-04-24 Marcelo Jimenez * SF Bug Tracker [ 1948586 ] Uppercase U in in "xmlns:U" in Invoke Action causes seg. f. diff --git a/THANKS b/THANKS index 0e8eb0c..a917e4f 100644 --- a/THANKS +++ b/THANKS @@ -12,6 +12,7 @@ exempt of errors. - Arno Willig - Bob Ciora - Chaos +- Charles Nepveu (cnepveu) - Chris Pickel - Craig Nelson - David Maass diff --git a/upnp/src/api/upnpdebug.c b/upnp/src/api/upnpdebug.c index 25f01d6..d2f0fab 100644 --- a/upnp/src/api/upnpdebug.c +++ b/upnp/src/api/upnpdebug.c @@ -310,17 +310,30 @@ void UpnpDisplayFileAndLine( IN const char *DbgFileName, IN int DbgLineNo) { - int starlength = 66; - const char *lines[2]; - char FileAndLine[500]; - lines[0] = "DEBUG"; - if (DbgFileName) { - sprintf(FileAndLine, - "FILE: %s, LINE: %d", - DbgFileName, DbgLineNo); - lines[1] = FileAndLine; +#define NLINES 2 +#define MAX_LINE_SIZE 512 +#define NUMBER_OF_STARS 80 + const char *lines[NLINES]; + char buf[NLINES][MAX_LINE_SIZE]; + int i; + + /* Initialize the pointer array */ + for (i = 0; i < NLINES; i++) { + lines[i] = buf[i]; } - UpnpDisplayBanner(fd, lines, 2, starlength); + + /* Put the debug lines in the buffer */ + sprintf(buf[0], "DEBUG - THREAD ID: 0x%lX", + (unsigned long int)ithread_self()); + if (DbgFileName) { + sprintf(buf[1], + "FILE: %s, LINE: %d", + DbgFileName, + DbgLineNo); + } + + /* Show the lines centered */ + UpnpDisplayBanner(fd, lines, NLINES, NUMBER_OF_STARS); fflush(fd); } #endif