shell32: Add the Serbian (Cyrillic) translation.
[wine] / dlls / dmscript / dmscript_main.c
1 /* DirectMusicScript Main
2  *
3  * Copyright (C) 2003-2004 Rok Mandeljc
4  *
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.
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 GNU
13  * Lesser General Public License for more details.
14  *
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
18  */
19
20 #include "config.h"
21 #include "wine/port.h"
22
23 #include "dmscript_private.h"
24
25 WINE_DEFAULT_DEBUG_CHANNEL(dmscript);
26
27 LONG DMSCRIPT_refCount = 0;
28
29 typedef struct {
30     const IClassFactoryVtbl *lpVtbl;
31 } IClassFactoryImpl;
32
33 /******************************************************************
34  *              DirectMusicScriptAutoImplSegment ClassFactory
35  */
36 static HRESULT WINAPI ScriptAutoImplSegmentCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
37         FIXME("- no interface IID: %s\n", debugstr_guid(riid));
38
39         if (ppobj == NULL) return E_POINTER;
40         
41         return E_NOINTERFACE;
42 }
43
44 static ULONG WINAPI ScriptAutoImplSegmentCF_AddRef(LPCLASSFACTORY iface) {
45         DMSCRIPT_LockModule();
46
47         return 2; /* non-heap based object */
48 }
49
50 static ULONG WINAPI ScriptAutoImplSegmentCF_Release(LPCLASSFACTORY iface) {
51         DMSCRIPT_UnlockModule();
52
53         return 1; /* non-heap based object */
54 }
55
56 static HRESULT WINAPI ScriptAutoImplSegmentCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
57         FIXME("- no interface IID: %s\n", debugstr_guid(riid));
58
59         if (ppobj == NULL) return E_POINTER;
60         
61         return E_NOINTERFACE;
62 }
63
64 static HRESULT WINAPI ScriptAutoImplSegmentCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
65         TRACE("(%d)\n", dolock);
66
67         if (dolock)
68                 DMSCRIPT_LockModule();
69         else
70                 DMSCRIPT_UnlockModule();
71         
72         return S_OK;
73 }
74
75 static const IClassFactoryVtbl ScriptAutoImplSegmentCF_Vtbl = {
76         ScriptAutoImplSegmentCF_QueryInterface,
77         ScriptAutoImplSegmentCF_AddRef,
78         ScriptAutoImplSegmentCF_Release,
79         ScriptAutoImplSegmentCF_CreateInstance,
80         ScriptAutoImplSegmentCF_LockServer
81 };
82
83 static IClassFactoryImpl ScriptAutoImplSegment_CF = {&ScriptAutoImplSegmentCF_Vtbl};
84
85 /******************************************************************
86  *              DirectMusicScriptTrack ClassFactory
87  */
88 static HRESULT WINAPI ScriptTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
89         FIXME("- no interface IID: %s\n", debugstr_guid(riid));
90
91         if (ppobj == NULL) return E_POINTER;
92         
93         return E_NOINTERFACE;
94 }
95
96 static ULONG WINAPI ScriptTrackCF_AddRef(LPCLASSFACTORY iface) {
97         DMSCRIPT_LockModule();
98
99         return 2; /* non-heap based object */
100 }
101
102 static ULONG WINAPI ScriptTrackCF_Release(LPCLASSFACTORY iface) {
103         DMSCRIPT_UnlockModule();
104
105         return 1; /* non-heap based object */
106 }
107
108 static HRESULT WINAPI ScriptTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
109         TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);
110         return DMUSIC_CreateDirectMusicScriptTrack (riid, ppobj, pOuter);
111 }
112
113 static HRESULT WINAPI ScriptTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
114         TRACE("(%d)\n", dolock);
115
116         if (dolock)
117                 DMSCRIPT_LockModule();
118         else
119                 DMSCRIPT_UnlockModule();
120         
121         return S_OK;
122 }
123
124 static const IClassFactoryVtbl ScriptTrackCF_Vtbl = {
125         ScriptTrackCF_QueryInterface,
126         ScriptTrackCF_AddRef,
127         ScriptTrackCF_Release,
128         ScriptTrackCF_CreateInstance,
129         ScriptTrackCF_LockServer
130 };
131
132 static IClassFactoryImpl ScriptTrack_CF = {&ScriptTrackCF_Vtbl};
133
134 /******************************************************************
135  *              DirectMusicAudioVBScript ClassFactory
136  */
137 static HRESULT WINAPI AudioVBScriptCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
138         FIXME("- no interface IID: %s\n", debugstr_guid(riid));
139
140         if (ppobj == NULL) return E_POINTER;
141         
142         return E_NOINTERFACE;
143 }
144
145 static ULONG WINAPI AudioVBScriptCF_AddRef(LPCLASSFACTORY iface) {
146         DMSCRIPT_LockModule();
147
148         return 2; /* non-heap based object */
149 }
150
151 static ULONG WINAPI AudioVBScriptCF_Release(LPCLASSFACTORY iface) {
152         DMSCRIPT_UnlockModule();
153
154         return 1; /* non-heap based object */
155 }
156
157 static HRESULT WINAPI AudioVBScriptCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
158         FIXME("- no interface IID: %s\n", debugstr_guid(riid));
159
160         if (ppobj == NULL) return E_POINTER;
161         
162         return E_NOINTERFACE;
163 }
164
165 static HRESULT WINAPI AudioVBScriptCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
166         TRACE("(%d)\n", dolock);
167
168         if (dolock)
169                 DMSCRIPT_LockModule();
170         else
171                 DMSCRIPT_UnlockModule();
172         
173         return S_OK;
174 }
175
176 static const IClassFactoryVtbl AudioVBScriptCF_Vtbl = {
177         AudioVBScriptCF_QueryInterface,
178         AudioVBScriptCF_AddRef,
179         AudioVBScriptCF_Release,
180         AudioVBScriptCF_CreateInstance,
181         AudioVBScriptCF_LockServer
182 };
183
184 static IClassFactoryImpl AudioVBScript_CF = {&AudioVBScriptCF_Vtbl};
185
186 /******************************************************************
187  *              DirectMusicScript ClassFactory
188  */
189 static HRESULT WINAPI ScriptCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
190         FIXME("- no interface IID: %s\n", debugstr_guid(riid));
191
192         if (ppobj == NULL) return E_POINTER;
193         
194         return E_NOINTERFACE;
195 }
196
197 static ULONG WINAPI ScriptCF_AddRef(LPCLASSFACTORY iface) {
198         DMSCRIPT_LockModule();
199
200         return 2; /* non-heap based object */
201 }
202
203 static ULONG WINAPI ScriptCF_Release(LPCLASSFACTORY iface) {
204         DMSCRIPT_UnlockModule();
205
206         return 1; /* non-heap based object */
207 }
208
209 static HRESULT WINAPI ScriptCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
210         TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);
211         
212         return DMUSIC_CreateDirectMusicScriptImpl (riid, ppobj, pOuter);
213 }
214
215 static HRESULT WINAPI ScriptCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
216         TRACE("(%d)\n", dolock);
217
218         if (dolock)
219                 DMSCRIPT_LockModule();
220         else
221                 DMSCRIPT_UnlockModule();
222         
223         return S_OK;
224 }
225
226 static const IClassFactoryVtbl ScriptCF_Vtbl = {
227         ScriptCF_QueryInterface,
228         ScriptCF_AddRef,
229         ScriptCF_Release,
230         ScriptCF_CreateInstance,
231         ScriptCF_LockServer
232 };
233
234 static IClassFactoryImpl Script_CF = {&ScriptCF_Vtbl};
235
236 /******************************************************************
237  *              DirectMusicScriptAutoImplPerformance ClassFactory
238  */
239 static HRESULT WINAPI ScriptAutoImplPerformanceCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
240         FIXME("- no interface IID: %s\n", debugstr_guid(riid));
241
242         if (ppobj == NULL) return E_POINTER;
243         
244         return E_NOINTERFACE;
245 }
246
247 static ULONG WINAPI ScriptAutoImplPerformanceCF_AddRef(LPCLASSFACTORY iface) {
248         DMSCRIPT_LockModule();
249
250         return 2; /* non-heap based object */
251 }
252
253 static ULONG WINAPI ScriptAutoImplPerformanceCF_Release(LPCLASSFACTORY iface) {
254         DMSCRIPT_UnlockModule();
255
256         return 1; /* non-heap based object */
257 }
258
259 static HRESULT WINAPI ScriptAutoImplPerformanceCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
260         FIXME("- no interface IID: %s\n", debugstr_guid(riid));
261
262         if (ppobj == NULL) return E_POINTER;
263         
264         return E_NOINTERFACE;
265 }
266
267 static HRESULT WINAPI ScriptAutoImplPerformanceCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
268         TRACE("(%d)\n", dolock);
269
270         if (dolock)
271                 DMSCRIPT_LockModule();
272         else
273                 DMSCRIPT_UnlockModule();
274         
275         return S_OK;
276 }
277
278 static const IClassFactoryVtbl ScriptAutoImplPerformanceCF_Vtbl = {
279         ScriptAutoImplPerformanceCF_QueryInterface,
280         ScriptAutoImplPerformanceCF_AddRef,
281         ScriptAutoImplPerformanceCF_Release,
282         ScriptAutoImplPerformanceCF_CreateInstance,
283         ScriptAutoImplPerformanceCF_LockServer
284 };
285
286 static IClassFactoryImpl ScriptAutoImplPerformance_CF = {&ScriptAutoImplPerformanceCF_Vtbl};
287
288 /******************************************************************
289  *              DirectMusicScriptSourceCodeLoader ClassFactory
290  */
291 static HRESULT WINAPI ScriptSourceCodeLoaderCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
292         FIXME("- no interface IID: %s\n", debugstr_guid(riid));
293
294         if (ppobj == NULL) return E_POINTER;
295         
296         return E_NOINTERFACE;
297 }
298
299 static ULONG WINAPI ScriptSourceCodeLoaderCF_AddRef(LPCLASSFACTORY iface) {
300         DMSCRIPT_LockModule();
301
302         return 2; /* non-heap based object */
303 }
304
305 static ULONG WINAPI ScriptSourceCodeLoaderCF_Release(LPCLASSFACTORY iface) {
306         DMSCRIPT_UnlockModule();
307
308         return 1; /* non-heap based object */
309 }
310
311 static HRESULT WINAPI ScriptSourceCodeLoaderCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
312         FIXME("- no interface IID: %s\n", debugstr_guid(riid));
313
314         if (ppobj == NULL) return E_POINTER;
315         
316         return E_NOINTERFACE;
317 }
318
319 static HRESULT WINAPI ScriptSourceCodeLoaderCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
320         TRACE("(%d)\n", dolock);
321
322         if (dolock)
323                 DMSCRIPT_LockModule();
324         else
325                 DMSCRIPT_UnlockModule();
326         
327         return S_OK;
328 }
329
330 static const IClassFactoryVtbl ScriptSourceCodeLoaderCF_Vtbl = {
331         ScriptSourceCodeLoaderCF_QueryInterface,
332         ScriptSourceCodeLoaderCF_AddRef,
333         ScriptSourceCodeLoaderCF_Release,
334         ScriptSourceCodeLoaderCF_CreateInstance,
335         ScriptSourceCodeLoaderCF_LockServer
336 };
337
338 static IClassFactoryImpl ScriptSourceCodeLoader_CF = {&ScriptSourceCodeLoaderCF_Vtbl};
339
340 /******************************************************************
341  *              DirectMusicScriptAutoImplSegmentState ClassFactory
342  */
343 static HRESULT WINAPI ScriptAutoImplSegmentStateCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
344         FIXME("- no interface IID: %s\n", debugstr_guid(riid));
345
346         if (ppobj == NULL) return E_POINTER;
347         
348         return E_NOINTERFACE;
349 }
350
351 static ULONG WINAPI ScriptAutoImplSegmentStateCF_AddRef(LPCLASSFACTORY iface) {
352         DMSCRIPT_LockModule();
353
354         return 2; /* non-heap based object */
355 }
356
357 static ULONG WINAPI ScriptAutoImplSegmentStateCF_Release(LPCLASSFACTORY iface) {
358         DMSCRIPT_UnlockModule();
359
360         return 1; /* non-heap based object */
361 }
362
363 static HRESULT WINAPI ScriptAutoImplSegmentStateCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
364         FIXME("- no interface IID: %s\n", debugstr_guid(riid));
365
366         if (ppobj == NULL) return E_POINTER;
367         
368         return E_NOINTERFACE;
369 }
370
371 static HRESULT WINAPI ScriptAutoImplSegmentStateCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
372         TRACE("(%d)\n", dolock);
373
374         if (dolock)
375                 DMSCRIPT_LockModule();
376         else
377                 DMSCRIPT_UnlockModule();
378         
379         return S_OK;
380 }
381
382 static const IClassFactoryVtbl ScriptAutoImplSegmentStateCF_Vtbl = {
383         ScriptAutoImplSegmentStateCF_QueryInterface,
384         ScriptAutoImplSegmentStateCF_AddRef,
385         ScriptAutoImplSegmentStateCF_Release,
386         ScriptAutoImplSegmentStateCF_CreateInstance,
387         ScriptAutoImplSegmentStateCF_LockServer
388 };
389
390 static IClassFactoryImpl ScriptAutoImplSegmentState_CF = {&ScriptAutoImplSegmentStateCF_Vtbl};
391
392 /******************************************************************
393  *              DirectMusicScriptAutoImplAudioPathConfig ClassFactory
394  */
395 static HRESULT WINAPI ScriptAutoImplAudioPathConfigCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
396         FIXME("- no interface IID: %s\n", debugstr_guid(riid));
397
398         if (ppobj == NULL) return E_POINTER;
399         
400         return E_NOINTERFACE;
401 }
402
403 static ULONG WINAPI ScriptAutoImplAudioPathConfigCF_AddRef(LPCLASSFACTORY iface) {
404         DMSCRIPT_LockModule();
405
406         return 2; /* non-heap based object */
407 }
408
409 static ULONG WINAPI ScriptAutoImplAudioPathConfigCF_Release(LPCLASSFACTORY iface) {
410         DMSCRIPT_UnlockModule();
411
412         return 1; /* non-heap based object */
413 }
414
415 static HRESULT WINAPI ScriptAutoImplAudioPathConfigCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
416         FIXME("- no interface IID: %s\n", debugstr_guid(riid));
417
418         if (ppobj == NULL) return E_POINTER;
419         
420         return E_NOINTERFACE;
421 }
422
423 static HRESULT WINAPI ScriptAutoImplAudioPathConfigCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
424         TRACE("(%d)\n", dolock);
425
426         if (dolock)
427                 DMSCRIPT_LockModule();
428         else
429                 DMSCRIPT_UnlockModule();
430         
431         return S_OK;
432 }
433
434 static const IClassFactoryVtbl ScriptAutoImplAudioPathConfigCF_Vtbl = {
435         ScriptAutoImplAudioPathConfigCF_QueryInterface,
436         ScriptAutoImplAudioPathConfigCF_AddRef,
437         ScriptAutoImplAudioPathConfigCF_Release,
438         ScriptAutoImplAudioPathConfigCF_CreateInstance,
439         ScriptAutoImplAudioPathConfigCF_LockServer
440 };
441
442 static IClassFactoryImpl ScriptAutoImplAudioPathConfig_CF = {&ScriptAutoImplAudioPathConfigCF_Vtbl};
443
444 /******************************************************************
445  *              DirectMusicScriptAutoImplAudioPath ClassFactory
446  */
447 static HRESULT WINAPI ScriptAutoImplAudioPathCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
448         FIXME("- no interface IID: %s\n", debugstr_guid(riid));
449
450         if (ppobj == NULL) return E_POINTER;
451         
452         return E_NOINTERFACE;
453 }
454
455 static ULONG WINAPI ScriptAutoImplAudioPathCF_AddRef(LPCLASSFACTORY iface) {
456         DMSCRIPT_LockModule();
457
458         return 2; /* non-heap based object */
459 }
460
461 static ULONG WINAPI ScriptAutoImplAudioPathCF_Release(LPCLASSFACTORY iface) {
462         DMSCRIPT_UnlockModule();
463
464         return 1; /* non-heap based object */
465 }
466
467 static HRESULT WINAPI ScriptAutoImplAudioPathCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
468         FIXME("- no interface IID: %s\n", debugstr_guid(riid));
469
470         if (ppobj == NULL) return E_POINTER;
471         
472         return E_NOINTERFACE;
473 }
474
475 static HRESULT WINAPI ScriptAutoImplAudioPathCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
476         TRACE("(%d)\n", dolock);
477
478         if (dolock)
479                 DMSCRIPT_LockModule();
480         else
481                 DMSCRIPT_UnlockModule();
482         
483         return S_OK;
484 }
485
486 static const IClassFactoryVtbl ScriptAutoImplAudioPathCF_Vtbl = {
487         ScriptAutoImplAudioPathCF_QueryInterface,
488         ScriptAutoImplAudioPathCF_AddRef,
489         ScriptAutoImplAudioPathCF_Release,
490         ScriptAutoImplAudioPathCF_CreateInstance,
491         ScriptAutoImplAudioPathCF_LockServer
492 };
493
494 static IClassFactoryImpl ScriptAutoImplAudioPath_CF = {&ScriptAutoImplAudioPathCF_Vtbl};
495
496 /******************************************************************
497  *              DirectMusicScriptAutoImplSong ClassFactory
498  */
499 static HRESULT WINAPI ScriptAutoImplSongCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
500         FIXME("- no interface IID: %s\n", debugstr_guid(riid));
501
502         if (ppobj == NULL) return E_POINTER;
503         
504         return E_NOINTERFACE;
505 }
506
507 static ULONG WINAPI ScriptAutoImplSongCF_AddRef(LPCLASSFACTORY iface) {
508         DMSCRIPT_LockModule();
509
510         return 2; /* non-heap based */
511 }
512
513 static ULONG WINAPI ScriptAutoImplSongCF_Release(LPCLASSFACTORY iface) {
514         DMSCRIPT_UnlockModule();
515
516         return 1; /* non-heap based object */
517 }
518
519 static HRESULT WINAPI ScriptAutoImplSongCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
520         FIXME("- no interface IID: %s\n", debugstr_guid(riid));
521
522         if (ppobj == NULL) return E_POINTER;
523         
524         return E_NOINTERFACE;
525 }
526
527 static HRESULT WINAPI ScriptAutoImplSongCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
528         TRACE("(%d)\n", dolock);
529
530         if (dolock)
531                 DMSCRIPT_LockModule();
532         else
533                 DMSCRIPT_UnlockModule();
534         
535         return S_OK;
536 }
537
538 static const IClassFactoryVtbl ScriptAutoImplSongCF_Vtbl = {
539         ScriptAutoImplSongCF_QueryInterface,
540         ScriptAutoImplSongCF_AddRef,
541         ScriptAutoImplSongCF_Release,
542         ScriptAutoImplSongCF_CreateInstance,
543         ScriptAutoImplSongCF_LockServer
544 };
545
546 static IClassFactoryImpl ScriptAutoImplSong_CF = {&ScriptAutoImplSongCF_Vtbl};
547
548 /******************************************************************
549  *              DllMain
550  *
551  *
552  */
553 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
554         if (fdwReason == DLL_PROCESS_ATTACH) {
555             DisableThreadLibraryCalls(hinstDLL);
556                 /* FIXME: Initialisation */
557         } else if (fdwReason == DLL_PROCESS_DETACH) {
558                 /* FIXME: Cleanup */
559         }
560
561         return TRUE;
562 }
563
564
565 /******************************************************************
566  *              DllCanUnloadNow (DMSCRIPT.@)
567  *
568  *
569  */
570 HRESULT WINAPI DllCanUnloadNow(void)
571 {
572         return DMSCRIPT_refCount != 0 ? S_FALSE : S_OK;
573 }
574
575
576 /******************************************************************
577  *              DllGetClassObject (DMSCRIPT.@)
578  *
579  *
580  */
581 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
582 {
583     TRACE("(%s, %s, %p)\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
584     if (IsEqualCLSID (rclsid, &CLSID_DirectMusicScriptAutoImpSegment) && IsEqualIID (riid, &IID_IClassFactory)) {
585       *ppv = &ScriptAutoImplSegment_CF;
586       IClassFactory_AddRef((IClassFactory*)*ppv);
587       return S_OK;
588         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicScriptTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
589       *ppv = &ScriptTrack_CF;
590       IClassFactory_AddRef((IClassFactory*)*ppv);
591       return S_OK;
592         } else if (IsEqualCLSID (rclsid, &CLSID_AudioVBScript) && IsEqualIID (riid, &IID_IClassFactory)) {
593       *ppv = &AudioVBScript_CF;
594       IClassFactory_AddRef((IClassFactory*)*ppv);
595       return S_OK;
596         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicScript) && IsEqualIID (riid, &IID_IClassFactory)) {
597       *ppv = &Script_CF;
598       IClassFactory_AddRef((IClassFactory*)*ppv);
599       return S_OK;
600         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicScriptAutoImpPerformance) && IsEqualIID (riid, &IID_IClassFactory)) {
601       *ppv = &ScriptAutoImplPerformance_CF;
602       IClassFactory_AddRef((IClassFactory*)*ppv);
603       return S_OK;
604         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicScriptSourceCodeLoader) && IsEqualIID (riid, &IID_IClassFactory)) {
605       *ppv = &ScriptSourceCodeLoader_CF;
606       IClassFactory_AddRef((IClassFactory*)*ppv);
607       return S_OK;
608         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicScriptAutoImpSegmentState) && IsEqualIID (riid, &IID_IClassFactory)) {
609       *ppv = &ScriptAutoImplSegmentState_CF;
610       IClassFactory_AddRef((IClassFactory*)*ppv);
611       return S_OK;
612         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicScriptAutoImpAudioPathConfig) && IsEqualIID (riid, &IID_IClassFactory)) {
613       *ppv = &ScriptAutoImplAudioPathConfig_CF;
614       IClassFactory_AddRef((IClassFactory*)*ppv);
615       return S_OK;
616         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicScriptAutoImpAudioPath) && IsEqualIID (riid, &IID_IClassFactory)) {
617       *ppv = &ScriptAutoImplAudioPath_CF;
618       IClassFactory_AddRef((IClassFactory*)*ppv);
619       return S_OK;
620         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicScriptAutoImpSong) && IsEqualIID (riid, &IID_IClassFactory)) {
621       *ppv = &ScriptAutoImplSong_CF;
622       IClassFactory_AddRef((IClassFactory*)*ppv);
623       return S_OK;
624         }               
625
626     WARN("(%s, %s, %p): no interface found.\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
627     return CLASS_E_CLASSNOTAVAILABLE;
628 }
629
630
631 /******************************************************************
632  *              Helper functions
633  *
634  *
635  */
636
637 /* FOURCC to string conversion for debug messages */
638 const char *debugstr_fourcc (DWORD fourcc) {
639     if (!fourcc) return "'null'";
640     return wine_dbg_sprintf ("\'%c%c%c%c\'",
641                 (char)(fourcc), (char)(fourcc >> 8),
642         (char)(fourcc >> 16), (char)(fourcc >> 24));
643 }
644
645 /* DMUS_VERSION struct to string conversion for debug messages */
646 static const char *debugstr_dmversion (const DMUS_VERSION *version) {
647         if (!version) return "'null'";
648         return wine_dbg_sprintf ("\'%i,%i,%i,%i\'",
649                 (int)((version->dwVersionMS & 0xFFFF0000) >> 8), (int)(version->dwVersionMS & 0x0000FFFF), 
650                 (int)((version->dwVersionLS & 0xFFFF0000) >> 8), (int)(version->dwVersionLS & 0x0000FFFF));
651 }
652
653 /* returns name of given GUID */
654 const char *debugstr_dmguid (const GUID *id) {
655         static const guid_info guids[] = {
656                 /* CLSIDs */
657                 GE(CLSID_AudioVBScript),
658                 GE(CLSID_DirectMusic),
659                 GE(CLSID_DirectMusicAudioPath),
660                 GE(CLSID_DirectMusicAudioPathConfig),
661                 GE(CLSID_DirectMusicAuditionTrack),
662                 GE(CLSID_DirectMusicBand),
663                 GE(CLSID_DirectMusicBandTrack),
664                 GE(CLSID_DirectMusicChordMapTrack),
665                 GE(CLSID_DirectMusicChordMap),
666                 GE(CLSID_DirectMusicChordTrack),
667                 GE(CLSID_DirectMusicCollection),
668                 GE(CLSID_DirectMusicCommandTrack),
669                 GE(CLSID_DirectMusicComposer),
670                 GE(CLSID_DirectMusicContainer),
671                 GE(CLSID_DirectMusicGraph),
672                 GE(CLSID_DirectMusicLoader),
673                 GE(CLSID_DirectMusicLyricsTrack),
674                 GE(CLSID_DirectMusicMarkerTrack),
675                 GE(CLSID_DirectMusicMelodyFormulationTrack),
676                 GE(CLSID_DirectMusicMotifTrack),
677                 GE(CLSID_DirectMusicMuteTrack),
678                 GE(CLSID_DirectMusicParamControlTrack),
679                 GE(CLSID_DirectMusicPatternTrack),
680                 GE(CLSID_DirectMusicPerformance),
681                 GE(CLSID_DirectMusicScript),
682                 GE(CLSID_DirectMusicScriptAutoImpSegment),
683                 GE(CLSID_DirectMusicScriptAutoImpPerformance),
684                 GE(CLSID_DirectMusicScriptAutoImpSegmentState),
685                 GE(CLSID_DirectMusicScriptAutoImpAudioPathConfig),
686                 GE(CLSID_DirectMusicScriptAutoImpAudioPath),
687                 GE(CLSID_DirectMusicScriptAutoImpSong),
688                 GE(CLSID_DirectMusicScriptSourceCodeLoader),
689                 GE(CLSID_DirectMusicScriptTrack),
690                 GE(CLSID_DirectMusicSection),
691                 GE(CLSID_DirectMusicSegment),
692                 GE(CLSID_DirectMusicSegmentState),
693                 GE(CLSID_DirectMusicSegmentTriggerTrack),
694                 GE(CLSID_DirectMusicSegTriggerTrack),
695                 GE(CLSID_DirectMusicSeqTrack),
696                 GE(CLSID_DirectMusicSignPostTrack),
697                 GE(CLSID_DirectMusicSong),
698                 GE(CLSID_DirectMusicStyle),
699                 GE(CLSID_DirectMusicStyleTrack),
700                 GE(CLSID_DirectMusicSynth),
701                 GE(CLSID_DirectMusicSynthSink),
702                 GE(CLSID_DirectMusicSysExTrack),
703                 GE(CLSID_DirectMusicTemplate),
704                 GE(CLSID_DirectMusicTempoTrack),
705                 GE(CLSID_DirectMusicTimeSigTrack),
706                 GE(CLSID_DirectMusicWaveTrack),
707                 GE(CLSID_DirectSoundWave),
708                 /* IIDs */
709                 GE(IID_IDirectMusic),
710                 GE(IID_IDirectMusic2),
711                 GE(IID_IDirectMusic8),
712                 GE(IID_IDirectMusicAudioPath),
713                 GE(IID_IDirectMusicBand),
714                 GE(IID_IDirectMusicBuffer),
715                 GE(IID_IDirectMusicChordMap),
716                 GE(IID_IDirectMusicCollection),
717                 GE(IID_IDirectMusicComposer),
718                 GE(IID_IDirectMusicContainer),
719                 GE(IID_IDirectMusicDownload),
720                 GE(IID_IDirectMusicDownloadedInstrument),
721                 GE(IID_IDirectMusicGetLoader),
722                 GE(IID_IDirectMusicGraph),
723                 GE(IID_IDirectMusicInstrument),
724                 GE(IID_IDirectMusicLoader),
725                 GE(IID_IDirectMusicLoader8),
726                 GE(IID_IDirectMusicObject),
727                 GE(IID_IDirectMusicPatternTrack),
728                 GE(IID_IDirectMusicPerformance),
729                 GE(IID_IDirectMusicPerformance2),
730                 GE(IID_IDirectMusicPerformance8),
731                 GE(IID_IDirectMusicPort),
732                 GE(IID_IDirectMusicPortDownload),
733                 GE(IID_IDirectMusicScript),
734                 GE(IID_IDirectMusicSegment),
735                 GE(IID_IDirectMusicSegment2),
736                 GE(IID_IDirectMusicSegment8),
737                 GE(IID_IDirectMusicSegmentState),
738                 GE(IID_IDirectMusicSegmentState8),
739                 GE(IID_IDirectMusicStyle),
740                 GE(IID_IDirectMusicStyle8),
741                 GE(IID_IDirectMusicSynth),
742                 GE(IID_IDirectMusicSynth8),
743                 GE(IID_IDirectMusicSynthSink),
744                 GE(IID_IDirectMusicThru),
745                 GE(IID_IDirectMusicTool),
746                 GE(IID_IDirectMusicTool8),
747                 GE(IID_IDirectMusicTrack),
748                 GE(IID_IDirectMusicTrack8),
749                 GE(IID_IUnknown),
750                 GE(IID_IPersistStream),
751                 GE(IID_IStream),
752                 GE(IID_IClassFactory),
753                 /* GUIDs */
754                 GE(GUID_DirectMusicAllTypes),
755                 GE(GUID_NOTIFICATION_CHORD),
756                 GE(GUID_NOTIFICATION_COMMAND),
757                 GE(GUID_NOTIFICATION_MEASUREANDBEAT),
758                 GE(GUID_NOTIFICATION_PERFORMANCE),
759                 GE(GUID_NOTIFICATION_RECOMPOSE),
760                 GE(GUID_NOTIFICATION_SEGMENT),
761                 GE(GUID_BandParam),
762                 GE(GUID_ChordParam),
763                 GE(GUID_CommandParam),
764                 GE(GUID_CommandParam2),
765                 GE(GUID_CommandParamNext),
766                 GE(GUID_IDirectMusicBand),
767                 GE(GUID_IDirectMusicChordMap),
768                 GE(GUID_IDirectMusicStyle),
769                 GE(GUID_MuteParam),
770                 GE(GUID_Play_Marker),
771                 GE(GUID_RhythmParam),
772                 GE(GUID_TempoParam),
773                 GE(GUID_TimeSignature),
774                 GE(GUID_Valid_Start_Time),
775                 GE(GUID_Clear_All_Bands),
776                 GE(GUID_ConnectToDLSCollection),
777                 GE(GUID_Disable_Auto_Download),
778                 GE(GUID_DisableTempo),
779                 GE(GUID_DisableTimeSig),
780                 GE(GUID_Download),
781                 GE(GUID_DownloadToAudioPath),
782                 GE(GUID_Enable_Auto_Download),
783                 GE(GUID_EnableTempo),
784                 GE(GUID_EnableTimeSig),
785                 GE(GUID_IgnoreBankSelectForGM),
786                 GE(GUID_SeedVariations),
787                 GE(GUID_StandardMIDIFile),
788                 GE(GUID_Unload),
789                 GE(GUID_UnloadFromAudioPath),
790                 GE(GUID_Variations),
791                 GE(GUID_PerfMasterTempo),
792                 GE(GUID_PerfMasterVolume),
793                 GE(GUID_PerfMasterGrooveLevel),
794                 GE(GUID_PerfAutoDownload),
795                 GE(GUID_DefaultGMCollection),
796                 GE(GUID_Synth_Default),
797                 GE(GUID_Buffer_Reverb),
798                 GE(GUID_Buffer_EnvReverb),
799                 GE(GUID_Buffer_Stereo),
800                 GE(GUID_Buffer_3D_Dry),
801                 GE(GUID_Buffer_Mono),
802                 GE(GUID_DMUS_PROP_GM_Hardware),
803                 GE(GUID_DMUS_PROP_GS_Capable),
804                 GE(GUID_DMUS_PROP_GS_Hardware),
805                 GE(GUID_DMUS_PROP_DLS1),
806                 GE(GUID_DMUS_PROP_DLS2),
807                 GE(GUID_DMUS_PROP_Effects),
808                 GE(GUID_DMUS_PROP_INSTRUMENT2),
809                 GE(GUID_DMUS_PROP_LegacyCaps),
810                 GE(GUID_DMUS_PROP_MemorySize),
811                 GE(GUID_DMUS_PROP_SampleMemorySize),
812                 GE(GUID_DMUS_PROP_SamplePlaybackRate),
813                 GE(GUID_DMUS_PROP_SetSynthSink),
814                 GE(GUID_DMUS_PROP_SinkUsesDSound),
815                 GE(GUID_DMUS_PROP_SynthSink_DSOUND),
816                 GE(GUID_DMUS_PROP_SynthSink_WAVE),
817                 GE(GUID_DMUS_PROP_Volume),
818                 GE(GUID_DMUS_PROP_WavesReverb),
819                 GE(GUID_DMUS_PROP_WriteLatency),
820                 GE(GUID_DMUS_PROP_WritePeriod),
821                 GE(GUID_DMUS_PROP_XG_Capable),
822                 GE(GUID_DMUS_PROP_XG_Hardware)
823         };
824
825         unsigned int i;
826
827         if (!id) return "(null)";
828
829         for (i = 0; i < sizeof(guids)/sizeof(guids[0]); i++) {
830                 if (IsEqualGUID(id, guids[i].guid))
831                         return guids[i].name;
832         }
833         /* if we didn't find it, act like standard debugstr_guid */     
834         return debugstr_guid(id);
835 }       
836
837 /* generic flag-dumping function */
838 static const char* debugstr_flags (DWORD flags, const flag_info* names, size_t num_names){
839         char buffer[128] = "", *ptr = &buffer[0];
840         unsigned int i;
841         int size = sizeof(buffer);
842         
843         for (i=0; i < num_names; i++)
844         {
845                 if ((flags & names[i].val) ||   /* standard flag*/
846                         ((!flags) && (!names[i].val))) { /* zero value only */
847                                 int cnt = snprintf(ptr, size, "%s ", names[i].name);
848                                 if (cnt < 0 || cnt >= size) break;
849                                 size -= cnt;
850                                 ptr += cnt;
851                 }
852         }
853         
854         return wine_dbg_sprintf("%s", buffer);
855 }
856
857 /* dump DMUS_OBJ flags */
858 static const char *debugstr_DMUS_OBJ_FLAGS (DWORD flagmask) {
859     static const flag_info flags[] = {
860             FE(DMUS_OBJ_OBJECT),
861             FE(DMUS_OBJ_CLASS),
862             FE(DMUS_OBJ_NAME),
863             FE(DMUS_OBJ_CATEGORY),
864             FE(DMUS_OBJ_FILENAME),
865             FE(DMUS_OBJ_FULLPATH),
866             FE(DMUS_OBJ_URL),
867             FE(DMUS_OBJ_VERSION),
868             FE(DMUS_OBJ_DATE),
869             FE(DMUS_OBJ_LOADED),
870             FE(DMUS_OBJ_MEMORY),
871             FE(DMUS_OBJ_STREAM)
872         };
873     return debugstr_flags (flagmask, flags, sizeof(flags)/sizeof(flags[0]));
874 }
875
876 /* dump whole DMUS_OBJECTDESC struct */
877 const char *debugstr_DMUS_OBJECTDESC (LPDMUS_OBJECTDESC pDesc) {
878         if (pDesc) {
879                 char buffer[1024] = "", *ptr = &buffer[0];
880                 
881                 ptr += sprintf(ptr, "DMUS_OBJECTDESC (%p):\n", pDesc);
882                 ptr += sprintf(ptr, " - dwSize = %d\n", pDesc->dwSize);
883                 ptr += sprintf(ptr, " - dwValidData = %s\n", debugstr_DMUS_OBJ_FLAGS (pDesc->dwValidData));
884                 if (pDesc->dwValidData & DMUS_OBJ_CLASS) ptr += sprintf(ptr, " - guidClass = %s\n", debugstr_dmguid(&pDesc->guidClass));
885                 if (pDesc->dwValidData & DMUS_OBJ_OBJECT) ptr += sprintf(ptr, " - guidObject = %s\n", debugstr_guid(&pDesc->guidObject));
886                 if (pDesc->dwValidData & DMUS_OBJ_DATE) ptr += sprintf(ptr, " - ftDate = FIXME\n");
887                 if (pDesc->dwValidData & DMUS_OBJ_VERSION) ptr += sprintf(ptr, " - vVersion = %s\n", debugstr_dmversion(&pDesc->vVersion));
888                 if (pDesc->dwValidData & DMUS_OBJ_NAME) ptr += sprintf(ptr, " - wszName = %s\n", debugstr_w(pDesc->wszName));
889                 if (pDesc->dwValidData & DMUS_OBJ_CATEGORY) ptr += sprintf(ptr, " - wszCategory = %s\n", debugstr_w(pDesc->wszCategory));
890                 if (pDesc->dwValidData & DMUS_OBJ_FILENAME) ptr += sprintf(ptr, " - wszFileName = %s\n", debugstr_w(pDesc->wszFileName));
891                 if (pDesc->dwValidData & DMUS_OBJ_MEMORY) ptr += sprintf(ptr, " - llMemLength = 0x%s\n  - pbMemData = %p\n", 
892                                                                      wine_dbgstr_longlong(pDesc->llMemLength), pDesc->pbMemData);
893                 if (pDesc->dwValidData & DMUS_OBJ_STREAM) ptr += sprintf(ptr, " - pStream = %p", pDesc->pStream);
894
895                 return wine_dbg_sprintf("%s", buffer);
896         } else {
897                 return wine_dbg_sprintf("(NULL)");
898         }
899 }