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