km_db_postgres.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * $Id$
  3. *
  4. * Copyright (C) 2001-2003 FhG Fokus
  5. * Copyright (C) 2008 1&1 Internet AG
  6. *
  7. * This file is part of Kamailio, a free SIP server.
  8. *
  9. * Kamailio is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version
  13. *
  14. * Kamailio is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. */
  23. /*! \file
  24. * \brief DB_POSTGRES :: Core
  25. * \ingroup db_postgres
  26. * Module: \ref db_postgres
  27. */
  28. /*! \defgroup db_postgres DB_POSTGRES :: the PostgreSQL driver for Kamailio
  29. * \brief The Kamailio database interface to the PostgreSQL database
  30. * - http://www.postgresql.org
  31. *
  32. */
  33. #include <stdio.h>
  34. #include "../../sr_module.h"
  35. #include "../../lib/srdb1/db_con.h"
  36. #include "../../lib/srdb1/db.h"
  37. #include "../../lib/srdb1/db_query.h"
  38. #include "km_dbase.h"
  39. #include "km_db_postgres.h"
  40. /*MODULE_VERSION*/
  41. /*
  42. * PostgreSQL database module interface
  43. */
  44. static kam_cmd_export_t cmds[]={
  45. {"db_bind_api", (cmd_function)db_postgres_bind_api, 0, 0, 0, 0},
  46. {0,0,0,0,0,0}
  47. };
  48. struct kam_module_exports kam_exports = {
  49. "db_postgres",
  50. DEFAULT_DLFLAGS, /* dlopen flags */
  51. cmds,
  52. 0, /* module parameters */
  53. 0, /* exported statistics */
  54. 0, /* exported MI functions */
  55. 0, /* exported pseudo-variables */
  56. 0, /* extra processes */
  57. km_postgres_mod_init, /* module initialization function */
  58. 0, /* response function*/
  59. 0, /* destroy function */
  60. 0 /* per-child init function */
  61. };
  62. int km_postgres_mod_init(void)
  63. {
  64. return 0;
  65. }
  66. int db_postgres_bind_api(db_func_t *dbb)
  67. {
  68. if(dbb==NULL)
  69. return -1;
  70. memset(dbb, 0, sizeof(db_func_t));
  71. dbb->use_table = db_postgres_use_table;
  72. dbb->init = db_postgres_init;
  73. dbb->init2 = db_postgres_init2;
  74. dbb->close = db_postgres_close;
  75. dbb->query = db_postgres_query;
  76. dbb->fetch_result = db_postgres_fetch_result;
  77. dbb->raw_query = db_postgres_raw_query;
  78. dbb->free_result = db_postgres_free_result;
  79. dbb->insert = db_postgres_insert;
  80. dbb->delete = db_postgres_delete;
  81. dbb->update = db_postgres_update;
  82. dbb->replace = db_postgres_replace;
  83. dbb->affected_rows = db_postgres_affected_rows;
  84. dbb->start_transaction= db_postgres_start_transaction;
  85. dbb->end_transaction = db_postgres_end_transaction;
  86. dbb->abort_transaction= db_postgres_abort_transaction;
  87. dbb->query_lock = db_postgres_query_lock;
  88. return 0;
  89. }