diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2016-10-11 10:52:49 +0200 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2016-10-11 10:52:49 +0200 |
commit | 8028c7fa47642b452038176004bea3a8966811ac (patch) | |
tree | 5c51ea2fd404b0ff4c362b402373458d5011e4cc /zyklonb.c | |
parent | 43de836b919db7f5c10f63a4a788acbc2752e74f (diff) | |
download | xK-8028c7fa47642b452038176004bea3a8966811ac.tar.gz xK-8028c7fa47642b452038176004bea3a8966811ac.tar.xz xK-8028c7fa47642b452038176004bea3a8966811ac.zip |
Bump liberty
Diffstat (limited to 'zyklonb.c')
-rw-r--r-- | zyklonb.c | 31 |
1 files changed, 18 insertions, 13 deletions
@@ -310,7 +310,7 @@ irc_get_boolean_from_config if (set_boolean_if_valid (value, str)) return true; - FAIL ("invalid configuration value for `%s'", name); + return error_set (e, "invalid configuration value for `%s'", name); } static bool @@ -324,12 +324,14 @@ irc_initialize_ca_set (SSL_CTX *ssl_ctx, const char *file, const char *path, if (SSL_CTX_load_verify_locations (ssl_ctx, file, path)) return true; - FAIL ("%s: %s", "failed to set locations for the CA certificate bundle", + return error_set (e, "%s: %s", + "failed to set locations for the CA certificate bundle", ERR_reason_error_string (ERR_get_error ())); } if (!SSL_CTX_set_default_verify_paths (ssl_ctx)) - FAIL ("%s: %s", "couldn't load the default CA certificate bundle", + return error_set (e, "%s: %s", + "couldn't load the default CA certificate bundle", ERR_reason_error_string (ERR_get_error ())); return true; } @@ -442,7 +444,7 @@ error_ssl_1: // multiple errors on the OpenSSL stack. if (!error_info) error_info = ERR_error_string (ERR_get_error (), NULL); - FAIL ("%s: %s", "could not initialize TLS", error_info); + return error_set (e, "%s: %s", "could not initialize TLS", error_info); } static bool @@ -455,7 +457,7 @@ irc_establish_connection (struct bot_context *ctx, int err = getaddrinfo (host, port, &gai_hints, &gai_result); if (err) - FAIL ("%s: %s: %s", "connection failed", + return error_set (e, "%s: %s: %s", "connection failed", "getaddrinfo", gai_strerror (err)); int sockfd; @@ -497,7 +499,7 @@ irc_establish_connection (struct bot_context *ctx, freeaddrinfo (gai_result); if (!gai_iter) - FAIL ("connection failed"); + return error_set (e, "connection failed"); ctx->irc_fd = sockfd; return true; @@ -1117,9 +1119,9 @@ static bool plugin_load (struct bot_context *ctx, const char *name, struct error **e) { if (!is_valid_plugin_name (name)) - FAIL ("invalid plugin name"); + return error_set (e, "invalid plugin name"); if (str_map_find (&ctx->plugins_by_name, name)) - FAIL ("the plugin has already been loaded"); + return error_set (e, "the plugin has already been loaded"); struct plugin *plugin; if (!(plugin = plugin_launch (ctx, name, e))) @@ -1149,7 +1151,7 @@ plugin_unload (struct bot_context *ctx, const char *name, struct error **e) struct plugin *plugin = str_map_find (&ctx->plugins_by_name, name); if (!plugin) - FAIL ("no such plugin is loaded"); + return error_set (e, "no such plugin is loaded"); plugin_zombify (plugin); @@ -1168,7 +1170,7 @@ plugin_load_all_from_config (struct bot_context *ctx) struct str_vector plugins; str_vector_init (&plugins); - cstr_split_ignore_empty (plugin_list, ',', &plugins); + cstr_split (plugin_list, ",", true, &plugins); for (size_t i = 0; i < plugins.len; i++) { char *name = cstr_strip_in_place (plugins.vector[i], " "); @@ -1208,7 +1210,7 @@ parse_bot_command (const char *s, const char *command, const char **following) static void split_bot_command_argument_list (const char *arguments, struct str_vector *out) { - cstr_split_ignore_empty (arguments, ',', out); + cstr_split (arguments, ",", true, out); for (size_t i = 0; i < out->len; ) { if (!*cstr_strip_in_place (out->vector[i], " \t")) @@ -1778,7 +1780,7 @@ irc_connect (struct bot_context *ctx, struct error **e) // TODO: again, get rid of `struct error' in here. The question is: how // do we tell our caller that he should not try to reconnect? if (!irc_host) - FAIL ("no hostname specified in configuration"); + return error_set (e, "no hostname specified in configuration"); bool use_tls; if (!irc_get_boolean_from_config (ctx, "tls", &use_tls, e)) @@ -1823,7 +1825,10 @@ parse_config (struct bot_context *ctx, struct error **e) const char *delay_str = str_map_find (&ctx->config, "reconnect_delay"); hard_assert (delay_str != NULL); // We have a default value for this if (!xstrtoul (&ctx->reconnect_delay, delay_str, 10)) - FAIL ("invalid configuration value for `%s'", "reconnect_delay"); + { + return error_set (e, + "invalid configuration value for `%s'", "reconnect_delay"); + } hard_assert (!ctx->admin_re); const char *admin = str_map_find (&ctx->config, "admin"); |