jabberd2  2.3.1
jid.h
Go to the documentation of this file.
1 /*
2  * jabberd - Jabber Open Source Server
3  * Copyright (c) 2002-2004 Jeremie Miller, Thomas Muldowney,
4  * Ryan Eatmon, Robert Norris
5  *
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.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA02111-1307USA
19  */
20 
35 #ifndef INCL_UTIL_JID_H
36 #define INCL_UTIL_JID_H 1
37 
39 #define MAXLEN_JID_COMP 1023 /* XMPP (RFC3920) 3.1 */
40 #define MAXLEN_JID 3071 /* nodename (1023) + '@' + domain (1023) + '/' + resource (1023) = 3071 */
41 
42 typedef struct jid_st {
43  /* basic components of the jid */
44  char *node;
45  char *domain;
46  char *resource;
47 
48  /* Points to jid broken with \0s into componets. node/domain/resource point
49  * into this string (or to statically allocated empty string, if they are
50  * empty) */
51  char *jid_data;
52  /* Valid only when jid_data != NULL. When = 0, jid_data is statically
53  * allocated. Otherwise it tells length of the allocated data. Used to
54  * implement jid_dup() */
55  size_t jid_data_len;
56 
57  /* the "user" part of the jid (sans resource) */
58  char *_user;
59 
60  /* the complete jid */
61  char *_full;
62 
63  /* application should set to 1 if user/full need regenerating */
64  int dirty;
65 
66  /* for lists of jids */
67  struct jid_st *next;
68 } *jid_t;
69 
70 typedef enum {
71  jid_NODE = 1,
74 } jid_part_t;
75 
77 typedef char jid_static_buf[3*1025];
78 
80 JABBERD2_API jid_t jid_new(const char *id, int len);
81 
85 
87 JABBERD2_API jid_t jid_reset(jid_t jid, const char *id, int len);
88 JABBERD2_API jid_t jid_reset_components(jid_t jid, const char *node, const char *domain, const char *resource);
89 
91 JABBERD2_API void jid_free(jid_t jid);
92 
94 JABBERD2_API int jid_prep(jid_t jid);
95 
98 
100 JABBERD2_API void jid_expand(jid_t jid);
101 
104 JABBERD2_API const char *jid_user(jid_t jid);
105 JABBERD2_API const char *jid_full(jid_t jid);
106 
111 
114 
118 JABBERD2_API int jid_search(jid_t list, jid_t jid);
119 
122 
125 
126 #endif
struct jid_st * jid_t
char * _user
Definition: jid.h:58
jid_t jid_reset(jid_t jid, const char *id, int len)
build a jid from an id
Definition: jid.c:113
const char * jid_user(jid_t jid)
expand and return the user
Definition: jid.c:339
const char * jid_full(jid_t jid)
expand and return the full
Definition: jid.c:347
jid_t jid_new(const char *id, int len)
make a new jid
Definition: jid.c:81
void jid_static(jid_t jid, jid_static_buf *buf)
Make jid to use static buffer (jid data won't be allocated dynamically, but given buffer will be alwa...
Definition: jid.c:102
int dirty
Definition: jid.h:64
#define JABBERD2_API
Definition: mio.h:39
jid_t jid_zap(jid_t list, jid_t jid)
remove a jid_t from a list, returning the new list
Definition: jid.c:423
char * resource
Definition: jid.h:46
jid_part_t
Definition: jid.h:70
void jid_random_part(jid_t jid, jid_part_t part)
create random resource
Definition: jid.c:492
void jid_expand(jid_t jid)
build user and full if they're out of date
Definition: jid.c:299
int jid_prep(jid_t jid)
do stringprep on the piece
Definition: jid.c:44
char * _full
Definition: jid.h:61
jid_t jid_reset_components(jid_t jid, const char *node, const char *domain, const char *resource)
build a jid from components
Definition: jid.c:281
char jid_static_buf[3 *1025]
JID static buffer.
Definition: jid.h:77
Definition: jid.h:71
int jid_search(jid_t list, jid_t jid)
util to search through jids
Definition: jid.c:413
void jid_free(jid_t jid)
free a jid
Definition: jid.c:286
char * domain
Definition: jid.h:45
Definition: jid.h:42
int jid_compare_full(jid_t a, jid_t b)
compare two full jids
Definition: jid.c:364
jid_t jid_append(jid_t list, jid_t jid)
make a copy of jid, link into list (avoiding dups)
Definition: jid.c:464
int jid_compare_user(jid_t a, jid_t b)
compare the user portion of two jids
Definition: jid.c:355
char * jid_data
Definition: jid.h:51
jid_t jid_dup(jid_t jid)
duplicate a jid
Definition: jid.c:373
struct jid_st * next
Definition: jid.h:67
size_t jid_data_len
Definition: jid.h:55
Definition: jid.h:72
char * node
Definition: jid.h:44