Free the debug info when making a critical section global.
[wine] / dlls / dmscript / dmscript_main.c
1 /* DirectMusicScript Main
2  *
3  * Copyright (C) 2003 Rok Mandeljc
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
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
13  * GNU Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  */
19
20 #include "dmscript_private.h"
21
22 WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
23
24
25 /******************************************************************
26  *              DirectMusicScript ClassFactory
27  *
28  *
29  */
30  
31 typedef struct
32 {
33     /* IUnknown fields */
34     ICOM_VFIELD(IClassFactory);
35     DWORD                       ref;
36 } IClassFactoryImpl;
37
38 static HRESULT WINAPI DMSCRCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
39 {
40         ICOM_THIS(IClassFactoryImpl,iface);
41
42         FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
43         return E_NOINTERFACE;
44 }
45
46 static ULONG WINAPI DMSCRCF_AddRef(LPCLASSFACTORY iface)
47 {
48         ICOM_THIS(IClassFactoryImpl,iface);
49         return ++(This->ref);
50 }
51
52 static ULONG WINAPI DMSCRCF_Release(LPCLASSFACTORY iface)
53 {
54         ICOM_THIS(IClassFactoryImpl,iface);
55         /* static class, won't be  freed */
56         return --(This->ref);
57 }
58
59 static HRESULT WINAPI DMSCRCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj)
60 {
61         ICOM_THIS(IClassFactoryImpl,iface);
62
63         TRACE ("(%p)->(%p,%s,%p)\n", This, pOuter, debugstr_guid(riid), ppobj);
64         if (IsEqualGUID (riid, &IID_IDirectMusicScript)) {
65                 return DMUSIC_CreateDirectMusicScript (riid, (LPDIRECTMUSICSCRIPT*)ppobj, pOuter);
66         }
67         WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
68         return E_NOINTERFACE;
69 }
70
71 static HRESULT WINAPI DMSCRCF_LockServer(LPCLASSFACTORY iface,BOOL dolock)
72 {
73         ICOM_THIS(IClassFactoryImpl,iface);
74         FIXME("(%p)->(%d),stub!\n", This, dolock);
75         return S_OK;
76 }
77
78 static ICOM_VTABLE(IClassFactory) DMSCRCF_Vtbl = {
79         ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
80         DMSCRCF_QueryInterface,
81         DMSCRCF_AddRef,
82         DMSCRCF_Release,
83         DMSCRCF_CreateInstance,
84         DMSCRCF_LockServer
85 };
86
87 static IClassFactoryImpl DMSCRIPT_CF = {&DMSCRCF_Vtbl, 1 };
88
89 /******************************************************************
90  *              DllMain
91  *
92  *
93  */
94 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
95 {
96         if (fdwReason == DLL_PROCESS_ATTACH)
97         {
98             DisableThreadLibraryCalls(hinstDLL);
99                 /* FIXME: Initialisation */
100         }
101         else if (fdwReason == DLL_PROCESS_DETACH)
102         {
103                 /* FIXME: Cleanup */
104         }
105
106         return TRUE;
107 }
108
109
110 /******************************************************************
111  *              DllCanUnloadNow (DMSCRIPT.1)
112  *
113  *
114  */
115 HRESULT WINAPI DMSCRIPT_DllCanUnloadNow(void)
116 {
117     FIXME("(void): stub\n");
118
119     return S_FALSE;
120 }
121
122
123 /******************************************************************
124  *              DllGetClassObject (DMSCRIPT.2)
125  *
126  *
127  */
128 HRESULT WINAPI DMSCRIPT_DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
129 {
130     TRACE("(%p,%p,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
131     if (IsEqualCLSID (&IID_IClassFactory, riid)) {
132       *ppv = (LPVOID) &DMSCRIPT_CF;
133       IClassFactory_AddRef((IClassFactory*)*ppv);
134       return S_OK;
135     }
136     WARN("(%p,%p,%p): no interface found.\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
137     return CLASS_E_CLASSNOTAVAILABLE;
138 }