[ekg2-commit] r3918 - trunk/plugins/irc: trunk/plugins/irc/irc.c trunk/plugins/irc/irc.h trunk/plugins/irc/misc.c
SVN commit
svn w toxygen.net
Czw, 20 Mar 2008, 00:31:25 CET
Author: wiechu
Date: 2008-03-20 00:31:25 +0100 (Thu, 20 Mar 2008)
New Revision: 3918
Modified:
trunk/plugins/irc/irc.c
trunk/plugins/irc/irc.h
trunk/plugins/irc/misc.c
Log:
Fix display "safe" channel name. (Now in /whois only)
Modified: trunk/plugins/irc/irc.c
===================================================================
--- trunk/plugins/irc/irc.c 2008-03-19 22:45:44 UTC (rev 3917)
+++ trunk/plugins/irc/irc.c 2008-03-19 23:31:25 UTC (rev 3918)
@@ -139,6 +139,7 @@
char ***v, int pr, int checkchan);
static char *irc_config_default_access_groups;
+int irc_config_experimental_chan_name_clean;
PLUGIN_DEFINE(irc, PLUGIN_PROTOCOL, irc_theme_init);
@@ -2282,6 +2283,7 @@
commands_lock = NULL;
variable_add(&irc_plugin, "access_groups", VAR_STR, 1, &irc_config_default_access_groups, NULL, NULL, NULL);
+ variable_add(&irc_plugin, "experimental_chan_name_clean", VAR_BOOL, 1, &irc_config_experimental_chan_name_clean, NULL, NULL, NULL);
return 0;
}
Modified: trunk/plugins/irc/irc.h
===================================================================
--- trunk/plugins/irc/irc.h 2008-03-19 22:45:44 UTC (rev 3917)
+++ trunk/plugins/irc/irc.h 2008-03-19 23:31:25 UTC (rev 3918)
@@ -31,7 +31,7 @@
/* irc_private->sopt */
enum { USERMODES=0, CHANMODES, _005_PREFIX, _005_CHANTYPES,
- _005_CHANMODES, _005_MODES, _005_CHANLIMIT, _005_NICKLEN, SERVOPTS };
+ _005_CHANMODES, _005_MODES, _005_CHANLIMIT, _005_NICKLEN, _005_IDCHAN, SERVOPTS };
/* irc_private_t->casemapping values */
enum { IRC_CASEMAPPING_ASCII, IRC_CASEMAPPING_RFC1459, IRC_CASEMAPPING_RFC1459_STRICT, IRC_CASEMAPPING_COUNT };
@@ -145,6 +145,7 @@
int irc_parse_line(session_t *s, char *buf, int fd); /* misc.c */
+extern int irc_config_experimental_chan_name_clean;
#endif /* __EKG_PLUGINS_IRC_IRC_H */
/*
Modified: trunk/plugins/irc/misc.c
===================================================================
--- trunk/plugins/irc/misc.c 2008-03-19 22:45:44 UTC (rev 3917)
+++ trunk/plugins/irc/misc.c 2008-03-19 23:31:25 UTC (rev 3918)
@@ -50,7 +50,7 @@
#include "input.h"
#include "autoacts.h"
-char *sopt_keys[SERVOPTS] = { NULL, NULL, "PREFIX", "CHANTYPES", "CHANMODES", "MODES", "CHANLIMIT", "NICKLEN" };
+char *sopt_keys[SERVOPTS] = { NULL, NULL, "PREFIX", "CHANTYPES", "CHANMODES", "MODES", "CHANLIMIT", "NICKLEN", "IDCHAN" };
char sopt_casemapping[] = "CASEMAPPING";
char *sopt_casemapping_values[IRC_CASEMAPPING_COUNT] = { "ascii", "rfc1459", "strict-rfc1459" };
@@ -688,6 +688,85 @@
return 0;
}
+static void clean_channel_name(session_t *session, char *channel)
+{
+ char chpfx;
+ int skip;
+
+ if (!irc_config_experimental_chan_name_clean)
+ return;
+
+ irc_private_t *j = irc_private(session);
+ char *idchan = SOP(_005_IDCHAN);
+
+ if (!idchan)
+ return;
+
+ while (*idchan) {
+ chpfx = *idchan;
+
+ if (idchan[1] != ':') /* ?WO? Check it only when IDCHAN is set & dot't check here */
+ return;
+
+ skip = strtoul(idchan+2, &idchan, 10);
+ if (*idchan == ',')
+ idchan++;
+ else if (*idchan) /* ?WO? Again: Check it only when IDCHAN is set & dot't check here */
+ return;
+
+ if (chpfx != channel[0])
+ continue;
+
+ if (strlen(channel) < skip)
+ return;
+
+ strcpy(channel + 1, channel + skip + 1);
+ }
+}
+
+static void clean_channel_names_list(session_t *session, char *channels)
+{
+ char *dest, *src, *next, *p;
+ int l;
+
+ if (!irc_config_experimental_chan_name_clean)
+ return;
+
+ irc_private_t *j = irc_private(session);
+ const char *idchan = SOP(_005_IDCHAN);
+
+ if (!idchan) /* ?WO? Faster then check in clean_channel_name() ? */
+ return;
+
+ char *chmode = SOP(_005_PREFIX);
+
+ if ( ( p = strchr(chmode,')') ) ) /* ?WO? Would be nice to have '@%+' not '(ohv)@%+' */
+ chmode = ++p;
+
+ dest = src = channels;
+ while ( src && *src ) {
+ if ((*src == ' ') || (strchr(chmode, *src))) {
+ *dest++ = *src++;
+ continue;
+ }
+ p = src;
+
+ next = strchr(src, ' ');
+
+ if (next)
+ *next = '\0';
+
+ clean_channel_name(session, p);
+ l = strlen(p);
+ strcpy(dest, p);
+ dest += l;
+ src = next;
+ if (next)
+ *next=' ';
+ }
+ *dest='\0';
+}
+
IRC_COMMAND(irc_c_whois)
{
char *t = saprintf("%s%s", IRC4, param[3]), *dest = NULL;
@@ -705,6 +784,8 @@
col[i] = irc_ircoldcolstr_to_ekgcolstr(s,
param[3+i]?OMITCOLON(param[3+i]):NULL,1);
+ if (irccommands[ecode].num == 319)
+ clean_channel_names_list(s, col[1]);
/*
if (irccommands[ecode].future & IRC_WHOERR)
print_window(dest, s, 0, "IRC_WHOERROR", session_name(s), col[0], col[1]);
Więcej informacji o liście dyskusyjnej ekg2-commit