api.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /**
  2. * ndb_mongodb module
  3. *
  4. * Copyright (C) 2015 Daniel-Constantin Mierla (asipto.com)
  5. *
  6. * This file is part of Kamailio, a free SIP server.
  7. *
  8. * Kamailio is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version
  12. *
  13. * Kamailio is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. *
  22. */
  23. #ifndef _NDB_MONGODB_API_H_
  24. #define _NDB_MONGODB_API_H_
  25. #include "../../sr_module.h"
  26. typedef int (*mongodbc_exec_simple_f)(str *srv, str *dname, str *cname, str *cmd, str *res);
  27. typedef int (*mongodbc_exec_f)(str *srv, str *dname, str *cname, str *cmd, str *res);
  28. typedef int (*mongodbc_find_f)(str *srv, str *dname, str *cname, str *cmd, str *res);
  29. typedef int (*mongodbc_find_one_f)(str *srv, str *dname, str *cname, str *cmd, str *res);
  30. typedef int (*mongodbc_next_reply_f)(str *name);
  31. typedef int (*mongodbc_free_reply_f)(str *name);
  32. typedef struct ndb_mongodb_api {
  33. mongodbc_exec_simple_f cmd_simple;
  34. mongodbc_exec_f cmd;
  35. mongodbc_find_f find;
  36. mongodbc_find_one_f find_one;
  37. mongodbc_next_reply_f next_reply;
  38. mongodbc_next_reply_f free_reply;
  39. } ndb_mongodb_api_t;
  40. typedef int (*bind_ndb_mongodb_f)(ndb_mongodb_api_t* api);
  41. int bind_ndb_mongodb(ndb_mongodb_api_t* api);
  42. /**
  43. * @brief Load the dispatcher API
  44. */
  45. static inline int ndb_mongodb_load_api(ndb_mongodb_api_t *api)
  46. {
  47. bind_ndb_mongodb_f bindndbmongodb;
  48. bindndbmongodb = (bind_ndb_mongodb_f)find_export("bind_ndb_mongodb", 0, 0);
  49. if(bindndbmongodb == 0) {
  50. LM_ERR("cannot find bind_ndb_mongodb\n");
  51. return -1;
  52. }
  53. if(bindndbmongodb(api)<0)
  54. {
  55. LM_ERR("cannot bind ndb mongodb api\n");
  56. return -1;
  57. }
  58. return 0;
  59. }
  60. #endif