summaryrefslogtreecommitdiff
path: root/include/private
diff options
context:
space:
mode:
authorPaul Querna <pquerna@apache.org>2009-03-24 10:32:34 +0000
committerPaul Querna <pquerna@apache.org>2009-03-24 10:32:34 +0000
commitdfd4f72bed0d7ac95c8ee1a27a6aa652bd766e52 (patch)
tree69804a4de7433f4755bd62c647dee518c48c673a /include/private
parent97a7d58c22e482e25154e5e46c7dd91d6222a947 (diff)
downloadapr-dfd4f72bed0d7ac95c8ee1a27a6aa652bd766e52.tar.gz
Merge APR-Util trunk into APR.
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@757704 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'include/private')
-rw-r--r--include/private/apr_crypto_internal.h253
-rw-r--r--include/private/apr_dbd_internal.h365
-rw-r--r--include/private/apr_dbd_odbc_v2.h119
-rw-r--r--include/private/apr_dbm_private.h121
-rw-r--r--include/private/apu_config.hnw53
-rw-r--r--include/private/apu_config.hw46
-rw-r--r--include/private/apu_internal.h73
-rw-r--r--include/private/apu_select_dbm.h.in28
-rw-r--r--include/private/apu_select_dbm.hw28
9 files changed, 1086 insertions, 0 deletions
diff --git a/include/private/apr_crypto_internal.h b/include/private/apr_crypto_internal.h
new file mode 100644
index 000000000..de109de57
--- /dev/null
+++ b/include/private/apr_crypto_internal.h
@@ -0,0 +1,253 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef APR_CRYPTO_INTERNAL_H
+#define APR_CRYPTO_INTERNAL_H
+
+#include <stdarg.h>
+
+#include "apr_crypto.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if APU_HAVE_CRYPTO
+
+struct apr_crypto_driver_t {
+
+ /** name */
+ const char *name;
+
+ /**
+ * @brief: allow driver to perform once-only initialisation.
+ * Called once only.
+ * @param pool The pool to register the cleanup in.
+ * @param params An array of optional init parameters.
+ */
+ apr_status_t (*init)(apr_pool_t *pool, const apr_array_header_t *params, int *rc);
+
+ /**
+ * @brief Create a context for supporting encryption. Keys, certificates,
+ * algorithms and other parameters will be set per context. More than
+ * one context can be created at one time. A cleanup will be automatically
+ * registered with the given pool to guarantee a graceful shutdown.
+ * @param driver - driver to use
+ * @param pool - process pool
+ * @param params - array of key parameters
+ * @param f - context pointer will be written here
+ * @return APR_ENOENGINE when the engine specified does not exist. APR_EINITENGINE
+ * if the engine cannot be initialised.
+ */
+ apr_status_t (*factory)(apr_pool_t *pool, const apr_array_header_t *params,
+ apr_crypto_t **f);
+
+ /**
+ * @brief Create a key from the given passphrase. By default, the PBKDF2
+ * algorithm is used to generate the key from the passphrase. It is expected
+ * that the same pass phrase will generate the same key, regardless of the
+ * backend crypto platform used. The key is cleaned up when the context
+ * is cleaned, and may be reused with multiple encryption or decryption
+ * operations.
+ * @note If *key is NULL, a apr_crypto_key_t will be created from a pool. If
+ * *key is not NULL, *key must point at a previously created structure.
+ * @param driver - driver to use
+ * @param p The pool to use.
+ * @param f The context to use.
+ * @param pass The passphrase to use.
+ * @param passLen The passphrase length in bytes
+ * @param salt The salt to use.
+ * @param saltLen The salt length in bytes
+ * @param type 3DES_192, AES_128, AES_192, AES_256.
+ * @param mode Electronic Code Book / Cipher Block Chaining.
+ * @param doPad Pad if necessary.
+ * @param key The key returned, see note.
+ * @param ivSize The size of the initialisation vector will be returned, based
+ * on whether an IV is relevant for this type of crypto.
+ * @return Returns APR_ENOKEY if the pass phrase is missing or empty, or if a backend
+ * error occurred while generating the key. APR_ENOCIPHER if the type or mode
+ * is not supported by the particular backend. APR_EKEYTYPE if the key type is
+ * not known. APR_EPADDING if padding was requested but is not supported.
+ * APR_ENOTIMPL if not implemented.
+ */
+ apr_status_t (*passphrase)(apr_pool_t *p, const apr_crypto_t *f,
+ const char *pass, apr_size_t passLen, const unsigned char * salt,
+ apr_size_t saltLen, const apr_crypto_block_key_type_e type,
+ const apr_crypto_block_key_mode_e mode, const int doPad,
+ const int iterations, apr_crypto_key_t **key, apr_size_t *ivSize);
+
+ /**
+ * @brief Initialise a context for encrypting arbitrary data using the given key.
+ * @note If *ctx is NULL, a apr_crypto_block_t will be created from a pool. If
+ * *ctx is not NULL, *ctx must point at a previously created structure.
+ * @param p The pool to use.
+ * @param f The block factory to use.
+ * @param key The key structure.
+ * @param iv Optional initialisation vector. If the buffer pointed to is NULL,
+ * an IV will be created at random, in space allocated from the pool.
+ * If the buffer pointed to is not NULL, the IV in the buffer will be
+ * used.
+ * @param ctx The block context returned, see note.
+ * @param ivSize The size of the initialisation vector will be returned, based
+ * on whether an IV is relevant for this type of crypto.
+ * @param blockSize The block size of the cipher.
+ * @return Returns APR_ENOIV if an initialisation vector is required but not specified.
+ * Returns APR_EINIT if the backend failed to initialise the context. Returns
+ * APR_ENOTIMPL if not implemented.
+ */
+ apr_status_t (*block_encrypt_init)(apr_pool_t *p, const apr_crypto_t *f,
+ const apr_crypto_key_t *key, const unsigned char **iv,
+ apr_crypto_block_t **ctx, apr_size_t *blockSize);
+
+ /**
+ * @brief Encrypt data provided by in, write it to out.
+ * @note The number of bytes written will be written to outlen. If
+ * out is NULL, outlen will contain the maximum size of the
+ * buffer needed to hold the data, including any data
+ * generated by apr_crypto_block_encrypt_finish below. If *out points
+ * to NULL, a buffer sufficiently large will be created from
+ * the pool provided. If *out points to a not-NULL value, this
+ * value will be used as a buffer instead.
+ * @param ctx The block context to use.
+ * @param out Address of a buffer to which data will be written,
+ * see note.
+ * @param outlen Length of the output will be written here.
+ * @param in Address of the buffer to read.
+ * @param inlen Length of the buffer to read.
+ * @return APR_ECRYPT if an error occurred. Returns APR_ENOTIMPL if
+ * not implemented.
+ */
+ apr_status_t (*block_encrypt)(apr_crypto_block_t *ctx, unsigned char **out,
+ apr_size_t *outlen, const unsigned char *in, apr_size_t inlen);
+
+ /**
+ * @brief Encrypt final data block, write it to out.
+ * @note If necessary the final block will be written out after being
+ * padded. Typically the final block will be written to the
+ * same buffer used by apr_crypto_block_encrypt, offset by the
+ * number of bytes returned as actually written by the
+ * apr_crypto_block_encrypt() call. After this call, the context
+ * is cleaned and can be reused by apr_crypto_block_encrypt_init().
+ * @param ctx The block context to use.
+ * @param out Address of a buffer to which data will be written. This
+ * buffer must already exist, and is usually the same
+ * buffer used by apr_evp_crypt(). See note.
+ * @param outlen Length of the output will be written here.
+ * @return APR_ECRYPT if an error occurred.
+ * @return APR_EPADDING if padding was enabled and the block was incorrectly
+ * formatted.
+ * @return APR_ENOTIMPL if not implemented.
+ */
+ apr_status_t (*block_encrypt_finish)(apr_crypto_block_t *ctx,
+ unsigned char *out, apr_size_t *outlen);
+
+ /**
+ * @brief Initialise a context for decrypting arbitrary data using the given key.
+ * @note If *ctx is NULL, a apr_crypto_block_t will be created from a pool. If
+ * *ctx is not NULL, *ctx must point at a previously created structure.
+ * @param p The pool to use.
+ * @param f The block factory to use.
+ * @param key The key structure.
+ * @param iv Optional initialisation vector. If the buffer pointed to is NULL,
+ * an IV will be created at random, in space allocated from the pool.
+ * If the buffer is not NULL, the IV in the buffer will be used.
+ * @param ctx The block context returned, see note.
+ * @param blockSize The block size of the cipher.
+ * @return Returns APR_ENOIV if an initialisation vector is required but not specified.
+ * Returns APR_EINIT if the backend failed to initialise the context. Returns
+ * APR_ENOTIMPL if not implemented.
+ */
+ apr_status_t (*block_decrypt_init)(apr_pool_t *p, const apr_crypto_t *f,
+ const apr_crypto_key_t *key, const unsigned char *iv,
+ apr_crypto_block_t **ctx, apr_size_t *blockSize);
+
+ /**
+ * @brief Decrypt data provided by in, write it to out.
+ * @note The number of bytes written will be written to outlen. If
+ * out is NULL, outlen will contain the maximum size of the
+ * buffer needed to hold the data, including any data
+ * generated by apr_crypto_block_decrypt_finish below. If *out points
+ * to NULL, a buffer sufficiently large will be created from
+ * the pool provided. If *out points to a not-NULL value, this
+ * value will be used as a buffer instead.
+ * @param ctx The block context to use.
+ * @param out Address of a buffer to which data will be written,
+ * see note.
+ * @param outlen Length of the output will be written here.
+ * @param in Address of the buffer to read.
+ * @param inlen Length of the buffer to read.
+ * @return APR_ECRYPT if an error occurred. Returns APR_ENOTIMPL if
+ * not implemented.
+ */
+ apr_status_t (*block_decrypt)(apr_crypto_block_t *ctx, unsigned char **out,
+ apr_size_t *outlen, const unsigned char *in, apr_size_t inlen);
+
+ /**
+ * @brief Decrypt final data block, write it to out.
+ * @note If necessary the final block will be written out after being
+ * padded. Typically the final block will be written to the
+ * same buffer used by apr_crypto_block_decrypt, offset by the
+ * number of bytes returned as actually written by the
+ * apr_crypto_block_decrypt() call. After this call, the context
+ * is cleaned and can be reused by apr_crypto_block_decrypt_init().
+ * @param ctx The block context to use.
+ * @param out Address of a buffer to which data will be written. This
+ * buffer must already exist, and is usually the same
+ * buffer used by apr_evp_crypt(). See note.
+ * @param outlen Length of the output will be written here.
+ * @return APR_ECRYPT if an error occurred.
+ * @return APR_EPADDING if padding was enabled and the block was incorrectly
+ * formatted.
+ * @return APR_ENOTIMPL if not implemented.
+ */
+ apr_status_t (*block_decrypt_finish)(apr_crypto_block_t *ctx,
+ unsigned char *out, apr_size_t *outlen);
+
+ /**
+ * @brief Clean encryption / decryption context.
+ * @note After cleanup, a context is free to be reused if necessary.
+ * @param driver - driver to use
+ * @param ctx The block context to use.
+ * @return Returns APR_ENOTIMPL if not supported.
+ */
+ apr_status_t (*block_cleanup)(apr_crypto_block_t *ctx);
+
+ /**
+ * @brief Clean encryption / decryption factory.
+ * @note After cleanup, a factory is free to be reused if necessary.
+ * @param driver - driver to use
+ * @param f The factory to use.
+ * @return Returns APR_ENOTIMPL if not supported.
+ */
+ apr_status_t (*cleanup)(apr_crypto_t *f);
+
+ /**
+ * @brief Clean encryption / decryption factory.
+ * @note After cleanup, a factory is free to be reused if necessary.
+ * @param pool The pool to use.
+ * @return Returns APR_ENOTIMPL if not supported.
+ */
+ apr_status_t (*shutdown)(apr_pool_t *p);
+
+};
+
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/private/apr_dbd_internal.h b/include/private/apr_dbd_internal.h
new file mode 100644
index 000000000..671ffb218
--- /dev/null
+++ b/include/private/apr_dbd_internal.h
@@ -0,0 +1,365 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* Overview of what this is and does:
+ * http://www.apache.org/~niq/dbd.html
+ */
+
+#ifndef APR_DBD_INTERNAL_H
+#define APR_DBD_INTERNAL_H
+
+#include <stdarg.h>
+
+#include "apr_dbd.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define TXN_IGNORE_ERRORS(t) \
+ ((t) && ((t)->mode & APR_DBD_TRANSACTION_IGNORE_ERRORS))
+#define TXN_NOTICE_ERRORS(t) \
+ ((t) && !((t)->mode & APR_DBD_TRANSACTION_IGNORE_ERRORS))
+
+#define TXN_DO_COMMIT(t) (!((t)->mode & APR_DBD_TRANSACTION_ROLLBACK))
+#define TXN_DO_ROLLBACK(t) ((t)->mode & APR_DBD_TRANSACTION_ROLLBACK)
+
+#define TXN_MODE_BITS \
+ (APR_DBD_TRANSACTION_ROLLBACK|APR_DBD_TRANSACTION_IGNORE_ERRORS)
+
+struct apr_dbd_driver_t {
+ /** name */
+ const char *name;
+
+ /** init: allow driver to perform once-only initialisation.
+ * Called once only. May be NULL
+ */
+ void (*init)(apr_pool_t *pool);
+
+ /** native_handle: return the native database handle of the underlying db
+ *
+ * @param handle - apr_dbd handle
+ * @return - native handle
+ */
+ void *(*native_handle)(apr_dbd_t *handle);
+
+ /** open: obtain a database connection from the server rec.
+ * Must be explicitly closed when you're finished with it.
+ * WARNING: only use this when you need a connection with
+ * a lifetime other than a request
+ *
+ * @param pool - a pool to use for error messages (if any).
+ * @param params - connection parameters.
+ * @param error - descriptive error.
+ * @return database handle, or NULL on error.
+ */
+ apr_dbd_t *(*open)(apr_pool_t *pool, const char *params,
+ const char **error);
+
+ /** check_conn: check status of a database connection
+ *
+ * @param pool - a pool to use for error messages (if any).
+ * @param handle - the connection to check
+ * @return APR_SUCCESS or error
+ */
+ apr_status_t (*check_conn)(apr_pool_t *pool, apr_dbd_t *handle);
+
+ /** close: close/release a connection obtained from open()
+ *
+ * @param handle - the connection to release
+ * @return APR_SUCCESS or error
+ */
+ apr_status_t (*close)(apr_dbd_t *handle);
+
+ /** set_dbname: select database name. May be a no-op if not supported.
+ *
+ * @param pool - working pool
+ * @param handle - the connection
+ * @param name - the database to select
+ * @return 0 for success or error code
+ */
+ int (*set_dbname)(apr_pool_t* pool, apr_dbd_t *handle, const char *name);
+
+ /** transaction: start a transaction. May be a no-op.
+ *
+ * @param pool - a pool to use for error messages (if any).
+ * @param handle - the connection
+ * @param trans - ptr to a transaction. May be null on entry
+ * @return 0 for success or error code
+ */
+ int (*start_transaction)(apr_pool_t *pool, apr_dbd_t *handle,
+ apr_dbd_transaction_t **trans);
+
+ /** end_transaction: end a transaction
+ * (commit on success, rollback on error).
+ * May be a no-op.
+ *
+ * @param trans - the transaction.
+ * @return 0 for success or error code
+ */
+ int (*end_transaction)(apr_dbd_transaction_t *trans);
+
+ /** query: execute an SQL query that doesn't return a result set
+ *
+ * @param handle - the connection
+ * @param nrows - number of rows affected.
+ * @param statement - the SQL statement to execute
+ * @return 0 for success or error code
+ */
+ int (*query)(apr_dbd_t *handle, int *nrows, const char *statement);
+
+ /** select: execute an SQL query that returns a result set
+ *
+ * @param pool - pool to allocate the result set
+ * @param handle - the connection
+ * @param res - pointer to result set pointer. May point to NULL on entry
+ * @param statement - the SQL statement to execute
+ * @param random - 1 to support random access to results (seek any row);
+ * 0 to support only looping through results in order
+ * (async access - faster)
+ * @return 0 for success or error code
+ */
+ int (*select)(apr_pool_t *pool, apr_dbd_t *handle, apr_dbd_results_t **res,
+ const char *statement, int random);
+
+ /** num_cols: get the number of columns in a results set
+ *
+ * @param res - result set.
+ * @return number of columns
+ */
+ int (*num_cols)(apr_dbd_results_t *res);
+
+ /** num_tuples: get the number of rows in a results set
+ * of a synchronous select
+ *
+ * @param res - result set.
+ * @return number of rows, or -1 if the results are asynchronous
+ */
+ int (*num_tuples)(apr_dbd_results_t *res);
+
+ /** get_row: get a row from a result set
+ *
+ * @param pool - pool to allocate the row
+ * @param res - result set pointer
+ * @param row - pointer to row pointer. May point to NULL on entry
+ * @param rownum - row number, or -1 for "next row". Ignored if random
+ * access is not supported.
+ * @return 0 for success, -1 for rownum out of range or data finished
+ */
+ int (*get_row)(apr_pool_t *pool, apr_dbd_results_t *res,
+ apr_dbd_row_t **row, int rownum);
+
+ /** get_entry: get an entry from a row
+ *
+ * @param row - row pointer
+ * @param col - entry number
+ * @param val - entry to fill
+ * @return 0 for success, -1 for no data, +1 for general error
+ */
+ const char* (*get_entry)(const apr_dbd_row_t *row, int col);
+
+ /** error: get current error message (if any)
+ *
+ * @param handle - the connection
+ * @param errnum - error code from operation that returned an error
+ * @return the database current error message, or message for errnum
+ * (implementation-dependent whether errnum is ignored)
+ */
+ const char *(*error)(apr_dbd_t *handle, int errnum);
+
+ /** escape: escape a string so it is safe for use in query/select
+ *
+ * @param pool - pool to alloc the result from
+ * @param string - the string to escape
+ * @param handle - the connection
+ * @return the escaped, safe string
+ */
+ const char *(*escape)(apr_pool_t *pool, const char *string,
+ apr_dbd_t *handle);
+
+ /** prepare: prepare a statement
+ *
+ * @param pool - pool to alloc the result from
+ * @param handle - the connection
+ * @param query - the SQL query
+ * @param label - A label for the prepared statement.
+ * use NULL for temporary prepared statements
+ * (eg within a Request in httpd)
+ * @param nargs - number of parameters in the query
+ * @param nvals - number of values passed in p[b]query/select
+ * @param types - pointer to an array with types of parameters
+ * @param statement - statement to prepare. May point to null on entry.
+ * @return 0 for success or error code
+ */
+ int (*prepare)(apr_pool_t *pool, apr_dbd_t *handle, const char *query,
+ const char *label, int nargs, int nvals,
+ apr_dbd_type_e *types, apr_dbd_prepared_t **statement);
+
+ /** pvquery: query using a prepared statement + args
+ *
+ * @param pool - working pool
+ * @param handle - the connection
+ * @param nrows - number of rows affected.
+ * @param statement - the prepared statement to execute
+ * @param args - args to prepared statement
+ * @return 0 for success or error code
+ */
+ int (*pvquery)(apr_pool_t *pool, apr_dbd_t *handle, int *nrows,
+ apr_dbd_prepared_t *statement, va_list args);
+
+ /** pvselect: select using a prepared statement + args
+ *
+ * @param pool - working pool
+ * @param handle - the connection
+ * @param res - pointer to query results. May point to NULL on entry
+ * @param statement - the prepared statement to execute
+ * @param random - Whether to support random-access to results
+ * @param args - args to prepared statement
+ * @return 0 for success or error code
+ */
+ int (*pvselect)(apr_pool_t *pool, apr_dbd_t *handle,
+ apr_dbd_results_t **res,
+ apr_dbd_prepared_t *statement, int random, va_list args);
+
+ /** pquery: query using a prepared statement + args
+ *
+ * @param pool - working pool
+ * @param handle - the connection
+ * @param nrows - number of rows affected.
+ * @param statement - the prepared statement to execute
+ * @param args - args to prepared statement
+ * @return 0 for success or error code
+ */
+ int (*pquery)(apr_pool_t *pool, apr_dbd_t *handle, int *nrows,
+ apr_dbd_prepared_t *statement, const char **args);
+
+ /** pselect: select using a prepared statement + args
+ *
+ * @param pool - working pool
+ * @param handle - the connection
+ * @param res - pointer to query results. May point to NULL on entry
+ * @param statement - the prepared statement to execute
+ * @param random - Whether to support random-access to results
+ * @param args - args to prepared statement
+ * @return 0 for success or error code
+ */
+ int (*pselect)(apr_pool_t *pool, apr_dbd_t *handle,
+ apr_dbd_results_t **res, apr_dbd_prepared_t *statement,
+ int random, const char **args);
+
+
+ /** get_name: get a column title from a result set
+ *
+ * @param res - result set pointer
+ * @param col - entry number
+ * @return param name, or NULL if col is out of bounds.
+ */
+ const char* (*get_name)(const apr_dbd_results_t *res, int col);
+
+ /** transaction_mode_get: get the mode of transaction
+ *
+ * @param trans - the transaction.
+ * @return mode of transaction
+ */
+ int (*transaction_mode_get)(apr_dbd_transaction_t *trans);
+
+ /** transaction_mode_set: get the mode of transaction
+ *
+ * @param trans - the transaction.
+ * @param mode - new mode of the transaction
+ * @return the mode of transaction in force after the call
+ */
+ int (*transaction_mode_set)(apr_dbd_transaction_t *trans, int mode);
+
+ /** format of prepared statement parameters */
+ const char *pformat;
+
+ /** pvbquery: query using a prepared statement + binary args
+ *
+ * @param pool - working pool
+ * @param handle - the connection
+ * @param nrows - number of rows affected.
+ * @param statement - the prepared statement to execute
+ * @param args - binary args to prepared statement
+ * @return 0 for success or error code
+ */
+ int (*pvbquery)(apr_pool_t *pool, apr_dbd_t *handle, int *nrows,
+ apr_dbd_prepared_t *statement, va_list args);
+
+ /** pvbselect: select using a prepared statement + binary args
+ *
+ * @param pool - working pool
+ * @param handle - the connection
+ * @param res - pointer to query results. May point to NULL on entry
+ * @param statement - the prepared statement to execute
+ * @param random - Whether to support random-access to results
+ * @param args - binary args to prepared statement
+ * @return 0 for success or error code
+ */
+ int (*pvbselect)(apr_pool_t *pool, apr_dbd_t *handle,
+ apr_dbd_results_t **res,
+ apr_dbd_prepared_t *statement, int random, va_list args);
+
+ /** pbquery: query using a prepared statement + binary args
+ *
+ * @param pool - working pool
+ * @param handle - the connection
+ * @param nrows - number of rows affected.
+ * @param statement - the prepared statement to execute
+ * @param args - binary args to prepared statement
+ * @return 0 for success or error code
+ */
+ int (*pbquery)(apr_pool_t *pool, apr_dbd_t *handle, int *nrows,
+ apr_dbd_prepared_t *statement,const void **args);
+
+ /** pbselect: select using a prepared statement + binary args
+ *
+ * @param pool - working pool
+ * @param handle - the connection
+ * @param res - pointer to query results. May point to NULL on entry
+ * @param statement - the prepared statement to execute
+ * @param random - Whether to support random-access to results
+ * @param args - binary args to prepared statement
+ * @return 0 for success or error code
+ */
+ int (*pbselect)(apr_pool_t *pool, apr_dbd_t *handle,
+ apr_dbd_results_t **res, apr_dbd_prepared_t *statement,
+ int random, const void **args);
+
+ /** datum_get: get a binary entry from a row
+ *
+ * @param row - row pointer
+ * @param col - entry number
+ * @param type - type of data to get
+ * @param data - pointer to data, allocated by the caller
+ * @return APR_SUCCESS, an error code on error or if col is out of bounds
+ */
+ apr_status_t (*datum_get)(const apr_dbd_row_t *row, int col,
+ apr_dbd_type_e type, void *data);
+};
+
+/* Export mutex lock/unlock for drivers that need it
+ * deprecated; create a per-dbd mutex within the (*init) function
+ * to avoid blocking other providers running on other threads
+ */
+APU_DECLARE(apr_status_t) apr_dbd_mutex_lock(void);
+APU_DECLARE(apr_status_t) apr_dbd_mutex_unlock(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/private/apr_dbd_odbc_v2.h b/include/private/apr_dbd_odbc_v2.h
new file mode 100644
index 000000000..dc7bc9c9c
--- /dev/null
+++ b/include/private/apr_dbd_odbc_v2.h
@@ -0,0 +1,119 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+/* ONLY USED FOR ODBC Version 2 -DODBCV2
+*
+* Re-define everything to work (more-or-less) in an ODBC V2 environment
+* Random access to retrieved rows is not supported - i.e. calls to apr_dbd_select() cannot
+* have a 'random' argument of 1. apr_dbd_get_row() must always pass rownum as 0 (get next row)
+*
+*/
+
+#define SQLHANDLE SQLHENV // Presumes that ENV, DBC, and STMT handles are all the same datatype
+#define SQL_NULL_HANDLE 0
+#define SQL_HANDLE_STMT 1
+#define SQL_HANDLE_DBC 2
+#define SQL_HANDLE_ENV 3
+#define SQL_NO_DATA SQL_NO_DATA_FOUND
+
+#ifndef SQL_SUCCEEDED
+#define SQL_SUCCEEDED(rc) (((rc)&(~1))==0)
+#endif
+
+#undef SQLSetEnvAttr
+#define SQLSetEnvAttr(henv, Attribute, Value, StringLength) (0)
+
+#undef SQLAllocHandle
+#define SQLAllocHandle(type, parent, hndl) \
+( (type == SQL_HANDLE_STMT) ? SQLAllocStmt(parent, hndl) \
+ : (type == SQL_HANDLE_ENV) ? SQLAllocEnv(hndl) \
+ : SQLAllocConnect(parent, hndl) \
+)
+
+#undef SQLFreeHandle
+#define SQLFreeHandle(type, hndl) \
+( (type == SQL_HANDLE_STMT) ? SQLFreeStmt(hndl, SQL_DROP) \
+ : (type == SQL_HANDLE_ENV) ? SQLFreeEnv(hndl) \
+ : SQLFreeConnect(hndl) \
+)
+
+#undef SQLGetDiagRec
+#define SQLGetDiagRec(type, h, i, state, native, buffer, bufsize, reslen) \
+ SQLError( (type == SQL_HANDLE_ENV) ? h : NULL, \
+ (type == SQL_HANDLE_DBC) ? h : NULL, \
+ (type == SQL_HANDLE_STMT) ? h : NULL, \
+ state, native, buffer, bufsize, reslen)
+
+#undef SQLCloseCursor
+#define SQLCloseCursor(stmt) SQLFreeStmt(stmt, SQL_CLOSE)
+
+#undef SQLGetConnectAttr
+#define SQLGetConnectAttr(hdbc, fOption, ValuePtr, BufferLength, NULL) \
+ SQLGetConnectOption(hdbc, fOption, ValuePtr)
+
+#undef SQLSetConnectAttr
+#define SQLSetConnectAttr(hdbc, fOption, ValuePtr, BufferLength) \
+ SQLSetConnectOption(hdbc, fOption, (SQLUINTEGER) ValuePtr)
+
+#undef SQLSetStmtAttr
+#define SQLSetStmtAttr(hstmt, fOption, ValuePtr, BufferLength) (0); return APR_ENOTIMPL;
+
+#undef SQLEndTran
+#define SQLEndTran(hType, hdbc,type) SQLTransact(henv, hdbc, type)
+
+#undef SQLFetchScroll
+#define SQLFetchScroll(stmt, orient, rownum) (0); return APR_ENOTIMPL;
+
+#define SQL_DESC_TYPE SQL_COLUMN_TYPE
+#define SQL_DESC_CONCISE_TYPE SQL_COLUMN_TYPE
+#define SQL_DESC_DISPLAY_SIZE SQL_COLUMN_DISPLAY_SIZE
+#define SQL_DESC_OCTET_LENGTH SQL_COLUMN_LENGTH
+#define SQL_DESC_UNSIGNED SQL_COLUMN_UNSIGNED
+
+#undef SQLColAttribute
+#define SQLColAttribute(s, c, f, a, l, m, n) SQLColAttributes(s, c, f, a, l, m, n)
+
+#define SQL_ATTR_ACCESS_MODE SQL_ACCESS_MODE
+#define SQL_ATTR_AUTOCOMMIT SQL_AUTOCOMMIT
+#define SQL_ATTR_CONNECTION_TIMEOUT 113
+#define SQL_ATTR_CURRENT_CATALOG SQL_CURRENT_QUALIFIER
+#define SQL_ATTR_DISCONNECT_BEHAVIOR 114
+#define SQL_ATTR_ENLIST_IN_DTC 1207
+#define SQL_ATTR_ENLIST_IN_XA 1208
+
+#define SQL_ATTR_CONNECTION_DEAD 1209
+#define SQL_CD_TRUE 1L /* Connection is closed/dead */
+#define SQL_CD_FALSE 0L /* Connection is open/available */
+
+#define SQL_ATTR_LOGIN_TIMEOUT SQL_LOGIN_TIMEOUT
+#define SQL_ATTR_ODBC_CURSORS SQL_ODBC_CURSORS
+#define SQL_ATTR_PACKET_SIZE SQL_PACKET_SIZE
+#define SQL_ATTR_QUIET_MODE SQL_QUIET_MODE
+#define SQL_ATTR_TRACE SQL_OPT_TRACE
+#define SQL_ATTR_TRACEFILE SQL_OPT_TRACEFILE
+#define SQL_ATTR_TRANSLATE_LIB SQL_TRANSLATE_DLL
+#define SQL_ATTR_TRANSLATE_OPTION SQL_TRANSLATE_OPTION
+#define SQL_ATTR_TXN_ISOLATION SQL_TXN_ISOLATION
+
+#define SQL_ATTR_CURSOR_SCROLLABLE -1
+
+#define SQL_C_SBIGINT (SQL_BIGINT+SQL_SIGNED_OFFSET) /* SIGNED BIGINT */
+#define SQL_C_UBIGINT (SQL_BIGINT+SQL_UNSIGNED_OFFSET) /* UNSIGNED BIGINT */
+
+#define SQL_FALSE 0
+#define SQL_TRUE 1
+
diff --git a/include/private/apr_dbm_private.h b/include/private/apr_dbm_private.h
new file mode 100644
index 000000000..020d3a6b8
--- /dev/null
+++ b/include/private/apr_dbm_private.h
@@ -0,0 +1,121 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef APR_DBM_PRIVATE_H
+#define APR_DBM_PRIVATE_H
+
+#include "apr.h"
+#include "apr_errno.h"
+#include "apr_pools.h"
+#include "apr_dbm.h"
+#include "apr_file_io.h"
+
+#include "apu.h"
+
+/* ### for now, include the DBM selection; this will go away once we start
+ ### building and linking all of the DBMs at once. */
+#include "apu_select_dbm.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** @internal */
+
+/**
+ * Most DBM libraries take a POSIX mode for creating files. Don't trust
+ * the mode_t type, some platforms may not support it, int is safe.
+ */
+APU_DECLARE(int) apr_posix_perms2mode(apr_fileperms_t perm);
+
+/**
+ * Structure to describe the operations of the DBM
+ */
+typedef struct {
+ /** The name of the DBM Type */
+ const char *name;
+
+ /** Open the DBM */
+ apr_status_t (*open)(apr_dbm_t **pdb, const char *pathname,
+ apr_int32_t mode, apr_fileperms_t perm,
+ apr_pool_t *pool);
+
+ /** Close the DBM */
+ void (*close)(apr_dbm_t *dbm);
+
+ /** Fetch a dbm record value by key */
+ apr_status_t (*fetch)(apr_dbm_t *dbm, apr_datum_t key,
+ apr_datum_t * pvalue);
+
+ /** Store a dbm record value by key */
+ apr_status_t (*store)(apr_dbm_t *dbm, apr_datum_t key, apr_datum_t value);
+
+ /** Delete a dbm record value by key */
+ apr_status_t (*del)(apr_dbm_t *dbm, apr_datum_t key);
+
+ /** Search for a key within the dbm */
+ int (*exists)(apr_dbm_t *dbm, apr_datum_t key);
+
+ /** Retrieve the first record key from a dbm */
+ apr_status_t (*firstkey)(apr_dbm_t *dbm, apr_datum_t * pkey);
+
+ /** Retrieve the next record key from a dbm */
+ apr_status_t (*nextkey)(apr_dbm_t *dbm, apr_datum_t * pkey);
+
+ /** Proactively toss any memory associated with the apr_datum_t. */
+ void (*freedatum)(apr_dbm_t *dbm, apr_datum_t data);
+
+ /** Get the names that the DBM will use for a given pathname. */
+ void (*getusednames)(apr_pool_t *pool,
+ const char *pathname,
+ const char **used1,
+ const char **used2);
+
+} apr_dbm_type_t;
+
+
+/**
+ * The actual DBM
+ */
+struct apr_dbm_t
+{
+ /** Associated pool */
+ apr_pool_t *pool;
+
+ /** pointer to DB Implementation Specific data */
+ void *file;
+
+ /** Current integer error code */
+ int errcode;
+ /** Current string error code */
+ const char *errmsg;
+
+ /** the type of DBM */
+ const apr_dbm_type_t *type;
+};
+
+
+/* Declare all of the DBM provider tables */
+APU_MODULE_DECLARE_DATA extern const apr_dbm_type_t apr_dbm_type_sdbm;
+APU_MODULE_DECLARE_DATA extern const apr_dbm_type_t apr_dbm_type_gdbm;
+APU_MODULE_DECLARE_DATA extern const apr_dbm_type_t apr_dbm_type_ndbm;
+APU_MODULE_DECLARE_DATA extern const apr_dbm_type_t apr_dbm_type_db;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* APR_DBM_PRIVATE_H */
diff --git a/include/private/apu_config.hnw b/include/private/apu_config.hnw
new file mode 100644
index 000000000..9c6c73e46
--- /dev/null
+++ b/include/private/apu_config.hnw
@@ -0,0 +1,53 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * Note: This is a NetWare specific version of apu_config.hnw. It is copied
+ * as apu_config.h at the start of a NetWare build.
+ */
+
+#ifdef NETWARE
+
+#ifndef APU_CONFIG_H
+#define APU_CONFIG_H
+
+/* Always compile Netware with DSO support for .nlm builds */
+#define APU_DSO_BUILD 0
+
+/*
+ * NetWare does not have GDBM, and we always use the bundled (new) Expat
+ */
+
+/* Define if you have the gdbm library (-lgdbm). */
+/* #undef HAVE_LIBGDBM */
+
+/* define if Expat 1.0 or 1.1 was found */
+/* #undef APR_HAVE_OLD_EXPAT */
+
+/* NetWare uses its own ICONV implementation. */
+#define HAVE_ICONV_H 1
+
+/*
+ * check for newer NDKs which use now correctly 'const char*' with iconv.
+ */
+#include <ndkvers.h>
+#if (CURRENT_NDK_THRESHOLD >= 705110000)
+#define APU_ICONV_INBUF_CONST
+#endif
+
+#endif /* APU_CONFIG_H */
+#endif /* NETWARE */
+
diff --git a/include/private/apu_config.hw b/include/private/apu_config.hw
new file mode 100644
index 000000000..015dd5263
--- /dev/null
+++ b/include/private/apu_config.hw
@@ -0,0 +1,46 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * Note: This is a Windows specific version of apu_config.hw. It is copied
+ * as apu_config.h at the start of a Windows build.
+ */
+
+#ifdef WIN32
+
+#ifndef APU_CONFIG_H
+#define APU_CONFIG_H
+
+/* Compile win32 with DSO support for .dll builds */
+#ifdef APU_DECLARE_STATIC
+#define APU_DSO_BUILD 0
+#else
+#define APU_DSO_BUILD 1
+#endif
+
+/*
+ * Windows does not have GDBM, and we always use the bundled (new) Expat
+ */
+
+/* Define if you have the gdbm library (-lgdbm). */
+/* #undef HAVE_LIBGDBM */
+
+/* define if Expat 1.0 or 1.1 was found */
+/* #undef APR_HAVE_OLD_EXPAT */
+
+
+#endif /* APU_CONFIG_H */
+#endif /* WIN32 */
diff --git a/include/private/apu_internal.h b/include/private/apu_internal.h
new file mode 100644
index 000000000..c95c9d502
--- /dev/null
+++ b/include/private/apu_internal.h
@@ -0,0 +1,73 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "apr.h"
+#include "apr_dso.h"
+#include "apu.h"
+
+#ifndef APU_INTERNAL_H
+#define APU_INTERNAL_H
+
+#if APU_DSO_BUILD
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* For modular dso loading, an internal interlock to allow us to
+ * continue to initialize modules by multiple threads, the caller
+ * of apu_dso_load must lock first, and not unlock until any init
+ * finalization is complete.
+ */
+apr_status_t apu_dso_init(apr_pool_t *pool);
+
+apr_status_t apu_dso_mutex_lock(void);
+apr_status_t apu_dso_mutex_unlock(void);
+
+apr_status_t apu_dso_load(apr_dso_handle_t **dso, apr_dso_handle_sym_t *dsoptr, const char *module,
+ const char *modsym, apr_pool_t *pool);
+
+#if APR_HAS_LDAP
+
+/* For LDAP internal builds, wrap our LDAP namespace */
+
+struct apr__ldap_dso_fntable {
+ int (*info)(apr_pool_t *pool, apr_ldap_err_t **result_err);
+ int (*init)(apr_pool_t *pool, LDAP **ldap, const char *hostname,
+ int portno, int secure, apr_ldap_err_t **result_err);
+ int (*ssl_init)(apr_pool_t *pool, const char *cert_auth_file,
+ int cert_file_type, apr_ldap_err_t **result_err);
+ int (*ssl_deinit)(void);
+ int (*get_option)(apr_pool_t *pool, LDAP *ldap, int option,
+ void *outvalue, apr_ldap_err_t **result_err);
+ int (*set_option)(apr_pool_t *pool, LDAP *ldap, int option,
+ const void *invalue, apr_ldap_err_t **result_err);
+ apr_status_t (*rebind_init)(apr_pool_t *pool);
+ apr_status_t (*rebind_add)(apr_pool_t *pool, LDAP *ld,
+ const char *bindDN, const char *bindPW);
+ apr_status_t (*rebind_remove)(LDAP *ld);
+};
+
+#endif /* APR_HAS_LDAP */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* APU_DSO_BUILD */
+
+#endif /* APU_INTERNAL_H */
+
diff --git a/include/private/apu_select_dbm.h.in b/include/private/apu_select_dbm.h.in
new file mode 100644
index 000000000..b69aec032
--- /dev/null
+++ b/include/private/apu_select_dbm.h.in
@@ -0,0 +1,28 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef APU_SELECT_DBM_H
+#define APU_SELECT_DBM_H
+
+/*
+** The following macros control what features APRUTIL will use
+*/
+#define APU_USE_SDBM @apu_use_sdbm@
+#define APU_USE_NDBM @apu_use_ndbm@
+#define APU_USE_GDBM @apu_use_gdbm@
+#define APU_USE_DB @apu_use_db@
+
+#endif /* !APU_SELECT_DBM_H */
diff --git a/include/private/apu_select_dbm.hw b/include/private/apu_select_dbm.hw
new file mode 100644
index 000000000..97c7b6c22
--- /dev/null
+++ b/include/private/apu_select_dbm.hw
@@ -0,0 +1,28 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef APU_SELECT_DBM_H
+#define APU_SELECT_DBM_H
+
+/*
+** The following macros control what features APRUTIL will use
+*/
+#define APU_USE_SDBM 1
+#define APU_USE_GDBM 0
+#define APU_USE_NDBM 0
+#define APU_USE_DB 0
+
+#endif /* !APU_SELECT_DBM_H */