aboutsummaryrefslogtreecommitdiffstats
path: root/protocols
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2011-12-19 01:00:31 +0100
committerWilmer van der Gaast <wilmer@gaast.net>2011-12-19 01:00:31 +0100
commit9b0ad7e8334c7c01e8d9652aa3b1aaa6c5f6d211 (patch)
tree09908d626161e333ce64cd636b0aaede502ce85f /protocols
parent64b663524a465efb7707a2c634be97b9fb6f963b (diff)
Moving msn_findheader() to lib/misc.c as get_rfc822_header() so I can use it
in OAuth as well. (Need it to find the Content-Type: header.)
Diffstat (limited to 'protocols')
-rw-r--r--protocols/msn/msn.h1
-rw-r--r--protocols/msn/msn_util.c52
-rw-r--r--protocols/msn/ns.c14
-rw-r--r--protocols/msn/sb.c8
4 files changed, 11 insertions, 64 deletions
diff --git a/protocols/msn/msn.h b/protocols/msn/msn.h
index da9430ab..bf7cdfa8 100644
--- a/protocols/msn/msn.h
+++ b/protocols/msn/msn.h
@@ -233,7 +233,6 @@ int msn_logged_in( struct im_connection *ic );
int msn_buddy_list_add( struct im_connection *ic, msn_buddy_flags_t list, const char *who, const char *realname_, const char *group );
int msn_buddy_list_remove( struct im_connection *ic, msn_buddy_flags_t list, const char *who, const char *group );
void msn_buddy_ask( bee_user_t *bu );
-char *msn_findheader( char *text, char *header, int len );
char **msn_linesplit( char *line );
int msn_handler( struct msn_handler_data *h );
void msn_msgq_purge( struct im_connection *ic, GSList **list );
diff --git a/protocols/msn/msn_util.c b/protocols/msn/msn_util.c
index 7fa68915..d5a74a47 100644
--- a/protocols/msn/msn_util.c
+++ b/protocols/msn/msn_util.c
@@ -227,58 +227,6 @@ void msn_buddy_ask( bee_user_t *bu )
imcb_ask( bu->ic, buf, bla, msn_buddy_ask_yes, msn_buddy_ask_no );
}
-char *msn_findheader( char *text, char *header, int len )
-{
- int hlen = strlen( header ), i;
- char *ret;
-
- if( len == 0 )
- len = strlen( text );
-
- i = 0;
- while( ( i + hlen ) < len )
- {
- /* Maybe this is a bit over-commented, but I just hate this part... */
- if( g_strncasecmp( text + i, header, hlen ) == 0 )
- {
- /* Skip to the (probable) end of the header */
- i += hlen;
-
- /* Find the first non-[: \t] character */
- while( i < len && ( text[i] == ':' || text[i] == ' ' || text[i] == '\t' ) ) i ++;
-
- /* Make sure we're still inside the string */
- if( i >= len ) return( NULL );
-
- /* Save the position */
- ret = text + i;
-
- /* Search for the end of this line */
- while( i < len && text[i] != '\r' && text[i] != '\n' ) i ++;
-
- /* Make sure we're still inside the string */
- if( i >= len ) return( NULL );
-
- /* Copy the found data */
- return( g_strndup( ret, text + i - ret ) );
- }
-
- /* This wasn't the header we were looking for, skip to the next line. */
- while( i < len && ( text[i] != '\r' && text[i] != '\n' ) ) i ++;
- while( i < len && ( text[i] == '\r' || text[i] == '\n' ) ) i ++;
-
- /* End of headers? */
- if( ( i >= 4 && strncmp( text + i - 4, "\r\n\r\n", 4 ) == 0 ) ||
- ( i >= 2 && ( strncmp( text + i - 2, "\n\n", 2 ) == 0 ||
- strncmp( text + i - 2, "\r\r", 2 ) == 0 ) ) )
- {
- break;
- }
- }
-
- return( NULL );
-}
-
/* *NOT* thread-safe, but that's not a problem for now... */
char **msn_linesplit( char *line )
{
diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c
index e144a8d2..0fa49ecb 100644
--- a/protocols/msn/ns.c
+++ b/protocols/msn/ns.c
@@ -608,7 +608,7 @@ static int msn_ns_message( struct msn_handler_data *handler, char *msg, int msgl
{
if( g_strcasecmp( cmd[1], "Hotmail" ) == 0 )
{
- char *ct = msn_findheader( msg, "Content-Type:", msglen );
+ char *ct = get_rfc822_header( msg, "Content-Type:", msglen );
if( !ct )
return( 1 );
@@ -621,8 +621,8 @@ static int msn_ns_message( struct msn_handler_data *handler, char *msg, int msgl
if( !body )
return( 1 );
- mtype = msn_findheader( body, "Type:", blen );
- arg1 = msn_findheader( body, "Arg1:", blen );
+ mtype = get_rfc822_header( body, "Type:", blen );
+ arg1 = get_rfc822_header( body, "Arg1:", blen );
if( mtype && strcmp( mtype, "1" ) == 0 )
{
@@ -641,8 +641,8 @@ static int msn_ns_message( struct msn_handler_data *handler, char *msg, int msgl
{
if( set_getbool( &ic->acc->set, "mail_notifications" ) )
{
- char *inbox = msn_findheader( body, "Inbox-Unread:", blen );
- char *folders = msn_findheader( body, "Folders-Unread:", blen );
+ char *inbox = get_rfc822_header( body, "Inbox-Unread:", blen );
+ char *folders = get_rfc822_header( body, "Folders-Unread:", blen );
if( inbox && folders )
imcb_log( ic, "INBOX contains %s new messages, plus %s messages in other folders.", inbox, folders );
@@ -655,8 +655,8 @@ static int msn_ns_message( struct msn_handler_data *handler, char *msg, int msgl
{
if( set_getbool( &ic->acc->set, "mail_notifications" ) )
{
- char *from = msn_findheader( body, "From-Addr:", blen );
- char *fromname = msn_findheader( body, "From:", blen );
+ char *from = get_rfc822_header( body, "From-Addr:", blen );
+ char *fromname = get_rfc822_header( body, "From:", blen );
if( from && fromname )
imcb_log( ic, "Received an e-mail message from %s <%s>.", fromname, from );
diff --git a/protocols/msn/sb.c b/protocols/msn/sb.c
index 69114469..ccd65e49 100644
--- a/protocols/msn/sb.c
+++ b/protocols/msn/sb.c
@@ -681,7 +681,7 @@ static int msn_sb_message( struct msn_handler_data *handler, char *msg, int msgl
if( strcmp( cmd[0], "MSG" ) == 0 )
{
- char *ct = msn_findheader( msg, "Content-Type:", msglen );
+ char *ct = get_rfc822_header( msg, "Content-Type:", msglen );
if( !ct )
return( 1 );
@@ -710,8 +710,8 @@ static int msn_sb_message( struct msn_handler_data *handler, char *msg, int msgl
// Disable MSN ft support for now.
else if( g_strncasecmp( ct, "text/x-msmsgsinvite", 19 ) == 0 )
{
- char *command = msn_findheader( body, "Invitation-Command:", blen );
- char *cookie = msn_findheader( body, "Invitation-Cookie:", blen );
+ char *command = get_rfc822_header( body, "Invitation-Command:", blen );
+ char *cookie = get_rfc822_header( body, "Invitation-Cookie:", blen );
unsigned int icookie;
g_free( ct );
@@ -749,7 +749,7 @@ static int msn_sb_message( struct msn_handler_data *handler, char *msg, int msgl
}
else if( g_strncasecmp( ct, "text/x-msmsgscontrol", 20 ) == 0 )
{
- char *who = msn_findheader( msg, "TypingUser:", msglen );
+ char *who = get_rfc822_header( msg, "TypingUser:", msglen );
if( who )
{