summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2021-07-17 17:40:24 +0200
committerAki <please@ignore.pl>2021-07-17 17:40:24 +0200
commitbc1e957bc1d764d2d639b181fc6e666055df4d81 (patch)
tree9054e2c51bb254f878342fd4980abc6c2e7ff01f
parent3cc750b05a9c0cd7b3cb0f0379de4d14e6fab51d (diff)
downloadmarkdown-bc1e957bc1d764d2d639b181fc6e666055df4d81.zip
markdown-bc1e957bc1d764d2d639b181fc6e666055df4d81.tar.gz
markdown-bc1e957bc1d764d2d639b181fc6e666055df4d81.tar.bz2
Added base address option
-rw-r--r--markdown.cpp25
1 files 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 <unistd.h>
+
#include <fstream>
#include <iostream>
#include <iterator>
@@ -11,6 +13,7 @@
#include <imgui_impl_opengl3.h>
#include <imgui_md.h>
+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<char>(in), {});
in.close();