~ubuntu-branches/ubuntu/feisty/apache2/feisty

« back to all changes in this revision

Viewing changes to srclib/apr/include/apr_general.h

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Barth
  • Date: 2006-12-09 21:05:45 UTC
  • mfrom: (0.6.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20061209210545-h70s0xaqc2v8vqr2
Tags: 2.2.3-3.2
* Non-maintainer upload.
* 043_ajp_connection_reuse: Patch from upstream Bugzilla, fixing a critical
  issue with regard to connection reuse in mod_proxy_ajp.
  Closes: #396265

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as
 
2
 * applicable.
 
3
 *
 
4
 * Licensed under the Apache License, Version 2.0 (the "License");
 
5
 * you may not use this file except in compliance with the License.
 
6
 * 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
 
 
20
/**
 
21
 * @file apr_general.h
 
22
 * This is collection of oddballs that didn't fit anywhere else,
 
23
 * and might move to more appropriate headers with the release
 
24
 * of APR 1.0.
 
25
 * @brief APR Miscellaneous library routines
 
26
 */
 
27
 
 
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
 
 
40
/**
 
41
 * @defgroup apr_general Miscellaneous library routines
 
42
 * @ingroup APR 
 
43
 * This is collection of oddballs that didn't fit anywhere else,
 
44
 * and might move to more appropriate headers with the release
 
45
 * of APR 1.0.
 
46
 * @{
 
47
 */
 
48
 
 
49
/** FALSE */
 
50
#ifndef FALSE
 
51
#define FALSE 0
 
52
#endif
 
53
/** TRUE */
 
54
#ifndef TRUE
 
55
#define TRUE (!FALSE)
 
56
#endif
 
57
 
 
58
/** a space */
 
59
#define APR_ASCII_BLANK  '\040'
 
60
/** a carrige return */
 
61
#define APR_ASCII_CR     '\015'
 
62
/** a line feed */
 
63
#define APR_ASCII_LF     '\012'
 
64
/** a tab */
 
65
#define APR_ASCII_TAB    '\011'
 
66
 
 
67
/** signal numbers typedef */
 
68
typedef int               apr_signum_t;
 
69
 
 
70
/**
 
71
 * Finding offsets of elements within structures.
 
72
 * Taken from the X code... they've sweated portability of this stuff
 
73
 * so we don't have to.  Sigh...
 
74
 * @param p_type pointer type name
 
75
 * @param field  data field within the structure pointed to
 
76
 * @return offset
 
77
 */
 
78
 
 
79
#if defined(CRAY) || (defined(__arm) && !defined(LINUX))
 
80
#ifdef __STDC__
 
81
#define APR_OFFSET(p_type,field) _Offsetof(p_type,field)
 
82
#else
 
83
#ifdef CRAY2
 
84
#define APR_OFFSET(p_type,field) \
 
85
        (sizeof(int)*((unsigned int)&(((p_type)NULL)->field)))
 
86
 
 
87
#else /* !CRAY2 */
 
88
 
 
89
#define APR_OFFSET(p_type,field) ((unsigned int)&(((p_type)NULL)->field))
 
90
 
 
91
#endif /* !CRAY2 */
 
92
#endif /* __STDC__ */
 
93
#else /* ! (CRAY || __arm) */
 
94
 
 
95
#define APR_OFFSET(p_type,field) \
 
96
        ((long) (((char *) (&(((p_type)NULL)->field))) - ((char *) NULL)))
 
97
 
 
98
#endif /* !CRAY */
 
99
 
 
100
/**
 
101
 * Finding offsets of elements within structures.
 
102
 * @param s_type structure type name
 
103
 * @param field  data field within the structure
 
104
 * @return offset
 
105
 */
 
106
#if defined(offsetof) && !defined(__cplusplus)
 
107
#define APR_OFFSETOF(s_type,field) offsetof(s_type,field)
 
108
#else
 
109
#define APR_OFFSETOF(s_type,field) APR_OFFSET(s_type*,field)
 
110
#endif
 
111
 
 
112
#ifndef DOXYGEN
 
113
 
 
114
/* A couple of prototypes for functions in case some platform doesn't 
 
115
 * have it
 
116
 */
 
117
#if (!APR_HAVE_STRCASECMP) && (APR_HAVE_STRICMP) 
 
118
#define strcasecmp(s1, s2) stricmp(s1, s2)
 
119
#elif (!APR_HAVE_STRCASECMP)
 
120
int strcasecmp(const char *a, const char *b);
 
121
#endif
 
122
 
 
123
#if (!APR_HAVE_STRNCASECMP) && (APR_HAVE_STRNICMP)
 
124
#define strncasecmp(s1, s2, n) strnicmp(s1, s2, n)
 
125
#elif (!APR_HAVE_STRNCASECMP)
 
126
int strncasecmp(const char *a, const char *b, size_t n);
 
127
#endif
 
128
 
 
129
#endif
 
130
 
 
131
/**
 
132
 * Alignment macros
 
133
 */
 
134
 
 
135
/* APR_ALIGN() is only to be used to align on a power of 2 boundary */
 
136
#define APR_ALIGN(size, boundary) \
 
137
    (((size) + ((boundary) - 1)) & ~((boundary) - 1))
 
138
 
 
139
/** Default alignment */
 
140
#define APR_ALIGN_DEFAULT(size) APR_ALIGN(size, 8)
 
141
 
 
142
 
 
143
/**
 
144
 * String and memory functions
 
145
 */
 
146
 
 
147
/* APR_STRINGIFY is defined here, and also in apr_release.h, so wrap it */
 
148
#ifndef APR_STRINGIFY
 
149
/** Properly quote a value as a string in the C preprocessor */
 
150
#define APR_STRINGIFY(n) APR_STRINGIFY_HELPER(n)
 
151
/** Helper macro for APR_STRINGIFY */
 
152
#define APR_STRINGIFY_HELPER(n) #n
 
153
#endif
 
154
 
 
155
#if (!APR_HAVE_MEMMOVE)
 
156
#define memmove(a,b,c) bcopy(b,a,c)
 
157
#endif
 
158
 
 
159
#if (!APR_HAVE_MEMCHR)
 
160
void *memchr(const void *s, int c, size_t n);
 
161
#endif
 
162
 
 
163
/** @} */
 
164
 
 
165
/**
 
166
 * @defgroup apr_library Library initialization and termination
 
167
 * @{
 
168
 */
 
169
 
 
170
/**
 
171
 * Setup any APR internal data structures.  This MUST be the first function 
 
172
 * called for any APR library.
 
173
 * @remark See apr_app_initialize if this is an application, rather than
 
174
 * a library consumer of apr.
 
175
 */
 
176
APR_DECLARE(apr_status_t) apr_initialize(void);
 
177
 
 
178
/**
 
179
 * Set up an application with normalized argc, argv (and optionally env) in
 
180
 * order to deal with platform-specific oddities, such as Win32 services,
 
181
 * code pages and signals.  This must be the first function called for any
 
182
 * APR program.
 
183
 * @param argc Pointer to the argc that may be corrected
 
184
 * @param argv Pointer to the argv that may be corrected
 
185
 * @param env Pointer to the env that may be corrected, may be NULL
 
186
 * @remark See apr_initialize if this is a library consumer of apr.
 
187
 * Otherwise, this call is identical to apr_initialize, and must be closed
 
188
 * with a call to apr_terminate at the end of program execution.
 
189
 */
 
190
APR_DECLARE(apr_status_t) apr_app_initialize(int *argc, 
 
191
                                             char const * const * *argv, 
 
192
                                             char const * const * *env);
 
193
 
 
194
/**
 
195
 * Tear down any APR internal data structures which aren't torn down 
 
196
 * automatically.
 
197
 * @remark An APR program must call this function at termination once it 
 
198
 *         has stopped using APR services.  The APR developers suggest using
 
199
 *         atexit to ensure this is called.  When using APR from a language
 
200
 *         other than C that has problems with the calling convention, use
 
201
 *         apr_terminate2() instead.
 
202
 */
 
203
APR_DECLARE_NONSTD(void) apr_terminate(void);
 
204
 
 
205
/**
 
206
 * Tear down any APR internal data structures which aren't torn down 
 
207
 * automatically, same as apr_terminate
 
208
 * @remark An APR program must call either the apr_terminate or apr_terminate2 
 
209
 *         function once it it has finished using APR services.  The APR 
 
210
 *         developers suggest using atexit(apr_terminate) to ensure this is done.
 
211
 *         apr_terminate2 exists to allow non-c language apps to tear down apr, 
 
212
 *         while apr_terminate is recommended from c language applications.
 
213
 */
 
214
APR_DECLARE(void) apr_terminate2(void);
 
215
 
 
216
/** @} */
 
217
 
 
218
/**
 
219
 * @defgroup apr_random Random Functions
 
220
 * @{
 
221
 */
 
222
 
 
223
#if APR_HAS_RANDOM || defined(DOXYGEN)
 
224
 
 
225
/* TODO: I'm not sure this is the best place to put this prototype...*/
 
226
/**
 
227
 * Generate random bytes.
 
228
 * @param buf Buffer to fill with random bytes
 
229
 * @param length Length of buffer in bytes
 
230
 */
 
231
APR_DECLARE(apr_status_t) apr_generate_random_bytes(unsigned char * buf, 
 
232
                                                    apr_size_t length);
 
233
 
 
234
#endif
 
235
/** @} */
 
236
 
 
237
#ifdef __cplusplus
 
238
}
 
239
#endif
 
240
 
 
241
#endif  /* ! APR_GENERAL_H */