Asterisk - The Open Source Telephony Project  GIT-master-a24979a
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
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 - must remain in sync with fake_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
 

Macros

#define __AST_MUTEX_DEFINE(scope, mutex)    scope ast_mutex_t mutex = AST_MUTEX_INIT_VALUE
 
#define __AST_RWLOCK_DEFINE(scope, rwlock)    scope ast_rwlock_t rwlock = AST_RWLOCK_INIT_VALUE
 
#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   /* A small indication that this is horribly wrong. */
 
#define AST_API_MODULE   1 /* gimme the inline defs! */
 
#define AST_CACHE_DIR_LEN   512
 
#define AST_DEFAULT_OPTIONS   AST_OPT_FLAG_TRANSCODE_VIA_SLIN
 
#define AST_FILENAME_MAX   80
 
#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. More...
 
#define AST_LIST_EMPTY(head)   (AST_LIST_FIRST(head) == NULL)
 Checks whether the specified list contains any entries. More...
 
#define AST_LIST_ENTRY(type)
 Declare a forward link structure inside a list entry. More...
 
#define AST_LIST_FIRST(head)   ((head)->first)
 Returns the first entry contained in a list. More...
 
#define AST_LIST_HEAD(name, type)
 Defines a structure to be used to hold a list of specified type. More...
 
#define AST_LIST_HEAD_INIT(head)
 Initializes a list head structure. More...
 
#define AST_LIST_HEAD_INIT_NOLOCK(head)
 Initializes a list head structure. More...
 
#define AST_LIST_HEAD_INIT_VALUE
 Defines initial values for a declaration of AST_LIST_HEAD. More...
 
#define AST_LIST_HEAD_NOLOCK(name, type)
 Defines a structure to be used to hold a list of specified type (with no lock). More...
 
#define AST_LIST_HEAD_NOLOCK_INIT_VALUE
 Defines initial values for a declaration of AST_LIST_HEAD_NOLOCK. More...
 
#define AST_LIST_HEAD_NOLOCK_STATIC(name, type)
 Defines a structure to be used to hold a list of specified type, statically initialized. More...
 
#define AST_LIST_HEAD_SET(head, entry)
 Initializes a list head structure with a specified first entry. More...
 
#define AST_LIST_HEAD_SET_NOLOCK(head, entry)
 Initializes a list head structure with a specified first entry. More...
 
#define AST_LIST_HEAD_STATIC(name, type)
 Defines a structure to be used to hold a list of specified type, statically initialized. More...
 
#define AST_LIST_INSERT_AFTER(head, listelm, elm, field)
 Inserts a list entry after a given entry. More...
 
#define AST_LIST_INSERT_BEFORE_CURRENT(head, elm, field)
 Inserts a list entry before the current entry during a traversal. More...
 
#define AST_LIST_INSERT_HEAD(head, elm, field)
 Inserts a list entry at the head of a list. More...
 
#define AST_LIST_INSERT_TAIL(head, elm, field)
 Appends a list entry to the tail of a list. More...
 
#define AST_LIST_LAST(head)   ((head)->last)
 Returns the last entry contained in a list. More...
 
#define AST_LIST_NEXT(elm, field)   ((elm)->field.next)
 Returns the next entry in the list after the given entry. More...
 
#define AST_LIST_REMOVE(head, elm, field)
 Removes a specific entry from a list. More...
 
#define AST_LIST_REMOVE_CURRENT(head, field)
 Removes the current entry from a list during a traversal. More...
 
#define AST_LIST_REMOVE_HEAD(head, field)
 Removes and returns the head entry from a list. More...
 
#define AST_LIST_TRAVERSE(head, var, field)    for((var) = (head)->first; (var); (var) = (var)->field.next)
 Loops over (traverses) the entries in a list. More...
 
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
 Loops safely over (traverses) the entries in a list. More...
 
#define AST_LIST_TRAVERSE_SAFE_END   }
 Closes a safe loop traversal block. More...
 
#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_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_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. More...
 
#define AST_RWLIST_HEAD_DESTROY(head)
 Destroys an rwlist head structure. More...
 
#define AST_RWLIST_HEAD_INIT(head)
 Initializes an rwlist head structure. More...
 
#define AST_RWLIST_HEAD_INIT_VALUE
 Defines initial values for a declaration of AST_RWLIST_HEAD. More...
 
#define AST_RWLIST_HEAD_SET(head, entry)
 Initializes an rwlist head structure with a specified first entry. More...
 
#define AST_RWLIST_HEAD_STATIC(name, type)
 Defines a structure to be used to hold a read/write list of specified type, statically initialized. More...
 
#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. More...
 
#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. More...
 
#define AST_RWLIST_WRLOCK(head)    ast_rwlock_wrlock(&(head)->lock)
 Write locks a list. More...
 
#define AST_RWLOCK_DEFINE_STATIC(rwlock)   __AST_RWLOCK_DEFINE(static, rwlock)
 
#define AST_RWLOCK_INIT_VALUE   PTHREAD_RWLOCK_INITIALIZER
 
#define ast_set2_flag(p, value, flag)
 
#define ast_test_flag(p, flag)
 
#define ASTMM_LIBC   ASTMM_IGNORE
 
#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 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   " > "
 

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_CACHE_MEDIA_FRAMES = (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_REF_DEBUG = (1 << 20) ,
  AST_OPT_FLAG_ALWAYS_FORK = (1 << 21) , AST_OPT_FLAG_MUTE = (1 << 22) , AST_OPT_FLAG_DEBUG_MODULE = (1 << 23) , AST_OPT_FLAG_TRACE_MODULE = (1 << 24) ,
  AST_OPT_FLAG_LIGHT_BACKGROUND = (1 << 25) , AST_OPT_FLAG_HIDE_MESSAGING_AMI_EVENTS = (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_GENERIC_PLC_ON_EQUAL_CODECS = (1 << 31) , 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_ALWAYS_FORK = (1 << 21) , AST_OPT_FLAG_MUTE = (1 << 22) , AST_OPT_FLAG_DEBUG_FILE = (1 << 23) ,
  AST_OPT_FLAG_LIGHT_BACKGROUND = (1 << 25) , 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)
 
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. More...
 
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 More...
 
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. More...
 
static int ast_add_hint (struct ast_exten *e)
 ast_add_hint: Add hint to hint list, check initial extension state More...
 
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. More...
 
int ast_atomic_fetchadd_int (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. More...
 
int ast_build_timing (struct ast_timing *i, const char *info_in)
 Construct a timing bitmap, for use in time-based conditionals. More...
 
static void ast_category_append (struct ast_config *config, struct ast_category *category)
 
static char * ast_category_browse (struct ast_config *config, const char *prev)
 
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)
 
static int ast_change_hint (struct ast_exten *oe, struct ast_exten *ne)
 ast_change_hint: Change hint for an extension More...
 
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. More...
 
static void ast_config_destroy (struct ast_config *cfg)
 
struct ast_categoryast_config_get_current_category (const struct ast_config *cfg)
 Retrieve the current category name being built. More...
 
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)
 
void ast_config_set_current_category (struct ast_config *cfg, const struct ast_category *cat)
 Set the category within the configuration as being current. More...
 
void ast_console_puts (const char *string)
 write the string to the root console, and all attached network console clients More...
 
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)
 
static int ast_context_add_switch2 (struct ast_context *con, const char *value, const char *data, int eval, const char *registrar)
 
static struct ast_contextast_context_find (const char *name)
 
static struct ast_contextast_context_find_or_create (struct ast_context **extcontexts, void *tab, const char *name, const char *registrar)
 
int ast_context_ignorepats_count (struct ast_context *con)
 
int ast_context_includes_count (struct ast_context *con)
 
int ast_context_switches_count (struct ast_context *con)
 
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)
 
static int ast_findlabel_extension2 (struct ast_channel *c, struct ast_context *con, const char *exten, const char *label, const char *callerid)
 
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,...)
 
void ast_log_backtrace (void)
 Log a backtrace of the current thread's execution stack to the Asterisk log. More...
 
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,...)
 
static int ast_remove_hint (struct ast_exten *e)
 ast_remove_hint: Remove hint from extension More...
 
void ast_replace_sigchld (void)
 Replace the SIGCHLD handler. More...
 
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 OS shell command while closing file descriptors. More...
 
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. More...
 
char * ast_skip_blanks (const char *str)
 
char * ast_strip (char *s)
 Strip leading/trailing whitespace from a string. More...
 
static force_inline int ast_strlen_zero (const char *s)
 
char * ast_trim_blanks (char *str)
 Trims trailing whitespace characters from a string. More...
 
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. More...
 
struct timeval ast_tvnow (void)
 
struct timeval ast_tvsub (struct timeval a, struct timeval b)
 Returns the difference of two timevals a - b. More...
 
static int ast_unlock_context (struct ast_context *con)
 
static int ast_unlock_contexts (void)
 
void ast_unreplace_sigchld (void)
 Restore the SIGCHLD handler. More...
 
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)
 
void ast_verbose (const char *fmt,...)
 
static struct ast_extenast_walk_context_extensions (struct ast_context *con, struct ast_exten *exten)
 
static struct ast_ignorepatast_walk_context_ignorepats (struct ast_context *con, struct ast_ignorepat *ip)
 
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. More...
 
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. More...
 
static int ext_strncpy (char *dst, const char *src, int len)
 copy a string skipping whitespace More...
 
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. More...
 
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. More...
 
static void get_timerange (struct ast_timing *i, char *times)
 store a bitmask of valid times, one bit each 2 minute More...
 
static int include_valid (struct ast_include *i)
 
static void inherit_category (struct ast_category *new, const struct ast_category *base)
 
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. More...
 
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) More...
 
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: More...
 
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. More...
 
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. More...
 
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. More...
 
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 = NULL
 
static ast_rwlock_t conlock = PTHREAD_RWLOCK_INITIALIZER
 
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 = PTHREAD_RWLOCK_INITIALIZER
 
static struct hints hints = { .first = NULL, .last = NULL, .lock = PTHREAD_RWLOCK_INITIALIZER , }
 
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. More...
 
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
 

Detailed Description

A condensation of the pbx_config stuff, to read into extensions.conf, and provide an interface to the data there, for operations outside of asterisk. A huge, awful hack.

Definition in file extconf.c.

Macro Definition Documentation

◆ __AST_MUTEX_DEFINE

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

Definition at line 496 of file extconf.c.

◆ __AST_RWLOCK_DEFINE

#define __AST_RWLOCK_DEFINE (   scope,
  rwlock 
)     scope ast_rwlock_t rwlock = AST_RWLOCK_INIT_VALUE

Definition at line 564 of file extconf.c.

◆ __LOG_DEBUG

#define __LOG_DEBUG   0

Definition at line 120 of file extconf.c.

◆ __LOG_DTMF

#define __LOG_DTMF   6

Definition at line 156 of file extconf.c.

◆ __LOG_ERROR

#define __LOG_ERROR   4

Definition at line 144 of file extconf.c.

◆ __LOG_EVENT

#define __LOG_EVENT   1

Definition at line 126 of file extconf.c.

◆ __LOG_NOTICE

#define __LOG_NOTICE   2

Definition at line 132 of file extconf.c.

◆ __LOG_VERBOSE

#define __LOG_VERBOSE   5

Definition at line 150 of file extconf.c.

◆ __LOG_WARNING

#define __LOG_WARNING   3

Definition at line 138 of file extconf.c.

◆ __MTX_PROF

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

Definition at line 163 of file extconf.c.

◆ _A_

#define _A_   __FILE__, __LINE__, __PRETTY_FUNCTION__

Definition at line 115 of file extconf.c.

◆ _ASTERISK_LOCK_H

#define _ASTERISK_LOCK_H   /* A small indication that this is horribly wrong. */

Definition at line 160 of file extconf.c.

◆ AST_API_MODULE

#define AST_API_MODULE   1 /* gimme the inline defs! */

Definition at line 78 of file extconf.c.

◆ AST_CACHE_DIR_LEN

#define AST_CACHE_DIR_LEN   512

Definition at line 1358 of file extconf.c.

◆ AST_DEFAULT_OPTIONS

#define AST_DEFAULT_OPTIONS   AST_OPT_FLAG_TRANSCODE_VIA_SLIN

These are the options that set by default when Asterisk starts

Definition at line 1362 of file extconf.c.

◆ AST_FILENAME_MAX

#define AST_FILENAME_MAX   80

Definition at line 1359 of file extconf.c.

◆ ast_fully_booted

#define ast_fully_booted   ast_test_flag(&ast_options, AST_OPT_FLAG_FULLY_BOOTED)

Definition at line 1375 of file extconf.c.

◆ AST_LIST_APPEND_LIST

#define AST_LIST_APPEND_LIST (   head,
  list,
  field 
)

Appends a whole list to the tail of a list.

Parameters
headThis is a pointer to the list head structure
listThis is a pointer to the list to be appended.
fieldThis 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.

◆ AST_LIST_EMPTY

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

Checks whether the specified list contains any entries.

Parameters
headThis is a pointer to the list head structure

Returns non-zero if the list has entries, zero if not.

Definition at line 1733 of file extconf.c.

◆ AST_LIST_ENTRY

#define AST_LIST_ENTRY (   type)
Value:
struct { \
struct type *next; \
}
static const char type[]
Definition: chan_ooh323.c:109

Declare a forward link structure inside a list entry.

Parameters
typeThis 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;
}
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
Definition: linkedlists.h:410

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

Definition at line 1694 of file extconf.c.

◆ AST_LIST_FIRST

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

Returns the first entry contained in a list.

Parameters
headThis is a pointer to the list head structure

Definition at line 1705 of file extconf.c.

◆ AST_LIST_HEAD

#define AST_LIST_HEAD (   name,
  type 
)
Value:
struct name { \
struct type *first; \
struct type *last; \
ast_mutex_t lock; \
}
struct sla_ringing_trunk * first
Definition: app_meetme.c:1094
ast_mutex_t lock
Definition: app_meetme.c:1093
struct sla_ringing_trunk * last
Definition: app_meetme.c:1094
static const char name[]
Definition: format_mp3.c:68

Defines a structure to be used to hold a list of specified type.

Parameters
nameThis will be the name of the defined structure.
typeThis 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;
#define AST_LIST_HEAD(name, type)
Defines a structure to be used to hold a list of specified type.
Definition: linkedlists.h:173
Definition: search.h:40

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 1457 of file extconf.c.

◆ AST_LIST_HEAD_INIT

#define AST_LIST_HEAD_INIT (   head)
Value:
{ \
(head)->first = NULL; \
(head)->last = NULL; \
ast_mutex_init(&(head)->lock); \
}
#define NULL
Definition: resample.c:96

Initializes a list head structure.

Parameters
headThis 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 1885 of file extconf.c.

◆ AST_LIST_HEAD_INIT_NOLOCK

#define AST_LIST_HEAD_INIT_NOLOCK (   head)
Value:
{ \
(head)->first = NULL; \
(head)->last = NULL; \
}

Initializes a list head structure.

Parameters
headThis 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 1926 of file extconf.c.

◆ AST_LIST_HEAD_INIT_VALUE

#define AST_LIST_HEAD_INIT_VALUE
Value:
{ \
.first = NULL, \
.last = NULL, \
}
#define AST_MUTEX_INIT_VALUE
Definition: extconf.c:467

Defines initial values for a declaration of AST_LIST_HEAD.

Definition at line 1518 of file extconf.c.

◆ AST_LIST_HEAD_NOLOCK

#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
nameThis will be the name of the defined structure.
typeThis 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:

AST_LIST_HEAD_NOLOCK(contactliststruct, contact)

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 1509 of file extconf.c.

◆ AST_LIST_HEAD_NOLOCK_INIT_VALUE

#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 1536 of file extconf.c.

◆ AST_LIST_HEAD_NOLOCK_STATIC

#define AST_LIST_HEAD_NOLOCK_STATIC (   name,
  type 
)
Value:
struct name { \
struct type *first; \
struct type *last; \
#define AST_LIST_HEAD_NOLOCK_INIT_VALUE
Defines initial values for a declaration of AST_LIST_HEAD_NOLOCK.
Definition: extconf.c:1536

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 1630 of file extconf.c.

◆ AST_LIST_HEAD_SET

#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
headThis is a pointer to the list head structure
entrypointer 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 1644 of file extconf.c.

◆ AST_LIST_HEAD_SET_NOLOCK

#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
headThis is a pointer to the list head structure
entrypointer 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 1672 of file extconf.c.

◆ AST_LIST_HEAD_STATIC

#define AST_LIST_HEAD_STATIC (   name,
  type 
)
Value:
struct name { \
struct type *first; \
struct type *last; \
ast_mutex_t lock; \
#define AST_LIST_HEAD_INIT_VALUE
Defines initial values for a declaration of AST_LIST_HEAD.
Definition: extconf.c:1518

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

Parameters
nameThis will be the name of the defined structure.
typeThis 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:

#define AST_LIST_HEAD_STATIC(name, type)
Defines a structure to be used to hold a list of specified type, statically initialized.
Definition: linkedlists.h:291

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

Definition at line 1575 of file extconf.c.

◆ AST_LIST_INSERT_AFTER

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

Inserts a list entry after a given entry.

Parameters
headThis is a pointer to the list head structure
listelmThis is a pointer to the entry after which the new entry should be inserted.
elmThis is a pointer to the entry to be inserted.
fieldThis is the name of the field (declared using AST_LIST_ENTRY()) used to link entries of this list together.

Definition at line 1940 of file extconf.c.

◆ AST_LIST_INSERT_BEFORE_CURRENT

#define AST_LIST_INSERT_BEFORE_CURRENT (   head,
  elm,
  field 
)

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

Parameters
headThis is a pointer to the list head structure
elmThis is a pointer to the entry to be inserted.
fieldThis 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 1858 of file extconf.c.

◆ AST_LIST_INSERT_HEAD

#define AST_LIST_INSERT_HEAD (   head,
  elm,
  field 
)

Inserts a list entry at the head of a list.

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

Definition at line 1956 of file extconf.c.

◆ AST_LIST_INSERT_TAIL

#define AST_LIST_INSERT_TAIL (   head,
  elm,
  field 
)

Appends a list entry to the tail of a list.

Parameters
headThis is a pointer to the list head structure
elmThis is a pointer to the entry to be appended.
fieldThis 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 1976 of file extconf.c.

◆ AST_LIST_LAST

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

Returns the last entry contained in a list.

Parameters
headThis is a pointer to the list head structure

Definition at line 1713 of file extconf.c.

◆ AST_LIST_NEXT

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

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

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

Definition at line 1723 of file extconf.c.

◆ AST_LIST_REMOVE

#define AST_LIST_REMOVE (   head,
  elm,
  field 
)

Removes a specific entry from a list.

Parameters
headThis is a pointer to the list head structure
elmThis is a pointer to the entry to be removed.
fieldThis 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 2037 of file extconf.c.

◆ AST_LIST_REMOVE_CURRENT

#define AST_LIST_REMOVE_CURRENT (   head,
  field 
)

Removes the current entry from a list during a traversal.

Parameters
headThis is a pointer to the list head structure
fieldThis 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 1836 of file extconf.c.

◆ AST_LIST_REMOVE_HEAD

#define AST_LIST_REMOVE_HEAD (   head,
  field 
)

Removes and returns the head entry from a list.

Parameters
headThis is a pointer to the list head structure
fieldThis 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 2016 of file extconf.c.

◆ AST_LIST_TRAVERSE

#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
headThis is a pointer to the list head structure
varThis 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.
fieldThis 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)
}
size_t current
Definition: main/cli.c:113
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 1773 of file extconf.c.

◆ AST_LIST_TRAVERSE_SAFE_BEGIN

#define AST_LIST_TRAVERSE_SAFE_BEGIN (   head,
  var,
  field 
)

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

Parameters
headThis is a pointer to the list head structure
varThis 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.
fieldThis 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)
}
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
Definition: linkedlists.h:615

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 1811 of file extconf.c.

◆ AST_LIST_TRAVERSE_SAFE_END

#define AST_LIST_TRAVERSE_SAFE_END   }

Closes a safe loop traversal block.

Definition at line 1874 of file extconf.c.

◆ AST_MAX_EXTENSION

#define AST_MAX_EXTENSION   80

Max length of an extension

Definition at line 2078 of file extconf.c.

◆ AST_MUTEX_DEFINE_STATIC

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

Definition at line 504 of file extconf.c.

◆ AST_MUTEX_INIT_VALUE

#define AST_MUTEX_INIT_VALUE   ((ast_mutex_t) PTHREAD_MUTEX_INIT_VALUE)

Definition at line 467 of file extconf.c.

◆ AST_MUTEX_INITIALIZER

#define AST_MUTEX_INITIALIZER   __use_AST_MUTEX_DEFINE_STATIC_rather_than_AST_MUTEX_INITIALIZER__

Definition at line 506 of file extconf.c.

◆ AST_MUTEX_KIND

#define AST_MUTEX_KIND   PTHREAD_MUTEX_RECURSIVE

Definition at line 194 of file extconf.c.

◆ ast_opt_always_fork

#define ast_opt_always_fork   ast_test_flag(&ast_options, AST_OPT_FLAG_ALWAYS_FORK)

Definition at line 1385 of file extconf.c.

◆ ast_opt_cache_record_files

#define ast_opt_cache_record_files   ast_test_flag(&ast_options, AST_OPT_FLAG_CACHE_RECORD_FILES)

Definition at line 1379 of file extconf.c.

◆ ast_opt_console

#define ast_opt_console   ast_test_flag(&ast_options, AST_OPT_FLAG_CONSOLE)

Definition at line 1369 of file extconf.c.

◆ ast_opt_dont_warn

#define ast_opt_dont_warn   ast_test_flag(&ast_options, AST_OPT_FLAG_DONT_WARN)

Definition at line 1384 of file extconf.c.

◆ ast_opt_dump_core

#define ast_opt_dump_core   ast_test_flag(&ast_options, AST_OPT_FLAG_DUMP_CORE)

Definition at line 1378 of file extconf.c.

◆ ast_opt_exec

#define ast_opt_exec   ast_test_flag(&ast_options, AST_OPT_FLAG_EXEC)

Definition at line 1373 of file extconf.c.

◆ ast_opt_exec_includes

#define ast_opt_exec_includes   ast_test_flag(&ast_options, AST_OPT_FLAG_EXEC_INCLUDES)

Definition at line 1366 of file extconf.c.

◆ ast_opt_high_priority

#define ast_opt_high_priority   ast_test_flag(&ast_options, AST_OPT_FLAG_HIGH_PRIORITY)

Definition at line 1370 of file extconf.c.

◆ ast_opt_init_keys

#define ast_opt_init_keys   ast_test_flag(&ast_options, AST_OPT_FLAG_INIT_KEYS)

Definition at line 1371 of file extconf.c.

◆ ast_opt_mute

#define ast_opt_mute   ast_test_flag(&ast_options, AST_OPT_FLAG_MUTE)

Definition at line 1386 of file extconf.c.

◆ ast_opt_no_color

#define ast_opt_no_color   ast_test_flag(&ast_options, AST_OPT_FLAG_NO_COLOR)

Definition at line 1374 of file extconf.c.

◆ ast_opt_no_fork

#define ast_opt_no_fork   ast_test_flag(&ast_options, AST_OPT_FLAG_NO_FORK)

Definition at line 1367 of file extconf.c.

◆ ast_opt_override_config

#define ast_opt_override_config   ast_test_flag(&ast_options, AST_OPT_FLAG_OVERRIDE_CONFIG)

Definition at line 1381 of file extconf.c.

◆ ast_opt_priority_jumping

#define ast_opt_priority_jumping   ast_test_flag(&ast_options, AST_OPT_FLAG_PRIORITY_JUMPING)

Definition at line 1377 of file extconf.c.

◆ ast_opt_quiet

#define ast_opt_quiet   ast_test_flag(&ast_options, AST_OPT_FLAG_QUIET)

Definition at line 1368 of file extconf.c.

◆ ast_opt_reconnect

#define ast_opt_reconnect   ast_test_flag(&ast_options, AST_OPT_FLAG_RECONNECT)

Definition at line 1382 of file extconf.c.

◆ ast_opt_remote

#define ast_opt_remote   ast_test_flag(&ast_options, AST_OPT_FLAG_REMOTE)

Definition at line 1372 of file extconf.c.

◆ ast_opt_timestamp

#define ast_opt_timestamp   ast_test_flag(&ast_options, AST_OPT_FLAG_TIMESTAMP)

Definition at line 1380 of file extconf.c.

◆ ast_opt_transcode_via_slin

#define ast_opt_transcode_via_slin   ast_test_flag(&ast_options, AST_OPT_FLAG_TRANSCODE_VIA_SLIN)

Definition at line 1376 of file extconf.c.

◆ ast_opt_transmit_silence

#define ast_opt_transmit_silence   ast_test_flag(&ast_options, AST_OPT_FLAG_TRANSMIT_SILENCE)

Definition at line 1383 of file extconf.c.

◆ ast_pthread_mutex_init

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

Definition at line 479 of file extconf.c.

◆ AST_PTHREADT_NULL

#define AST_PTHREADT_NULL   (pthread_t) -1

Definition at line 180 of file extconf.c.

◆ AST_PTHREADT_STOP

#define AST_PTHREADT_STOP   (pthread_t) -2

Definition at line 181 of file extconf.c.

◆ AST_RWLIST_APPEND_LIST

#define AST_RWLIST_APPEND_LIST   AST_LIST_APPEND_LIST

Definition at line 2005 of file extconf.c.

◆ AST_RWLIST_EMPTY

#define AST_RWLIST_EMPTY   AST_LIST_EMPTY

Definition at line 1735 of file extconf.c.

◆ AST_RWLIST_ENTRY

#define AST_RWLIST_ENTRY   AST_LIST_ENTRY

Definition at line 1699 of file extconf.c.

◆ AST_RWLIST_FIRST

#define AST_RWLIST_FIRST   AST_LIST_FIRST

Definition at line 1707 of file extconf.c.

◆ AST_RWLIST_HEAD

#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
nameThis will be the name of the defined structure.
typeThis 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;
#define AST_RWLIST_HEAD(name, type)
Defines a structure to be used to hold a read/write list of specified type.
Definition: linkedlists.h:199

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 1483 of file extconf.c.

◆ AST_RWLIST_HEAD_DESTROY

#define AST_RWLIST_HEAD_DESTROY (   head)
Value:
{ \
(head)->first = NULL; \
(head)->last = NULL; \
ast_rwlock_destroy(&(head)->lock); \
}

Destroys an rwlist head structure.

Parameters
headThis 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 1912 of file extconf.c.

◆ AST_RWLIST_HEAD_INIT

#define AST_RWLIST_HEAD_INIT (   head)
Value:
{ \
(head)->first = NULL; \
(head)->last = NULL; \
ast_rwlock_init(&(head)->lock); \
}

Initializes an rwlist head structure.

Parameters
headThis 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 1898 of file extconf.c.

◆ AST_RWLIST_HEAD_INIT_VALUE

#define AST_RWLIST_HEAD_INIT_VALUE
Value:
{ \
.first = NULL, \
.last = NULL, \
}
#define AST_RWLOCK_INIT_VALUE
Definition: extconf.c:563

Defines initial values for a declaration of AST_RWLIST_HEAD.

Definition at line 1527 of file extconf.c.

◆ AST_RWLIST_HEAD_SET

#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
headThis is a pointer to the list head structure
entrypointer 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 1658 of file extconf.c.

◆ AST_RWLIST_HEAD_STATIC

#define AST_RWLIST_HEAD_STATIC (   name,
  type 
)
Value:
struct name { \
struct type *first; \
struct type *last; \
ast_rwlock_t lock; \
#define AST_RWLIST_HEAD_INIT_VALUE
Defines initial values for a declaration of AST_RWLIST_HEAD.
Definition: extconf.c:1527

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

Parameters
nameThis will be the name of the defined structure.
typeThis 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:

#define AST_RWLIST_HEAD_STATIC(name, type)
Defines a structure to be used to hold a read/write list of specified type, statically initialized.
Definition: linkedlists.h:333

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

Definition at line 1617 of file extconf.c.

◆ AST_RWLIST_INSERT_AFTER

#define AST_RWLIST_INSERT_AFTER   AST_LIST_INSERT_AFTER

Definition at line 1947 of file extconf.c.

◆ AST_RWLIST_INSERT_BEFORE_CURRENT

#define AST_RWLIST_INSERT_BEFORE_CURRENT   AST_LIST_INSERT_BEFORE_CURRENT

Definition at line 1869 of file extconf.c.

◆ AST_RWLIST_INSERT_HEAD

#define AST_RWLIST_INSERT_HEAD   AST_LIST_INSERT_HEAD

Definition at line 1963 of file extconf.c.

◆ AST_RWLIST_INSERT_TAIL

#define AST_RWLIST_INSERT_TAIL   AST_LIST_INSERT_TAIL

Definition at line 1986 of file extconf.c.

◆ AST_RWLIST_LAST

#define AST_RWLIST_LAST   AST_LIST_LAST

Definition at line 1715 of file extconf.c.

◆ AST_RWLIST_NEXT

#define AST_RWLIST_NEXT   AST_LIST_NEXT

Definition at line 1725 of file extconf.c.

◆ AST_RWLIST_RDLOCK

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

Read locks a list.

Parameters
headThis 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 1424 of file extconf.c.

◆ AST_RWLIST_REMOVE

#define AST_RWLIST_REMOVE   AST_LIST_REMOVE

Definition at line 2055 of file extconf.c.

◆ AST_RWLIST_REMOVE_CURRENT

#define AST_RWLIST_REMOVE_CURRENT   AST_LIST_REMOVE_CURRENT

Definition at line 1846 of file extconf.c.

◆ AST_RWLIST_REMOVE_HEAD

#define AST_RWLIST_REMOVE_HEAD   AST_LIST_REMOVE_HEAD

Definition at line 2027 of file extconf.c.

◆ AST_RWLIST_TRAVERSE

#define AST_RWLIST_TRAVERSE   AST_LIST_TRAVERSE

Definition at line 1776 of file extconf.c.

◆ AST_RWLIST_TRAVERSE_SAFE_BEGIN

#define AST_RWLIST_TRAVERSE_SAFE_BEGIN   AST_LIST_TRAVERSE_SAFE_BEGIN

Definition at line 1823 of file extconf.c.

◆ AST_RWLIST_TRAVERSE_SAFE_END

#define AST_RWLIST_TRAVERSE_SAFE_END   AST_LIST_TRAVERSE_SAFE_END

Definition at line 1876 of file extconf.c.

◆ AST_RWLIST_UNLOCK

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

Attempts to unlock a read/write based list.

Parameters
headThis 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 1435 of file extconf.c.

◆ AST_RWLIST_WRLOCK

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

Write locks a list.

Parameters
headThis 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 1413 of file extconf.c.

◆ AST_RWLOCK_DEFINE_STATIC

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

Definition at line 568 of file extconf.c.

◆ AST_RWLOCK_INIT_VALUE

#define AST_RWLOCK_INIT_VALUE   PTHREAD_RWLOCK_INITIALIZER

Definition at line 563 of file extconf.c.

◆ ast_set2_flag

#define ast_set2_flag (   p,
  value,
  flag 
)

Definition at line 684 of file extconf.c.

◆ ast_test_flag

#define ast_test_flag (   p,
  flag 
)

Definition at line 677 of file extconf.c.

◆ ASTMM_LIBC

#define ASTMM_LIBC   ASTMM_IGNORE

Definition at line 46 of file extconf.c.

◆ BACKGROUND_MATCHEXTEN

#define BACKGROUND_MATCHEXTEN   (1 << 2)

Definition at line 2327 of file extconf.c.

◆ BACKGROUND_NOANSWER

#define BACKGROUND_NOANSWER   (1 << 1)

Definition at line 2326 of file extconf.c.

◆ BACKGROUND_PLAYBACK

#define BACKGROUND_PLAYBACK   (1 << 3)

Definition at line 2328 of file extconf.c.

◆ BACKGROUND_SKIP

#define BACKGROUND_SKIP   (1 << 0)

Definition at line 2325 of file extconf.c.

◆ CB_INCR

#define CB_INCR   250

Definition at line 711 of file extconf.c.

◆ COMMENT_END

#define COMMENT_END   "--;"

Definition at line 698 of file extconf.c.

◆ COMMENT_META

#define COMMENT_META   ';'

Definition at line 699 of file extconf.c.

◆ COMMENT_START

#define COMMENT_START   ";--"

Definition at line 697 of file extconf.c.

◆ COMMENT_TAG

#define COMMENT_TAG   '-'

Definition at line 700 of file extconf.c.

◆ DEBUG_M

#define DEBUG_M (   a)
Value:
{ \
a; \
}

Definition at line 96 of file extconf.c.

◆ EVENTLOG

#define EVENTLOG   "event_log"

Definition at line 93 of file extconf.c.

◆ EXT_DATA_SIZE

#define EXT_DATA_SIZE   8192

Definition at line 3604 of file extconf.c.

◆ gethostbyname

#define gethostbyname   __gethostbyname__is__not__reentrant__use__ast_gethostbyname__instead__

Definition at line 508 of file extconf.c.

◆ LOG_DEBUG

#define LOG_DEBUG   __LOG_DEBUG, _A_

Definition at line 121 of file extconf.c.

◆ LOG_DTMF

#define LOG_DTMF   __LOG_DTMF, _A_

Definition at line 157 of file extconf.c.

◆ LOG_ERROR

#define LOG_ERROR   __LOG_ERROR, _A_

Definition at line 145 of file extconf.c.

◆ LOG_EVENT

#define LOG_EVENT   __LOG_EVENT, _A_

Definition at line 127 of file extconf.c.

◆ LOG_NOTICE

#define LOG_NOTICE   __LOG_NOTICE, _A_

Definition at line 133 of file extconf.c.

◆ LOG_VERBOSE

#define LOG_VERBOSE   __LOG_VERBOSE, _A_

Definition at line 151 of file extconf.c.

◆ LOG_WARNING

#define LOG_WARNING   __LOG_WARNING, _A_

Definition at line 139 of file extconf.c.

◆ MAX_INCLUDE_LEVEL

#define MAX_INCLUDE_LEVEL   10

Definition at line 895 of file extconf.c.

◆ MAX_NESTED_COMMENTS

#define MAX_NESTED_COMMENTS   128

Definition at line 696 of file extconf.c.

◆ ONE_MILLION

#define ONE_MILLION   1000000

Definition at line 2261 of file extconf.c.

◆ PRIORITY_HINT

#define PRIORITY_HINT   -1

Special Priority for a hint

Definition at line 2082 of file extconf.c.

◆ pthread_cond_t

#define pthread_cond_t   use_ast_cond_t_instead_of_pthread_cond_t

Definition at line 502 of file extconf.c.

◆ pthread_create

#define pthread_create   __use_ast_pthread_create_instead__

Definition at line 511 of file extconf.c.

◆ pthread_mutex_init

#define pthread_mutex_init   use_ast_mutex_init_instead_of_pthread_mutex_init

Definition at line 501 of file extconf.c.

◆ PTHREAD_MUTEX_INIT_VALUE

#define PTHREAD_MUTEX_INIT_VALUE   PTHREAD_MUTEX_INITIALIZER

Definition at line 193 of file extconf.c.

◆ pthread_mutex_t

#define pthread_mutex_t   use_ast_mutex_t_instead_of_pthread_mutex_t

Definition at line 500 of file extconf.c.

◆ QUEUELOG

#define QUEUELOG   "queue_log"

Definition at line 94 of file extconf.c.

◆ S_OR

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

Definition at line 957 of file extconf.c.

◆ STATUS_NO_CONTEXT

#define STATUS_NO_CONTEXT   1

Definition at line 2449 of file extconf.c.

◆ STATUS_NO_EXTENSION

#define STATUS_NO_EXTENSION   2

Definition at line 2450 of file extconf.c.

◆ STATUS_NO_LABEL

#define STATUS_NO_LABEL   4

Definition at line 2452 of file extconf.c.

◆ STATUS_NO_PRIORITY

#define STATUS_NO_PRIORITY   3

Definition at line 2451 of file extconf.c.

◆ STATUS_SUCCESS

#define STATUS_SUCCESS   5

Definition at line 2453 of file extconf.c.

◆ SWITCH_DATA_LENGTH

#define SWITCH_DATA_LENGTH   256

Definition at line 3611 of file extconf.c.

◆ VAR_BUF_SIZE

#define VAR_BUF_SIZE   4096

Definition at line 2319 of file extconf.c.

◆ VAR_HARDTRAN

#define VAR_HARDTRAN   3

Definition at line 2323 of file extconf.c.

◆ VAR_NORMAL

#define VAR_NORMAL   1

Definition at line 2321 of file extconf.c.

◆ VAR_SOFTTRAN

#define VAR_SOFTTRAN   2

Definition at line 2322 of file extconf.c.

◆ VERBOSE_PREFIX_1

#define VERBOSE_PREFIX_1   " "

Definition at line 100 of file extconf.c.

◆ VERBOSE_PREFIX_2

#define VERBOSE_PREFIX_2   " == "

Definition at line 101 of file extconf.c.

◆ VERBOSE_PREFIX_3

#define VERBOSE_PREFIX_3   " -- "

Definition at line 102 of file extconf.c.

◆ VERBOSE_PREFIX_4

#define VERBOSE_PREFIX_4   " > "

Definition at line 103 of file extconf.c.

Typedef Documentation

◆ ast_cond_t

Definition at line 481 of file extconf.c.

◆ ast_mutex_t

Definition at line 465 of file extconf.c.

◆ ast_rwlock_t

typedef pthread_rwlock_t ast_rwlock_t

Definition at line 514 of file extconf.c.

◆ ast_state_cb_type

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

Definition at line 2353 of file extconf.c.

◆ ast_switch_f

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 2105 of file extconf.c.

◆ config_load_func

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 933 of file extconf.c.

◆ realtime_multi_get

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

Definition at line 935 of file extconf.c.

◆ realtime_update

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

Definition at line 936 of file extconf.c.

◆ realtime_var_get

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

Definition at line 934 of file extconf.c.

Enumeration Type Documentation

◆ ast_extension_states

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 2084 of file extconf.c.

2084  {
2085  AST_EXTENSION_REMOVED = -2, /*!< Extension removed */
2086  AST_EXTENSION_DEACTIVATED = -1, /*!< Extension hint removed */
2087  AST_EXTENSION_NOT_INUSE = 0, /*!< No device INUSE or BUSY */
2088  AST_EXTENSION_INUSE = 1 << 0, /*!< One or more devices INUSE */
2089  AST_EXTENSION_BUSY = 1 << 1, /*!< All devices BUSY */
2090  AST_EXTENSION_UNAVAILABLE = 1 << 2, /*!< All devices UNAVAILABLE/UNREGISTERED */
2091  AST_EXTENSION_RINGING = 1 << 3, /*!< All devices RINGING */
2092  AST_EXTENSION_ONHOLD = 1 << 4, /*!< All devices ONHOLD */
2093 };
@ AST_EXTENSION_REMOVED
Definition: extconf.c:2085
@ AST_EXTENSION_RINGING
Definition: extconf.c:2091
@ AST_EXTENSION_NOT_INUSE
Definition: extconf.c:2087
@ AST_EXTENSION_INUSE
Definition: extconf.c:2088
@ AST_EXTENSION_UNAVAILABLE
Definition: extconf.c:2090
@ AST_EXTENSION_ONHOLD
Definition: extconf.c:2092
@ AST_EXTENSION_BUSY
Definition: extconf.c:2089
@ AST_EXTENSION_DEACTIVATED
Definition: extconf.c:2086

◆ ast_option_flags

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_CACHE_MEDIA_FRAMES 

Cache media frames for performance

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_REF_DEBUG 

Reference Debugging

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_TRACE_MODULE 

There is a per-module trace setting

AST_OPT_FLAG_LIGHT_BACKGROUND 

Terminal colors should be adjusted for a light-colored background

AST_OPT_FLAG_HIDE_MESSAGING_AMI_EVENTS 

Make the global Message channel an internal channel to suppress AMI events

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_GENERIC_PLC_ON_EQUAL_CODECS 

Generic PLC onm equal codecs

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_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_LIGHT_BACKGROUND 

Terminal colors should be adjusted for a light-colored background

AST_OPT_FLAG_FORCE_BLACK_BACKGROUND 

Force black background

Definition at line 1308 of file extconf.c.

1308  {
1309  /*! Allow \#exec in config files */
1310  AST_OPT_FLAG_EXEC_INCLUDES = (1 << 0),
1311  /*! Do not fork() */
1312  AST_OPT_FLAG_NO_FORK = (1 << 1),
1313  /*! Keep quiet */
1314  AST_OPT_FLAG_QUIET = (1 << 2),
1315  /*! Console mode */
1316  AST_OPT_FLAG_CONSOLE = (1 << 3),
1317  /*! Run in realtime Linux priority */
1318  AST_OPT_FLAG_HIGH_PRIORITY = (1 << 4),
1319  /*! Initialize keys for RSA authentication */
1320  AST_OPT_FLAG_INIT_KEYS = (1 << 5),
1321  /*! Remote console */
1322  AST_OPT_FLAG_REMOTE = (1 << 6),
1323  /*! Execute an asterisk CLI command upon startup */
1324  AST_OPT_FLAG_EXEC = (1 << 7),
1325  /*! Don't use termcap colors */
1326  AST_OPT_FLAG_NO_COLOR = (1 << 8),
1327  /*! Are we fully started yet? */
1328  AST_OPT_FLAG_FULLY_BOOTED = (1 << 9),
1329  /*! Trascode via signed linear */
1330  AST_OPT_FLAG_TRANSCODE_VIA_SLIN = (1 << 10),
1331  /*! Dump core on a seg fault */
1332  AST_OPT_FLAG_DUMP_CORE = (1 << 12),
1333  /*! Cache sound files */
1334  AST_OPT_FLAG_CACHE_RECORD_FILES = (1 << 13),
1335  /*! Display timestamp in CLI verbose output */
1336  AST_OPT_FLAG_TIMESTAMP = (1 << 14),
1337  /*! Override config */
1338  AST_OPT_FLAG_OVERRIDE_CONFIG = (1 << 15),
1339  /*! Reconnect */
1340  AST_OPT_FLAG_RECONNECT = (1 << 16),
1341  /*! Transmit Silence during Record() and DTMF Generation */
1342  AST_OPT_FLAG_TRANSMIT_SILENCE = (1 << 17),
1343  /*! Suppress some warnings */
1344  AST_OPT_FLAG_DONT_WARN = (1 << 18),
1345  /*! Always fork, even if verbose or debug settings are non-zero */
1346  AST_OPT_FLAG_ALWAYS_FORK = (1 << 21),
1347  /*! Disable log/verbose output to remote consoles */
1348  AST_OPT_FLAG_MUTE = (1 << 22),
1349  /*! There is a per-file debug setting */
1350  AST_OPT_FLAG_DEBUG_FILE = (1 << 23),
1351  /*! Terminal colors should be adjusted for a light-colored background */
1352  AST_OPT_FLAG_LIGHT_BACKGROUND = (1 << 25),
1353  /*! Force black background */
1355 };
@ AST_OPT_FLAG_HIGH_PRIORITY
Definition: extconf.c:1318
@ AST_OPT_FLAG_TRANSCODE_VIA_SLIN
Definition: extconf.c:1330
@ AST_OPT_FLAG_EXEC_INCLUDES
Definition: extconf.c:1310
@ AST_OPT_FLAG_NO_COLOR
Definition: extconf.c:1326
@ AST_OPT_FLAG_NO_FORK
Definition: extconf.c:1312
@ AST_OPT_FLAG_DEBUG_FILE
Definition: extconf.c:1350
@ AST_OPT_FLAG_TRANSMIT_SILENCE
Definition: extconf.c:1342
@ AST_OPT_FLAG_ALWAYS_FORK
Definition: extconf.c:1346
@ AST_OPT_FLAG_QUIET
Definition: extconf.c:1314
@ AST_OPT_FLAG_MUTE
Definition: extconf.c:1348
@ AST_OPT_FLAG_OVERRIDE_CONFIG
Definition: extconf.c:1338
@ AST_OPT_FLAG_TIMESTAMP
Definition: extconf.c:1336
@ AST_OPT_FLAG_EXEC
Definition: extconf.c:1324
@ AST_OPT_FLAG_CACHE_RECORD_FILES
Definition: extconf.c:1334
@ AST_OPT_FLAG_FULLY_BOOTED
Definition: extconf.c:1328
@ AST_OPT_FLAG_INIT_KEYS
Definition: extconf.c:1320
@ AST_OPT_FLAG_CONSOLE
Definition: extconf.c:1316
@ AST_OPT_FLAG_DONT_WARN
Definition: extconf.c:1344
@ AST_OPT_FLAG_FORCE_BLACK_BACKGROUND
Definition: extconf.c:1354
@ AST_OPT_FLAG_LIGHT_BACKGROUND
Definition: extconf.c:1352
@ AST_OPT_FLAG_REMOTE
Definition: extconf.c:1322
@ AST_OPT_FLAG_DUMP_CORE
Definition: extconf.c:1332
@ AST_OPT_FLAG_RECONNECT
Definition: extconf.c:1340

Function Documentation

◆ __ast_context_create()

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

Definition at line 4707 of file extconf.c.

4708 {
4709  struct ast_context *tmp, **loc_contexts;
4710  int length = sizeof(struct ast_context) + strlen(name) + 1;
4711 
4712  if (!extcontexts) {
4714  loc_contexts = &contexts;
4715  } else
4716  loc_contexts = extcontexts;
4717 
4718  for (tmp = *loc_contexts; tmp; tmp = tmp->next) {
4719  if (!strcasecmp(tmp->name, name)) {
4720  if (!existsokay) {
4721  ast_log(LOG_WARNING, "Tried to register context '%s', already in use\n", name);
4722  tmp = NULL;
4723  }
4724  if (!extcontexts)
4726  return tmp;
4727  }
4728  }
4729  if ((tmp = ast_calloc(1, length))) {
4730  ast_rwlock_init(&tmp->lock);
4731  ast_mutex_init(&tmp->macrolock);
4732  strcpy(tmp->name, name);
4733  tmp->root = NULL;
4734  tmp->registrar = registrar;
4735  tmp->next = *loc_contexts;
4736  tmp->includes = NULL;
4737  tmp->ignorepats = NULL;
4738  *loc_contexts = tmp;
4739  if (option_debug)
4740  ast_log(LOG_DEBUG, "Registered context '%s'\n", tmp->name);
4741  if (option_verbose > 2)
4742  ast_verbose( VERBOSE_PREFIX_3 "Registered extension context '%s'\n", tmp->name);
4743  }
4744 
4745  if (!extcontexts)
4747  return tmp;
4748 }
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:202
static int tmp()
Definition: bt_open.c:389
#define VERBOSE_PREFIX_3
Definition: extconf.c:102
static int ast_wrlock_contexts(void)
Definition: extconf.c:4610
static int ast_mutex_init(ast_mutex_t *pmutex)
Definition: extconf.c:469
#define LOG_DEBUG
Definition: extconf.c:121
void ast_verbose(const char *fmt,...)
Definition: extconf.c:2206
static struct ast_context * contexts
Definition: extconf.c:3598
static int ast_unlock_contexts(void)
Definition: extconf.c:4615
static void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Definition: extconf.c:2194
#define LOG_WARNING
Definition: extconf.c:139
static int ast_rwlock_init(ast_rwlock_t *prwlock)
Definition: extconf.c:516
int option_debug
Definition: options.c:69
int option_verbose
Definition: options.c:67
static char * registrar
Definition: pbx_ael.c:78
ast_context: An extension context - must remain in sync with fake_context
Definition: pbx.c:284

References ast_calloc, ast_log(), ast_mutex_init(), ast_rwlock_init(), ast_unlock_contexts(), ast_verbose(), ast_wrlock_contexts(), contexts, LOG_DEBUG, LOG_WARNING, name, NULL, option_debug, option_verbose, registrar, tmp(), and VERBOSE_PREFIX_3.

Referenced by ast_context_find_or_create(), and localized_context_find_or_create().

◆ __ast_context_destroy()

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

Definition at line 5503 of file extconf.c.

5504 {
5505  struct ast_context *tmp, *tmpl=NULL;
5506  struct ast_include *tmpi;
5507  struct ast_sw *sw;
5508  struct ast_exten *e, *el, *en;
5509  struct ast_ignorepat *ipi;
5510 
5511  for (tmp = contexts; tmp; ) {
5512  struct ast_context *next; /* next starting point */
5513  for (; tmp; tmpl = tmp, tmp = tmp->next) {
5514  if (option_debug)
5515  ast_log(LOG_DEBUG, "check ctx %s %s\n", tmp->name, tmp->registrar);
5516  if ( (!registrar || !strcasecmp(registrar, tmp->registrar)) &&
5517  (!con || !strcasecmp(tmp->name, con->name)) )
5518  break; /* found it */
5519  }
5520  if (!tmp) /* not found, we are done */
5521  break;
5523  if (option_debug)
5524  ast_log(LOG_DEBUG, "delete ctx %s %s\n", tmp->name, tmp->registrar);
5525  next = tmp->next;
5526  if (tmpl)
5527  tmpl->next = next;
5528  else
5529  contexts = next;
5530  /* Okay, now we're safe to let it go -- in a sense, we were
5531  ready to let it go as soon as we locked it. */
5533  for (tmpi = tmp->includes; tmpi; ) { /* Free includes */
5534  struct ast_include *tmpil = tmpi;
5535  tmpi = tmpi->next;
5536  free(tmpil);
5537  }
5538  for (ipi = tmp->ignorepats; ipi; ) { /* Free ignorepats */
5539  struct ast_ignorepat *ipl = ipi;
5540  ipi = ipi->next;
5541  free(ipl);
5542  }
5543  while ((sw = AST_LIST_REMOVE_HEAD(&tmp->alts, list)))
5544  free(sw);
5545  for (e = tmp->root; e;) {
5546  for (en = e->peer; en;) {
5547  el = en;
5548  en = en->peer;
5549  destroy_exten(el);
5550  }
5551  el = e;
5552  e = e->next;
5553  destroy_exten(el);
5554  }
5555  ast_rwlock_destroy(&tmp->lock);
5556  free(tmp);
5557  /* if we have a specific match, we are done, otherwise continue */
5558  tmp = con ? NULL : next;
5559  }
5560 }
static EditLine * el
Definition: asterisk.c:340
static int ast_wrlock_context(struct ast_context *con)
Definition: extconf.c:4620
static int ast_rwlock_destroy(ast_rwlock_t *prwlock)
Definition: extconf.c:529
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
Definition: extconf.c:2016
static int ast_unlock_context(struct ast_context *con)
Definition: extconf.c:4625
static void destroy_exten(struct ast_exten *e)
Definition: extconf.c:3766
void free()
char name[0]
Definition: pbx.c:297
struct ast_context * next
Definition: pbx.c:289
ast_exten: An extension The dialplan is saved as a linked list with each context having it's own link...
Definition: pbx.c:237
struct ast_exten * peer
Definition: pbx.c:250
struct ast_exten * next
Definition: pbx.c:256
ast_ignorepat: Ignore patterns in dial plan
Definition: pbx_ignorepat.c:37
struct ast_ignorepat * next
Definition: extconf.c:2388
ast_include: include= support in extensions.conf
Definition: pbx_include.c:37
struct ast_include * next
Definition: extconf.c:2370
ast_sw: Switch statement in extensions.conf
Definition: pbx_sw.c:37

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

Referenced by ast_merge_contexts_and_delete(), and localized_context_destroy().

◆ _extension_match_core()

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

Definition at line 4192 of file extconf.c.

4193 {
4194  mode &= E_MATCH_MASK; /* only consider the relevant bits */
4195 
4196  if ( (mode == E_MATCH) && (pattern[0] == '_') && (strcasecmp(pattern,data)==0) ) /* note: if this test is left out, then _x. will not match _x. !!! */
4197  return 1;
4198 
4199  if (pattern[0] != '_') { /* not a pattern, try exact or partial match */
4200  int ld = strlen(data), lp = strlen(pattern);
4201 
4202  if (lp < ld) /* pattern too short, cannot match */
4203  return 0;
4204  /* depending on the mode, accept full or partial match or both */
4205  if (mode == E_MATCH)
4206  return !strcmp(pattern, data); /* 1 on match, 0 on fail */
4207  if (ld == 0 || !strncasecmp(pattern, data, ld)) /* partial or full match */
4208  return (mode == E_MATCHMORE) ? lp > ld : 1; /* XXX should consider '!' and '/' ? */
4209  else
4210  return 0;
4211  }
4212  pattern++; /* skip leading _ */
4213  /*
4214  * XXX below we stop at '/' which is a separator for the CID info. However we should
4215  * not store '/' in the pattern at all. When we insure it, we can remove the checks.
4216  */
4217  while (*data && *pattern && *pattern != '/') {
4218  const char *end;
4219 
4220  if (*data == '-') { /* skip '-' in data (just a separator) */
4221  data++;
4222  continue;
4223  }
4224  switch (toupper(*pattern)) {
4225  case '[': /* a range */
4226  end = strchr(pattern+1, ']'); /* XXX should deal with escapes ? */
4227  if (end == NULL) {
4228  ast_log(LOG_WARNING, "Wrong usage of [] in the extension\n");
4229  return 0; /* unconditional failure */
4230  }
4231  for (pattern++; pattern != end; pattern++) {
4232  if (pattern+2 < end && pattern[1] == '-') { /* this is a range */
4233  if (*data >= pattern[0] && *data <= pattern[2])
4234  break; /* match found */
4235  else {
4236  pattern += 2; /* skip a total of 3 chars */
4237  continue;
4238  }
4239  } else if (*data == pattern[0])
4240  break; /* match found */
4241  }
4242  if (pattern == end)
4243  return 0;
4244  pattern = end; /* skip and continue */
4245  break;
4246  case 'N':
4247  if (*data < '2' || *data > '9')
4248  return 0;
4249  break;
4250  case 'X':
4251  if (*data < '0' || *data > '9')
4252  return 0;
4253  break;
4254  case 'Z':
4255  if (*data < '1' || *data > '9')
4256  return 0;
4257  break;
4258  case '.': /* Must match, even with more digits */
4259  return 1;
4260  case '!': /* Early match */
4261  return 2;
4262  case ' ':
4263  case '-': /* Ignore these in patterns */
4264  data--; /* compensate the final data++ */
4265  break;
4266  default:
4267  if (*data != *pattern)
4268  return 0;
4269  }
4270  data++;
4271  pattern++;
4272  }
4273  if (*data) /* data longer than pattern, no match */
4274  return 0;
4275  /*
4276  * match so far, but ran off the end of the data.
4277  * Depending on what is next, determine match or not.
4278  */
4279  if (*pattern == '\0' || *pattern == '/') /* exact match */
4280  return (mode == E_MATCHMORE) ? 0 : 1; /* this is a failure for E_MATCHMORE */
4281  else if (*pattern == '!') /* early match */
4282  return 2;
4283  else /* partial match */
4284  return (mode == E_MATCH) ? 0 : 1; /* this is a failure for E_MATCH */
4285 }
char * end
Definition: eagi_proxy.c:73
@ E_MATCH_MASK
Definition: extconf.h:219
@ E_MATCH
Definition: extconf.h:218
@ E_MATCHMORE
Definition: extconf.h:216

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

Referenced by extension_match_core().

◆ _null_sig_handler()

static void _null_sig_handler ( int  sig)
static

NULL handler so we can collect the child exit status.

Definition at line 789 of file extconf.c.

790 {
791 
792 }

◆ add_pri()

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 3676 of file extconf.c.

3678 {
3679  struct ast_exten *ep;
3680 
3681  for (ep = NULL; e ; ep = e, e = e->peer) {
3682  if (e->priority >= tmp->priority)
3683  break;
3684  }
3685  if (!e) { /* go at the end, and ep is surely set because the list is not empty */
3686  ep->peer = tmp;
3687  return 0; /* success */
3688  }
3689  if (e->priority == tmp->priority) {
3690  /* Can't have something exactly the same. Is this a
3691  replacement? If so, replace, otherwise, bonk. */
3692  if (!replace) {
3693  ast_log(LOG_WARNING, "Unable to register extension '%s', priority %d in '%s', already in use\n", tmp->exten, tmp->priority, con->name);
3694  tmp->datad(tmp->data);
3695  free(tmp);
3696  return -1;
3697  }
3698  /* we are replacing e, so copy the link fields and then update
3699  * whoever pointed to e to point to us
3700  */
3701  tmp->next = e->next; /* not meaningful if we are not first in the peer list */
3702  tmp->peer = e->peer; /* always meaningful */
3703  if (ep) /* We're in the peer list, just insert ourselves */
3704  ep->peer = tmp;
3705  else if (el) /* We're the first extension. Take over e's functions */
3706  el->next = tmp;
3707  else /* We're the very first extension. */
3708  con->root = tmp;
3709  if (tmp->priority == PRIORITY_HINT)
3710  ast_change_hint(e,tmp);
3711  /* Destroy the old one */
3712  e->datad(e->data);
3713  free(e);
3714  } else { /* Slip ourselves in just before e */
3715  tmp->peer = e;
3716  tmp->next = e->next; /* extension chain, or NULL if e is not the first extension */
3717  if (ep) /* Easy enough, we're just in the peer list */
3718  ep->peer = tmp;
3719  else { /* we are the first in some peer list, so link in the ext list */
3720  if (el)
3721  el->next = tmp; /* in the middle... */
3722  else
3723  con->root = tmp; /* ... or at the head */
3724  e->next = NULL; /* e is no more at the head, so e->next must be reset */
3725  }
3726  /* And immediately return success. */
3727  if (tmp->priority == PRIORITY_HINT)
3728  ast_add_hint(tmp);
3729  }
3730  return 0;
3731 }
#define PRIORITY_HINT
Definition: extconf.c:2082
static int ast_change_hint(struct ast_exten *oe, struct ast_exten *ne)
ast_change_hint: Change hint for an extension
Definition: extconf.c:3626
static int ast_add_hint(struct ast_exten *e)
ast_add_hint: Add hint to hint list, check initial extension state
Definition: extconf.c:3643
static int replace(struct ast_channel *chan, const char *cmd, char *data, struct ast_str **buf, ssize_t len)
Definition: func_strings.c:815
struct ast_exten * root
Definition: pbx.c:286

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

Referenced by ast_add_extension2().

◆ ALLOC_COMMENT()

static struct ast_comment* ALLOC_COMMENT ( const char *  buffer)
static

Definition at line 877 of file extconf.c.

878 {
879  struct ast_comment *x = ast_calloc(1,sizeof(struct ast_comment)+strlen(buffer)+1);
880  strcpy(x->cmt, buffer);
881  return x;
882 }
Structure to keep comments for rewriting configuration files.
Definition: main/config.c:84
char cmt[0]
Definition: main/config.c:87

References ast_calloc, and ast_comment::cmt.

Referenced by process_text_line().

◆ ast_add_extension2()

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 4775 of file extconf.c.

4779 {
4780  /*
4781  * Sort extensions (or patterns) according to the rules indicated above.
4782  * These are implemented by the function ext_cmp()).
4783  * All priorities for the same ext/pattern/cid are kept in a list,
4784  * using the 'peer' field as a link field..
4785  */
4786  struct ast_exten *tmp, *e, *el = NULL;
4787  int res;
4788  int length;
4789  char *p;
4790 
4791  /* if we are adding a hint, and there are global variables, and the hint
4792  contains variable references, then expand them --- NOT In this situation!!!
4793  */
4794 
4795  length = sizeof(struct ast_exten);
4796  length += strlen(extension) + 1;
4797  length += strlen(application) + 1;
4798  if (label)
4799  length += strlen(label) + 1;
4800  if (callerid)
4801  length += strlen(callerid) + 1;
4802  else
4803  length ++; /* just the '\0' */
4804 
4805  /* Be optimistic: Build the extension structure first */
4806  if (datad == NULL)
4807  datad = null_datad;
4808  if (!(tmp = ast_calloc(1, length)))
4809  return -1;
4810 
4811  /* use p as dst in assignments, as the fields are const char * */
4812  p = tmp->stuff;
4813  if (label) {
4814  tmp->label = p;
4815  strcpy(p, label);
4816  p += strlen(label) + 1;
4817  }
4818  tmp->exten = p;
4819  p += ext_strncpy(p, extension, strlen(extension) + 1) + 1;
4820  tmp->priority = priority;
4821  tmp->cidmatch = p; /* but use p for assignments below */
4822  if (callerid) {
4823  p += ext_strncpy(p, callerid, strlen(callerid) + 1) + 1;
4824  tmp->matchcid = 1;
4825  } else {
4826  *p++ = '\0';
4827  tmp->matchcid = 0;
4828  }
4829  tmp->app = p;
4830  strcpy(p, application);
4831  tmp->parent = con;
4832  tmp->data = data;
4833  tmp->datad = datad;
4834  tmp->registrar = registrar;
4835 
4836  res = 0; /* some compilers will think it is uninitialized otherwise */
4837  for (e = con->root; e; el = e, e = e->next) { /* scan the extension list */
4838  res = ext_cmp(e->exten, extension);
4839  if (res == 0) { /* extension match, now look at cidmatch */
4840  if (!e->matchcid && !tmp->matchcid)
4841  res = 0;
4842  else if (tmp->matchcid && !e->matchcid)
4843  res = 1;
4844  else if (e->matchcid && !tmp->matchcid)
4845  res = -1;
4846  else
4847  res = strcasecmp(e->cidmatch, tmp->cidmatch);
4848  }
4849  if (res >= 0)
4850  break;
4851  }
4852  if (e && res == 0) { /* exact match, insert in the pri chain */
4853  res = add_pri(con, tmp, el, e, replace);
4854  if (res < 0) {
4855  errno = EEXIST; /* XXX do we care ? */
4856  return 0; /* XXX should we return -1 maybe ? */
4857  }
4858  } else {
4859  /*
4860  * not an exact match, this is the first entry with this pattern,
4861  * so insert in the main list right before 'e' (if any)
4862  */
4863  tmp->next = e;
4864  if (el)
4865  el->next = tmp;
4866  else
4867  con->root = tmp;
4868  if (tmp->priority == PRIORITY_HINT)
4869  ast_add_hint(tmp);
4870  }
4871  if (option_debug) {
4872  if (tmp->matchcid) {
4873  ast_log(LOG_DEBUG, "Added extension '%s' priority %d (CID match '%s') to %s\n",
4874  tmp->exten, tmp->priority, tmp->cidmatch, con->name);
4875  } else {
4876  ast_log(LOG_DEBUG, "Added extension '%s' priority %d to %s\n",
4877  tmp->exten, tmp->priority, con->name);
4878  }
4879  }
4880  if (option_verbose > 2) {
4881  if (tmp->matchcid) {
4882  ast_verbose( VERBOSE_PREFIX_3 "Added extension '%s' priority %d (CID match '%s')to %s\n",
4883  tmp->exten, tmp->priority, tmp->cidmatch, con->name);
4884  } else {
4885  ast_verbose( VERBOSE_PREFIX_3 "Added extension '%s' priority %d to %s\n",
4886  tmp->exten, tmp->priority, con->name);
4887  }
4888  }
4889  return 0;
4890 }
static int priority
static int ext_cmp(const char *a, const char *b)
the full routine to compare extensions in rules.
Definition: extconf.c:3945
static int ext_strncpy(char *dst, const char *src, int len)
copy a string skipping whitespace
Definition: extconf.c:3972
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
Definition: extconf.c:3676
static void null_datad(void *foo)
Definition: extconf.c:2743
int errno
char * exten
Definition: pbx.c:238
const char * cidmatch
Definition: pbx.c:241
void * data
Definition: pbx.c:248
void(* datad)(void *)
Definition: pbx.c:249
const char * label
Definition: pbx.c:244
int matchcid
Definition: pbx.c:240
structure to hold extensions

References add_pri(), 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(), option_debug, option_verbose, priority, PRIORITY_HINT, registrar, replace(), ast_context::root, tmp(), and VERBOSE_PREFIX_3.

Referenced by localized_add_extension2(), and pbx_load_config().

◆ ast_add_hint()

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 3643 of file extconf.c.

3644 {
3645  struct ast_hint *hint;
3646 
3647  if (!e)
3648  return -1;
3649 
3650 
3651  /* Search if hint exists, do nothing */
3652  AST_RWLIST_TRAVERSE(&hints, hint, list) {
3653  if (hint->exten == e) {
3654  if (option_debug > 1)
3655  ast_log(LOG_DEBUG, "HINTS: Not re-adding existing hint %s: %s\n", ast_get_extension_name(e), ast_get_extension_app(e));
3656  return -1;
3657  }
3658  }
3659 
3660  if (option_debug > 1)
3661  ast_log(LOG_DEBUG, "HINTS: Adding hint %s: %s\n", ast_get_extension_name(e), ast_get_extension_app(e));
3662 
3663  if (!(hint = ast_calloc(1, sizeof(*hint)))) {
3664  return -1;
3665  }
3666  /* Initialize and insert new item at the top */
3667  hint->exten = e;
3668  AST_RWLIST_INSERT_HEAD(&hints, hint, list);
3669 
3670  return 0;
3671 }
static const char * ast_get_extension_name(struct ast_exten *exten)
Definition: extconf.c:3618
static const char * ast_get_extension_app(struct ast_exten *e)
Definition: extconf.c:3613
#define AST_RWLIST_TRAVERSE
Definition: extconf.c:1776
#define AST_RWLIST_INSERT_HEAD
Definition: extconf.c:1963
Structure for dial plan hints.
Definition: pbx.c:324
struct ast_exten * exten
Hint extension.
Definition: pbx.c:331

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

Referenced by add_pri(), and ast_add_extension2().

◆ ast_app_separate_args()

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

Definition at line 2487 of file extconf.c.

2488 {
2489  int argc;
2490  char *scan;
2491  int paren = 0, quote = 0;
2492 
2493  if (!buf || !array || !arraylen)
2494  return 0;
2495 
2496  memset(array, 0, arraylen * sizeof(*array));
2497 
2498  scan = buf;
2499 
2500  for (argc = 0; *scan && (argc < arraylen - 1); argc++) {
2501  array[argc] = scan;
2502  for (; *scan; scan++) {
2503  if (*scan == '(')
2504  paren++;
2505  else if (*scan == ')') {
2506  if (paren)
2507  paren--;
2508  } else if (*scan == '"' && delim != '"') {
2509  quote = quote ? 0 : 1;
2510  /* Remove quote character from argument */
2511  memmove(scan, scan + 1, strlen(scan));
2512  scan--;
2513  } else if (*scan == '\\') {
2514  /* Literal character, don't parse */
2515  memmove(scan, scan + 1, strlen(scan));
2516  } else if ((*scan == delim) && !paren && !quote) {
2517  *scan++ = '\0';
2518  break;
2519  }
2520  }
2521  }
2522 
2523  if (*scan)
2524  array[argc++] = scan;
2525 
2526  return argc;
2527 }
#define paren
Definition: ael_lex.c:973
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
static int array(struct ast_channel *chan, const char *cmd, char *var, const char *value)
static int quote(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)

References array(), buf, paren, and quote().

Referenced by pbx_builtin_setvar().

◆ ast_atomic_dec_and_test()

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.

Definition at line 634 of file extconf.c.

637 {

◆ ast_atomic_fetchadd_int()

int ast_atomic_fetchadd_int ( 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.

Definition at line 593 of file extconf.c.

596 {

◆ ast_build_timing()

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

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

Parameters
iPointer to an ast_timing structure.
info_inStandard string containing a timerange, weekday range, monthday range, and month range, as well as an optional timezone.
Return values
1on success.
0on failure.

Definition at line 3807 of file extconf.c.

3808 {
3809  char *info;
3810  int j, num_fields, last_sep = -1;
3811 
3812  i->timezone = NULL;
3813 
3814  /* Check for empty just in case */
3815  if (ast_strlen_zero(info_in)) {
3816  return 0;
3817  }
3818 
3819  /* make a copy just in case we were passed a static string */
3820  info = ast_strdupa(info_in);
3821 
3822  /* count the number of fields in the timespec */
3823  for (j = 0, num_fields = 1; info[j] != '\0'; j++) {
3824  if (info[j] == '|' || info[j] == ',') {
3825  last_sep = j;
3826  num_fields++;
3827  }
3828  }
3829 
3830  /* save the timezone, if it is specified */
3831  if (num_fields == 5) {
3832  i->timezone = ast_strdup(info + last_sep + 1);
3833  }
3834 
3835  /* Assume everything except time */
3836  i->monthmask = 0xfff; /* 12 bits */
3837  i->daymask = 0x7fffffffU; /* 31 bits */
3838  i->dowmask = 0x7f; /* 7 bits */
3839  /* on each call, use strsep() to move info to the next argument */
3840  get_timerange(i, strsep(&info, "|,"));
3841  if (info)
3842  i->dowmask = get_range(strsep(&info, "|,"), 7, days, "day of week");
3843  if (info)
3844  i->daymask = get_range(strsep(&info, "|,"), 31, NULL, "day");
3845  if (info)
3846  i->monthmask = get_range(strsep(&info, "|,"), 12, months, "month");
3847  return 1;
3848 }
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:241
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:298
char * days[]
Definition: extconf.c:3776
static void get_timerange(struct ast_timing *i, char *times)
store a bitmask of valid times, one bit each 2 minute
Definition: extconf.c:2683
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,...
Definition: extconf.c:2639
char * months[]
Definition: extconf.c:3788
static force_inline int ast_strlen_zero(const char *s)
Definition: extconf.c:952
char * strsep(char **str, const char *delims)
def info(msg)
unsigned int monthmask
Definition: pbx.h:173
unsigned int daymask
Definition: pbx.h:174
char * timezone
Definition: pbx.h:177
unsigned int dowmask
Definition: pbx.h:175

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

Referenced by ast_context_add_include2(), iftime(), include_alloc(), pbx_builtin_execiftime(), and pbx_builtin_gotoiftime().

◆ ast_category_append()

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

Definition at line 2834 of file extconf.c.

2835 {
2836  if (config->last)
2837  config->last->next = category;
2838  else
2839  config->root = category;
2840  config->last = category;
2841  config->current = category;
2842 }
static const char config[]
Definition: chan_ooh323.c:111

Referenced by process_text_line().

◆ ast_category_browse()

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

Definition at line 3327 of file extconf.c.

3328 {
3329  struct ast_category *cat = NULL;
3330 
3331  if (prev && config->last_browse && (config->last_browse->name == prev))
3332  cat = config->last_browse->next;
3333  else if (!prev && config->root)
3334  cat = config->root;
3335  else if (prev) {
3336  for (cat = config->root; cat; cat = cat->next) {
3337  if (cat->name == prev) {
3338  cat = cat->next;
3339  break;
3340  }
3341  }
3342  if (!cat) {
3343  for (cat = config->root; cat; cat = cat->next) {
3344  if (!strcasecmp(cat->name, prev)) {
3345  cat = cat->next;
3346  break;
3347  }
3348  }
3349  }
3350  }
3351 
3352  if (cat)
3353  cat = next_available_category(cat);
3354 
3355  config->last_browse = cat;
3356  return (cat) ? cat->name : NULL;
3357 }
static struct ast_category * next_available_category(struct ast_category *cat)
Definition: extconf.c:3320
char name[80]
Definition: main/config.c:226
struct ast_category * next
Definition: main/config.c:246
struct ast_category * prev
Definition: main/config.c:244

Referenced by pbx_load_config().

◆ ast_category_destroy()

static void ast_category_destroy ( struct ast_category cat)
static

Definition at line 2846 of file extconf.c.

2847 {
2849  if (cat->file)
2850  free(cat->file);
2851 
2852  free(cat);
2853 }
static void ast_variables_destroy(struct ast_variable *v)
Definition: extconf.c:1262
struct ast_variable * root
Definition: main/config.c:240
char * file
The file name from whence this declaration was read.
Definition: main/config.c:233

Referenced by process_text_line().

◆ ast_category_get()

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

Definition at line 1210 of file extconf.c.

1211 {
1212  return category_get(config, category_name, 0);
1213 }
static struct ast_category * category_get(const struct ast_config *config, const char *category_name, int ignored)
Definition: extconf.c:1192

References category_get(), and config.

Referenced by ast_variable_browse().

◆ ast_category_new()

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

Definition at line 2789 of file extconf.c.

2790 {
2791  struct ast_category *category;
2792 
2793  if ((category = ast_calloc(1, sizeof(*category))))
2794  ast_copy_string(category->name, name, sizeof(category->name));
2795  category->file = strdup(in_file);
2796  category->lineno = lineno; /* if you don't know the lineno, set it to 999999 or something real big */
2797  return category;
2798 }
#define strdup(a)
Definition: astmm.h:163
void ast_copy_string(char *dst, const char *src, size_t size)
Definition: extconf.c:970

Referenced by process_text_line().

◆ ast_change_hint()

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 3626 of file extconf.c.

3627 {
3628  struct ast_hint *hint;
3629  int res = -1;
3630 
3631  AST_RWLIST_TRAVERSE(&hints, hint, list) {
3632  if (hint->exten == oe) {
3633  hint->exten = ne;
3634  res = 0;
3635  break;
3636  }
3637  }
3638 
3639  return res;
3640 }

References AST_RWLIST_TRAVERSE, and ast_hint::exten.

Referenced by add_pri().

◆ ast_check_timing()

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
iPointer to an ast_timing structure.
Return values
1if the time matches.
0if the current time falls outside of the specified range.

Definition at line 4001 of file extconf.c.

4002 {
4003  /* sorry, but this feature will NOT be available
4004  in the standalone version */
4005  return 0;
4006 }

Referenced by iftime(), include_valid(), and pbx_builtin_execiftime().

◆ ast_config_destroy()

static void ast_config_destroy ( struct ast_config cfg)
static

Definition at line 1289 of file extconf.c.

1290 {
1291  struct ast_category *cat, *catn;
1292 
1293  if (!cfg)
1294  return;
1295 
1297 
1298  cat = cfg->root;
1299  while (cat) {
1301  catn = cat;
1302  cat = cat->next;
1303  free(catn);
1304  }
1305  free(cfg);
1306 }
static void ast_includes_destroy(struct ast_config_include *incls)
Definition: extconf.c:1273
struct ast_category * root
Definition: main/config.c:251
struct ast_config_include * includes
Definition: main/config.c:258

Referenced by localized_config_load(), localized_config_load_with_comments(), pbx_load_config(), and process_text_line().

◆ ast_config_get_current_category()

struct ast_category* ast_config_get_current_category ( const struct ast_config cfg)

Retrieve the current category name being built.

API for backend configuration engines while building a configuration set.

Definition at line 2782 of file extconf.c.

2783 {
2784  return cfg->current;
2785 }
struct ast_category * current
Definition: main/config.c:254

References ast_config::current.

Referenced by config_curl(), config_odbc(), and config_text_file_load().

◆ ast_config_internal_load()

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

Definition at line 2863 of file extconf.c.

2864 {
2865  char db[256] = "";
2866  char table[256] = "";
2867  struct ast_config_engine *loader = &text_file_engine;
2868  struct ast_config *result;
2869 
2870  if (cfg->include_level == cfg->max_include_level) {
2871  ast_log(LOG_WARNING, "Maximum Include level (%d) exceeded\n", cfg->max_include_level);
2872  return NULL;
2873  }
2874 
2875  cfg->include_level++;
2876  /* silence is golden!
2877  ast_log(LOG_WARNING, "internal loading file %s level=%d\n", filename, cfg->include_level);
2878  */
2879 
2880  if (strcmp(filename, extconfig_conf) && strcmp(filename, "asterisk.conf") && config_engine_list) {
2881  struct ast_config_engine *eng;
2882 
2883  eng = find_engine(filename, db, sizeof(db), table, sizeof(table));
2884 
2885 
2886  if (eng && eng->load_func) {
2887  loader = eng;
2888  } else {
2889  eng = find_engine("global", db, sizeof(db), table, sizeof(table));
2890  if (eng && eng->load_func)
2891  loader = eng;
2892  }
2893  }
2894 
2895  result = loader->load_func(db, table, filename, cfg, withcomments, suggested_incl_file);
2896  /* silence is golden
2897  ast_log(LOG_WARNING, "finished internal loading file %s level=%d\n", filename, cfg->include_level);
2898  */
2899 
2900  if (result)
2901  result->include_level--;
2902 
2903  return result;
2904 }
static char * table
Definition: cdr_odbc.c:55
static sqlite3 * db
static PGresult * result
Definition: cel_pgsql.c:84
static struct ast_config_engine * config_engine_list
Definition: extconf.c:893
static struct ast_config_engine * find_engine(const char *family, char *database, int dbsiz, char *table, int tabsiz)
Find realtime engine for realtime family.
Definition: extconf.c:2748
static char * extconfig_conf
Definition: extconf.c:702
static struct ast_config_engine text_file_engine
Definition: extconf.c:2855
Configuration engine structure, used to define realtime drivers.
config_load_func * load_func
int include_level
Definition: main/config.c:256
int max_include_level
Definition: main/config.c:257

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

Referenced by localized_config_load(), localized_config_load_with_comments(), and process_text_line().

◆ ast_config_new()

static struct ast_config* ast_config_new ( void  )
static

Definition at line 3275 of file extconf.c.

3276 {
3277  struct ast_config *config;
3278 
3279  if ((config = ast_calloc(1, sizeof(*config))))
3280  config->max_include_level = MAX_INCLUDE_LEVEL;
3281  return config;
3282 }
#define MAX_INCLUDE_LEVEL
Definition: extconf.c:895

Referenced by localized_config_load(), and localized_config_load_with_comments().

◆ ast_config_set_current_category()

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 3363 of file extconf.c.

3364 {
3365  /* cast below is just to silence compiler warning about dropping "const" */
3366  cfg->current = (struct ast_category *) cat;
3367 }

References ast_config::current.

◆ ast_console_puts()

void ast_console_puts ( const char *  string)

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

Definition at line 1350 of file asterisk.c.

1351 {
1352  /* Send to the root console */
1353  fputs(string, stdout);
1354  fflush(stdout);
1355 
1356  /* Send to any network console clients */
1357  ast_network_puts(string);
1358 }
static void ast_network_puts(const char *string)
write the string to all attached console clients
Definition: asterisk.c:1334

◆ ast_context_add_ignorepat2()

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

Definition at line 4568 of file extconf.c.

4569 {
4570  struct ast_ignorepat *ignorepat, *ignorepatc, *ignorepatl = NULL;
4571  int length;
4572  length = sizeof(struct ast_ignorepat);
4573  length += strlen(value) + 1;
4574  if (!(ignorepat = ast_calloc(1, length)))
4575  return -1;
4576  /* The cast to char * is because we need to write the initial value.
4577  * The field is not supposed to be modified otherwise
4578  */
4579  strcpy((char *)ignorepat->pattern, value);
4580  ignorepat->next = NULL;
4581  ignorepat->registrar = registrar;
4582  for (ignorepatc = con->ignorepats; ignorepatc; ignorepatc = ignorepatc->next) {
4583  ignorepatl = ignorepatc;
4584  if (!strcasecmp(ignorepatc->pattern, value)) {
4585  /* Already there */
4586  errno = EEXIST;
4587  return -1;
4588  }
4589  }
4590  if (ignorepatl)
4591  ignorepatl->next = ignorepat;
4592  else
4593  con->ignorepats = ignorepat;
4594  return 0;
4595 
4596 }
struct ast_ignorepats ignorepats
Definition: pbx.c:291
const char pattern[0]
Definition: pbx_ignorepat.c:39
const char * registrar
Definition: pbx_ignorepat.c:38
int value
Definition: syslog.c:37

References ast_calloc, errno, ast_context::ignorepats, ast_ignorepat::next, NULL, ast_ignorepat::pattern, ast_ignorepat::registrar, registrar, and value.

Referenced by localized_context_add_ignorepat2(), and pbx_load_config().

◆ ast_context_add_include2()

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

Definition at line 4502 of file extconf.c.

4504 {
4505  struct ast_include *new_include;
4506  char *c;
4507  struct ast_include *i, *il = NULL; /* include, include_last */
4508  int length;
4509  char *p;
4510 
4511  length = sizeof(struct ast_include);
4512  length += 2 * (strlen(value) + 1);
4513 
4514  /* allocate new include structure ... */
4515  if (!(new_include = ast_calloc(1, length)))
4516  return -1;
4517  /* Fill in this structure. Use 'p' for assignments, as the fields
4518  * in the structure are 'const char *'
4519  */
4520  p = new_include->stuff;
4521  new_include->name = p;
4522  strcpy(p, value);
4523  p += strlen(value) + 1;
4524  new_include->rname = p;
4525  strcpy(p, value);
4526  /* Strip off timing info, and process if it is there */
4527  if ( (c = strchr(p, '|')) || (c = strchr(p, ',')) ) {
4528  *c++ = '\0';
4529  new_include->hastime = ast_build_timing(&(new_include->timing), c);
4530  }
4531  new_include->next = NULL;
4532  new_include->registrar = registrar;
4533 
4534 
4535  /* ... go to last include and check if context is already included too... */
4536  for (i = con->includes; i; i = i->next) {
4537  if (!strcasecmp(i->name, new_include->name)) {
4538  free(new_include);
4539  errno = EEXIST;
4540  return -1;
4541  }
4542  il = i;
4543  }
4544 
4545  /* ... include new context into context list, unlock, return */
4546  if (il)
4547  il->next = new_include;
4548  else
4549  con->includes = new_include;
4550  if (option_verbose > 2)
4551  ast_verbose(VERBOSE_PREFIX_3 "Including context '%s' in context '%s'\n", new_include->name, ast_get_context_name(con));
4552 
4553  return 0;
4554 }
int ast_build_timing(struct ast_timing *i, const char *info_in)
Construct a timing bitmap, for use in time-based conditionals.
Definition: extconf.c:3807
static const char * ast_get_context_name(struct ast_context *con)
Definition: extconf.c:4487
struct ast_includes includes
Definition: pbx.c:290
struct ast_timing timing
Definition: pbx_include.c:46
const char * rname
Definition: pbx_include.c:40
char stuff[0]
Definition: pbx_include.c:47
const char * registrar
Definition: pbx_include.c:42
const char * name
Definition: pbx_include.c:38
static struct test_val c

References ast_build_timing(), ast_calloc, ast_get_context_name(), ast_verbose(), c, errno, free(), ast_include::hastime, ast_context::includes, ast_include::name, ast_include::next, NULL, option_verbose, ast_include::registrar, registrar, ast_include::rname, ast_include::stuff, ast_include::timing, value, and VERBOSE_PREFIX_3.

Referenced by localized_context_add_include2(), and pbx_load_config().

◆ ast_context_add_switch2()

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

Definition at line 4640 of file extconf.c.

4642 {
4643  struct ast_sw *new_sw;
4644  struct ast_sw *i;
4645  int length;
4646  char *p;
4647 
4648  length = sizeof(struct ast_sw);
4649  length += strlen(value) + 1;
4650  if (data)
4651  length += strlen(data);
4652  length++;
4653  if (eval) {
4654  /* Create buffer for evaluation of variables */
4655  length += SWITCH_DATA_LENGTH;
4656  length++;
4657  }
4658 
4659  /* allocate new sw structure ... */
4660  if (!(new_sw = ast_calloc(1, length)))
4661  return -1;
4662  /* ... fill in this structure ... */
4663  p = new_sw->stuff;
4664  new_sw->name = p;
4665  strcpy(new_sw->name, value);
4666  p += strlen(value) + 1;
4667  new_sw->data = p;
4668  if (data) {
4669  strcpy(new_sw->data, data);
4670  p += strlen(data) + 1;
4671  } else {
4672  strcpy(new_sw->data, "");
4673  p++;
4674  }
4675  if (eval)
4676  new_sw->tmpdata = p;
4677  new_sw->eval = eval;
4678  new_sw->registrar = registrar;
4679 
4680  /* ... go to last sw and check if context is already swd too... */
4681  AST_LIST_TRAVERSE(&con->alts, i, list) {
4682  if (!strcasecmp(i->name, new_sw->name) && !strcasecmp(i->data, new_sw->data)) {
4683  free(new_sw);
4684  errno = EEXIST;
4685  return -1;
4686  }
4687  }
4688 
4689  /* ... sw new context into context list, unlock, return */
4690  AST_LIST_INSERT_TAIL(&con->alts, new_sw, list);
4691 
4692  if (option_verbose > 2)
4693  ast_verbose(VERBOSE_PREFIX_3 "Including switch '%s/%s' in context '%s'\n", new_sw->name, new_sw->data, ast_get_context_name(con));
4694 
4695  return 0;
4696 }
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: extconf.c:1773
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
Definition: extconf.c:1976
#define SWITCH_DATA_LENGTH
Definition: extconf.c:3611
struct ast_sws alts
Definition: pbx.c:292
struct ast_sw::@407 list
char stuff[0]
Definition: pbx_sw.c:45
int eval
Definition: pbx_sw.c:43
char * tmpdata
Definition: extconf.c:2381
const char * registrar
Definition: pbx_sw.c:40
const char * data
Definition: pbx_sw.c:42
const char * name
Definition: pbx_sw.c:38

References ast_context::alts, ast_calloc, ast_get_context_name(), AST_LIST_INSERT_TAIL, AST_LIST_TRAVERSE, ast_verbose(), ast_sw::data, errno, ast_sw::eval, free(), ast_sw::list, ast_sw::name, option_verbose, ast_sw::registrar, registrar, ast_sw::stuff, SWITCH_DATA_LENGTH, ast_sw::tmpdata, value, and VERBOSE_PREFIX_3.

Referenced by localized_context_add_switch2(), and pbx_load_config().

◆ ast_context_find()

static struct ast_context* ast_context_find ( const char *  name)
static

Definition at line 4173 of file extconf.c.

4174 {
4175  struct ast_context *tmp = NULL;
4176  while ( (tmp = ast_walk_contexts(tmp)) ) {
4177  if (!name || !strcasecmp(name, tmp->name))
4178  break;
4179  }
4180  return tmp;
4181 }
static struct ast_context * ast_walk_contexts(struct ast_context *con)
Definition: extconf.c:4025

Referenced by ast_context_verify_includes().

◆ ast_context_find_or_create()

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

Definition at line 4982 of file extconf.c.

4983 {
4984  return __ast_context_create(extcontexts, name, registrar, 1);
4985 }
static struct ast_context * __ast_context_create(struct ast_context **extcontexts, const char *name, const char *registrar, int existsokay)
Definition: extconf.c:4707

References __ast_context_create(), name, and registrar.

Referenced by pbx_load_config().

◆ ast_context_ignorepats_count()

int ast_context_ignorepats_count ( struct ast_context con)

Definition at line 4124 of file extconf.c.

4125 {
4126  int c = 0;
4127  struct ast_ignorepat *ip = NULL;
4128 
4129  while ((ip = ast_walk_context_ignorepats(con, ip))) {
4130  c++;
4131  }
4132 
4133  return c;
4134 }
static struct ast_ignorepat * ast_walk_context_ignorepats(struct ast_context *con, struct ast_ignorepat *ip)
Definition: extconf.c:4114

References ast_walk_context_ignorepats(), c, and NULL.

◆ ast_context_includes_count()

int ast_context_includes_count ( struct ast_context con)

Definition at line 4091 of file extconf.c.

4092 {
4093  int c = 0;
4094  struct ast_include *inc = NULL;
4095 
4096  while ((inc = ast_walk_context_includes(con, inc))) {
4097  c++;
4098  }
4099 
4100  return c;
4101 }
static struct ast_include * ast_walk_context_includes(struct ast_context *con, struct ast_include *inc)
Definition: extconf.c:4081

References ast_walk_context_includes(), c, and NULL.

◆ ast_context_switches_count()

int ast_context_switches_count ( struct ast_context con)

Definition at line 4158 of file extconf.c.

4159 {
4160  int c = 0;
4161  struct ast_sw *sw = NULL;
4162 
4163  while ((sw = ast_walk_context_switches(con, sw))) {
4164  c++;
4165  }
4166 
4167  return c;
4168 }
static struct ast_sw * ast_walk_context_switches(struct ast_context *con, struct ast_sw *sw)
Definition: extconf.c:4140

References ast_walk_context_switches(), c, and NULL.

◆ ast_context_verify_includes()

static int ast_context_verify_includes ( struct ast_context con)
static

Definition at line 5622 of file extconf.c.

5623 {
5624  struct ast_include *inc = NULL;
5625  int res = 0;
5626 
5627  while ( (inc = ast_walk_context_includes(con, inc)) )
5628  if (!ast_context_find(inc->rname)) {
5629  res = -1;
5630  if (strcasecmp(inc->rname,"parkedcalls")!=0)
5631  ast_log(LOG_WARNING, "Context '%s' tries to include the nonexistent context '%s'\n",
5632  ast_get_context_name(con), inc->rname);
5633  }
5634  return res;
5635 }
static struct ast_context * ast_context_find(const char *name)
Definition: extconf.c:4173

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

Referenced by ast_tvnow(), and localized_context_verify_includes().

◆ ast_copy_string()

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

◆ ast_extension_match()

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

Definition at line 4296 of file extconf.c.

4297 {
4298  return extension_match_core(pattern, data, E_MATCH);
4299 }
static int extension_match_core(const char *pattern, const char *data, enum ext_match_t mode)
Definition: extconf.c:4287

Referenced by matchcid().

◆ ast_findlabel_extension2()

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

Definition at line 4977 of file extconf.c.

4978 {
4979  return pbx_extension_helper(c, con, NULL, exten, 0, label, callerid, E_FINDLABEL);
4980 }
static char exten[AST_MAX_EXTENSION]
Definition: chan_alsa.c:122
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:
Definition: extconf.c:4916
@ E_FINDLABEL
Definition: extconf.h:221

Referenced by pbx_load_config().

◆ ast_func_read()

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

Definition at line 4995 of file extconf.c.

4996 {
4997  ast_log(LOG_ERROR, "Function %s not registered\n", function);
4998  return -1;
4999 }
#define LOG_ERROR
Definition: extconf.c:145

References ast_log(), and LOG_ERROR.

Referenced by pbx_substitute_variables_helper_full().

◆ ast_func_write()

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

Definition at line 2479 of file extconf.c.

2480 {
2481 
2482  /* ast_log(LOG_ERROR, "Function %s not registered\n", function); we are not interested in the details here */
2483 
2484  return -1;
2485 }

Referenced by pbx_builtin_setvar_helper().

◆ ast_get_context_name()

static const char* ast_get_context_name ( struct ast_context con)
static

Definition at line 4487 of file extconf.c.

4488 {
4489  return con ? con->name : NULL;
4490 }

References ast_context::name, and NULL.

Referenced by ast_context_add_include2(), ast_context_add_switch2(), and ast_context_verify_includes().

◆ ast_get_extension_app()

static const char* ast_get_extension_app ( struct ast_exten e)
static

Definition at line 3613 of file extconf.c.

3614 {
3615  return e ? e->app : NULL;
3616 }
const char * app
Definition: pbx.c:246

References ast_exten::app, and NULL.

Referenced by ast_add_hint().

◆ ast_get_extension_name()

static const char* ast_get_extension_name ( struct ast_exten exten)
static

Definition at line 3618 of file extconf.c.

3619 {
3620  return exten ? exten->exten : NULL;
3621 }

References exten, and NULL.

Referenced by ast_add_hint().

◆ ast_include_find()

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

Definition at line 1163 of file extconf.c.

1164 {
1165  struct ast_config_include *x;
1166  for (x=conf->includes;x;x=x->next)
1167  {
1168  if (strcmp(x->included_file,included_file) == 0)
1169  return x;
1170  }
1171  return 0;
1172 }
char * included_file
file name included
Definition: main/config.c:278
struct ast_config_include * next
Definition: main/config.c:282
All configuration options for statsd client.
Definition: res_statsd.c:101

Referenced by ast_include_new().

◆ ast_include_new()

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

Definition at line 1074 of file extconf.c.

1075 {
1076  /* a file should be included ONCE. Otherwise, if one of the instances is changed,
1077  then all be changed. -- how do we know to include it? -- Handling modified
1078  instances is possible, I'd have
1079  to create a new master for each instance. */
1080  struct ast_config_include *inc;
1081 
1083  if (inc)
1084  {
1085  inc->inclusion_count++;
1086  snprintf(real_included_file_name, real_included_file_name_size, "%s~~%d", included_file, inc->inclusion_count);
1087  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);
1088  } else
1089  *real_included_file_name = 0;
1090 
1091  inc = ast_calloc(1,sizeof(struct ast_config_include));
1092  inc->include_location_file = ast_strdup(from_file);
1093  inc->include_location_lineno = from_lineno;
1094  if (!ast_strlen_zero(real_included_file_name))
1095  inc->included_file = ast_strdup(real_included_file_name);
1096  else
1098 
1099  inc->exec = is_exec;
1100  if (is_exec)
1101  inc->exec_file = ast_strdup(exec_file);
1102 
1103  /* attach this new struct to the conf struct */
1104  inc->next = conf->includes;
1105  conf->includes = inc;
1106 
1107  return inc;
1108 }
static struct ast_config_include * ast_include_find(struct ast_config *conf, const char *included_file)
Definition: extconf.c:1163
char * include_location_file
file name in which the include occurs
Definition: main/config.c:266
char * exec_file
if it's an exec, you'll have both the /var/tmp to read, and the original script
Definition: main/config.c:273

Referenced by process_text_line().

◆ ast_includes_destroy()

static void ast_includes_destroy ( struct ast_config_include incls)
static

Definition at line 1273 of file extconf.c.

1274 {
1275  struct ast_config_include *incl,*inclnext;
1276 
1277  for (incl=incls; incl; incl = inclnext) {
1278  inclnext = incl->next;
1279  if (incl->include_location_file)
1280  free(incl->include_location_file);
1281  if (incl->exec_file)
1282  free(incl->exec_file);
1283  if (incl->included_file)
1284  free(incl->included_file);
1285  free(incl);
1286  }
1287 }

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

Referenced by ast_config_destroy().

◆ ast_log()

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

◆ ast_log_backtrace()

void ast_log_backtrace ( void  )

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

Definition at line 2244 of file logger.c.

2245 {
2246 #ifdef HAVE_BKTR
2247  struct ast_bt *bt;
2248  int i = 0;
2249  struct ast_vector_string *strings;
2250 
2251  if (!(bt = ast_bt_create())) {
2252  ast_log(LOG_WARNING, "Unable to allocate space for backtrace structure\n");
2253  return;
2254  }
2255 
2256  if ((strings = ast_bt_get_symbols(bt->addresses, bt->num_frames))) {
2257  int count = AST_VECTOR_SIZE(strings);
2258  struct ast_str *buf = ast_str_create(bt->num_frames * 64);
2259 
2260  if (buf) {
2261  ast_str_append(&buf, 0, "Got %d backtrace record%c\n", count - 3, count - 3 != 1 ? 's' : ' ');
2262  for (i = 3; i < AST_VECTOR_SIZE(strings); i++) {
2263  ast_str_append(&buf, 0, "#%2d: %s\n", i - 3, AST_VECTOR_GET(strings, i));
2264  }
2266  ast_free(buf);
2267  }
2268 
2269  ast_bt_free_symbols(strings);
2270  } else {
2271  ast_log(LOG_ERROR, "Could not allocate memory for backtrace\n");
2272  }
2273  ast_bt_destroy(bt);
2274 #else
2275  ast_log(LOG_WARNING, "Must run configure with '--with-execinfo' for stack backtraces.\n");
2276 #endif /* defined(HAVE_BKTR) */
2277 }
#define ast_free(a)
Definition: astmm.h:180
#define ast_bt_free_symbols(string_vector)
Definition: backtrace.h:42
#define ast_bt_get_symbols(addresses, num_frames)
Definition: backtrace.h:41
#define ast_bt_create()
Definition: backtrace.h:39
#define ast_bt_destroy(bt)
Definition: backtrace.h:40
#define __LOG_ERROR
#define LOG_ERROR
#define LOG_WARNING
void ast_log_safe(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message with protection against recursion.
Definition: logger.c:2209
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 i...
Definition: logger.c:2187
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
Definition: strings.h:1117
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition: strings.h:739
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
Definition: strings.h:640
A structure to hold backtrace information. This structure provides an easy means to store backtrace i...
Definition: backtrace.h:50
void * addresses[AST_MAX_BT_FRAMES]
Definition: backtrace.h:52
int num_frames
Definition: backtrace.h:54
Support for dynamic strings.
Definition: strings.h:604
String vector definitions.
Definition: vector.h:55
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:609
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
Definition: vector.h:680

◆ ast_mark_lock_failed()

void ast_mark_lock_failed ( void *  lock_addr)

Definition at line 2313 of file extconf.c.

2314 {
2315  /* Pretend to do something. */
2316 }

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

◆ ast_merge_contexts_and_delete()

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

Definition at line 5572 of file extconf.c.

5573 {
5574  struct ast_context *tmp, *lasttmp = NULL;
5575 
5576  /* it is very important that this function hold the hint list lock _and_ the conlock
5577  during its operation; not only do we need to ensure that the list of contexts
5578  and extensions does not change, but also that no hint callbacks (watchers) are
5579  added or removed during the merge/delete process
5580 
5581  in addition, the locks _must_ be taken in this order, because there are already
5582  other code paths that use this order
5583  */
5585 
5586  tmp = *extcontexts;
5587  if (registrar) {
5588  /* XXX remove previous contexts from same registrar */
5589  if (option_debug)
5590  ast_log(LOG_DEBUG, "must remove any reg %s\n", registrar);
5592  while (tmp) {
5593  lasttmp = tmp;
5594  tmp = tmp->next;
5595  }
5596  } else {
5597  /* XXX remove contexts with the same name */
5598  while (tmp) {
5599  ast_log(LOG_WARNING, "must remove %s reg %s\n", tmp->name, tmp->registrar);
5600  __ast_context_destroy(tmp,tmp->registrar);
5601  lasttmp = tmp;
5602  tmp = tmp->next;
5603  }
5604  }
5605  if (lasttmp) {
5606  lasttmp->next = contexts;
5607  contexts = *extcontexts;
5608  *extcontexts = NULL;
5609  } else
5610  ast_log(LOG_WARNING, "Requested contexts didn't get merged\n");
5611 
5613 
5614  return;
5615 }
static void __ast_context_destroy(struct ast_context *con, const char *registrar)
Definition: extconf.c:5503

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

Referenced by ast_tvnow(), and localized_merge_contexts_and_delete().

◆ ast_mutex_init()

static int ast_mutex_init ( ast_mutex_t pmutex)
inlinestatic

Definition at line 469 of file extconf.c.

470 {
471  pthread_mutexattr_t attr;
472 
473  pthread_mutexattr_init(&attr);
474  pthread_mutexattr_settype(&attr, AST_MUTEX_KIND);
475 
476  return pthread_mutex_init(pmutex, &attr);
477 }
#define AST_MUTEX_KIND
Definition: extconf.c:194
#define pthread_mutex_init
Definition: extconf.c:501

References AST_MUTEX_KIND, and pthread_mutex_init.

Referenced by __ast_context_create().

◆ ast_process_quotes_and_slashes()

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

Definition at line 2218 of file extconf.c.

2219 {
2220  char *dataPut = start;
2221  int inEscape = 0;
2222  int inQuotes = 0;
2223 
2224  for (; *start; start++) {
2225  if (inEscape) {
2226  *dataPut++ = *start; /* Always goes verbatim */
2227  inEscape = 0;
2228  } else {
2229  if (*start == '\\') {
2230  inEscape = 1; /* Do not copy \ into the data */
2231  } else if (*start == '\'') {
2232  inQuotes = 1 - inQuotes; /* Do not copy ' into the data */
2233  } else {
2234  /* Replace , with |, unless in quotes */
2235  *dataPut++ = inQuotes ? *start : ((*start == find) ? replace_with : *start);
2236  }
2237  }
2238  }
2239  if (start != dataPut)
2240  *dataPut = 0;
2241  return dataPut;
2242 }

Referenced by pbx_load_config().

◆ ast_queue_log()

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

Definition at line 952 of file logger.c.

953 {
954  va_list ap;
955  struct timeval tv;
956  struct ast_tm tm;
957  char qlog_msg[8192];
958  int qlog_len;
959  char time_str[30];
960 
961  if (!logger_initialized) {
962  /* You are too early. We are not open yet! */
963  return;
964  }
965  if (!queuelog_init) {
966  /* We must initialize now since someone is trying to log something. */
968  }
969 
970  if (ast_check_realtime("queue_log")) {
971  tv = ast_tvnow();
972  ast_localtime(&tv, &tm, logfiles.queue_log_realtime_use_gmt ? "GMT" : NULL);
973  ast_strftime(time_str, sizeof(time_str), "%F %T.%6q", &tm);
974  va_start(ap, fmt);
975  vsnprintf(qlog_msg, sizeof(qlog_msg), fmt, ap);
976  va_end(ap);
977  if (logfiles.queue_adaptive_realtime) {
979  AST_APP_ARG(data)[5];
980  );
981  AST_NONSTANDARD_APP_ARGS(args, qlog_msg, '|');
982  /* Ensure fields are large enough to receive data */
983  ast_realtime_require_field("queue_log",
984  "data1", RQ_CHAR, strlen(S_OR(args.data[0], "")),
985  "data2", RQ_CHAR, strlen(S_OR(args.data[1], "")),
986  "data3", RQ_CHAR, strlen(S_OR(args.data[2], "")),
987  "data4", RQ_CHAR, strlen(S_OR(args.data[3], "")),
988  "data5", RQ_CHAR, strlen(S_OR(args.data[4], "")),
989  SENTINEL);
990 
991  /* Store the log */
992  ast_store_realtime("queue_log", "time", time_str,
993  "callid", callid,
994  "queuename", queuename,
995  "agent", agent,
996  "event", event,
997  "data1", S_OR(args.data[0], ""),
998  "data2", S_OR(args.data[1], ""),
999  "data3", S_OR(args.data[2], ""),
1000  "data4", S_OR(args.data[3], ""),
1001  "data5", S_OR(args.data[4], ""),
1002  SENTINEL);
1003  } else {
1004  ast_store_realtime("queue_log", "time", time_str,
1005  "callid", callid,
1006  "queuename", queuename,
1007  "agent", agent,
1008  "event", event,
1009  "data", qlog_msg,
1010  SENTINEL);
1011  }
1012 
1013  if (!logfiles.queue_log_to_file) {
1014  return;
1015  }
1016  }
1017 
1018  if (qlog) {
1019  va_start(ap, fmt);
1020  qlog_len = snprintf(qlog_msg, sizeof(qlog_msg), "%ld|%s|%s|%s|%s|", (long)time(NULL), callid, queuename, agent, event);
1021  vsnprintf(qlog_msg + qlog_len, sizeof(qlog_msg) - qlog_len, fmt, ap);
1022  va_end(ap);
1024  if (qlog) {
1025  fprintf(qlog, "%s\n", qlog_msg);
1026  fflush(qlog);
1027  }
1029  }
1030 }
#define SENTINEL
Definition: compiler.h:87
#define AST_APP_ARG(name)
Define an application argument.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define AST_NONSTANDARD_APP_ARGS(args, parse, sep)
Performs the 'nonstandard' argument separation process for an application.
int ast_realtime_require_field(const char *family,...) attribute_sentinel
Inform realtime what fields that may be stored.
Definition: main/config.c:3448
int ast_check_realtime(const char *family)
Check if realtime engine is configured for family.
Definition: main/config.c:3429
int ast_store_realtime(const char *family,...) attribute_sentinel
Create realtime configuration.
Definition: main/config.c:3639
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
Definition: linkedlists.h:78
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:151
int ast_strftime(char *buf, size_t len, const char *format, const struct ast_tm *tm)
Special version of strftime(3) that handles fractions of a second. Takes the same arguments as strfti...
Definition: localtime.c:2524
struct ast_tm * ast_localtime(const struct timeval *timep, struct ast_tm *p_tm, const char *zone)
Timezone-independent version of localtime_r(3).
Definition: localtime.c:1739
static int queuelog_init
Definition: logger.c:88
void logger_queue_start(void)
Start the ast_queue_log() logger.
Definition: logger.c:1940
static FILE * qlog
Definition: logger.c:200
static struct @397 logfiles
static int logger_initialized
Definition: logger.c:89
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one.
Definition: strings.h:80
Definition: astman.c:222
const char * args
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:157

Referenced by logger_queue_start(), and reload_logger().

◆ ast_remove_hint()

static int ast_remove_hint ( struct ast_exten e)
static

ast_remove_hint: Remove hint from extension

Definition at line 3734 of file extconf.c.

3735 {
3736  /* Cleanup the Notifys if hint is removed */
3737  struct ast_hint *hint;
3738  struct ast_state_cb *cblist, *cbprev;
3739  int res = -1;
3740 
3741  if (!e)
3742  return -1;
3743 
3744  AST_RWLIST_TRAVERSE_SAFE_BEGIN(&hints, hint, list) {
3745  if (hint->exten == e) {
3746  cbprev = NULL;
3747  cblist = hint->callbacks;
3748  while (cblist) {
3749  /* Notify with -1 and remove all callbacks */
3750  cbprev = cblist;
3751  cblist = cblist->next;
3752  free(cbprev);
3753  }
3754  hint->callbacks = NULL;
3756  free(hint);
3757  res = 0;
3758  break;
3759  }
3760  }
3762 
3763  return res;
3764 }
#define AST_RWLIST_REMOVE_CURRENT
Definition: extconf.c:1846
#define AST_RWLIST_TRAVERSE_SAFE_BEGIN
Definition: extconf.c:1823
#define AST_RWLIST_TRAVERSE_SAFE_END
Definition: extconf.c:1876
struct ao2_container * callbacks
Definition: pbx.c:332
ast_state_cb: An extension state notify register item
Definition: pbx.c:301
struct ast_state_cb * next
Definition: pbx.c:313

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.

Referenced by destroy_exten().

◆ ast_replace_sigchld()

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 801 of file extconf.c.

802 {
803  unsigned int level;
804 
805  level = safe_system_level++;
806 
807  /* only replace the handler if it has not already been done */
808  if (level == 0) {
809  sigaction(SIGCHLD, &null_sig_handler, &safe_system_prev_handler);
810  }
811 }
static unsigned int safe_system_level
Keep track of how many threads are currently trying to wait*() on a child process.
Definition: extconf.c:785
static struct sigaction safe_system_prev_handler
Definition: extconf.c:786
static struct sigaction null_sig_handler
Definition: extconf.c:794

References null_sig_handler, safe_system_level, and safe_system_prev_handler.

Referenced by ast_safe_fork(), and ast_safe_system().

◆ ast_rwlock_destroy()

static int ast_rwlock_destroy ( ast_rwlock_t prwlock)
inlinestatic

Definition at line 529 of file extconf.c.

530 {
531  return pthread_rwlock_destroy(prwlock);
532 }

Referenced by __ast_context_destroy().

◆ ast_rwlock_init()

static int ast_rwlock_init ( ast_rwlock_t prwlock)
inlinestatic

Definition at line 516 of file extconf.c.

517 {
518  pthread_rwlockattr_t attr;
519 
520  pthread_rwlockattr_init(&attr);
521 
522 #ifdef HAVE_PTHREAD_RWLOCK_PREFER_WRITER_NP
523  pthread_rwlockattr_setkind_np(&attr, PTHREAD_RWLOCK_PREFER_WRITER_NP);
524 #endif
525 
526  return pthread_rwlock_init(prwlock, &attr);
527 }

Referenced by __ast_context_create().

◆ ast_rwlock_rdlock()

static int ast_rwlock_rdlock ( ast_rwlock_t prwlock)
inlinestatic

Definition at line 539 of file extconf.c.

540 {
541  return pthread_rwlock_rdlock(prwlock);
542 }

Referenced by pbx_retrieve_variable().

◆ ast_rwlock_unlock()

static int ast_rwlock_unlock ( ast_rwlock_t prwlock)
inlinestatic

Definition at line 534 of file extconf.c.

535 {
536  return pthread_rwlock_unlock(prwlock);
537 }

Referenced by ast_unlock_context(), ast_unlock_contexts(), and pbx_retrieve_variable().

◆ ast_rwlock_wrlock()

static int ast_rwlock_wrlock ( ast_rwlock_t prwlock)
inlinestatic

Definition at line 544 of file extconf.c.

545 {
546  return pthread_rwlock_wrlock(prwlock);
547 }

Referenced by ast_wrlock_context(), and ast_wrlock_contexts().

◆ ast_safe_system()

int ast_safe_system ( const char *  s)

Safely spawn an OS shell command while closing file descriptors.

Note
This replaces the system call in all Asterisk modules
Parameters
s- OS shell command string to execute.
Warning
Command injection can happen using this call if the passed in string is created using untrusted data from an external source. It is best not to use untrusted data. However, the caller could filter out dangerous characters to avoid command injection.

Definition at line 829 of file extconf.c.

830 {
831  pid_t pid;
832 #ifdef HAVE_WORKING_FORK
833  int x;
834 #endif
835  int res;
836  int status;
837 
838 #if defined(HAVE_WORKING_FORK) || defined(HAVE_WORKING_VFORK)
840 
841 #ifdef HAVE_WORKING_FORK
842  pid = fork();
843 #else
844  pid = vfork();
845 #endif
846 
847  if (pid == 0) {
848 #ifdef HAVE_WORKING_FORK
849  /* Close file descriptors and launch system command */
850  for (x = STDERR_FILENO + 1; x < 4096; x++)
851  close(x);
852 #endif
853  execl("/bin/sh", "/bin/sh", "-c", s, (char *) NULL);
854  _exit(1);
855  } else if (pid > 0) {
856  for(;;) {
857  res = waitpid(pid, &status, 0);
858  if (res > -1) {
859  res = WIFEXITED(status) ? WEXITSTATUS(status) : -1;
860  break;
861  } else if (errno != EINTR)
862  break;
863  }
864  } else {
865  ast_log(LOG_WARNING, "Fork failed: %s\n", strerror(errno));
866  res = -1;
867  }
868 
870 #else
871  res = -1;
872 #endif
873 
874  return res;
875 }
jack_status_t status
Definition: app_jack.c:146
void ast_replace_sigchld(void)
Replace the SIGCHLD handler.
Definition: extconf.c:801
void ast_unreplace_sigchld(void)
Restore the SIGCHLD handler.
Definition: extconf.c:815
#define WEXITSTATUS(status)
#define WIFEXITED(status)

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

Referenced by add_email_attachment(), alarmreceiver_exec(), ast_monitor_stop(), AST_TEST_DEFINE(), convert_bdb_to_sqlite3(), mixmonitor_thread(), notify_message(), process_text_line(), rotate_file(), run_externnotify(), sendmail(), sendpage(), system_exec_helper(), and vm_change_password_shell().

◆ ast_shrink_phone_number()

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 2136 of file extconf.c.

2137 {
2138  int x, y=0;
2139  int bracketed = 0;
2140 
2141  for (x=0; n[x]; x++) {
2142  switch(n[x]) {
2143  case '[':
2144  bracketed++;
2145  n[y++] = n[x];
2146  break;
2147  case ']':
2148  bracketed--;
2149  n[y++] = n[x];
2150  break;
2151  case '-':
2152  if (bracketed)
2153  n[y++] = n[x];
2154  break;
2155  case '.':
2156  if (!n[x+1])
2157  n[y++] = n[x];
2158  break;
2159  default:
2160  if (!strchr("()", n[x]))
2161  n[y++] = n[x];
2162  }
2163  }
2164  n[y] = '\0';
2165 }

Referenced by pbx_load_config().

◆ ast_skip_blanks()

char* ast_skip_blanks ( const char *  str)

Definition at line 979 of file extconf.c.

988 {

References str.

Referenced by ast_trim_blanks(), pbx_load_config(), and process_text_line().

◆ ast_strip()

char* ast_strip ( char *  s)

Strip leading/trailing whitespace from a string.

Parameters
sThe 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.

Definition at line 1023 of file extconf.c.

1028 {

Referenced by config_text_file_load(), and process_text_line().

◆ ast_strlen_zero()

static force_inline int ast_strlen_zero ( const char *  s)
static

◆ ast_trim_blanks()

char* ast_trim_blanks ( char *  str)

Trims trailing whitespace characters from a string.

Parameters
strthe input string
Returns
a pointer to the modified string

Definition at line 1004 of file extconf.c.

1017 {

References ast_skip_blanks().

◆ ast_true()

static int ast_true ( const char *  s)
static

Definition at line 2244 of file extconf.c.

2245 {
2246  if (ast_strlen_zero(s))
2247  return 0;
2248 
2249  /* Determine if this is a true value */
2250  if (!strcasecmp(s, "yes") ||
2251  !strcasecmp(s, "true") ||
2252  !strcasecmp(s, "y") ||
2253  !strcasecmp(s, "t") ||
2254  !strcasecmp(s, "1") ||
2255  !strcasecmp(s, "on"))
2256  return -1;
2257 
2258  return 0;
2259 }

References ast_strlen_zero().

Referenced by pbx_load_config().

◆ ast_tvadd()

struct timeval ast_tvadd ( struct timeval  a,
struct timeval  b 
)

Returns the sum of two timevals a + b.

Definition at line 2244 of file extconf.c.

2283 {
2284  /* consistency checks to guarantee usec in 0..999999 */
2285  a = tvfix(a);
2286  b = tvfix(b);
2287  a.tv_sec += b.tv_sec;
2288  a.tv_usec += b.tv_usec;
2289  if (a.tv_usec >= ONE_MILLION) {
2290  a.tv_sec++;
2291  a.tv_usec -= ONE_MILLION;
2292  }
2293  return a;
2294 }
#define ONE_MILLION
Definition: extconf.c:2261
static struct timeval tvfix(struct timeval a)
Definition: extconf.c:2266
static struct test_val b
static struct test_val a

Referenced by __get_from_jb(), acf_jabberreceive_read(), ast_audiohook_trigger_wait(), ast_bridge_channel_feature_digit(), ast_bridge_interval_hook(), ast_channel_cmpwhentohangup_tv(), ast_channel_setwhentohangup_tv(), ast_poll2(), ast_rtp_dtmf_begin(), ast_rtp_dtmf_end_with_duration(), ast_rtp_sendcng(), ast_sched_runq(), ast_sip_sched_task_get_times2(), ast_sip_schedule_task(), ast_smoother_read(), AST_TEST_DEFINE(), ast_translate(), bridge_builtin_set_limits(), bridge_channel_handle_interval(), bridge_sync_wait(), calc_rxstamp(), calc_timestamp(), cli_tps_ping(), conf_run(), consumer_should_stay(), dial_exec_full(), do_cdr(), do_timing(), expire_objects_from_cache(), handle_keepalive_message(), handler_wait_for_message(), hook_event_cb(), iax2_process_thread(), jb_get_and_deliver(), mb_poll_thread(), monmp3thread(), mp3_exec(), mwi_monitor_handler(), rtp_deallocate_transport(), run_task(), sched_run(), sched_settime(), schedule_cache_expiration(), schedule_delivery(), set_timeout(), sla_process_timers(), smdi_message_wait(), sorcery_memory_cache_print_object(), subscription_persistence_update(), and user_event_wait_for_events().

◆ ast_tvnow()

struct timeval ast_tvnow ( void  )

Definition at line 5646 of file extconf.c.

5674 {
5675  struct timeval t;
5676  gettimeofday(&t, NULL);
5677  return t;
5678 }

References ast_context_verify_includes(), ast_merge_contexts_and_delete(), ast_walk_contexts(), config_filename, global_registrar, local_contexts, ast_context::name, NULL, and pbx_load_config().

◆ ast_tvsub()

struct timeval ast_tvsub ( struct timeval  a,
struct timeval  b 
)

Returns the difference of two timevals a - b.

Definition at line 2244 of file extconf.c.

2298 {
2299  /* consistency checks to guarantee usec in 0..999999 */
2300  a = tvfix(a);
2301  b = tvfix(b);
2302  a.tv_sec -= b.tv_sec;
2303  a.tv_usec -= b.tv_usec;
2304  if (a.tv_usec < 0) {
2305  a.tv_sec-- ;
2306  a.tv_usec += ONE_MILLION;
2307  }
2308  return a;
2309 }

Referenced by action_login(), ast_poll2(), ast_sched_dump(), AST_TEST_DEFINE(), ast_translate(), ast_waitfor_nandfds(), calc_rxstamp(), calc_timestamp(), cli_tps_ping(), conf_run(), debug_check_frame_for_silence(), handle_showcalls(), handle_showuptime(), memory_cache_stale_check_object(), object_stale_callback(), and publish_fully_booted().

◆ ast_unlock_context()

static int ast_unlock_context ( struct ast_context con)
static

Definition at line 4625 of file extconf.c.

4626 {
4627  return ast_rwlock_unlock(&con->lock);
4628 }
static int ast_rwlock_unlock(ast_rwlock_t *prwlock)
Definition: extconf.c:534
ast_rwlock_t lock
Definition: pbx.c:285

References ast_rwlock_unlock(), and ast_context::lock.

Referenced by __ast_context_destroy().

◆ ast_unlock_contexts()

static int ast_unlock_contexts ( void  )
static

Definition at line 4615 of file extconf.c.

4616 {
4617  return ast_rwlock_unlock(&conlock);
4618 }
static ast_rwlock_t conlock
Definition: extconf.c:4483

References ast_rwlock_unlock(), and conlock.

Referenced by __ast_context_create(), ast_merge_contexts_and_delete(), and localized_context_destroy().

◆ ast_unreplace_sigchld()

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 815 of file extconf.c.

816 {
817  unsigned int level;
818 
819  level = --safe_system_level;
820 
821  /* only restore the handler if we are the last one */
822  if (level == 0) {
823  sigaction(SIGCHLD, &safe_system_prev_handler, NULL);
824  }
825 }

References NULL, safe_system_level, and safe_system_prev_handler.

Referenced by ast_safe_fork_cleanup(), and ast_safe_system().

◆ ast_var_assign()

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

Definition at line 2455 of file extconf.c.

2456 {
2457  struct ast_var_t *var;
2458  int name_len = strlen(name) + 1;
2459  int value_len = strlen(value) + 1;
2460 
2461  if (!(var = ast_calloc(sizeof(*var) + name_len + value_len, sizeof(char)))) {
2462  return NULL;
2463  }
2464 
2465  ast_copy_string(var->name, name, name_len);
2466  var->value = var->name + name_len;
2467  ast_copy_string(var->value, value, value_len);
2468 
2469  return var;
2470 }
#define var
Definition: ast_expr2f.c:614

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

Referenced by pbx_builtin_setvar_helper().

◆ ast_var_delete()

static void ast_var_delete ( struct ast_var_t var)
static

Definition at line 2472 of file extconf.c.

2473 {
2474  free(var);
2475 }

Referenced by pbx_builtin_setvar_helper().

◆ ast_var_name()

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

Definition at line 2170 of file extconf.c.

2171 {
2172  const char *name;
2173 
2174  if (var == NULL || (name = var->name) == NULL)
2175  return NULL;
2176  /* Return the name without the initial underscores */
2177  if (name[0] == '_') {
2178  name++;
2179  if (name[0] == '_')
2180  name++;
2181  }
2182  return name;
2183 }

References name, NULL, and var.

Referenced by pbx_builtin_setvar_helper(), and pbx_retrieve_variable().

◆ ast_var_value()

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

Definition at line 5027 of file extconf.c.

5028 {
5029  return (var ? var->value : NULL);
5030 }

References NULL, and var.

Referenced by pbx_retrieve_variable().

◆ ast_variable_append()

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

Definition at line 1177 of file extconf.c.

1178 {
1179  if (!variable)
1180  return;
1181  if (category->last)
1182  category->last->next = variable;
1183  else
1184  category->root = variable;
1185  category->last = variable;
1186  while (category->last->next)
1187  category->last = category->last->next;
1188 }
struct ast_variable * last
Definition: main/config.c:242
struct ast_variable * next

Referenced by inherit_category(), move_variables(), and process_text_line().

◆ ast_variable_browse()

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

Definition at line 1215 of file extconf.c.

1216 {
1217  struct ast_category *cat = NULL;
1218 
1219  if (category && config->last_browse && (config->last_browse->name == category))
1220  cat = config->last_browse;
1221  else
1222  cat = ast_category_get(config, category);
1223 
1224  return (cat) ? cat->root : NULL;
1225 }
static struct ast_category * ast_category_get(const struct ast_config *config, const char *category_name)
Definition: extconf.c:1210

Referenced by ast_variable_retrieve(), and pbx_load_config().

◆ ast_variable_new()

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

Definition at line 1055 of file extconf.c.

1056 {
1057  struct ast_variable *variable;
1058  int name_len = strlen(name) + 1;
1059  size_t value_len = strlen(value) + 1;
1060  size_t filename_len = strlen(filename) + 1;
1061 
1062  if ((variable = ast_calloc(1, name_len + value_len + filename_len + sizeof(*variable)))) {
1063  variable->name = variable->stuff;
1064  variable->value = variable->stuff + name_len;
1065  variable->file = variable->value + value_len;
1066  strcpy(variable->name,name);
1067  ast_copy_string(variable->value, value, value_len);
1068  ast_copy_string(variable->file, filename, filename_len);
1069  }
1070 
1071  return variable;
1072 }
Structure for variables, used for configurations and for channel variables.
char stuff[0]
Contents of file, name, and value in that order stuffed here.

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

Referenced by process_text_line(), and variable_clone().

◆ ast_variable_retrieve()

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

Definition at line 1227 of file extconf.c.

1228 {
1229  struct ast_variable *v;
1230 
1231  if (category) {
1232  for (v = ast_variable_browse(config, category); v; v = v->next) {
1233  if (!strcasecmp(variable, v->name))
1234  return v->value;
1235  }
1236  } else {
1237  struct ast_category *cat;
1238 
1239  for (cat = config->root; cat; cat = cat->next)
1240  for (v = cat->root; v; v = v->next)
1241  if (!strcasecmp(variable, v->name))
1242  return v->value;
1243  }
1244 
1245  return NULL;
1246 }
static struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category)
Definition: extconf.c:1215

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

Referenced by pbx_load_config().

◆ ast_variables_destroy()

static void ast_variables_destroy ( struct ast_variable v)
static

Definition at line 1262 of file extconf.c.

1263 {
1264  struct ast_variable *vn;
1265 
1266  while (v) {
1267  vn = v;
1268  v = v->next;
1269  free(vn);
1270  }
1271 }

Referenced by ast_category_destroy(), and ast_config_destroy().

◆ ast_verbose()

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

Definition at line 2206 of file extconf.c.

2207 {
2208  va_list vars;
2209  va_start(vars,fmt);
2210 
2211  printf("VERBOSE: ");
2212  vprintf(fmt, vars);
2213  fflush(stdout);
2214  va_end(vars);
2215 }

Referenced by __ast_context_create(), acl_change_stasis_cb(), add_codec_to_sdp(), add_noncodec_to_sdp(), add_tcodec_to_sdp(), add_vcodec_to_sdp(), alsa_answer(), alsa_call(), alsa_digit(), alsa_hangup(), alsa_indicate(), alsa_text(), ast_add_extension2(), ast_agi_send(), ast_ari_callback(), ast_context_add_include2(), ast_context_add_switch2(), ast_remotecontrol(), ast_rtcp_calculate_sr_rr_statistics(), ast_rtcp_interpret(), ast_rtp_dtmf_begin(), ast_rtp_dtmf_continuation(), ast_rtp_dtmf_end_with_duration(), ast_rtp_read(), ast_rtp_sendcng(), ast_stun_handle_packet(), astman_append(), astman_flush(), bridge_p2p_rtp_write(), can_safely_quit(), check_peer_ok(), conf_run(), config_text_file_load(), console_answer(), dahdi_softhangup_all(), do_register_auth(), dundi_debug_output(), get_also_info(), get_destination(), get_refer_info(), handle_incoming(), handle_request_do(), handle_request_info(), handle_request_invite(), handle_request_message(), handle_request_refer(), handle_request_subscribe(), handle_response(), handle_transfer_button(), hook_event_cb(), iax_debug_output(), initialize_initreq(), jb_debug_output(), load_module(), localized_config_text_file_save(), log_action(), logging_on_rx_msg(), logging_on_tx_msg(), match_filter(), mgcp_reload(), pbx_builtin_setvar_helper(), print_intro_message(), process_dtmf_rfc2833(), process_sdp(), process_sdp_a_audio(), process_sdp_a_text(), process_sdp_a_video(), process_sdp_o(), receive_message(), retrans_pkt(), rtp_raw_write(), send_request(), send_response(), set_destination(), sip_auth_headers(), sip_pvt_dtor(), sip_reload(), sip_route_dump(), sip_scheddestroy_full(), sip_sendtext(), stasis_app_message_handler(), stun_process_attr(), timing_read(), transmit_register(), use_reason_header(), xmpp_log_hook(), and xmpp_pubsub_receive_node_list().

◆ ast_walk_context_extensions()

static struct ast_exten* ast_walk_context_extensions ( struct ast_context con,
struct ast_exten exten 
)
static

Definition at line 4041 of file extconf.c.

4043 {
4044  if (!exten)
4045  return con ? con->root : NULL;
4046  else
4047  return exten->next;
4048 }

References exten, NULL, and ast_context::root.

Referenced by localized_walk_context_extensions(), and pbx_find_extension().

◆ ast_walk_context_ignorepats()

static struct ast_ignorepat* ast_walk_context_ignorepats ( struct ast_context con,
struct ast_ignorepat ip 
)
static

Definition at line 4114 of file extconf.c.

4116 {
4117  if (!ip)
4118  return con ? con->ignorepats : NULL;
4119  else
4120  return ip->next;
4121 }

References ast_context::ignorepats, ast_ignorepat::next, and NULL.

Referenced by ast_context_ignorepats_count().

◆ ast_walk_context_includes()

static struct ast_include* ast_walk_context_includes ( struct ast_context con,
struct ast_include inc 
)
static

Definition at line 4081 of file extconf.c.

4083 {
4084  if (!inc)
4085  return con ? con->includes : NULL;
4086  else
4087  return inc->next;
4088 }

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

Referenced by ast_context_includes_count(), ast_context_verify_includes(), and localized_walk_context_includes().

◆ ast_walk_context_switches()

static struct ast_sw* ast_walk_context_switches ( struct ast_context con,
struct ast_sw sw 
)
static

Definition at line 4140 of file extconf.c.

4142 {
4143  if (!sw)
4144  return con ? AST_LIST_FIRST(&con->alts) : NULL;
4145  else
4146  return AST_LIST_NEXT(sw, list);
4147 }
#define AST_LIST_FIRST(head)
Returns the first entry contained in a list.
Definition: extconf.c:1705
#define AST_LIST_NEXT(elm, field)
Returns the next entry in the list after the given entry.
Definition: extconf.c:1723

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

Referenced by ast_context_switches_count(), and localized_walk_context_switches().

◆ ast_walk_contexts()

static struct ast_context* ast_walk_contexts ( struct ast_context con)
static

Definition at line 4025 of file extconf.c.

4026 {
4027  return con ? con->next : contexts;
4028 }

Referenced by ast_context_find(), ast_tvnow(), localized_walk_contexts(), and pbx_find_extension().

◆ ast_walk_extension_priorities()

static struct ast_exten* ast_walk_extension_priorities ( struct ast_exten exten,
struct ast_exten priority 
)
static

Definition at line 4062 of file extconf.c.

4064 {
4065  return priority ? priority->peer : exten;
4066 }

Referenced by localized_walk_extension_priorities(), and pbx_find_extension().

◆ ast_wrlock_context()

static int ast_wrlock_context ( struct ast_context con)
static

Definition at line 4620 of file extconf.c.

4621 {
4622  return ast_rwlock_wrlock(&con->lock);
4623 }
static int ast_rwlock_wrlock(ast_rwlock_t *prwlock)
Definition: extconf.c:544

References ast_rwlock_wrlock(), and ast_context::lock.

Referenced by __ast_context_destroy().

◆ ast_wrlock_contexts()

static int ast_wrlock_contexts ( void  )
static

Definition at line 4610 of file extconf.c.

4611 {
4612  return ast_rwlock_wrlock(&conlock);
4613 }

References ast_rwlock_wrlock(), and conlock.

Referenced by __ast_context_create(), ast_merge_contexts_and_delete(), and localized_context_destroy().

◆ category_get()

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

Definition at line 1192 of file extconf.c.

1193 {
1194  struct ast_category *cat;
1195 
1196  /* try exact match first, then case-insensitive match */
1197  for (cat = config->root; cat; cat = cat->next) {
1198  if (cat->name == category_name && (ignored || !cat->ignored))
1199  return cat;
1200  }
1201 
1202  for (cat = config->root; cat; cat = cat->next) {
1203  if (!strcasecmp(cat->name, category_name) && (ignored || !cat->ignored))
1204  return cat;
1205  }
1206 
1207  return NULL;
1208 }

References config, ast_category::ignored, ast_category::name, ast_category::next, and NULL.

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

◆ CB_ADD()

static void CB_ADD ( char *  str)
static

Definition at line 737 of file extconf.c.

738 {
739  int rem = comment_buffer_size - strlen(comment_buffer) - 1;
740  int siz = strlen(str);
741  if (rem < siz+1) {
743  if (!comment_buffer)
744  return;
745  comment_buffer_size += CB_INCR+siz+1;
746  }
747  strcat(comment_buffer,str);
748 }
const char * str
Definition: app_jack.c:147
#define ast_realloc(p, len)
A wrapper for realloc()
Definition: astmm.h:226
#define CB_INCR
Definition: extconf.c:711
static char * comment_buffer
Definition: extconf.c:705
static int comment_buffer_size
Definition: extconf.c:706

References ast_realloc, CB_INCR, comment_buffer, comment_buffer_size, and str.

Referenced by config_text_file_load().

◆ CB_ADD_LEN()

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

Definition at line 750 of file extconf.c.

751 {
752  int cbl = strlen(comment_buffer) + 1;
753  int rem = comment_buffer_size - cbl;
754  if (rem < len+1) {
756  if (!comment_buffer)
757  return;
759  }
760  strncat(comment_buffer,str,len); /* safe */
761  comment_buffer[cbl+len-1] = 0;
762 }
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)

References ast_realloc, CB_INCR, comment_buffer, comment_buffer_size, len(), and str.

Referenced by config_text_file_load().

◆ CB_INIT()

static void CB_INIT ( void  )
static

Definition at line 718 of file extconf.c.

719 {
720  if (!comment_buffer) {
722  if (!comment_buffer)
723  return;
724  comment_buffer[0] = 0;
727  if (!lline_buffer)
728  return;
729  lline_buffer[0] = 0;
731  } else {
732  comment_buffer[0] = 0;
733  lline_buffer[0] = 0;
734  }
735 }
#define ast_malloc(len)
A wrapper for malloc()
Definition: astmm.h:191
static char * lline_buffer