|
| |||||||||||||
#include "libjabber.h"Go to the source code of this file.
Functions | |
| jid | jid_safe (jid id) |
| jid | jid_new (xode_pool p, char *idstr) |
| void | jid_set (jid id, char *str, int item) |
| char * | jid_full (jid id) |
| xode | jid_xres (jid id) |
| int | _jid_nullstrcmp (char *a, char *b) |
| int | _jid_nullstrcasecmp (char *a, char *b) |
| int | jid_cmp (jid a, jid b) |
| int | jid_cmpx (jid a, jid b, int parts) |
| jid | jid_append (jid a, jid b) |
| xode | jid_nodescan (jid id, xode x) |
| jid | jid_user (jid a) |
|
||||||||||||
|
Definition at line 247 of file jid.c. References NULL. Referenced by jid_cmp(), and jid_cmpx(). 00248 {
00249 if (a == NULL && b == NULL)
00250 return 0;
00251 if (a == NULL || b == NULL)
00252 return -1;
00253 return strcasecmp(a, b);
00254 }
|
|
||||||||||||
|
Definition at line 238 of file jid.c. References NULL. Referenced by jid_cmp(), and jid_cmpx(). 00239 {
00240 if (a == NULL && b == NULL)
00241 return 0;
00242 if (a == NULL || b == NULL)
00243 return -1;
00244 return strcmp(a, b);
00245 }
|
|
||||||||||||
|
Definition at line 291 of file jid.c. References jid, jid_cmp(), jid_full(), jid_new(), jid_struct::next, and jid_struct::p. 00292 {
00293 jid next;
00294
00295 if (a == NULL)
00296 return NULL;
00297
00298 if (b == NULL)
00299 return a;
00300
00301 next = a;
00302 while (next != NULL) {
00303 /* check for dups */
00304 if (jid_cmp(next, b) == 0)
00305 break;
00306 if (next->next == NULL)
00307 next->next = jid_new(a->p, jid_full(b));
00308 next = next->next;
00309 }
00310 return a;
00311 }
|
|
||||||||||||
|
Definition at line 257 of file jid.c. References _jid_nullstrcasecmp(), _jid_nullstrcmp(), jid, NULL, jid_struct::resource, jid_struct::server, and jid_struct::user. Referenced by jid_append(), and jid_nodescan(). 00258 {
00259 if (a == NULL || b == NULL)
00260 return -1;
00261
00262 if (_jid_nullstrcmp(a->resource, b->resource) != 0)
00263 return -1;
00264 if (_jid_nullstrcasecmp(a->user, b->user) != 0)
00265 return -1;
00266 if (_jid_nullstrcmp(a->server, b->server) != 0)
00267 return -1;
00268
00269 return 0;
00270 }
|
|
||||||||||||||||
|
Definition at line 274 of file jid.c. References _jid_nullstrcasecmp(), _jid_nullstrcmp(), jid, JID_RESOURCE, JID_SERVER, JID_USER, NULL, jid_struct::resource, jid_struct::server, and jid_struct::user. 00275 {
00276 if (a == NULL || b == NULL)
00277 return -1;
00278
00279 if (parts & JID_RESOURCE && _jid_nullstrcmp(a->resource, b->resource) != 0)
00280 return -1;
00281 if (parts & JID_USER && _jid_nullstrcasecmp(a->user, b->user) != 0)
00282 return -1;
00283 if (parts & JID_SERVER && _jid_nullstrcmp(a->server, b->server) != 0)
00284 return -1;
00285
00286 return 0;
00287 }
|
|
|
Definition at line 164 of file jid.c. References jid_struct::full, jid, jid_struct::p, jid_struct::resource, jid_struct::server, jid_struct::user, xode_spool, xode_spool_add(), xode_spool_newfrompool(), xode_spool_tostr(), and xode_spooler(). Referenced by jid_append(). 00165 {
00166 xode_spool s;
00167
00168 if (id == NULL)
00169 return NULL;
00170
00171 /* use cached copy */
00172 if (id->full != NULL)
00173 return id->full;
00174
00175 s = xode_spool_newfrompool(id->p);
00176
00177 if (id->user != NULL)
00178 xode_spooler(s, id->user, "@", s);
00179
00180 xode_spool_add(s, id->server);
00181
00182 if (id->resource != NULL)
00183 xode_spooler(s, "/", id->resource, s);
00184
00185 id->full = xode_spool_tostr(s);
00186 return id->full;
00187 }
|
|
||||||||||||
|
Definition at line 75 of file jid.c. References jid, jid_safe(), NULL, jid_struct::p, xode_pool, xode_pool_malloco(), and xode_pool_strdup(). Referenced by jab_new(), jabpacket_reset(), jid_append(), and jid_nodescan(). 00076 {
00077 char *server, *resource, *type, *str;
00078 jid id;
00079
00080 if (p == NULL || idstr == NULL || strlen(idstr) == 0)
00081 return NULL;
00082
00083 /* user@server/resource */
00084
00085 str = xode_pool_strdup(p, idstr);
00086
00087 id = xode_pool_malloco(p, sizeof(struct jid_struct));
00088 id->p = p;
00089 id->full = xode_pool_strdup(p, idstr);
00090
00091 resource = strstr(str, "/");
00092 if (resource != NULL) {
00093 *resource = '\0';
00094 ++resource;
00095 if (strlen(resource) > 0)
00096 id->resource = resource;
00097 }
00098 else {
00099 resource = str + strlen(str); /* point to end */
00100 }
00101
00102 type = strstr(str, ":");
00103 if (type != NULL && type < resource) {
00104 *type = '\0';
00105 ++type;
00106 str = type; /* ignore the type: prefix */
00107 }
00108
00109 server = strstr(str, "@");
00110 if (server == NULL || server > resource) { /* if there's no @, it's
00111 * just the server
00112 * address */
00113 id->server = str;
00114 }
00115 else {
00116 *server = '\0';
00117 ++server;
00118 id->server = server;
00119 if (strlen(str) > 0)
00120 id->user = str;
00121 }
00122
00123 return jid_safe(id);
00124 }
|
|
||||||||||||
|
Definition at line 314 of file jid.c. References jid, jid_cmp(), jid_new(), NULL, xode, xode_get_attrib(), xode_get_firstchild(), xode_get_nextsibling(), xode_get_type(), xode_pool, xode_pool_free(), and xode_pool_new(). 00315 {
00316 xode cur;
00317 xode_pool p;
00318 jid tmp;
00319
00320 if (id == NULL || xode_get_firstchild(x) == NULL)
00321 return NULL;
00322
00323 p = xode_pool_new();
00324 for (cur = xode_get_firstchild(x); cur != NULL; cur = xode_get_nextsibling(cur)) {
00325 if (xode_get_type(cur) != XODE_TYPE_TAG)
00326 continue;
00327
00328 tmp = jid_new(p, xode_get_attrib(cur, "jid"));
00329 if (tmp == NULL)
00330 continue;
00331
00332 if (jid_cmp(tmp, id) == 0)
00333 break;
00334 }
00335 xode_pool_free(p);
00336
00337 return cur;
00338 }
|
|
|
Definition at line 47 of file jid.c. References jid, NULL, jid_struct::server, and jid_struct::user. Referenced by jid_new(), and jid_set(). 00048 {
00049 unsigned char *str;
00050
00051 if (strlen(id->server) == 0 || strlen(id->server) > 255)
00052 return NULL;
00053
00054 /* lowercase the hostname, make sure it's valid characters */
00055 for (str = id->server; *str != '\0'; str++) {
00056 *str = tolower(*str);
00057 if (!(isalnum(*str) || *str == '.' || *str == '-' || *str == '_'))
00058 return NULL;
00059 }
00060
00061 /* cut off the user */
00062 if (id->user != NULL && strlen(id->user) > 64)
00063 id->user[64] = '\0';
00064
00065 /* check for low and invalid ascii characters in the username */
00066 if (id->user != NULL)
00067 for (str = id->user; *str != '\0'; str++)
00068 if (*str <= 32 || *str == ':' || *str == '@' || *str == '<' || *str == '>' || *str == '\'' || *str == '"' || *str == '&')
00069 return NULL;
00070
00071 return id;
00072 }
|
|
||||||||||||||||
|
Definition at line 127 of file jid.c. References jid_struct::full, jid, JID_RESOURCE, jid_safe(), JID_SERVER, JID_USER, NULL, jid_struct::p, jid_struct::resource, jid_struct::server, jid_struct::user, and xode_pool_strdup(). 00128 {
00129 char *old;
00130
00131 if (id == NULL)
00132 return;
00133
00134 /* invalidate the cached copy */
00135 id->full = NULL;
00136
00137 switch (item) {
00138 case JID_RESOURCE:
00139 if (str != NULL && strlen(str) != 0)
00140 id->resource = xode_pool_strdup(id->p, str);
00141 else
00142 id->resource = NULL;
00143 break;
00144 case JID_USER:
00145 old = id->user;
00146 if (str != NULL && strlen(str) != 0)
00147 id->user = xode_pool_strdup(id->p, str);
00148 else
00149 id->user = NULL;
00150 if (jid_safe(id) == NULL)
00151 id->user = old; /* revert if invalid */
00152 break;
00153 case JID_SERVER:
00154 old = id->server;
00155 id->server = xode_pool_strdup(id->p, str);
00156 if (jid_safe(id) == NULL)
00157 id->server = old; /* revert if invalid */
00158 break;
00159 }
00160
00161 }
|
|
|
Definition at line 341 of file jid.c. References jid, NULL, jid_struct::p, jid_struct::resource, jid_struct::server, jid_struct::user, and xode_pool_malloco(). 00342 {
00343 jid ret;
00344
00345 if (a == NULL || a->resource == NULL)
00346 return a;
00347
00348 ret = xode_pool_malloco(a->p, sizeof(struct jid_struct));
00349 ret->p = a->p;
00350 ret->user = a->user;
00351 ret->server = a->server;
00352
00353 return ret;
00354 }
|
|
|
Definition at line 194 of file jid.c. References jid, NULL, jid_struct::p, jid_struct::resource, xode, xode_new_frompool(), xode_pool_strdup(), and xode_put_attrib(). 00195 {
00196 char *cur, *qmark, *amp, *eq;
00197 xode x;
00198
00199 if (id == NULL || id->resource == NULL)
00200 return NULL;
00201
00202 cur = xode_pool_strdup(id->p, id->resource);
00203 qmark = strstr(cur, "?");
00204 if (qmark == NULL)
00205 return NULL;
00206 *qmark = '\0';
00207 qmark++;
00208
00209 x = xode_new_frompool(id->p, cur);
00210
00211 cur = qmark;
00212 while (cur != '\0') {
00213 eq = strstr(cur, "=");
00214 if (eq == NULL)
00215 break;
00216 *eq = '\0';
00217 eq++;
00218
00219 amp = strstr(eq, "&");
00220 if (amp != NULL) {
00221 *amp = '\0';
00222 amp++;
00223 }
00224
00225 xode_put_attrib(x, cur, eq);
00226
00227 if (amp != NULL)
00228 cur = amp;
00229 else
00230 break;
00231 }
00232
00233 return x;
00234 }
|
| Last updated at Tue Dec 18 21:07:42 PST 2007. | This site and project hosted by... |