Asterisk - The Open Source Telephony Project GIT-master-77d630f
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 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_flag64(&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_flag64(&ast_options, AST_OPT_FLAG_ALWAYS_FORK)
 
#define ast_opt_cache_record_files   ast_test_flag64(&ast_options, AST_OPT_FLAG_CACHE_RECORD_FILES)
 
#define ast_opt_console   ast_test_flag64(&ast_options, AST_OPT_FLAG_CONSOLE)
 
#define ast_opt_dont_warn   ast_test_flag64(&ast_options, AST_OPT_FLAG_DONT_WARN)
 
#define ast_opt_dump_core   ast_test_flag64(&ast_options, AST_OPT_FLAG_DUMP_CORE)
 
#define ast_opt_exec   ast_test_flag64(&ast_options, AST_OPT_FLAG_EXEC)
 
#define ast_opt_exec_includes   ast_test_flag64(&ast_options, AST_OPT_FLAG_EXEC_INCLUDES)
 
#define ast_opt_high_priority   ast_test_flag64(&ast_options, AST_OPT_FLAG_HIGH_PRIORITY)
 
#define ast_opt_init_keys   ast_test_flag64(&ast_options, AST_OPT_FLAG_INIT_KEYS)
 
#define ast_opt_mute   ast_test_flag64(&ast_options, AST_OPT_FLAG_MUTE)
 
#define ast_opt_no_color   ast_test_flag64(&ast_options, AST_OPT_FLAG_NO_COLOR)
 
#define ast_opt_no_fork   ast_test_flag64(&ast_options, AST_OPT_FLAG_NO_FORK)
 
#define ast_opt_override_config   ast_test_flag64(&ast_options, AST_OPT_FLAG_OVERRIDE_CONFIG)
 
#define ast_opt_priority_jumping   ast_test_flag64(&ast_options, AST_OPT_FLAG_PRIORITY_JUMPING)
 
#define ast_opt_quiet   ast_test_flag64(&ast_options, AST_OPT_FLAG_QUIET)
 
#define ast_opt_reconnect   ast_test_flag64(&ast_options, AST_OPT_FLAG_RECONNECT)
 
#define ast_opt_remote   ast_test_flag64(&ast_options, AST_OPT_FLAG_REMOTE)
 
#define ast_opt_timestamp   ast_test_flag64(&ast_options, AST_OPT_FLAG_TIMESTAMP)
 
#define ast_opt_transcode_via_slin   ast_test_flag64(&ast_options, AST_OPT_FLAG_TRANSCODE_VIA_SLIN)
 
#define ast_opt_transmit_silence   ast_test_flag64(&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_test_flag64(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 SWAP64_32(flags)   (flags)
 
#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_SOUNDS_SEARCH_CUSTOM = (1 << 19) ,
  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

uint64_t __unsigned_int_flags_dummy64
 
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 1356 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 1360 of file extconf.c.

◆ AST_FILENAME_MAX

#define AST_FILENAME_MAX   80

Definition at line 1357 of file extconf.c.

◆ ast_fully_booted

#define ast_fully_booted   ast_test_flag64(&ast_options, AST_OPT_FLAG_FULLY_BOOTED)

Definition at line 1373 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 1993 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 1731 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 1692 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 1703 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_sla.c:338
ast_mutex_t lock
Definition: app_sla.c:337
struct sla_ringing_trunk * last
Definition: app_sla.c:338
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

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 1455 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 1883 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 1924 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 1516 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:

static AST_LIST_HEAD_NOLOCK(entry_list, entry) entries;
#define AST_LIST_HEAD_NOLOCK(name, type)
Defines a structure to be used to hold a list of specified type (with no lock).
Definition: linkedlists.h:225

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 1507 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 1534 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:1534

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 1628 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 1642 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 1670 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:1516

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 1573 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 1938 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 1856 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 1954 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 1974 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 1711 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 1721 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 2035 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 1834 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 2014 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
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 1771 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 1809 of file extconf.c.

◆ AST_LIST_TRAVERSE_SAFE_END

#define AST_LIST_TRAVERSE_SAFE_END   }

Closes a safe loop traversal block.

Definition at line 1872 of file extconf.c.

◆ AST_MAX_EXTENSION

#define AST_MAX_EXTENSION   80

Max length of an extension

Definition at line 2076 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_flag64(&ast_options, AST_OPT_FLAG_ALWAYS_FORK)

Definition at line 1383 of file extconf.c.

◆ ast_opt_cache_record_files

#define ast_opt_cache_record_files   ast_test_flag64(&ast_options, AST_OPT_FLAG_CACHE_RECORD_FILES)

Definition at line 1377 of file extconf.c.

◆ ast_opt_console

#define ast_opt_console   ast_test_flag64(&ast_options, AST_OPT_FLAG_CONSOLE)

Definition at line 1367 of file extconf.c.

◆ ast_opt_dont_warn

#define ast_opt_dont_warn   ast_test_flag64(&ast_options, AST_OPT_FLAG_DONT_WARN)

Definition at line 1382 of file extconf.c.

◆ ast_opt_dump_core

#define ast_opt_dump_core   ast_test_flag64(&ast_options, AST_OPT_FLAG_DUMP_CORE)

Definition at line 1376 of file extconf.c.

◆ ast_opt_exec

#define ast_opt_exec   ast_test_flag64(&ast_options, AST_OPT_FLAG_EXEC)

Definition at line 1371 of file extconf.c.

◆ ast_opt_exec_includes

#define ast_opt_exec_includes   ast_test_flag64(&ast_options, AST_OPT_FLAG_EXEC_INCLUDES)

Definition at line 1364 of file extconf.c.

◆ ast_opt_high_priority

#define ast_opt_high_priority   ast_test_flag64(&ast_options, AST_OPT_FLAG_HIGH_PRIORITY)

Definition at line 1368 of file extconf.c.

◆ ast_opt_init_keys

#define ast_opt_init_keys   ast_test_flag64(&ast_options, AST_OPT_FLAG_INIT_KEYS)

Definition at line 1369 of file extconf.c.

◆ ast_opt_mute

#define ast_opt_mute   ast_test_flag64(&ast_options, AST_OPT_FLAG_MUTE)

Definition at line 1384 of file extconf.c.

◆ ast_opt_no_color

#define ast_opt_no_color   ast_test_flag64(&ast_options, AST_OPT_FLAG_NO_COLOR)

Definition at line 1372 of file extconf.c.

◆ ast_opt_no_fork

#define ast_opt_no_fork   ast_test_flag64(&ast_options, AST_OPT_FLAG_NO_FORK)

Definition at line 1365 of file extconf.c.

◆ ast_opt_override_config

#define ast_opt_override_config   ast_test_flag64(&ast_options, AST_OPT_FLAG_OVERRIDE_CONFIG)

Definition at line 1379 of file extconf.c.

◆ ast_opt_priority_jumping

#define ast_opt_priority_jumping   ast_test_flag64(&ast_options, AST_OPT_FLAG_PRIORITY_JUMPING)

Definition at line 1375 of file extconf.c.

◆ ast_opt_quiet

#define ast_opt_quiet   ast_test_flag64(&ast_options, AST_OPT_FLAG_QUIET)

Definition at line 1366 of file extconf.c.

◆ ast_opt_reconnect

#define ast_opt_reconnect   ast_test_flag64(&ast_options, AST_OPT_FLAG_RECONNECT)

Definition at line 1380 of file extconf.c.

◆ ast_opt_remote

#define ast_opt_remote   ast_test_flag64(&ast_options, AST_OPT_FLAG_REMOTE)

Definition at line 1370 of file extconf.c.

◆ ast_opt_timestamp

#define ast_opt_timestamp   ast_test_flag64(&ast_options, AST_OPT_FLAG_TIMESTAMP)

Definition at line 1378 of file extconf.c.

◆ ast_opt_transcode_via_slin

#define ast_opt_transcode_via_slin   ast_test_flag64(&ast_options, AST_OPT_FLAG_TRANSCODE_VIA_SLIN)

Definition at line 1374 of file extconf.c.

◆ ast_opt_transmit_silence

#define ast_opt_transmit_silence   ast_test_flag64(&ast_options, AST_OPT_FLAG_TRANSMIT_SILENCE)

Definition at line 1381 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 2003 of file extconf.c.

◆ AST_RWLIST_EMPTY

#define AST_RWLIST_EMPTY   AST_LIST_EMPTY

Definition at line 1733 of file extconf.c.

◆ AST_RWLIST_ENTRY

#define AST_RWLIST_ENTRY   AST_LIST_ENTRY

Definition at line 1697 of file extconf.c.

◆ AST_RWLIST_FIRST

#define AST_RWLIST_FIRST   AST_LIST_FIRST

Definition at line 1705 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 1481 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 1910 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 1896 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 1525 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 1656 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:1525

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

◆ AST_RWLIST_INSERT_AFTER

#define AST_RWLIST_INSERT_AFTER   AST_LIST_INSERT_AFTER

Definition at line 1945 of file extconf.c.

◆ AST_RWLIST_INSERT_BEFORE_CURRENT

#define AST_RWLIST_INSERT_BEFORE_CURRENT   AST_LIST_INSERT_BEFORE_CURRENT

Definition at line 1867 of file extconf.c.

◆ AST_RWLIST_INSERT_HEAD

#define AST_RWLIST_INSERT_HEAD   AST_LIST_INSERT_HEAD

Definition at line 1961 of file extconf.c.

◆ AST_RWLIST_INSERT_TAIL

#define AST_RWLIST_INSERT_TAIL   AST_LIST_INSERT_TAIL

Definition at line 1984 of file extconf.c.

◆ AST_RWLIST_LAST

#define AST_RWLIST_LAST   AST_LIST_LAST

Definition at line 1713 of file extconf.c.

◆ AST_RWLIST_NEXT

#define AST_RWLIST_NEXT   AST_LIST_NEXT

Definition at line 1723 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 1422 of file extconf.c.

◆ AST_RWLIST_REMOVE

#define AST_RWLIST_REMOVE   AST_LIST_REMOVE

Definition at line 2053 of file extconf.c.

◆ AST_RWLIST_REMOVE_CURRENT

#define AST_RWLIST_REMOVE_CURRENT   AST_LIST_REMOVE_CURRENT

Definition at line 1844 of file extconf.c.

◆ AST_RWLIST_REMOVE_HEAD

#define AST_RWLIST_REMOVE_HEAD   AST_LIST_REMOVE_HEAD

Definition at line 2025 of file extconf.c.

◆ AST_RWLIST_TRAVERSE

#define AST_RWLIST_TRAVERSE   AST_LIST_TRAVERSE

Definition at line 1774 of file extconf.c.

◆ AST_RWLIST_TRAVERSE_SAFE_BEGIN

#define AST_RWLIST_TRAVERSE_SAFE_BEGIN   AST_LIST_TRAVERSE_SAFE_BEGIN

Definition at line 1821 of file extconf.c.

◆ AST_RWLIST_TRAVERSE_SAFE_END

#define AST_RWLIST_TRAVERSE_SAFE_END   AST_LIST_TRAVERSE_SAFE_END

Definition at line 1874 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 1433 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 1411 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_test_flag64

#define ast_test_flag64 (   p,
  flag 
)

Definition at line 685 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 2325 of file extconf.c.

◆ BACKGROUND_NOANSWER

#define BACKGROUND_NOANSWER   (1 << 1)

Definition at line 2324 of file extconf.c.

◆ BACKGROUND_PLAYBACK

#define BACKGROUND_PLAYBACK   (1 << 3)

Definition at line 2326 of file extconf.c.

◆ BACKGROUND_SKIP

#define BACKGROUND_SKIP   (1 << 0)

Definition at line 2323 of file extconf.c.

◆ CB_INCR

#define CB_INCR   250

Definition at line 709 of file extconf.c.

◆ COMMENT_END

#define COMMENT_END   "--;"

Definition at line 696 of file extconf.c.

◆ COMMENT_META

#define COMMENT_META   ';'

Definition at line 697 of file extconf.c.

◆ COMMENT_START

#define COMMENT_START   ";--"

Definition at line 695 of file extconf.c.

◆ COMMENT_TAG

#define COMMENT_TAG   '-'

Definition at line 698 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 3601 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 893 of file extconf.c.

◆ MAX_NESTED_COMMENTS

#define MAX_NESTED_COMMENTS   128

Definition at line 694 of file extconf.c.

◆ ONE_MILLION

#define ONE_MILLION   1000000

Definition at line 2259 of file extconf.c.

◆ PRIORITY_HINT

#define PRIORITY_HINT   -1

Special Priority for a hint

Definition at line 2080 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 955 of file extconf.c.

◆ STATUS_NO_CONTEXT

#define STATUS_NO_CONTEXT   1

Definition at line 2446 of file extconf.c.

◆ STATUS_NO_EXTENSION

#define STATUS_NO_EXTENSION   2

Definition at line 2447 of file extconf.c.

◆ STATUS_NO_LABEL

#define STATUS_NO_LABEL   4

Definition at line 2449 of file extconf.c.

◆ STATUS_NO_PRIORITY

#define STATUS_NO_PRIORITY   3

Definition at line 2448 of file extconf.c.

◆ STATUS_SUCCESS

#define STATUS_SUCCESS   5

Definition at line 2450 of file extconf.c.

◆ SWAP64_32

#define SWAP64_32 (   flags)    (flags)

Definition at line 680 of file extconf.c.

◆ SWITCH_DATA_LENGTH

#define SWITCH_DATA_LENGTH   256

Definition at line 3608 of file extconf.c.

◆ VAR_BUF_SIZE

#define VAR_BUF_SIZE   4096

Definition at line 2317 of file extconf.c.

◆ VAR_HARDTRAN

#define VAR_HARDTRAN   3

Definition at line 2321 of file extconf.c.

◆ VAR_NORMAL

#define VAR_NORMAL   1

Definition at line 2319 of file extconf.c.

◆ VAR_SOFTTRAN

#define VAR_SOFTTRAN   2

Definition at line 2320 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 2351 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 2103 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 931 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 933 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 934 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 932 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 2082 of file extconf.c.

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

◆ 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_SOUNDS_SEARCH_CUSTOM 

Search custom directory for sounds first

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

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

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

4705{
4706 struct ast_context *tmp, **loc_contexts;
4707 int length = sizeof(struct ast_context) + strlen(name) + 1;
4708
4709 if (!extcontexts) {
4711 loc_contexts = &contexts;
4712 } else
4713 loc_contexts = extcontexts;
4714
4715 for (tmp = *loc_contexts; tmp; tmp = tmp->next) {
4716 if (!strcasecmp(tmp->name, name)) {
4717 if (!existsokay) {
4718 ast_log(LOG_WARNING, "Tried to register context '%s', already in use\n", name);
4719 tmp = NULL;
4720 }
4721 if (!extcontexts)
4723 return tmp;
4724 }
4725 }
4726 if ((tmp = ast_calloc(1, length))) {
4727 ast_rwlock_init(&tmp->lock);
4728 strcpy(tmp->name, name);
4729 tmp->root = NULL;
4730 tmp->registrar = registrar;
4731 tmp->next = *loc_contexts;
4732 tmp->includes = NULL;
4733 tmp->ignorepats = NULL;
4734 *loc_contexts = tmp;
4735 if (option_debug)
4736 ast_log(LOG_DEBUG, "Registered context '%s'\n", tmp->name);
4737 if (option_verbose > 2)
4738 ast_verbose( VERBOSE_PREFIX_3 "Registered extension context '%s'\n", tmp->name);
4739 }
4740
4741 if (!extcontexts)
4743 return tmp;
4744}
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:202
#define VERBOSE_PREFIX_3
Definition: extconf.c:102
static int ast_wrlock_contexts(void)
Definition: extconf.c:4607
#define LOG_DEBUG
Definition: extconf.c:121
void ast_verbose(const char *fmt,...)
Definition: extconf.c:2204
static struct ast_context * contexts
Definition: extconf.c:3595
static int ast_unlock_contexts(void)
Definition: extconf.c:4612
static void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Definition: extconf.c:2192
#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:70
int option_verbose
Definition: options.c:68
static char * registrar
Definition: pbx_ael.c:81
ast_context: An extension context
Definition: pbx.c:299
struct ast_exten * root
Definition: pbx.c:304
struct ast_ignorepats ignorepats
Definition: pbx.c:309
struct ast_includes includes
Definition: pbx.c:308
const char * registrar
Definition: pbx.c:301
struct ast_context * next
Definition: pbx.c:307
ast_rwlock_t lock
Definition: pbx.c:303
const char * name
Definition: pbx.c:300

References ast_calloc, ast_log(), ast_rwlock_init(), ast_unlock_contexts(), ast_verbose(), ast_wrlock_contexts(), contexts, ast_context::ignorepats, ast_context::includes, ast_context::lock, LOG_DEBUG, LOG_WARNING, name, ast_context::name, ast_context::next, NULL, option_debug, option_verbose, ast_context::registrar, registrar, ast_context::root, 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 5499 of file extconf.c.

5500{
5501 struct ast_context *tmp, *tmpl=NULL;
5502 struct ast_include *tmpi;
5503 struct ast_sw *sw;
5504 struct ast_exten *e, *el, *en;
5505 struct ast_ignorepat *ipi;
5506
5507 for (tmp = contexts; tmp; ) {
5508 struct ast_context *next; /* next starting point */
5509 for (; tmp; tmpl = tmp, tmp = tmp->next) {
5510 if (option_debug)
5511 ast_log(LOG_DEBUG, "check ctx %s %s\n", tmp->name, tmp->registrar);
5512 if ( (!registrar || !strcasecmp(registrar, tmp->registrar)) &&
5513 (!con || !strcasecmp(tmp->name, con->name)) )
5514 break; /* found it */
5515 }
5516 if (!tmp) /* not found, we are done */
5517 break;
5518 ast_wrlock_context(tmp);
5519 if (option_debug)
5520 ast_log(LOG_DEBUG, "delete ctx %s %s\n", tmp->name, tmp->registrar);
5521 next = tmp->next;
5522 if (tmpl)
5523 tmpl->next = next;
5524 else
5525 contexts = next;
5526 /* Okay, now we're safe to let it go -- in a sense, we were
5527 ready to let it go as soon as we locked it. */
5528 ast_unlock_context(tmp);
5529 for (tmpi = tmp->includes; tmpi; ) { /* Free includes */
5530 struct ast_include *tmpil = tmpi;
5531 tmpi = tmpi->next;
5532 free(tmpil);
5533 }
5534 for (ipi = tmp->ignorepats; ipi; ) { /* Free ignorepats */
5535 struct ast_ignorepat *ipl = ipi;
5536 ipi = ipi->next;
5537 free(ipl);
5538 }
5539 while ((sw = AST_LIST_REMOVE_HEAD(&tmp->alts, list)))
5540 free(sw);
5541 for (e = tmp->root; e;) {
5542 for (en = e->peer; en;) {
5543 el = en;
5544 en = en->peer;
5546 }
5547 el = e;
5548 e = e->next;
5550 }
5551 ast_rwlock_destroy(&tmp->lock);
5552 free(tmp);
5553 /* if we have a specific match, we are done, otherwise continue */
5554 tmp = con ? NULL : next;
5555 }
5556}
static EditLine * el
Definition: asterisk.c:347
static int ast_wrlock_context(struct ast_context *con)
Definition: extconf.c:4617
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:2014
static int ast_unlock_context(struct ast_context *con)
Definition: extconf.c:4622
static void destroy_exten(struct ast_exten *e)
Definition: extconf.c:3763
void free()
ast_exten: An extension The dialplan is saved as a linked list with each context having it's own link...
Definition: pbx.c:252
struct ast_exten * peer
Definition: pbx.c:265
struct ast_exten * next
Definition: pbx.c:271
ast_ignorepat: Ignore patterns in dial plan
Definition: pbx_ignorepat.c:37
struct ast_ignorepat * next
Definition: extconf.c:2386
ast_include: include= support in extensions.conf
Definition: pbx_include.c:37
struct ast_include * next
Definition: extconf.c:2368
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, and registrar.

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

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

References ast_log(), ast_context::data, 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 787 of file extconf.c.

788{
789
790}

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

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

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

Referenced by ast_add_extension2().

◆ ALLOC_COMMENT()

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

Definition at line 875 of file extconf.c.

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

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

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

References add_pri(), ast_exten::app, ast_add_hint(), ast_calloc, ast_log(), ast_verbose(), ast_exten::cidmatch, ast_exten::data, ast_exten::datad, el, errno, ext_cmp(), ext_strncpy(), ast_exten::exten, ast_exten::label, LOG_DEBUG, ast_exten::matchcid, ast_context::name, ast_exten::next, NULL, null_datad(), option_debug, option_verbose, ast_exten::parent, priority, ast_exten::priority, PRIORITY_HINT, ast_exten::registrar, registrar, replace(), ast_context::root, ast_exten::stuff, 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 3640 of file extconf.c.

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

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

2485{
2486 int argc;
2487 char *scan;
2488 int paren = 0, quote = 0;
2489
2490 if (!buf || !array || !arraylen)
2491 return 0;
2492
2493 memset(array, 0, arraylen * sizeof(*array));
2494
2495 scan = buf;
2496
2497 for (argc = 0; *scan && (argc < arraylen - 1); argc++) {
2498 array[argc] = scan;
2499 for (; *scan; scan++) {
2500 if (*scan == '(')
2501 paren++;
2502 else if (*scan == ')') {
2503 if (paren)
2504 paren--;
2505 } else if (*scan == '"' && delim != '"') {
2506 quote = quote ? 0 : 1;
2507 /* Remove quote character from argument */
2508 memmove(scan, scan + 1, strlen(scan));
2509 scan--;
2510 } else if (*scan == '\\') {
2511 /* Literal character, don't parse */
2512 memmove(scan, scan + 1, strlen(scan));
2513 } else if ((*scan == delim) && !paren && !quote) {
2514 *scan++ = '\0';
2515 break;
2516 }
2517 }
2518 }
2519
2520 if (*scan)
2521 array[argc++] = scan;
2522
2523 return argc;
2524}
#define paren
Definition: ael_lex.c:962
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 3804 of file extconf.c.

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

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

2832{
2833 if (config->last)
2834 config->last->next = category;
2835 else
2836 config->root = category;
2837 config->last = category;
2838 config->current = category;
2839}
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 3324 of file extconf.c.

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

Referenced by pbx_load_config().

◆ ast_category_destroy()

static void ast_category_destroy ( struct ast_category cat)
static

Definition at line 2843 of file extconf.c.

2844{
2846 if (cat->file)
2847 free(cat->file);
2848
2849 free(cat);
2850}
static void ast_variables_destroy(struct ast_variable *v)
Definition: extconf.c:1260
struct ast_variable * root
Definition: main/config.c:241
char * file
The file name from whence this declaration was read.
Definition: main/config.c:234

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

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

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

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

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

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

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

3999{
4000 /* sorry, but this feature will NOT be available
4001 in the standalone version */
4002 return 0;
4003}

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

1288{
1289 struct ast_category *cat, *catn;
1290
1291 if (!cfg)
1292 return;
1293
1295
1296 cat = cfg->root;
1297 while (cat) {
1299 catn = cat;
1300 cat = cat->next;
1301 free(catn);
1302 }
1303 free(cfg);
1304}
static void ast_includes_destroy(struct ast_config_include *incls)
Definition: extconf.c:1271
struct ast_config_include * includes
Definition: extconf.c:916
struct ast_category * root
Definition: main/config.c:252

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

2780{
2781 return cfg->current;
2782}
struct ast_category * current
Definition: main/config.c:255

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

2861{
2862 char db[256] = "";
2863 char table[256] = "";
2864 struct ast_config_engine *loader = &text_file_engine;
2865 struct ast_config *result;
2866
2867 if (cfg->include_level == cfg->max_include_level) {
2868 ast_log(LOG_WARNING, "Maximum Include level (%d) exceeded\n", cfg->max_include_level);
2869 return NULL;
2870 }
2871
2872 cfg->include_level++;
2873 /* silence is golden!
2874 ast_log(LOG_WARNING, "internal loading file %s level=%d\n", filename, cfg->include_level);
2875 */
2876
2877 if (strcmp(filename, extconfig_conf) && strcmp(filename, "asterisk.conf") && config_engine_list) {
2878 struct ast_config_engine *eng;
2879
2880 eng = find_engine(filename, db, sizeof(db), table, sizeof(table));
2881
2882
2883 if (eng && eng->load_func) {
2884 loader = eng;
2885 } else {
2886 eng = find_engine("global", db, sizeof(db), table, sizeof(table));
2887 if (eng && eng->load_func)
2888 loader = eng;
2889 }
2890 }
2891
2892 result = loader->load_func(db, table, filename, cfg, withcomments, suggested_incl_file);
2893 /* silence is golden
2894 ast_log(LOG_WARNING, "finished internal loading file %s level=%d\n", filename, cfg->include_level);
2895 */
2896
2897 if (result)
2898 result->include_level--;
2899
2900 return result;
2901}
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:891
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:2745
static char * extconfig_conf
Definition: extconf.c:700
static struct ast_config_engine text_file_engine
Definition: extconf.c:2852
Configuration engine structure, used to define realtime drivers.
config_load_func * load_func
int include_level
Definition: main/config.c:257
int max_include_level
Definition: main/config.c:258

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

3273{
3274 struct ast_config *config;
3275
3276 if ((config = ast_calloc(1, sizeof(*config))))
3277 config->max_include_level = MAX_INCLUDE_LEVEL;
3278 return config;
3279}
#define MAX_INCLUDE_LEVEL
Definition: extconf.c:893

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

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

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 1368 of file asterisk.c.

1369{
1370 /* Send to the root console */
1371 fputs(string, stdout);
1372 fflush(stdout);
1373
1374 /* Send to any network console clients */
1375 ast_network_puts(string);
1376}
static void ast_network_puts(const char *string)
write the string to all attached console clients
Definition: asterisk.c:1352

◆ ast_context_add_ignorepat2()

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

Definition at line 4565 of file extconf.c.

4566{
4567 struct ast_ignorepat *ignorepat, *ignorepatc, *ignorepatl = NULL;
4568 int length;
4569 length = sizeof(struct ast_ignorepat);
4570 length += strlen(value) + 1;
4571 if (!(ignorepat = ast_calloc(1, length)))
4572 return -1;
4573 /* The cast to char * is because we need to write the initial value.
4574 * The field is not supposed to be modified otherwise
4575 */
4576 strcpy((char *)ignorepat->pattern, value);
4577 ignorepat->next = NULL;
4578 ignorepat->registrar = registrar;
4579 for (ignorepatc = con->ignorepats; ignorepatc; ignorepatc = ignorepatc->next) {
4580 ignorepatl = ignorepatc;
4581 if (!strcasecmp(ignorepatc->pattern, value)) {
4582 /* Already there */
4583 errno = EEXIST;
4584 return -1;
4585 }
4586 }
4587 if (ignorepatl)
4588 ignorepatl->next = ignorepat;
4589 else
4590 con->ignorepats = ignorepat;
4591 return 0;
4592
4593}
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 4499 of file extconf.c.

4501{
4502 struct ast_include *new_include;
4503 char *c;
4504 struct ast_include *i, *il = NULL; /* include, include_last */
4505 int length;
4506 char *p;
4507
4508 length = sizeof(struct ast_include);
4509 length += 2 * (strlen(value) + 1);
4510
4511 /* allocate new include structure ... */
4512 if (!(new_include = ast_calloc(1, length)))
4513 return -1;
4514 /* Fill in this structure. Use 'p' for assignments, as the fields
4515 * in the structure are 'const char *'
4516 */
4517 p = new_include->stuff;
4518 new_include->name = p;
4519 strcpy(p, value);
4520 p += strlen(value) + 1;
4521 new_include->rname = p;
4522 strcpy(p, value);
4523 /* Strip off timing info, and process if it is there */
4524 if ( (c = strchr(p, '|')) || (c = strchr(p, ',')) ) {
4525 *c++ = '\0';
4526 new_include->hastime = ast_build_timing(&(new_include->timing), c);
4527 }
4528 new_include->next = NULL;
4529 new_include->registrar = registrar;
4530
4531
4532 /* ... go to last include and check if context is already included too... */
4533 for (i = con->includes; i; i = i->next) {
4534 if (!strcasecmp(i->name, new_include->name)) {
4535 free(new_include);
4536 errno = EEXIST;
4537 return -1;
4538 }
4539 il = i;
4540 }
4541
4542 /* ... include new context into context list, unlock, return */
4543 if (il)
4544 il->next = new_include;
4545 else
4546 con->includes = new_include;
4547 if (option_verbose > 2)
4548 ast_verbose(VERBOSE_PREFIX_3 "Including context '%s' in context '%s'\n", new_include->name, ast_get_context_name(con));
4549
4550 return 0;
4551}
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:3804
static const char * ast_get_context_name(struct ast_context *con)
Definition: extconf.c:4484
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 4637 of file extconf.c.

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

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

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

4979{
4980 return __ast_context_create(extcontexts, name, registrar, 1);
4981}
static struct ast_context * __ast_context_create(struct ast_context **extcontexts, const char *name, const char *registrar, int existsokay)
Definition: extconf.c:4704

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

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

References ast_walk_context_ignorepats(), c, and NULL.

◆ ast_context_includes_count()

int ast_context_includes_count ( struct ast_context con)

Definition at line 4088 of file extconf.c.

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

References ast_walk_context_includes(), c, and NULL.

◆ ast_context_switches_count()

int ast_context_switches_count ( struct ast_context con)

Definition at line 4155 of file extconf.c.

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

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

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

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

Referenced by localized_context_verify_includes(), and localized_pbx_load_module().

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

4294{
4295 return extension_match_core(pattern, data, E_MATCH);
4296}
static int extension_match_core(const char *pattern, const char *data, enum ext_match_t mode)
Definition: extconf.c:4284

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

4974{
4975 return pbx_extension_helper(c, con, NULL, exten, 0, label, callerid, E_FINDLABEL);
4976}
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:4912
@ E_FINDLABEL
Definition: extconf.h:220

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

4992{
4993 ast_log(LOG_ERROR, "Function %s not registered\n", function);
4994 return -1;
4995}
#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 2476 of file extconf.c.

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

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

4485{
4486 return con ? con->name : NULL;
4487}

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

3611{
3612 return e ? e->app : NULL;
3613}

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

3616{
3617 return exten ? exten->exten : NULL;
3618}

References ast_exten::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 1161 of file extconf.c.

1162{
1163 struct ast_config_include *x;
1164 for (x=conf->includes;x;x=x->next)
1165 {
1166 if (strcmp(x->included_file,included_file) == 0)
1167 return x;
1168 }
1169 return 0;
1170}
char * included_file
file name included
Definition: main/config.c:300
struct ast_config_include * next
Definition: main/config.c:308
All configuration options for http media cache.

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

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

Referenced by process_text_line().

◆ ast_includes_destroy()

static void ast_includes_destroy ( struct ast_config_include incls)
static

Definition at line 1271 of file extconf.c.

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

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 2480 of file logger.c.

2481{
2482#ifdef HAVE_BKTR
2483 struct ast_bt *bt;
2484 int i = 0;
2485 struct ast_vector_string *strings;
2486
2487 if (!(bt = ast_bt_create())) {
2488 ast_log(LOG_WARNING, "Unable to allocate space for backtrace structure\n");
2489 return;
2490 }
2491
2492 if ((strings = ast_bt_get_symbols(bt->addresses, bt->num_frames))) {
2493 int count = AST_VECTOR_SIZE(strings);
2494 struct ast_str *buf = ast_str_create(bt->num_frames * 64);
2495
2496 if (buf) {
2497 ast_str_append(&buf, 0, "Got %d backtrace record%c\n", count - 3, count - 3 != 1 ? 's' : ' ');
2498 for (i = 3; i < AST_VECTOR_SIZE(strings); i++) {
2499 ast_str_append(&buf, 0, "#%2d: %s\n", i - 3, AST_VECTOR_GET(strings, i));
2500 }
2502 ast_free(buf);
2503 }
2504
2505 ast_bt_free_symbols(strings);
2506 } else {
2507 ast_log(LOG_ERROR, "Could not allocate memory for backtrace\n");
2508 }
2509 ast_bt_destroy(bt);
2510#else
2511 ast_log(LOG_WARNING, "Must run configure with '--with-execinfo' for stack backtraces.\n");
2512#endif /* defined(HAVE_BKTR) */
2513}
#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:2445
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:2423
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:1139
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition: strings.h:761
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
Definition: strings.h:659
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:623
String vector definitions.
Definition: vector.h:55
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:620
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
Definition: vector.h:691

◆ ast_mark_lock_failed()

void ast_mark_lock_failed ( void *  lock_addr)

Definition at line 2311 of file extconf.c.

2312{
2313 /* Pretend to do something. */
2314}

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

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

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

Referenced by localized_merge_contexts_and_delete(), and localized_pbx_load_module().

◆ 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.

◆ ast_process_quotes_and_slashes()

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

Definition at line 2216 of file extconf.c.

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

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 957 of file logger.c.

958{
959 va_list ap;
960 struct timeval tv;
961 struct ast_tm tm;
962 char qlog_msg[8192];
963 int qlog_len;
964 char time_str[30];
965
966 if (!logger_initialized) {
967 /* You are too early. We are not open yet! */
968 return;
969 }
970 if (!queuelog_init) {
971 /* We must initialize now since someone is trying to log something. */
973 }
974
975 if (ast_check_realtime("queue_log")) {
976 tv = ast_tvnow();
977 ast_localtime(&tv, &tm, logfiles.queue_log_realtime_use_gmt ? "GMT" : NULL);
978 ast_strftime(time_str, sizeof(time_str), "%F %T.%6q", &tm);
979 va_start(ap, fmt);
980 vsnprintf(qlog_msg, sizeof(qlog_msg), fmt, ap);
981 va_end(ap);
982 if (logfiles.queue_adaptive_realtime) {
984 AST_APP_ARG(data)[5];
985 );
986 AST_NONSTANDARD_APP_ARGS(args, qlog_msg, '|');
987 /* Ensure fields are large enough to receive data */
988 ast_realtime_require_field("queue_log",
989 "data1", RQ_CHAR, strlen(S_OR(args.data[0], "")),
990 "data2", RQ_CHAR, strlen(S_OR(args.data[1], "")),
991 "data3", RQ_CHAR, strlen(S_OR(args.data[2], "")),
992 "data4", RQ_CHAR, strlen(S_OR(args.data[3], "")),
993 "data5", RQ_CHAR, strlen(S_OR(args.data[4], "")),
994 SENTINEL);
995
996 /* Store the log */
997 ast_store_realtime("queue_log", "time", time_str,
998 "callid", callid,
999 "queuename", queuename,
1000 "agent", agent,
1001 "event", event,
1002 "data1", S_OR(args.data[0], ""),
1003 "data2", S_OR(args.data[1], ""),
1004 "data3", S_OR(args.data[2], ""),
1005 "data4", S_OR(args.data[3], ""),
1006 "data5", S_OR(args.data[4], ""),
1007 SENTINEL);
1008 } else {
1009 ast_store_realtime("queue_log", "time", time_str,
1010 "callid", callid,
1011 "queuename", queuename,
1012 "agent", agent,
1013 "event", event,
1014 "data", qlog_msg,
1015 SENTINEL);
1016 }
1017
1018 if (!logfiles.queue_log_to_file) {
1019 return;
1020 }
1021 }
1022
1023 if (qlog) {
1024 va_start(ap, fmt);
1025 qlog_len = snprintf(qlog_msg, sizeof(qlog_msg), "%ld|%s|%s|%s|%s|", (long)time(NULL), callid, queuename, agent, event);
1026 vsnprintf(qlog_msg + qlog_len, sizeof(qlog_msg) - qlog_len, fmt, ap);
1027 va_end(ap);
1029 if (qlog) {
1030 fprintf(qlog, "%s\n", qlog_msg);
1031 fflush(qlog);
1032 }
1034 }
1035}
#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:3781
int ast_check_realtime(const char *family)
Check if realtime engine is configured for family.
Definition: main/config.c:3762
int ast_store_realtime(const char *family,...) attribute_sentinel
Create realtime configuration.
Definition: main/config.c:3972
#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
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
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
static int queuelog_init
Definition: logger.c:85
void logger_queue_start(void)
Start the ast_queue_log() logger.
Definition: logger.c:2156
static FILE * qlog
Definition: logger.c:198
static int logger_initialized
Definition: logger.c:86
static struct @373 logfiles
#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:159

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

3732{
3733 /* Cleanup the Notifys if hint is removed */
3734 struct ast_hint *hint;
3735 struct ast_state_cb *cblist, *cbprev;
3736 int res = -1;
3737
3738 if (!e)
3739 return -1;
3740
3742 if (hint->exten == e) {
3743 cbprev = NULL;
3744 cblist = hint->callbacks;
3745 while (cblist) {
3746 /* Notify with -1 and remove all callbacks */
3747 cbprev = cblist;
3748 cblist = cblist->next;
3749 free(cbprev);
3750 }
3751 hint->callbacks = NULL;
3753 free(hint);
3754 res = 0;
3755 break;
3756 }
3757 }
3759
3760 return res;
3761}
#define AST_RWLIST_REMOVE_CURRENT
Definition: extconf.c:1844
#define AST_RWLIST_TRAVERSE_SAFE_BEGIN
Definition: extconf.c:1821
#define AST_RWLIST_TRAVERSE_SAFE_END
Definition: extconf.c:1874
struct ao2_container * callbacks
Definition: pbx.c:354
ast_state_cb: An extension state notify register item
Definition: pbx.c:323
struct ast_state_cb * next
Definition: pbx.c:335

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

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

References null_sig_handler, safe_system_level, and safe_system_prev_handler.

Referenced by ast_safe_fork(), ast_safe_system(), and handle_include_exec().

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

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

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

Referenced by pbx_load_config().

◆ ast_skip_blanks()

char * ast_skip_blanks ( const char *  str)

Definition at line 977 of file extconf.c.

986{

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

1026{

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

1015{

References ast_skip_blanks(), and ast_trim_blanks().

Referenced by ast_trim_blanks().

◆ ast_true()

static int ast_true ( const char *  s)
static

Definition at line 2242 of file extconf.c.

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

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

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

References a, b, ONE_MILLION, and tvfix().

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_and_jitter(), calc_timestamp(), cli_show_tasks(), cli_tps_ping(), conf_run(), consumer_should_stay(), dial_exec_full(), do_cdr(), do_timing(), expire_objects_from_cache(), handler_wait_for_message(), hook_event_cb(), iax2_process_thread(), jb_get_and_deliver(), jitterbuffer_frame_get_ntp_timestamp(), make_deadline(), 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(), timeout_write(), user_event_wait_for_events(), and wait_for_stimulus().

◆ ast_tvnow()

struct timeval ast_tvnow ( void  )

Definition at line 5669 of file extconf.c.

5670{
5671 struct timeval t;
5672 gettimeofday(&t, NULL);
5673 return t;
5674}

References NULL.

◆ ast_tvsub()

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

Returns the difference of two timevals a - b.

Definition at line 2295 of file extconf.c.

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

References a, b, ONE_MILLION, and tvfix().

Referenced by action_login(), ast_poll2(), ast_sched_dump(), AST_TEST_DEFINE(), ast_translate(), ast_waitfor_nandfds(), calc_rxstamp(), calc_rxstamp_and_jitter(), calc_timestamp(), cli_tps_ping(), conf_run(), debug_check_frame_for_silence(), handle_showcalls(), handle_showuptime(), jitterbuffer_frame_get_ntp_timestamp(), 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 4622 of file extconf.c.

4623{
4624 return ast_rwlock_unlock(&con->lock);
4625}
static int ast_rwlock_unlock(ast_rwlock_t *prwlock)
Definition: extconf.c:534

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

4613{
4614 return ast_rwlock_unlock(&conlock);
4615}
static ast_rwlock_t conlock
Definition: extconf.c:4480

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

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

References NULL, safe_system_level, and safe_system_prev_handler.

Referenced by ast_safe_fork_cleanup(), ast_safe_system(), and handle_include_exec().

◆ ast_var_assign()

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

Definition at line 2452 of file extconf.c.

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

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

2470{
2471 free(var);
2472}

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

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

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

5024{
5025 return (var ? var->value : NULL);
5026}

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

1176{
1177 if (!variable)
1178 return;
1179 if (category->last)
1180 category->last->next = variable;
1181 else
1182 category->root = variable;
1183 category->last = variable;
1184 while (category->last->next)
1185 category->last = category->last->next;
1186}
struct ast_variable * last
Definition: main/config.c:243
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 1213 of file extconf.c.

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

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

1054{
1055 struct ast_variable *variable;
1056 int name_len = strlen(name) + 1;
1057 size_t value_len = strlen(value) + 1;
1058 size_t filename_len = strlen(filename) + 1;
1059
1060 if ((variable = ast_calloc(1, name_len + value_len + filename_len + sizeof(*variable)))) {
1061 variable->name = variable->stuff;
1062 variable->value = variable->stuff + name_len;
1063 variable->file = variable->value + value_len;
1064 strcpy(variable->name,name);
1065 ast_copy_string(variable->value, value, value_len);
1066 ast_copy_string(variable->file, filename, filename_len);
1067 }
1068
1069 return variable;
1070}
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 1225 of file extconf.c.

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

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

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

Referenced by ast_category_destroy(), and ast_config_destroy().

◆ ast_verbose()

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

◆ ast_walk_context_extensions()

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

Definition at line 4038 of file extconf.c.

4040{
4041 if (!exten)
4042 return con ? con->root : NULL;
4043 else
4044 return exten->next;
4045}

References ast_exten::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 4111 of file extconf.c.

4113{
4114 if (!ip)
4115 return con ? con->ignorepats : NULL;
4116 else
4117 return ip->next;
4118}

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

4080{
4081 if (!inc)
4082 return con ? con->includes : NULL;
4083 else
4084 return inc->next;
4085}

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

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

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

4023{
4024 return con ? con->next : contexts;
4025}

Referenced by ast_context_find(), localized_pbx_load_module(), 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 4059 of file extconf.c.

4061{
4062 return priority ? priority->peer : exten;
4063}

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

4618{
4619 return ast_rwlock_wrlock(&con->lock);
4620}
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 4607 of file extconf.c.

4608{
4609 return ast_rwlock_wrlock(&conlock);
4610}

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

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

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

736{
737 int rem = comment_buffer_size - strlen(comment_buffer) - 1;
738 int siz = strlen(str);
739 if (rem < siz+1) {
741 if (!comment_buffer)
742 return;
744 }
745 strcat(comment_buffer,str);
746}
const char * str
Definition: app_jack.c:150
#define ast_realloc(p, len)
A wrapper for realloc()
Definition: astmm.h:226
#define CB_INCR
Definition: extconf.c:709
static char * comment_buffer
Definition: extconf.c:703
static int comment_buffer_size
Definition: extconf.c:704

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

749{
750 int cbl = strlen(comment_buffer) + 1;
751 int rem = comment_buffer_size - cbl;
752 if (rem < len+1) {
754 if (!comment_buffer)
755 return;
757 }
758 strncat(comment_buffer,str,len); /* safe */
759 comment_buffer[cbl+len-1] = 0;
760}
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 716 of file extconf.c.

717{
718 if (!comment_buffer) {
720 if (!comment_buffer)
721 return;
722 comment_buffer[0] = 0;
725 if (!lline_buffer)
726 return;
727 lline_buffer[0] = 0;
729 } else {
730 comment_buffer[0] = 0;
731 lline_buffer[0] = 0;
732 }
733}
#define ast_malloc(len)
A wrapper for malloc()
Definition: astmm.h:191
static char * lline_buffer
Definition: extconf.c:706
static int lline_buffer_size
Definition: extconf.c:707

References ast_malloc, CB_INCR, comment_buffer, comment_buffer_size, lline_buffer, and lline_buffer_size.

Referenced by config_text_file_load().

◆ CB_RESET()

static void CB_RESET ( void  )
static

Definition at line 775 of file extconf.c.

776{
777 comment_buffer[0] = 0;
778 lline_buffer[0] = 0;
779}

References comment_buffer, and lline_buffer.

Referenced by process_text_line().

◆ config_text_file_load()

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

Definition at line 3117 of file extconf.c.

3118{
3119 char fn[256];
3120 char buf[8192];
3121 char *new_buf, *comment_p, *process_buf;
3122 FILE *f;
3123 int lineno=0;
3124 int comment = 0, nest[MAX_NESTED_COMMENTS];
3125 struct ast_category *cat = NULL;
3126 int count = 0;
3127 struct stat statbuf;
3128
3130
3131 if (filename[0] == '/') {
3132 ast_copy_string(fn, filename, sizeof(fn));
3133 } else {
3134 if (use_local_dir)
3135 snprintf(fn, sizeof(fn), "./%s", filename);
3136 else
3137 snprintf(fn, sizeof(fn), "%s/%s", ast_config_AST_CONFIG_DIR, filename);
3138 }
3139
3140 if (withcomments && cfg && cfg->include_level < 2 ) {
3141 CB_INIT();
3142 }
3143
3144 do {
3145 if (stat(fn, &statbuf))
3146 continue;
3147
3148 if (!S_ISREG(statbuf.st_mode)) {
3149 ast_log(LOG_WARNING, "'%s' is not a regular file, ignoring\n", fn);
3150 continue;
3151 }
3152 if (option_verbose > 1) {
3153 ast_verbose(VERBOSE_PREFIX_2 "Parsing '%s': ", fn);
3154 fflush(stdout);
3155 }
3156 if (!(f = fopen(fn, "r"))) {
3157 if (option_debug)
3158 ast_log(LOG_DEBUG, "No file to parse: %s\n", fn);
3159 if (option_verbose > 1)
3160 ast_verbose( "Not found (%s)\n", strerror(errno));
3161 continue;
3162 }
3163 count++;
3164 if (option_debug)
3165 ast_log(LOG_DEBUG, "Parsing %s\n", fn);
3166 if (option_verbose > 1)
3167 ast_verbose("Found\n");
3168 while(!feof(f)) {
3169 lineno++;
3170 if (fgets(buf, sizeof(buf), f)) {
3171 if ( withcomments ) {
3172 CB_ADD(lline_buffer); /* add the current lline buffer to the comment buffer */
3173 lline_buffer[0] = 0; /* erase the lline buffer */
3174 }
3175
3176 new_buf = buf;
3177 if (comment)
3178 process_buf = NULL;
3179 else
3180 process_buf = buf;
3181
3182 while ((comment_p = strchr(new_buf, COMMENT_META))) {
3183 if ((comment_p > new_buf) && (*(comment_p-1) == '\\')) {
3184 /* Yuck, gotta memmove */
3185 memmove(comment_p - 1, comment_p, strlen(comment_p) + 1);
3186 new_buf = comment_p;
3187 } else if(comment_p[1] == COMMENT_TAG && comment_p[2] == COMMENT_TAG && (comment_p[3] != '-')) {
3188 /* Meta-Comment start detected ";--" */
3190 *comment_p = '\0';
3191 new_buf = comment_p + 3;
3192 comment++;
3193 nest[comment-1] = lineno;
3194 } else {
3195 ast_log(LOG_ERROR, "Maximum nest limit of %d reached.\n", MAX_NESTED_COMMENTS);
3196 }
3197 } else if ((comment_p >= new_buf + 2) &&
3198 (*(comment_p - 1) == COMMENT_TAG) &&
3199 (*(comment_p - 2) == COMMENT_TAG)) {
3200 /* Meta-Comment end detected */
3201 comment--;
3202 new_buf = comment_p + 1;
3203 if (!comment) {
3204 /* Back to non-comment now */
3205 if (process_buf) {
3206 /* Actually have to move what's left over the top, then continue */
3207 char *oldptr;
3208 oldptr = process_buf + strlen(process_buf);
3209 if ( withcomments ) {
3210 CB_ADD(";");
3211 CB_ADD_LEN(oldptr+1,new_buf-oldptr-1);
3212 }
3213
3214 memmove(oldptr, new_buf, strlen(new_buf) + 1);
3215 new_buf = oldptr;
3216 } else
3217 process_buf = new_buf;
3218 }
3219 } else {
3220 if (!comment) {
3221 /* If ; is found, and we are not nested in a comment,
3222 we immediately stop all comment processing */
3223 if ( withcomments ) {
3224 LLB_ADD(comment_p);
3225 }
3226 *comment_p = '\0';
3227 new_buf = comment_p;
3228 } else
3229 new_buf = comment_p + 1;
3230 }
3231 }
3232 if( withcomments && comment && !process_buf )
3233 {
3234 CB_ADD(buf); /* the whole line is a comment, store it */
3235 }
3236
3237 if (process_buf) {
3238 char *stripped_process_buf = ast_strip(process_buf);
3239 if (!ast_strlen_zero(stripped_process_buf)) {
3240 if (process_text_line(cfg, &cat, stripped_process_buf, lineno, filename, withcomments, suggested_include_file)) {
3241 cfg = NULL;
3242 break;
3243 }
3244 }
3245 }
3246 }
3247 }
3248 fclose(f);
3249 } while(0);
3250 if (comment) {
3251 ast_log(LOG_WARNING,"Unterminated comment detected beginning on line %d\n", nest[comment]);
3252 }
3253 if (cfg && cfg->include_level == 1 && withcomments && comment_buffer) {
3254 if (comment_buffer) {
3258 lline_buffer=0;
3261 }
3262 }
3263 if (count == 0)
3264 return NULL;
3265
3266 return cfg;
3267}
#define comment
Definition: ael_lex.c:965
#define MAX_NESTED_COMMENTS
Definition: extconf.c:694
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)
Definition: extconf.c:2904
#define COMMENT_TAG
Definition: extconf.c:698
#define VERBOSE_PREFIX_2
Definition: extconf.c:101
static int use_local_dir
Definition: extconf.c:3101
static void CB_INIT(void)
Definition: extconf.c:716
struct ast_category * ast_config_get_current_category(const struct ast_config *cfg)
Retrieve the current category name being built.
Definition: extconf.c:2779
static void CB_ADD(char *str)
Definition: extconf.c:735
#define COMMENT_META
Definition: extconf.c:697
char * ast_strip(char *s)
Strip leading/trailing whitespace from a string.
Definition: extconf.c:1021
static void CB_ADD_LEN(char *str, int len)
Definition: extconf.c:748
static void LLB_ADD(char *str)
Definition: extconf.c:762
const char * ast_config_AST_CONFIG_DIR
Definition: options.c:152

References ast_config_AST_CONFIG_DIR, ast_config_get_current_category(), ast_copy_string(), ast_log(), ast_strip(), ast_strlen_zero(), ast_verbose(), buf, CB_ADD(), CB_ADD_LEN(), CB_INIT(), comment, comment_buffer, comment_buffer_size, COMMENT_META, COMMENT_TAG, errno, free(), ast_config::include_level, LLB_ADD(), lline_buffer, lline_buffer_size, LOG_DEBUG, LOG_ERROR, LOG_WARNING, MAX_NESTED_COMMENTS, NULL, option_debug, option_verbose, process_text_line(), use_local_dir, and VERBOSE_PREFIX_2.

◆ destroy_exten()

static void destroy_exten ( struct ast_exten e)
static

Definition at line 3763 of file extconf.c.

3764{
3765 if (e->priority == PRIORITY_HINT)
3766 ast_remove_hint(e);
3767
3768 if (e->datad)
3769 e->datad(e->data);
3770 free(e);
3771}
static int ast_remove_hint(struct ast_exten *e)
ast_remove_hint: Remove hint from extension
Definition: extconf.c:3731

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

Referenced by __ast_context_destroy().

◆ ext_cmp()

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

the full routine to compare extensions in rules.

Definition at line 3942 of file extconf.c.

3943{
3944 /* make sure non-patterns come first.
3945 * If a is not a pattern, it either comes first or
3946 * we use strcmp to compare the strings.
3947 */
3948 int ret = 0;
3949
3950 if (a[0] != '_')
3951 return (b[0] == '_') ? -1 : strcmp(a, b);
3952
3953 /* Now we know a is a pattern; if b is not, a comes first */
3954 if (b[0] != '_')
3955 return 1;
3956#if 0 /* old mode for ext matching */
3957 return strcmp(a, b);
3958#endif
3959 /* ok we need full pattern sorting routine */
3960 while (!ret && a && b)
3961 ret = ext_cmp1(&a) - ext_cmp1(&b);
3962 if (ret == 0)
3963 return 0;
3964 else
3965 return (ret > 0) ? 1 : -1;
3966}
static int ext_cmp1(const char **p)
helper functions to sort extensions and patterns in the desired way, so that more specific patterns a...
Definition: extconf.c:3870

References a, b, and ext_cmp1().

Referenced by ast_add_extension2().

◆ ext_cmp1()

static int ext_cmp1 ( const char **  p)
static

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

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

  1. the empty set is equivalent to NUL.
  2. given that a full set has always 0 as the first element, we could encode the special cases as 0xffXX where XX is 1, 2, 3, 4 as used above.

Definition at line 3870 of file extconf.c.

3871{
3872 uint32_t chars[8];
3873 int c, cmin = 0xff, count = 0;
3874 const char *end;
3875
3876 /* load, sign extend and advance pointer until we find
3877 * a valid character.
3878 */
3879 while ( (c = *(*p)++) && (c == ' ' || c == '-') )
3880 ; /* ignore some characters */
3881
3882 /* always return unless we have a set of chars */
3883 switch (c) {
3884 default: /* ordinary character */
3885 return 0x0000 | (c & 0xff);
3886
3887 case 'N': /* 2..9 */
3888 return 0x0700 | '2' ;
3889
3890 case 'X': /* 0..9 */
3891 return 0x0900 | '0';
3892
3893 case 'Z': /* 1..9 */
3894 return 0x0800 | '1';
3895
3896 case '.': /* wildcard */
3897 return 0x10000;
3898
3899 case '!': /* earlymatch */
3900 return 0x20000; /* less specific than NULL */
3901
3902 case '\0': /* empty string */
3903 *p = NULL;
3904 return 0x30000;
3905
3906 case '[': /* pattern */
3907 break;
3908 }
3909 /* locate end of set */
3910 end = strchr(*p, ']');
3911
3912 if (end == NULL) {
3913 ast_log(LOG_WARNING, "Wrong usage of [] in the extension\n");
3914 return 0x40000; /* XXX make this entry go last... */
3915 }
3916
3917 memset(chars, '\0', sizeof(chars)); /* clear all chars in the set */
3918 for (; *p < end ; (*p)++) {
3919 unsigned char c1, c2; /* first-last char in range */
3920 c1 = (unsigned char)((*p)[0]);
3921 if (*p + 2 < end && (*p)[1] == '-') { /* this is a range */
3922 c2 = (unsigned char)((*p)[2]);
3923 *p += 2; /* skip a total of 3 chars */
3924 } else /* individual character */
3925 c2 = c1;
3926 if (c1 < cmin)
3927 cmin = c1;
3928 for (; c1 <= c2; c1++) {
3929 uint32_t mask = 1 << (c1 % 32);
3930 if ( (chars[ c1 / 32 ] & mask) == 0)
3931 count += 0x100;
3932 chars[ c1 / 32 ] |= mask;
3933 }
3934 }
3935 (*p)++;
3936 return count == 0 ? 0x30000 : (count | cmin);
3937}

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

Referenced by ext_cmp().

◆ ext_strncpy()

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

copy a string skipping whitespace

Definition at line 3969 of file extconf.c.

3970{
3971 int count=0;
3972
3973 while (*src && (count < len - 1)) {
3974 switch(*src) {
3975 case ' ':
3976 /* otherwise exten => [a-b],1,... doesn't work */
3977 /* case '-': */
3978 /* Ignore */
3979 break;
3980 default:
3981 *dst = *src;
3982 dst++;
3983 }
3984 src++;
3985 count++;
3986 }
3987 *dst = '\0';
3988
3989 return count;
3990}

References len().

Referenced by ast_add_extension2().

◆ extension_match_core()

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

Definition at line 4284 of file extconf.c.

4285{
4286 int i;
4287 i = _extension_match_core(pattern, data, mode);
4288 return i;
4289}
static int _extension_match_core(const char *pattern, const char *data, enum ext_match_t mode)
Definition: extconf.c:4189

References _extension_match_core(), and ast_context::data.

Referenced by ast_extension_match(), and pbx_find_extension().

◆ find_engine()

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

Find realtime engine for realtime family.

Definition at line 2745 of file extconf.c.

2746{
2747 struct ast_config_engine *eng, *ret = NULL;
2748 struct ast_config_map *map;
2749
2750
2751 for (map = config_maps; map; map = map->next) {
2752 if (!strcasecmp(family, map->name)) {
2753 if (database)
2754 ast_copy_string(database, map->database, dbsiz);
2755 if (table)
2756 ast_copy_string(table, map->table ? map->table : family, tabsiz);
2757 break;
2758 }
2759 }
2760
2761 /* Check if the required driver (engine) exist */
2762 if (map) {
2763 for (eng = config_engine_list; !ret && eng; eng = eng->next) {
2764 if (!strcasecmp(eng->name, map->driver))
2765 ret = eng;
2766 }
2767 }
2768
2769
2770 /* if we found a mapping, but the engine is not available, then issue a warning */
2771 if (map && !ret)
2772 ast_log(LOG_WARNING, "Realtime mapping for '%s' found to engine '%s', but the engine is not available\n", map->name, map->driver);
2773
2774 return ret;
2775}
static struct ast_config_map * config_maps
struct ast_config_engine * next
const char * driver
Definition: main/config.c:206
struct ast_config_map * next
Definition: main/config.c:201
const char * table
Definition: main/config.c:210
const char * database
Definition: main/config.c:208
const char * name
Definition: main/config.c:204

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

Referenced by ast_config_internal_load().

◆ gen_header()

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

Definition at line 3386 of file extconf.c.

3387{
3388 char date[256]="";
3389 time_t t;
3390 time(&t);
3391 ast_copy_string(date, ctime(&t), sizeof(date));
3392
3393 fprintf(f1, ";!\n");
3394 fprintf(f1, ";! Automatically generated configuration file\n");
3395 if (strcmp(configfile, fn))
3396 fprintf(f1, ";! Filename: %s (%s)\n", configfile, fn);
3397 else
3398 fprintf(f1, ";! Filename: %s\n", configfile);
3399 fprintf(f1, ";! Generator: %s\n", generator);
3400 fprintf(f1, ";! Creation Date: %s", date);
3401 fprintf(f1, ";!\n");
3402}

References ast_copy_string().

Referenced by localized_config_text_file_save().

◆ get_range()

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

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

Definition at line 2636 of file extconf.c.

2637{
2638 int start, end; /* start and ending position */
2639 unsigned int mask = 0;
2640 char *part;
2641
2642 /* Check for whole range */
2643 if (ast_strlen_zero(src) || !strcmp(src, "*")) {
2644 return (1 << max) - 1;
2645 }
2646
2647 while ((part = strsep(&src, "&"))) {
2648 /* Get start and ending position */
2649 char *endpart = strchr(part, '-');
2650 if (endpart) {
2651 *endpart++ = '\0';
2652 }
2653 /* Find the start */
2654 if ((start = lookup_name(part, names, max)) < 0) {
2655 ast_log(LOG_WARNING, "Invalid %s '%s', skipping element\n", msg, part);
2656 continue;
2657 }
2658 if (endpart) { /* find end of range */
2659 if ((end = lookup_name(endpart, names, max)) < 0) {
2660 ast_log(LOG_WARNING, "Invalid end %s '%s', skipping element\n", msg, endpart);
2661 continue;
2662 }
2663 } else {
2664 end = start;
2665 }
2666 /* Fill the mask. Remember that ranges are cyclic */
2667 mask |= (1 << end); /* initialize with last element */
2668 while (start != end) {
2669 if (start >= max) {
2670 start = 0;
2671 }
2672 mask |= (1 << start);
2673 start++;
2674 }
2675 }
2676 return mask;
2677}
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 suppli...
Definition: extconf.c:2613
#define max(a, b)
Definition: f2c.h:198

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

Referenced by ast_build_timing().

◆ get_timerange()

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

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

Definition at line 2680 of file extconf.c.

2681{
2682 char *endpart, *part;
2683 int x;
2684 int st_h, st_m;
2685 int endh, endm;
2686 int minute_start, minute_end;
2687
2688 /* start disabling all times, fill the fields with 0's, as they may contain garbage */
2689 memset(i->minmask, 0, sizeof(i->minmask));
2690
2691 /* 1-minute per bit */
2692 /* Star is all times */
2693 if (ast_strlen_zero(times) || !strcmp(times, "*")) {
2694 /* 48, because each hour takes 2 integers; 30 bits each */
2695 for (x = 0; x < 48; x++) {
2696 i->minmask[x] = 0x3fffffff; /* 30 bits */
2697 }
2698 return;
2699 }
2700 /* Otherwise expect a range */
2701 while ((part = strsep(&times, "&"))) {
2702 if (!(endpart = strchr(part, '-'))) {
2703 if (sscanf(part, "%2d:%2d", &st_h, &st_m) != 2 || st_h < 0 || st_h > 23 || st_m < 0 || st_m > 59) {
2704 ast_log(LOG_WARNING, "%s isn't a valid time.\n", part);
2705 continue;
2706 }
2707 i->minmask[st_h * 2 + (st_m >= 30 ? 1 : 0)] |= (1 << (st_m % 30));
2708 continue;
2709 }
2710 *endpart++ = '\0';
2711 /* why skip non digits? Mostly to skip spaces */
2712 while (*endpart && !isdigit(*endpart)) {
2713 endpart++;
2714 }
2715 if (!*endpart) {
2716 ast_log(LOG_WARNING, "Invalid time range starting with '%s-'.\n", part);
2717 continue;
2718 }
2719 if (sscanf(part, "%2d:%2d", &st_h, &st_m) != 2 || st_h < 0 || st_h > 23 || st_m < 0 || st_m > 59) {
2720 ast_log(LOG_WARNING, "'%s' isn't a valid start time.\n", part);
2721 continue;
2722 }
2723 if (sscanf(endpart, "%2d:%2d", &endh, &endm) != 2 || endh < 0 || endh > 23 || endm < 0 || endm > 59) {
2724 ast_log(LOG_WARNING, "'%s' isn't a valid end time.\n", endpart);
2725 continue;
2726 }
2727 minute_start = st_h * 60 + st_m;
2728 minute_end = endh * 60 + endm;
2729 /* Go through the time and enable each appropriate bit */
2730 for (x = minute_start; x != minute_end; x = (x + 1) % (24 * 60)) {
2731 i->minmask[x / 30] |= (1 << (x % 30));
2732 }
2733 /* Do the last one */
2734 i->minmask[x / 30] |= (1 << (x % 30));
2735 }
2736 /* All done */
2737 return;
2738}
unsigned int minmask[48]
Definition: pbx.h:177

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

Referenced by ast_build_timing().

◆ include_valid()

static int include_valid ( struct ast_include i)
inlinestatic

Definition at line 4309 of file extconf.c.

4310{
4311 if (!i->hastime)
4312 return 1;
4313
4314 return ast_check_timing(&(i->timing));
4315}
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.
Definition: extconf.c:3998

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

Referenced by pbx_find_extension().

◆ inherit_category()

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

Definition at line 2821 of file extconf.c.

2822{
2823 struct ast_variable *var;
2824
2825 for (var = base->root; var; var = var->next)
2827}
static void ast_variable_append(struct ast_category *category, struct ast_variable *variable)
Definition: extconf.c:1175
static struct ast_variable * variable_clone(const struct ast_variable *old)
Definition: extconf.c:1246

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

Referenced by process_text_line().

◆ LLB_ADD()

static void LLB_ADD ( char *  str)
static

Definition at line 762 of file extconf.c.

763{
764 int rem = lline_buffer_size - strlen(lline_buffer) - 1;
765 int siz = strlen(str);
766 if (rem < siz+1) {
768 if (!lline_buffer)
769 return;
770 lline_buffer_size += CB_INCR + siz + 1;
771 }
772 strcat(lline_buffer,str);
773}

References ast_realloc, CB_INCR, lline_buffer, lline_buffer_size, and str.

Referenced by config_text_file_load().

◆ localized_add_extension2()

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

Definition at line 4893 of file extconf.c.

4897{
4898 return ast_add_extension2(con, replace, extension, priority, label, callerid, application, data, datad, registrar);
4899}
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.
Definition: extconf.c:4771

References ast_add_extension2(), ast_exten::data, ast_exten::datad, ast_exten::label, priority, registrar, and replace().

◆ localized_ast_include_rename()

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

Definition at line 1108 of file extconf.c.

1109{
1110 struct ast_config_include *incl;
1111 struct ast_category *cat;
1112 struct ast_variable *v;
1113
1114 int from_len = strlen(from_file);
1115 int to_len = strlen(to_file);
1116
1117 if (strcmp(from_file, to_file) == 0) /* no use wasting time if the name is the same */
1118 return;
1119
1120 /* the manager code allows you to read in one config file, then
1121 write it back out under a different name. But, the new arrangement
1122 ties output lines to the file name. So, before you try to write
1123 the config file to disk, better riffle thru the data and make sure
1124 the file names are changed.
1125 */
1126 /* file names are on categories, includes (of course), and on variables. So,
1127 traverse all this and swap names */
1128
1129 for (incl = conf->includes; incl; incl=incl->next) {
1130 if (strcmp(incl->include_location_file,from_file) == 0) {
1131 if (from_len >= to_len)
1132 strcpy(incl->include_location_file, to_file);
1133 else {
1135 incl->include_location_file = strdup(to_file);
1136 }
1137 }
1138 }
1139 for (cat = conf->root; cat; cat = cat->next) {
1140 if (strcmp(cat->file,from_file) == 0) {
1141 if (from_len >= to_len)
1142 strcpy(cat->file, to_file);
1143 else {
1144 free(cat->file);
1145 cat->file = strdup(to_file);
1146 }
1147 }
1148 for (v = cat->root; v; v = v->next) {
1149 if (strcmp(v->file,from_file) == 0) {
1150 if (from_len >= to_len)
1151 strcpy(v->file, to_file);
1152 else {
1153 free(v->file);
1154 v->file = strdup(to_file);
1155 }
1156 }
1157 }
1158 }
1159}

References ast_variable::file, ast_category::file, free(), ast_config_include::include_location_file, ast_variable::next, ast_category::next, ast_config_include::next, ast_category::root, and strdup.

◆ localized_category_get()

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

Definition at line 2799 of file extconf.c.

2800{
2801 return category_get(config, category_name, 0);
2802}

References category_get(), and config.

◆ localized_config_load()

struct ast_config * localized_config_load ( const char *  filename)

Definition at line 3283 of file extconf.c.

3284{
3285 struct ast_config *cfg;
3286 struct ast_config *result;
3287
3288 cfg = ast_config_new();
3289 if (!cfg)
3290 return NULL;
3291
3292 result = ast_config_internal_load(filename, cfg, 0, "");
3293 if (!result)
3294 ast_config_destroy(cfg);
3295
3296 return result;
3297}
static struct ast_config * ast_config_new(void)
Definition: extconf.c:3272
static struct ast_config * ast_config_internal_load(const char *filename, struct ast_config *cfg, int withcomments, const char *suggested_incl_file)
Definition: extconf.c:2860
static void ast_config_destroy(struct ast_config *cfg)
Definition: extconf.c:1287

References ast_config_destroy(), ast_config_internal_load(), ast_config_new(), NULL, and result.

Referenced by pbx_load_config().

◆ localized_config_load_with_comments()

struct ast_config * localized_config_load_with_comments ( const char *  filename)

Definition at line 3301 of file extconf.c.

3302{
3303 struct ast_config *cfg;
3304 struct ast_config *result;
3305
3306 cfg = ast_config_new();
3307 if (!cfg)
3308 return NULL;
3309
3310 result = ast_config_internal_load(filename, cfg, 1, "");
3311 if (!result)
3312 ast_config_destroy(cfg);
3313
3314 return result;
3315}

References ast_config_destroy(), ast_config_internal_load(), ast_config_new(), NULL, and result.

◆ localized_config_text_file_save()

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

Definition at line 3419 of file extconf.c.

3420{
3421 FILE *f;
3422 char fn[256];
3423 struct ast_variable *var;
3424 struct ast_category *cat;
3425 struct ast_comment *cmt;
3426 struct ast_config_include *incl;
3427 int blanklines = 0;
3428
3429 /* reset all the output flags, in case this isn't our first time saving this data */
3430
3431 for (incl=cfg->includes; incl; incl = incl->next)
3432 incl->output = 0;
3433
3434 /* go thru all the inclusions and make sure all the files involved (configfile plus all its inclusions)
3435 are all truncated to zero bytes and have that nice header*/
3436
3437 for (incl=cfg->includes; incl; incl = incl->next)
3438 {
3439 if (!incl->exec) { /* leave the execs alone -- we'll write out the #exec directives, but won't zero out the include files or exec files*/
3440 FILE *f1;
3441
3442 set_fn(fn, sizeof(fn), incl->included_file, configfile); /* normally, fn is just set to incl->included_file, prepended with config dir if relative */
3443 f1 = fopen(fn,"w");
3444 if (f1) {
3445 gen_header(f1, configfile, fn, generator);
3446 fclose(f1); /* this should zero out the file */
3447 } else {
3448 ast_verbose(VERBOSE_PREFIX_2 "Unable to write %s (%s)", fn, strerror(errno));
3449 }
3450 }
3451 }
3452
3453 set_fn(fn, sizeof(fn), 0, configfile); /* just set fn to absolute ver of configfile */
3454#ifdef __CYGWIN__
3455 if ((f = fopen(fn, "w+"))) {
3456#else
3457 if ((f = fopen(fn, "w"))) {
3458#endif
3459 if (option_verbose > 1)
3460 ast_verbose(VERBOSE_PREFIX_2 "Saving '%s': ", fn);
3461
3462 gen_header(f, configfile, fn, generator);
3463 cat = cfg->root;
3464 fclose(f);
3465
3466 /* from here out, we open each involved file and concat the stuff we need to add to the end and immediately close... */
3467 /* since each var, cat, and associated comments can come from any file, we have to be
3468 mobile, and open each file, print, and close it on an entry-by-entry basis */
3469
3470 while(cat) {
3471 set_fn(fn, sizeof(fn), cat->file, configfile);
3472 f = fopen(fn, "a");
3473 if (!f)
3474 {
3475 ast_verbose(VERBOSE_PREFIX_2 "Unable to write %s (%s)", fn, strerror(errno));
3476 return -1;
3477 }
3478
3479 /* dump any includes that happen before this category header */
3480 for (incl=cfg->includes; incl; incl = incl->next) {
3481 if (strcmp(incl->include_location_file, cat->file) == 0){
3482 if (cat->lineno > incl->include_location_lineno && !incl->output) {
3483 if (incl->exec)
3484 fprintf(f,"#exec \"%s\"\n", incl->exec_file);
3485 else
3486 fprintf(f,"#include \"%s\"\n", incl->included_file);
3487 incl->output = 1;
3488 }
3489 }
3490 }
3491
3492 /* Dump section with any appropriate comment */
3493 for (cmt = cat->precomments; cmt; cmt=cmt->next) {
3494 if (cmt->cmt[0] != ';' || cmt->cmt[1] != '!')
3495 fprintf(f,"%s", cmt->cmt);
3496 }
3497 if (!cat->precomments)
3498 fprintf(f,"\n");
3499 fprintf(f, "[%s]", cat->name);
3500 for(cmt = cat->sameline; cmt; cmt=cmt->next) {
3501 fprintf(f,"%s", cmt->cmt);
3502 }
3503 if (!cat->sameline)
3504 fprintf(f,"\n");
3505 fclose(f);
3506
3507 var = cat->root;
3508 while(var) {
3509 set_fn(fn, sizeof(fn), var->file, configfile);
3510 f = fopen(fn, "a");
3511 if (!f)
3512 {
3513 ast_verbose(VERBOSE_PREFIX_2 "Unable to write %s (%s)", fn, strerror(errno));
3514 return -1;
3515 }
3516
3517 /* dump any includes that happen before this category header */
3518 for (incl=cfg->includes; incl; incl = incl->next) {
3519 if (strcmp(incl->include_location_file, var->file) == 0){
3520 if (var->lineno > incl->include_location_lineno && !incl->output) {
3521 if (incl->exec)
3522 fprintf(f,"#exec \"%s\"\n", incl->exec_file);
3523 else
3524 fprintf(f,"#include \"%s\"\n", incl->included_file);
3525 incl->output = 1;
3526 }
3527 }
3528 }
3529
3530 for (cmt = var->precomments; cmt; cmt=cmt->next) {
3531 if (cmt->cmt[0] != ';' || cmt->cmt[1] != '!')
3532 fprintf(f,"%s", cmt->cmt);
3533 }
3534 if (var->sameline)
3535 fprintf(f, "%s %s %s %s", var->name, (var->object ? "=>" : "="), var->value, var->sameline->cmt);
3536 else
3537 fprintf(f, "%s %s %s\n", var->name, (var->object ? "=>" : "="), var->value);
3538 if (var->blanklines) {
3539 blanklines = var->blanklines;
3540 while (blanklines--)
3541 fprintf(f, "\n");
3542 }
3543
3544 fclose(f);
3545
3546
3547 var = var->next;
3548 }
3549 cat = cat->next;
3550 }
3551 if ((option_verbose > 1) && !option_debug)
3552 ast_verbose("Saved\n");
3553 } else {
3554 if (option_debug)
3555 ast_log(LOG_DEBUG, "Unable to open for writing: %s\n", fn);
3556 if (option_verbose > 1)
3557 ast_verbose(VERBOSE_PREFIX_2 "Unable to write (%s)", strerror(errno));
3558 return -1;
3559 }
3560
3561 /* Now, for files with trailing #include/#exec statements,
3562 we have to make sure every entry is output */
3563
3564 for (incl=cfg->includes; incl; incl = incl->next) {
3565 if (!incl->output) {
3566 /* open the respective file */
3567 set_fn(fn, sizeof(fn), incl->include_location_file, configfile);
3568 f = fopen(fn, "a");
3569 if (!f)
3570 {
3571 ast_verbose(VERBOSE_PREFIX_2 "Unable to write %s (%s)", fn, strerror(errno));
3572 return -1;
3573 }
3574
3575 /* output the respective include */
3576 if (incl->exec)
3577 fprintf(f,"#exec \"%s\"\n", incl->exec_file);
3578 else
3579 fprintf(f,"#include \"%s\"\n", incl->included_file);
3580 fclose(f);
3581 incl->output = 1;
3582 }
3583 }
3584
3585 return 0;
3586}
static void gen_header(FILE *f1, const char *configfile, const char *fn, const char *generator)
Definition: extconf.c:3386
static void set_fn(char *fn, int fn_size, const char *file, const char *configfile)
Definition: extconf.c:3404
struct ast_comment * precomments
Definition: main/config.c:237
struct ast_comment * sameline
Definition: main/config.c:238
struct ast_comment * next
Definition: main/config.c:86

References ast_log(), ast_verbose(), ast_comment::cmt, errno, ast_config_include::exec, ast_config_include::exec_file, ast_category::file, gen_header(), ast_config_include::include_location_file, ast_config_include::include_location_lineno, ast_config_include::included_file, ast_config::includes, ast_category::lineno, LOG_DEBUG, ast_category::name, ast_comment::next, ast_category::next, ast_config_include::next, option_debug, option_verbose, ast_config_include::output, ast_category::precomments, ast_category::root, ast_config::root, ast_category::sameline, set_fn(), var, and VERBOSE_PREFIX_2.

◆ localized_context_add_ignorepat2()

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

Definition at line 4597 of file extconf.c.

4598{
4600}
static int ast_context_add_ignorepat2(struct ast_context *con, const char *value, const char *registrar)
Definition: extconf.c:4565

References ast_context_add_ignorepat2(), registrar, and value.

◆ localized_context_add_include2()

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

Definition at line 4555 of file extconf.c.

4557{
4559}
static int ast_context_add_include2(struct ast_context *con, const char *value, const char *registrar)
Definition: extconf.c:4499

References ast_context_add_include2(), registrar, and value.

◆ localized_context_add_switch2()

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

Definition at line 4698 of file extconf.c.

4700{
4701 return ast_context_add_switch2(con, value, data, eval, registrar);
4702}
static int ast_context_add_switch2(struct ast_context *con, const char *value, const char *data, int eval, const char *registrar)
Definition: extconf.c:4637

References ast_context_add_switch2(), ast_sw::data, ast_sw::eval, registrar, and value.

◆ localized_context_destroy()

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

◆ localized_context_find_or_create()

struct ast_context * localized_context_find_or_create ( struct ast_context **  extcontexts,
void *  tab,
const char *  name,
const char *  registrar 
)
Version
1.6.1 added tab parameter
1.6.1 renamed function from localized_context_create to localized_context_find_or_create

Definition at line 4984 of file extconf.c.

4985{
4986 return __ast_context_create(extcontexts, name, registrar, 1);
4987}

References __ast_context_create(), name, and registrar.

◆ localized_context_verify_includes()

int localized_context_verify_includes ( struct ast_context con)

Definition at line 5635 of file extconf.c.

5636{
5637 return ast_context_verify_includes(con);
5638}
static int ast_context_verify_includes(struct ast_context *con)
Definition: extconf.c:5618

References ast_context_verify_includes().

◆ localized_find_extension()

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

Definition at line 4466 of file extconf.c.

4474{
4475 return pbx_find_extension(NULL, bypass, q, context, exten, priority, label, callerid, action);
4476}
static struct ast_exten * pbx_find_extension(struct ast_channel *chan, struct ast_context *bypass, struct pbx_find_info *q, const char *context, const char *exten, int priority, const char *label, const char *callerid, enum ext_match_t action)
Definition: extconf.c:4330

References voicemailpwcheck::context, ast_exten::exten, ast_exten::label, NULL, pbx_find_extension(), and priority.

Referenced by pbx_find_extension().

◆ localized_merge_contexts_and_delete()

void localized_merge_contexts_and_delete ( struct ast_context **  extcontexts,
void *  tab,
const char *  registrar 
)
Version
1.6.1 added tab parameter

Definition at line 5613 of file extconf.c.

5614{
5616}
static void ast_merge_contexts_and_delete(struct ast_context **extcontexts, const char *registrar)
Definition: extconf.c:5568

References ast_merge_contexts_and_delete(), and registrar.

◆ localized_pbx_builtin_setvar()

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

Definition at line 2603 of file extconf.c.

2604{
2605 return pbx_builtin_setvar(chan, data);
2606}
static int pbx_builtin_setvar(struct ast_channel *chan, const void *data)
Definition: extconf.c:2566

References pbx_builtin_setvar().

◆ localized_pbx_load_module()

int localized_pbx_load_module ( void  )

Definition at line 5642 of file extconf.c.

5643{
5644 struct ast_context *con;
5645
5647 return -1 /* AST_MODULE_LOAD_DECLINE*/;
5648
5649 /* pbx_load_users(); */ /* does this affect the dialplan? */
5650
5652
5653 for (con = NULL; (con = ast_walk_contexts(con));)
5655
5656 printf("=== Loading extensions.conf ===\n");
5657 con = 0;
5658 while ((con = ast_walk_contexts(con)) ) {
5659 printf("Context: %s\n", con->name);
5660 }
5661 printf("=========\n");
5662
5663 return 0;
5664}
static struct ast_context * local_contexts
Definition: extconf.c:3594
static int pbx_load_config(const char *config_file)
Definition: extconf.c:5334
static char * global_registrar
Definition: extconf.c:2119
static char * config_filename
Definition: extconf.c:2118

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().

Referenced by check_goto(), and check_pval_item().

◆ localized_use_conf_dir()

void localized_use_conf_dir ( void  )

Definition at line 3111 of file extconf.c.

3112{
3113 use_local_dir = 0;
3114}

References use_local_dir.

Referenced by main().

◆ localized_use_local_dir()

void localized_use_local_dir ( void  )

Definition at line 3106 of file extconf.c.

3107{
3108 use_local_dir = 1;
3109}

References use_local_dir.

Referenced by main().

◆ localized_walk_context_extensions()

struct ast_exten * localized_walk_context_extensions ( struct ast_context con,
struct ast_exten exten 
)

Definition at line 4049 of file extconf.c.

4051{
4052 return ast_walk_context_extensions(con,exten);
4053}
static struct ast_exten * ast_walk_context_extensions(struct ast_context *con, struct ast_exten *exten)
Definition: extconf.c:4038

References ast_walk_context_extensions(), and ast_exten::exten.

◆ localized_walk_context_includes()

struct ast_include * localized_walk_context_includes ( struct ast_context con,
struct ast_include inc 
)

Definition at line 4102 of file extconf.c.

4104{
4105 return ast_walk_context_includes(con, inc);
4106}

References ast_walk_context_includes().

◆ localized_walk_context_switches()

struct ast_sw * localized_walk_context_switches ( struct ast_context con,
struct ast_sw sw 
)

Definition at line 4148 of file extconf.c.

4150{
4151 return ast_walk_context_switches(con, sw);
4152}

References ast_walk_context_switches().

◆ localized_walk_contexts()

struct ast_context * localized_walk_contexts ( struct ast_context con)

Definition at line 4028 of file extconf.c.

4029{
4030 return ast_walk_contexts(con);
4031}

References ast_walk_contexts().

◆ localized_walk_extension_priorities()

struct ast_exten * localized_walk_extension_priorities ( struct ast_exten exten,
struct ast_exten priority 
)

Definition at line 4067 of file extconf.c.

4069{
4071}
static struct ast_exten * ast_walk_extension_priorities(struct ast_exten *exten, struct ast_exten *priority)
Definition: extconf.c:4059

References ast_walk_extension_priorities(), ast_exten::exten, and priority.

◆ lookup_name()

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

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

Definition at line 2613 of file extconf.c.

2614{
2615 int i;
2616
2617 if (names && *s > '9') {
2618 for (i = 0; names[i]; i++) {
2619 if (!strcasecmp(s, names[i])) {
2620 return i;
2621 }
2622 }
2623 }
2624
2625 /* Allow months and weekdays to be specified as numbers, as well */
2626 if (sscanf(s, "%2d", &i) == 1 && i >= 1 && i <= max) {
2627 /* What the array offset would have been: "1" would be at offset 0 */
2628 return i - 1;
2629 }
2630 return -1; /* error return */
2631}

References max.

Referenced by get_range().

◆ matchcid()

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

Definition at line 4298 of file extconf.c.

4299{
4300 /* If the Caller*ID pattern is empty, then we're matching NO Caller*ID, so
4301 failing to get a number should count as a match, otherwise not */
4302
4303 if (ast_strlen_zero(callerid))
4304 return ast_strlen_zero(cidpattern) ? 1 : 0;
4305
4306 return ast_extension_match(cidpattern, callerid);
4307}
static int ast_extension_match(const char *pattern, const char *data)
Definition: extconf.c:4293

References ast_extension_match(), and ast_strlen_zero().

Referenced by pbx_find_extension().

◆ move_variables()

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

Definition at line 2804 of file extconf.c.

2805{
2806 struct ast_variable *var = old->root;
2807 old->root = NULL;
2808#if 1
2809 /* we can just move the entire list in a single op */
2811#else
2812 while (var) {
2813 struct ast_variable *next = var->next;
2814 var->next = NULL;
2816 var = next;
2817 }
2818#endif
2819}

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

Referenced by process_text_line().

◆ next_available_category()

static struct ast_category * next_available_category ( struct ast_category cat)
static

Definition at line 3317 of file extconf.c.

3318{
3319 for (; cat && cat->ignored; cat = cat->next);
3320
3321 return cat;
3322}

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

Referenced by ast_category_browse().

◆ null_datad()

static void null_datad ( void *  foo)
static

Definition at line 2740 of file extconf.c.

2741{
2742}

Referenced by ast_add_extension2().

◆ parse_variable_name()

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

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

Definition at line 5001 of file extconf.c.

5002{
5003 int parens=0;
5004
5005 *offset = 0;
5006 *length = INT_MAX;
5007 *isfunc = 0;
5008 for (; *var; var++) {
5009 if (*var == '(') {
5010 (*isfunc)++;
5011 parens++;
5012 } else if (*var == ')') {
5013 parens--;
5014 } else if (*var == ':' && parens == 0) {
5015 *var++ = '\0';
5016 sscanf(var, "%30d:%30d", offset, length);
5017 return 1; /* offset:length valid */
5018 }
5019 }
5020 return 0;
5021}

References var.

Referenced by pbx_retrieve_variable(), and pbx_substitute_variables_helper_full().

◆ pbx_builtin_setvar()

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

Definition at line 2566 of file extconf.c.

2567{
2568 char *name, *value, *mydata;
2569 int argc;
2570 char *argv[24]; /* this will only support a maximum of 24 variables being set in a single operation */
2571 int global = 0;
2572 int x;
2573
2574 if (ast_strlen_zero(data)) {
2575 ast_log(LOG_WARNING, "Set requires at least one variable name/value pair.\n");
2576 return 0;
2577 }
2578
2579 mydata = ast_strdupa(data);
2580 argc = ast_app_separate_args(mydata, '|', argv, sizeof(argv) / sizeof(argv[0]));
2581
2582 /* check for a trailing flags argument */
2583 if ((argc > 1) && !strchr(argv[argc-1], '=')) {
2584 argc--;
2585 if (strchr(argv[argc], 'g'))
2586 global = 1;
2587 }
2588
2589 for (x = 0; x < argc; x++) {
2590 name = argv[x];
2591 if ((value = strchr(name, '='))) {
2592 *value++ = '\0';
2594 } else
2595 ast_log(LOG_WARNING, "Ignoring entry '%s' with no = (and not last 'options' entry)\n", name);
2596 }
2597
2598 return(0);
2599}
static void pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Definition: extconf.c:2526
static unsigned int ast_app_separate_args(char *buf, char delim, char **array, int arraylen)
Definition: extconf.c:2484
static struct aco_type global
Definition: test_config.c:1445

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

Referenced by localized_pbx_builtin_setvar().

◆ pbx_builtin_setvar_helper()

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

Definition at line 2526 of file extconf.c.

2527{
2528 struct ast_var_t *newvariable;
2529 struct varshead *headp;
2530 const char *nametail = name;
2531
2532 /* XXX may need locking on the channel ? */
2533 if (name[strlen(name)-1] == ')') {
2534 char *function = ast_strdupa(name);
2535
2536 ast_func_write(chan, function, value);
2537 return;
2538 }
2539
2540 headp = &globals;
2541
2542 /* For comparison purposes, we have to strip leading underscores */
2543 if (*nametail == '_') {
2544 nametail++;
2545 if (*nametail == '_')
2546 nametail++;
2547 }
2548
2549 AST_LIST_TRAVERSE (headp, newvariable, entries) {
2550 if (strcasecmp(ast_var_name(newvariable), nametail) == 0) {
2551 /* there is already such a variable, delete it */
2552 AST_LIST_REMOVE(headp, newvariable, entries);
2553 ast_var_delete(newvariable);
2554 break;
2555 }
2556 }
2557
2558 if (value && (newvariable = ast_var_assign(name, value))) {
2559 if ((option_verbose > 1) && (headp == &globals))
2560 ast_verbose(VERBOSE_PREFIX_2 "Setting global variable '%s' to '%s'\n", name, value);
2561 AST_LIST_INSERT_HEAD(headp, newvariable, entries);
2562 }
2563
2564}
static struct ast_var_t * ast_var_assign(const char *name, const char *value)
Definition: extconf.c:2452
static const char * ast_var_name(const struct ast_var_t *var)
Definition: extconf.c:2168
#define AST_LIST_INSERT_HEAD(head, elm, field)
Inserts a list entry at the head of a list.
Definition: extconf.c:1954
#define AST_LIST_REMOVE(head, elm, field)
Removes a specific entry from a list.
Definition: extconf.c:2035
static int ast_func_write(struct ast_channel *chan, const char *function, const char *value)
Definition: extconf.c:2476
static void ast_var_delete(struct ast_var_t *var)
Definition: extconf.c:2469
static struct varshead globals
Definition: extconf.c:2066

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

Referenced by pbx_builtin_setvar(), and pbx_load_config().

◆ pbx_extension_helper()

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

The return value depends on the action:

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

Definition at line 4912 of file extconf.c.

4915{
4916 struct ast_exten *e;
4917 int res;
4918 struct pbx_find_info q = { .stacklen = 0 }; /* the rest is reset in pbx_find_extension */
4919
4920 int matching_action = (action == E_MATCH || action == E_CANMATCH || action == E_MATCHMORE);
4921
4922 e = pbx_find_extension(NULL, con, &q, context, exten, priority, label, callerid, action);
4923 if (e) {
4924 if (matching_action) {
4925 return -1; /* success, we found it */
4926 } else if (action == E_FINDLABEL) { /* map the label to a priority */
4927 res = e->priority;
4928 return res; /* the priority we were looking for */
4929 } else { /* spawn */
4930
4931 /* NOT!!!!! */
4932 return 0;
4933 }
4934 } else if (q.swo) { /* not found here, but in another switch */
4935 if (matching_action)
4936 return -1;
4937 else {
4938 if (!q.swo->exec) {
4939 ast_log(LOG_WARNING, "No execution engine for switch %s\n", q.swo->name);
4940 res = -1;
4941 }
4942 return q.swo->exec(c, q.foundcontext ? q.foundcontext : context, exten, priority, callerid, q.data);
4943 }
4944 } else { /* not found anywhere, see what happened */
4945 switch (q.status) {
4946 case STATUS_NO_CONTEXT:
4947 if (!matching_action)
4948 ast_log(LOG_NOTICE, "Cannot find extension context '%s'\n", context);
4949 break;
4951 if (!matching_action)
4952 ast_log(LOG_NOTICE, "Cannot find extension '%s' in context '%s'\n", exten, context);
4953 break;
4954 case STATUS_NO_PRIORITY:
4955 if (!matching_action)
4956 ast_log(LOG_NOTICE, "No such priority %d in extension '%s' in context '%s'\n", priority, exten, context);
4957 break;
4958 case STATUS_NO_LABEL:
4959 if (context)
4960 ast_log(LOG_NOTICE, "No such label '%s' in extension '%s' in context '%s'\n", label, exten, context);
4961 break;
4962 default:
4963 if (option_debug)
4964 ast_log(LOG_DEBUG, "Shouldn't happen!\n");
4965 }
4966
4967 return (matching_action) ? 0 : -1;
4968 }
4969}
#define STATUS_NO_LABEL
Definition: extconf.c:2449
#define STATUS_NO_EXTENSION
Definition: extconf.c:2447
#define STATUS_NO_CONTEXT
Definition: extconf.c:2446
#define STATUS_NO_PRIORITY
Definition: extconf.c:2448
#define LOG_NOTICE
Definition: extconf.c:133
@ E_CANMATCH
Definition: extconf.h:216
ast_switch_f * exec
Definition: pbx.h:168
const char * name
Definition: pbx.h:163
int stacklen
Definition: extconf.h:237
struct ast_switch * swo
Definition: extconf.h:239
const char * foundcontext
Definition: extconf.h:241
const char * data
Definition: extconf.h:240

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

Referenced by ast_findlabel_extension2().

◆ pbx_find_extension()

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

Definition at line 4330 of file extconf.c.

4339{
4340 int x;
4341 struct ast_context *tmp;
4342 struct ast_exten *e, *eroot;
4343 struct ast_include *i;
4344
4345 if (!context) {
4346 return NULL;
4347 }
4348
4349 /* Initialize status if appropriate */
4350 if (q->stacklen == 0) {
4352 q->swo = NULL;
4353 q->data = NULL;
4354 q->foundcontext = NULL;
4355 } else if (q->stacklen >= AST_PBX_MAX_STACK) {
4356 ast_log(LOG_WARNING, "Maximum PBX stack exceeded\n");
4357 return NULL;
4358 }
4359 /* Check first to see if we've already been checked */
4360 for (x = 0; x < q->stacklen; x++) {
4361 if (!strcasecmp(q->incstack[x], context))
4362 return NULL;
4363 }
4364 if (bypass) /* bypass means we only look there */
4365 tmp = bypass;
4366 else { /* look in contexts */
4367 tmp = NULL;
4368 while ((tmp = ast_walk_contexts(tmp)) ) {
4369 if (!strcmp(tmp->name, context))
4370 break;
4371 }
4372 if (!tmp)
4373 return NULL;
4374 }
4375 if (q->status < STATUS_NO_EXTENSION)
4377
4378 /* scan the list trying to match extension and CID */
4379 eroot = NULL;
4380 while ( (eroot = ast_walk_context_extensions(tmp, eroot)) ) {
4381 int match = extension_match_core(eroot->exten, exten, action);
4382 /* 0 on fail, 1 on match, 2 on earlymatch */
4383
4384 if (!match || (eroot->matchcid && !matchcid(eroot->cidmatch, callerid)))
4385 continue; /* keep trying */
4386 if (match == 2 && action == E_MATCHMORE) {
4387 /* We match an extension ending in '!'.
4388 * The decision in this case is final and is NULL (no match).
4389 */
4390 return NULL;
4391 }
4392 /* found entry, now look for the right priority */
4393 if (q->status < STATUS_NO_PRIORITY)
4395 e = NULL;
4396 while ( (e = ast_walk_extension_priorities(eroot, e)) ) {
4397 /* Match label or priority */
4398 if (action == E_FINDLABEL) {
4399 if (q->status < STATUS_NO_LABEL)
4401 if (label && e->label && !strcmp(label, e->label))
4402 break; /* found it */
4403 } else if (e->priority == priority) {
4404 break; /* found it */
4405 } /* else keep searching */
4406 }
4407 if (e) { /* found a valid match */
4409 q->foundcontext = context;
4410 return e;
4411 }
4412 }
4413#ifdef NOT_RIGHT_NOW
4414 /* Check alternative switches??? */
4415 AST_LIST_TRAVERSE(&tmp->alts, sw, list) {
4416 struct ast_switch *asw = pbx_findswitch(sw->name);
4417 ast_switch_f *aswf = NULL;
4418 char *datap;
4419
4420 if (!asw) {
4421 ast_log(LOG_WARNING, "No such switch '%s'\n", sw->name);
4422 continue;
4423 }
4424 /* No need to Substitute variables now; we shouldn't be here if there's any */
4425
4426 /* equivalent of extension_match_core() at the switch level */
4427 if (action == E_CANMATCH)
4428 aswf = asw->canmatch;
4429 else if (action == E_MATCHMORE)
4430 aswf = asw->matchmore;
4431 else /* action == E_MATCH */
4432 aswf = asw->exists;
4433 datap = sw->eval ? sw->tmpdata : sw->data;
4434 res = !aswf ? 0 : aswf(chan, context, exten, priority, callerid, datap);
4435 if (res) { /* Got a match */
4436 q->swo = asw;
4437 q->data = datap;
4438 q->foundcontext = context;
4439 /* XXX keep status = STATUS_NO_CONTEXT ? */
4440 return NULL;
4441 }
4442 }
4443#endif
4444 q->incstack[q->stacklen++] = tmp->name; /* Setup the stack */
4445 /* Now try any includes we have in this context */
4446 for (i = tmp->includes; i; i = i->next) {
4447 if (include_valid(i)) {
4448 if ((e = pbx_find_extension(NULL, bypass, q, i->rname, exten, priority, label, callerid, action)))
4449 return e;
4450 if (q->swo)
4451 return NULL;
4452 }
4453 }
4454 return NULL;
4455}
static int match(struct ast_sockaddr *addr, unsigned short callno, unsigned short dcallno, const struct chan_iax2_pvt *cur, int check_dcallno)
Definition: chan_iax2.c:2388
static int include_valid(struct ast_include *i)
Definition: extconf.c:4309
int() ast_switch_f(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)
Definition: extconf.c:2103
static int matchcid(const char *cidpattern, const char *callerid)
Definition: extconf.c:4298
#define STATUS_SUCCESS
Definition: extconf.c:2450
#define AST_PBX_MAX_STACK
Definition: extconf.h:225
struct ast_switch * pbx_findswitch(const char *sw)
Definition: pbx_switch.c:40
ast_switch_f * canmatch
Definition: pbx.h:167
ast_switch_f * exists
Definition: pbx.h:166
ast_switch_f * matchmore
Definition: pbx.h:169
char * incstack[AST_PBX_MAX_STACK]
Definition: extconf.h:236

References ast_context::alts, AST_LIST_TRAVERSE, ast_log(), AST_PBX_MAX_STACK, ast_walk_context_extensions(), ast_walk_contexts(), ast_walk_extension_priorities(), ast_switch::canmatch, ast_exten::cidmatch, voicemailpwcheck::context, pbx_find_info::data, E_CANMATCH, E_FINDLABEL, E_MATCHMORE, ast_switch::exists, ast_exten::exten, extension_match_core(), pbx_find_info::foundcontext, include_valid(), ast_context::includes, pbx_find_info::incstack, ast_exten::label, LOG_WARNING, match(), ast_exten::matchcid, matchcid(), ast_switch::matchmore, ast_context::name, ast_include::next, NULL, pbx_find_extension(), pbx_findswitch(), priority, ast_exten::priority, ast_include::rname, pbx_find_info::stacklen, pbx_find_info::status, STATUS_NO_CONTEXT, STATUS_NO_EXTENSION, STATUS_NO_LABEL, STATUS_NO_PRIORITY, STATUS_SUCCESS, and pbx_find_info::swo.

Referenced by localized_find_extension(), pbx_extension_helper(), and pbx_find_extension().

◆ pbx_load_config()

static int pbx_load_config ( const char *  config_file)
static

Definition at line 5334 of file extconf.c.

5335{
5336 struct ast_config *cfg;
5337 char *end;
5338 char *label;
5339 char realvalue[256];
5340 int lastpri = -2;
5341 struct ast_context *con;
5342 struct ast_variable *v;
5343 const char *cxt;
5344 const char *aft;
5345
5347 if (!cfg)
5348 return 0;
5349
5350 /* Use existing config to populate the PBX table */
5351 static_config = ast_true(ast_variable_retrieve(cfg, "general", "static"));
5352 write_protect_config = ast_true(ast_variable_retrieve(cfg, "general", "writeprotect"));
5353 if ((aft = ast_variable_retrieve(cfg, "general", "autofallthrough")))
5355 clearglobalvars_config = ast_true(ast_variable_retrieve(cfg, "general", "clearglobalvars"));
5356
5357 if ((cxt = ast_variable_retrieve(cfg, "general", "userscontext")))
5359 else
5360 ast_copy_string(userscontext, "default", sizeof(userscontext));
5361
5362 for (v = ast_variable_browse(cfg, "globals"); v; v = v->next) {
5363 memset(realvalue, 0, sizeof(realvalue));
5364 pbx_substitute_variables_helper(NULL, v->value, realvalue, sizeof(realvalue) - 1);
5365 pbx_builtin_setvar_helper(NULL, v->name, realvalue);
5366 }
5367 for (cxt = NULL; (cxt = ast_category_browse(cfg, cxt)); ) {
5368 /* All categories but "general" or "globals" are considered contexts */
5369 if (!strcasecmp(cxt, "general") || !strcasecmp(cxt, "globals"))
5370 continue;
5372 if (con == NULL)
5373 continue;
5374
5375 for (v = ast_variable_browse(cfg, cxt); v; v = v->next) {
5376 if (!strcasecmp(v->name, "exten")) {
5377 char *tc = ast_strdup(v->value);
5378 if (tc) {
5379 int ipri = -2;
5380 char realext[256]="";
5381 char *plus, *firstp, *firstc;
5382 char *pri, *appl, *data, *cidmatch;
5383 char *stringp = tc;
5384 char *ext = strsep(&stringp, ",");
5385 if (!ext)
5386 ext="";
5387 pbx_substitute_variables_helper(NULL, ext, realext, sizeof(realext) - 1);
5388 cidmatch = strchr(realext, '/');
5389 if (cidmatch) {
5390 *cidmatch++ = '\0';
5391 ast_shrink_phone_number(cidmatch);
5392 }
5393 pri = strsep(&stringp, ",");
5394 if (!pri)
5395 pri="";
5396 label = strchr(pri, '(');
5397 if (label) {
5398 *label++ = '\0';
5399 end = strchr(label, ')');
5400 if (end)
5401 *end = '\0';
5402 else
5403 ast_log(LOG_WARNING, "Label missing trailing ')' at line %d\n", v->lineno);
5404 }
5405 plus = strchr(pri, '+');
5406 if (plus)
5407 *plus++ = '\0';
5408 if (!strcmp(pri,"hint"))
5409 ipri=PRIORITY_HINT;
5410 else if (!strcmp(pri, "next") || !strcmp(pri, "n")) {
5411 if (lastpri > -2)
5412 ipri = lastpri + 1;
5413 else
5414 ast_log(LOG_WARNING, "Can't use 'next' priority on the first entry!\n");
5415 } else if (!strcmp(pri, "same") || !strcmp(pri, "s")) {
5416 if (lastpri > -2)
5417 ipri = lastpri;
5418 else
5419 ast_log(LOG_WARNING, "Can't use 'same' priority on the first entry!\n");
5420 } else if (sscanf(pri, "%30d", &ipri) != 1 &&
5421 (ipri = ast_findlabel_extension2(NULL, con, realext, pri, cidmatch)) < 1) {
5422 ast_log(LOG_WARNING, "Invalid priority/label '%s' at line %d\n", pri, v->lineno);
5423 ipri = 0;
5424 }
5425 appl = S_OR(stringp, "");
5426 /* Find the first occurrence of either '(' or ',' */
5427 firstc = strchr(appl, ',');
5428 firstp = strchr(appl, '(');
5429 if (firstc && (!firstp || firstc < firstp)) {
5430 /* comma found, no parenthesis */
5431 /* or both found, but comma found first */
5432 appl = strsep(&stringp, ",");
5433 data = stringp;
5434 } else if (!firstc && !firstp) {
5435 /* Neither found */
5436 data = "";
5437 } else {
5438 /* Final remaining case is parenthesis found first */
5439 appl = strsep(&stringp, "(");
5440 data = stringp;
5441 end = strrchr(data, ')');
5442 if ((end = strrchr(data, ')'))) {
5443 *end = '\0';
5444 } else {
5445 ast_log(LOG_WARNING, "No closing parenthesis found? '%s(%s'\n", appl, data);
5446 }
5447 ast_process_quotes_and_slashes(data, ',', '|');
5448 }
5449
5450 if (!data)
5451 data="";
5452 appl = ast_skip_blanks(appl);
5453 if (ipri) {
5454 if (plus)
5455 ipri += atoi(plus);
5456 lastpri = ipri;
5457 if (!ast_opt_dont_warn && !strcmp(realext, "_."))
5458 ast_log(LOG_WARNING, "The use of '_.' for an extension is strongly discouraged and can have unexpected behavior. Please use '_X.' instead at line %d\n", v->lineno);
5459 if (ast_add_extension2(con, 0, realext, ipri, label, cidmatch, appl, strdup(data), ast_free_ptr, global_registrar)) {
5460 ast_log(LOG_WARNING, "Unable to register extension at line %d\n", v->lineno);
5461 }
5462 }
5463 free(tc);
5464 }
5465 } else if (!strcasecmp(v->name, "include")) {
5466 memset(realvalue, 0, sizeof(realvalue));
5467 pbx_substitute_variables_helper(NULL, v->value, realvalue, sizeof(realvalue) - 1);
5468 if (ast_context_add_include2(con, realvalue, global_registrar))
5469 ast_log(LOG_WARNING, "Unable to include context '%s' in context '%s'\n", v->value, cxt);
5470 } else if (!strcasecmp(v->name, "ignorepat")) {
5471 memset(realvalue, 0, sizeof(realvalue));
5472 pbx_substitute_variables_helper(NULL, v->value, realvalue, sizeof(realvalue) - 1);
5473 if (ast_context_add_ignorepat2(con, realvalue, global_registrar))
5474 ast_log(LOG_WARNING, "Unable to include ignorepat '%s' in context '%s'\n", v->value, cxt);
5475 } else if (!strcasecmp(v->name, "switch") || !strcasecmp(v->name, "lswitch") || !strcasecmp(v->name, "eswitch")) {
5476 char *stringp= realvalue;
5477 char *appl, *data;
5478
5479 memset(realvalue, 0, sizeof(realvalue));
5480 if (!strcasecmp(v->name, "switch"))
5481 pbx_substitute_variables_helper(NULL, v->value, realvalue, sizeof(realvalue) - 1);
5482 else
5483 ast_copy_string(realvalue, v->value, sizeof(realvalue));
5484 appl = strsep(&stringp, "/");
5485 data = strsep(&stringp, ""); /* XXX what for ? */
5486 if (!data)
5487 data = "";
5488 if (ast_context_add_switch2(con, appl, data, !strcasecmp(v->name, "eswitch"), global_registrar))
5489 ast_log(LOG_WARNING, "Unable to include switch '%s' in context '%s'\n", v->value, cxt);
5490 } else {
5491 ast_log(LOG_WARNING, "==!!== Unknown directive: %s at line %d -- IGNORING!!!\n", v->name, v->lineno);
5492 }
5493 }
5494 }
5495 ast_config_destroy(cfg);
5496 return 1;
5497}
void ast_free_ptr(void *ptr)
free() wrapper
Definition: astmm.c:1739
static const char config_file[]
Definition: cdr_odbc.c:54
static int ast_true(const char *s)
Definition: extconf.c:2242
static int autofallthrough_config
Definition: extconf.c:2123
#define S_OR(a, b)
Definition: extconf.c:955
static const char * ast_variable_retrieve(const struct ast_config *config, const char *category, const char *variable)
Definition: extconf.c:1225
#define ast_opt_dont_warn
Definition: extconf.c:1382
static char * ast_process_quotes_and_slashes(char *start, char find, char replace_with)
Definition: extconf.c:2216
static char * ast_category_browse(struct ast_config *config, const char *prev)
Definition: extconf.c:3324
static int clearglobalvars_config
Definition: extconf.c:2124
static struct ast_context * ast_context_find_or_create(struct ast_context **extcontexts, void *tab, const char *name, const char *registrar)
Definition: extconf.c:4978
static int static_config
Definition: extconf.c:2121
static char userscontext[AST_MAX_EXTENSION]
Definition: extconf.c:2120
struct ast_config * localized_config_load(const char *filename)
Definition: extconf.c:3283
static void ast_shrink_phone_number(char *n)
Clean up phone string remove '(', ' ', ')', non-trailing '.', and '-' not in square brackets....
Definition: extconf.c:2134
static int ast_findlabel_extension2(struct ast_channel *c, struct ast_context *con, const char *exten, const char *label, const char *callerid)
Definition: extconf.c:4973
char * ast_skip_blanks(const char *str)
Definition: extconf.c:977
static void pbx_substitute_variables_helper(struct ast_channel *c, const char *cp1, char *cp2, int count)
Definition: extconf.c:5326
static int write_protect_config
Definition: extconf.c:2122
const char * ext
Definition: http.c:150

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

Referenced by localized_pbx_load_module().

◆ pbx_retrieve_variable()

static void pbx_retrieve_variable ( struct ast_channel c,
const char *  var,
char **  ret,
char *  workspace,
int  workspacelen,
struct varshead headp 
)
static

Support for Asterisk built-in variables in the dialplan.

Note
See also

Definition at line 5077 of file extconf.c.

5078{
5079 const char not_found = '\0';
5080 char *tmpvar;
5081 const char *s; /* the result */
5082 int offset, length;
5083 int i, need_substring;
5084 struct varshead *places[2] = { headp, &globals }; /* list of places where we may look */
5085
5086 /*
5087 * Make a copy of var because parse_variable_name() modifies the string.
5088 * Then if called directly, we might need to run substring() on the result;
5089 * remember this for later in 'need_substring', 'offset' and 'length'
5090 */
5091 tmpvar = ast_strdupa(var); /* parse_variable_name modifies the string */
5092 need_substring = parse_variable_name(tmpvar, &offset, &length, &i /* ignored */);
5093
5094 /*
5095 * Look first into predefined variables, then into variable lists.
5096 * Variable 's' points to the result, according to the following rules:
5097 * s == &not_found (set at the beginning) means that we did not find a
5098 * matching variable and need to look into more places.
5099 * If s != &not_found, s is a valid result string as follows:
5100 * s = NULL if the variable does not have a value;
5101 * you typically do this when looking for an unset predefined variable.
5102 * s = workspace if the result has been assembled there;
5103 * typically done when the result is built e.g. with an snprintf(),
5104 * so we don't need to do an additional copy.
5105 * s != workspace in case we have a string, that needs to be copied
5106 * (the ast_copy_string is done once for all at the end).
5107 * Typically done when the result is already available in some string.
5108 */
5109 s = &not_found; /* default value */
5110 if (s == &not_found) { /* look for more */
5111 if (!strcmp(var, "EPOCH")) {
5112 snprintf(workspace, workspacelen, "%u",(int)time(NULL));
5113 }
5114
5115 s = workspace;
5116 }
5117 /* if not found, look into chanvars or global vars */
5118 for (i = 0; s == &not_found && i < (sizeof(places) / sizeof(places[0])); i++) {
5119 struct ast_var_t *variables;
5120 if (!places[i])
5121 continue;
5122 if (places[i] == &globals)
5124 AST_LIST_TRAVERSE(places[i], variables, entries) {
5125 if (strcasecmp(ast_var_name(variables), var)==0) {
5126 s = ast_var_value(variables);
5127 break;
5128 }
5129 }
5130 if (places[i] == &globals)
5132 }
5133 if (s == &not_found || s == NULL)
5134 *ret = NULL;
5135 else {
5136 if (s != workspace)
5137 ast_copy_string(workspace, s, workspacelen);
5138 *ret = workspace;
5139 if (need_substring)
5140 *ret = substring(*ret, offset, length, workspace, workspacelen);
5141 }
5142}
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.
Definition: extconf.c:5036
static ast_rwlock_t globalslock
Definition: extconf.c:2065
static const char * ast_var_value(const struct ast_var_t *var)
Definition: extconf.c:5023
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,...
Definition: extconf.c:5001
static int ast_rwlock_rdlock(ast_rwlock_t *prwlock)
Definition: extconf.c:539
struct ast_var_t::@216 entries

References ast_copy_string(), AST_LIST_TRAVERSE, ast_rwlock_rdlock(), ast_rwlock_unlock(), ast_strdupa, ast_var_name(), ast_var_value(), ast_var_t::entries, globals, globalslock, NULL, parse_variable_name(), substring(), and var.

Referenced by pbx_substitute_variables_helper_full().

◆ pbx_substitute_variables_helper()

static void pbx_substitute_variables_helper ( struct ast_channel c,
const char *  cp1,
char *  cp2,
int  count 
)
static

Definition at line 5326 of file extconf.c.

5327{
5328 pbx_substitute_variables_helper_full(c, NULL, cp1, cp2, count);
5329}
static void pbx_substitute_variables_helper_full(struct ast_channel *c, struct varshead *headp, const char *cp1, char *cp2, int count)
Definition: extconf.c:5144

References c, NULL, and pbx_substitute_variables_helper_full().

Referenced by pbx_load_config().

◆ pbx_substitute_variables_helper_full()

static void pbx_substitute_variables_helper_full ( struct ast_channel c,
struct varshead headp,
const char *  cp1,
char *  cp2,
int  count 
)
static

Definition at line 5144 of file extconf.c.

5145{
5146 /* Substitutes variables into cp2, based on string cp1, and assuming cp2 to be
5147 zero-filled */
5148 char *cp4;
5149 const char *tmp, *whereweare;
5150 int length, offset, offset2, isfunction;
5151 char *workspace = NULL;
5152 char *ltmp = NULL, *var = NULL;
5153 char *nextvar, *nextexp, *nextthing;
5154 char *vars, *vare;
5155 int pos, brackets, needsub, len;
5156
5157 *cp2 = 0; /* just in case there's nothing to do */
5158 whereweare=tmp=cp1;
5159 while (!ast_strlen_zero(whereweare) && count) {
5160 /* Assume we're copying the whole remaining string */
5161 pos = strlen(whereweare);
5162 nextvar = NULL;
5163 nextexp = NULL;
5164 nextthing = strchr(whereweare, '$');
5165 if (nextthing) {
5166 switch (nextthing[1]) {
5167 case '{':
5168 nextvar = nextthing;
5169 pos = nextvar - whereweare;
5170 break;
5171 case '[':
5172 nextexp = nextthing;
5173 pos = nextexp - whereweare;
5174 break;
5175 }
5176 }
5177
5178 if (pos) {
5179 /* Can't copy more than 'count' bytes */
5180 if (pos > count)
5181 pos = count;
5182
5183 /* Copy that many bytes */
5184 memcpy(cp2, whereweare, pos);
5185
5186 count -= pos;
5187 cp2 += pos;
5188 whereweare += pos;
5189 *cp2 = 0;
5190 }
5191
5192 if (nextvar) {
5193 /* We have a variable. Find the start and end, and determine
5194 if we are going to have to recursively call ourselves on the
5195 contents */
5196 vars = vare = nextvar + 2;
5197 brackets = 1;
5198 needsub = 0;
5199
5200 /* Find the end of it */
5201 while (brackets && *vare) {
5202 if ((vare[0] == '$') && (vare[1] == '{')) {
5203 needsub++;
5204 } else if (vare[0] == '{') {
5205 brackets++;
5206 } else if (vare[0] == '}') {
5207 brackets--;
5208 } else if ((vare[0] == '$') && (vare[1] == '['))
5209 needsub++;
5210 vare++;
5211 }
5212 if (brackets)
5213 ast_log(LOG_NOTICE, "Error in extension logic (missing '}' in '%s')\n", cp1);
5214 len = vare - vars - 1;
5215
5216 /* Skip totally over variable string */
5217 whereweare += (len + 3);
5218
5219 if (!var)
5220 var = alloca(VAR_BUF_SIZE);
5221
5222 /* Store variable name (and truncate) */
5223 ast_copy_string(var, vars, len + 1);
5224
5225 /* Substitute if necessary */
5226 if (needsub) {
5227 if (!ltmp)
5228 ltmp = alloca(VAR_BUF_SIZE);
5229
5230 memset(ltmp, 0, VAR_BUF_SIZE);
5232 vars = ltmp;
5233 } else {
5234 vars = var;
5235 }
5236
5237 if (!workspace)
5238 workspace = alloca(VAR_BUF_SIZE);
5239
5240 workspace[0] = '\0';
5241
5242 parse_variable_name(vars, &offset, &offset2, &isfunction);
5243 if (isfunction) {
5244 /* Evaluate function */
5245 cp4 = ast_func_read(c, vars, workspace, VAR_BUF_SIZE) ? NULL : workspace;
5246 if (option_debug)
5247 ast_log(LOG_DEBUG, "Function result is '%s'\n", cp4 ? cp4 : "(null)");
5248 } else {
5249 /* Retrieve variable value */
5250 pbx_retrieve_variable(c, vars, &cp4, workspace, VAR_BUF_SIZE, headp);
5251 }
5252 if (cp4) {
5253 cp4 = substring(cp4, offset, offset2, workspace, VAR_BUF_SIZE);
5254
5255 length = strlen(cp4);
5256 if (length > count)
5257 length = count;
5258 memcpy(cp2, cp4, length);
5259 count -= length;
5260 cp2 += length;
5261 *cp2 = 0;
5262 }
5263 } else if (nextexp) {
5264 /* We have an expression. Find the start and end, and determine
5265 if we are going to have to recursively call ourselves on the
5266 contents */
5267 vars = vare = nextexp + 2;
5268 brackets = 1;
5269 needsub = 0;
5270
5271 /* Find the end of it */
5272 while (brackets && *vare) {
5273 if ((vare[0] == '$') && (vare[1] == '[')) {
5274 needsub++;
5275 brackets++;
5276 vare++;
5277 } else if (vare[0] == '[') {
5278 brackets++;
5279 } else if (vare[0] == ']') {
5280 brackets--;
5281 } else if ((vare[0] == '$') && (vare[1] == '{')) {
5282 needsub++;
5283 vare++;
5284 }
5285 vare++;
5286 }
5287 if (brackets)
5288 ast_log(LOG_NOTICE, "Error in extension logic (missing ']')\n");
5289 len = vare - vars - 1;
5290
5291 /* Skip totally over expression */
5292 whereweare += (len + 3);
5293
5294 if (!var)
5295 var = alloca(VAR_BUF_SIZE);
5296
5297 /* Store variable name (and truncate) */
5298 ast_copy_string(var, vars, len + 1);
5299
5300 /* Substitute if necessary */
5301 if (needsub) {
5302 if (!ltmp)
5303 ltmp = alloca(VAR_BUF_SIZE);
5304
5305 memset(ltmp, 0, VAR_BUF_SIZE);
5307 vars = ltmp;
5308 } else {
5309 vars = var;
5310 }
5311
5312 length = ast_expr(vars, cp2, count, NULL);
5313
5314 if (length) {
5315 if (option_debug)
5316 ast_log(LOG_DEBUG, "Expression result is '%s'\n", cp2);
5317 count -= length;
5318 cp2 += length;
5319 *cp2 = 0;
5320 }
5321 } else
5322 break;
5323 }
5324}
int ast_expr(char *expr, char *buf, int length, struct ast_channel *chan)
Evaluate the given expression.
Definition: ast_expr2f.c:2391
static int ast_func_read(struct ast_channel *chan, const char *function, char *workspace, size_t len)
Definition: extconf.c:4991
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.
Definition: extconf.c:5077
#define VAR_BUF_SIZE
Definition: extconf.c:2317

References ast_copy_string(), ast_expr(), ast_func_read(), ast_log(), ast_strlen_zero(), c, len(), LOG_DEBUG, LOG_NOTICE, NULL, option_debug, parse_variable_name(), pbx_retrieve_variable(), pbx_substitute_variables_helper_full(), substring(), var, and VAR_BUF_SIZE.

Referenced by pbx_substitute_variables_helper(), and pbx_substitute_variables_helper_full().

◆ process_text_line()

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

Definition at line 2904 of file extconf.c.

2905{
2906 char *c;
2907 char *cur = buf;
2908 struct ast_variable *v;
2909 char exec_file[512];
2910 int object, do_exec, do_include;
2911
2912 /* Actually parse the entry */
2913 if (cur[0] == '[') {
2914 struct ast_category *newcat = NULL;
2915 char *catname;
2916
2917 /* A category header */
2918 c = strchr(cur, ']');
2919 if (!c) {
2920 ast_log(LOG_WARNING, "parse error: no closing ']', line %d of %s\n", lineno, configfile);
2921 return -1;
2922 }
2923 *c++ = '\0';
2924 cur++;
2925 if (*c++ != '(')
2926 c = NULL;
2927 catname = cur;
2928 if (!(*cat = newcat = ast_category_new(catname, ast_strlen_zero(suggested_include_file)?configfile:suggested_include_file, lineno))) {
2929 return -1;
2930 }
2931 (*cat)->lineno = lineno;
2932
2933 /* add comments */
2934 if (withcomments && comment_buffer && comment_buffer[0] ) {
2936 }
2937 if (withcomments && lline_buffer && lline_buffer[0] ) {
2939 }
2940 if( withcomments )
2941 CB_RESET();
2942
2943 /* If there are options or categories to inherit from, process them now */
2944 if (c) {
2945 if (!(cur = strchr(c, ')'))) {
2946 ast_log(LOG_WARNING, "parse error: no closing ')', line %d of %s\n", lineno, configfile);
2947 return -1;
2948 }
2949 *cur = '\0';
2950 while ((cur = strsep(&c, ","))) {
2951 if (!strcasecmp(cur, "!")) {
2952 (*cat)->ignored = 1;
2953 } else if (!strcasecmp(cur, "+")) {
2954 *cat = category_get(cfg, catname, 1);
2955 if (!*cat) {
2956 ast_config_destroy(cfg);
2957 if (newcat)
2958 ast_category_destroy(newcat);
2959 ast_log(LOG_WARNING, "Category addition requested, but category '%s' does not exist, line %d of %s\n", catname, lineno, configfile);
2960 return -1;
2961 }
2962 if (newcat) {
2963 move_variables(newcat, *cat);
2964 ast_category_destroy(newcat);
2965 newcat = NULL;
2966 }
2967 } else {
2968 struct ast_category *base;
2969
2970 base = category_get(cfg, cur, 1);
2971 if (!base) {
2972 ast_log(LOG_WARNING, "Inheritance requested, but category '%s' does not exist, line %d of %s\n", cur, lineno, configfile);
2973 return -1;
2974 }
2975 inherit_category(*cat, base);
2976 }
2977 }
2978 }
2979 if (newcat)
2980 ast_category_append(cfg, *cat);
2981 } else if (cur[0] == '#') {
2982 /* A directive */
2983 cur++;
2984 c = cur;
2985 while(*c && (*c > 32)) c++;
2986 if (*c) {
2987 *c = '\0';
2988 /* Find real argument */
2989 c = ast_skip_blanks(c + 1);
2990 if (!*c)
2991 c = NULL;
2992 } else
2993 c = NULL;
2994 do_include = !strcasecmp(cur, "include");
2995 if(!do_include)
2996 do_exec = !strcasecmp(cur, "exec");
2997 else
2998 do_exec = 0;
2999 if (do_exec && !ast_opt_exec_includes) {
3000 ast_log(LOG_WARNING, "Cannot perform #exec unless execincludes option is enabled in asterisk.conf (options section)!\n");
3001 do_exec = 0;
3002 }
3003 if (do_include || do_exec) {
3004 if (c) {
3005 char *cur2;
3006 char real_inclusion_name[525];
3007
3008 /* Strip off leading and trailing "'s and <>'s */
3009 while((*c == '<') || (*c == '>') || (*c == '\"')) c++;
3010 /* Get rid of leading mess */
3011 cur = c;
3012 cur2 = cur;
3013 while (!ast_strlen_zero(cur)) {
3014 c = cur + strlen(cur) - 1;
3015 if ((*c == '>') || (*c == '<') || (*c == '\"'))
3016 *c = '\0';
3017 else
3018 break;
3019 }
3020 /* #exec </path/to/executable>
3021 We create a tmp file, then we #include it, then we delete it. */
3022 if (do_exec) {
3023 char cmd[1024];
3024
3025 snprintf(exec_file, sizeof(exec_file), "/var/tmp/exec.%d.%ld", (int)time(NULL), (long)pthread_self());
3026 if (snprintf(cmd, sizeof(cmd), "%s > %s 2>&1", cur, exec_file) >= sizeof(cmd)) {
3027 ast_log(LOG_ERROR, "Failed to construct command string to execute %s.\n", cur);
3028
3029 return -1;
3030 }
3031 ast_safe_system(cmd);
3032 cur = exec_file;
3033 } else
3034 exec_file[0] = '\0';
3035 /* A #include */
3036 /* ast_log(LOG_WARNING, "Reading in included file %s withcomments=%d\n", cur, withcomments); */
3037
3038 /* record this inclusion */
3039 ast_include_new(cfg, configfile, cur, do_exec, cur2, lineno, real_inclusion_name, sizeof(real_inclusion_name));
3040
3041 do_include = ast_config_internal_load(cur, cfg, withcomments, real_inclusion_name) ? 1 : 0;
3042 if(!ast_strlen_zero(exec_file))
3043 unlink(exec_file);
3044 if(!do_include)
3045 return 0;
3046 /* ast_log(LOG_WARNING, "Done reading in included file %s withcomments=%d\n", cur, withcomments); */
3047
3048 } else {
3049 ast_log(LOG_WARNING, "Directive '#%s' needs an argument (%s) at line %d of %s\n",
3050 do_exec ? "exec" : "include",
3051 do_exec ? "/path/to/executable" : "filename",
3052 lineno,
3053 configfile);
3054 }
3055 }
3056 else
3057 ast_log(LOG_WARNING, "Unknown directive '%s' at line %d of %s\n", cur, lineno, configfile);
3058 } else {
3059 /* Just a line (variable = value) */
3060 if (!*cat) {
3062 "parse error: No category context for line %d of %s\n", lineno, configfile);
3063 return -1;
3064 }
3065 c = strchr(cur, '=');
3066 if (c) {
3067 *c = 0;
3068 c++;
3069 /* Ignore > in => */
3070 if (*c== '>') {
3071 object = 1;
3072 c++;
3073 } else
3074 object = 0;
3075 if ((v = ast_variable_new(ast_strip(cur), ast_strip(c), configfile))) {
3076 v->lineno = lineno;
3077 v->object = object;
3078 /* Put and reset comments */
3079 v->blanklines = 0;
3080 ast_variable_append(*cat, v);
3081 /* add comments */
3082 if (withcomments && comment_buffer && comment_buffer[0] ) {
3084 }
3085 if (withcomments && lline_buffer && lline_buffer[0] ) {
3087 }
3088 if( withcomments )
3089 CB_RESET();
3090
3091 } else {
3092 return -1;
3093 }
3094 } else {
3095 ast_log(LOG_WARNING, "EXTENSIONS.CONF: No '=' (equal sign) in line %d of %s\n", lineno, configfile);
3096 }
3097 }
3098 return 0;
3099}
static void CB_RESET(void)
Definition: extconf.c:775
static struct ast_variable * ast_variable_new(const char *name, const char *value, const char *filename)
Definition: extconf.c:1053
static void inherit_category(struct ast_category *new, const struct ast_category *base)
Definition: extconf.c:2821
static void ast_category_append(struct ast_config *config, struct ast_category *category)
Definition: extconf.c:2831
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)
Definition: extconf.c:1072
static struct ast_category * ast_category_new(const char *name, const char *in_file, int lineno)
Definition: extconf.c:2786
static void move_variables(struct ast_category *old, struct ast_category *new)
Definition: extconf.c:2804
static void ast_category_destroy(struct ast_category *cat)
Definition: extconf.c:2843
int ast_safe_system(const char *s)
Safely spawn an OS shell command while closing file descriptors.
Definition: extconf.c:827
static struct ast_comment * ALLOC_COMMENT(const char *buffer)
Definition: extconf.c:875
#define ast_opt_exec_includes
Definition: extconf.c:1364
struct ast_comment * precomments
struct ast_comment * sameline

References ALLOC_COMMENT(), ast_category_append(), ast_category_destroy(), ast_category_new(), ast_config_destroy(), ast_config_internal_load(), ast_include_new(), ast_log(), ast_opt_exec_includes, ast_safe_system(), ast_skip_blanks(), ast_strip(), ast_strlen_zero(), ast_variable_append(), ast_variable_new(), ast_variable::blanklines, buf, c, category_get(), CB_RESET(), comment_buffer, inherit_category(), ast_variable::lineno, ast_category::lineno, lline_buffer, LOG_ERROR, LOG_WARNING, move_variables(), NULL, ast_variable::object, ast_variable::precomments, ast_category::precomments, ast_variable::sameline, ast_category::sameline, and strsep().

Referenced by config_text_file_load().

◆ set_fn()

static void set_fn ( char *  fn,
int  fn_size,
const char *  file,
const char *  configfile 
)
static

Definition at line 3404 of file extconf.c.

3405{
3406 if (!file || file[0] == 0) {
3407 if (configfile[0] == '/')
3408 ast_copy_string(fn, configfile, fn_size);
3409 else
3410 snprintf(fn, fn_size, "%s/%s", ast_config_AST_CONFIG_DIR, configfile);
3411 } else if (file[0] == '/')
3412 ast_copy_string(fn, file, fn_size);
3413 else
3414 snprintf(fn, fn_size, "%s/%s", ast_config_AST_CONFIG_DIR, file);
3415}

References ast_config_AST_CONFIG_DIR, ast_copy_string(), and make_ari_stubs::file.

Referenced by localized_config_text_file_save().

◆ substring()

static char * substring ( const char *  value,
int  offset,
int  length,
char *  workspace,
size_t  workspace_len 
)
static

takes a substring. It is ok to call with value == workspace.

offset < 0 means start from the end of the string and set the beginning to be that many characters back. length is the length of the substring. A value less than 0 means to leave that many off the end. Always return a copy in workspace.

Definition at line 5036 of file extconf.c.

5037{
5038 char *ret = workspace;
5039 int lr; /* length of the input string after the copy */
5040
5041 ast_copy_string(workspace, value, workspace_len); /* always make a copy */
5042
5043 lr = strlen(ret); /* compute length after copy, so we never go out of the workspace */
5044
5045 /* Quick check if no need to do anything */
5046 if (offset == 0 && length >= lr) /* take the whole string */
5047 return ret;
5048
5049 if (offset < 0) { /* translate negative offset into positive ones */
5050 offset = lr + offset;
5051 if (offset < 0) /* If the negative offset was greater than the length of the string, just start at the beginning */
5052 offset = 0;
5053 }
5054
5055 /* too large offset result in empty string so we know what to return */
5056 if (offset >= lr)
5057 return ret + lr; /* the final '\0' */
5058
5059 ret += offset; /* move to the start position */
5060 if (length >= 0 && length < lr - offset) /* truncate if necessary */
5061 ret[length] = '\0';
5062 else if (length < 0) {
5063 if (lr > offset - length) /* After we remove from the front and from the rear, is there anything left? */
5064 ret[lr + length - offset] = '\0';
5065 else
5066 ret[0] = '\0';
5067 }
5068
5069 return ret;
5070}

References ast_copy_string(), and value.

Referenced by pbx_retrieve_variable(), and pbx_substitute_variables_helper_full().

◆ tvfix()

static struct timeval tvfix ( struct timeval  a)
static

Definition at line 2264 of file extconf.c.

2265{
2266 if (a.tv_usec >= ONE_MILLION) {
2267 ast_log(LOG_WARNING, "warning too large timestamp %ld.%ld\n",
2268 (long)a.tv_sec, (long int) a.tv_usec);
2269 a.tv_sec += a.tv_usec / ONE_MILLION;
2270 a.tv_usec %= ONE_MILLION;
2271 } else if (a.tv_usec < 0) {
2272 ast_log(LOG_WARNING, "warning negative timestamp %ld.%ld\n",
2273 (long)a.tv_sec, (long int) a.tv_usec);
2274 a.tv_usec = 0;
2275 }
2276 return a;
2277}

References a, ast_log(), LOG_WARNING, and ONE_MILLION.

Referenced by ast_tvadd(), and ast_tvsub().

◆ variable_clone()

static struct ast_variable * variable_clone ( const struct ast_variable old)
static

Definition at line 1246 of file extconf.c.

1247{
1248 struct ast_variable *new = ast_variable_new(old->name, old->value, old->file);
1249
1250 if (new) {
1251 new->lineno = old->lineno;
1252 new->object = old->object;
1253 new->blanklines = old->blanklines;
1254 /* TODO: clone comments? */
1255 }
1256
1257 return new;
1258}

References ast_variable_new(), ast_variable::blanklines, ast_variable::file, ast_variable::lineno, ast_variable::name, ast_variable::object, and ast_variable::value.

Referenced by inherit_category().

Variable Documentation

◆ __unsigned_int_flags_dummy64

uint64_t __unsigned_int_flags_dummy64
extern

◆ ast_defaultlanguage

char ast_defaultlanguage[]
extern

Definition at line 99 of file options.c.

Referenced by load_asterisk_conf().

◆ ast_language_is_prefix

int ast_language_is_prefix
extern

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.

This is settable in asterisk.conf.

Definition at line 68 of file file.c.

Referenced by fileexists_test().

◆ ast_mainpid

pid_t ast_mainpid
extern

Definition at line 322 of file asterisk.c.

Referenced by asterisk_daemon(), main(), and netconsole().

◆ autofallthrough_config

int autofallthrough_config = 0
static

Definition at line 2123 of file extconf.c.

Referenced by pbx_load_config().

◆ clearglobalvars_config

int clearglobalvars_config = 0
static

Definition at line 2124 of file extconf.c.

Referenced by pbx_load_config().

◆ comment_buffer

char* comment_buffer
static

Growable string buffer this will be a comment collector.

Definition at line 703 of file extconf.c.

Referenced by CB_ADD(), CB_ADD_LEN(), CB_INIT(), CB_RESET(), config_text_file_load(), and process_text_line().

◆ comment_buffer_size

int comment_buffer_size
static

the amount of storage so far alloc'd for the comment_buffer

Definition at line 704 of file extconf.c.

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

◆ config_engine_list

static struct ast_config_engine * config_engine_list
static

Definition at line 891 of file extconf.c.

Referenced by ast_config_internal_load(), and find_engine().

◆ config_filename

char* config_filename = "extensions.conf"
static

Definition at line 2118 of file extconf.c.

Referenced by AST_TEST_DEFINE(), localized_pbx_load_module(), and parse_config().

◆ config_maps

struct ast_config_map * config_maps = NULL
static

Referenced by find_engine().

◆ conlock

ast_rwlock_t conlock = PTHREAD_RWLOCK_INITIALIZER
static

Lock for the ast_context list

Definition at line 4480 of file extconf.c.

Referenced by ast_unlock_contexts(), and ast_wrlock_contexts().

◆ contexts

static struct ast_context * contexts = NULL
static

◆ days

char* days[]

Definition at line 3773 of file extconf.c.

Referenced by ast_build_timing().

◆ debug_filename

char debug_filename[AST_FILENAME_MAX]
extern

◆ extconfig_conf

char* extconfig_conf = "extconfig.conf"
static

Definition at line 700 of file extconf.c.

Referenced by ast_config_internal_load().

◆ global_registrar

char* global_registrar = "conf2ael"
static

Definition at line 2119 of file extconf.c.

Referenced by localized_pbx_load_module(), and pbx_load_config().

◆ globals

struct varshead globals = AST_LIST_HEAD_NOLOCK_INIT_VALUE
static

Definition at line 2066 of file extconf.c.

Referenced by pbx_builtin_setvar_helper(), and pbx_retrieve_variable().

◆ globalslock

ast_rwlock_t globalslock = PTHREAD_RWLOCK_INITIALIZER
static

Definition at line 2065 of file extconf.c.

Referenced by pbx_retrieve_variable().

◆ hints

struct hints hints = { .first = NULL, .last = NULL, .lock = PTHREAD_RWLOCK_INITIALIZER , }
static

◆ lline_buffer

char* lline_buffer
static

A buffer for stuff behind the ;

Definition at line 706 of file extconf.c.

Referenced by CB_INIT(), CB_RESET(), config_text_file_load(), LLB_ADD(), and process_text_line().

◆ lline_buffer_size

int lline_buffer_size
static

Definition at line 707 of file extconf.c.

Referenced by CB_INIT(), config_text_file_load(), and LLB_ADD().

◆ local_contexts

struct ast_context* local_contexts = NULL
static

Definition at line 3594 of file extconf.c.

Referenced by localized_pbx_load_module(), and pbx_load_config().

◆ months

char* months[]

Definition at line 3785 of file extconf.c.

Referenced by ast_build_timing().

◆ null_sig_handler

struct sigaction null_sig_handler
static
Initial value:
= {
.sa_handler = _null_sig_handler,
.sa_flags = SA_RESTART,
}
static void _null_sig_handler(int sig)
NULL handler so we can collect the child exit status.
Definition: extconf.c:787

Definition at line 792 of file extconf.c.

Referenced by ast_replace_sigchld().

◆ record_cache_dir

char record_cache_dir[AST_CACHE_DIR_LEN]
extern

Definition at line 97 of file options.c.

Referenced by load_asterisk_conf().

◆ safe_system_level

unsigned int safe_system_level = 0
static

Keep track of how many threads are currently trying to wait*() on a child process.

Definition at line 783 of file extconf.c.

Referenced by ast_replace_sigchld(), and ast_unreplace_sigchld().

◆ safe_system_prev_handler

struct sigaction safe_system_prev_handler
static

Definition at line 784 of file extconf.c.

Referenced by ast_replace_sigchld(), and ast_unreplace_sigchld().

◆ static_config

int static_config = 0
static

Definition at line 2121 of file extconf.c.

Referenced by pbx_load_config().

◆ text_file_engine

struct ast_config_engine text_file_engine
static
Initial value:
= {
.name = "text",
.load_func = config_text_file_load,
}
static struct ast_config * config_text_file_load(const char *database, const char *table, const char *filename, struct ast_config *cfg, int withcomments, const char *suggested_include_file)
Definition: extconf.c:3117

Definition at line 2852 of file extconf.c.

Referenced by ast_config_internal_load().

◆ use_local_dir

int use_local_dir = 1
static

◆ userscontext

char userscontext[AST_MAX_EXTENSION] = "default"
static

Definition at line 2120 of file extconf.c.

Referenced by pbx_load_config().

◆ write_protect_config

int write_protect_config = 1
static

Definition at line 2122 of file extconf.c.

Referenced by pbx_load_config().