xcap_callbacks.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * $Id: xcap_callback.c,v 1.2 2007/02/20 13:40:09 anca_vamanu Exp $
  3. *
  4. * xcap_client module - Kamailio xcap client module
  5. *
  6. * Copyright (C) 2007 Voice Sistem S.R.L.
  7. *
  8. * This file is part of Kamailio, a free SIP server.
  9. *
  10. * Kamailio is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version
  14. *
  15. * Kamailio is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  23. *
  24. *History:
  25. *--------
  26. * 2007-08-30 initial version (anca)
  27. */
  28. #include <stdio.h>
  29. #include <stdlib.h>
  30. #include "../../dprint.h"
  31. #include "../../mem/shm_mem.h"
  32. #include "../presence/hash.h"
  33. #include "xcap_callbacks.h"
  34. #include "xcap_client.h"
  35. void run_xcap_update_cb(int type, str xid, char* stream)
  36. {
  37. xcap_callback_t* cb;
  38. for (cb= xcapcb_list; cb; cb=cb->next)
  39. {
  40. if(cb->types & type)
  41. {
  42. LM_DBG("found callback\n");
  43. cb->callback(type, xid, stream);
  44. }
  45. }
  46. }
  47. int register_xcapcb( int types, xcap_cb f)
  48. {
  49. xcap_callback_t* xcb;
  50. xcb= (xcap_callback_t*)shm_malloc(sizeof(xcap_callback_t));
  51. if(xcb== NULL)
  52. {
  53. ERR_MEM(SHARE_MEM);
  54. }
  55. memset(xcb, 0, sizeof(xcap_callback_t));
  56. xcb->callback= f;
  57. xcb->types= types;
  58. xcb->next= xcapcb_list;
  59. xcapcb_list= xcb;
  60. return 0;
  61. error:
  62. return -1;
  63. }
  64. void destroy_xcapcb_list(void)
  65. {
  66. xcap_callback_t* xcb, *prev_xcb;
  67. xcb= xcapcb_list;
  68. while(xcb)
  69. {
  70. prev_xcb= xcb;
  71. xcb= xcb->next;
  72. shm_free(prev_xcb);
  73. }
  74. }