/** * Check the configured key bindings for errors, and display a status * message every 10 seconds. */ static gboolean timer_check_key_bindings(G_GNUC_UNUSED gpointer data) { char buf[256]; #ifdef ENABLE_KEYDEF_SCREEN char comment[64]; #endif gboolean key_error; key_error = check_key_bindings(NULL, buf, sizeof(buf)); if (!key_error) { /* no error: disable this timer for the rest of this process */ check_key_bindings_source_id = 0; return FALSE; } #ifdef ENABLE_KEYDEF_SCREEN g_strchomp(buf); g_strlcat(buf, " (", sizeof(buf)); /* to translators: a key was bound twice in the key editor, and this is a hint for the user what to press to correct that */ g_snprintf(comment, sizeof(comment), _("press %s for the key editor"), get_key_names(CMD_SCREEN_KEYDEF, false)); g_strlcat(buf, comment, sizeof(buf)); g_strlcat(buf, ")", sizeof(buf)); #endif screen_status_printf("%s", buf); doupdate(); return TRUE; }
void command_dump_keys(void) { for (int i = 0; cmds[i].description; i++) if (cmds[i].command != CMD_NONE) printf(" %20s : %s\n", get_key_names(cmds[i].command, true), cmds[i].name); }
/*! * Parse legacy key files and get public key, private key, and key timing. */ int legacy_key_parse(const char *filename, dnssec_key_t **key_ptr, dnssec_binary_t *pem_ptr, dnssec_kasp_key_timing_t *timing) { if (!filename || !key_ptr || !pem_ptr || !timing) { return DNSSEC_EINVAL; } _cleanup_free_ char *filename_public = NULL; _cleanup_free_ char *filename_private = NULL; int result = get_key_names(filename, &filename_public, &filename_private); if (result != DNSSEC_EOK) { return result; } dnssec_key_t *key = NULL; result = legacy_pubkey_parse(filename_public, &key); if (result != DNSSEC_EOK) { return result; } legacy_privkey_t params = { 0 }; result = legacy_privkey_parse(filename_private, ¶ms); if (result != DNSSEC_EOK) { dnssec_key_free(key); return result; } dnssec_binary_t pem = { 0 }; result = params_to_pem(key, ¶ms, &pem); if (result != DNSSEC_EOK) { legacy_privkey_free(¶ms); return result; } *key_ptr = key; *pem_ptr = pem; params_to_timing(¶ms, timing); legacy_privkey_free(¶ms); return DNSSEC_EOK; }
/** * This timer is installed when the connection to the MPD server is * broken. It tries to recover by reconnecting periodically. */ static gboolean timer_reconnect(G_GNUC_UNUSED gpointer data) { bool success; struct mpd_connection *connection; assert(!mpdclient_is_connected(mpd)); reconnect_source_id = 0; char *name = default_settings_name(); screen_status_printf(_("Connecting to %s... [Press %s to abort]"), name, get_key_names(CMD_QUIT, false)); g_free(name); doupdate(); mpdclient_disconnect(mpd); success = mpdclient_connect(mpd, options.host, options.port, options.timeout_ms, options.password); if (!success) { /* try again in 5 seconds */ reconnect_source_id = g_timeout_add(5000, timer_reconnect, NULL); return FALSE; } connection = mpdclient_get_connection(mpd); #ifndef NCMPC_MINI /* quit if mpd is pre 0.11.0 - song id not supported by mpd */ if (mpd_connection_cmp_server_version(connection, 0, 12, 0) < 0) { const unsigned *version = mpd_connection_get_server_version(connection); screen_status_printf(_("Error: MPD version %d.%d.%d is to old (%s needed)"), version[0], version[1], version[2], "0.12.0"); mpdclient_disconnect(mpd); doupdate(); /* try again after 30 seconds */ reconnect_source_id = g_timeout_add(30000, timer_reconnect, NULL); return FALSE; } #endif if (mpd_connection_cmp_server_version(connection, 0, 14, 0) >= 0) mpd->source = mpd_glib_new(connection, idle_callback, mpd); name = connection_settings_name(connection); screen_status_printf(_("Connected to %s"), name); g_free(name); doupdate(); /* update immediately */ mpd->events = MPD_IDLE_ALL; do_mpd_update(); auto_update_timer(); return FALSE; }