summaryrefslogtreecommitdiffhomepage
path: root/public/tools/open/src/CommandLine.cc
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2025-01-14 11:52:02 +0100
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2025-01-14 11:54:18 +0100
commit99826c21b9da1c3a74fd8b3ebc08c7f8dbfadd30 (patch)
tree6cfa8f7d18ed018917ea5609aeba1d870cd4e27a /public/tools/open/src/CommandLine.cc
parent39d565d61bb9f9926806bb87abb48f93d0b981f8 (diff)
T& Labs's ZKA, Multi-Processor Operating System.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'public/tools/open/src/CommandLine.cc')
-rw-r--r--public/tools/open/src/CommandLine.cc49
1 files changed, 49 insertions, 0 deletions
diff --git a/public/tools/open/src/CommandLine.cc b/public/tools/open/src/CommandLine.cc
new file mode 100644
index 00000000..64b4076b
--- /dev/null
+++ b/public/tools/open/src/CommandLine.cc
@@ -0,0 +1,49 @@
+/*
+ * Created on Thu Oct 17 08:00:42 CEST 2024
+ *
+ * Copyright (c) 2024 t& Labs
+ */
+
+#include <LibSCI/SCI.h>
+
+/// @brief This program opens an application from **OPEN_APP_BASE_PATH**
+
+#define OPEN_APP_APP_FLAG "-a"
+#define OPEN_APP_HELP_FLAG "-h"
+#define OPEN_APP_BASE_PATH "/app/"
+
+int main(int argc, char* argv[])
+{
+ if (argc == 1)
+ return EXIT_FAILURE;
+
+ for (SizeT i = 1UL; i < argc; ++i)
+ {
+ if (MmStrCmp(argv[i], OPEN_APP_HELP_FLAG) == 0)
+ {
+ ConOut(nullptr, "open: Open Tool.\n");
+ ConOut(nullptr, "open: © t& Labs, All rights reserved.\n");
+
+ ConOut(nullptr, "open: %s: Application is taken as input (opens a PEF/PE32+/ELF program depending on architecture).\n", OPEN_APP_APP_FLAG);
+
+ return EXIT_SUCCESS;
+ }
+ else if (MmStrCmp(argv[i], OPEN_APP_APP_FLAG) == 0)
+ {
+ if ((i + 1) == argc)
+ return EXIT_FAILURE;
+
+ Char base_path[FILE_MAX_LEN] = OPEN_APP_BASE_PATH;
+ MmCopyMemory(base_path + MmStrLen(OPEN_APP_BASE_PATH), argv[i + 1], MmStrLen(argv[i + 1]));
+
+ Bool ret = RtlSpawnProcess(base_path, 0, nullptr, nullptr, 0);
+
+ if (ret > 0)
+ return EXIT_SUCCESS;
+
+ break;
+ }
+ }
+
+ return EXIT_FAILURE;
+}