diff options
author | sketch <sketch@pkgsrc.org> | 2010-05-18 21:38:49 +0000 |
---|---|---|
committer | sketch <sketch@pkgsrc.org> | 2010-05-18 21:38:49 +0000 |
commit | c66b2ca69f4a01b5efadd346b405cefb0d3b3905 (patch) | |
tree | d084dcf821685c134f5edc512a40c10558ae64d2 | |
parent | eb78450f9a94a47d09e2835812746871a3223e3e (diff) | |
download | pkgsrc-c66b2ca69f4a01b5efadd346b405cefb0d3b3905.tar.gz |
Fix line length problems, previously sending >255 char messages to icb
would just result in a server error. Now we split them correctly.
-rw-r--r-- | chat/irssi-icb/Makefile | 4 | ||||
-rw-r--r-- | chat/irssi-icb/distinfo | 5 | ||||
-rw-r--r-- | chat/irssi-icb/patches/patch-af | 95 | ||||
-rw-r--r-- | chat/irssi-icb/patches/patch-ag | 23 | ||||
-rw-r--r-- | chat/irssi-icb/patches/patch-ah | 13 |
5 files changed, 137 insertions, 3 deletions
diff --git a/chat/irssi-icb/Makefile b/chat/irssi-icb/Makefile index 996f0b2854f..f13b3151258 100644 --- a/chat/irssi-icb/Makefile +++ b/chat/irssi-icb/Makefile @@ -1,8 +1,8 @@ -# $NetBSD: Makefile,v 1.29 2010/05/17 20:13:25 sketch Exp $ +# $NetBSD: Makefile,v 1.30 2010/05/18 21:38:49 sketch Exp $ # DISTNAME= irssi-icb-0.14 -PKGREVISION= 16 +PKGREVISION= 17 CATEGORIES= chat MASTER_SITES= http://www.irssi.org/files/plugins/icb/ DISTFILES= ${DISTNAME}.tar.gz ${IRSSI_DISTFILE} diff --git a/chat/irssi-icb/distinfo b/chat/irssi-icb/distinfo index 83e828cc8a7..633eb8eab80 100644 --- a/chat/irssi-icb/distinfo +++ b/chat/irssi-icb/distinfo @@ -1,4 +1,4 @@ -$NetBSD: distinfo,v 1.16 2010/05/17 20:13:25 sketch Exp $ +$NetBSD: distinfo,v 1.17 2010/05/18 21:38:49 sketch Exp $ SHA1 (irssi-0.8.15.tar.bz2) = b79ce8c2c98a76b004f63706e7868cd363000d89 RMD160 (irssi-0.8.15.tar.bz2) = 0c8fba8cf3409621f6c1883127e14538a58c3359 @@ -11,3 +11,6 @@ SHA1 (patch-ab) = 768826fbd30ed66fff6ce45b7ca492b69c0c7437 SHA1 (patch-ac) = 68409b392f3212a8da9a79c2dfcc4dc265504d98 SHA1 (patch-ad) = f5cf3b9294a1a8a450f8c380ff41bbaafd425337 SHA1 (patch-ae) = ee3ed714e2f1d136562b87cfd82bc4b58b7d80df +SHA1 (patch-af) = 8f68dadd44acd870b3e84fd561edbd5958305ef3 +SHA1 (patch-ag) = 4b0df5a1f59397455963888fbda1a57d56f90757 +SHA1 (patch-ah) = 097bab1ebd959372a0266fa5d9a99c78c3a2c1fe diff --git a/chat/irssi-icb/patches/patch-af b/chat/irssi-icb/patches/patch-af new file mode 100644 index 00000000000..4f0b13f2c83 --- /dev/null +++ b/chat/irssi-icb/patches/patch-af @@ -0,0 +1,95 @@ +--- src/core/icb-protocol.c.orig 2010-05-18 21:09:43.000000000 +0100 ++++ src/core/icb-protocol.c 2010-05-18 22:32:50.000000000 +0100 +@@ -121,7 +121,91 @@ + + void icb_send_open_msg(ICB_SERVER_REC *server, const char *text) + { +- icb_send_cmd(server, 'b', text, NULL); ++ size_t remain; ++ ++ /* ++ * ICB has 255 byte line length limit, and public messages are sent ++ * out with our nickname, so split text accordingly. ++ * ++ * 250 = 255 - 'b' - 1 space after nick - ^A - nul - extra ++ * ++ * Taken from ircII's icb.c, thanks phone :-) ++ */ ++ remain = 250 - strlen(server->connrec->nick); ++ ++ while(*text) { ++ char buf[256], *sendbuf; ++ size_t len, copylen; ++ ++ len = strlen(text); ++ copylen = remain; ++ if (len > remain) { ++ int i; ++ ++ /* try to split on a word boundary */ ++ for (i = 1; i < 128 && i < len; i++) { ++ if (isspace(text[remain - i])) { ++ copylen -= i - 1; ++ break; ++ } ++ } ++ strncpy(buf, text, copylen); ++ buf[copylen] = 0; ++ sendbuf = buf; ++ } else { ++ sendbuf = (char *)text; ++ } ++ icb_send_cmd(server, 'b', sendbuf, NULL); ++ text += len > copylen ? copylen : len; ++ } ++} ++ ++void icb_send_private_msg(ICB_SERVER_REC *server, const char *target, ++ const char *text) ++{ ++ size_t mylen, targlen, remain; ++ ++ /* ++ * ICB has 255 byte line length limit. Private messages are sent ++ * out with our nickname, but received with the target nickname, ++ * so deduct the larger of the two in addition to other parts. ++ * ++ * 248 = 255 - 'hm' - 1 space after nick - ^A's - nul - extra ++ * ++ * Taken from ircII's icb.c, thanks phone :-) ++ */ ++ mylen = strlen(server->connrec->nick); ++ targlen = strlen(target); ++ if (mylen > targlen) { ++ remain = 248 - mylen; ++ } else { ++ remain = 248 - targlen; ++ } ++ while(*text) { ++ char buf[256], *sendbuf; ++ size_t len, copylen; ++ ++ len = strlen(text); ++ copylen = remain; ++ if (len > remain) { ++ int i; ++ ++ /* try to split on a word boundary */ ++ for (i = 1; i < 128 && i < len; i++) { ++ if (isspace(text[remain - i])) { ++ copylen -= i - 1; ++ break; ++ } ++ } ++ strncpy(buf, text, copylen); ++ buf[copylen] = 0; ++ sendbuf = g_strconcat(target, " ", buf, NULL); ++ } else { ++ sendbuf = g_strconcat(target, " ", text, NULL); ++ } ++ icb_send_cmd(server, 'h', "m", sendbuf, NULL); ++ text += len > copylen ? copylen : len; ++ } + } + + void icb_command(ICB_SERVER_REC *server, const char *cmd, diff --git a/chat/irssi-icb/patches/patch-ag b/chat/irssi-icb/patches/patch-ag new file mode 100644 index 00000000000..1b634521842 --- /dev/null +++ b/chat/irssi-icb/patches/patch-ag @@ -0,0 +1,23 @@ +$NetBSD: patch-ag,v 1.1 2010/05/18 21:38:49 sketch Exp $ + +--- src/core/icb-servers.c.orig 2010-05-18 21:25:22.000000000 +0100 ++++ src/core/icb-servers.c 2010-05-18 21:24:58.000000000 +0100 +@@ -113,7 +113,6 @@ + const char *msg, int target_type) + { + ICB_SERVER_REC *icbserver; +- char *str; + + icbserver = ICB_SERVER(server); + g_return_if_fail(server != NULL); +@@ -125,9 +124,7 @@ + icb_send_open_msg(icbserver, msg); + } else { + /* private message */ +- str = g_strconcat(target, " ", msg, NULL); +- icb_command(icbserver, "m", str, NULL); +- g_free(str); ++ icb_send_private_msg(icbserver, target, msg); + } + } + diff --git a/chat/irssi-icb/patches/patch-ah b/chat/irssi-icb/patches/patch-ah new file mode 100644 index 00000000000..b7871032a1f --- /dev/null +++ b/chat/irssi-icb/patches/patch-ah @@ -0,0 +1,13 @@ +$NetBSD: patch-ah,v 1.1 2010/05/18 21:38:49 sketch Exp $ + +--- src/core/icb-protocol.h.orig 2010-05-18 21:34:32.000000000 +0100 ++++ src/core/icb-protocol.h 2010-05-18 21:34:15.000000000 +0100 +@@ -4,6 +4,8 @@ + #define ICB_PROTOCOL_LEVEL 1 + + void icb_send_open_msg(ICB_SERVER_REC *server, const char *text); ++void icb_send_private_msg(ICB_SERVER_REC *server, const char *target, ++ const char *text); + void icb_command(ICB_SERVER_REC *server, const char *cmd, + const char *args, const char *id); + void icb_protocol(ICB_SERVER_REC *server, const char *level, |