vbscript: Moved includes required by vbscript.h to the header.
[wine] / dlls / vbscript / vbscript_main.c
1 /*
2  * Copyright 2011 Jacek Caban for CodeWeavers
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18
19 #include "initguid.h"
20
21 #include "vbscript.h"
22 #include "objsafe.h"
23 #include "rpcproxy.h"
24 #include "vbscript_classes.h"
25
26 #include "wine/debug.h"
27
28 WINE_DEFAULT_DEBUG_CHANNEL(vbscript);
29
30 static HINSTANCE vbscript_hinstance;
31
32 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
33 {
34     *ppv = NULL;
35
36     if(IsEqualGUID(&IID_IUnknown, riid)) {
37         TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
38         *ppv = iface;
39     }else if(IsEqualGUID(&IID_IClassFactory, riid)) {
40         TRACE("(%p)->(IID_IClassFactory %p)\n", iface, ppv);
41         *ppv = iface;
42     }
43
44     if(*ppv) {
45         IUnknown_AddRef((IUnknown*)*ppv);
46         return S_OK;
47     }
48
49     FIXME("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
50     return E_NOINTERFACE;
51 }
52
53 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
54 {
55     TRACE("(%p)\n", iface);
56     return 2;
57 }
58
59 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
60 {
61     TRACE("(%p)\n", iface);
62     return 1;
63 }
64
65 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL fLock)
66 {
67     TRACE("(%p)->(%x)\n", iface, fLock);
68     return S_OK;
69 }
70
71 static const IClassFactoryVtbl VBScriptFactoryVtbl = {
72     ClassFactory_QueryInterface,
73     ClassFactory_AddRef,
74     ClassFactory_Release,
75     VBScriptFactory_CreateInstance,
76     ClassFactory_LockServer
77 };
78
79 static IClassFactory VBScriptFactory = { &VBScriptFactoryVtbl };
80
81 /******************************************************************
82  *              DllMain (vbscript.@)
83  */
84 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
85 {
86     TRACE("(%p %d %p)\n", hInstDLL, fdwReason, lpv);
87
88     switch(fdwReason)
89     {
90     case DLL_WINE_PREATTACH:
91         return FALSE;  /* prefer native version */
92     case DLL_PROCESS_ATTACH:
93         DisableThreadLibraryCalls(hInstDLL);
94         vbscript_hinstance = hInstDLL;
95         break;
96     }
97
98     return TRUE;
99 }
100
101 /***********************************************************************
102  *              DllGetClassObject       (vbscript.@)
103  */
104 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
105 {
106     if(IsEqualGUID(&CLSID_VBScript, rclsid)) {
107         TRACE("(CLSID_VBScript %s %p)\n", debugstr_guid(riid), ppv);
108         return IClassFactory_QueryInterface(&VBScriptFactory, riid, ppv);
109     }
110
111     FIXME("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
112     return CLASS_E_CLASSNOTAVAILABLE;
113 }
114
115 /***********************************************************************
116  *          DllCanUnloadNow (vbscript.@)
117  */
118 HRESULT WINAPI DllCanUnloadNow(void)
119 {
120     return S_FALSE;
121 }
122
123 /***********************************************************************
124  *          DllRegisterServer (vbscript.@)
125  */
126 HRESULT WINAPI DllRegisterServer(void)
127 {
128     TRACE("()\n");
129     return __wine_register_resources(vbscript_hinstance);
130 }
131
132 /***********************************************************************
133  *          DllUnregisterServer (vbscript.@)
134  */
135 HRESULT WINAPI DllUnregisterServer(void)
136 {
137     TRACE("()\n");
138     return __wine_unregister_resources(vbscript_hinstance);
139 }