aboutsummaryrefslogtreecommitdiff
path: root/src/shared/init.hh
diff options
context:
space:
mode:
authorNicolas James <Eele1Ephe7uZahRie@tutanota.com>2025-02-12 21:57:46 +1100
committerNicolas James <Eele1Ephe7uZahRie@tutanota.com>2025-02-12 21:57:46 +1100
commite4483eca01b48b943cd0461e24a74ae1a3139ed4 (patch)
treeed58c3c246e3af1af337697695d780aa31f6ad9a /src/shared/init.hh
parent1cc08c51eb4b0f95c30c0a98ad1fc5ad3459b2df (diff)
Update to most recent version (old initial commit)
Diffstat (limited to 'src/shared/init.hh')
-rw-r--r--src/shared/init.hh38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/shared/init.hh b/src/shared/init.hh
new file mode 100644
index 0000000..735730d
--- /dev/null
+++ b/src/shared/init.hh
@@ -0,0 +1,38 @@
+#ifndef SHARED_INIT_HH_
+#define SHARED_INIT_HH_
+
+#include <string>
+#include <vector>
+
+#include <boost/lexical_cast.hpp>
+
+namespace shared {
+
+constexpr auto DEFAULT_ADDRESS = "0.0.0.0";
+constexpr auto SINGLEPLAYER_ADDRESS = "localhost";
+constexpr auto DEFAULT_PORT = "8191";
+
+void init();
+using main_func_t = void (*)(const std::string_view, const std::string_view);
+void try_main(const main_func_t& func, const std::string_view address,
+ const std::string_view port);
+
+// We use our own arg struct to parse args.
+struct arg {
+ const char* name; // "address"
+ const char* desc; // "change the address"
+ const char* val; // "a:"
+};
+using args_t = std::vector<arg>;
+const args_t& get_options();
+
+using args_callback_t = bool (*)(const int& c, const char* const arg);
+bool parse_arg(const int& c, const char* const arg);
+
+using args_callbacks_t = std::vector<args_callback_t>;
+void parse_args(const int argc, char* const argv[], const args_t& args,
+ const args_callbacks_t& callback);
+
+} // namespace shared
+
+#endif