jabberd2  2.2.17
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  unsigned char *node;
45  unsigned char *domain;
46  unsigned 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  unsigned 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  unsigned char *_user;
59 
60  /* the complete jid */
61  unsigned 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 unsigned char *id, int len);
81 
85 
87 JABBERD2_API jid_t jid_reset(jid_t jid, const unsigned char *id, int len);
88 JABBERD2_API jid_t jid_reset_components(jid_t jid, const unsigned char *node, const unsigned char *domain, const unsigned 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 unsigned char *jid_user(jid_t jid);
105 JABBERD2_API const unsigned 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