mirror of
https://github.com/reactos/reactos.git
synced 2024-07-01 02:10:07 +00:00
[NET]
Clean-up the new functions. This should have been done by the author of the patch! svn path=/trunk/; revision=58908
This commit is contained in:
parent
9aff77470a
commit
96970e7413
|
@ -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;
|
||||
printf("[OpenSCManager] Error: %ld\n", GetLastError());
|
||||
nError = 1;
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
||||
hService = OpenService(hManager, argv[2], SERVICE_PAUSE_CONTINUE);
|
||||
|
||||
if(hService == NULL)
|
||||
if (hService == NULL)
|
||||
{
|
||||
printf("[OpenService] Error: %d\n", errorCode=GetLastError());
|
||||
printf("[OpenService] Error: %ld\n", GetLastError());
|
||||
nError = 1;
|
||||
goto done;
|
||||
}
|
||||
|
||||
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 errorCode;
|
||||
}
|
||||
|
||||
if(!ControlService(hService, SERVICE_CONTROL_CONTINUE, &status))
|
||||
{
|
||||
printf("[ControlService] Error: %d\n", errorCode=GetLastError());
|
||||
}
|
||||
|
||||
CloseServiceHandle(hService);
|
||||
CloseServiceHandle(hManager);
|
||||
|
||||
return errorCode;
|
||||
return nError;
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
printf("[OpenSCManager] Error: %ld\n", GetLastError());
|
||||
nError = 1;
|
||||
goto done;
|
||||
}
|
||||
|
||||
hService=OpenService(hManager, argv[2], SERVICE_PAUSE_CONTINUE);
|
||||
if(hService == NULL)
|
||||
|
||||
hService = OpenService(hManager, argv[2], SERVICE_PAUSE_CONTINUE);
|
||||
if (hService == NULL)
|
||||
{
|
||||
printf("[OpenService] Error: %d\n", errorCode=GetLastError());
|
||||
printf("[OpenService] Error: %ld\n", GetLastError());
|
||||
nError = 1;
|
||||
goto done;
|
||||
}
|
||||
|
||||
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 errorCode;
|
||||
}
|
||||
|
||||
if(!ControlService(hService, SERVICE_CONTROL_PAUSE, &status))
|
||||
{
|
||||
printf("[ControlService] Error: %d\n", errorCode=GetLastError());
|
||||
}
|
||||
|
||||
CloseServiceHandle(hService);
|
||||
CloseServiceHandle(hManager);
|
||||
|
||||
return errorCode;
|
||||
return nError;
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* FILE:
|
||||
* PURPOSE:
|
||||
*
|
||||
* PROGRAMMERS: Magnus Olsen (greatlord@reactos.org)
|
||||
* PROGRAMMERS: Magnus Olsen (greatlord@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[]);
|
||||
|
|
Loading…
Reference in a new issue