msvcrt: Fix strtof() error reporting for values out of float range.
[wine.git] / dlls / d3dxof / main.c
blob080545c4387bfd50894e03489d823049d9a5aa89
1 /*
2 * DirectX Files Functions (D3DXOF.DLL)
4 * Copyright 2004 Christian Costa
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <stdarg.h>
22 #include <string.h>
24 #define COBJMACROS
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winuser.h"
29 #include "winreg.h"
30 #include "winerror.h"
32 #include "ole2.h"
33 #include "rpcproxy.h"
34 #include "uuids.h"
36 #include "d3dxof_private.h"
37 #include "dxfile.h"
39 #include "wine/debug.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(d3dxof);
43 /******************************************************************************
44 * DirectX File ClassFactory
46 typedef struct {
47 IClassFactory IClassFactory_iface;
49 LONG ref;
50 HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
51 } IClassFactoryImpl;
53 static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
55 return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
58 struct object_creation_info
60 const CLSID *clsid;
61 HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
64 static const struct object_creation_info object_creation[] =
66 { &CLSID_CDirectXFile, IDirectXFileImpl_Create },
69 static HRESULT WINAPI XFCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid, LPVOID *ppobj)
71 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
73 if (IsEqualGUID(riid, &IID_IUnknown)
74 || IsEqualGUID(riid, &IID_IClassFactory))
76 IClassFactory_AddRef(iface);
77 *ppobj = &This->IClassFactory_iface;
78 return S_OK;
81 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
82 return E_NOINTERFACE;
85 static ULONG WINAPI XFCF_AddRef(LPCLASSFACTORY iface)
87 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
88 return InterlockedIncrement(&This->ref);
91 static ULONG WINAPI XFCF_Release(LPCLASSFACTORY iface)
93 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
95 ULONG ref = InterlockedDecrement(&This->ref);
97 if (ref == 0)
98 HeapFree(GetProcessHeap(), 0, This);
100 return ref;
103 static HRESULT WINAPI XFCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj)
105 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
106 HRESULT hres;
107 LPUNKNOWN punk;
109 TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
111 *ppobj = NULL;
112 hres = This->pfnCreateInstance(pOuter, (LPVOID *) &punk);
113 if (SUCCEEDED(hres)) {
114 hres = IUnknown_QueryInterface(punk, riid, ppobj);
115 IUnknown_Release(punk);
117 return hres;
120 static HRESULT WINAPI XFCF_LockServer(LPCLASSFACTORY iface, BOOL dolock)
122 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
123 FIXME("(%p)->(%d), stub!\n",This,dolock);
124 return S_OK;
127 static const IClassFactoryVtbl XFCF_Vtbl =
129 XFCF_QueryInterface,
130 XFCF_AddRef,
131 XFCF_Release,
132 XFCF_CreateInstance,
133 XFCF_LockServer
136 /***********************************************************************
137 * DirectXFileCreate (D3DXOF.@)
139 HRESULT WINAPI DirectXFileCreate(LPDIRECTXFILE* lplpDirectXFile)
141 HRESULT hr;
143 TRACE("(%p)\n", lplpDirectXFile);
145 if (!lplpDirectXFile)
146 return DXFILEERR_BADVALUE;
148 hr = IDirectXFileImpl_Create(NULL, (LPVOID)lplpDirectXFile);
150 if (FAILED(hr))
151 return DXFILEERR_BADALLOC;
153 return S_OK;
156 /*******************************************************************************
157 * DllGetClassObject [D3DXOF.@]
158 * Retrieves class object from a DLL object
160 * NOTES
161 * Docs say returns STDAPI
163 * PARAMS
164 * rclsid [I] CLSID for the class object
165 * riid [I] Reference to identifier of interface for class object
166 * ppv [O] Address of variable to receive interface pointer for riid
168 * RETURNS
169 * Success: S_OK
170 * Failure: CLASS_E_CLASSNOTAVAILABLE, E_OUTOFMEMORY, E_INVALIDARG,
171 * E_UNEXPECTED
173 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
175 unsigned int i;
176 IClassFactoryImpl *factory;
178 TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
180 if ( !IsEqualGUID( &IID_IClassFactory, riid )
181 && ! IsEqualGUID( &IID_IUnknown, riid) )
182 return E_NOINTERFACE;
184 for (i = 0; i < ARRAY_SIZE(object_creation); i++)
186 if (IsEqualGUID(object_creation[i].clsid, rclsid))
187 break;
190 if (i == ARRAY_SIZE(object_creation))
192 FIXME("%s: no class found.\n", debugstr_guid(rclsid));
193 return CLASS_E_CLASSNOTAVAILABLE;
196 factory = HeapAlloc(GetProcessHeap(), 0, sizeof(*factory));
197 if (factory == NULL) return E_OUTOFMEMORY;
199 factory->IClassFactory_iface.lpVtbl = &XFCF_Vtbl;
200 factory->ref = 1;
202 factory->pfnCreateInstance = object_creation[i].pfnCreateInstance;
204 *ppv = &(factory->IClassFactory_iface);
205 return S_OK;