Added YUV routines needed for v4l driver, and in the future possibly
[wine/gsoc-2012-control.git] / dlls / dxerr8 / dxerr8.c
bloba5ededcba4c23a5396038d02168648b7bdfcfdd7
1 /*
2 * DirectX 8 error routines
4 * Copyright 2004 Robert Reif
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * TODO:
23 * Add error codes for D3D8, D3DX8, DDRAW, DPLAY8, DMUSIC, DINPUT and DSHOW.
24 * Sort list for faster lookup.
27 #include <stdarg.h>
28 #include <stdio.h>
30 #define COM_NO_WINDOWS_H
31 #include "windef.h"
32 #include "winbase.h"
33 #include "wingdi.h"
34 #include "winuser.h"
35 #include "winnls.h"
37 #include "mmsystem.h"
38 #include "dsound.h"
40 #include "dxerr8.h"
42 #include "wine/debug.h"
44 WINE_DEFAULT_DEBUG_CHANNEL(dxerr);
46 typedef struct {
47 HRESULT hr;
48 const CHAR* resultA;
49 const WCHAR* resultW;
50 const CHAR* descriptionA;
51 const WCHAR* descriptionW;
52 } error_info;
54 #include "errors.h"
56 const char * WINAPI DXGetErrorString8A(HRESULT hr)
58 unsigned int i;
59 TRACE("(0x%08lx)\n", hr);
61 for (i = 0; i < sizeof(info)/sizeof(info[0]); i++) {
62 if (hr == info[i].hr)
63 return info[i].resultA;
66 return "Unknown";
69 const WCHAR * WINAPI DXGetErrorString8W(HRESULT hr)
71 static const WCHAR unknown[] = { 'U', 'n', 'k', 'n', 'o', 'w', 'n', 0 };
72 unsigned int i;
73 TRACE("(0x%08lx)\n", hr);
75 for (i = 0; i < sizeof(info)/sizeof(info[0]); i++) {
76 if (hr == info[i].hr) {
77 return info[i].resultW;
81 return unknown;
84 const char * WINAPI DXGetErrorDescription8A(HRESULT hr)
86 unsigned int i;
87 TRACE("(0x%08lx)\n", hr);
89 for (i = 0; i < sizeof(info)/sizeof(info[0]); i++) {
90 if (hr == info[i].hr)
91 return info[i].descriptionA;
94 return "n/a";
97 const WCHAR * WINAPI DXGetErrorDescription8W(HRESULT hr)
99 static const WCHAR na[] = { 'n', '/', 'a', 0 };
100 unsigned int i;
101 TRACE("(0x%08lx)\n", hr);
103 for (i = 0; i < sizeof(info)/sizeof(info[0]); i++) {
104 if (hr == info[i].hr) {
105 return info[i].descriptionW;
109 return na;
112 HRESULT WINAPI DXTraceA(const char* strFile, DWORD dwLine, HRESULT hr, const char* strMsg, BOOL bPopMsgBox)
114 char msg[1024];
115 TRACE("(%p,%ld,0x%08lx,%p,%d)\n", strFile, dwLine, hr, strMsg, bPopMsgBox);
117 if (bPopMsgBox) {
118 snprintf(msg, sizeof(msg), "File: %s\nLine: %ld\nError Code: %s (0x%08lx)\nCalling: %s",
119 strFile, dwLine, DXGetErrorString8A(hr), hr, strMsg);
120 MessageBoxA(0, msg, "Unexpected error encountered", MB_OK|MB_ICONERROR);
121 } else {
122 snprintf(msg, sizeof(msg), "%s(%ld): %s (hr=%s (0x%08lx))", strFile,
123 dwLine, strMsg, DXGetErrorString8A(hr), hr);
124 OutputDebugStringA(msg);
127 return hr;
130 HRESULT WINAPI DXTraceW(const char* strFile, DWORD dwLine, HRESULT hr, const WCHAR* strMsg, BOOL bPopMsgBox)
132 WCHAR msg[1024];
133 TRACE("(%p,%ld,0x%08lx,%p,%d)\n", strFile, dwLine, hr, strMsg, bPopMsgBox);
135 if (bPopMsgBox) {
136 static const WCHAR format[] = { 'F','i','l','e',':',' ','%','s','\\','n','L','i','n',
137 'e',':',' ','%','l','d','\\','n','E','r','r','o','r',' ','C','o',
138 'd','e',':',' ','%','s',' ','(','0','x','%','0','8','l','x',')',
139 '\\','n','C','a','l','l','i','n','g',':',' ','%','s',0 };
140 static const WCHAR caption[] = { 'U','n','e','x','p','e','c','t','e','d',' ','e','r',
141 'r','o','r',' ','e','n','c','o','u','n','t','e','r','e','d',0 };
142 /* FIXME: should use wsnprintf */
143 wsprintfW(msg, format, strFile, dwLine,
144 DXGetErrorString8W(hr), hr, strMsg);
145 MessageBoxW(0, msg, caption, MB_OK|MB_ICONERROR);
146 } else {
147 static const WCHAR format[] = { '%','s','(','%','l','d',')',':',' ','%','s',' ','(',
148 'h','r','=','%','s',' ','(','0','x','%','0','8','l','x',')',')',' ',
149 0 };
150 /* FIXME: should use wsnprintf */
151 wsprintfW(msg, format, strFile, dwLine, strMsg,
152 DXGetErrorString8W(hr), hr);
153 OutputDebugStringW(msg);
156 return hr;