[NET] Add (incomplete) COMPUTER command and rename help.c to cmdHelp.c.
authorEric Kohl <eric.kohl@reactos.org>
Mon, 24 Dec 2018 13:39:26 +0000 (14:39 +0100)
committerEric Kohl <eric.kohl@reactos.org>
Mon, 24 Dec 2018 13:39:26 +0000 (14:39 +0100)
base/applications/network/net/CMakeLists.txt
base/applications/network/net/cmdComputer.c [new file with mode: 0644]
base/applications/network/net/cmdHelp.c [moved from base/applications/network/net/help.c with 98% similarity]
base/applications/network/net/main.c
base/applications/network/net/net.h

index cee4e85..06313f7 100644 (file)
@@ -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 (file)
index 0000000..c094885
--- /dev/null
@@ -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 <eric.kohl@reactos.org>
+ */
+
+#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 */
similarity index 98%
rename from base/applications/network/net/help.c
rename to base/applications/network/net/cmdHelp.c
index 01b67a6..716009e 100644 (file)
@@ -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)
index 02c2b45..579ea4c 100644 (file)
@@ -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},
index de61f92..d484523 100644 (file)
@@ -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);