From 306b2a87075cfce4eb13e7821763bf27614c25f4 Mon Sep 17 00:00:00 2001 From: Berke Viktor Date: Sun, 15 Jan 2012 21:15:33 +0100 Subject: [PATCH] implement XSASL LIST --- plugins/xsasl/xsasl.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/plugins/xsasl/xsasl.c b/plugins/xsasl/xsasl.c index 2b2ec0c7..43689fd3 100644 --- a/plugins/xsasl/xsasl.c +++ b/plugins/xsasl/xsasl.c @@ -43,7 +43,7 @@ static xchat_plugin *ph; /* plugin handle */ static const char name[] = "X-SASL"; static const char desc[] = "SASL authentication plugin for XChat"; static const char version[] = "1.1"; -static const char xsasl_help[] = "X-SASL Usage:\n /XSASL ADD , enable SASL authentication for given network\n /XSASL DEL , disable SASL authentication for given network\n"; +static const char xsasl_help[] = "X-SASL Usage:\n /XSASL ADD , enable SASL authentication for given network\n /XSASL DEL , disable SASL authentication for given network\n /XSASL LIST, get the list of SASL-enabled networks\n"; struct sasl_info { @@ -69,6 +69,29 @@ del_info (char const* network) return xchat_pluginpref_delete (ph, network); } +static void +print_info () +{ + char list[512]; + char* token; + + if (xchat_pluginpref_list (ph, list)) + { + xchat_printf (ph, "%s\tSASL-enabled networks:", name); + xchat_printf (ph, "%s\t----------------------", name); + token = strtok (list, ","); + while (token != NULL) + { + xchat_printf (ph, "%s\t%s", name, token); + token = strtok (NULL, ","); + } + } + else + { + xchat_printf (ph, "%s\tThere are no SASL-enabled networks currently", name); + } +} + static sasl_info* find_info (char const* network) { @@ -232,6 +255,11 @@ sasl_cmd_cb (char *word[], char *word_eol[], void *userdata) return XCHAT_EAT_ALL; } + else if (!stricmp ("LIST", mode)) + { + print_info (); + return XCHAT_EAT_ALL; + } else { xchat_printf (ph, "%s", xsasl_help);