https://git.reactos.org/?p=reactos.git;a=commitdiff;h=2e868f2604c73cb830e4c…
commit 2e868f2604c73cb830e4cd8e17fdf345c82cad6d
Author: Serge Gautherie <32623169+SergeGautherie(a)users.noreply.github.com>
AuthorDate: Sat Jan 27 20:54:26 2018 +0100
Commit: Ged Murphy <gedmurphy(a)reactos.org>
CommitDate: Sat Jan 27 19:54:26 2018 +0000
[SC] print.c: Minor code improvements. (#324)
- Plus: Update license header.
- Re-use PrintServiceStatus(), as SERVICE_STATUS_PROCESS is in fact an extension of
SERVICE_STATUS.
- Use the "SERVICE_*" defines, not magic numbers.
---
base/applications/sc/print.c | 124 +++++++++++--------------------------------
1 file changed, 31 insertions(+), 93 deletions(-)
diff --git a/base/applications/sc/print.c b/base/applications/sc/print.c
index 7c3a26a2fd..caf82a4ae6 100644
--- a/base/applications/sc/print.c
+++ b/base/applications/sc/print.c
@@ -1,10 +1,10 @@
/*
* PROJECT: ReactOS Services
- * LICENSE: GPL - See COPYING in the top level directory
+ * LICENSE: GPL-2.0+ (
https://spdx.org/licenses/GPL-2.0+)
* FILE: base/applications/sc/print.c
* PURPOSE: print service info
* COPYRIGHT: Copyright 2005 - 2006 Ged Murphy <gedmurphy(a)gmail.com>
- *
+ * Copyright 2016 Eric Kohl <eric.kohl(a)reactos.org>
*/
#include "sc.h"
@@ -16,81 +16,8 @@ PrintService(LPCTSTR lpServiceName,
{
_tprintf(_T("SERVICE_NAME: %s\n"), lpServiceName);
- _tprintf(_T("\tTYPE : %x "),
- (unsigned int)pStatus->dwServiceType);
- switch (pStatus->dwServiceType)
- {
- case SERVICE_KERNEL_DRIVER:
- _tprintf(_T("KERNEL_DRIVER\n"));
- break;
-
- case SERVICE_FILE_SYSTEM_DRIVER:
- _tprintf(_T("FILE_SYSTEM_DRIVER\n"));
- break;
-
- case SERVICE_WIN32_OWN_PROCESS:
- _tprintf(_T("WIN32_OWN_PROCESS\n"));
- break;
-
- case SERVICE_WIN32_SHARE_PROCESS:
- _tprintf(_T("WIN32_SHARE_PROCESS\n"));
- break;
-
- case SERVICE_WIN32_OWN_PROCESS + SERVICE_INTERACTIVE_PROCESS:
- _tprintf(_T("WIN32_OWN_PROCESS (interactive)\n"));
- break;
-
- case SERVICE_WIN32_SHARE_PROCESS + SERVICE_INTERACTIVE_PROCESS:
- _tprintf(_T("WIN32_SHARE_PROCESS (interactive)\n"));
- break;
-
- default : _tprintf(_T("\n")); break;
- }
-
- _tprintf(_T("\tSTATE : %x "),
- (unsigned int)pStatus->dwCurrentState);
-
- switch (pStatus->dwCurrentState)
- {
- case 1 : _tprintf(_T("STOPPED\n")); break;
- case 2 : _tprintf(_T("START_PENDING\n")); break;
- case 3 : _tprintf(_T("STOP_PENDING\n")); break;
- case 4 : _tprintf(_T("RUNNING\n")); break;
- case 5 : _tprintf(_T("CONTINUE_PENDING\n")); break;
- case 6 : _tprintf(_T("PAUSE_PENDING\n")); break;
- case 7 : _tprintf(_T("PAUSED\n")); break;
- default : _tprintf(_T("\n")); break;
- }
-
- _tprintf(_T("\t\t\t\t("));
-
- if (pStatus->dwControlsAccepted & SERVICE_ACCEPT_STOP)
- _tprintf(_T("STOPPABLE,"));
- else
- _tprintf(_T("NOT_STOPPABLE,"));
-
- if (pStatus->dwControlsAccepted & SERVICE_ACCEPT_PAUSE_CONTINUE)
- _tprintf(_T("PAUSABLE,"));
- else
- _tprintf(_T("NOT_PAUSABLE,"));
-
- if (pStatus->dwControlsAccepted & SERVICE_ACCEPT_SHUTDOWN)
- _tprintf(_T("ACCEPTS_SHUTDOWN"));
- else
- _tprintf(_T("IGNORES_SHUTDOWN"));
-
- _tprintf(_T(")\n"));
-
- _tprintf(_T("\tWIN32_EXIT_CODE : %u (0x%x)\n"),
- (unsigned int)pStatus->dwWin32ExitCode,
- (unsigned int)pStatus->dwWin32ExitCode);
- _tprintf(_T("\tSERVICE_EXIT_CODE : %u (0x%x)\n"),
- (unsigned int)pStatus->dwServiceSpecificExitCode,
- (unsigned int)pStatus->dwServiceSpecificExitCode);
- _tprintf(_T("\tCHECKPOINT : 0x%x\n"),
- (unsigned int)pStatus->dwCheckPoint);
- _tprintf(_T("\tWAIT_HINT : 0x%x\n"),
- (unsigned int)pStatus->dwWaitHint);
+ // Re-use PrintServiceStatus(), as SERVICE_STATUS_PROCESS is in fact an extension of
SERVICE_STATUS.
+ PrintServiceStatus((LPSERVICE_STATUS)pStatus);
if (bExtended)
{
@@ -110,33 +37,29 @@ PrintServiceStatus(
{
_tprintf(_T("\tTYPE : %x "),
(unsigned int)pStatus->dwServiceType);
+
switch (pStatus->dwServiceType)
{
case SERVICE_KERNEL_DRIVER:
_tprintf(_T("KERNEL_DRIVER\n"));
break;
-
case SERVICE_FILE_SYSTEM_DRIVER:
_tprintf(_T("FILE_SYSTEM_DRIVER\n"));
break;
-
case SERVICE_WIN32_OWN_PROCESS:
_tprintf(_T("WIN32_OWN_PROCESS\n"));
break;
-
case SERVICE_WIN32_SHARE_PROCESS:
_tprintf(_T("WIN32_SHARE_PROCESS\n"));
break;
-
case SERVICE_WIN32_OWN_PROCESS + SERVICE_INTERACTIVE_PROCESS:
_tprintf(_T("WIN32_OWN_PROCESS (interactive)\n"));
break;
-
case SERVICE_WIN32_SHARE_PROCESS + SERVICE_INTERACTIVE_PROCESS:
_tprintf(_T("WIN32_SHARE_PROCESS (interactive)\n"));
break;
-
- default : _tprintf(_T("\n")); break;
+ default:
+ _tprintf(_T("\n"));
}
_tprintf(_T("\tSTATE : %x "),
@@ -144,14 +67,29 @@ PrintServiceStatus(
switch (pStatus->dwCurrentState)
{
- case 1 : _tprintf(_T("STOPPED\n")); break;
- case 2 : _tprintf(_T("START_PENDING\n")); break;
- case 3 : _tprintf(_T("STOP_PENDING\n")); break;
- case 4 : _tprintf(_T("RUNNING\n")); break;
- case 5 : _tprintf(_T("CONTINUE_PENDING\n")); break;
- case 6 : _tprintf(_T("PAUSE_PENDING\n")); break;
- case 7 : _tprintf(_T("PAUSED\n")); break;
- default : _tprintf(_T("\n")); break;
+ case SERVICE_STOPPED:
+ _tprintf(_T("STOPPED\n"));
+ break;
+ case SERVICE_START_PENDING:
+ _tprintf(_T("START_PENDING\n"));
+ break;
+ case SERVICE_STOP_PENDING:
+ _tprintf(_T("STOP_PENDING\n"));
+ break;
+ case SERVICE_RUNNING:
+ _tprintf(_T("RUNNING\n"));
+ break;
+ case SERVICE_CONTINUE_PENDING:
+ _tprintf(_T("CONTINUE_PENDING\n"));
+ break;
+ case SERVICE_PAUSE_PENDING:
+ _tprintf(_T("PAUSE_PENDING\n"));
+ break;
+ case SERVICE_PAUSED:
+ _tprintf(_T("PAUSED\n"));
+ break;
+ default:
+ _tprintf(_T("\n"));
}
_tprintf(_T("\t\t\t\t("));
@@ -183,4 +121,4 @@ PrintServiceStatus(
(unsigned int)pStatus->dwCheckPoint);
_tprintf(_T("\tWAIT_HINT : 0x%x\n"),
(unsigned int)pStatus->dwWaitHint);
-}
\ No newline at end of file
+}