From c2c9d4dc581d76f171cc99cfa8d1ba01affac030 Mon Sep 17 00:00:00 2001 From: Přemysl Janouch Date: Wed, 15 Apr 2015 12:38:21 +0200 Subject: degesch: update TODO/FIXME comments --- degesch.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/degesch.c b/degesch.c index 1f21461..451d149 100644 --- a/degesch.c +++ b/degesch.c @@ -177,9 +177,6 @@ enum buffer_type BUFFER_PM ///< Private messages (query) }; -// TODO: now I can't just print messages with print_status() etc., -// all that stuff has to go in a buffer now - struct buffer { LIST_HEADER (struct buffer) @@ -746,6 +743,9 @@ buffer_line_display (struct app_context *ctx, struct buffer_line *line) if (ctx->readline_prompt_shown) app_readline_hide (&state); + // TODO: write the line to a log file; note that the global and server + // buffers musn't collide with filenames + printf ("%s\n", text.str); str_free (&text); @@ -1079,6 +1079,7 @@ ca_error: } // Only inform the user if we're not actually verifying + // FIXME: print to the server buffer print_warning ("%s", error->message); error_free (error); return true; @@ -1103,10 +1104,12 @@ irc_initialize_ssl (struct app_context *ctx, struct error **e) { char *path = resolve_config_filename (ssl_cert); if (!path) + // FIXME: print to the global buffer print_error ("%s: %s", "cannot open file", ssl_cert); // XXX: perhaps we should read the file ourselves for better messages else if (!SSL_use_certificate_file (ctx->ssl, path, SSL_FILETYPE_PEM) || !SSL_use_PrivateKey_file (ctx->ssl, path, SSL_FILETYPE_PEM)) + // FIXME: print to the global buffer print_error ("%s: %s", "setting the SSL client certificate failed", ERR_error_string (ERR_get_error (), NULL)); free (path); @@ -1184,8 +1187,8 @@ irc_establish_connection (struct app_context *ctx, else real_host = buf; - // XXX: we shouldn't mix these statuses with `struct error'; choose 1! char *address = format_host_port_pair (real_host, port); + // FIXME: print to the server buffer print_status ("connecting to %s...", address); free (address); @@ -1347,6 +1350,7 @@ irc_process_message (const struct irc_message *msg, || !strcasecmp (msg->command, "376") // RPL_ENDOFMOTD || !strcasecmp (msg->command, "422"))) // ERR_NOMOTD { + // FIXME: print to the server buffer print_status ("successfully connected"); ctx->irc_ready = true; @@ -1362,6 +1366,7 @@ irc_process_message (const struct irc_message *msg, // This is going to be a lot more complicated if (show_to_user) // TODO: ensure proper encoding + // FIXME: print to the server buffer print_status ("%s", raw); } @@ -1526,6 +1531,7 @@ on_irc_reconnect_timeout (void *user_data) if (irc_connect (ctx, &e)) return; + // FIXME: print to the server buffer print_error ("%s", e->message); error_free (e); irc_queue_reconnect (ctx); @@ -1535,6 +1541,7 @@ static void irc_queue_reconnect (struct app_context *ctx) { hard_assert (ctx->irc_fd == -1); + // FIXME: print to the server buffer print_status ("trying to reconnect in %ld seconds...", ctx->reconnect_delay); poller_timer_set (&ctx->reconnect_tmr, ctx->reconnect_delay * 1000); @@ -1574,6 +1581,7 @@ static void on_irc_ping_timeout (void *user_data) { struct app_context *ctx = user_data; + // FIXME: print to the server buffer print_error ("connection timeout"); on_irc_disconnected (ctx); } @@ -1617,10 +1625,12 @@ on_irc_readable (const struct pollfd *fd, struct app_context *ctx) case IRC_READ_AGAIN: goto end; case IRC_READ_ERROR: + // FIXME: print to the server buffer print_error ("reading from the IRC server failed"); disconnected = true; goto end; case IRC_READ_EOF: + // FIXME: print to the server buffer print_status ("the IRC server closed the connection"); disconnected = true; goto end; @@ -1630,6 +1640,7 @@ on_irc_readable (const struct pollfd *fd, struct app_context *ctx) if (buf->len >= (1 << 20)) { + // FIXME: print to the server buffer print_error ("the IRC server seems to spew out data frantically"); irc_shutdown (ctx); goto end; @@ -1682,6 +1693,7 @@ irc_connect (struct app_context *ctx, struct error **e) { char *address = format_host_port_pair (irc_host, irc_port); char *socks_address = format_host_port_pair (socks_host, socks_port); + // FIXME: print to the server buffer print_status ("connecting to %s via %s...", address, socks_address); free (socks_address); free (address); @@ -1706,6 +1718,7 @@ irc_connect (struct app_context *ctx, struct error **e) ctx->irc_fd = -1; return false; } + // FIXME: print to the server buffer print_status ("connection established"); poller_fd_init (&ctx->irc_event, &ctx->poller, ctx->irc_fd); @@ -1940,6 +1953,7 @@ load_config (struct app_context *ctx, struct error **e) str_init (&value); if (!unescape_string (iter.link->data, &value, &e)) { + // FIXME: use the "e" argument, don't print it print_error ("error reading configuration: %s: %s", iter.link->key, e->message); error_free (e); @@ -2061,10 +2075,13 @@ main (int argc, char *argv[]) refresh_prompt (&ctx); // TODO: connect asynchronously (first step towards multiple servers) + // TODO: print load_config() errors to the global buffer, + // switch buffers and print irc_connect() errors to the server buffer? struct error *e = NULL; if (!load_config (&ctx, &e) || !irc_connect (&ctx, &e)) { + // FIXME: print to the global buffer print_error ("%s", e->message); error_free (e); exit (EXIT_FAILURE); -- cgit v1.2.3-70-g09d2