#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>

static void CDECL dbg_printf(char *fmt,...)
{
	va_list   ap;
	char      *p;
	HWND      h;

	if ( (p=(char *)malloc(16384+4)) == NULL )
		return;
	va_start(ap,fmt);
	vsprintf(p,fmt,ap);
	va_end(ap);
	if ( (h=FindWindow("udbwin","Debug Window")) == 0 )
	{
		WinExec("udbwin.exe",SW_SHOW);
		if ( (h=FindWindow("udbwin","Debug Window")) == 0 )
		{
			free(p);
			MessageBeep(0);
			return;
		}
	}
	PostMessage(h,WM_COMMAND,2345,GlobalAddAtom(p));
	free(p);
}

