GME  13
apr_general.h
Go to the documentation of this file.
00001 /* Licensed to the Apache Software Foundation (ASF) under one or more
00002  * contributor license agreements.  See the NOTICE file distributed with
00003  * this work for additional information regarding copyright ownership.
00004  * The ASF licenses this file to You under the Apache License, Version 2.0
00005  * (the "License"); you may not use this file except in compliance with
00006  * the License.  You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #ifndef APR_GENERAL_H
00018 #define APR_GENERAL_H
00019 
00028 #include "apr.h"
00029 #include "apr_pools.h"
00030 #include "apr_errno.h"
00031 
00032 #if APR_HAVE_SIGNAL_H
00033 #include <signal.h>
00034 #endif
00035 
00036 #ifdef __cplusplus
00037 extern "C" {
00038 #endif /* __cplusplus */
00039 
00050 #ifndef FALSE
00051 #define FALSE 0
00052 #endif
00053 
00054 #ifndef TRUE
00055 #define TRUE (!FALSE)
00056 #endif
00057 
00059 #define APR_ASCII_BLANK  '\040'
00060 
00061 #define APR_ASCII_CR     '\015'
00062 
00063 #define APR_ASCII_LF     '\012'
00064 
00065 #define APR_ASCII_TAB    '\011'
00066 
00068 typedef int               apr_signum_t;
00069 
00079 #if defined(CRAY) || (defined(__arm) && !(defined(LINUX) || defined(__FreeBSD__)))
00080 #ifdef __STDC__
00081 #define APR_OFFSET(p_type,field) _Offsetof(p_type,field)
00082 #else
00083 #ifdef CRAY2
00084 #define APR_OFFSET(p_type,field) \
00085         (sizeof(int)*((unsigned int)&(((p_type)NULL)->field)))
00086 
00087 #else /* !CRAY2 */
00088 
00089 #define APR_OFFSET(p_type,field) ((unsigned int)&(((p_type)NULL)->field))
00090 
00091 #endif /* !CRAY2 */
00092 #endif /* __STDC__ */
00093 #else /* ! (CRAY || __arm) */
00094 
00095 #define APR_OFFSET(p_type,field) \
00096         ((long) (((char *) (&(((p_type)NULL)->field))) - ((char *) NULL)))
00097 
00098 #endif /* !CRAY */
00099 
00106 #if defined(offsetof) && !defined(__cplusplus)
00107 #define APR_OFFSETOF(s_type,field) offsetof(s_type,field)
00108 #else
00109 #define APR_OFFSETOF(s_type,field) APR_OFFSET(s_type*,field)
00110 #endif
00111 
00112 #ifndef DOXYGEN
00113 
00114 /* A couple of prototypes for functions in case some platform doesn't 
00115  * have it
00116  */
00117 #if (!APR_HAVE_STRCASECMP) && (APR_HAVE_STRICMP) 
00118 #define strcasecmp(s1, s2) stricmp(s1, s2)
00119 #elif (!APR_HAVE_STRCASECMP)
00120 int strcasecmp(const char *a, const char *b);
00121 #endif
00122 
00123 #if (!APR_HAVE_STRNCASECMP) && (APR_HAVE_STRNICMP)
00124 #define strncasecmp(s1, s2, n) strnicmp(s1, s2, n)
00125 #elif (!APR_HAVE_STRNCASECMP)
00126 int strncasecmp(const char *a, const char *b, size_t n);
00127 #endif
00128 
00129 #endif
00130 
00135 /* APR_ALIGN() is only to be used to align on a power of 2 boundary */
00136 #define APR_ALIGN(size, boundary) \
00137     (((size) + ((boundary) - 1)) & ~((boundary) - 1))
00138 
00140 #define APR_ALIGN_DEFAULT(size) APR_ALIGN(size, 8)
00141 
00142 
00147 /* APR_STRINGIFY is defined here, and also in apr_release.h, so wrap it */
00148 #ifndef APR_STRINGIFY
00149 
00150 #define APR_STRINGIFY(n) APR_STRINGIFY_HELPER(n)
00151 
00152 #define APR_STRINGIFY_HELPER(n) #n
00153 #endif
00154 
00155 #if (!APR_HAVE_MEMMOVE)
00156 #define memmove(a,b,c) bcopy(b,a,c)
00157 #endif
00158 
00159 #if (!APR_HAVE_MEMCHR)
00160 void *memchr(const void *s, int c, size_t n);
00161 #endif
00162 
00177 APR_DECLARE(apr_status_t) apr_initialize(void);
00178 
00191 APR_DECLARE(apr_status_t) apr_app_initialize(int *argc, 
00192                                              char const * const * *argv, 
00193                                              char const * const * *env);
00194 
00205 APR_DECLARE_NONSTD(void) apr_terminate(void);
00206 
00216 APR_DECLARE(void) apr_terminate2(void);
00217 
00225 #if APR_HAS_RANDOM || defined(DOXYGEN)
00226 
00227 /* TODO: I'm not sure this is the best place to put this prototype...*/
00233 APR_DECLARE(apr_status_t) apr_generate_random_bytes(unsigned char * buf, 
00234                                                     apr_size_t length);
00235 
00236 #endif
00237 
00239 #ifdef __cplusplus
00240 }
00241 #endif
00242 
00243 #endif  /* ! APR_GENERAL_H */