[CSCRIPT][WSCRIPT] Sync with Wine Staging 4.18. CORE-16441
[reactos.git] / base / applications / cmdutils / wscript / host.c
index b867fae..a61851e 100644 (file)
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
+#include <stdarg.h>
+
+#define COBJMACROS
+#define CONST_VTABLE
+
+#include <windef.h>
+#include <winbase.h>
+#include <ole2.h>
+
 #include "wscript.h"
 
+#include <wine/debug.h>
+#include <wine/heap.h>
+
+WINE_DEFAULT_DEBUG_CHANNEL(wscript);
+
 #define BUILDVERSION 16535
 
 static const WCHAR wshNameW[] = {'W','i','n','d','o','w','s',' ','S','c','r','i','p','t',' ','H','o','s','t',0};
@@ -65,11 +79,11 @@ static void print_string(const WCHAR *string)
         return;
     }
 
-    len = strlenW(string);
+    len = lstrlenW(string);
     ret = WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), string, len, &count, NULL);
     if(ret) {
         static const WCHAR crnlW[] = {'\r','\n'};
-        WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), crnlW, sizeof(crnlW)/sizeof(*crnlW), &count, NULL);
+        WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), crnlW, ARRAY_SIZE(crnlW), &count, NULL);
         return;
     }
 
@@ -168,7 +182,7 @@ static HRESULT WINAPI Host_get_FullName(IHost *iface, BSTR *out_Path)
 
     WINE_TRACE("(%p)\n", out_Path);
 
-    if(GetModuleFileNameW(NULL, fullPath, sizeof(fullPath)/sizeof(WCHAR)) == 0)
+    if(GetModuleFileNameW(NULL, fullPath, ARRAY_SIZE(fullPath)) == 0)
         return E_FAIL;
     if(!(*out_Path = SysAllocString(fullPath)))
         return E_OUTOFMEMORY;
@@ -183,9 +197,9 @@ static HRESULT WINAPI Host_get_Path(IHost *iface, BSTR *out_Path)
 
     WINE_TRACE("(%p)\n", out_Path);
 
-    if(GetModuleFileNameW(NULL, path, sizeof(path)/sizeof(WCHAR)) == 0)
+    if(GetModuleFileNameW(NULL, path, ARRAY_SIZE(path)) == 0)
         return E_FAIL;
-    pos = strrchrW(path, '\\');
+    pos = wcsrchr(path, '\\');
     howMany = pos - path;
     if(!(*out_Path = SysAllocStringLen(path, howMany)))
         return E_OUTOFMEMORY;
@@ -222,7 +236,7 @@ static HRESULT WINAPI Host_get_ScriptName(IHost *iface, BSTR *out_ScriptName)
 
     WINE_TRACE("(%p)\n", out_ScriptName);
 
-    scriptName = strrchrW(scriptFullName, '\\');
+    scriptName = wcsrchr(scriptFullName, '\\');
     ++scriptName;
     if(!(*out_ScriptName = SysAllocString(scriptName)))
         return E_OUTOFMEMORY;
@@ -307,7 +321,11 @@ static HRESULT WINAPI Host_Echo(IHost *iface, SAFEARRAY *args)
 {
     WCHAR *output = NULL, *ptr;
     unsigned argc, i, len;
+#ifdef __REACTOS__
     LONG ubound, lbound;
+#else
+    int ubound, lbound;
+#endif
     VARIANT *argv;
     BSTR *strs;
     HRESULT hres;