api.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /**
  2. * $Id$
  3. *
  4. * Copyright (C) 2008 Elena-Ramona Modroiu (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. #ifndef _HT_MOD_API_H_
  23. #define _HT_MOD_API_H_
  24. #include "../../sr_module.h"
  25. #include "../../usr_avp.h"
  26. typedef int (*ht_api_set_cell_f)(str *hname, str *name, int type,
  27. int_str *val, int mode);
  28. typedef int (*ht_api_del_cell_f)(str *hname, str *name);
  29. typedef int (*ht_api_set_cell_expire_f)(str *hname, str *name,
  30. int type, int_str *val);
  31. typedef int (*ht_api_get_cell_expire_f)(str *hname, str *name,
  32. unsigned int *val);
  33. typedef int (*ht_api_rm_cell_re_f)(str *hname, str *sre, int mode);
  34. typedef int (*ht_api_count_cells_re_f)(str *hname, str *sre, int mode);
  35. typedef struct htable_api {
  36. ht_api_set_cell_f set;
  37. ht_api_del_cell_f rm;
  38. ht_api_set_cell_expire_f set_expire;
  39. ht_api_get_cell_expire_f get_expire;
  40. ht_api_rm_cell_re_f rm_re;
  41. ht_api_count_cells_re_f count_re;
  42. } htable_api_t;
  43. typedef int (*bind_htable_f)(htable_api_t* api);
  44. int bind_htable(htable_api_t* api);
  45. /**
  46. * @brief Load the Sanity API
  47. */
  48. static inline int htable_load_api(htable_api_t *api)
  49. {
  50. bind_htable_f bindhtable;
  51. bindhtable = (bind_htable_f)find_export("bind_htable", 0, 0);
  52. if(bindhtable == 0) {
  53. LM_ERR("cannot find bind_htable\n");
  54. return -1;
  55. }
  56. if(bindhtable(api)<0)
  57. {
  58. LM_ERR("cannot bind htable api\n");
  59. return -1;
  60. }
  61. return 0;
  62. }
  63. #endif