Sat Aug 6 00:39:31 2011

Asterisk developer's documentation


private.h

Go to the documentation of this file.
00001 #ifndef PRIVATE_H
00002 
00003 #define PRIVATE_H
00004 
00005 /*
00006 ** This file is in the public domain, so clarified as of
00007 ** 1996-06-05 by Arthur David Olson.
00008 */
00009 
00010 /*
00011 ** This header is for use ONLY with the time conversion code.
00012 ** There is no guarantee that it will remain unchanged,
00013 ** or that it will remain at all.
00014 ** Do NOT copy it to any system include directory.
00015 ** Thank you!
00016 */
00017 
00018 /*
00019 ** ID
00020 */
00021 
00022 #ifndef lint
00023 #ifndef NOID
00024 static char __attribute__((unused)) privatehid[] = "@(#)private.h 8.3";
00025 #endif /* !defined NOID */
00026 #endif /* !defined lint */
00027 
00028 #define GRANDPARENTED   "Local time zone must be set--see zic manual page"
00029 
00030 /*
00031 ** Defaults for preprocessor symbols.
00032 ** You can override these in your C compiler options, e.g. `-DHAVE_ADJTIME=0'.
00033 */
00034 
00035 #ifndef HAVE_ADJTIME
00036 #define HAVE_ADJTIME    1
00037 #endif /* !defined HAVE_ADJTIME */
00038 
00039 #ifndef HAVE_GETTEXT
00040 #define HAVE_GETTEXT    0
00041 #endif /* !defined HAVE_GETTEXT */
00042 
00043 #ifndef HAVE_INCOMPATIBLE_CTIME_R
00044 #define HAVE_INCOMPATIBLE_CTIME_R   0
00045 #endif /* !defined INCOMPATIBLE_CTIME_R */
00046 
00047 #ifndef HAVE_SETTIMEOFDAY
00048 #define HAVE_SETTIMEOFDAY  3
00049 #endif /* !defined HAVE_SETTIMEOFDAY */
00050 
00051 #ifndef HAVE_STRERROR
00052 #define HAVE_STRERROR      1
00053 #endif /* !defined HAVE_STRERROR */
00054 
00055 #ifndef HAVE_SYMLINK
00056 #define HAVE_SYMLINK    1
00057 #endif /* !defined HAVE_SYMLINK */
00058 
00059 #ifndef HAVE_SYS_STAT_H
00060 #define HAVE_SYS_STAT_H    1
00061 #endif /* !defined HAVE_SYS_STAT_H */
00062 
00063 #ifndef HAVE_SYS_WAIT_H
00064 #define HAVE_SYS_WAIT_H    1
00065 #endif /* !defined HAVE_SYS_WAIT_H */
00066 
00067 #ifndef HAVE_UNISTD_H
00068 #define HAVE_UNISTD_H      1
00069 #endif /* !defined HAVE_UNISTD_H */
00070 
00071 #ifndef HAVE_UTMPX_H
00072 #define HAVE_UTMPX_H    0
00073 #endif /* !defined HAVE_UTMPX_H */
00074 
00075 #ifndef LOCALE_HOME
00076 #define LOCALE_HOME     "/usr/lib/locale"
00077 #endif /* !defined LOCALE_HOME */
00078 
00079 #if HAVE_INCOMPATIBLE_CTIME_R
00080 #define asctime_r _incompatible_asctime_r
00081 #define ctime_r _incompatible_ctime_r
00082 #endif /* HAVE_INCOMPATIBLE_CTIME_R */
00083 
00084 /*
00085 ** Nested includes
00086 */
00087 
00088 #include "sys/types.h"  /* for time_t */
00089 #include "stdio.h"
00090 #include "errno.h"
00091 #include "string.h"
00092 #include "limits.h"  /* for CHAR_BIT et al. */
00093 #include "time.h"
00094 #include "stdlib.h"
00095 
00096 #if HAVE_GETTEXT
00097 #include "libintl.h"
00098 #endif /* HAVE_GETTEXT */
00099 
00100 #if HAVE_SYS_WAIT_H
00101 #include <sys/wait.h>   /* for WIFEXITED and WEXITSTATUS */
00102 #endif /* HAVE_SYS_WAIT_H */
00103 
00104 #ifndef WIFEXITED
00105 #define WIFEXITED(status)  (((status) & 0xff) == 0)
00106 #endif /* !defined WIFEXITED */
00107 #ifndef WEXITSTATUS
00108 #define WEXITSTATUS(status)   (((status) >> 8) & 0xff)
00109 #endif /* !defined WEXITSTATUS */
00110 
00111 #if HAVE_UNISTD_H
00112 #include "unistd.h"  /* for F_OK and R_OK */
00113 #endif /* HAVE_UNISTD_H */
00114 
00115 #if !HAVE_UNISTD_H
00116 #ifndef F_OK
00117 #define F_OK   0
00118 #endif /* !defined F_OK */
00119 #ifndef R_OK
00120 #define R_OK   4
00121 #endif /* !defined R_OK */
00122 #endif /* !HAVE_UNISTD_H */
00123 
00124 /* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX. */
00125 #define is_digit(c) ((unsigned)(c) - '0' <= 9)
00126 
00127 /*
00128 ** Define HAVE_STDINT_H's default value here, rather than at the
00129 ** start, since __GLIBC__'s value depends on previously-included
00130 ** files.
00131 ** (glibc 2.1 and later have stdint.h, even with pre-C99 compilers.)
00132 */
00133 #ifndef HAVE_STDINT_H
00134 #define HAVE_STDINT_H \
00135    (199901 <= __STDC_VERSION__ || \
00136    2 < (__GLIBC__ + (0 < __GLIBC_MINOR__)))
00137 #endif /* !defined HAVE_STDINT_H */
00138 
00139 #if HAVE_STDINT_H
00140 #include "stdint.h"
00141 #endif /* !HAVE_STDINT_H */
00142 
00143 #ifndef INT_FAST64_MAX
00144 /* Pre-C99 GCC compilers define __LONG_LONG_MAX__ instead of LLONG_MAX.  */
00145 #if defined LLONG_MAX || defined __LONG_LONG_MAX__
00146 typedef long long int_fast64_t;
00147 #else /* ! (defined LLONG_MAX || defined __LONG_LONG_MAX__) */
00148 #if (LONG_MAX >> 31) < 0xffffffff
00149 Please use a compiler that supports a 64-bit integer type (or wider);
00150 you may need to compile with "-DHAVE_STDINT_H".
00151 #endif /* (LONG_MAX >> 31) < 0xffffffff */
00152 typedef long      int_fast64_t;
00153 #endif /* ! (defined LLONG_MAX || defined __LONG_LONG_MAX__) */
00154 #endif /* !defined INT_FAST64_MAX */
00155 
00156 #ifndef INT32_MAX
00157 #define INT32_MAX 0x7fffffff
00158 #endif /* !defined INT32_MAX */
00159 #ifndef INT32_MIN
00160 #define INT32_MIN (-1 - INT32_MAX)
00161 #endif /* !defined INT32_MIN */
00162 
00163 /*
00164 ** Workarounds for compilers/systems.
00165 */
00166 
00167 /*
00168 ** If your compiler lacks prototypes, "#define P(x) ()".
00169 */
00170 
00171 #ifndef P
00172 #define P(x)   x
00173 #endif /* !defined P */
00174 
00175 /*
00176 ** SunOS 4.1.1 headers lack EXIT_SUCCESS.
00177 */
00178 
00179 #ifndef EXIT_SUCCESS
00180 #define EXIT_SUCCESS 0
00181 #endif /* !defined EXIT_SUCCESS */
00182 
00183 /*
00184 ** SunOS 4.1.1 headers lack EXIT_FAILURE.
00185 */
00186 
00187 #ifndef EXIT_FAILURE
00188 #define EXIT_FAILURE 1
00189 #endif /* !defined EXIT_FAILURE */
00190 
00191 /*
00192 ** SunOS 4.1.1 headers lack FILENAME_MAX.
00193 */
00194 
00195 #ifndef FILENAME_MAX
00196 
00197 #ifndef MAXPATHLEN
00198 #ifdef unix
00199 #include "sys/param.h"
00200 #endif /* defined unix */
00201 #endif /* !defined MAXPATHLEN */
00202 
00203 #ifdef MAXPATHLEN
00204 #define FILENAME_MAX MAXPATHLEN
00205 #endif /* defined MAXPATHLEN */
00206 #ifndef MAXPATHLEN
00207 #define FILENAME_MAX 1024     /* Pure guesswork */
00208 #endif /* !defined MAXPATHLEN */
00209 
00210 #endif /* !defined FILENAME_MAX */
00211 
00212 /*
00213 ** SunOS 4.1.1 libraries lack remove.
00214 */
00215 
00216 #ifndef remove
00217 extern int  unlink P((const char * filename));
00218 #define remove unlink
00219 #endif /* !defined remove */
00220 
00221 /*
00222 ** Some ancient errno.h implementations don't declare errno.
00223 ** But some newer errno.h implementations define it as a macro.
00224 ** Fix the former without affecting the latter.
00225 */
00226 
00227 #ifndef errno
00228 extern int errno;
00229 #endif /* !defined errno */
00230 
00231 /*
00232 ** Private function declarations.
00233 */
00234 
00235 char *      icalloc P((int nelem, int elsize));
00236 char *      icatalloc P((char * old, const char * new));
00237 char *      icpyalloc P((const char * string));
00238 char *      imalloc P((int n));
00239 void *      irealloc P((void * pointer, int size));
00240 void     icfree P((char * pointer));
00241 void     ifree P((char * pointer));
00242 const char *   scheck P((const char * string, const char * format));
00243 
00244 /*
00245 ** Finally, some convenience items.
00246 */
00247 
00248 #ifndef TRUE
00249 #define TRUE   1
00250 #endif /* !defined TRUE */
00251 
00252 #ifndef FALSE
00253 #define FALSE  0
00254 #endif /* !defined FALSE */
00255 
00256 #ifndef TYPE_BIT
00257 #define TYPE_BIT(type)  (sizeof (type) * CHAR_BIT)
00258 #endif /* !defined TYPE_BIT */
00259 
00260 #ifndef TYPE_SIGNED
00261 #define TYPE_SIGNED(type) (((type) -1) < 0)
00262 #endif /* !defined TYPE_SIGNED */
00263 
00264 /*
00265 ** Since the definition of TYPE_INTEGRAL contains floating point numbers,
00266 ** it cannot be used in preprocessor directives.
00267 */
00268 
00269 #ifndef TYPE_INTEGRAL
00270 #define TYPE_INTEGRAL(type) (((type) 0.5) != 0.5)
00271 #endif /* !defined TYPE_INTEGRAL */
00272 
00273 #ifndef INT_STRLEN_MAXIMUM
00274 /*
00275 ** 302 / 1000 is log10(2.0) rounded up.
00276 ** Subtract one for the sign bit if the type is signed;
00277 ** add one for integer division truncation;
00278 ** add one more for a minus sign if the type is signed.
00279 */
00280 #define INT_STRLEN_MAXIMUM(type) \
00281    ((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + \
00282    1 + TYPE_SIGNED(type))
00283 #endif /* !defined INT_STRLEN_MAXIMUM */
00284 
00285 /*
00286 ** INITIALIZE(x)
00287 */
00288 
00289 #ifndef GNUC_or_lint
00290 #ifdef lint
00291 #define GNUC_or_lint
00292 #endif /* defined lint */
00293 #ifndef lint
00294 #ifdef __GNUC__
00295 #define GNUC_or_lint
00296 #endif /* defined __GNUC__ */
00297 #endif /* !defined lint */
00298 #endif /* !defined GNUC_or_lint */
00299 
00300 #ifndef INITIALIZE
00301 #ifdef GNUC_or_lint
00302 #define INITIALIZE(x)   ((x) = 0)
00303 #endif /* defined GNUC_or_lint */
00304 #ifndef GNUC_or_lint
00305 #define INITIALIZE(x)
00306 #endif /* !defined GNUC_or_lint */
00307 #endif /* !defined INITIALIZE */
00308 
00309 /*
00310 ** For the benefit of GNU folk...
00311 ** `_(MSGID)' uses the current locale's message library string for MSGID.
00312 ** The default is to use gettext if available, and use MSGID otherwise.
00313 */
00314 
00315 #ifndef _
00316 #if HAVE_GETTEXT
00317 #define _(msgid) gettext(msgid)
00318 #else /* !HAVE_GETTEXT */
00319 #define _(msgid) msgid
00320 #endif /* !HAVE_GETTEXT */
00321 #endif /* !defined _ */
00322 
00323 #ifndef TZ_DOMAIN
00324 #define TZ_DOMAIN "tz"
00325 #endif /* !defined TZ_DOMAIN */
00326 
00327 #if HAVE_INCOMPATIBLE_CTIME_R
00328 #undef asctime_r
00329 #undef ctime_r
00330 char *asctime_r P((struct tm const *, char *));
00331 char *ctime_r P((time_t const *, char *));
00332 #endif /* HAVE_INCOMPATIBLE_CTIME_R */
00333 
00334 #ifndef YEARSPERREPEAT
00335 #define YEARSPERREPEAT     400   /* years before a Gregorian repeat */
00336 #endif /* !defined YEARSPERREPEAT */
00337 
00338 /*
00339 ** The Gregorian year averages 365.2425 days, which is 31556952 seconds.
00340 */
00341 
00342 #ifndef AVGSECSPERYEAR
00343 #define AVGSECSPERYEAR     31556952L
00344 #endif /* !defined AVGSECSPERYEAR */
00345 
00346 #ifndef SECSPERREPEAT
00347 #define SECSPERREPEAT      ((int_fast64_t) YEARSPERREPEAT * (int_fast64_t) AVGSECSPERYEAR)
00348 #endif /* !defined SECSPERREPEAT */
00349 
00350 #ifndef SECSPERREPEAT_BITS
00351 #define SECSPERREPEAT_BITS 34 /* ceil(log2(SECSPERREPEAT)) */
00352 #endif /* !defined SECSPERREPEAT_BITS */
00353 
00354 /*
00355 ** UNIX was a registered trademark of The Open Group in 2003.
00356 */
00357 
00358 #endif /* !defined PRIVATE_H */

Generated on Sat Aug 6 00:39:31 2011 for Asterisk - the Open Source PBX by  doxygen 1.4.7