dbase.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * $Id$
  3. *
  4. * SQlite module core functions
  5. *
  6. * Copyright (C) 2010 Timo Teräs
  7. *
  8. * This file is part of Kamailio, a free SIP server.
  9. *
  10. * Kamailio is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version
  14. *
  15. * Kamailio is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  23. */
  24. #ifndef DBASE_H
  25. #define DBASE_H
  26. #include <sqlite3.h>
  27. #include "../../lib/srdb1/db_pool.h"
  28. #include "../../lib/srdb1/db_con.h"
  29. #include "../../lib/srdb1/db_res.h"
  30. #include "../../lib/srdb1/db_key.h"
  31. #include "../../lib/srdb1/db_op.h"
  32. #include "../../lib/srdb1/db_val.h"
  33. #define DB_SQLITE_MAX_BINDS 64
  34. struct sqlite_connection {
  35. struct pool_con hdr;
  36. sqlite3 *conn;
  37. int bindpos;
  38. sqlite3_stmt *stmt;
  39. const db_val_t *bindarg[DB_SQLITE_MAX_BINDS];
  40. };
  41. #define CON_SQLITE(db_con) ((struct sqlite_connection *) db_con->tail)
  42. db1_con_t* db_sqlite_init(const str* _sqlurl);
  43. void db_sqlite_close(db1_con_t* _h);
  44. int db_sqlite_free_result(db1_con_t* _h, db1_res_t* _r);
  45. int db_sqlite_query(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _op,
  46. const db_val_t* _v, const db_key_t* _c, int _n, int _nc,
  47. const db_key_t _o, db1_res_t** _r);
  48. int db_sqlite_insert(const db1_con_t* _h, const db_key_t* _k, const db_val_t* _v,
  49. int _n);
  50. int db_sqlite_delete(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _o,
  51. const db_val_t* _v, int _n);
  52. int db_sqlite_update(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _o,
  53. const db_val_t* _v, const db_key_t* _uk, const db_val_t* _uv,
  54. int _n, int _un);
  55. int db_sqlite_raw_query(const db1_con_t* _h, const str* _s, db1_res_t** _r);
  56. int db_sqlite_use_table(db1_con_t* _h, const str* _t);
  57. #endif /* DBASE_H */