summaryrefslogtreecommitdiffhomepage
path: root/main.c
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2022-03-21 11:32:43 +0100
committerJo-Philipp Wich <jo@mein.io>2022-03-21 11:32:43 +0100
commiteb0d2f124872aa279ed605c5231997f71f0b6139 (patch)
tree201063be20559c0312dfd4118c07aa8da78577c2 /main.c
parent753dea91bcfecb82fb5db646e72c9a022d2d2cbf (diff)
main: turn ucode into multicall executable
Turn the ucode executable into a multicall binary and select default flags based on the name it was invoked with. Introduce two new symlinks "ucc" and "utpl" which start ucode in compile and template mode respectively. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'main.c')
-rw-r--r--main.c30
1 files changed, 26 insertions, 4 deletions
diff --git a/main.c b/main.c
index c974c69..e066961 100644
--- a/main.c
+++ b/main.c
@@ -37,8 +37,6 @@ static FILE *stdin_unused;
static void
print_usage(const char *app)
{
- const char *p = strrchr(app, '/');
-
printf(
"Usage:\n"
" %1$s -h\n"
@@ -100,7 +98,7 @@ print_usage(const char *app)
"-s\n"
" Omit (strip) debug information when compiling files.\n"
" Only meaningful in conjunction with `-c`.\n\n",
- p ? p + 1 : app);
+ app);
}
@@ -444,6 +442,22 @@ parse_library_load(char *opt, uc_vm_t *vm)
return true;
}
+static const char *
+appname(const char *argv0)
+{
+ const char *p;
+
+ if (!argv0)
+ return "ucode";
+
+ p = strrchr(argv0, '/');
+
+ if (p)
+ return p + 1;
+
+ return argv0;
+}
+
int
main(int argc, char **argv)
{
@@ -454,6 +468,7 @@ main(int argc, char **argv)
bool strip = false;
uc_vm_t vm = { 0 };
int opt, rv = 0;
+ const char *app;
uc_value_t *o;
int fd;
@@ -464,11 +479,18 @@ main(int argc, char **argv)
.raw_mode = true
};
+ app = appname(argv[0]);
+
if (argc == 1) {
- print_usage(argv[0]);
+ print_usage(app);
goto out;
}
+ if (!strcmp(app, "utpl"))
+ config.raw_mode = false;
+ else if (!strcmp(app, "ucc"))
+ outfile = "./uc.out";
+
stdin_unused = stdin;
uc_vm_init(&vm, &config);