Changeset 6649 for trunk/src/quartz/main.c
- Timestamp:
- Sep 5, 2001, 3:39:12 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/quartz/main.c
r6578 r6649 1 /* $Id: main.c,v 1.3 2001-09-05 13:36:37 bird Exp $ */ 2 1 3 #include "config.h" 2 4 … … 22 24 typedef struct QUARTZ_CLASSENTRY 23 25 { 24 const CLSID*pclsid;25 QUARTZ_pCreateIUnknownpCreateIUnk;26 const CLSID* pclsid; 27 QUARTZ_pCreateIUnknown pCreateIUnk; 26 28 } QUARTZ_CLASSENTRY; 27 29 … … 36 38 static ICOM_VTABLE(IClassFactory) iclassfact = 37 39 { 38 39 40 41 42 43 40 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE 41 IClassFactory_fnQueryInterface, 42 IClassFactory_fnAddRef, 43 IClassFactory_fnRelease, 44 IClassFactory_fnCreateInstance, 45 IClassFactory_fnLockServer 44 46 }; 45 47 46 48 typedef struct 47 49 { 48 49 50 DWORDref;51 52 50 /* IUnknown fields */ 51 ICOM_VFIELD(IClassFactory); 52 DWORD ref; 53 /* IClassFactory fields */ 54 const QUARTZ_CLASSENTRY* pEntry; 53 55 } IClassFactoryImpl; 54 56 55 57 static const QUARTZ_CLASSENTRY QUARTZ_ClassList[] = 56 58 { 57 58 59 60 59 { &CLSID_FilterGraph, &QUARTZ_CreateFilterGraph }, 60 { &CLSID_SystemClock, &QUARTZ_CreateSystemClock }, 61 { &CLSID_MemoryAllocator, &QUARTZ_CreateMemoryAllocator }, 62 { NULL, NULL }, 61 63 }; 62 64 … … 68 70 void* QUARTZ_AllocObj( DWORD dwSize ) 69 71 { 70 void*pv;71 72 73 74 75 76 77 78 79 72 void* pv; 73 74 EnterCriticalSection( &csHeap ); 75 dwClassObjRef ++; 76 pv = HeapAlloc( hDLLHeap, 0, dwSize ); 77 if ( pv == NULL ) 78 dwClassObjRef --; 79 LeaveCriticalSection( &csHeap ); 80 81 return pv; 80 82 } 81 83 82 84 void QUARTZ_FreeObj( void* pobj ) 83 85 { 84 85 86 87 86 EnterCriticalSection( &csHeap ); 87 HeapFree( hDLLHeap, 0, pobj ); 88 dwClassObjRef --; 89 LeaveCriticalSection( &csHeap ); 88 90 } 89 91 90 92 void* QUARTZ_AllocMem( DWORD dwSize ) 91 93 { 92 94 return HeapAlloc( hDLLHeap, 0, dwSize ); 93 95 } 94 96 95 97 void QUARTZ_FreeMem( void* pMem ) 96 98 { 97 99 HeapFree( hDLLHeap, 0, pMem ); 98 100 } 99 101 … … 103 105 IClassFactory_fnQueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) 104 106 { 105 106 107 108 109 110 111 112 113 114 115 116 107 ICOM_THIS(IClassFactoryImpl,iface); 108 109 TRACE("(%p)->(%p,%p)\n",This,riid,ppobj); 110 if ( ( IsEqualGUID( &IID_IUnknown, riid ) ) || 111 ( IsEqualGUID( &IID_IClassFactory, riid ) ) ) 112 { 113 *ppobj = iface; 114 IClassFactory_AddRef(iface); 115 return S_OK; 116 } 117 118 return E_NOINTERFACE; 117 119 } 118 120 119 121 static ULONG WINAPI IClassFactory_fnAddRef(LPCLASSFACTORY iface) 120 122 { 121 122 123 124 125 123 ICOM_THIS(IClassFactoryImpl,iface); 124 125 TRACE("(%p)->()\n",This); 126 127 return ++(This->ref); 126 128 } 127 129 128 130 static ULONG WINAPI IClassFactory_fnRelease(LPCLASSFACTORY iface) 129 131 { 130 131 132 133 134 135 136 137 132 ICOM_THIS(IClassFactoryImpl,iface); 133 134 TRACE("(%p)->()\n",This); 135 if ( (--(This->ref)) > 0 ) 136 return This->ref; 137 138 QUARTZ_FreeObj(This); 139 return 0; 138 140 } 139 141 140 142 static HRESULT WINAPI IClassFactory_fnCreateInstance(LPCLASSFACTORY iface,LPUNKNOWN pOuter,REFIID riid,LPVOID *ppobj) 141 143 { 142 143 HRESULThr;144 IUnknown*punk;145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 144 ICOM_THIS(IClassFactoryImpl,iface); 145 HRESULT hr; 146 IUnknown* punk; 147 148 TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj); 149 150 if ( ppobj == NULL ) 151 return E_POINTER; 152 if ( pOuter != NULL && !IsEqualGUID( riid, &IID_IUnknown ) ) 153 return CLASS_E_NOAGGREGATION; 154 155 *ppobj = NULL; 156 157 hr = (*This->pEntry->pCreateIUnk)(pOuter,(void**)&punk); 158 if ( hr != S_OK ) 159 return hr; 160 161 hr = IUnknown_QueryInterface(punk,riid,ppobj); 162 IUnknown_Release(punk); 163 164 return hr; 163 165 } 164 166 165 167 static HRESULT WINAPI IClassFactory_fnLockServer(LPCLASSFACTORY iface,BOOL dolock) 166 168 { 167 168 HRESULThr;169 170 171 172 173 174 175 176 169 ICOM_THIS(IClassFactoryImpl,iface); 170 HRESULT hr; 171 172 FIXME("(%p)->(%d),stub!\n",This,dolock); 173 if (dolock) 174 hr = IClassFactory_AddRef(iface); 175 else 176 hr = IClassFactory_Release(iface); 177 178 return hr; 177 179 } 178 180 … … 181 183 static HRESULT IClassFactory_Alloc( const CLSID* pclsid, void** ppobj ) 182 184 { 183 const QUARTZ_CLASSENTRY*pEntry;184 IClassFactoryImpl*pImpl;185 186 187 188 189 190 191 192 193 194 195 185 const QUARTZ_CLASSENTRY* pEntry; 186 IClassFactoryImpl* pImpl; 187 188 TRACE( "(%s,%p)\n", debugstr_guid(pclsid), ppobj ); 189 190 pEntry = QUARTZ_ClassList; 191 while ( pEntry->pclsid != NULL ) 192 { 193 if ( IsEqualGUID( pclsid, pEntry->pclsid ) ) 194 goto found; 195 } 196 197 return CLASS_E_CLASSNOTAVAILABLE; 196 198 found: 197 198 199 200 201 202 203 204 205 206 207 } 208 209 210 /*********************************************************************** 211 * 199 pImpl = (IClassFactoryImpl*)QUARTZ_AllocObj( sizeof(IClassFactoryImpl) ); 200 if ( pImpl == NULL ) 201 return E_OUTOFMEMORY; 202 203 ICOM_VTBL(pImpl) = &iclassfact; 204 pImpl->ref = 1; 205 pImpl->pEntry = pEntry; 206 207 *ppobj = (void*)pImpl; 208 return S_OK; 209 } 210 211 212 /*********************************************************************** 213 * QUARTZ_InitProcess (internal) 212 214 */ 213 215 static BOOL QUARTZ_InitProcess( void ) 214 216 { 215 216 217 218 219 220 221 222 223 224 225 226 } 227 228 /*********************************************************************** 229 * 217 TRACE("()\n"); 218 219 dwClassObjRef = 0; 220 hDLLHeap = (HANDLE)NULL; 221 InitializeCriticalSection( &csHeap ); 222 223 hDLLHeap = HeapCreate( 0, 0x10000, 0 ); 224 if ( hDLLHeap == (HANDLE)NULL ) 225 return FALSE; 226 227 return TRUE; 228 } 229 230 /*********************************************************************** 231 * QUARTZ_UninitProcess (internal) 230 232 */ 231 233 static void QUARTZ_UninitProcess( void ) 232 234 { 233 234 235 236 237 238 239 240 241 242 243 } 244 245 /*********************************************************************** 246 * 235 TRACE("()\n"); 236 237 if ( dwClassObjRef != 0 ) 238 ERR( "you must release some objects allocated from quartz.\n" ); 239 if ( hDLLHeap != (HANDLE)NULL ) 240 { 241 HeapDestroy( hDLLHeap ); 242 hDLLHeap = (HANDLE)NULL; 243 } 244 DeleteCriticalSection( &csHeap ); 245 } 246 247 /*********************************************************************** 248 * QUARTZ_DllMain 247 249 */ 248 250 BOOL WINAPI QUARTZ_DllMain( 249 250 251 252 { 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 } 270 271 272 /*********************************************************************** 273 * 251 HINSTANCE hInstDLL, 252 DWORD fdwReason, 253 LPVOID lpvReserved ) 254 { 255 switch ( fdwReason ) 256 { 257 case DLL_PROCESS_ATTACH: 258 if ( !QUARTZ_InitProcess() ) 259 return FALSE; 260 break; 261 case DLL_PROCESS_DETACH: 262 QUARTZ_UninitProcess(); 263 break; 264 case DLL_THREAD_ATTACH: 265 break; 266 case DLL_THREAD_DETACH: 267 break; 268 } 269 270 return TRUE; 271 } 272 273 274 /*********************************************************************** 275 * DllCanUnloadNow (QUARTZ.@) 274 276 * 275 277 * RETURNS … … 279 281 HRESULT WINAPI QUARTZ_DllCanUnloadNow(void) 280 282 { 281 HRESULThr;282 283 284 285 286 287 288 } 289 290 /*********************************************************************** 291 * 283 HRESULT hr; 284 285 EnterCriticalSection( &csHeap ); 286 hr = ( dwClassObjRef == 0 ) ? S_OK : S_FALSE; 287 LeaveCriticalSection( &csHeap ); 288 289 return hr; 290 } 291 292 /*********************************************************************** 293 * DllGetClassObject (QUARTZ.@) 292 294 */ 293 295 HRESULT WINAPI QUARTZ_DllGetClassObject( 294 295 { 296 297 298 299 300 301 302 303 304 } 305 306 /*********************************************************************** 307 * 296 const CLSID* pclsid,const IID* piid,void** ppv) 297 { 298 *ppv = NULL; 299 if ( IsEqualCLSID( &IID_IUnknown, piid ) || 300 IsEqualCLSID( &IID_IClassFactory, piid ) ) 301 { 302 return IClassFactory_Alloc( pclsid, ppv ); 303 } 304 305 return CLASS_E_CLASSNOTAVAILABLE; 306 } 307 308 /*********************************************************************** 309 * DllRegisterServer (QUARTZ.@) 308 310 */ 309 311 310 312 HRESULT WINAPI QUARTZ_DllRegisterServer( void ) 311 313 { 312 313 314 } 315 316 /*********************************************************************** 317 * 314 FIXME( "(): stub\n" ); 315 return E_FAIL; 316 } 317 318 /*********************************************************************** 319 * DllUnregisterServer (QUARTZ.@) 318 320 */ 319 321 320 322 HRESULT WINAPI QUARTZ_DllUnregisterServer( void ) 321 323 { 322 323 324 } 325 324 FIXME( "(): stub\n" ); 325 return E_FAIL; 326 } 327
Note:
See TracChangeset
for help on using the changeset viewer.