github.com/krum110487/go-htaccess@v0.0.0-20240316004156-60641c8e7598/tests/data/apache_2_2_34/include/mod_dbd.h (about) 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 /** 18 * @file mod_dbd.h 19 * @brief Database Access Extension Module for Apache 20 * 21 * Overview of what this is and does: 22 * http://www.apache.org/~niq/dbd.html 23 * or 24 * http://apache.webthing.com/database/ 25 * 26 * @defgroup MOD_DBD mod_dbd 27 * @ingroup APACHE_MODS 28 * @{ 29 */ 30 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 59 typedef struct { 60 apr_dbd_t *handle; 61 const apr_dbd_driver_t *driver; 62 apr_hash_t *prepared; 63 apr_pool_t *pool; 64 } ap_dbd_t; 65 66 /* Export functions to access the database */ 67 68 /* acquire a connection that MUST be explicitly closed. 69 * Returns NULL on error 70 */ 71 DBD_DECLARE_NONSTD(ap_dbd_t*) ap_dbd_open(apr_pool_t*, server_rec*); 72 73 /* release a connection acquired with ap_dbd_open */ 74 DBD_DECLARE_NONSTD(void) ap_dbd_close(server_rec*, ap_dbd_t*); 75 76 /* acquire a connection that will have the lifetime of a request 77 * and MUST NOT be explicitly closed. Return NULL on error. 78 * This is the preferred function for most applications. 79 */ 80 DBD_DECLARE_NONSTD(ap_dbd_t*) ap_dbd_acquire(request_rec*); 81 82 /* acquire a connection that will have the lifetime of a connection 83 * and MUST NOT be explicitly closed. Return NULL on error. 84 * This is the preferred function for most applications. 85 */ 86 DBD_DECLARE_NONSTD(ap_dbd_t*) ap_dbd_cacquire(conn_rec*); 87 88 /* Prepare a statement for use by a client module during 89 * the server startup/configuration phase. Can't be called 90 * after the server has created its children (use apr_dbd_*). 91 */ 92 DBD_DECLARE_NONSTD(void) ap_dbd_prepare(server_rec*, const char*, const char*); 93 94 /* Also export them as optional functions for modules that prefer it */ 95 APR_DECLARE_OPTIONAL_FN(ap_dbd_t*, ap_dbd_open, (apr_pool_t*, server_rec*)); 96 APR_DECLARE_OPTIONAL_FN(void, ap_dbd_close, (server_rec*, ap_dbd_t*)); 97 APR_DECLARE_OPTIONAL_FN(ap_dbd_t*, ap_dbd_acquire, (request_rec*)); 98 APR_DECLARE_OPTIONAL_FN(ap_dbd_t*, ap_dbd_cacquire, (conn_rec*)); 99 APR_DECLARE_OPTIONAL_FN(void, ap_dbd_prepare, (server_rec*, const char*, const char*)); 100 101 #endif 102 /** @} */ 103