# HG changeset patch # User Stu Tomlinson # Date 1132423791 0 # Node ID d6417efb990cce28bc9bd641b87dd524d7f60743 # Parent f8e22fef03fcdb2f20e0a76f078c8ac3a36d672f [gaim-migrate @ 14467] g_str_has_prefix is only available in glib >= 2.2.0. we already have a wrapper for this in gaim, but I guess it's not legitimate to use that in meanwhile, so I duplicated the wrapper there too. code reuse at it's worst. committer: Tailor Script diff -r f8e22fef03fc -r d6417efb990c src/protocols/sametime/meanwhile/mw_util.c --- a/src/protocols/sametime/meanwhile/mw_util.c Sat Nov 19 18:07:19 2005 +0000 +++ b/src/protocols/sametime/meanwhile/mw_util.c Sat Nov 19 18:09:51 2005 +0000 @@ -78,3 +78,17 @@ mw_datum_clear(d); g_free(d); } + +gboolean +mw_str_has_prefix(const char *s, const char *p) +{ +#if GLIB_CHECK_VERSION(2,2,0) + return g_str_has_prefix(s, p); +#else + if (!strncmp(s, p, strlen(p))) + return TRUE; + + return FALSE; +#endif +} + diff -r f8e22fef03fc -r d6417efb990c src/protocols/sametime/meanwhile/mw_util.h --- a/src/protocols/sametime/meanwhile/mw_util.h Sat Nov 19 18:07:19 2005 +0000 +++ b/src/protocols/sametime/meanwhile/mw_util.h Sat Nov 19 18:09:51 2005 +0000 @@ -21,7 +21,7 @@ #ifndef _MW_UTIL_H #define _MW_UTIL_H - +#include #include #include #include @@ -81,5 +81,6 @@ void mw_datum_free(struct mw_datum *d); +gboolean mw_str_has_prefix(const char *s, const char *p); #endif diff -r f8e22fef03fc -r d6417efb990c src/protocols/sametime/meanwhile/srvc_im.c --- a/src/protocols/sametime/meanwhile/srvc_im.c Sat Nov 19 18:07:19 2005 +0000 +++ b/src/protocols/sametime/meanwhile/srvc_im.c Sat Nov 19 18:09:51 2005 +0000 @@ -184,7 +184,7 @@ c->features = srvc->features; /* mark external users */ - c->ext_id = g_str_has_prefix(to->user, "@E "); + c->ext_id = mw_str_has_prefix(to->user, "@E "); srvc->convs = g_list_prepend(srvc->convs, c); } diff -r f8e22fef03fc -r d6417efb990c src/protocols/sametime/sametime.c --- a/src/protocols/sametime/sametime.c Sat Nov 19 18:07:19 2005 +0000 +++ b/src/protocols/sametime/sametime.c Sat Nov 19 18:09:51 2005 +0000 @@ -717,7 +717,7 @@ static gboolean buddy_is_external(GaimBuddy *b) { g_return_val_if_fail(b != NULL, FALSE); - return g_str_has_prefix(b->name, "@E "); + return gaim_str_has_prefix(b->name, "@E "); } @@ -2658,7 +2658,7 @@ if(! type) { ; /* feh */ - } else if(g_str_has_prefix(type, "image")) { + } else if(gaim_str_has_prefix(type, "image")) { /* put images into the image store */ guchar *d_dat; @@ -2683,7 +2683,7 @@ /* recall the image for dereferencing later */ images = g_list_append(images, GINT_TO_POINTER(img)); - } else if(g_str_has_prefix(type, "text")) { + } else if(gaim_str_has_prefix(type, "text")) { /* concatenate all the text parts together */ guchar *data; @@ -4040,7 +4040,7 @@ str = g_string_new(NULL); - if(g_str_has_prefix(who, "@E ")) { + if(gaim_str_has_prefix(who, "@E ")) { g_string_append(str, _("External User
")); } @@ -4452,7 +4452,7 @@ srvc = pd->srvc_resolve; /* catch external buddies. They won't be in the resolve service */ - if(g_str_has_prefix(buddy->name, "@E ")) { + if(gaim_str_has_prefix(buddy->name, "@E ")) { buddy_add(pd, buddy); return; }