From a3739eee822b7424183e8630c8a93b0bf9395ead Mon Sep 17 00:00:00 2001 From: Yuri Benditovich Date: Thu, 29 Jun 2023 19:43:18 +0300 Subject: [PATCH] netkvm-prot: rework processing of app parameters Make it exactly as described in the decumentation: 'i' or 'install', 'u' or 'uninstall' add usage for not recognized parameters. Signed-off-by: Yuri Benditovich --- NetKVM/ProtocolService/ProtocolService.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/NetKVM/ProtocolService/ProtocolService.cpp b/NetKVM/ProtocolService/ProtocolService.cpp index a7ad2d49..62667118 100644 --- a/NetKVM/ProtocolService/ProtocolService.cpp +++ b/NetKVM/ProtocolService/ProtocolService.cpp @@ -986,6 +986,11 @@ static bool InstallProtocol() return !system("netcfg -v -l vioprot.inf -c p -i VIOPROT"); } +static void Usage() +{ + puts("i(nstall)|u(ninstall)|q(uery)"); +} + int __cdecl main(int argc, char **argv) { CStringA s; @@ -1000,7 +1005,7 @@ int __cdecl main(int argc, char **argv) if (!s.IsEmpty()) { CoInitialize(NULL); - if (!s.CompareNoCase("i")) + if (!s.CompareNoCase("i") || !s.CompareNoCase("install")) { if (DummyService.Installed()) { @@ -1011,7 +1016,7 @@ int __cdecl main(int argc, char **argv) puts("Protocol installed"); } } - if (!s.CompareNoCase("u")) + else if (!s.CompareNoCase("u") || !s.CompareNoCase("uninstall")) { if (DummyService.Installed()) { @@ -1024,26 +1029,30 @@ int __cdecl main(int argc, char **argv) UninstallProtocol(); } } - if (!s.CompareNoCase("q")) + else if (!s.CompareNoCase("q") || !s.CompareNoCase("query")) { printf("Service %sinstalled\n", DummyService.Installed() ? "" : "not"); printf("VIOPROT %sinstalled\n", IsVioProtInstalled() ? "" : "not "); } - if (!s.CompareNoCase("d")) + else if (!s.CompareNoCase("d") || !s.CompareNoCase("dump")) { DummyService.Control(CProtocolServiceImplementation::ctlDump); } - if (!s.CompareNoCase("e")) + else if (!s.CompareNoCase("e")) { puts("Dumping interface table to debug output"); CInterfaceTable t; t.Dump(); } + else + { + Usage(); + } CoUninitialize(); } else { - puts("i(nstall)|u(ninstall)|q(uery)"); + Usage(); } return 0; }