aboutsummaryrefslogtreecommitdiffstats
path: root/irc.c
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2006-03-31 19:55:47 +0200
committerWilmer van der Gaast <wilmer@gaast.net>2006-03-31 19:55:47 +0200
commite27661d09e8c3fc85c979d4769ba20d1d3c289e2 (patch)
tree63c11c2afb214d8a2077c78a19ee1b81ec0806ba /irc.c
parentd783e48a831cf5058e2307a382e7e95a06680289 (diff)
Finished the iconv() fix. Instead of doing it every time something goes from
or to the IM-modules, it's now just done with everything that goes between BitlBee and the user. Incomparably more efficient/reliable. Plus some more cleanups. It compiles, can't test it for real yet. ;-)
Diffstat (limited to 'irc.c')
-rw-r--r--irc.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/irc.c b/irc.c
index b6185d85..0d308912 100644
--- a/irc.c
+++ b/irc.c
@@ -345,7 +345,7 @@ void irc_setpass (irc_t *irc, const char *pass)
void irc_process( irc_t *irc )
{
- char **lines, *temp, **cmd;
+ char **lines, *temp, **cmd, *cs;
int i;
if( irc->readbuffer != NULL )
@@ -354,6 +354,9 @@ void irc_process( irc_t *irc )
for( i = 0; *lines[i] != '\0'; i ++ )
{
+ /* [WvG] Because irc_tokenize splits at every newline, the lines[] list
+ should end with an empty string. This is why this actually works.
+ Took me a while to figure out, Maurits. :-P */
if( lines[i+1] == NULL )
{
temp = g_strdup( lines[i] );
@@ -361,7 +364,16 @@ void irc_process( irc_t *irc )
irc->readbuffer = temp;
i ++;
break;
- }
+ }
+
+ if( ( cs = set_getstr( irc, "charset" ) ) )
+ {
+ char conv[IRC_MAX_LINE+1];
+
+ conv[IRC_MAX_LINE] = 0;
+ if( do_iconv( cs, "UTF-8", lines[i], conv, 0, IRC_MAX_LINE - 2 ) != -1 )
+ strcpy( lines[i], conv );
+ }
if( ( cmd = irc_parse_line( lines[i] ) ) == NULL )
continue;
@@ -387,6 +399,8 @@ void irc_process( irc_t *irc )
}
}
+/* Splits a long string into separate lines. The array is NULL-terminated and, unless the string
+ contains an incomplete line at the end, ends with an empty string. */
char **irc_tokenize( char *buffer )
{
int i, j;
@@ -427,6 +441,7 @@ char **irc_tokenize( char *buffer )
return( lines );
}
+/* Split an IRC-style line into little parts/arguments. */
char **irc_parse_line( char *line )
{
int i, j;
@@ -486,6 +501,7 @@ char **irc_parse_line( char *line )
return cmd;
}
+/* Converts such an array back into a command string. Mainly used for the IPC code right now. */
char *irc_build_line( char **cmd )
{
int i, len;