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

« back to all changes in this revision

Viewing changes to srclib/apr-util/include/apr_optional.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 2001-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_OPTIONAL_H
 
18
#define APR_OPTIONAL_H
 
19
 
 
20
#include "apu.h"
 
21
/** 
 
22
 * @file apr_optional.h
 
23
 * @brief APR-UTIL registration of functions exported by modules
 
24
 */
 
25
#ifdef __cplusplus
 
26
extern "C" {
 
27
#endif
 
28
 
 
29
/** 
 
30
 * @defgroup APR_Util_Opt Optional Functions
 
31
 * @ingroup APR_Util
 
32
 *
 
33
 * Typesafe registration and retrieval of functions that may not be present
 
34
 * (i.e. functions exported by optional modules)
 
35
 * @{
 
36
 */
 
37
 
 
38
/**
 
39
 * The type of an optional function.
 
40
 * @param name The name of the function
 
41
 */
 
42
#define APR_OPTIONAL_FN_TYPE(name) apr_OFN_##name##_t
 
43
 
 
44
/**
 
45
 * Declare an optional function.
 
46
 * @param ret The return type of the function
 
47
 * @param name The name of the function
 
48
 * @param args The function arguments (including brackets)
 
49
 */
 
50
#define APR_DECLARE_OPTIONAL_FN(ret,name,args) \
 
51
typedef ret (APR_OPTIONAL_FN_TYPE(name)) args
 
52
 
 
53
/**
 
54
 * XXX: This doesn't belong here, then!
 
55
 * Private function! DO NOT USE! 
 
56
 * @internal
 
57
 */
 
58
 
 
59
typedef void (apr_opt_fn_t)(void);
 
60
/** @internal */
 
61
APU_DECLARE_NONSTD(void) apr_dynamic_fn_register(const char *szName, 
 
62
                                                  apr_opt_fn_t *pfn);
 
63
 
 
64
/**
 
65
 * Register an optional function. This can be later retrieved, type-safely, by
 
66
 * name. Like all global functions, the name must be unique. Note that,
 
67
 * confusingly but correctly, the function itself can be static!
 
68
 * @param name The name of the function
 
69
 */
 
70
#define APR_REGISTER_OPTIONAL_FN(name) do { \
 
71
  APR_OPTIONAL_FN_TYPE(name) *apu__opt = name; \
 
72
  apr_dynamic_fn_register(#name,(apr_opt_fn_t *)apu__opt); \
 
73
} while (0)
 
74
 
 
75
/** @internal
 
76
 * Private function! DO NOT USE! 
 
77
 */
 
78
APU_DECLARE(apr_opt_fn_t *) apr_dynamic_fn_retrieve(const char *szName);
 
79
 
 
80
/**
 
81
 * Retrieve an optional function. Returns NULL if the function is not present.
 
82
 * @param name The name of the function
 
83
 */
 
84
#define APR_RETRIEVE_OPTIONAL_FN(name) \
 
85
        (APR_OPTIONAL_FN_TYPE(name) *)apr_dynamic_fn_retrieve(#name)
 
86
 
 
87
/** @} */
 
88
#ifdef __cplusplus
 
89
}
 
90
#endif
 
91
 
 
92
#endif /* APR_OPTIONAL_H */