00001 /* 00002 *$Id: local_route.c 5132 2008-10-24 11:49:14Z miconda $ 00003 * 00004 * Copyright (C) 2001-2003 FhG Fokus 00005 * 00006 * This file is part of Kamailio, a free SIP server. 00007 * 00008 * Kamailio is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU General Public License as published by 00010 * the Free Software Foundation; either version 2 of the License, or 00011 * (at your option) any later version 00012 * 00013 * Kamailio is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU General Public License 00019 * along with this program; if not, write to the Free Software 00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00021 */ 00022 00023 /*! 00024 * \file 00025 * \brief Local Route related functions. 00026 */ 00027 00028 #include <string.h> 00029 00030 #include "dprint.h" 00031 #include "mem/mem.h" 00032 00033 #include "local_route.h" 00034 00035 static lrt_info_t* lrt_info_list = 0; 00036 static int lrt_info_no = 0; 00037 00038 00039 int lrt_do_init_child(void) 00040 { 00041 int i; 00042 00043 for ( i=0; i< lrt_info_no; i++ ) 00044 { 00045 if ( lrt_info_list[i].init && lrt_info_list[i].init()!=0 ) 00046 { 00047 LM_ERR("failed to init child for local route <%s>\n", 00048 lrt_info_list[i].name); 00049 return -1; 00050 } 00051 } 00052 return 0; 00053 } 00054 00055 int register_lrt_info(lrt_info_t *lrti) 00056 { 00057 lrt_info_t *l; 00058 00059 if(lrti==NULL || lrti->name==NULL || lrti->init==NULL) 00060 return 0; 00061 00062 l = (lrt_info_t*)pkg_realloc(lrt_info_list, 00063 (lrt_info_no+1)*sizeof(lrt_info_t)); 00064 if (l==0) 00065 { 00066 LM_ERR("no more pkg memory\n"); 00067 return -1; 00068 } 00069 00070 lrt_info_list = l; 00071 lrt_info_list[lrt_info_no].init = lrti->init; 00072 lrt_info_list[lrt_info_no].name = lrti->name; 00073 lrt_info_no++; 00074 00075 return 0; 00076 } 00077 00078
1.5.6