cmd: Use wide-char string literals.
[wine/zf.git] / dlls / dmscript / dmscript_main.c
blob163dd6718585bfea5ac44a46178437fb1c7e8ee8
1 /* DirectMusicScript Main
3 * Copyright (C) 2003-2004 Rok Mandeljc
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <stdarg.h>
23 #define COBJMACROS
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winnt.h"
28 #include "wingdi.h"
29 #include "winuser.h"
30 #include "winreg.h"
31 #include "objbase.h"
32 #include "rpcproxy.h"
33 #include "initguid.h"
34 #include "dmusici.h"
36 #include "dmscript_private.h"
37 #include "dmobject.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(dmscript);
41 static HINSTANCE instance;
42 LONG DMSCRIPT_refCount = 0;
44 typedef struct {
45 IClassFactory IClassFactory_iface;
46 HRESULT WINAPI (*fnCreateInstance)(REFIID riid, void **ppv, IUnknown *pUnkOuter);
47 } IClassFactoryImpl;
49 static HRESULT WINAPI create_unimpl_instance(REFIID riid, void **ppv, IUnknown *pUnkOuter)
51 FIXME("(%p, %s, %p) stub\n", pUnkOuter, debugstr_dmguid(riid), ppv);
53 return CLASS_E_CLASSNOTAVAILABLE;
56 /******************************************************************
57 * IClassFactory implementation
59 static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
61 return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
64 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
66 if (ppv == NULL)
67 return E_POINTER;
69 if (IsEqualGUID(&IID_IUnknown, riid))
70 TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
71 else if (IsEqualGUID(&IID_IClassFactory, riid))
72 TRACE("(%p)->(IID_IClassFactory %p)\n", iface, ppv);
73 else {
74 FIXME("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
75 *ppv = NULL;
76 return E_NOINTERFACE;
79 *ppv = iface;
80 IUnknown_AddRef((IUnknown*)*ppv);
81 return S_OK;
84 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
86 DMSCRIPT_LockModule();
88 return 2; /* non-heap based object */
91 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
93 DMSCRIPT_UnlockModule();
95 return 1; /* non-heap based object */
98 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pUnkOuter,
99 REFIID riid, void **ppv)
101 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
103 TRACE ("(%p, %s, %p)\n", pUnkOuter, debugstr_dmguid(riid), ppv);
105 return This->fnCreateInstance(riid, ppv, pUnkOuter);
108 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
110 TRACE("(%d)\n", dolock);
112 if (dolock)
113 DMSCRIPT_LockModule();
114 else
115 DMSCRIPT_UnlockModule();
117 return S_OK;
120 static const IClassFactoryVtbl classfactory_vtbl = {
121 ClassFactory_QueryInterface,
122 ClassFactory_AddRef,
123 ClassFactory_Release,
124 ClassFactory_CreateInstance,
125 ClassFactory_LockServer
128 static IClassFactoryImpl ScriptAutoImplSegment_CF = {{&classfactory_vtbl}, create_unimpl_instance};
129 static IClassFactoryImpl ScriptTrack_CF = {{&classfactory_vtbl},
130 DMUSIC_CreateDirectMusicScriptTrack};
131 static IClassFactoryImpl AudioVBScript_CF = {{&classfactory_vtbl}, create_unimpl_instance};
132 static IClassFactoryImpl Script_CF = {{&classfactory_vtbl}, DMUSIC_CreateDirectMusicScriptImpl};
133 static IClassFactoryImpl ScriptAutoImplPerformance_CF = {{&classfactory_vtbl},
134 create_unimpl_instance};
135 static IClassFactoryImpl ScriptSourceCodeLoader_CF = {{&classfactory_vtbl}, create_unimpl_instance};
136 static IClassFactoryImpl ScriptAutoImplSegmentState_CF = {{&classfactory_vtbl},
137 create_unimpl_instance};
138 static IClassFactoryImpl ScriptAutoImplAudioPathConfig_CF = {{&classfactory_vtbl},
139 create_unimpl_instance};
140 static IClassFactoryImpl ScriptAutoImplAudioPath_CF = {{&classfactory_vtbl},
141 create_unimpl_instance};
142 static IClassFactoryImpl ScriptAutoImplSong_CF = {{&classfactory_vtbl}, create_unimpl_instance};
144 /******************************************************************
145 * DllMain
149 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
150 if (fdwReason == DLL_PROCESS_ATTACH) {
151 instance = hinstDLL;
152 DisableThreadLibraryCalls(hinstDLL);
155 return TRUE;
159 /******************************************************************
160 * DllCanUnloadNow (DMSCRIPT.@)
164 HRESULT WINAPI DllCanUnloadNow(void)
166 return DMSCRIPT_refCount != 0 ? S_FALSE : S_OK;
170 /******************************************************************
171 * DllGetClassObject (DMSCRIPT.@)
175 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
177 TRACE("(%s, %s, %p)\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
178 if (IsEqualCLSID (rclsid, &CLSID_DirectMusicScriptAutoImpSegment) && IsEqualIID (riid, &IID_IClassFactory)) {
179 *ppv = &ScriptAutoImplSegment_CF;
180 IClassFactory_AddRef((IClassFactory*)*ppv);
181 return S_OK;
182 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicScriptTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
183 *ppv = &ScriptTrack_CF;
184 IClassFactory_AddRef((IClassFactory*)*ppv);
185 return S_OK;
186 } else if (IsEqualCLSID (rclsid, &CLSID_AudioVBScript) && IsEqualIID (riid, &IID_IClassFactory)) {
187 *ppv = &AudioVBScript_CF;
188 IClassFactory_AddRef((IClassFactory*)*ppv);
189 return S_OK;
190 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicScript) && IsEqualIID (riid, &IID_IClassFactory)) {
191 *ppv = &Script_CF;
192 IClassFactory_AddRef((IClassFactory*)*ppv);
193 return S_OK;
194 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicScriptAutoImpPerformance) && IsEqualIID (riid, &IID_IClassFactory)) {
195 *ppv = &ScriptAutoImplPerformance_CF;
196 IClassFactory_AddRef((IClassFactory*)*ppv);
197 return S_OK;
198 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicScriptSourceCodeLoader) && IsEqualIID (riid, &IID_IClassFactory)) {
199 *ppv = &ScriptSourceCodeLoader_CF;
200 IClassFactory_AddRef((IClassFactory*)*ppv);
201 return S_OK;
202 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicScriptAutoImpSegmentState) && IsEqualIID (riid, &IID_IClassFactory)) {
203 *ppv = &ScriptAutoImplSegmentState_CF;
204 IClassFactory_AddRef((IClassFactory*)*ppv);
205 return S_OK;
206 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicScriptAutoImpAudioPathConfig) && IsEqualIID (riid, &IID_IClassFactory)) {
207 *ppv = &ScriptAutoImplAudioPathConfig_CF;
208 IClassFactory_AddRef((IClassFactory*)*ppv);
209 return S_OK;
210 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicScriptAutoImpAudioPath) && IsEqualIID (riid, &IID_IClassFactory)) {
211 *ppv = &ScriptAutoImplAudioPath_CF;
212 IClassFactory_AddRef((IClassFactory*)*ppv);
213 return S_OK;
214 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicScriptAutoImpSong) && IsEqualIID (riid, &IID_IClassFactory)) {
215 *ppv = &ScriptAutoImplSong_CF;
216 IClassFactory_AddRef((IClassFactory*)*ppv);
217 return S_OK;
220 WARN("(%s, %s, %p): no interface found.\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
221 return CLASS_E_CLASSNOTAVAILABLE;
225 /***********************************************************************
226 * DllRegisterServer (DMSCRIPT.@)
228 HRESULT WINAPI DllRegisterServer(void)
230 return __wine_register_resources( instance );
233 /***********************************************************************
234 * DllUnregisterServer (DMSCRIPT.@)
236 HRESULT WINAPI DllUnregisterServer(void)
238 return __wine_unregister_resources( instance );