extconf.c File Reference

#include "asterisk.h"
#include "asterisk/compat.h"
#include "asterisk/paths.h"
#include <errno.h>
#include <time.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/wait.h>
#include <stdarg.h>
#include <string.h>
#include <locale.h>
#include <ctype.h>
#include <err.h>
#include <regex.h>
#include <limits.h>
#include <pthread.h>
#include <netdb.h>
#include <sys/param.h>
#include <signal.h>
#include "asterisk/inline_api.h"
#include "asterisk/endian.h"
#include "asterisk/ast_expr.h"
#include "asterisk/extconf.h"
#include "asterisk/hashtab.h"
#include "asterisk/ael_structs.h"
#include "asterisk/pval.h"

Include dependency graph for extconf.c:

Go to the source code of this file.

Data Structures

struct  ast_app
 ast_app: A registered application More...
struct  ast_category
struct  ast_channel
 Main Channel structure associated with a channel. More...
struct  ast_comment
 Structure to keep comments for rewriting configuration files. More...
struct  ast_config
struct  ast_config_engine
 Configuration engine structure, used to define realtime drivers. More...
struct  ast_config_include
struct  ast_config_map
struct  ast_context
 ast_context: An extension context More...
struct  ast_custom_function
 Data structure associated with a custom dialplan function. More...
struct  ast_exten
 ast_exten: An extension The dialplan is saved as a linked list with each context having it's own linked list of extensions - one item per priority. More...
struct  ast_flags
 Structure used to handle boolean flags. More...
struct  ast_hint
 Structure for dial plan hints. More...
struct  ast_ignorepat
 ast_ignorepat: Ignore patterns in dial plan More...
struct  ast_include
 ast_include: include= support in extensions.conf More...
struct  ast_state_cb
 ast_state_cb: An extension state notify register item More...
struct  ast_sw
 ast_sw: Switch statement in extensions.conf More...
struct  ast_switch
struct  ast_timing
struct  ast_var_t
struct  ast_variable
 Structure for variables, used for configurations and for channel variables. More...
struct  hints
struct  store_hint
struct  store_hints
struct  varshead

Defines

#define __AST_MUTEX_DEFINE(scope, mutex)   scope ast_mutex_t mutex = AST_MUTEX_INIT_VALUE
#define __AST_RWLOCK_DEFINE(scope, rwlock)
#define __LOG_DEBUG   0
#define __LOG_DTMF   6
#define __LOG_ERROR   4
#define __LOG_EVENT   1
#define __LOG_NOTICE   2
#define __LOG_VERBOSE   5
#define __LOG_WARNING   3
#define __MTX_PROF(a)   return pthread_mutex_lock((a))
#define _A_   __FILE__, __LINE__, __PRETTY_FUNCTION__
#define _ASTERISK_LOCK_H
#define ASINCLUDE_GLOB   1
#define AST_API_MODULE   1
#define ast_asprintf(ret, fmt,...)   _ast_asprintf((ret), __FILE__, __LINE__, __PRETTY_FUNCTION__, fmt, __VA_ARGS__)
 A wrapper for asprintf().
#define ast_asprintf(ret, fmt,...)   _ast_asprintf((ret), __FILE__, __LINE__, __PRETTY_FUNCTION__, fmt, __VA_ARGS__)
 A wrapper for asprintf().
#define AST_CACHE_DIR_LEN   512
#define ast_calloc(num, len)   _ast_calloc((num), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
 A wrapper for calloc().
#define ast_calloc(num, len)   _ast_calloc((num), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
 A wrapper for calloc().
#define ast_calloc_cache(num, len)   _ast_calloc((num), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
 A wrapper for calloc() for use in cache pools.
#define ast_calloc_cache(num, len)   _ast_calloc((num), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
 A wrapper for calloc() for use in cache pools.
#define AST_DEFAULT_OPTIONS   AST_OPT_FLAG_TRANSCODE_VIA_SLIN
#define AST_FILENAME_MAX   80
#define ast_free   free
#define ast_free_ptr   free
#define ast_fully_booted   ast_test_flag(&ast_options, AST_OPT_FLAG_FULLY_BOOTED)
#define AST_LIST_APPEND_LIST(head, list, field)
 Appends a whole list to the tail of a list.
#define AST_LIST_EMPTY(head)   (AST_LIST_FIRST(head) == NULL)
 Checks whether the specified list contains any entries.
#define AST_LIST_ENTRY(type)
 Declare a forward link structure inside a list entry.
#define AST_LIST_FIRST(head)   ((head)->first)
 Returns the first entry contained in a list.
#define AST_LIST_HEAD(name, type)
 Defines a structure to be used to hold a list of specified type.
#define AST_LIST_HEAD_INIT(head)
 Initializes a list head structure.
#define AST_LIST_HEAD_INIT_NOLOCK(head)
 Initializes a list head structure.
#define AST_LIST_HEAD_INIT_VALUE
 Defines initial values for a declaration of AST_LIST_HEAD.
#define AST_LIST_HEAD_NOLOCK(name, type)
 Defines a structure to be used to hold a list of specified type (with no lock).
#define AST_LIST_HEAD_NOLOCK_INIT_VALUE
 Defines initial values for a declaration of AST_LIST_HEAD_NOLOCK.
#define AST_LIST_HEAD_NOLOCK_STATIC(name, type)
 Defines a structure to be used to hold a list of specified type, statically initialized.
#define AST_LIST_HEAD_SET(head, entry)
 Initializes a list head structure with a specified first entry.
#define AST_LIST_HEAD_SET_NOLOCK(head, entry)
 Initializes a list head structure with a specified first entry.
#define AST_LIST_HEAD_STATIC(name, type)
 Defines a structure to be used to hold a list of specified type, statically initialized.
#define AST_LIST_INSERT_AFTER(head, listelm, elm, field)
 Inserts a list entry after a given entry.
#define AST_LIST_INSERT_BEFORE_CURRENT(head, elm, field)
 Inserts a list entry before the current entry during a traversal.
#define AST_LIST_INSERT_HEAD(head, elm, field)
 Inserts a list entry at the head of a list.
#define AST_LIST_INSERT_TAIL(head, elm, field)
 Appends a list entry to the tail of a list.
#define AST_LIST_LAST(head)   ((head)->last)
 Returns the last entry contained in a list.
#define AST_LIST_NEXT(elm, field)   ((elm)->field.next)
 Returns the next entry in the list after the given entry.
#define AST_LIST_REMOVE(head, elm, field)
 Removes a specific entry from a list.
#define AST_LIST_REMOVE_CURRENT(head, field)
 Removes the current entry from a list during a traversal.
#define AST_LIST_REMOVE_HEAD(head, field)
 Removes and returns the head entry from a list.
#define AST_LIST_TRAVERSE(head, var, field)   for((var) = (head)->first; (var); (var) = (var)->field.next)
 Loops over (traverses) the entries in a list.
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
 Loops safely over (traverses) the entries in a list.
#define AST_LIST_TRAVERSE_SAFE_END   }
 Closes a safe loop traversal block.
#define ast_malloc(len)   _ast_malloc((len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
 A wrapper for malloc().
#define ast_malloc(len)   _ast_malloc((len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
 A wrapper for malloc().
#define AST_MAX_EXTENSION   80
#define AST_MUTEX_DEFINE_STATIC(mutex)   __AST_MUTEX_DEFINE(static, mutex)
#define AST_MUTEX_INIT_VALUE   ((ast_mutex_t) PTHREAD_MUTEX_INIT_VALUE)
#define AST_MUTEX_INITIALIZER   __use_AST_MUTEX_DEFINE_STATIC_rather_than_AST_MUTEX_INITIALIZER__
#define AST_MUTEX_KIND   PTHREAD_MUTEX_RECURSIVE
#define ast_opt_always_fork   ast_test_flag(&ast_options, AST_OPT_FLAG_ALWAYS_FORK)
#define ast_opt_cache_record_files   ast_test_flag(&ast_options, AST_OPT_FLAG_CACHE_RECORD_FILES)
#define ast_opt_console   ast_test_flag(&ast_options, AST_OPT_FLAG_CONSOLE)
#define ast_opt_dont_warn   ast_test_flag(&ast_options, AST_OPT_FLAG_DONT_WARN)
#define ast_opt_dump_core   ast_test_flag(&ast_options, AST_OPT_FLAG_DUMP_CORE)
#define ast_opt_end_cdr_before_h_exten   ast_test_flag(&ast_options, AST_OPT_FLAG_END_CDR_BEFORE_H_EXTEN)
#define ast_opt_exec   ast_test_flag(&ast_options, AST_OPT_FLAG_EXEC)
#define ast_opt_exec_includes   ast_test_flag(&ast_options, AST_OPT_FLAG_EXEC_INCLUDES)
#define ast_opt_high_priority   ast_test_flag(&ast_options, AST_OPT_FLAG_HIGH_PRIORITY)
#define ast_opt_init_keys   ast_test_flag(&ast_options, AST_OPT_FLAG_INIT_KEYS)
#define ast_opt_mute   ast_test_flag(&ast_options, AST_OPT_FLAG_MUTE)
#define ast_opt_no_color   ast_test_flag(&ast_options, AST_OPT_FLAG_NO_COLOR)
#define ast_opt_no_fork   ast_test_flag(&ast_options, AST_OPT_FLAG_NO_FORK)
#define ast_opt_override_config   ast_test_flag(&ast_options, AST_OPT_FLAG_OVERRIDE_CONFIG)
#define ast_opt_priority_jumping   ast_test_flag(&ast_options, AST_OPT_FLAG_PRIORITY_JUMPING)
#define ast_opt_quiet   ast_test_flag(&ast_options, AST_OPT_FLAG_QUIET)
#define ast_opt_reconnect   ast_test_flag(&ast_options, AST_OPT_FLAG_RECONNECT)
#define ast_opt_remote   ast_test_flag(&ast_options, AST_OPT_FLAG_REMOTE)
#define ast_opt_timestamp   ast_test_flag(&ast_options, AST_OPT_FLAG_TIMESTAMP)
#define ast_opt_transcode_via_slin   ast_test_flag(&ast_options, AST_OPT_FLAG_TRANSCODE_VIA_SLIN)
#define ast_opt_transmit_silence   ast_test_flag(&ast_options, AST_OPT_FLAG_TRANSMIT_SILENCE)
#define ast_pthread_mutex_init(pmutex, a)   pthread_mutex_init(pmutex,a)
#define AST_PTHREADT_NULL   (pthread_t) -1
#define AST_PTHREADT_STOP   (pthread_t) -2
#define ast_realloc(p, len)   _ast_realloc((p), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
 A wrapper for realloc().
#define ast_realloc(p, len)   _ast_realloc((p), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
 A wrapper for realloc().
#define AST_RWLIST_APPEND_LIST   AST_LIST_APPEND_LIST
#define AST_RWLIST_EMPTY   AST_LIST_EMPTY
#define AST_RWLIST_ENTRY   AST_LIST_ENTRY
#define AST_RWLIST_FIRST   AST_LIST_FIRST
#define AST_RWLIST_HEAD(name, type)
 Defines a structure to be used to hold a read/write list of specified type.
#define AST_RWLIST_HEAD_DESTROY(head)
 Destroys an rwlist head structure.
#define AST_RWLIST_HEAD_INIT(head)
 Initializes an rwlist head structure.
#define AST_RWLIST_HEAD_INIT_VALUE
 Defines initial values for a declaration of AST_RWLIST_HEAD.
#define AST_RWLIST_HEAD_SET(head, entry)
 Initializes an rwlist head structure with a specified first entry.
#define AST_RWLIST_HEAD_STATIC(name, type)
 Defines a structure to be used to hold a read/write list of specified type, statically initialized.
#define AST_RWLIST_INSERT_AFTER   AST_LIST_INSERT_AFTER
#define AST_RWLIST_INSERT_BEFORE_CURRENT   AST_LIST_INSERT_BEFORE_CURRENT
#define AST_RWLIST_INSERT_HEAD   AST_LIST_INSERT_HEAD
#define AST_RWLIST_INSERT_TAIL   AST_LIST_INSERT_TAIL
#define AST_RWLIST_LAST   AST_LIST_LAST
#define AST_RWLIST_NEXT   AST_LIST_NEXT
#define AST_RWLIST_RDLOCK(head)   ast_rwlock_rdlock(&(head)->lock)
 Read locks a list.
#define AST_RWLIST_REMOVE   AST_LIST_REMOVE
#define AST_RWLIST_REMOVE_CURRENT   AST_LIST_REMOVE_CURRENT
#define AST_RWLIST_REMOVE_HEAD   AST_LIST_REMOVE_HEAD
#define AST_RWLIST_TRAVERSE   AST_LIST_TRAVERSE
#define AST_RWLIST_TRAVERSE_SAFE_BEGIN   AST_LIST_TRAVERSE_SAFE_BEGIN
#define AST_RWLIST_TRAVERSE_SAFE_END   AST_LIST_TRAVERSE_SAFE_END
#define AST_RWLIST_UNLOCK(head)   ast_rwlock_unlock(&(head)->lock)
 Attempts to unlock a read/write based list.
#define AST_RWLIST_WRLOCK(head)   ast_rwlock_wrlock(&(head)->lock)
 Write locks a list.
#define AST_RWLOCK_DEFINE_STATIC(rwlock)   __AST_RWLOCK_DEFINE(static, rwlock)
#define ast_set2_flag(p, value, flag)
#define ast_strdup(str)   _ast_strdup((str), __FILE__, __LINE__, __PRETTY_FUNCTION__)
 A wrapper for strdup().
#define ast_strdup(str)   _ast_strdup((str), __FILE__, __LINE__, __PRETTY_FUNCTION__)
 A wrapper for strdup().
#define ast_strdupa(s)
 duplicate a string in memory from the stack
#define ast_strndup(str, len)   _ast_strndup((str), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
 A wrapper for strndup().
#define ast_strndup(str, len)   _ast_strndup((str), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
 A wrapper for strndup().
#define ast_test_flag(p, flag)
#define ast_vasprintf(ret, fmt, ap)   _ast_vasprintf((ret), __FILE__, __LINE__, __PRETTY_FUNCTION__, (fmt), (ap))
 A wrapper for vasprintf().
#define ast_vasprintf(ret, fmt, ap)   _ast_vasprintf((ret), __FILE__, __LINE__, __PRETTY_FUNCTION__, (fmt), (ap))
 A wrapper for vasprintf().
#define BACKGROUND_MATCHEXTEN   (1 << 2)
#define BACKGROUND_NOANSWER   (1 << 1)
#define BACKGROUND_PLAYBACK   (1 << 3)
#define BACKGROUND_SKIP   (1 << 0)
#define CB_INCR   250
#define COMMENT_END   "--;"
#define COMMENT_META   ';'
#define COMMENT_START   ";--"
#define COMMENT_TAG   '-'
#define DEBUG_M(a)
#define EVENTLOG   "event_log"
#define EXT_DATA_SIZE   8192
#define gethostbyname   __gethostbyname__is__not__reentrant__use__ast_gethostbyname__instead__
#define LOG_DEBUG   __LOG_DEBUG, _A_
#define LOG_DTMF   __LOG_DTMF, _A_
#define LOG_ERROR   __LOG_ERROR, _A_
#define LOG_EVENT   __LOG_EVENT, _A_
#define LOG_NOTICE   __LOG_NOTICE, _A_
#define LOG_VERBOSE   __LOG_VERBOSE, _A_
#define LOG_WARNING   __LOG_WARNING, _A_
#define MALLOC_FAILURE_MSG   ast_log(LOG_ERROR, "Memory Allocation Failure in function %s at line %d of %s\n", func, lineno, file);
#define MALLOC_FAILURE_MSG   ast_log(LOG_ERROR, "Memory Allocation Failure in function %s at line %d of %s\n", func, lineno, file);
#define MAX_INCLUDE_LEVEL   10
#define MAX_NESTED_COMMENTS   128
#define ONE_MILLION   1000000
#define PRIORITY_HINT   -1
#define pthread_cond_t   use_ast_cond_t_instead_of_pthread_cond_t
#define pthread_create   __use_ast_pthread_create_instead__
#define pthread_mutex_init   use_ast_mutex_init_instead_of_pthread_mutex_init
#define PTHREAD_MUTEX_INIT_VALUE   PTHREAD_MUTEX_INITIALIZER
#define pthread_mutex_t   use_ast_mutex_t_instead_of_pthread_mutex_t
#define QUEUELOG   "queue_log"
#define S_OR(a, b)   (!ast_strlen_zero(a) ? (a) : (b))
#define STATUS_NO_CONTEXT   1
#define STATUS_NO_EXTENSION   2
#define STATUS_NO_LABEL   4
#define STATUS_NO_PRIORITY   3
#define STATUS_SUCCESS   5
#define SWITCH_DATA_LENGTH   256
#define VAR_BUF_SIZE   4096
#define VAR_HARDTRAN   3
#define VAR_NORMAL   1
#define VAR_SOFTTRAN   2
#define VERBOSE_PREFIX_1   " "
#define VERBOSE_PREFIX_2   " == "
#define VERBOSE_PREFIX_3   " -- "
#define VERBOSE_PREFIX_4   " > "
#define WRAP_LIBC_MALLOC

Typedefs

typedef pthread_cond_t ast_cond_t
typedef pthread_mutex_t ast_mutex_t
typedef pthread_rwlock_t ast_rwlock_t
typedef int(* ast_state_cb_type )(char *context, char *id, enum ast_extension_states state, void *data)
typedef int( ast_switch_f )(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)
typedef struct ast_configconfig_load_func (const char *database, const char *table, const char *configfile, struct ast_config *config, int withcomments, const char *suggested_include_file)
typedef struct ast_configrealtime_multi_get (const char *database, const char *table, va_list ap)
typedef int realtime_update (const char *database, const char *table, const char *keyfield, const char *entity, va_list ap)
typedef struct ast_variablerealtime_var_get (const char *database, const char *table, va_list ap)

Enumerations

enum  ast_extension_states {
  AST_EXTENSION_REMOVED = -2, AST_EXTENSION_DEACTIVATED = -1, AST_EXTENSION_NOT_INUSE = 0, AST_EXTENSION_INUSE = 1 << 0,
  AST_EXTENSION_BUSY = 1 << 1, AST_EXTENSION_UNAVAILABLE = 1 << 2, AST_EXTENSION_RINGING = 1 << 3, AST_EXTENSION_ONHOLD = 1 << 4,
  AST_EXTENSION_REMOVED = -2, AST_EXTENSION_DEACTIVATED = -1, AST_EXTENSION_NOT_INUSE = 0, AST_EXTENSION_INUSE = 1 << 0,
  AST_EXTENSION_BUSY = 1 << 1, AST_EXTENSION_UNAVAILABLE = 1 << 2, AST_EXTENSION_RINGING = 1 << 3, AST_EXTENSION_ONHOLD = 1 << 4
}
enum  ast_option_flags {
  AST_OPT_FLAG_EXEC_INCLUDES = (1 << 0), AST_OPT_FLAG_NO_FORK = (1 << 1), AST_OPT_FLAG_QUIET = (1 << 2), AST_OPT_FLAG_CONSOLE = (1 << 3),
  AST_OPT_FLAG_HIGH_PRIORITY = (1 << 4), AST_OPT_FLAG_INIT_KEYS = (1 << 5), AST_OPT_FLAG_REMOTE = (1 << 6), AST_OPT_FLAG_EXEC = (1 << 7),
  AST_OPT_FLAG_NO_COLOR = (1 << 8), AST_OPT_FLAG_FULLY_BOOTED = (1 << 9), AST_OPT_FLAG_TRANSCODE_VIA_SLIN = (1 << 10), AST_OPT_FLAG_STDEXTEN_MACRO = (1 << 11),
  AST_OPT_FLAG_DUMP_CORE = (1 << 12), AST_OPT_FLAG_CACHE_RECORD_FILES = (1 << 13), AST_OPT_FLAG_TIMESTAMP = (1 << 14), AST_OPT_FLAG_OVERRIDE_CONFIG = (1 << 15),
  AST_OPT_FLAG_RECONNECT = (1 << 16), AST_OPT_FLAG_TRANSMIT_SILENCE = (1 << 17), AST_OPT_FLAG_DONT_WARN = (1 << 18), AST_OPT_FLAG_END_CDR_BEFORE_H_EXTEN = (1 << 19),
  AST_OPT_FLAG_ALWAYS_FORK = (1 << 21), AST_OPT_FLAG_MUTE = (1 << 22), AST_OPT_FLAG_DEBUG_MODULE = (1 << 23), AST_OPT_FLAG_VERBOSE_MODULE = (1 << 24),
  AST_OPT_FLAG_LIGHT_BACKGROUND = (1 << 25), AST_OPT_FLAG_INITIATED_SECONDS = (1 << 26), AST_OPT_FLAG_FORCE_BLACK_BACKGROUND = (1 << 27), AST_OPT_FLAG_HIDE_CONSOLE_CONNECT = (1 << 28),
  AST_OPT_FLAG_LOCK_CONFIG_DIR = (1 << 29), AST_OPT_FLAG_GENERIC_PLC = (1 << 30), AST_OPT_FLAG_EXEC_INCLUDES = (1 << 0), AST_OPT_FLAG_NO_FORK = (1 << 1),
  AST_OPT_FLAG_QUIET = (1 << 2), AST_OPT_FLAG_CONSOLE = (1 << 3), AST_OPT_FLAG_HIGH_PRIORITY = (1 << 4), AST_OPT_FLAG_INIT_KEYS = (1 << 5),
  AST_OPT_FLAG_REMOTE = (1 << 6), AST_OPT_FLAG_EXEC = (1 << 7), AST_OPT_FLAG_NO_COLOR = (1 << 8), AST_OPT_FLAG_FULLY_BOOTED = (1 << 9),
  AST_OPT_FLAG_TRANSCODE_VIA_SLIN = (1 << 10), AST_OPT_FLAG_DUMP_CORE = (1 << 12), AST_OPT_FLAG_CACHE_RECORD_FILES = (1 << 13), AST_OPT_FLAG_TIMESTAMP = (1 << 14),
  AST_OPT_FLAG_OVERRIDE_CONFIG = (1 << 15), AST_OPT_FLAG_RECONNECT = (1 << 16), AST_OPT_FLAG_TRANSMIT_SILENCE = (1 << 17), AST_OPT_FLAG_DONT_WARN = (1 << 18),
  AST_OPT_FLAG_END_CDR_BEFORE_H_EXTEN = (1 << 19), AST_OPT_FLAG_ALWAYS_FORK = (1 << 21), AST_OPT_FLAG_MUTE = (1 << 22), AST_OPT_FLAG_DEBUG_FILE = (1 << 23),
  AST_OPT_FLAG_VERBOSE_FILE = (1 << 24), AST_OPT_FLAG_LIGHT_BACKGROUND = (1 << 25), AST_OPT_FLAG_INITIATED_SECONDS = (1 << 26), AST_OPT_FLAG_FORCE_BLACK_BACKGROUND = (1 << 27)
}

Functions

static struct ast_context__ast_context_create (struct ast_context **extcontexts, const char *name, const char *registrar, int existsokay)
static void __ast_context_destroy (struct ast_context *con, const char *registrar)
int _ast_asprintf (char **ret, const char *file, int lineno, const char *func, const char *fmt,...)
void * _ast_calloc (size_t num, size_t len, const char *file, int lineno, const char *func)
void * _ast_malloc (size_t len, const char *file, int lineno, const char *func)
void * _ast_realloc (void *p, size_t len, const char *file, int lineno, const char *func)
char * _ast_strdup (const char *str, const char *file, int lineno, const char *func)
char * _ast_strndup (const char *str, size_t len, const char *file, int lineno, const char *func)
int _ast_vasprintf (char **ret, const char *file, int lineno, const char *func, const char *fmt, va_list ap)
static int _extension_match_core (const char *pattern, const char *data, enum ext_match_t mode)
static void _null_sig_handler (int sig)
 NULL handler so we can collect the child exit status.
static int add_pri (struct ast_context *con, struct ast_exten *tmp, struct ast_exten *el, struct ast_exten *e, int replace)
 add the extension in the priority chain. returns 0 on success, -1 on failure
static struct ast_commentALLOC_COMMENT (const char *buffer)
static int ast_add_extension2 (struct ast_context *con, int replace, const char *extension, int priority, const char *label, const char *callerid, const char *application, void *data, void(*datad)(void *), const char *registrar)
 Main interface to add extensions to the list for out context.
static int ast_add_hint (struct ast_exten *e)
 ast_add_hint: Add hint to hint list, check initial extension state
static unsigned int ast_app_separate_args (char *buf, char delim, char **array, int arraylen)
int ast_atomic_dec_and_test (volatile int *p)
 decrement *p by 1 and return true if the variable has reached 0. Useful e.g. to check if a refcount has reached 0.
int ast_atomic_fetchadd_int (volatile int *p, int v)
static int ast_atomic_fetchadd_int_slow (volatile int *p, int v)
 Atomically add v to *p and return * the previous value of *p. This can be used to handle reference counts, and the return value can be used to generate unique identifiers.
int ast_build_timing (struct ast_timing *i, const char *info_in)
 Construct a timing bitmap, for use in time-based conditionals.
static void ast_category_append (struct ast_config *config, struct ast_category *category)
 Appends a category to a config.
static char * ast_category_browse (struct ast_config *config, const char *prev)
 Browse categories.
static void ast_category_destroy (struct ast_category *cat)
static struct ast_categoryast_category_get (const struct ast_config *config, const char *category_name)
static struct ast_categoryast_category_new (const char *name, const char *in_file, int lineno)
 Create a category.
static int ast_change_hint (struct ast_exten *oe, struct ast_exten *ne)
 ast_change_hint: Change hint for an extension
int ast_check_timing (const struct ast_timing *i)
 Evaluate a pre-constructed bitmap as to whether the current time falls within the range specified.
static void ast_config_destroy (struct ast_config *cfg)
 Destroys a config.
struct ast_categoryast_config_get_current_category (const struct ast_config *cfg)
 Retrieve the current category name being built.
static struct ast_configast_config_internal_load (const char *filename, struct ast_config *cfg, int withcomments, const char *suggested_incl_file)
static struct ast_configast_config_new (void)
 Create a new base configuration structure.
void ast_config_set_current_category (struct ast_config *cfg, const struct ast_category *cat)
 Set the category within the configuration as being current.
void ast_console_puts (const char *string)
 write the string to the root console, and all attached network console clients
static int ast_context_add_ignorepat2 (struct ast_context *con, const char *value, const char *registrar)
static int ast_context_add_include2 (struct ast_context *con, const char *value, const char *registrar)
 Add a context include.
static int ast_context_add_switch2 (struct ast_context *con, const char *value, const char *data, int eval, const char *registrar)
 Adds a switch (first param is a ast_context).
static struct ast_contextast_context_find (const char *name)
 Find a context.
static struct ast_contextast_context_find_or_create (struct ast_context **extcontexts, void *tab, const char *name, const char *registrar)
static int ast_context_verify_includes (struct ast_context *con)
void ast_copy_string (char *dst, const char *src, size_t size)
static int ast_extension_match (const char *pattern, const char *data)
 Determine if a given extension matches a given pattern (in NXX format).
static int ast_findlabel_extension2 (struct ast_channel *c, struct ast_context *con, const char *exten, const char *label, const char *callerid)
 Find the priority of an extension that has the specified label.
static int ast_func_read (struct ast_channel *chan, const char *function, char *workspace, size_t len)
static int ast_func_write (struct ast_channel *chan, const char *function, const char *value)
static const char * ast_get_context_name (struct ast_context *con)
static const char * ast_get_extension_app (struct ast_exten *e)
static const char * ast_get_extension_name (struct ast_exten *exten)
static struct ast_config_includeast_include_find (struct ast_config *conf, const char *included_file)
static struct ast_config_includeast_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)
static void ast_includes_destroy (struct ast_config_include *incls)
static void ast_log (int level, const char *file, int line, const char *function, const char *fmt,...)
 Used for sending a log message This is the standard logger function. Probably the only way you will invoke it would be something like this: ast_log(AST_LOG_WHATEVER, "Problem with the %s Captain. We should get some more. Will %d be enough?\n", "flux capacitor", 10); where WHATEVER is one of ERROR, DEBUG, EVENT, NOTICE, or WARNING depending on which log you wish to output to. These are implemented as macros, that will provide the function with the needed arguments.
void ast_log_backtrace (void)
 Log a backtrace of the current thread's execution stack to the Asterisk log.
void ast_mark_lock_failed (void *lock_addr)
static void ast_merge_contexts_and_delete (struct ast_context **extcontexts, const char *registrar)
static int ast_mutex_init (ast_mutex_t *pmutex)
static char * ast_process_quotes_and_slashes (char *start, char find, char replace_with)
void ast_queue_log (const char *queuename, const char *callid, const char *agent, const char *event, const char *fmt,...)
int ast_register_verbose (void(*verboser)(const char *string))
static int ast_remove_hint (struct ast_exten *e)
 ast_remove_hint: Remove hint from extension
void ast_replace_sigchld (void)
 Replace the SIGCHLD handler.
static int ast_rwlock_destroy (ast_rwlock_t *prwlock)
static int ast_rwlock_init (ast_rwlock_t *prwlock)
static int ast_rwlock_rdlock (ast_rwlock_t *prwlock)
static int ast_rwlock_unlock (ast_rwlock_t *prwlock)
static int ast_rwlock_wrlock (ast_rwlock_t *prwlock)
int ast_safe_system (const char *s)
 Safely spawn an external program while closing file descriptors.
static void ast_shrink_phone_number (char *n)
 Clean up phone string remove '(', ' ', ')', non-trailing '.', and '-' not in square brackets. Basically, remove anything that could be invalid in a pattern.
char * ast_skip_blanks (const char *str)
char * ast_strip (char *s)
 Strip leading/trailing whitespace from a string.
static force_inline int ast_strlen_zero (const char *s)
char * ast_trim_blanks (char *str)
 Trims trailing whitespace characters from a string.
static int ast_true (const char *s)
struct timeval ast_tvadd (struct timeval a, struct timeval b)
 Returns the sum of two timevals a + b.
struct timeval ast_tvnow (void)
struct timeval ast_tvsub (struct timeval a, struct timeval b)
 Returns the difference of two timevals a - b.
static int ast_unlock_context (struct ast_context *con)
static int ast_unlock_contexts (void)
int ast_unregister_verbose (void(*verboser)(const char *string))
void ast_unreplace_sigchld (void)
 Restore the SIGCHLD handler.
static struct ast_var_tast_var_assign (const char *name, const char *value)
static void ast_var_delete (struct ast_var_t *var)
static const char * ast_var_name (const struct ast_var_t *var)
static const char * ast_var_value (const struct ast_var_t *var)
static void ast_variable_append (struct ast_category *category, struct ast_variable *variable)
static struct ast_variableast_variable_browse (const struct ast_config *config, const char *category)
static struct ast_variableast_variable_new (const char *name, const char *value, const char *filename)
static const char * ast_variable_retrieve (const struct ast_config *config, const char *category, const char *variable)
static void ast_variables_destroy (struct ast_variable *v)
 Free variable list.
void ast_verbose (const char *fmt,...)
static struct ast_extenast_walk_context_extensions (struct ast_context *con, struct ast_exten *exten)
static struct ast_includeast_walk_context_includes (struct ast_context *con, struct ast_include *inc)
static struct ast_swast_walk_context_switches (struct ast_context *con, struct ast_sw *sw)
static struct ast_contextast_walk_contexts (struct ast_context *con)
static struct ast_extenast_walk_extension_priorities (struct ast_exten *exten, struct ast_exten *priority)
static int ast_wrlock_context (struct ast_context *con)
static int ast_wrlock_contexts (void)
static struct ast_categorycategory_get (const struct ast_config *config, const char *category_name, int ignored)
static void CB_ADD (char *str)
static void CB_ADD_LEN (char *str, int len)
static void CB_INIT (void)
static void CB_RESET (void)
static struct ast_configconfig_text_file_load (const char *database, const char *table, const char *filename, struct ast_config *cfg, int withcomments, const char *suggested_include_file)
static void destroy_exten (struct ast_exten *e)
static int ext_cmp (const char *a, const char *b)
 the full routine to compare extensions in rules.
static int ext_cmp1 (const char **p)
 helper functions to sort extensions and patterns in the desired way, so that more specific patterns appear first.
static int ext_strncpy (char *dst, const char *src, int len)
 copy a string skipping whitespace
static int extension_match_core (const char *pattern, const char *data, enum ext_match_t mode)
static struct ast_config_enginefind_engine (const char *family, char *database, int dbsiz, char *table, int tabsiz)
 Find realtime engine for realtime family.
static void fini_conlock (void)
static void fini_globalslock (void)
static void fini_hints (void)
static void gen_header (FILE *f1, const char *configfile, const char *fn, const char *generator)
static unsigned get_range (char *src, int max, char *const names[], const char *msg)
 helper function to return a range up to max (7, 12, 31 respectively). names, if supplied, is an array of names that should be mapped to numbers.
static void get_timerange (struct ast_timing *i, char *times)
 store a bitmask of valid times, one bit each 2 minute
static int include_valid (struct ast_include *i)
static void inherit_category (struct ast_category *new, const struct ast_category *base)
static void init_conlock (void)
static void init_globalslock (void)
static void init_hints (void)
static void LLB_ADD (char *str)
int localized_add_extension2 (struct ast_context *con, int replace, const char *extension, int priority, const char *label, const char *callerid, const char *application, void *data, void(*datad)(void *), const char *registrar)
void localized_ast_include_rename (struct ast_config *conf, const char *from_file, const char *to_file)
struct ast_categorylocalized_category_get (const struct ast_config *config, const char *category_name)
struct ast_configlocalized_config_load (const char *filename)
struct ast_configlocalized_config_load_with_comments (const char *filename)
int localized_config_text_file_save (const char *configfile, const struct ast_config *cfg, const char *generator)
int localized_context_add_ignorepat2 (struct ast_context *con, const char *value, const char *registrar)
int localized_context_add_include2 (struct ast_context *con, const char *value, const char *registrar)
int localized_context_add_switch2 (struct ast_context *con, const char *value, const char *data, int eval, const char *registrar)
void localized_context_destroy (struct ast_context *con, const char *registrar)
struct ast_contextlocalized_context_find_or_create (struct ast_context **extcontexts, void *tab, const char *name, const char *registrar)
int localized_context_verify_includes (struct ast_context *con)
struct ast_extenlocalized_find_extension (struct ast_context *bypass, struct pbx_find_info *q, const char *context, const char *exten, int priority, const char *label, const char *callerid, enum ext_match_t action)
void localized_merge_contexts_and_delete (struct ast_context **extcontexts, void *tab, const char *registrar)
int localized_pbx_builtin_setvar (struct ast_channel *chan, const void *data)
int localized_pbx_load_module (void)
void localized_use_conf_dir (void)
void localized_use_local_dir (void)
struct ast_extenlocalized_walk_context_extensions (struct ast_context *con, struct ast_exten *exten)
struct ast_includelocalized_walk_context_includes (struct ast_context *con, struct ast_include *inc)
struct ast_swlocalized_walk_context_switches (struct ast_context *con, struct ast_sw *sw)
struct ast_contextlocalized_walk_contexts (struct ast_context *con)
struct ast_extenlocalized_walk_extension_priorities (struct ast_exten *exten, struct ast_exten *priority)
static int lookup_name (const char *s, char *const names[], int max)
 Helper for get_range. return the index of the matching entry, starting from 1. If names is not supplied, try numeric values.
static int matchcid (const char *cidpattern, const char *callerid)
static void move_variables (struct ast_category *old, struct ast_category *new)
static struct ast_categorynext_available_category (struct ast_category *cat)
static void null_datad (void *foo)
static int parse_variable_name (char *var, int *offset, int *length, int *isfunc)
 extract offset:length from variable name. Returns 1 if there is a offset:length part, which is trimmed off (values go into variables)
static int pbx_builtin_setvar (struct ast_channel *chan, const void *data)
static void pbx_builtin_setvar_helper (struct ast_channel *chan, const char *name, const char *value)
static int pbx_extension_helper (struct ast_channel *c, struct ast_context *con, const char *context, const char *exten, int priority, const char *label, const char *callerid, enum ext_match_t action)
 The return value depends on the action:.
static struct ast_extenpbx_find_extension (struct ast_channel *chan, struct ast_context *bypass, struct pbx_find_info *q, const char *context, const char *exten, int priority, const char *label, const char *callerid, enum ext_match_t action)
static int pbx_load_config (const char *config_file)
static void pbx_retrieve_variable (struct ast_channel *c, const char *var, char **ret, char *workspace, int workspacelen, struct varshead *headp)
 Support for Asterisk built-in variables in the dialplan.
static void pbx_substitute_variables_helper (struct ast_channel *c, const char *cp1, char *cp2, int count)
static void pbx_substitute_variables_helper_full (struct ast_channel *c, struct varshead *headp, const char *cp1, char *cp2, int count)
static int process_text_line (struct ast_config *cfg, struct ast_category **cat, char *buf, int lineno, const char *configfile, int withcomments, const char *suggested_include_file)
static void set_fn (char *fn, int fn_size, const char *file, const char *configfile)
static char * substring (const char *value, int offset, int length, char *workspace, size_t workspace_len)
 takes a substring. It is ok to call with value == workspace.
static struct timeval tvfix (struct timeval a)
static struct ast_variablevariable_clone (const struct ast_variable *old)

Variables

char ast_defaultlanguage []
int ast_language_is_prefix
 The following variable controls the layout of localized sound files. If 0, use the historical layout with prefix just before the filename (i.e. digits/en/1.gsm , digits/it/1.gsm or default to digits/1.gsm), if 1 put the prefix at the beginning of the filename (i.e. en/digits/1.gsm, it/digits/1.gsm or default to digits/1.gsm). The latter permits a language to be entirely in one directory.
pid_t ast_mainpid
int ast_option_maxcalls
double ast_option_maxload
struct ast_flags ast_options = { AST_DEFAULT_OPTIONS }
static int autofallthrough_config = 0
static int clearglobalvars_config = 0
static char * comment_buffer
static int comment_buffer_size
static struct ast_config_engineconfig_engine_list
static char * config_filename = "extensions.conf"
static struct ast_config_mapconfig_maps
static ast_rwlock_t conlock
static struct ast_contextcontexts = NULL
char * days []
char debug_filename [AST_FILENAME_MAX]
static char * extconfig_conf = "extconfig.conf"
static char * global_registrar = "conf2ael"
static struct varshead globals = AST_LIST_HEAD_NOLOCK_INIT_VALUE
static ast_rwlock_t globalslock
static char * lline_buffer
static int lline_buffer_size
static struct ast_contextlocal_contexts = NULL
char * months []
static struct sigaction null_sig_handler
int option_debug
int option_verbose
char record_cache_dir [AST_CACHE_DIR_LEN]
static unsigned int safe_system_level = 0
 Keep track of how many threads are currently trying to wait*() on a child process.
static struct sigaction safe_system_prev_handler
static int static_config = 0
static struct ast_config_engine text_file_engine
static int use_local_dir = 1
static char userscontext [AST_MAX_EXTENSION] = "default"
static int write_protect_config = 1


Define Documentation

#define __AST_MUTEX_DEFINE ( scope,
mutex   )     scope ast_mutex_t mutex = AST_MUTEX_INIT_VALUE

Definition at line 509 of file extconf.c.

#define __AST_RWLOCK_DEFINE ( scope,
rwlock   ) 

Definition at line 565 of file extconf.c.

#define __LOG_DEBUG   0

Definition at line 133 of file extconf.c.

#define __LOG_DTMF   6

Definition at line 169 of file extconf.c.

#define __LOG_ERROR   4

Definition at line 157 of file extconf.c.

#define __LOG_EVENT   1

Definition at line 139 of file extconf.c.

#define __LOG_NOTICE   2

Definition at line 145 of file extconf.c.

#define __LOG_VERBOSE   5

Definition at line 163 of file extconf.c.

#define __LOG_WARNING   3

Definition at line 151 of file extconf.c.

#define __MTX_PROF ( a   )     return pthread_mutex_lock((a))

Definition at line 176 of file extconf.c.

#define _A_   __FILE__, __LINE__, __PRETTY_FUNCTION__

Definition at line 128 of file extconf.c.

#define _ASTERISK_LOCK_H

Definition at line 173 of file extconf.c.

#define ASINCLUDE_GLOB   1

Definition at line 78 of file extconf.c.

#define AST_API_MODULE   1

Definition at line 88 of file extconf.c.

#define ast_asprintf ( ret,
fmt,
...   )     _ast_asprintf((ret), __FILE__, __LINE__, __PRETTY_FUNCTION__, fmt, __VA_ARGS__)

A wrapper for asprintf().

ast_asprintf() is a wrapper for asprintf() that will generate an Asterisk log message in the case that the allocation fails.

The arguments and return value are the same as asprintf()

Definition at line 897 of file extconf.c.

#define ast_asprintf ( ret,
fmt,
...   )     _ast_asprintf((ret), __FILE__, __LINE__, __PRETTY_FUNCTION__, fmt, __VA_ARGS__)

A wrapper for asprintf().

ast_asprintf() is a wrapper for asprintf() that will generate an Asterisk log message in the case that the allocation fails.

The arguments and return value are the same as asprintf()

Definition at line 897 of file extconf.c.

#define AST_CACHE_DIR_LEN   512

Definition at line 1629 of file extconf.c.

#define ast_calloc ( num,
len   )     _ast_calloc((num), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)

A wrapper for calloc().

ast_calloc() is a wrapper for calloc() that will generate an Asterisk log message in the case that the allocation fails.

The arguments and return value are the same as calloc()

Definition at line 780 of file extconf.c.

#define ast_calloc ( num,
len   )     _ast_calloc((num), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)

A wrapper for calloc().

ast_calloc() is a wrapper for calloc() that will generate an Asterisk log message in the case that the allocation fails.

The arguments and return value are the same as calloc()

Definition at line 780 of file extconf.c.

#define ast_calloc_cache ( num,
len   )     _ast_calloc((num), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)

A wrapper for calloc() for use in cache pools.

ast_calloc_cache() is a wrapper for calloc() that will generate an Asterisk log message in the case that the allocation fails. When memory debugging is in use, the memory allocated by this function will be marked as 'cache' so it can be distinguished from normal memory allocations.

The arguments and return value are the same as calloc()

Definition at line 805 of file extconf.c.

#define ast_calloc_cache ( num,
len   )     _ast_calloc((num), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)

A wrapper for calloc() for use in cache pools.

ast_calloc_cache() is a wrapper for calloc() that will generate an Asterisk log message in the case that the allocation fails. When memory debugging is in use, the memory allocated by this function will be marked as 'cache' so it can be distinguished from normal memory allocations.

The arguments and return value are the same as calloc()

Definition at line 805 of file extconf.c.

#define AST_DEFAULT_OPTIONS   AST_OPT_FLAG_TRANSCODE_VIA_SLIN

These are the options that set by default when Asterisk starts

Definition at line 1633 of file extconf.c.

#define AST_FILENAME_MAX   80

Definition at line 1630 of file extconf.c.

#define ast_free   free

Definition at line 687 of file extconf.c.

#define ast_free_ptr   free

Definition at line 688 of file extconf.c.

#define ast_fully_booted   ast_test_flag(&ast_options, AST_OPT_FLAG_FULLY_BOOTED)

Definition at line 1646 of file extconf.c.

#define AST_LIST_APPEND_LIST ( head,
list,
field   ) 

Appends a whole list to the tail of a list.

Parameters:
head This is a pointer to the list head structure
list This is a pointer to the list to be appended.
field This is the name of the field (declared using AST_LIST_ENTRY()) used to link entries of this list together.

Definition at line 2267 of file extconf.c.

#define AST_LIST_EMPTY ( head   )     (AST_LIST_FIRST(head) == NULL)

Checks whether the specified list contains any entries.

Parameters:
head This is a pointer to the list head structure
Returns non-zero if the list has entries, zero if not.

Definition at line 2005 of file extconf.c.

#define AST_LIST_ENTRY ( type   ) 

Value:

struct {                      \
   struct type *next;                  \
}
Declare a forward link structure inside a list entry.

Parameters:
type This is the type of each list entry.
This macro declares a structure to be used to link list entries together. It must be used inside the definition of the structure named in type, as follows:

  struct list_entry {
   ...
   AST_LIST_ENTRY(list_entry) list;
  }

The field name list here is arbitrary, and can be anything you wish.

Definition at line 1966 of file extconf.c.

#define AST_LIST_FIRST ( head   )     ((head)->first)

Returns the first entry contained in a list.

Parameters:
head This is a pointer to the list head structure

Definition at line 1977 of file extconf.c.

#define AST_LIST_HEAD ( name,
type   ) 

Value:

struct name {                       \
   struct type *first;                 \
   struct type *last;                  \
   ast_mutex_t lock;                \
}
Defines a structure to be used to hold a list of specified type.

Parameters:
name This will be the name of the defined structure.
type This is the type of each list entry.
This macro creates a structure definition that can be used to hold a list of the entries of type type. It does not actually declare (allocate) a structure; to do that, either follow this macro with the desired name of the instance you wish to declare, or use the specified name to declare instances elsewhere.

Example usage:

  static AST_LIST_HEAD(entry_list, entry) entries;

This would define struct entry_list, and declare an instance of it named entries, all intended to hold a list of type struct entry.

Definition at line 1729 of file extconf.c.

#define AST_LIST_HEAD_INIT ( head   ) 

Value:

{              \
   (head)->first = NULL;                  \
   (head)->last = NULL;                \
   ast_mutex_init(&(head)->lock);               \
}
Initializes a list head structure.

Parameters:
head This is a pointer to the list head structure
This macro initializes a list head structure by setting the head entry to NULL (empty list) and recreating the embedded lock.

Definition at line 2157 of file extconf.c.

#define AST_LIST_HEAD_INIT_NOLOCK ( head   ) 

Value:

{           \
   (head)->first = NULL;                  \
   (head)->last = NULL;                \
}
Initializes a list head structure.

Parameters:
head This is a pointer to the list head structure
This macro initializes a list head structure by setting the head entry to NULL (empty list). There is no embedded lock handling with this macro.

Definition at line 2198 of file extconf.c.

#define AST_LIST_HEAD_INIT_VALUE

Value:

{     \
   .first = NULL,             \
   .last = NULL,              \
   .lock = AST_MUTEX_INIT_VALUE,       \
   }
Defines initial values for a declaration of AST_LIST_HEAD.

Definition at line 1790 of file extconf.c.

#define AST_LIST_HEAD_NOLOCK ( name,
type   ) 

Value:

struct name {                       \
   struct type *first;                 \
   struct type *last;                  \
}
Defines a structure to be used to hold a list of specified type (with no lock).

Parameters:
name This will be the name of the defined structure.
type This is the type of each list entry.
This macro creates a structure definition that can be used to hold a list of the entries of type type. It does not actually declare (allocate) a structure; to do that, either follow this macro with the desired name of the instance you wish to declare, or use the specified name to declare instances elsewhere.

Example usage:

This would define struct entry_list, and declare an instance of it named entries, all intended to hold a list of type struct entry.

Definition at line 1781 of file extconf.c.

#define AST_LIST_HEAD_NOLOCK_INIT_VALUE

Value:

{  \
   .first = NULL,             \
   .last = NULL,              \
   }
Defines initial values for a declaration of AST_LIST_HEAD_NOLOCK.

Definition at line 1808 of file extconf.c.

#define AST_LIST_HEAD_NOLOCK_STATIC ( name,
type   ) 

Value:

struct name {                       \
   struct type *first;                 \
   struct type *last;                  \
} name = AST_LIST_HEAD_NOLOCK_INIT_VALUE
Defines a structure to be used to hold a list of specified type, statically initialized.

This is the same as AST_LIST_HEAD_STATIC, except without the lock included.

Definition at line 1902 of file extconf.c.

#define AST_LIST_HEAD_SET ( head,
entry   ) 

Value:

do {           \
   (head)->first = (entry);               \
   (head)->last = (entry);                \
   ast_mutex_init(&(head)->lock);               \
} while (0)
Initializes a list head structure with a specified first entry.

Parameters:
head This is a pointer to the list head structure
entry pointer to the list entry that will become the head of the list
This macro initializes a list head structure by setting the head entry to the supplied value and recreating the embedded lock.

Definition at line 1916 of file extconf.c.

#define AST_LIST_HEAD_SET_NOLOCK ( head,
entry   ) 

Value:

do {        \
   (head)->first = (entry);               \
   (head)->last = (entry);                \
} while (0)
Initializes a list head structure with a specified first entry.

Parameters:
head This is a pointer to the list head structure
entry pointer to the list entry that will become the head of the list
This macro initializes a list head structure by setting the head entry to the supplied value.

Definition at line 1944 of file extconf.c.

#define AST_LIST_HEAD_STATIC ( name,
type   ) 

Value:

struct name {                       \
   struct type *first;                 \
   struct type *last;                  \
   ast_mutex_t lock;                \
} name = AST_LIST_HEAD_INIT_VALUE
Defines a structure to be used to hold a list of specified type, statically initialized.

Parameters:
name This will be the name of the defined structure.
type This is the type of each list entry.
This macro creates a structure definition that can be used to hold a list of the entries of type type, and allocates an instance of it, initialized to be empty.

Example usage:

This would define struct entry_list, intended to hold a list of type struct entry.

Definition at line 1847 of file extconf.c.

#define AST_LIST_INSERT_AFTER ( head,
listelm,
elm,
field   ) 

Inserts a list entry after a given entry.

Parameters:
head This is a pointer to the list head structure
listelm This is a pointer to the entry after which the new entry should be inserted.
elm This is a pointer to the entry to be inserted.
field This is the name of the field (declared using AST_LIST_ENTRY()) used to link entries of this list together.

Definition at line 2212 of file extconf.c.

#define AST_LIST_INSERT_BEFORE_CURRENT ( head,
elm,
field   ) 

Inserts a list entry before the current entry during a traversal.

Parameters:
head This is a pointer to the list head structure
elm This is a pointer to the entry to be inserted.
field This is the name of the field (declared using AST_LIST_ENTRY()) used to link entries of this list together.
Note:
This macro can only be used inside an AST_LIST_TRAVERSE_SAFE_BEGIN() block.

Definition at line 2130 of file extconf.c.

#define AST_LIST_INSERT_HEAD ( head,
elm,
field   ) 

Inserts a list entry at the head of a list.

Parameters:
head This is a pointer to the list head structure
elm This is a pointer to the entry to be inserted.
field This is the name of the field (declared using AST_LIST_ENTRY()) used to link entries of this list together.

Definition at line 2228 of file extconf.c.

#define AST_LIST_INSERT_TAIL ( head,
elm,
field   ) 

Appends a list entry to the tail of a list.

Parameters:
head This is a pointer to the list head structure
elm This is a pointer to the entry to be appended.
field This is the name of the field (declared using AST_LIST_ENTRY()) used to link entries of this list together.
Note: The link field in the appended entry is not modified, so if it is actually the head of a list itself, the entire list will be appended temporarily (until the next AST_LIST_INSERT_TAIL is performed).

Definition at line 2248 of file extconf.c.

#define AST_LIST_LAST ( head   )     ((head)->last)

Returns the last entry contained in a list.

Parameters:
head This is a pointer to the list head structure

Definition at line 1985 of file extconf.c.

#define AST_LIST_NEXT ( elm,
field   )     ((elm)->field.next)

Returns the next entry in the list after the given entry.

Parameters:
elm This is a pointer to the current entry.
field This is the name of the field (declared using AST_LIST_ENTRY()) used to link entries of this list together.

Definition at line 1995 of file extconf.c.

#define AST_LIST_REMOVE ( head,
elm,
field   ) 

Removes a specific entry from a list.

Parameters:
head This is a pointer to the list head structure
elm This is a pointer to the entry to be removed.
field This is the name of the field (declared using AST_LIST_ENTRY()) used to link entries of this list together.
Warning:
The removed entry is not freed nor modified in any way.

Definition at line 2309 of file extconf.c.

#define AST_LIST_REMOVE_CURRENT ( head,
field   ) 

Removes the current entry from a list during a traversal.

Parameters:
head This is a pointer to the list head structure
field This is the name of the field (declared using AST_LIST_ENTRY()) used to link entries of this list together.
Note:
This macro can only be used inside an AST_LIST_TRAVERSE_SAFE_BEGIN() block; it is used to unlink the current entry from the list without affecting the list traversal (and without having to re-traverse the list to modify the previous entry, if any).

Definition at line 2108 of file extconf.c.

#define AST_LIST_REMOVE_HEAD ( head,
field   ) 

Removes and returns the head entry from a list.

Parameters:
head This is a pointer to the list head structure
field This is the name of the field (declared using AST_LIST_ENTRY()) used to link entries of this list together.
Removes the head entry from the list, and returns a pointer to it. This macro is safe to call on an empty list.

Definition at line 2288 of file extconf.c.

#define AST_LIST_TRAVERSE ( head,
var,
field   )     for((var) = (head)->first; (var); (var) = (var)->field.next)

Loops over (traverses) the entries in a list.

Parameters:
head This is a pointer to the list head structure
var This is the name of the variable that will hold a pointer to the current list entry on each iteration. It must be declared before calling this macro.
field This is the name of the field (declared using AST_LIST_ENTRY()) used to link entries of this list together.
This macro is use to loop over (traverse) the entries in a list. It uses a for loop, and supplies the enclosed code with a pointer to each list entry as it loops. It is typically used as follows:
  static AST_LIST_HEAD(entry_list, list_entry) entries;
  ...
  struct list_entry {
   ...
   AST_LIST_ENTRY(list_entry) list;
  }
  ...
  struct list_entry *current;
  ...
  AST_LIST_TRAVERSE(&entries, current, list) {
     (do something with current here)
  }
Warning:
If you modify the forward-link pointer contained in the current entry while inside the loop, the behavior will be unpredictable. At a minimum, the following macros will modify the forward-link pointer, and should not be used inside AST_LIST_TRAVERSE() against the entry pointed to by the current pointer without careful consideration of their consequences:

Definition at line 2045 of file extconf.c.

#define AST_LIST_TRAVERSE_SAFE_BEGIN ( head,
var,
field   ) 

Loops safely over (traverses) the entries in a list.

Parameters:
head This is a pointer to the list head structure
var This is the name of the variable that will hold a pointer to the current list entry on each iteration. It must be declared before calling this macro.
field This is the name of the field (declared using AST_LIST_ENTRY()) used to link entries of this list together.
This macro is used to safely loop over (traverse) the entries in a list. It uses a for loop, and supplies the enclosed code with a pointer to each list entry as it loops. It is typically used as follows:

  static AST_LIST_HEAD(entry_list, list_entry) entries;
  ...
  struct list_entry {
   ...
   AST_LIST_ENTRY(list_entry) list;
  }
  ...
  struct list_entry *current;
  ...
  AST_LIST_TRAVERSE_SAFE_BEGIN(&entries, current, list) {
     (do something with current here)
  }
  AST_LIST_TRAVERSE_SAFE_END;

It differs from AST_LIST_TRAVERSE() in that the code inside the loop can modify (or even free, after calling AST_LIST_REMOVE_CURRENT()) the entry pointed to by the current pointer without affecting the loop traversal.

Definition at line 2083 of file extconf.c.

#define AST_LIST_TRAVERSE_SAFE_END   }

Closes a safe loop traversal block.

Definition at line 2146 of file extconf.c.

#define ast_malloc ( len   )     _ast_malloc((len), __FILE__, __LINE__, __PRETTY_FUNCTION__)

A wrapper for malloc().

ast_malloc() is a wrapper for malloc() that will generate an Asterisk log message in the case that the allocation fails.

The argument and return value are the same as malloc()

Definition at line 757 of file extconf.c.

#define ast_malloc ( len   )     _ast_malloc((len), __FILE__, __LINE__, __PRETTY_FUNCTION__)

A wrapper for malloc().

ast_malloc() is a wrapper for malloc() that will generate an Asterisk log message in the case that the allocation fails.

The argument and return value are the same as malloc()

Definition at line 757 of file extconf.c.

#define AST_MAX_EXTENSION   80

Max length of an extension

Definition at line 2350 of file extconf.c.

#define AST_MUTEX_DEFINE_STATIC ( mutex   )     __AST_MUTEX_DEFINE(static, mutex)

Definition at line 517 of file extconf.c.

#define AST_MUTEX_INIT_VALUE   ((ast_mutex_t) PTHREAD_MUTEX_INIT_VALUE)

Definition at line 480 of file extconf.c.

#define AST_MUTEX_INITIALIZER   __use_AST_MUTEX_DEFINE_STATIC_rather_than_AST_MUTEX_INITIALIZER__

Definition at line 519 of file extconf.c.

#define AST_MUTEX_KIND   PTHREAD_MUTEX_RECURSIVE

Definition at line 207 of file extconf.c.

#define ast_opt_always_fork   ast_test_flag(&ast_options, AST_OPT_FLAG_ALWAYS_FORK)

Definition at line 1657 of file extconf.c.

#define ast_opt_cache_record_files   ast_test_flag(&ast_options, AST_OPT_FLAG_CACHE_RECORD_FILES)

Definition at line 1650 of file extconf.c.

#define ast_opt_console   ast_test_flag(&ast_options, AST_OPT_FLAG_CONSOLE)

Definition at line 1640 of file extconf.c.

#define ast_opt_dont_warn   ast_test_flag(&ast_options, AST_OPT_FLAG_DONT_WARN)

Definition at line 1655 of file extconf.c.

#define ast_opt_dump_core   ast_test_flag(&ast_options, AST_OPT_FLAG_DUMP_CORE)

Definition at line 1649 of file extconf.c.

#define ast_opt_end_cdr_before_h_exten   ast_test_flag(&ast_options, AST_OPT_FLAG_END_CDR_BEFORE_H_EXTEN)

Definition at line 1656 of file extconf.c.

#define ast_opt_exec   ast_test_flag(&ast_options, AST_OPT_FLAG_EXEC)

Definition at line 1644 of file extconf.c.

#define ast_opt_exec_includes   ast_test_flag(&ast_options, AST_OPT_FLAG_EXEC_INCLUDES)

Definition at line 1637 of file extconf.c.

#define ast_opt_high_priority   ast_test_flag(&ast_options, AST_OPT_FLAG_HIGH_PRIORITY)

Definition at line 1641 of file extconf.c.

#define ast_opt_init_keys   ast_test_flag(&ast_options, AST_OPT_FLAG_INIT_KEYS)

Definition at line 1642 of file extconf.c.

#define ast_opt_mute   ast_test_flag(&ast_options, AST_OPT_FLAG_MUTE)

Definition at line 1658 of file extconf.c.

#define ast_opt_no_color   ast_test_flag(&ast_options, AST_OPT_FLAG_NO_COLOR)

Definition at line 1645 of file extconf.c.

#define ast_opt_no_fork   ast_test_flag(&ast_options, AST_OPT_FLAG_NO_FORK)

Definition at line 1638 of file extconf.c.

#define ast_opt_override_config   ast_test_flag(&ast_options, AST_OPT_FLAG_OVERRIDE_CONFIG)

Definition at line 1652 of file extconf.c.

#define ast_opt_priority_jumping   ast_test_flag(&ast_options, AST_OPT_FLAG_PRIORITY_JUMPING)

Definition at line 1648 of file extconf.c.

#define ast_opt_quiet   ast_test_flag(&ast_options, AST_OPT_FLAG_QUIET)

Definition at line 1639 of file extconf.c.

#define ast_opt_reconnect   ast_test_flag(&ast_options, AST_OPT_FLAG_RECONNECT)

Definition at line 1653 of file extconf.c.

#define ast_opt_remote   ast_test_flag(&ast_options, AST_OPT_FLAG_REMOTE)

Definition at line 1643 of file extconf.c.

#define ast_opt_timestamp   ast_test_flag(&ast_options, AST_OPT_FLAG_TIMESTAMP)

Definition at line 1651 of file extconf.c.

#define ast_opt_transcode_via_slin   ast_test_flag(&ast_options, AST_OPT_FLAG_TRANSCODE_VIA_SLIN)

Definition at line 1647 of file extconf.c.

#define ast_opt_transmit_silence   ast_test_flag(&ast_options, AST_OPT_FLAG_TRANSMIT_SILENCE)

Definition at line 1654 of file extconf.c.

#define ast_pthread_mutex_init ( pmutex,
a   )     pthread_mutex_init(pmutex,a)

Definition at line 492 of file extconf.c.

#define AST_PTHREADT_NULL   (pthread_t) -1

Definition at line 193 of file extconf.c.

#define AST_PTHREADT_STOP   (pthread_t) -2

Definition at line 194 of file extconf.c.

#define ast_realloc ( p,
len   )     _ast_realloc((p), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)

A wrapper for realloc().

ast_realloc() is a wrapper for realloc() that will generate an Asterisk log message in the case that the allocation fails.

The arguments and return value are the same as realloc()

Definition at line 816 of file extconf.c.

#define ast_realloc ( p,
len   )     _ast_realloc((p), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)

A wrapper for realloc().

ast_realloc() is a wrapper for realloc() that will generate an Asterisk log message in the case that the allocation fails.

The arguments and return value are the same as realloc()

Definition at line 816 of file extconf.c.

#define AST_RWLIST_APPEND_LIST   AST_LIST_APPEND_LIST

Definition at line 2277 of file extconf.c.

#define AST_RWLIST_EMPTY   AST_LIST_EMPTY

Definition at line 2007 of file extconf.c.

#define AST_RWLIST_ENTRY   AST_LIST_ENTRY

Definition at line 1971 of file extconf.c.

#define AST_RWLIST_FIRST   AST_LIST_FIRST

Definition at line 1979 of file extconf.c.

#define AST_RWLIST_HEAD ( name,
type   ) 

Value:

struct name {                                                           \
        struct type *first;                                             \
        struct type *last;                                              \
        ast_rwlock_t lock;                                              \
}
Defines a structure to be used to hold a read/write list of specified type.

Parameters:
name This will be the name of the defined structure.
type This is the type of each list entry.
This macro creates a structure definition that can be used to hold a list of the entries of type type. It does not actually declare (allocate) a structure; to do that, either follow this macro with the desired name of the instance you wish to declare, or use the specified name to declare instances elsewhere.

Example usage:

  static AST_RWLIST_HEAD(entry_list, entry) entries;

This would define struct entry_list, and declare an instance of it named entries, all intended to hold a list of type struct entry.

Definition at line 1755 of file extconf.c.

#define AST_RWLIST_HEAD_DESTROY ( head   ) 

Value:

{                                 \
        (head)->first = NULL;                                           \
        (head)->last = NULL;                                            \
        ast_rwlock_destroy(&(head)->lock);                              \
}
Destroys an rwlist head structure.

Parameters:
head This is a pointer to the list head structure
This macro destroys a list head structure by setting the head entry to NULL (empty list) and destroying the embedded lock. It does not free the structure from memory.

Definition at line 2184 of file extconf.c.

#define AST_RWLIST_HEAD_INIT ( head   ) 

Value:

{                                    \
        (head)->first = NULL;                                           \
        (head)->last = NULL;                                            \
        ast_rwlock_init(&(head)->lock);                                 \
}
Initializes an rwlist head structure.

Parameters:
head This is a pointer to the list head structure
This macro initializes a list head structure by setting the head entry to NULL (empty list) and recreating the embedded lock.

Definition at line 2170 of file extconf.c.

#define AST_RWLIST_HEAD_INIT_VALUE

Value:

{               \
        .first = NULL,                                  \
        .last = NULL,                                   \
        .lock = AST_RWLOCK_INIT_VALUE,                  \
        }
Defines initial values for a declaration of AST_RWLIST_HEAD.

Definition at line 1799 of file extconf.c.

#define AST_RWLIST_HEAD_SET ( head,
entry   ) 

Value:

do {                           \
        (head)->first = (entry);                                        \
        (head)->last = (entry);                                         \
        ast_rwlock_init(&(head)->lock);                                 \
} while (0)
Initializes an rwlist head structure with a specified first entry.

Parameters:
head This is a pointer to the list head structure
entry pointer to the list entry that will become the head of the list
This macro initializes a list head structure by setting the head entry to the supplied value and recreating the embedded lock.

Definition at line 1930 of file extconf.c.

#define AST_RWLIST_HEAD_STATIC ( name,
type   ) 

Defines a structure to be used to hold a read/write list of specified type, statically initialized.

Parameters:
name This will be the name of the defined structure.
type This is the type of each list entry.
This macro creates a structure definition that can be used to hold a list of the entries of type type, and allocates an instance of it, initialized to be empty.

Example usage:

This would define struct entry_list, intended to hold a list of type struct entry.

Definition at line 1873 of file extconf.c.

#define AST_RWLIST_INSERT_AFTER   AST_LIST_INSERT_AFTER

Definition at line 2219 of file extconf.c.

#define AST_RWLIST_INSERT_BEFORE_CURRENT   AST_LIST_INSERT_BEFORE_CURRENT

Definition at line 2141 of file extconf.c.

#define AST_RWLIST_INSERT_HEAD   AST_LIST_INSERT_HEAD

Definition at line 2235 of file extconf.c.

#define AST_RWLIST_INSERT_TAIL   AST_LIST_INSERT_TAIL

Definition at line 2258 of file extconf.c.

#define AST_RWLIST_LAST   AST_LIST_LAST

Definition at line 1987 of file extconf.c.

#define AST_RWLIST_NEXT   AST_LIST_NEXT

Definition at line 1997 of file extconf.c.

#define AST_RWLIST_RDLOCK ( head   )     ast_rwlock_rdlock(&(head)->lock)

Read locks a list.

Parameters:
head This is a pointer to the list head structure
This macro attempts to place a read lock in the list head structure pointed to by head. Returns non-zero on success, 0 on failure

Definition at line 1696 of file extconf.c.

#define AST_RWLIST_REMOVE   AST_LIST_REMOVE

Definition at line 2327 of file extconf.c.

#define AST_RWLIST_REMOVE_CURRENT   AST_LIST_REMOVE_CURRENT

Definition at line 2118 of file extconf.c.

#define AST_RWLIST_REMOVE_HEAD   AST_LIST_REMOVE_HEAD

Definition at line 2299 of file extconf.c.

#define AST_RWLIST_TRAVERSE   AST_LIST_TRAVERSE

Definition at line 2048 of file extconf.c.

#define AST_RWLIST_TRAVERSE_SAFE_BEGIN   AST_LIST_TRAVERSE_SAFE_BEGIN

Definition at line 2095 of file extconf.c.

#define AST_RWLIST_TRAVERSE_SAFE_END   AST_LIST_TRAVERSE_SAFE_END

Definition at line 2148 of file extconf.c.

#define AST_RWLIST_UNLOCK ( head   )     ast_rwlock_unlock(&(head)->lock)

Attempts to unlock a read/write based list.

Parameters:
head This is a pointer to the list head structure
This macro attempts to remove a read or write lock from the list head structure pointed to by head. If the list was not locked by this thread, this macro has no effect.

Definition at line 1707 of file extconf.c.

#define AST_RWLIST_WRLOCK ( head   )     ast_rwlock_wrlock(&(head)->lock)

Write locks a list.

Parameters:
head This is a pointer to the list head structure
This macro attempts to place an exclusive write lock in the list head structure pointed to by head. Returns non-zero on success, 0 on failure

Definition at line 1685 of file extconf.c.

#define AST_RWLOCK_DEFINE_STATIC ( rwlock   )     __AST_RWLOCK_DEFINE(static, rwlock)

Definition at line 581 of file extconf.c.

#define ast_set2_flag ( p,
value,
flag   ) 

Definition at line 735 of file extconf.c.

#define ast_strdup ( str   )     _ast_strdup((str), __FILE__, __LINE__, __PRETTY_FUNCTION__)

A wrapper for strdup().

ast_strdup() is a wrapper for strdup() that will generate an Asterisk log message in the case that the allocation fails.

ast_strdup(), unlike strdup(), can safely accept a NULL argument. If a NULL argument is provided, ast_strdup will return NULL without generating any kind of error log message.

The argument and return value are the same as strdup()

Definition at line 843 of file extconf.c.

#define ast_strdup ( str   )     _ast_strdup((str), __FILE__, __LINE__, __PRETTY_FUNCTION__)

A wrapper for strdup().

ast_strdup() is a wrapper for strdup() that will generate an Asterisk log message in the case that the allocation fails.

ast_strdup(), unlike strdup(), can safely accept a NULL argument. If a NULL argument is provided, ast_strdup will return NULL without generating any kind of error log message.

The argument and return value are the same as strdup()

Definition at line 843 of file extconf.c.

#define ast_strdupa (  ) 

duplicate a string in memory from the stack

Parameters:
s The string to duplicate
This macro will duplicate the given string. It returns a pointer to the stack allocatted memory for the new string.

Definition at line 948 of file extconf.c.

#define ast_strndup ( str,
len   )     _ast_strndup((str), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)

A wrapper for strndup().

ast_strndup() is a wrapper for strndup() that will generate an Asterisk log message in the case that the allocation fails.

ast_strndup(), unlike strndup(), can safely accept a NULL argument for the string to duplicate. If a NULL argument is provided, ast_strdup will return NULL without generating any kind of error log message.

The arguments and return value are the same as strndup()

Definition at line 872 of file extconf.c.

#define ast_strndup ( str,
len   )     _ast_strndup((str), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)

A wrapper for strndup().

ast_strndup() is a wrapper for strndup() that will generate an Asterisk log message in the case that the allocation fails.

ast_strndup(), unlike strndup(), can safely accept a NULL argument for the string to duplicate. If a NULL argument is provided, ast_strdup will return NULL without generating any kind of error log message.

The arguments and return value are the same as strndup()

Definition at line 872 of file extconf.c.

#define ast_test_flag ( p,
flag   ) 

Definition at line 728 of file extconf.c.

#define ast_vasprintf ( ret,
fmt,
ap   )     _ast_vasprintf((ret), __FILE__, __LINE__, __PRETTY_FUNCTION__, (fmt), (ap))

A wrapper for vasprintf().

ast_vasprintf() is a wrapper for vasprintf() that will generate an Asterisk log message in the case that the allocation fails.

The arguments and return value are the same as vasprintf()

Definition at line 924 of file extconf.c.

#define ast_vasprintf ( ret,
fmt,
ap   )     _ast_vasprintf((ret), __FILE__, __LINE__, __PRETTY_FUNCTION__, (fmt), (ap))

A wrapper for vasprintf().

ast_vasprintf() is a wrapper for vasprintf() that will generate an Asterisk log message in the case that the allocation fails.

The arguments and return value are the same as vasprintf()

Definition at line 924 of file extconf.c.

#define BACKGROUND_MATCHEXTEN   (1 << 2)

Definition at line 2599 of file extconf.c.

#define BACKGROUND_NOANSWER   (1 << 1)

Definition at line 2598 of file extconf.c.

#define BACKGROUND_PLAYBACK   (1 << 3)

Definition at line 2600 of file extconf.c.

#define BACKGROUND_SKIP   (1 << 0)

Definition at line 2597 of file extconf.c.

#define CB_INCR   250

Definition at line 977 of file extconf.c.

Referenced by CB_ADD(), CB_ADD_LEN(), CB_INIT(), and LLB_ADD().

#define COMMENT_END   "--;"

Definition at line 964 of file extconf.c.

#define COMMENT_META   ';'

Definition at line 965 of file extconf.c.

#define COMMENT_START   ";--"

Definition at line 963 of file extconf.c.

#define COMMENT_TAG   '-'

Definition at line 966 of file extconf.c.

#define DEBUG_M ( a   ) 

Value:

{ \
   a; \
}

Definition at line 106 of file extconf.c.

#define EVENTLOG   "event_log"

Definition at line 103 of file extconf.c.

#define EXT_DATA_SIZE   8192

Definition at line 3901 of file extconf.c.

#define gethostbyname   __gethostbyname__is__not__reentrant__use__ast_gethostbyname__instead__

Definition at line 521 of file extconf.c.

#define LOG_DEBUG   __LOG_DEBUG, _A_

Definition at line 134 of file extconf.c.

#define LOG_DTMF   __LOG_DTMF, _A_

Definition at line 170 of file extconf.c.

#define LOG_ERROR   __LOG_ERROR, _A_

Definition at line 158 of file extconf.c.

#define LOG_EVENT   __LOG_EVENT, _A_

Definition at line 140 of file extconf.c.

#define LOG_NOTICE   __LOG_NOTICE, _A_

Definition at line 146 of file extconf.c.

#define LOG_VERBOSE   __LOG_VERBOSE, _A_

Definition at line 164 of file extconf.c.

#define LOG_WARNING   __LOG_WARNING, _A_

Definition at line 152 of file extconf.c.

#define MALLOC_FAILURE_MSG   ast_log(LOG_ERROR, "Memory Allocation Failure in function %s at line %d of %s\n", func, lineno, file);

Definition at line 747 of file extconf.c.

#define MALLOC_FAILURE_MSG   ast_log(LOG_ERROR, "Memory Allocation Failure in function %s at line %d of %s\n", func, lineno, file);

Definition at line 747 of file extconf.c.

#define MAX_INCLUDE_LEVEL   10

Definition at line 1161 of file extconf.c.

#define MAX_NESTED_COMMENTS   128

Definition at line 962 of file extconf.c.

#define ONE_MILLION   1000000

Definition at line 2533 of file extconf.c.

#define PRIORITY_HINT   -1

Special Priority for a hint

Definition at line 2354 of file extconf.c.

#define pthread_cond_t   use_ast_cond_t_instead_of_pthread_cond_t

Definition at line 515 of file extconf.c.

#define pthread_create   __use_ast_pthread_create_instead__

Definition at line 524 of file extconf.c.

#define pthread_mutex_init   use_ast_mutex_init_instead_of_pthread_mutex_init

Definition at line 514 of file extconf.c.

#define PTHREAD_MUTEX_INIT_VALUE   PTHREAD_MUTEX_INITIALIZER

Definition at line 206 of file extconf.c.

#define pthread_mutex_t   use_ast_mutex_t_instead_of_pthread_mutex_t

Definition at line 513 of file extconf.c.

#define QUEUELOG   "queue_log"

Definition at line 104 of file extconf.c.

#define S_OR ( a,
b   )     (!ast_strlen_zero(a) ? (a) : (b))

Definition at line 1223 of file extconf.c.

#define STATUS_NO_CONTEXT   1

Definition at line 2721 of file extconf.c.

#define STATUS_NO_EXTENSION   2

Definition at line 2722 of file extconf.c.

#define STATUS_NO_LABEL   4

Definition at line 2724 of file extconf.c.

#define STATUS_NO_PRIORITY   3

Definition at line 2723 of file extconf.c.

#define STATUS_SUCCESS   5

Definition at line 2725 of file extconf.c.

#define SWITCH_DATA_LENGTH   256

Definition at line 3908 of file extconf.c.

#define VAR_BUF_SIZE   4096

Definition at line 2591 of file extconf.c.

#define VAR_HARDTRAN   3

Definition at line 2595 of file extconf.c.

#define VAR_NORMAL   1

Definition at line 2593 of file extconf.c.

#define VAR_SOFTTRAN   2

Definition at line 2594 of file extconf.c.

#define VERBOSE_PREFIX_1   " "

Definition at line 110 of file extconf.c.

#define VERBOSE_PREFIX_2   " == "

Definition at line 111 of file extconf.c.

#define VERBOSE_PREFIX_3   " -- "

Definition at line 112 of file extconf.c.

#define VERBOSE_PREFIX_4   " > "

Definition at line 113 of file extconf.c.

#define WRAP_LIBC_MALLOC

Definition at line 46 of file extconf.c.


Typedef Documentation

typedef pthread_cond_t ast_cond_t

Definition at line 494 of file extconf.c.

typedef pthread_mutex_t ast_mutex_t

Definition at line 478 of file extconf.c.

typedef pthread_rwlock_t ast_rwlock_t

Definition at line 527 of file extconf.c.

typedef int(* ast_state_cb_type)(char *context, char *id, enum ast_extension_states state, void *data)

Definition at line 2625 of file extconf.c.

typedef int( ast_switch_f)(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)

Definition at line 2377 of file extconf.c.

typedef struct ast_config* config_load_func(const char *database, const char *table, const char *configfile, struct ast_config *config, int withcomments, const char *suggested_include_file)

Definition at line 1199 of file extconf.c.

typedef struct ast_config* realtime_multi_get(const char *database, const char *table, va_list ap)

Definition at line 1201 of file extconf.c.

typedef int realtime_update(const char *database, const char *table, const char *keyfield, const char *entity, va_list ap)

Definition at line 1202 of file extconf.c.

typedef struct ast_variable* realtime_var_get(const char *database, const char *table, va_list ap)

Definition at line 1200 of file extconf.c.


Enumeration Type Documentation

Enumerator:
AST_EXTENSION_REMOVED  Extension removed
AST_EXTENSION_DEACTIVATED  Extension hint removed
AST_EXTENSION_NOT_INUSE  No device INUSE or BUSY
AST_EXTENSION_INUSE  One or more devices INUSE
AST_EXTENSION_BUSY  All devices BUSY
AST_EXTENSION_UNAVAILABLE  All devices UNAVAILABLE/UNREGISTERED
AST_EXTENSION_RINGING  All devices RINGING
AST_EXTENSION_ONHOLD  All devices ONHOLD
AST_EXTENSION_REMOVED  Extension removed
AST_EXTENSION_DEACTIVATED  Extension hint removed
AST_EXTENSION_NOT_INUSE  No device INUSE or BUSY
AST_EXTENSION_INUSE  One or more devices INUSE
AST_EXTENSION_BUSY  All devices BUSY
AST_EXTENSION_UNAVAILABLE  All devices UNAVAILABLE/UNREGISTERED
AST_EXTENSION_RINGING  All devices RINGING
AST_EXTENSION_ONHOLD  All devices ONHOLD

Definition at line 2356 of file extconf.c.

02356                           {
02357    AST_EXTENSION_REMOVED = -2,   /*!< Extension removed */
02358    AST_EXTENSION_DEACTIVATED = -1,  /*!< Extension hint removed */
02359    AST_EXTENSION_NOT_INUSE = 0,  /*!< No device INUSE or BUSY  */
02360    AST_EXTENSION_INUSE = 1 << 0, /*!< One or more devices INUSE */
02361    AST_EXTENSION_BUSY = 1 << 1,  /*!< All devices BUSY */
02362    AST_EXTENSION_UNAVAILABLE = 1 << 2, /*!< All devices UNAVAILABLE/UNREGISTERED */
02363    AST_EXTENSION_RINGING = 1 << 3,  /*!< All devices RINGING */
02364    AST_EXTENSION_ONHOLD = 1 << 4,   /*!< All devices ONHOLD */
02365 };

Enumerator:
AST_OPT_FLAG_EXEC_INCLUDES  Allow #exec in config files
AST_OPT_FLAG_NO_FORK  Do not fork()
AST_OPT_FLAG_QUIET  Keep quiet
AST_OPT_FLAG_CONSOLE  Console mode
AST_OPT_FLAG_HIGH_PRIORITY  Run in realtime Linux priority
AST_OPT_FLAG_INIT_KEYS  Initialize keys for RSA authentication
AST_OPT_FLAG_REMOTE  Remote console
AST_OPT_FLAG_EXEC  Execute an asterisk CLI command upon startup
AST_OPT_FLAG_NO_COLOR  Don't use termcap colors
AST_OPT_FLAG_FULLY_BOOTED  Are we fully started yet?
AST_OPT_FLAG_TRANSCODE_VIA_SLIN  Trascode via signed linear
AST_OPT_FLAG_STDEXTEN_MACRO  Invoke the stdexten using the legacy macro method.
AST_OPT_FLAG_DUMP_CORE  Dump core on a seg fault
AST_OPT_FLAG_CACHE_RECORD_FILES  Cache sound files
AST_OPT_FLAG_TIMESTAMP  Display timestamp in CLI verbose output
AST_OPT_FLAG_OVERRIDE_CONFIG  Override config
AST_OPT_FLAG_RECONNECT  Reconnect
AST_OPT_FLAG_TRANSMIT_SILENCE  Transmit Silence during Record() and DTMF Generation
AST_OPT_FLAG_DONT_WARN  Suppress some warnings
AST_OPT_FLAG_END_CDR_BEFORE_H_EXTEN  End CDRs before the 'h' extension
AST_OPT_FLAG_ALWAYS_FORK  Always fork, even if verbose or debug settings are non-zero
AST_OPT_FLAG_MUTE  Disable log/verbose output to remote consoles
AST_OPT_FLAG_DEBUG_MODULE  There is a per-module debug setting
AST_OPT_FLAG_VERBOSE_MODULE  There is a per-module verbose setting
AST_OPT_FLAG_LIGHT_BACKGROUND  Terminal colors should be adjusted for a light-colored background
AST_OPT_FLAG_INITIATED_SECONDS  Count Initiated seconds in CDR's
AST_OPT_FLAG_FORCE_BLACK_BACKGROUND  Force black background
AST_OPT_FLAG_HIDE_CONSOLE_CONNECT  Hide remote console connect messages on console
AST_OPT_FLAG_LOCK_CONFIG_DIR  Protect the configuration file path with a lock
AST_OPT_FLAG_GENERIC_PLC  Generic PLC
AST_OPT_FLAG_EXEC_INCLUDES  Allow #exec in config files
AST_OPT_FLAG_NO_FORK  Do not fork()
AST_OPT_FLAG_QUIET  Keep quiet
AST_OPT_FLAG_CONSOLE  Console mode
AST_OPT_FLAG_HIGH_PRIORITY  Run in realtime Linux priority
AST_OPT_FLAG_INIT_KEYS  Initialize keys for RSA authentication
AST_OPT_FLAG_REMOTE  Remote console
AST_OPT_FLAG_EXEC  Execute an asterisk CLI command upon startup
AST_OPT_FLAG_NO_COLOR  Don't use termcap colors
AST_OPT_FLAG_FULLY_BOOTED  Are we fully started yet?
AST_OPT_FLAG_TRANSCODE_VIA_SLIN  Trascode via signed linear
AST_OPT_FLAG_DUMP_CORE  Dump core on a seg fault
AST_OPT_FLAG_CACHE_RECORD_FILES  Cache sound files
AST_OPT_FLAG_TIMESTAMP  Display timestamp in CLI verbose output
AST_OPT_FLAG_OVERRIDE_CONFIG  Override config
AST_OPT_FLAG_RECONNECT  Reconnect
AST_OPT_FLAG_TRANSMIT_SILENCE  Transmit Silence during Record() and DTMF Generation
AST_OPT_FLAG_DONT_WARN  Suppress some warnings
AST_OPT_FLAG_END_CDR_BEFORE_H_EXTEN  End CDRs before the 'h' extension
AST_OPT_FLAG_ALWAYS_FORK  Always fork, even if verbose or debug settings are non-zero
AST_OPT_FLAG_MUTE  Disable log/verbose output to remote consoles
AST_OPT_FLAG_DEBUG_FILE  There is a per-file debug setting
AST_OPT_FLAG_VERBOSE_FILE  There is a per-file verbose setting
AST_OPT_FLAG_LIGHT_BACKGROUND  Terminal colors should be adjusted for a light-colored background
AST_OPT_FLAG_INITIATED_SECONDS  Count Initiated seconds in CDR's
AST_OPT_FLAG_FORCE_BLACK_BACKGROUND  Force black background

Definition at line 1573 of file extconf.c.

01573                       {
01574    /*! Allow \#exec in config files */
01575    AST_OPT_FLAG_EXEC_INCLUDES = (1 << 0),
01576    /*! Do not fork() */
01577    AST_OPT_FLAG_NO_FORK = (1 << 1),
01578    /*! Keep quiet */
01579    AST_OPT_FLAG_QUIET = (1 << 2),
01580    /*! Console mode */
01581    AST_OPT_FLAG_CONSOLE = (1 << 3),
01582    /*! Run in realtime Linux priority */
01583    AST_OPT_FLAG_HIGH_PRIORITY = (1 << 4),
01584    /*! Initialize keys for RSA authentication */
01585    AST_OPT_FLAG_INIT_KEYS = (1 << 5),
01586    /*! Remote console */
01587    AST_OPT_FLAG_REMOTE = (1 << 6),
01588    /*! Execute an asterisk CLI command upon startup */
01589    AST_OPT_FLAG_EXEC = (1 << 7),
01590    /*! Don't use termcap colors */
01591    AST_OPT_FLAG_NO_COLOR = (1 << 8),
01592    /*! Are we fully started yet? */
01593    AST_OPT_FLAG_FULLY_BOOTED = (1 << 9),
01594    /*! Trascode via signed linear */
01595    AST_OPT_FLAG_TRANSCODE_VIA_SLIN = (1 << 10),
01596    /*! Dump core on a seg fault */
01597    AST_OPT_FLAG_DUMP_CORE = (1 << 12),
01598    /*! Cache sound files */
01599    AST_OPT_FLAG_CACHE_RECORD_FILES = (1 << 13),
01600    /*! Display timestamp in CLI verbose output */
01601    AST_OPT_FLAG_TIMESTAMP = (1 << 14),
01602    /*! Override config */
01603    AST_OPT_FLAG_OVERRIDE_CONFIG = (1 << 15),
01604    /*! Reconnect */
01605    AST_OPT_FLAG_RECONNECT = (1 << 16),
01606    /*! Transmit Silence during Record() and DTMF Generation */
01607    AST_OPT_FLAG_TRANSMIT_SILENCE = (1 << 17),
01608    /*! Suppress some warnings */
01609    AST_OPT_FLAG_DONT_WARN = (1 << 18),
01610    /*! End CDRs before the 'h' extension */
01611    AST_OPT_FLAG_END_CDR_BEFORE_H_EXTEN = (1 << 19),
01612    /*! Always fork, even if verbose or debug settings are non-zero */
01613    AST_OPT_FLAG_ALWAYS_FORK = (1 << 21),
01614    /*! Disable log/verbose output to remote consoles */
01615    AST_OPT_FLAG_MUTE = (1 << 22),
01616    /*! There is a per-file debug setting */
01617    AST_OPT_FLAG_DEBUG_FILE = (1 << 23),
01618    /*! There is a per-file verbose setting */
01619    AST_OPT_FLAG_VERBOSE_FILE = (1 << 24),
01620    /*! Terminal colors should be adjusted for a light-colored background */
01621    AST_OPT_FLAG_LIGHT_BACKGROUND = (1 << 25),
01622    /*! Count Initiated seconds in CDR's */
01623    AST_OPT_FLAG_INITIATED_SECONDS = (1 << 26),
01624    /*! Force black background */
01625    AST_OPT_FLAG_FORCE_BLACK_BACKGROUND = (1 << 27),
01626 };


Function Documentation

static struct ast_context* __ast_context_create ( struct ast_context **  extcontexts,
const char *  name,
const char *  registrar,
int  existsokay 
) [static, read]

Definition at line 4949 of file extconf.c.

References ast_calloc, ast_log, ast_mutex_init, ast_rwlock_init, ast_unlock_contexts(), ast_verbose, ast_wrlock_contexts(), ast_context::ignorepats, ast_context::includes, ast_context::lock, LOG_DEBUG, LOG_WARNING, ast_context::macrolock, ast_context::name, ast_context::next, NULL, ast_context::registrar, ast_context::root, and VERBOSE_PREFIX_3.

Referenced by ast_context_find_or_create(), and localized_context_find_or_create().

04950 {
04951    struct ast_context *tmp, **loc_contexts;
04952    int length = sizeof(struct ast_context) + strlen(name) + 1;
04953 
04954    if (!extcontexts) {
04955       ast_wrlock_contexts();
04956       loc_contexts = &contexts;
04957    } else
04958       loc_contexts = extcontexts;
04959 
04960    for (tmp = *loc_contexts; tmp; tmp = tmp->next) {
04961       if (!strcasecmp(tmp->name, name)) {
04962          if (!existsokay) {
04963             ast_log(LOG_WARNING, "Tried to register context '%s', already in use\n", name);
04964             tmp = NULL;
04965          }
04966          if (!extcontexts)
04967             ast_unlock_contexts();
04968          return tmp;
04969       }
04970    }
04971    if ((tmp = ast_calloc(1, length))) {
04972       ast_rwlock_init(&tmp->lock);
04973       ast_mutex_init(&tmp->macrolock);
04974       strcpy(tmp->name, name);
04975       tmp->root = NULL;
04976       tmp->registrar = registrar;
04977       tmp->next = *loc_contexts;
04978       tmp->includes = NULL;
04979       tmp->ignorepats = NULL;
04980       *loc_contexts = tmp;
04981       if (option_debug)
04982          ast_log(LOG_DEBUG, "Registered context '%s'\n", tmp->name);
04983       if (option_verbose > 2)
04984          ast_verbose( VERBOSE_PREFIX_3 "Registered extension context '%s'\n", tmp->name);
04985    }
04986 
04987    if (!extcontexts)
04988       ast_unlock_contexts();
04989    return tmp;
04990 }

static void __ast_context_destroy ( struct ast_context con,
const char *  registrar 
) [static]

Definition at line 5745 of file extconf.c.

References AST_LIST_REMOVE_HEAD, ast_log, ast_rwlock_destroy, ast_unlock_context(), ast_wrlock_context(), destroy_exten(), el, free, LOG_DEBUG, ast_context::name, ast_exten::next, ast_ignorepat::next, ast_include::next, ast_context::next, ast_custom_function::next, NULL, and ast_exten::peer.

05746 {
05747    struct ast_context *tmp, *tmpl=NULL;
05748    struct ast_include *tmpi;
05749    struct ast_sw *sw;
05750    struct ast_exten *e, *el, *en;
05751    struct ast_ignorepat *ipi;
05752 
05753    for (tmp = contexts; tmp; ) {
05754       struct ast_context *next;  /* next starting point */
05755       for (; tmp; tmpl = tmp, tmp = tmp->next) {
05756          if (option_debug)
05757             ast_log(LOG_DEBUG, "check ctx %s %s\n", tmp->name, tmp->registrar);
05758          if ( (!registrar || !strcasecmp(registrar, tmp->registrar)) &&
05759               (!con || !strcasecmp(tmp->name, con->name)) )
05760             break;   /* found it */
05761       }
05762       if (!tmp)   /* not found, we are done */
05763          break;
05764       ast_wrlock_context(tmp);
05765       if (option_debug)
05766          ast_log(LOG_DEBUG, "delete ctx %s %s\n", tmp->name, tmp->registrar);
05767       next = tmp->next;
05768       if (tmpl)
05769          tmpl->next = next;
05770       else
05771          contexts = next;
05772       /* Okay, now we're safe to let it go -- in a sense, we were
05773          ready to let it go as soon as we locked it. */
05774       ast_unlock_context(tmp);
05775       for (tmpi = tmp->includes; tmpi; ) { /* Free includes */
05776          struct ast_include *tmpil = tmpi;
05777          tmpi = tmpi->next;
05778          free(tmpil);
05779       }
05780       for (ipi = tmp->ignorepats; ipi; ) { /* Free ignorepats */
05781          struct ast_ignorepat *ipl = ipi;
05782          ipi = ipi->next;
05783          free(ipl);
05784       }
05785       while ((sw = AST_LIST_REMOVE_HEAD(&tmp->alts, list)))
05786          free(sw);
05787       for (e = tmp->root; e;) {
05788          for (en = e->peer; en;) {
05789             el = en;
05790             en = en->peer;
05791             destroy_exten(el);
05792          }
05793          el = e;
05794          e = e->next;
05795          destroy_exten(el);
05796       }
05797       ast_rwlock_destroy(&tmp->lock);
05798       free(tmp);
05799       /* if we have a specific match, we are done, otherwise continue */
05800       tmp = con ? NULL : next;
05801    }
05802 }

int _ast_asprintf ( char **  ret,
const char *  file,
int  lineno,
const char *  func,
const char *  fmt,
  ... 
) [inline]

Definition at line 2606 of file main/utils.c.

References MALLOC_FAILURE_MSG, and vasprintf.

02607 {
02608    int res;
02609    va_list ap;
02610 
02611    va_start(ap, fmt);
02612    if ((res = vasprintf(ret, fmt, ap)) == -1) {
02613       MALLOC_FAILURE_MSG;
02614    }
02615    va_end(ap);
02616 
02617    return res;
02618 }

void* _ast_calloc ( size_t  num,
size_t  len,
const char *  file,
int  lineno,
const char *  func 
)

void* _ast_malloc ( size_t  len,
const char *  file,
int  lineno,
const char *  func 
)

void* _ast_realloc ( void *  p,
size_t  len,
const char *  file,
int  lineno,
const char *  func 
)

char* _ast_strdup ( const char *  str,
const char *  file,
int  lineno,
const char *  func 
)

char* _ast_strndup ( const char *  str,
size_t  len,
const char *  file,
int  lineno,
const char *  func 
)

int _ast_vasprintf ( char **  ret,
const char *  file,
int  lineno,
const char *  func,
const char *  fmt,
va_list  ap 
)

static int _extension_match_core ( const char *  pattern,
const char *  data,
enum ext_match_t  mode 
) [static]

Definition at line 4438 of file extconf.c.

References ast_log, E_MATCH, E_MATCH_MASK, E_MATCHMORE, end, LOG_WARNING, and NULL.

04439 {
04440    mode &= E_MATCH_MASK;   /* only consider the relevant bits */
04441 
04442    if ( (mode == E_MATCH) && (pattern[0] == '_') && (strcasecmp(pattern,data)==0) ) /* note: if this test is left out, then _x. will not match _x. !!! */
04443       return 1;
04444 
04445    if (pattern[0] != '_') { /* not a pattern, try exact or partial match */
04446       int ld = strlen(data), lp = strlen(pattern);
04447 
04448       if (lp < ld)      /* pattern too short, cannot match */
04449          return 0;
04450       /* depending on the mode, accept full or partial match or both */
04451       if (mode == E_MATCH)
04452          return !strcmp(pattern, data); /* 1 on match, 0 on fail */
04453       if (ld == 0 || !strncasecmp(pattern, data, ld)) /* partial or full match */
04454          return (mode == E_MATCHMORE) ? lp > ld : 1; /* XXX should consider '!' and '/' ? */
04455       else
04456          return 0;
04457    }
04458    pattern++; /* skip leading _ */
04459    /*
04460     * XXX below we stop at '/' which is a separator for the CID info. However we should
04461     * not store '/' in the pattern at all. When we insure it, we can remove the checks.
04462     */
04463    while (*data && *pattern && *pattern != '/') {
04464       const char *end;
04465 
04466       if (*data == '-') { /* skip '-' in data (just a separator) */
04467          data++;
04468          continue;
04469       }
04470       switch (toupper(*pattern)) {
04471       case '[':   /* a range */
04472          end = strchr(pattern+1, ']'); /* XXX should deal with escapes ? */
04473          if (end == NULL) {
04474             ast_log(LOG_WARNING, "Wrong usage of [] in the extension\n");
04475             return 0;   /* unconditional failure */
04476          }
04477          for (pattern++; pattern != end; pattern++) {
04478             if (pattern+2 < end && pattern[1] == '-') { /* this is a range */
04479                if (*data >= pattern[0] && *data <= pattern[2])
04480                   break;   /* match found */
04481                else {
04482                   pattern += 2; /* skip a total of 3 chars */
04483                   continue;
04484                }
04485             } else if (*data == pattern[0])
04486                break;   /* match found */
04487          }
04488          if (pattern == end)
04489             return 0;
04490          pattern = end; /* skip and continue */
04491          break;
04492       case 'N':
04493          if (*data < '2' || *data > '9')
04494             return 0;
04495          break;
04496       case 'X':
04497          if (*data < '0' || *data > '9')
04498             return 0;
04499          break;
04500       case 'Z':
04501          if (*data < '1' || *data > '9')
04502             return 0;
04503          break;
04504       case '.':   /* Must match, even with more digits */
04505          return 1;
04506       case '!':   /* Early match */
04507          return 2;
04508       case ' ':
04509       case '-':   /* Ignore these in patterns */
04510          data--; /* compensate the final data++ */
04511          break;
04512       default:
04513          if (*data != *pattern)
04514             return 0;
04515       }
04516       data++;
04517       pattern++;
04518    }
04519    if (*data)        /* data longer than pattern, no match */
04520       return 0;
04521    /*
04522     * match so far, but ran off the end of the data.
04523     * Depending on what is next, determine match or not.
04524     */
04525    if (*pattern == '\0' || *pattern == '/')  /* exact match */
04526       return (mode == E_MATCHMORE) ? 0 : 1;  /* this is a failure for E_MATCHMORE */
04527    else if (*pattern == '!')        /* early match */
04528       return 2;
04529    else                 /* partial match */
04530       return (mode == E_MATCH) ? 0 : 1;   /* this is a failure for E_MATCH */
04531 }

static void _null_sig_handler ( int  sig  )  [static]

NULL handler so we can collect the child exit status.

Definition at line 1055 of file extconf.c.

01056 {
01057 
01058 }

static int add_pri ( struct ast_context con,
struct ast_exten tmp,
struct ast_exten el,
struct ast_exten e,
int  replace 
) [static]

add the extension in the priority chain. returns 0 on success, -1 on failure

Definition at line 3973 of file extconf.c.

References ast_add_hint(), ast_change_hint(), ast_log, ast_exten::data, ast_exten::datad, ast_exten::exten, free, LOG_WARNING, ast_context::name, ast_exten::next, NULL, ast_exten::peer, ast_exten::priority, PRIORITY_HINT, and ast_context::root.

Referenced by ast_add_extension2().

03975 {
03976    struct ast_exten *ep;
03977 
03978    for (ep = NULL; e ; ep = e, e = e->peer) {
03979       if (e->priority >= tmp->priority)
03980          break;
03981    }
03982    if (!e) {   /* go at the end, and ep is surely set because the list is not empty */
03983       ep->peer = tmp;
03984       return 0;   /* success */
03985    }
03986    if (e->priority == tmp->priority) {
03987       /* Can't have something exactly the same.  Is this a
03988          replacement?  If so, replace, otherwise, bonk. */
03989       if (!replace) {
03990          ast_log(LOG_WARNING, "Unable to register extension '%s', priority %d in '%s', already in use\n", tmp->exten, tmp->priority, con->name);
03991          tmp->datad(tmp->data);
03992          free(tmp);
03993          return -1;
03994       }
03995       /* we are replacing e, so copy the link fields and then update
03996        * whoever pointed to e to point to us
03997        */
03998       tmp->next = e->next; /* not meaningful if we are not first in the peer list */
03999       tmp->peer = e->peer; /* always meaningful */
04000       if (ep)        /* We're in the peer list, just insert ourselves */
04001          ep->peer = tmp;
04002       else if (el)      /* We're the first extension. Take over e's functions */
04003          el->next = tmp;
04004       else        /* We're the very first extension.  */
04005          con->root = tmp;
04006       if (tmp->priority == PRIORITY_HINT)
04007          ast_change_hint(e,tmp);
04008       /* Destroy the old one */
04009       e->datad(e->data);
04010       free(e);
04011    } else { /* Slip ourselves in just before e */
04012       tmp->peer = e;
04013       tmp->next = e->next; /* extension chain, or NULL if e is not the first extension */
04014       if (ep)        /* Easy enough, we're just in the peer list */
04015          ep->peer = tmp;
04016       else {         /* we are the first in some peer list, so link in the ext list */
04017          if (el)
04018             el->next = tmp;   /* in the middle... */
04019          else
04020             con->root = tmp; /* ... or at the head */
04021          e->next = NULL;   /* e is no more at the head, so e->next must be reset */
04022       }
04023       /* And immediately return success. */
04024       if (tmp->priority == PRIORITY_HINT)
04025           ast_add_hint(tmp);
04026    }
04027    return 0;
04028 }

static struct ast_comment* ALLOC_COMMENT ( const char *  buffer  )  [static, read]

Definition at line 1143 of file extconf.c.

References ast_calloc, and ast_comment::cmt.

01144 { 
01145    struct ast_comment *x = ast_calloc(1,sizeof(struct ast_comment)+strlen(buffer)+1);
01146    strcpy(x->cmt, buffer);
01147    return x;
01148 }

static int ast_add_extension2 ( struct ast_context con,
int  replace,
const char *  extension,
int  priority,
const char *  label,
const char *  callerid,
const char *  application,
void *  data,
void(*)(void *)  datad,
const char *  registrar 
) [static]

Main interface to add extensions to the list for out context.

We sort extensions in order of matching preference, so that we can stop the search as soon as we find a suitable match. This ordering also takes care of wildcards such as '.' (meaning "one or more of any character") and '!' (which is 'earlymatch', meaning "zero or more of any character" but also impacts the return value from CANMATCH and EARLYMATCH.

The extension match rules defined in the devmeeting 2006.05.05 are quite simple: WE SELECT THE LONGEST MATCH. In detail, "longest" means the number of matched characters in the extension. In case of ties (e.g. _XXX and 333) in the length of a pattern, we give priority to entries with the smallest cardinality (e.g, [5-9] comes before [2-8] before the former has only 5 elements, while the latter has 7, etc. In case of same cardinality, the first element in the range counts. If we still have a tie, any final '!' will make this as a possibly less specific pattern.

EBUSY - can't lock EEXIST - extension with the same priority exist and no replace is set

Definition at line 5017 of file extconf.c.

References add_pri(), ast_exten::app, ast_add_hint(), ast_calloc, ast_log, ast_verbose, ast_exten::cidmatch, ast_exten::data, ast_exten::datad, el, errno, ext_cmp(), ext_strncpy(), ast_exten::exten, ast_exten::label, LOG_DEBUG, ast_exten::matchcid, ast_context::name, ast_exten::next, NULL, null_datad(), ast_exten::parent, ast_exten::priority, PRIORITY_HINT, ast_exten::registrar, ast_context::root, ast_exten::stuff, and VERBOSE_PREFIX_3.

05021 {
05022    /*
05023     * Sort extensions (or patterns) according to the rules indicated above.
05024     * These are implemented by the function ext_cmp()).
05025     * All priorities for the same ext/pattern/cid are kept in a list,
05026     * using the 'peer' field  as a link field..
05027     */
05028    struct ast_exten *tmp, *e, *el = NULL;
05029    int res;
05030    int length;
05031    char *p;
05032 
05033    /* if we are adding a hint, and there are global variables, and the hint
05034       contains variable references, then expand them --- NOT In this situation!!!
05035    */
05036 
05037    length = sizeof(struct ast_exten);
05038    length += strlen(extension) + 1;
05039    length += strlen(application) + 1;
05040    if (label)
05041       length += strlen(label) + 1;
05042    if (callerid)
05043       length += strlen(callerid) + 1;
05044    else
05045       length ++;  /* just the '\0' */
05046 
05047    /* Be optimistic:  Build the extension structure first */
05048    if (datad == NULL)
05049       datad = null_datad;
05050    if (!(tmp = ast_calloc(1, length)))
05051       return -1;
05052 
05053    /* use p as dst in assignments, as the fields are const char * */
05054    p = tmp->stuff;
05055    if (label) {
05056       tmp->label = p;
05057       strcpy(p, label);
05058       p += strlen(label) + 1;
05059    }
05060    tmp->exten = p;
05061    p += ext_strncpy(p, extension, strlen(extension) + 1) + 1;
05062    tmp->priority = priority;
05063    tmp->cidmatch = p;   /* but use p for assignments below */
05064    if (callerid) {
05065       p += ext_strncpy(p, callerid, strlen(callerid) + 1) + 1;
05066       tmp->matchcid = 1;
05067    } else {
05068       *p++ = '\0';
05069       tmp->matchcid = 0;
05070    }
05071    tmp->app = p;
05072    strcpy(p, application);
05073    tmp->parent = con;
05074    tmp->data = data;
05075    tmp->datad = datad;
05076    tmp->registrar = registrar;
05077 
05078    res = 0; /* some compilers will think it is uninitialized otherwise */
05079    for (e = con->root; e; el = e, e = e->next) {   /* scan the extension list */
05080       res = ext_cmp(e->exten, extension);
05081       if (res == 0) { /* extension match, now look at cidmatch */
05082          if (!e->matchcid && !tmp->matchcid)
05083             res = 0;
05084          else if (tmp->matchcid && !e->matchcid)
05085             res = 1;
05086          else if (e->matchcid && !tmp->matchcid)
05087             res = -1;
05088          else
05089             res = strcasecmp(e->cidmatch, tmp->cidmatch);
05090       }
05091       if (res >= 0)
05092          break;
05093    }
05094    if (e && res == 0) { /* exact match, insert in the pri chain */
05095       res = add_pri(con, tmp, el, e, replace);
05096       if (res < 0) {
05097          errno = EEXIST;   /* XXX do we care ? */
05098          return 0; /* XXX should we return -1 maybe ? */
05099       }
05100    } else {
05101       /*
05102        * not an exact match, this is the first entry with this pattern,
05103        * so insert in the main list right before 'e' (if any)
05104        */
05105       tmp->next = e;
05106       if (el)
05107          el->next = tmp;
05108       else
05109          con->root = tmp;
05110       if (tmp->priority == PRIORITY_HINT)
05111          ast_add_hint(tmp);
05112    }
05113    if (option_debug) {
05114       if (tmp->matchcid) {
05115          ast_log(LOG_DEBUG, "Added extension '%s' priority %d (CID match '%s') to %s\n",
05116             tmp->exten, tmp->priority, tmp->cidmatch, con->name);
05117       } else {
05118          ast_log(LOG_DEBUG, "Added extension '%s' priority %d to %s\n",
05119             tmp->exten, tmp->priority, con->name);
05120       }
05121    }
05122    if (option_verbose > 2) {
05123       if (tmp->matchcid) {
05124          ast_verbose( VERBOSE_PREFIX_3 "Added extension '%s' priority %d (CID match '%s')to %s\n",
05125             tmp->exten, tmp->priority, tmp->cidmatch, con->name);
05126       } else {
05127          ast_verbose( VERBOSE_PREFIX_3 "Added extension '%s' priority %d to %s\n",
05128             tmp->exten, tmp->priority, con->name);
05129       }
05130    }
05131    return 0;
05132 }

static int ast_add_hint ( struct ast_exten e  )  [static]

ast_add_hint: Add hint to hint list, check initial extension state

Definition at line 3940 of file extconf.c.

References ast_calloc, ast_get_extension_app(), ast_get_extension_name(), ast_log, AST_RWLIST_INSERT_HEAD, AST_RWLIST_TRAVERSE, ast_hint::exten, and LOG_DEBUG.

03941 {
03942    struct ast_hint *hint;
03943 
03944    if (!e)
03945       return -1;
03946 
03947 
03948    /* Search if hint exists, do nothing */
03949    AST_RWLIST_TRAVERSE(&hints, hint, list) {
03950       if (hint->exten == e) {
03951          if (option_debug > 1)
03952             ast_log(LOG_DEBUG, "HINTS: Not re-adding existing hint %s: %s\n", ast_get_extension_name(e), ast_get_extension_app(e));
03953          return -1;
03954       }
03955    }
03956 
03957    if (option_debug > 1)
03958       ast_log(LOG_DEBUG, "HINTS: Adding hint %s: %s\n", ast_get_extension_name(e), ast_get_extension_app(e));
03959 
03960    if (!(hint = ast_calloc(1, sizeof(*hint)))) {
03961       return -1;
03962    }
03963    /* Initialize and insert new item at the top */
03964    hint->exten = e;
03965    AST_RWLIST_INSERT_HEAD(&hints, hint, list);
03966 
03967    return 0;
03968 }

static unsigned int ast_app_separate_args ( char *  buf,
char  delim,
char **  array,
int  arraylen 
) [static]

Definition at line 2759 of file extconf.c.

References paren, quote(), and scan().

02760 {
02761    int argc;
02762    char *scan;
02763    int paren = 0, quote = 0;
02764 
02765    if (!buf || !array || !arraylen)
02766       return 0;
02767 
02768    memset(array, 0, arraylen * sizeof(*array));
02769 
02770    scan = buf;
02771 
02772    for (argc = 0; *scan && (argc < arraylen - 1); argc++) {
02773       array[argc] = scan;
02774       for (; *scan; scan++) {
02775          if (*scan == '(')
02776             paren++;
02777          else if (*scan == ')') {
02778             if (paren)
02779                paren--;
02780          } else if (*scan == '"' && delim != '"') {
02781             quote = quote ? 0 : 1;
02782             /* Remove quote character from argument */
02783             memmove(scan, scan + 1, strlen(scan));
02784             scan--;
02785          } else if (*scan == '\\') {
02786             /* Literal character, don't parse */
02787             memmove(scan, scan + 1, strlen(scan));
02788          } else if ((*scan == delim) && !paren && !quote) {
02789             *scan++ = '\0';
02790             break;
02791          }
02792       }
02793    }
02794 
02795    if (*scan)
02796       array[argc++] = scan;
02797 
02798    return argc;
02799 }

int ast_atomic_dec_and_test ( volatile int *  p  ) 

decrement *p by 1 and return true if the variable has reached 0. Useful e.g. to check if a refcount has reached 0.

int ast_atomic_fetchadd_int ( volatile int *  p,
int  v 
)

static int ast_atomic_fetchadd_int_slow ( volatile int *  p,
int  v 
) [static]

Atomically add v to *p and return * the previous value of *p. This can be used to handle reference counts, and the return value can be used to generate unique identifiers.

Definition at line 627 of file extconf.c.

00628 {
00629    int ret;
00630    ret = *p;
00631    *p += v;
00632    return ret;
00633 }

int ast_build_timing ( struct ast_timing i,
const char *  info_in 
)

Construct a timing bitmap, for use in time-based conditionals.

/brief Build timing

/param i info /param info_in

Definition at line 9267 of file pbx.c.

References ast_strdup, ast_strdupa, ast_strlen_zero, ast_timing::daymask, days, ast_timing::dowmask, get_range(), get_timerange(), ast_timing::monthmask, months, NULL, strsep(), and ast_timing::timezone.

09268 {
09269    char *info;
09270    int j, num_fields, last_sep = -1;
09271 
09272    i->timezone = NULL;
09273 
09274    /* Check for empty just in case */
09275    if (ast_strlen_zero(info_in)) {
09276       return 0;
09277    }
09278 
09279    /* make a copy just in case we were passed a static string */
09280    info = ast_strdupa(info_in);
09281 
09282    /* count the number of fields in the timespec */
09283    for (j = 0, num_fields = 1; info[j] != '\0'; j++) {
09284       if (info[j] == ',') {
09285          last_sep = j;
09286          num_fields++;
09287       }
09288    }
09289 
09290    /* save the timezone, if it is specified */
09291    if (num_fields == 5) {
09292       i->timezone = ast_strdup(info + last_sep + 1);
09293    }
09294 
09295    /* Assume everything except time */
09296    i->monthmask = 0xfff;   /* 12 bits */
09297    i->daymask = 0x7fffffffU; /* 31 bits */
09298    i->dowmask = 0x7f; /* 7 bits */
09299    /* on each call, use strsep() to move info to the next argument */
09300    get_timerange(i, strsep(&info, "|,"));
09301    if (info)
09302       i->dowmask = get_range(strsep(&info, "|,"), 7, days, "day of week");
09303    if (info)
09304       i->daymask = get_range(strsep(&info, "|,"), 31, NULL, "day");
09305    if (info)
09306       i->monthmask = get_range(strsep(&info, "|,"), 12, months, "month");
09307    return 1;
09308 }

static void ast_category_append ( struct ast_config config,
struct ast_category category 
) [static]

Appends a category to a config.

Parameters:
config which config to use
cat category to insert

Definition at line 941 of file main/config.c.

References ast_config::current, ast_config::include_level, ast_category::include_level, ast_config::last, ast_category::next, NULL, ast_category::prev, and ast_config::root.

00942 {
00943    if (config->last) {
00944       config->last->next = category;
00945       category->prev = config->last;
00946    } else {
00947       config->root = category;
00948       category->prev = NULL;
00949    }
00950    category->next = NULL;
00951    category->include_level = config->include_level;
00952 
00953    config->last = category;
00954    config->current = category;
00955 }

static char* ast_category_browse ( struct ast_config config,
const char *  prev 
) [static]

Browse categories.

Parameters:
config Which config structure you wish to "browse"
prev_name A pointer to a previous category name.
This function is kind of non-intuitive in it's use. To begin, one passes NULL as the second argument. It will return a pointer to the string of the first category in the file. From here on after, one must then pass the previous usage's return value as the second pointer, and it will return a pointer to the category name afterwards.

Return values:
a category name on success
NULL on failure/no-more-categories
Note:
ast_category_browse maintains internal state. Therefore is not thread safe, cannot be called recursively, and it is not safe to add or remove categories while browsing. ast_category_browse_filtered does not have these restrictions.

Definition at line 1163 of file main/config.c.

References ast_config::last_browse, ast_category::name, ast_category::next, next_available_category(), NULL, and ast_config::root.

01164 {
01165    struct ast_category *cat;
01166 
01167    if (!prev) {
01168       /* First time browse. */
01169       cat = config->root;
01170    } else if (config->last_browse && (config->last_browse->name == prev)) {
01171       /* Simple last browse found. */
01172       cat = config->last_browse->next;
01173    } else {
01174       /*
01175        * Config changed since last browse.
01176        *
01177        * First try cheap last browse search. (Rebrowsing a different
01178        * previous category?)
01179        */
01180       for (cat = config->root; cat; cat = cat->next) {
01181          if (cat->name == prev) {
01182             /* Found it. */
01183             cat = cat->next;
01184             break;
01185          }
01186       }
01187       if (!cat) {
01188          /*
01189           * Have to do it the hard way. (Last category was deleted and
01190           * re-added?)
01191           */
01192          for (cat = config->root; cat; cat = cat->next) {
01193             if (!strcasecmp(cat->name, prev)) {
01194                /* Found it. */
01195                cat = cat->next;
01196                break;
01197             }
01198          }
01199       }
01200    }
01201 
01202    if (cat)
01203       cat = next_available_category(cat, NULL, NULL);
01204 
01205    config->last_browse = cat;
01206    return (cat) ? cat->name : NULL;
01207 }

static void ast_category_destroy ( struct ast_category cat  )  [static]

static struct ast_category* ast_category_get ( const struct ast_config config,
const char *  category_name 
) [static, read]

Definition at line 1475 of file extconf.c.

References category_get().

01476 {
01477    return category_get(config, category_name, 0);
01478 }

static struct ast_category* ast_category_new ( const char *  name,
const char *  in_file,
int  lineno 
) [static, read]

Create a category.

Parameters:
name name of new category
in_file filename which contained the new config
lineno line number

Definition at line 872 of file main/config.c.

References new_category().

00873 {
00874    return new_category(name, in_file, lineno, 0);
00875 }

static int ast_change_hint ( struct ast_exten oe,
struct ast_exten ne 
) [static]

ast_change_hint: Change hint for an extension

Definition at line 3923 of file extconf.c.

References AST_RWLIST_TRAVERSE, and ast_hint::exten.

03924 {
03925    struct ast_hint *hint;
03926    int res = -1;
03927 
03928    AST_RWLIST_TRAVERSE(&hints, hint, list) {
03929       if (hint->exten == oe) {
03930             hint->exten = ne;
03931          res = 0;
03932          break;
03933       }
03934    }
03935 
03936    return res;
03937 }

int ast_check_timing ( const struct ast_timing i  ) 

Evaluate a pre-constructed bitmap as to whether the current time falls within the range specified.

Parameters:
i Pointer to an ast_timing structure.
Return values:
Returns 1, if the time matches or 0, if the current time falls outside of the specified range.

Definition at line 9310 of file pbx.c.

References ast_check_timing2(), and ast_tvnow().

09311 {
09312    return ast_check_timing2(i, ast_tvnow());
09313 }

static void ast_config_destroy ( struct ast_config cfg  )  [static]

Destroys a config.

Parameters:
config pointer to config data structure
Free memory associated with a given config

Definition at line 1397 of file main/config.c.

References ast_category_destroy(), ast_free, ast_includes_destroy(), ast_config::includes, ast_category::next, and ast_config::root.

01398 {
01399    struct ast_category *cat, *catn;
01400 
01401    if (!cfg)
01402       return;
01403 
01404    ast_includes_destroy(cfg->includes);
01405 
01406    cat = cfg->root;
01407    while (cat) {
01408       catn = cat;
01409       cat = cat->next;
01410       ast_category_destroy(catn);
01411    }
01412    ast_free(cfg);
01413 }

struct ast_category* ast_config_get_current_category ( const struct ast_config cfg  )  [read]

Retrieve the current category name being built.

API for backend configuration engines while building a configuration set.

Definition at line 1415 of file main/config.c.

References ast_config::current.

01416 {
01417    return cfg->current;
01418 }

static struct ast_config * ast_config_internal_load ( const char *  filename,
struct ast_config cfg,
int  withcomments,
const char *  suggested_incl_file 
) [static, read]

Definition at line 3135 of file extconf.c.

References ast_log, db, find_engine(), ast_config::include_level, ast_config_engine::load_func, LOG_WARNING, ast_config::max_include_level, NULL, result, and table.

03136 {
03137    char db[256];
03138    char table[256];
03139    struct ast_config_engine *loader = &text_file_engine;
03140    struct ast_config *result; 
03141 
03142    if (cfg->include_level == cfg->max_include_level) {
03143       ast_log(LOG_WARNING, "Maximum Include level (%d) exceeded\n", cfg->max_include_level);
03144       return NULL;
03145    }
03146 
03147    cfg->include_level++;
03148    /*  silence is golden!
03149       ast_log(LOG_WARNING, "internal loading file %s level=%d\n", filename, cfg->include_level);
03150    */
03151 
03152    if (strcmp(filename, extconfig_conf) && strcmp(filename, "asterisk.conf") && config_engine_list) {
03153       struct ast_config_engine *eng;
03154 
03155       eng = find_engine(filename, db, sizeof(db), table, sizeof(table));
03156 
03157 
03158       if (eng && eng->load_func) {
03159          loader = eng;
03160       } else {
03161          eng = find_engine("global", db, sizeof(db), table, sizeof(table));
03162          if (eng && eng->load_func)
03163             loader = eng;
03164       }
03165    }
03166 
03167    result = loader->load_func(db, table, filename, cfg, withcomments, suggested_incl_file);
03168    /* silence is golden 
03169       ast_log(LOG_WARNING, "finished internal loading file %s level=%d\n", filename, cfg->include_level);
03170    */
03171 
03172    if (result)
03173       result->include_level--;
03174 
03175    return result;
03176 }

static struct ast_config* ast_config_new ( void   )  [static, read]

Create a new base configuration structure.

Definition at line 1264 of file main/config.c.

References ast_calloc, MAX_INCLUDE_LEVEL, and ast_config::max_include_level.

01265 {
01266    struct ast_config *config;
01267 
01268    if ((config = ast_calloc(1, sizeof(*config))))
01269       config->max_include_level = MAX_INCLUDE_LEVEL;
01270    return config;
01271 }

void ast_config_set_current_category ( struct ast_config cfg,
const struct ast_category cat 
)

Set the category within the configuration as being current.

API for backend configuration engines while building a configuration set.

Definition at line 1420 of file main/config.c.

References ast_config::current.

01421 {
01422    /* cast below is just to silence compiler warning about dropping "const" */
01423    cfg->current = (struct ast_category *) cat;
01424 }

void ast_console_puts ( const char *  string  ) 

write the string to the root console, and all attached network console clients

Definition at line 1405 of file asterisk.c.

References ast_network_puts().

01406 {
01407    /* Send to the root console */
01408    fputs(string, stdout);
01409    fflush(stdout);
01410 
01411    /* Send to any network console clients */
01412    ast_network_puts(string);
01413 }

static int ast_context_add_ignorepat2 ( struct ast_context con,
const char *  value,
const char *  registrar 
) [static]

Definition at line 9564 of file pbx.c.

References ast_calloc, ast_free, ast_unlock_context(), ast_wrlock_context(), errno, ast_context::ignorepats, localized_context_add_ignorepat2(), ast_ignorepat::next, NULL, ast_ignorepat::pattern, and ast_ignorepat::registrar.

09565 {
09566    struct ast_ignorepat *ignorepat, *ignorepatc, *ignorepatl = NULL;
09567    int length;
09568    char *pattern;
09569    length = sizeof(struct ast_ignorepat);
09570    length += strlen(value) + 1;
09571    if (!(ignorepat = ast_calloc(1, length)))
09572       return -1;
09573    /* The cast to char * is because we need to write the initial value.
09574     * The field is not supposed to be modified otherwise.  Also, gcc 4.2
09575     * sees the cast as dereferencing a type-punned pointer and warns about
09576     * it.  This is the workaround (we're telling gcc, yes, that's really
09577     * what we wanted to do).
09578     */
09579    pattern = (char *) ignorepat->pattern;
09580    strcpy(pattern, value);
09581    ignorepat->next = NULL;
09582    ignorepat->registrar = registrar;
09583    ast_wrlock_context(con);
09584    for (ignorepatc = con->ignorepats; ignorepatc; ignorepatc = ignorepatc->next) {
09585       ignorepatl = ignorepatc;
09586       if (!strcasecmp(ignorepatc->pattern, value)) {
09587          /* Already there */
09588          ast_unlock_context(con);
09589          ast_free(ignorepat);
09590          errno = EEXIST;
09591          return -1;
09592       }
09593    }
09594    if (ignorepatl)
09595       ignorepatl->next = ignorepat;
09596    else
09597       con->ignorepats = ignorepat;
09598    ast_unlock_context(con);
09599    return 0;
09600 
09601 }

static int ast_context_add_include2 ( struct ast_context con,
const char *  value,
const char *  registrar 
) [static]

Add a context include.

Parameters:
con context to add the include to
value include value to add
registrar who registered the context
Adds an include taking a struct ast_context as the first parameter

Return values:
0 on success
-1 on failure

Definition at line 9364 of file pbx.c.

References ast_build_timing(), ast_calloc, ast_destroy_timing(), ast_free, ast_get_context_name(), ast_unlock_context(), ast_verb, ast_wrlock_context(), c, errno, ast_include::hastime, ast_context::includes, localized_context_add_include2(), ast_include::name, ast_include::next, NULL, ast_include::registrar, ast_include::rname, ast_include::stuff, and ast_include::timing.

09366 {
09367    struct ast_include *new_include;
09368    char *c;
09369    struct ast_include *i, *il = NULL; /* include, include_last */
09370    int length;
09371    char *p;
09372 
09373    length = sizeof(struct ast_include);
09374    length += 2 * (strlen(value) + 1);
09375 
09376    /* allocate new include structure ... */
09377    if (!(new_include = ast_calloc(1, length)))
09378       return -1;
09379    /* Fill in this structure. Use 'p' for assignments, as the fields
09380     * in the structure are 'const char *'
09381     */
09382    p = new_include->stuff;
09383    new_include->name = p;
09384    strcpy(p, value);
09385    p += strlen(value) + 1;
09386    new_include->rname = p;
09387    strcpy(p, value);
09388    /* Strip off timing info, and process if it is there */
09389    if ( (c = strchr(p, ',')) ) {
09390       *c++ = '\0';
09391       new_include->hastime = ast_build_timing(&(new_include->timing), c);
09392    }
09393    new_include->next      = NULL;
09394    new_include->registrar = registrar;
09395 
09396    ast_wrlock_context(con);
09397 
09398    /* ... go to last include and check if context is already included too... */
09399    for (i = con->includes; i; i = i->next) {
09400       if (!strcasecmp(i->name, new_include->name)) {
09401          ast_destroy_timing(&(new_include->timing));
09402          ast_free(new_include);
09403          ast_unlock_context(con);
09404          errno = EEXIST;
09405          return -1;
09406       }
09407       il = i;
09408    }
09409 
09410    /* ... include new context into context list, unlock, return */
09411    if (il)
09412       il->next = new_include;
09413    else
09414       con->includes = new_include;
09415    ast_verb(3, "Including context '%s' in context '%s'\n", new_include->name, ast_get_context_name(con));
09416 
09417    ast_unlock_context(con);
09418 
09419    return 0;
09420 }

static int ast_context_add_switch2 ( struct ast_context con,
const char *  value,
const char *  data,
int  eval,
const char *  registrar 
) [static]

Adds a switch (first param is a ast_context).

Note:
See ast_context_add_switch() for argument information, with the exception of the first argument. In this case, it's a pointer to an ast_context structure as opposed to the name.

Definition at line 9447 of file pbx.c.

References ast_context::alts, ast_calloc, ast_free, ast_get_context_name(), AST_LIST_INSERT_TAIL, AST_LIST_TRAVERSE, ast_unlock_context(), ast_verb, ast_wrlock_context(), ast_sw::data, errno, ast_sw::eval, localized_context_add_switch2(), ast_sw::name, ast_sw::registrar, and ast_sw::stuff.

09449 {
09450    struct ast_sw *new_sw;
09451    struct ast_sw *i;
09452    int length;
09453    char *p;
09454 
09455    length = sizeof(struct ast_sw);
09456    length += strlen(value) + 1;
09457    if (data)
09458       length += strlen(data);
09459    length++;
09460 
09461    /* allocate new sw structure ... */
09462    if (!(new_sw = ast_calloc(1, length)))
09463       return -1;
09464    /* ... fill in this structure ... */
09465    p = new_sw->stuff;
09466    new_sw->name = p;
09467    strcpy(new_sw->name, value);
09468    p += strlen(value) + 1;
09469    new_sw->data = p;
09470    if (data) {
09471       strcpy(new_sw->data, data);
09472       p += strlen(data) + 1;
09473    } else {
09474       strcpy(new_sw->data, "");
09475       p++;
09476    }
09477    new_sw->eval     = eval;
09478    new_sw->registrar = registrar;
09479 
09480    /* ... try to lock this context ... */
09481    ast_wrlock_context(con);
09482 
09483    /* ... go to last sw and check if context is already swd too... */
09484    AST_LIST_TRAVERSE(&con->alts, i, list) {
09485       if (!strcasecmp(i->name, new_sw->name) && !strcasecmp(i->data, new_sw->data)) {
09486          ast_free(new_sw);
09487          ast_unlock_context(con);
09488          errno = EEXIST;
09489          return -1;
09490       }
09491    }
09492 
09493    /* ... sw new context into context list, unlock, return */
09494    AST_LIST_INSERT_TAIL(&con->alts, new_sw, list);
09495 
09496    ast_verb(3, "Including switch '%s/%s' in context '%s'\n", new_sw->name, new_sw->data, ast_get_context_name(con));
09497 
09498    ast_unlock_context(con);
09499 
09500    return 0;
09501 }

static struct ast_context* ast_context_find ( const char *  name  )  [static, read]

Find a context.

Parameters:
name name of the context to find
Will search for the context with the given name.

Returns:
the ast_context on success, NULL on failure.

Definition at line 3124 of file pbx.c.

References ast_copy_string(), ast_hashtab_lookup(), ast_rdlock_contexts(), ast_unlock_contexts(), ast_walk_contexts(), ast_context::name, fake_context::name, NULL, and tmp().

03125 {
03126    struct ast_context *tmp;
03127    struct fake_context item;
03128 
03129    if (!name) {
03130       return NULL;
03131    }
03132    ast_rdlock_contexts();
03133    if (contexts_table) {
03134       ast_copy_string(item.name, name, sizeof(item.name));
03135       tmp = ast_hashtab_lookup(contexts_table, &item);
03136    } else {
03137       tmp = NULL;
03138       while ((tmp = ast_walk_contexts(tmp))) {
03139          if (!strcasecmp(name, tmp->name)) {
03140             break;
03141          }
03142       }
03143    }
03144    ast_unlock_contexts();
03145    return tmp;
03146 }

static struct ast_context* ast_context_find_or_create ( struct ast_context **  extcontexts,
void *  tab,
const char *  name,
const char *  registrar 
) [static, read]

Definition at line 5224 of file extconf.c.

References __ast_context_create().

05225 {
05226    return __ast_context_create(extcontexts, name, registrar, 1);
05227 }

static int ast_context_verify_includes ( struct ast_context con  )  [static]

Definition at line 5864 of file extconf.c.

References ast_context_find(), ast_get_context_name(), ast_log, ast_walk_context_includes(), LOG_WARNING, NULL, and ast_include::rname.

05865 {
05866    struct ast_include *inc = NULL;
05867    int res = 0;
05868 
05869    while ( (inc = ast_walk_context_includes(con, inc)) )
05870       if (!ast_context_find(inc->rname)) {
05871          res = -1;
05872          if (strcasecmp(inc->rname,"parkedcalls")!=0)
05873             ast_log(LOG_WARNING, "Context '%s' tries to include the nonexistent context '%s'\n",
05874                   ast_get_context_name(con), inc->rname);
05875       }
05876    return res;
05877 }

void ast_copy_string ( char *  dst,
const char *  src,
size_t  size 
)

static int ast_extension_match ( const char *  pattern,
const char *  data 
) [static]

Determine if a given extension matches a given pattern (in NXX format).

Parameters:
pattern pattern to match
extension extension to check against the pattern.
Checks whether or not the given extension matches the given pattern.

Return values:
1 on match
0 on failure

Definition at line 3096 of file pbx.c.

References E_MATCH, and extension_match_core().

03097 {
03098    return extension_match_core(pattern, data, E_MATCH);
03099 }

static int ast_findlabel_extension2 ( struct ast_channel c,
struct ast_context con,
const char *  exten,
const char *  label,
const char *  callerid 
) [static]

Find the priority of an extension that has the specified label.

Note:
It is possible for autoservice to be started and stopped on c during this function call, it is important that c is not locked prior to calling this. Otherwise a deadlock may occur

This function is the same as ast_findlabel_extension, except that it accepts a pointer to an ast_context structure to specify the context instead of the name of the context. Otherwise, the functions behave the same.

Definition at line 5950 of file pbx.c.

References E_FINDLABEL, NULL, and pbx_extension_helper().

05951 {
05952    return pbx_extension_helper(c, con, NULL, exten, 0, label, callerid, E_FINDLABEL, 0, 0);
05953 }

static int ast_func_read ( struct ast_channel chan,
const char *  function,
char *  workspace,
size_t  len 
) [static]

Definition at line 5237 of file extconf.c.

References ast_log, and LOG_ERROR.

05238 {
05239    ast_log(LOG_ERROR, "Function %s not registered\n", function);
05240    return -1;
05241 }

static int ast_func_write ( struct ast_channel chan,
const char *  function,
const char *  value 
) [static]

Definition at line 2751 of file extconf.c.

02752 {
02753 
02754    /* ast_log(LOG_ERROR, "Function %s not registered\n", function); we are not interested in the details here */
02755 
02756    return -1;
02757 }

static const char* ast_get_context_name ( struct ast_context con  )  [static]

Lock for the ast_context list

Definition at line 12182 of file pbx.c.

References ast_context::name, and NULL.

12183 {
12184    return con ? con->name : NULL;
12185 }

static const char* ast_get_extension_app ( struct ast_exten e  )  [static]

Definition at line 3910 of file extconf.c.

References ast_exten::app, and NULL.

03911 {
03912    return e ? e->app : NULL;
03913 }

static const char* ast_get_extension_name ( struct ast_exten exten  )  [static]

Definition at line 3915 of file extconf.c.

References ast_exten::exten, and NULL.

03916 {
03917    return exten ? exten->exten : NULL;
03918 }

static struct ast_config_include* ast_include_find ( struct ast_config conf,
const char *  included_file 
) [static, read]

Definition at line 479 of file main/config.c.

References ast_config_include::included_file, ast_config::includes, and ast_config_include::next.

00480 {
00481    struct ast_config_include *x;
00482    for (x=conf->includes;x;x=x->next) {
00483       if (strcmp(x->included_file,included_file) == 0)
00484          return x;
00485    }
00486    return 0;
00487 }

static 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 
) [static, read]

Definition at line 339 of file main/config.c.

References ast_calloc, ast_include_find(), ast_includes_destroy(), ast_log, ast_strdup, ast_strlen_zero, ast_config::includes, LOG_WARNING, and NULL.

00340 {
00341    /* a file should be included ONCE. Otherwise, if one of the instances is changed,
00342     * then all be changed. -- how do we know to include it? -- Handling modified
00343     * instances is possible, I'd have
00344     * to create a new master for each instance. */
00345    struct ast_config_include *inc;
00346    struct stat statbuf;
00347 
00348    inc = ast_include_find(conf, included_file);
00349    if (inc) {
00350       do {
00351          inc->inclusion_count++;
00352          snprintf(real_included_file_name, real_included_file_name_size, "%s~~%d", included_file, inc->inclusion_count);
00353       } while (stat(real_included_file_name, &statbuf) == 0);
00354       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);
00355    } else
00356       *real_included_file_name = 0;
00357 
00358    inc = ast_calloc(1,sizeof(struct ast_config_include));
00359    if (!inc) {
00360       return NULL;
00361    }
00362    inc->include_location_file = ast_strdup(from_file);
00363    inc->include_location_lineno = from_lineno;
00364    if (!ast_strlen_zero(real_included_file_name))
00365       inc->included_file = ast_strdup(real_included_file_name);
00366    else
00367       inc->included_file = ast_strdup(included_file);
00368 
00369    inc->exec = is_exec;
00370    if (is_exec)
00371       inc->exec_file = ast_strdup(exec_file);
00372 
00373    if (!inc->include_location_file
00374       || !inc->included_file
00375       || (is_exec && !inc->exec_file)) {
00376       ast_includes_destroy(inc);
00377       return NULL;
00378    }
00379 
00380    /* attach this new struct to the conf struct */
00381    inc->next = conf->includes;
00382    conf->includes = inc;
00383 
00384    return inc;
00385 }

static void ast_includes_destroy ( struct ast_config_include incls  )  [static]

Definition at line 1538 of file extconf.c.

References ast_config_include::exec_file, free, ast_config_include::include_location_file, ast_config_include::included_file, and ast_config_include::next.

01539 {
01540    struct ast_config_include *incl,*inclnext;
01541     
01542    for (incl=incls; incl; incl = inclnext) {
01543       inclnext = incl->next;
01544       if (incl->include_location_file)
01545          free(incl->include_location_file);
01546       if (incl->exec_file)
01547          free(incl->exec_file);
01548       if (incl->included_file)
01549          free(incl->included_file);
01550       free(incl);
01551    }
01552 }

static void ast_log ( int  level,
const char *  file,
int  line,
const char *  function,
const char *  fmt,
  ... 
) [static]

Used for sending a log message This is the standard logger function. Probably the only way you will invoke it would be something like this: ast_log(AST_LOG_WHATEVER, "Problem with the %s Captain. We should get some more. Will %d be enough?\n", "flux capacitor", 10); where WHATEVER is one of ERROR, DEBUG, EVENT, NOTICE, or WARNING depending on which log you wish to output to. These are implemented as macros, that will provide the function with the needed arguments.

Parameters:
level Type of log event
file Will be provided by the AST_LOG_* macro
line Will be provided by the AST_LOG_* macro
function Will be provided by the AST_LOG_* macro
fmt This is what is important. The format is the same as your favorite breed of printf. You know how that works, right? :-)

Definition at line 1707 of file logger.c.

References __ast_verbose_ap(), __LOG_VERBOSE, ast_log_full(), and ast_read_threadstorage_callid().

01708 {
01709    ast_callid callid;
01710    va_list ap;
01711 
01712    callid = ast_read_threadstorage_callid();
01713 
01714    va_start(ap, fmt);
01715    if (level == __LOG_VERBOSE) {
01716       __ast_verbose_ap(file, line, function, 0, callid, fmt, ap);
01717    } else {
01718       ast_log_full(level, file, line, function, callid, fmt, ap);
01719    }
01720    va_end(ap);
01721 }

void ast_log_backtrace ( void   ) 

Log a backtrace of the current thread's execution stack to the Asterisk log.

Definition at line 1758 of file logger.c.

References ast_bt::addresses, ast_bt_create, ast_bt_destroy, ast_bt_get_symbols, ast_log, ast_std_free, ast_verbose, LOG_WARNING, and ast_bt::num_frames.

01759 {
01760 #ifdef HAVE_BKTR
01761    struct ast_bt *bt;
01762    int i = 0;
01763    char **strings;
01764 
01765    if (!(bt = ast_bt_create())) {
01766       ast_log(LOG_WARNING, "Unable to allocate space for backtrace structure\n");
01767       return;
01768    }
01769 
01770    if ((strings = ast_bt_get_symbols(bt->addresses, bt->num_frames))) {
01771       ast_verbose("Got %d backtrace record%c\n", bt->num_frames, bt->num_frames != 1 ? 's' : ' ');
01772       for (i = 3; i < bt->num_frames - 2; i++) {
01773          ast_verbose("#%d: [%p] %s\n", i - 3, bt->addresses[i], strings[i]);
01774       }
01775 
01776       ast_std_free(strings);
01777    } else {
01778       ast_verbose("Could not allocate memory for backtrace\n");
01779    }
01780    ast_bt_destroy(bt);
01781 #else
01782    ast_log(LOG_WARNING, "Must run configure with '--with-execinfo' for stack backtraces.\n");
01783 #endif /* defined(HAVE_BKTR) */
01784 }

void ast_mark_lock_failed ( void *  lock_addr  ) 

Definition at line 2585 of file extconf.c.

Referenced by __ast_pthread_mutex_trylock(), __ast_rwlock_tryrdlock(), and __ast_rwlock_trywrlock().

02586 {
02587    /* Pretend to do something. */
02588 }

static void ast_merge_contexts_and_delete ( struct ast_context **  extcontexts,
const char *  registrar 
) [static]

Definition at line 5814 of file extconf.c.

References __ast_context_destroy(), ast_log, ast_unlock_contexts(), ast_wrlock_contexts(), LOG_DEBUG, LOG_WARNING, ast_context::name, ast_context::next, NULL, and ast_context::registrar.

05815 {
05816    struct ast_context *tmp, *lasttmp = NULL;
05817 
05818    /* it is very important that this function hold the hint list lock _and_ the conlock
05819       during its operation; not only do we need to ensure that the list of contexts
05820       and extensions does not change, but also that no hint callbacks (watchers) are
05821       added or removed during the merge/delete process
05822 
05823       in addition, the locks _must_ be taken in this order, because there are already
05824       other code paths that use this order
05825    */
05826    ast_wrlock_contexts();
05827 
05828    tmp = *extcontexts;
05829    if (registrar) {
05830       /* XXX remove previous contexts from same registrar */
05831       if (option_debug)
05832          ast_log(LOG_DEBUG, "must remove any reg %s\n", registrar);
05833       __ast_context_destroy(NULL,registrar);
05834       while (tmp) {
05835          lasttmp = tmp;
05836          tmp = tmp->next;
05837       }
05838    } else {
05839       /* XXX remove contexts with the same name */
05840       while (tmp) {
05841          ast_log(LOG_WARNING, "must remove %s  reg %s\n", tmp->name, tmp->registrar);
05842          __ast_context_destroy(tmp,tmp->registrar);
05843          lasttmp = tmp;
05844          tmp = tmp->next;
05845       }
05846    }
05847    if (lasttmp) {
05848       lasttmp->next = contexts;
05849       contexts = *extcontexts;
05850       *extcontexts = NULL;
05851    } else
05852       ast_log(LOG_WARNING, "Requested contexts didn't get merged\n");
05853 
05854    ast_unlock_contexts();
05855 
05856    return;
05857 }

static int ast_mutex_init ( ast_mutex_t pmutex  )  [inline, static]

Definition at line 482 of file extconf.c.

References AST_MUTEX_KIND, and pthread_mutex_init.

00483 {
00484    pthread_mutexattr_t attr;
00485 
00486    pthread_mutexattr_init(&attr);
00487    pthread_mutexattr_settype(&attr, AST_MUTEX_KIND);
00488 
00489    return pthread_mutex_init(pmutex, &attr);
00490 }

static char* ast_process_quotes_and_slashes ( char *  start,
char  find,
char  replace_with 
) [static]

Definition at line 2490 of file extconf.c.

02491 {
02492    char *dataPut = start;
02493    int inEscape = 0;
02494    int inQuotes = 0;
02495 
02496    for (; *start; start++) {
02497       if (inEscape) {
02498          *dataPut++ = *start;       /* Always goes verbatim */
02499          inEscape = 0;
02500       } else {
02501          if (*start == '\\') {
02502             inEscape = 1;      /* Do not copy \ into the data */
02503          } else if (*start == '\'') {
02504             inQuotes = 1 - inQuotes;   /* Do not copy ' into the data */
02505          } else {
02506             /* Replace , with |, unless in quotes */
02507             *dataPut++ = inQuotes ? *start : ((*start == find) ? replace_with : *start);
02508          }
02509       }
02510    }
02511    if (start != dataPut)
02512       *dataPut = 0;
02513    return dataPut;
02514 }

void ast_queue_log ( const char *  queuename,
const char *  callid,
const char *  agent,
const char *  event,
const char *  fmt,
  ... 
)

Definition at line 547 of file logger.c.

References args, AST_APP_ARG, ast_check_realtime(), AST_DECLARE_APP_ARGS, ast_localtime(), AST_NONSTANDARD_APP_ARGS, ast_realtime_require_field(), AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK, ast_store_realtime(), ast_strftime(), ast_tvnow(), logfiles, logger_queue_start(), NULL, qlog, RQ_CHAR, S_OR, and SENTINEL.

00548 {
00549    va_list ap;
00550    struct timeval tv;
00551    struct ast_tm tm;
00552    char qlog_msg[8192];
00553    int qlog_len;
00554    char time_str[30];
00555 
00556    if (!logger_initialized) {
00557       /* You are too early.  We are not open yet! */
00558       return;
00559    }
00560    if (!queuelog_init) {
00561       /* We must initialize now since someone is trying to log something. */
00562       logger_queue_start();
00563    }
00564 
00565    if (ast_check_realtime("queue_log")) {
00566       tv = ast_tvnow();
00567       ast_localtime(&tv, &tm, logfiles.queue_log_realtime_use_gmt ? "GMT" : NULL);
00568       ast_strftime(time_str, sizeof(time_str), "%F %T.%6q", &tm);
00569       va_start(ap, fmt);
00570       vsnprintf(qlog_msg, sizeof(qlog_msg), fmt, ap);
00571       va_end(ap);
00572       if (logfiles.queue_adaptive_realtime) {
00573          AST_DECLARE_APP_ARGS(args,
00574             AST_APP_ARG(data)[5];
00575          );
00576          AST_NONSTANDARD_APP_ARGS(args, qlog_msg, '|');
00577          /* Ensure fields are large enough to receive data */
00578          ast_realtime_require_field("queue_log",
00579             "data1", RQ_CHAR, strlen(S_OR(args.data[0], "")),
00580             "data2", RQ_CHAR, strlen(S_OR(args.data[1], "")),
00581             "data3", RQ_CHAR, strlen(S_OR(args.data[2], "")),
00582             "data4", RQ_CHAR, strlen(S_OR(args.data[3], "")),
00583             "data5", RQ_CHAR, strlen(S_OR(args.data[4], "")),
00584             SENTINEL);
00585 
00586          /* Store the log */
00587          ast_store_realtime("queue_log", "time", time_str,
00588             "callid", callid,
00589             "queuename", queuename,
00590             "agent", agent,
00591             "event", event,
00592             "data1", S_OR(args.data[0], ""),
00593             "data2", S_OR(args.data[1], ""),
00594             "data3", S_OR(args.data[2], ""),
00595             "data4", S_OR(args.data[3], ""),
00596             "data5", S_OR(args.data[4], ""),
00597             SENTINEL);
00598       } else {
00599          ast_store_realtime("queue_log", "time", time_str,
00600             "callid", callid,
00601             "queuename", queuename,
00602             "agent", agent,
00603             "event", event,
00604             "data", qlog_msg,
00605             SENTINEL);
00606       }
00607 
00608       if (!logfiles.queue_log_to_file) {
00609          return;
00610       }
00611    }
00612 
00613    if (qlog) {
00614       va_start(ap, fmt);
00615       qlog_len = snprintf(qlog_msg, sizeof(qlog_msg), "%ld|%s|%s|%s|%s|", (long)time(NULL), callid, queuename, agent, event);
00616       vsnprintf(qlog_msg + qlog_len, sizeof(qlog_msg) - qlog_len, fmt, ap);
00617       va_end(ap);
00618       AST_RWLIST_RDLOCK(&logchannels);
00619       if (qlog) {
00620          fprintf(qlog, "%s\n", qlog_msg);
00621          fflush(qlog);
00622       }
00623       AST_RWLIST_UNLOCK(&logchannels);
00624    }
00625 }

int ast_register_verbose ( void(*)(const char *string verboser  ) 

Definition at line 2014 of file logger.c.

References ast_malloc, AST_RWLIST_INSERT_HEAD, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, logchannel::list, and verb::verboser.

02015 {
02016    struct verb *verb;
02017 
02018    if (!(verb = ast_malloc(sizeof(*verb))))
02019       return -1;
02020 
02021    verb->verboser = v;
02022 
02023    AST_RWLIST_WRLOCK(&verbosers);
02024    AST_RWLIST_INSERT_HEAD(&verbosers, verb, list);
02025    AST_RWLIST_UNLOCK(&verbosers);
02026 
02027    return 0;
02028 }

static int ast_remove_hint ( struct ast_exten e  )  [static]

ast_remove_hint: Remove hint from extension

Definition at line 4031 of file extconf.c.

References AST_RWLIST_REMOVE_CURRENT, AST_RWLIST_TRAVERSE_SAFE_BEGIN, AST_RWLIST_TRAVERSE_SAFE_END, ast_hint::callbacks, ast_hint::exten, free, ast_state_cb::next, and NULL.

04032 {
04033    /* Cleanup the Notifys if hint is removed */
04034    struct ast_hint *hint;
04035    struct ast_state_cb *cblist, *cbprev;
04036    int res = -1;
04037 
04038    if (!e)
04039       return -1;
04040 
04041    AST_RWLIST_TRAVERSE_SAFE_BEGIN(&hints, hint, list) {
04042       if (hint->exten == e) {
04043          cbprev = NULL;
04044          cblist = hint->callbacks;
04045          while (cblist) {
04046             /* Notify with -1 and remove all callbacks */
04047             cbprev = cblist;
04048             cblist = cblist->next;
04049             free(cbprev);
04050          }
04051          hint->callbacks = NULL;
04052          AST_RWLIST_REMOVE_CURRENT(&hints, list);
04053          free(hint);
04054             res = 0;
04055          break;
04056       }
04057    }
04058    AST_RWLIST_TRAVERSE_SAFE_END
04059 
04060    return res;
04061 }

void ast_replace_sigchld ( void   ) 

Replace the SIGCHLD handler.

Normally, Asterisk has a SIGCHLD handler that is cleaning up all zombie processes from forking elsewhere in Asterisk. However, if you want to wait*() on the process to retrieve information about it's exit status, then this signal handler needs to be temporarily replaced.

Code that executes this function *must* call ast_unreplace_sigchld() after it is finished doing the wait*().

Definition at line 1224 of file asterisk.c.

References ast_mutex_lock, ast_mutex_unlock, null_sig_handler, safe_system_level, safe_system_lock, and safe_system_prev_handler.

01225 {
01226    unsigned int level;
01227 
01228    ast_mutex_lock(&safe_system_lock);
01229    level = safe_system_level++;
01230 
01231    /* only replace the handler if it has not already been done */
01232    if (level == 0) {
01233       sigaction(SIGCHLD, &null_sig_handler, &safe_system_prev_handler);
01234    }
01235 
01236    ast_mutex_unlock(&safe_system_lock);
01237 }

static int ast_rwlock_destroy ( ast_rwlock_t prwlock  )  [inline, static]

Definition at line 542 of file extconf.c.

00543 {
00544    return pthread_rwlock_destroy(prwlock);
00545 }

static int ast_rwlock_init ( ast_rwlock_t prwlock  )  [inline, static]

Definition at line 529 of file extconf.c.

00530 {
00531    pthread_rwlockattr_t attr;
00532 
00533    pthread_rwlockattr_init(&attr);
00534 
00535 #ifdef HAVE_PTHREAD_RWLOCK_PREFER_WRITER_NP
00536    pthread_rwlockattr_setkind_np(&attr, PTHREAD_RWLOCK_PREFER_WRITER_NP);
00537 #endif
00538 
00539    return pthread_rwlock_init(prwlock, &attr);
00540 }

static int ast_rwlock_rdlock ( ast_rwlock_t prwlock  )  [inline, static]

Definition at line 552 of file extconf.c.

00553 {
00554    return pthread_rwlock_rdlock(prwlock);
00555 }

static int ast_rwlock_unlock ( ast_rwlock_t prwlock  )  [inline, static]

Definition at line 547 of file extconf.c.

00548 {
00549    return pthread_rwlock_unlock(prwlock);
00550 }

static int ast_rwlock_wrlock ( ast_rwlock_t prwlock  )  [inline, static]

Definition at line 557 of file extconf.c.

00558 {
00559    return pthread_rwlock_wrlock(prwlock);
00560 }

int ast_safe_system ( const char *  s  ) 

Safely spawn an external program while closing file descriptors.

Note:
This replaces the system call in all Asterisk modules

Definition at line 1254 of file asterisk.c.

References ast_close_fds_above_n(), ast_log, ast_opt_high_priority, ast_replace_sigchld(), ast_set_priority(), ast_unreplace_sigchld(), errno, LOG_WARNING, NULL, status, WEXITSTATUS, and WIFEXITED.

01255 {
01256    pid_t pid;
01257    int res;
01258    int status;
01259 
01260 #if defined(HAVE_WORKING_FORK) || defined(HAVE_WORKING_VFORK)
01261    ast_replace_sigchld();
01262 
01263 #ifdef HAVE_WORKING_FORK
01264    pid = fork();
01265 #else
01266    pid = vfork();
01267 #endif
01268 
01269    if (pid == 0) {
01270 #ifdef HAVE_CAP
01271       cap_t cap = cap_from_text("cap_net_admin-eip");
01272 
01273       if (cap_set_proc(cap)) {
01274          /* Careful with order! Logging cannot happen after we close FDs */
01275          ast_log(LOG_WARNING, "Unable to remove capabilities.\n");
01276       }
01277       cap_free(cap);
01278 #endif
01279 #ifdef HAVE_WORKING_FORK
01280       if (ast_opt_high_priority)
01281          ast_set_priority(0);
01282       /* Close file descriptors and launch system command */
01283       ast_close_fds_above_n(STDERR_FILENO);
01284 #endif
01285       execl("/bin/sh", "/bin/sh", "-c", s, (char *) NULL);
01286       _exit(1);
01287    } else if (pid > 0) {
01288       for (;;) {
01289          res = waitpid(pid, &status, 0);
01290          if (res > -1) {
01291             res = WIFEXITED(status) ? WEXITSTATUS(status) : -1;
01292             break;
01293          } else if (errno != EINTR)
01294             break;
01295       }
01296    } else {
01297       ast_log(LOG_WARNING, "Fork failed: %s\n", strerror(errno));
01298       res = -1;
01299    }
01300 
01301    ast_unreplace_sigchld();
01302 #else /* !defined(HAVE_WORKING_FORK) && !defined(HAVE_WORKING_VFORK) */
01303    res = -1;
01304 #endif
01305 
01306    return res;
01307 }

static void ast_shrink_phone_number ( char *  n  )  [static]

Clean up phone string remove '(', ' ', ')', non-trailing '.', and '-' not in square brackets. Basically, remove anything that could be invalid in a pattern.

Definition at line 2408 of file extconf.c.

References ast_channel::x.

02409 {
02410    int x, y=0;
02411    int bracketed = 0;
02412 
02413    for (x=0; n[x]; x++) {
02414       switch(n[x]) {
02415       case '[':
02416          bracketed++;
02417          n[y++] = n[x];
02418          break;
02419       case ']':
02420          bracketed--;
02421          n[y++] = n[x];
02422          break;
02423       case '-':
02424          if (bracketed)
02425             n[y++] = n[x];
02426          break;
02427       case '.':
02428          if (!n[x+1])
02429             n[y++] = n[x];
02430          break;
02431       default:
02432          if (!strchr("()", n[x]))
02433             n[y++] = n[x];
02434       }
02435    }
02436    n[y] = '\0';
02437 }

char* ast_skip_blanks ( const char *  str  ) 

char* ast_strip ( char *  s  ) 

Strip leading/trailing whitespace from a string.

Parameters:
s The string to be stripped (will be modified).
Returns:
The stripped string.
This functions strips all leading and trailing whitespace characters from the input string, and returns a pointer to the resulting string. The string is modified in place.

static force_inline int ast_strlen_zero ( const char *  s  )  [static]

Definition at line 1218 of file extconf.c.

01219 {
01220    return (!s || (*s == '\0'));
01221 }

char* ast_trim_blanks ( char *  str  ) 

Trims trailing whitespace characters from a string.

Parameters:
ast_trim_blanks function being used
str the input string
Returns:
a pointer to the modified string

static int ast_true ( const char *  s  )  [static]

Definition at line 2516 of file extconf.c.

References ast_strlen_zero.

02517 {
02518    if (ast_strlen_zero(s))
02519       return 0;
02520 
02521    /* Determine if this is a true value */
02522    if (!strcasecmp(s, "yes") ||
02523        !strcasecmp(s, "true") ||
02524        !strcasecmp(s, "y") ||
02525        !strcasecmp(s, "t") ||
02526        !strcasecmp(s, "1") ||
02527        !strcasecmp(s, "on"))
02528       return -1;
02529 
02530    return 0;
02531 }

struct timeval ast_tvadd ( struct timeval  a,
struct timeval  b 
) [read]

Returns the sum of two timevals a + b.

Definition at line 1726 of file main/utils.c.

References b, ONE_MILLION, and tvfix().

01727 {
01728    /* consistency checks to guarantee usec in 0..999999 */
01729    a = tvfix(a);
01730    b = tvfix(b);
01731    a.tv_sec += b.tv_sec;
01732    a.tv_usec += b.tv_usec;
01733    if (a.tv_usec >= ONE_MILLION) {
01734       a.tv_sec++;
01735       a.tv_usec -= ONE_MILLION;
01736    }
01737    return a;
01738 }

struct timeval ast_tvnow ( void   )  [read]

struct timeval ast_tvsub ( struct timeval  a,
struct timeval  b 
) [read]

Returns the difference of two timevals a - b.

Definition at line 1740 of file main/utils.c.

References b, ONE_MILLION, and tvfix().

01741 {
01742    /* consistency checks to guarantee usec in 0..999999 */
01743    a = tvfix(a);
01744    b = tvfix(b);
01745    a.tv_sec -= b.tv_sec;
01746    a.tv_usec -= b.tv_usec;
01747    if (a.tv_usec < 0) {
01748       a.tv_sec-- ;
01749       a.tv_usec += ONE_MILLION;
01750    }
01751    return a;
01752 }

static int ast_unlock_context ( struct ast_context con  )  [static]

Definition at line 4867 of file extconf.c.

References ast_rwlock_unlock, and ast_context::lock.

04868 {
04869    return ast_rwlock_unlock(&con->lock);
04870 }

static int ast_unlock_contexts ( void   )  [static]

Definition at line 4857 of file extconf.c.

References ast_rwlock_unlock, and conlock.

04858 {
04859    return ast_rwlock_unlock(&conlock);
04860 }

int ast_unregister_verbose ( void(*)(const char *string verboser  ) 

Definition at line 2030 of file logger.c.

References ast_free, AST_RWLIST_REMOVE_CURRENT, AST_RWLIST_TRAVERSE_SAFE_BEGIN, AST_RWLIST_TRAVERSE_SAFE_END, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, logchannel::list, and verb::verboser.

02031 {
02032    struct verb *cur;
02033 
02034    AST_RWLIST_WRLOCK(&verbosers);
02035    AST_RWLIST_TRAVERSE_SAFE_BEGIN(&verbosers, cur, list) {
02036       if (cur->verboser == v) {
02037          AST_RWLIST_REMOVE_CURRENT(list);
02038          ast_free(cur);
02039          break;
02040       }
02041    }
02042    AST_RWLIST_TRAVERSE_SAFE_END;
02043    AST_RWLIST_UNLOCK(&verbosers);
02044 
02045    return cur ? 0 : -1;
02046 }

void ast_unreplace_sigchld ( void   ) 

Restore the SIGCHLD handler.

This function is called after a call to ast_replace_sigchld. It restores the SIGCHLD handler that cleans up any zombie processes.

Definition at line 1239 of file asterisk.c.

References ast_mutex_lock, ast_mutex_unlock, NULL, safe_system_level, safe_system_lock, and safe_system_prev_handler.

01240 {
01241    unsigned int level;
01242 
01243    ast_mutex_lock(&safe_system_lock);
01244    level = --safe_system_level;
01245 
01246    /* only restore the handler if we are the last one */
01247    if (level == 0) {
01248       sigaction(SIGCHLD, &safe_system_prev_handler, NULL);
01249    }
01250 
01251    ast_mutex_unlock(&safe_system_lock);
01252 }

static struct ast_var_t* ast_var_assign ( const char *  name,
const char *  value 
) [static, read]

Definition at line 41 of file chanvars.c.

References __ast_calloc(), ast_calloc, ast_copy_string(), ast_var_t::name, NULL, ast_var_t::value, and var.

00043 {
00044    struct ast_var_t *var;
00045    int name_len = strlen(name) + 1;
00046    int value_len = strlen(value) + 1;
00047 
00048 #ifdef MALLOC_DEBUG
00049    if (!(var = __ast_calloc(sizeof(*var) + name_len + value_len, sizeof(char), file, lineno, function))) {
00050 #else
00051    if (!(var = ast_calloc(sizeof(*var) + name_len + value_len, sizeof(char)))) {
00052 #endif
00053       return NULL;
00054    }
00055 
00056    ast_copy_string(var->name, name, name_len);
00057    var->value = var->name + name_len;
00058    ast_copy_string(var->value, value, value_len);
00059 
00060    return var;
00061 }

static void ast_var_delete ( struct ast_var_t var  )  [static]

Definition at line 63 of file chanvars.c.

References ast_free.

00064 {
00065    ast_free(var);
00066 }

static const char* ast_var_name ( const struct ast_var_t var  )  [static]

Definition at line 2442 of file extconf.c.

References ast_var_t::name, ast_custom_function::name, and NULL.

02443 {
02444    const char *name;
02445 
02446    if (var == NULL || (name = var->name) == NULL)
02447       return NULL;
02448    /* Return the name without the initial underscores */
02449    if (name[0] == '_') {
02450       name++;
02451       if (name[0] == '_')
02452          name++;
02453    }
02454    return name;
02455 }

static const char* ast_var_value ( const struct ast_var_t var  )  [static]

Definition at line 5269 of file extconf.c.

References NULL, and ast_var_t::value.

05270 {
05271    return (var ? var->value : NULL);
05272 }

static void ast_variable_append ( struct ast_category category,
struct ast_variable variable 
) [static]

Definition at line 490 of file main/config.c.

References ast_category::last, ast_variable::next, and ast_category::root.

00491 {
00492    if (!variable)
00493       return;
00494    if (category->last)
00495       category->last->next = variable;
00496    else
00497       category->root = variable;
00498    category->last = variable;
00499    while (category->last->next)
00500       category->last = category->last->next;
00501 }

static struct ast_variable* ast_variable_browse ( const struct ast_config config,
const char *  category 
) [static, read]

Definition at line 604 of file main/config.c.

References ast_category_get(), ast_config::last_browse, ast_category::name, NULL, and ast_category::root.

00605 {
00606    struct ast_category *cat;
00607 
00608    if (config->last_browse && (config->last_browse->name == category)) {
00609       cat = config->last_browse;
00610    } else {
00611       cat = ast_category_get(config, category, NULL);
00612    }
00613 
00614    return (cat) ? cat->root : NULL;
00615 }

static struct ast_variable* ast_variable_new ( const char *  name,
const char *  value,
const char *  filename 
) [static, read]

Definition at line 285 of file main/config.c.

References __ast_calloc(), ast_calloc, ast_variable::file, MIN_VARIABLE_FNAME_SPACE, ast_variable::name, ast_variable::stuff, and ast_variable::value.

00287 {
00288    struct ast_variable *variable;
00289    int name_len = strlen(name) + 1;
00290    int val_len = strlen(value) + 1;
00291    int fn_len = strlen(filename) + 1;
00292 
00293    /* Ensure a minimum length in case the filename is changed later. */
00294    if (fn_len < MIN_VARIABLE_FNAME_SPACE) {
00295       fn_len = MIN_VARIABLE_FNAME_SPACE;
00296    }
00297 
00298    if (
00299 #ifdef MALLOC_DEBUG
00300       (variable = __ast_calloc(1, fn_len + name_len + val_len + sizeof(*variable), file, lineno, func))
00301 #else
00302       (variable = ast_calloc(1, fn_len + name_len + val_len + sizeof(*variable)))
00303 #endif
00304       ) {
00305       char *dst = variable->stuff;  /* writable space starts here */
00306 
00307       /* Put file first so ast_include_rename() can calculate space available. */
00308       variable->file = strcpy(dst, filename);
00309       dst += fn_len;
00310       variable->name = strcpy(dst, name);
00311       dst += name_len;
00312       variable->value = strcpy(dst, value);
00313    }
00314    return variable;
00315 }

static const char * ast_variable_retrieve ( const struct ast_config config,
const char *  category,
const char *  variable 
) [static]

Definition at line 1492 of file extconf.c.

References ast_variable_browse(), ast_variable::name, ast_category::next, ast_variable::next, NULL, ast_category::root, ast_config::root, and ast_variable::value.

01493 {
01494    struct ast_variable *v;
01495 
01496    if (category) {
01497       for (v = ast_variable_browse(config, category); v; v = v->next) {
01498          if (!strcasecmp(variable, v->name))
01499             return v->value;
01500       }
01501    } else {
01502       struct ast_category *cat;
01503 
01504       for (cat = config->root; cat; cat = cat->next)
01505          for (v = cat->root; v; v = v->next)
01506             if (!strcasecmp(variable, v->name))
01507                return v->value;
01508    }
01509 
01510    return NULL;
01511 }

static void ast_variables_destroy ( struct ast_variable v  )  [static]

Free variable list.

Parameters:
var the linked list of variables to free
This function frees a list of variables.

Definition at line 593 of file main/config.c.

References ast_variable_destroy(), and ast_variable::next.

00594 {
00595    struct ast_variable *vn;
00596 
00597    while (v) {
00598       vn = v;
00599       v = v->next;
00600       ast_variable_destroy(vn);
00601    }
00602 }

void ast_verbose ( const char *  fmt,
  ... 
)

static struct ast_exten* ast_walk_context_extensions ( struct ast_context con,
struct ast_exten exten 
) [static, read]

Definition at line 12288 of file pbx.c.

References ast_exten::next, NULL, and ast_context::root.

12290 {
12291    if (!exten)
12292       return con ? con->root : NULL;
12293    else
12294       return exten->next;
12295 }

static struct ast_include* ast_walk_context_includes ( struct ast_context con,
struct ast_include inc 
) [static, read]

Definition at line 12312 of file pbx.c.

References ast_context::includes, ast_include::next, and NULL.

12314 {
12315    if (!inc)
12316       return con ? con->includes : NULL;
12317    else
12318       return inc->next;
12319 }

static struct ast_sw* ast_walk_context_switches ( struct ast_context con,
struct ast_sw sw 
) [static, read]

Definition at line 12297 of file pbx.c.

References ast_context::alts, AST_LIST_FIRST, AST_LIST_NEXT, and NULL.

12299 {
12300    if (!sw)
12301       return con ? AST_LIST_FIRST(&con->alts) : NULL;
12302    else
12303       return AST_LIST_NEXT(sw, list);
12304 }

static struct ast_context* ast_walk_contexts ( struct ast_context con  )  [static, read]

Definition at line 12283 of file pbx.c.

References ast_context::next.

12284 {
12285    return con ? con->next : contexts;
12286 }

static struct ast_exten* ast_walk_extension_priorities ( struct ast_exten exten,
struct ast_exten priority 
) [static, read]

Definition at line 12306 of file pbx.c.

References ast_exten::peer.

12308 {
12309    return priority ? priority->peer : exten;
12310 }

static int ast_wrlock_context ( struct ast_context con  )  [static]

Definition at line 4862 of file extconf.c.

References ast_rwlock_wrlock, and ast_context::lock.

04863 {
04864    return ast_rwlock_wrlock(&con->lock);
04865 }

static int ast_wrlock_contexts ( void   )  [static]

Definition at line 4852 of file extconf.c.

References ast_rwlock_wrlock, and conlock.

04853 {
04854    return ast_rwlock_wrlock(&conlock);
04855 }

static struct ast_category * category_get ( const struct ast_config config,
const char *  category_name,
int  ignored 
) [static, read]

Definition at line 1457 of file extconf.c.

References ast_category::ignored, ast_category::name, ast_category::next, NULL, and ast_config::root.

Referenced by ast_category_get(), localized_category_get(), and process_text_line().

01458 {
01459    struct ast_category *cat;
01460 
01461    /* try exact match first, then case-insensitive match */
01462    for (cat = config->root; cat; cat = cat->next) {
01463       if (cat->name == category_name && (ignored || !cat->ignored))
01464          return cat;
01465    }
01466 
01467    for (cat = config->root; cat; cat = cat->next) {
01468       if (!strcasecmp(cat->name, category_name) && (ignored || !cat->ignored))
01469          return cat;
01470    }
01471 
01472    return NULL;
01473 }

static void CB_ADD ( char *  str  )  [static]

Definition at line 1003 of file extconf.c.

References ast_realloc, and CB_INCR.

01004 {
01005    int rem = comment_buffer_size - strlen(comment_buffer) - 1;
01006    int siz = strlen(str);
01007    if (rem < siz+1) {
01008       comment_buffer = ast_realloc(comment_buffer, comment_buffer_size + CB_INCR + siz + 1);
01009       if (!comment_buffer)
01010          return;
01011       comment_buffer_size += CB_INCR+siz+1;
01012    }
01013    strcat(comment_buffer,str);
01014 }

static void CB_ADD_LEN ( char *  str,
int  len 
) [static]

Definition at line 1016 of file extconf.c.

References ast_realloc, and CB_INCR.

01017 {
01018    int cbl = strlen(comment_buffer) + 1;
01019    int rem = comment_buffer_size - cbl;
01020    if (rem < len+1) {
01021       comment_buffer = ast_realloc(comment_buffer, comment_buffer_size + CB_INCR + len + 1);
01022       if (!comment_buffer)
01023          return;
01024       comment_buffer_size += CB_INCR+len+1;
01025    }
01026    strncat(comment_buffer,str,len); /* safe */
01027    comment_buffer[cbl+len-1] = 0;
01028 }

static void CB_INIT ( void   )  [static]

Definition at line 984 of file extconf.c.

References ast_malloc, and CB_INCR.

Referenced by config_text_file_load().

00985 {
00986    if (!comment_buffer) {
00987       comment_buffer = ast_malloc(CB_INCR);
00988       if (!comment_buffer)
00989          return;
00990       comment_buffer[0] = 0;
00991       comment_buffer_size = CB_INCR;
00992       lline_buffer = ast_malloc(CB_INCR);
00993       if (!lline_buffer)
00994          return;
00995       lline_buffer[0] = 0;
00996       lline_buffer_size = CB_INCR;
00997    } else {
00998       comment_buffer[0] = 0;
00999       lline_buffer[0] = 0;
01000    }
01001 }

static void CB_RESET ( void   )  [static]

Definition at line 1043 of file extconf.c.

01044 { 
01045    comment_buffer[0] = 0; 
01046    lline_buffer[0] = 0;
01047 }

static struct ast_config * config_text_file_load ( const char *  database,
const char *  table,
const char *  filename,
struct ast_config cfg,
int  withcomments,
const char *  suggested_include_file 
) [static, read]

Definition at line 3386 of file extconf.c.

References ast_config_AST_CONFIG_DIR, ast_config_get_current_category(), ast_copy_string(), ast_log, ast_strip(), ast_strlen_zero, ast_verbose, buf, CB_ADD(), CB_ADD_LEN(), CB_INIT(), comment, COMMENT_META, COMMENT_TAG, errno, f, free, GLOB_ABORTED, ast_config::include_level, LLB_ADD(), LOG_DEBUG, LOG_ERROR, LOG_WARNING, MAX_NESTED_COMMENTS, NULL, process_text_line(), and VERBOSE_PREFIX_2.

03387 {
03388    char fn[256];
03389    char buf[8192];
03390    char *new_buf, *comment_p, *process_buf;
03391    FILE *f;
03392    int lineno=0;
03393    int comment = 0, nest[MAX_NESTED_COMMENTS];
03394    struct ast_category *cat = NULL;
03395    int count = 0;
03396    struct stat statbuf;
03397    
03398    cat = ast_config_get_current_category(cfg);
03399 
03400    if (filename[0] == '/') {
03401       ast_copy_string(fn, filename, sizeof(fn));
03402    } else {
03403       if (use_local_dir)
03404          snprintf(fn, sizeof(fn), "./%s", filename);
03405       else
03406          snprintf(fn, sizeof(fn), "%s/%s", ast_config_AST_CONFIG_DIR, filename);
03407    }
03408 
03409    if (withcomments && cfg && cfg->include_level < 2 ) {
03410       CB_INIT();
03411    }
03412    
03413 #ifdef AST_INCLUDE_GLOB
03414    {
03415       int glob_ret;
03416       glob_t globbuf;
03417 
03418       globbuf.gl_offs = 0; /* initialize it to silence gcc */
03419 #ifdef SOLARIS
03420       glob_ret = glob(fn, GLOB_NOCHECK, NULL, &globbuf);
03421 #else
03422       glob_ret = glob(fn, GLOB_NOMAGIC|GLOB_BRACE, NULL, &globbuf);
03423 #endif
03424       if (glob_ret == GLOB_NOSPACE)
03425          ast_log(LOG_WARNING,
03426             "Glob Expansion of pattern '%s' failed: Not enough memory\n", fn);
03427       else if (glob_ret  == GLOB_ABORTED)
03428          ast_log(LOG_WARNING,
03429             "Glob Expansion of pattern '%s' failed: Read error\n", fn);
03430       else  {
03431          /* loop over expanded files */
03432          int i;
03433          for (i=0; i<globbuf.gl_pathc; i++) {
03434             ast_copy_string(fn, globbuf.gl_pathv[i], sizeof(fn));
03435 #endif
03436    do {
03437       if (stat(fn, &statbuf))
03438          continue;
03439 
03440       if (!S_ISREG(statbuf.st_mode)) {
03441          ast_log(LOG_WARNING, "'%s' is not a regular file, ignoring\n", fn);
03442          continue;
03443       }
03444       if (option_verbose > 1) {
03445          ast_verbose(VERBOSE_PREFIX_2 "Parsing '%s': ", fn);
03446          fflush(stdout);
03447       }
03448       if (!(f = fopen(fn, "r"))) {
03449          if (option_debug)
03450             ast_log(LOG_DEBUG, "No file to parse: %s\n", fn);
03451          if (option_verbose > 1)
03452             ast_verbose( "Not found (%s)\n", strerror(errno));
03453          continue;
03454       }
03455       count++;
03456       if (option_debug)
03457          ast_log(LOG_DEBUG, "Parsing %s\n", fn);
03458       if (option_verbose > 1)
03459          ast_verbose("Found\n");
03460       while(!feof(f)) {
03461          lineno++;
03462          if (fgets(buf, sizeof(buf), f)) {
03463             if ( withcomments ) {    
03464                CB_ADD(lline_buffer);       /* add the current lline buffer to the comment buffer */
03465                lline_buffer[0] = 0;        /* erase the lline buffer */
03466             }
03467             
03468             new_buf = buf;
03469             if (comment) 
03470                process_buf = NULL;
03471             else
03472                process_buf = buf;
03473             
03474             while ((comment_p = strchr(new_buf, COMMENT_META))) {
03475                if ((comment_p > new_buf) && (*(comment_p-1) == '\\')) {
03476                   /* Yuck, gotta memmove */
03477                   memmove(comment_p - 1, comment_p, strlen(comment_p) + 1);
03478                   new_buf = comment_p;
03479                } else if(comment_p[1] == COMMENT_TAG && comment_p[2] == COMMENT_TAG && (comment_p[3] != '-')) {
03480                   /* Meta-Comment start detected ";--" */
03481                   if (comment < MAX_NESTED_COMMENTS) {
03482                      *comment_p = '\0';
03483                      new_buf = comment_p + 3;
03484                      comment++;
03485                      nest[comment-1] = lineno;
03486                   } else {
03487                      ast_log(LOG_ERROR, "Maximum nest limit of %d reached.\n", MAX_NESTED_COMMENTS);
03488                   }
03489                } else if ((comment_p >= new_buf + 2) &&
03490                      (*(comment_p - 1) == COMMENT_TAG) &&
03491                      (*(comment_p - 2) == COMMENT_TAG)) {
03492                   /* Meta-Comment end detected */
03493                   comment--;
03494                   new_buf = comment_p + 1;
03495                   if (!comment) {
03496                      /* Back to non-comment now */
03497                      if (process_buf) {
03498                         /* Actually have to move what's left over the top, then continue */
03499                         char *oldptr;
03500                         oldptr = process_buf + strlen(process_buf);
03501                         if ( withcomments ) {
03502                            CB_ADD(";");
03503                            CB_ADD_LEN(oldptr+1,new_buf-oldptr-1);
03504                         }
03505                         
03506                         memmove(oldptr, new_buf, strlen(new_buf) + 1);
03507                         new_buf = oldptr;
03508                      } else
03509                         process_buf = new_buf;
03510                   }
03511                } else {
03512                   if (!comment) {
03513                      /* If ; is found, and we are not nested in a comment, 
03514                         we immediately stop all comment processing */
03515                      if ( withcomments ) {
03516                         LLB_ADD(comment_p);
03517                      }
03518                      *comment_p = '\0'; 
03519                      new_buf = comment_p;
03520                   } else
03521                      new_buf = comment_p + 1;
03522                }
03523             }
03524             if( withcomments && comment && !process_buf )
03525             {
03526                CB_ADD(buf);  /* the whole line is a comment, store it */
03527             }
03528             
03529             if (process_buf) {
03530                char *stripped_process_buf = ast_strip(process_buf);
03531                if (!ast_strlen_zero(stripped_process_buf)) {
03532                   if (process_text_line(cfg, &cat, stripped_process_buf, lineno, filename, withcomments, suggested_include_file)) {
03533                      cfg = NULL;
03534                      break;
03535                   }
03536                }
03537             }
03538          }
03539       }
03540       fclose(f);     
03541    } while(0);
03542    if (comment) {
03543       ast_log(LOG_WARNING,"Unterminated comment detected beginning on line %d\n", nest[comment]);
03544    }
03545 #ifdef AST_INCLUDE_GLOB
03546                if (!cfg)
03547                   break;
03548             }
03549             globfree(&globbuf);
03550          }
03551       }
03552 #endif
03553    if (cfg && cfg->include_level == 1 && withcomments && comment_buffer) {
03554       if (comment_buffer) { 
03555          free(comment_buffer);
03556          free(lline_buffer);
03557          comment_buffer=0; 
03558          lline_buffer=0; 
03559          comment_buffer_size=0; 
03560          lline_buffer_size=0;
03561       }
03562    }
03563    if (count == 0)
03564       return NULL;
03565 
03566    return cfg;
03567 }

static void destroy_exten ( struct ast_exten e  )  [static]

Definition at line 4063 of file extconf.c.

References ast_remove_hint(), ast_exten::data, ast_exten::datad, free, ast_exten::priority, and PRIORITY_HINT.

04064 {
04065    if (e->priority == PRIORITY_HINT)
04066       ast_remove_hint(e);
04067 
04068    if (e->datad)
04069       e->datad(e->data);
04070    free(e);
04071 }

static int ext_cmp ( const char *  a,
const char *  b 
) [static]

the full routine to compare extensions in rules.

Definition at line 4242 of file extconf.c.

References ext_cmp1().

04243 {
04244    /* make sure non-patterns come first.
04245     * If a is not a pattern, it either comes first or
04246     * we use strcmp to compare the strings.
04247     */
04248    int ret = 0;
04249 
04250    if (a[0] != '_')
04251       return (b[0] == '_') ? -1 : strcmp(a, b);
04252 
04253    /* Now we know a is a pattern; if b is not, a comes first */
04254    if (b[0] != '_')
04255       return 1;
04256 #if 0 /* old mode for ext matching */
04257    return strcmp(a, b);
04258 #endif
04259    /* ok we need full pattern sorting routine */
04260    while (!ret && a && b)
04261       ret = ext_cmp1(&a) - ext_cmp1(&b);
04262    if (ret == 0)
04263       return 0;
04264    else
04265       return (ret > 0) ? 1 : -1;
04266 }

static int ext_cmp1 ( const char **  p  )  [static]

helper functions to sort extensions and patterns in the desired way, so that more specific patterns appear first.

ext_cmp1 compares individual characters (or sets of), returning an int where bits 0-7 are the ASCII code of the first char in the set, while bit 8-15 are the cardinality of the set minus 1. This way more specific patterns (smaller cardinality) appear first. Wildcards have a special value, so that we can directly compare them to sets by subtracting the two values. In particular: 0x000xx one character, xx 0x0yyxx yy character set starting with xx 0x10000 '.' (one or more of anything) 0x20000 '!' (zero or more of anything) 0x30000 NUL (end of string) 0x40000 error in set. The pointer to the string is advanced according to needs. NOTES: 1. the empty set is equivalent to NUL. 2. given that a full set has always 0 as the first element, we could encode the special cases as 0xffXX where XX is 1, 2, 3, 4 as used above.

Definition at line 4170 of file extconf.c.

References ast_log, c, end, LOG_WARNING, and NULL.

Referenced by ext_cmp().

04171 {
04172    uint32_t chars[8];
04173    int c, cmin = 0xff, count = 0;
04174    const char *end;
04175 
04176    /* load, sign extend and advance pointer until we find
04177     * a valid character.
04178     */
04179    while ( (c = *(*p)++) && (c == ' ' || c == '-') )
04180       ;  /* ignore some characters */
04181 
04182    /* always return unless we have a set of chars */
04183    switch (c) {
04184    default: /* ordinary character */
04185       return 0x0000 | (c & 0xff);
04186 
04187    case 'N':   /* 2..9 */
04188       return 0x0700 | '2' ;
04189 
04190    case 'X':   /* 0..9 */
04191       return 0x0900 | '0';
04192 
04193    case 'Z':   /* 1..9 */
04194       return 0x0800 | '1';
04195 
04196    case '.':   /* wildcard */
04197       return 0x10000;
04198 
04199    case '!':   /* earlymatch */
04200       return 0x20000;   /* less specific than NULL */
04201 
04202    case '\0':  /* empty string */
04203       *p = NULL;
04204       return 0x30000;
04205 
04206    case '[':   /* pattern */
04207       break;
04208    }
04209    /* locate end of set */
04210    end = strchr(*p, ']');  
04211 
04212    if (end == NULL) {
04213       ast_log(LOG_WARNING, "Wrong usage of [] in the extension\n");
04214       return 0x40000;   /* XXX make this entry go last... */
04215    }
04216 
04217    memset(chars, '\0', sizeof(chars)); /* clear all chars in the set */
04218    for (; *p < end  ; (*p)++) {
04219       unsigned char c1, c2;   /* first-last char in range */
04220       c1 = (unsigned char)((*p)[0]);
04221       if (*p + 2 < end && (*p)[1] == '-') { /* this is a range */
04222          c2 = (unsigned char)((*p)[2]);
04223          *p += 2; /* skip a total of 3 chars */
04224       } else         /* individual character */
04225          c2 = c1;
04226       if (c1 < cmin)
04227          cmin = c1;
04228       for (; c1 <= c2; c1++) {
04229          uint32_t mask = 1 << (c1 % 32);
04230          if ( (chars[ c1 / 32 ] & mask) == 0)
04231             count += 0x100;
04232          chars[ c1 / 32 ] |= mask;
04233       }
04234    }
04235    (*p)++;
04236    return count == 0 ? 0x30000 : (count | cmin);
04237 }

static int ext_strncpy ( char *  dst,
const char *  src,
int  len 
) [static]

copy a string skipping whitespace

Definition at line 4269 of file extconf.c.

04270 {
04271    int count=0;
04272 
04273    while (*src && (count < len - 1)) {
04274       switch(*src) {
04275       case ' ':
04276          /* otherwise exten => [a-b],1,... doesn't work */
04277          /*    case '-': */
04278          /* Ignore */
04279          break;
04280       default:
04281          *dst = *src;
04282          dst++;
04283       }
04284       src++;
04285       count++;
04286    }
04287    *dst = '\0';
04288 
04289    return count;
04290 }

static int extension_match_core ( const char *  pattern,
const char *  data,
enum ext_match_t  mode 
) [static]

Definition at line 4533 of file extconf.c.

References _extension_match_core().

04534 {
04535    int i;
04536    i = _extension_match_core(pattern, data, mode);
04537    return i;
04538 }

static struct ast_config_engine* find_engine ( const char *  family,
char *  database,
int  dbsiz,
char *  table,
int  tabsiz 
) [static, read]

Find realtime engine for realtime family.

Definition at line 3020 of file extconf.c.

References ast_copy_string(), ast_log, config_maps, ast_config_map::database, ast_config_map::driver, LOG_WARNING, map, ast_config_map::name, ast_config_engine::next, ast_config_map::next, NULL, and ast_config_map::table.

03021 {
03022    struct ast_config_engine *eng, *ret = NULL;
03023    struct ast_config_map *map;
03024 
03025 
03026    for (map = config_maps; map; map = map->next) {
03027       if (!strcasecmp(family, map->name)) {
03028          if (database)
03029             ast_copy_string(database, map->database, dbsiz);
03030          if (table)
03031             ast_copy_string(table, map->table ? map->table : family, tabsiz);
03032          break;
03033       }
03034    }
03035 
03036    /* Check if the required driver (engine) exist */
03037    if (map) {
03038       for (eng = config_engine_list; !ret && eng; eng = eng->next) {
03039          if (!strcasecmp(eng->name, map->driver))
03040             ret = eng;
03041       }
03042    }
03043    
03044    
03045    /* if we found a mapping, but the engine is not available, then issue a warning */
03046    if (map && !ret)
03047       ast_log(LOG_WARNING, "Realtime mapping for '%s' found to engine '%s', but the engine is not available\n", map->name, map->driver);
03048    
03049    return ret;
03050 }

static void fini_conlock ( void   )  [static]

Definition at line 4725 of file extconf.c.

04730 {

static void fini_globalslock ( void   )  [static]

Definition at line 2339 of file extconf.c.

02343 : struct ast_var_t *ast_var_assign(const char *name, const char *value); */

static void fini_hints ( void   )  [static]

Definition at line 3920 of file extconf.c.

03922 : Change hint for an extension */

static void gen_header ( FILE *  f1,
const char *  configfile,
const char *  fn,
const char *  generator 
) [static]

Definition at line 3686 of file extconf.c.

References ast_copy_string().

03687 {
03688    char date[256]="";
03689    time_t t;
03690    time(&t);
03691    ast_copy_string(date, ctime(&t), sizeof(date));
03692    
03693    fprintf(f1, ";!\n");
03694    fprintf(f1, ";! Automatically generated configuration file\n");
03695    if (strcmp(configfile, fn))
03696       fprintf(f1, ";! Filename: %s (%s)\n", configfile, fn);
03697    else
03698       fprintf(f1, ";! Filename: %s\n", configfile);
03699    fprintf(f1, ";! Generator: %s\n", generator);
03700    fprintf(f1, ";! Creation Date: %s", date);
03701    fprintf(f1, ";!\n");
03702 }

static unsigned get_range ( char *  src,
int  max,
char *const   names[],
const char *  msg 
) [static]

helper function to return a range up to max (7, 12, 31 respectively). names, if supplied, is an array of names that should be mapped to numbers.

Definition at line 2911 of file extconf.c.

References ast_log, ast_strlen_zero, end, LOG_WARNING, lookup_name(), and strsep().

02912 {
02913    int start, end; /* start and ending position */
02914    unsigned int mask = 0;
02915    char *part;
02916 
02917    /* Check for whole range */
02918    if (ast_strlen_zero(src) || !strcmp(src, "*")) {
02919       return (1 << max) - 1;
02920    }
02921 
02922    while ((part = strsep(&src, "&"))) {
02923       /* Get start and ending position */
02924       char *endpart = strchr(part, '-');
02925       if (endpart) {
02926          *endpart++ = '\0';
02927       }
02928       /* Find the start */
02929       if ((start = lookup_name(part, names, max)) < 0) {
02930          ast_log(LOG_WARNING, "Invalid %s '%s', skipping element\n", msg, part);
02931          continue;
02932       }
02933       if (endpart) { /* find end of range */
02934          if ((end = lookup_name(endpart, names, max)) < 0) {
02935             ast_log(LOG_WARNING, "Invalid end %s '%s', skipping element\n", msg, endpart);
02936             continue;
02937          }
02938       } else {
02939          end = start;
02940       }
02941       /* Fill the mask. Remember that ranges are cyclic */
02942       mask |= (1 << end);   /* initialize with last element */
02943       while (start != end) {
02944          if (start >= max) {
02945             start = 0;
02946          }
02947          mask |= (1 << start);
02948          start++;
02949       }
02950    }
02951    return mask;
02952 }

static void get_timerange ( struct ast_timing i,
char *  times 
) [static]

store a bitmask of valid times, one bit each 2 minute

Definition at line 2955 of file extconf.c.

References ast_log, ast_strlen_zero, LOG_WARNING, ast_timing::minmask, and strsep().

02956 {
02957    char *endpart, *part;
02958    int x;
02959    int st_h, st_m;
02960    int endh, endm;
02961    int minute_start, minute_end;
02962 
02963    /* start disabling all times, fill the fields with 0's, as they may contain garbage */
02964    memset(i->minmask, 0, sizeof(i->minmask));
02965 
02966    /* 1-minute per bit */
02967    /* Star is all times */
02968    if (ast_strlen_zero(times) || !strcmp(times, "*")) {
02969       /* 48, because each hour takes 2 integers; 30 bits each */
02970       for (x = 0; x < 48; x++) {
02971          i->minmask[x] = 0x3fffffff; /* 30 bits */
02972       }
02973       return;
02974    }
02975    /* Otherwise expect a range */
02976    while ((part = strsep(&times, "&"))) {
02977       if (!(endpart = strchr(part, '-'))) {
02978          if (sscanf(part, "%2d:%2d", &st_h, &st_m) != 2 || st_h < 0 || st_h > 23 || st_m < 0 || st_m > 59) {
02979             ast_log(LOG_WARNING, "%s isn't a valid time.\n", part);
02980             continue;
02981          }
02982          i->minmask[st_h * 2 + (st_m >= 30 ? 1 : 0)] |= (1 << (st_m % 30));
02983          continue;
02984       }
02985       *endpart++ = '\0';
02986       /* why skip non digits? Mostly to skip spaces */
02987       while (*endpart && !isdigit(*endpart)) {
02988          endpart++;
02989       }
02990       if (!*endpart) {
02991          ast_log(LOG_WARNING, "Invalid time range starting with '%s-'.\n", part);
02992          continue;
02993       }
02994       if (sscanf(part, "%2d:%2d", &st_h, &st_m) != 2 || st_h < 0 || st_h > 23 || st_m < 0 || st_m > 59) {
02995          ast_log(LOG_WARNING, "'%s' isn't a valid start time.\n", part);
02996          continue;
02997       }
02998       if (sscanf(endpart, "%2d:%2d", &endh, &endm) != 2 || endh < 0 || endh > 23 || endm < 0 || endm > 59) {
02999          ast_log(LOG_WARNING, "'%s' isn't a valid end time.\n", endpart);
03000          continue;
03001       }
03002       minute_start = st_h * 60 + st_m;
03003       minute_end = endh * 60 + endm;
03004       /* Go through the time and enable each appropriate bit */
03005       for (x = minute_start; x != minute_end; x = (x + 1) % (24 * 60)) {
03006          i->minmask[x / 30] |= (1 << (x % 30));
03007       }
03008       /* Do the last one */
03009       i->minmask[x / 30] |= (1 << (x % 30));
03010    }
03011    /* All done */
03012    return;
03013 }

static int include_valid ( struct ast_include i  )  [inline, static]

Definition at line 4558 of file extconf.c.

References ast_check_timing(), ast_include::hastime, and ast_include::timing.

04559 {
04560    if (!i->hastime)
04561       return 1;
04562 
04563    return ast_check_timing(&(i->timing));
04564 }

static void inherit_category ( struct ast_category new,
const struct ast_category base 
) [static]

Definition at line 3096 of file extconf.c.

References ast_variable_append(), ast_variable::next, ast_category::root, var, and variable_clone().

Referenced by process_text_line().

03097 {
03098    struct ast_variable *var;
03099 
03100    for (var = base->root; var; var = var->next)
03101       ast_variable_append(new, variable_clone(var));
03102 }

static void init_conlock ( void   )  [static]

Definition at line 4725 of file extconf.c.

04730 {

static void init_globalslock ( void   )  [static]

Definition at line 2339 of file extconf.c.

02343 : struct ast_var_t *ast_var_assign(const char *name, const char *value); */

static void init_hints ( void   )  [static]

Definition at line 3920 of file extconf.c.

03922 : Change hint for an extension */

static void LLB_ADD ( char *  str  )  [static]

Definition at line 1030 of file extconf.c.

References ast_realloc, and CB_INCR.

Referenced by config_text_file_load().

01031 {
01032    int rem = lline_buffer_size - strlen(lline_buffer) - 1;
01033    int siz = strlen(str);
01034    if (rem < siz+1) {
01035       lline_buffer = ast_realloc(lline_buffer, lline_buffer_size + CB_INCR + siz + 1);
01036       if (!lline_buffer) 
01037          return;
01038       lline_buffer_size += CB_INCR + siz + 1;
01039    }
01040    strcat(lline_buffer,str);
01041 }

int localized_add_extension2 ( struct ast_context con,
int  replace,
const char *  extension,
int  priority,
const char *  label,
const char *  callerid,
const char *  application,
void *  data,
void(*)(void *)  datad,
const char *  registrar 
)

void localized_ast_include_rename ( struct ast_config conf,
const char *  from_file,
const char *  to_file 
)

Definition at line 1375 of file extconf.c.

References ast_variable::file, ast_category::file, free, ast_config_include::include_location_file, ast_config::includes, ast_variable::next, ast_category::next, ast_config_include::next, ast_category::root, ast_config::root, and strdup.

01376 {
01377    struct ast_config_include *incl;
01378    struct ast_category *cat;
01379    struct ast_variable *v;
01380     
01381    int from_len = strlen(from_file);
01382    int to_len = strlen(to_file);
01383     
01384    if (strcmp(from_file, to_file) == 0) /* no use wasting time if the name is the same */
01385       return;
01386    
01387    /* the manager code allows you to read in one config file, then
01388        write it back out under a different name. But, the new arrangement
01389       ties output lines to the file name. So, before you try to write
01390        the config file to disk, better riffle thru the data and make sure
01391        the file names are changed.
01392    */
01393    /* file names are on categories, includes (of course), and on variables. So,
01394       traverse all this and swap names */
01395    
01396    for (incl = conf->includes; incl; incl=incl->next) {
01397       if (strcmp(incl->include_location_file,from_file) == 0) {
01398          if (from_len >= to_len)
01399             strcpy(incl->include_location_file, to_file);
01400          else {
01401             free(incl->include_location_file);
01402             incl->include_location_file = strdup(to_file);
01403          }
01404       }
01405    }
01406    for (cat = conf->root; cat; cat = cat->next) {
01407       if (strcmp(cat->file,from_file) == 0) {
01408          if (from_len >= to_len)
01409             strcpy(cat->file, to_file);
01410          else {
01411             free(cat->file);
01412             cat->file = strdup(to_file);
01413          }
01414       }
01415       for (v = cat->root; v; v = v->next) {
01416          if (strcmp(v->file,from_file) == 0) {
01417             if (from_len >= to_len)
01418                strcpy(v->file, to_file);
01419             else {
01420                free(v->file);
01421                v->file = strdup(to_file);
01422             }
01423          }
01424       }
01425    }
01426 }

struct ast_category* localized_category_get ( const struct ast_config config,
const char *  category_name 
) [read]

struct ast_config* localized_config_load ( const char *  filename  )  [read]

struct ast_config* localized_config_load_with_comments ( const char *  filename  )  [read]

int localized_config_text_file_save ( const char *  configfile,
const struct ast_config cfg,
const char *  generator 
)

int localized_context_add_ignorepat2 ( struct ast_context con,
const char *  value,
const char *  registrar 
)

int localized_context_add_include2 ( struct ast_context con,
const char *  value,
const char *  registrar 
)

int localized_context_add_switch2 ( struct ast_context con,
const char *  value,
const char *  data,
int  eval,
const char *  registrar 
)

void localized_context_destroy ( struct ast_context con,
const char *  registrar 
)

struct ast_context* localized_context_find_or_create ( struct ast_context **  extcontexts,
void *  tab,
const char *  name,
const char *  registrar 
) [read]

int localized_context_verify_includes ( struct ast_context con  ) 

struct ast_exten* localized_find_extension ( struct ast_context bypass,
struct pbx_find_info q,
const char *  context,
const char *  exten,
int  priority,
const char *  label,
const char *  callerid,
enum ext_match_t  action 
) [read]

void localized_merge_contexts_and_delete ( struct ast_context **  extcontexts,
void *  tab,
const char *  registrar 
)

Version:
1.6.1 added tab parameter

Definition at line 5859 of file extconf.c.

References ast_merge_contexts_and_delete().

Referenced by ast_merge_contexts_and_delete().

05860 {
05861    ast_merge_contexts_and_delete(extcontexts, registrar);
05862 }

int localized_pbx_builtin_setvar ( struct ast_channel chan,
const void *  data 
)

int localized_pbx_load_module ( void   ) 

void localized_use_conf_dir ( void   ) 

void localized_use_local_dir ( void   ) 

struct ast_exten* localized_walk_context_extensions ( struct ast_context con,
struct ast_exten exten 
) [read]

struct ast_include* localized_walk_context_includes ( struct ast_context con,
struct ast_include inc 
) [read]

struct ast_sw* localized_walk_context_switches ( struct ast_context con,
struct ast_sw sw 
) [read]

struct ast_context* localized_walk_contexts ( struct ast_context con  )  [read]

struct ast_exten* localized_walk_extension_priorities ( struct ast_exten exten,
struct ast_exten priority 
) [read]

static int lookup_name ( const char *  s,
char *const   names[],
int  max 
) [static]

Helper for get_range. return the index of the matching entry, starting from 1. If names is not supplied, try numeric values.

Definition at line 2888 of file extconf.c.

02889 {
02890    int i;
02891 
02892    if (names && *s > '9') {
02893       for (i = 0; names[i]; i++) {
02894          if (!strcasecmp(s, names[i])) {
02895             return i;
02896          }
02897       }
02898    }
02899 
02900    /* Allow months and weekdays to be specified as numbers, as well */
02901    if (sscanf(s, "%2d", &i) == 1 && i >= 1 && i <= max) {
02902       /* What the array offset would have been: "1" would be at offset 0 */
02903       return i - 1;
02904    }
02905    return -1; /* error return */
02906 }

static int matchcid ( const char *  cidpattern,
const char *  callerid 
) [static]

Definition at line 4547 of file extconf.c.

References ast_extension_match(), and ast_strlen_zero.

04548 {
04549    /* If the Caller*ID pattern is empty, then we're matching NO Caller*ID, so
04550       failing to get a number should count as a match, otherwise not */
04551 
04552    if (ast_strlen_zero(callerid))
04553       return ast_strlen_zero(cidpattern) ? 1 : 0;
04554 
04555    return ast_extension_match(cidpattern, callerid);
04556 }

static void move_variables ( struct ast_category old,
struct ast_category new 
) [static]

Definition at line 3079 of file extconf.c.

References ast_variable_append(), ast_variable::next, ast_custom_function::next, NULL, ast_category::root, and var.

03080 {
03081    struct ast_variable *var = old->root;
03082    old->root = NULL;
03083 #if 1
03084    /* we can just move the entire list in a single op */
03085    ast_variable_append(new, var);
03086 #else
03087    while (var) {
03088       struct ast_variable *next = var->next;
03089       var->next = NULL;
03090       ast_variable_append(new, var);
03091       var = next;
03092    }
03093 #endif
03094 }

static struct ast_category* next_available_category ( struct ast_category cat  )  [static, read]

Definition at line 3617 of file extconf.c.

References ast_category::ignored, and ast_category::next.

03618 {
03619    for (; cat && cat->ignored; cat = cat->next);
03620 
03621    return cat;
03622 }

static void null_datad ( void *  foo  )  [static]

Definition at line 3015 of file extconf.c.

Referenced by ast_add_extension2().

03016 {
03017 }

static int parse_variable_name ( char *  var,
int *  offset,
int *  length,
int *  isfunc 
) [static]

extract offset:length from variable name. Returns 1 if there is a offset:length part, which is trimmed off (values go into variables)

Definition at line 5247 of file extconf.c.

05248 {
05249    int parens=0;
05250 
05251    *offset = 0;
05252    *length = INT_MAX;
05253    *isfunc = 0;
05254    for (; *var; var++) {
05255       if (*var == '(') {
05256          (*isfunc)++;
05257          parens++;
05258       } else if (*var == ')') {
05259          parens--;
05260       } else if (*var == ':' && parens == 0) {
05261          *var++ = '\0';
05262          sscanf(var, "%30d:%30d", offset, length);
05263          return 1; /* offset:length valid */
05264       }
05265    }
05266    return 0;
05267 }

static int pbx_builtin_setvar ( struct ast_channel chan,
const void *  data 
) [static]

Definition at line 2841 of file extconf.c.

References ast_app_separate_args, ast_log, ast_strdupa, ast_strlen_zero, global, LOG_WARNING, ast_custom_function::name, NULL, pbx_builtin_setvar_helper(), and value.

02842 {
02843    char *name, *value, *mydata;
02844    int argc;
02845    char *argv[24];      /* this will only support a maximum of 24 variables being set in a single operation */
02846    int global = 0;
02847    int x;
02848 
02849    if (ast_strlen_zero(data)) {
02850       ast_log(LOG_WARNING, "Set requires at least one variable name/value pair.\n");
02851       return 0;
02852    }
02853 
02854    mydata = ast_strdupa(data);
02855    argc = ast_app_separate_args(mydata, '|', argv, sizeof(argv) / sizeof(argv[0]));
02856 
02857    /* check for a trailing flags argument */
02858    if ((argc > 1) && !strchr(argv[argc-1], '=')) {
02859       argc--;
02860       if (strchr(argv[argc], 'g'))
02861          global = 1;
02862    }
02863 
02864    for (x = 0; x < argc; x++) {
02865       name = argv[x];
02866       if ((value = strchr(name, '='))) {
02867          *value++ = '\0';
02868          pbx_builtin_setvar_helper((global) ? NULL : chan, name, value);
02869       } else
02870          ast_log(LOG_WARNING, "Ignoring entry '%s' with no = (and not last 'options' entry)\n", name);
02871    }
02872 
02873    return(0);
02874 }

static void pbx_builtin_setvar_helper ( struct ast_channel chan,
const char *  name,
const char *  value 
) [static]

Definition at line 2801 of file extconf.c.

References ast_func_write(), AST_LIST_INSERT_HEAD, AST_LIST_REMOVE, AST_LIST_TRAVERSE, ast_strdupa, ast_var_assign(), ast_var_delete(), ast_var_name(), ast_verbose, and VERBOSE_PREFIX_2.

02802 {
02803    struct ast_var_t *newvariable;
02804    struct varshead *headp;
02805    const char *nametail = name;
02806 
02807    /* XXX may need locking on the channel ? */
02808    if (name[strlen(name)-1] == ')') {
02809       char *function = ast_strdupa(name);
02810 
02811       ast_func_write(chan, function, value);
02812       return;
02813    }
02814 
02815    headp = &globals;
02816 
02817    /* For comparison purposes, we have to strip leading underscores */
02818    if (*nametail == '_') {
02819       nametail++;
02820       if (*nametail == '_')
02821          nametail++;
02822    }
02823 
02824    AST_LIST_TRAVERSE (headp, newvariable, entries) {
02825       if (strcasecmp(ast_var_name(newvariable), nametail) == 0) {
02826          /* there is already such a variable, delete it */
02827          AST_LIST_REMOVE(headp, newvariable, entries);
02828          ast_var_delete(newvariable);
02829          break;
02830       }
02831    }
02832 
02833    if (value && (newvariable = ast_var_assign(name, value))) {
02834       if ((option_verbose > 1) && (headp == &globals))
02835          ast_verbose(VERBOSE_PREFIX_2 "Setting global variable '%s' to '%s'\n", name, value);
02836       AST_LIST_INSERT_HEAD(headp, newvariable, entries);
02837    }
02838 
02839 }

static int pbx_extension_helper ( struct ast_channel c,
struct ast_context con,
const char *  context,
const char *  exten,
int  priority,
const char *  label,
const char *  callerid,
enum ext_match_t  action 
) [static]

The return value depends on the action:.

E_MATCH, E_CANMATCH, E_MATCHMORE require a real match, and return 0 on failure, -1 on match; E_FINDLABEL maps the label to a priority, and returns the priority on success, ... XXX E_SPAWN, spawn an application, and return 0 on success, -1 on failure.

Definition at line 5158 of file extconf.c.

References ast_log, pbx_find_info::data, E_CANMATCH, E_FINDLABEL, E_MATCH, E_MATCHMORE, ast_switch::exec, pbx_find_info::foundcontext, LOG_DEBUG, LOG_NOTICE, LOG_WARNING, ast_switch::name, NULL, pbx_find_extension(), ast_exten::priority, pbx_find_info::stacklen, pbx_find_info::status, STATUS_NO_CONTEXT, STATUS_NO_EXTENSION, STATUS_NO_LABEL, STATUS_NO_PRIORITY, and pbx_find_info::swo.

05161 {
05162    struct ast_exten *e;
05163    int res;
05164    struct pbx_find_info q = { .stacklen = 0 }; /* the rest is reset in pbx_find_extension */
05165 
05166    int matching_action = (action == E_MATCH || action == E_CANMATCH || action == E_MATCHMORE);
05167 
05168    e = pbx_find_extension(NULL, con, &q, context, exten, priority, label, callerid, action);
05169    if (e) {
05170       if (matching_action) {
05171          return -1;  /* success, we found it */
05172       } else if (action == E_FINDLABEL) { /* map the label to a priority */
05173          res = e->priority;
05174          return res; /* the priority we were looking for */
05175       } else { /* spawn */
05176 
05177          /* NOT!!!!! */
05178          return 0;
05179       }
05180    } else if (q.swo) {  /* not found here, but in another switch */
05181       if (matching_action)
05182          return -1;
05183       else {
05184          if (!q.swo->exec) {
05185             ast_log(LOG_WARNING, "No execution engine for switch %s\n", q.swo->name);
05186             res = -1;
05187          }
05188          return q.swo->exec(c, q.foundcontext ? q.foundcontext : context, exten, priority, callerid, q.data);
05189       }
05190    } else { /* not found anywhere, see what happened */
05191       switch (q.status) {
05192       case STATUS_NO_CONTEXT:
05193          if (!matching_action)
05194             ast_log(LOG_NOTICE, "Cannot find extension context '%s'\n", context);
05195          break;
05196       case STATUS_NO_EXTENSION:
05197          if (!matching_action)
05198             ast_log(LOG_NOTICE, "Cannot find extension '%s' in context '%s'\n", exten, context);
05199          break;
05200       case STATUS_NO_PRIORITY:
05201          if (!matching_action)
05202             ast_log(LOG_NOTICE, "No such priority %d in extension '%s' in context '%s'\n", priority, exten, context);
05203          break;
05204       case STATUS_NO_LABEL:
05205          if (context)
05206             ast_log(LOG_NOTICE, "No such label '%s' in extension '%s' in context '%s'\n", label, exten, context);
05207          break;
05208       default:
05209          if (option_debug)
05210             ast_log(LOG_DEBUG, "Shouldn't happen!\n");
05211       }
05212 
05213       return (matching_action) ? 0 : -1;
05214    }
05215 }

static struct ast_exten* pbx_find_extension ( struct ast_channel chan,
struct ast_context bypass,
struct pbx_find_info q,
const char *  context,
const char *  exten,
int  priority,
const char *  label,
const char *  callerid,
enum ext_match_t  action 
) [static, read]

Definition at line 3166 of file pbx.c.

References ast_context::alts, ast_autoservice_start(), ast_autoservice_stop(), ast_debug, ast_hashtab_lookup(), AST_LIST_TRAVERSE, ast_log, AST_PBX_MAX_STACK, ast_str_buffer(), ast_str_size(), ast_str_thread_get(), ast_strdupa, ast_strlen_zero, ast_walk_context_extensions(), ast_switch::canmatch, scoreboard::canmatch_exten, create_match_char_tree(), ast_sw::data, pbx_find_info::data, e, E_CANMATCH, E_FINDLABEL, E_MATCHMORE, ast_sw::eval, ast_switch::exists, ast_exten::exten, scoreboard::exten, extension_match_core(), find_context(), pbx_find_info::foundcontext, include_valid(), ast_context::includes, pbx_find_info::incstack, ast_exten::label, scoreboard::last_char, LOG_NOTICE, LOG_WARNING, match(), matchcid(), ast_switch::matchmore, ast_context::name, ast_sw::name, new_find_extension(), ast_include::next, scoreboard::node, NULL, ast_context::pattern_tree, pbx_find_extension(), pbx_findswitch(), pbx_substitute_variables_helper(), ast_exten::priority, ast_include::rname, ast_context::root_table, pbx_find_info::stacklen, pbx_find_info::status, STATUS_NO_CONTEXT, STATUS_NO_EXTENSION, STATUS_NO_LABEL, STATUS_NO_PRIORITY, STATUS_SUCCESS, strsep(), switch_data, pbx_find_info::swo, tmp(), ast_sw::tmpdata, scoreboard::total_length, scoreboard::total_specificity, and trie_find_next_match().

03170 {
03171    int x, res;
03172    struct ast_context *tmp = NULL;
03173    struct ast_exten *e = NULL, *eroot = NULL;
03174    struct ast_include *i = NULL;
03175    struct ast_sw *sw = NULL;
03176    struct ast_exten pattern = {NULL, };
03177    struct scoreboard score = {0, };
03178    struct ast_str *tmpdata = NULL;
03179 
03180    pattern.label = label;
03181    pattern.priority = priority;
03182 #ifdef NEED_DEBUG_HERE
03183    ast_log(LOG_NOTICE, "Looking for cont/ext/prio/label/action = %s/%s/%d/%s/%d\n", context, exten, priority, label, (int) action);
03184 #endif
03185 
03186    /* Initialize status if appropriate */
03187    if (q->stacklen == 0) {
03188       q->status = STATUS_NO_CONTEXT;
03189       q->swo = NULL;
03190       q->data = NULL;
03191       q->foundcontext = NULL;
03192    } else if (q->stacklen >= AST_PBX_MAX_STACK) {
03193       ast_log(LOG_WARNING, "Maximum PBX stack exceeded\n");
03194       return NULL;
03195    }
03196 
03197    /* Check first to see if we've already been checked */
03198    for (x = 0; x < q->stacklen; x++) {
03199       if (!strcasecmp(q->incstack[x], context))
03200          return NULL;
03201    }
03202 
03203    if (bypass) { /* bypass means we only look there */
03204       tmp = bypass;
03205    } else {      /* look in contexts */
03206       tmp = find_context(context);
03207       if (!tmp) {
03208          return NULL;
03209       }
03210    }
03211 
03212    if (q->status < STATUS_NO_EXTENSION)
03213       q->status = STATUS_NO_EXTENSION;
03214 
03215    /* Do a search for matching extension */
03216 
03217    eroot = NULL;
03218    score.total_specificity = 0;
03219    score.exten = 0;
03220    score.total_length = 0;
03221    if (!tmp->pattern_tree && tmp->root_table) {
03222       create_match_char_tree(tmp);
03223 #ifdef NEED_DEBUG
03224       ast_debug(1, "Tree Created in context %s:\n", context);
03225       log_match_char_tree(tmp->pattern_tree," ");
03226 #endif
03227    }
03228 #ifdef NEED_DEBUG
03229    ast_log(LOG_NOTICE, "The Trie we are searching in:\n");
03230    log_match_char_tree(tmp->pattern_tree, "::  ");
03231 #endif
03232 
03233    do {
03234       if (!ast_strlen_zero(overrideswitch)) {
03235          char *osw = ast_strdupa(overrideswitch), *name;
03236          struct ast_switch *asw;
03237          ast_switch_f *aswf = NULL;
03238          char *datap;
03239          int eval = 0;
03240 
03241          name = strsep(&osw, "/");
03242          asw = pbx_findswitch(name);
03243 
03244          if (!asw) {
03245             ast_log(LOG_WARNING, "No such switch '%s'\n", name);
03246             break;
03247          }
03248 
03249          if (osw && strchr(osw, '$')) {
03250             eval = 1;
03251          }
03252 
03253          if (eval && !(tmpdata = ast_str_thread_get(&switch_data, 512))) {
03254             ast_log(LOG_WARNING, "Can't evaluate overrideswitch?!\n");
03255             break;
03256          } else if (eval) {
03257             /* Substitute variables now */
03258             pbx_substitute_variables_helper(chan, osw, ast_str_buffer(tmpdata), ast_str_size(tmpdata));
03259             datap = ast_str_buffer(tmpdata);
03260          } else {
03261             datap = osw;
03262          }
03263 
03264          /* equivalent of extension_match_core() at the switch level */
03265          if (action == E_CANMATCH)
03266             aswf = asw->canmatch;
03267          else if (action == E_MATCHMORE)
03268             aswf = asw->matchmore;
03269          else /* action == E_MATCH */
03270             aswf = asw->exists;
03271          if (!aswf) {
03272             res = 0;
03273          } else {
03274             if (chan) {
03275                ast_autoservice_start(chan);
03276             }
03277             res = aswf(chan, context, exten, priority, callerid, datap);
03278             if (chan) {
03279                ast_autoservice_stop(chan);
03280             }
03281          }
03282          if (res) {  /* Got a match */
03283             q->swo = asw;
03284             q->data = datap;
03285             q->foundcontext = context;
03286             /* XXX keep status = STATUS_NO_CONTEXT ? */
03287             return NULL;
03288          }
03289       }
03290    } while (0);
03291 
03292    if (extenpatternmatchnew) {
03293       new_find_extension(exten, &score, tmp->pattern_tree, 0, 0, callerid, label, action);
03294       eroot = score.exten;
03295 
03296       if (score.last_char == '!' && action == E_MATCHMORE) {
03297          /* We match an extension ending in '!'.
03298           * The decision in this case is final and is NULL (no match).
03299           */
03300 #ifdef NEED_DEBUG_HERE
03301          ast_log(LOG_NOTICE,"Returning MATCHMORE NULL with exclamation point.\n");
03302 #endif
03303          return NULL;
03304       }
03305 
03306       if (!eroot && (action == E_CANMATCH || action == E_MATCHMORE) && score.canmatch_exten) {
03307          q->status = STATUS_SUCCESS;
03308 #ifdef NEED_DEBUG_HERE
03309          ast_log(LOG_NOTICE,"Returning CANMATCH exten %s\n", score.canmatch_exten->exten);
03310 #endif
03311          return score.canmatch_exten;
03312       }
03313 
03314       if ((action == E_MATCHMORE || action == E_CANMATCH)  && eroot) {
03315          if (score.node) {
03316             struct ast_exten *z = trie_find_next_match(score.node);
03317             if (z) {
03318 #ifdef NEED_DEBUG_HERE
03319                ast_log(LOG_NOTICE,"Returning CANMATCH/MATCHMORE next_match exten %s\n", z->exten);
03320 #endif
03321             } else {
03322                if (score.canmatch_exten) {
03323 #ifdef NEED_DEBUG_HERE
03324                   ast_log(LOG_NOTICE,"Returning CANMATCH/MATCHMORE canmatchmatch exten %s(%p)\n", score.canmatch_exten->exten, score.canmatch_exten);
03325 #endif
03326                   return score.canmatch_exten;
03327                } else {
03328 #ifdef NEED_DEBUG_HERE
03329                   ast_log(LOG_NOTICE,"Returning CANMATCH/MATCHMORE next_match exten NULL\n");
03330 #endif
03331                }
03332             }
03333             return z;
03334          }
03335 #ifdef NEED_DEBUG_HERE
03336          ast_log(LOG_NOTICE, "Returning CANMATCH/MATCHMORE NULL (no next_match)\n");
03337 #endif
03338          return NULL;  /* according to the code, complete matches are null matches in MATCHMORE mode */
03339       }
03340 
03341       if (eroot) {
03342          /* found entry, now look for the right priority */
03343          if (q->status < STATUS_NO_PRIORITY)
03344             q->status = STATUS_NO_PRIORITY;
03345          e = NULL;
03346          if (action == E_FINDLABEL && label ) {
03347             if (q->status < STATUS_NO_LABEL)
03348                q->status = STATUS_NO_LABEL;
03349             e = ast_hashtab_lookup(eroot->peer_label_table, &pattern);
03350          } else {
03351             e = ast_hashtab_lookup(eroot->peer_table, &pattern);
03352          }
03353          if (e) { /* found a valid match */
03354             q->status = STATUS_SUCCESS;
03355             q->foundcontext = context;
03356 #ifdef NEED_DEBUG_HERE
03357             ast_log(LOG_NOTICE,"Returning complete match of exten %s\n", e->exten);
03358 #endif
03359             return e;
03360          }
03361       }
03362    } else {   /* the old/current default exten pattern match algorithm */
03363 
03364       /* scan the list trying to match extension and CID */
03365       eroot = NULL;
03366       while ( (eroot = ast_walk_context_extensions(tmp, eroot)) ) {
03367          int match = extension_match_core(eroot->exten, exten, action);
03368          /* 0 on fail, 1 on match, 2 on earlymatch */
03369 
03370          if (!match || (eroot->matchcid && !matchcid(eroot->cidmatch, callerid)))
03371             continue;   /* keep trying */
03372          if (match == 2 && action == E_MATCHMORE) {
03373             /* We match an extension ending in '!'.
03374              * The decision in this case is final and is NULL (no match).
03375              */
03376             return NULL;
03377          }
03378          /* found entry, now look for the right priority */
03379          if (q->status < STATUS_NO_PRIORITY)
03380             q->status = STATUS_NO_PRIORITY;
03381          e = NULL;
03382          if (action == E_FINDLABEL && label ) {
03383             if (q->status < STATUS_NO_LABEL)
03384                q->status = STATUS_NO_LABEL;
03385             e = ast_hashtab_lookup(eroot->peer_label_table, &pattern);
03386          } else {
03387             e = ast_hashtab_lookup(eroot->peer_table, &pattern);
03388          }
03389          if (e) { /* found a valid match */
03390             q->status = STATUS_SUCCESS;
03391             q->foundcontext = context;
03392             return e;
03393          }
03394       }
03395    }
03396 
03397    /* Check alternative switches */
03398    AST_LIST_TRAVERSE(&tmp->alts, sw, list) {
03399       struct ast_switch *asw = pbx_findswitch(sw->name);
03400       ast_switch_f *aswf = NULL;
03401       char *datap;
03402 
03403       if (!asw) {
03404          ast_log(LOG_WARNING, "No such switch '%s'\n", sw->name);
03405          continue;
03406       }
03407 
03408       /* Substitute variables now */
03409       if (sw->eval) {
03410          if (!(tmpdata = ast_str_thread_get(&switch_data, 512))) {
03411             ast_log(LOG_WARNING, "Can't evaluate switch?!\n");
03412             continue;
03413          }
03414          pbx_substitute_variables_helper(chan, sw->data, ast_str_buffer(tmpdata), ast_str_size(tmpdata));
03415       }
03416 
03417       /* equivalent of extension_match_core() at the switch level */
03418       if (action == E_CANMATCH)
03419          aswf = asw->canmatch;
03420       else if (action == E_MATCHMORE)
03421          aswf = asw->matchmore;
03422       else /* action == E_MATCH */
03423          aswf = asw->exists;
03424       datap = sw->eval ? ast_str_buffer(tmpdata) : sw->data;
03425       if (!aswf)
03426          res = 0;
03427       else {
03428          if (chan)
03429             ast_autoservice_start(chan);
03430          res = aswf(chan, context, exten, priority, callerid, datap);
03431          if (chan)
03432             ast_autoservice_stop(chan);
03433       }
03434       if (res) {  /* Got a match */
03435          q->swo = asw;
03436          q->data = datap;
03437          q->foundcontext = context;
03438          /* XXX keep status = STATUS_NO_CONTEXT ? */
03439          return NULL;
03440       }
03441    }
03442    q->incstack[q->stacklen++] = tmp->name;   /* Setup the stack */
03443    /* Now try any includes we have in this context */
03444    for (i = tmp->includes; i; i = i->next) {
03445       if (include_valid(i)) {
03446          if ((e = pbx_find_extension(chan, bypass, q, i->rname, exten, priority, label, callerid, action))) {
03447 #ifdef NEED_DEBUG_HERE
03448             ast_log(LOG_NOTICE,"Returning recursive match of %s\n", e->exten);
03449 #endif
03450             return e;
03451          }
03452          if (q->swo)
03453             return NULL;
03454       }
03455    }
03456    return NULL;
03457 }

static int pbx_load_config ( const char *  config_file  )  [static]

Definition at line 5580 of file extconf.c.

References ast_add_extension2(), ast_category_browse(), ast_config_destroy(), ast_context_add_ignorepat2(), ast_context_add_include2(), ast_context_add_switch2(), ast_context_find_or_create(), ast_copy_string(), ast_findlabel_extension2(), ast_free_ptr, ast_log, ast_opt_dont_warn, ast_process_quotes_and_slashes(), ast_shrink_phone_number(), ast_skip_blanks(), ast_strdup, ast_true(), ast_variable_browse(), ast_variable_retrieve(), autofallthrough_config, clearglobalvars_config, end, ext, free, global_registrar, ast_variable::lineno, localized_config_load(), LOG_WARNING, ast_variable::name, ast_variable::next, NULL, pbx_builtin_setvar_helper(), pbx_substitute_variables_helper(), PRIORITY_HINT, S_OR, static_config, strdup, strsep(), userscontext, ast_variable::value, and write_protect_config.

05581 {
05582    struct ast_config *cfg;
05583    char *end;
05584    char *label;
05585    char realvalue[256];
05586    int lastpri = -2;
05587    struct ast_context *con;
05588    struct ast_variable *v;
05589    const char *cxt;
05590    const char *aft;
05591 
05592    cfg = localized_config_load(config_file);
05593    if (!cfg)
05594       return 0;
05595 
05596    /* Use existing config to populate the PBX table */
05597    static_config = ast_true(ast_variable_retrieve(cfg, "general", "static"));
05598    write_protect_config = ast_true(ast_variable_retrieve(cfg, "general", "writeprotect"));
05599    if ((aft = ast_variable_retrieve(cfg, "general", "autofallthrough")))
05600       autofallthrough_config = ast_true(aft);
05601    clearglobalvars_config = ast_true(ast_variable_retrieve(cfg, "general", "clearglobalvars"));
05602 
05603    if ((cxt = ast_variable_retrieve(cfg, "general", "userscontext"))) 
05604       ast_copy_string(userscontext, cxt, sizeof(userscontext));
05605    else
05606       ast_copy_string(userscontext, "default", sizeof(userscontext));
05607                             
05608    for (v = ast_variable_browse(cfg, "globals"); v; v = v->next) {
05609       memset(realvalue, 0, sizeof(realvalue));
05610       pbx_substitute_variables_helper(NULL, v->value, realvalue, sizeof(realvalue) - 1);
05611       pbx_builtin_setvar_helper(NULL, v->name, realvalue);
05612    }
05613    for (cxt = NULL; (cxt = ast_category_browse(cfg, cxt)); ) {
05614       /* All categories but "general" or "globals" are considered contexts */
05615       if (!strcasecmp(cxt, "general") || !strcasecmp(cxt, "globals"))
05616          continue;
05617       con=ast_context_find_or_create(&local_contexts,NULL,cxt, global_registrar);
05618       if (con == NULL)
05619          continue;
05620 
05621       for (v = ast_variable_browse(cfg, cxt); v; v = v->next) {
05622          if (!strcasecmp(v->name, "exten")) {
05623             char *tc = ast_strdup(v->value);
05624             if (tc) {
05625                int ipri = -2;
05626                char realext[256]="";
05627                char *plus, *firstp, *firstc;
05628                char *pri, *appl, *data, *cidmatch;
05629                char *stringp = tc;
05630                char *ext = strsep(&stringp, ",");
05631                if (!ext)
05632                   ext="";
05633                pbx_substitute_variables_helper(NULL, ext, realext, sizeof(realext) - 1);
05634                cidmatch = strchr(realext, '/');
05635                if (cidmatch) {
05636                   *cidmatch++ = '\0';
05637                   ast_shrink_phone_number(cidmatch);
05638                }
05639                pri = strsep(&stringp, ",");
05640                if (!pri)
05641                   pri="";
05642                label = strchr(pri, '(');
05643                if (label) {
05644                   *label++ = '\0';
05645                   end = strchr(label, ')');
05646                   if (end)
05647                      *end = '\0';
05648                   else
05649                      ast_log(LOG_WARNING, "Label missing trailing ')' at line %d\n", v->lineno);
05650                }
05651                plus = strchr(pri, '+');
05652                if (plus)
05653                   *plus++ = '\0';
05654                if (!strcmp(pri,"hint"))
05655                   ipri=PRIORITY_HINT;
05656                else if (!strcmp(pri, "next") || !strcmp(pri, "n")) {
05657                   if (lastpri > -2)
05658                      ipri = lastpri + 1;
05659                   else
05660                      ast_log(LOG_WARNING, "Can't use 'next' priority on the first entry!\n");
05661                } else if (!strcmp(pri, "same") || !strcmp(pri, "s")) {
05662                   if (lastpri > -2)
05663                      ipri = lastpri;
05664                   else
05665                      ast_log(LOG_WARNING, "Can't use 'same' priority on the first entry!\n");
05666                } else if (sscanf(pri, "%30d", &ipri) != 1 &&
05667                    (ipri = ast_findlabel_extension2(NULL, con, realext, pri, cidmatch)) < 1) {
05668                   ast_log(LOG_WARNING, "Invalid priority/label '%s' at line %d\n", pri, v->lineno);
05669                   ipri = 0;
05670                }
05671                appl =