~ubuntu-branches/ubuntu/jaunty/irssi-plugin-xmpp/jaunty

« back to all changes in this revision

Viewing changes to src/core/xmpp-tools.c

  • Committer: Bazaar Package Importer
  • Author(s): David Ammouial
  • Date: 2008-06-23 16:03:33 UTC
  • mfrom: (1.1.2 upstream) (2.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080623160333-3wwbzgtzwznjjvrf
Tags: 0.13+cvs20080610-1
* New CVS snapshot:
  - New features and bugfixes.
  - Fix ignoring of messages without a type attribute (Closes: #477989).
* Depend on irssi >=0.8.12 (Closes: #469923).
* Add FAQ and MUC to documentation files (Closes: #485595).
* debian/rules: install help files in irssi help directory.
* debian/rules: Remove useless "make -n" command in build-stamp rule.
* Bump Standards-Version to 3.8.0 (no changes needed). 
* debian/control: Add "Enhances: irssi".

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * $Id: xmpp-tools.c,v 1.5 2007/11/26 12:55:07 errtu Exp $
 
2
 * $Id: xmpp-tools.c,v 1.8 2008/04/15 18:39:55 errtu Exp $
3
3
 *
4
4
 * Copyright (C) 2007 Colin DIDIER
5
5
 *
6
6
 * This program is free software; you can redistribute it and/or modify
7
 
 * it under the terms of the GNU General Public License as published by
8
 
 * the Free Software Foundation; either version 2 of the License, or
9
 
 * (at your option) any later version.
 
7
 * it under the terms of the GNU General Public License version 2 as
 
8
 * published by the Free Software Foundation.
10
9
 *
11
10
 * This program is distributed in the hope that it will be useful,
12
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
81
80
}
82
81
 
83
82
char *
 
83
xmpp_find_resource_sep(const char *jid) {
 
84
        return jid == NULL ? NULL : g_utf8_strchr(jid, -1, '/');
 
85
}
 
86
 
 
87
char *
84
88
xmpp_extract_resource(const char *jid)
85
89
{
86
90
        char *pos;
87
91
 
88
92
        g_return_val_if_fail(jid != NULL, NULL);
89
93
 
90
 
        pos = g_utf8_strchr(jid, -1, '/');
 
94
        pos = xmpp_find_resource_sep(jid);
91
95
        return (pos != NULL) ? g_strdup(pos + 1) : NULL;
92
96
}
93
97
 
98
102
 
99
103
        g_return_val_if_fail(jid != NULL, NULL);
100
104
 
101
 
        pos = g_utf8_strchr(jid, -1, '/');
 
105
        pos = xmpp_find_resource_sep(jid);
102
106
        return (pos != NULL) ? g_strndup(jid, pos - jid) : g_strdup(jid);
103
107
}
104
108
 
120
124
        char *pos1, *pos2;
121
125
 
122
126
        pos1 = g_utf8_strchr(jid, -1, '@');
123
 
        pos2 = g_utf8_strchr(jid, -1, '/');
 
127
        pos2 = xmpp_find_resource_sep(jid);
124
128
 
125
129
        if (pos1 == NULL)
126
130
                return NULL;
150
154
 
151
155
        g_return_val_if_fail(jid != NULL, FALSE);
152
156
 
153
 
        pos = g_utf8_strchr(jid, -1, '/');
 
157
        pos = xmpp_find_resource_sep(jid);
154
158
        return (pos != NULL && *(pos+1) != '\0');
155
159
}
156
160