On Saturday 30 April 2005 11:17 pm, tabris wrote:
> I have a tentative patch for skip_target() that handles Unreal's
> multi-prefix NOTICEs. I'm thinking that it's a bit hackish atm
> however, so want to know how I can get access to the isupport
> PREFIXes so that I can support any prefix.
>
New patch for this, this should be portable.
It has been compile tested, w/ --enable-gc. No warnings, no errors in
the modified files.
It has been runtime-tested. However only on dancer-ircd (freenode) and
Unreal 3.2.3 w/ PREFIX_AQ enabled.
--
tabris
-
Big book, big bore.
-- Callimachus
Index: src/fe-common/irc/fe-irc-messages.c
===================================================================
--- src/fe-common/irc/fe-irc-messages.c (revision 3742)
+++ src/fe-common/irc/fe-irc-messages.c (working copy)
@@ -37,16 +37,43 @@
#include "fe-queries.h"
#include "window-items.h"
-static const char *skip_target(const char *target)
+static const char *skip_target(IRC_SERVER_REC *server, const char *target)
{
- if (target != NULL && *target == '@') {
- /* @#channel, @+#channel - Hybrid6 / Bahamut features */
- if (target[1] == '+' && ischannel(target[2]))
- target += 2;
- else if (ischannel(target[1]))
- target++;
+ int i = 0, j = 0, isprefix = 0;
+ char *prefix = g_hash_table_lookup(server->isupport, "PREFIX");
+ char *prefixes;
+
+ if (prefix) {
+ // PREFIX=(ov)@+
+ prefixes = strchr(prefix, ')');
}
+ else {
+ prefixes = strdup("@+");
+ }
+
+ for(i = 0; i < strlen(target); i++) {
+ isprefix = 0;
+ for(j = 0; j < strlen(prefixes); j++) {
+ if(target[i] == prefixes[j]) {
+ isprefix = 1;
+ break;
+ }
+ }
+ if (!isprefix)
+ break;
+ }
+
+ if(ischannel(target[i])) {
+ target += i;
+ };
+ if (prefix) {
+ g_free(prefix);
+ }
+ else {
+ g_free(prefixes);
+ };
+
return target;
}
@@ -57,7 +84,7 @@ static void sig_message_own_public(SERVE
char *nickmode;
oldtarget = target;
- target = skip_target(target);
+ target = skip_target(IRC_SERVER(server), target);
if (IS_IRC_SERVER(server) && target != oldtarget) {
/* Hybrid 6 / Bahamut feature, send msg to all
ops / ops+voices in channel */
@@ -179,7 +206,7 @@ static void sig_message_irc_action(IRC_S
static void sig_message_own_notice(IRC_SERVER_REC *server, const char *msg,
const char *target)
{
- printformat(server, skip_target(target), MSGLEVEL_NOTICES |
+ printformat(server, skip_target(server, target), MSGLEVEL_NOTICES |
MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT,
IRCTXT_OWN_NOTICE, target, msg);
}
@@ -191,7 +218,7 @@ static void sig_message_irc_notice(SERVE
const char *oldtarget;
oldtarget = target;
- target = skip_target(target);
+ target = skip_target(IRC_SERVER(server), target);
if (address == NULL || *address == '\0') {
/* notice from server */
Index: src/fe-common/irc/fe-irc-commands.c
===================================================================
--- src/fe-common/irc/fe-irc-commands.c (revision 3742)
+++ src/fe-common/irc/fe-irc-commands.c (working copy)
@@ -41,16 +41,43 @@
#include "printtext.h"
#include "keyboard.h"
-static const char *skip_target(const char *target)
+static const char *skip_target(IRC_SERVER_REC *server, const char *target)
{
- if (*target == '@') {
- /* @#channel, @+#channel - Hybrid6 / Bahamut features */
- if (target[1] == '+' && ischannel(target[2]))
- target += 2;
- else if (ischannel(target[1]))
- target++;
+ int i = 0, j = 0, isprefix = 0;
+ const char *prefix = g_hash_table_lookup(server->isupport, "PREFIX");
+ const char *prefixes;
+
+ if (prefix) {
+ // PREFIX=(ov)@+
+ prefixes = strchr(prefix, ')');
+ }
+ else {
+ prefixes = strdup("@+");
+ }
+
+ for(i = 0; i < strlen(target); i++) {
+ isprefix = 0;
+ for(j = 0; j < strlen(prefixes); j++) {
+ if(target[i] == prefixes[j]) {
+ isprefix = 1;
+ break;
+ }
+ }
+ if (!isprefix)
+ break;
}
+ if(ischannel(target[i])) {
+ target += i;
+ };
+
+ if (prefix) {
+ g_free(prefix);
+ }
+ else {
+ g_free(prefixes);
+ };
+
return target;
}
@@ -103,7 +130,7 @@ static void cmd_action(const char *data,
recoded = recode_out(SERVER(server), text, target);
irc_send_cmdv(server, "PRIVMSG %s :\001ACTION %s\001", target, recoded);
- target = skip_target(target);
+ target = skip_target(server, target);
signal_emit("message irc own_action", 3, server, recoded, target);
g_free(recoded);
@@ -158,7 +185,7 @@ static void cmd_ctcp(const char *data, I
return;
}
- target = skip_target(target);
+ target = skip_target(server, target);
g_strup(ctcpcmd);
signal_emit("message irc own_ctcp", 4,
@@ -183,7 +210,7 @@ static void cmd_nctcp(const char *data,
if (*target == '\0' || *text == '\0')
cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
- target = skip_target(target);
+ target = skip_target(server, target);
signal_emit("message irc own_notice", 3, server, text, target);
cmd_params_free(free_arg);
}
pgplABs1uPRWm.pgp
Description: PGP signature
