api.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * $Id$
  3. *
  4. * Copyright (C) 2012 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. #ifndef _CFGUTILS_API_H_
  23. #define _CFGUTILS_API_H_
  24. #include "../../str.h"
  25. typedef int (*cfgutils_lock_f)(str *lkey);
  26. typedef int (*cfgutils_unlock_f)(str *lkey);
  27. /**
  28. * @brief CFGUTILS API structure
  29. */
  30. typedef struct cfgutils_api {
  31. cfgutils_lock_f mlock;
  32. cfgutils_unlock_f munlock;
  33. } cfgutils_api_t;
  34. typedef int (*bind_cfgutils_f)(cfgutils_api_t* api);
  35. /**
  36. * @brief Load the CFGUTILS API
  37. */
  38. static inline int cfgutils_load_api(cfgutils_api_t *api)
  39. {
  40. bind_cfgutils_f bindcfgutils;
  41. bindcfgutils = (bind_cfgutils_f)find_export("bind_cfgutils", 0, 0);
  42. if(bindcfgutils == 0) {
  43. LM_ERR("cannot find bind_cfgutils\n");
  44. return -1;
  45. }
  46. if (bindcfgutils(api)<0)
  47. {
  48. LM_ERR("cannot bind cfgutils api\n");
  49. return -1;
  50. }
  51. return 0;
  52. }
  53. #endif