00001 /* 00002 * $Id: xcap_callback.c,v 1.2 2007/02/20 13:40:09 anca_vamanu Exp $ 00003 * 00004 * xcap_client module - openser xcap client module 00005 * 00006 * Copyright (C) 2007 Voice Sistem S.R.L. 00007 * 00008 * This file is part of Kamailio, a free SIP server. 00009 * 00010 * Kamailio is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version 00014 * 00015 * Kamailio is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU General Public License for more details. 00019 * 00020 * You should have received a copy of the GNU General Public License 00021 * along with this program; if not, write to the Free Software 00022 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00023 * 00024 *History: 00025 *-------- 00026 * 2007-08-30 initial version (anca) 00027 */ 00028 00029 #include <stdio.h> 00030 #include <stdlib.h> 00031 #include "../../dprint.h" 00032 #include "../../mem/shm_mem.h" 00033 #include "../presence/hash.h" 00034 #include "xcap_callbacks.h" 00035 #include "xcap_client.h" 00036 00037 void run_xcap_update_cb(int type, str xid, char* stream) 00038 { 00039 xcap_callback_t* cb; 00040 00041 for (cb= xcapcb_list; cb; cb=cb->next) 00042 { 00043 if(cb->types & type) 00044 { 00045 LM_DBG("found callback\n"); 00046 cb->callback(type, xid, stream); 00047 } 00048 } 00049 } 00050 00051 int register_xcapcb( int types, xcap_cb f) 00052 { 00053 xcap_callback_t* xcb; 00054 00055 xcb= (xcap_callback_t*)shm_malloc(sizeof(xcap_callback_t)); 00056 if(xcb== NULL) 00057 { 00058 ERR_MEM(SHARE_MEM); 00059 } 00060 memset(xcb, 0, sizeof(xcap_callback_t)); 00061 00062 xcb->callback= f; 00063 xcb->types= types; 00064 xcb->next= xcapcb_list; 00065 xcapcb_list= xcb; 00066 return 0; 00067 00068 error: 00069 return -1; 00070 } 00071 00072 void destroy_xcapcb_list(void) 00073 { 00074 xcap_callback_t* xcb, *prev_xcb; 00075 00076 xcb= xcapcb_list; 00077 while(xcb) 00078 { 00079 prev_xcb= xcb; 00080 xcb= xcb->next; 00081 shm_free(xcb); 00082 } 00083 }
1.5.6