aboutsummaryrefslogtreecommitdiff
path: root/src/zyklonb.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/zyklonb.c')
-rw-r--r--src/zyklonb.c50
1 files changed, 12 insertions, 38 deletions
diff --git a/src/zyklonb.c b/src/zyklonb.c
index de4e3ac..906df7e 100644
--- a/src/zyklonb.c
+++ b/src/zyklonb.c
@@ -106,15 +106,6 @@ plugin_data_free (struct plugin_data *self)
str_free (&self->queued_output);
}
-static size_t connect_error_domain_tag;
-#define CONNECT_ERROR (error_resolve_domain (&connect_error_domain_tag))
-
-enum
-{
- CONNECT_ERROR_INVALID_CONFIGURATION,
- CONNECT_ERROR_FAILED
-};
-
struct bot_context
{
struct str_map config; ///< User configuration
@@ -306,8 +297,7 @@ error_ssl_2:
error_ssl_1:
// XXX: these error strings are really nasty; also there could be
// multiple errors on the OpenSSL stack.
- error_set (e, CONNECT_ERROR, CONNECT_ERROR_FAILED,
- "%s: %s", "could not initialize SSL",
+ error_set (e, "%s: %s", "could not initialize SSL",
ERR_error_string (ERR_get_error (), NULL));
return false;
}
@@ -325,7 +315,7 @@ irc_establish_connection (struct bot_context *ctx,
int err = getaddrinfo (host, port, &gai_hints, &gai_result);
if (err)
{
- error_set (e, CONNECT_ERROR, CONNECT_ERROR_FAILED, "%s: %s: %s",
+ error_set (e, "%s: %s: %s",
"connection failed", "getaddrinfo", gai_strerror (err));
return false;
}
@@ -367,7 +357,7 @@ irc_establish_connection (struct bot_context *ctx,
if (!gai_iter)
{
- error_set (e, CONNECT_ERROR, CONNECT_ERROR_FAILED, "connection failed");
+ error_set (e, "connection failed");
return false;
}
@@ -633,16 +623,6 @@ setup_recovery_handler (struct bot_context *ctx)
/// The name of the special IRC command for interprocess communication
static const char *plugin_ipc_command = "ZYKLONB";
-static size_t plugin_error_domain_tag;
-#define PLUGIN_ERROR (error_resolve_domain (&plugin_error_domain_tag))
-
-enum
-{
- PLUGIN_ERROR_ALREADY_LOADED,
- PLUGIN_ERROR_NOT_LOADED,
- PLUGIN_ERROR_LOADING_FAILED
-};
-
static struct plugin_data *
plugin_find_by_pid (struct bot_context *ctx, pid_t pid)
{
@@ -923,29 +903,26 @@ plugin_load (struct bot_context *ctx, const char *name, struct error **e)
const char *plugin_dir = str_map_find (&ctx->config, "plugin_dir");
if (!plugin_dir)
{
- error_set (e, PLUGIN_ERROR, PLUGIN_ERROR_LOADING_FAILED,
- "plugin directory not set");
+ error_set (e, "plugin directory not set");
return false;
}
if (!is_valid_plugin_name (name))
{
- error_set (e, PLUGIN_ERROR, PLUGIN_ERROR_LOADING_FAILED,
- "invalid plugin name");
+ error_set (e, "invalid plugin name");
return false;
}
if (str_map_find (&ctx->plugins_by_name, name))
{
- error_set (e, PLUGIN_ERROR, PLUGIN_ERROR_ALREADY_LOADED,
- "the plugin has already been loaded");
+ error_set (e, "the plugin has already been loaded");
return false;
}
int stdin_pipe[2];
if (pipe (stdin_pipe) == -1)
{
- error_set (e, PLUGIN_ERROR, PLUGIN_ERROR_LOADING_FAILED, "%s: %s: %s",
+ error_set (e, "%s: %s: %s",
"failed to load the plugin", "pipe", strerror (errno));
goto fail_1;
}
@@ -953,7 +930,7 @@ plugin_load (struct bot_context *ctx, const char *name, struct error **e)
int stdout_pipe[2];
if (pipe (stdout_pipe) == -1)
{
- error_set (e, PLUGIN_ERROR, PLUGIN_ERROR_LOADING_FAILED, "%s: %s: %s",
+ error_set (e, "%s: %s: %s",
"failed to load the plugin", "pipe", strerror (errno));
goto fail_2;
}
@@ -964,7 +941,7 @@ plugin_load (struct bot_context *ctx, const char *name, struct error **e)
pid_t pid = fork ();
if (pid == -1)
{
- error_set (e, PLUGIN_ERROR, PLUGIN_ERROR_LOADING_FAILED, "%s: %s: %s",
+ error_set (e, "%s: %s: %s",
"failed to load the plugin", "fork", strerror (errno));
goto fail_3;
}
@@ -1034,8 +1011,7 @@ plugin_unload (struct bot_context *ctx, const char *name, struct error **e)
if (!plugin)
{
- error_set (e, PLUGIN_ERROR, PLUGIN_ERROR_NOT_LOADED,
- "no such plugin is loaded");
+ error_set (e, "no such plugin is loaded");
return false;
}
@@ -1551,16 +1527,14 @@ irc_connect (struct bot_context *ctx, struct error **e)
// do we tell our caller that he should not try to reconnect?
if (!irc_host)
{
- error_set (e, CONNECT_ERROR, CONNECT_ERROR_INVALID_CONFIGURATION,
- "no hostname specified in configuration");
+ error_set (e, "no hostname specified in configuration");
return false;
}
bool use_ssl;
if (!set_boolean_if_valid (&use_ssl, ssl_use_str))
{
- error_set (e, CONNECT_ERROR, CONNECT_ERROR_INVALID_CONFIGURATION,
- "invalid configuration value for `%s'", "use_ssl");
+ error_set (e, "invalid configuration value for `%s'", "use_ssl");
return false;
}