Wed Oct 28 11:51:02 2009

Asterisk developer's documentation


compat.h

Go to the documentation of this file.
00001 /*
00002  * Asterisk -- A telephony toolkit for Linux.
00003  * 
00004  * Copyright (C) 1999-2006, Digium, Inc.
00005  *
00006  * Mark Spencer <markster@digium.com>
00007  *
00008  * This program is free software, distributed under the terms of
00009  * the GNU General Public License
00010  */
00011 
00012 /*! \file
00013  * \brief General Definitions for Asterisk top level program
00014  * Included by asterisk.h to handle platform-specific issues
00015  * especially those related to header files.
00016  */
00017 
00018 #include "asterisk/compiler.h"
00019 
00020 #ifndef _COMPAT_H
00021 #define _COMPAT_H
00022 
00023 #ifndef __STDC_VERSION__
00024 /* flex output wants to find this defined. */
00025 #define  __STDC_VERSION__ 0
00026 #endif
00027 
00028 #ifdef HAVE_INTTYPES_H
00029 #include <inttypes.h>
00030 #endif
00031 
00032 #ifdef HAVE_LIMITS_H
00033 #include <limits.h>
00034 #endif
00035 
00036 #ifdef HAVE_UNISTD_H
00037 #include <unistd.h>
00038 #endif
00039 
00040 #ifdef HAVE_STDDEF_H
00041 #include <stddef.h>
00042 #endif
00043 
00044 #ifdef HAVE_STDINT_H
00045 #include <stdint.h>
00046 #endif
00047 
00048 #ifdef HAVE_SYS_TYPES_H
00049 #include <sys/types.h>
00050 #endif
00051 
00052 #include <stdarg.h>
00053 
00054 #ifdef HAVE_STDLIB_H
00055 #include <stdlib.h>
00056 #endif
00057 
00058 #ifdef HAVE_ALLOCA_H
00059 #include <alloca.h>    /* not necessarily present - could be in stdlib */
00060 #elif defined(HAVE_ALLOCA) && defined(__MINGW32__)
00061 #include <malloc.h>    /* see if it is here... */
00062 #endif
00063 
00064 #include <stdio.h>   /* this is always present */
00065 
00066 #ifdef HAVE_STRING_H
00067 #include <string.h>
00068 #endif
00069 
00070 #ifndef AST_POLL_COMPAT
00071 #include <sys/poll.h>
00072 #else
00073 #include "asterisk/poll-compat.h"
00074 #endif
00075 
00076 #if !defined(HAVE_ASPRINTF) && !defined(__AST_DEBUG_MALLOC)
00077 int __attribute__((format(printf, 2, 3))) asprintf(char **str, const char *fmt, ...);
00078 #endif
00079 
00080 #ifndef HAVE_GETLOADAVG
00081 int getloadavg(double *list, int nelem);
00082 #endif
00083 
00084 #ifndef HAVE_SETENV
00085 int setenv(const char *name, const char *value, int overwrite);
00086 #endif
00087 
00088 #ifndef HAVE_STRCASESTR
00089 char *strcasestr(const char *, const char *);
00090 #endif
00091 
00092 #if !defined(HAVE_STRNDUP) && !defined(__AST_DEBUG_MALLOC)
00093 char *strndup(const char *, size_t);
00094 #endif
00095 
00096 #ifndef HAVE_STRNLEN
00097 size_t strnlen(const char *, size_t);
00098 #endif
00099 
00100 #ifndef HAVE_STRSEP
00101 char* strsep(char** str, const char* delims);
00102 #endif
00103 
00104 #ifndef HAVE_STRTOQ
00105 uint64_t strtoq(const char *nptr, char **endptr, int base);
00106 #endif
00107 
00108 #ifndef HAVE_UNSETENV
00109 int unsetenv(const char *name);
00110 #endif
00111 
00112 #if !defined(HAVE_VASPRINTF) && !defined(__AST_DEBUG_MALLOC)
00113 int __attribute__((format(printf, 2, 0))) vasprintf(char **strp, const char *fmt, va_list ap);
00114 #endif
00115 
00116 #ifndef HAVE_STRLCAT
00117 size_t strlcat(char *dst, const char *src, size_t siz);
00118 #endif
00119 
00120 #ifndef HAVE_STRLCPY
00121 size_t strlcpy(char *dst, const char *src, size_t siz);
00122 #endif
00123 
00124 #include <errno.h>
00125 
00126 #ifdef SOLARIS
00127 #define __BEGIN_DECLS
00128 #define __END_DECLS
00129 
00130 #ifndef __P
00131 #define __P(p) p
00132 #endif
00133 
00134 #include <alloca.h>
00135 #include <strings.h>
00136 #include <string.h>
00137 #include <pthread.h>
00138 #include <sys/stat.h>
00139 #include <signal.h>
00140 #include <netinet/in.h>
00141 #include <sys/loadavg.h>
00142 #include <dat/dat_platform_specific.h>
00143 
00144 #ifndef BYTE_ORDER
00145 #define LITTLE_ENDIAN   1234
00146 #define BIG_ENDIAN   4321
00147 
00148 #ifdef __sparc__
00149 #define BYTE_ORDER   BIG_ENDIAN
00150 #else
00151 #define BYTE_ORDER   LITTLE_ENDIAN
00152 #endif
00153 #endif
00154 
00155 #ifndef __BYTE_ORDER
00156 #define __LITTLE_ENDIAN LITTLE_ENDIAN
00157 #define __BIG_ENDIAN BIG_ENDIAN
00158 #define __BYTE_ORDER BYTE_ORDER
00159 #endif
00160 
00161 #ifndef __BIT_TYPES_DEFINED__
00162 #define __BIT_TYPES_DEFINED__
00163 typedef unsigned char   u_int8_t;
00164 typedef unsigned short  u_int16_t;
00165 typedef unsigned int u_int32_t;
00166 typedef unsigned int uint;
00167 #endif
00168 
00169 #endif /* SOLARIS */
00170 
00171 #ifdef __CYGWIN__
00172 #define _WIN32_WINNT 0x0500
00173 #ifndef INET_ADDRSTRLEN
00174 #define INET_ADDRSTRLEN  16
00175 #endif
00176 #ifndef INET6_ADDRSTRLEN
00177 #define INET6_ADDRSTRLEN 46
00178 #endif
00179 #endif /* __CYGWIN__ */
00180 
00181 #ifdef __CYGWIN__
00182 typedef unsigned long long uint64_t;
00183 #endif
00184 
00185 /* glob compat stuff */
00186 #if defined(__Darwin__) || defined(__CYGWIN__)
00187 #define GLOB_ABORTED GLOB_ABEND
00188 #endif
00189 #include <glob.h>
00190 #if !defined(HAVE_GLOB_NOMAGIC) || !defined(HAVE_GLOB_BRACE)
00191 #define MY_GLOB_FLAGS   GLOB_NOCHECK
00192 #else
00193 #define MY_GLOB_FLAGS   (GLOB_NOMAGIC | GLOB_BRACE)
00194 #endif
00195 
00196 #endif

Generated on Wed Oct 28 11:51:02 2009 for Asterisk - the Open Source PBX by  doxygen 1.5.6