Author: zguo
Date: Tue Apr 30 02:57:30 2013
New Revision: 58894
URL:
http://svn.reactos.org/svn/reactos?rev=58894&view=rev
Log:
[NET]
Implementation of pause, continue, and help commands for net service application. Patch by
theflash.
Core-7131 #resolve
Added:
trunk/reactos/base/applications/network/net/cmdContinue.c (with props)
trunk/reactos/base/applications/network/net/cmdHelpMsg.c (with props)
trunk/reactos/base/applications/network/net/cmdPause.c (with props)
Modified:
trunk/reactos/base/applications/network/net/CMakeLists.txt
trunk/reactos/base/applications/network/net/help.c
trunk/reactos/base/applications/network/net/main.c
trunk/reactos/base/applications/network/net/net.h
Modified: trunk/reactos/base/applications/network/net/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/network/…
==============================================================================
--- trunk/reactos/base/applications/network/net/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/reactos/base/applications/network/net/CMakeLists.txt [iso-8859-1] Tue Apr 30
02:57:30 2013
@@ -5,6 +5,9 @@
main.c
cmdstart.c
cmdStop.c
+ cmdHelpMsg.c
+ cmdPause.c
+ cmdContinue.c
help.c)
add_executable(net ${SOURCE})
Added: 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 (added)
+++ trunk/reactos/base/applications/network/net/cmdContinue.c [iso-8859-1] Tue Apr 30
02:57:30 2013
@@ -1,0 +1,51 @@
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS net command
+ * FILE: cmdContinue.c
+ * PURPOSE:
+ *
+ * PROGRAMMERS: Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
+ */
+
+#include "net.h"
+
+int cmdContinue(int argc, wchar_t *argv[])
+{
+ int errorCode = 0;
+ SC_HANDLE hManager, hService;
+ SERVICE_STATUS status;
+ if(argc != 3)
+ {
+ puts("Usage: NET CONTINUE <Service Name>");
+ return 1;
+ }
+
+ 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;
+ }
+
+ if(!ControlService(hService, SERVICE_CONTROL_CONTINUE, &status))
+ {
+ printf("[ControlService] Error: %d\n", errorCode=GetLastError());
+ }
+
+ CloseServiceHandle(hService);
+ CloseServiceHandle(hManager);
+
+ return errorCode;
+}
+
+/* EOF */
+
Propchange: trunk/reactos/base/applications/network/net/cmdContinue.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: 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 (added)
+++ trunk/reactos/base/applications/network/net/cmdHelpMsg.c [iso-8859-1] Tue Apr 30
02:57:30 2013
@@ -1,0 +1,47 @@
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS net command
+ * FILE: cmdHelpmsg.c
+ * PURPOSE:
+ *
+ * PROGRAMMERS: Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
+ */
+
+#include "net.h"
+#include "stdlib.h"
+
+int cmdHelpMsg(int argc, wchar_t *argv[])
+{
+ wchar_t *endptr;
+ LPSTR lpBuffer;
+ if(argc<3)
+ {
+ puts("Usage: NET HELPMSG <Error Code>");
+ return 1;
+ }
+ long errNum=wcstol(argv[2], &endptr, 10);
+ 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))
+ {
+ printf("\n%s\n", lpBuffer);
+ LocalFree(lpBuffer);
+ }
+ else printf("Unrecognized error code: %ld\n", errNum);
+
+ return 0;
+}
+
+/* EOF */
+
Propchange: trunk/reactos/base/applications/network/net/cmdHelpMsg.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: 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 (added)
+++ trunk/reactos/base/applications/network/net/cmdPause.c [iso-8859-1] Tue Apr 30
02:57:30 2013
@@ -1,0 +1,50 @@
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS net command
+ * FILE: cmdPause.c
+ * PURPOSE:
+ *
+ * PROGRAMMERS: Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
+ */
+
+#include "net.h"
+
+int cmdPause(int argc, wchar_t *argv[])
+{
+ int errorCode=0;
+ SC_HANDLE hManager, hService;
+ SERVICE_STATUS status;
+ if(argc != 3)
+ {
+ puts("Usage: NET PAUSE <Service Name>");
+ return 1;
+ }
+
+ 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;
+ }
+
+ if(!ControlService(hService, SERVICE_CONTROL_PAUSE, &status))
+ {
+ printf("[ControlService] Error: %d\n", errorCode=GetLastError());
+ }
+
+ CloseServiceHandle(hService);
+ CloseServiceHandle(hManager);
+
+ return errorCode;
+}
+
+/* EOF */
+
Propchange: trunk/reactos/base/applications/network/net/cmdPause.c
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/reactos/base/applications/network/net/help.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/network/…
==============================================================================
--- trunk/reactos/base/applications/network/net/help.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/network/net/help.c [iso-8859-1] Tue Apr 30 02:57:30
2013
@@ -11,7 +11,7 @@
INT cmdHelp(INT argc, WCHAR **argv)
{
- if (argc > 3)
+ if (argc != 3)
{
return 0;
}
Modified: trunk/reactos/base/applications/network/net/main.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/network/…
==============================================================================
--- trunk/reactos/base/applications/network/net/main.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/network/net/main.c [iso-8859-1] Tue Apr 30 02:57:30
2013
@@ -21,14 +21,15 @@
{L"accounts", unimplemented},
{L"computer", unimplemented},
{L"config", unimplemented},
- {L"continue", unimplemented},
+ {L"continue", cmdContinue},
{L"file", unimplemented},
{L"group", unimplemented},
{L"help", cmdHelp},
- {L"helpmsg", unimplemented},
+ {L"helpmsg", cmdHelpMsg},
{L"localgroup", unimplemented},
{L"name", unimplemented},
{L"print", unimplemented},
+ {L"pause", cmdPause},
{L"send", unimplemented},
{L"session", unimplemented},
{L"share", unimplemented},
@@ -39,7 +40,7 @@
{L"use", unimplemented},
{L"user", unimplemented},
{L"view", unimplemented},
-
+ {NULL, NULL}
};
int wmain(int argc, WCHAR **argv)
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] Tue Apr 30 02:57:30
2013
@@ -19,3 +19,6 @@
INT cmdHelp(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[]);