api.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /* Copyright (C) 2008 Telecats BV
  2. *
  3. * This file is part of Kamailio, a free SIP server.
  4. *
  5. * Kamailio is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License
  7. * as published by the Free Software Foundation; either version 2
  8. * of the License, or (at your option) any later version.
  9. *
  10. * Kamailio is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  18. *
  19. */
  20. /*!
  21. * \file
  22. * \brief API
  23. * \ingroup textops
  24. * Module: \ref textops
  25. */
  26. #ifndef TEXTOPS_API_H_
  27. #define TEXTOPS_API_H_
  28. #include "../../str.h"
  29. #include "../../sr_module.h"
  30. typedef int (*append_hf_t)(struct sip_msg*, str*);
  31. typedef int (*remove_hf_t)(struct sip_msg*, str*);
  32. typedef int (*search_append_t)(struct sip_msg*, str*, str*);
  33. typedef int (*search_t)(struct sip_msg*, str*);
  34. typedef int (*is_privacy_t)(struct sip_msg*, str*);
  35. /*
  36. * Struct with the textops api.
  37. */
  38. typedef struct textops_binds {
  39. append_hf_t append_hf; // Append a header to the message.
  40. remove_hf_t remove_hf; // Remove a header with the specified name from the message.
  41. search_append_t search_append; // Append a str after a match of the specified regex.
  42. search_t search; // Check if the regex matches a part of the message.
  43. is_privacy_t is_privacy;
  44. } textops_api_t;
  45. typedef int (*bind_textops_f)(textops_api_t*);
  46. /*
  47. * function exported by module - it will load the other functions
  48. */
  49. int bind_textops(textops_api_t*);
  50. /*
  51. * Function to be called direclty from other modules to load
  52. * the textops API.
  53. */
  54. inline static int load_textops_api(textops_api_t *tob){
  55. bind_textops_f bind_textops_exports;
  56. if(!(bind_textops_exports=(bind_textops_f)find_export("bind_textops",0,0))){
  57. LM_ERR("Failed to import bind_textops\n");
  58. return -1;
  59. }
  60. return bind_textops_exports(tob);
  61. }
  62. #endif /*TEXT_OPS_API_H_*/