summaryrefslogtreecommitdiff
path: root/monkey/main.c
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2014-10-26 12:42:53 +0000
committerVincent Sanders <vince@kyllikki.org>2014-10-26 12:42:53 +0000
commit14e282948996f75e87a14ab90f4b3ed54d9d6ad7 (patch)
tree7f78ad2cc5c9965f6a329c81c025d1c240eb4f87 /monkey/main.c
parenta913af5cf54400b441f3b1fbfc5d508cf85fea43 (diff)
downloadnetsurf-14e282948996f75e87a14ab90f4b3ed54d9d6ad7.tar.gz
netsurf-14e282948996f75e87a14ab90f4b3ed54d9d6ad7.tar.bz2
remove the die API from the core.
The die() API for abnormal termination does not belong within the core of netsurf and instead errors are propogated back to the callers. This is the final part of this change and the API is now only used within some parts of the frontends
Diffstat (limited to 'monkey/main.c')
-rw-r--r--monkey/main.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/monkey/main.c b/monkey/main.c
index 77ef831b1..289017d94 100644
--- a/monkey/main.c
+++ b/monkey/main.c
@@ -42,6 +42,19 @@ char **respaths; /** resource search path vector */
static bool monkey_done = false;
+/**
+ * Cause an abnormal program termination.
+ *
+ * \note This never returns and is intended to terminate without any cleanup.
+ *
+ * \param error The message to display to the user.
+ */
+static void die(const char * const error)
+{
+ fprintf(stderr, "DIE %s\n", error);
+ exit(EXIT_FAILURE);
+}
+
/* Stolen from gtk/gui.c */
static char **
nsmonkey_init_resource(const char *resource_path)
@@ -174,8 +187,16 @@ main(int argc, char **argv)
urldb_load_cookies(nsoption_charp(cookie_file));
monkey_prepare_input();
- monkey_register_handler("QUIT", quit_handler);
- monkey_register_handler("WINDOW", monkey_window_handle_command);
+
+ ret = monkey_register_handler("QUIT", quit_handler);
+ if (ret != NSERROR_OK) {
+ die("quit handler failed to register");
+ }
+
+ ret = monkey_register_handler("WINDOW", monkey_window_handle_command);
+ if (ret != NSERROR_OK) {
+ die("window handler fialed to register");
+ }
fprintf(stdout, "GENERIC STARTED\n");