- build as unicode
authorGed Murphy <gedmurphy@reactos.org>
Sat, 12 Nov 2005 00:26:21 +0000 (00:26 +0000)
committerGed Murphy <gedmurphy@reactos.org>
Sat, 12 Nov 2005 00:26:21 +0000 (00:26 +0000)
- use a _tmain hack w3seek put together

svn path=/trunk/; revision=19165

reactos/subsys/system/sc/sc.c
reactos/subsys/system/sc/sc.xml

index e17ff4f..16082d0 100644 (file)
@@ -137,10 +137,13 @@ INT ScControl(LPTSTR MachineName,   // remote machine name
     return 0;
 }
 
     return 0;
 }
 
+#if defined(_UNICODE) && defined(__GNUC__)
+static
+#endif
 
 int _tmain(int argc, LPCTSTR argv[])
 {
 
 int _tmain(int argc, LPCTSTR argv[])
 {
-    LPTSTR MachineName = NULL;   // remote machine
+       LPTSTR MachineName = NULL;   // remote machine
     LPCTSTR Command = NULL;      // sc command
     LPCTSTR ServiceName = NULL;  // Name of service
 
     LPCTSTR Command = NULL;      // sc command
     LPCTSTR ServiceName = NULL;  // Name of service
 
@@ -169,3 +172,42 @@ int _tmain(int argc, LPCTSTR argv[])
 
     return MainUsage();
 }
 
     return MainUsage();
 }
+
+
+#if defined(_UNICODE) && defined(__GNUC__)
+/* HACK - MINGW HAS NO OFFICIAL SUPPORT FOR wmain()!!! */
+int main( int argc, char **argv )
+{
+    WCHAR **argvW;
+    int i, j, Ret = 1;
+
+    if ((argvW = malloc(argc * sizeof(WCHAR*))))
+    {
+        /* convert the arguments */
+        for (i = 0, j = 0; i < argc; i++)
+        {
+            if (!(argvW[i] = malloc((strlen(argv[i]) + 1) * sizeof(WCHAR))))
+            {
+                j++;
+            }
+            swprintf(argvW[i], L"%hs", argv[i]);
+        }
+        
+        if (j == 0)
+        {
+            /* no error converting the parameters, call wmain() */
+            Ret = wmain(argc, (LPCTSTR *)argvW);
+        }
+        
+        /* free the arguments */
+        for (i = 0; i < argc; i++)
+        {
+            if (argvW[i])
+                free(argvW[i]);
+        }
+        free(argvW);
+    }
+    
+    return Ret;
+}
+#endif
index 9ba8301..57693ca 100644 (file)
@@ -1,6 +1,8 @@
 <module name="sc" type="win32cui" installbase="system32" installname="sc.exe">\r
        <define name="__USE_W32API" />\r
        <define name="DEFINE_GUID" />\r
 <module name="sc" type="win32cui" installbase="system32" installname="sc.exe">\r
        <define name="__USE_W32API" />\r
        <define name="DEFINE_GUID" />\r
+       <define name="UNICODE" />\r
+       <define name="_UNICODE" />\r
        <library>kernel32</library>\r
        <file>sc.c</file>\r
        <file>start.c</file>\r
        <library>kernel32</library>\r
        <file>sc.c</file>\r
        <file>start.c</file>\r