Apache2
apr_general.h
Go to the documentation of this file.
1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2  * contributor license agreements. See the NOTICE file distributed with
3  * this work for additional information regarding copyright ownership.
4  * The ASF licenses this file to You under the Apache License, Version 2.0
5  * (the "License"); you may not use this file except in compliance with
6  * the License. You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef APR_GENERAL_H
18 #define APR_GENERAL_H
19 
28 #include "apr.h"
29 #include "apr_pools.h"
30 #include "apr_errno.h"
31 
32 #if APR_HAVE_SIGNAL_H
33 #include <signal.h>
34 #endif
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif /* __cplusplus */
39 
50 #ifndef FALSE
51 #define FALSE 0
52 #endif
54 #ifndef TRUE
55 #define TRUE (!FALSE)
56 #endif
57 
59 #define APR_ASCII_BLANK '\040'
61 #define APR_ASCII_CR '\015'
63 #define APR_ASCII_LF '\012'
65 #define APR_ASCII_TAB '\011'
66 
68 typedef int apr_signum_t;
69 
70 /* Type of I/O to wait for */
72 
82 #if defined(CRAY) || (defined(__arm) && !(defined(LINUX) || defined(__FreeBSD__)))
83 #ifdef __STDC__
84 #define APR_OFFSET(p_type,field) _Offsetof(p_type,field)
85 #else
86 #ifdef CRAY2
87 #define APR_OFFSET(p_type,field) \
88  (sizeof(int)*((unsigned int)&(((p_type)NULL)->field)))
89 
90 #else /* !CRAY2 */
91 
92 #define APR_OFFSET(p_type,field) ((unsigned int)&(((p_type)NULL)->field))
93 
94 #endif /* !CRAY2 */
95 #endif /* __STDC__ */
96 #else /* ! (CRAY || __arm) */
97 
98 #define APR_OFFSET(p_type,field) \
99  ((long) (((char *) (&(((p_type)NULL)->field))) - ((char *) NULL)))
100 
101 #endif /* !CRAY */
102 
109 #if defined(__has_builtin)
110 #if __has_builtin(__builtin_offsetof)
111 #define APR_OFFSETOF(s_type,field) __builtin_offsetof(s_type,field)
112 #endif
113 #endif /* __has_builtin */
114 #ifndef APR_OFFSETOF
115 #if defined(offsetof) && !defined(__cplusplus)
116 #define APR_OFFSETOF(s_type,field) offsetof(s_type,field)
117 #else
118 #define APR_OFFSETOF(s_type,field) APR_OFFSET(s_type*,field)
119 #endif
120 #endif /* ndef APR_OFFSETOF */
121 
122 #ifndef DOXYGEN
123 
124 /* A couple of prototypes for functions in case some platform doesn't
125  * have it
126  */
127 #if (!APR_HAVE_STRCASECMP) && (APR_HAVE_STRICMP)
128 #define strcasecmp(s1, s2) stricmp(s1, s2)
129 #elif (!APR_HAVE_STRCASECMP)
130 int strcasecmp(const char *a, const char *b);
131 #endif
132 
133 #if (!APR_HAVE_STRNCASECMP) && (APR_HAVE_STRNICMP)
134 #define strncasecmp(s1, s2, n) strnicmp(s1, s2, n)
135 #elif (!APR_HAVE_STRNCASECMP)
136 int strncasecmp(const char *a, const char *b, size_t n);
137 #endif
138 
139 #endif
140 
145 /* APR_ALIGN() is only to be used to align on a power of 2 boundary */
146 #define APR_ALIGN(size, boundary) \
147  (((size) + ((boundary) - 1)) & ~((boundary) - 1))
148 
150 #define APR_ALIGN_DEFAULT(size) APR_ALIGN(size, 8)
151 
152 
157 /* APR_STRINGIFY is defined here, and also in apr_release.h, so wrap it */
158 #ifndef APR_STRINGIFY
160 #define APR_STRINGIFY(n) APR_STRINGIFY_HELPER(n)
162 #define APR_STRINGIFY_HELPER(n) #n
163 #endif
164 
165 #if (!APR_HAVE_MEMMOVE)
166 #define memmove(a,b,c) bcopy(b,a,c)
167 #endif
168 
169 #if (!APR_HAVE_MEMCHR)
170 void *memchr(const void *s, int c, size_t n);
171 #endif
172 
177 #define APR_TYPEDEF_STRUCT(type, incompletion) \
178 struct type { \
179  incompletion \
180  void *unk[]; \
181 };
182 
198 
212  char const * const * *argv,
213  char const * const * *env);
214 
227 
238 
246 #if APR_HAS_RANDOM || defined(DOXYGEN)
247 
248 /* TODO: I'm not sure this is the best place to put this prototype...*/
255  apr_size_t length);
256 
257 #endif
260 #ifdef __cplusplus
261 }
262 #endif
263 
264 #endif /* ! APR_GENERAL_H */
APR Platform Definitions.
APR Error Codes.
APR memory allocation.
const char * s
Definition: mod_dav.h:1332
int apr_status_t
Definition: apr_errno.h:44
apr_wait_type_t
Definition: apr_general.h:71
int apr_signum_t
Definition: apr_general.h:68
@ APR_WAIT_WRITE
Definition: apr_general.h:71
@ APR_WAIT_READ
Definition: apr_general.h:71
void apr_terminate2(void)
apr_status_t apr_initialize(void)
void apr_terminate(void)
apr_status_t apr_app_initialize(int *argc, char const *const **argv, char const *const **env)
size_t apr_size_t
Definition: apr.h:401
apr_status_t apr_generate_random_bytes(unsigned char *buf, apr_size_t length)
#define APR_DECLARE(x)
Definition: macros.h:6
#define APR_DECLARE_NONSTD(x)
Definition: macros.h:7