db_unixodbc.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * $Id$
  3. *
  4. * UNIXODBC module interface
  5. *
  6. * Copyright (C) 2005-2006 Marco Lorrai
  7. * Copyright (C) 2008 1&1 Internet AG
  8. *
  9. * This file is part of Kamailio, a free SIP server.
  10. *
  11. * Kamailio is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version
  15. *
  16. * Kamailio is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  24. *
  25. *
  26. * History:
  27. * --------
  28. * 2005-12-01 initial commit (chgen)
  29. */
  30. #include "../../sr_module.h"
  31. #include "../../lib/srdb1/db.h"
  32. #include "../../lib/srdb1/db_query.h"
  33. #include "dbase.h"
  34. #include "db_unixodbc.h"
  35. int ping_interval = 5 * 60; /* Default is 5 minutes */
  36. int auto_reconnect = 1; /* Default is enabled */
  37. int use_escape_common = 0; /* Enable common escaping */
  38. MODULE_VERSION
  39. int db_unixodbc_bind_api(db_func_t *dbb);
  40. int unixodbc_mod_init(void);
  41. /*
  42. * MySQL database module interface
  43. */
  44. static cmd_export_t cmds[] = {
  45. {"db_bind_api", (cmd_function)db_unixodbc_bind_api, 0, 0, 0, 0},
  46. {0, 0, 0, 0, 0, 0}
  47. };
  48. /*
  49. * Exported parameters
  50. */
  51. static param_export_t params[] = {
  52. {"ping_interval", INT_PARAM, &ping_interval},
  53. {"auto_reconnect", INT_PARAM, &auto_reconnect},
  54. {"use_escape_common", INT_PARAM, &use_escape_common},
  55. {0, 0, 0}
  56. };
  57. struct module_exports exports = {
  58. "db_unixodbc",
  59. DEFAULT_DLFLAGS, /* dlopen flags */
  60. cmds,
  61. params, /* module parameters */
  62. 0, /* exported statistics */
  63. 0, /* exported MI functions */
  64. 0, /* exported pseudo-variables */
  65. 0, /* extra processes */
  66. unixodbc_mod_init, /* module initialization function */
  67. 0, /* response function*/
  68. 0, /* destroy function */
  69. 0 /* per-child init function */
  70. };
  71. int db_unixodbc_bind_api(db_func_t *dbb)
  72. {
  73. if(dbb==NULL)
  74. return -1;
  75. memset(dbb, 0, sizeof(db_func_t));
  76. dbb->use_table = db_unixodbc_use_table;
  77. dbb->init = db_unixodbc_init;
  78. dbb->close = db_unixodbc_close;
  79. dbb->query = db_unixodbc_query;
  80. dbb->fetch_result = db_unixodbc_fetch_result;
  81. dbb->raw_query = db_unixodbc_raw_query;
  82. dbb->free_result = db_unixodbc_free_result;
  83. dbb->insert = db_unixodbc_insert;
  84. dbb->delete = db_unixodbc_delete;
  85. dbb->update = db_unixodbc_update;
  86. dbb->replace = db_unixodbc_replace;
  87. return 0;
  88. }
  89. int mod_register(char *path, int *dlflags, void *p1, void *p2)
  90. {
  91. if(db_api_init()<0)
  92. return -1;
  93. return 0;
  94. }
  95. int unixodbc_mod_init(void)
  96. {
  97. return 0;
  98. }