Apache2
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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
53 
54 #ifndef TRUE
55 #define TRUE (!FALSE)
56 #endif
57 
59 #define APR_ASCII_BLANK '\040'
60 
61 #define APR_ASCII_CR '\015'
62 
63 #define APR_ASCII_LF '\012'
64 
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(offsetof) && !defined(__cplusplus)
110 #define APR_OFFSETOF(s_type,field) offsetof(s_type,field)
111 #else
112 #define APR_OFFSETOF(s_type,field) APR_OFFSET(s_type*,field)
113 #endif
114 
115 #ifndef DOXYGEN
116 
117 /* A couple of prototypes for functions in case some platform doesn't
118  * have it
119  */
120 #if (!APR_HAVE_STRCASECMP) && (APR_HAVE_STRICMP)
121 #define strcasecmp(s1, s2) stricmp(s1, s2)
122 #elif (!APR_HAVE_STRCASECMP)
123 int strcasecmp(const char *a, const char *b);
124 #endif
125 
126 #if (!APR_HAVE_STRNCASECMP) && (APR_HAVE_STRNICMP)
127 #define strncasecmp(s1, s2, n) strnicmp(s1, s2, n)
128 #elif (!APR_HAVE_STRNCASECMP)
129 int strncasecmp(const char *a, const char *b, size_t n);
130 #endif
131 
132 #endif
133 
138 /* APR_ALIGN() is only to be used to align on a power of 2 boundary */
139 #define APR_ALIGN(size, boundary) \
140  (((size) + ((boundary) - 1)) & ~((boundary) - 1))
141 
143 #define APR_ALIGN_DEFAULT(size) APR_ALIGN(size, 8)
144 
145 
150 /* APR_STRINGIFY is defined here, and also in apr_release.h, so wrap it */
151 #ifndef APR_STRINGIFY
152 
153 #define APR_STRINGIFY(n) APR_STRINGIFY_HELPER(n)
154 
155 #define APR_STRINGIFY_HELPER(n) #n
156 #endif
157 
158 #if (!APR_HAVE_MEMMOVE)
159 #define memmove(a,b,c) bcopy(b,a,c)
160 #endif
161 
162 #if (!APR_HAVE_MEMCHR)
163 void *memchr(const void *s, int c, size_t n);
164 #endif
165 
170 #define APR_TYPEDEF_STRUCT(type, incompletion) \
171 struct type { \
172  incompletion \
173  void *unk[]; \
174 };
175 
191 
205  char const * const * *argv,
206  char const * const * *env);
207 
220 
230 APR_DECLARE(void) apr_terminate2(void);
231 
239 #if APR_HAS_RANDOM || defined(DOXYGEN)
240 
241 /* TODO: I'm not sure this is the best place to put this prototype...*/
248  apr_size_t length);
249 
250 #endif
251 
253 #ifdef __cplusplus
254 }
255 #endif
256 
257 #endif /* ! APR_GENERAL_H */
size_t apr_size_t
Definition: apr.h:375
int apr_signum_t
Definition: apr_general.h:68
apr_status_t apr_generate_random_bytes(unsigned char *buf, apr_size_t length)
#define APR_DECLARE_NONSTD(x)
Definition: macros.h:7
apr_status_t apr_app_initialize(int *argc, char const *const **argv, char const *const **env)
Definition: apr_general.h:71
APR memory allocation.
void apr_terminate2(void)
apr_status_t apr_initialize(void)
APR Error Codes.
APR Platform Definitions.
apr_wait_type_t
Definition: apr_general.h:71
#define APR_DECLARE(x)
Definition: macros.h:6
int apr_status_t
Definition: apr_errno.h:44
void apr_terminate(void)
Definition: apr_general.h:71