km_db_postgres.c 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 "km_dbase.h"
  38. #include "km_db_postgres.h"
  39. /*MODULE_VERSION*/
  40. /*
  41. * PostgreSQL database module interface
  42. */
  43. static kam_cmd_export_t cmds[]={
  44. {"db_bind_api", (cmd_function)db_postgres_bind_api, 0, 0, 0, 0},
  45. {0,0,0,0,0,0}
  46. };
  47. struct kam_module_exports kam_exports = {
  48. "db_postgres",
  49. DEFAULT_DLFLAGS, /* dlopen flags */
  50. cmds,
  51. 0, /* module parameters */
  52. 0, /* exported statistics */
  53. 0, /* exported MI functions */
  54. 0, /* exported pseudo-variables */
  55. 0, /* extra processes */
  56. km_postgres_mod_init, /* module initialization function */
  57. 0, /* response function*/
  58. 0, /* destroy function */
  59. 0 /* per-child init function */
  60. };
  61. int km_postgres_mod_init(void)
  62. {
  63. return 0;
  64. }
  65. int db_postgres_bind_api(db_func_t *dbb)
  66. {
  67. if(dbb==NULL)
  68. return -1;
  69. memset(dbb, 0, sizeof(db_func_t));
  70. dbb->use_table = db_postgres_use_table;
  71. dbb->init = db_postgres_init;
  72. dbb->close = db_postgres_close;
  73. dbb->query = db_postgres_query;
  74. dbb->fetch_result = db_postgres_fetch_result;
  75. dbb->raw_query = db_postgres_raw_query;
  76. dbb->free_result = db_postgres_free_result;
  77. dbb->insert = db_postgres_insert;
  78. dbb->delete = db_postgres_delete;
  79. dbb->update = db_postgres_update;
  80. return 0;
  81. }