jabberd2
2.2.16
|
00001 /* 00002 * jabberd - Jabber Open Source Server 00003 * Copyright (c) 2002-2004 Jeremie Miller, Thomas Muldowney, 00004 * Ryan Eatmon, Robert Norris 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA02111-1307USA 00019 */ 00020 00035 #ifndef INCL_UTIL_JID_H 00036 #define INCL_UTIL_JID_H 1 00037 00039 #define MAXLEN_JID_COMP 1023 /* XMPP (RFC3920) 3.1 */ 00040 #define MAXLEN_JID 3071 /* nodename (1023) + '@' + domain (1023) + '/' + resource (1023) = 3071 */ 00041 00042 typedef struct jid_st { 00043 /* basic components of the jid */ 00044 unsigned char *node; 00045 unsigned char *domain; 00046 unsigned char *resource; 00047 00048 /* Points to jid broken with \0s into componets. node/domain/resource point 00049 * into this string (or to statically allocated empty string, if they are 00050 * empty) */ 00051 unsigned char *jid_data; 00052 /* Valid only when jid_data != NULL. When = 0, jid_data is statically 00053 * allocated. Otherwise it tells length of the allocated data. Used to 00054 * implement jid_dup() */ 00055 size_t jid_data_len; 00056 00057 /* the "user" part of the jid (sans resource) */ 00058 unsigned char *_user; 00059 00060 /* the complete jid */ 00061 unsigned char *_full; 00062 00063 /* application should set to 1 if user/full need regenerating */ 00064 int dirty; 00065 00066 /* for lists of jids */ 00067 struct jid_st *next; 00068 } *jid_t; 00069 00070 typedef enum { 00071 jid_NODE = 1, 00072 jid_DOMAIN = 2, 00073 jid_RESOURCE = 3 00074 } jid_part_t; 00075 00077 typedef char jid_static_buf[3*1025]; 00078 00080 JABBERD2_API jid_t jid_new(const unsigned char *id, int len); 00081 00084 JABBERD2_API void jid_static(jid_t jid, jid_static_buf *buf); 00085 00087 JABBERD2_API jid_t jid_reset(jid_t jid, const unsigned char *id, int len); 00088 JABBERD2_API jid_t jid_reset_components(jid_t jid, const unsigned char *node, const unsigned char *domain, const unsigned char *resource); 00089 00091 JABBERD2_API void jid_free(jid_t jid); 00092 00094 JABBERD2_API int jid_prep(jid_t jid); 00095 00097 JABBERD2_API void jid_random_part(jid_t jid, jid_part_t part); 00098 00100 JABBERD2_API void jid_expand(jid_t jid); 00101 00104 JABBERD2_API const unsigned char *jid_user(jid_t jid); 00105 JABBERD2_API const unsigned char *jid_full(jid_t jid); 00106 00109 JABBERD2_API int jid_compare_user(jid_t a, jid_t b); 00110 JABBERD2_API int jid_compare_full(jid_t a, jid_t b); 00111 00113 JABBERD2_API jid_t jid_dup(jid_t jid); 00114 00118 JABBERD2_API int jid_search(jid_t list, jid_t jid); 00119 00121 JABBERD2_API jid_t jid_zap(jid_t list, jid_t jid); 00122 00124 JABBERD2_API jid_t jid_append(jid_t list, jid_t jid); 00125 00126 #endif