2005-01-18 14:18:51 +02:00
|
|
|
#ifdef DEBUGP
|
|
|
|
#undef DEBUGP
|
|
|
|
#endif
|
2004-12-23 15:16:30 +02:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
#include <cstdio>
|
2005-01-18 14:18:51 +02:00
|
|
|
#ifdef WIN32
|
|
|
|
#include <cstring>
|
|
|
|
#endif
|
2004-12-23 15:16:30 +02:00
|
|
|
#else
|
|
|
|
#include <stdio.h>
|
2005-01-18 14:18:51 +02:00
|
|
|
#ifdef WIN32
|
|
|
|
#include <string.h>
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2005-01-27 15:01:45 +02:00
|
|
|
#ifndef __GNUC__
|
2005-01-18 14:18:51 +02:00
|
|
|
#ifndef __DEBUG_H__
|
|
|
|
#define __DEBUG_H__
|
|
|
|
#include <stdarg.h>
|
|
|
|
static void debugprintf(const char *format, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
char *f = NULL;
|
|
|
|
const char *p="%s:%d ";
|
|
|
|
size_t plen = strlen(p);
|
|
|
|
va_start(ap, format);
|
|
|
|
f = (char *)malloc(plen + strlen(format) + 1);
|
|
|
|
if (!f) return;
|
|
|
|
memcpy(f, p, plen);
|
|
|
|
memcpy(f + plen, format, strlen(format) + 1);
|
|
|
|
vfprintf(stderr, f, ap);
|
|
|
|
va_end(ap);
|
|
|
|
free(f);
|
|
|
|
}
|
|
|
|
static void dummyprintf(const char *format, ...)
|
|
|
|
{}
|
|
|
|
#endif
|
2004-12-23 15:16:30 +02:00
|
|
|
#endif
|
2005-01-18 14:18:51 +02:00
|
|
|
|
2004-12-23 15:16:30 +02:00
|
|
|
#ifdef DEBUG
|
2005-01-27 15:01:45 +02:00
|
|
|
#ifndef __GNUC__
|
2005-01-18 14:18:51 +02:00
|
|
|
#define DEBUGP debugprintf
|
|
|
|
#else
|
2004-12-23 15:16:30 +02:00
|
|
|
#define DEBUGP(args...) do { fprintf(stderr, "%s:%d ", __FILE__, __LINE__); fprintf(stderr, ## args); } while(0)
|
2005-01-18 14:18:51 +02:00
|
|
|
#endif
|
|
|
|
#else
|
2005-01-27 15:01:45 +02:00
|
|
|
#ifndef __GNUC__
|
2005-01-18 14:18:51 +02:00
|
|
|
#define DEBUGP dummyprintf
|
2004-12-23 15:16:30 +02:00
|
|
|
#else
|
|
|
|
#define DEBUGP(args...)
|
|
|
|
#endif
|
|
|
|
#endif
|