ReactOS  0.4.13-dev-1158-g658d5a3
statuscode.c
Go to the documentation of this file.
1 /*
2  * Copyright 2009 Hans Leidekker for CodeWeavers
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18 
19 #define COBJMACROS
20 
21 #include "config.h"
22 #include <stdarg.h>
23 #include <stdio.h>
24 
25 #include "windef.h"
26 #include "winbase.h"
27 #include "ole2.h"
28 #include "wbemcli.h"
29 
30 #include "wine/debug.h"
31 #include "wine/unicode.h"
32 #include "wmiutils_private.h"
33 
35 
36 typedef struct status_code
37 {
40 } status_code;
41 
43 {
44  return CONTAINING_RECORD(iface, status_code, IWbemStatusCodeText_iface);
45 }
46 
48  IWbemStatusCodeText *iface )
49 {
52 }
53 
55  IWbemStatusCodeText *iface )
56 {
59  if (!refs)
60  {
61  TRACE("destroying %p\n", status_code);
63  }
64  return refs;
65 }
66 
68  IWbemStatusCodeText *iface,
69  REFIID riid,
70  void **ppvObject )
71 {
73 
74  TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
75 
76  if ( IsEqualGUID( riid, &IID_IWbemStatusCodeText ) ||
78  {
79  *ppvObject = iface;
80  }
81  else
82  {
83  FIXME("interface %s not implemented\n", debugstr_guid(riid));
84  return E_NOINTERFACE;
85  }
86  IWbemStatusCodeText_AddRef( iface );
87  return S_OK;
88 }
89 
91  IWbemStatusCodeText *iface,
92  HRESULT res,
93  LCID lcid,
94  LONG flags,
95  BSTR *text )
96 {
97  static const WCHAR fmt[] =
98  {'E','r','r','o','r',' ','c','o','d','e',':',' ','0','x','%','0','8','x',0};
99  WCHAR msg[32];
100 
101  FIXME("%p, 0x%08x, 0x%04x, 0x%08x, %p\n", iface, res, lcid, flags, text);
102 
103  sprintfW(msg, fmt, res);
104  *text = SysAllocString(msg);
105  return WBEM_S_NO_ERROR;
106 }
107 
109  IWbemStatusCodeText *iface,
110  HRESULT res,
111  LCID lcid,
112  LONG flags,
113  BSTR *text )
114 {
115  static const WCHAR fmt[] =
116  {'F','a','c','i','l','i','t','y',' ','c','o','d','e',':',' ','0','x','%','0','8','x',0};
117  WCHAR msg[32];
118 
119  FIXME("%p, 0x%08x, 0x%04x, 0x%08x, %p\n", iface, res, lcid, flags, text);
120 
121  sprintfW(msg, fmt, res);
122  *text = SysAllocString(msg);
123  return WBEM_S_NO_ERROR;
124 }
125 
126 static const struct IWbemStatusCodeTextVtbl status_code_vtbl =
127 {
133 };
134 
136 {
137  status_code *sc;
138 
139  TRACE("(%p)\n", ppObj);
140 
141  if (!(sc = heap_alloc( sizeof(*sc) ))) return E_OUTOFMEMORY;
142 
144  sc->refs = 1;
145 
146  *ppObj = &sc->IWbemStatusCodeText_iface;
147 
148  TRACE("returning iface %p\n", *ppObj);
149  return S_OK;
150 }
#define REFIID
Definition: guiddef.h:118
#define E_NOINTERFACE
Definition: winerror.h:2364
static ULONG WINAPI status_code_Release(IWbemStatusCodeText *iface)
Definition: statuscode.c:54
WINE_DEFAULT_DEBUG_CHANNEL(wmiutils)
REFIID riid
Definition: precomp.h:44
const WCHAR * text
Definition: package.c:1827
DWORD LCID
Definition: nls.h:13
OLECHAR * BSTR
Definition: compat.h:1934
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
struct status_code status_code
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
long LONG
Definition: pedump.c:60
#define FIXME(fmt,...)
Definition: debug.h:110
HRESULT WbemStatusCodeText_create(LPVOID *ppObj)
Definition: statuscode.c:135
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:241
static ULONG WINAPI status_code_AddRef(IWbemStatusCodeText *iface)
Definition: statuscode.c:47
static HRESULT WINAPI status_code_GetFacilityCodeText(IWbemStatusCodeText *iface, HRESULT res, LCID lcid, LONG flags, BSTR *text)
Definition: statuscode.c:108
#define debugstr_guid
Definition: kernel32.h:35
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
static const struct IWbemStatusCodeTextVtbl status_code_vtbl
Definition: statuscode.c:126
static HRESULT WINAPI status_code_GetErrorCodeText(IWbemStatusCodeText *iface, HRESULT res, LCID lcid, LONG flags, BSTR *text)
Definition: statuscode.c:90
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
const GUID IID_IUnknown
#define WINAPI
Definition: msvc.h:8
GLbitfield flags
Definition: glext.h:7161
static status_code * impl_from_IWbemStatusCodeText(IWbemStatusCodeText *iface)
Definition: statuscode.c:42
#define InterlockedDecrement
Definition: armddk.h:52
REFIID LPVOID * ppvObject
Definition: precomp.h:44
#define S_OK
Definition: intsafe.h:59
#define InterlockedIncrement
Definition: armddk.h:53
#define sprintfW
Definition: unicode.h:58
static HRESULT WINAPI status_code_QueryInterface(IWbemStatusCodeText *iface, REFIID riid, void **ppvObject)
Definition: statuscode.c:67
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4021
#define msg(x)
Definition: auth_time.c:54
GLuint res
Definition: glext.h:9613
unsigned int ULONG
Definition: retypes.h:1
Definition: dsound.c:943
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
IWbemStatusCodeText IWbemStatusCodeText_iface
Definition: statuscode.c:38