2 * Asterisk -- A telephony toolkit for Linux.
6 * Copyright (C) 2004, Digium
8 * This program is free software, distributed under the terms of
9 * the GNU General Public License
12 #ifndef _ASTERISK_UTIL_H
13 #define _ASTERISK_UTIL_H
15 #include <netinet/in.h>
18 #include <asterisk/lock.h>
21 #define ast_test_flag(p,flag) ((p)->flags & (flag))
23 #define ast_set_flag(p,flag) ((p)->flags |= (flag))
25 #define ast_clear_flag(p,flag) ((p)->flags &= ~(flag))
27 #define ast_copy_flags(dest,src,flagz) do { (dest)->flags &= ~(flagz); \
28 (dest)->flags |= ((src)->flags & (flagz)); } while(0)
30 #define ast_set2_flag(p,value,flag) ((value) ? ast_set_flag(p,flag) : ast_clear_flag(p,flag))
32 #define AST_FLAGS_ALL UINT_MAX
34 static inline int ast_strlen_zero(const char *s)
48 extern char *ast_strip(char *buf);
49 extern struct hostent *ast_gethostbyname(const char *host, struct ast_hostent *hp);
50 extern int ast_base64encode(char *dst, unsigned char *src, int srclen, int max);
51 extern int ast_base64decode(unsigned char *dst, char *src, int max);
53 extern int test_for_thread_safety(void);
54 extern const char *ast_inet_ntoa(char *buf, int bufsiz, struct in_addr ia);
55 extern int ast_utils_init(void);
60 #define inet_ntoa __dont__use__inet_ntoa__use__ast_inet_ntoa__instead__
63 #define ast_pthread_create pthread_create
64 #define ast_strcasestr strcasestr
66 /* Linux threads have a default 2MB stack size. */
67 #ifndef PTHREAD_ATTR_STACKSIZE
68 #define PTHREAD_ATTR_STACKSIZE 2097152
69 #endif /* PTHREAD_ATTR_STACKSIZE */
70 extern int ast_pthread_create(pthread_t *thread, pthread_attr_t *attr, void *(*start_routine)(void *), void *data);
71 #endif /* __linux__ */
73 extern char *ast_strcasestr(const char *, const char *);