aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2005-12-27 16:20:35 +0100
committerWilmer van der Gaast <wilmer@gaast.net>2005-12-27 16:20:35 +0100
commitc88999c6ea83ffbc8a0eb8f1ceb0ee07612dfe29 (patch)
treea9f02be8758d3f43e4a399a6f931c0392ff54dff
parente62762bc4b884d576c00fd7a2636b610e7c1b578 (diff)
Forgot to actually move those functions in previous commit. And *argh*, don't commit things done for debugging!
-rw-r--r--bitlbee.c74
-rw-r--r--util.c80
2 files changed, 75 insertions, 79 deletions
diff --git a/bitlbee.c b/bitlbee.c
index 3d7e4c4f..b9021074 100644
--- a/bitlbee.c
+++ b/bitlbee.c
@@ -199,8 +199,6 @@ gboolean bitlbee_io_current_client_read( GIOChannel *source, GIOCondition condit
return FALSE;
}
- return TRUE;
-
/* Very naughty, go read the RFCs! >:) */
if( irc->readbuffer && ( strlen( irc->readbuffer ) > 1024 ) )
{
@@ -347,75 +345,3 @@ int root_command( irc_t *irc, char *cmd[] )
return( 1 );
}
-
-/* Decode%20a%20file%20name */
-void http_decode( char *s )
-{
- char *t;
- int i, j, k;
-
- t = g_new( char, strlen( s ) + 1 );
-
- for( i = j = 0; s[i]; i ++, j ++ )
- {
- if( s[i] == '%' )
- {
- if( sscanf( s + i + 1, "%2x", &k ) )
- {
- t[j] = k;
- i += 2;
- }
- else
- {
- *t = 0;
- break;
- }
- }
- else
- {
- t[j] = s[i];
- }
- }
- t[j] = 0;
-
- strcpy( s, t );
- g_free( t );
-}
-
-/* Warning: This one explodes the string. Worst-cases can make the string 3x its original size! */
-/* This fuction is safe, but make sure you call it safely as well! */
-void http_encode( char *s )
-{
- char *t;
- int i, j;
-
- t = g_strdup( s );
-
- for( i = j = 0; t[i]; i ++, j ++ )
- {
- if( t[i] <= ' ' || ((unsigned char *)t)[i] >= 128 || t[i] == '%' )
- {
- sprintf( s + j, "%%%02X", ((unsigned char*)t)[i] );
- j += 2;
- }
- else
- {
- s[j] = t[i];
- }
- }
- s[j] = 0;
-
- g_free( t );
-}
-
-/* Strip newlines from a string. Modifies the string passed to it. */
-char *strip_newlines( char *source )
-{
- int i;
-
- for( i = 0; source[i] != '\0'; i ++ )
- if( source[i] == '\n' || source[i] == '\r' )
- source[i] = 32;
-
- return source;
-}
diff --git a/util.c b/util.c
index 6a2f2e46..73298fab 100644
--- a/util.c
+++ b/util.c
@@ -5,13 +5,12 @@
\********************************************************************/
/*
- * nogaim
- *
- * Gaim without gaim - for BitlBee
+ * Various utility functions. Some are copied from Gaim to support the
+ * IM-modules, most are from BitlBee.
*
* Copyright (C) 1998-1999, Mark Spencer <markster@marko.net>
* (and possibly other members of the Gaim team)
- * Copyright 2002-2004 Wilmer van der Gaast <lintux@lintux.cx>
+ * Copyright 2002-2005 Wilmer van der Gaast <wilmer@gaast.net>
*/
/*
@@ -31,7 +30,6 @@
Suite 330, Boston, MA 02111-1307 USA
*/
-/* Parts from util.c from gaim needed by nogaim */
#define BITLBEE_CORE
#include "nogaim.h"
#include <stdio.h>
@@ -411,3 +409,75 @@ void info_string_append(GString *str, char *newline, char *name, char *value)
if( value && value[0] )
g_string_sprintfa( str, "%s%s: %s", newline, name, value );
}
+
+/* Decode%20a%20file%20name */
+void http_decode( char *s )
+{
+ char *t;
+ int i, j, k;
+
+ t = g_new( char, strlen( s ) + 1 );
+
+ for( i = j = 0; s[i]; i ++, j ++ )
+ {
+ if( s[i] == '%' )
+ {
+ if( sscanf( s + i + 1, "%2x", &k ) )
+ {
+ t[j] = k;
+ i += 2;
+ }
+ else
+ {
+ *t = 0;
+ break;
+ }
+ }
+ else
+ {
+ t[j] = s[i];
+ }
+ }
+ t[j] = 0;
+
+ strcpy( s, t );
+ g_free( t );
+}
+
+/* Warning: This one explodes the string. Worst-cases can make the string 3x its original size! */
+/* This fuction is safe, but make sure you call it safely as well! */
+void http_encode( char *s )
+{
+ char *t;
+ int i, j;
+
+ t = g_strdup( s );
+
+ for( i = j = 0; t[i]; i ++, j ++ )
+ {
+ if( t[i] <= ' ' || ((unsigned char *)t)[i] >= 128 || t[i] == '%' )
+ {
+ sprintf( s + j, "%%%02X", ((unsigned char*)t)[i] );
+ j += 2;
+ }
+ else
+ {
+ s[j] = t[i];
+ }
+ }
+ s[j] = 0;
+
+ g_free( t );
+}
+
+/* Strip newlines from a string. Modifies the string passed to it. */
+char *strip_newlines( char *source )
+{
+ int i;
+
+ for( i = 0; source[i] != '\0'; i ++ )
+ if( source[i] == '\n' || source[i] == '\r' )
+ source[i] = ' ';
+
+ return source;
+}