aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/frontend.h3
-rw-r--r--src/jalv_console.c6
-rw-r--r--src/main.c9
3 files changed, 11 insertions, 7 deletions
diff --git a/src/frontend.h b/src/frontend.h
index c798ea8..f18fb86 100644
--- a/src/frontend.h
+++ b/src/frontend.h
@@ -15,6 +15,9 @@
// Interface that must be implemented by UIs
JALV_BEGIN_DECLS
+/// Arbitrary return code for successful early exit (for --help and so on)
+#define JALV_EARLY_EXIT_STATUS (-431)
+
/// Command-line arguments passed to an executable
typedef struct {
int* argc; ///< Pointer to `argc` like in `main`
diff --git a/src/jalv_console.c b/src/jalv_console.c
index 664d175..1a700fc 100644
--- a/src/jalv_console.c
+++ b/src/jalv_console.c
@@ -54,7 +54,7 @@ print_usage(const char* name, bool error)
" -U URI Load the UI with the given URI\n"
" -V Display version information and exit\n"
" -x Exit if the requested JACK client name is taken\n");
- return error ? 1 : 0;
+ return error ? 1 : JALV_EARLY_EXIT_STATUS;
}
static int
@@ -65,7 +65,7 @@ print_version(void)
"License ISC: <https://spdx.org/licenses/ISC>.\n"
"This is free software; you are free to change and redistribute it."
"\nThere is NO WARRANTY, to the extent permitted by law.\n");
- return 1;
+ return JALV_EARLY_EXIT_STATUS;
}
static int
@@ -116,7 +116,7 @@ jalv_frontend_init(JalvFrontendArgs* const args, JalvOptions* const opts)
int a = 1;
for (; a < argc && argv[a][0] == '-'; ++a) {
if (argv[a][1] == 'h' || !strcmp(argv[a], "--help")) {
- return print_usage(cmd, true);
+ return print_usage(cmd, false);
}
if (argv[a][1] == 'V' || !strcmp(argv[a], "--version")) {
diff --git a/src/main.c b/src/main.c
index cf88af2..5c49b10 100644
--- a/src/main.c
+++ b/src/main.c
@@ -53,9 +53,10 @@ main(int argc, char** argv)
jalv.backend = jalv_backend_allocate();
// Initialize application
- if (jalv_open(&jalv, &argc, &argv)) {
+ const int orc = jalv_open(&jalv, &argc, &argv);
+ if (orc) {
jalv_close(&jalv);
- return EXIT_FAILURE;
+ return orc == JALV_EARLY_EXIT_STATUS ? EXIT_SUCCESS : EXIT_FAILURE;
}
// Set up signal handlers and activate audio processing
@@ -70,7 +71,7 @@ main(int argc, char** argv)
// Deactivate audio processing and tear down application
jalv_deactivate(&jalv);
- const int ret = jalv_close(&jalv);
+ const int crc = jalv_close(&jalv);
jalv_backend_free(jalv.backend);
- return ret;
+ return crc;
}