Author: ekohl
Date: Wed May 1 21:54:40 2013
New Revision: 58908
URL:
http://svn.reactos.org/svn/reactos?rev=58908&view=rev
Log:
[NET]
Clean-up the new functions.
This should have been done by the author of the patch!
Modified:
trunk/reactos/base/applications/network/net/cmdContinue.c
trunk/reactos/base/applications/network/net/cmdHelpMsg.c
trunk/reactos/base/applications/network/net/cmdPause.c
trunk/reactos/base/applications/network/net/net.h
Modified: trunk/reactos/base/applications/network/net/cmdContinue.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/network/…
==============================================================================
--- trunk/reactos/base/applications/network/net/cmdContinue.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/network/net/cmdContinue.c [iso-8859-1] Wed May 1
21:54:40 2013
@@ -9,42 +9,49 @@
#include "net.h"
-int cmdContinue(int argc, wchar_t *argv[])
+INT cmdContinue(INT argc, WCHAR **argv)
{
- int errorCode = 0;
- SC_HANDLE hManager, hService;
+ SC_HANDLE hManager = NULL;
+ SC_HANDLE hService = NULL;
SERVICE_STATUS status;
- if(argc != 3)
+ INT nError = 0;
+
+ if (argc != 3)
{
puts("Usage: NET CONTINUE <Service Name>");
return 1;
}
- hManager=OpenSCManager(NULL, SERVICES_ACTIVE_DATABASE,
SC_MANAGER_ENUMERATE_SERVICE);
- if(hManager == NULL)
+ hManager = OpenSCManager(NULL, SERVICES_ACTIVE_DATABASE,
SC_MANAGER_ENUMERATE_SERVICE);
+ if (hManager == NULL)
{
- printf("[OpenSCManager] Error: %d\n", errorCode = GetLastError());
- return errorCode;
- }
-
- hService = OpenService(hManager, argv[2], SERVICE_PAUSE_CONTINUE);
-
- if(hService == NULL)
- {
- printf("[OpenService] Error: %d\n", errorCode=GetLastError());
- CloseServiceHandle(hManager);
- return errorCode;
+ printf("[OpenSCManager] Error: %ld\n", GetLastError());
+ nError = 1;
+ goto done;
}
- if(!ControlService(hService, SERVICE_CONTROL_CONTINUE, &status))
+ hService = OpenService(hManager, argv[2], SERVICE_PAUSE_CONTINUE);
+ if (hService == NULL)
{
- printf("[ControlService] Error: %d\n", errorCode=GetLastError());
+ printf("[OpenService] Error: %ld\n", GetLastError());
+ nError = 1;
+ goto done;
}
- CloseServiceHandle(hService);
- CloseServiceHandle(hManager);
-
- return errorCode;
+ if (!ControlService(hService, SERVICE_CONTROL_CONTINUE, &status))
+ {
+ printf("[ControlService] Error: %ld\n", GetLastError());
+ nError = 1;
+ }
+
+done:
+ if (hService != NULL)
+ CloseServiceHandle(hService);
+
+ if (hManager != NULL)
+ CloseServiceHandle(hManager);
+
+ return nError;
}
/* EOF */
Modified: trunk/reactos/base/applications/network/net/cmdHelpMsg.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/network/…
==============================================================================
--- trunk/reactos/base/applications/network/net/cmdHelpMsg.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/network/net/cmdHelpMsg.c [iso-8859-1] Wed May 1
21:54:40 2013
@@ -10,38 +10,42 @@
#include "net.h"
#include "stdlib.h"
-int cmdHelpMsg(int argc, wchar_t *argv[])
+INT cmdHelpMsg(INT argc, WCHAR **argv)
{
- wchar_t *endptr;
- LPSTR lpBuffer;
- long errNum;
+ LPWSTR endptr;
+ LPWSTR lpBuffer;
+ LONG errNum;
- if(argc<3)
+ if (argc < 3)
{
puts("Usage: NET HELPMSG <Error Code>");
return 1;
}
+
errNum = wcstol(argv[2], &endptr, 10);
- if(*endptr != 0)
+ if (*endptr != 0)
{
puts("Usage: NET HELPMSG <Error Code>");
return 1;
}
/* Unicode printing is not supported in ReactOS yet */
- if(FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
- NULL,
- errNum,
- LANG_USER_DEFAULT,
- (LPSTR)&lpBuffer,
- 0,
- NULL))
+ if (FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
+ NULL,
+ errNum,
+ LANG_USER_DEFAULT,
+ (LPWSTR)&lpBuffer,
+ 0,
+ NULL))
{
- printf("\n%s\n", lpBuffer);
+ printf("\n%S\n", lpBuffer);
LocalFree(lpBuffer);
}
- else printf("Unrecognized error code: %ld\n", errNum);
-
+ else
+ {
+ printf("Unrecognized error code: %ld\n", errNum);
+ }
+
return 0;
}
Modified: trunk/reactos/base/applications/network/net/cmdPause.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/network/…
==============================================================================
--- trunk/reactos/base/applications/network/net/cmdPause.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/network/net/cmdPause.c [iso-8859-1] Wed May 1
21:54:40 2013
@@ -9,41 +9,48 @@
#include "net.h"
-int cmdPause(int argc, wchar_t *argv[])
+INT cmdPause(INT argc, WCHAR **argv)
{
- int errorCode=0;
- SC_HANDLE hManager, hService;
+ SC_HANDLE hManager = NULL;
+ SC_HANDLE hService = NULL;
SERVICE_STATUS status;
- if(argc != 3)
+ INT nError = 0;
+
+ if (argc != 3)
{
puts("Usage: NET PAUSE <Service Name>");
return 1;
}
hManager = OpenSCManager(NULL, SERVICES_ACTIVE_DATABASE,
SC_MANAGER_ENUMERATE_SERVICE);
- if(hManager == NULL)
+ if (hManager == NULL)
{
- printf("[OpenSCManager] Error: %d\n", errorCode=GetLastError());
- return errorCode;
- }
-
- hService=OpenService(hManager, argv[2], SERVICE_PAUSE_CONTINUE);
- if(hService == NULL)
- {
- printf("[OpenService] Error: %d\n", errorCode=GetLastError());
- CloseServiceHandle(hManager);
- return errorCode;
- }
-
- if(!ControlService(hService, SERVICE_CONTROL_PAUSE, &status))
- {
- printf("[ControlService] Error: %d\n", errorCode=GetLastError());
+ printf("[OpenSCManager] Error: %ld\n", GetLastError());
+ nError = 1;
+ goto done;
}
- CloseServiceHandle(hService);
- CloseServiceHandle(hManager);
+ hService = OpenService(hManager, argv[2], SERVICE_PAUSE_CONTINUE);
+ if (hService == NULL)
+ {
+ printf("[OpenService] Error: %ld\n", GetLastError());
+ nError = 1;
+ goto done;
+ }
- return errorCode;
+ if (!ControlService(hService, SERVICE_CONTROL_PAUSE, &status))
+ {
+ printf("[ControlService] Error: %ld\n", GetLastError());
+ }
+
+done:
+ if (hService != NULL)
+ CloseServiceHandle(hService);
+
+ if (hManager != NULL)
+ CloseServiceHandle(hManager);
+
+ return nError;
}
/* EOF */
Modified: trunk/reactos/base/applications/network/net/net.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/network/…
==============================================================================
--- trunk/reactos/base/applications/network/net/net.h [iso-8859-1] (original)
+++ trunk/reactos/base/applications/network/net/net.h [iso-8859-1] Wed May 1 21:54:40
2013
@@ -4,7 +4,7 @@
* FILE:
* PURPOSE:
*
- * PROGRAMMERS: Magnus Olsen (greatlord(a)reactos.org)
+ * PROGRAMMERS: Magnus Olsen (greatlord(a)reactos.org)
*/
#include <stdarg.h>
@@ -16,9 +16,9 @@
VOID help(VOID);
INT unimplemented(INT argc, WCHAR **argv);
+INT cmdContinue(INT argc, WCHAR **argv);
INT cmdHelp(INT argc, WCHAR **argv);
+INT cmdHelpMsg(INT argc, WCHAR **argv);
+INT cmdPause(INT argc, WCHAR **argv);
INT cmdStart(INT argc, WCHAR **argv);
INT cmdStop(INT argc, WCHAR **argv);
-int cmdHelpMsg(int argc, wchar_t *argv[]);
-int cmdPause(int argc, wchar_t *argv[]);
-int cmdContinue(int argc, wchar_t *argv[]);