aboutsummaryrefslogtreecommitdiff
path: root/net/centericq
diff options
context:
space:
mode:
authorYing-Chieh Liao <ijliao@FreeBSD.org>2002-11-19 08:45:53 +0000
committerYing-Chieh Liao <ijliao@FreeBSD.org>2002-11-19 08:45:53 +0000
commit8187f306328ca186068361804456b1169cd0543c (patch)
tree48239e687c6e264c9445918e2e6946206c84c0db /net/centericq
parentbee7e2deef138a7be0de5558564b6e452b003470 (diff)
downloadports-8187f306328ca186068361804456b1169cd0543c.tar.gz
ports-8187f306328ca186068361804456b1169cd0543c.zip
Notes
Diffstat (limited to 'net/centericq')
-rw-r--r--net/centericq/Makefile2
-rw-r--r--net/centericq/files/patch-msn_commands.cc199
-rw-r--r--net/centericq/files/patch-msnhook.cc159
-rw-r--r--net/centericq/files/patch-utf8conv.h59
4 files changed, 219 insertions, 200 deletions
diff --git a/net/centericq/Makefile b/net/centericq/Makefile
index 4fc83b76e8c1..1eeb9e11c015 100644
--- a/net/centericq/Makefile
+++ b/net/centericq/Makefile
@@ -8,7 +8,7 @@
PORTNAME= centericq
PORTVERSION= 4.8.7
-PORTREVISION= 0
+PORTREVISION= 1
CATEGORIES= net
MASTER_SITES= http://konst.org.ua/download/
diff --git a/net/centericq/files/patch-msn_commands.cc b/net/centericq/files/patch-msn_commands.cc
deleted file mode 100644
index 00838c3e63cb..000000000000
--- a/net/centericq/files/patch-msn_commands.cc
+++ /dev/null
@@ -1,199 +0,0 @@
---- libmsn-0.1/msn_commands.cc.orig Wed Oct 16 18:20:59 2002
-+++ libmsn-0.1/msn_commands.cc Wed Oct 30 16:44:55 2002
-@@ -30,7 +30,10 @@
- #include <sys/socket.h>
- #include <errno.h>
- #include <netdb.h>
--
-+#define HAVE_ICONV_H 1
-+#if HAVE_ICONV_H
-+#include <iconv.h>
-+#endif
- #include "libmsn.h"
- #include "msn_commands.h"
- #include "parse_utils.h"
-@@ -426,6 +429,128 @@
- return 0;
- }
-
-+#if HAVE_ICONV_H
-+/*
-+** Name: safe_iconv
-+** Purpose: 'Fault-tolerant' version if iconv. Replaces invalid seq with '?'
-+** Input: see iconv manpage
-+*/
-+static int safe_iconv( iconv_t handle,
-+ const char **inbuf, size_t *inbytesleft,
-+ char **outbuf, size_t *outbytesleft)
-+{
-+ int ret;
-+ while (*inbytesleft) {
-+ ret = iconv( handle, inbuf, inbytesleft,
-+ outbuf, outbytesleft);
-+ if (!*inbytesleft || !*outbytesleft)
-+ return ret;
-+ /*got invalid seq - so replace it with '?' */
-+ **outbuf = '?'; (*outbuf)++; (*outbytesleft)--;
-+ (*inbuf)++; (*inbytesleft)--;
-+ }
-+ return ret;
-+}
-+
-+/* charset name cache buffer */
-+char loc_charset[32];
-+
-+#define DEFAULT_CHARSET "ISO-8859-1"
-+
-+/*
-+** Name: guess_current_locale_charset
-+** Purpose: Try to guess default charset for the current locale
-+** Output: charset name
-+** FIXME: is there more right method for guessing charset
-+ than scanning $LANG ?
-+*/
-+static char* guess_current_locale_charset()
-+{
-+ char *lang, *ch;
-+ /* Return previously learned charset */
-+ return "big5";
-+ if (loc_charset[0])
-+ return loc_charset;
-+
-+ lang = getenv("LANG");
-+ ch = strrchr( lang, '.' ) + 1;
-+ if (!ch)
-+ strcpy( loc_charset, DEFAULT_CHARSET );
-+ else {
-+ iconv_t pt;
-+ strncpy( loc_charset, ch, sizeof(loc_charset) );
-+ /* try to open iconv handle using guessed charset */
-+ if ( (pt = iconv_open( loc_charset, loc_charset )) == (iconv_t)(-1) )
-+ {
-+ strcpy( loc_charset, DEFAULT_CHARSET );
-+ } else {
-+ iconv_close(pt);
-+ };
-+
-+ }
-+
-+ return loc_charset;
-+}
-+#endif /* HAVE_ICONV_H */
-+
-+/*
-+** Name: Str2Utf8
-+** Purpose: convert a string in UTF-8 format
-+** Input: inbuf - the string to convert
-+** Output: a new string in UTF-8 format
-+*/
-+static char *StrToUtf8( const char *inbuf )
-+{
-+#if HAVE_ICONV_H
-+ size_t length = strlen( inbuf );
-+ size_t outmaxlength = length * 4; /* FIXME: Is x4 multiplier enoght? */
-+ char *outbuf = (char*) malloc( outmaxlength + 1 );
-+ char *outbuf_save = outbuf;
-+ int ret;
-+
-+ iconv_t handle = iconv_open( "utf-8", guess_current_locale_charset() );
-+ ret = safe_iconv( handle, (const char **) &inbuf, &length, &outbuf, &outmaxlength );
-+
-+ iconv_close( handle );
-+
-+ return outbuf_save;
-+#else
-+ char *outbuf = strdup( inbuf );
-+ char *outbuf_save = outbuf;
-+ /* Clear eight bit */
-+ for (; *outbuf; ++outbuf)
-+ *outbuf &= 0x7F;
-+ return outbuf_save;
-+#endif
-+}
-+
-+/*
-+** Name: Utf8ToStr
-+** Purpose: revert UTF-8 string conversion
-+** Input: inbuf - the string to decode
-+** Output: a new decoded string
-+*/
-+static char *Utf8ToStr( char *inbuf )
-+{
-+#if HAVE_ICONV_H
-+ size_t length = strlen( inbuf );
-+ size_t outmaxlength = length;
-+ char *outbuf = (char*) malloc( outmaxlength + 1 );
-+ char *outbuf_save = outbuf;
-+ int ret;
-+
-+ iconv_t handle = iconv_open( guess_current_locale_charset(), "utf-8" );
-+
-+ ret = safe_iconv( handle, (const char **) &inbuf, &length, &outbuf, &outmaxlength );
-+
-+ iconv_close( handle );
-+
-+ return outbuf_save;
-+#else
-+ return strdup( inbuf );
-+#endif
-+}
-+
- /*
- ** Name: HandleMessage
- ** Purpose: This function handles an instant message from either the server
-@@ -440,6 +565,7 @@
- {
- MSN_InstantMessage newIm;
- char *message;
-+ char *decodedIm;
- char *mimeInfo, *im;
- int length, nread;
- struct timeval t;
-@@ -448,6 +574,8 @@
- message = NULL;
- mimeInfo = NULL;
- im = NULL;
-+ decodedIm = NULL;
-+
-
- if (numOfArgs != 4)
- return -1;
-@@ -470,13 +598,15 @@
-
- if (mimeInfo != NULL) {
- if (strstr(mimeInfo, "text/plain") != NULL) {
-+
-+ decodedIm = Utf8ToStr( im );
- newIm.year = 0;
- newIm.month = 0;
- newIm.day = 0;
- newIm.hour = 0;
- newIm.minute = 0;
- newIm.sec = 0;
-- newIm.msg = im;
-+ newIm.msg = decodedIm;
- RemoveHotmail(args[1], &newIm.sender);
- newIm.friendlyhandle = args[2];
- newIm.fd = conn->fd;
-@@ -571,15 +701,18 @@
- int SendMessage(MSN_Conn *conn, const char *message)
- {
- char *commandLine;
-+ char *UTFmessage;
- int length;
-
- if (!message)
- return -1;
-+ UTFmessage = NULL;
-
-- commandLine = (char *)malloc(strlen(MIME_HEADER)+strlen(message)+25);
-+ UTFmessage = StrToUtf8( message );
-+ commandLine = (char *)malloc(strlen(MIME_HEADER)+strlen(UTFmessage)+25);
- length = sprintf(commandLine, "%s %lu N %d\r\n%s%s", CommandString[MSG],
-- TrID++, strlen(message)+strlen(MIME_HEADER), MIME_HEADER,
-- message);
-+ TrID++, strlen(UTFmessage)+strlen(MIME_HEADER), MIME_HEADER,
-+ UTFmessage);
-
- write(conn->fd, commandLine, length);
- free(commandLine);
diff --git a/net/centericq/files/patch-msnhook.cc b/net/centericq/files/patch-msnhook.cc
new file mode 100644
index 000000000000..12ceb55cf702
--- /dev/null
+++ b/net/centericq/files/patch-msnhook.cc
@@ -0,0 +1,159 @@
+--- src/hooks/msnhook.cc Tue Nov 19 10:18:22 2002
++++ src/hooks/msnhook.cc Tue Nov 19 10:18:35 2002
+@@ -30,6 +30,7 @@
+ #include "eventmanager.h"
+ #include "centericq.h"
+ #include "imlogger.h"
++#include "utf8conv.h"
+
+ msnhook mhook;
+
+@@ -159,7 +160,8 @@
+ }
+
+ icqcontact *c = clist.get(ev.getcontact());
+- text = siconv(text, conf.getrussian() ? "koi8-u" : DEFAULT_CHARSET, "utf8");
++ text = StrToUtf8(text);
++// text = siconv(text, conf.getrussian() ? "koi8-u" : DEFAULT_CHARSET, "utf8");
+ // text = toutf8(rusconv("kw", text));
+
+ if(c)
+@@ -274,8 +276,8 @@
+ m.homepage = "http://members.msn.com/" + b.email;
+
+ if(!friendlynicks[ic.nickname].empty()) {
+- c->setdispnick(friendlynicks[ic.nickname]);
+- b.fname = friendlynicks[ic.nickname];
++ c->setdispnick(Utf8ToStr(friendlynicks[ic.nickname]));
++ b.fname = Utf8ToStr(friendlynicks[ic.nickname]);
+ }
+
+ c->setbasicinfo(b);
+@@ -371,7 +373,8 @@
+ }
+
+ // text = rusconv("wk", fromutf8(d->msg));
+- text = siconv(d->msg, "utf8", conf.getrussian() ? "koi8-u" : DEFAULT_CHARSET);
++// text = siconv(d->msg, "utf8", conf.getrussian() ? "koi8-u" : DEFAULT_CHARSET);
++ text = Utf8ToStr(d->msg);
+ em.store(immessage(ic, imevent::incoming, text));
+
+ if(c)
+@@ -453,3 +456,117 @@
+ clist.get(contactroot)->playsound(imevent::email);
+ }
+ }
++#if HAVE_ICONV_H
++int safe_iconv( iconv_t handle, const char **inbuf, size_t *inbytesleft,
++ char **outbuf, size_t *outbytesleft)
++{
++ int ret;
++ while (*inbytesleft) {
++ ret = iconv( handle, inbuf, inbytesleft,
++ outbuf, outbytesleft);
++ if (!*inbytesleft || !*outbytesleft)
++ return ret;
++ /*got invalid seq - so replace it with '?' */
++ **outbuf = '?'; (*outbuf)++; (*outbytesleft)--;
++ (*inbuf)++; (*inbytesleft)--;
++ }
++ return ret;
++}
++
++const char* guess_current_locale_charset()
++{
++ char *lang, *ch;
++ /* Return previously learned charset */
++ if (loc_charset[0])
++ return loc_charset;
++
++ lang = getenv("LANG");
++ ch = strrchr( lang, '.' ) + 1;
++ if (!ch)
++ strcpy( loc_charset, DEFAULT_CHARSET );
++ else {
++ iconv_t pt;
++ strncpy( loc_charset, ch, sizeof(loc_charset) );
++ /* try to open iconv handle using guessed charset */
++ if ( (pt = iconv_open( loc_charset, loc_charset )) == (iconv_t)(-1) )
++ {
++ strcpy( loc_charset, DEFAULT_CHARSET );
++ } else {
++ iconv_close(pt);
++ };
++
++ }
++
++ return loc_charset;
++}
++
++char *StrToUtf8( const char *inbuf )
++{
++ size_t length = strlen( inbuf );
++ size_t outmaxlength = length * 4; /* FIXME: Is x4 multiplier enoght? */
++ char *outbuf = (char*) malloc( outmaxlength + 1 );
++ char *outbuf_save = outbuf;
++ int ret;
++
++ iconv_t handle = iconv_open( "utf-8", guess_current_locale_charset() );
++ ret = safe_iconv( handle, (const char **) &inbuf, &length, &outbuf, &outmaxlength );
++
++ iconv_close( handle );
++
++ return outbuf_save;
++}
++
++std::string StrToUtf8( const std::string &instr )
++{
++ size_t length = instr.length();
++ size_t outmaxlength = length * 4; /* FIXME: Is x4 multiplier enoght? */
++ const char *inbuf = instr.c_str();
++ char *outbuf = (char*) malloc( outmaxlength + 1 );
++ char *outbuf_save = outbuf;
++ int ret;
++
++ iconv_t handle = iconv_open( "utf-8", guess_current_locale_charset() );
++ ret = safe_iconv( handle, (const char **) &inbuf, &length, &outbuf, &outmaxlength );
++
++ iconv_close( handle );
++
++ std::string return_me = outbuf_save;
++ return return_me;
++}
++
++char *Utf8ToStr( const char *inbuf )
++{
++ size_t length = strlen( inbuf );
++ size_t outmaxlength = length;
++ char *outbuf = (char*) malloc( outmaxlength + 1 );
++ char *outbuf_save = outbuf;
++ int ret;
++
++ iconv_t handle = iconv_open( guess_current_locale_charset(), "utf-8" );
++
++ ret = safe_iconv( handle, (const char **) &inbuf, &length, &outbuf, &outmaxlength );
++
++ iconv_close( handle );
++
++ return outbuf_save;
++}
++
++std::string Utf8ToStr( const std::string &instr )
++{
++ size_t length = instr.length();
++ size_t outmaxlength = length;
++ const char *inbuf = instr.c_str();
++ char *outbuf = (char*) malloc( outmaxlength + 1 );
++ char *outbuf_save = outbuf;
++ int ret;
++
++ iconv_t handle = iconv_open( guess_current_locale_charset(), "utf-8" );
++
++ ret = safe_iconv( handle, (const char **) &inbuf, &length, &outbuf, &outmaxlength );
++
++ iconv_close( handle );
++
++ std::string return_me = outbuf_save;
++ return return_me;
++}
++#endif /* HAVE_ICONV_H */
diff --git a/net/centericq/files/patch-utf8conv.h b/net/centericq/files/patch-utf8conv.h
new file mode 100644
index 000000000000..ece334f978df
--- /dev/null
+++ b/net/centericq/files/patch-utf8conv.h
@@ -0,0 +1,59 @@
+--- src/hooks/utf8conv.h Thu Jan 1 08:00:00 1970
++++ src/hooks/utf8conv.h Tue Nov 19 15:19:44 2002
+@@ -0,0 +1,56 @@
++/*-------------------------------------------------------*/
++/* utf8conv.h ( Utf8 Converter ) */
++/*-------------------------------------------------------*/
++/* target : Converting Utf8 from/to string/char */
++/* modifier : clsung@dragon2.net */
++/* create : unknown */
++/* update : 02/11/19 */
++/*-------------------------------------------------------*/
++#ifndef _UTF8CONV_
++#define _UTF8CONV_
++
++#ifndef HAVE_ICONV_H
++#define HAVE_ICONV_H
++#endif
++
++#ifdef HAVE_ICONV_H
++#include <iconv.h>
++#endif
++#include <string>
++#define DEFAULT_CHARSET "ISO-8859-1"
++/* charset name cache buffer */
++static char loc_charset[32];
++/*
++** Name: safe_iconv
++** Purpose: 'Fault-tolerant' version if iconv. Replaces invalid seq with '?'
++** Input: see iconv manpage
++*/
++int safe_iconv( iconv_t handle, const char **inbuf, size_t *inbytesleft,
++ char **outbuf, size_t *outbytesleft);
++
++/*
++** Name: guess_current_locale_charset
++** Purpose: Try to guess default charset for the current locale
++** Output: charset name
++** FIXME: is there more right method for guessing charset
++ than scanning $LANG ?
++*/
++const char* guess_current_locale_charset();
++
++/*
++** Name: Str2Utf8
++** Purpose: convert a string in UTF-8 format
++** Input: inbuf - the string to convert
++** Output: a new string in UTF-8 format
++*/
++char *StrToUtf8( const char *inbuf );
++std::string StrToUtf8( const std::string &instr );
++/*
++** Name: Utf8ToStr
++** Purpose: revert UTF-8 string conversion
++** Input: inbuf - the string to decode
++** Output: a new decoded string
++*/
++char *Utf8ToStr( const char *inbuf );
++std::string Utf8ToStr( const std::string &instr );
++#endif