Module: sip-router Branch: janakj/kcore Commit: bf3d622b425765640287b00f90755709a0d66007 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=bf3d622b...
Author: Jan Janak jan@iptel.org Committer: Jan Janak jan@iptel.org Date: Tue Mar 3 00:40:19 2009 +0100
Files local_route.[ch] from kamailio core add to libkcore
Kamailio modules that include "../../local_route.h" should be updated to include "../../lib/kcore/local_route.h" instead.
---
lib/kcore/local_route.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++ lib/kcore/local_route.h | 42 +++++++++++++++++++++++++ 2 files changed, 120 insertions(+), 0 deletions(-)
diff --git a/lib/kcore/local_route.c b/lib/kcore/local_route.c new file mode 100644 index 0000000..ba2f156 --- /dev/null +++ b/lib/kcore/local_route.c @@ -0,0 +1,78 @@ +/* + *$Id: local_route.c 5132 2008-10-24 11:49:14Z miconda $ + * + * Copyright (C) 2001-2003 FhG Fokus + * + * This file is part of Kamailio, a free SIP server. + * + * Kamailio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version + * + * Kamailio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/*! + * \file + * \brief Local Route related functions. + */ + +#include <string.h> + +#include "../../dprint.h" +#include "../../mem/mem.h" + +#include "local_route.h" + +static lrt_info_t* lrt_info_list = 0; +static int lrt_info_no = 0; + + +int lrt_do_init_child(void) +{ + int i; + + for ( i=0; i< lrt_info_no; i++ ) + { + if ( lrt_info_list[i].init && lrt_info_list[i].init()!=0 ) + { + LM_ERR("failed to init child for local route <%s>\n", + lrt_info_list[i].name); + return -1; + } + } + return 0; +} + +int register_lrt_info(lrt_info_t *lrti) +{ + lrt_info_t *l; + + if(lrti==NULL || lrti->name==NULL || lrti->init==NULL) + return 0; + + l = (lrt_info_t*)pkg_realloc(lrt_info_list, + (lrt_info_no+1)*sizeof(lrt_info_t)); + if (l==0) + { + LM_ERR("no more pkg memory\n"); + return -1; + } + + lrt_info_list = l; + lrt_info_list[lrt_info_no].init = lrti->init; + lrt_info_list[lrt_info_no].name = lrti->name; + lrt_info_no++; + + return 0; +} + + diff --git a/lib/kcore/local_route.h b/lib/kcore/local_route.h new file mode 100644 index 0000000..fe1da2c --- /dev/null +++ b/lib/kcore/local_route.h @@ -0,0 +1,42 @@ +/* + *$Id: local_route.h 5132 2008-10-24 11:49:14Z miconda $ + * + * Copyright (C) 2001-2003 FhG Fokus + * + * This file is part of Kamailio, a free SIP server. + * + * Kamailio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version + * + * Kamailio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/*! + * \file + * \brief Local Route related functions. + */ + +#ifndef _LOCAL_ROUTE_H_ +#define _LOCAL_ROUTE_H_ + +typedef int (lrt_child_init_f)(void); + +typedef struct _lrt_info { + char *name; + lrt_child_init_f *init; +} lrt_info_t; + +int lrt_do_init_child(void); +int register_lrt_info(lrt_info_t *lrti); + +#endif +