From 7a27dc8a55463b0d77327bd28e506778085d9ba4 Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Mon, 24 Dec 2018 14:39:26 +0100 Subject: [PATCH] [NET] Add (incomplete) COMPUTER command and rename help.c to cmdHelp.c. --- base/applications/network/net/CMakeLists.txt | 1 + base/applications/network/net/cmdComputer.c | 103 ++++++++++++++++++ .../network/net/{help.c => cmdHelp.c} | 2 +- base/applications/network/net/main.c | 2 +- base/applications/network/net/net.h | 1 + 5 files changed, 107 insertions(+), 2 deletions(-) create mode 100644 base/applications/network/net/cmdComputer.c rename base/applications/network/net/{help.c => cmdHelp.c} (98%) diff --git a/base/applications/network/net/CMakeLists.txt b/base/applications/network/net/CMakeLists.txt index cee4e856d3f..06313f7386f 100644 --- a/base/applications/network/net/CMakeLists.txt +++ b/base/applications/network/net/CMakeLists.txt @@ -6,6 +6,7 @@ include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/conutils) list(APPEND SOURCE main.c cmdAccounts.c + cmdComputer.c cmdConfig.c cmdContinue.c cmdGroup.c diff --git a/base/applications/network/net/cmdComputer.c b/base/applications/network/net/cmdComputer.c new file mode 100644 index 00000000000..c0948853614 --- /dev/null +++ b/base/applications/network/net/cmdComputer.c @@ -0,0 +1,103 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS net command + * FILE: base/applications/network/net/cmdComputer.c + * PROGRAMMERS: Eric Kohl + */ + +#include "net.h" + +INT +cmdComputer( + INT argc, + WCHAR **argv) +{ + INT i, result = 0; + BOOL bAdd = FALSE; + BOOL bDelete = FALSE; + PWSTR pComputerName = NULL; +/* + OSVERSIONINFOEX VersionInfo; + + VersionInfo.dwOSVersionInfoSize = sizeof(VersionInfo); + if (!GetVersionEx((LPOSVERSIONINFO)&VersionInfo)) + { + PrintErrorMessage(GetLastError()); + return 1; + } + + if (VersionInfo.wProductType != VER_NT_DOMAIN_CONTROLLER) + { + PrintErrorMessage(3515); + return 1; + } +*/ + + i = 2; + if (argc > 2 && argv[i][0] != L'\\' && argv[i][1] != L'\\') + { + pComputerName = argv[i]; + i++; + } + + for (; i < argc; i++) + { + if (_wcsicmp(argv[i], L"help") == 0) + { + /* Print short syntax help */ + ConResPuts(StdOut, IDS_GENERIC_SYNTAX); + PrintNetMessage(MSG_COMPUTER_SYNTAX); + return 0; + } + + if (_wcsicmp(argv[i], L"/help") == 0) + { + /* Print full help text*/ + ConResPuts(StdOut, IDS_GENERIC_SYNTAX); + PrintNetMessage(MSG_COMPUTER_SYNTAX); + PrintNetMessage(MSG_COMPUTER_HELP); + return 0; + } + + if (_wcsicmp(argv[i], L"/add") == 0) + { + bAdd = TRUE; + continue; + } + else if (_wcsicmp(argv[i], L"/del") == 0) + { + bDelete = TRUE; + continue; + } + else + { + PrintErrorMessage(3506/*, argv[i]*/); + return 1; + } + } + + if (pComputerName == NULL || + (bAdd == FALSE && bDelete == FALSE) || + (bAdd == TRUE && bDelete == TRUE)) + { + ConResPuts(StdOut, IDS_GENERIC_SYNTAX); + PrintNetMessage(MSG_COMPUTER_SYNTAX); + return 1; + } + + if (bAdd) + { + printf("Add %S (not implemented yet)\n", pComputerName); + } + else if (bDelete) + { + printf("Delete %S (not implemented yet)\n", pComputerName); + } + + if (result == 0) + PrintErrorMessage(ERROR_SUCCESS); + + return result; +} + +/* EOF */ diff --git a/base/applications/network/net/help.c b/base/applications/network/net/cmdHelp.c similarity index 98% rename from base/applications/network/net/help.c rename to base/applications/network/net/cmdHelp.c index 01b67a65725..716009ed592 100644 --- a/base/applications/network/net/help.c +++ b/base/applications/network/net/cmdHelp.c @@ -1,7 +1,7 @@ /* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS net command - * FILE: base/applications/network/net/help.c + * FILE: base/applications/network/net/cmdHelp.c * PURPOSE: * * PROGRAMMERS: Magnus Olsen (greatlord@reactos.org) diff --git a/base/applications/network/net/main.c b/base/applications/network/net/main.c index 02c2b4579e6..579ea4c10c4 100644 --- a/base/applications/network/net/main.c +++ b/base/applications/network/net/main.c @@ -21,7 +21,7 @@ typedef struct _COMMAND COMMAND cmds[] = { {L"accounts", cmdAccounts}, - {L"computer", unimplemented}, + {L"computer", cmdComputer}, {L"config", cmdConfig}, {L"continue", cmdContinue}, {L"file", unimplemented}, diff --git a/base/applications/network/net/net.h b/base/applications/network/net/net.h index de61f92f398..d4845232eb4 100644 --- a/base/applications/network/net/net.h +++ b/base/applications/network/net/net.h @@ -57,6 +57,7 @@ VOID help(VOID); INT unimplemented(INT argc, WCHAR **argv); INT cmdAccounts(INT argc, WCHAR **argv); +INT cmdComputer(INT argc, WCHAR **argv); INT cmdConfig(INT argc, WCHAR **argv); INT cmdContinue(INT argc, WCHAR **argv); INT cmdGroup(INT argc, WCHAR **argv); -- 2.17.1