diff options
author | Jo-Philipp Wich <jo@mein.io> | 2022-03-21 12:54:40 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-21 12:54:40 +0100 |
commit | 3eaca1db52be980f62aed281fedf319eff599fbd (patch) | |
tree | 201063be20559c0312dfd4118c07aa8da78577c2 /main.c | |
parent | 753dea91bcfecb82fb5db646e72c9a022d2d2cbf (diff) | |
parent | eb0d2f124872aa279ed605c5231997f71f0b6139 (diff) |
Merge pull request #58 from jow-/multicall
main: turn ucode into multicall executable
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 30 |
1 files changed, 26 insertions, 4 deletions
@@ -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); |