From 6e0eccd2f3c9ea37ccbcbe5d7a31fe06cc1c5237 Mon Sep 17 00:00:00 2001 From: Ged Murphy Date: Sat, 12 Nov 2005 00:26:21 +0000 Subject: [PATCH] - build as unicode - use a _tmain hack w3seek put together svn path=/trunk/; revision=19165 --- reactos/subsys/system/sc/sc.c | 44 ++++++++++++++++++++++++++++++++- reactos/subsys/system/sc/sc.xml | 2 ++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/reactos/subsys/system/sc/sc.c b/reactos/subsys/system/sc/sc.c index e17ff4feaa4..16082d0f7e5 100644 --- a/reactos/subsys/system/sc/sc.c +++ b/reactos/subsys/system/sc/sc.c @@ -137,10 +137,13 @@ INT ScControl(LPTSTR MachineName, // remote machine name return 0; } +#if defined(_UNICODE) && defined(__GNUC__) +static +#endif 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 @@ -169,3 +172,42 @@ int _tmain(int argc, LPCTSTR argv[]) 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 diff --git a/reactos/subsys/system/sc/sc.xml b/reactos/subsys/system/sc/sc.xml index 9ba8301bffc..57693ca2f6d 100644 --- a/reactos/subsys/system/sc/sc.xml +++ b/reactos/subsys/system/sc/sc.xml @@ -1,6 +1,8 @@ + + kernel32 sc.c start.c