mongodb_client.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. #ifndef _MONGODB_CLIENT_H_
  22. #define _MONGODB_CLIENT_H_
  23. #include <mongoc.h>
  24. #include <bson.h>
  25. #include "../../str.h"
  26. #include "../../parser/parse_param.h"
  27. #include "../../mod_fix.h"
  28. int mongodbc_init(void);
  29. int mongodbc_destroy(void);
  30. int mongodbc_add_server(char *spec);
  31. int mongodbc_exec_simple(str *srv, str *dname, str *cname, str *cmd, str *res);
  32. int mongodbc_exec(str *srv, str *dname, str *cname, str *cmd, str *res);
  33. int mongodbc_find(str *srv, str *dname, str *cname, str *cmd, str *res);
  34. typedef struct mongodbc_server {
  35. str *sname;
  36. str *uri;
  37. unsigned int hname;
  38. param_t *attrs;
  39. mongoc_client_t *client;
  40. struct mongodbc_server *next;
  41. } mongodbc_server_t;
  42. typedef struct mongodbc_reply {
  43. str rname;
  44. unsigned int hname;
  45. mongoc_collection_t *collection;
  46. mongoc_cursor_t *cursor;
  47. str jsonrpl;
  48. struct mongodbc_reply *next;
  49. } mongodbc_reply_t;
  50. typedef struct mongodbc_pv {
  51. str rname;
  52. mongodbc_reply_t *reply;
  53. str rkey;
  54. int rkeyid;
  55. } mongodbc_pv_t;
  56. /* Server related functions */
  57. mongodbc_server_t* mongodbc_get_server(str *name);
  58. int mongodbc_reconnect_server(mongodbc_server_t *rsrv);
  59. /* Command related functions */
  60. mongodbc_reply_t *mongodbc_get_reply(str *name);
  61. int mongodbc_free_reply(str *name);
  62. int mongodbc_next_reply(str *name);
  63. #endif