Apache2
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
mod_dbd.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 
31 #ifndef DBD_H
32 #define DBD_H
33 
34 /* Create a set of DBD_DECLARE(type), DBD_DECLARE_NONSTD(type) and
35  * DBD_DECLARE_DATA with appropriate export and import tags for the platform
36  */
37 #if !defined(WIN32)
38 #define DBD_DECLARE(type) type
39 #define DBD_DECLARE_NONSTD(type) type
40 #define DBD_DECLARE_DATA
41 #elif defined(DBD_DECLARE_STATIC)
42 #define DBD_DECLARE(type) type __stdcall
43 #define DBD_DECLARE_NONSTD(type) type
44 #define DBD_DECLARE_DATA
45 #elif defined(DBD_DECLARE_EXPORT)
46 #define DBD_DECLARE(type) __declspec(dllexport) type __stdcall
47 #define DBD_DECLARE_NONSTD(type) __declspec(dllexport) type
48 #define DBD_DECLARE_DATA __declspec(dllexport)
49 #else
50 #define DBD_DECLARE(type) __declspec(dllimport) type __stdcall
51 #define DBD_DECLARE_NONSTD(type) __declspec(dllimport) type
52 #define DBD_DECLARE_DATA __declspec(dllimport)
53 #endif
54 
55 #include <httpd.h>
56 #include <apr_optional.h>
57 #include <apr_hash.h>
58 #include <apr_hooks.h>
59 
60 typedef struct {
62  const char *name;
63  const char *params;
64  int persist;
65 #if APR_HAS_THREADS
66  int nmin;
67  int nkeep;
68  int nmax;
69  int exptime;
70  int set;
71 #endif
74 } dbd_cfg_t;
75 
76 typedef struct {
81 } ap_dbd_t;
82 
83 /* Export functions to access the database */
84 
85 /* acquire a connection that MUST be explicitly closed.
86  * Returns NULL on error
87  */
89 
90 /* release a connection acquired with ap_dbd_open */
91 DBD_DECLARE_NONSTD(void) ap_dbd_close(server_rec*, ap_dbd_t*);
92 
93 /* acquire a connection that will have the lifetime of a request
94  * and MUST NOT be explicitly closed. Return NULL on error.
95  * This is the preferred function for most applications.
96  */
98 
99 /* acquire a connection that will have the lifetime of a connection
100  * and MUST NOT be explicitly closed. Return NULL on error.
101  * This is the preferred function for most applications.
102  */
104 
105 /* Prepare a statement for use by a client module during
106  * the server startup/configuration phase. Can't be called
107  * after the server has created its children (use apr_dbd_*).
108  */
109 DBD_DECLARE_NONSTD(void) ap_dbd_prepare(server_rec*, const char*, const char*);
110 
111 /* Also export them as optional functions for modules that prefer it */
112 APR_DECLARE_OPTIONAL_FN(ap_dbd_t*, ap_dbd_open, (apr_pool_t*, server_rec*));
113 APR_DECLARE_OPTIONAL_FN(void, ap_dbd_close, (server_rec*, ap_dbd_t*));
114 APR_DECLARE_OPTIONAL_FN(ap_dbd_t*, ap_dbd_acquire, (request_rec*));
115 APR_DECLARE_OPTIONAL_FN(ap_dbd_t*, ap_dbd_cacquire, (conn_rec*));
116 APR_DECLARE_OPTIONAL_FN(void, ap_dbd_prepare, (server_rec*, const char*, const char*));
117 
118 APR_DECLARE_EXTERNAL_HOOK(dbd, DBD, apr_status_t, post_connect,
119  (apr_pool_t *, dbd_cfg_t *, ap_dbd_t *))
120 
121 #endif
122 
server_rec * server
Definition: mod_dbd.h:61
apr_array_header_t * init_queries
Definition: mod_dbd.h:73
Definition: apr_tables.h:62
apr_pool_t * pool
Definition: mod_dbd.h:80
int exptime
Definition: mod_dbd.h:69
ap_dbd_t * ap_dbd_cacquire(conn_rec *)
const char * name
Definition: mod_dbd.h:62
struct apr_dbd_t apr_dbd_t
Definition: apr_dbd.h:83
APR Hash Tables.
int nmin
Definition: mod_dbd.h:66
Structure to store things which are per connection.
Definition: httpd.h:1123
APR-UTIL registration of functions exported by modules.
Definition: mod_dbd.h:60
HTTP Daemon routines.
Apache hook functions.
int nkeep
Definition: mod_dbd.h:67
int set
Definition: mod_dbd.h:70
A structure to store information for each virtual server.
Definition: httpd.h:1310
ap_dbd_t * ap_dbd_acquire(request_rec *)
apr_dbd_t * handle
Definition: mod_dbd.h:77
#define APR_DECLARE_EXTERNAL_HOOK(ns, link, ret, name, args)
Definition: apr_hooks.h:118
void ap_dbd_prepare(server_rec *, const char *, const char *)
#define DBD_DECLARE_NONSTD(type)
Definition: mod_dbd.h:39
struct apr_hash_t apr_hash_t
Definition: apr_hash.h:52
Definition: mod_dbd.h:76
const char * params
Definition: mod_dbd.h:63
A structure that represents the current request.
Definition: httpd.h:810
Definition: apr_dbd_internal.h:43
int persist
Definition: mod_dbd.h:64
int nmax
Definition: mod_dbd.h:68
struct apr_pool_t apr_pool_t
Definition: apr_pools.h:60
const char const char *ap_dbd_t * ap_dbd_open(apr_pool_t *, server_rec *)
void ap_dbd_close(server_rec *, ap_dbd_t *)
int apr_status_t
Definition: apr_errno.h:44
#define APR_DECLARE_OPTIONAL_FN(ret, name, args)
Definition: apr_optional.h:50
const apr_dbd_driver_t * driver
Definition: mod_dbd.h:78
apr_hash_t * queries
Definition: mod_dbd.h:72
apr_hash_t * prepared
Definition: mod_dbd.h:79