crypt32: Add additional path for Solaris 11 Express.
[wine] / programs / wscript / host.c
1 /*
2  * Copyright 2010 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 <stdarg.h>
20
21 #define COBJMACROS
22 #define CONST_VTABLE
23
24 #include <windef.h>
25 #include <winbase.h>
26 #include <ole2.h>
27
28 #include "wscript.h"
29
30 #include <wine/debug.h>
31
32 #define BUILDVERSION 16535
33
34 static const WCHAR wshNameW[] = {'W','i','n','d','o','w','s',' ','S','c','r','i','p','t',' ','H','o','s','t',0};
35 static const WCHAR wshVersionW[] = {'5','.','8'};
36
37 WINE_DEFAULT_DEBUG_CHANNEL(wscript);
38
39 static HRESULT WINAPI Host_QueryInterface(IHost *iface, REFIID riid, void **ppv)
40 {
41     WINE_TRACE("(%s %p)\n", wine_dbgstr_guid(riid), ppv);
42
43     if(IsEqualGUID(&IID_IUnknown, riid)
44        || IsEqualGUID(&IID_IDispatch, riid)
45        || IsEqualGUID(&IID_IHost, riid)) {
46         *ppv = iface;
47         return S_OK;
48     }
49
50     *ppv = NULL;
51     return E_NOINTERFACE;
52 }
53
54 static ULONG WINAPI Host_AddRef(IHost *iface)
55 {
56     return 2;
57 }
58
59 static ULONG WINAPI Host_Release(IHost *iface)
60 {
61     return 1;
62 }
63
64 static HRESULT WINAPI Host_GetTypeInfoCount(IHost *iface, UINT *pctinfo)
65 {
66     WINE_TRACE("(%p)\n", pctinfo);
67     *pctinfo = 1;
68     return S_OK;
69 }
70
71 static HRESULT WINAPI Host_GetTypeInfo(IHost *iface, UINT iTInfo, LCID lcid,
72         ITypeInfo **ppTInfo)
73 {
74     WINE_TRACE("(%x %x %p\n", iTInfo, lcid, ppTInfo);
75
76     ITypeInfo_AddRef(host_ti);
77     *ppTInfo = host_ti;
78     return S_OK;
79 }
80
81 static HRESULT WINAPI Host_GetIDsOfNames(IHost *iface, REFIID riid, LPOLESTR *rgszNames,
82         UINT cNames, LCID lcid, DISPID *rgDispId)
83 {
84     WINE_TRACE("(%s %p %d %x %p)\n", wine_dbgstr_guid(riid), rgszNames,
85         cNames, lcid, rgDispId);
86
87     return ITypeInfo_GetIDsOfNames(host_ti, rgszNames, cNames, rgDispId);
88 }
89
90 static HRESULT WINAPI Host_Invoke(IHost *iface, DISPID dispIdMember, REFIID riid,
91         LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
92         EXCEPINFO *pExcepInfo, UINT *puArgErr)
93 {
94     WINE_TRACE("(%d %p %p)\n", dispIdMember, pDispParams, pVarResult);
95
96     return ITypeInfo_Invoke(host_ti, iface, dispIdMember, wFlags, pDispParams,
97             pVarResult, pExcepInfo, puArgErr);
98 }
99
100 static HRESULT WINAPI Host_get_Name(IHost *iface, BSTR *out_Name)
101 {
102     WINE_TRACE("(%p)\n", out_Name);
103
104     if(!(*out_Name = SysAllocString(wshNameW)))
105         return E_OUTOFMEMORY;
106     return S_OK;
107 }
108
109 static HRESULT WINAPI Host_get_Application(IHost *iface, IDispatch **out_Dispatch)
110 {
111     WINE_FIXME("(%p)\n", out_Dispatch);
112     return E_NOTIMPL;
113 }
114
115 static HRESULT WINAPI Host_get_FullName(IHost *iface, BSTR *out_Path)
116 {
117     WINE_FIXME("(%p)\n", out_Path);
118     return E_NOTIMPL;
119 }
120
121 static HRESULT WINAPI Host_get_Path(IHost *iface, BSTR *out_Path)
122 {
123     WINE_FIXME("(%p)\n", out_Path);
124     return E_NOTIMPL;
125 }
126
127 static HRESULT WINAPI Host_get_Interactive(IHost *iface, VARIANT_BOOL *out_Interactive)
128 {
129     WINE_FIXME("(%p)\n", out_Interactive);
130     return E_NOTIMPL;
131 }
132
133 static HRESULT WINAPI Host_put_Interactive(IHost *iface, VARIANT_BOOL v)
134 {
135     WINE_FIXME("(%x)\n", v);
136     return E_NOTIMPL;
137 }
138
139 static HRESULT WINAPI Host_Quit(IHost *iface, int ExitCode)
140 {
141     WINE_FIXME("(%d)\n", ExitCode);
142     return E_NOTIMPL;
143 }
144
145 static HRESULT WINAPI Host_get_ScriptName(IHost *iface, BSTR *out_ScriptName)
146 {
147     WINE_FIXME("(%p)\n", out_ScriptName);
148     return E_NOTIMPL;
149 }
150
151 static HRESULT WINAPI Host_get_ScriptFullName(IHost *iface, BSTR *out_ScriptFullName)
152 {
153     WINE_FIXME("(%p)\n", out_ScriptFullName);
154     return E_NOTIMPL;
155 }
156
157 static HRESULT WINAPI Host_get_Arguments(IHost *iface, IArguments2 **out_Arguments)
158 {
159     WINE_FIXME("(%p)\n", out_Arguments);
160     return E_NOTIMPL;
161 }
162
163 static HRESULT WINAPI Host_get_Version(IHost *iface, BSTR *out_Version)
164 {
165     WINE_TRACE("(%p)\n", out_Version);
166
167     if(!(*out_Version = SysAllocString(wshVersionW)))
168         return E_OUTOFMEMORY;
169     return S_OK;
170 }
171
172 static HRESULT WINAPI Host_get_BuildVersion(IHost *iface, int *out_Build)
173 {
174     WINE_TRACE("(%p)\n", out_Build);
175
176     *out_Build = BUILDVERSION;
177     return S_OK;
178 }
179
180 static HRESULT WINAPI Host_get_Timeout(IHost *iface, LONG *out_Timeout)
181 {
182     WINE_FIXME("(%p)\n", out_Timeout);
183     return E_NOTIMPL;
184 }
185
186 static HRESULT WINAPI Host_put_Timeout(IHost *iface, LONG v)
187 {
188     WINE_FIXME("(%d)\n", v);
189     return E_NOTIMPL;
190 }
191
192 static HRESULT WINAPI Host_CreateObject(IHost *iface, BSTR ProgID, BSTR Prefix,
193         IDispatch **out_Dispatch)
194 {
195     WINE_FIXME("(%s %s %p)\n", wine_dbgstr_w(ProgID), wine_dbgstr_w(Prefix), out_Dispatch);
196     return E_NOTIMPL;
197 }
198
199 static HRESULT WINAPI Host_Echo(IHost *iface, SAFEARRAY *args)
200 {
201     WINE_FIXME("(%p)\n", args);
202     return E_NOTIMPL;
203 }
204
205 static HRESULT WINAPI Host_GetObject(IHost *iface, BSTR Pathname, BSTR ProgID,
206         BSTR Prefix, IDispatch **out_Dispatch)
207 {
208     WINE_FIXME("(%s %s %s %p)\n", wine_dbgstr_w(Pathname), wine_dbgstr_w(ProgID),
209         wine_dbgstr_w(Prefix), out_Dispatch);
210     return E_NOTIMPL;
211 }
212
213 static HRESULT WINAPI Host_DisconnectObject(IHost *iface, IDispatch *Object)
214 {
215     WINE_FIXME("(%p)\n", Object);
216     return E_NOTIMPL;
217 }
218
219 static HRESULT WINAPI Host_Sleep(IHost *iface, LONG Time)
220 {
221     WINE_FIXME("(%d)\n", Time);
222     return E_NOTIMPL;
223 }
224
225 static HRESULT WINAPI Host_ConnectObject(IHost *iface, IDispatch *Object, BSTR Prefix)
226 {
227     WINE_FIXME("(%p %s)\n", Object, wine_dbgstr_w(Prefix));
228     return E_NOTIMPL;
229 }
230
231 static HRESULT WINAPI Host_get_StdIn(IHost *iface, ITextStream **ppts)
232 {
233     WINE_FIXME("(%p)\n", ppts);
234     return E_NOTIMPL;
235 }
236
237 static HRESULT WINAPI Host_get_StdOut(IHost *iface, ITextStream **ppts)
238 {
239     WINE_FIXME("(%p)\n", ppts);
240     return E_NOTIMPL;
241 }
242
243 static HRESULT WINAPI Host_get_StdErr(IHost *iface, ITextStream **ppts)
244 {
245     WINE_FIXME("(%p)\n", ppts);
246     return E_NOTIMPL;
247 }
248
249 static const IHostVtbl HostVtbl = {
250     Host_QueryInterface,
251     Host_AddRef,
252     Host_Release,
253     Host_GetTypeInfoCount,
254     Host_GetTypeInfo,
255     Host_GetIDsOfNames,
256     Host_Invoke,
257     Host_get_Name,
258     Host_get_Application,
259     Host_get_FullName,
260     Host_get_Path,
261     Host_get_Interactive,
262     Host_put_Interactive,
263     Host_Quit,
264     Host_get_ScriptName,
265     Host_get_ScriptFullName,
266     Host_get_Arguments,
267     Host_get_Version,
268     Host_get_BuildVersion,
269     Host_get_Timeout,
270     Host_put_Timeout,
271     Host_CreateObject,
272     Host_Echo,
273     Host_GetObject,
274     Host_DisconnectObject,
275     Host_Sleep,
276     Host_ConnectObject,
277     Host_get_StdIn,
278     Host_get_StdOut,
279     Host_get_StdErr
280 };
281
282 IHost host_obj = { &HostVtbl };