⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jabberdlib.h

📁 jabber server jabber server jabber server jabber server
💻 H
📖 第 1 页 / 共 3 页
字号:
/* --------------------------------------------------------- */char *strescape(pool p, char *buf); /* Escape <>&'" chars */char *strunescape(pool p, char *buf);/* --------------------------------------------------------- *//*                                                           *//* String pools (spool) functions                            *//*                                                           *//* --------------------------------------------------------- */struct spool_node{    char *c;    struct spool_node *next;};typedef struct spool_struct{    pool p;    int len;    struct spool_node *last;    struct spool_node *first;} *spool;spool spool_new(pool p); /* create a string pool */void spooler(spool s, ...); /* append all the char * args to the pool, terminate args with s again */char *spool_print(spool s); /* return a big string */void spool_add(spool s, char *str); /* add a single char to the pool */char *spools(pool p, ...); /* wrap all the spooler stuff in one function, the happy fun ball! *//* --------------------------------------------------------- *//*                                                           *//* xmlnodes - Document Object Model                          *//*                                                           *//* --------------------------------------------------------- */#define NTYPE_TAG    0#define NTYPE_ATTRIB 1#define NTYPE_CDATA  2#define NTYPE_LAST   2#define NTYPE_UNDEF  -1/* --------------------------------------------------------------------------    Node structure. Do not use directly! Always use accessor macros    and methods!   -------------------------------------------------------------------------- */typedef struct xmlnode_t{     char*               name;     unsigned short      type;     char*               data;     int                 data_sz;     int                 complete;     pool               p;     struct xmlnode_t*  parent;     struct xmlnode_t*  firstchild;      struct xmlnode_t*  lastchild;     struct xmlnode_t*  prev;      struct xmlnode_t*  next;     struct xmlnode_t*  firstattrib;     struct xmlnode_t*  lastattrib;} _xmlnode, *xmlnode;/* Node creation routines */xmlnode  xmlnode_wrap(xmlnode x,const char* wrapper);xmlnode  xmlnode_new_tag(const char* name);xmlnode  xmlnode_new_tag_pool(pool p, const char* name);xmlnode  xmlnode_insert_tag(xmlnode parent, const char* name); xmlnode  xmlnode_insert_cdata(xmlnode parent, const char* CDATA, unsigned int size);xmlnode  xmlnode_insert_tag_node(xmlnode parent, xmlnode node);void     xmlnode_insert_node(xmlnode parent, xmlnode node);xmlnode  xmlnode_str(char *str, int len);xmlnode  xmlnode_file(char *file);char*    xmlnode_file_borked(char *file); /* same as _file but returns the parsing error */xmlnode  xmlnode_dup(xmlnode x); /* duplicate x */xmlnode  xmlnode_dup_pool(pool p, xmlnode x);/* Node Memory Pool */pool xmlnode_pool(xmlnode node);xmlnode _xmlnode_new(pool p, const char *name, unsigned int type);/* Node editing */void xmlnode_hide(xmlnode child);void xmlnode_hide_attrib(xmlnode parent, const char *name);/* Node deletion routine, also frees the node pool! */void xmlnode_free(xmlnode node);/* Locates a child tag by name and returns it */xmlnode  xmlnode_get_tag(xmlnode parent, const char* name);char* xmlnode_get_tag_data(xmlnode parent, const char* name);/* Attribute accessors */void     xmlnode_put_attrib(xmlnode owner, const char* name, const char* value);char*    xmlnode_get_attrib(xmlnode owner, const char* name);void     xmlnode_put_expat_attribs(xmlnode owner, const char** atts);/* Bastard am I, but these are fun for internal use ;-) */void     xmlnode_put_vattrib(xmlnode owner, const char* name, void *value);void*    xmlnode_get_vattrib(xmlnode owner, const char* name);/* Node traversal routines */xmlnode  xmlnode_get_firstattrib(xmlnode parent);xmlnode  xmlnode_get_firstchild(xmlnode parent);xmlnode  xmlnode_get_lastchild(xmlnode parent);xmlnode  xmlnode_get_nextsibling(xmlnode sibling);xmlnode  xmlnode_get_prevsibling(xmlnode sibling);xmlnode  xmlnode_get_parent(xmlnode node);/* Node information routines */char*    xmlnode_get_name(xmlnode node);char*    xmlnode_get_data(xmlnode node);int      xmlnode_get_datasz(xmlnode node);int      xmlnode_get_type(xmlnode node);int      xmlnode_has_children(xmlnode node);int      xmlnode_has_attribs(xmlnode node);/* Node-to-string translation */char*    xmlnode2str(xmlnode node);/* Node-to-terminated-string translation    -- useful for interfacing w/ scripting langs */char*    xmlnode2tstr(xmlnode node);int      xmlnode_cmp(xmlnode a, xmlnode b); /* compares a and b for equality */int      xmlnode2file(char *file, xmlnode node); /* writes node to file */int	 xmlnode2file_limited(char *file, xmlnode node, size_t sizelimit);/* Expat callbacks */void expat_startElement(void* userdata, const char* name, const char** atts);void expat_endElement(void* userdata, const char* name);void expat_charData(void* userdata, const char* s, int len);/*********************** * XSTREAM Section ***********************/#define XSTREAM_MAXNODE 1000000#define XSTREAM_MAXDEPTH 100#define XSTREAM_ROOT        0 /* root element */#define XSTREAM_NODE        1 /* normal node */#define XSTREAM_CLOSE       2 /* closed </stream:stream> */#define XSTREAM_ERR         4 /* parser error */typedef void (*xstream_onNode)(int type, xmlnode x, void *arg); /* xstream event handler */typedef struct xstream_struct{    XML_Parser parser;    xmlnode node;    char *cdata;    int cdata_len;    pool p;    xstream_onNode f;    void *arg;    int status;    int depth;} *xstream, _xstream;xstream xstream_new(pool p, xstream_onNode f, void *arg); /* create a new xstream */int xstream_eat(xstream xs, char *buff, int len); /* parse new data for this xstream, returns last XSTREAM_* status *//* convience functions */xmlnode xstream_header(char *namespace, char *to, char *from);char *xstream_header_char(xmlnode x);/** error cause types for streams, see section 4.7.3 of RFC 3920 */typedef enum {    unknown_error_type,		/**< no errror type found, especially legacy stream errors */    bad_format,			/**< XML cannot be processed */    bad_namespace_prefix,	/**< unsupported namespace prefix */    conflict,			/**< new stream has been initiated, that conflicts */    connection_timeout,		/**< no traffic on the stream for some time */    host_gone,			/**< hostname is no longer hosted on this server */    host_unknown,		/**< hostname is not known by this server */    improper_addressing,	/**< missing to or from attribute */    internal_server_error,	/**< missconfiguration or something like that */    invalid_from,		/**< from address is not authorzed */    invalid_id,			/**< invalid stream id */    invalid_namespace,		/**< wrong namespace for stream or dialback */    invalid_xml,		/**< invalid XML was found */    not_authorized,		/**< session not authorized */    policy_violation,		/**< local service policy violated */    remote_connection_failed,	/**< could not connect to a required remote entity for auth */    resource_constraint,	/**< server lacks system resources */    restricted_xml,		/**< received restricted XML features */    see_other_host,		/**< redirection to another host */    system_shutdown,		/**< server is being shut down */    undefined_condition,	/**< something else ... */    unsupported_encoding,	/**< stream is coded in an unsupported encoding */    unsupported_stanza_type,	/**< stanza is not supported */    unsupported_version,	/**< XMPP version requested is not supported */    xml_not_well_formed		/**< received XML, that is not well formed */} streamerr_reason;/** severity of stream error (well all stream errors are unrecoverable, but we might log them different */typedef enum {    normal,			/**< something that is just normal to happen (e.g. connection timeout) */    configuration,		/**< something that seems to be caused by configuration errors (e.g. host gone) */    feature_lack,		/**< something caused by features not supported by the other end (e.g. unsupported version) */    unknown,			/**< absolutely no clue */    error			/**< something that shut not happen in any case and seems to be an implementation error (e.g. xml_not_well_formed) */} streamerr_severity;/** structure that contains information about a stream error */typedef struct streamerr_struct {    char *text;			/**< the error message */    char *lang;			/**< language of the error message */    streamerr_reason reason;	/**< a generic cause type */    streamerr_severity severity;/**< something that admin needs to care about? */} *streamerr, _streamerr;void xstream_format_error(spool s, streamerr errstruct);streamerr_severity xstream_parse_error(pool p, xmlnode errnode, streamerr errstruct);typedef struct {  unsigned long H[5];  unsigned long W[80];  int lenW;  unsigned long sizeHi,sizeLo;} j_SHA_CTX;void shaInit(j_SHA_CTX *ctx);void shaUpdate(j_SHA_CTX *ctx, unsigned char *dataIn, int len);void shaFinal(j_SHA_CTX *ctx, unsigned char hashout[20]);void shaBlock(unsigned char *dataIn, int len, unsigned char hashout[20]);/********** END OLD libxode.h BEGIN OLD jabber.h *************//* --------------------------------------------------------- *//*                                                           *//* JID structures & constants                                *//*                                                           *//* --------------------------------------------------------- */#define JID_RESOURCE 1#define JID_USER     2#define JID_SERVER   4typedef struct jid_struct{     pool               p;    char*              resource;    char*              user;    char*              server;    char*              full;    struct jid_struct *next; /* for lists of jids */} *jid;  jid     jid_new(pool p, char *idstr);	       /* Creates a jabber id from the idstr */void    jid_set(jid id, char *str, int item);  /* Individually sets jid components */char*   jid_full(jid id);		       /* Builds a string type=user/resource@server from the jid data */int     jid_cmp(jid a, jid b);		       /* Compares two jid's, returns 0 for perfect match */int     jid_cmpx(jid a, jid b, int parts);     /* Compares just the parts specified as JID_|JID_ */jid     jid_append(jid a, jid b);	       /* Appending b to a (list), no dups */xmlnode jid_xres(jid id);		       /* Returns xmlnode representation of the resource?query=string */xmlnode jid_nodescan(jid id, xmlnode x);       /* Scans the children of the node for a matching jid attribute */jid     jid_user(jid a);                       /* returns the same jid but just of the user@host part */void	jid_init_cache();		       /**< initialize the stringprep caches */void	jid_stop_caching();		       /**< free all caches that have been initialized */void	jid_clean_cache();		       /**< check the stringprep caches for expired entries *//* --------------------------------------------------------- *//*                                                           *//* JPacket structures & constants                            *//*                                                           *//* --------------------------------------------------------- */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -