ReactOS  0.4.12-dev-102-g4b7f1e0
main.c File Reference
#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
#include <winreg.h>
#include <ole2.h>
#include <shellapi.h>
#include <activscp.h>
#include <initguid.h>
#include "wscript.h"
#include <wine/debug.h>
#include <wine/unicode.h>
Include dependency graph for main.c:

Go to the source code of this file.

Macros

#define COBJMACROS
 
#define IActiveScriptParse_Release   IActiveScriptParse32_Release
 
#define IActiveScriptParse_InitNew   IActiveScriptParse32_InitNew
 
#define IActiveScriptParse_ParseScriptText   IActiveScriptParse32_ParseScriptText
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (wscript)
 
static HRESULT query_interface (REFIID, void **)
 
static HRESULT WINAPI ActiveScriptSite_QueryInterface (IActiveScriptSite *iface, REFIID riid, void **ppv)
 
static ULONG WINAPI ActiveScriptSite_AddRef (IActiveScriptSite *iface)
 
static ULONG WINAPI ActiveScriptSite_Release (IActiveScriptSite *iface)
 
static HRESULT WINAPI ActiveScriptSite_GetLCID (IActiveScriptSite *iface, LCID *plcid)
 
static HRESULT WINAPI ActiveScriptSite_GetItemInfo (IActiveScriptSite *iface, LPCOLESTR pstrName, DWORD dwReturnMask, IUnknown **ppunkItem, ITypeInfo **ppti)
 
static HRESULT WINAPI ActiveScriptSite_GetDocVersionString (IActiveScriptSite *iface, BSTR *pbstrVersion)
 
static HRESULT WINAPI ActiveScriptSite_OnScriptTerminate (IActiveScriptSite *iface, const VARIANT *pvarResult, const EXCEPINFO *pexcepinfo)
 
static HRESULT WINAPI ActiveScriptSite_OnStateChange (IActiveScriptSite *iface, SCRIPTSTATE ssScriptState)
 
static HRESULT WINAPI ActiveScriptSite_OnScriptError (IActiveScriptSite *iface, IActiveScriptError *pscripterror)
 
static HRESULT WINAPI ActiveScriptSite_OnEnterScript (IActiveScriptSite *iface)
 
static HRESULT WINAPI ActiveScriptSite_OnLeaveScript (IActiveScriptSite *iface)
 
static HRESULT WINAPI ActiveScriptSiteWindow_QueryInterface (IActiveScriptSiteWindow *iface, REFIID riid, void **ppv)
 
static ULONG WINAPI ActiveScriptSiteWindow_AddRef (IActiveScriptSiteWindow *iface)
 
static ULONG WINAPI ActiveScriptSiteWindow_Release (IActiveScriptSiteWindow *iface)
 
static HRESULT WINAPI ActiveScriptSiteWindow_GetWindow (IActiveScriptSiteWindow *iface, HWND *phwnd)
 
static HRESULT WINAPI ActiveScriptSiteWindow_EnableModeless (IActiveScriptSiteWindow *iface, BOOL fEnable)
 
static BOOL load_typelib (void)
 
static BOOL get_engine_clsid (const WCHAR *ext, CLSID *clsid)
 
static BOOL create_engine (CLSID *clsid, IActiveScript **script_ret, IActiveScriptParse **parser)
 
static BOOL init_engine (IActiveScript *script, IActiveScriptParse *parser)
 
static BSTR get_script_str (const WCHAR *filename)
 
static void run_script (const WCHAR *filename, IActiveScript *script, IActiveScriptParse *parser)
 
static BOOL set_host_properties (const WCHAR *prop)
 
int WINAPI wWinMain (HINSTANCE hInst, HINSTANCE hPrevInst, LPWSTR cmdline, int cmdshow)
 

Variables

static const WCHAR wscriptW [] = {'W','S','c','r','i','p','t',0}
 
static const WCHAR wshW [] = {'W','S','H',0}
 
WCHAR scriptFullName [MAX_PATH]
 
ITypeInfohost_ti
 
ITypeInfoarguments_ti
 
static IActiveScriptSiteVtbl ActiveScriptSiteVtbl
 
static IActiveScriptSite script_site = { &ActiveScriptSiteVtbl }
 
static const IActiveScriptSiteWindowVtbl ActiveScriptSiteWindowVtbl
 
static IActiveScriptSiteWindow script_site_window = { &ActiveScriptSiteWindowVtbl }
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 21 of file main.c.

◆ IActiveScriptParse_InitNew

#define IActiveScriptParse_InitNew   IActiveScriptParse32_InitNew

Definition at line 48 of file main.c.

Referenced by init_engine().

◆ IActiveScriptParse_ParseScriptText

#define IActiveScriptParse_ParseScriptText   IActiveScriptParse32_ParseScriptText

Definition at line 49 of file main.c.

Referenced by run_script().

◆ IActiveScriptParse_Release

#define IActiveScriptParse_Release   IActiveScriptParse32_Release

Definition at line 47 of file main.c.

Referenced by wWinMain().

Function Documentation

◆ ActiveScriptSite_AddRef()

static ULONG WINAPI ActiveScriptSite_AddRef ( IActiveScriptSite iface)
static

Definition at line 70 of file main.c.

71 {
72  return 2;
73 }

◆ ActiveScriptSite_GetDocVersionString()

static HRESULT WINAPI ActiveScriptSite_GetDocVersionString ( IActiveScriptSite iface,
BSTR pbstrVersion 
)
static

Definition at line 109 of file main.c.

111 {
112  WINE_FIXME("()\n");
113  return E_NOTIMPL;
114 }
#define E_NOTIMPL
Definition: ddrawi.h:99
#define WINE_FIXME
Definition: debug.h:365

◆ ActiveScriptSite_GetItemInfo()

static HRESULT WINAPI ActiveScriptSite_GetItemInfo ( IActiveScriptSite iface,
LPCOLESTR  pstrName,
DWORD  dwReturnMask,
IUnknown **  ppunkItem,
ITypeInfo **  ppti 
)
static

Definition at line 88 of file main.c.

90 {
91  WINE_TRACE("(%s %x %p %p)\n", wine_dbgstr_w(pstrName), dwReturnMask, ppunkItem, ppti);
92 
93  if(strcmpW(pstrName, wshW) && strcmpW(pstrName, wscriptW))
94  return E_FAIL;
95 
96  if(dwReturnMask & SCRIPTINFO_ITYPEINFO) {
97  ITypeInfo_AddRef(host_ti);
98  *ppti = host_ti;
99  }
100 
101  if(dwReturnMask & SCRIPTINFO_IUNKNOWN) {
102  IHost_AddRef(&host_obj);
103  *ppunkItem = (IUnknown*)&host_obj;
104  }
105 
106  return S_OK;
107 }
IHost host_obj
Definition: host.c:472
#define WINE_TRACE
Definition: debug.h:353
#define E_FAIL
Definition: ddrawi.h:102
char * wine_dbgstr_w(const wchar_t *wstr)
Definition: CString.cpp:62
static const WCHAR wscriptW[]
Definition: main.c:55
ITypeInfo * host_ti
Definition: main.c:59
static const WCHAR wshW[]
Definition: main.c:56
#define S_OK
Definition: intsafe.h:59
WINE_UNICODE_INLINE int strcmpW(const WCHAR *str1, const WCHAR *str2)
Definition: unicode.h:229

◆ ActiveScriptSite_GetLCID()

static HRESULT WINAPI ActiveScriptSite_GetLCID ( IActiveScriptSite iface,
LCID plcid 
)
static

Definition at line 80 of file main.c.

81 {
82  WINE_TRACE("()\n");
83 
84  *plcid = GetUserDefaultLCID();
85  return S_OK;
86 }
#define WINE_TRACE
Definition: debug.h:353
LCID WINAPI GetUserDefaultLCID(void)
Definition: lang.c:523
#define S_OK
Definition: intsafe.h:59

◆ ActiveScriptSite_OnEnterScript()

static HRESULT WINAPI ActiveScriptSite_OnEnterScript ( IActiveScriptSite iface)
static

Definition at line 137 of file main.c.

138 {
139  WINE_TRACE("()\n");
140  return S_OK;
141 }
#define WINE_TRACE
Definition: debug.h:353
#define S_OK
Definition: intsafe.h:59

◆ ActiveScriptSite_OnLeaveScript()

static HRESULT WINAPI ActiveScriptSite_OnLeaveScript ( IActiveScriptSite iface)
static

Definition at line 143 of file main.c.

144 {
145  WINE_TRACE("()\n");
146  return S_OK;
147 }
#define WINE_TRACE
Definition: debug.h:353
#define S_OK
Definition: intsafe.h:59

◆ ActiveScriptSite_OnScriptError()

static HRESULT WINAPI ActiveScriptSite_OnScriptError ( IActiveScriptSite iface,
IActiveScriptError pscripterror 
)
static

Definition at line 130 of file main.c.

132 {
133  WINE_FIXME("()\n");
134  return E_NOTIMPL;
135 }
#define E_NOTIMPL
Definition: ddrawi.h:99
#define WINE_FIXME
Definition: debug.h:365

◆ ActiveScriptSite_OnScriptTerminate()

static HRESULT WINAPI ActiveScriptSite_OnScriptTerminate ( IActiveScriptSite iface,
const VARIANT pvarResult,
const EXCEPINFO *  pexcepinfo 
)
static

Definition at line 116 of file main.c.

118 {
119  WINE_FIXME("()\n");
120  return E_NOTIMPL;
121 }
#define E_NOTIMPL
Definition: ddrawi.h:99
#define WINE_FIXME
Definition: debug.h:365

◆ ActiveScriptSite_OnStateChange()

static HRESULT WINAPI ActiveScriptSite_OnStateChange ( IActiveScriptSite iface,
SCRIPTSTATE  ssScriptState 
)
static

Definition at line 123 of file main.c.

125 {
126  WINE_TRACE("(%x)\n", ssScriptState);
127  return S_OK;
128 }
#define WINE_TRACE
Definition: debug.h:353
#define S_OK
Definition: intsafe.h:59

◆ ActiveScriptSite_QueryInterface()

static HRESULT WINAPI ActiveScriptSite_QueryInterface ( IActiveScriptSite iface,
REFIID  riid,
void **  ppv 
)
static

Definition at line 64 of file main.c.

66 {
67  return query_interface(riid, ppv);
68 }
static HRESULT query_interface(REFIID, void **)
Definition: main.c:204
REFIID riid
Definition: precomp.h:44

◆ ActiveScriptSite_Release()

static ULONG WINAPI ActiveScriptSite_Release ( IActiveScriptSite iface)
static

Definition at line 75 of file main.c.

76 {
77  return 1;
78 }

◆ ActiveScriptSiteWindow_AddRef()

static ULONG WINAPI ActiveScriptSiteWindow_AddRef ( IActiveScriptSiteWindow iface)
static

Definition at line 170 of file main.c.

171 {
172  return 2;
173 }

◆ ActiveScriptSiteWindow_EnableModeless()

static HRESULT WINAPI ActiveScriptSiteWindow_EnableModeless ( IActiveScriptSiteWindow iface,
BOOL  fEnable 
)
static

Definition at line 188 of file main.c.

189 {
190  TRACE("(%x)\n", fEnable);
191  return S_OK;
192 }
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59

◆ ActiveScriptSiteWindow_GetWindow()

static HRESULT WINAPI ActiveScriptSiteWindow_GetWindow ( IActiveScriptSiteWindow iface,
HWND phwnd 
)
static

Definition at line 180 of file main.c.

181 {
182  TRACE("(%p)\n", phwnd);
183 
184  *phwnd = NULL;
185  return S_OK;
186 }
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59

◆ ActiveScriptSiteWindow_QueryInterface()

static HRESULT WINAPI ActiveScriptSiteWindow_QueryInterface ( IActiveScriptSiteWindow iface,
REFIID  riid,
void **  ppv 
)
static

Definition at line 165 of file main.c.

166 {
167  return query_interface(riid, ppv);
168 }
static HRESULT query_interface(REFIID, void **)
Definition: main.c:204
REFIID riid
Definition: precomp.h:44

◆ ActiveScriptSiteWindow_Release()

static ULONG WINAPI ActiveScriptSiteWindow_Release ( IActiveScriptSiteWindow iface)
static

Definition at line 175 of file main.c.

176 {
177  return 1;
178 }

◆ create_engine()

static BOOL create_engine ( CLSID clsid,
IActiveScript **  script_ret,
IActiveScriptParse **  parser 
)
static

Definition at line 284 of file main.c.

Referenced by wWinMain().

286 {
288  IUnknown *unk;
289  HRESULT hres;
290 
291  hres = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
292  &IID_IUnknown, (void**)&unk);
293  if(FAILED(hres))
294  return FALSE;
295 
296  hres = IUnknown_QueryInterface(unk, &IID_IActiveScript, (void**)&script);
297  IUnknown_Release(unk);
298  if(FAILED(hres))
299  return FALSE;
300 
301  hres = IActiveScript_QueryInterface(script, &IID_IActiveScriptParse, (void**)parser);
302  if(FAILED(hres)) {
303  IActiveScript_Release(script);
304  return FALSE;
305  }
306 
307  *script_ret = script;
308  return TRUE;
309 }
#define TRUE
Definition: types.h:120
smooth NULL
Definition: ftsmooth.c:416
script
Definition: msipriv.h:374
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
const GUID IID_IUnknown
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3237
Definition: import.c:86

◆ get_engine_clsid()

static BOOL get_engine_clsid ( const WCHAR ext,
CLSID clsid 
)
static

Definition at line 244 of file main.c.

Referenced by wWinMain().

245 {
246  WCHAR fileid[64], progid[64];
247  DWORD res;
248  LONG size;
249  HKEY hkey;
250  HRESULT hres;
251 
252  static const WCHAR script_engineW[] =
253  {'\\','S','c','r','i','p','t','E','n','g','i','n','e',0};
254 
255  res = RegOpenKeyW(HKEY_CLASSES_ROOT, ext, &hkey);
256  if(res != ERROR_SUCCESS)
257  return FALSE;
258 
259  size = ARRAY_SIZE(fileid);
260  res = RegQueryValueW(hkey, NULL, fileid, &size);
261  RegCloseKey(hkey);
262  if(res != ERROR_SUCCESS)
263  return FALSE;
264 
265  WINE_TRACE("fileid is %s\n", wine_dbgstr_w(fileid));
266 
267  strcatW(fileid, script_engineW);
268  res = RegOpenKeyW(HKEY_CLASSES_ROOT, fileid, &hkey);
269  if(res != ERROR_SUCCESS)
270  return FALSE;
271 
272  size = ARRAY_SIZE(progid);
273  res = RegQueryValueW(hkey, NULL, progid, &size);
274  RegCloseKey(hkey);
275  if(res != ERROR_SUCCESS)
276  return FALSE;
277 
278  WINE_TRACE("ProgID is %s\n", wine_dbgstr_w(progid));
279 
280  hres = CLSIDFromProgID(progid, clsid);
281  return SUCCEEDED(hres);
282 }
#define ERROR_SUCCESS
Definition: deptool.c:10
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define WINE_TRACE
Definition: debug.h:353
HRESULT WINAPI DECLSPEC_HOTPATCH CLSIDFromProgID(LPCOLESTR progid, LPCLSID clsid)
Definition: compobj.c:2514
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
long LONG
Definition: pedump.c:60
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3311
char * wine_dbgstr_w(const wchar_t *wstr)
Definition: CString.cpp:62
smooth NULL
Definition: ftsmooth.c:416
char ext[3]
Definition: mkdosfs.c:358
GLsizeiptr size
Definition: glext.h:5919
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
LSTATUS WINAPI RegQueryValueW(HKEY hkey, LPCWSTR name, LPWSTR data, LPLONG count)
Definition: reg.c:4272
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ARRAY_SIZE(a)
Definition: main.h:24
WINE_UNICODE_INLINE WCHAR * strcatW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:242
GLuint res
Definition: glext.h:9613
#define progid(str)
Definition: exdisp.idl:31
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
#define SUCCEEDED(hr)
Definition: intsafe.h:57

◆ get_script_str()

static BSTR get_script_str ( const WCHAR filename)
static

Definition at line 338 of file main.c.

Referenced by run_script().

339 {
340  const char *file_map;
341  HANDLE file, map;
342  DWORD size, len;
343  BSTR ret;
344 
346  if(file == INVALID_HANDLE_VALUE)
347  return NULL;
348 
349  size = GetFileSize(file, NULL);
350  map = CreateFileMappingW(file, NULL, PAGE_READONLY, 0, 0, NULL);
351  CloseHandle(file);
352  if(map == INVALID_HANDLE_VALUE)
353  return NULL;
354 
355  file_map = MapViewOfFile(map, FILE_MAP_READ, 0, 0, 0);
356  CloseHandle(map);
357  if(!file_map)
358  return NULL;
359 
360  len = MultiByteToWideChar(CP_ACP, 0, file_map, size, NULL, 0);
361  ret = SysAllocStringLen(NULL, len);
362  MultiByteToWideChar(CP_ACP, 0, file_map, size, ret, len);
363 
364  UnmapViewOfFile(file_map);
365  return ret;
366 }
#define CloseHandle
Definition: compat.h:398
#define MapViewOfFile
Definition: compat.h:402
BSTR WINAPI SysAllocStringLen(const OLECHAR *str, unsigned int len)
Definition: oleaut.c:343
#define CP_ACP
Definition: compat.h:99
GLenum GLclampf GLint GLenum GLuint GLenum GLenum GLsizei GLenum const GLvoid GLfloat GLfloat GLfloat GLfloat GLclampd GLint GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean GLboolean GLboolean GLboolean GLint GLenum GLsizei const GLvoid GLenum GLint GLenum GLint GLint GLsizei GLint GLenum GLint GLint GLint GLint GLsizei GLenum GLsizei const GLuint GLboolean GLenum GLenum GLint GLsizei GLenum GLsizei GLenum const GLvoid GLboolean const GLboolean GLenum const GLdouble const GLfloat const GLdouble const GLfloat GLenum GLint GLint GLint GLint GLint GLint GLenum GLfloat GLenum GLint GLenum GLsizei GLenum GLboolean GLenum GLdouble GLenum GLfloat GLenum GLenum GLfloat GLenum GLenum GLdouble GLenum GLenum GLint GLenum GLenum GLint GLenum map
Definition: glfuncs.h:124
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
OLECHAR * BSTR
Definition: compat.h:1927
const char * filename
Definition: ioapi.h:135
smooth NULL
Definition: ftsmooth.c:416
#define FILE_MAP_READ
Definition: compat.h:427
#define OPEN_EXISTING
Definition: compat.h:426
GLsizeiptr size
Definition: glext.h:5919
#define CreateFileMappingW(a, b, c, d, e, f)
Definition: compat.h:401
const char file[]
Definition: icontest.c:11
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:481
int ret
GLenum GLsizei len
Definition: glext.h:6722
#define GENERIC_READ
Definition: compat.h:124
#define PAGE_READONLY
Definition: compat.h:127
#define MultiByteToWideChar
Definition: compat.h:100
#define CreateFileW
Definition: compat.h:400
#define UnmapViewOfFile
Definition: compat.h:403

◆ init_engine()

static BOOL init_engine ( IActiveScript script,
IActiveScriptParse *  parser 
)
static

Definition at line 311 of file main.c.

Referenced by wWinMain().

312 {
313  HRESULT hres;
314 
315  if(!load_typelib())
316  return FALSE;
317 
318  hres = IActiveScript_SetScriptSite(script, &script_site);
319  if(FAILED(hres))
320  return FALSE;
321 
323  if(FAILED(hres))
324  return FALSE;
325 
326  hres = IActiveScript_AddNamedItem(script, wscriptW, SCRIPTITEM_ISVISIBLE);
327  if(FAILED(hres))
328  return FALSE;
329 
330  hres = IActiveScript_AddNamedItem(script, wshW, SCRIPTITEM_ISVISIBLE);
331  if(FAILED(hres))
332  return FALSE;
333 
334  hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_INITIALIZED);
335  return SUCCEEDED(hres);
336 }
static IActiveScriptSite script_site
Definition: main.c:163
static BOOL load_typelib(void)
Definition: main.c:225
static const WCHAR wscriptW[]
Definition: main.c:55
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
static const WCHAR wshW[]
Definition: main.c:56
#define IActiveScriptParse_InitNew
Definition: main.c:48
Definition: import.c:86
#define SUCCEEDED(hr)
Definition: intsafe.h:57

◆ load_typelib()

static BOOL load_typelib ( void  )
static

Definition at line 225 of file main.c.

Referenced by init_engine().

226 {
227  ITypeLib *typelib;
228  HRESULT hres;
229 
230  static const WCHAR wscript_exeW[] = {'w','s','c','r','i','p','t','.','e','x','e',0};
231 
232  hres = LoadTypeLib(wscript_exeW, &typelib);
233  if(FAILED(hres))
234  return FALSE;
235 
236  hres = ITypeLib_GetTypeInfoOfGuid(typelib, &IID_IHost, &host_ti);
237  if(SUCCEEDED(hres))
238  hres = ITypeLib_GetTypeInfoOfGuid(typelib, &IID_IArguments2, &arguments_ti);
239 
240  ITypeLib_Release(typelib);
241  return SUCCEEDED(hres);
242 }
__wchar_t WCHAR
Definition: xmlstorage.h:180
static ITypeLib * typelib
Definition: apps.c:105
HRESULT WINAPI LoadTypeLib(const OLECHAR *szFile, ITypeLib **pptLib)
Definition: typelib.c:461
ITypeInfo * arguments_ti
Definition: main.c:60
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
ITypeInfo * host_ti
Definition: main.c:59
#define SUCCEEDED(hr)
Definition: intsafe.h:57

◆ query_interface()

static HRESULT query_interface ( REFIID  riid,
void **  ppv 
)
static

Definition at line 204 of file main.c.

Referenced by ActiveScriptSite_QueryInterface(), and ActiveScriptSiteWindow_QueryInterface().

205 {
206  if(IsEqualGUID(riid, &IID_IUnknown)) {
207  TRACE("(IID_IUnknown %p)\n", ppv);
208  *ppv = &script_site;
209  }else if(IsEqualGUID(riid, &IID_IActiveScriptSite)) {
210  TRACE("(IID_IActiveScriptSite %p)\n", ppv);
211  *ppv = &script_site;
212  }else if(IsEqualGUID(riid, &IID_IActiveScriptSiteWindow)) {
213  TRACE("(IID_IActiveScriptSiteWindow %p)\n", ppv);
214  *ppv = &script_site_window;
215  }else {
216  *ppv = NULL;
217  TRACE("(%s %p)\n", wine_dbgstr_guid(riid), ppv);
218  return E_NOINTERFACE;
219  }
220 
221  IUnknown_AddRef((IUnknown*)*ppv);
222  return S_OK;
223 }
static IActiveScriptSite script_site
Definition: main.c:163
#define E_NOINTERFACE
Definition: winerror.h:2364
REFIID riid
Definition: precomp.h:44
const char * wine_dbgstr_guid(const GUID *guid)
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
const GUID IID_IUnknown
#define S_OK
Definition: intsafe.h:59
static IActiveScriptSiteWindow script_site_window
Definition: main.c:202
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4024

◆ run_script()

static void run_script ( const WCHAR filename,
IActiveScript script,
IActiveScriptParse *  parser 
)
static

Definition at line 368 of file main.c.

Referenced by wWinMain().

369 {
370  BSTR text;
371  HRESULT hres;
372 
373  text = get_script_str(filename);
374  if(!text) {
375  WINE_FIXME("Could not get script text\n");
376  return;
377  }
378 
380  SCRIPTTEXT_HOSTMANAGESSOURCE|SCRIPTITEM_ISVISIBLE, NULL, NULL);
381  SysFreeString(text);
382  if(FAILED(hres)) {
383  WINE_FIXME("ParseScriptText failed: %08x\n", hres);
384  return;
385  }
386 
387  hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_STARTED);
388  if(FAILED(hres))
389  WINE_FIXME("SetScriptState failed: %08x\n", hres);
390 }
const WCHAR * text
Definition: package.c:1827
void WINAPI SysFreeString(BSTR str)
Definition: oleaut.c:275
OLECHAR * BSTR
Definition: compat.h:1927
const char * filename
Definition: ioapi.h:135
smooth NULL
Definition: ftsmooth.c:416
static BSTR get_script_str(const WCHAR *filename)
Definition: main.c:338
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
Definition: import.c:86
#define IActiveScriptParse_ParseScriptText
Definition: main.c:49
#define WINE_FIXME
Definition: debug.h:365

◆ set_host_properties()

static BOOL set_host_properties ( const WCHAR prop)
static

Definition at line 392 of file main.c.

Referenced by wWinMain().

393 {
394  static const WCHAR nologoW[] = {'n','o','l','o','g','o',0};
395  static const WCHAR iactive[] = {'i',0};
396  static const WCHAR batch[] = {'b',0};
397 
398  if(*prop == '/') {
399  ++prop;
400  if(*prop == '/')
401  ++prop;
402  }
403  else
404  ++prop;
405 
406  if(strcmpiW(prop, iactive) == 0)
407  wshInteractive = VARIANT_TRUE;
408  else if(strcmpiW(prop, batch) == 0)
409  wshInteractive = VARIANT_FALSE;
410  else if(strcmpiW(prop, nologoW) == 0)
411  WINE_FIXME("ignored %s switch\n", debugstr_w(nologoW));
412  else
413  {
414  WINE_FIXME("unsupported switch %s\n", debugstr_w(prop));
415  return FALSE;
416  }
417  return TRUE;
418 }
#define TRUE
Definition: types.h:120
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define debugstr_w
Definition: kernel32.h:32
#define strcmpiW(s1, s2)
Definition: unicode.h:39
VARIANT_BOOL wshInteractive
Definition: host.c:41
#define WINE_FIXME
Definition: debug.h:365

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( wscript  )

◆ wWinMain()

int WINAPI wWinMain ( HINSTANCE  hInstance,
HINSTANCE  hPrevInstance,
LPWSTR  lpCmdLine,
int  nShowCmd 
)

This file has no copyright assigned and is placed in the Public Domain. This file is part of the w64 mingw-runtime package. No warranty is given; refer to the file DISCLAIMER.PD within this package.

Definition at line 420 of file main.c.

421 {
422  WCHAR *ext, *filepart, *filename = NULL;
423  IActiveScriptParse *parser;
425  WCHAR **argv;
426  CLSID clsid;
427  int argc, i;
428  DWORD res;
429 
430  WINE_TRACE("(%p %p %s %x)\n", hInst, hPrevInst, wine_dbgstr_w(cmdline), cmdshow);
431 
432  argv = CommandLineToArgvW(GetCommandLineW(), &argc);
433  if(!argv)
434  return 1;
435 
436  for(i=1; i<argc; i++) {
437  if(*argv[i] == '/' || *argv[i] == '-') {
438  if(!set_host_properties(argv[i]))
439  return 1;
440  }else {
441  filename = argv[i];
442  argums = argv+i+1;
443  numOfArgs = argc-i-1;
444  break;
445  }
446  }
447 
448  if(!filename) {
449  WINE_FIXME("No file name specified\n");
450  return 1;
451  }
452  res = GetFullPathNameW(filename, ARRAY_SIZE(scriptFullName), scriptFullName, &filepart);
453  if(!res || res > ARRAY_SIZE(scriptFullName))
454  return 1;
455 
456  ext = strrchrW(filepart, '.');
457  if(!ext || !get_engine_clsid(ext, &clsid)) {
458  WINE_FIXME("Could not find engine for %s\n", wine_dbgstr_w(ext));
459  return 1;
460  }
461 
463 
464  if(!create_engine(&clsid, &script, &parser)) {
465  WINE_FIXME("Could not create script engine\n");
466  CoUninitialize();
467  return 1;
468  }
469 
470  if(init_engine(script, parser)) {
471  run_script(filename, script, parser);
472  IActiveScript_Close(script);
473  ITypeInfo_Release(host_ti);
474  }else {
475  WINE_FIXME("Script initialization failed\n");
476  }
477 
478  IActiveScript_Release(script);
480 
481  CoUninitialize();
482 
483  return 0;
484 }
static BOOL create_engine(CLSID *clsid, IActiveScript **script_ret, IActiveScriptParse **parser)
Definition: main.c:284
static int argc
Definition: ServiceArgs.c:12
__wchar_t WCHAR
Definition: xmlstorage.h:180
static BOOL get_engine_clsid(const WCHAR *ext, CLSID *clsid)
Definition: main.c:244
#define WINE_TRACE
Definition: debug.h:353
DWORD WINAPI GetFullPathNameW(IN LPCWSTR lpFileName, IN DWORD nBufferLength, OUT LPWSTR lpBuffer, OUT LPWSTR *lpFilePart)
Definition: path.c:1105
WCHAR ** argums
Definition: arguments.c:34
TCHAR * cmdline
Definition: stretchblt.cpp:32
const char * filename
Definition: ioapi.h:135
static char ** argv
Definition: ServiceArgs.c:11
GLenum GLclampf GLint i
Definition: glfuncs.h:14
WCHAR scriptFullName[MAX_PATH]
Definition: main.c:57
LPWSTR WINAPI GetCommandLineW(VOID)
Definition: proc.c:2043
static BOOL set_host_properties(const WCHAR *prop)
Definition: main.c:392
char * wine_dbgstr_w(const wchar_t *wstr)
Definition: CString.cpp:62
LPWSTR *WINAPI CommandLineToArgvW(LPCWSTR lpCmdline, int *numargs)
Definition: shell32_main.c:76
smooth NULL
Definition: ftsmooth.c:416
char ext[3]
Definition: mkdosfs.c:358
script
Definition: msipriv.h:374
static BOOL init_engine(IActiveScript *script, IActiveScriptParse *parser)
Definition: main.c:311
int numOfArgs
Definition: arguments.c:35
unsigned long DWORD
Definition: ntddk_ex.h:95
ITypeInfo * host_ti
Definition: main.c:59
#define IActiveScriptParse_Release
Definition: main.c:47
REFCLSID clsid
Definition: msctf.c:84
static void run_script(const WCHAR *filename, IActiveScript *script, IActiveScriptParse *parser)
Definition: main.c:368
WINE_UNICODE_INLINE WCHAR * strrchrW(const WCHAR *str, WCHAR ch)
Definition: unicode.h:254
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:1994
#define ARRAY_SIZE(a)
Definition: main.h:24
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1900
Definition: import.c:86
GLuint res
Definition: glext.h:9613
#define WINE_FIXME
Definition: debug.h:365

Variable Documentation

◆ ActiveScriptSiteVtbl

IActiveScriptSiteVtbl ActiveScriptSiteVtbl
static
Initial value:
= {
}
static HRESULT WINAPI ActiveScriptSite_OnScriptTerminate(IActiveScriptSite *iface, const VARIANT *pvarResult, const EXCEPINFO *pexcepinfo)
Definition: main.c:116
static HRESULT WINAPI ActiveScriptSite_GetItemInfo(IActiveScriptSite *iface, LPCOLESTR pstrName, DWORD dwReturnMask, IUnknown **ppunkItem, ITypeInfo **ppti)
Definition: main.c:88
static HRESULT WINAPI ActiveScriptSite_OnEnterScript(IActiveScriptSite *iface)
Definition: main.c:137
static HRESULT WINAPI ActiveScriptSite_OnLeaveScript(IActiveScriptSite *iface)
Definition: main.c:143
static HRESULT WINAPI ActiveScriptSite_GetDocVersionString(IActiveScriptSite *iface, BSTR *pbstrVersion)
Definition: main.c:109
static HRESULT WINAPI ActiveScriptSite_OnScriptError(IActiveScriptSite *iface, IActiveScriptError *pscripterror)
Definition: main.c:130
static HRESULT WINAPI ActiveScriptSite_GetLCID(IActiveScriptSite *iface, LCID *plcid)
Definition: main.c:80
static ULONG WINAPI ActiveScriptSite_Release(IActiveScriptSite *iface)
Definition: main.c:75
static HRESULT WINAPI ActiveScriptSite_QueryInterface(IActiveScriptSite *iface, REFIID riid, void **ppv)
Definition: main.c:64
static ULONG WINAPI ActiveScriptSite_AddRef(IActiveScriptSite *iface)
Definition: main.c:70
static HRESULT WINAPI ActiveScriptSite_OnStateChange(IActiveScriptSite *iface, SCRIPTSTATE ssScriptState)
Definition: main.c:123

Definition at line 149 of file main.c.

◆ ActiveScriptSiteWindowVtbl

const IActiveScriptSiteWindowVtbl ActiveScriptSiteWindowVtbl
static
Initial value:
= {
}
static HRESULT WINAPI ActiveScriptSiteWindow_GetWindow(IActiveScriptSiteWindow *iface, HWND *phwnd)
Definition: main.c:180
static HRESULT WINAPI ActiveScriptSiteWindow_EnableModeless(IActiveScriptSiteWindow *iface, BOOL fEnable)
Definition: main.c:188
static HRESULT WINAPI ActiveScriptSiteWindow_QueryInterface(IActiveScriptSiteWindow *iface, REFIID riid, void **ppv)
Definition: main.c:165
static ULONG WINAPI ActiveScriptSiteWindow_AddRef(IActiveScriptSiteWindow *iface)
Definition: main.c:170
static ULONG WINAPI ActiveScriptSiteWindow_Release(IActiveScriptSiteWindow *iface)
Definition: main.c:175

Definition at line 194 of file main.c.

◆ arguments_ti

ITypeInfo* arguments_ti

Definition at line 60 of file main.c.

Referenced by Arguments2_GetIDsOfNames(), Arguments2_GetTypeInfo(), and Arguments2_Invoke().

◆ host_ti

ITypeInfo* host_ti

◆ script_site

IActiveScriptSite script_site = { &ActiveScriptSiteVtbl }
static

Definition at line 163 of file main.c.

Referenced by query_interface().

◆ script_site_window

IActiveScriptSiteWindow script_site_window = { &ActiveScriptSiteWindowVtbl }
static

Definition at line 202 of file main.c.

Referenced by query_interface().

◆ scriptFullName

WCHAR scriptFullName[MAX_PATH]

Definition at line 57 of file main.c.

Referenced by Host_get_ScriptFullName(), Host_get_ScriptName(), and wWinMain().

◆ wscriptW

const WCHAR wscriptW[] = {'W','S','c','r','i','p','t',0}
static

Definition at line 55 of file main.c.

Referenced by ActiveScriptSite_GetItemInfo(), and init_engine().

◆ wshW

const WCHAR wshW[] = {'W','S','H',0}
static

Definition at line 56 of file main.c.

Referenced by ActiveScriptSite_GetItemInfo(), and init_engine().