db_mongodb_mod.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /**
  2. * Copyright (C) 2014 Daniel-Constantin Mierla (asipto.com)
  3. *
  4. * This file is part of Kamailio, a free SIP server.
  5. *
  6. * Kamailio is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version
  10. *
  11. * Kamailio 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
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. *
  20. */
  21. #include <string.h>
  22. #include <stdlib.h>
  23. #include <stdio.h>
  24. #include "../../sr_module.h"
  25. #include "../../dprint.h"
  26. #include "../../lib/srdb1/db.h"
  27. #include "../../lib/srdb1/db_query.h"
  28. #include "mongodb_dbase.h"
  29. MODULE_VERSION
  30. static int db_mongodb_bind_api(db_func_t *dbb);
  31. static int mod_init(void);
  32. static cmd_export_t cmds[] = {
  33. {"db_bind_api", (cmd_function)db_mongodb_bind_api, 0, 0, 0, 0},
  34. {0, 0, 0, 0, 0, 0}
  35. };
  36. /*
  37. * Exported parameters
  38. */
  39. static param_export_t params[] = {
  40. {0, 0, 0}
  41. };
  42. struct module_exports exports = {
  43. "db_mongodb",
  44. DEFAULT_DLFLAGS, /* dlopen flags */
  45. cmds,
  46. params, /* module parameters */
  47. 0, /* exported statistics */
  48. 0, /* exported MI functions */
  49. 0, /* exported pseudo-variables */
  50. 0, /* extra processes */
  51. mod_init, /* module initialization function */
  52. 0, /* response function*/
  53. 0, /* destroy function */
  54. 0 /* per-child init function */
  55. };
  56. static int db_mongodb_bind_api(db_func_t *dbb)
  57. {
  58. if(dbb==NULL)
  59. return -1;
  60. memset(dbb, 0, sizeof(db_func_t));
  61. dbb->use_table = db_mongodb_use_table;
  62. dbb->init = db_mongodb_init;
  63. dbb->close = db_mongodb_close;
  64. dbb->query = db_mongodb_query;
  65. dbb->fetch_result = 0; //db_mongodb_fetch_result;
  66. dbb->raw_query = 0; //db_mongodb_raw_query;
  67. dbb->free_result = db_mongodb_free_result;
  68. dbb->insert = db_mongodb_insert;
  69. dbb->delete = db_mongodb_delete;
  70. dbb->update = db_mongodb_update;
  71. dbb->replace = 0; //db_mongodb_replace;
  72. return 0;
  73. }
  74. int mod_register(char *path, int *dlflags, void *p1, void *p2)
  75. {
  76. if(db_api_init()<0)
  77. return -1;
  78. return 0;
  79. }
  80. static int mod_init(void)
  81. {
  82. LM_DBG("module initializing\n");
  83. return 0;
  84. }