Added a framework for testing CreateProcess and a few tests.
[wine] / dlls / avifil32 / comentry.c
1 /*
2  * Copyright 2001 Hidenori TAKESHIMA <hidenori@a2.ctktv.ne.jp>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  */
18
19 #include <string.h>
20 #include <stdio.h>
21 #include <assert.h>
22
23 #include "winbase.h"
24 #include "winnls.h"
25 #include "mmsystem.h"
26 #include "winerror.h"
27 #include "ole2.h"
28 #include "vfw.h"
29 #include "wine/debug.h"
30 #include "avifile_private.h"
31
32 WINE_DEFAULT_DEBUG_CHANNEL(avifile);
33
34 static HRESULT WINAPI
35 IClassFactory_fnQueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj);
36 static ULONG WINAPI IClassFactory_fnAddRef(LPCLASSFACTORY iface);
37 static ULONG WINAPI IClassFactory_fnRelease(LPCLASSFACTORY iface);
38 static HRESULT WINAPI IClassFactory_fnCreateInstance(LPCLASSFACTORY iface,LPUNKNOWN pOuter,REFIID riid,LPVOID *ppobj);
39 static HRESULT WINAPI IClassFactory_fnLockServer(LPCLASSFACTORY iface,BOOL dolock);
40
41 static ICOM_VTABLE(IClassFactory) iclassfact =
42 {
43         ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
44         IClassFactory_fnQueryInterface,
45         IClassFactory_fnAddRef,
46         IClassFactory_fnRelease,
47         IClassFactory_fnCreateInstance,
48         IClassFactory_fnLockServer
49 };
50
51 typedef struct
52 {
53         /* IUnknown fields */
54         ICOM_VFIELD(IClassFactory);
55         DWORD   ref;
56 } IClassFactoryImpl;
57
58 static IClassFactoryImpl AVIFILE_GlobalCF = {&iclassfact, 0 };
59
60
61
62 static HRESULT WINAPI
63 IClassFactory_fnQueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
64 {
65         ICOM_THIS(IClassFactoryImpl,iface);
66
67         TRACE("(%p)->(%p,%p)\n",This,riid,ppobj);
68         if ( ( IsEqualGUID( &IID_IUnknown, riid ) ) ||
69              ( IsEqualGUID( &IID_IClassFactory, riid ) ) )
70         {
71                 *ppobj = iface;
72                 IClassFactory_AddRef(iface);
73                 return S_OK;
74         }
75
76         return E_NOINTERFACE;
77 }
78
79 static ULONG WINAPI IClassFactory_fnAddRef(LPCLASSFACTORY iface)
80 {
81         ICOM_THIS(IClassFactoryImpl,iface);
82
83         TRACE("(%p)->()\n",This);
84         if ( (This->ref) == 0 )
85                 AVIFILE_data.dwClassObjRef ++;
86
87         return ++(This->ref);
88 }
89
90 static ULONG WINAPI IClassFactory_fnRelease(LPCLASSFACTORY iface)
91 {
92         ICOM_THIS(IClassFactoryImpl,iface);
93
94         TRACE("(%p)->()\n",This);
95         if ( (--(This->ref)) > 0 )
96                 return This->ref;
97
98         AVIFILE_data.dwClassObjRef --;
99         return 0;
100 }
101
102 static HRESULT WINAPI IClassFactory_fnCreateInstance(LPCLASSFACTORY iface,LPUNKNOWN pOuter,REFIID riid,LPVOID *ppobj)
103 {
104     /*ICOM_THIS(IClassFactoryImpl,iface);*/
105
106         *ppobj = NULL;
107         if ( pOuter != NULL )
108                 return E_FAIL;
109
110         if ( IsEqualGUID( &IID_IAVIFile, riid ) )
111                 return AVIFILE_CreateIAVIFile(ppobj);
112         if ( IsEqualGUID( &IID_IAVIStream, riid ) )
113                 return AVIFILE_CreateIAVIStream(ppobj);
114
115         return E_NOINTERFACE;
116 }
117
118 static HRESULT WINAPI IClassFactory_fnLockServer(LPCLASSFACTORY iface,BOOL dolock)
119 {
120         ICOM_THIS(IClassFactoryImpl,iface);
121         HRESULT hr;
122
123         FIXME("(%p)->(%d),stub!\n",This,dolock);
124         if (dolock)
125                 hr = IClassFactory_AddRef(iface);
126         else
127                 hr = IClassFactory_Release(iface);
128
129         return hr;
130 }
131
132
133 /***********************************************************************
134  *              DllGetClassObject (AVIFIL32.@)
135  */
136 HRESULT WINAPI AVIFILE_DllGetClassObject(const CLSID* pclsid,const IID* piid,void** ppv)
137 {
138         *ppv = NULL;
139         if ( IsEqualCLSID( &IID_IClassFactory, piid ) )
140         {
141                 *ppv = (LPVOID)&AVIFILE_GlobalCF;
142                 IClassFactory_AddRef((IClassFactory*)*ppv);
143                 return S_OK;
144         }
145
146         return CLASS_E_CLASSNOTAVAILABLE;
147 }
148
149 /*****************************************************************************
150  *              DllCanUnloadNow (AVIFIL32.@)
151  */
152 DWORD WINAPI AVIFILE_DllCanUnloadNow(void)
153 {
154         return ( AVIFILE_data.dwClassObjRef == 0 ) ? S_OK : S_FALSE;
155 }
156