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

📄 jabberdlib.h

📁 jabber server jabber server jabber server jabber server
💻 H
📖 第 1 页 / 共 3 页
字号:
#define JPACKET_UNKNOWN   0x00#define JPACKET_MESSAGE   0x01#define JPACKET_PRESENCE  0x02#define JPACKET_IQ        0x04#define JPACKET_S10N      0x08#define JPACKET__UNKNOWN      0#define JPACKET__NONE         1#define JPACKET__ERROR        2#define JPACKET__CHAT         3#define JPACKET__GROUPCHAT    4#define JPACKET__GET          5#define JPACKET__SET          6#define JPACKET__RESULT       7#define JPACKET__SUBSCRIBE    8#define JPACKET__SUBSCRIBED   9#define JPACKET__UNSUBSCRIBE  10#define JPACKET__UNSUBSCRIBED 11#define JPACKET__AVAILABLE    12#define JPACKET__UNAVAILABLE  13#define JPACKET__PROBE        14#define JPACKET__HEADLINE     15#define JPACKET__INVISIBLE    16typedef struct jpacket_struct{    unsigned char type;		    /**< stanza type (JPACKET_*) */    int           subtype;	    /**< subtype of a stanza */    int           flag;		    /**< used by the session manager to flag messages, that are read from offline storage */    void*         aux1;		    /**< pointer to data passed around with a jpacket, multiple use inside jsm */    xmlnode       x;		    /**< xmlnode containing the stanza inside the jpacket */    jid           to;		    /**< destination of the stanza */    jid           from;		    /**< source address for the stanza */    char*         iqns;		    /**< pointer to the namespace inside an IQ stanza */    xmlnode       iq;		    /**< "content" of an iq stanza, pointer to the element in its own namespace */    pool          p;		    /**< memory pool used for this stanza */} *jpacket, _jpacket; jpacket jpacket_new(xmlnode x);	    /* Creates a jabber packet from the xmlnode */jpacket jpacket_reset(jpacket p);   /* Resets the jpacket values based on the xmlnode */int     jpacket_subtype(jpacket p); /* Returns the subtype value (looks at xmlnode for it) *//* --------------------------------------------------------- *//*                                                           *//* Presence Proxy DB structures & constants                  *//*                                                           *//* --------------------------------------------------------- */#ifdef INCLUDE_LEGACYtypedef struct ppdb_struct{			          jid     id;		       /* entry data */    int     pri;    xmlnode x;    struct ppdb_struct* user;  /* linked list for user@server */    pool                p;     /* db-level data */    struct ppdb_struct* next;} _ppdb, *ppdb;ppdb    ppdb_insert(ppdb db, jid id, xmlnode x); /* Inserts presence into the proxy */xmlnode ppdb_primary(ppdb db, jid id);		 /* Fetches the matching primary presence for the id */void    ppdb_free(ppdb db);			 /* Frees the db and all entries */xmlnode ppdb_get(ppdb db, jid id);		 /* Called successively to return each presence xmlnode */						 /*   for the id and children, returns NULL at the end */#endif/* --------------------------------------------------------- *//*                                                           *//* Simple Jabber Rate limit functions                        *//*                                                           *//* --------------------------------------------------------- */typedef struct jlimit_struct{    char *key;    int start;    int points;    int maxt, maxp;    pool p;} *jlimit, _jlimit; jlimit jlimit_new(int maxt, int maxp);void jlimit_free(jlimit r);int jlimit_check(jlimit r, char *key, int points);/* #define KARMA_DEBUG *//* default to disable karma */#define KARMA_READ_MAX(k) (abs(k)*100) /* how much you are allowed to read off the sock */#define KARMA_INIT 5   /* internal "init" value */#define KARMA_HEARTBEAT 2 /* seconds to register for heartbeat */#define KARMA_MAX 10     /* total max karma you can have */#define KARMA_INC 1      /* how much to increment every KARMA_HEARTBEAT seconds */#define KARMA_DEC 0      /* how much to penalize for reading KARMA_READ_MAX in                            KARMA_HEARTBEAT seconds */#define KARMA_PENALTY -5 /* where you go when you hit 0 karma */#define KARMA_RESTORE 5  /* where you go when you payed your penelty or INIT */#define KARMA_RESETMETER 0 /* Reset byte meter on restore default is falst */struct karma{    int init; /* struct initialized */    int reset_meter; /* reset the byte meter on restore */    int val; /* current karma value */    long bytes; /* total bytes read (in that time period) */    int max;  /* max karma you can have */    int inc,dec; /* how much to increment/decrement */    int penalty,restore; /* what penalty (<0) or restore (>0) */    time_t last_update; /* time this was last incremented */};struct karma *karma_new(pool p); /* creates a new karma object, with default values */void karma_copy(struct karma *new, struct karma *old); /* makes a copy of old in new */void karma_increment(struct karma *k);          /* inteligently increments karma */void karma_decrement(struct karma *k, long bytes_read); /* inteligently decrements karma */int karma_check(struct karma *k,long bytes_read); /* checks to see if we have good karma *//* --------------------------------------------------------- *//*                                                           *//* Error structures & constants                              *//*                                                           *//* --------------------------------------------------------- */typedef struct terror_struct{    int  code;    char msg[64];} terror;#define TERROR_BAD           (terror){400,"Bad Request"}#define TERROR_AUTH          (terror){401,"Unauthorized"}#define TERROR_PAY           (terror){402,"Payment Required"}#define TERROR_FORBIDDEN     (terror){403,"Forbidden"}#define TERROR_NOTFOUND      (terror){404,"Not Found"}#define TERROR_NOTALLOWED    (terror){405,"Not Allowed"}#define TERROR_NOTACCEPTABLE (terror){406,"Not Acceptable"}#define TERROR_REGISTER      (terror){407,"Registration Required"}#define TERROR_REQTIMEOUT    (terror){408,"Request Timeout"}#define TERROR_CONFLICT      (terror){409,"Conflict"}#define TERROR_INTERNAL   (terror){500,"Internal Server Error"}#define TERROR_NOTIMPL    (terror){501,"Not Implemented"}#define TERROR_EXTERNAL   (terror){502,"Remote Server Error"}#define TERROR_UNAVAIL    (terror){503,"Service Unavailable"}#define TERROR_EXTTIMEOUT (terror){504,"Remote Server Timeout"}#define TERROR_DISCONNECTED (terror){510,"Disconnected"}/* we define this to signal that we support xterror */#define HAS_XTERRORtypedef struct xterror_struct{    int  code;    char msg[256];    char type[9];    char condition[64];} xterror;#define XTERROR_BAD		(xterror){400,"Bad Request","modify","bad-request"}#define XTERROR_CONFLICT	(xterror){409,"Conflict","cancel","conflict"}#define XTERROR_NOTIMPL		(xterror){501,"Not Implemented","cancel","feature-not-implemented"}#define XTERROR_FORBIDDEN	(xterror){403,"Forbidden","auth","forbidden"}#define XTERROR_GONE		(xterror){302,"Gone","modify","gone"}#define XTERROR_INTERNAL	(xterror){500,"Internal Server Error","wait","internal-server-error"}#define XTERROR_NOTFOUND	(xterror){404,"Not Found","cancel","item-not-found"}#define XTERROR_JIDMALFORMED	(xterror){400,"Bad Request","modify","jid-malformed"}#define XTERROR_NOTACCEPTABLE	(xterror){406,"Not Acceptable","modify","not-acceptable"}#define XTERROR_NOTALLOWED	(xterror){405,"Not Allowed","cancel","not-allowed"}#define XTERROR_AUTH		(xterror){401,"Unauthorized","auth","not-authorized"}#define XTERROR_PAY		(xterror){402,"Payment Required","auth","payment-required"}#define XTERROR_RECIPIENTUNAVAIL (xterror){404,"Receipient Is Unavailable","wait","recipient-unavailable"}#define XTERROR_REDIRECT	(xterror){302,"Redirect","modify","redirect"}#define XTERROR_REGISTER	(xterror){407,"Registration Required","auth","registration-required"}#define XTERROR_REMOTENOTFOUND	(xterror){404,"Remote Server Not Found","cancel","remote-server-not-found"}#define XTERROR_REMOTETIMEOUT	(xterror){504,"Remote Server Timeout","wait","remote-server-timeout"}#define XTERROR_RESCONSTRAINT	(xterror){500,"Resource Constraint","wait","resource-constraint"}#define XTERROR_UNAVAIL		(xterror){503,"Service Unavailable","cancel","service-unavailable"}#define XTERROR_SUBSCRIPTIONREQ	(xterror){407,"Subscription Required","auth","subscription-required"}#define XTERROR_UNDEF_CANCEL	(xterror){500,NULL,"cancel","undefined-condition"}#define XTERROR_UNDEF_CONTINUE	(xterror){500,NULL,"continue","undefined-condition"}#define XTERROR_UNDEF_MODIFY	(xterror){500,NULL,"modify","undefined-condition"}#define XTERROR_UNDEF_AUTH	(xterror){500,NULL,"auth","undefined-condition"}#define XTERROR_UNDEF_WAIT	(xterror){500,NULL,"wait","undefined-condition"}#define XTERROR_UNEXPECTED	(xterror){400,"Unexpected Request","wait","unexpected-request"}#define XTERROR_REQTIMEOUT	(xterror){408,"Request Timeout","wait","remote-server-timeout"}#define XTERROR_EXTERNAL	(xterror){502,"Remote Server Error","wait","service-unavailable"}#define XTERROR_EXTTIMEOUT	(xterror){504,"Remote Server Timeout","wait","remote-server-timeout"}#define XTERROR_DISCONNECTED	(xterror){510,"Disconnected","cancel","service-unavailable"}/* --------------------------------------------------------- *//*                                                           *//* Namespace constants                                       *//*                                                           *//* --------------------------------------------------------- */#define NSCHECK(x,n) (j_strcmp(xmlnode_get_attrib(x,"xmlns"),n) == 0)#define NS_CLIENT    "jabber:client"#define NS_SERVER    "jabber:server"#define NS_DIALBACK  "jabber:server:dialback"#define NS_AUTH      "jabber:iq:auth"#define NS_AUTH_CRYPT "jabber:iq:auth:crypt"#define NS_REGISTER  "jabber:iq:register"#define NS_ROSTER    "jabber:iq:roster"#define NS_OFFLINE   "jabber:x:offline"#define NS_AGENT     "jabber:iq:agent"#define NS_AGENTS    "jabber:iq:agents"#define NS_DELAY     "jabber:x:delay"#define NS_VERSION   "jabber:iq:version"#define NS_TIME      "jabber:iq:time"#define NS_VCARD     "vcard-temp"#define NS_PRIVATE   "jabber:iq:private"#define NS_SEARCH    "jabber:iq:search"#define NS_OOB       "jabber:iq:oob"#define NS_XOOB      "jabber:x:oob"#define NS_ADMIN     "jabber:iq:admin"#define NS_FILTER    "jabber:iq:filter"#define NS_AUTH_0K   "jabber:iq:auth:0k"#define NS_BROWSE    "jabber:iq:browse"#define NS_EVENT     "jabber:x:event"#define NS_CONFERENCE "jabber:iq:conference"#define NS_SIGNED    "jabber:x:signed"#define NS_ENCRYPTED "jabber:x:encrypted"#define NS_GATEWAY   "jabber:iq:gateway"#define NS_LAST      "jabber:iq:last"#define NS_ENVELOPE  "jabber:x:envelope"#define NS_EXPIRE    "jabber:x:expire"#define NS_XHTML     "http://www.w3.org/1999/xhtml"#define NS_DISCO_INFO "http://jabber.org/protocol/disco#info"#define NS_DISCO_ITEMS "http://jabber.org/protocol/disco#items"#define NS_IQ_AUTH    "http://jabber.org/features/iq-auth"#define NS_REGISTER_FEATURE "http://jabber.org/features/iq-register"#define NS_XDBGINSERT "jabber:xdb:ginsert"#define NS_XDBNSLIST  "jabber:xdb:nslist"#define NS_XMPP_STANZAS "urn:ietf:params:xml:ns:xmpp-stanzas"#define NS_XMPP_TLS  "urn:ietf:params:xml:ns:xmpp-tls"#define NS_XMPP_STREAMS "urn:ietf:params:xml:ns:xmpp-streams"#define NS_JABBERD_STOREDPRESENCE "http://jabberd.org/ns/storedpresence"#define NS_JABBERD_HISTORY "http://jabberd.org/ns/history"/* --------------------------------------------------------- *//*                                                           *//* JUtil functions                                           *//*                                                           *//* --------------------------------------------------------- */xmlnode jutil_presnew(int type, char *to, char *status); /* Create a skeleton presence packet */xmlnode jutil_iqnew(int type, char *ns);		 /* Create a skeleton iq packet */xmlnode jutil_msgnew(char *type, char *to, char *subj, char *body);							 /* Create a skeleton message packet */xmlnode jutil_header(char* xmlns, char* server);	 /* Create a skeleton stream packet */int     jutil_priority(xmlnode x);			 /* Determine priority of this packet */void    jutil_tofrom(xmlnode x);			 /* Swaps to/from fields on a packet */xmlnode jutil_iqresult(xmlnode x);			 /* Generate a skeleton iq/result, given a iq/query */char*   jutil_timestamp(void);				 /* Get stringified timestamp */void    jutil_error(xmlnode x, terror E);		 /* Append an <error> node to x */void    jutil_error_xmpp(xmlnode x, xterror E);		 /* Append an <error> node to x using XMPP syntax */void	jutil_error_map(terror old, xterror *mapped);	 /* map an old terror structure to a new xterror structure */void    jutil_delay(xmlnode msg, char *reason);		 /* Append a delay packet to msg */char*   jutil_regkey(char *key, char *seed);		 /* pass a seed to generate a key, pass the key again to validate (returns it) */#ifdef __cplusplus}#endif#endif	/* INCL_LIB_H */

⌨️ 快捷键说明

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