diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2014-07-14 22:12:04 +0200 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2014-07-14 22:15:56 +0200 |
commit | 18cb2941f340550c1425dfa1f1376fdf3e69d42e (patch) | |
tree | c8a63b092d621bb8739bd84c8e841bc17ea468bf /src/zyklonb.c | |
parent | b0cf09fb4c3db2457141a48847dd99973dfd68cb (diff) | |
download | xK-18cb2941f340550c1425dfa1f1376fdf3e69d42e.tar.gz xK-18cb2941f340550c1425dfa1f1376fdf3e69d42e.tar.xz xK-18cb2941f340550c1425dfa1f1376fdf3e69d42e.zip |
Resolve paths relative to XDG config. paths
This should make the programs an awful lot less painful to set up.
Diffstat (limited to 'src/zyklonb.c')
-rw-r--r-- | src/zyklonb.c | 33 |
1 files changed, 9 insertions, 24 deletions
diff --git a/src/zyklonb.c b/src/zyklonb.c index 1c7f6ae..de4e3ac 100644 --- a/src/zyklonb.c +++ b/src/zyklonb.c @@ -277,12 +277,16 @@ irc_initialize_ssl (struct bot_context *ctx, struct error **e) goto error_ssl_2; const char *ssl_cert = str_map_find (&ctx->config, "ssl_cert"); - if (ssl_cert - && !SSL_use_certificate_file (ctx->ssl, ssl_cert, SSL_FILETYPE_PEM)) + if (ssl_cert) { + char *path = resolve_config_filename (ssl_cert); + if (!path) + print_error ("%s: %s", "cannot open file", ssl_cert); // XXX: perhaps we should read the file ourselves for better messages - print_error ("%s: %s", "setting the SSL client certificate failed", - ERR_error_string (ERR_get_error (), NULL)); + else if (!SSL_use_certificate_file (ctx->ssl, path, SSL_FILETYPE_PEM)) + print_error ("%s: %s", "setting the SSL client certificate failed", + ERR_error_string (ERR_get_error (), NULL)); + free (path); } SSL_set_connect_state (ctx->ssl); @@ -1686,25 +1690,6 @@ print_usage (const char *program_name) program_name); } -static void -call_write_default_config (const char *hint) -{ - static const char *prolog = - "# " PROGRAM_NAME " " PROGRAM_VERSION " configuration file\n" - "\n"; - - struct error *e = NULL; - char *filename = write_default_config (hint, prolog, g_config_table, &e); - if (!filename) - { - print_fatal ("%s", e->message); - error_free (e); - exit (EXIT_FAILURE); - } - print_status ("configuration written to `%s'", filename); - free (filename); -} - int main (int argc, char *argv[]) { @@ -1741,7 +1726,7 @@ main (int argc, char *argv[]) printf (PROGRAM_NAME " " PROGRAM_VERSION "\n"); exit (EXIT_SUCCESS); case 'w': - call_write_default_config (optarg); + call_write_default_config (optarg, g_config_table); exit (EXIT_SUCCESS); default: print_fatal ("error in options"); |