jabberdlib.h

Go to the documentation of this file.
00001 /*
00002  * Copyrights
00003  * 
00004  * Portions created by or assigned to Jabber.com, Inc. are 
00005  * Copyright (c) 1999-2002 Jabber.com, Inc.  All Rights Reserved.  Contact
00006  * information for Jabber.com, Inc. is available at http://www.jabber.com/.
00007  *
00008  * Portions Copyright (c) 1998-1999 Jeremie Miller.
00009  *
00010  * Portions Copyright (c) 2006-2007 Matthias Wimmer
00011  *
00012  * This file is part of jabberd14.
00013  *
00014  * This software is free software; you can redistribute it and/or
00015  * modify it under the terms of the GNU General Public License as
00016  * published by the Free Software Foundation; either version 2 of the
00017  * License, or (at your option) any later version.
00018  *
00019  * This software is distributed in the hope that it will be useful, but
00020  * WITHOUT ANY WARRANTY; without even the implied warranty of
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00022  * General Public License for more details.
00023  *
00024  * You should have received a copy of the GNU General Public License
00025  * along with this software; if not, write to the Free Software
00026  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00027  * 02110-1301, USA.
00028  *
00029  */
00030 
00052 #ifdef HAVE_CONFIG_H
00053 #   include <config.h>
00054 #endif
00055 
00056 #ifndef N_
00057 #   define N_(n) (n)
00058 #endif
00059 
00060 #include <cstring>
00061 #include <cstdlib>
00062 #include <sys/types.h>
00063 #include <stdio.h>
00064 #include <setjmp.h>
00065 #include <sys/stat.h>
00066 #include <fcntl.h>
00067 #include <errno.h>
00068 #include <signal.h>
00069 #include <syslog.h>
00070 #include <strings.h>
00071 #include <unistd.h>
00072 #include <sys/param.h>
00073 #include <sys/socket.h>
00074 #include <netinet/in.h>
00075 #include <netdb.h>
00076 #include <arpa/inet.h>
00077 #include <arpa/nameser.h>
00078 #include <sys/time.h>
00079 #include <stdarg.h>
00080 #include <ctype.h>
00081 #include <ctime>
00082 #include <pth.h>
00083 
00084 #include <expat.h>
00085 
00086 #include <utility>
00087 #include <list>
00088 
00089 #ifdef HAS_TR1_UNORDERED_MAP
00090 #   include <tr1/unordered_map>
00091 #else
00092 #   include <map>
00093 #endif
00094 
00095 #include <glibmm.h>
00096 
00097 /*
00098 **  Arrange to use either varargs or stdargs
00099 */
00100 
00101 #define MAXSHORTSTR     203             /* max short string length */
00102 #define QUAD_T  unsigned long long
00103 
00104 #ifdef __STDC__
00105 
00106 #include <stdarg.h>
00107 
00108 # define VA_LOCAL_DECL  va_list ap;
00109 # define VA_START(f)    va_start(ap, f)
00110 # define VA_END         va_end(ap)
00111 
00112 #else /* __STDC__ */
00113 
00114 # include <varargs.h>
00115 
00116 # define VA_LOCAL_DECL  va_list ap;
00117 # define VA_START(f)    va_start(ap)
00118 # define VA_END         va_end(ap)
00119 
00120 #endif /* __STDC__ */
00121 
00122 
00123 #ifndef INCL_LIB_H
00124 #define INCL_LIB_H
00125 
00126 #include <string>
00127 #include <vector>
00128 #include <sstream>
00129 #include <stdexcept>
00130 #include <set>
00131 
00132 namespace xmppd {
00133 
00134     /* ******************** Managed pointers ******************** */
00135 
00143     template<class pointed_type> class pointer {
00144         public:
00148             pointer();
00149 
00161             pointer(pointed_type* pointed_object, bool malloc_allocated = false);
00162 
00170             pointer(const pointer<pointed_type>& src);
00171 
00178             ~pointer();
00179 
00186             void delete_object();
00187 
00196             pointer<pointed_type>& operator=(const pointer<pointed_type>& src);
00197 
00206             pointed_type& operator*();
00207 
00217             pointed_type* operator->() const;
00218 
00224             bool points_to_NULL() const;
00225         private:
00229             void point_nothing();
00230 
00234             pointed_type* pointed_object;
00235 
00239             std::set<pointer<pointed_type>*>* all_pointers_to_this_object;
00240 
00246             bool malloc_allocated;
00247     };
00248 
00249     /* ******************** Hashing algorithms ****************** */
00250 
00254     class hash {
00255         public:
00256             virtual void update(const std::string& data) =0;
00257             virtual std::vector<uint8_t> final() =0;
00258             std::string final_hex();
00259     };
00260 
00264     class sha1 : public hash {
00265         public:
00269             sha1();
00270 
00276             void update(const std::string& data);
00277 
00283             void update(const std::vector<uint8_t> data);
00284 
00292             std::vector<uint8_t> final();
00293         private:
00297             bool padded;
00298 
00302             std::vector<uint8_t> current_block;
00303 
00307             std::vector<uint32_t> W;
00308 
00314             unsigned W_pos;
00315 
00319             std::vector<uint32_t> H;
00320 
00324             void hash_block();
00325 
00329             inline static uint32_t circular_shift(uint32_t X, int n);
00330 
00334             inline static uint32_t f_0_19(uint32_t B, uint32_t C, uint32_t D);
00335 
00339             inline static uint32_t f_20_39(uint32_t B, uint32_t C, uint32_t D);
00340 
00344             inline static uint32_t f_40_59(uint32_t B, uint32_t C, uint32_t D);
00345 
00349             inline static uint32_t f_60_79(uint32_t B, uint32_t C, uint32_t D);
00350 
00354             uint64_t l;
00355     };
00356 }
00357 
00358 #define ZONE zonestr(__FILE__,__LINE__)
00359 char *zonestr(char const* file, int line);
00360 
00361 /* --------------------------------------------------------- */
00362 /*                                                           */
00363 /* Pool-based memory management routines                     */
00364 /*                                                           */
00365 /* --------------------------------------------------------- */
00366 
00367 #ifdef POOL_DEBUG
00368 # define POOL_NUM 40009
00369 #endif
00370 
00371 /* pheap - singular allocation of memory */
00372 struct pheap
00373 {
00374     void *block;
00375     int size, used;
00376 };
00377 
00378 /* pool_cleaner - callback type which is associated
00379    with a pool entry; invoked when the pool entry is 
00380    free'd */
00381 typedef void (*pool_cleaner)(void *arg);
00382 
00383 /* pfree - a linked list node which stores an
00384    allocation chunk, plus a callback */
00385 struct pfree
00386 {
00387     pool_cleaner f;
00388     void *arg;
00389     struct pheap *heap;
00390     struct pfree *next;
00391 };
00392 
00393 /* pool - base node for a pool. Maintains a linked list
00394    of pool entries (pfree) */
00395 typedef struct pool_struct
00396 {
00397     int size;
00398     struct pfree *cleanup;
00399     struct pheap *heap;
00400 #ifdef POOL_DEBUG
00401     char name[8], zone[32];
00402     int lsize;
00403 } _pool, *pool;
00404 #define pool_new() _pool_new(__FILE__,__LINE__)
00405 #define pool_heap(i) _pool_new_heap(i,__FILE__,__LINE__)
00406 #else
00407 } _pool, *pool;
00408 #define pool_heap(i) _pool_new_heap(i, NULL, 0) 
00409 #define pool_new() _pool_new(NULL, 0) 
00410 #endif
00411 
00412 pool _pool_new(char *zone, int line); /* new pool :) */
00413 pool _pool_new_heap(int size, char *zone, int line); /* creates a new memory pool with an initial heap size */
00414 void *pmalloc(pool p, int size); /* wrapper around malloc, takes from the pool, cleaned up automatically */
00415 void *pmalloc_x(pool p, int size, char c); /* Wrapper around pmalloc which prefils buffer with c */
00416 void *pmalloco(pool p, int size); /* YAPW for zeroing the block */
00417 char *pstrdup(pool p, const char *src); /* wrapper around strdup, gains mem from pool */
00418 void pool_stat(int full); /* print to stderr the changed pools and reset */
00419 char *pstrdupx(pool p, const char *src); /* temp stub */
00420 void pool_cleanup(pool p, pool_cleaner f, void *arg); /* calls f(arg) before the pool is freed during cleanup */
00421 void pool_free(pool p); /* calls the cleanup functions, frees all the data on the pool, and deletes the pool itself */
00422 int pool_size(pool p); /* returns total bytes allocated in this pool */
00423 
00424 
00425 
00426 
00427 /* --------------------------------------------------------- */
00428 /*                                                           */
00429 /* Socket helper stuff                                       */
00430 /*                                                           */
00431 /* --------------------------------------------------------- */
00432 #ifndef MAXHOSTNAMELEN
00433 #define MAXHOSTNAMELEN 64
00434 #endif
00435 
00436 #define NETSOCKET_SERVER 0 
00437 #define NETSOCKET_CLIENT 1 
00438 #define NETSOCKET_UDP 2    
00440 #ifndef WIN32
00441 int make_netsocket(u_short port, char const* host, int type);
00442 int make_netsocket2(Glib::ustring servname, Glib::ustring nodename, int type);
00443 struct in_addr *make_addr(char const* host);
00444 #ifdef WITH_IPV6
00445 struct in6_addr *make_addr_ipv6(char const* host);
00446 #endif
00447 #endif
00448 
00449 
00450 /* --------------------------------------------------------- */
00451 /*                                                           */
00452 /* String management routines                                */
00453 /*                                                           */
00454 /* --------------------------------------------------------- */
00455 char *j_strdup(const char *str); /* provides NULL safe strdup wrapper */
00456 char *j_strcat(char *dest, char *txt); /* strcpy() clone */
00457 int j_strcmp(const char *a, const char *b); /* provides NULL safe strcmp wrapper */
00458 int j_strcasecmp(const char *a, const char *b); /* provides NULL safe strcasecmp wrapper */
00459 int j_strncmp(const char *a, const char *b, int i); /* provides NULL safe strncmp wrapper */
00460 int j_strncasecmp(const char *a, const char *b, int i); /* provides NULL safe strncasecmp wrapper */
00461 int j_strlen(const char *a); /* provides NULL safe strlen wrapper */
00462 int j_atoi(const char *a, int def); /* checks for NULL and uses default instead, convienence */
00463 void str_b64decode(char *str); /* what it says */
00464 
00465 namespace xmppd {
00466     class to_lower {
00467         public:
00468             to_lower(std::locale const& l) : loc(l) {}
00469             char operator() (char c) const { return std::tolower(c, loc); }
00470         private:
00471             std::locale const& loc;
00472     };
00473 }
00474 
00475 /* --------------------------------------------------------- */
00476 /*                                                           */
00477 /* Base64 routines                                           */
00478 /*                                                           */
00479 /* --------------------------------------------------------- */
00480 int base64_encode(unsigned char *source, size_t sourcelen, char *target, size_t targetlen);
00481 size_t base64_decode(const char *source, unsigned char *target, size_t targetlen);
00482 
00483 
00484 /* --------------------------------------------------------- */
00485 /*                                                           */
00486 /* SHA calculations                                          */
00487 /*                                                           */
00488 /* --------------------------------------------------------- */
00489 #if (SIZEOF_INT == 4)
00490 typedef unsigned int uint32;
00491 #elif (SIZEOF_SHORT == 4)
00492 typedef unsigned short uint32;
00493 #else
00494 typedef unsigned int uint32;
00495 #endif /* HAVEUINT32 */
00496 
00497 char *shahash(char const* str); /* NOT THREAD SAFE */
00498 void shahash_r(const char* str, char hashbuf[41]); /* USE ME */
00499 void shaBlock(unsigned char *dataIn, int len, unsigned char hashout[20]);
00500 
00501 /* --------------------------------------------------------- */
00502 /*                                                           */
00503 /* SHA calculations                                          */
00504 /*                                                           */
00505 /* --------------------------------------------------------- */
00506 
00507 void crc32_r(const char *str, char crc32buf[9]);
00508 
00509 /* --------------------------------------------------------- */
00510 /*                                                           */
00511 /* Hashtable functions                                       */
00512 /*                                                           */
00513 /* --------------------------------------------------------- */
00514 namespace xmppd {
00515 
00527     template <class value_type> class xhash :
00528 #ifdef HAS_TR1_UNORDERED_MAP
00529         public std::tr1::unordered_map<std::string, value_type>
00530 #else
00531         public std::map<std::string, value_type>
00532 #endif
00533     {
00534         public:
00545             typename xhash<value_type>::iterator get_by_domain(std::string domainkey);
00546     };
00547 }
00548 
00549 typedef xmppd::xhash<void*>* xht;
00550 
00551 xht xhash_new(int prime);
00552 void xhash_put(xht h, const char *key, void *val);
00553 void *xhash_get(xht h, const char *key);
00554 void *xhash_get_by_domain(xht h, const char *domain);
00555 void xhash_zap(xht h, const char *key);
00556 void xhash_free(xht h);
00557 typedef void (*xhash_walker)(xht h, const char *key, void *val, void *arg);
00558 void xhash_walk(xht h, xhash_walker w, void *arg);
00559 
00560 /* --------------------------------------------------------- */
00561 /*                                                           */
00562 /* XML escaping utils                                        */
00563 /*                                                           */
00564 /* --------------------------------------------------------- */
00565 char *strescape(pool p, char *buf); /* Escape <>&'" chars */
00566 char *strunescape(pool p, char *buf);
00567 std::string strescape(std::string s);
00568 
00569 
00570 /* --------------------------------------------------------- */
00571 /*                                                           */
00572 /* xmlnodes - Document Object Model                          */
00573 /*                                                           */
00574 /* --------------------------------------------------------- */
00575 #define NTYPE_TAG    0  
00576 #define NTYPE_ATTRIB 1  
00577 #define NTYPE_CDATA  2  
00579 #define NTYPE_LAST   2  
00580 #define NTYPE_UNDEF  -1 
00582 #define XMLNS_SEPARATOR ' '     
00584 /* -------------------------------------------------------------------------- 
00585    Node structure. Do not use directly! Always use accessor macros 
00586    and methods!
00587    -------------------------------------------------------------------------- */
00588 typedef struct xmlnode_t {
00589      char*              name;           
00590      char*              prefix;         
00591      char*              ns_iri;         
00592      unsigned short     type;           
00593      char*              data;           
00594      int                data_sz;        
00595 /*     int                 complete; */
00596      pool               p;              
00597      struct xmlnode_t*  parent;         
00598      struct xmlnode_t*  firstchild;     
00599      struct xmlnode_t*  lastchild;      
00600      struct xmlnode_t*  prev;           
00601      struct xmlnode_t*  next;           
00602      struct xmlnode_t*  firstattrib;    
00603      struct xmlnode_t*  lastattrib;     
00604 } _xmlnode, *xmlnode;
00605 
00606 namespace xmppd {
00607 
00611     class ns_decl_list : private std::list<std::pair<std::string, std::string> > {
00612         public:
00613             ns_decl_list();
00614             ns_decl_list(const xmlnode node);
00615             void update(const std::string& prefix, const std::string& ns_iri);
00616             void delete_last(const std::string& prefix);
00617             char const* get_nsprefix(const std::string& iri) const;
00618             char const* get_nsprefix(const std::string& iri, bool accept_default_prefix) const;
00619             char const* get_nsiri(const std::string& prefix) const;
00620             bool check_prefix(const std::string& prefix, const std::string& ns_iri) const;
00621         private:
00622     };
00623 
00624 }
00625 
00634 typedef std::vector<xmlnode> xmlnode_vector;
00635 
00636 /* Node creation routines */
00637 xmlnode  xmlnode_wrap(xmlnode x,const char* wrapper);
00638 xmlnode  xmlnode_wrap_ns(xmlnode x,const char* name, const char *prefix, const char *ns_iri);
00639 xmlnode  xmlnode_new_tag(const char* name);
00640 xmlnode  xmlnode_new_tag_ns(const char* name, const char* prefix, const char *ns_iri);
00641 xmlnode  xmlnode_new_tag_pool(pool p, const char* name);
00642 xmlnode  xmlnode_new_tag_pool_ns(pool p, const char* name, const char* prefix, const char *ns_iri);
00643 xmlnode  xmlnode_insert_tag(xmlnode parent, const char* name); 
00644 xmlnode  xmlnode_insert_tag_ns(xmlnode parent, const char* name, const char *prefix, const char *ns_iri); 
00645 xmlnode  xmlnode_insert_cdata(xmlnode parent, const char* CDATA, unsigned int size);
00646 xmlnode  xmlnode_insert_tag_node(xmlnode parent, xmlnode node);
00647 void     xmlnode_insert_node(xmlnode parent, xmlnode node);
00648 xmlnode  xmlnode_str(const char *str, int len);
00649 xmlnode  xmlnode_file(const char *file);
00650 char const*    xmlnode_file_borked(char const *file); /* same as _file but returns the parsing error */
00651 xmlnode  xmlnode_dup(xmlnode x); /* duplicate x */
00652 xmlnode  xmlnode_dup_pool(pool p, xmlnode x);
00653 
00654 /* Node Memory Pool */
00655 pool xmlnode_pool(xmlnode node);
00656 
00657 /* Node editing */
00658 void xmlnode_hide(xmlnode child);
00659 void xmlnode_hide_attrib(xmlnode parent, const char *name);
00660 void xmlnode_hide_attrib_ns(xmlnode parent, const char *name, const char *ns_iri);
00661 
00662 /* Node deletion routine, also frees the node pool! */
00663 void xmlnode_free(xmlnode node);
00664 
00665 /* Locates a child tag by name and returns it */
00666 xmlnode  xmlnode_get_tag(xmlnode parent, const char* name);
00667 char* xmlnode_get_tag_data(xmlnode parent, const char* name);
00668 xmlnode_vector xmlnode_get_tags(xmlnode context_node, const char *path, xht namespaces);
00669 xmlnode xmlnode_get_list_item(const xmlnode_vector& first, unsigned int i);
00670 char* xmlnode_get_list_item_data(const xmlnode_vector& first, unsigned int i);
00671 xmlnode xmlnode_select_by_lang(const xmlnode_vector& nodes, const char* lang);
00672 
00673 /* Attribute accessors */
00674 void     xmlnode_put_attrib(xmlnode owner, const char* name, const char* value);
00675 void     xmlnode_put_attrib_ns(xmlnode owner, const char* name, const char* prefix, const char *ns_iri, const char* value);
00676 char*    xmlnode_get_attrib(xmlnode owner, const char* name);
00677 char*    xmlnode_get_attrib_ns(xmlnode owner, const char* name, const char *ns_iri);
00678 void     xmlnode_put_expat_attribs(xmlnode owner, const char** atts, xmppd::ns_decl_list& nslist);
00679 
00680 const char* xmlnode_get_lang(xmlnode node);
00681 
00682 /* Node traversal routines */
00683 xmlnode  xmlnode_get_firstattrib(xmlnode parent);
00684 xmlnode  xmlnode_get_firstchild(xmlnode parent);
00685 xmlnode  xmlnode_get_lastchild(xmlnode parent);
00686 xmlnode  xmlnode_get_nextsibling(xmlnode sibling);
00687 xmlnode  xmlnode_get_prevsibling(xmlnode sibling);
00688 xmlnode  xmlnode_get_parent(xmlnode node);
00689 
00690 /* Node information routines */
00691 char*    xmlnode_get_name(xmlnode node);
00692 char*    xmlnode_get_data(xmlnode node);
00693 int      xmlnode_get_type(xmlnode node);
00694 const char* xmlnode_get_localname(xmlnode node);
00695 const char* xmlnode_get_namespace(xmlnode node);
00696 const char* xmlnode_get_nsprefix(xmlnode node);
00697 void     xmlnode_change_namespace(xmlnode node, const char *ns_iri);
00698 
00699 int      xmlnode_has_children(xmlnode node);
00700 
00701 /* Node-to-string translation */
00702 char*    xmlnode_serialize_string(xmlnode_t const* node, const xmppd::ns_decl_list& nslist, int stream_type);
00703 
00704 int      xmlnode2file(char const* file, xmlnode node); /* writes node to file */
00705 int      xmlnode2file_limited(char const* file, xmlnode node, size_t sizelimit);
00706 
00707 /* Expat callbacks */
00708 void expat_startElement(void* userdata, const char* name, const char** atts);
00709 void expat_endElement(void* userdata, const char* name);
00710 void expat_charData(void* userdata, const char* s, int len);
00711 
00712 /* conversion between xhash to xml */
00713 xmlnode xhash_to_xml(xht h);
00714 xht xhash_from_xml(xmlnode hash, pool p);
00715 
00716 /***********************
00717  * XSTREAM Section
00718  ***********************/
00719 
00720 #define XSTREAM_MAXNODE 1000000
00721 #define XSTREAM_MAXDEPTH 100
00722 
00723 #define XSTREAM_ROOT        0 /* root element */
00724 #define XSTREAM_NODE        1 /* normal node */
00725 #define XSTREAM_CLOSE       2 /* closed </stream:stream> */
00726 #define XSTREAM_ERR         4 /* parser error */
00727 
00728 typedef void (*xstream_onNode)(int type, xmlnode x, void *arg); /* xstream event handler */
00729 
00730 typedef struct xstream_struct {
00731     XML_Parser parser;
00732     xmlnode node;
00733     char *cdata;
00734     int cdata_len;
00735     pool p;
00736     xstream_onNode f;
00737     void *arg;
00738     int status;
00739     int depth;
00740 
00741     const char *root_lang;              
00743     xmppd::ns_decl_list *ns_root;       
00744     xmppd::ns_decl_list *ns_stanza;     
00745 } *xstream, _xstream;
00746 
00747 xstream xstream_new(pool p, xstream_onNode f, void *arg); /* create a new xstream */
00748 int xstream_eat(xstream xs, char *buff, int len); /* parse new data for this xstream, returns last XSTREAM_* status */
00749 
00750 /* convience functions */
00751 xmlnode xstream_header(const char *to, const char *from);
00752 char *xstream_header_char(xmlnode x, int stream_type);
00753 
00755 typedef enum {
00756     unknown_error_type,         
00757     bad_format,                 
00758     bad_namespace_prefix,       
00759     conflict,                   
00760     connection_timeout,         
00761     host_gone,                  
00762     host_unknown,               
00763     improper_addressing,        
00764     internal_server_error,      
00765     invalid_from,               
00766     invalid_id,                 
00767     invalid_namespace,          
00768     invalid_xml,                
00769     not_authorized,             
00770     policy_violation,           
00771     remote_connection_failed,   
00772     resource_constraint,        
00773     restricted_xml,             
00774     see_other_host,             
00775     system_shutdown,            
00776     undefined_condition,        
00777     unsupported_encoding,       
00778     unsupported_stanza_type,    
00779     unsupported_version,        
00780     xml_not_well_formed         
00781 } streamerr_reason;
00782 
00784 typedef enum {
00785     normal,                     
00786     configuration,              
00787     feature_lack,               
00788     unknown,                    
00789     error                       
00790 } streamerr_severity;
00791 
00793 typedef struct streamerr_struct {
00794     char *text;                 
00795     char *lang;                 
00796     streamerr_reason reason;    
00797     streamerr_severity severity;
00798 } *streamerr, _streamerr;
00799 
00800 void xstream_format_error(std::ostream& out, streamerr errstruct);
00801 streamerr_severity xstream_parse_error(pool p, xmlnode errnode, streamerr errstruct);
00802 
00803 typedef struct {
00804   unsigned long H[5];
00805   unsigned long W[80];
00806   int lenW;
00807   unsigned long sizeHi,sizeLo;
00808 } j_SHA_CTX;
00809 
00810 
00811 void shaInit(j_SHA_CTX *ctx);
00812 void shaUpdate(j_SHA_CTX *ctx, unsigned char *dataIn, int len);
00813 void shaFinal(j_SHA_CTX *ctx, unsigned char hashout[20]);
00814 void shaBlock(unsigned char *dataIn, int len, unsigned char hashout[20]);
00815 
00816 
00817 /* message authentication code */
00818 void hmac_sha1_ascii_r(char const* secret, unsigned char const* message, size_t len, char hmac[41]);
00819 
00820 /********** END OLD libxode.h BEGIN OLD jabber.h *************/
00821 
00822 namespace xmppd {
00823 
00827     class jabberid {
00828         public:
00835             jabberid(const Glib::ustring& jid);
00836 
00843             void set_node(const Glib::ustring& node);
00844 
00851             void set_domain(const Glib::ustring& domain);
00852 
00859             void set_resource(const Glib::ustring& resource);
00860 
00866             const Glib::ustring& get_node() { return node; };
00867 
00873             bool has_node() { return node.length() > 0; };
00874 
00880             const Glib::ustring& get_domain() { return domain; };
00881 
00887             const Glib::ustring& get_resource() { return resource; };
00888 
00894             bool has_resource() { return resource.length() > 0; };
00895 
00902             bool operator==(const jabberid& otherjid);
00903 
00913             bool compare(const jabberid& otherjid, bool compare_resource = false, bool compare_node = true, bool compare_domain = true);
00914 
00920             jabberid get_user();
00921 
00927             Glib::ustring full();
00928         private:
00934             Glib::ustring node;
00935 
00941             Glib::ustring domain;
00942 
00948             Glib::ustring resource;
00949     };
00950 
00956     class jabberid_pool : public jabberid {
00957         public:
00965             jabberid_pool(const Glib::ustring& jid, ::pool p);
00966 
00972             char* full_pooled();
00973 
00980             void set_node(const Glib::ustring& node);
00981 
00988             void set_domain(const Glib::ustring& domain);
00989 
00996             void set_resource(const Glib::ustring& resource);
00997 
01003             pool get_pool() { return p; };
01004 
01008             jabberid_pool* next;
01009         private:
01015 	    ::pool p;
01016 
01022             char* jid_full;
01023     };
01024 }
01025 
01026 /* --------------------------------------------------------- */
01027 /*                                                           */
01028 /* JID structures & constants                                */
01029 /*                                                           */
01030 /* --------------------------------------------------------- */
01031 #define JID_RESOURCE 1
01032 #define JID_USER     2
01033 #define JID_SERVER   4
01034 
01035 typedef xmppd::jabberid_pool* jid;
01036 
01037 jid     jid_new(pool p, const char *idstr);            /* Creates a jabber id from the idstr */
01038 void    jid_set(jid id, const char *str, int item);  /* Individually sets jid components */
01039 char*   jid_full(jid id);                      /* Builds a string type=user/resource@server from the jid data */
01040 int     jid_cmp(jid a, jid b);                 /* Compares two jid's, returns 0 for perfect match */
01041 int     jid_cmpx(jid a, jid b, int parts);     /* Compares just the parts specified as JID_|JID_ */
01042 jid     jid_user(jid a);                       /* returns the same jid but just of the user@host part */
01043 jid     jid_user_pool(jid a, pool p);          /* returns the same jid, but just the user@host part */
01044 jid     jid_append(jid a, jid b);
01045 
01046 /* --------------------------------------------------------- */
01047 /*                                                           */
01048 /* JPacket structures & constants                            */
01049 /*                                                           */
01050 /* --------------------------------------------------------- */
01051 #define JPACKET_UNKNOWN   0x00
01052 #define JPACKET_MESSAGE   0x01
01053 #define JPACKET_PRESENCE  0x02
01054 #define JPACKET_IQ        0x04
01055 #define JPACKET_S10N      0x08
01056 
01057 #define JPACKET__UNKNOWN      0
01058 #define JPACKET__NONE         1
01059 #define JPACKET__ERROR        2
01060 #define JPACKET__CHAT         3
01061 #define JPACKET__GROUPCHAT    4
01062 #define JPACKET__GET          5
01063 #define JPACKET__SET          6
01064 #define JPACKET__RESULT       7
01065 #define JPACKET__SUBSCRIBE    8
01066 #define JPACKET__SUBSCRIBED   9
01067 #define JPACKET__UNSUBSCRIBE  10
01068 #define JPACKET__UNSUBSCRIBED 11
01069 #define JPACKET__AVAILABLE    12
01070 #define JPACKET__UNAVAILABLE  13
01071 #define JPACKET__PROBE        14
01072 #define JPACKET__HEADLINE     15
01073 #define JPACKET__INVISIBLE    16
01074 
01075 typedef struct jpacket_struct
01076 {
01077     unsigned char type;             
01078     int           subtype;          
01079     int           flag;             
01080     void*         aux1;             
01081     xmlnode       x;                
01082     jid           to;               
01083     jid           from;             
01084     char*         iqns;             
01085     xmlnode       iq;               
01086     pool          p;                
01087 } *jpacket, _jpacket;
01088  
01089 jpacket jpacket_new(xmlnode x);     /* Creates a jabber packet from the xmlnode */
01090 jpacket jpacket_reset(jpacket p);   /* Resets the jpacket values based on the xmlnode */
01091 int     jpacket_subtype(jpacket p); /* Returns the subtype value (looks at xmlnode for it) */
01092 
01093 
01094 /* --------------------------------------------------------- */
01095 /*                                                           */
01096 /* Simple Jabber Rate limit functions                        */
01097 /*                                                           */
01098 /* --------------------------------------------------------- */
01099 typedef struct jlimit_struct
01100 {
01101     char *key;
01102     int start;
01103     int points;
01104     int maxt, maxp;
01105     pool p;
01106 } *jlimit, _jlimit;
01107  
01108 jlimit jlimit_new(int maxt, int maxp);
01109 void jlimit_free(jlimit r);
01110 int jlimit_check(jlimit r, char *key, int points);
01111 
01112 
01113 /* #define KARMA_DEBUG */
01114 /* default to disable karma */
01115 #define KARMA_READ_MAX(k) (abs(k)*100) /* how much you are allowed to read off the sock */
01116 #define KARMA_INIT 5   /* internal "init" value */
01117 #define KARMA_HEARTBEAT 2 /* seconds to register for heartbeat */
01118 #define KARMA_MAX 10     /* total max karma you can have */
01119 #define KARMA_INC 1      /* how much to increment every KARMA_HEARTBEAT seconds */
01120 #define KARMA_DEC 0      /* how much to penalize for reading KARMA_READ_MAX in
01121                             KARMA_HEARTBEAT seconds */
01122 #define KARMA_PENALTY -5 /* where you go when you hit 0 karma */
01123 #define KARMA_RESTORE 5  /* where you go when you payed your penelty or INIT */
01124 #define KARMA_RESETMETER 0 /* Reset byte meter on restore default is falst */
01125 
01126 struct karma {
01127     int reset_meter; /* reset the byte meter on restore */
01128     int val; /* current karma value */
01129     long bytes; /* total bytes read (in that time period) */
01130     int max;  /* max karma you can have */
01131     int inc,dec; /* how much to increment/decrement */
01132     int penalty,restore; /* what penalty (<0) or restore (>0) */
01133     time_t last_update; /* time this was last incremented */
01134 };
01135 
01136 struct karma *karma_new(pool p); /* creates a new karma object, with default values */
01137 void karma_copy(struct karma *new_instance, struct karma *old); /* makes a copy of old in new */
01138 void karma_increment(struct karma *k);          /* inteligently increments karma */
01139 void karma_decrement(struct karma *k, long bytes_read); /* inteligently decrements karma */
01140 int karma_check(struct karma *k,long bytes_read); /* checks to see if we have good karma */
01141 
01142 
01143 
01144 /* --------------------------------------------------------- */
01145 /*                                                           */
01146 /* Error structures & constants                              */
01147 /*                                                           */
01148 /* --------------------------------------------------------- */
01149 typedef struct terror_struct
01150 {
01151     int  code;
01152     char msg[64];
01153 } terror;
01154 
01155 #define TERROR_BAD           (terror){400,"Bad Request"}
01156 #define TERROR_AUTH          (terror){401,"Unauthorized"}
01157 #define TERROR_PAY           (terror){402,"Payment Required"}
01158 #define TERROR_FORBIDDEN     (terror){403,"Forbidden"}
01159 #define TERROR_NOTFOUND      (terror){404,"Not Found"}
01160 #define TERROR_NOTALLOWED    (terror){405,"Not Allowed"}
01161 #define TERROR_NOTACCEPTABLE (terror){406,"Not Acceptable"}
01162 #define TERROR_REGISTER      (terror){407,"Registration Required"}
01163 #define TERROR_REQTIMEOUT    (terror){408,"Request Timeout"}
01164 #define TERROR_CONFLICT      (terror){409,"Conflict"}
01165 
01166 #define TERROR_INTERNAL   (terror){500,"Internal Server Error"}
01167 #define TERROR_NOTIMPL    (terror){501,"Not Implemented"}
01168 #define TERROR_EXTERNAL   (terror){502,"Remote Server Error"}
01169 #define TERROR_UNAVAIL    (terror){503,"Service Unavailable"}
01170 #define TERROR_EXTTIMEOUT (terror){504,"Remote Server Timeout"}
01171 #define TERROR_DISCONNECTED (terror){510,"Disconnected"}
01172 
01173 /* we define this to signal that we support xterror */
01174 #define HAS_XTERROR
01175 
01176 typedef struct xterror_struct
01177 {
01178     int  code;
01179     char msg[256];
01180     char type[9];
01181     char condition[64];
01182 } xterror;
01183 
01184 #define XTERROR_BAD             (xterror){400, N_("Bad Request"),"modify","bad-request"}
01185 #define XTERROR_CONFLICT        (xterror){409, N_("Conflict"), "cancel", "conflict"}
01186 #define XTERROR_NOTIMPL         (xterror){501, N_("Not Implemented"), "cancel", "feature-not-implemented"}
01187 #define XTERROR_FORBIDDEN       (xterror){403, N_("Forbidden"), "auth", "forbidden"}
01188 #define XTERROR_GONE            (xterror){302, N_("Gone"), "modify", "gone"}
01189 #define XTERROR_INTERNAL        (xterror){500, N_("Internal Server Error"), "wait", "internal-server-error"}
01190 #define XTERROR_NOTFOUND        (xterror){404, N_("Not Found"), "cancel", "item-not-found"}
01191 #define XTERROR_JIDMALFORMED    (xterror){400, N_("Bad Request"), "modify", "jid-malformed"}
01192 #define XTERROR_NOTACCEPTABLE   (xterror){406, N_("Not Acceptable"), "modify", "not-acceptable"}
01193 #define XTERROR_NOTALLOWED      (xterror){405, N_("Not Allowed"), "cancel", "not-allowed"}
01194 #define XTERROR_AUTH            (xterror){401, N_("Unauthorized"), "auth", "not-authorized"}
01195 #define XTERROR_PAY             (xterror){402, N_("Payment Required"), "auth", "payment-required"}
01196 #define XTERROR_RECIPIENTUNAVAIL (xterror){404, N_("Recipient Is Unavailable"), "wait", "recipient-unavailable"}
01197 #define XTERROR_REDIRECT        (xterror){302, N_("Redirect"), "modify", "redirect"}
01198 #define XTERROR_REGISTER        (xterror){407, N_("Registration Required"), "auth", "registration-required"}
01199 #define XTERROR_REMOTENOTFOUND  (xterror){404, N_("Remote Server Not Found"), "cancel", "remote-server-not-found"}
01200 #define XTERROR_REMOTETIMEOUT   (xterror){504, N_("Remote Server Timeout"), "wait", "remote-server-timeout"}
01201 #define XTERROR_RESCONSTRAINT   (xterror){500, N_("Resource Constraint"), "wait", "resource-constraint"}
01202 #define XTERROR_UNAVAIL         (xterror){503, N_("Service Unavailable"), "cancel", "service-unavailable"}
01203 #define XTERROR_SUBSCRIPTIONREQ (xterror){407, N_("Subscription Required"), "auth", "subscription-required"}
01204 #define XTERROR_UNDEF_CANCEL    (xterror){500, NULL, "cancel", "undefined-condition"}
01205 #define XTERROR_UNDEF_CONTINUE  (xterror){500, NULL, "continue", "undefined-condition"}
01206 #define XTERROR_UNDEF_MODIFY    (xterror){500, NULL, "modify", "undefined-condition"}
01207 #define XTERROR_UNDEF_AUTH      (xterror){500, NULL, "auth", "undefined-condition"}
01208 #define XTERROR_UNDEF_WAIT      (xterror){500, NULL, "wait", "undefined-condition"}
01209 #define XTERROR_UNEXPECTED      (xterror){400, N_("Unexpected Request"), "wait", "unexpected-request"}
01210 
01211 #define XTERROR_REQTIMEOUT      (xterror){408, N_("Request Timeout"), "wait", "remote-server-timeout"}
01212 #define XTERROR_EXTERNAL        (xterror){502, N_("Remote Server Error"), "wait", "service-unavailable"}
01213 #define XTERROR_EXTTIMEOUT      (xterror){504, N_("Remote Server Timeout"), "wait", "remote-server-timeout"}
01214 #define XTERROR_DISCONNECTED    (xterror){510, N_("Disconnected"), "cancel", "service-unavailable"}
01215 #define XTERROR_STORAGE_FAILED  (xterror){500, N_("Storage Failed"), "wait", "internal-server-error"}
01216 
01217 /* --------------------------------------------------------- */
01218 /*                                                           */
01219 /* Namespace constants                                       */
01220 /*                                                           */
01221 /* --------------------------------------------------------- */
01222 #define NSCHECK(x,n) (j_strcmp(xmlnode_get_namespace(x), n) == 0)
01223 
01224 #define NS_STREAM    "http://etherx.jabber.org/streams"
01225 #define NS_FLASHSTREAM "http://www.jabber.com/streams/flash"
01226 #define NS_CLIENT    "jabber:client"
01227 #define NS_SERVER    "jabber:server"
01228 #define NS_DIALBACK  "jabber:server:dialback"
01229 #define NS_COMPONENT_ACCEPT "jabber:component:accept"
01230 #define NS_AUTH      "jabber:iq:auth"
01231 #define NS_AUTH_CRYPT "jabber:iq:auth:crypt"
01232 #define NS_REGISTER  "jabber:iq:register"
01233 #define NS_ROSTER    "jabber:iq:roster"
01234 #define NS_OFFLINE   "jabber:x:offline"
01235 #define NS_AGENT     "jabber:iq:agent"
01236 #define NS_AGENTS    "jabber:iq:agents"
01237 #define NS_DELAY     "jabber:x:delay"
01238 #define NS_VERSION   "jabber:iq:version"
01239 #define NS_TIME      "jabber:iq:time"
01240 #define NS_VCARD     "vcard-temp"
01241 #define NS_PRIVATE   "jabber:iq:private"
01242 #define NS_SEARCH    "jabber:iq:search"
01243 #define NS_OOB       "jabber:iq:oob"
01244 #define NS_XOOB      "jabber:x:oob"
01245 #define NS_FILTER    "jabber:iq:filter"
01246 #define NS_AUTH_0K   "jabber:iq:auth:0k"
01247 #define NS_BROWSE    "jabber:iq:browse"
01248 #define NS_EVENT     "jabber:x:event"
01249 #define NS_CONFERENCE "jabber:iq:conference"
01250 #define NS_SIGNED    "jabber:x:signed"
01251 #define NS_ENCRYPTED "jabber:x:encrypted"
01252 #define NS_GATEWAY   "jabber:iq:gateway"
01253 #define NS_LAST      "jabber:iq:last"
01254 #define NS_ENVELOPE  "jabber:x:envelope"
01255 #define NS_EXPIRE    "jabber:x:expire"
01256 #define NS_PRIVACY   "jabber:iq:privacy"
01257 #define NS_XHTML     "http://www.w3.org/1999/xhtml"
01258 #define NS_DISCO_INFO "http://jabber.org/protocol/disco#info"
01259 #define NS_DISCO_ITEMS "http://jabber.org/protocol/disco#items"
01260 #define NS_DATA      "jabber:x:data"
01261 #define NS_FLEXIBLE_OFFLINE "http://jabber.org/protocol/offline"
01262 #define NS_IQ_AUTH    "http://jabber.org/features/iq-auth"
01263 #define NS_REGISTER_FEATURE "http://jabber.org/features/iq-register"
01264 #define NS_MSGOFFLINE "msgoffline"
01265 #define NS_BYTESTREAMS "http://jabber.org/protocol/bytestreams"
01266 #define NS_COMMAND      "http://jabber.org/protocol/commands"
01267 
01268 /* #define NS_XDBGINSERT "jabber:xdb:ginsert" XXX: I guess this it not used ANYWHERE and can be deleted */
01269 #define NS_XDBNSLIST  "jabber:xdb:nslist"
01270 
01271 #define NS_XMPP_STANZAS "urn:ietf:params:xml:ns:xmpp-stanzas"
01272 #define NS_XMPP_TLS  "urn:ietf:params:xml:ns:xmpp-tls"
01273 #define NS_XMPP_STREAMS "urn:ietf:params:xml:ns:xmpp-streams"
01274 #define NS_XMPP_SASL "urn:ietf:params:xml:ns:xmpp-sasl"
01275 
01276 #define NS_XMPP_PING "urn:xmpp:ping"
01277 
01278 #define NS_JABBERD_STOREDPRESENCE "http://jabberd.org/ns/storedpresence"
01279 #define NS_JABBERD_STOREDPEERPRESENCE "http://jabberd.org/ns/storedpeerpresence"
01280 #define NS_JABBERD_STOREDREQUEST "http://jabberd.org/ns/storedsubscriptionrequest"
01281 #define NS_JABBERD_STOREDSTATE "http://jabberd.org/ns/storedstate"      
01282 #define NS_JABBERD_HISTORY "http://jabberd.org/ns/history"
01283 #define NS_JABBERD_HASH "http://jabberd.org/ns/hash"                    
01284 #define NS_JABBERD_XDB "http://jabberd.org/ns/xdb"                      
01285 #define NS_JABBERD_WRAPPER "http://jabberd.org/ns/wrapper"              
01286 #define NS_JABBERD_XDBSQL "http://jabberd.org/ns/xdbsql"                
01287 #define NS_JABBERD_ACL "http://jabberd.org/ns/acl"                      
01288 #define NS_JABBERD_LOOPCHECK "http://jabberd.org/ns/loopcheck"          
01289 #define NS_JABBERD_ERRMSG "http://jabberd.org/ns/errmsg"                
01291 #define NS_SESSION "http://jabberd.jabberstudio.org/ns/session/1.0"     
01293 #define NS_XMLNS "http://www.w3.org/2000/xmlns/"        
01294 #define NS_XML "http://www.w3.org/XML/1998/namespace"   
01296 #define NS_JABBERD_CONFIGFILE "http://jabberd.org/ns/configfile" 
01297 #define NS_JABBERD_CONFIGFILE_REPLACE "http://jabberd.org/ns/configfile/replace" 
01298 #define NS_JABBERD_CONFIGFILE_ROUTER "http://xmppd.org/ns/configfile/router" 
01299 #define NS_JABBERD_CONFIG_XDBFILE "jabber:config:xdb_file" 
01300 #define NS_JABBERD_CONFIG_DIALBACK "jabber:config:dialback" 
01301 #define NS_JABBERD_CONFIG_DNSRV "jabber:config:dnsrv" 
01302 #define NS_JABBERD_CONFIG_JSM "jabber:config:jsm" 
01303 #define NS_JABBERD_CONFIG_PTHCSOCK "jabber:config:pth-csock" 
01304 #define NS_JABBERD_CONFIG_XDBSQL "jabber:config:xdb_sql" 
01305 #define NS_JABBERD_CONFIG_DYNAMICHOST "http://xmppd.org/ns/dynamichost" 
01307 /* --------------------------------------------------------- */
01308 /*                                                           */
01309 /* JUtil functions                                           */
01310 /*                                                           */
01311 /* --------------------------------------------------------- */
01312 xmlnode jutil_presnew(int type, char const* to, const char *status); /* Create a skeleton presence packet */
01313 xmlnode jutil_iqnew(int type, char const* ns);           /* Create a skeleton iq packet */
01314 xmlnode jutil_msgnew(char const* type, char const* to, char const* subj, char const* body);
01315                                                          /* Create a skeleton message packet */
01316 int     jutil_priority(xmlnode x);                       /* Determine priority of this packet */
01317 void    jutil_tofrom(xmlnode x);                         /* Swaps to/from fields on a packet */
01318 xmlnode jutil_iqresult(xmlnode x);                       /* Generate a skeleton iq/result, given a iq/query */
01319 char*   jutil_timestamp(void);                           /* Get stringified timestamp */
01320 char*   jutil_timestamp_ms(char *buffer);                /* Get stringified timestamp including milliseconds */
01321 void    jutil_error(xmlnode x, terror E);                /* Append an <error> node to x */
01322 void    jutil_error_xmpp(xmlnode x, xterror E);          /* Append an <error> node to x using XMPP syntax */
01323 void    jutil_error_map(terror old, xterror *mapped);    /* map an old terror structure to a new xterror structure */
01324 void    jutil_delay(xmlnode msg, char const* reason);            /* Append a delay packet to msg */
01325 char*   jutil_regkey(char *key, char *seed);             /* pass a seed to generate a key, pass the key again to validate (returns it) */
01326 
01327 /* --------------------------------------------------------- */
01328 /*                                                           */
01329 /* Functions to access localized messages                    */
01330 /*                                                           */
01331 /* --------------------------------------------------------- */
01332 void messages_set_mapping(const char* lang, const char* locale_name);
01333 const char* messages_get(const char* lang, const char* message);
01334 
01335 /* --------------------------------------------------------- */
01336 /*                                                           */
01337 /* Objects to access a lwresd                                */
01338 /*                                                           */
01339 /* --------------------------------------------------------- */
01340 namespace xmppd {
01341     namespace lwresc {
01342 
01343         class invalid_packet : public std::logic_error {
01344             public:
01345                 invalid_packet(const std::string& __arg);
01346         };
01347 
01348         // forward declaration
01349         class lwquery;
01350 
01354         std::ostream& operator<<(std::ostream& os, const lwquery& lwq);
01355 
01359         class lwquery {
01360             public:
01361                 friend std::ostream& operator<<(std::ostream& os, const lwquery& lwq);
01362 
01363                 uint32_t getSerial() const;
01364 
01365             protected:
01370                 lwquery();
01371 
01375                 virtual ~lwquery();
01376 
01384                 void write_header(std::ostream& os, uint32_t opcode, size_t rdata_len) const;
01385 
01392                 static void write_uint16(std::ostream& os, uint16_t value);
01393 
01400                 static void write_uint32(std::ostream& os, uint32_t value);
01401 
01405                 uint16_t flags;
01406 
01410                 uint32_t serial;
01411 
01412             private:
01419                 virtual void write_to_stream(std::ostream& os) const =0;
01420 
01424                 static int next_serial;
01425         };
01426 
01430         class rrsetbyname : public lwquery {
01431             public:
01435                 rrsetbyname(const std::string& hostname, ::ns_class qclass, ::ns_type qtype);
01436             private:
01440                 std::string hostname;
01441 
01445                 ::ns_class qclass;
01446 
01450                 ::ns_type qtype;
01451 
01457                 void write_to_stream(std::ostream& os) const;
01458         };
01459 
01460         class rrecord {
01461             public:
01462                 virtual ~rrecord();
01463         };
01464 
01465         class srv_record : public rrecord {
01466             public:
01467                 srv_record(std::istream& is);
01468 
01469                 // accessor functions
01470                 uint16_t getPrio() const;
01471                 uint16_t getWeight() const;
01472                 uint16_t getPort() const;
01473                 const std::string& getDName() const;
01474             private:
01475                 uint16_t prio;
01476                 uint16_t weight;
01477                 uint16_t port;
01478                 std::string dname;
01479         };
01480 
01481         class aaaa_record : public rrecord {
01482             public:
01483                 aaaa_record(std::istream& is);
01484 
01485                 // accessor functions
01486                 const std::string& getAddress() const;
01487             private:
01488                 std::string address;
01489         };
01490 
01491         class a_record : public rrecord {
01492             public:
01493                 a_record(std::istream& is);
01494 
01495                 // accessor functions
01496                 const std::string& getAddress() const;
01497             private:
01498                 std::string address;
01499         };
01500 
01501         class lwresult_rdata {
01502             public:
01503                 virtual ~lwresult_rdata();
01504         };
01505 
01506         class lwresult_rrset : public lwresult_rdata {
01507             public:
01508                 lwresult_rrset(std::istream& is, uint32_t rdata_len);
01509                 ~lwresult_rrset();
01510 
01511                 // accessor functions
01512                 uint32_t getTTL() const;
01513                 std::vector<rrecord *> getRR() const;
01514             private:
01515                 uint32_t flags;
01516                 ::ns_class rclass;
01517                 ::ns_type rtype;
01518                 uint32_t ttl;
01519                 uint16_t number_rr;
01520                 uint16_t number_sig;
01521                 std::string real_name;
01522 
01523                 std::vector<rrecord*> rr;
01524         };
01525 
01529         class lwresult {
01530             public:
01536                 lwresult(std::istream& is);
01537 
01541                 ~lwresult();
01542 
01550                 static uint16_t read_uint16(std::istream& is);
01551 
01559                 static uint32_t read_uint32(std::istream& is);
01560 
01570                 static std::string read_string(std::istream& is);
01571 
01581                 static std::string read_qname(std::istream& is);
01582 
01586                 enum QueryResult {
01587                     res_success = 0,
01588                     res_nomemory = 1,
01589                     res_timeout = 2,
01590                     res_notfound = 3,
01591                     res_unexpectedend = 4,
01592                     res_failure = 5,
01593                     res_ioerror = 6,
01594                     res_notimplemented = 7,
01595                     res_unexpected = 8,
01596                     res_trailingdata = 9,
01597                     res_incomplete = 10,
01598                     res_retry = 11,
01599                     res_typenotfound = 12,
01600                     res_toolarge = 13
01601                 };
01602 
01603                 // accessor functions
01604 
01605                 uint32_t getSerial() const;
01606                 QueryResult getResult() const;
01607                 lwresult_rdata const* getRData() const;
01608 
01609             private:
01610                 uint32_t length;
01611                 uint16_t version;
01612                 uint16_t flags;
01613                 uint32_t serial;
01614                 uint32_t opcode;
01615                 uint32_t result;
01616                 uint32_t recv_len;
01617                 uint16_t auth_type;
01618                 uint16_t auth_len;
01619 
01620                 lwresult_rdata* rdata;
01621         };
01622 
01623     }
01624 }
01625 
01626 #include <pointer.tcc>
01627 
01628 #endif  /* INCL_LIB_H */
Generated on Fri Jul 30 06:00:06 2010 for jabberd14 by  doxygen 1.6.3