1999-10-24 18:00:20 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								/*
 
							 
						 
					
						
							
								
									
										
										
										
											2005-09-14 20:46:50 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								 *  Asterisk  - -  An  open  source  telephony  toolkit . 
							 
						 
					
						
							
								
									
										
										
										
											1999-10-24 18:00:20 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								 * 
							 
						 
					
						
							
								
									
										
										
										
											2010-07-17 17:39:28 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								 *  Copyright  ( C )  1999  -  2010 ,  Digium ,  Inc . 
							 
						 
					
						
							
								
									
										
										
										
											1999-10-24 18:00:20 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								 * 
							 
						 
					
						
							
								
									
										
										
										
											2004-10-02 17:16:36 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								 *  Mark  Spencer  < markster @ digium . com > 
							 
						 
					
						
							
								
									
										
										
										
											1999-10-24 18:00:20 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								 * 
							 
						 
					
						
							
								
									
										
										
										
											2005-09-14 20:46:50 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								 *  See  http : //www.asterisk.org for more information about
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  the  Asterisk  project .  Please  do  not  directly  contact 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  any  of  the  maintainers  of  this  project  for  assistance ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  the  project  provides  a  web  site ,  mailing  lists  and  IRC 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  channels  for  your  use . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 * 
							 
						 
					
						
							
								
									
										
										
										
											1999-10-24 18:00:20 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								 *  This  program  is  free  software ,  distributed  under  the  terms  of 
							 
						 
					
						
							
								
									
										
										
										
											2005-09-14 20:46:50 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								 *  the  GNU  General  Public  License  Version  2.  See  the  LICENSE  file 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  at  the  top  of  the  source  tree . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2005-10-24 20:12:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								/*! \file
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  \ brief  Configuration  File  Parser 
							 
						 
					
						
							
								
									
										
										
										
											2005-09-14 20:46:50 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								 * 
							 
						 
					
						
							
								
									
										
										
										
											2005-12-30 21:18:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								 *  \ author  Mark  Spencer  < markster @ digium . com > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 * 
							 
						 
					
						
							
								
									
										
										
										
											2005-10-24 20:12:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								 *  Includes  the  Asterisk  Realtime  API  -  ARA 
							 
						 
					
						
							
								
									
										
										
										
											2011-02-02 18:56:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								 *  See  http : //wiki.asterisk.org
 
							 
						 
					
						
							
								
									
										
										
										
											1999-10-24 18:00:20 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								 */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2006-06-07 18:54:56 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# include  "asterisk.h" 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								ASTERISK_FILE_VERSION ( __FILE__ ,  " $Revision$ " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-11-20 23:16:15 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# include  "asterisk/paths.h"	/* use ast_config_AST_CONFIG_DIR */ 
 
							 
						 
					
						
							
								
									
										
										
										
											2007-11-17 16:18:53 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# include  "asterisk/network.h"	/* we do some sockaddr manipulation here */ 
 
							 
						 
					
						
							
								
									
										
										
										
											2003-03-09 06:00:18 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# include  <time.h> 
 
							 
						 
					
						
							
								
									
										
										
										
											2005-10-31 21:08:55 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# include  <sys/stat.h> 
 
							 
						 
					
						
							
								
									
										
										
										
											2007-12-08 18:18:28 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-12-19 15:15:03 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# include  <math.h>	/* HUGE_VAL */ 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2004-12-11 05:16:30 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# define AST_INCLUDE_GLOB 1 
 
							 
						 
					
						
							
								
									
										
										
										
											2007-12-08 18:18:28 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2005-04-21 06:02:45 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# include  "asterisk/config.h" 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# include  "asterisk/cli.h" 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# include  "asterisk/lock.h" 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# include  "asterisk/utils.h" 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# include  "asterisk/channel.h" 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# include  "asterisk/app.h" 
 
							 
						 
					
						
							
								
									
										
										
										
											2007-09-12 20:50:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# include  "asterisk/astobj2.h" 
 
							 
						 
					
						
							
								
									
										
										
										
											2007-12-08 18:50:32 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# include  "asterisk/strings.h"	/* for the ast_str_*() API */ 
 
							 
						 
					
						
							
								
									
										
										
										
											2010-07-08 22:08:07 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# include  "asterisk/netsock2.h" 
 
							 
						 
					
						
							
								
									
										
										
										
											1999-10-24 18:00:20 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2004-12-04 16:09:45 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# define MAX_NESTED_COMMENTS 128 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# define COMMENT_START ";--" 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# define COMMENT_END "--;" 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# define COMMENT_META ';' 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# define COMMENT_TAG '-' 
 
							 
						 
					
						
							
								
									
										
										
										
											2002-03-05 23:57:31 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								/*!
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  Define  the  minimum  filename  space  to  reserve  for  each 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  ast_variable  in  case  the  filename  is  renamed  later  by 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  ast_include_rename ( ) . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# define MIN_VARIABLE_FNAME_SPACE	40 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								static  char  * extconfig_conf  =  " extconfig.conf " ; 
							 
						 
					
						
							
								
									
										
										
										
											2004-10-05 06:46:11 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2006-10-26 01:38:47 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-02-24 20:29:41 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								/*! \brief Structure to keep comments for rewriting configuration files */ 
							 
						 
					
						
							
								
									
										
										
										
											2006-10-26 01:38:47 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								struct  ast_comment  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									struct  ast_comment  * next ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									/*! Comment body allocated after struct. */ 
							 
						 
					
						
							
								
									
										
										
										
											2006-10-26 01:38:47 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									char  cmt [ 0 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-08-16 21:09:46 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								/*! \brief Hold the mtime for config files, so if we don't need to reread our config, don't. */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								struct  cache_file_include  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									AST_LIST_ENTRY ( cache_file_include )  list ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									char  include [ 0 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								struct  cache_file_mtime  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									AST_LIST_ENTRY ( cache_file_mtime )  list ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									AST_LIST_HEAD_NOLOCK ( includes ,  cache_file_include )  includes ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-16 21:09:46 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									unsigned  int  has_exec : 1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									time_t  mtime ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									/*! String stuffed in filename[] after the filename string. */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									const  char  * who_asked ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									/*! Filename and who_asked stuffed after it. */ 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-16 21:09:46 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									char  filename [ 0 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								/*! Cached file mtime list. */ 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-16 21:09:46 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								static  AST_LIST_HEAD_STATIC ( cfmtime_head ,  cache_file_mtime ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-08-05 18:25:16 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								static  int  init_appendbuf ( void  * data ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									struct  ast_str  * * str  =  data ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									* str  =  ast_str_create ( 16 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									return  * str  ?  0  :  - 1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								AST_THREADSTORAGE_CUSTOM ( appendbuf ,  init_appendbuf ,  ast_free_ptr ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2006-10-26 01:38:47 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-12-08 18:50:32 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								/* comment buffers are better implemented using the ast_str_*() API */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# define CB_SIZE 250	 /* initial size of comment buffers */ 
 
							 
						 
					
						
							
								
									
										
										
										
											2006-10-26 01:38:47 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-12-08 18:50:32 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								static  void   CB_ADD ( struct  ast_str  * * cb ,  const  char  * str ) 
							 
						 
					
						
							
								
									
										
										
										
											2006-10-26 01:38:47 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2007-12-08 18:50:32 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									ast_str_append ( cb ,  0 ,  " %s " ,  str ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2006-10-26 01:38:47 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-12-08 18:50:32 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								static  void   CB_ADD_LEN ( struct  ast_str  * * cb ,  const  char  * str ,  int  len ) 
							 
						 
					
						
							
								
									
										
										
										
											2006-10-26 01:38:47 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2007-12-08 18:50:32 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									char  * s  =  alloca ( len  +  1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									ast_copy_string ( s ,  str ,  len ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									ast_str_append ( cb ,  0 ,  " %s " ,  str ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2006-10-26 01:38:47 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-12-08 18:50:32 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								static  void  CB_RESET ( struct  ast_str  * cb ,  struct  ast_str  * llb )   
							 
						 
					
						
							
								
									
										
										
										
											2006-10-26 01:38:47 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{  
							 
						 
					
						
							
								
									
										
										
										
											2008-12-13 08:36:35 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									if  ( cb )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										ast_str_reset ( cb ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									if  ( llb )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										ast_str_reset ( llb ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2006-10-26 01:38:47 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-12-13 08:36:35 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								static  struct  ast_comment  * ALLOC_COMMENT ( struct  ast_str  * buffer ) 
							 
						 
					
						
							
								
									
										
										
										
											2006-10-26 01:38:47 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{  
							 
						 
					
						
							
								
									
										
										
										
											2007-12-08 18:50:32 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									struct  ast_comment  * x  =  NULL ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-12-13 08:36:35 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									if  ( ! buffer  | |  ! ast_str_strlen ( buffer ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										return  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									if  ( ( x  =  ast_calloc ( 1 ,  sizeof ( * x )  +  ast_str_strlen ( buffer )  +  1 ) ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										strcpy ( x - > cmt ,  ast_str_buffer ( buffer ) ) ;  /* SAFE */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2006-10-26 01:38:47 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									return  x ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-09-12 20:50:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								/* I need to keep track of each config file, and all its inclusions,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								   so  that  we  can  track  blank  lines  in  each  */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-12-08 18:05:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								struct  inclfile  { 
							 
						 
					
						
							
								
									
										
										
										
											2007-09-12 20:50:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									char  * fname ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									int  lineno ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								static  int  hash_string ( const  void  * obj ,  const  int  flags ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2008-12-13 08:36:35 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									char  * str  =  ( ( struct  inclfile  * )  obj ) - > fname ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-09-12 20:50:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									int  total ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-12-13 08:36:35 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									for  ( total  =  0 ;  * str ;  str + + )  { 
							 
						 
					
						
							
								
									
										
										
										
											2007-09-12 20:50:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										unsigned  int  tmp  =  total ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										total  < < =  1 ;  /* multiply by 2 */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										total  + =  tmp ;  /* multiply by 3 */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										total  < < =  2 ;  /* multiply by 12 */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										total  + =  tmp ;  /* multiply by 13 */ 
							 
						 
					
						
							
								
									
										
										
										
											2008-03-04 23:04:29 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-12-13 08:36:35 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										total  + =  ( ( unsigned  int )  ( * str ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-09-12 20:50:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2008-12-13 08:36:35 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									if  ( total  <  0 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2007-09-12 20:50:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										total  =  - total ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-12-13 08:36:35 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2007-09-12 20:50:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									return  total ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-11-25 01:01:49 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								static  int  hashtab_compare_strings ( void  * a ,  void  * b ,  int  flags ) 
							 
						 
					
						
							
								
									
										
										
										
											2007-09-12 20:50:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									const  struct  inclfile  * ae  =  a ,  * be  =  b ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-29 17:47:17 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									return  ! strcmp ( ae - > fname ,  be - > fname )  ?  CMP_MATCH  |  CMP_STOP  :  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-09-12 20:50:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
									
										
										
										
											2006-10-26 01:38:47 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2004-10-05 06:46:11 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								static  struct  ast_config_map  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									struct  ast_config_map  * next ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-07-23 16:19:21 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									int  priority ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									/*! Stored in stuff[] at struct end. */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									const  char  * name ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									/*! Stored in stuff[] at struct end. */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									const  char  * driver ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									/*! Stored in stuff[] at struct end. */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									const  char  * database ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									/*! Stored in stuff[] at struct end. */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									const  char  * table ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									/*! Contents of name, driver, database, and table in that order stuffed here. */ 
							 
						 
					
						
							
								
									
										
										
										
											2004-10-05 06:46:11 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									char  stuff [ 0 ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								}  * config_maps  =  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								AST_MUTEX_DEFINE_STATIC ( config_lock ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								static  struct  ast_config_engine  * config_engine_list ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# define MAX_INCLUDE_LEVEL 10 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-11-06 21:08:38 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								struct  ast_category_template_instance  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									char  name [ 80 ] ;  /* redundant? */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									const  struct  ast_category  * inst ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									AST_LIST_ENTRY ( ast_category_template_instance )  next ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								struct  ast_category  { 
							 
						 
					
						
							
								
									
										
										
										
											2006-02-24 10:50:43 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									char  name [ 80 ] ; 
							 
						 
					
						
							
								
									
										
											 
										 
										
											
												This is the perhaps the biggest, boldest, most daring change I've ever committed to trunk. Forgive me in advance any disruption this may cause, and please, report any problems via the bugtracker. The upside is that this can speed up large dialplans by 20 times (or more). Context, extension, and priority matching are all fairly constant-time searches.  I introduce here my hashtables (hashtabs), and a regression for them. I would have used the ast_obj2 tables, but mine are resizeable, and don't need the object destruction capability. The hashtab stuff is well tested and stable. I introduce a data structure, a trie, for extension pattern matching, in which knowledge of all patterns is accumulated, and all matches can be found via a single traversal of the tree. This is per-context. The trie is formed on the first lookup attempt, and stored in the context for future lookups. Destruction routines are in place for hashtabs and the pattern match trie. You can see the contents of the pattern match trie by using the 'dialplan show' cli command when 'core set debug' has been done to put it in debug mode. The pattern tree traversal only traverses those parts of the tree that are interesting. It uses a scoreboard sort of approach to find the best match. The speed of the traversal is more a function of the length of the pattern than the number of patterns in the tree. The tree also contains the CID matching patterns. See the source code comments for details on how everything works. I believe the approach general enough that any issues that might come up involving fine points in the pattern matching algorithm, can be solved by just tweaking things. We shall see. The current pattern matcher is fairly involved, and replicating every nuance of it is difficult. If you find and report problems, I will try to resolve than as quickly as I can. The trie and hashtabs are added to the existing context and exten structs, and none of the old machinery has been removed for the sake of the multitude of functions that use them. In the future, we can (maybe) weed out the linked lists and save some space.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89129 65c4cc65-6c06-0410-ace0-fbb531ad65f3
											 
										 
										
											2007-11-09 16:00:22 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									int  ignored ; 			/*!< do not let user of the config see this category -- set by (!) after the category decl; a template */ 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									int  include_level ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									/*!
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 *  \ brief  The  file  name  from  whence  this  declaration  was  read 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 *  \ note  Will  never  be  NULL 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									char  * file ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									int  lineno ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-11-06 21:08:38 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									AST_LIST_HEAD_NOLOCK ( template_instance_list ,  ast_category_template_instance )  template_instances ; 
							 
						 
					
						
							
								
									
										
										
										
											2006-10-26 01:38:47 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									struct  ast_comment  * precomments ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									struct  ast_comment  * sameline ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-09-05 14:47:45 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									struct  ast_comment  * trailing ;  /*!< the last object in the list will get assigned any trailing comments when EOF is hit */ 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									/*! First category variable in the list. */ 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									struct  ast_variable  * root ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									/*! Last category variable in the list. */ 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									struct  ast_variable  * last ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									/*! Next node in the list. */ 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									struct  ast_category  * next ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								struct  ast_config  { 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									/*! First config category in the list. */ 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									struct  ast_category  * root ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									/*! Last config category in the list. */ 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									struct  ast_category  * last ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									struct  ast_category  * current ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									struct  ast_category  * last_browse ;      /*!< used to cache the last category supplied via category_browse */ 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									int  include_level ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									int  max_include_level ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									struct  ast_config_include  * includes ;   /*!< a list of inclusions, which should describe the entire tree */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								struct  ast_config_include  { 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									/*!
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 *  \ brief  file  name  in  which  the  include  occurs 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 *  \ note  Will  never  be  NULL 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									char  * include_location_file ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									int   include_location_lineno ;     /*!< lineno where include occurred */ 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									int   exec ;                        /*!< set to non-zero if its a #exec statement */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									/*!
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 *  \ brief  if  it ' s  an  exec ,  you ' ll  have  both  the  / var / tmp  to  read ,  and  the  original  script 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 *  \ note  Will  never  be  NULL  if  exec  is  non - zero 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									char  * exec_file ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									/*!
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 *  \ brief  file  name  included 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 *  \ note  Will  never  be  NULL 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									char  * included_file ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									int  inclusion_count ;              /*!< if the file is included more than once, a running count thereof -- but, worry not,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									                                      we  explode  the  instances  and  will  include  those - -  so  all  entries  will  be  unique  */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									int  output ;                       /*!< a flag to indicate if the inclusion has been output */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									struct  ast_config_include  * next ;  /*!< ptr to next inclusion in the list */ 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								} ; 
							 
						 
					
						
							
								
									
										
										
										
											1999-10-24 18:00:20 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								static  void  ast_variable_destroy ( struct  ast_variable  * doomed ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								static  void  ast_includes_destroy ( struct  ast_config_include  * incls ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-10-14 22:38:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# ifdef MALLOC_DEBUG 
 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								struct  ast_variable  * _ast_variable_new ( const  char  * name ,  const  char  * value ,  const  char  * filename ,  const  char  * file ,  const  char  * func ,  int  lineno ) 
							 
						 
					
						
							
								
									
										
										
										
											2008-10-14 22:38:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# else 
 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								struct  ast_variable  * ast_variable_new ( const  char  * name ,  const  char  * value ,  const  char  * filename ) 
							 
						 
					
						
							
								
									
										
										
										
											2008-10-14 22:38:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# endif 
 
							 
						 
					
						
							
								
									
										
										
										
											1999-10-24 18:00:20 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									struct  ast_variable  * variable ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									int  name_len  =  strlen ( name )  +  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									int  val_len  =  strlen ( value )  +  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									int  fn_len  =  strlen ( filename )  +  1 ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-11-14 13:18:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									/* Ensure a minimum length in case the filename is changed later. */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									if  ( fn_len  <  MIN_VARIABLE_FNAME_SPACE )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										fn_len  =  MIN_VARIABLE_FNAME_SPACE ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									if  ( 
							 
						 
					
						
							
								
									
										
										
										
											2008-10-14 22:38:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# ifdef MALLOC_DEBUG 
 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										( variable  =  __ast_calloc ( 1 ,  fn_len  +  name_len  +  val_len  +  sizeof ( * variable ) ,  file ,  lineno ,  func ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2008-10-14 22:38:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# else 
 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										( variable  =  ast_calloc ( 1 ,  fn_len  +  name_len  +  val_len  +  sizeof ( * variable ) ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2008-10-14 22:38:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# endif 
 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										)  { 
							 
						 
					
						
							
								
									
										
										
										
											2007-11-14 13:18:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										char  * dst  =  variable - > stuff ; 	/* writable space starts here */ 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										/* Put file first so ast_include_rename() can calculate space available. */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										variable - > file  =  strcpy ( dst ,  filename ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										dst  + =  fn_len ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-11-14 13:18:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										variable - > name  =  strcpy ( dst ,  name ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										dst  + =  name_len ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										variable - > value  =  strcpy ( dst ,  value ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2001-10-09 14:54:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									return  variable ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								/*!
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  \ internal 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  \ brief  Move  the  contents  from  the  source  to  the  destination  variable . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  \ param  dst_var  Destination  variable  node 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  \ param  src_var  Source  variable  node 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  \ return  Nothing 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								static  void  ast_variable_move ( struct  ast_variable  * dst_var ,  struct  ast_variable  * src_var ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									dst_var - > lineno  =  src_var - > lineno ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									dst_var - > object  =  src_var - > object ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									dst_var - > blanklines  =  src_var - > blanklines ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									dst_var - > precomments  =  src_var - > precomments ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									src_var - > precomments  =  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									dst_var - > sameline  =  src_var - > sameline ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									src_var - > sameline  =  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									dst_var - > trailing  =  src_var - > trailing ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									src_var - > trailing  =  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								struct  ast_config_include  * ast_include_new ( struct  ast_config  * conf ,  const  char  * from_file ,  const  char  * included_file ,  int  is_exec ,  const  char  * exec_file ,  int  from_lineno ,  char  * real_included_file_name ,  int  real_included_file_name_size ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									/* a file should be included ONCE. Otherwise, if one of the instances is changed,
 
							 
						 
					
						
							
								
									
										
										
										
											2008-03-04 23:04:29 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 *  then  all  be  changed .  - -  how  do  we  know  to  include  it ?  - -  Handling  modified  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 *  instances  is  possible ,  I ' d  have 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 *  to  create  a  new  master  for  each  instance .  */ 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									struct  ast_config_include  * inc ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-09-02 14:37:53 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									struct  stat  statbuf ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									inc  =  ast_include_find ( conf ,  included_file ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-09-02 14:37:53 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									if  ( inc )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										do  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											inc - > inclusion_count + + ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											snprintf ( real_included_file_name ,  real_included_file_name_size ,  " %s~~%d " ,  included_file ,  inc - > inclusion_count ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										}  while  ( stat ( real_included_file_name ,  & statbuf )  = =  0 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										ast_log ( LOG_WARNING , " '%s', line %d:  Same File included more than once! This data will be saved in %s if saved back to disk. \n " ,  from_file ,  from_lineno ,  real_included_file_name ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									}  else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										* real_included_file_name  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									inc  =  ast_calloc ( 1 , sizeof ( struct  ast_config_include ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									if  ( ! inc )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										return  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									inc - > include_location_file  =  ast_strdup ( from_file ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									inc - > include_location_lineno  =  from_lineno ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									if  ( ! ast_strlen_zero ( real_included_file_name ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										inc - > included_file  =  ast_strdup ( real_included_file_name ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										inc - > included_file  =  ast_strdup ( included_file ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									inc - > exec  =  is_exec ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									if  ( is_exec ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										inc - > exec_file  =  ast_strdup ( exec_file ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									if  ( ! inc - > include_location_file 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										| |  ! inc - > included_file 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										| |  ( is_exec  & &  ! inc - > exec_file ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										ast_includes_destroy ( inc ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										return  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									/* attach this new struct to the conf struct */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									inc - > next  =  conf - > includes ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									conf - > includes  =  inc ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									return  inc ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								void  ast_include_rename ( struct  ast_config  * conf ,  const  char  * from_file ,  const  char  * to_file ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									struct  ast_config_include  * incl ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									struct  ast_category  * cat ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									char  * str ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									int  from_len  =  strlen ( from_file ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									int  to_len  =  strlen ( to_file ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									if  ( strcmp ( from_file ,  to_file )  = =  0 )  /* no use wasting time if the name is the same */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									/* the manager code allows you to read in one config file, then
 
							 
						 
					
						
							
								
									
										
										
										
											2008-03-04 23:04:29 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 *  write  it  back  out  under  a  different  name .  But ,  the  new  arrangement 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 *  ties  output  lines  to  the  file  name .  So ,  before  you  try  to  write 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 *  the  config  file  to  disk ,  better  riffle  thru  the  data  and  make  sure 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 *  the  file  names  are  changed . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 */ 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									/* file names are on categories, includes (of course), and on variables. So,
 
							 
						 
					
						
							
								
									
										
										
										
											2008-03-04 23:04:29 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									 *  traverse  all  this  and  swap  names  */ 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									for  ( incl  =  conf - > includes ;  incl ;  incl = incl - > next )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( strcmp ( incl - > include_location_file , from_file )  = =  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											if  ( from_len  > =  to_len ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												strcpy ( incl - > include_location_file ,  to_file ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											else  { 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												/* Keep the old filename if the allocation fails. */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												str  =  ast_strdup ( to_file ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												if  ( str )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													ast_free ( incl - > include_location_file ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													incl - > include_location_file  =  str ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									for  ( cat  =  conf - > root ;  cat ;  cat  =  cat - > next )  { 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										struct  ast_variable  * * prev ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										struct  ast_variable  * v ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										struct  ast_variable  * new_var ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										if  ( strcmp ( cat - > file , from_file )  = =  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											if  ( from_len  > =  to_len ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												strcpy ( cat - > file ,  to_file ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											else  { 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												/* Keep the old filename if the allocation fails. */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												str  =  ast_strdup ( to_file ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												if  ( str )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													ast_free ( cat - > file ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													cat - > file  =  str ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										for  ( prev  =  & cat - > root ,  v  =  cat - > root ;  v ;  prev  =  & v - > next ,  v  =  v - > next )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											if  ( strcmp ( v - > file ,  from_file ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											/*
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											 *  Calculate  actual  space  available .   The  file  string  is 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											 *  intentionally  stuffed  before  the  name  string  just  so  we  can 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											 *  do  this . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											 */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											if  ( to_len  <  v - > name  -  v - > file )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												/* The new name will fit in the available space. */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												str  =  ( char  * )  v - > file ; /* Stupid compiler complains about discarding qualifiers even though I used a cast. */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												strcpy ( str ,  to_file ) ; /* SAFE */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											/* Keep the old filename if the allocation fails. */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											new_var  =  ast_variable_new ( v - > name ,  v - > value ,  to_file ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											if  ( ! new_var )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											/* Move items from the old list node to the replacement node. */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											ast_variable_move ( new_var ,  v ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											/* Replace the old node in the list with the new node. */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											new_var - > next  =  v - > next ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											if  ( cat - > last  = =  v )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												cat - > last  =  new_var ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											* prev  =  new_var ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											ast_variable_destroy ( v ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											v  =  new_var ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								struct  ast_config_include  * ast_include_find ( struct  ast_config  * conf ,  const  char  * included_file ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									struct  ast_config_include  * x ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-12-08 18:05:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									for  ( x = conf - > includes ; x ; x = x - > next )  { 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										if  ( strcmp ( x - > included_file , included_file )  = =  0 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											return  x ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									return  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								void  ast_variable_append ( struct  ast_category  * category ,  struct  ast_variable  * variable ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2006-04-06 16:06:57 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									if  ( ! variable ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										return ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-30 17:34:44 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									if  ( category - > last ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										category - > last - > next  =  variable ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										category - > root  =  variable ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									category - > last  =  variable ; 
							 
						 
					
						
							
								
									
										
										
										
											2006-11-15 20:05:26 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									while  ( category - > last - > next ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										category - > last  =  category - > last - > next ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-02-12 00:24:36 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								void  ast_variable_insert ( struct  ast_category  * category ,  struct  ast_variable  * variable ,  const  char  * line ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									struct  ast_variable  * cur  =  category - > root ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									int  lineno ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									int  insertline ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-08-10 19:20:57 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									if  ( ! variable  | |  sscanf ( line ,  " %30d " ,  & insertline )  ! =  1 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2008-02-12 00:24:36 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										return ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-11-20 17:53:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2008-02-12 00:24:36 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									if  ( ! insertline )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										variable - > next  =  category - > root ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										category - > root  =  variable ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										for  ( lineno  =  1 ;  lineno  <  insertline ;  lineno + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											cur  =  cur - > next ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-11-20 17:53:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											if  ( ! cur - > next )  { 
							 
						 
					
						
							
								
									
										
										
										
											2008-02-12 00:24:36 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												break ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-11-20 17:53:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2008-02-12 00:24:36 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										variable - > next  =  cur - > next ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										cur - > next  =  variable ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2010-01-18 19:57:52 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								static  void  ast_comment_destroy ( struct  ast_comment  * * comment ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									struct  ast_comment  * n ,  * p ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									for  ( p  =  * comment ;  p ;  p  =  n )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										n  =  p - > next ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										ast_free ( p ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									* comment  =  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-08-22 17:00:03 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								static  void  ast_variable_destroy ( struct  ast_variable  * doomed ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									ast_comment_destroy ( & doomed - > precomments ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									ast_comment_destroy ( & doomed - > sameline ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									ast_comment_destroy ( & doomed - > trailing ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									ast_free ( doomed ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-11-01 20:53:37 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								struct  ast_variable  * ast_variables_dup ( struct  ast_variable  * var ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									struct  ast_variable  * cloned ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									struct  ast_variable  * tmp ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									if  ( ! ( cloned  =  ast_variable_new ( var - > name ,  var - > value ,  var - > file ) ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										return  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									tmp  =  cloned ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									while  ( ( var  =  var - > next ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( ! ( tmp - > next  =  ast_variable_new ( var - > name ,  var - > value ,  var - > file ) ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											ast_variables_destroy ( cloned ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											return  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										tmp  =  tmp - > next ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									return  cloned ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								void  ast_variables_destroy ( struct  ast_variable  * v ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									struct  ast_variable  * vn ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-01-23 00:11:32 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									while  ( v )  { 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										vn  =  v ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										v  =  v - > next ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-08-22 17:00:03 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										ast_variable_destroy ( vn ) ; 
							 
						 
					
						
							
								
									
										
										
										
											1999-10-24 18:00:20 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								struct  ast_variable  * ast_variable_browse ( const  struct  ast_config  * config ,  const  char  * category ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									struct  ast_category  * cat  =  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-11-20 17:53:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									if  ( category  & &  config - > last_browse  & &  ( config - > last_browse - > name  = =  category ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										cat  =  config - > last_browse ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-11-20 17:53:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										cat  =  ast_category_get ( config ,  category ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-11-20 17:53:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2006-04-06 16:06:57 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									return  ( cat )  ?  cat - > root  :  NULL ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2006-09-20 20:40:39 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								const  char  * ast_config_option ( struct  ast_config  * cfg ,  const  char  * cat ,  const  char  * var ) 
							 
						 
					
						
							
								
									
										
										
										
											2006-09-16 23:53:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2006-09-20 20:40:39 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									const  char  * tmp ; 
							 
						 
					
						
							
								
									
										
										
										
											2006-09-16 23:53:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									tmp  =  ast_variable_retrieve ( cfg ,  cat ,  var ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-11-20 17:53:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									if  ( ! tmp )  { 
							 
						 
					
						
							
								
									
										
										
										
											2006-09-16 23:53:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										tmp  =  ast_variable_retrieve ( cfg ,  " general " ,  var ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-11-20 17:53:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2006-09-16 23:53:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									return  tmp ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2006-09-20 20:40:39 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								const  char  * ast_variable_retrieve ( const  struct  ast_config  * config ,  const  char  * category ,  const  char  * variable ) 
							 
						 
					
						
							
								
									
										
										
										
											1999-10-24 18:00:20 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									struct  ast_variable  * v ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											1999-12-11 20:09:45 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									if  ( category )  { 
							 
						 
					
						
							
								
									
										
										
										
											2005-10-17 03:53:27 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										for  ( v  =  ast_variable_browse ( config ,  category ) ;  v ;  v  =  v - > next )  { 
							 
						 
					
						
							
								
									
										
										
										
											2008-11-20 17:53:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											if  ( ! strcasecmp ( variable ,  v - > name ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2005-10-17 13:53:50 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												return  v - > value ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-11-20 17:53:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2005-10-17 03:53:27 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											1999-12-11 20:09:45 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										struct  ast_category  * cat ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-11-20 17:46:56 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										for  ( cat  =  config - > root ;  cat ;  cat  =  cat - > next )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											for  ( v  =  cat - > root ;  v ;  v  =  v - > next )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												if  ( ! strcasecmp ( variable ,  v - > name ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											1999-12-11 20:09:45 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
													return  v - > value ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-11-20 17:46:56 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											1999-10-24 18:00:20 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											1999-10-24 18:00:20 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
									return  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2005-01-30 06:26:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								static  struct  ast_variable  * variable_clone ( const  struct  ast_variable  * old ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									struct  ast_variable  * new  =  ast_variable_new ( old - > name ,  old - > value ,  old - > file ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-30 06:26:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									if  ( new )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										new - > lineno  =  old - > lineno ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										new - > object  =  old - > object ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										new - > blanklines  =  old - > blanklines ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										/* TODO: clone comments? */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									return  new ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								static  void  move_variables ( struct  ast_category  * old ,  struct  ast_category  * new ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2006-04-06 16:06:57 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									struct  ast_variable  * var  =  old - > root ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-12-08 18:05:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2005-01-30 06:26:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									old - > root  =  NULL ; 
							 
						 
					
						
							
								
									
										
										
										
											2006-04-06 16:06:57 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									/* we can just move the entire list in a single op */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									ast_variable_append ( new ,  var ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-30 06:26:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								struct  ast_category  * ast_category_new ( const  char  * name ,  const  char  * in_file ,  int  lineno )  
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									struct  ast_category  * category ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									category  =  ast_calloc ( 1 ,  sizeof ( * category ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									if  ( ! category )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										return  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									category - > file  =  ast_strdup ( in_file ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									if  ( ! category - > file )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										ast_category_destroy ( category ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										return  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									ast_copy_string ( category - > name ,  name ,  sizeof ( category - > name ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									category - > lineno  =  lineno ;  /* if you don't know the lineno, set it to 999999 or something real big */ 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									return  category ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2005-01-30 06:26:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								static  struct  ast_category  * category_get ( const  struct  ast_config  * config ,  const  char  * category_name ,  int  ignored ) 
							 
						 
					
						
							
								
									
										
										
										
											2003-03-09 06:00:18 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									struct  ast_category  * cat ; 
							 
						 
					
						
							
								
									
										
										
										
											2004-10-05 06:46:11 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2006-04-06 16:06:57 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									/* try exact match first, then case-insensitive match */ 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									for  ( cat  =  config - > root ;  cat ;  cat  =  cat - > next )  { 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-30 06:26:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										if  ( cat - > name  = =  category_name  & &  ( ignored  | |  ! cat - > ignored ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											return  cat ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									for  ( cat  =  config - > root ;  cat ;  cat  =  cat - > next )  { 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-30 06:26:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										if  ( ! strcasecmp ( cat - > name ,  category_name )  & &  ( ignored  | |  ! cat - > ignored ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											return  cat ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-22 22:13:11 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2004-10-05 06:46:11 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2005-01-22 22:13:11 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									return  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2005-01-30 06:26:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								struct  ast_category  * ast_category_get ( const  struct  ast_config  * config ,  const  char  * category_name ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									return  category_get ( config ,  category_name ,  0 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								int  ast_category_exist ( const  struct  ast_config  * config ,  const  char  * category_name ) 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-22 22:13:11 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									return  ! ! ast_category_get ( config ,  category_name ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2003-03-09 06:00:18 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								void  ast_category_append ( struct  ast_config  * config ,  struct  ast_category  * category ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									if  ( config - > last ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										config - > last - > next  =  category ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										config - > root  =  category ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-01-04 22:34:24 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									category - > include_level  =  config - > include_level ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									config - > last  =  category ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									config - > current  =  category ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
									
										
										
										
											2004-10-05 06:46:11 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-02-12 00:24:36 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								void  ast_category_insert ( struct  ast_config  * config ,  struct  ast_category  * cat ,  const  char  * match ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									struct  ast_category  * cur_category ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									if  ( ! cat  | |  ! match ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									if  ( ! strcasecmp ( config - > root - > name ,  match ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										cat - > next  =  config - > root ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										config - > root  =  cat ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									}  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									for  ( cur_category  =  config - > root ;  cur_category ;  cur_category  =  cur_category - > next )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( ! strcasecmp ( cur_category - > next - > name ,  match ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											cat - > next  =  cur_category - > next ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											cur_category - > next  =  cat ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-11-06 21:08:38 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								static  void  ast_destroy_template_list ( struct  ast_category  * cat ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									struct  ast_category_template_instance  * x ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-11-08 05:28:47 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									while  ( ( x  =  AST_LIST_REMOVE_HEAD ( & cat - > template_instances ,  next ) ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										ast_free ( x ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-11-06 21:08:38 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								void  ast_category_destroy ( struct  ast_category  * cat ) 
							 
						 
					
						
							
								
									
										
										
										
											2003-03-09 06:00:18 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									ast_variables_destroy ( cat - > root ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									cat - > root  =  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									cat - > last  =  NULL ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-01-18 19:57:52 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									ast_comment_destroy ( & cat - > precomments ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									ast_comment_destroy ( & cat - > sameline ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									ast_comment_destroy ( & cat - > trailing ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-11-06 21:08:38 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									ast_destroy_template_list ( cat ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									ast_free ( cat - > file ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-06-06 21:20:11 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									ast_free ( cat ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
									
										
										
										
											2004-10-05 06:46:11 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								static  void  ast_includes_destroy ( struct  ast_config_include  * incls ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									struct  ast_config_include  * incl , * inclnext ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									for  ( incl = incls ;  incl ;  incl  =  inclnext )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										inclnext  =  incl - > next ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										ast_free ( incl - > include_location_file ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										ast_free ( incl - > exec_file ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										ast_free ( incl - > included_file ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										ast_free ( incl ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2005-01-30 06:26:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								static  struct  ast_category  * next_available_category ( struct  ast_category  * cat ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									for  ( ;  cat  & &  cat - > ignored ;  cat  =  cat - > next ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									return  cat ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-11-16 10:07:24 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								/*! return the first var of a category */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								struct  ast_variable  * ast_category_first ( struct  ast_category  * cat ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									return  ( cat )  ?  cat - > root  :  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-08-06 16:54:51 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								struct  ast_variable  * ast_category_root ( struct  ast_config  * config ,  char  * cat ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									struct  ast_category  * category  =  ast_category_get ( config ,  cat ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-12-08 18:05:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-08-06 16:54:51 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									if  ( category ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										return  category - > root ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									return  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								char  * ast_category_browse ( struct  ast_config  * config ,  const  char  * prev ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 	
							 
						 
					
						
							
								
									
										
										
										
											2011-08-22 21:22:24 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									struct  ast_category  * cat ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-08-22 21:22:24 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									if  ( ! prev )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										/* First time browse. */ 
							 
						 
					
						
							
								
									
										
										
										
											2006-04-06 16:06:57 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										cat  =  config - > root ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-08-22 21:22:24 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									}  else  if  ( config - > last_browse  & &  ( config - > last_browse - > name  = =  prev ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										/* Simple last browse found. */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										cat  =  config - > last_browse - > next ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										/*
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 *  Config  changed  since  last  browse . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 *  First  try  cheap  last  browse  search .  ( Rebrowsing  a  different 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 *  previous  category ? ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 */ 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										for  ( cat  =  config - > root ;  cat ;  cat  =  cat - > next )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											if  ( cat - > name  = =  prev )  { 
							 
						 
					
						
							
								
									
										
										
										
											2011-08-22 21:22:24 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												/* Found it. */ 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												cat  =  cat - > next ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2003-03-09 06:00:18 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										if  ( ! cat )  { 
							 
						 
					
						
							
								
									
										
										
										
											2011-08-22 21:22:24 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											/*
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											 *  Have  to  do  it  the  hard  way .  ( Last  category  was  deleted  and 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											 *  re - added ? ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											 */ 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											for  ( cat  =  config - > root ;  cat ;  cat  =  cat - > next )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												if  ( ! strcasecmp ( cat - > name ,  prev ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2011-08-22 21:22:24 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
													/* Found it. */ 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
													cat  =  cat - > next ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2003-03-09 06:00:18 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-30 06:26:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									if  ( cat ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										cat  =  next_available_category ( cat ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									config - > last_browse  =  cat ; 
							 
						 
					
						
							
								
									
										
										
										
											2006-04-06 16:06:57 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									return  ( cat )  ?  cat - > name  :  NULL ; 
							 
						 
					
						
							
								
									
										
										
										
											2003-03-09 06:00:18 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								struct  ast_variable  * ast_category_detach_variables ( struct  ast_category  * cat ) 
							 
						 
					
						
							
								
									
										
										
										
											2003-03-09 06:00:18 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									struct  ast_variable  * v ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									v  =  cat - > root ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									cat - > root  =  NULL ; 
							 
						 
					
						
							
								
									
										
										
										
											2006-11-15 20:05:26 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									cat - > last  =  NULL ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									return  v ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								void  ast_category_rename ( struct  ast_category  * cat ,  const  char  * name ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2005-07-10 22:56:21 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									ast_copy_string ( cat - > name ,  name ,  sizeof ( cat - > name ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2005-01-30 06:26:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								static  void  inherit_category ( struct  ast_category  * new ,  const  struct  ast_category  * base ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									struct  ast_variable  * var ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									struct  ast_category_template_instance  * x ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-12-08 18:05:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									x  =  ast_calloc ( 1 ,  sizeof ( * x ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									if  ( ! x )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2007-11-06 21:08:38 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									strcpy ( x - > name ,  base - > name ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									x - > inst  =  base ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									AST_LIST_INSERT_TAIL ( & new - > template_instances ,  x ,  next ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2006-04-06 16:06:57 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									for  ( var  =  base - > root ;  var ;  var  =  var - > next ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										ast_variable_append ( new ,  variable_clone ( var ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-30 06:26:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								struct  ast_config  * ast_config_new ( void )  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									struct  ast_config  * config ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2006-04-06 16:06:57 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									if  ( ( config  =  ast_calloc ( 1 ,  sizeof ( * config ) ) ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										config - > max_include_level  =  MAX_INCLUDE_LEVEL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									return  config ; 
							 
						 
					
						
							
								
									
										
										
										
											2003-03-09 06:00:18 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-02-12 00:24:36 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								int  ast_variable_delete ( struct  ast_category  * category ,  const  char  * variable ,  const  char  * match ,  const  char  * line ) 
							 
						 
					
						
							
								
									
										
										
										
											2006-07-19 13:28:38 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2006-07-29 22:02:37 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									struct  ast_variable  * cur ,  * prev = NULL ,  * curn ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									int  res  =  - 1 ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-08-22 21:22:24 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									int  num_item  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									int  req_item ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									req_item  =  - 1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									if  ( ! ast_strlen_zero ( line ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										/* Requesting to delete by item number. */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( sscanf ( line ,  " %30d " ,  & req_item )  ! =  1 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											| |  req_item  <  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											/* Invalid item number to delete. */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											return  - 1 ; 
							 
						 
					
						
							
								
									
										
										
										
											2006-07-19 13:28:38 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2006-07-19 17:26:47 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									prev  =  NULL ; 
							 
						 
					
						
							
								
									
										
										
										
											2006-07-19 13:28:38 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									cur  =  category - > root ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									while  ( cur )  { 
							 
						 
					
						
							
								
									
										
										
										
											2006-07-29 22:02:37 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										curn  =  cur - > next ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-08-22 21:22:24 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										/* Delete by item number or by variable name with optional value. */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( ( 0  < =  req_item  & &  num_item  = =  req_item ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											| |  ( req_item  <  0  & &  ! strcasecmp ( cur - > name ,  variable ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												& &  ( ast_strlen_zero ( match )  | |  ! strcasecmp ( cur - > value ,  match ) ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2006-07-19 13:28:38 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											if  ( prev )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												prev - > next  =  cur - > next ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												if  ( cur  = =  category - > last ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													category - > last  =  prev ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												category - > root  =  cur - > next ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												if  ( cur  = =  category - > last ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													category - > last  =  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2011-08-22 21:22:24 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											ast_variable_destroy ( cur ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2006-07-29 22:02:37 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											res  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										}  else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											prev  =  cur ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										cur  =  curn ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-08-22 21:22:24 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										+ + num_item ; 
							 
						 
					
						
							
								
									
										
										
										
											2006-07-19 13:28:38 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2006-07-29 22:02:37 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									return  res ; 
							 
						 
					
						
							
								
									
										
										
										
											2006-07-19 13:28:38 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-04-20 18:23:24 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								int  ast_variable_update ( struct  ast_category  * category ,  const  char  * variable ,  
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
														const  char  * value ,  const  char  * match ,  unsigned  int  object ) 
							 
						 
					
						
							
								
									
										
										
										
											2006-07-19 13:28:38 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 21:30:26 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									struct  ast_variable  * cur ,  * prev = NULL ,  * newer = NULL ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-04-20 18:23:24 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									for  ( cur  =  category - > root ;  cur ;  prev  =  cur ,  cur  =  cur - > next )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( strcasecmp ( cur - > name ,  variable )  | | 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											( ! ast_strlen_zero ( match )  & &  strcasecmp ( cur - > value ,  match ) ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										if  ( ! ( newer  =  ast_variable_new ( variable ,  value ,  cur - > file ) ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											return  - 1 ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-23 21:25:17 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										ast_variable_move ( newer ,  cur ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										newer - > object  =  newer - > object  | |  object ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-23 21:25:17 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										/* Replace the old node in the list with the new node. */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										newer - > next  =  cur - > next ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-04-20 18:23:24 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										if  ( prev ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											prev - > next  =  newer ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											category - > root  =  newer ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( category - > last  = =  cur ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											category - > last  =  newer ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										ast_variable_destroy ( cur ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-04-20 18:23:24 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										return  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2006-07-19 13:28:38 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-08-05 18:25:16 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									/* Could not find variable to update */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									return  - 1 ; 
							 
						 
					
						
							
								
									
										
										
										
											2006-07-19 13:28:38 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-01-05 23:58:53 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								int  ast_category_delete ( struct  ast_config  * cfg ,  const  char  * category ) 
							 
						 
					
						
							
								
									
										
										
										
											2006-07-19 13:28:38 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									struct  ast_category  * prev = NULL ,  * cat ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-12-08 18:05:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2006-07-19 13:28:38 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									cat  =  cfg - > root ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-01-23 00:11:32 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									while  ( cat )  { 
							 
						 
					
						
							
								
									
										
										
										
											2006-07-19 13:28:38 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										if  ( cat - > name  = =  category )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											if  ( prev )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												prev - > next  =  cat - > next ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												if  ( cat  = =  cfg - > last ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													cfg - > last  =  prev ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												cfg - > root  =  cat - > next ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												if  ( cat  = =  cfg - > last ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													cfg - > last  =  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2007-11-06 21:08:38 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											ast_category_destroy ( cat ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2006-07-19 13:28:38 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											return  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										prev  =  cat ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										cat  =  cat - > next ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2006-07-19 17:26:47 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									prev  =  NULL ; 
							 
						 
					
						
							
								
									
										
										
										
											2006-07-19 13:28:38 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									cat  =  cfg - > root ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-01-23 00:11:32 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									while  ( cat )  { 
							 
						 
					
						
							
								
									
										
										
										
											2006-07-19 13:28:38 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										if  ( ! strcasecmp ( cat - > name ,  category ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											if  ( prev )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												prev - > next  =  cat - > next ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												if  ( cat  = =  cfg - > last ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													cfg - > last  =  prev ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												cfg - > root  =  cat - > next ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												if  ( cat  = =  cfg - > last ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													cfg - > last  =  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2007-11-06 21:08:38 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											ast_category_destroy ( cat ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2006-07-19 13:28:38 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											return  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										prev  =  cat ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										cat  =  cat - > next ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									return  - 1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-02-12 00:24:36 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								int  ast_category_empty ( struct  ast_config  * cfg ,  const  char  * category ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									struct  ast_category  * cat ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									for  ( cat  =  cfg - > root ;  cat ;  cat  =  cat - > next )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( ! strcasecmp ( cat - > name ,  category ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										ast_variables_destroy ( cat - > root ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										cat - > root  =  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										cat - > last  =  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										return  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									return  - 1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								void  ast_config_destroy ( struct  ast_config  * cfg ) 
							 
						 
					
						
							
								
									
										
										
										
											2001-04-23 16:50:12 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									struct  ast_category  * cat ,  * catn ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									if  ( ! cfg ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									ast_includes_destroy ( cfg - > includes ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									cat  =  cfg - > root ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-01-23 00:11:32 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									while  ( cat )  { 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										catn  =  cat ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										cat  =  cat - > next ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-11-06 21:08:38 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										ast_category_destroy ( catn ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2007-06-06 21:20:11 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									ast_free ( cfg ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2001-04-23 16:50:12 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								struct  ast_category  * ast_config_get_current_category ( const  struct  ast_config  * cfg ) 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-22 22:13:11 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									return  cfg - > current ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-22 22:13:11 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-28 19:58:43 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								void  ast_config_set_current_category ( struct  ast_config  * cfg ,  const  struct  ast_category  * cat ) 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-22 22:13:11 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									/* cast below is just to silence compiler warning about dropping "const" */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									cfg - > current  =  ( struct  ast_category  * )  cat ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-22 22:13:11 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
									
										
										
										
											2004-12-28 14:53:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								/*!
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  \ internal 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  \ brief  Create  a  new  cfmtime  list  node . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  \ param  filename  Config  filename  caching . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  \ param  who_asked  Who  wanted  to  know . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  \ retval  cfmtime  New  node  on  success . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  \ retval  NULL  on  error . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								static  struct  cache_file_mtime  * cfmtime_new ( const  char  * filename ,  const  char  * who_asked ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									struct  cache_file_mtime  * cfmtime ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									char  * dst ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									cfmtime  =  ast_calloc ( 1 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										sizeof ( * cfmtime )  +  strlen ( filename )  +  1  +  strlen ( who_asked )  +  1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									if  ( ! cfmtime )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										return  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									dst  =  cfmtime - > filename ; 	/* writable space starts here */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									strcpy ( dst ,  filename ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									dst  + =  strlen ( dst )  +  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									cfmtime - > who_asked  =  strcpy ( dst ,  who_asked ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									return  cfmtime ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-08-16 21:09:46 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								enum  config_cache_attribute_enum  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									ATTRIBUTE_INCLUDE  =  0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									ATTRIBUTE_EXEC  =  1 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-03-11 22:55:16 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								static  void  config_cache_attribute ( const  char  * configfile ,  enum  config_cache_attribute_enum  attrtype ,  const  char  * filename ,  const  char  * who_asked ) 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-16 21:09:46 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									struct  cache_file_mtime  * cfmtime ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									struct  cache_file_include  * cfinclude ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									struct  stat  statbuf  =  {  0 ,  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									/* Find our cached entry for this configuration file */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									AST_LIST_LOCK ( & cfmtime_head ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									AST_LIST_TRAVERSE ( & cfmtime_head ,  cfmtime ,  list )  { 
							 
						 
					
						
							
								
									
										
										
										
											2008-05-21 02:20:31 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										if  ( ! strcmp ( cfmtime - > filename ,  configfile )  & &  ! strcmp ( cfmtime - > who_asked ,  who_asked ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-16 21:09:46 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									if  ( ! cfmtime )  { 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										cfmtime  =  cfmtime_new ( configfile ,  who_asked ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-16 21:09:46 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										if  ( ! cfmtime )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											AST_LIST_UNLOCK ( & cfmtime_head ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										/* Note that the file mtime is initialized to 0, i.e. 1970 */ 
							 
						 
					
						
							
								
									
										
										
										
											2008-03-26 19:19:31 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										AST_LIST_INSERT_SORTALPHA ( & cfmtime_head ,  cfmtime ,  list ,  filename ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-16 21:09:46 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									if  ( ! stat ( configfile ,  & statbuf ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										cfmtime - > mtime  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										cfmtime - > mtime  =  statbuf . st_mtime ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									switch  ( attrtype )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									case  ATTRIBUTE_INCLUDE : 
							 
						 
					
						
							
								
									
										
										
										
											2007-11-02 13:17:48 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										AST_LIST_TRAVERSE ( & cfmtime - > includes ,  cfinclude ,  list )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											if  ( ! strcmp ( cfinclude - > include ,  filename ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												AST_LIST_UNLOCK ( & cfmtime_head ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-16 21:09:46 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										cfinclude  =  ast_calloc ( 1 ,  sizeof ( * cfinclude )  +  strlen ( filename )  +  1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( ! cfinclude )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											AST_LIST_UNLOCK ( & cfmtime_head ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										strcpy ( cfinclude - > include ,  filename ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										AST_LIST_INSERT_TAIL ( & cfmtime - > includes ,  cfinclude ,  list ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									case  ATTRIBUTE_EXEC : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										cfmtime - > has_exec  =  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									AST_LIST_UNLOCK ( & cfmtime_head ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-12-08 03:47:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								/*! \brief parse one line in the configuration.
 
							 
						 
					
						
							
								
									
										
										
										
											2008-02-15 17:29:08 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								 *  \ verbatim 
							 
						 
					
						
							
								
									
										
										
										
											2007-12-08 03:47:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								 *  We  can  have  a  category  header 	[ foo ] ( . . . ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  a  directive 				# include  /  # exec 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  or  a  regular  line 			name  =  value 
							 
						 
					
						
							
								
									
										
										
										
											2008-02-15 17:29:08 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								 *  \ endverbatim 
							 
						 
					
						
							
								
									
										
										
										
											2007-12-08 03:47:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								 */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								static  int  process_text_line ( struct  ast_config  * cfg ,  struct  ast_category  * * cat , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									char  * buf ,  int  lineno ,  const  char  * configfile ,  struct  ast_flags  flags , 
							 
						 
					
						
							
								
									
										
										
										
											2007-12-08 18:50:32 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									struct  ast_str  * comment_buffer , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									struct  ast_str  * lline_buffer , 
							 
						 
					
						
							
								
									
										
										
										
											2007-12-08 03:47:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									const  char  * suggested_include_file , 
							 
						 
					
						
							
								
									
										
										
										
											2008-03-11 22:55:16 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									struct  ast_category  * * last_cat ,  struct  ast_variable  * * last_var ,  const  char  * who_asked ) 
							 
						 
					
						
							
								
									
										
										
										
											2002-03-05 23:57:31 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									char  * c ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-30 06:26:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									char  * cur  =  buf ; 
							 
						 
					
						
							
								
									
										
										
										
											2002-03-05 23:57:31 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									struct  ast_variable  * v ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-02-02 03:38:24 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									char  cmd [ 512 ] ,  exec_file [ 512 ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-22 22:13:11 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									/* Actually parse the entry */ 
							 
						 
					
						
							
								
									
										
										
										
											2007-12-08 03:47:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									if  ( cur [ 0 ]  = =  ' [ ' )  {  /* A category header */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										/* format is one of the following:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 *  [ foo ] 	define  a  new  category  named  ' foo ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 *  [ foo ] ( ! ) 	define  a  new  template  category  named  ' foo ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 *  [ foo ] ( + ) 	append  to  category  ' foo ' ,  error  if  foo  does  not  exist . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 *  [ foo ] ( a ) 	define  a  new  category  and  inherit  from  template  a . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 * 		You  can  put  a  comma - separated  list  of  templates  and  ' ! '  and  ' + ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 * 		between  parentheses ,  with  obvious  meaning . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 */ 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-30 06:26:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										struct  ast_category  * newcat  =  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										char  * catname ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2005-01-22 22:13:11 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										c  =  strchr ( cur ,  ' ] ' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( ! c )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											ast_log ( LOG_WARNING ,  " parse error: no closing ']', line %d of %s \n " ,  lineno ,  configfile ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											return  - 1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-30 06:26:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										* c + +  =  ' \0 ' ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-22 22:13:11 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										cur + + ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-30 06:26:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								 		if  ( * c + +  ! =  ' ( ' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 			c  =  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										catname  =  cur ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-12-05 05:41:41 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										if  ( ! ( * cat  =  newcat  =  ast_category_new ( catname , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												S_OR ( suggested_include_file ,  cfg - > include_level  = =  1  ?  " "  :  configfile ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												lineno ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-22 22:13:11 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											return  - 1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										( * cat ) - > lineno  =  lineno ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-09-05 14:47:45 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										* last_var  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										* last_cat  =  newcat ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										
							 
						 
					
						
							
								
									
										
										
										
											2006-10-26 01:38:47 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										/* add comments */ 
							 
						 
					
						
							
								
									
										
										
										
											2007-12-08 18:50:32 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										if  ( ast_test_flag ( & flags ,  CONFIG_FLAG_WITHCOMMENTS ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											newcat - > precomments  =  ALLOC_COMMENT ( comment_buffer ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( ast_test_flag ( & flags ,  CONFIG_FLAG_WITHCOMMENTS ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											newcat - > sameline  =  ALLOC_COMMENT ( lline_buffer ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-16 21:09:46 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										if  ( ast_test_flag ( & flags ,  CONFIG_FLAG_WITHCOMMENTS ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2007-03-26 20:27:02 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											CB_RESET ( comment_buffer ,  lline_buffer ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2006-10-26 01:38:47 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										
							 
						 
					
						
							
								
									
										
										
										
											2005-01-30 06:26:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								 		/* If there are options or categories to inherit from, process them now */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 		if  ( c )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 			if  ( ! ( cur  =  strchr ( c ,  ' ) ' ) ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 				ast_log ( LOG_WARNING ,  " parse error: no closing ')', line %d of %s \n " ,  lineno ,  configfile ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 				return  - 1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 			} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 			* cur  =  ' \0 ' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 			while  ( ( cur  =  strsep ( & c ,  " , " ) ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												if  ( ! strcasecmp ( cur ,  " ! " ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													( * cat ) - > ignored  =  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												}  else  if  ( ! strcasecmp ( cur ,  " + " ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													* cat  =  category_get ( cfg ,  catname ,  1 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-03-26 20:27:02 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
													if  ( ! ( * cat ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-30 06:26:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
														if  ( newcat ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
															ast_category_destroy ( newcat ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														ast_log ( LOG_WARNING ,  " Category addition requested, but category '%s' does not exist, line %d of %s \n " ,  catname ,  lineno ,  configfile ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														return  - 1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													if  ( newcat )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														move_variables ( newcat ,  * cat ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														ast_category_destroy ( newcat ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														newcat  =  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													struct  ast_category  * base ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 				
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													base  =  category_get ( cfg ,  cur ,  1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													if  ( ! base )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														ast_log ( LOG_WARNING ,  " Inheritance requested, but category '%s' does not exist, line %d of %s \n " ,  cur ,  lineno ,  configfile ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														return  - 1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													inherit_category ( * cat ,  base ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 			} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 		} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( newcat ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											ast_category_append ( cfg ,  * cat ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-12-08 03:47:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									}  else  if  ( cur [ 0 ]  = =  ' # ' )  {  /* A directive - #include or #exec */ 
							 
						 
					
						
							
								
									
										
										
										
											2007-12-08 19:06:01 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										char  * cur2 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										char  real_inclusion_name [ 256 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										int  do_include  =  0 ; 	/* otherwise, it is exec */ 
							 
						 
					
						
							
								
									
										
										
										
											2007-12-08 03:47:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2005-01-22 22:13:11 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										cur + + ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										c  =  cur ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-09-12 23:30:03 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										while  ( * c  & &  ( * c  >  32 ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											c + + ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2005-01-22 22:13:11 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										if  ( * c )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											* c  =  ' \0 ' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											/* Find real argument */ 
							 
						 
					
						
							
								
									
										
										
										
											2010-06-28 21:42:52 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											c  =  ast_strip ( c  +  1 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-09-12 23:30:03 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											if  ( ! ( * c ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-22 21:00:31 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												c  =  NULL ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-09-12 23:30:03 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2010-06-28 21:42:52 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-22 22:13:11 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											c  =  NULL ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-06-28 21:42:52 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2007-12-08 19:06:01 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										if  ( ! strcasecmp ( cur ,  " include " ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											do_include  =  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										}  else  if  ( ! strcasecmp ( cur ,  " exec " ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											if  ( ! ast_opt_exec_includes )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												ast_log ( LOG_WARNING ,  " Cannot perform #exec unless execincludes option is enabled in asterisk.conf (options section)! \n " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												return  0 ; 	/* XXX is this correct ? or we should return -1 ? */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2008-07-18 18:50:37 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											ast_log ( LOG_WARNING ,  " Unknown directive '#%s' at line %d of %s \n " ,  cur ,  lineno ,  configfile ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-12-08 19:06:01 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											return  0 ; 	/* XXX is this correct ? or we should return -1 ? */ 
							 
						 
					
						
							
								
									
										
										
										
											2005-02-02 03:38:24 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2007-12-08 19:06:01 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( c  = =  NULL )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											ast_log ( LOG_WARNING ,  " Directive '#%s' needs an argument (%s) at line %d of %s \n " ,  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													do_include  ?  " include "  :  " exec " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													do_include  ?  " filename "  :  " /path/to/executable " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													lineno , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													configfile ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											return  0 ; 	/* XXX is this correct ? or we should return -1 ? */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-08-05 18:25:16 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										cur  =  c ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-09-16 23:42:12 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										/* Strip off leading and trailing "'s and <>'s */ 
							 
						 
					
						
							
								
									
										
										
										
											2010-06-28 21:42:52 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										/* Dequote */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( ( * c  = =  ' " ' )  | |  ( * c  = =  ' < ' ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											char  quote_char  =  * c ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											if  ( quote_char  = =  ' < ' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												quote_char  =  ' > ' ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-09-16 23:42:12 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2010-06-28 21:42:52 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											if  ( * ( c  +  strlen ( c )  -  1 )  = =  quote_char )  { 
							 
						 
					
						
							
								
									
										
										
										
											2009-09-16 23:42:12 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												cur + + ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												* ( c  +  strlen ( c )  -  1 )  =  ' \0 ' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-05 18:25:16 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2009-09-16 23:42:12 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										cur2  =  cur ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-08-05 18:25:16 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										/* #exec </path/to/executable>
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										   We  create  a  tmp  file ,  then  we  # include  it ,  then  we  delete  it .  */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( ! do_include )  { 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-10 19:35:50 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											struct  timeval  now  =  ast_tvnow ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-05 18:25:16 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											if  ( ! ast_test_flag ( & flags ,  CONFIG_FLAG_NOCACHE ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												config_cache_attribute ( configfile ,  ATTRIBUTE_EXEC ,  NULL ,  who_asked ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-10 19:35:50 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											snprintf ( exec_file ,  sizeof ( exec_file ) ,  " /var/tmp/exec.%d%d.%ld " ,  ( int ) now . tv_sec ,  ( int ) now . tv_usec ,  ( long ) pthread_self ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-05 18:25:16 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											snprintf ( cmd ,  sizeof ( cmd ) ,  " %s > %s 2>&1 " ,  cur ,  exec_file ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											ast_safe_system ( cmd ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											cur  =  exec_file ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											if  ( ! ast_test_flag ( & flags ,  CONFIG_FLAG_NOCACHE ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												config_cache_attribute ( configfile ,  ATTRIBUTE_INCLUDE ,  cur ,  who_asked ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											exec_file [ 0 ]  =  ' \0 ' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										/* A #include */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										/* record this inclusion */ 
							 
						 
					
						
							
								
									
										
										
										
											2011-05-03 19:55:49 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										ast_include_new ( cfg ,  cfg - > include_level  = =  1  ?  " "  :  configfile ,  cur ,  ! do_include ,  cur2 ,  lineno ,  real_inclusion_name ,  sizeof ( real_inclusion_name ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-05 18:25:16 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										do_include  =  ast_config_internal_load ( cur ,  cfg ,  flags ,  real_inclusion_name ,  who_asked )  ?  1  :  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( ! ast_strlen_zero ( exec_file ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											unlink ( exec_file ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( ! do_include )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											ast_log ( LOG_ERROR ,  " The file '%s' was listed as a #include but it does not exist. \n " ,  cur ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											return  - 1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										/* XXX otherwise what ? the default return is 0 anyways */ 
							 
						 
					
						
							
								
									
										
										
										
											2005-02-02 03:38:24 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2005-01-22 22:13:11 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										/* Just a line (variable = value) */ 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-05 18:25:16 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										int  object  =  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-03-26 20:27:02 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										if  ( ! ( * cat ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-22 22:13:11 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											ast_log ( LOG_WARNING , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												" parse error: No category context for line %d of %s \n " ,  lineno ,  configfile ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											return  - 1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										c  =  strchr ( cur ,  ' = ' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-05 18:25:16 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( c  & &  c  >  cur  & &  ( * ( c  -  1 )  = =  ' + ' ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											struct  ast_variable  * var ,  * replace  =  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											struct  ast_str  * * str  =  ast_threadstorage_get ( & appendbuf ,  sizeof ( * str ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											if  ( ! str  | |  ! * str )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												return  - 1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											* ( c  -  1 )  =  ' \0 ' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											c + + ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											cur  =  ast_strip ( cur ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											/* Must iterate through category until we find last variable of same name (since there could be multiple) */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											for  ( var  =  ast_category_first ( * cat ) ;  var ;  var  =  var - > next )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												if  ( ! strcmp ( var - > name ,  cur ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													replace  =  var ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											if  ( ! replace )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												/* Nothing to replace; just set a variable normally. */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												goto  set_new_variable ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											ast_str_set ( str ,  0 ,  " %s " ,  replace - > value ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											ast_str_append ( str ,  0 ,  " %s " ,  c ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-12-13 08:36:35 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											ast_str_trim_blanks ( * str ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											ast_variable_update ( * cat ,  replace - > name ,  ast_skip_blanks ( ast_str_buffer ( * str ) ) ,  replace - > value ,  object ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-05 18:25:16 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										}  else  if  ( c )  { 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-22 22:13:11 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											* c  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											c + + ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											/* Ignore > in => */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											if  ( * c = =  ' > ' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												object  =  1 ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-22 21:00:31 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												c + + ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-05 18:25:16 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set_new_variable : 
							 
						 
					
						
							
								
									
										
										
										
											2008-12-05 05:41:41 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											if  ( ( v  =  ast_variable_new ( ast_strip ( cur ) ,  ast_strip ( c ) ,  S_OR ( suggested_include_file ,  cfg - > include_level  = =  1  ?  " "  :  configfile ) ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-22 22:13:11 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												v - > lineno  =  lineno ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												v - > object  =  object ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-09-05 14:47:45 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												* last_cat  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												* last_var  =  v ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-22 22:13:11 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												/* Put and reset comments */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												v - > blanklines  =  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												ast_variable_append ( * cat ,  v ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2006-10-26 01:38:47 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												/* add comments */ 
							 
						 
					
						
							
								
									
										
										
										
											2007-12-08 18:50:32 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												if  ( ast_test_flag ( & flags ,  CONFIG_FLAG_WITHCOMMENTS ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													v - > precomments  =  ALLOC_COMMENT ( comment_buffer ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												if  ( ast_test_flag ( & flags ,  CONFIG_FLAG_WITHCOMMENTS ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													v - > sameline  =  ALLOC_COMMENT ( lline_buffer ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-16 21:09:46 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												if  ( ast_test_flag ( & flags ,  CONFIG_FLAG_WITHCOMMENTS ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2007-03-26 20:27:02 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
													CB_RESET ( comment_buffer ,  lline_buffer ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2006-10-26 01:38:47 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												
							 
						 
					
						
							
								
									
										
										
										
											2005-01-22 21:00:31 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-22 22:13:11 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												return  - 1 ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-22 21:00:31 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-22 22:13:11 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											ast_log ( LOG_WARNING ,  " No '=' (equal sign) in line %d of %s \n " ,  lineno ,  configfile ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2003-03-09 06:00:18 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2002-03-05 23:57:31 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									return  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-03-11 22:55:16 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								static  struct  ast_config  * config_text_file_load ( const  char  * database ,  const  char  * table ,  const  char  * filename ,  struct  ast_config  * cfg ,  struct  ast_flags  flags ,  const  char  * suggested_include_file ,  const  char  * who_asked ) 
							 
						 
					
						
							
								
									
										
										
										
											1999-10-24 18:00:20 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2006-02-24 10:50:43 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									char  fn [ 256 ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-06-03 22:17:07 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# if defined(LOW_MEMORY) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									char  buf [ 512 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# else 
 
							 
						 
					
						
							
								
									
										
										
										
											2004-06-12 14:34:15 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									char  buf [ 8192 ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-06-03 22:17:07 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# endif 
 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									char  * new_buf ,  * comment_p ,  * process_buf ; 
							 
						 
					
						
							
								
									
										
										
										
											1999-10-24 18:00:20 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
									FILE  * f ; 
							 
						 
					
						
							
								
									
										
										
										
											2006-02-24 10:50:43 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									int  lineno = 0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2004-12-04 16:09:45 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									int  comment  =  0 ,  nest [ MAX_NESTED_COMMENTS ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									struct  ast_category  * cat  =  NULL ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-06-07 21:28:04 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									int  count  =  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-10-31 21:08:55 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									struct  stat  statbuf ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-16 21:09:46 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									struct  cache_file_mtime  * cfmtime  =  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									struct  cache_file_include  * cfinclude ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-09-05 14:47:45 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									struct  ast_variable  * last_var  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									struct  ast_category  * last_cat  =  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-03-26 20:27:02 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									/*! Growable string buffer */ 
							 
						 
					
						
							
								
									
										
										
										
											2007-12-08 19:06:01 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									struct  ast_str  * comment_buffer  =  NULL ; 	/*!< this will be a comment collector.*/ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									struct  ast_str  * lline_buffer  =  NULL ; 	/*!< A buffer for stuff behind the ; */ 
							 
						 
					
						
							
								
									
										
										
										
											2007-03-26 20:27:02 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-08-16 21:09:46 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									if  ( cfg ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										cat  =  ast_config_get_current_category ( cfg ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2004-06-17 04:53:55 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									if  ( filename [ 0 ]  = =  ' / ' )  { 
							 
						 
					
						
							
								
									
										
										
										
											2005-07-10 22:56:21 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										ast_copy_string ( fn ,  filename ,  sizeof ( fn ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											1999-10-24 18:00:20 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
									}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2007-12-18 09:46:18 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										snprintf ( fn ,  sizeof ( fn ) ,  " %s/%s " ,  ast_config_AST_CONFIG_DIR ,  filename ) ; 
							 
						 
					
						
							
								
									
										
										
										
											1999-10-24 18:00:20 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-08-16 21:09:46 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									if  ( ast_test_flag ( & flags ,  CONFIG_FLAG_WITHCOMMENTS ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2007-12-08 18:50:32 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										comment_buffer  =  ast_str_create ( CB_SIZE ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( comment_buffer ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											lline_buffer  =  ast_str_create ( CB_SIZE ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( ! lline_buffer )  { 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											ast_free ( comment_buffer ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-01-04 22:34:24 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											ast_log ( LOG_ERROR ,  " Failed to initialize the comment buffer! \n " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											return  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2006-10-26 01:38:47 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2004-12-11 05:16:30 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# ifdef AST_INCLUDE_GLOB 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										int  glob_ret ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										glob_t  globbuf ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										globbuf . gl_offs  =  0 ; 	/* initialize it to silence gcc */ 
							 
						 
					
						
							
								
									
										
										
										
											2007-12-08 18:18:28 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										glob_ret  =  glob ( fn ,  MY_GLOB_FLAGS ,  NULL ,  & globbuf ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2004-12-11 05:16:30 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										if  ( glob_ret  = =  GLOB_NOSPACE ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											ast_log ( LOG_WARNING , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												" Glob Expansion of pattern '%s' failed: Not enough memory \n " ,  fn ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										else  if  ( glob_ret   = =  GLOB_ABORTED ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											ast_log ( LOG_WARNING , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												" Glob Expansion of pattern '%s' failed: Read error \n " ,  fn ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										else   { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											/* loop over expanded files */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											int  i ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											for  ( i = 0 ;  i < globbuf . gl_pathc ;  i + + )  { 
							 
						 
					
						
							
								
									
										
										
										
											2005-07-10 22:56:21 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												ast_copy_string ( fn ,  globbuf . gl_pathv [ i ] ,  sizeof ( fn ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2004-12-11 05:16:30 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# endif 
 
							 
						 
					
						
							
								
									
										
										
										
											2007-12-08 17:58:08 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									/*
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 *  The  following  is  not  a  loop ,  but  just  a  convenient  way  to  define  a  block 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 *  ( using  do  {  }  while ( 0 )  ) ,  and  be  able  to  exit  from  it  with  ' continue ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 *  or  ' break '  in  case  of  errors .  Nice  trick . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									 */ 
							 
						 
					
						
							
								
									
										
										
										
											2005-10-31 21:08:55 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									do  { 
							 
						 
					
						
							
								
									
										
										
										
											2005-11-07 22:05:31 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										if  ( stat ( fn ,  & statbuf ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2005-10-31 21:08:55 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											continue ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-11-07 22:05:31 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2005-10-31 21:08:55 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										if  ( ! S_ISREG ( statbuf . st_mode ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											ast_log ( LOG_WARNING ,  " '%s' is not a regular file, ignoring \n " ,  fn ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-16 21:09:46 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( ! ast_test_flag ( & flags ,  CONFIG_FLAG_NOCACHE ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											/* Find our cached entry for this configuration file */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											AST_LIST_LOCK ( & cfmtime_head ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											AST_LIST_TRAVERSE ( & cfmtime_head ,  cfmtime ,  list )  { 
							 
						 
					
						
							
								
									
										
										
										
											2008-03-11 22:55:16 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												if  ( ! strcmp ( cfmtime - > filename ,  fn )  & &  ! strcmp ( cfmtime - > who_asked ,  who_asked ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-16 21:09:46 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
													break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											if  ( ! cfmtime )  { 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												cfmtime  =  cfmtime_new ( fn ,  who_asked ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-16 21:09:46 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												if  ( ! cfmtime ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												/* Note that the file mtime is initialized to 0, i.e. 1970 */ 
							 
						 
					
						
							
								
									
										
										
										
											2008-03-26 19:19:31 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												AST_LIST_INSERT_SORTALPHA ( & cfmtime_head ,  cfmtime ,  list ,  filename ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-16 21:09:46 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( cfmtime  & &  ( ! cfmtime - > has_exec )  & &  ( cfmtime - > mtime  = =  statbuf . st_mtime )  & &  ast_test_flag ( & flags ,  CONFIG_FLAG_FILEUNCHANGED ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											/* File is unchanged, what about the (cached) includes (if any)? */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											int  unchanged  =  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											AST_LIST_TRAVERSE ( & cfmtime - > includes ,  cfinclude ,  list )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												/* We must glob here, because if we did not, then adding a file to globbed directory would
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												 *  incorrectly  cause  no  reload  to  be  necessary .  */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												char  fn2 [ 256 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# ifdef AST_INCLUDE_GLOB 
 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-10 19:35:50 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												int  glob_return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												glob_t  glob_buf  =  {  . gl_offs  =  0  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												glob_return  =  glob ( cfinclude - > include ,  MY_GLOB_FLAGS ,  NULL ,  & glob_buf ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-16 21:09:46 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												/* On error, we reparse */ 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-10 19:35:50 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												if  ( glob_return  = =  GLOB_NOSPACE  | |  glob_return   = =  GLOB_ABORTED ) 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-16 21:09:46 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
													unchanged  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												else   { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													/* loop over expanded files */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													int  j ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-10 19:35:50 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
													for  ( j  =  0 ;  j  <  glob_buf . gl_pathc ;  j + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														ast_copy_string ( fn2 ,  glob_buf . gl_pathv [ j ] ,  sizeof ( fn2 ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-16 21:09:46 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# else 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														ast_copy_string ( fn2 ,  cfinclude - > include ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# endif 
 
							 
						 
					
						
							
								
									
										
										
										
											2008-03-11 22:55:16 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
														if  ( config_text_file_load ( NULL ,  NULL ,  fn2 ,  NULL ,  flags ,  " " ,  who_asked )  = =  NULL )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
															/* that second-to-last field needs to be looked at in this case... TODO */ 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-16 21:09:46 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
															unchanged  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
															/* One change is enough to short-circuit and reload the whole shebang */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
															break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# ifdef AST_INCLUDE_GLOB 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# endif 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											if  ( unchanged )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												AST_LIST_UNLOCK ( & cfmtime_head ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												return  CONFIG_STATUS_FILEUNCHANGED ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-17 14:41:33 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										if  ( ! ast_test_flag ( & flags ,  CONFIG_FLAG_NOCACHE ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-16 21:09:46 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											AST_LIST_UNLOCK ( & cfmtime_head ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										/* If cfg is NULL, then we just want an answer */ 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										if  ( cfg  = =  NULL )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											ast_free ( comment_buffer ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											ast_free ( lline_buffer ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-16 21:09:46 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											return  NULL ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-16 21:09:46 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( cfmtime ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											cfmtime - > mtime  =  statbuf . st_mtime ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-07-26 15:49:18 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										ast_verb ( 2 ,  " Parsing '%s':  " ,  fn ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-10-31 21:08:55 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											fflush ( stdout ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( ! ( f  =  fopen ( fn ,  " r " ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2007-06-14 19:39:12 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											ast_debug ( 1 ,  " No file to parse: %s \n " ,  fn ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-07-26 15:49:18 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											ast_verb ( 2 ,  " Not found (%s) \n " ,  strerror ( errno ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-10-31 21:08:55 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2005-06-07 21:28:04 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										count + + ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-09-03 18:01:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										/* If we get to this point, then we're loading regardless */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										ast_clear_flag ( & flags ,  CONFIG_FLAG_FILEUNCHANGED ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-06-14 19:39:12 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										ast_debug ( 1 ,  " Parsing %s \n " ,  fn ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-07-26 15:49:18 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										ast_verb ( 2 ,  " Found \n " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-01-23 00:11:32 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										while  ( ! feof ( f ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-22 22:13:11 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											lineno + + ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											if  ( fgets ( buf ,  sizeof ( buf ) ,  f ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2008-12-13 08:36:35 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												if  ( ast_test_flag ( & flags ,  CONFIG_FLAG_WITHCOMMENTS )  & &  lline_buffer  & &  ast_str_strlen ( lline_buffer ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													CB_ADD ( & comment_buffer ,  ast_str_buffer ( lline_buffer ) ) ;        /* add the current lline buffer to the comment buffer */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													ast_str_reset ( lline_buffer ) ;         /* erase the lline buffer */ 
							 
						 
					
						
							
								
									
										
										
										
											2006-10-26 01:38:47 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												
							 
						 
					
						
							
								
									
										
										
										
											2005-01-22 22:13:11 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												new_buf  =  buf ; 
							 
						 
					
						
							
								
									
										
										
										
											2006-10-26 01:38:47 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												if  ( comment )  
							 
						 
					
						
							
								
									
										
										
										
											2005-01-22 22:13:11 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
													process_buf  =  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													process_buf  =  buf ; 
							 
						 
					
						
							
								
									
										
										
										
											2006-10-26 01:38:47 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												
							 
						 
					
						
							
								
									
										
										
										
											2008-12-13 08:36:35 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												if  ( ast_test_flag ( & flags ,  CONFIG_FLAG_WITHCOMMENTS )  & &  comment_buffer  & &  ast_str_strlen ( comment_buffer )  & &  ( ast_strlen_zero ( buf )  | |  strlen ( buf )  = =  strspn ( buf , "   \t \n \r " ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2007-09-11 22:37:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
													/* blank line? really? Can we add it to an existing comment and maybe preserve inter- and post- comment spacing? */ 
							 
						 
					
						
							
								
									
										
										
										
											2007-12-08 18:50:32 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
													CB_ADD ( & comment_buffer ,  " \n " ) ;        /* add a newline to the comment buffer */ 
							 
						 
					
						
							
								
									
										
										
										
											2007-09-11 22:37:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
													continue ;  /* go get a new line, then */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												
							 
						 
					
						
							
								
									
										
										
										
											2005-01-22 22:13:11 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												while  ( ( comment_p  =  strchr ( new_buf ,  COMMENT_META ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2008-12-13 08:36:35 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
													if  ( ( comment_p  >  new_buf )  & &  ( * ( comment_p  -  1 )  = =  ' \\ ' ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-06 16:31:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
														/* Escaped semicolons aren't comments. */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														new_buf  =  comment_p  +  1 ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-01-23 00:11:32 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
													}  else  if  ( comment_p [ 1 ]  = =  COMMENT_TAG  & &  comment_p [ 2 ]  = =  COMMENT_TAG  & &  ( comment_p [ 3 ]  ! =  ' - ' ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-22 22:13:11 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
														/* Meta-Comment start detected ";--" */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														if  ( comment  <  MAX_NESTED_COMMENTS )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
															* comment_p  =  ' \0 ' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
															new_buf  =  comment_p  +  3 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
															comment + + ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
															nest [ comment - 1 ]  =  lineno ; 
							 
						 
					
						
							
								
									
										
										
										
											2004-12-04 16:09:45 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
														}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-22 22:13:11 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
															ast_log ( LOG_ERROR ,  " Maximum nest limit of %d reached. \n " ,  MAX_NESTED_COMMENTS ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													}  else  if  ( ( comment_p  > =  new_buf  +  2 )  & & 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														   ( * ( comment_p  -  1 )  = =  COMMENT_TAG )  & & 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														   ( * ( comment_p  -  2 )  = =  COMMENT_TAG ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														/* Meta-Comment end detected */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														comment - - ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														new_buf  =  comment_p  +  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														if  ( ! comment )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
															/* Back to non-comment now */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
															if  ( process_buf )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
																/* Actually have to move what's left over the top, then continue */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
																char  * oldptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
																oldptr  =  process_buf  +  strlen ( process_buf ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-16 21:09:46 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
																if  ( ast_test_flag ( & flags ,  CONFIG_FLAG_WITHCOMMENTS ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2007-12-08 18:50:32 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
																	CB_ADD ( & comment_buffer ,  " ; " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
																	CB_ADD_LEN ( & comment_buffer ,  oldptr + 1 ,  new_buf - oldptr - 1 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2006-10-26 01:38:47 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
																} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
																
							 
						 
					
						
							
								
									
										
										
										
											2005-01-22 22:13:11 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
																memmove ( oldptr ,  new_buf ,  strlen ( new_buf )  +  1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
																new_buf  =  oldptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2004-12-04 16:09:45 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
															}  else 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-22 22:13:11 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
																process_buf  =  new_buf ; 
							 
						 
					
						
							
								
									
										
										
										
											2004-12-04 16:09:45 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
														} 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-22 22:13:11 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
													}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														if  ( ! comment )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
															/* If ; is found, and we are not nested in a comment, 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
															   we  immediately  stop  all  comment  processing  */ 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-16 21:09:46 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
															if  ( ast_test_flag ( & flags ,  CONFIG_FLAG_WITHCOMMENTS ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2007-12-08 18:50:32 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
																CB_ADD ( & lline_buffer ,  comment_p ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2006-10-26 01:38:47 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
															} 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-22 22:13:11 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
															* comment_p  =  ' \0 ' ;  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
															new_buf  =  comment_p ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														}  else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
															new_buf  =  comment_p  +  1 ; 
							 
						 
					
						
							
								
									
										
										
										
											2004-12-04 16:09:45 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
													} 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-22 22:13:11 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2007-12-08 18:50:32 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												if  ( ast_test_flag ( & flags ,  CONFIG_FLAG_WITHCOMMENTS )  & &  comment  & &  ! process_buf  )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													CB_ADD ( & comment_buffer ,  buf ) ;   /* the whole line is a comment, store it */ 
							 
						 
					
						
							
								
									
										
										
										
											2006-10-26 01:38:47 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												
							 
						 
					
						
							
								
									
										
										
										
											2005-01-30 06:26:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												if  ( process_buf )  { 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-10 19:35:50 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
													char  * buffer  =  ast_strip ( process_buf ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													if  ( ! ast_strlen_zero ( buffer ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														if  ( process_text_line ( cfg ,  & cat ,  buffer ,  lineno ,  fn ,  flags ,  comment_buffer ,  lline_buffer ,  suggested_include_file ,  & last_cat ,  & last_var ,  who_asked ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2008-09-12 23:30:03 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
															cfg  =  CONFIG_STATUS_FILEINVALID ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-30 06:26:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
															break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														} 
							 
						 
					
						
							
								
									
										
										
										
											2005-10-26 18:54:24 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
													} 
							 
						 
					
						
							
								
									
										
										
										
											1999-10-24 18:00:20 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-22 22:13:11 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2007-09-05 14:47:45 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										/* end of file-- anything in a comment buffer? */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( last_cat )  { 
							 
						 
					
						
							
								
									
										
										
										
											2008-12-13 08:36:35 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											if  ( ast_test_flag ( & flags ,  CONFIG_FLAG_WITHCOMMENTS )  & &  comment_buffer  & &  ast_str_strlen ( comment_buffer ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												if  ( lline_buffer  & &  ast_str_strlen ( lline_buffer ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													CB_ADD ( & comment_buffer ,  ast_str_buffer ( lline_buffer ) ) ;        /* add the current lline buffer to the comment buffer */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													ast_str_reset ( lline_buffer ) ;         /* erase the lline buffer */ 
							 
						 
					
						
							
								
									
										
										
										
											2007-12-08 18:50:32 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2007-09-05 14:47:45 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												last_cat - > trailing  =  ALLOC_COMMENT ( comment_buffer ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										}  else  if  ( last_var )  { 
							 
						 
					
						
							
								
									
										
										
										
											2008-12-13 08:36:35 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											if  ( ast_test_flag ( & flags ,  CONFIG_FLAG_WITHCOMMENTS )  & &  comment_buffer  & &  ast_str_strlen ( comment_buffer ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												if  ( lline_buffer  & &  ast_str_strlen ( lline_buffer ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													CB_ADD ( & comment_buffer ,  ast_str_buffer ( lline_buffer ) ) ;        /* add the current lline buffer to the comment buffer */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													ast_str_reset ( lline_buffer ) ;         /* erase the lline buffer */ 
							 
						 
					
						
							
								
									
										
										
										
											2007-12-08 18:50:32 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2007-09-05 14:47:45 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												last_var - > trailing  =  ALLOC_COMMENT ( comment_buffer ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2008-12-13 08:36:35 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											if  ( ast_test_flag ( & flags ,  CONFIG_FLAG_WITHCOMMENTS )  & &  comment_buffer  & &  ast_str_strlen ( comment_buffer ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												ast_debug ( 1 ,  " Nothing to attach comments to, discarded: %s \n " ,  ast_str_buffer ( comment_buffer ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-09-05 14:47:45 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( ast_test_flag ( & flags ,  CONFIG_FLAG_WITHCOMMENTS ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2007-12-08 18:50:32 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											CB_RESET ( comment_buffer ,  lline_buffer ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-09-05 14:47:45 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-12-13 08:36:35 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										fclose ( f ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-01-23 00:11:32 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									}  while  ( 0 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2004-12-04 16:09:45 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									if  ( comment )  { 
							 
						 
					
						
							
								
									
										
										
										
											2007-06-14 23:23:35 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										ast_log ( LOG_WARNING , " Unterminated comment detected beginning on line %d \n " ,  nest [ comment  -  1 ] ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2004-12-04 16:09:45 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2004-12-11 05:16:30 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# ifdef AST_INCLUDE_GLOB 
 
							 
						 
					
						
							
								
									
										
										
										
											2008-09-12 23:30:03 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
													if  ( cfg  = =  NULL  | |  cfg  = =  CONFIG_STATUS_FILEUNCHANGED  | |  cfg  = =  CONFIG_STATUS_FILEINVALID )  { 
							 
						 
					
						
							
								
									
										
										
										
											2004-12-11 05:16:30 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
														break ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-09-12 23:30:03 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
													} 
							 
						 
					
						
							
								
									
										
										
										
											2004-12-11 05:16:30 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												globfree ( & globbuf ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# endif 
 
							 
						 
					
						
							
								
									
										
										
										
											2007-01-04 22:34:24 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-09-12 23:30:03 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									if  ( cfg  & &  cfg  ! =  CONFIG_STATUS_FILEUNCHANGED  & &  cfg  ! =  CONFIG_STATUS_FILEINVALID  & &  cfg - > include_level  = =  1  & &  ast_test_flag ( & flags ,  CONFIG_FLAG_WITHCOMMENTS ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										ast_free ( comment_buffer ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										ast_free ( lline_buffer ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-01-04 22:34:24 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										comment_buffer  =  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										lline_buffer  =  NULL ; 
							 
						 
					
						
							
								
									
										
										
										
											2006-10-26 01:38:47 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2007-01-04 22:34:24 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									
							 
						 
					
						
							
								
									
										
										
										
											2005-06-07 21:28:04 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									if  ( count  = =  0 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										return  NULL ; 
							 
						 
					
						
							
								
									
										
										
										
											2004-12-11 05:16:30 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									return  cfg ; 
							 
						 
					
						
							
								
									
										
										
										
											1999-10-24 18:00:20 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								/* NOTE: categories and variables each have a file and lineno attribute. On a save operation, these are used to determine
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								   which  file  and  line  number  to  write  out  to .  Thus ,  an  entire  hierarchy  of  config  files  ( via  # include  statements )  can  be 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								   recreated .  BUT ,  care  must  be  taken  to  make  sure  that  every  cat  and  var  has  the  proper  file  name  stored ,  or  you  may 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								   be  shocked  and  mystified  as  to  why  things  are  not  showing  up  in  the  files !  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								   Also ,  All  # include / # exec  statements  are  recorded  in  the  " includes "  LL  in  the  ast_config  structure .  The  file  name 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								   and  line  number  are  stored  for  each  include ,  plus  the  name  of  the  file  included ,  so  that  these  statements  may  be 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								   included  in  the  output  files  on  a  file_save  operation .  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								   The  lineno ' s  are  really  just  for  relative  placement  in  the  file .  There  is  no  attempt  to  make  sure  that  blank  lines 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								   are  included  to  keep  the  lineno ' s  the  same  between  input  and  output .  The  lineno  fields  are  used  mainly  to  determine 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								   the  position  of  the  # include  and  # exec  directives .  So ,  blank  lines  tend  to  disappear  from  a  read / rewrite  operation , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								   and  a  header  gets  added . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								   vars  and  category  heads  are  output  in  the  order  they  are  stored  in  the  config  file .  So ,  if  the  software 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								   shuffles  these  at  all ,  then  the  placement  of  # include  directives  might  get  a  little  mixed  up ,  because  the 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								   file / lineno  data  probably  won ' t  get  changed . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								*/ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								static  void  gen_header ( FILE  * f1 ,  const  char  * configfile ,  const  char  * fn ,  const  char  * generator ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									char  date [ 256 ] = " " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									time_t  t ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-12-08 18:05:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									time ( & t ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									ast_copy_string ( date ,  ctime ( & t ) ,  sizeof ( date ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									fprintf ( f1 ,  " ;! \n " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									fprintf ( f1 ,  " ;! Automatically generated configuration file \n " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									if  ( strcmp ( configfile ,  fn ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										fprintf ( f1 ,  " ;! Filename: %s (%s) \n " ,  configfile ,  fn ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										fprintf ( f1 ,  " ;! Filename: %s \n " ,  configfile ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									fprintf ( f1 ,  " ;! Generator: %s \n " ,  generator ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									fprintf ( f1 ,  " ;! Creation Date: %s " ,  date ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									fprintf ( f1 ,  " ;! \n " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								static  void  inclfile_destroy ( void  * obj ) 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2007-09-12 20:50:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									const  struct  inclfile  * o  =  obj ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-12-08 18:05:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									ast_free ( o - > fname ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-09-12 20:50:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								static  struct  inclfile  * set_fn ( char  * fn ,  int  fn_size ,  const  char  * file ,  const  char  * configfile ,  struct  ao2_container  * fileset ) 
							 
						 
					
						
							
								
									
										
										
										
											2007-09-12 20:50:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									struct  inclfile  lookup ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									struct  inclfile  * fi ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									if  ( ast_strlen_zero ( file ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										if  ( configfile [ 0 ]  = =  ' / ' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											ast_copy_string ( fn ,  configfile ,  fn_size ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											snprintf ( fn ,  fn_size ,  " %s/%s " ,  ast_config_AST_CONFIG_DIR ,  configfile ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									}  else  if  ( file [ 0 ]  = =  ' / ' ) 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										ast_copy_string ( fn ,  file ,  fn_size ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										snprintf ( fn ,  fn_size ,  " %s/%s " ,  ast_config_AST_CONFIG_DIR ,  file ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-09-12 20:50:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									lookup . fname  =  fn ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									fi  =  ao2_find ( fileset ,  & lookup ,  OBJ_POINTER ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									if  ( fi )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										/* Found existing include file scratch pad. */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										return  fi ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									/* set up a file scratch pad */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									fi  =  ao2_alloc ( sizeof ( struct  inclfile ) ,  inclfile_destroy ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									if  ( ! fi )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										/* Scratch pad creation failed. */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										return  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									fi - > fname  =  ast_strdup ( fn ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									if  ( ! fi - > fname )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										/* Scratch pad creation failed. */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										ao2_ref ( fi ,  - 1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										return  NULL ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-09-12 20:50:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									fi - > lineno  =  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									ao2_link ( fileset ,  fi ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									return  fi ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-09-12 20:50:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								static  int  count_linefeeds ( char  * str ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									int  count  =  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-12-08 18:05:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-09-12 20:50:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									while  ( * str )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( * str  = = ' \n ' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											count + + ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										str + + ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									return  count ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								static  int  count_linefeeds_in_comments ( struct  ast_comment  * x ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									int  count  =  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-12-08 18:05:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									while  ( x )  { 
							 
						 
					
						
							
								
									
										
										
										
											2007-09-12 20:50:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										count  + =  count_linefeeds ( x - > cmt ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										x  =  x - > next ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									return  count ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								static  void  insert_leading_blank_lines ( FILE  * fp ,  struct  inclfile  * fi ,  struct  ast_comment  * precomments ,  int  lineno ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									int  precomment_lines ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-09-12 20:50:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									int  i ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									if  ( ! fi )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										/* No file scratch pad object so insert no blank lines. */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									precomment_lines  =  count_linefeeds_in_comments ( precomments ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-09-12 20:50:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									/* I don't have to worry about those ;! comments, they are
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									   stored  in  the  precomments ,  but  not  printed  back  out . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									   I  did  have  to  make  sure  that  comments  following 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									   the  ; !  header  comments  were  not  also  deleted  in  the  process  */ 
							 
						 
					
						
							
								
									
										
										
										
											2008-11-18 18:07:55 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									if  ( lineno  -  precomment_lines  -  fi - > lineno  <  0 )  {  /* insertions can mess up the line numbering and produce negative numbers that mess things up */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										return ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-23 21:25:17 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									}  else  if  ( lineno  = =  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										/* Line replacements also mess things up */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 	}  else  if  ( lineno  -  precomment_lines  -  fi - > lineno  <  5 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 		/* Only insert less than 5 blank lines; if anything more occurs,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 		 *  it ' s  probably  due  to  context  deletion .  */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 		for  ( i  =  fi - > lineno ;  i  <  lineno  -  precomment_lines ;  i + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 			fprintf ( fp ,  " \n " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 		} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 	}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 		/* Deletion occurred - insert a single blank line, for separation of
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 		 *  contexts .  */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 		fprintf ( fp ,  " \n " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 	} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 	fi - > lineno  =  lineno  +  1 ;  /* Advance the file lineno */ 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								int  config_text_file_save ( const  char  * configfile ,  const  struct  ast_config  * cfg ,  const  char  * generator ) 
							 
						 
					
						
							
								
									
										
										
										
											2008-11-04 18:47:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									return  ast_config_text_file_save ( configfile ,  cfg ,  generator ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								int  ast_config_text_file_save ( const  char  * configfile ,  const  struct  ast_config  * cfg ,  const  char  * generator ) 
							 
						 
					
						
							
								
									
										
										
										
											2004-06-17 04:53:55 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									FILE  * f ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									char  fn [ PATH_MAX ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									struct  ast_variable  * var ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									struct  ast_category  * cat ; 
							 
						 
					
						
							
								
									
										
										
										
											2006-10-26 01:38:47 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									struct  ast_comment  * cmt ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									struct  ast_config_include  * incl ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									int  blanklines  =  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									struct  ao2_container  * fileset ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									struct  inclfile  * fi ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									fileset  =  ao2_container_alloc ( 1023 ,  hash_string ,  hashtab_compare_strings ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									if  ( ! fileset )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										/* Container creation failed. */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										return  - 1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2011-08-22 22:11:54 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									/* reset all the output flags, in case this isn't our first time saving this data */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									for  ( incl  =  cfg - > includes ;  incl ;  incl  =  incl - > next )  { 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										incl - > output  =  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									/* go thru all the inclusions and make sure all the files involved (configfile plus all its inclusions)
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									   are  all  truncated  to  zero  bytes  and  have  that  nice  header */ 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									for  ( incl  =  cfg - > includes ;  incl ;  incl  =  incl - > next )  { 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										if  ( ! incl - > exec )  {  /* leave the execs alone -- we'll write out the #exec directives, but won't zero out the include files or exec files*/ 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											/* normally, fn is just set to incl->included_file, prepended with config dir if relative */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											fi  =  set_fn ( fn ,  sizeof ( fn ) ,  incl - > included_file ,  configfile ,  fileset ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											f  =  fopen ( fn ,  " w " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											if  ( f )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												gen_header ( f ,  configfile ,  fn ,  generator ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												fclose ( f ) ;  /* this should zero out the file */ 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												ast_debug ( 1 ,  " Unable to open for writing: %s \n " ,  fn ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												ast_verb ( 2 ,  " Unable to write %s (%s) " ,  fn ,  strerror ( errno ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											if  ( fi )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												ao2_ref ( fi ,  - 1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2004-06-11 00:12:35 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									/* just set fn to absolute ver of configfile */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									fi  =  set_fn ( fn ,  sizeof ( fn ) ,  0 ,  configfile ,  fileset ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									if  ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# ifdef __CYGWIN__ 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										( f  =  fopen ( fn ,  " w+ " ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2005-11-01 21:53:30 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# else 
 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										( f  =  fopen ( fn ,  " w " ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# endif 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										)  { 
							 
						 
					
						
							
								
									
										
										
										
											2007-07-26 15:49:18 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										ast_verb ( 2 ,  " Saving '%s':  " ,  fn ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										gen_header ( f ,  configfile ,  fn ,  generator ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										cat  =  cfg - > root ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										fclose ( f ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										if  ( fi )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											ao2_ref ( fi ,  - 1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										/* from here out, we open each involved file and concat the stuff we need to add to the end and immediately close... */ 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										/* since each var, cat, and associated comments can come from any file, we have to be
 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										   mobile ,  and  open  each  file ,  print ,  and  close  it  on  an  entry - by - entry  basis  */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-01-23 00:11:32 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										while  ( cat )  { 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											fi  =  set_fn ( fn ,  sizeof ( fn ) ,  cat - > file ,  configfile ,  fileset ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											f  =  fopen ( fn ,  " a " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											if  ( ! f )  { 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												ast_debug ( 1 ,  " Unable to open for writing: %s \n " ,  fn ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												ast_verb ( 2 ,  " Unable to write %s (%s) " ,  fn ,  strerror ( errno ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												if  ( fi )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													ao2_ref ( fi ,  - 1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2007-09-12 20:50:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												ao2_ref ( fileset ,  - 1 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												return  - 1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											/* dump any includes that happen before this category header */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											for  ( incl = cfg - > includes ;  incl ;  incl  =  incl - > next )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												if  ( strcmp ( incl - > include_location_file ,  cat - > file )  = =  0 ) { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													if  ( cat - > lineno  >  incl - > include_location_lineno  & &  ! incl - > output )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														if  ( incl - > exec ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
															fprintf ( f , " #exec  \" %s \" \n " ,  incl - > exec_file ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
															fprintf ( f , " #include  \" %s \" \n " ,  incl - > included_file ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														incl - > output  =  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2008-11-18 18:07:55 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-09-12 20:50:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											insert_leading_blank_lines ( f ,  fi ,  cat - > precomments ,  cat - > lineno ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											/* Dump section with any appropriate comment */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											for  ( cmt  =  cat - > precomments ;  cmt ;  cmt = cmt - > next )  { 
							 
						 
					
						
							
								
									
										
										
										
											2007-09-12 20:50:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												char  * cmtp  =  cmt - > cmt ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												while  ( * cmtp  = =  ' ; '  & &  * ( cmtp + 1 )  = =  ' ! ' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													char  * cmtp2  =  strchr ( cmtp + 1 ,  ' \n ' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													if  ( cmtp2 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														cmtp  =  cmtp2 + 1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													else  cmtp  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												if  ( cmtp ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													fprintf ( f , " %s " ,  cmtp ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2006-10-26 01:38:47 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											fprintf ( f ,  " [%s] " ,  cat - > name ) ; 
							 
						 
					
						
							
								
									
										
											 
										 
										
											
												Merged revisions 109908 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r109908 | murf | 2008-03-19 09:41:13 -0600 (Wed, 19 Mar 2008) | 72 lines
(closes issue #11442)
Reported by: tzafrir
Patches:
      11442.patch uploaded by murf (license 17)
Tested by: murf
I didn't give tzafrir very much time to test this, but if he does 
still have remaining issues, he is welcome to 
re-open this bug, and we'll do what is called for.
I reproduced the problem, and tested the fix, so I hope I
am not jumping by just going ahead and committing the fix.
The problem was with what file_save does with templates; 
firstly, it tended to print out multiple options:
[my_category](!)(templateref)
instead of 
[my_category](!,templateref)
which is fixed by this patch.
Nextly, the code to suppress output of duplicate declarations
that would occur because the reader copies inherited declarations
down the hierarchy, was not working. Thus:
 [master-template](!)
 mastervar = bar
 [template](!,master-template)
 tvar = value
 [cat](template)
 catvar = val
would be rewritten as:
 ;!
 ;! Automatically generated configuration file
 ;! Filename: experiment.conf (/etc/asterisk/experiment.conf)
 ;! Generator: Manager
 ;! Creation Date: Tue Mar 18 23:17:46 2008
 ;!
 
 [master-template](!)
 mastervar = bar
 
 [template](!,master-template)
 mastervar = bar
 tvar = value
 
 [cat](template)
 mastervar = bar
 tvar = value
 catvar = val
This has been fixed. Since the config reader 'explodes' inherited
vars into the category, users may, in certain circumstances, see
output different from what they originally entered, but it should
be both correct and equivalent.
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@109942 65c4cc65-6c06-0410-ace0-fbb531ad65f3
											 
										 
										
											2008-03-19 16:24:51 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											if  ( cat - > ignored  | |  ! AST_LIST_EMPTY ( & cat - > template_instances ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2007-11-06 21:08:38 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												fprintf ( f ,  " ( " ) ; 
							 
						 
					
						
							
								
									
										
											 
										 
										
											
												Merged revisions 109908 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r109908 | murf | 2008-03-19 09:41:13 -0600 (Wed, 19 Mar 2008) | 72 lines
(closes issue #11442)
Reported by: tzafrir
Patches:
      11442.patch uploaded by murf (license 17)
Tested by: murf
I didn't give tzafrir very much time to test this, but if he does 
still have remaining issues, he is welcome to 
re-open this bug, and we'll do what is called for.
I reproduced the problem, and tested the fix, so I hope I
am not jumping by just going ahead and committing the fix.
The problem was with what file_save does with templates; 
firstly, it tended to print out multiple options:
[my_category](!)(templateref)
instead of 
[my_category](!,templateref)
which is fixed by this patch.
Nextly, the code to suppress output of duplicate declarations
that would occur because the reader copies inherited declarations
down the hierarchy, was not working. Thus:
 [master-template](!)
 mastervar = bar
 [template](!,master-template)
 tvar = value
 [cat](template)
 catvar = val
would be rewritten as:
 ;!
 ;! Automatically generated configuration file
 ;! Filename: experiment.conf (/etc/asterisk/experiment.conf)
 ;! Generator: Manager
 ;! Creation Date: Tue Mar 18 23:17:46 2008
 ;!
 
 [master-template](!)
 mastervar = bar
 
 [template](!,master-template)
 mastervar = bar
 tvar = value
 
 [cat](template)
 mastervar = bar
 tvar = value
 catvar = val
This has been fixed. Since the config reader 'explodes' inherited
vars into the category, users may, in certain circumstances, see
output different from what they originally entered, but it should
be both correct and equivalent.
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@109942 65c4cc65-6c06-0410-ace0-fbb531ad65f3
											 
										 
										
											2008-03-19 16:24:51 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												if  ( cat - > ignored )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													fprintf ( f ,  " ! " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												if  ( cat - > ignored  & &  ! AST_LIST_EMPTY ( & cat - > template_instances ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													fprintf ( f ,  " , " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												if  ( ! AST_LIST_EMPTY ( & cat - > template_instances ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													struct  ast_category_template_instance  * x ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													AST_LIST_TRAVERSE ( & cat - > template_instances ,  x ,  next )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														fprintf ( f , " %s " , x - > name ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														if  ( x  ! =  AST_LIST_LAST ( & cat - > template_instances ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
															fprintf ( f , " , " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													} 
							 
						 
					
						
							
								
									
										
										
										
											2007-11-06 21:08:38 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												fprintf ( f ,  " ) " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											for ( cmt  =  cat - > sameline ;  cmt ;  cmt = cmt - > next ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											{ 
							 
						 
					
						
							
								
									
										
										
										
											2006-10-26 01:38:47 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												fprintf ( f , " %s " ,  cmt - > cmt ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											if  ( ! cat - > sameline ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												fprintf ( f , " \n " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-09-05 14:47:45 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											for  ( cmt  =  cat - > trailing ;  cmt ;  cmt = cmt - > next )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												if  ( cmt - > cmt [ 0 ]  ! =  ' ; '  | |  cmt - > cmt [ 1 ]  ! =  ' ! ' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													fprintf ( f , " %s " ,  cmt - > cmt ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											fclose ( f ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											if  ( fi )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												ao2_ref ( fi ,  - 1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											var  =  cat - > root ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-01-23 00:11:32 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											while  ( var )  { 
							 
						 
					
						
							
								
									
										
										
										
											2007-11-06 21:08:38 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												struct  ast_category_template_instance  * x ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												int  found  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												AST_LIST_TRAVERSE ( & cat - > template_instances ,  x ,  next )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													struct  ast_variable  * v ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													for  ( v  =  x - > inst - > root ;  v ;  v  =  v - > next )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														if  ( ! strcasecmp ( var - > name ,  v - > name )  & &  ! strcmp ( var - > value ,  v - > value ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
															found  =  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
															break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													if  ( found ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												if  ( found )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													var  =  var - > next ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												fi  =  set_fn ( fn ,  sizeof ( fn ) ,  var - > file ,  configfile ,  fileset ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												f  =  fopen ( fn ,  " a " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												if  ( ! f )  { 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
													ast_debug ( 1 ,  " Unable to open for writing: %s \n " ,  fn ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													ast_verb ( 2 ,  " Unable to write %s (%s) " ,  fn ,  strerror ( errno ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
													if  ( fi )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														ao2_ref ( fi ,  - 1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													} 
							 
						 
					
						
							
								
									
										
										
										
											2007-09-12 20:50:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
													ao2_ref ( fileset ,  - 1 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
													return  - 1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												/* dump any includes that happen before this category header */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												for  ( incl = cfg - > includes ;  incl ;  incl  =  incl - > next )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													if  ( strcmp ( incl - > include_location_file ,  var - > file )  = =  0 ) { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														if  ( var - > lineno  >  incl - > include_location_lineno  & &  ! incl - > output )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
															if  ( incl - > exec ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
																fprintf ( f , " #exec  \" %s \" \n " ,  incl - > exec_file ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
															else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
																fprintf ( f , " #include  \" %s \" \n " ,  incl - > included_file ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
															incl - > output  =  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-09-12 20:50:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												insert_leading_blank_lines ( f ,  fi ,  var - > precomments ,  var - > lineno ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												for  ( cmt  =  var - > precomments ;  cmt ;  cmt = cmt - > next )  { 
							 
						 
					
						
							
								
									
										
										
										
											2006-10-26 01:38:47 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
													if  ( cmt - > cmt [ 0 ]  ! =  ' ; '  | |  cmt - > cmt [ 1 ]  ! =  ' ! ' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														fprintf ( f , " %s " ,  cmt - > cmt ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												if  ( var - > sameline ) 
							 
						 
					
						
							
								
									
										
										
										
											2006-10-26 01:38:47 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
													fprintf ( f ,  " %s %s %s  %s " ,  var - > name ,  ( var - > object  ?  " => "  :  " = " ) ,  var - > value ,  var - > sameline - > cmt ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												else 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
													fprintf ( f ,  " %s %s %s \n " ,  var - > name ,  ( var - > object  ?  " => "  :  " = " ) ,  var - > value ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-09-05 14:47:45 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												for  ( cmt  =  var - > trailing ;  cmt ;  cmt = cmt - > next )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													if  ( cmt - > cmt [ 0 ]  ! =  ' ; '  | |  cmt - > cmt [ 1 ]  ! =  ' ! ' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														fprintf ( f , " %s " ,  cmt - > cmt ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												if  ( var - > blanklines )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													blanklines  =  var - > blanklines ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													while  ( blanklines - - ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														fprintf ( f ,  " \n " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												fclose ( f ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												if  ( fi )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													ao2_ref ( fi ,  - 1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												var  =  var - > next ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											cat  =  cat - > next ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2007-07-26 15:49:18 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										if  ( ! option_debug ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											ast_verb ( 2 ,  " Saved \n " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2007-06-14 19:39:12 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										ast_debug ( 1 ,  " Unable to open for writing: %s \n " ,  fn ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-07-26 15:49:18 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										ast_verb ( 2 ,  " Unable to write (%s) " ,  strerror ( errno ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										if  ( fi )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											ao2_ref ( fi ,  - 1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2007-09-12 20:50:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										ao2_ref ( fileset ,  - 1 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										return  - 1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									/* Now, for files with trailing #include/#exec statements,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									   we  have  to  make  sure  every  entry  is  output  */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									for  ( incl = cfg - > includes ;  incl ;  incl  =  incl - > next )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( ! incl - > output )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											/* open the respective file */ 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											fi  =  set_fn ( fn ,  sizeof ( fn ) ,  incl - > include_location_file ,  configfile ,  fileset ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											f  =  fopen ( fn ,  " a " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											if  ( ! f )  { 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												ast_debug ( 1 ,  " Unable to open for writing: %s \n " ,  fn ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												ast_verb ( 2 ,  " Unable to write %s (%s) " ,  fn ,  strerror ( errno ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												if  ( fi )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													ao2_ref ( fi ,  - 1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2007-09-12 20:50:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												ao2_ref ( fileset ,  - 1 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												return  - 1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											/* output the respective include */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											if  ( incl - > exec ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												fprintf ( f , " #exec  \" %s \" \n " ,  incl - > exec_file ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												fprintf ( f , " #include  \" %s \" \n " ,  incl - > included_file ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											fclose ( f ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											incl - > output  =  1 ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											if  ( fi )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												ao2_ref ( fi ,  - 1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2007-08-29 20:55:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2007-09-12 20:50:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									ao2_ref ( fileset ,  - 1 ) ;  /* this should destroy the hash container */ 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									return  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								static  void  clear_config_maps ( void )  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									struct  ast_config_map  * map ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									ast_mutex_lock ( & config_lock ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									while  ( config_maps )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										map  =  config_maps ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										config_maps  =  config_maps - > next ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-06-06 21:20:11 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										ast_free ( map ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									ast_mutex_unlock ( & config_lock ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2010-07-23 16:19:21 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								static  int  append_mapping ( const  char  * name ,  const  char  * driver ,  const  char  * database ,  const  char  * table ,  int  priority ) 
							 
						 
					
						
							
								
									
										
										
										
											2005-02-10 21:14:11 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									struct  ast_config_map  * map ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									char  * dst ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-02-10 21:14:11 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									int  length ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									length  =  sizeof ( * map ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									length  + =  strlen ( name )  +  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									length  + =  strlen ( driver )  +  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									length  + =  strlen ( database )  +  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									if  ( table ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										length  + =  strlen ( table )  +  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2006-02-09 16:59:50 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									if  ( ! ( map  =  ast_calloc ( 1 ,  length ) ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2005-02-10 21:14:11 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										return  - 1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									dst  =  map - > stuff ; 	/* writable space starts here */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									map - > name  =  strcpy ( dst ,  name ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									dst  + =  strlen ( dst )  +  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									map - > driver  =  strcpy ( dst ,  driver ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									dst  + =  strlen ( dst )  +  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									map - > database  =  strcpy ( dst ,  database ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-02-10 21:14:11 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									if  ( table )  { 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										dst  + =  strlen ( dst )  +  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										map - > table  =  strcpy ( dst ,  table ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-02-10 21:14:11 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2010-07-23 16:19:21 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									map - > priority  =  priority ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-02-10 21:14:11 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									map - > next  =  config_maps ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-02 17:10:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									config_maps  =  map ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-02-10 21:14:11 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-07-26 15:49:18 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									ast_verb ( 2 ,  " Binding %s to %s/%s/%s \n " ,  map - > name ,  map - > driver ,  map - > database ,  map - > table  ?  map - > table  :  map - > name ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-02-10 21:14:11 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									return  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2006-02-14 23:08:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								int  read_config_maps ( void )  
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2005-06-07 21:28:04 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									struct  ast_config  * config ,  * configtmp ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									struct  ast_variable  * v ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-07-23 16:19:21 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									char  * driver ,  * table ,  * database ,  * textpri ,  * stringp ,  * tmp ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-07-20 19:35:02 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									struct  ast_flags  flags  =  {  CONFIG_FLAG_NOREALTIME  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-07-23 16:19:21 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									int  pri ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									clear_config_maps ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2005-06-07 21:28:04 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									configtmp  =  ast_config_new ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									configtmp - > max_include_level  =  1 ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-03-26 18:39:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									config  =  ast_config_internal_load ( extconfig_conf ,  configtmp ,  flags ,  " " ,  " extconfig " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-06-30 01:01:14 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									if  ( config  = =  CONFIG_STATUS_FILEINVALID )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										return  - 1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									}  else  if  ( ! config )  { 
							 
						 
					
						
							
								
									
										
										
										
											2005-06-07 21:28:04 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										ast_config_destroy ( configtmp ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2006-02-14 23:08:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										return  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-06-07 21:28:04 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									for  ( v  =  ast_variable_browse ( config ,  " settings " ) ;  v ;  v  =  v - > next )  { 
							 
						 
					
						
							
								
									
										
										
										
											2007-11-14 13:18:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										char  buf [ 512 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										ast_copy_string ( buf ,  v - > value ,  sizeof ( buf ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										stringp  =  buf ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										driver  =  strsep ( & stringp ,  " , " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-12-27 06:42:29 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-01-10 19:49:26 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										if  ( ( tmp  =  strchr ( stringp ,  ' \" ' ) ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											stringp  =  tmp ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2005-12-27 06:42:29 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										/* check if the database text starts with a double quote */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( * stringp  = =  ' " ' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											stringp + + ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											database  =  strsep ( & stringp ,  " \" " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											strsep ( & stringp ,  " , " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											/* apparently this text has no quotes */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											database  =  strsep ( & stringp ,  " , " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										table  =  strsep ( & stringp ,  " , " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-07-23 16:19:21 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										textpri  =  strsep ( & stringp ,  " , " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( ! textpri  | |  ! ( pri  =  atoi ( textpri ) ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											pri  =  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2005-12-27 06:42:29 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2005-07-05 22:11:43 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										if  ( ! strcmp ( v - > name ,  extconfig_conf ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											ast_log ( LOG_WARNING ,  " Cannot bind '%s'! \n " ,  extconfig_conf ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( ! strcmp ( v - > name ,  " asterisk.conf " ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											ast_log ( LOG_WARNING ,  " Cannot bind 'asterisk.conf'! \n " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( ! strcmp ( v - > name ,  " logger.conf " ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											ast_log ( LOG_WARNING ,  " Cannot bind 'logger.conf'! \n " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( ! driver  | |  ! database ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											continue ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-02-10 21:14:11 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										if  ( ! strcasecmp ( v - > name ,  " sipfriends " ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2011-11-01 19:37:47 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											ast_log ( LOG_WARNING ,  " The 'sipfriends' table is obsolete, update your config to use sippeers instead. \n " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-07-23 16:19:21 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											append_mapping ( " sippeers " ,  driver ,  database ,  table  ?  table  :  " sipfriends " ,  pri ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-02-10 21:14:11 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										}  else  if  ( ! strcasecmp ( v - > name ,  " iaxfriends " ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											ast_log ( LOG_WARNING ,  " The 'iaxfriends' table is obsolete, update your config to use iaxusers and iaxpeers, though they can point to the same table. \n " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-07-23 16:19:21 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											append_mapping ( " iaxusers " ,  driver ,  database ,  table  ?  table  :  " iaxfriends " ,  pri ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											append_mapping ( " iaxpeers " ,  driver ,  database ,  table  ?  table  :  " iaxfriends " ,  pri ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-02-10 21:14:11 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										}  else  
							 
						 
					
						
							
								
									
										
										
										
											2010-07-23 16:19:21 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											append_mapping ( v - > name ,  driver ,  database ,  table ,  pri ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									ast_config_destroy ( config ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2006-02-14 23:08:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									return  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								int  ast_config_engine_register ( struct  ast_config_engine  * new )  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									struct  ast_config_engine  * ptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									ast_mutex_lock ( & config_lock ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									if  ( ! config_engine_list )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										config_engine_list  =  new ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										for  ( ptr  =  config_engine_list ;  ptr - > next ;  ptr = ptr - > next ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										ptr - > next  =  new ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									ast_mutex_unlock ( & config_lock ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									ast_log ( LOG_NOTICE , " Registered Config Engine %s \n " ,  new - > name ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2004-06-11 00:12:35 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									return  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								int  ast_config_engine_deregister ( struct  ast_config_engine  * del )  
							 
						 
					
						
							
								
									
										
										
										
											2004-06-17 04:53:55 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									struct  ast_config_engine  * ptr ,  * last = NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									ast_mutex_lock ( & config_lock ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									for  ( ptr  =  config_engine_list ;  ptr ;  ptr = ptr - > next )  { 
							 
						 
					
						
							
								
									
										
										
										
											2004-06-17 04:53:55 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										if  ( ptr  = =  del )  { 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											if  ( last ) 
							 
						 
					
						
							
								
									
										
										
										
											2004-06-17 04:53:55 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												last - > next  =  ptr - > next ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												config_engine_list  =  ptr - > next ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											break ; 
							 
						 
					
						
							
								
									
										
										
										
											2004-06-17 04:53:55 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										last  =  ptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2004-06-11 00:12:35 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									ast_mutex_unlock ( & config_lock ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									return  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2004-06-11 00:12:35 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2006-01-20 00:18:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								/*! \brief Find realtime engine for realtime family */ 
							 
						 
					
						
							
								
									
										
										
										
											2010-07-23 16:19:21 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								static  struct  ast_config_engine  * find_engine ( const  char  * family ,  int  priority ,  char  * database ,  int  dbsiz ,  char  * table ,  int  tabsiz )  
							 
						 
					
						
							
								
									
										
										
										
											2002-03-05 23:57:31 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2005-07-05 21:17:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									struct  ast_config_engine  * eng ,  * ret  =  NULL ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									struct  ast_config_map  * map ; 
							 
						 
					
						
							
								
									
										
										
										
											2002-03-05 23:57:31 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									ast_mutex_lock ( & config_lock ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2004-11-23 17:58:59 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2005-07-05 21:17:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									for  ( map  =  config_maps ;  map ;  map  =  map - > next )  { 
							 
						 
					
						
							
								
									
										
										
										
											2010-07-23 16:19:21 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										if  ( ! strcasecmp ( family ,  map - > name )  & &  ( priority  = =  map - > priority ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2005-08-23 01:44:28 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											if  ( database ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												ast_copy_string ( database ,  map - > database ,  dbsiz ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											if  ( table ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												ast_copy_string ( table ,  map - > table  ?  map - > table  :  family ,  tabsiz ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											break ; 
							 
						 
					
						
							
								
									
										
										
										
											2001-10-09 14:54:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2005-08-23 01:44:28 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									/* Check if the required driver (engine) exist */ 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									if  ( map )  { 
							 
						 
					
						
							
								
									
										
										
										
											2005-07-05 21:17:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										for  ( eng  =  config_engine_list ;  ! ret  & &  eng ;  eng  =  eng - > next )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											if  ( ! strcasecmp ( eng - > name ,  map - > driver ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												ret  =  eng ; 
							 
						 
					
						
							
								
									
										
										
										
											1999-10-24 18:00:20 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2005-07-05 21:17:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									ast_mutex_unlock ( & config_lock ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-07-05 21:17:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									/* if we found a mapping, but the engine is not available, then issue a warning */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									if  ( map  & &  ! ret ) 
							 
						 
					
						
							
								
									
										
										
										
											2005-08-23 01:44:28 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										ast_log ( LOG_WARNING ,  " Realtime mapping for '%s' found to engine '%s', but the engine is not available \n " ,  map - > name ,  map - > driver ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									return  ret ; 
							 
						 
					
						
							
								
									
										
										
										
											1999-10-24 18:00:20 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
									
										
										
										
											2004-06-11 00:12:35 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								static  struct  ast_config_engine  text_file_engine  =  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									. name  =  " text " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									. load_func  =  config_text_file_load , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} ; 
							 
						 
					
						
							
								
									
										
										
										
											2004-06-11 00:12:35 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-03-11 22:55:16 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								struct  ast_config  * ast_config_internal_load ( const  char  * filename ,  struct  ast_config  * cfg ,  struct  ast_flags  flags ,  const  char  * suggested_include_file ,  const  char  * who_asked ) 
							 
						 
					
						
							
								
									
										
										
										
											2004-06-17 04:53:55 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2006-02-24 10:50:43 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									char  db [ 256 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									char  table [ 256 ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									struct  ast_config_engine  * loader  =  & text_file_engine ; 
							 
						 
					
						
							
								
									
										
										
										
											2006-10-26 01:38:47 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									struct  ast_config  * result ;  
							 
						 
					
						
							
								
									
										
										
										
											2004-06-11 00:12:35 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-02-25 20:50:57 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									/* The config file itself bumps include_level by 1 */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									if  ( cfg - > max_include_level  >  0  & &  cfg - > include_level  = =  cfg - > max_include_level  +  1 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										ast_log ( LOG_WARNING ,  " Maximum Include level (%d) exceeded \n " ,  cfg - > max_include_level ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										return  NULL ; 
							 
						 
					
						
							
								
									
										
										
										
											2004-06-11 00:12:35 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									cfg - > include_level + + ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2010-07-20 19:35:02 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									if  ( ! ast_test_flag ( & flags ,  CONFIG_FLAG_NOREALTIME )  & &  config_engine_list )  { 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										struct  ast_config_engine  * eng ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2010-07-23 16:19:21 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										eng  =  find_engine ( filename ,  1 ,  db ,  sizeof ( db ) ,  table ,  sizeof ( table ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-02-02 03:38:24 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										if  ( eng  & &  eng - > load_func )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											loader  =  eng ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2010-07-23 16:19:21 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											eng  =  find_engine ( " global " ,  1 ,  db ,  sizeof ( db ) ,  table ,  sizeof ( table ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											if  ( eng  & &  eng - > load_func ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												loader  =  eng ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-03-11 22:55:16 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									result  =  loader - > load_func ( db ,  table ,  filename ,  cfg ,  flags ,  suggested_include_file ,  who_asked ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-02-02 03:38:24 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-10-20 05:07:25 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									if  ( result  & &  result  ! =  CONFIG_STATUS_FILEINVALID  & &  result  ! =  CONFIG_STATUS_FILEUNCHANGED ) 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										result - > include_level - - ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-10-20 05:07:25 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									else  if  ( result  ! =  CONFIG_STATUS_FILEINVALID ) 
							 
						 
					
						
							
								
									
										
										
										
											2007-04-26 01:29:23 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										cfg - > include_level - - ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									return  result ; 
							 
						 
					
						
							
								
									
										
										
										
											2004-06-11 00:12:35 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-03-11 22:55:16 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								struct  ast_config  * ast_config_load2 ( const  char  * filename ,  const  char  * who_asked ,  struct  ast_flags  flags ) 
							 
						 
					
						
							
								
									
										
										
										
											2006-07-19 13:28:38 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									struct  ast_config  * cfg ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									struct  ast_config  * result ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									cfg  =  ast_config_new ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									if  ( ! cfg ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										return  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-03-11 22:55:16 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									result  =  ast_config_internal_load ( filename ,  cfg ,  flags ,  " " ,  who_asked ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-09-12 23:30:03 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									if  ( ! result  | |  result  = =  CONFIG_STATUS_FILEUNCHANGED  | |  result  = =  CONFIG_STATUS_FILEINVALID ) 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										ast_config_destroy ( cfg ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									return  result ; 
							 
						 
					
						
							
								
									
										
										
										
											2004-06-11 00:12:35 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-01-14 05:34:32 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								static  struct  ast_variable  * ast_load_realtime_helper ( const  char  * family ,  va_list  ap ) 
							 
						 
					
						
							
								
									
										
										
										
											2004-06-17 04:53:55 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									struct  ast_config_engine  * eng ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-10-14 00:08:52 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									char  db [ 256 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									char  table [ 256 ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									struct  ast_variable  * res = NULL ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-07-23 16:19:21 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									int  i ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2010-07-23 16:19:21 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									for  ( i  =  1 ;  ;  i + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( ( eng  =  find_engine ( family ,  i ,  db ,  sizeof ( db ) ,  table ,  sizeof ( table ) ) ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											if  ( eng - > realtime_func  & &  ( res  =  eng - > realtime_func ( db ,  table ,  ap ) ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												return  res ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											return  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2007-01-14 05:34:32 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									return  res ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								struct  ast_variable  * ast_load_realtime_all ( const  char  * family ,  . . . ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									struct  ast_variable  * res ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									va_list  ap ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									va_start ( ap ,  family ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									res  =  ast_load_realtime_helper ( family ,  ap ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									va_end ( ap ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									return  res ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-01-07 16:21:12 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								struct  ast_variable  * ast_load_realtime ( const  char  * family ,  . . . ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2011-08-22 17:00:03 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									struct  ast_variable  * res ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									struct  ast_variable  * cur ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									struct  ast_variable  * * prev ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-01-07 16:21:12 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									va_list  ap ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									va_start ( ap ,  family ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-01-14 05:34:32 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									res  =  ast_load_realtime_helper ( family ,  ap ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-01-07 16:21:12 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									va_end ( ap ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-08-22 17:00:03 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									/* Filter the list. */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									prev  =  & res ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									cur  =  res ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									while  ( cur )  { 
							 
						 
					
						
							
								
									
										
										
										
											2007-01-07 16:21:12 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										if  ( ast_strlen_zero ( cur - > value ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2011-08-22 17:00:03 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											/* Eliminate empty entries */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											struct  ast_variable  * next ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											next  =  cur - > next ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											* prev  =  next ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											ast_variable_destroy ( cur ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											cur  =  next ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-01-07 16:21:12 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2011-08-22 17:00:03 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											/* Make blank entries empty and keep them. */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											if  ( cur - > value [ 0 ]  = =  '   '  & &  cur - > value [ 1 ]  = =  ' \0 ' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												char  * vptr  =  ( char  * )  cur - > value ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												vptr [ 0 ]  =  ' \0 ' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											prev  =  & cur - > next ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											cur  =  cur - > next ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-01-07 16:21:12 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									return  res ; 
							 
						 
					
						
							
								
									
										
										
										
											2004-06-11 00:12:35 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2006-01-20 00:18:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								/*! \brief Check if realtime engine is configured for family */ 
							 
						 
					
						
							
								
									
										
										
										
											2005-08-23 01:44:28 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								int  ast_check_realtime ( const  char  * family ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									struct  ast_config_engine  * eng ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-02-17 15:18:55 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									if  ( ! ast_realtime_enabled ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										return  0 ; 	/* There are no engines at all so fail early */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2005-08-23 01:44:28 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2010-07-23 16:19:21 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									eng  =  find_engine ( family ,  1 ,  NULL ,  0 ,  NULL ,  0 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-08-23 01:44:28 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									if  ( eng ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										return  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									return  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-02-14 20:22:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								/*! \brief Check if there's any realtime engines loaded */ 
							 
						 
					
						
							
								
									
										
										
										
											2011-08-22 21:22:24 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								int  ast_realtime_enabled ( void ) 
							 
						 
					
						
							
								
									
										
										
										
											2007-02-14 20:22:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									return  config_maps  ?  1  :  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-06-05 19:07:27 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								int  ast_realtime_require_field ( const  char  * family ,  . . . ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									struct  ast_config_engine  * eng ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-10-14 00:08:52 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									char  db [ 256 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									char  table [ 256 ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-06-05 19:07:27 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									va_list  ap ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-07-23 16:19:21 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									int  res  =  - 1 ,  i ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-06-05 19:07:27 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									va_start ( ap ,  family ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-07-23 16:19:21 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									for  ( i  =  1 ;  ;  i + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( ( eng  =  find_engine ( family ,  i ,  db ,  sizeof ( db ) ,  table ,  sizeof ( table ) ) ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											/* If the require succeeds, it returns 0. */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											if  ( eng - > require_func  & &  ! ( res  =  eng - > require_func ( db ,  table ,  ap ) ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2008-06-05 19:07:27 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									va_end ( ap ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									return  res ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								int  ast_unload_realtime ( const  char  * family ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									struct  ast_config_engine  * eng ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-10-14 00:08:52 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									char  db [ 256 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									char  table [ 256 ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-07-23 16:19:21 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									int  res  =  - 1 ,  i ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-06-05 19:07:27 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2010-07-23 16:19:21 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									for  ( i  =  1 ;  ;  i + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( ( eng  =  find_engine ( family ,  i ,  db ,  sizeof ( db ) ,  table ,  sizeof ( table ) ) ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											if  ( eng - > unload_func )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												/* Do this for ALL engines */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												res  =  eng - > unload_func ( db ,  table ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2008-06-05 19:07:27 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									return  res ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								struct  ast_config  * ast_load_realtime_multientry ( const  char  * family ,  . . . ) 
							 
						 
					
						
							
								
									
										
										
										
											2004-06-17 04:53:55 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									struct  ast_config_engine  * eng ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-10-14 00:08:52 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									char  db [ 256 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									char  table [ 256 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									struct  ast_config  * res  =  NULL ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									va_list  ap ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-07-23 16:19:21 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									int  i ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									va_start ( ap ,  family ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-07-23 16:19:21 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									for  ( i  =  1 ;  ;  i + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( ( eng  =  find_engine ( family ,  i ,  db ,  sizeof ( db ) ,  table ,  sizeof ( table ) ) ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											if  ( eng - > realtime_multi_func  & &  ( res  =  eng - > realtime_multi_func ( db ,  table ,  ap ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2011-10-25 01:23:29 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												/* If we were returned an empty cfg, destroy it and return NULL */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												if  ( ! res - > root )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													ast_config_destroy ( res ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													res  =  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2010-07-23 16:19:21 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									va_end ( ap ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									return  res ; 
							 
						 
					
						
							
								
									
										
										
										
											2004-06-11 00:12:35 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								int  ast_update_realtime ( const  char  * family ,  const  char  * keyfield ,  const  char  * lookup ,  . . . ) 
							 
						 
					
						
							
								
									
										
										
										
											2004-06-17 04:53:55 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									struct  ast_config_engine  * eng ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-07-23 16:19:21 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									int  res  =  - 1 ,  i ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-10-14 00:08:52 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									char  db [ 256 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									char  table [ 256 ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									va_list  ap ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									va_start ( ap ,  lookup ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-07-23 16:19:21 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									for  ( i  =  1 ;  ;  i + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( ( eng  =  find_engine ( family ,  i ,  db ,  sizeof ( db ) ,  table ,  sizeof ( table ) ) ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											/* If the update succeeds, it returns 0. */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											if  ( eng - > update_func  & &  ! ( res  =  eng - > update_func ( db ,  table ,  keyfield ,  lookup ,  ap ) ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									va_end ( ap ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-04-11 13:41:17 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									return  res ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-10-14 00:08:52 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								int  ast_update2_realtime ( const  char  * family ,  . . . ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									struct  ast_config_engine  * eng ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-07-23 16:19:21 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									int  res  =  - 1 ,  i ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-10-14 00:08:52 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									char  db [ 256 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									char  table [ 256 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									va_list  ap ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									va_start ( ap ,  family ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-07-23 16:19:21 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									for  ( i  =  1 ;  ;  i + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( ( eng  =  find_engine ( family ,  i ,  db ,  sizeof ( db ) ,  table ,  sizeof ( table ) ) ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											if  ( eng - > update2_func  & &  ! ( res  =  eng - > update2_func ( db ,  table ,  ap ) ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2008-10-14 00:08:52 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									va_end ( ap ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									return  res ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-05-02 02:33:04 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								int  ast_store_realtime ( const  char  * family ,  . . . ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2007-04-11 13:41:17 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									struct  ast_config_engine  * eng ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-07-23 16:19:21 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									int  res  =  - 1 ,  i ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-10-14 00:08:52 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									char  db [ 256 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									char  table [ 256 ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-04-11 13:41:17 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									va_list  ap ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									va_start ( ap ,  family ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-07-23 16:19:21 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									for  ( i  =  1 ;  ;  i + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( ( eng  =  find_engine ( family ,  i ,  db ,  sizeof ( db ) ,  table ,  sizeof ( table ) ) ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											/* If the store succeeds, it returns 0. */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											if  ( eng - > store_func  & &  ! ( res  =  eng - > store_func ( db ,  table ,  ap ) ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2007-04-11 13:41:17 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									va_end ( ap ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									return  res ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-05-02 02:33:04 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								int  ast_destroy_realtime ( const  char  * family ,  const  char  * keyfield ,  const  char  * lookup ,  . . . ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2007-04-11 13:41:17 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									struct  ast_config_engine  * eng ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-07-23 16:19:21 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									int  res  =  - 1 ,  i ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-10-14 00:08:52 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									char  db [ 256 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									char  table [ 256 ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-04-11 13:41:17 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									va_list  ap ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									va_start ( ap ,  lookup ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-07-23 16:19:21 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									for  ( i  =  1 ;  ;  i + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( ( eng  =  find_engine ( family ,  i ,  db ,  sizeof ( db ) ,  table ,  sizeof ( table ) ) ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											if  ( eng - > destroy_func  & &  ! ( res  =  eng - > destroy_func ( db ,  table ,  keyfield ,  lookup ,  ap ) ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2007-04-11 13:41:17 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									va_end ( ap ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									return  res ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-07-17 14:32:15 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2010-07-17 17:39:28 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								char  * ast_realtime_decode_chunk ( char  * chunk ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									char  * orig  =  chunk ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									for  ( ;  * chunk ;  chunk + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( * chunk  = =  ' ^ '  & &  strchr ( " 0123456789ABCDEFabcdef " ,  chunk [ 1 ] )  & &  strchr ( " 0123456789ABCDEFabcdef " ,  chunk [ 2 ] ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2010-08-27 20:31:55 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											sscanf ( chunk  +  1 ,  " %02hhX " ,  chunk ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-07-17 17:39:28 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											memmove ( chunk  +  1 ,  chunk  +  3 ,  strlen ( chunk  +  3 )  +  1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									return  orig ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								char  * ast_realtime_encode_chunk ( struct  ast_str  * * dest ,  ssize_t  maxlen ,  const  char  * chunk ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									if  ( ! strchr ( chunk ,  ' ; ' )  & &  ! strchr ( chunk ,  ' ^ ' ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										ast_str_set ( dest ,  maxlen ,  " %s " ,  chunk ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										ast_str_reset ( * dest ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										for  ( ;  * chunk ;  chunk + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											if  ( strchr ( " ;^ " ,  * chunk ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												ast_str_append ( dest ,  maxlen ,  " ^%02hhX " ,  * chunk ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												ast_str_append ( dest ,  maxlen ,  " %c " ,  * chunk ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									return  ast_str_buffer ( * dest ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-07-17 14:32:15 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								/*! \brief Helper function to parse arguments
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  See  documentation  in  config . h 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								int  ast_parse_arg ( const  char  * arg ,  enum  ast_parse_flags  flags , 
							 
						 
					
						
							
								
									
										
										
										
											2008-03-04 23:04:29 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									void  * p_result ,  . . . ) 
							 
						 
					
						
							
								
									
										
										
										
											2007-07-17 14:32:15 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									va_list  ap ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									int  error  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									va_start ( ap ,  p_result ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									switch  ( flags  &  PARSE_TYPE )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									case  PARSE_INT32 : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										int32_t  * result  =  p_result ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										int32_t  x ,  def  =  result  ?  * result  :  0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											high  =  ( int32_t ) 0x7fffffff , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											low   =  ( int32_t ) 0x80000000 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										/* optional argument: first default value, then range */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( flags  &  PARSE_DEFAULT ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											def  =  va_arg ( ap ,  int32_t ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( flags  &  ( PARSE_IN_RANGE | PARSE_OUT_RANGE ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											/* range requested, update bounds */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											low  =  va_arg ( ap ,  int32_t ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											high  =  va_arg ( ap ,  int32_t ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										x  =  strtol ( arg ,  NULL ,  0 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										error  =  ( x  <  low )  | |  ( x  >  high ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( flags  &  PARSE_OUT_RANGE ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											error  =  ! error ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( result ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											* result   =  error  ?  def  :  x ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										ast_debug ( 3 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											" extract int from [%s] in [%d, %d] gives [%d](%d) \n " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											arg ,  low ,  high , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											result  ?  * result  :  x ,  error ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									case  PARSE_UINT32 : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										uint32_t  * result  =  p_result ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										uint32_t  x ,  def  =  result  ?  * result  :  0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											low  =  0 ,  high  =  ( uint32_t ) ~ 0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										/* optional argument: first default value, then range */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( flags  &  PARSE_DEFAULT ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											def  =  va_arg ( ap ,  uint32_t ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( flags  &  ( PARSE_IN_RANGE | PARSE_OUT_RANGE ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											/* range requested, update bounds */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											low  =  va_arg ( ap ,  uint32_t ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											high  =  va_arg ( ap ,  uint32_t ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										x  =  strtoul ( arg ,  NULL ,  0 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										error  =  ( x  <  low )  | |  ( x  >  high ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( flags  &  PARSE_OUT_RANGE ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											error  =  ! error ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( result ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											* result   =  error  ?  def  :  x ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										ast_debug ( 3 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											" extract uint from [%s] in [%u, %u] gives [%u](%d) \n " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											arg ,  low ,  high , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											result  ?  * result  :  x ,  error ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-12-19 15:15:03 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									case  PARSE_DOUBLE : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										double  * result  =  p_result ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										double  x ,  def  =  result  ?  * result  :  0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											low  =  - HUGE_VAL ,  high  =  HUGE_VAL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										/* optional argument: first default value, then range */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( flags  &  PARSE_DEFAULT ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											def  =  va_arg ( ap ,  double ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( flags  &  ( PARSE_IN_RANGE | PARSE_OUT_RANGE ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											/* range requested, update bounds */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											low  =  va_arg ( ap ,  double ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											high  =  va_arg ( ap ,  double ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										x  =  strtod ( arg ,  NULL ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										error  =  ( x  <  low )  | |  ( x  >  high ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( flags  &  PARSE_OUT_RANGE ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											error  =  ! error ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( result ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											* result   =  error  ?  def  :  x ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										ast_debug ( 3 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											" extract double from [%s] in [%f, %f] gives [%f](%d) \n " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											arg ,  low ,  high , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											result  ?  * result  :  x ,  error ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									    } 
							 
						 
					
						
							
								
									
										
										
										
											2010-07-08 22:08:07 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									case  PARSE_ADDR : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										struct  ast_sockaddr  * addr  =  ( struct  ast_sockaddr  * ) p_result ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( ! ast_sockaddr_parse ( addr ,  arg ,  flags  &  PARSE_PORT_MASK ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											error  =  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										ast_debug ( 3 ,  " extract addr from %s gives %s(%d) \n " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											  arg ,  ast_sockaddr_stringify ( addr ) ,  error ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									case  PARSE_INADDR : 	/* TODO Remove this (use PARSE_ADDR instead). */ 
							 
						 
					
						
							
								
									
										
										
										
											2007-07-17 14:32:15 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										char  * port ,  * buf ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										struct  sockaddr_in  _sa_buf ; 	/* buffer for the result */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										struct  sockaddr_in  * sa  =  p_result  ? 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											( struct  sockaddr_in  * ) p_result  :  & _sa_buf ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										/* default is either the supplied value or the result itself */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										struct  sockaddr_in  * def  =  ( flags  &  PARSE_DEFAULT )  ? 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											va_arg ( ap ,  struct  sockaddr_in  * )  :  sa ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										struct  hostent  * hp ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										struct  ast_hostent  ahp ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-10-09 14:17:33 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										memset ( & _sa_buf ,  ' \0 ' ,  sizeof ( _sa_buf ) ) ;  /* clear buffer */ 
							 
						 
					
						
							
								
									
										
										
										
											2007-07-17 14:32:15 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										/* duplicate the string to strip away the :port */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										port  =  ast_strdupa ( arg ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										buf  =  strsep ( & port ,  " : " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										sa - > sin_family  =  AF_INET ; 	/* assign family */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										/*
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 *  honor  the  ports  flag  setting ,  assign  default  value 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 *  in  case  of  errors  or  field  unset . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										 */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										flags  & =  PARSE_PORT_MASK ;  /* the only flags left to process */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( port )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											if  ( flags  = =  PARSE_PORT_FORBID )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												error  =  1 ; 	/* port was forbidden */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												sa - > sin_port  =  def - > sin_port ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											}  else  if  ( flags  = =  PARSE_PORT_IGNORE ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												sa - > sin_port  =  def - > sin_port ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											else  /* accept or require */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												sa - > sin_port  =  htons ( strtol ( port ,  NULL ,  0 ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											sa - > sin_port  =  def - > sin_port ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											if  ( flags  = =  PARSE_PORT_REQUIRE ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												error  =  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										/* Now deal with host part, even if we have errors before. */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										hp  =  ast_gethostbyname ( buf ,  & ahp ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( hp ) 	/* resolved successfully */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											memcpy ( & sa - > sin_addr ,  hp - > h_addr ,  sizeof ( sa - > sin_addr ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											error  =  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											sa - > sin_addr  =  def - > sin_addr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										ast_debug ( 3 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											" extract inaddr from [%s] gives [%s:%d](%d) \n " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											arg ,  ast_inet_ntoa ( sa - > sin_addr ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											ntohs ( sa - > sin_port ) ,  error ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									    	break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									va_end ( ap ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									return  error ; 
							 
						 
					
						
							
								
									
										
										
										
											2004-06-11 00:12:35 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-10-19 18:01:00 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								static  char  * handle_cli_core_show_config_mappings ( struct  ast_cli_entry  * e ,  int  cmd ,  struct  ast_cli_args  * a ) 
							 
						 
					
						
							
								
									
										
										
										
											2004-06-17 04:53:55 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									struct  ast_config_engine  * eng ; 
							 
						 
					
						
							
								
									
										
										
										
											2004-10-05 06:46:11 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									struct  ast_config_map  * map ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-10-19 18:01:00 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									switch  ( cmd )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									case  CLI_INIT : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										e - > command  =  " core show config mappings " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										e - > usage  = 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											" Usage: core show config mappings \n " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											" 	Shows the filenames to config engines. \n " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										return  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									case  CLI_GENERATE : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										return  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2004-06-11 00:12:35 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									ast_mutex_lock ( & config_lock ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-01-07 21:12:33 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									if  ( ! config_engine_list )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										ast_cli ( a - > fd ,  " No config mappings found. \n " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										for  ( eng  =  config_engine_list ;  eng ;  eng  =  eng - > next )  { 
							 
						 
					
						
							
								
									
										
										
										
											2010-07-05 13:53:44 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											ast_cli ( a - > fd ,  " Config Engine: %s \n " ,  eng - > name ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-01-07 21:12:33 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											for  ( map  =  config_maps ;  map ;  map  =  map - > next )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												if  ( ! strcasecmp ( map - > driver ,  eng - > name ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													ast_cli ( a - > fd ,  " ===> %s (db=%s, table=%s) \n " ,  map - > name ,  map - > database , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
															map - > table  ?  map - > table  :  map - > name ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2008-01-07 21:12:33 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2004-06-11 00:12:35 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									ast_mutex_unlock ( & config_lock ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-10-19 18:01:00 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									return  CLI_SUCCESS ; 
							 
						 
					
						
							
								
									
										
										
										
											2004-06-11 00:12:35 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-03-26 18:39:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								static  char  * handle_cli_config_reload ( struct  ast_cli_entry  * e ,  int  cmd ,  struct  ast_cli_args  * a ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									struct  cache_file_mtime  * cfmtime ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-03-26 19:58:09 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									char  * prev  =  " " ,  * completion_value  =  NULL ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-03-26 18:39:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									int  wordlen ,  which  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									switch  ( cmd )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									case  CLI_INIT : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										e - > command  =  " config reload " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										e - > usage  = 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											" Usage: config reload <filename.conf> \n " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											"    Reloads all modules that reference <filename.conf> \n " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										return  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									case  CLI_GENERATE : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( a - > pos  >  2 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											return  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										wordlen  =  strlen ( a - > word ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										AST_LIST_LOCK ( & cfmtime_head ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										AST_LIST_TRAVERSE ( & cfmtime_head ,  cfmtime ,  list )  { 
							 
						 
					
						
							
								
									
										
										
										
											2008-03-26 19:58:09 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											/* Skip duplicates - this only works because the list is sorted by filename */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											if  ( strcmp ( cfmtime - > filename ,  prev )  = =  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												continue ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-03-26 18:39:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-03-26 19:58:09 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											/* Core configs cannot be reloaded */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											if  ( ast_strlen_zero ( cfmtime - > who_asked ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2008-03-26 18:39:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											if  ( + + which  >  a - > n  & &  strncmp ( cfmtime - > filename ,  a - > word ,  wordlen )  = =  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												completion_value  =  ast_strdup ( cfmtime - > filename ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											/* Otherwise save that we've seen this filename */ 
							 
						 
					
						
							
								
									
										
										
										
											2008-03-26 19:58:09 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											prev  =  cfmtime - > filename ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-03-26 18:39:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										AST_LIST_UNLOCK ( & cfmtime_head ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										return  completion_value ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									if  ( a - > argc  ! =  3 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										return  CLI_SHOWUSAGE ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									AST_LIST_LOCK ( & cfmtime_head ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									AST_LIST_TRAVERSE ( & cfmtime_head ,  cfmtime ,  list )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( ! strcmp ( cfmtime - > filename ,  a - > argv [ 2 ] ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											char  * buf  =  alloca ( strlen ( " module reload  " )  +  strlen ( cfmtime - > who_asked )  +  1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											sprintf ( buf ,  " module reload %s " ,  cfmtime - > who_asked ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											ast_cli_command ( a - > fd ,  buf ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									AST_LIST_UNLOCK ( & cfmtime_head ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									return  CLI_SUCCESS ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								static  char  * handle_cli_config_list ( struct  ast_cli_entry  * e ,  int  cmd ,  struct  ast_cli_args  * a ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									struct  cache_file_mtime  * cfmtime ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									switch  ( cmd )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									case  CLI_INIT : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										e - > command  =  " config list " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										e - > usage  = 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											" Usage: config list \n " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											"    Show all modules that have loaded a configuration file \n " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										return  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									case  CLI_GENERATE : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										return  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									AST_LIST_LOCK ( & cfmtime_head ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									AST_LIST_TRAVERSE ( & cfmtime_head ,  cfmtime ,  list )  { 
							 
						 
					
						
							
								
									
										
										
										
											2008-03-26 19:58:09 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										ast_cli ( a - > fd ,  " %-20.20s %-50s \n " ,  S_OR ( cfmtime - > who_asked ,  " core " ) ,  cfmtime - > filename ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-03-26 18:39:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									AST_LIST_UNLOCK ( & cfmtime_head ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									return  CLI_SUCCESS ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2006-09-18 19:54:18 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								static  struct  ast_cli_entry  cli_config [ ]  =  { 
							 
						 
					
						
							
								
									
										
										
										
											2007-10-22 20:05:18 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									AST_CLI_DEFINE ( handle_cli_core_show_config_mappings ,  " Display config mappings (file names to config engines) " ) , 
							 
						 
					
						
							
								
									
										
										
										
											2008-03-26 18:39:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									AST_CLI_DEFINE ( handle_cli_config_reload ,  " Force a reload on modules using a particular configuration file " ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									AST_CLI_DEFINE ( handle_cli_config_list ,  " Show all files that have loaded a configuration file " ) , 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-25 06:10:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								} ; 
							 
						 
					
						
							
								
									
										
										
										
											2004-06-11 00:12:35 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-08-22 21:22:24 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								int  register_config_cli ( void ) 
							 
						 
					
						
							
								
									
										
										
										
											2004-06-17 04:53:55 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2008-12-05 10:31:25 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									ast_cli_register_multiple ( cli_config ,  ARRAY_LEN ( cli_config ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2006-09-18 19:54:18 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									return  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2004-06-11 00:12:35 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								}