api.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. * History:
  21. * ---------
  22. * 2008-07-14 first version (Ardjan Zwartjes)
  23. */
  24. #ifndef TEXTOPS_API_H_
  25. #define TEXTOPS_API_H_
  26. #include "../../str.h"
  27. #include "../../sr_module.h"
  28. typedef int (*append_hf_t)(struct sip_msg*, str*);
  29. typedef int (*remove_hf_t)(struct sip_msg*, str*);
  30. typedef int (*search_append_t)(struct sip_msg*, str*, str*);
  31. typedef int (*search_t)(struct sip_msg*, str*);
  32. typedef int (*is_privacy_t)(struct sip_msg*, str*);
  33. /*
  34. * Struct with the textops api.
  35. */
  36. typedef struct textops_binds {
  37. append_hf_t append_hf; // Append a header to the message.
  38. remove_hf_t remove_hf; // Remove a header with the specified name from the message.
  39. search_append_t search_append; // Append a str after a match of the specified regex.
  40. search_t search; // Check if the regex matches a part of the message.
  41. is_privacy_t is_privacy;
  42. } textops_api_t;
  43. typedef int (*bind_textops_f)(textops_api_t*);
  44. /*
  45. * function exported by module - it will load the other functions
  46. */
  47. int bind_textops(textops_api_t*);
  48. /*
  49. * Function to be called direclty from other modules to load
  50. * the textops API.
  51. */
  52. inline static int load_textops_api(textops_api_t *tob){
  53. bind_textops_f bind_textops_exports;
  54. if(!(bind_textops_exports=(bind_textops_f)find_export("bind_textops",0,0))){
  55. LM_ERR("Failed to import bind_textops\n");
  56. return -1;
  57. }
  58. return bind_textops_exports(tob);
  59. }
  60. #endif /*TEXT_OPS_API_H_*/