rsaenh: Add a test for importing a key into a container and acquiring a container...
[wine] / dlls / dmcompos / dmcompos_main.c
1 /* DirectMusicComposer 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 "dmcompos_private.h"
24
25 WINE_DEFAULT_DEBUG_CHANNEL(dmcompos);
26
27 LONG DMCOMPOS_refCount = 0;
28
29 typedef struct {
30     const IClassFactoryVtbl *lpVtbl;
31 } IClassFactoryImpl;
32
33 /******************************************************************
34  *              DirectMusicChordMap ClassFactory
35  */
36 static HRESULT WINAPI ChordMapCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
37         FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));
38         
39         if (ppobj == NULL) return E_POINTER;
40         
41         return E_NOINTERFACE;
42 }
43
44 static ULONG WINAPI ChordMapCF_AddRef(LPCLASSFACTORY iface) {
45         DMCOMPOS_LockModule();
46         
47         return 2; /* non-heap based object */
48 }
49
50 static ULONG WINAPI ChordMapCF_Release(LPCLASSFACTORY iface) {
51         DMCOMPOS_UnlockModule();
52         
53         return 1; /* non-heap based object */
54 }
55
56 static HRESULT WINAPI ChordMapCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
57         TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);
58         
59         return DMUSIC_CreateDirectMusicChordMapImpl (riid, ppobj, pOuter);
60 }
61
62 static HRESULT WINAPI ChordMapCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
63         TRACE("(%d)\n", dolock);
64         
65         if (dolock)
66                 DMCOMPOS_LockModule();
67         else
68                 DMCOMPOS_UnlockModule();
69
70         return S_OK;
71 }
72
73 static const IClassFactoryVtbl ChordMapCF_Vtbl = {
74         ChordMapCF_QueryInterface,
75         ChordMapCF_AddRef,
76         ChordMapCF_Release,
77         ChordMapCF_CreateInstance,
78         ChordMapCF_LockServer
79 };
80
81 static IClassFactoryImpl ChordMap_CF = {&ChordMapCF_Vtbl};
82
83 /******************************************************************
84  *              DirectMusicComposer ClassFactory
85  */
86 static HRESULT WINAPI ComposerCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
87         FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));
88         
89         if (ppobj == NULL) return E_POINTER;
90         
91         return E_NOINTERFACE;
92 }
93
94 static ULONG WINAPI ComposerCF_AddRef(LPCLASSFACTORY iface) {
95         DMCOMPOS_LockModule();
96         
97         return 2; /* non-heap based object */
98 }
99
100 static ULONG WINAPI ComposerCF_Release(LPCLASSFACTORY iface) {
101         DMCOMPOS_UnlockModule();
102         
103         return 1; /* non-heap based object */
104 }
105
106 static HRESULT WINAPI ComposerCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
107         TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);
108         
109         return DMUSIC_CreateDirectMusicComposerImpl (riid, ppobj, pOuter);
110 }
111
112 static HRESULT WINAPI ComposerCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
113         TRACE("(%d)\n", dolock);
114         
115         if (dolock)
116                 DMCOMPOS_LockModule();
117         else
118                 DMCOMPOS_UnlockModule();
119
120         return S_OK;
121 }
122
123 static const IClassFactoryVtbl ComposerCF_Vtbl = {
124         ComposerCF_QueryInterface,
125         ComposerCF_AddRef,
126         ComposerCF_Release,
127         ComposerCF_CreateInstance,
128         ComposerCF_LockServer
129 };
130
131 static IClassFactoryImpl Composer_CF = {&ComposerCF_Vtbl};
132
133 /******************************************************************
134  *              DirectMusicChordMapTrack ClassFactory
135  */
136 static HRESULT WINAPI ChordMapTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
137         FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));
138         
139         if (ppobj == NULL) return E_POINTER;
140         
141         return E_NOINTERFACE;
142 }
143
144 static ULONG WINAPI ChordMapTrackCF_AddRef(LPCLASSFACTORY iface) {
145         DMCOMPOS_LockModule();
146         
147         return 2; /* non-heap based object */
148 }
149
150 static ULONG WINAPI ChordMapTrackCF_Release(LPCLASSFACTORY iface) {
151         DMCOMPOS_UnlockModule();
152         
153         return 1; /* non-heap based object */
154 }
155
156 static HRESULT WINAPI ChordMapTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
157         TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);
158         
159         return DMUSIC_CreateDirectMusicChordMapTrack (riid, ppobj, pOuter);
160 }
161
162 static HRESULT WINAPI ChordMapTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
163         TRACE("(%d)\n", dolock);
164         
165         if (dolock)
166                 DMCOMPOS_LockModule();
167         else
168                 DMCOMPOS_UnlockModule();
169
170         return S_OK;
171 }
172
173 static const IClassFactoryVtbl ChordMapTrackCF_Vtbl = {
174         ChordMapTrackCF_QueryInterface,
175         ChordMapTrackCF_AddRef,
176         ChordMapTrackCF_Release,
177         ChordMapTrackCF_CreateInstance,
178         ChordMapTrackCF_LockServer
179 };
180
181 static IClassFactoryImpl ChordMapTrack_CF = {&ChordMapTrackCF_Vtbl};
182
183 /******************************************************************
184  *              DirectMusicTemplate ClassFactory
185  */
186 static HRESULT WINAPI TemplateCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
187         FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));
188         
189         if (ppobj == NULL) return E_POINTER;
190         
191         return E_NOINTERFACE;
192 }
193
194 static ULONG WINAPI TemplateCF_AddRef(LPCLASSFACTORY iface) {
195         DMCOMPOS_LockModule();
196         
197         return 2; /* non-heap based object */
198 }
199
200 static ULONG WINAPI TemplateCF_Release(LPCLASSFACTORY iface) {
201         DMCOMPOS_UnlockModule();
202         
203         return 1; /* non-heap based object */
204 }
205
206 static HRESULT WINAPI TemplateCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
207         TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);
208         /* nothing yet */
209         WARN("(%s,%p): not found\n", debugstr_dmguid(riid), ppobj);
210         
211         return E_NOINTERFACE;
212 }
213
214 static HRESULT WINAPI TemplateCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
215         TRACE("(%d)\n", dolock);
216         
217         if (dolock)
218                 DMCOMPOS_LockModule();
219         else
220                 DMCOMPOS_UnlockModule();
221
222         return S_OK;
223 }
224
225 static const IClassFactoryVtbl TemplateCF_Vtbl = {
226         TemplateCF_QueryInterface,
227         TemplateCF_AddRef,
228         TemplateCF_Release,
229         TemplateCF_CreateInstance,
230         TemplateCF_LockServer
231 };
232
233 static IClassFactoryImpl Template_CF = {&TemplateCF_Vtbl};
234
235 /******************************************************************
236  *              DirectMusicSignPostTrack ClassFactory
237  */
238 static HRESULT WINAPI SignPostTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
239         FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));
240         
241         if (ppobj == NULL) return E_POINTER;
242         
243         return E_NOINTERFACE;
244 }
245
246 static ULONG WINAPI SignPostTrackCF_AddRef(LPCLASSFACTORY iface) {
247         DMCOMPOS_LockModule();
248         
249         return 2; /* non-heap based object */
250 }
251
252 static ULONG WINAPI SignPostTrackCF_Release(LPCLASSFACTORY iface) {
253         DMCOMPOS_UnlockModule();
254         
255         return 1; /* non-heap based object */
256 }
257
258 static HRESULT WINAPI SignPostTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
259         TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);
260         
261         return DMUSIC_CreateDirectMusicSignPostTrack (riid, ppobj, pOuter);
262 }
263
264 static HRESULT WINAPI SignPostTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
265         TRACE("(%d)\n", dolock);
266         
267         if (dolock)
268                 DMCOMPOS_LockModule();
269         else
270                 DMCOMPOS_UnlockModule();
271
272         return S_OK;
273 }
274
275 static const IClassFactoryVtbl SignPostTrackCF_Vtbl = {
276         SignPostTrackCF_QueryInterface,
277         SignPostTrackCF_AddRef,
278         SignPostTrackCF_Release,
279         SignPostTrackCF_CreateInstance,
280         SignPostTrackCF_LockServer
281 };
282
283 static IClassFactoryImpl SignPostTrack_CF = {&SignPostTrackCF_Vtbl};
284
285 /******************************************************************
286  *              DllMain
287  *
288  *
289  */
290 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
291         if (fdwReason == DLL_PROCESS_ATTACH)    {
292             DisableThreadLibraryCalls(hinstDLL);
293                 /* FIXME: Initialisation */
294         }
295         else if (fdwReason == DLL_PROCESS_DETACH)       {
296                 /* FIXME: Cleanup */
297         }
298
299         return TRUE;
300 }
301
302
303 /******************************************************************
304  *              DllCanUnloadNow (DMCOMPOS.@)
305  *
306  *
307  */
308 HRESULT WINAPI DllCanUnloadNow(void) {
309     return DMCOMPOS_refCount != 0 ? S_FALSE : S_OK;
310 }
311
312
313 /******************************************************************
314  *              DllGetClassObject (DMCOMPOS.@)
315  *
316  *
317  */
318 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv) {
319     TRACE("(%s, %s, %p)\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
320     if (IsEqualCLSID (rclsid, &CLSID_DirectMusicChordMap) && IsEqualIID (riid, &IID_IClassFactory)) {
321                 *ppv = &ChordMap_CF;
322                 IClassFactory_AddRef((IClassFactory*)*ppv);
323                 return S_OK;
324         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicComposer) && IsEqualIID (riid, &IID_IClassFactory)) { 
325                 *ppv = &Composer_CF;
326                 IClassFactory_AddRef((IClassFactory*)*ppv);             
327                 return S_OK;
328         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicChordMapTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
329                 *ppv = &ChordMapTrack_CF;
330                 IClassFactory_AddRef((IClassFactory*)*ppv);             
331                 return S_OK;
332         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicTemplate) && IsEqualIID (riid, &IID_IClassFactory)) {
333                 *ppv = &Template_CF;
334                 IClassFactory_AddRef((IClassFactory*)*ppv);             
335                 return S_OK;
336         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicSignPostTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
337                 *ppv = &SignPostTrack_CF;
338                 IClassFactory_AddRef((IClassFactory*)*ppv);             
339                 return S_OK;
340         }
341
342     WARN("(%s, %s, %p): no interface found.\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
343     return CLASS_E_CLASSNOTAVAILABLE;
344 }
345
346
347 /******************************************************************
348  *              Helper functions
349  *
350  *
351  */
352 /* FOURCC to string conversion for debug messages */
353 const char *debugstr_fourcc (DWORD fourcc) {
354     if (!fourcc) return "'null'";
355     return wine_dbg_sprintf ("\'%c%c%c%c\'",
356                 (char)(fourcc), (char)(fourcc >> 8),
357         (char)(fourcc >> 16), (char)(fourcc >> 24));
358 }
359
360 /* DMUS_VERSION struct to string conversion for debug messages */
361 static const char *debugstr_dmversion (const DMUS_VERSION *version) {
362         if (!version) return "'null'";
363         return wine_dbg_sprintf ("\'%i,%i,%i,%i\'",
364                 (int)((version->dwVersionMS & 0xFFFF0000) >> 8), (int)(version->dwVersionMS & 0x0000FFFF), 
365                 (int)((version->dwVersionLS & 0xFFFF0000) >> 8), (int)(version->dwVersionLS & 0x0000FFFF));
366 }
367
368 /* returns name of given GUID */
369 const char *debugstr_dmguid (const GUID *id) {
370         static const guid_info guids[] = {
371                 /* CLSIDs */
372                 GE(CLSID_AudioVBScript),
373                 GE(CLSID_DirectMusic),
374                 GE(CLSID_DirectMusicAudioPath),
375                 GE(CLSID_DirectMusicAudioPathConfig),
376                 GE(CLSID_DirectMusicAuditionTrack),
377                 GE(CLSID_DirectMusicBand),
378                 GE(CLSID_DirectMusicBandTrack),
379                 GE(CLSID_DirectMusicChordMapTrack),
380                 GE(CLSID_DirectMusicChordMap),
381                 GE(CLSID_DirectMusicChordTrack),
382                 GE(CLSID_DirectMusicCollection),
383                 GE(CLSID_DirectMusicCommandTrack),
384                 GE(CLSID_DirectMusicComposer),
385                 GE(CLSID_DirectMusicContainer),
386                 GE(CLSID_DirectMusicGraph),
387                 GE(CLSID_DirectMusicLoader),
388                 GE(CLSID_DirectMusicLyricsTrack),
389                 GE(CLSID_DirectMusicMarkerTrack),
390                 GE(CLSID_DirectMusicMelodyFormulationTrack),
391                 GE(CLSID_DirectMusicMotifTrack),
392                 GE(CLSID_DirectMusicMuteTrack),
393                 GE(CLSID_DirectMusicParamControlTrack),
394                 GE(CLSID_DirectMusicPatternTrack),
395                 GE(CLSID_DirectMusicPerformance),
396                 GE(CLSID_DirectMusicScript),
397                 GE(CLSID_DirectMusicScriptAutoImpSegment),
398                 GE(CLSID_DirectMusicScriptAutoImpPerformance),
399                 GE(CLSID_DirectMusicScriptAutoImpSegmentState),
400                 GE(CLSID_DirectMusicScriptAutoImpAudioPathConfig),
401                 GE(CLSID_DirectMusicScriptAutoImpAudioPath),
402                 GE(CLSID_DirectMusicScriptAutoImpSong),
403                 GE(CLSID_DirectMusicScriptSourceCodeLoader),
404                 GE(CLSID_DirectMusicScriptTrack),
405                 GE(CLSID_DirectMusicSection),
406                 GE(CLSID_DirectMusicSegment),
407                 GE(CLSID_DirectMusicSegmentState),
408                 GE(CLSID_DirectMusicSegmentTriggerTrack),
409                 GE(CLSID_DirectMusicSegTriggerTrack),
410                 GE(CLSID_DirectMusicSeqTrack),
411                 GE(CLSID_DirectMusicSignPostTrack),
412                 GE(CLSID_DirectMusicSong),
413                 GE(CLSID_DirectMusicStyle),
414                 GE(CLSID_DirectMusicStyleTrack),
415                 GE(CLSID_DirectMusicSynth),
416                 GE(CLSID_DirectMusicSynthSink),
417                 GE(CLSID_DirectMusicSysExTrack),
418                 GE(CLSID_DirectMusicTemplate),
419                 GE(CLSID_DirectMusicTempoTrack),
420                 GE(CLSID_DirectMusicTimeSigTrack),
421                 GE(CLSID_DirectMusicWaveTrack),
422                 GE(CLSID_DirectSoundWave),
423                 /* IIDs */
424                 GE(IID_IDirectMusic),
425                 GE(IID_IDirectMusic2),
426                 GE(IID_IDirectMusic8),
427                 GE(IID_IDirectMusicAudioPath),
428                 GE(IID_IDirectMusicBand),
429                 GE(IID_IDirectMusicBuffer),
430                 GE(IID_IDirectMusicChordMap),
431                 GE(IID_IDirectMusicCollection),
432                 GE(IID_IDirectMusicComposer),
433                 GE(IID_IDirectMusicContainer),
434                 GE(IID_IDirectMusicDownload),
435                 GE(IID_IDirectMusicDownloadedInstrument),
436                 GE(IID_IDirectMusicGetLoader),
437                 GE(IID_IDirectMusicGraph),
438                 GE(IID_IDirectMusicInstrument),
439                 GE(IID_IDirectMusicLoader),
440                 GE(IID_IDirectMusicLoader8),
441                 GE(IID_IDirectMusicObject),
442                 GE(IID_IDirectMusicPatternTrack),
443                 GE(IID_IDirectMusicPerformance),
444                 GE(IID_IDirectMusicPerformance2),
445                 GE(IID_IDirectMusicPerformance8),
446                 GE(IID_IDirectMusicPort),
447                 GE(IID_IDirectMusicPortDownload),
448                 GE(IID_IDirectMusicScript),
449                 GE(IID_IDirectMusicSegment),
450                 GE(IID_IDirectMusicSegment2),
451                 GE(IID_IDirectMusicSegment8),
452                 GE(IID_IDirectMusicSegmentState),
453                 GE(IID_IDirectMusicSegmentState8),
454                 GE(IID_IDirectMusicStyle),
455                 GE(IID_IDirectMusicStyle8),
456                 GE(IID_IDirectMusicSynth),
457                 GE(IID_IDirectMusicSynth8),
458                 GE(IID_IDirectMusicSynthSink),
459                 GE(IID_IDirectMusicThru),
460                 GE(IID_IDirectMusicTool),
461                 GE(IID_IDirectMusicTool8),
462                 GE(IID_IDirectMusicTrack),
463                 GE(IID_IDirectMusicTrack8),
464                 GE(IID_IUnknown),
465                 GE(IID_IPersistStream),
466                 GE(IID_IStream),
467                 GE(IID_IClassFactory),
468                 /* GUIDs */
469                 GE(GUID_DirectMusicAllTypes),
470                 GE(GUID_NOTIFICATION_CHORD),
471                 GE(GUID_NOTIFICATION_COMMAND),
472                 GE(GUID_NOTIFICATION_MEASUREANDBEAT),
473                 GE(GUID_NOTIFICATION_PERFORMANCE),
474                 GE(GUID_NOTIFICATION_RECOMPOSE),
475                 GE(GUID_NOTIFICATION_SEGMENT),
476                 GE(GUID_BandParam),
477                 GE(GUID_ChordParam),
478                 GE(GUID_CommandParam),
479                 GE(GUID_CommandParam2),
480                 GE(GUID_CommandParamNext),
481                 GE(GUID_IDirectMusicBand),
482                 GE(GUID_IDirectMusicChordMap),
483                 GE(GUID_IDirectMusicStyle),
484                 GE(GUID_MuteParam),
485                 GE(GUID_Play_Marker),
486                 GE(GUID_RhythmParam),
487                 GE(GUID_TempoParam),
488                 GE(GUID_TimeSignature),
489                 GE(GUID_Valid_Start_Time),
490                 GE(GUID_Clear_All_Bands),
491                 GE(GUID_ConnectToDLSCollection),
492                 GE(GUID_Disable_Auto_Download),
493                 GE(GUID_DisableTempo),
494                 GE(GUID_DisableTimeSig),
495                 GE(GUID_Download),
496                 GE(GUID_DownloadToAudioPath),
497                 GE(GUID_Enable_Auto_Download),
498                 GE(GUID_EnableTempo),
499                 GE(GUID_EnableTimeSig),
500                 GE(GUID_IgnoreBankSelectForGM),
501                 GE(GUID_SeedVariations),
502                 GE(GUID_StandardMIDIFile),
503                 GE(GUID_Unload),
504                 GE(GUID_UnloadFromAudioPath),
505                 GE(GUID_Variations),
506                 GE(GUID_PerfMasterTempo),
507                 GE(GUID_PerfMasterVolume),
508                 GE(GUID_PerfMasterGrooveLevel),
509                 GE(GUID_PerfAutoDownload),
510                 GE(GUID_DefaultGMCollection),
511                 GE(GUID_Synth_Default),
512                 GE(GUID_Buffer_Reverb),
513                 GE(GUID_Buffer_EnvReverb),
514                 GE(GUID_Buffer_Stereo),
515                 GE(GUID_Buffer_3D_Dry),
516                 GE(GUID_Buffer_Mono),
517                 GE(GUID_DMUS_PROP_GM_Hardware),
518                 GE(GUID_DMUS_PROP_GS_Capable),
519                 GE(GUID_DMUS_PROP_GS_Hardware),
520                 GE(GUID_DMUS_PROP_DLS1),
521                 GE(GUID_DMUS_PROP_DLS2),
522                 GE(GUID_DMUS_PROP_Effects),
523                 GE(GUID_DMUS_PROP_INSTRUMENT2),
524                 GE(GUID_DMUS_PROP_LegacyCaps),
525                 GE(GUID_DMUS_PROP_MemorySize),
526                 GE(GUID_DMUS_PROP_SampleMemorySize),
527                 GE(GUID_DMUS_PROP_SamplePlaybackRate),
528                 GE(GUID_DMUS_PROP_SetSynthSink),
529                 GE(GUID_DMUS_PROP_SinkUsesDSound),
530                 GE(GUID_DMUS_PROP_SynthSink_DSOUND),
531                 GE(GUID_DMUS_PROP_SynthSink_WAVE),
532                 GE(GUID_DMUS_PROP_Volume),
533                 GE(GUID_DMUS_PROP_WavesReverb),
534                 GE(GUID_DMUS_PROP_WriteLatency),
535                 GE(GUID_DMUS_PROP_WritePeriod),
536                 GE(GUID_DMUS_PROP_XG_Capable),
537                 GE(GUID_DMUS_PROP_XG_Hardware)
538         };
539
540         unsigned int i;
541
542         if (!id) return "(null)";
543
544         for (i = 0; i < sizeof(guids)/sizeof(guids[0]); i++) {
545                 if (IsEqualGUID(id, guids[i].guid))
546                         return guids[i].name;
547         }
548         /* if we didn't find it, act like standard debugstr_guid */     
549         return debugstr_guid(id);
550 }       
551
552 /* generic flag-dumping function */
553 static const char* debugstr_flags (DWORD flags, const flag_info* names, size_t num_names){
554         char buffer[128] = "", *ptr = &buffer[0];
555         unsigned int i;
556         int size = sizeof(buffer);
557         
558         for (i=0; i < num_names; i++)
559         {
560                 if ((flags & names[i].val) ||   /* standard flag*/
561                         ((!flags) && (!names[i].val))) { /* zero value only */
562                                 int cnt = snprintf(ptr, size, "%s ", names[i].name);
563                                 if (cnt < 0 || cnt >= size) break;
564                                 size -= cnt;
565                                 ptr += cnt;
566                 }
567         }
568         
569         return wine_dbg_sprintf("%s", buffer);
570 }
571
572 /* dump DMUS_OBJ flags */
573 static const char *debugstr_DMUS_OBJ_FLAGS (DWORD flagmask) {
574     static const flag_info flags[] = {
575             FE(DMUS_OBJ_OBJECT),
576             FE(DMUS_OBJ_CLASS),
577             FE(DMUS_OBJ_NAME),
578             FE(DMUS_OBJ_CATEGORY),
579             FE(DMUS_OBJ_FILENAME),
580             FE(DMUS_OBJ_FULLPATH),
581             FE(DMUS_OBJ_URL),
582             FE(DMUS_OBJ_VERSION),
583             FE(DMUS_OBJ_DATE),
584             FE(DMUS_OBJ_LOADED),
585             FE(DMUS_OBJ_MEMORY),
586             FE(DMUS_OBJ_STREAM)
587         };
588     return debugstr_flags (flagmask, flags, sizeof(flags)/sizeof(flags[0]));
589 }
590
591 /* dump whole DMUS_OBJECTDESC struct */
592 const char *debugstr_DMUS_OBJECTDESC (LPDMUS_OBJECTDESC pDesc) {
593         if (pDesc) {
594                 char buffer[1024] = "", *ptr = &buffer[0];
595                 
596                 ptr += sprintf(ptr, "DMUS_OBJECTDESC (%p):\n", pDesc);
597                 ptr += sprintf(ptr, " - dwSize = %d\n", pDesc->dwSize);
598                 ptr += sprintf(ptr, " - dwValidData = %s\n", debugstr_DMUS_OBJ_FLAGS (pDesc->dwValidData));
599                 if (pDesc->dwValidData & DMUS_OBJ_CLASS) ptr += sprintf(ptr, " - guidClass = %s\n", debugstr_dmguid(&pDesc->guidClass));
600                 if (pDesc->dwValidData & DMUS_OBJ_OBJECT) ptr += sprintf(ptr, " - guidObject = %s\n", debugstr_guid(&pDesc->guidObject));
601                 if (pDesc->dwValidData & DMUS_OBJ_DATE) ptr += sprintf(ptr, " - ftDate = FIXME\n");
602                 if (pDesc->dwValidData & DMUS_OBJ_VERSION) ptr += sprintf(ptr, " - vVersion = %s\n", debugstr_dmversion(&pDesc->vVersion));
603                 if (pDesc->dwValidData & DMUS_OBJ_NAME) ptr += sprintf(ptr, " - wszName = %s\n", debugstr_w(pDesc->wszName));
604                 if (pDesc->dwValidData & DMUS_OBJ_CATEGORY) ptr += sprintf(ptr, " - wszCategory = %s\n", debugstr_w(pDesc->wszCategory));
605                 if (pDesc->dwValidData & DMUS_OBJ_FILENAME) ptr += sprintf(ptr, " - wszFileName = %s\n", debugstr_w(pDesc->wszFileName));
606                 if (pDesc->dwValidData & DMUS_OBJ_MEMORY) ptr += sprintf(ptr, " - llMemLength = 0x%s\n  - pbMemData = %p\n",
607                                                                      wine_dbgstr_longlong(pDesc->llMemLength), pDesc->pbMemData);
608                 if (pDesc->dwValidData & DMUS_OBJ_STREAM) ptr += sprintf(ptr, " - pStream = %p", pDesc->pStream);
609
610                 return wine_dbg_sprintf("%s", buffer);
611         } else {
612                 return wine_dbg_sprintf("(NULL)");
613         }
614 }