-
Notifications
You must be signed in to change notification settings - Fork 1
/
DbgOut.cpp
73 lines (57 loc) · 1.9 KB
/
DbgOut.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/**
* Part of the foobar2000 Matroska plugin
*
* Copyright (C) Jory Stone - 2003
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
*/
#include "DbgOut.h"
#ifdef DEBUG_OUT_PUT
#include <stdio.h>
#include <wchar.h>
#include <stdarg.h>
static DWORD g_dwTimeOffset = timeGetTime();
void WINAPI DbgStringOut(const TCHAR *pFormat,...)
{
TCHAR szInfo[2000];
// Format the variable length parameter list
va_list va;
va_start(va, pFormat);
lstrcpy(szInfo, TEXT("foo_input_matroska - "));
wsprintf(szInfo + lstrlen(szInfo),
TEXT("(tid %x) %8d : "),
GetCurrentThreadId(), timeGetTime() - g_dwTimeOffset);
_vstprintf(szInfo + lstrlen(szInfo), pFormat, va);
lstrcat(szInfo, TEXT("\r\n"));
OutputDebugString(szInfo);
va_end(va);
};
#ifdef UNICODE
void WINAPI DbgLogInfo(const CHAR *pFormat,...)
{
TCHAR szInfo[2000];
// Format the variable length parameter list
va_list va;
va_start(va, pFormat);
lstrcpy(szInfo, TEXT("foo_input_matroska - "));
wsprintf(szInfo + lstrlen(szInfo),
TEXT("(tid %x) %8d : "),
GetCurrentThreadId(), timeGetTime() - g_dwTimeOffset);
CHAR szInfoA[2000];
WideCharToMultiByte(CP_ACP, 0, szInfo, -1, szInfoA, sizeof(szInfoA)/sizeof(CHAR), 0, 0);
wvsprintfA(szInfoA + lstrlenA(szInfoA), pFormat, va);
lstrcatA(szInfoA, "\r\n");
WCHAR wszOutString[2000];
MultiByteToWideChar(CP_ACP, 0, szInfoA, -1, wszOutString, sizeof(wszOutString)/sizeof(WCHAR));
DbgOutString(wszOutString);
va_end(va);
}
#endif
#endif