1 /* 2 * libdbi - database independent abstraction layer for C. 3 * Copyright (C) 2001-2003, David Parker and Mark Tobenkin. 4 * http://libdbi.sourceforge.net 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 2.1 of the License, or (at your option) any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with this library; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 * 20 * $Id: dbd.h,v 1.33 2013/01/08 23:54:30 mhoenicka Exp $ 21 */ 22 23 24 #ifndef __DBD_H__ 25 #define __DBD_H__ 26 27 #ifdef __cplusplus 28 extern "C" { 29 #endif 30 31 #include <dbi/dbi.h> 32 #include <dbi/dbi-dev.h> 33 34 /* FUNCTIONS EXPORTED BY EACH DRIVER */ 35 void dbd_register_driver(const dbi_info_t **_driver_info, const char ***_custom_functions, const char ***_reserved_words); 36 int dbd_initialize(dbi_driver_t *driver); 37 int dbd_finalize(dbi_driver_t *driver); 38 int dbd_connect(dbi_conn_t *conn); 39 int dbd_disconnect(dbi_conn_t *conn); 40 int dbd_fetch_row(dbi_result_t *result, unsigned long long rowidx); 41 int dbd_free_query(dbi_result_t *result); 42 int dbd_goto_row(dbi_result_t *result, unsigned long long rowidx, unsigned long long currowidx); 43 int dbd_get_socket(dbi_conn_t *conn); 44 const char *dbd_get_encoding(dbi_conn_t *conn); 45 const char* dbd_encoding_from_iana(const char *iana_encoding); 46 const char* dbd_encoding_to_iana(const char *iana_encoding); 47 char *dbd_get_engine_version(dbi_conn_t *conn, char *versionstring); 48 dbi_result_t *dbd_list_dbs(dbi_conn_t *conn, const char *pattern); 49 dbi_result_t *dbd_list_tables(dbi_conn_t *conn, const char *db, const char *pattern); 50 dbi_result_t *dbd_query(dbi_conn_t *conn, const char *statement); 51 dbi_result_t *dbd_query_null(dbi_conn_t *conn, const unsigned char *statement, size_t st_length); 52 int dbd_transaction_begin(dbi_conn_t *conn); 53 int dbd_transaction_commit(dbi_conn_t *conn); 54 int dbd_transaction_rollback(dbi_conn_t *conn); 55 int dbd_savepoint(dbi_conn_t *conn, const char *savepoint); 56 int dbd_rollback_to_savepoint(dbi_conn_t *conn, const char *savepoint); 57 int dbd_release_savepoint(dbi_conn_t *conn, const char *savepoint); 58 size_t dbd_quote_string(dbi_driver_t *driver, const char *orig, char *dest); 59 size_t dbd_quote_binary(dbi_conn_t *conn, const unsigned char *orig, size_t from_length, unsigned char **ptr_dest); 60 size_t dbd_conn_quote_string(dbi_conn_t *conn, const char *orig, char *dest); 61 const char *dbd_select_db(dbi_conn_t *conn, const char *db); 62 int dbd_geterror(dbi_conn_t *conn, int *err_no, char **errstr); 63 unsigned long long dbd_get_seq_last(dbi_conn_t *conn, const char *sequence); 64 unsigned long long dbd_get_seq_next(dbi_conn_t *conn, const char *sequence); 65 int dbd_ping(dbi_conn_t *conn); 66 67 /* _DBD_* DRIVER AUTHORS HELPER FUNCTIONS */ 68 dbi_result_t *_dbd_result_create(dbi_conn_t *conn, void *handle, unsigned long long numrows_matched, unsigned long long numrows_affected); 69 void _dbd_result_set_numfields(dbi_result_t *result, unsigned int numfields); 70 void _dbd_result_add_field(dbi_result_t *result, unsigned int fieldidx, char *name, unsigned short type, unsigned int attribs); 71 dbi_row_t *_dbd_row_allocate(unsigned int numfields); 72 void _dbd_row_finalize(dbi_result_t *result, dbi_row_t *row, unsigned long long rowidx); 73 void _dbd_internal_error_handler(dbi_conn_t *conn, const char *errmsg, const int err_no); 74 dbi_result_t *_dbd_result_create_from_stringarray(dbi_conn_t *conn, unsigned long long numrows_matched, const char **stringarray); 75 void _dbd_register_driver_cap(dbi_driver_t *driver, const char *capname, int value); 76 void _dbd_register_conn_cap(dbi_conn_t *conn, const char *capname, int value); 77 int _dbd_result_add_to_conn(dbi_result_t *result); 78 time_t _dbd_parse_datetime(const char *raw, unsigned int attribs); 79 size_t _dbd_escape_chars(char *dest, const char *orig, size_t orig_size, const char *toescape); 80 size_t _dbd_encode_binary(const unsigned char *in, size_t n, unsigned char *out); 81 size_t _dbd_decode_binary(const unsigned char *in, unsigned char *out); 82 83 #ifdef __cplusplus 84 } 85 #endif /* __cplusplus */ 86 87 #endif /* __DBD_H__ */ 88