Blame modules/database/mod_dbd.h

Packit 90a5c9
/* Licensed to the Apache Software Foundation (ASF) under one or more
Packit 90a5c9
 * contributor license agreements.  See the NOTICE file distributed with
Packit 90a5c9
 * this work for additional information regarding copyright ownership.
Packit 90a5c9
 * The ASF licenses this file to You under the Apache License, Version 2.0
Packit 90a5c9
 * (the "License"); you may not use this file except in compliance with
Packit 90a5c9
 * the License.  You may obtain a copy of the License at
Packit 90a5c9
 *
Packit 90a5c9
 *     http://www.apache.org/licenses/LICENSE-2.0
Packit 90a5c9
 *
Packit 90a5c9
 * Unless required by applicable law or agreed to in writing, software
Packit 90a5c9
 * distributed under the License is distributed on an "AS IS" BASIS,
Packit 90a5c9
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Packit 90a5c9
 * See the License for the specific language governing permissions and
Packit 90a5c9
 * limitations under the License.
Packit 90a5c9
 */
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * @file  mod_dbd.h
Packit 90a5c9
 * @brief Database Access Extension Module for Apache
Packit 90a5c9
 *
Packit 90a5c9
 * Overview of what this is and does:
Packit 90a5c9
 * http://www.apache.org/~niq/dbd.html
Packit 90a5c9
 * or
Packit 90a5c9
 * http://apache.webthing.com/database/
Packit 90a5c9
 *
Packit 90a5c9
 * @defgroup MOD_DBD mod_dbd
Packit 90a5c9
 * @ingroup APACHE_MODS
Packit 90a5c9
 * @{
Packit 90a5c9
 */
Packit 90a5c9
Packit 90a5c9
#ifndef DBD_H
Packit 90a5c9
#define DBD_H
Packit 90a5c9
Packit 90a5c9
/* Create a set of DBD_DECLARE(type), DBD_DECLARE_NONSTD(type) and
Packit 90a5c9
 * DBD_DECLARE_DATA with appropriate export and import tags for the platform
Packit 90a5c9
 */
Packit 90a5c9
#if !defined(WIN32)
Packit 90a5c9
#define DBD_DECLARE(type)            type
Packit 90a5c9
#define DBD_DECLARE_NONSTD(type)     type
Packit 90a5c9
#define DBD_DECLARE_DATA
Packit 90a5c9
#elif defined(DBD_DECLARE_STATIC)
Packit 90a5c9
#define DBD_DECLARE(type)            type __stdcall
Packit 90a5c9
#define DBD_DECLARE_NONSTD(type)     type
Packit 90a5c9
#define DBD_DECLARE_DATA
Packit 90a5c9
#elif defined(DBD_DECLARE_EXPORT)
Packit 90a5c9
#define DBD_DECLARE(type)            __declspec(dllexport) type __stdcall
Packit 90a5c9
#define DBD_DECLARE_NONSTD(type)     __declspec(dllexport) type
Packit 90a5c9
#define DBD_DECLARE_DATA             __declspec(dllexport)
Packit 90a5c9
#else
Packit 90a5c9
#define DBD_DECLARE(type)            __declspec(dllimport) type __stdcall
Packit 90a5c9
#define DBD_DECLARE_NONSTD(type)     __declspec(dllimport) type
Packit 90a5c9
#define DBD_DECLARE_DATA             __declspec(dllimport)
Packit 90a5c9
#endif
Packit 90a5c9
Packit 90a5c9
#include <httpd.h>
Packit 90a5c9
#include <apr_optional.h>
Packit 90a5c9
#include <apr_hash.h>
Packit 90a5c9
#include <apr_hooks.h>
Packit 90a5c9
Packit 90a5c9
typedef struct {
Packit 90a5c9
    server_rec *server;
Packit 90a5c9
    const char *name;
Packit 90a5c9
    const char *params;
Packit 90a5c9
    int persist;
Packit 90a5c9
#if APR_HAS_THREADS
Packit 90a5c9
    int nmin;
Packit 90a5c9
    int nkeep;
Packit 90a5c9
    int nmax;
Packit 90a5c9
    int exptime;
Packit 90a5c9
    int set;
Packit 90a5c9
#endif
Packit 90a5c9
    apr_hash_t *queries;
Packit 90a5c9
    apr_array_header_t *init_queries;
Packit 90a5c9
} dbd_cfg_t;
Packit 90a5c9
Packit 90a5c9
typedef struct {
Packit 90a5c9
    apr_dbd_t *handle;
Packit 90a5c9
    const apr_dbd_driver_t *driver;
Packit 90a5c9
    apr_hash_t *prepared;
Packit 90a5c9
    apr_pool_t *pool;
Packit 90a5c9
} ap_dbd_t;
Packit 90a5c9
Packit 90a5c9
/* Export functions to access the database */
Packit 90a5c9
Packit 90a5c9
/* acquire a connection that MUST be explicitly closed.
Packit 90a5c9
 * Returns NULL on error
Packit 90a5c9
 */
Packit 90a5c9
DBD_DECLARE_NONSTD(ap_dbd_t*) ap_dbd_open(apr_pool_t*, server_rec*);
Packit 90a5c9
Packit 90a5c9
/* release a connection acquired with ap_dbd_open */
Packit 90a5c9
DBD_DECLARE_NONSTD(void) ap_dbd_close(server_rec*, ap_dbd_t*);
Packit 90a5c9
Packit 90a5c9
/* acquire a connection that will have the lifetime of a request
Packit 90a5c9
 * and MUST NOT be explicitly closed.  Return NULL on error.
Packit 90a5c9
 * This is the preferred function for most applications.
Packit 90a5c9
 */
Packit 90a5c9
DBD_DECLARE_NONSTD(ap_dbd_t*) ap_dbd_acquire(request_rec*);
Packit 90a5c9
Packit 90a5c9
/* acquire a connection that will have the lifetime of a connection
Packit 90a5c9
 * and MUST NOT be explicitly closed.  Return NULL on error.
Packit 90a5c9
 * This is the preferred function for most applications.
Packit 90a5c9
 */
Packit 90a5c9
DBD_DECLARE_NONSTD(ap_dbd_t*) ap_dbd_cacquire(conn_rec*);
Packit 90a5c9
Packit 90a5c9
/* Prepare a statement for use by a client module during
Packit 90a5c9
 * the server startup/configuration phase.  Can't be called
Packit 90a5c9
 * after the server has created its children (use apr_dbd_*).
Packit 90a5c9
 */
Packit 90a5c9
DBD_DECLARE_NONSTD(void) ap_dbd_prepare(server_rec*, const char*, const char*);
Packit 90a5c9
Packit 90a5c9
/* Also export them as optional functions for modules that prefer it */
Packit 90a5c9
APR_DECLARE_OPTIONAL_FN(ap_dbd_t*, ap_dbd_open, (apr_pool_t*, server_rec*));
Packit 90a5c9
APR_DECLARE_OPTIONAL_FN(void, ap_dbd_close, (server_rec*, ap_dbd_t*));
Packit 90a5c9
APR_DECLARE_OPTIONAL_FN(ap_dbd_t*, ap_dbd_acquire, (request_rec*));
Packit 90a5c9
APR_DECLARE_OPTIONAL_FN(ap_dbd_t*, ap_dbd_cacquire, (conn_rec*));
Packit 90a5c9
APR_DECLARE_OPTIONAL_FN(void, ap_dbd_prepare, (server_rec*, const char*, const char*));
Packit 90a5c9
Packit 90a5c9
APR_DECLARE_EXTERNAL_HOOK(dbd, DBD, apr_status_t, post_connect,
Packit 90a5c9
                          (apr_pool_t *, dbd_cfg_t *, ap_dbd_t *))
Packit 90a5c9
Packit 90a5c9
#endif
Packit 90a5c9
/** @} */
Packit 90a5c9