From bc1e957bc1d764d2d639b181fc6e666055df4d81 Mon Sep 17 00:00:00 2001 From: Aki Date: Sat, 17 Jul 2021 17:40:24 +0200 Subject: Added base address option --- markdown.cpp | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/markdown.cpp b/markdown.cpp index fa14396..63f293d 100644 --- a/markdown.cpp +++ b/markdown.cpp @@ -1,3 +1,5 @@ +#include + #include #include #include @@ -11,6 +13,7 @@ #include #include +std::string g_base_address; ImFont * g_font_regular; ImFont * g_font_bold; ImFont * g_font_bold_large; @@ -56,12 +59,28 @@ static void resized(GLFWwindow *, int width, int height) static void print_usage(const char * program) { - std::cerr << "Usage: " << program << " FILE" << std::endl; + std::cerr << "Usage: " << program << " [-b BASE_ADDRESS] FILE" << std::endl; } int main(int argc, char ** argv) { - if (2 != argc) + int opt; + + while (-1 != (opt = getopt(argc, argv, "b:"))) + { + switch (opt) + { + case 'b': + g_base_address = optarg; + break; + case '?': + default: + print_usage(argv[0]); + return 2; + } + } + + if (optind >= argc) { print_usage(argv[0]); return 2; @@ -100,7 +119,7 @@ int main(int argc, char ** argv) ImGui_ImplOpenGL3_Init(glsl_version); std::ifstream in; - in.open(argv[1]); + in.open(argv[optind]); std::string text(std::istreambuf_iterator(in), {}); in.close(); -- cgit v1.1