Apache Portable Runtime Utility Library
|
00001 /* Licensed to the Apache Software Foundation (ASF) under one or more 00002 * contributor license agreements. See the NOTICE file distributed with 00003 * this work for additional information regarding copyright ownership. 00004 * The ASF licenses this file to You under the Apache License, Version 2.0 00005 * (the "License"); you may not use this file except in compliance with 00006 * the License. You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 /* Overview of what this is and does: 00018 * http://www.apache.org/~niq/dbd.html 00019 */ 00020 00021 #ifndef APR_DBD_H 00022 #define APR_DBD_H 00023 00024 #include "apu.h" 00025 #include "apr_pools.h" 00026 00027 #ifdef __cplusplus 00028 extern "C" { 00029 #endif 00030 00055 typedef enum { 00056 APR_DBD_TYPE_NONE, 00057 APR_DBD_TYPE_TINY, 00058 APR_DBD_TYPE_UTINY, 00059 APR_DBD_TYPE_SHORT, 00060 APR_DBD_TYPE_USHORT, 00061 APR_DBD_TYPE_INT, 00062 APR_DBD_TYPE_UINT, 00063 APR_DBD_TYPE_LONG, 00064 APR_DBD_TYPE_ULONG, 00065 APR_DBD_TYPE_LONGLONG, 00066 APR_DBD_TYPE_ULONGLONG, 00067 APR_DBD_TYPE_FLOAT, 00068 APR_DBD_TYPE_DOUBLE, 00069 APR_DBD_TYPE_STRING, 00070 APR_DBD_TYPE_TEXT, 00071 APR_DBD_TYPE_TIME, 00072 APR_DBD_TYPE_DATE, 00073 APR_DBD_TYPE_DATETIME, 00074 APR_DBD_TYPE_TIMESTAMP, 00075 APR_DBD_TYPE_ZTIMESTAMP, 00076 APR_DBD_TYPE_BLOB, 00077 APR_DBD_TYPE_CLOB, 00078 APR_DBD_TYPE_NULL 00079 } apr_dbd_type_e; 00080 00081 /* These are opaque structs. Instantiation is up to each backend */ 00082 typedef struct apr_dbd_driver_t apr_dbd_driver_t; 00083 typedef struct apr_dbd_t apr_dbd_t; 00084 typedef struct apr_dbd_transaction_t apr_dbd_transaction_t; 00085 typedef struct apr_dbd_results_t apr_dbd_results_t; 00086 typedef struct apr_dbd_row_t apr_dbd_row_t; 00087 typedef struct apr_dbd_prepared_t apr_dbd_prepared_t; 00088 00093 APU_DECLARE(apr_status_t) apr_dbd_init(apr_pool_t *pool); 00094 00105 APU_DECLARE(apr_status_t) apr_dbd_get_driver(apr_pool_t *pool, const char *name, 00106 const apr_dbd_driver_t **driver); 00107 00140 APU_DECLARE(apr_status_t) apr_dbd_open_ex(const apr_dbd_driver_t *driver, 00141 apr_pool_t *pool, const char *params, 00142 apr_dbd_t **handle, 00143 const char **error); 00144 00155 APU_DECLARE(apr_status_t) apr_dbd_open(const apr_dbd_driver_t *driver, 00156 apr_pool_t *pool, const char *params, 00157 apr_dbd_t **handle); 00158 00165 APU_DECLARE(apr_status_t) apr_dbd_close(const apr_dbd_driver_t *driver, 00166 apr_dbd_t *handle); 00167 00168 /* apr-function-shaped versions of things */ 00169 00175 APU_DECLARE(const char*) apr_dbd_name(const apr_dbd_driver_t *driver); 00176 00183 APU_DECLARE(void*) apr_dbd_native_handle(const apr_dbd_driver_t *driver, 00184 apr_dbd_t *handle); 00185 00193 APU_DECLARE(int) apr_dbd_check_conn(const apr_dbd_driver_t *driver, apr_pool_t *pool, 00194 apr_dbd_t *handle); 00195 00204 APU_DECLARE(int) apr_dbd_set_dbname(const apr_dbd_driver_t *driver, apr_pool_t *pool, 00205 apr_dbd_t *handle, const char *name); 00206 00221 APU_DECLARE(int) apr_dbd_transaction_start(const apr_dbd_driver_t *driver, 00222 apr_pool_t *pool, 00223 apr_dbd_t *handle, 00224 apr_dbd_transaction_t **trans); 00225 00235 APU_DECLARE(int) apr_dbd_transaction_end(const apr_dbd_driver_t *driver, 00236 apr_pool_t *pool, 00237 apr_dbd_transaction_t *trans); 00238 00239 #define APR_DBD_TRANSACTION_COMMIT 0x00 00240 #define APR_DBD_TRANSACTION_ROLLBACK 0x01 00241 #define APR_DBD_TRANSACTION_IGNORE_ERRORS 0x02 00249 APU_DECLARE(int) apr_dbd_transaction_mode_get(const apr_dbd_driver_t *driver, 00250 apr_dbd_transaction_t *trans); 00251 00259 APU_DECLARE(int) apr_dbd_transaction_mode_set(const apr_dbd_driver_t *driver, 00260 apr_dbd_transaction_t *trans, 00261 int mode); 00262 00271 APU_DECLARE(int) apr_dbd_query(const apr_dbd_driver_t *driver, apr_dbd_t *handle, 00272 int *nrows, const char *statement); 00273 00286 APU_DECLARE(int) apr_dbd_select(const apr_dbd_driver_t *driver, apr_pool_t *pool, 00287 apr_dbd_t *handle, apr_dbd_results_t **res, 00288 const char *statement, int random); 00289 00296 APU_DECLARE(int) apr_dbd_num_cols(const apr_dbd_driver_t *driver, 00297 apr_dbd_results_t *res); 00298 00306 APU_DECLARE(int) apr_dbd_num_tuples(const apr_dbd_driver_t *driver, 00307 apr_dbd_results_t *res); 00308 00319 APU_DECLARE(int) apr_dbd_get_row(const apr_dbd_driver_t *driver, apr_pool_t *pool, 00320 apr_dbd_results_t *res, apr_dbd_row_t **row, 00321 int rownum); 00322 00330 APU_DECLARE(const char*) apr_dbd_get_entry(const apr_dbd_driver_t *driver, 00331 apr_dbd_row_t *row, int col); 00332 00340 APU_DECLARE(const char*) apr_dbd_get_name(const apr_dbd_driver_t *driver, 00341 apr_dbd_results_t *res, int col); 00342 00343 00352 APU_DECLARE(const char*) apr_dbd_error(const apr_dbd_driver_t *driver, 00353 apr_dbd_t *handle, int errnum); 00354 00363 APU_DECLARE(const char*) apr_dbd_escape(const apr_dbd_driver_t *driver, 00364 apr_pool_t *pool, const char *string, 00365 apr_dbd_t *handle); 00366 00395 APU_DECLARE(int) apr_dbd_prepare(const apr_dbd_driver_t *driver, apr_pool_t *pool, 00396 apr_dbd_t *handle, const char *query, 00397 const char *label, 00398 apr_dbd_prepared_t **statement); 00399 00400 00412 APU_DECLARE(int) apr_dbd_pquery(const apr_dbd_driver_t *driver, apr_pool_t *pool, 00413 apr_dbd_t *handle, int *nrows, 00414 apr_dbd_prepared_t *statement, int nargs, 00415 const char **args); 00416 00429 APU_DECLARE(int) apr_dbd_pselect(const apr_dbd_driver_t *driver, apr_pool_t *pool, 00430 apr_dbd_t *handle, apr_dbd_results_t **res, 00431 apr_dbd_prepared_t *statement, int random, 00432 int nargs, const char **args); 00433 00444 APU_DECLARE_NONSTD(int) apr_dbd_pvquery(const apr_dbd_driver_t *driver, 00445 apr_pool_t *pool, 00446 apr_dbd_t *handle, int *nrows, 00447 apr_dbd_prepared_t *statement, ...); 00448 00460 APU_DECLARE_NONSTD(int) apr_dbd_pvselect(const apr_dbd_driver_t *driver, 00461 apr_pool_t *pool, apr_dbd_t *handle, 00462 apr_dbd_results_t **res, 00463 apr_dbd_prepared_t *statement, 00464 int random, ...); 00465 00476 APU_DECLARE(int) apr_dbd_pbquery(const apr_dbd_driver_t *driver, 00477 apr_pool_t *pool, apr_dbd_t *handle, 00478 int *nrows, apr_dbd_prepared_t *statement, 00479 const void **args); 00480 00492 APU_DECLARE(int) apr_dbd_pbselect(const apr_dbd_driver_t *driver, 00493 apr_pool_t *pool, 00494 apr_dbd_t *handle, apr_dbd_results_t **res, 00495 apr_dbd_prepared_t *statement, int random, 00496 const void **args); 00497 00508 APU_DECLARE_NONSTD(int) apr_dbd_pvbquery(const apr_dbd_driver_t *driver, 00509 apr_pool_t *pool, 00510 apr_dbd_t *handle, int *nrows, 00511 apr_dbd_prepared_t *statement, ...); 00512 00524 APU_DECLARE_NONSTD(int) apr_dbd_pvbselect(const apr_dbd_driver_t *driver, 00525 apr_pool_t *pool, apr_dbd_t *handle, 00526 apr_dbd_results_t **res, 00527 apr_dbd_prepared_t *statement, 00528 int random, ...); 00529 00539 APU_DECLARE(apr_status_t) apr_dbd_datum_get(const apr_dbd_driver_t *driver, 00540 apr_dbd_row_t *row, int col, 00541 apr_dbd_type_e type, void *data); 00542 00545 #ifdef __cplusplus 00546 } 00547 #endif 00548 00549 #endif