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

📄 jabberdlib.h

📁 jabber server jabber server jabber server jabber server
💻 H
📖 第 1 页 / 共 3 页
字号:
#ifdef HAVE_CONFIG_H#   include <config.h>#endif#include <string.h>#include <stdlib.h>#include <sys/types.h>#include <stdio.h>#include <setjmp.h>#include <sys/stat.h>#include <fcntl.h>#include <errno.h>#include <signal.h>#include <syslog.h>#include <strings.h>#include <unistd.h>#include <sys/param.h>#include <sys/socket.h>#include <netinet/in.h>#include <netdb.h>#include <arpa/inet.h>#include <sys/time.h>#include <stdarg.h>#include <ctype.h>#include <time.h>#include <pth.h>#include <expat.h>/***  Arrange to use either varargs or stdargs*/#define MAXSHORTSTR	203		/* max short string length */#define QUAD_T	unsigned long long#ifdef __STDC__#include <stdarg.h># define VA_LOCAL_DECL	va_list ap;# define VA_START(f)	va_start(ap, f)# define VA_END		va_end(ap)#else /* __STDC__ */# include <varargs.h># define VA_LOCAL_DECL	va_list ap;# define VA_START(f)	va_start(ap)# define VA_END		va_end(ap)#endif /* __STDC__ */#ifndef INCL_LIB_H#define INCL_LIB_H#ifdef __cplusplusextern "C" {#endif#ifndef HAVE_SNPRINTFextern int ap_snprintf(char *, size_t, const char *, ...);#define snprintf ap_snprintf#endif#ifndef HAVE_VSNPRINTFextern int ap_vsnprintf(char *, size_t, const char *, va_list ap);#define vsnprintf ap_vsnprintf#endif#define ZONE zonestr(__FILE__,__LINE__)char *zonestr(char *file, int line);/* --------------------------------------------------------- *//*                                                           *//* Pool-based memory management routines                     *//*                                                           *//* --------------------------------------------------------- */#ifdef POOL_DEBUG# define POOL_NUM 40009#endif/* pheap - singular allocation of memory */struct pheap{    void *block;    int size, used;};/* pool_cleaner - callback type which is associated   with a pool entry; invoked when the pool entry is    free'd */typedef void (*pool_cleaner)(void *arg);/* pfree - a linked list node which stores an   allocation chunk, plus a callback */struct pfree{    pool_cleaner f;    void *arg;    struct pheap *heap;    struct pfree *next;};/* pool - base node for a pool. Maintains a linked list   of pool entries (pfree) */typedef struct pool_struct{    int size;    struct pfree *cleanup;    struct pheap *heap;#ifdef POOL_DEBUG    char name[8], zone[32];    int lsize;} _pool, *pool;#define pool_new() _pool_new(__FILE__,__LINE__)#define pool_heap(i) _pool_new_heap(i,__FILE__,__LINE__)#else} _pool, *pool;#define pool_heap(i) _pool_new_heap(i, NULL, 0) #define pool_new() _pool_new(NULL, 0) #endifpool _pool_new(char *zone, int line); /* new pool :) */pool _pool_new_heap(int size, char *zone, int line); /* creates a new memory pool with an initial heap size */void *pmalloc(pool p, int size); /* wrapper around malloc, takes from the pool, cleaned up automatically */void *pmalloc_x(pool p, int size, char c); /* Wrapper around pmalloc which prefils buffer with c */void *pmalloco(pool p, int size); /* YAPW for zeroing the block */char *pstrdup(pool p, const char *src); /* wrapper around strdup, gains mem from pool */void pool_stat(int full); /* print to stderr the changed pools and reset */char *pstrdupx(pool p, const char *src); /* temp stub */void pool_cleanup(pool p, pool_cleaner f, void *arg); /* calls f(arg) before the pool is freed during cleanup */void pool_free(pool p); /* calls the cleanup functions, frees all the data on the pool, and deletes the pool itself */int pool_size(pool p); /* returns total bytes allocated in this pool *//* --------------------------------------------------------- *//*                                                           *//* Socket helper stuff                                       *//*                                                           *//* --------------------------------------------------------- */#ifndef MAXHOSTNAMELEN#define MAXHOSTNAMELEN 64#endif#define NETSOCKET_SERVER 0 /**< type of a local listening socket */#define NETSOCKET_CLIENT 1 /**< type of a connection socket */#define NETSOCKET_UDP 2    /**< type of a UDP connection socket */#ifndef WIN32int make_netsocket(u_short port, char *host, int type);struct in_addr *make_addr(char *host);#ifdef INCLUDE_LEGACYint set_fd_close_on_exec(int fd, int flag);#endif#ifdef WITH_IPV6struct in6_addr *make_addr_ipv6(char *host);#endif#endif/* --------------------------------------------------------- *//*                                                           *//* String management routines                                *//*                                                           *//* --------------------------------------------------------- */char *j_strdup(const char *str); /* provides NULL safe strdup wrapper */char *j_strcat(char *dest, char *txt); /* strcpy() clone */int j_strcmp(const char *a, const char *b); /* provides NULL safe strcmp wrapper */int j_strcasecmp(const char *a, const char *b); /* provides NULL safe strcasecmp wrapper */int j_strncmp(const char *a, const char *b, int i); /* provides NULL safe strncmp wrapper */int j_strncasecmp(const char *a, const char *b, int i); /* provides NULL safe strncasecmp wrapper */int j_strlen(const char *a); /* provides NULL safe strlen wrapper */int j_atoi(const char *a, int def); /* checks for NULL and uses default instead, convienence */void str_b64decode(char *str); /* what it says *//* --------------------------------------------------------- *//*                                                           *//* Base64 routines                                           *//*                                                           *//* --------------------------------------------------------- */int base64_encode(unsigned char *source, size_t sourcelen, char *target, size_t targetlen);size_t base64_decode(char *source, unsigned char *target, size_t targetlen);/* --------------------------------------------------------- *//*                                                           *//* SHA calculations                                          *//*                                                           *//* --------------------------------------------------------- */#if (SIZEOF_INT == 4)typedef unsigned int uint32;#elif (SIZEOF_SHORT == 4)typedef unsigned short uint32;#elsetypedef unsigned int uint32;#endif /* HAVEUINT32 */char *shahash(char *str);	/* NOT THREAD SAFE */void shahash_r(const char* str, char hashbuf[40]); /* USE ME */int strprintsha(char *dest, int *hashval);/* --------------------------------------------------------- *//*                                                           *//* SHA calculations                                          *//*                                                           *//* --------------------------------------------------------- */void crc32_r(const char *str, char crc32buf[9]);/* --------------------------------------------------------- *//*                                                           *//* Hashtable functions                                       *//*                                                           *//* --------------------------------------------------------- */typedef struct xhn_struct{    struct xhn_struct *next;    const char *key;    void *val;} *xhn, _xhn;typedef struct xht_struct{    pool p;    int prime;    struct xhn_struct *zen;} *xht, _xht;xht xhash_new(int prime);void xhash_put(xht h, const char *key, void *val);void *xhash_get(xht h, const char *key);void xhash_zap(xht h, const char *key);void xhash_free(xht h);typedef void (*xhash_walker)(xht h, const char *key, void *val, void *arg);void xhash_walk(xht h, xhash_walker w, void *arg);/* --------------------------------------------------------- *//*                                                           *//* DEPRECIATED Hashtable functions                           *//*                                                           *//* --------------------------------------------------------- */#ifdef INCLUDE_LEGACYtypedef int (*KEYHASHFUNC)(const void *key);typedef int (*KEYCOMPAREFUNC)(const void *key1, const void *key2);typedef int (*TABLEWALKFUNC)(void *user_data, const void *key, void *data);typedef void *HASHTABLE;HASHTABLE ghash_create(int buckets, KEYHASHFUNC hash, KEYCOMPAREFUNC cmp);HASHTABLE ghash_create_pool(pool p, int buckets, KEYHASHFUNC hash, KEYCOMPAREFUNC cmp);void ghash_destroy(HASHTABLE tbl);void *ghash_get(HASHTABLE tbl, const void *key);int ghash_put(HASHTABLE tbl, const void *key, void *value);int ghash_remove(HASHTABLE tbl, const void *key);int ghash_walk(HASHTABLE tbl, TABLEWALKFUNC func, void *user_data);int str_hash_code(const char *s);#endif/* --------------------------------------------------------- *//*                                                           *//* XML escaping utils                                        *//*                                                           */

⌨️ 快捷键说明

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