mirror of
https://github.com/reactos/reactos.git
synced 2024-07-01 02:10:07 +00:00
[NET]
Implementation of pause, continue, and help commands for net service application. Patch by theflash. Core-7131 #resolve svn path=/trunk/; revision=58894
This commit is contained in:
parent
6cdfa4a25c
commit
82cd964e20
|
@ -5,6 +5,9 @@ list(APPEND SOURCE
|
|||
main.c
|
||||
cmdstart.c
|
||||
cmdStop.c
|
||||
cmdHelpMsg.c
|
||||
cmdPause.c
|
||||
cmdContinue.c
|
||||
help.c)
|
||||
|
||||
add_executable(net ${SOURCE})
|
||||
|
|
51
reactos/base/applications/network/net/cmdContinue.c
Normal file
51
reactos/base/applications/network/net/cmdContinue.c
Normal file
|
@ -0,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 */
|
||||
|
47
reactos/base/applications/network/net/cmdHelpMsg.c
Normal file
47
reactos/base/applications/network/net/cmdHelpMsg.c
Normal file
|
@ -0,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 */
|
||||
|
50
reactos/base/applications/network/net/cmdPause.c
Normal file
50
reactos/base/applications/network/net/cmdPause.c
Normal file
|
@ -0,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 */
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
INT cmdHelp(INT argc, WCHAR **argv)
|
||||
{
|
||||
if (argc > 3)
|
||||
if (argc != 3)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -21,14 +21,15 @@ COMMAND cmds[] =
|
|||
{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 @@ COMMAND cmds[] =
|
|||
{L"use", unimplemented},
|
||||
{L"user", unimplemented},
|
||||
{L"view", unimplemented},
|
||||
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
int wmain(int argc, WCHAR **argv)
|
||||
|
|
|
@ -19,3 +19,6 @@ INT unimplemented(INT argc, WCHAR **argv);
|
|||
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[]);
|
||||
|
|
Loading…
Reference in a new issue