Asterisk - The Open Source Telephony Project  18.5.0
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
extconf.c File Reference
#include "asterisk.h"
#include "asterisk/compat.h"
#include "asterisk/paths.h"
#include <errno.h>
#include <time.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/wait.h>
#include <stdarg.h>
#include <string.h>
#include <locale.h>
#include <ctype.h>
#include <err.h>
#include <regex.h>
#include <limits.h>
#include <pthread.h>
#include <netdb.h>
#include <sys/param.h>
#include <signal.h>
#include "asterisk/inline_api.h"
#include "asterisk/endian.h"
#include "asterisk/ast_expr.h"
#include "asterisk/extconf.h"
#include "asterisk/hashtab.h"
#include "asterisk/ael_structs.h"
#include "asterisk/pval.h"
Include dependency graph for extconf.c:

Go to the source code of this file.

Data Structures

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

Macros

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

Typedefs

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

Enumerations

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

Functions

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

Variables

char ast_defaultlanguage []
 
int ast_language_is_prefix
 The following variable controls the layout of localized sound files. If 0, use the historical layout with prefix just before the filename (i.e. digits/en/1.gsm , digits/it/1.gsm or default to digits/1.gsm), if 1 put the prefix at the beginning of the filename (i.e. en/digits/1.gsm, it/digits/1.gsm or default to digits/1.gsm). The latter permits a language to be entirely in one directory. More...
 
pid_t ast_mainpid
 
int ast_option_maxcalls
 
double ast_option_maxload
 
struct ast_flags ast_options = { AST_DEFAULT_OPTIONS }
 
static int autofallthrough_config = 0
 
static int clearglobalvars_config = 0
 
static char * comment_buffer
 
static int comment_buffer_size
 
static struct ast_config_engineconfig_engine_list
 
static char * config_filename = "extensions.conf"
 
static struct ast_config_mapconfig_maps = NULL
 
static ast_rwlock_t conlock = { PTHREAD_RWLOCK_INITIALIZER , NULL, {1, 0} }
 
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 , NULL, {1, 0} }
 
static struct hints hints = { .first = NULL, .last = NULL, .lock = { PTHREAD_RWLOCK_INITIALIZER , NULL, {1, 0} } , }
 
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 exensions.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 1359 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 1363 of file extconf.c.

◆ AST_FILENAME_MAX

#define AST_FILENAME_MAX   80

Definition at line 1360 of file extconf.c.

◆ ast_fully_booted

#define ast_fully_booted   ast_test_flag(&ast_options, AST_OPT_FLAG_FULLY_BOOTED)

Definition at line 1376 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 1996 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 1734 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
struct ast_frame * next

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;
}

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

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

Referenced by ast_walk_context_switches().

◆ AST_LIST_HEAD

#define AST_LIST_HEAD (   name,
  type 
)
Value:
struct name { \
struct type *first; \
struct type *last; \
ast_mutex_t lock; \
}
static const char type[]
Definition: chan_ooh323.c:109
struct sla_ringing_trunk * last
Definition: app_meetme.c:1092
ast_mutex_t lock
Definition: app_meetme.c:1091
struct sla_ringing_trunk * first
Definition: app_meetme.c:1092
static const char name[]
Definition: cdr_mysql.c:74

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;

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 1458 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
struct sla_ringing_trunk * last
Definition: app_meetme.c:1092
ast_mutex_t lock
Definition: app_meetme.c:1091
struct sla_ringing_trunk * first
Definition: app_meetme.c:1092

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

◆ AST_LIST_HEAD_INIT_NOLOCK

#define AST_LIST_HEAD_INIT_NOLOCK (   head)
Value:
{ \
(head)->first = NULL; \
(head)->last = NULL; \
}
#define NULL
Definition: resample.c:96
struct sla_ringing_trunk * last
Definition: app_meetme.c:1092
struct sla_ringing_trunk * first
Definition: app_meetme.c:1092

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

◆ AST_LIST_HEAD_INIT_VALUE

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

Defines initial values for a declaration of AST_LIST_HEAD.

Definition at line 1519 of file extconf.c.

◆ AST_LIST_HEAD_NOLOCK

#define AST_LIST_HEAD_NOLOCK (   name,
  type 
)
Value:
struct name { \
struct type *first; \
struct type *last; \
}
static const char type[]
Definition: chan_ooh323.c:109
struct sla_ringing_trunk * last
Definition: app_meetme.c:1092
struct sla_ringing_trunk * first
Definition: app_meetme.c:1092
static const char name[]
Definition: cdr_mysql.c:74

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:

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

◆ AST_LIST_HEAD_NOLOCK_INIT_VALUE

#define AST_LIST_HEAD_NOLOCK_INIT_VALUE
Value:
{ \
.first = NULL, \
.last = NULL, \
}
#define NULL
Definition: resample.c:96

Defines initial values for a declaration of AST_LIST_HEAD_NOLOCK.

Definition at line 1537 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; \
static const char type[]
Definition: chan_ooh323.c:109
struct sla_ringing_trunk * last
Definition: app_meetme.c:1092
struct sla_ringing_trunk * first
Definition: app_meetme.c:1092
static const char name[]
Definition: cdr_mysql.c:74
#define AST_LIST_HEAD_NOLOCK_INIT_VALUE
Defines initial values for a declaration of AST_LIST_HEAD_NOLOCK.
Definition: extconf.c:1537

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 1631 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)
struct sla_ringing_trunk * last
Definition: app_meetme.c:1092
ast_mutex_t lock
Definition: app_meetme.c:1091
struct sla_ringing_trunk * first
Definition: app_meetme.c:1092
Definition: search.h:40

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 1645 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)
struct sla_ringing_trunk * last
Definition: app_meetme.c:1092
struct sla_ringing_trunk * first
Definition: app_meetme.c:1092
Definition: search.h:40

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 1673 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; \
static const char type[]
Definition: chan_ooh323.c:109
#define AST_LIST_HEAD_INIT_VALUE
Defines initial values for a declaration of AST_LIST_HEAD.
Definition: extconf.c:1519
struct sla_ringing_trunk * last
Definition: app_meetme.c:1092
ast_mutex_t lock
Definition: app_meetme.c:1091
struct sla_ringing_trunk * first
Definition: app_meetme.c:1092
static const char name[]
Definition: cdr_mysql.c:74

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:

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

Definition at line 1576 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 1941 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 1859 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 1957 of file extconf.c.

Referenced by pbx_builtin_setvar_helper().

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

Referenced by ast_context_add_switch2().

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

Referenced by ast_walk_context_switches().

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

Referenced by pbx_builtin_setvar_helper().

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

Referenced by __ast_context_destroy().

◆ 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)
}
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 1774 of file extconf.c.

Referenced by ast_context_add_switch2(), pbx_builtin_setvar_helper(), pbx_find_extension(), and pbx_retrieve_variable().

◆ 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)
}

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

◆ AST_LIST_TRAVERSE_SAFE_END

#define AST_LIST_TRAVERSE_SAFE_END   }

Closes a safe loop traversal block.

Definition at line 1875 of file extconf.c.

◆ AST_MAX_EXTENSION

#define AST_MAX_EXTENSION   80

Max length of an extension

Definition at line 2079 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.

Referenced by ast_mutex_init().

◆ ast_opt_always_fork

#define ast_opt_always_fork   ast_test_flag(&ast_options, AST_OPT_FLAG_ALWAYS_FORK)

Definition at line 1386 of file extconf.c.

◆ ast_opt_cache_record_files

#define ast_opt_cache_record_files   ast_test_flag(&ast_options, AST_OPT_FLAG_CACHE_RECORD_FILES)

Definition at line 1380 of file extconf.c.

◆ ast_opt_console

#define ast_opt_console   ast_test_flag(&ast_options, AST_OPT_FLAG_CONSOLE)

Definition at line 1370 of file extconf.c.

◆ ast_opt_dont_warn

#define ast_opt_dont_warn   ast_test_flag(&ast_options, AST_OPT_FLAG_DONT_WARN)

Definition at line 1385 of file extconf.c.

Referenced by pbx_load_config().

◆ ast_opt_dump_core

#define ast_opt_dump_core   ast_test_flag(&ast_options, AST_OPT_FLAG_DUMP_CORE)

Definition at line 1379 of file extconf.c.

◆ ast_opt_exec

#define ast_opt_exec   ast_test_flag(&ast_options, AST_OPT_FLAG_EXEC)

Definition at line 1374 of file extconf.c.

◆ ast_opt_exec_includes

#define ast_opt_exec_includes   ast_test_flag(&ast_options, AST_OPT_FLAG_EXEC_INCLUDES)

Definition at line 1367 of file extconf.c.

Referenced by process_text_line().

◆ ast_opt_high_priority

#define ast_opt_high_priority   ast_test_flag(&ast_options, AST_OPT_FLAG_HIGH_PRIORITY)

Definition at line 1371 of file extconf.c.

◆ ast_opt_init_keys

#define ast_opt_init_keys   ast_test_flag(&ast_options, AST_OPT_FLAG_INIT_KEYS)

Definition at line 1372 of file extconf.c.

◆ ast_opt_mute

#define ast_opt_mute   ast_test_flag(&ast_options, AST_OPT_FLAG_MUTE)

Definition at line 1387 of file extconf.c.

◆ ast_opt_no_color

#define ast_opt_no_color   ast_test_flag(&ast_options, AST_OPT_FLAG_NO_COLOR)

Definition at line 1375 of file extconf.c.

◆ ast_opt_no_fork

#define ast_opt_no_fork   ast_test_flag(&ast_options, AST_OPT_FLAG_NO_FORK)

Definition at line 1368 of file extconf.c.

◆ ast_opt_override_config

#define ast_opt_override_config   ast_test_flag(&ast_options, AST_OPT_FLAG_OVERRIDE_CONFIG)

Definition at line 1382 of file extconf.c.

◆ ast_opt_priority_jumping

#define ast_opt_priority_jumping   ast_test_flag(&ast_options, AST_OPT_FLAG_PRIORITY_JUMPING)

Definition at line 1378 of file extconf.c.

◆ ast_opt_quiet

#define ast_opt_quiet   ast_test_flag(&ast_options, AST_OPT_FLAG_QUIET)

Definition at line 1369 of file extconf.c.

◆ ast_opt_reconnect

#define ast_opt_reconnect   ast_test_flag(&ast_options, AST_OPT_FLAG_RECONNECT)

Definition at line 1383 of file extconf.c.

◆ ast_opt_remote

#define ast_opt_remote   ast_test_flag(&ast_options, AST_OPT_FLAG_REMOTE)

Definition at line 1373 of file extconf.c.

◆ ast_opt_timestamp

#define ast_opt_timestamp   ast_test_flag(&ast_options, AST_OPT_FLAG_TIMESTAMP)

Definition at line 1381 of file extconf.c.

◆ ast_opt_transcode_via_slin

#define ast_opt_transcode_via_slin   ast_test_flag(&ast_options, AST_OPT_FLAG_TRANSCODE_VIA_SLIN)

Definition at line 1377 of file extconf.c.

◆ ast_opt_transmit_silence

#define ast_opt_transmit_silence   ast_test_flag(&ast_options, AST_OPT_FLAG_TRANSMIT_SILENCE)

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

◆ AST_RWLIST_EMPTY

#define AST_RWLIST_EMPTY   AST_LIST_EMPTY

Definition at line 1736 of file extconf.c.

◆ AST_RWLIST_ENTRY

#define AST_RWLIST_ENTRY   AST_LIST_ENTRY

Definition at line 1700 of file extconf.c.

◆ AST_RWLIST_FIRST

#define AST_RWLIST_FIRST   AST_LIST_FIRST

Definition at line 1708 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; \
}
static const char type[]
Definition: chan_ooh323.c:109
struct sla_ringing_trunk * last
Definition: app_meetme.c:1092
ast_mutex_t lock
Definition: app_meetme.c:1091
struct sla_ringing_trunk * first
Definition: app_meetme.c:1092
static const char name[]
Definition: cdr_mysql.c:74

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;

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 1484 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); \
}
#define NULL
Definition: resample.c:96
struct sla_ringing_trunk * last
Definition: app_meetme.c:1092
ast_mutex_t lock
Definition: app_meetme.c:1091
struct sla_ringing_trunk * first
Definition: app_meetme.c:1092

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 1913 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); \
}
#define NULL
Definition: resample.c:96
struct sla_ringing_trunk * last
Definition: app_meetme.c:1092
ast_mutex_t lock
Definition: app_meetme.c:1091
struct sla_ringing_trunk * first
Definition: app_meetme.c:1092

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 1899 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
#define NULL
Definition: resample.c:96

Defines initial values for a declaration of AST_RWLIST_HEAD.

Definition at line 1528 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)
struct sla_ringing_trunk * last
Definition: app_meetme.c:1092
ast_mutex_t lock
Definition: app_meetme.c:1091
struct sla_ringing_trunk * first
Definition: app_meetme.c:1092
Definition: search.h:40

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 1659 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; \
static const char type[]
Definition: chan_ooh323.c:109
struct sla_ringing_trunk * last
Definition: app_meetme.c:1092
ast_mutex_t lock
Definition: app_meetme.c:1091
#define AST_RWLIST_HEAD_INIT_VALUE
Defines initial values for a declaration of AST_RWLIST_HEAD.
Definition: extconf.c:1528
struct sla_ringing_trunk * first
Definition: app_meetme.c:1092
static const char name[]
Definition: cdr_mysql.c:74

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:

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

Definition at line 1618 of file extconf.c.

◆ AST_RWLIST_INSERT_AFTER

#define AST_RWLIST_INSERT_AFTER   AST_LIST_INSERT_AFTER

Definition at line 1948 of file extconf.c.

◆ AST_RWLIST_INSERT_BEFORE_CURRENT

#define AST_RWLIST_INSERT_BEFORE_CURRENT   AST_LIST_INSERT_BEFORE_CURRENT

Definition at line 1870 of file extconf.c.

◆ AST_RWLIST_INSERT_HEAD

#define AST_RWLIST_INSERT_HEAD   AST_LIST_INSERT_HEAD

Definition at line 1964 of file extconf.c.

Referenced by ast_add_hint().

◆ AST_RWLIST_INSERT_TAIL

#define AST_RWLIST_INSERT_TAIL   AST_LIST_INSERT_TAIL

Definition at line 1987 of file extconf.c.

◆ AST_RWLIST_LAST

#define AST_RWLIST_LAST   AST_LIST_LAST

Definition at line 1716 of file extconf.c.

◆ AST_RWLIST_NEXT

#define AST_RWLIST_NEXT   AST_LIST_NEXT

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

◆ AST_RWLIST_REMOVE

#define AST_RWLIST_REMOVE   AST_LIST_REMOVE

Definition at line 2056 of file extconf.c.

◆ AST_RWLIST_REMOVE_CURRENT

#define AST_RWLIST_REMOVE_CURRENT   AST_LIST_REMOVE_CURRENT

Definition at line 1847 of file extconf.c.

Referenced by ast_remove_hint().

◆ AST_RWLIST_REMOVE_HEAD

#define AST_RWLIST_REMOVE_HEAD   AST_LIST_REMOVE_HEAD

Definition at line 2028 of file extconf.c.

◆ AST_RWLIST_TRAVERSE

#define AST_RWLIST_TRAVERSE   AST_LIST_TRAVERSE

Definition at line 1777 of file extconf.c.

Referenced by ast_add_hint(), ast_change_hint(), and ast_check_timing().

◆ AST_RWLIST_TRAVERSE_SAFE_BEGIN

#define AST_RWLIST_TRAVERSE_SAFE_BEGIN   AST_LIST_TRAVERSE_SAFE_BEGIN

Definition at line 1824 of file extconf.c.

Referenced by ast_remove_hint().

◆ AST_RWLIST_TRAVERSE_SAFE_END

#define AST_RWLIST_TRAVERSE_SAFE_END   AST_LIST_TRAVERSE_SAFE_END

Definition at line 1877 of file extconf.c.

Referenced by ast_remove_hint().

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

◆ AST_RWLOCK_DEFINE_STATIC

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

Definition at line 568 of file extconf.c.

◆ AST_RWLOCK_INIT_VALUE

#define AST_RWLOCK_INIT_VALUE   PTHREAD_RWLOCK_INITIALIZER

Definition at line 563 of file extconf.c.

◆ ast_set2_flag

#define ast_set2_flag (   p,
  value,
  flag 
)

Definition at line 684 of file extconf.c.

◆ ast_test_flag

#define ast_test_flag (   p,
  flag 
)

Definition at line 677 of file extconf.c.

◆ ASTMM_LIBC

#define ASTMM_LIBC   ASTMM_IGNORE

Definition at line 46 of file extconf.c.

◆ BACKGROUND_MATCHEXTEN

#define BACKGROUND_MATCHEXTEN   (1 << 2)

Definition at line 2328 of file extconf.c.

◆ BACKGROUND_NOANSWER

#define BACKGROUND_NOANSWER   (1 << 1)

Definition at line 2327 of file extconf.c.

◆ BACKGROUND_PLAYBACK

#define BACKGROUND_PLAYBACK   (1 << 3)

Definition at line 2329 of file extconf.c.

◆ BACKGROUND_SKIP

#define BACKGROUND_SKIP   (1 << 0)

Definition at line 2326 of file extconf.c.

◆ CB_INCR

#define CB_INCR   250

Definition at line 711 of file extconf.c.

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

◆ COMMENT_END

#define COMMENT_END   "--;"

Definition at line 698 of file extconf.c.

◆ COMMENT_META

#define COMMENT_META   ';'

Definition at line 699 of file extconf.c.

Referenced by config_text_file_load().

◆ COMMENT_START

#define COMMENT_START   ";--"

Definition at line 697 of file extconf.c.

◆ COMMENT_TAG

#define COMMENT_TAG   '-'

Definition at line 700 of file extconf.c.

Referenced by config_text_file_load().

◆ 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 3605 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_

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

Referenced by ast_func_read(), config_text_file_load(), and process_text_line().

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

Referenced by pbx_extension_helper(), and pbx_substitute_variables_helper_full().

◆ LOG_VERBOSE

#define LOG_VERBOSE   __LOG_VERBOSE, _A_

Definition at line 151 of file extconf.c.

◆ LOG_WARNING

#define LOG_WARNING   __LOG_WARNING, _A_

◆ MAX_INCLUDE_LEVEL

#define MAX_INCLUDE_LEVEL   10

Definition at line 895 of file extconf.c.

Referenced by ast_config_new().

◆ MAX_NESTED_COMMENTS

#define MAX_NESTED_COMMENTS   128

Definition at line 696 of file extconf.c.

Referenced by config_text_file_load().

◆ ONE_MILLION

#define ONE_MILLION   1000000

Definition at line 2262 of file extconf.c.

Referenced by ast_tvadd(), ast_tvsub(), and tvfix().

◆ PRIORITY_HINT

#define PRIORITY_HINT   -1

Special Priority for a hint

Definition at line 2083 of file extconf.c.

Referenced by add_pri(), ast_add_extension2(), destroy_exten(), and pbx_load_config().

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

Referenced by ast_mutex_init().

◆ PTHREAD_MUTEX_INIT_VALUE

#define PTHREAD_MUTEX_INIT_VALUE   PTHREAD_MUTEX_INITIALIZER

Definition at line 193 of file extconf.c.

◆ pthread_mutex_t

#define pthread_mutex_t   use_ast_mutex_t_instead_of_pthread_mutex_t

Definition at line 500 of file extconf.c.

◆ QUEUELOG

#define QUEUELOG   "queue_log"

Definition at line 94 of file extconf.c.

◆ S_OR

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

Definition at line 957 of file extconf.c.

Referenced by pbx_load_config().

◆ STATUS_NO_CONTEXT

#define STATUS_NO_CONTEXT   1

Definition at line 2450 of file extconf.c.

Referenced by pbx_extension_helper(), and pbx_find_extension().

◆ STATUS_NO_EXTENSION

#define STATUS_NO_EXTENSION   2

Definition at line 2451 of file extconf.c.

Referenced by pbx_extension_helper(), and pbx_find_extension().

◆ STATUS_NO_LABEL

#define STATUS_NO_LABEL   4

Definition at line 2453 of file extconf.c.

Referenced by pbx_extension_helper(), and pbx_find_extension().

◆ STATUS_NO_PRIORITY

#define STATUS_NO_PRIORITY   3

Definition at line 2452 of file extconf.c.

Referenced by pbx_extension_helper(), and pbx_find_extension().

◆ STATUS_SUCCESS

#define STATUS_SUCCESS   5

Definition at line 2454 of file extconf.c.

Referenced by pbx_find_extension().

◆ SWITCH_DATA_LENGTH

#define SWITCH_DATA_LENGTH   256

Definition at line 3612 of file extconf.c.

Referenced by ast_context_add_switch2().

◆ VAR_BUF_SIZE

#define VAR_BUF_SIZE   4096

Definition at line 2320 of file extconf.c.

Referenced by pbx_substitute_variables_helper_full().

◆ VAR_HARDTRAN

#define VAR_HARDTRAN   3

Definition at line 2324 of file extconf.c.

◆ VAR_NORMAL

#define VAR_NORMAL   1

Definition at line 2322 of file extconf.c.

◆ VAR_SOFTTRAN

#define VAR_SOFTTRAN   2

Definition at line 2323 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   " == "

◆ VERBOSE_PREFIX_3

#define VERBOSE_PREFIX_3   " -- "

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

◆ config_load_func

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

Definition at line 933 of file extconf.c.

◆ realtime_multi_get

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

Definition at line 935 of file extconf.c.

◆ realtime_update

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

Definition at line 936 of file extconf.c.

◆ realtime_var_get

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

Definition at line 934 of file extconf.c.

Enumeration Type Documentation

◆ ast_extension_states

Enumerator
AST_EXTENSION_REMOVED 

Extension removed

AST_EXTENSION_DEACTIVATED 

Extension hint removed

AST_EXTENSION_NOT_INUSE 

No device INUSE or BUSY

AST_EXTENSION_INUSE 

One or more devices INUSE

AST_EXTENSION_BUSY 

All devices BUSY

AST_EXTENSION_UNAVAILABLE 

All devices UNAVAILABLE/UNREGISTERED

AST_EXTENSION_RINGING 

All devices RINGING

AST_EXTENSION_ONHOLD 

All devices ONHOLD

AST_EXTENSION_REMOVED 

Extension removed

AST_EXTENSION_DEACTIVATED 

Extension hint removed

AST_EXTENSION_NOT_INUSE 

No device INUSE or BUSY

AST_EXTENSION_INUSE 

One or more devices INUSE

AST_EXTENSION_BUSY 

All devices BUSY

AST_EXTENSION_UNAVAILABLE 

All devices UNAVAILABLE/UNREGISTERED

AST_EXTENSION_RINGING 

All devices RINGING

AST_EXTENSION_ONHOLD 

All devices ONHOLD

Definition at line 2085 of file extconf.c.

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

◆ ast_option_flags

Enumerator
AST_OPT_FLAG_EXEC_INCLUDES 

Allow #exec in config files

AST_OPT_FLAG_NO_FORK 

Do not fork()

AST_OPT_FLAG_QUIET 

Keep quiet

AST_OPT_FLAG_CONSOLE 

Console mode

AST_OPT_FLAG_HIGH_PRIORITY 

Run in realtime Linux priority

AST_OPT_FLAG_INIT_KEYS 

Initialize keys for RSA authentication

AST_OPT_FLAG_REMOTE 

Remote console

AST_OPT_FLAG_EXEC 

Execute an asterisk CLI command upon startup

AST_OPT_FLAG_NO_COLOR 

Don't use termcap colors

AST_OPT_FLAG_FULLY_BOOTED 

Are we fully started yet?

AST_OPT_FLAG_TRANSCODE_VIA_SLIN 

Trascode via signed linear

AST_OPT_FLAG_STDEXTEN_MACRO 

Invoke the stdexten using the legacy macro method.

AST_OPT_FLAG_DUMP_CORE 

Dump core on a seg fault

AST_OPT_FLAG_CACHE_RECORD_FILES 

Cache sound files

AST_OPT_FLAG_TIMESTAMP 

Display timestamp in CLI verbose output

AST_OPT_FLAG_CACHE_MEDIA_FRAMES 

Cache media frames for performance

AST_OPT_FLAG_RECONNECT 

Reconnect

AST_OPT_FLAG_TRANSMIT_SILENCE 

Transmit Silence during Record() and DTMF Generation

AST_OPT_FLAG_DONT_WARN 

Suppress some warnings

AST_OPT_FLAG_REF_DEBUG 

Reference Debugging

AST_OPT_FLAG_ALWAYS_FORK 

Always fork, even if verbose or debug settings are non-zero

AST_OPT_FLAG_MUTE 

Disable log/verbose output to remote consoles

AST_OPT_FLAG_DEBUG_MODULE 

There is a per-module debug setting

AST_OPT_FLAG_TRACE_MODULE 

There is a per-module trace setting

AST_OPT_FLAG_LIGHT_BACKGROUND 

Terminal colors should be adjusted for a light-colored background

AST_OPT_FLAG_HIDE_MESSAGING_AMI_EVENTS 

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

AST_OPT_FLAG_FORCE_BLACK_BACKGROUND 

Force black background

AST_OPT_FLAG_HIDE_CONSOLE_CONNECT 

Hide remote console connect messages on console

AST_OPT_FLAG_LOCK_CONFIG_DIR 

Protect the configuration file path with a lock

AST_OPT_FLAG_GENERIC_PLC 

Generic PLC

AST_OPT_FLAG_GENERIC_PLC_ON_EQUAL_CODECS 

Generic PLC onm equal codecs

AST_OPT_FLAG_EXEC_INCLUDES 

Allow #exec in config files

AST_OPT_FLAG_NO_FORK 

Do not fork()

AST_OPT_FLAG_QUIET 

Keep quiet

AST_OPT_FLAG_CONSOLE 

Console mode

AST_OPT_FLAG_HIGH_PRIORITY 

Run in realtime Linux priority

AST_OPT_FLAG_INIT_KEYS 

Initialize keys for RSA authentication

AST_OPT_FLAG_REMOTE 

Remote console

AST_OPT_FLAG_EXEC 

Execute an asterisk CLI command upon startup

AST_OPT_FLAG_NO_COLOR 

Don't use termcap colors

AST_OPT_FLAG_FULLY_BOOTED 

Are we fully started yet?

AST_OPT_FLAG_TRANSCODE_VIA_SLIN 

Trascode via signed linear

AST_OPT_FLAG_DUMP_CORE 

Dump core on a seg fault

AST_OPT_FLAG_CACHE_RECORD_FILES 

Cache sound files

AST_OPT_FLAG_TIMESTAMP 

Display timestamp in CLI verbose output

AST_OPT_FLAG_OVERRIDE_CONFIG 

Override config

AST_OPT_FLAG_RECONNECT 

Reconnect

AST_OPT_FLAG_TRANSMIT_SILENCE 

Transmit Silence during Record() and DTMF Generation

AST_OPT_FLAG_DONT_WARN 

Suppress some warnings

AST_OPT_FLAG_ALWAYS_FORK 

Always fork, even if verbose or debug settings are non-zero

AST_OPT_FLAG_MUTE 

Disable log/verbose output to remote consoles

AST_OPT_FLAG_DEBUG_FILE 

There is a per-file debug setting

AST_OPT_FLAG_LIGHT_BACKGROUND 

Terminal colors should be adjusted for a light-colored background

AST_OPT_FLAG_FORCE_BLACK_BACKGROUND 

Force black background

Definition at line 1309 of file extconf.c.

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

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

References ast_calloc, ast_log(), ast_mutex_init(), 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, ast_context::macrolock, ast_context::name, ast_context::next, NULL, registrar, ast_context::registrar, ast_context::root, tmp(), and VERBOSE_PREFIX_3.

Referenced by ast_context_find_or_create(), and localized_context_find_or_create().

4709 {
4710  struct ast_context *tmp, **loc_contexts;
4711  int length = sizeof(struct ast_context) + strlen(name) + 1;
4712 
4713  if (!extcontexts) {
4715  loc_contexts = &contexts;
4716  } else
4717  loc_contexts = extcontexts;
4718 
4719  for (tmp = *loc_contexts; tmp; tmp = tmp->next) {
4720  if (!strcasecmp(tmp->name, name)) {
4721  if (!existsokay) {
4722  ast_log(LOG_WARNING, "Tried to register context '%s', already in use\n", name);
4723  tmp = NULL;
4724  }
4725  if (!extcontexts)
4727  return tmp;
4728  }
4729  }
4730  if ((tmp = ast_calloc(1, length))) {
4731  ast_rwlock_init(&tmp->lock);
4732  ast_mutex_init(&tmp->macrolock);
4733  strcpy(tmp->name, name);
4734  tmp->root = NULL;
4735  tmp->registrar = registrar;
4736  tmp->next = *loc_contexts;
4737  tmp->includes = NULL;
4738  tmp->ignorepats = NULL;
4739  *loc_contexts = tmp;
4740  if (option_debug)
4741  ast_log(LOG_DEBUG, "Registered context '%s'\n", tmp->name);
4742  if (option_verbose > 2)
4743  ast_verbose( VERBOSE_PREFIX_3 "Registered extension context '%s'\n", tmp->name);
4744  }
4745 
4746  if (!extcontexts)
4748  return tmp;
4749 }
struct ast_ignorepats ignorepats
Definition: pbx.c:291
struct ast_exten * root
Definition: pbx.c:286
int option_debug
Definition: options.c:69
static struct ast_context * contexts
Definition: extconf.c:3599
static int tmp()
Definition: bt_open.c:389
int option_verbose
Definition: options.c:67
void ast_verbose(const char *fmt,...)
Definition: extconf.c:2207
#define NULL
Definition: resample.c:96
static int ast_rwlock_init(ast_rwlock_t *prwlock)
Definition: extconf.c:516
#define VERBOSE_PREFIX_3
Definition: extconf.c:102
static int ast_mutex_init(ast_mutex_t *pmutex)
Definition: extconf.c:469
struct ast_context * next
Definition: pbx.c:289
ast_mutex_t macrolock
Definition: pbx.c:296
static int ast_unlock_contexts(void)
Definition: extconf.c:4616
char * registrar
Definition: pbx.c:293
static void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Definition: extconf.c:2195
struct ast_includes includes
Definition: pbx.c:290
#define LOG_WARNING
Definition: extconf.c:139
ast_rwlock_t lock
Definition: pbx.c:285
char name[0]
Definition: pbx.c:297
static char * registrar
Definition: pbx_ael.c:78
static const char name[]
Definition: cdr_mysql.c:74
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:204
#define LOG_DEBUG
Definition: extconf.c:121
static int ast_wrlock_contexts(void)
Definition: extconf.c:4611
ast_context: An extension context - must remain in sync with fake_context
Definition: pbx.c:284

◆ __ast_context_destroy()

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

Definition at line 5504 of file extconf.c.

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

Referenced by ast_merge_contexts_and_delete(), and localized_context_destroy().

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

◆ _extension_match_core()

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

Definition at line 4193 of file extconf.c.

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

Referenced by extension_match_core().

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

◆ _null_sig_handler()

static void _null_sig_handler ( int  sig)
static

NULL handler so we can collect the child exit status.

Definition at line 789 of file extconf.c.

790 {
791 
792 }

◆ add_pri()

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

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

Definition at line 3677 of file extconf.c.

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

Referenced by ast_add_extension2().

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

◆ ALLOC_COMMENT()

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

Definition at line 877 of file extconf.c.

References ast_calloc, ast_comment::cmt, ast_config_map::next, and ast_channel::x.

Referenced by process_text_line().

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

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

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

Referenced by localized_add_extension2(), and pbx_load_config().

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

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

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

Referenced by add_pri(), and ast_add_extension2().

3645 {
3646  struct ast_hint *hint;
3647 
3648  if (!e)
3649  return -1;
3650 
3651 
3652  /* Search if hint exists, do nothing */
3653  AST_RWLIST_TRAVERSE(&hints, hint, list) {
3654  if (hint->exten == e) {
3655  if (option_debug > 1)
3656  ast_log(LOG_DEBUG, "HINTS: Not re-adding existing hint %s: %s\n", ast_get_extension_name(e), ast_get_extension_app(e));
3657  return -1;
3658  }
3659  }
3660 
3661  if (option_debug > 1)
3662  ast_log(LOG_DEBUG, "HINTS: Adding hint %s: %s\n", ast_get_extension_name(e), ast_get_extension_app(e));
3663 
3664  if (!(hint = ast_calloc(1, sizeof(*hint)))) {
3665  return -1;
3666  }
3667  /* Initialize and insert new item at the top */
3668  hint->exten = e;
3669  AST_RWLIST_INSERT_HEAD(&hints, hint, list);
3670 
3671  return 0;
3672 }
int option_debug
Definition: options.c:69
static const char * ast_get_extension_app(struct ast_exten *e)
Definition: extconf.c:3614
static const char * ast_get_extension_name(struct ast_exten *exten)
Definition: extconf.c:3619
static void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Definition: extconf.c:2195
struct ast_exten * exten
Hint extension.
Definition: pbx.c:331
Structure for dial plan hints.
Definition: pbx.c:324
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:204
#define LOG_DEBUG
Definition: extconf.c:121
#define AST_RWLIST_TRAVERSE
Definition: extconf.c:1777
#define AST_RWLIST_INSERT_HEAD
Definition: extconf.c:1964

◆ ast_app_separate_args()

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

Definition at line 2488 of file extconf.c.

References buf, paren, and quote().

Referenced by pbx_builtin_setvar().

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

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

References a, ast_atomic_fetchadd_int(), ast_channel_lock, ast_channel_trylock, ast_channel_unlock, AST_INLINE_API, and SIZEOF_INT.

Referenced by ast_atomic_fetchadd_int().

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.

References ast_atomic_dec_and_test(), AST_INLINE_API, HAVE_GCC_ATOMICS, and SIZEOF_INT.

Referenced by ast_atomic_dec_and_test().

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.
infoStandard string containing a timerange, weekday range, monthday range, and month range, as well as an optional timezone.
Return values
Returns1 on success or 0 on failure.

/brief Build timing

/param i info /param info_in

Definition at line 3808 of file extconf.c.

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

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

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

◆ ast_category_append()

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

Definition at line 2835 of file extconf.c.

References ast_category_destroy(), ast_config::current, ast_config::last, ast_category::next, and ast_config::root.

Referenced by inherit_category(), and process_text_line().

2836 {
2837  if (config->last)
2838  config->last->next = category;
2839  else
2840  config->root = category;
2841  config->last = category;
2842  config->current = category;
2843 }
struct ast_category * next
Definition: main/config.c:246
struct ast_category * last
Definition: main/config.c:253
struct ast_category * current
Definition: main/config.c:254
struct ast_category * root
Definition: main/config.c:251

◆ ast_category_browse()

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

Definition at line 3328 of file extconf.c.

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

Referenced by pbx_load_config().

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

◆ ast_category_destroy()

static void ast_category_destroy ( struct ast_category cat)
static

Definition at line 2847 of file extconf.c.

References ast_variables_destroy(), ast_category::file, free(), and ast_category::root.

Referenced by ast_category_append(), and process_text_line().

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

◆ ast_category_get()

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

Definition at line 1211 of file extconf.c.

References category_get().

Referenced by ast_variable_browse().

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

◆ ast_category_new()

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

Definition at line 2790 of file extconf.c.

References ast_calloc, ast_copy_string(), ast_category::file, ast_category::lineno, localized_category_get(), ast_category::name, and strdup.

Referenced by ast_config_get_current_category(), and process_text_line().

2791 {
2792  struct ast_category *category;
2793 
2794  if ((category = ast_calloc(1, sizeof(*category))))
2795  ast_copy_string(category->name, name, sizeof(category->name));
2796  category->file = strdup(in_file);
2797  category->lineno = lineno; /* if you don't know the lineno, set it to 999999 or something real big */
2798  return category;
2799 }
char * file
The file name from whence this declaration was read.
Definition: main/config.c:233
void ast_copy_string(char *dst, const char *src, size_t size)
Definition: extconf.c:970
static const char name[]
Definition: cdr_mysql.c:74
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:204
char name[80]
Definition: main/config.c:226
#define strdup(a)
Definition: astmm.h:165

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

References AST_RWLIST_TRAVERSE, and ast_hint::exten.

Referenced by add_pri().

3628 {
3629  struct ast_hint *hint;
3630  int res = -1;
3631 
3632  AST_RWLIST_TRAVERSE(&hints, hint, list) {
3633  if (hint->exten == oe) {
3634  hint->exten = ne;
3635  res = 0;
3636  break;
3637  }
3638  }
3639 
3640  return res;
3641 }
struct ast_exten * exten
Hint extension.
Definition: pbx.c:331
Structure for dial plan hints.
Definition: pbx.c:324
#define AST_RWLIST_TRAVERSE
Definition: extconf.c:1777

◆ 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
Returns1, if the time matches or 0, if the current time falls outside of the specified range.

Definition at line 4002 of file extconf.c.

References AST_RWLIST_TRAVERSE, ast_walk_contexts(), ast_switch::list, ast_switch::name, and pbx_findswitch().

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

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

◆ ast_config_destroy()

static void ast_config_destroy ( struct ast_config cfg)
static

Definition at line 1290 of file extconf.c.

References ast_includes_destroy(), ast_variables_destroy(), free(), ast_config::includes, ast_category::next, ast_category::root, and ast_config::root.

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

1291 {
1292  struct ast_category *cat, *catn;
1293 
1294  if (!cfg)
1295  return;
1296 
1298 
1299  cat = cfg->root;
1300  while (cat) {
1302  catn = cat;
1303  cat = cat->next;
1304  free(catn);
1305  }
1306  free(cfg);
1307 }
struct ast_category * next
Definition: main/config.c:246
struct ast_config_include * includes
Definition: main/config.c:258
void free()
struct ast_variable * root
Definition: main/config.c:240
static void ast_variables_destroy(struct ast_variable *v)
Definition: extconf.c:1263
static void ast_includes_destroy(struct ast_config_include *incls)
Definition: extconf.c:1274
struct ast_category * root
Definition: main/config.c:251

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

References ast_category_new(), ast_config::current, and ast_channel::name.

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

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

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

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

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

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

◆ ast_config_new()

static struct ast_config* ast_config_new ( void  )
static

Definition at line 3276 of file extconf.c.

References ast_calloc, config, localized_config_load(), ast_config::max_include_level, and MAX_INCLUDE_LEVEL.

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

3277 {
3278  struct ast_config *config;
3279 
3280  if ((config = ast_calloc(1, sizeof(*config))))
3282  return config;
3283 }
#define MAX_INCLUDE_LEVEL
Definition: extconf.c:895
char * config
Definition: conf2ael.c:66
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:204
int max_include_level
Definition: main/config.c:257

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

References ast_config::current.

Referenced by ast_category_browse().

3365 {
3366  /* cast below is just to silence compiler warning about dropping "const" */
3367  cfg->current = (struct ast_category *) cat;
3368 }
struct ast_category * current
Definition: main/config.c:254

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

References ast_network_puts().

1315 {
1316  /* Send to the root console */
1317  fputs(string, stdout);
1318  fflush(stdout);
1319 
1320  /* Send to any network console clients */
1321  ast_network_puts(string);
1322 }
static void ast_network_puts(const char *string)
write the string to all attached console clients
Definition: asterisk.c:1298

◆ ast_context_add_ignorepat2()

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

Definition at line 4569 of file extconf.c.

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

Referenced by localized_context_add_ignorepat2(), localized_context_add_include2(), and pbx_load_config().

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

◆ ast_context_add_include2()

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

Definition at line 4503 of file extconf.c.

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

Referenced by ast_get_context_name(), localized_context_add_include2(), and pbx_load_config().

4505 {
4506  struct ast_include *new_include;
4507  char *c;
4508  struct ast_include *i, *il = NULL; /* include, include_last */
4509  int length;
4510  char *p;
4511 
4512  length = sizeof(struct ast_include);
4513  length += 2 * (strlen(value) + 1);
4514 
4515  /* allocate new include structure ... */
4516  if (!(new_include = ast_calloc(1, length)))
4517  return -1;
4518  /* Fill in this structure. Use 'p' for assignments, as the fields
4519  * in the structure are 'const char *'
4520  */
4521  p = new_include->stuff;
4522  new_include->name = p;
4523  strcpy(p, value);
4524  p += strlen(value) + 1;
4525  new_include->rname = p;
4526  strcpy(p, value);
4527  /* Strip off timing info, and process if it is there */
4528  if ( (c = strchr(p, '|')) ) {
4529  *c++ = '\0';
4530  new_include->hastime = ast_build_timing(&(new_include->timing), c);
4531  }
4532  new_include->next = NULL;
4533  new_include->registrar = registrar;
4534 
4535 
4536  /* ... go to last include and check if context is already included too... */
4537  for (i = con->includes; i; i = i->next) {
4538  if (!strcasecmp(i->name, new_include->name)) {
4539  free(new_include);
4540  errno = EEXIST;
4541  return -1;
4542  }
4543  il = i;
4544  }
4545 
4546  /* ... include new context into context list, unlock, return */
4547  if (il)
4548  il->next = new_include;
4549  else
4550  con->includes = new_include;
4551  if (option_verbose > 2)
4552  ast_verbose(VERBOSE_PREFIX_3 "Including context '%s' in context '%s'\n", new_include->name, ast_get_context_name(con));
4553 
4554  return 0;
4555 }
ast_include: include= support in extensions.conf
Definition: pbx_include.c:37
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:3808
int option_verbose
Definition: options.c:67
static struct test_val c
void ast_verbose(const char *fmt,...)
Definition: extconf.c:2207
struct ast_include * next
Definition: conf2ael.c:151
#define NULL
Definition: resample.c:96
int value
Definition: syslog.c:37
char stuff[0]
Definition: pbx_include.c:47
#define VERBOSE_PREFIX_3
Definition: extconf.c:102
struct ast_timing timing
Definition: pbx_include.c:46
static const char * ast_get_context_name(struct ast_context *con)
Definition: extconf.c:4488
void free()
struct ast_includes includes
Definition: pbx.c:290
int errno
static char * registrar
Definition: pbx_ael.c:78
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:204
const char * name
Definition: pbx_include.c:38
const char * rname
Definition: pbx_include.c:40
const char * registrar
Definition: pbx_include.c:42

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

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, localized_context_add_switch2(), ast_sw::name, ast_sw::registrar, registrar, ast_sw::stuff, SWITCH_DATA_LENGTH, ast_sw::tmpdata, and VERBOSE_PREFIX_3.

Referenced by ast_unlock_context(), localized_context_add_switch2(), and pbx_load_config().

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

◆ ast_context_find()

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

Definition at line 4174 of file extconf.c.

References ast_walk_contexts(), ast_context::name, NULL, and tmp().

Referenced by ast_context_switches_count(), and ast_context_verify_includes().

4175 {
4176  struct ast_context *tmp = NULL;
4177  while ( (tmp = ast_walk_contexts(tmp)) ) {
4178  if (!name || !strcasecmp(name, tmp->name))
4179  break;
4180  }
4181  return tmp;
4182 }
static int tmp()
Definition: bt_open.c:389
#define NULL
Definition: resample.c:96
static struct ast_context * ast_walk_contexts(struct ast_context *con)
Definition: extconf.c:4026
char name[0]
Definition: pbx.c:297
static const char name[]
Definition: cdr_mysql.c:74
ast_context: An extension context - must remain in sync with fake_context
Definition: pbx.c:284

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

References __ast_context_create(), and localized_context_find_or_create().

Referenced by pbx_load_config().

4984 {
4985  return __ast_context_create(extcontexts, name, registrar, 1);
4986 }
static struct ast_context * __ast_context_create(struct ast_context **extcontexts, const char *name, const char *registrar, int existsokay)
Definition: extconf.c:4708
static char * registrar
Definition: pbx_ael.c:78
static const char name[]
Definition: cdr_mysql.c:74

◆ ast_context_ignorepats_count()

int ast_context_ignorepats_count ( struct ast_context con)

Definition at line 4125 of file extconf.c.

References ast_walk_context_ignorepats(), ast_walk_context_switches(), c, and NULL.

Referenced by ast_walk_context_ignorepats().

4126 {
4127  int c = 0;
4128  struct ast_ignorepat *ip = NULL;
4129 
4130  while ((ip = ast_walk_context_ignorepats(con, ip))) {
4131  c++;
4132  }
4133 
4134  return c;
4135 }
static struct ast_ignorepat * ast_walk_context_ignorepats(struct ast_context *con, struct ast_ignorepat *ip)
Definition: extconf.c:4115
static struct test_val c
#define NULL
Definition: resample.c:96
ast_ignorepat: Ignore patterns in dial plan
Definition: pbx_ignorepat.c:37

◆ ast_context_includes_count()

int ast_context_includes_count ( struct ast_context con)

Definition at line 4092 of file extconf.c.

References ast_walk_context_includes(), c, localized_walk_context_includes(), and NULL.

Referenced by ast_walk_context_includes().

4093 {
4094  int c = 0;
4095  struct ast_include *inc = NULL;
4096 
4097  while ((inc = ast_walk_context_includes(con, inc))) {
4098  c++;
4099  }
4100 
4101  return c;
4102 }
ast_include: include= support in extensions.conf
Definition: pbx_include.c:37
static struct ast_include * ast_walk_context_includes(struct ast_context *con, struct ast_include *inc)
Definition: extconf.c:4082
static struct test_val c
#define NULL
Definition: resample.c:96

◆ ast_context_switches_count()

int ast_context_switches_count ( struct ast_context con)

Definition at line 4159 of file extconf.c.

References ast_context_find(), ast_walk_context_switches(), c, and NULL.

Referenced by localized_walk_context_switches().

4160 {
4161  int c = 0;
4162  struct ast_sw *sw = NULL;
4163 
4164  while ((sw = ast_walk_context_switches(con, sw))) {
4165  c++;
4166  }
4167 
4168  return c;
4169 }
static struct test_val c
#define NULL
Definition: resample.c:96
ast_sw: Switch statement in extensions.conf
Definition: pbx_sw.c:37
static struct ast_sw * ast_walk_context_switches(struct ast_context *con, struct ast_sw *sw)
Definition: extconf.c:4141

◆ ast_context_verify_includes()

static int ast_context_verify_includes ( struct ast_context con)
static

Definition at line 5623 of file extconf.c.

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

Referenced by localized_context_verify_includes(), and localized_pbx_load_module().

5624 {
5625  struct ast_include *inc = NULL;
5626  int res = 0;
5627 
5628  while ( (inc = ast_walk_context_includes(con, inc)) )
5629  if (!ast_context_find(inc->rname)) {
5630  res = -1;
5631  if (strcasecmp(inc->rname,"parkedcalls")!=0)
5632  ast_log(LOG_WARNING, "Context '%s' tries to include the nonexistent context '%s'\n",
5633  ast_get_context_name(con), inc->rname);
5634  }
5635  return res;
5636 }
ast_include: include= support in extensions.conf
Definition: pbx_include.c:37
static struct ast_include * ast_walk_context_includes(struct ast_context *con, struct ast_include *inc)
Definition: extconf.c:4082
#define NULL
Definition: resample.c:96
static const char * ast_get_context_name(struct ast_context *con)
Definition: extconf.c:4488
static void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Definition: extconf.c:2195
#define LOG_WARNING
Definition: extconf.c:139
const char * rname
Definition: pbx_include.c:40
static struct ast_context * ast_context_find(const char *name)
Definition: extconf.c:4174

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

References E_MATCH, and extension_match_core().

Referenced by extension_match_core(), and matchcid().

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

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

References E_FINDLABEL, NULL, and pbx_extension_helper().

Referenced by pbx_extension_helper(), and pbx_load_config().

4979 {
4980  return pbx_extension_helper(c, con, NULL, exten, 0, label, callerid, E_FINDLABEL);
4981 }
static char exten[AST_MAX_EXTENSION]
Definition: chan_alsa.c:118
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:4917
#define NULL
Definition: resample.c:96

◆ ast_func_read()

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

Definition at line 4996 of file extconf.c.

References ast_log(), and LOG_ERROR.

Referenced by pbx_substitute_variables_helper_full().

4997 {
4998  ast_log(LOG_ERROR, "Function %s not registered\n", function);
4999  return -1;
5000 }
#define LOG_ERROR
Definition: extconf.c:145
static void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Definition: extconf.c:2195

◆ ast_func_write()

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

Definition at line 2480 of file extconf.c.

Referenced by pbx_builtin_setvar_helper().

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

◆ ast_get_context_name()

static const char* ast_get_context_name ( struct ast_context con)
static

Definition at line 4488 of file extconf.c.

References ast_context_add_include2(), ast_context::name, NULL, registrar, and value.

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

4489 {
4490  return con ? con->name : NULL;
4491 }
#define NULL
Definition: resample.c:96
char name[0]
Definition: pbx.c:297

◆ ast_get_extension_app()

static const char* ast_get_extension_app ( struct ast_exten e)
static

Definition at line 3614 of file extconf.c.

References ast_exten::app, and NULL.

Referenced by ast_add_hint().

3615 {
3616  return e ? e->app : NULL;
3617 }
#define NULL
Definition: resample.c:96
const char * app
Definition: pbx.c:246

◆ ast_get_extension_name()

static const char* ast_get_extension_name ( struct ast_exten exten)
static

Definition at line 3619 of file extconf.c.

References ast_exten::exten, and NULL.

Referenced by ast_add_hint().

3620 {
3621  return exten ? exten->exten : NULL;
3622 }
#define NULL
Definition: resample.c:96
char * exten
Definition: pbx.c:238

◆ ast_include_find()

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

Definition at line 1164 of file extconf.c.

References ast_variable_append(), ast_config_include::included_file, ast_config::includes, ast_config_include::next, and ast_channel::x.

Referenced by ast_include_new().

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

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

References ast_calloc, ast_include_find(), ast_log(), ast_strdup, ast_strlen_zero(), ast_config_include::exec, ast_config_include::exec_file, ast_config_include::include_location_file, ast_config_include::include_location_lineno, ast_config_include::included_file, ast_config::includes, ast_config_include::inclusion_count, LOG_WARNING, and ast_config_include::next.

Referenced by process_text_line().

1076 {
1077  /* a file should be included ONCE. Otherwise, if one of the instances is changed,
1078  then all be changed. -- how do we know to include it? -- Handling modified
1079  instances is possible, I'd have
1080  to create a new master for each instance. */
1081  struct ast_config_include *inc;
1082 
1083  inc = ast_include_find(conf, included_file);
1084  if (inc)
1085  {
1086  inc->inclusion_count++;
1087  snprintf(real_included_file_name, real_included_file_name_size, "%s~~%d", included_file, inc->inclusion_count);
1088  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);
1089  } else
1090  *real_included_file_name = 0;
1091 
1092  inc = ast_calloc(1,sizeof(struct ast_config_include));
1093  inc->include_location_file = ast_strdup(from_file);
1094  inc->include_location_lineno = from_lineno;
1095  if (!ast_strlen_zero(real_included_file_name))
1096  inc->included_file = ast_strdup(real_included_file_name);
1097  else
1099 
1100  inc->exec = is_exec;
1101  if (is_exec)
1102  inc->exec_file = ast_strdup(exec_file);
1103 
1104  /* attach this new struct to the conf struct */
1105  inc->next = conf->includes;
1106  conf->includes = inc;
1107 
1108  return inc;
1109 }
char * include_location_file
file name in which the include occurs
Definition: main/config.c:266
struct ast_config_include * includes
Definition: main/config.c:258
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
char * exec_file
if it&#39;s an exec, you&#39;ll have both the /var/tmp to read, and the original script
Definition: main/config.c:273
char * included_file
file name included
Definition: main/config.c:278
static force_inline int ast_strlen_zero(const char *s)
Definition: extconf.c:952
static void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Definition: extconf.c:2195
#define LOG_WARNING
Definition: extconf.c:139
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:204
struct ast_config_include * next
Definition: main/config.c:282
static struct ast_config_include * ast_include_find(struct ast_config *conf, const char *included_file)
Definition: extconf.c:1164

◆ ast_includes_destroy()

static void ast_includes_destroy ( struct ast_config_include incls)
static

Definition at line 1274 of file extconf.c.

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

Referenced by ast_config_destroy().

1275 {
1276  struct ast_config_include *incl,*inclnext;
1277 
1278  for (incl=incls; incl; incl = inclnext) {
1279  inclnext = incl->next;
1280  if (incl->include_location_file)
1281  free(incl->include_location_file);
1282  if (incl->exec_file)
1283  free(incl->exec_file);
1284  if (incl->included_file)
1285  free(incl->included_file);
1286  free(incl);
1287  }
1288 }
char * include_location_file
file name in which the include occurs
Definition: main/config.c:266
char * exec_file
if it&#39;s an exec, you&#39;ll have both the /var/tmp to read, and the original script
Definition: main/config.c:273
void free()
char * included_file
file name included
Definition: main/config.c:278
struct ast_config_include * next
Definition: main/config.c:282

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

References __LOG_ERROR, ast_bt::addresses, ast_bt_create, ast_bt_destroy, ast_bt_free_symbols, ast_bt_get_symbols, ast_free, ast_log(), ast_log_safe(), ast_str_append(), ast_str_buffer(), ast_str_create, AST_VECTOR_GET, AST_VECTOR_SIZE, buf, LOG_ERROR, LOG_WARNING, NULL, and ast_bt::num_frames.

2159 {
2160 #ifdef HAVE_BKTR
2161  struct ast_bt *bt;
2162  int i = 0;
2163  struct ast_vector_string *strings;
2164 
2165  if (!(bt = ast_bt_create())) {
2166  ast_log(LOG_WARNING, "Unable to allocate space for backtrace structure\n");
2167  return;
2168  }
2169 
2170  if ((strings = ast_bt_get_symbols(bt->addresses, bt->num_frames))) {
2171  int count = AST_VECTOR_SIZE(strings);
2172  struct ast_str *buf = ast_str_create(bt->num_frames * 64);
2173 
2174  if (buf) {
2175  ast_str_append(&buf, 0, "Got %d backtrace record%c\n", count - 3, count - 3 != 1 ? 's' : ' ');
2176  for (i = 3; i < AST_VECTOR_SIZE(strings); i++) {
2177  ast_str_append(&buf, 0, "#%2d: %s\n", i - 3, AST_VECTOR_GET(strings, i));
2178  }
2179  ast_log_safe(__LOG_ERROR, NULL, 0, NULL, "%s\n", ast_str_buffer(buf));
2180  ast_free(buf);
2181  }
2182 
2183  ast_bt_free_symbols(strings);
2184  } else {
2185  ast_log(LOG_ERROR, "Could not allocate memory for backtrace\n");
2186  }
2187  ast_bt_destroy(bt);
2188 #else
2189  ast_log(LOG_WARNING, "Must run configure with '--with-execinfo' for stack backtraces.\n");
2190 #endif /* defined(HAVE_BKTR) */
2191 }
#define ast_bt_free_symbols(string_vector)
Definition: backtrace.h:42
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
#define LOG_WARNING
Definition: logger.h:274
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition: strings.h:714
#define ast_bt_get_symbols(addresses, num_frames)
Definition: backtrace.h:41
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:1091
#define ast_bt_destroy(bt)
Definition: backtrace.h:40
#define __LOG_ERROR
Definition: logger.h:284
#define NULL
Definition: resample.c:96
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:2123
#define LOG_ERROR
Definition: logger.h:285
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
Definition: strings.h:584
#define ast_bt_create()
Definition: backtrace.h:39
#define ast_free(a)
Definition: astmm.h:182
void * addresses[AST_MAX_BT_FRAMES]
Definition: backtrace.h:52
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:2101
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
Definition: vector.h:682
int num_frames
Definition: backtrace.h:54
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:611
#define ast_str_create(init_len)
Create a malloc&#39;ed dynamic length string.
Definition: strings.h:620

◆ ast_mark_lock_failed()

void ast_mark_lock_failed ( void *  lock_addr)

Mark the last lock as failed (trylock)

Definition at line 2314 of file extconf.c.

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

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

◆ ast_merge_contexts_and_delete()

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

Definition at line 5573 of file extconf.c.

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

Referenced by localized_merge_contexts_and_delete(), and localized_pbx_load_module().

5574 {
5575  struct ast_context *tmp, *lasttmp = NULL;
5576 
5577  /* it is very important that this function hold the hint list lock _and_ the conlock
5578  during its operation; not only do we need to ensure that the list of contexts
5579  and extensions does not change, but also that no hint callbacks (watchers) are
5580  added or removed during the merge/delete process
5581 
5582  in addition, the locks _must_ be taken in this order, because there are already
5583  other code paths that use this order
5584  */
5586 
5587  tmp = *extcontexts;
5588  if (registrar) {
5589  /* XXX remove previous contexts from same registrar */
5590  if (option_debug)
5591  ast_log(LOG_DEBUG, "must remove any reg %s\n", registrar);
5593  while (tmp) {
5594  lasttmp = tmp;
5595  tmp = tmp->next;
5596  }
5597  } else {
5598  /* XXX remove contexts with the same name */
5599  while (tmp) {
5600  ast_log(LOG_WARNING, "must remove %s reg %s\n", tmp->name, tmp->registrar);
5601  __ast_context_destroy(tmp,tmp->registrar);
5602  lasttmp = tmp;
5603  tmp = tmp->next;
5604  }
5605  }
5606  if (lasttmp) {
5607  lasttmp->next = contexts;
5608  contexts = *extcontexts;
5609  *extcontexts = NULL;
5610  } else
5611  ast_log(LOG_WARNING, "Requested contexts didn't get merged\n");
5612 
5614 
5615  return;
5616 }
int option_debug
Definition: options.c:69
static struct ast_context * contexts
Definition: extconf.c:3599
static int tmp()
Definition: bt_open.c:389
#define NULL
Definition: resample.c:96
struct ast_context * next
Definition: pbx.c:289
static int ast_unlock_contexts(void)
Definition: extconf.c:4616
char * registrar
Definition: pbx.c:293
static void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Definition: extconf.c:2195
#define LOG_WARNING
Definition: extconf.c:139
char name[0]
Definition: pbx.c:297
static char * registrar
Definition: pbx_ael.c:78
#define LOG_DEBUG
Definition: extconf.c:121
static void __ast_context_destroy(struct ast_context *con, const char *registrar)
Definition: extconf.c:5504
static int ast_wrlock_contexts(void)
Definition: extconf.c:4611
ast_context: An extension context - must remain in sync with fake_context
Definition: pbx.c:284

◆ ast_mutex_init()

static int ast_mutex_init ( ast_mutex_t pmutex)
inlinestatic

Definition at line 469 of file extconf.c.

References AST_MUTEX_KIND, and pthread_mutex_init.

Referenced by __ast_context_create().

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 pthread_mutex_init
Definition: extconf.c:501
#define AST_MUTEX_KIND
Definition: extconf.c:194

◆ ast_process_quotes_and_slashes()

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

Definition at line 2219 of file extconf.c.

Referenced by pbx_load_config().

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

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

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

Referenced by logger_queue_start(), and reload_logger().

895 {
896  va_list ap;
897  struct timeval tv;
898  struct ast_tm tm;
899  char qlog_msg[8192];
900  int qlog_len;
901  char time_str[30];
902 
903  if (!logger_initialized) {
904  /* You are too early. We are not open yet! */
905  return;
906  }
907  if (!queuelog_init) {
908  /* We must initialize now since someone is trying to log something. */
910  }
911 
912  if (ast_check_realtime("queue_log")) {
913  tv = ast_tvnow();
914  ast_localtime(&tv, &tm, logfiles.queue_log_realtime_use_gmt ? "GMT" : NULL);
915  ast_strftime(time_str, sizeof(time_str), "%F %T.%6q", &tm);
916  va_start(ap, fmt);
917  vsnprintf(qlog_msg, sizeof(qlog_msg), fmt, ap);
918  va_end(ap);
919  if (logfiles.queue_adaptive_realtime) {
921  AST_APP_ARG(data)[5];
922  );
923  AST_NONSTANDARD_APP_ARGS(args, qlog_msg, '|');
924  /* Ensure fields are large enough to receive data */
925  ast_realtime_require_field("queue_log",
926  "data1", RQ_CHAR, strlen(S_OR(args.data[0], "")),
927  "data2", RQ_CHAR, strlen(S_OR(args.data[1], "")),
928  "data3", RQ_CHAR, strlen(S_OR(args.data[2], "")),
929  "data4", RQ_CHAR, strlen(S_OR(args.data[3], "")),
930  "data5", RQ_CHAR, strlen(S_OR(args.data[4], "")),
931  SENTINEL);
932 
933  /* Store the log */
934  ast_store_realtime("queue_log", "time", time_str,
935  "callid", callid,
936  "queuename", queuename,
937  "agent", agent,
938  "event", event,
939  "data1", S_OR(args.data[0], ""),
940  "data2", S_OR(args.data[1], ""),
941  "data3", S_OR(args.data[2], ""),
942  "data4", S_OR(args.data[3], ""),
943  "data5", S_OR(args.data[4], ""),
944  SENTINEL);
945  } else {
946  ast_store_realtime("queue_log", "time", time_str,
947  "callid", callid,
948  "queuename", queuename,
949  "agent", agent,
950  "event", event,
951  "data", qlog_msg,
952  SENTINEL);
953  }
954 
955  if (!logfiles.queue_log_to_file) {
956  return;
957  }
958  }
959 
960  if (qlog) {
961  va_start(ap, fmt);
962  qlog_len = snprintf(qlog_msg, sizeof(qlog_msg), "%ld|%s|%s|%s|%s|", (long)time(NULL), callid, queuename, agent, event);
963  vsnprintf(qlog_msg + qlog_len, sizeof(qlog_msg) - qlog_len, fmt, ap);
964  va_end(ap);
966  if (qlog) {
967  fprintf(qlog, "%s\n", qlog_msg);
968  fflush(qlog);
969  }
971  }
972 }
static int queuelog_init
Definition: logger.c:86
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150
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_check_realtime(const char *family)
Check if realtime engine is configured for family.
Definition: main/config.c:3363
Definition: astman.c:222
void logger_queue_start(void)
Start the ast_queue_log() logger.
Definition: logger.c:1854
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:150
const char * args
#define NULL
Definition: resample.c:96
static FILE * qlog
Definition: logger.c:193
static int logger_initialized
Definition: logger.c:87
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
Definition: linkedlists.h:77
#define SENTINEL
Definition: compiler.h:87
int ast_store_realtime(const char *family,...) attribute_sentinel
Create realtime configuration.
Definition: main/config.c:3570
int ast_realtime_require_field(const char *family,...) attribute_sentinel
Inform realtime what fields that may be stored.
Definition: main/config.c:3382
#define AST_NONSTANDARD_APP_ARGS(args, parse, sep)
Performs the &#39;nonstandard&#39; argument separation process for an application.
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
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
Definition: strings.h:79
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application&#39;s arguments.
static struct @403 logfiles
#define AST_APP_ARG(name)
Define an application argument.

◆ ast_remove_hint()

static int ast_remove_hint ( struct ast_exten e)
static

ast_remove_hint: Remove hint from extension

Definition at line 3735 of file extconf.c.

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

Referenced by destroy_exten().

3736 {
3737  /* Cleanup the Notifys if hint is removed */
3738  struct ast_hint *hint;
3739  struct ast_state_cb *cblist, *cbprev;
3740  int res = -1;
3741 
3742  if (!e)
3743  return -1;
3744 
3745  AST_RWLIST_TRAVERSE_SAFE_BEGIN(&hints, hint, list) {
3746  if (hint->exten == e) {
3747  cbprev = NULL;
3748  cblist = hint->callbacks;
3749  while (cblist) {
3750  /* Notify with -1 and remove all callbacks */
3751  cbprev = cblist;
3752  cblist = cblist->next;
3753  free(cbprev);
3754  }
3755  hint->callbacks = NULL;
3757  free(hint);
3758  res = 0;
3759  break;
3760  }
3761  }
3763 
3764  return res;
3765 }
struct ast_state_cb * next
Definition: pbx.c:313
ast_state_cb: An extension state notify register item
Definition: pbx.c:301
#define AST_RWLIST_TRAVERSE_SAFE_END
Definition: extconf.c:1877
#define NULL
Definition: resample.c:96
void free()
#define AST_RWLIST_TRAVERSE_SAFE_BEGIN
Definition: extconf.c:1824
struct ast_exten * exten
Hint extension.
Definition: pbx.c:331
#define AST_RWLIST_REMOVE_CURRENT
Definition: extconf.c:1847
Structure for dial plan hints.
Definition: pbx.c:324
struct ao2_container * callbacks
Definition: pbx.c:332

◆ ast_replace_sigchld()

void ast_replace_sigchld ( void  )

Replace the SIGCHLD handler.

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

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

Definition at line 801 of file extconf.c.

References ast_unreplace_sigchld(), and safe_system_prev_handler.

Referenced by ast_safe_fork(), and ast_safe_system().

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

◆ ast_rwlock_destroy()

static int ast_rwlock_destroy ( ast_rwlock_t prwlock)
inlinestatic

Definition at line 529 of file extconf.c.

Referenced by __ast_context_destroy().

530 {
531  return pthread_rwlock_destroy(prwlock);
532 }

◆ ast_rwlock_init()

static int ast_rwlock_init ( ast_rwlock_t prwlock)
inlinestatic

Definition at line 516 of file extconf.c.

Referenced by __ast_context_create().

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 }

◆ ast_rwlock_rdlock()

static int ast_rwlock_rdlock ( ast_rwlock_t prwlock)
inlinestatic

Definition at line 539 of file extconf.c.

Referenced by pbx_retrieve_variable().

540 {
541  return pthread_rwlock_rdlock(prwlock);
542 }

◆ ast_rwlock_unlock()

static int ast_rwlock_unlock ( ast_rwlock_t prwlock)
inlinestatic

Definition at line 534 of file extconf.c.

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

535 {
536  return pthread_rwlock_unlock(prwlock);
537 }

◆ ast_rwlock_wrlock()

static int ast_rwlock_wrlock ( ast_rwlock_t prwlock)
inlinestatic

Definition at line 544 of file extconf.c.

Referenced by ast_wrlock_context(), and ast_wrlock_contexts().

545 {
546  return pthread_rwlock_wrlock(prwlock);
547 }

◆ ast_safe_system()

int ast_safe_system ( const char *  s)

Safely spawn an OS shell command while closing file descriptors.

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

Definition at line 829 of file extconf.c.

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

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

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

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

References ast_channel::x.

Referenced by pbx_load_config().

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

◆ ast_skip_blanks()

char* ast_skip_blanks ( const char *  str)

Definition at line 979 of file extconf.c.

References str.

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

989 {

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

Referenced by config_text_file_load(), and process_text_line().

1029 {

◆ 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
ast_trim_blanksfunction being used
strthe input string
Returns
a pointer to the modified string

Definition at line 1005 of file extconf.c.

References ast_skip_blanks().

1018 {

◆ ast_true()

static int ast_true ( const char *  s)
static

Definition at line 2245 of file extconf.c.

References ast_strlen_zero().

Referenced by pbx_load_config().

2246 {
2247  if (ast_strlen_zero(s))
2248  return 0;
2249 
2250  /* Determine if this is a true value */
2251  if (!strcasecmp(s, "yes") ||
2252  !strcasecmp(s, "true") ||
2253  !strcasecmp(s, "y") ||
2254  !strcasecmp(s, "t") ||
2255  !strcasecmp(s, "1") ||
2256  !strcasecmp(s, "on"))
2257  return -1;
2258 
2259  return 0;
2260 }
static force_inline int ast_strlen_zero(const char *s)
Definition: extconf.c:952

◆ ast_tvadd()

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

Returns the sum of two timevals a + b.

Definition at line 2283 of file extconf.c.

References a, 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_ice_turn_request(), ast_rtp_sendcng(), ast_sched_runq(), ast_sip_sched_task_get_times2(), ast_sip_schedule_task(), ast_smoother_read(), AST_TEST_DEFINE(), ast_translate(), bridge_builtin_set_limits(), bridge_channel_handle_interval(), bridge_sync_wait(), calc_rxstamp(), calc_timestamp(), cli_show_tasks(), cli_tps_ping(), conf_run(), consumer_should_stay(), dial_exec_full(), do_cdr(), do_timing(), drop_packets_data_update(), expire_objects_from_cache(), handle_keepalive_message(), handler_wait_for_message(), hook_event_cb(), iax2_process_thread(), ice_reset_session(), jb_get_and_deliver(), jitterbuffer_frame_get_ntp_timestamp(), make_deadline(), mb_poll_thread(), monmp3thread(), mp3_exec(), mwi_monitor_handler(), NBScat_exec(), register_aor_core(), 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().

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

◆ ast_tvnow()

struct timeval ast_tvnow ( void  )

Definition at line 5674 of file extconf.c.

References NULL.

5675 {
5676  struct timeval t;
5677  gettimeofday(&t, NULL);
5678  return t;
5679 }
#define NULL
Definition: resample.c:96

◆ ast_tvsub()

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

Returns the difference of two timevals a - b.

Definition at line 2298 of file extconf.c.

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

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

2299 {
2300  /* consistency checks to guarantee usec in 0..999999 */
2301  a = tvfix(a);
2302  b = tvfix(b);
2303  a.tv_sec -= b.tv_sec;
2304  a.tv_usec -= b.tv_usec;
2305  if (a.tv_usec < 0) {
2306  a.tv_sec-- ;
2307  a.tv_usec += ONE_MILLION;
2308  }
2309  return a;
2310 }
static struct timeval tvfix(struct timeval a)
Definition: extconf.c:2267
static struct test_val b
#define ONE_MILLION
Definition: extconf.c:2262
static struct test_val a

◆ ast_unlock_context()

static int ast_unlock_context ( struct ast_context con)
static

Definition at line 4626 of file extconf.c.

References ast_context_add_switch2(), ast_rwlock_unlock(), and ast_context::lock.

Referenced by __ast_context_destroy().

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

◆ ast_unlock_contexts()

static int ast_unlock_contexts ( void  )
static

Definition at line 4616 of file extconf.c.

References ast_rwlock_unlock(), and conlock.

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

4617 {
4618  return ast_rwlock_unlock(&conlock);
4619 }
static ast_rwlock_t conlock
Definition: extconf.c:4484
static int ast_rwlock_unlock(ast_rwlock_t *prwlock)
Definition: extconf.c:534

◆ ast_unreplace_sigchld()

void ast_unreplace_sigchld ( void  )

Restore the SIGCHLD handler.

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

Definition at line 815 of file extconf.c.

References ast_safe_system(), NULL, safe_system_level, and safe_system_prev_handler.

Referenced by ast_replace_sigchld(), ast_safe_fork_cleanup(), ast_safe_system(), and AST_TEST_DEFINE().

816 {
817  unsigned int level;
818 
819  level = --safe_system_level;
820 
821  /* only restore the handler if we are the last one */
822  if (level == 0) {
823  sigaction(SIGCHLD, &safe_system_prev_handler, NULL);
824  }
825 }
#define NULL
Definition: resample.c:96
static unsigned int safe_system_level
Keep track of how many threads are currently trying to wait*() on a child process.
Definition: extconf.c:785
static struct sigaction safe_system_prev_handler
Definition: extconf.c:786

◆ ast_var_assign()

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

Definition at line 2456 of file extconf.c.

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

Referenced by pbx_builtin_setvar_helper().

2457 {
2458  struct ast_var_t *var;
2459  int name_len = strlen(name) + 1;
2460  int value_len = strlen(value) + 1;
2461 
2462  if (!(var = ast_calloc(sizeof(*var) + name_len + value_len, sizeof(char)))) {
2463  return NULL;
2464  }
2465 
2466  ast_copy_string(var->name, name, name_len);
2467  var->value = var->name + name_len;
2468  ast_copy_string(var->value, value, value_len);
2469 
2470  return var;
2471 }
void ast_copy_string(char *dst, const char *src, size_t size)
Definition: extconf.c:970
#define var
Definition: ast_expr2f.c:614
#define NULL
Definition: resample.c:96
int value
Definition: syslog.c:37
char name[0]
Definition: chanvars.h:31
char * value
Definition: chanvars.h:30
static const char name[]
Definition: cdr_mysql.c:74
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:204

◆ ast_var_delete()

static void ast_var_delete ( struct ast_var_t var)
static

Definition at line 2473 of file extconf.c.

References free().

Referenced by pbx_builtin_setvar_helper().

2474 {
2475  free(var);
2476 }
void free()

◆ ast_var_name()

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

Definition at line 2171 of file extconf.c.

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

Referenced by pbx_builtin_setvar_helper(), and pbx_retrieve_variable().

2172 {
2173  const char *name;
2174 
2175  if (var == NULL || (name = var->name) == NULL)
2176  return NULL;
2177  /* Return the name without the initial underscores */
2178  if (name[0] == '_') {
2179  name++;
2180  if (name[0] == '_')
2181  name++;
2182  }
2183  return name;
2184 }
#define NULL
Definition: resample.c:96
char name[0]
Definition: chanvars.h:31
static const char name[]
Definition: cdr_mysql.c:74

◆ ast_var_value()

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

Definition at line 5028 of file extconf.c.

References NULL, and ast_var_t::value.

Referenced by pbx_retrieve_variable().

5029 {
5030  return (var ? var->value : NULL);
5031 }
#define NULL
Definition: resample.c:96
char * value
Definition: chanvars.h:30

◆ ast_variable_append()

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

Definition at line 1178 of file extconf.c.

References category_get(), config, ast_category::ignored, ast_category::last, ast_variable::next, and ast_category::root.

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

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

◆ ast_variable_browse()

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

Definition at line 1216 of file extconf.c.

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

Referenced by ast_variable_retrieve(), and pbx_load_config().

1217 {
1218  struct ast_category *cat = NULL;
1219 
1220  if (category && config->last_browse && (config->last_browse->name == category))
1221  cat = config->last_browse;
1222  else
1223  cat = ast_category_get(config, category);
1224 
1225  return (cat) ? cat->root : NULL;
1226 }
#define NULL
Definition: resample.c:96
static struct ast_category * ast_category_get(const struct ast_config *config, const char *category_name)
Definition: extconf.c:1211
struct ast_variable * root
Definition: main/config.c:240
struct ast_category * last_browse
Definition: main/config.c:255
char name[80]
Definition: main/config.c:226

◆ ast_variable_new()

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

Definition at line 1056 of file extconf.c.

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

Referenced by process_text_line(), and variable_clone().

1057 {
1058  struct ast_variable *variable;
1059  int name_len = strlen(name) + 1;
1060  size_t value_len = strlen(value) + 1;
1061  size_t filename_len = strlen(filename) + 1;
1062 
1063  if ((variable = ast_calloc(1, name_len + value_len + filename_len + sizeof(*variable)))) {
1064  variable->name = variable->stuff;
1065  variable->value = variable->stuff + name_len;
1066  variable->file = variable->value + value_len;
1067  strcpy(variable->name,name);
1068  ast_copy_string(variable->value, value, value_len);
1069  ast_copy_string(variable->file, filename, filename_len);
1070  }
1071 
1072  return variable;
1073 }
void ast_copy_string(char *dst, const char *src, size_t size)
Definition: extconf.c:970
Structure for variables, used for configurations and for channel variables.
int value
Definition: syslog.c:37
char stuff[0]
Contents of file, name, and value in that order stuffed here.
static const char name[]
Definition: cdr_mysql.c:74
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:204

◆ ast_variable_retrieve()

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

Definition at line 1228 of file extconf.c.

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

Referenced by pbx_load_config().

1229 {
1230  struct ast_variable *v;
1231 
1232  if (category) {
1233  for (v = ast_variable_browse(config, category); v; v = v->next) {
1234  if (!strcasecmp(variable, v->name))
1235  return v->value;
1236  }
1237  } else {
1238  struct ast_category *cat;
1239 
1240  for (cat = config->root; cat; cat = cat->next)
1241  for (v = cat->root; v; v = v->next)
1242  if (!strcasecmp(variable, v->name))
1243  return v->value;
1244  }
1245 
1246  return NULL;
1247 }
struct ast_variable * next
struct ast_category * next
Definition: main/config.c:246
static struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category)
Definition: extconf.c:1216
Structure for variables, used for configurations and for channel variables.
#define NULL
Definition: resample.c:96
struct ast_variable * root
Definition: main/config.c:240
struct ast_category * root
Definition: main/config.c:251

◆ ast_variables_destroy()

static void ast_variables_destroy ( struct ast_variable v)
static

Definition at line 1263 of file extconf.c.

References free(), and ast_variable::next.

Referenced by ast_category_destroy(), and ast_config_destroy().

1264 {
1265  struct ast_variable *vn;
1266 
1267  while (v) {
1268  vn = v;
1269  v = v->next;
1270  free(vn);
1271  }
1272 }
struct ast_variable * next
Structure for variables, used for configurations and for channel variables.
void free()

◆ ast_verbose()

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

Definition at line 2207 of file extconf.c.

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

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

◆ ast_walk_context_extensions()

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

Definition at line 4042 of file extconf.c.

References localized_walk_context_extensions(), ast_exten::next, NULL, and ast_context::root.

Referenced by localized_walk_context_extensions(), localized_walk_contexts(), and pbx_find_extension().

4044 {
4045  if (!exten)
4046  return con ? con->root : NULL;
4047  else
4048  return exten->next;
4049 }
struct ast_exten * root
Definition: pbx.c:286
#define NULL
Definition: resample.c:96
struct ast_exten * next
Definition: pbx.c:256

◆ ast_walk_context_ignorepats()

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

Definition at line 4115 of file extconf.c.

References ast_context_ignorepats_count(), ast_context::ignorepats, ast_ignorepat::next, and NULL.

Referenced by ast_context_ignorepats_count(), and localized_walk_context_includes().

4117 {
4118  if (!ip)
4119  return con ? con->ignorepats : NULL;
4120  else
4121  return ip->next;
4122 }
struct ast_ignorepats ignorepats
Definition: pbx.c:291
struct ast_ignorepat * next
Definition: conf2ael.c:169
#define NULL
Definition: resample.c:96

◆ ast_walk_context_includes()

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

Definition at line 4082 of file extconf.c.

References ast_context_includes_count(), ast_context::includes, ast_include::next, and NULL.

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

4084 {
4085  if (!inc)
4086  return con ? con->includes : NULL;
4087  else
4088  return inc->next;
4089 }
struct ast_include * next
Definition: conf2ael.c:151
#define NULL
Definition: resample.c:96
struct ast_includes includes
Definition: pbx.c:290

◆ ast_walk_context_switches()

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

Definition at line 4141 of file extconf.c.

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

Referenced by ast_context_ignorepats_count(), ast_context_switches_count(), and localized_walk_context_switches().

4143 {
4144  if (!sw)
4145  return con ? AST_LIST_FIRST(&con->alts) : NULL;
4146  else
4147  return AST_LIST_NEXT(sw, list);
4148 }
#define NULL
Definition: resample.c:96
#define AST_LIST_NEXT(elm, field)
Returns the next entry in the list after the given entry.
Definition: extconf.c:1724
#define AST_LIST_FIRST(head)
Returns the first entry contained in a list.
Definition: extconf.c:1706
struct ast_sws alts
Definition: pbx.c:292

◆ ast_walk_contexts()

static struct ast_context* ast_walk_contexts ( struct ast_context con)
static

Definition at line 4026 of file extconf.c.

References contexts, localized_walk_contexts(), and ast_context::next.

Referenced by ast_check_timing(), ast_context_find(), localized_pbx_load_module(), localized_walk_contexts(), and pbx_find_extension().

4027 {
4028  return con ? con->next : contexts;
4029 }
static struct ast_context * contexts
Definition: extconf.c:3599
struct ast_context * next
Definition: pbx.c:289

◆ ast_walk_extension_priorities()

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

Definition at line 4063 of file extconf.c.

References exten, localized_walk_extension_priorities(), and ast_exten::peer.

Referenced by localized_walk_context_extensions(), localized_walk_extension_priorities(), and pbx_find_extension().

4065 {
4066  return priority ? priority->peer : exten;
4067 }
static char exten[AST_MAX_EXTENSION]
Definition: chan_alsa.c:118
struct ast_exten * peer
Definition: pbx.c:250

◆ ast_wrlock_context()

static int ast_wrlock_context ( struct ast_context con)
static

Definition at line 4621 of file extconf.c.

References ast_rwlock_wrlock(), and ast_context::lock.

Referenced by __ast_context_destroy().

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

◆ ast_wrlock_contexts()

static int ast_wrlock_contexts ( void  )
static

Definition at line 4611 of file extconf.c.

References ast_rwlock_wrlock(), and conlock.

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

4612 {
4613  return ast_rwlock_wrlock(&conlock);
4614 }
static ast_rwlock_t conlock
Definition: extconf.c:4484
static int ast_rwlock_wrlock(ast_rwlock_t *prwlock)
Definition: extconf.c:544

◆ category_get()

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

Definition at line 1193 of file extconf.c.

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

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

1194 {
1195  struct ast_category *cat;
1196 
1197  /* try exact match first, then case-insensitive match */
1198  for (cat = config->root; cat; cat = cat->next) {
1199  if (cat->name == category_name && (ignored || !cat->ignored))
1200  return cat;
1201  }
1202 
1203  for (cat = config->root; cat; cat = cat->next) {
1204  if (!strcasecmp(cat->name, category_name) && (ignored || !cat->ignored))
1205  return cat;
1206  }
1207 
1208  return NULL;
1209 }
struct ast_category * next
Definition: main/config.c:246
#define NULL
Definition: resample.c:96
char name[80]
Definition: main/config.c:226
struct ast_category * root
Definition: main/config.c:251

◆ CB_ADD()

static void CB_ADD ( char *  str)
static

Definition at line 737 of file extconf.c.

References ast_realloc, and CB_INCR.

Referenced by config_text_file_load().

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

◆ CB_ADD_LEN()

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

Definition at line 750 of file extconf.c.

References ast_realloc, and CB_INCR.

Referenced by config_text_file_load().

751 {
752  int cbl = strlen(comment_buffer) + 1;
753  int rem = comment_buffer_size - cbl;
754  if (rem < len+1) {
756  if (!comment_buffer)
757  return;
759  }
760  strncat(comment_buffer,str,len); /* safe */
761  comment_buffer[cbl+len-1] = 0;
762 }
#define ast_realloc(p, len)
A wrapper for realloc()
Definition: astmm.h:228
static int comment_buffer_size
Definition: extconf.c:706
const char * str
Definition: app_jack.c:147
static char * comment_buffer
Definition: extconf.c:705
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
#define CB_INCR
Definition: extconf.c:711

◆ CB_INIT()

static void CB_INIT ( void  )
static

Definition at line 718 of file extconf.c.

References ast_malloc, and CB_INCR.

Referenced by config_text_file_load().

719 {
720  if (!comment_buffer) {
722  if (!comment_buffer)
723  return;
724  comment_buffer[0] = 0;
727  if (!lline_buffer)
728  return;
729  lline_buffer[0] = 0;
731  } else {
732  comment_buffer[0] = 0;
733  lline_buffer[0] = 0;
734  }
735 }
static int comment_buffer_size
Definition: extconf.c:706
static int lline_buffer_size
Definition: extconf.c:709
static char * lline_buffer
Definition: extconf.c:708
#define ast_malloc(len)
A wrapper for malloc()
Definition: astmm.h:193
static char * comment_buffer
Definition: extconf.c:705
#define CB_INCR
Definition: extconf.c:711

◆ CB_RESET()

static void CB_RESET ( void  )
static

Definition at line 777 of file extconf.c.

Referenced by process_text_line().

778 {
779  comment_buffer[0] = 0;
780  lline_buffer[0] = 0;
781 }
static char * lline_buffer
Definition: extconf.c:708
static char * comment_buffer
Definition: extconf.c:705

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

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

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

◆ destroy_exten()

static void destroy_exten ( struct ast_exten e)
static

Definition at line 3767 of file extconf.c.

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

Referenced by __ast_context_destroy().

3768 {
3769  if (e->priority == PRIORITY_HINT)
3770  ast_remove_hint(e);
3771 
3772  if (e->datad)
3773  e->datad(e->data);
3774  free(e);
3775 }
static int ast_remove_hint(struct ast_exten *e)
ast_remove_hint: Remove hint from extension
Definition: extconf.c:3735
int priority
Definition: pbx.c:243
void free()
void(* datad)(void *)
Definition: pbx.c:249
#define PRIORITY_HINT
Definition: extconf.c:2083
void * data
Definition: pbx.c:248

◆ ext_cmp()

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

the full routine to compare extensions in rules.

Definition at line 3946 of file extconf.c.

References ext_cmp1().

Referenced by ast_add_extension2().

3947 {
3948  /* make sure non-patterns come first.
3949  * If a is not a pattern, it either comes first or
3950  * we use strcmp to compare the strings.
3951  */
3952  int ret = 0;
3953 
3954  if (a[0] != '_')
3955  return (b[0] == '_') ? -1 : strcmp(a, b);
3956 
3957  /* Now we know a is a pattern; if b is not, a comes first */
3958  if (b[0] != '_')
3959  return 1;
3960 #if 0 /* old mode for ext matching */
3961  return strcmp(a, b);
3962 #endif
3963  /* ok we need full pattern sorting routine */
3964  while (!ret && a && b)
3965  ret = ext_cmp1(&a) - ext_cmp1(&b);
3966  if (ret == 0)
3967  return 0;
3968  else
3969  return (ret > 0) ? 1 : -1;
3970 }
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:3874
static struct test_val b
static struct test_val a

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

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

Referenced by ext_cmp().

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

◆ ext_strncpy()

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

copy a string skipping whitespace

Definition at line 3973 of file extconf.c.

References ast_check_timing().

Referenced by ast_add_extension2().

3974 {
3975  int count=0;
3976 
3977  while (*src && (count < len - 1)) {
3978  switch(*src) {
3979  case ' ':
3980  /* otherwise exten => [a-b],1,... doesn't work */
3981  /* case '-': */
3982  /* Ignore */
3983  break;
3984  default:
3985  *dst = *src;
3986  dst++;
3987  }
3988  src++;
3989  count++;
3990  }
3991  *dst = '\0';
3992 
3993  return count;
3994 }
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)

◆ extension_match_core()

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

Definition at line 4288 of file extconf.c.

References _extension_match_core(), and ast_extension_match().

Referenced by ast_extension_match(), and pbx_find_extension().

4289 {
4290  int i;
4291  i = _extension_match_core(pattern, data, mode);
4292  return i;
4293 }
static int _extension_match_core(const char *pattern, const char *data, enum ext_match_t mode)
Definition: extconf.c:4193

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

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

Referenced by ast_config_internal_load().

2750 {
2751  struct ast_config_engine *eng, *ret = NULL;
2752  struct ast_config_map *map;
2753 
2754 
2755  for (map = config_maps; map; map = map->next) {
2756  if (!strcasecmp(family, map->name)) {
2757  if (database)
2758  ast_copy_string(database, map->database, dbsiz);
2759  if (table)
2760  ast_copy_string(table, map->table ? map->table : family, tabsiz);
2761  break;
2762  }
2763  }
2764 
2765  /* Check if the required driver (engine) exist */
2766  if (map) {
2767  for (eng = config_engine_list; !ret && eng; eng = eng->next) {
2768  if (!strcasecmp(eng->name, map->driver))
2769  ret = eng;
2770  }
2771  }
2772 
2773 
2774  /* if we found a mapping, but the engine is not available, then issue a warning */
2775  if (map && !ret)
2776  ast_log(LOG_WARNING, "Realtime mapping for '%s' found to engine '%s', but the engine is not available\n", map->name, map->driver);
2777 
2778  return ret;
2779 }
struct ast_config_map * next
Definition: main/config.c:200
static int * map
Definition: misdn_config.c:438
const char * database
Definition: main/config.c:207
void ast_copy_string(char *dst, const char *src, size_t size)
Definition: extconf.c:970
#define NULL
Definition: resample.c:96
const char * table
Definition: main/config.c:209
static struct ast_config_map * config_maps
Configuration engine structure, used to define realtime drivers.
struct ast_config_engine * next
static char * table
Definition: cdr_odbc.c:58
static void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Definition: extconf.c:2195
static struct ast_config_engine * config_engine_list
Definition: extconf.c:893
#define LOG_WARNING
Definition: extconf.c:139
const char * name
Definition: main/config.c:203
const char * driver
Definition: main/config.c:205

◆ gen_header()

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

Definition at line 3390 of file extconf.c.

References ast_copy_string().

Referenced by localized_config_text_file_save().

3391 {
3392  char date[256]="";
3393  time_t t;
3394  time(&t);
3395  ast_copy_string(date, ctime(&t), sizeof(date));
3396 
3397  fprintf(f1, ";!\n");
3398  fprintf(f1, ";! Automatically generated configuration file\n");
3399  if (strcmp(configfile, fn))
3400  fprintf(f1, ";! Filename: %s (%s)\n", configfile, fn);
3401  else
3402  fprintf(f1, ";! Filename: %s\n", configfile);
3403  fprintf(f1, ";! Generator: %s\n", generator);
3404  fprintf(f1, ";! Creation Date: %s", date);
3405  fprintf(f1, ";!\n");
3406 }
void ast_copy_string(char *dst, const char *src, size_t size)
Definition: extconf.c:970
static struct ast_generator generator
Definition: app_fax.c:359

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

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

Referenced by ast_build_timing().

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

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

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

Referenced by ast_build_timing().

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

◆ include_valid()

static int include_valid ( struct ast_include i)
inlinestatic

Definition at line 4313 of file extconf.c.

References ast_check_timing(), ast_include::hastime, ast_exten::label, pbx_find_extension(), and ast_include::timing.

Referenced by pbx_find_extension().

4314 {
4315  if (!i->hastime)
4316  return 1;
4317 
4318  return ast_check_timing(&(i->timing));
4319 }
struct ast_timing timing
Definition: pbx_include.c:46
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:4002

◆ inherit_category()

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

Definition at line 2825 of file extconf.c.

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

Referenced by process_text_line().

2826 {
2827  struct ast_variable *var;
2828 
2829  for (var = base->root; var; var = var->next)
2831 }
struct ast_variable * next
static struct ast_variable * variable_clone(const struct ast_variable *old)
Definition: extconf.c:1249
Structure for variables, used for configurations and for channel variables.
#define var
Definition: ast_expr2f.c:614
struct ast_variable * root
Definition: main/config.c:240
static void ast_variable_append(struct ast_category *category, struct ast_variable *variable)
Definition: extconf.c:1178

◆ LLB_ADD()

static void LLB_ADD ( char *  str)
static

Definition at line 764 of file extconf.c.

References ast_realloc, and CB_INCR.

Referenced by config_text_file_load().

765 {
766  int rem = lline_buffer_size - strlen(lline_buffer) - 1;
767  int siz = strlen(str);
768  if (rem < siz+1) {
770  if (!lline_buffer)
771  return;
772  lline_buffer_size += CB_INCR + siz + 1;
773  }
774  strcat(lline_buffer,str);
775 }
#define ast_realloc(p, len)
A wrapper for realloc()
Definition: astmm.h:228
const char * str
Definition: app_jack.c:147
static int lline_buffer_size
Definition: extconf.c:709
static char * lline_buffer
Definition: extconf.c:708
#define CB_INCR
Definition: extconf.c:711

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

References ast_add_extension2(), and ast_exten::datad.

Referenced by ast_add_extension2().

4902 {
4903  return ast_add_extension2(con, replace, extension, priority, label, callerid, application, data, datad, registrar);
4904 }
static int priority
structure to hold extensions
static char * registrar
Definition: pbx_ael.c:78
static int replace(struct ast_channel *chan, const char *cmd, char *data, struct ast_str **buf, ssize_t len)
Definition: func_strings.c:790
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:4776

◆ localized_ast_include_rename()

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

Definition at line 1111 of file extconf.c.

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

1112 {
1113  struct ast_config_include *incl;
1114  struct ast_category *cat;
1115  struct ast_variable *v;
1116 
1117  int from_len = strlen(from_file);
1118  int to_len = strlen(to_file);
1119 
1120  if (strcmp(from_file, to_file) == 0) /* no use wasting time if the name is the same */
1121  return;
1122 
1123  /* the manager code allows you to read in one config file, then
1124  write it back out under a different name. But, the new arrangement
1125  ties output lines to the file name. So, before you try to write
1126  the config file to disk, better riffle thru the data and make sure
1127  the file names are changed.
1128  */
1129  /* file names are on categories, includes (of course), and on variables. So,
1130  traverse all this and swap names */
1131 
1132  for (incl = conf->includes; incl; incl=incl->next) {
1133  if (strcmp(incl->include_location_file,from_file) == 0) {
1134  if (from_len >= to_len)
1135  strcpy(incl->include_location_file, to_file);
1136  else {
1137  free(incl->include_location_file);
1138  incl->include_location_file = strdup(to_file);
1139  }
1140  }
1141  }
1142  for (cat = conf->root; cat; cat = cat->next) {
1143  if (strcmp(cat->file,from_file) == 0) {
1144  if (from_len >= to_len)
1145  strcpy(cat->file, to_file);
1146  else {
1147  free(cat->file);
1148  cat->file = strdup(to_file);
1149  }
1150  }
1151  for (v = cat->root; v; v = v->next) {
1152  if (strcmp(v->file,from_file) == 0) {
1153  if (from_len >= to_len)
1154  strcpy(v->file, to_file);
1155  else {
1156  free(v->file);
1157  v->file = strdup(to_file);
1158  }
1159  }
1160  }
1161  }
1162 }
struct ast_variable * next
struct ast_category * next
Definition: main/config.c:246
char * file
The file name from whence this declaration was read.
Definition: main/config.c:233
char * include_location_file
file name in which the include occurs
Definition: main/config.c:266
struct ast_config_include * includes
Definition: main/config.c:258
Structure for variables, used for configurations and for channel variables.
void free()
struct ast_variable * root
Definition: main/config.c:240
struct ast_config_include * next
Definition: main/config.c:282
struct ast_category * root
Definition: main/config.c:251
#define strdup(a)
Definition: astmm.h:165

◆ localized_category_get()

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

Definition at line 2803 of file extconf.c.

References category_get().

Referenced by ast_category_new().

2804 {
2805  return category_get(config, category_name, 0);
2806 }
static struct ast_category * category_get(const struct ast_config *config, const char *category_name, int ignored)
Definition: extconf.c:1193

◆ localized_config_load()

struct ast_config* localized_config_load ( const char *  filename)

Definition at line 3287 of file extconf.c.

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

Referenced by ast_config_new(), and pbx_load_config().

3288 {
3289  struct ast_config *cfg;
3290  struct ast_config *result;
3291 
3292  cfg = ast_config_new();
3293  if (!cfg)
3294  return NULL;
3295 
3296  result = ast_config_internal_load(filename, cfg, 0, "");
3297  if (!result)
3298  ast_config_destroy(cfg);
3299 
3300  return result;
3301 }
static void ast_config_destroy(struct ast_config *cfg)
Definition: extconf.c:1290
#define NULL
Definition: resample.c:96
static struct ast_config * ast_config_new(void)
Definition: extconf.c:3276
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:2864
static PGresult * result
Definition: cel_pgsql.c:88

◆ localized_config_load_with_comments()

struct ast_config* localized_config_load_with_comments ( const char *  filename)

Definition at line 3305 of file extconf.c.

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

Referenced by localized_config_load().

3306 {
3307  struct ast_config *cfg;
3308  struct ast_config *result;
3309 
3310  cfg = ast_config_new();
3311  if (!cfg)
3312  return NULL;
3313 
3314  result = ast_config_internal_load(filename, cfg, 1, "");
3315  if (!result)
3316  ast_config_destroy(cfg);
3317 
3318  return result;
3319 }
static void ast_config_destroy(struct ast_config *cfg)
Definition: extconf.c:1290
#define NULL
Definition: resample.c:96
static struct ast_config * ast_config_new(void)
Definition: extconf.c:3276
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:2864
static PGresult * result
Definition: cel_pgsql.c:88

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

References ast_log(), ast_verbose(), ast_variable::blanklines, ast_comment::cmt, errno, ast_config_include::exec, ast_config_include::exec_file, ast_variable::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_variable::lineno, ast_category::lineno, LOG_DEBUG, ast_variable::name, ast_category::name, ast_comment::next, ast_variable::next, ast_category::next, ast_config_include::next, ast_variable::object, ast_config_include::output, ast_variable::precomments, ast_category::precomments, ast_category::root, ast_config::root, ast_variable::sameline, ast_category::sameline, set_fn(), ast_variable::value, var, and VERBOSE_PREFIX_2.

Referenced by set_fn().

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

◆ localized_context_add_ignorepat2()

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

Definition at line 4601 of file extconf.c.

References ast_context_add_ignorepat2().

Referenced by ast_context_add_ignorepat2().

4602 {
4604 }
static int ast_context_add_ignorepat2(struct ast_context *con, const char *value, const char *registrar)
Definition: extconf.c:4569
int value
Definition: syslog.c:37
static char * registrar
Definition: pbx_ael.c:78

◆ localized_context_add_include2()

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

Definition at line 4559 of file extconf.c.

References ast_context_add_ignorepat2(), and ast_context_add_include2().

Referenced by ast_context_add_include2().

4561 {
4563 }
int value
Definition: syslog.c:37
static char * registrar
Definition: pbx_ael.c:78
static int ast_context_add_include2(struct ast_context *con, const char *value, const char *registrar)
Definition: extconf.c:4503

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

References ast_context_add_switch2().

Referenced by ast_context_add_switch2().

4704 {
4705  return ast_context_add_switch2(con, value, data, eval, registrar);
4706 }
int value
Definition: syslog.c:37
static char * registrar
Definition: pbx_ael.c:78
static int ast_context_add_switch2(struct ast_context *con, const char *value, const char *data, int eval, const char *registrar)
Definition: extconf.c:4641

◆ localized_context_destroy()

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

Definition at line 5565 of file extconf.c.

References __ast_context_destroy(), ast_unlock_contexts(), and ast_wrlock_contexts().

Referenced by __ast_context_destroy(), and ast_context_destroy().

5566 {
5570 }
static int ast_unlock_contexts(void)
Definition: extconf.c:4616
static char * registrar
Definition: pbx_ael.c:78
static void __ast_context_destroy(struct ast_context *con, const char *registrar)
Definition: extconf.c:5504
static int ast_wrlock_contexts(void)
Definition: extconf.c:4611

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

References __ast_context_create().

Referenced by ast_context_find_or_create().

4990 {
4991  return __ast_context_create(extcontexts, name, registrar, 1);
4992 }
static struct ast_context * __ast_context_create(struct ast_context **extcontexts, const char *name, const char *registrar, int existsokay)
Definition: extconf.c:4708
static char * registrar
Definition: pbx_ael.c:78
static const char name[]
Definition: cdr_mysql.c:74

◆ localized_context_verify_includes()

int localized_context_verify_includes ( struct ast_context con)

Definition at line 5640 of file extconf.c.

References ast_context_verify_includes(), and localized_pbx_load_module().

Referenced by ast_context_verify_includes().

5641 {
5642  return ast_context_verify_includes(con);
5643 }
static int ast_context_verify_includes(struct ast_context *con)
Definition: extconf.c:5623

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

References NULL, and pbx_find_extension().

Referenced by pbx_find_extension().

4478 {
4479  return pbx_find_extension(NULL, bypass, q, context, exten, priority, label, callerid, action);
4480 }
static char exten[AST_MAX_EXTENSION]
Definition: chan_alsa.c:118
#define NULL
Definition: resample.c:96
static int priority
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:4334
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:116

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

References ast_merge_contexts_and_delete().

Referenced by ast_merge_contexts_and_delete().

5619 {
5621 }
static char * registrar
Definition: pbx_ael.c:78
static void ast_merge_contexts_and_delete(struct ast_context **extcontexts, const char *registrar)
Definition: extconf.c:5573

◆ localized_pbx_builtin_setvar()

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

Definition at line 2607 of file extconf.c.

References pbx_builtin_setvar().

Referenced by pbx_builtin_setvar().

2608 {
2609  return pbx_builtin_setvar(chan, data);
2610 }
static int pbx_builtin_setvar(struct ast_channel *chan, const void *data)
Definition: extconf.c:2570

◆ localized_pbx_load_module()

int localized_pbx_load_module ( void  )

Definition at line 5647 of file extconf.c.

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

Referenced by check_goto(), check_pval_item(), localized_context_verify_includes(), and main().

5648 {
5649  struct ast_context *con;
5650 
5652  return -1 /* AST_MODULE_LOAD_DECLINE*/;
5653 
5654  /* pbx_load_users(); */ /* does this affect the dialplan? */
5655 
5657 
5658  for (con = NULL; (con = ast_walk_contexts(con));)
5660 
5661  printf("=== Loading extensions.conf ===\n");
5662  con = 0;
5663  while ((con = ast_walk_contexts(con)) ) {
5664  printf("Context: %s\n", con->name);
5665  }
5666  printf("=========\n");
5667 
5668  return 0;
5669 }
static char * global_registrar
Definition: extconf.c:2122
#define NULL
Definition: resample.c:96
static struct ast_context * ast_walk_contexts(struct ast_context *con)
Definition: extconf.c:4026
static char * config_filename
Definition: extconf.c:2121
static struct ast_context * local_contexts
Definition: extconf.c:3598
char name[0]
Definition: pbx.c:297
static int ast_context_verify_includes(struct ast_context *con)
Definition: extconf.c:5623
static void ast_merge_contexts_and_delete(struct ast_context **extcontexts, const char *registrar)
Definition: extconf.c:5573
ast_context: An extension context - must remain in sync with fake_context
Definition: pbx.c:284
static int pbx_load_config(const char *config_file)
Definition: extconf.c:5339

◆ localized_use_conf_dir()

void localized_use_conf_dir ( void  )

Definition at line 3115 of file extconf.c.

Referenced by main().

3116 {
3117  use_local_dir = 0;
3118 }
static int use_local_dir
Definition: extconf.c:3105

◆ localized_use_local_dir()

void localized_use_local_dir ( void  )

Definition at line 3110 of file extconf.c.

Referenced by main().

3111 {
3112  use_local_dir = 1;
3113 }
static int use_local_dir
Definition: extconf.c:3105

◆ localized_walk_context_extensions()

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

Definition at line 4053 of file extconf.c.

References ast_walk_context_extensions(), and ast_walk_extension_priorities().

Referenced by ast_walk_context_extensions(), and main().

4055 {
4056  return ast_walk_context_extensions(con,exten);
4057 }
static struct ast_exten * ast_walk_context_extensions(struct ast_context *con, struct ast_exten *exten)
Definition: extconf.c:4042

◆ localized_walk_context_includes()

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

Definition at line 4106 of file extconf.c.

References ast_walk_context_ignorepats(), and ast_walk_context_includes().

Referenced by ast_context_includes_count().

4108 {
4109  return ast_walk_context_includes(con, inc);
4110 }
static struct ast_include * ast_walk_context_includes(struct ast_context *con, struct ast_include *inc)
Definition: extconf.c:4082

◆ localized_walk_context_switches()

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

Definition at line 4152 of file extconf.c.

References ast_context_switches_count(), and ast_walk_context_switches().

Referenced by ast_walk_context_switches(), and main().

4154 {
4155  return ast_walk_context_switches(con, sw);
4156 }
static struct ast_sw * ast_walk_context_switches(struct ast_context *con, struct ast_sw *sw)
Definition: extconf.c:4141

◆ localized_walk_contexts()

struct ast_context* localized_walk_contexts ( struct ast_context con)

Definition at line 4032 of file extconf.c.

References ast_walk_context_extensions(), and ast_walk_contexts().

Referenced by ast_walk_contexts(), and main().

4033 {
4034  return ast_walk_contexts(con);
4035 }
static struct ast_context * ast_walk_contexts(struct ast_context *con)
Definition: extconf.c:4026

◆ localized_walk_extension_priorities()

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

Definition at line 4071 of file extconf.c.

References ast_walk_context_includes(), and ast_walk_extension_priorities().

Referenced by ast_walk_extension_priorities(), and main().

4073 {
4074  return ast_walk_extension_priorities(exten, priority);
4075 }
static struct ast_exten * ast_walk_extension_priorities(struct ast_exten *exten, struct ast_exten *priority)
Definition: extconf.c:4063

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

Referenced by get_range().

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

◆ matchcid()

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

Definition at line 4302 of file extconf.c.

References ast_extension_match(), and ast_strlen_zero().

Referenced by pbx_find_extension().

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

◆ move_variables()

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

Definition at line 2808 of file extconf.c.

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

Referenced by process_text_line().

2809 {
2810  struct ast_variable *var = old->root;
2811  old->root = NULL;
2812 #if 1
2813  /* we can just move the entire list in a single op */
2814  ast_variable_append(new, var);
2815 #else
2816  while (var) {
2817  struct ast_variable *next = var->next;
2818  var->next = NULL;
2819  ast_variable_append(new, var);
2820  var = next;
2821  }
2822 #endif
2823 }
struct ast_variable * next
Structure for variables, used for configurations and for channel variables.
#define var
Definition: ast_expr2f.c:614
#define NULL
Definition: resample.c:96
struct ast_variable * root
Definition: main/config.c:240
static void ast_variable_append(struct ast_category *category, struct ast_variable *variable)
Definition: extconf.c:1178

◆ next_available_category()

static struct ast_category* next_available_category ( struct ast_category cat)
static

Definition at line 3321 of file extconf.c.

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

Referenced by ast_category_browse().

3322 {
3323  for (; cat && cat->ignored; cat = cat->next);
3324 
3325  return cat;
3326 }
struct ast_category * next
Definition: main/config.c:246

◆ null_datad()

static void null_datad ( void *  foo)
static

Definition at line 2744 of file extconf.c.

Referenced by ast_add_extension2().

2745 {
2746 }

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

References var.

Referenced by pbx_retrieve_variable(), and pbx_substitute_variables_helper_full().

5007 {
5008  int parens=0;
5009 
5010  *offset = 0;
5011  *length = INT_MAX;
5012  *isfunc = 0;
5013  for (; *var; var++) {
5014  if (*var == '(') {
5015  (*isfunc)++;
5016  parens++;
5017  } else if (*var == ')') {
5018  parens--;
5019  } else if (*var == ':' && parens == 0) {
5020  *var++ = '\0';
5021  sscanf(var, "%30d:%30d", offset, length);
5022  return 1; /* offset:length valid */
5023  }
5024  }
5025  return 0;
5026 }
#define var
Definition: ast_expr2f.c:614

◆ pbx_builtin_setvar()

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

Definition at line 2570 of file extconf.c.

References ast_app_separate_args(), ast_log(), ast_strdupa, ast_strlen_zero(), ast_channel::data, global, localized_pbx_builtin_setvar(), LOG_WARNING, ast_channel::name, NULL, pbx_builtin_setvar_helper(), value, and ast_channel::x.

Referenced by localized_pbx_builtin_setvar().

2571 {
2572  char *name, *value, *mydata;
2573  int argc;
2574  char *argv[24]; /* this will only support a maximum of 24 variables being set in a single operation */
2575  int global = 0;
2576  int x;
2577 
2578  if (ast_strlen_zero(data)) {
2579  ast_log(LOG_WARNING, "Set requires at least one variable name/value pair.\n");
2580  return 0;
2581  }
2582 
2583  mydata = ast_strdupa(data);
2584  argc = ast_app_separate_args(mydata, '|', argv, sizeof(argv) / sizeof(argv[0]));
2585 
2586  /* check for a trailing flags argument */
2587  if ((argc > 1) && !strchr(argv[argc-1], '=')) {
2588  argc--;
2589  if (strchr(argv[argc], 'g'))
2590  global = 1;
2591  }
2592 
2593  for (x = 0; x < argc; x++) {
2594  name = argv[x];
2595  if ((value = strchr(name, '='))) {
2596  *value++ = '\0';
2597  pbx_builtin_setvar_helper((global) ? NULL : chan, name, value);
2598  } else
2599  ast_log(LOG_WARNING, "Ignoring entry '%s' with no = (and not last 'options' entry)\n", name);
2600  }
2601 
2602  return(0);
2603 }
static struct aco_type global
Definition: test_config.c:1445
static unsigned int ast_app_separate_args(char *buf, char delim, char **array, int arraylen)
Definition: extconf.c:2488
#define NULL
Definition: resample.c:96
int value
Definition: syslog.c:37
static void pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Definition: extconf.c:2530
static force_inline int ast_strlen_zero(const char *s)
Definition: extconf.c:952
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
static void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Definition: extconf.c:2195
#define LOG_WARNING
Definition: extconf.c:139
static const char name[]
Definition: cdr_mysql.c:74

◆ pbx_builtin_setvar_helper()

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

Definition at line 2530 of file extconf.c.

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

Referenced by pbx_builtin_setvar(), and pbx_load_config().

2531 {
2532  struct ast_var_t *newvariable;
2533  struct varshead *headp;
2534  const char *nametail = name;
2535 
2536  /* XXX may need locking on the channel ? */
2537  if (name[strlen(name)-1] == ')') {
2538  char *function = ast_strdupa(name);
2539 
2540  ast_func_write(chan, function, value);
2541  return;
2542  }
2543 
2544  headp = &globals;
2545 
2546  /* For comparison purposes, we have to strip leading underscores */
2547  if (*nametail == '_') {
2548  nametail++;
2549  if (*nametail == '_')
2550  nametail++;
2551  }
2552 
2553  AST_LIST_TRAVERSE (headp, newvariable, entries) {
2554  if (strcasecmp(ast_var_name(newvariable), nametail) == 0) {
2555  /* there is already such a variable, delete it */
2556  AST_LIST_REMOVE(headp, newvariable, entries);
2557  ast_var_delete(newvariable);
2558  break;
2559  }
2560  }
2561 
2562  if (value && (newvariable = ast_var_assign(name, value))) {
2563  if ((option_verbose > 1) && (headp == &globals))
2564  ast_verbose(VERBOSE_PREFIX_2 "Setting global variable '%s' to '%s'\n", name, value);
2565  AST_LIST_INSERT_HEAD(headp, newvariable, entries);
2566  }
2567 
2568 }
static struct varshead globals
Definition: extconf.c:2069
static int ast_func_write(struct ast_channel *chan, const char *function, const char *value)
Definition: extconf.c:2480
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: extconf.c:1774
int option_verbose
Definition: options.c:67
void ast_verbose(const char *fmt,...)
Definition: extconf.c:2207
int value
Definition: syslog.c:37
#define AST_LIST_INSERT_HEAD(head, elm, field)
Inserts a list entry at the head of a list.
Definition: extconf.c:1957
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
#define VERBOSE_PREFIX_2
Definition: extconf.c:101
static const char * ast_var_name(const struct ast_var_t *var)
Definition: extconf.c:2171
static const char name[]
Definition: cdr_mysql.c:74
static struct ast_var_t * ast_var_assign(const char *name, const char *value)
Definition: extconf.c:2456
static void ast_var_delete(struct ast_var_t *var)
Definition: extconf.c:2473
#define AST_LIST_REMOVE(head, elm, field)
Removes a specific entry from a list.
Definition: extconf.c:2038

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

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

Referenced by ast_findlabel_extension2().

4920 {
4921  struct ast_exten *e;
4922  int res;
4923  struct pbx_find_info q = { .stacklen = 0 }; /* the rest is reset in pbx_find_extension */
4924 
4925  int matching_action = (action == E_MATCH || action == E_CANMATCH || action == E_MATCHMORE);
4926 
4927  e = pbx_find_extension(NULL, con, &q, context, exten, priority, label, callerid, action);
4928  if (e) {
4929  if (matching_action) {
4930  return -1; /* success, we found it */
4931  } else if (action == E_FINDLABEL) { /* map the label to a priority */
4932  res = e->priority;
4933  return res; /* the priority we were looking for */
4934  } else { /* spawn */
4935 
4936  /* NOT!!!!! */
4937  return 0;
4938  }
4939  } else if (q.swo) { /* not found here, but in another switch */
4940  if (matching_action)
4941  return -1;
4942  else {
4943  if (!q.swo->exec) {
4944  ast_log(LOG_WARNING, "No execution engine for switch %s\n", q.swo->name);
4945  res = -1;
4946  }
4947  return q.swo->exec(c, q.foundcontext ? q.foundcontext : context, exten, priority, callerid, q.data);
4948  }
4949  } else { /* not found anywhere, see what happened */
4950  switch (q.status) {
4951  case STATUS_NO_CONTEXT:
4952  if (!matching_action)
4953  ast_log(LOG_NOTICE, "Cannot find extension context '%s'\n", context);
4954  break;
4955  case STATUS_NO_EXTENSION:
4956  if (!matching_action)
4957  ast_log(LOG_NOTICE, "Cannot find extension '%s' in context '%s'\n", exten, context);
4958  break;
4959  case STATUS_NO_PRIORITY:
4960  if (!matching_action)
4961  ast_log(LOG_NOTICE, "No such priority %d in extension '%s' in context '%s'\n", priority, exten, context);
4962  break;
4963  case STATUS_NO_LABEL:
4964  if (context)
4965  ast_log(LOG_NOTICE, "No such label '%s' in extension '%s' in context '%s'\n", label, exten, context);
4966  break;
4967  default:
4968  if (option_debug)
4969  ast_log(LOG_DEBUG, "Shouldn't happen!\n");
4970  }
4971 
4972  return (matching_action) ? 0 : -1;
4973  }
4974 }
static char exten[AST_MAX_EXTENSION]
Definition: chan_alsa.c:118
ast_exten: An extension The dialplan is saved as a linked list with each context having it&#39;s own link...
Definition: pbx.c:237
#define STATUS_NO_LABEL
Definition: extconf.c:2453
#define STATUS_NO_EXTENSION
Definition: extconf.c:2451
ast_switch_f * exec
Definition: pbx.h:167
int option_debug
Definition: options.c:69
#define NULL
Definition: resample.c:96
static int priority
const char * name
Definition: pbx.h:162
int priority
Definition: pbx.c:243
const char * data
Definition: extconf.h:241
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:4334
static void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Definition: extconf.c:2195
#define LOG_WARNING
Definition: extconf.c:139
#define STATUS_NO_PRIORITY
Definition: extconf.c:2452
const char * foundcontext
Definition: extconf.h:242
int stacklen
Definition: extconf.h:238
#define LOG_DEBUG
Definition: extconf.c:121
struct ast_switch * swo
Definition: extconf.h:240
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:116
#define STATUS_NO_CONTEXT
Definition: extconf.c:2450
#define LOG_NOTICE
Definition: extconf.c:133

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

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, context, ast_sw::data, pbx_find_info::data, E_CANMATCH, E_FINDLABEL, E_MATCHMORE, ast_sw::eval, 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, localized_find_extension(), LOG_WARNING, match(), ast_exten::matchcid, matchcid(), ast_switch::matchmore, ast_sw::name, ast_context::name, ast_include::next, NULL, pbx_findswitch(), 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, pbx_find_info::swo, tmp(), ast_sw::tmpdata, and ast_channel::x.

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

4343 {
4344  int x;
4345  struct ast_context *tmp;
4346  struct ast_exten *e, *eroot;
4347  struct ast_include *i;
4348 
4349  if (!context) {
4350  return NULL;
4351  }
4352 
4353  /* Initialize status if appropriate */
4354  if (q->stacklen == 0) {
4356  q->swo = NULL;
4357  q->data = NULL;
4358  q->foundcontext = NULL;
4359  } else if (q->stacklen >= AST_PBX_MAX_STACK) {
4360  ast_log(LOG_WARNING, "Maximum PBX stack exceeded\n");
4361  return NULL;
4362  }
4363  /* Check first to see if we've already been checked */
4364  for (x = 0; x < q->stacklen; x++) {
4365  if (!strcasecmp(q->incstack[x], context))
4366  return NULL;
4367  }
4368  if (bypass) /* bypass means we only look there */
4369  tmp = bypass;
4370  else { /* look in contexts */
4371  tmp = NULL;
4372  while ((tmp = ast_walk_contexts(tmp)) ) {
4373  if (!strcmp(tmp->name, context))
4374  break;
4375  }
4376  if (!tmp)
4377  return NULL;
4378  }
4379  if (q->status < STATUS_NO_EXTENSION)
4381 
4382  /* scan the list trying to match extension and CID */
4383  eroot = NULL;
4384  while ( (eroot = ast_walk_context_extensions(tmp, eroot)) ) {
4385  int match = extension_match_core(eroot->exten, exten, action);
4386  /* 0 on fail, 1 on match, 2 on earlymatch */
4387 
4388  if (!match || (eroot->matchcid && !matchcid(eroot->cidmatch, callerid)))
4389  continue; /* keep trying */
4390  if (match == 2 && action == E_MATCHMORE) {
4391  /* We match an extension ending in '!'.
4392  * The decision in this case is final and is NULL (no match).
4393  */
4394  return NULL;
4395  }
4396  /* found entry, now look for the right priority */
4397  if (q->status < STATUS_NO_PRIORITY)
4399  e = NULL;
4400  while ( (e = ast_walk_extension_priorities(eroot, e)) ) {
4401  /* Match label or priority */
4402  if (action == E_FINDLABEL) {
4403  if (q->status < STATUS_NO_LABEL)
4404  q->status = STATUS_NO_LABEL;
4405  if (label && e->label && !strcmp(label, e->label))
4406  break; /* found it */
4407  } else if (e->priority == priority) {
4408  break; /* found it */
4409  } /* else keep searching */
4410  }
4411  if (e) { /* found a valid match */
4412  q->status = STATUS_SUCCESS;
4413  q->foundcontext = context;
4414  return e;
4415  }
4416  }
4417 #ifdef NOT_RIGHT_NOW
4418  /* Check alternative switches??? */
4419  AST_LIST_TRAVERSE(&tmp->alts, sw, list) {
4420  struct ast_switch *asw = pbx_findswitch(sw->name);
4421  ast_switch_f *aswf = NULL;
4422  char *datap;
4423 
4424  if (!asw) {
4425  ast_log(LOG_WARNING, "No such switch '%s'\n", sw->name);
4426  continue;
4427  }
4428  /* No need to Substitute variables now; we shouldn't be here if there's any */
4429 
4430  /* equivalent of extension_match_core() at the switch level */
4431  if (action == E_CANMATCH)
4432  aswf = asw->canmatch;
4433  else if (action == E_MATCHMORE)
4434  aswf = asw->matchmore;
4435  else /* action == E_MATCH */
4436  aswf = asw->exists;
4437  datap = sw->eval ? sw->tmpdata : sw->data;
4438  res = !aswf ? 0 : aswf(chan, context, exten, priority, callerid, datap);
4439  if (res) { /* Got a match */
4440  q->swo = asw;
4441  q->data = datap;
4442  q->foundcontext = context;
4443  /* XXX keep status = STATUS_NO_CONTEXT ? */
4444  return NULL;
4445  }
4446  }
4447 #endif
4448  q->incstack[q->stacklen++] = tmp->name; /* Setup the stack */
4449  /* Now try any includes we have in this context */
4450  for (i = tmp->includes; i; i = i->next) {
4451  if (include_valid(i)) {
4452  if ((e = pbx_find_extension(NULL, bypass, q, i->rname, exten, priority, label, callerid, action)))
4453  return e;
4454  if (q->swo)
4455  return NULL;
4456  }
4457  }
4458  return NULL;
4459 }
const char * label
Definition: pbx.c:244
ast_include: include= support in extensions.conf
Definition: pbx_include.c:37
static struct ast_exten * ast_walk_extension_priorities(struct ast_exten *exten, struct ast_exten *priority)
Definition: extconf.c:4063
static char exten[AST_MAX_EXTENSION]
Definition: chan_alsa.c:118
ast_exten: An extension The dialplan is saved as a linked list with each context having it&#39;s own link...
Definition: pbx.c:237
#define STATUS_NO_LABEL
Definition: extconf.c:2453
#define STATUS_NO_EXTENSION
Definition: extconf.c:2451
ast_switch_f * matchmore
Definition: pbx.h:168
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: extconf.c:1774
static int tmp()
Definition: bt_open.c:389
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:2315
struct ast_include * next
Definition: conf2ael.c:151
#define NULL
Definition: resample.c:96
char * incstack[AST_PBX_MAX_STACK]
Definition: extconf.h:237
static struct ast_context * ast_walk_contexts(struct ast_context *con)
Definition: extconf.c:4026
static int priority
ast_switch_f * exists
Definition: pbx.h:165
ast_switch_f * canmatch
Definition: pbx.h:166
int matchcid
Definition: pbx.c:240
static int include_valid(struct ast_include *i)
Definition: extconf.c:4313
int priority
Definition: pbx.c:243
const char * data
Definition: extconf.h:241
struct ast_switch * pbx_findswitch(const char *sw)
Definition: pbx_switch.c:40
static int matchcid(const char *cidpattern, const char *callerid)
Definition: extconf.c:4302
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:4334
static void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Definition: extconf.c:2195
struct ast_includes includes
Definition: pbx.c:290
#define LOG_WARNING
Definition: extconf.c:139
char * exten
Definition: pbx.c:238
#define STATUS_NO_PRIORITY
Definition: extconf.c:2452
char name[0]
Definition: pbx.c:297
#define AST_PBX_MAX_STACK
Definition: extconf.h:226
static struct ast_exten * ast_walk_context_extensions(struct ast_context *con, struct ast_exten *exten)
Definition: extconf.c:4042
const char * foundcontext
Definition: extconf.h:242
int stacklen
Definition: extconf.h:238
const char * cidmatch
Definition: pbx.c:241
const char * rname
Definition: pbx_include.c:40
#define STATUS_SUCCESS
Definition: extconf.c:2454
static int extension_match_core(const char *pattern, const char *data, enum ext_match_t mode)
Definition: extconf.c:4288
struct ast_switch * swo
Definition: extconf.h:240
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:2106
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:116
struct ast_sws alts
Definition: pbx.c:292
ast_context: An extension context - must remain in sync with fake_context
Definition: pbx.c:284
#define STATUS_NO_CONTEXT
Definition: extconf.c:2450

◆ pbx_load_config()

static int pbx_load_config ( const char *  config_file)
static

Definition at line 5339 of file extconf.c.

References ast_channel::appl, 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(), ast_channel::data, end, ext, free(), ast_variable::lineno, localized_config_load(), LOG_WARNING, ast_variable::name, ast_variable::next, NULL, pbx_builtin_setvar_helper(), pbx_substitute_variables_helper(), PRIORITY_HINT, S_OR, strdup, strsep(), and ast_variable::value.

Referenced by localized_pbx_load_module(), and pbx_substitute_variables_helper().

5340 {
5341  struct ast_config *cfg;
5342  char *end;
5343  char *label;
5344  char realvalue[256];
5345  int lastpri = -2;
5346  struct ast_context *con;
5347  struct ast_variable *v;
5348  const char *cxt;
5349  const char *aft;
5350 
5352  if (!cfg)
5353  return 0;
5354 
5355  /* Use existing config to populate the PBX table */
5356  static_config = ast_true(ast_variable_retrieve(cfg, "general", "static"));
5357  write_protect_config = ast_true(ast_variable_retrieve(cfg, "general", "writeprotect"));
5358  if ((aft = ast_variable_retrieve(cfg, "general", "autofallthrough")))
5360  clearglobalvars_config = ast_true(ast_variable_retrieve(cfg, "general", "clearglobalvars"));
5361 
5362  if ((cxt = ast_variable_retrieve(cfg, "general", "userscontext")))
5363  ast_copy_string(userscontext, cxt, sizeof(userscontext));
5364  else
5365  ast_copy_string(userscontext, "default", sizeof(userscontext));
5366 
5367  for (v = ast_variable_browse(cfg, "globals"); v; v = v->next) {
5368  memset(realvalue, 0, sizeof(realvalue));
5369  pbx_substitute_variables_helper(NULL, v->value, realvalue, sizeof(realvalue) - 1);
5370  pbx_builtin_setvar_helper(NULL, v->name, realvalue);
5371  }
5372  for (cxt = NULL; (cxt = ast_category_browse(cfg, cxt)); ) {
5373  /* All categories but "general" or "globals" are considered contexts */
5374  if (!strcasecmp(cxt, "general") || !strcasecmp(cxt, "globals"))
5375  continue;
5377  if (con == NULL)
5378  continue;
5379 
5380  for (v = ast_variable_browse(cfg, cxt); v; v = v->next) {
5381  if (!strcasecmp(v->name, "exten")) {
5382  char *tc = ast_strdup(v->value);
5383  if (tc) {
5384  int ipri = -2;
5385  char realext[256]="";
5386  char *plus, *firstp, *firstc;
5387  char *pri, *appl, *data, *cidmatch;
5388  char *stringp = tc;
5389  char *ext = strsep(&stringp, ",");
5390  if (!ext)
5391  ext="";
5392  pbx_substitute_variables_helper(NULL, ext, realext, sizeof(realext) - 1);
5393  cidmatch = strchr(realext, '/');
5394  if (cidmatch) {
5395  *cidmatch++ = '\0';
5396  ast_shrink_phone_number(cidmatch);
5397  }
5398  pri = strsep(&stringp, ",");
5399  if (!pri)
5400  pri="";
5401  label = strchr(pri, '(');
5402  if (label) {
5403  *label++ = '\0';
5404  end = strchr(label, ')');
5405  if (end)
5406  *end = '\0';
5407  else
5408  ast_log(LOG_WARNING, "Label missing trailing ')' at line %d\n", v->lineno);
5409  }
5410  plus = strchr(pri, '+');
5411  if (plus)
5412  *plus++ = '\0';
5413  if (!strcmp(pri,"hint"))
5414  ipri=PRIORITY_HINT;
5415  else if (!strcmp(pri, "next") || !strcmp(pri, "n")) {
5416  if (lastpri > -2)
5417  ipri = lastpri + 1;
5418  else
5419  ast_log(LOG_WARNING, "Can't use 'next' priority on the first entry!\n");
5420  } else if (!strcmp(pri, "same") || !strcmp(pri, "s")) {
5421  if (lastpri > -2)
5422  ipri = lastpri;
5423  else
5424  ast_log(LOG_WARNING, "Can't use 'same' priority on the first entry!\n");
5425  } else if (sscanf(pri, "%30d", &ipri) != 1 &&
5426  (ipri = ast_findlabel_extension2(NULL, con, realext, pri, cidmatch)) < 1) {
5427  ast_log(LOG_WARNING, "Invalid priority/label '%s' at line %d\n", pri, v->lineno);
5428  ipri = 0;
5429  }
5430  appl = S_OR(stringp, "");
5431  /* Find the first occurrence of either '(' or ',' */
5432  firstc = strchr(appl, ',');
5433  firstp = strchr(appl, '(');
5434  if (firstc && (!firstp || firstc < firstp)) {
5435  /* comma found, no parenthesis */
5436  /* or both found, but comma found first */
5437  appl = strsep(&stringp, ",");
5438  data = stringp;
5439  } else if (!firstc && !firstp) {
5440  /* Neither found */
5441  data = "";
5442  } else {
5443  /* Final remaining case is parenthesis found first */
5444  appl = strsep(&stringp, "(");
5445  data = stringp;
5446  end = strrchr(data, ')');
5447  if ((end = strrchr(data, ')'))) {
5448  *end = '\0';
5449  } else {
5450  ast_log(LOG_WARNING, "No closing parenthesis found? '%s(%s'\n", appl, data);
5451  }
5452  ast_process_quotes_and_slashes(data, ',', '|');
5453  }
5454 
5455  if (!data)
5456  data="";
5457  appl = ast_skip_blanks(appl);
5458  if (ipri) {
5459  if (plus)
5460  ipri += atoi(plus);
5461  lastpri = ipri;
5462  if (!ast_opt_dont_warn && !strcmp(realext, "_."))
5463  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);
5464  if (ast_add_extension2(con, 0, realext, ipri, label, cidmatch, appl, strdup(data), ast_free_ptr, global_registrar)) {
5465  ast_log(LOG_WARNING, "Unable to register extension at line %d\n", v->lineno);
5466  }
5467  }
5468  free(tc);
5469  }
5470  } else if (!strcasecmp(v->name, "include")) {
5471  memset(realvalue, 0, sizeof(realvalue));
5472  pbx_substitute_variables_helper(NULL, v->value, realvalue, sizeof(realvalue) - 1);
5473  if (ast_context_add_include2(con, realvalue, global_registrar))
5474  ast_log(LOG_WARNING, "Unable to include context '%s' in context '%s'\n", v->value, cxt);
5475  } else if (!strcasecmp(v->name, "ignorepat")) {
5476  memset(realvalue, 0, sizeof(realvalue));
5477  pbx_substitute_variables_helper(NULL, v->value, realvalue, sizeof(realvalue) - 1);
5478  if (ast_context_add_ignorepat2(con, realvalue, global_registrar))
5479  ast_log(LOG_WARNING, "Unable to include ignorepat '%s' in context '%s'\n", v->value, cxt);
5480  } else if (!strcasecmp(v->name, "switch") || !strcasecmp(v->name, "lswitch") || !strcasecmp(v->name, "eswitch")) {
5481  char *stringp= realvalue;
5482  char *appl, *data;
5483 
5484  memset(realvalue, 0, sizeof(realvalue));
5485  if (!strcasecmp(v->name, "switch"))
5486  pbx_substitute_variables_helper(NULL, v->value, realvalue, sizeof(realvalue) - 1);
5487  else
5488  ast_copy_string(realvalue, v->value, sizeof(realvalue));
5489  appl = strsep(&stringp, "/");
5490  data = strsep(&stringp, ""); /* XXX what for ? */
5491  if (!data)
5492  data = "";
5493  if (ast_context_add_switch2(con, appl, data, !strcasecmp(v->name, "eswitch"), global_registrar))
5494  ast_log(LOG_WARNING, "Unable to include switch '%s' in context '%s'\n", v->value, cxt);
5495  } else {
5496  ast_log(LOG_WARNING, "==!!== Unknown directive: %s at line %d -- IGNORING!!!\n", v->name, v->lineno);
5497  }
5498  }
5499  }
5500  ast_config_destroy(cfg);
5501  return 1;
5502 }
struct ast_variable * next
static int ast_context_add_ignorepat2(struct ast_context *con, const char *value, const char *registrar)
Definition: extconf.c:4569
static void ast_config_destroy(struct ast_config *cfg)
Definition: extconf.c:1290
static const char config_file[]
Definition: cdr_odbc.c:57
static struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category)
Definition: extconf.c:1216
static void pbx_substitute_variables_helper(struct ast_channel *c, const char *cp1, char *cp2, int count)
Definition: extconf.c:5331
void ast_copy_string(char *dst, const char *src, size_t size)
Definition: extconf.c:970
Structure for variables, used for configurations and for channel variables.
static int clearglobalvars_config
Definition: extconf.c:2127
static char * global_registrar
Definition: extconf.c:2122
#define S_OR(a, b)
Definition: extconf.c:957
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
#define NULL
Definition: resample.c:96
char * end
Definition: eagi_proxy.c:73
const char * ext
Definition: http.c:147
void ast_free_ptr(void *ptr)
free() wrapper
Definition: astmm.c:1771
static char * ast_category_browse(struct ast_config *config, const char *prev)
Definition: extconf.c:3328
static void ast_shrink_phone_number(char *n)
Clean up phone string remove &#39;(&#39;, &#39; &#39;, &#39;)&#39;, non-trailing &#39;.&#39;, and &#39;-&#39; not in square brackets...
Definition: extconf.c:2137
char * ast_skip_blanks(const char *str)
Definition: extconf.c:979
static void pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Definition: extconf.c:2530
void free()
static int static_config
Definition: extconf.c:2124
static char * ast_process_quotes_and_slashes(char *start, char find, char replace_with)
Definition: extconf.c:2219
static struct ast_context * local_contexts
Definition: extconf.c:3598
static void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Definition: extconf.c:2195
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:4978
#define LOG_WARNING
Definition: extconf.c:139
static int autofallthrough_config
Definition: extconf.c:2126
static const char * ast_variable_retrieve(const struct ast_config *config, const char *category, const char *variable)
Definition: extconf.c:1228
static struct ast_context * ast_context_find_or_create(struct ast_context **extcontexts, void *tab, const char *name, const char *registrar)
Definition: extconf.c:4983
static char userscontext[AST_MAX_EXTENSION]
Definition: extconf.c:2123
static int ast_context_add_include2(struct ast_context *con, const char *value, const char *registrar)
Definition: extconf.c:4503
char * strsep(char **str, const char *delims)
#define PRIORITY_HINT
Definition: extconf.c:2083
struct ast_config * localized_config_load(const char *filename)
Definition: extconf.c:3287
static int ast_true(const char *s)
Definition: extconf.c:2245
static int write_protect_config
Definition: extconf.c:2125
#define strdup(a)
Definition: astmm.h:165
#define ast_opt_dont_warn
Definition: extconf.c:1385
ast_context: An extension context - must remain in sync with fake_context
Definition: pbx.c:284
static int ast_context_add_switch2(struct ast_context *con, const char *value, const char *data, int eval, const char *registrar)
Definition: extconf.c:4641
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:4776

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

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, globalslock, NULL, parse_variable_name(), and substring().

Referenced by pbx_substitute_variables_helper_full().

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

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

References config_file, NULL, pbx_load_config(), and pbx_substitute_variables_helper_full().

Referenced by pbx_load_config().

5332 {
5333  pbx_substitute_variables_helper_full(c, NULL, cp1, cp2, count);
5334 }
static void pbx_substitute_variables_helper_full(struct ast_channel *c, struct varshead *headp, const char *cp1, char *cp2, int count)
Definition: extconf.c:5149
#define NULL
Definition: resample.c:96

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

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

Referenced by pbx_substitute_variables_helper().

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

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

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(), inherit_category(), ast_variable::lineno, ast_category::lineno, 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().

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

◆ set_fn()

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

Definition at line 3408 of file extconf.c.

References ast_config_AST_CONFIG_DIR, ast_copy_string(), ast_channel::generator, and localized_config_text_file_save().

Referenced by localized_config_text_file_save().

3409 {
3410  if (!file || file[0] == 0) {
3411  if (configfile[0] == '/')
3412  ast_copy_string(fn, configfile, fn_size);
3413  else
3414  snprintf(fn, fn_size, "%s/%s", ast_config_AST_CONFIG_DIR, configfile);
3415  } else if (file[0] == '/')
3416  ast_copy_string(fn, file, fn_size);
3417  else
3418  snprintf(fn, fn_size, "%s/%s", ast_config_AST_CONFIG_DIR, file);
3419 }
void ast_copy_string(char *dst, const char *src, size_t size)
Definition: extconf.c:970
const char * ast_config_AST_CONFIG_DIR
Definition: options.c:151

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

References ast_copy_string().

Referenced by pbx_retrieve_variable(), and pbx_substitute_variables_helper_full().

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

◆ tvfix()

static struct timeval tvfix ( struct timeval  a)
static

Definition at line 2267 of file extconf.c.

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

Referenced by ast_tvadd(), and ast_tvsub().

2268 {
2269  if (a.tv_usec >= ONE_MILLION) {
2270  ast_log(LOG_WARNING, "warning too large timestamp %ld.%ld\n",
2271  (long)a.tv_sec, (long int) a.tv_usec);
2272  a.tv_sec += a.tv_usec / ONE_MILLION;
2273  a.tv_usec %= ONE_MILLION;
2274  } else if (a.tv_usec < 0) {
2275  ast_log(LOG_WARNING, "warning negative timestamp %ld.%ld\n",
2276  (long)a.tv_sec, (long int) a.tv_usec);
2277  a.tv_usec = 0;
2278  }
2279  return a;
2280 }
static void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Definition: extconf.c:2195
#define LOG_WARNING
Definition: extconf.c:139
#define ONE_MILLION
Definition: extconf.c:2262
static struct test_val a

◆ variable_clone()

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

Definition at line 1249 of file extconf.c.

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

1250 {
1251  struct ast_variable *new = ast_variable_new(old->name, old->value, old->file);
1252 
1253  if (new) {
1254  new->lineno = old->lineno;
1255  new->object = old->object;
1256  new->blanklines = old->blanklines;
1257  /* TODO: clone comments? */
1258  }
1259 
1260  return new;
1261 }
Structure for variables, used for configurations and for channel variables.
static struct ast_variable * ast_variable_new(const char *name, const char *value, const char *filename)
Definition: extconf.c:1056

Variable Documentation

◆ ast_defaultlanguage

char ast_defaultlanguage[]

Definition at line 98 of file options.c.

Referenced by load_asterisk_conf().

◆ ast_language_is_prefix

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.

This is settable in asterisk.conf.

Definition at line 67 of file file.c.

Referenced by fileexists_test().

◆ ast_mainpid

pid_t ast_mainpid

Definition at line 315 of file asterisk.c.

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

◆ autofallthrough_config

int autofallthrough_config = 0
static

Definition at line 2126 of file extconf.c.

◆ clearglobalvars_config

int clearglobalvars_config = 0
static

Definition at line 2127 of file extconf.c.

◆ comment_buffer

char* comment_buffer
static

Growable string buffer this will be a comment collector.

Definition at line 705 of file extconf.c.

Referenced by config_text_file_load().

◆ comment_buffer_size

int comment_buffer_size
static

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

Definition at line 706 of file extconf.c.

◆ config_engine_list

static struct ast_config_engine * config_engine_list
static

Definition at line 893 of file extconf.c.

◆ config_filename

char* config_filename = "extensions.conf"
static

Definition at line 2121 of file extconf.c.

Referenced by AST_TEST_DEFINE(), 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 , NULL, {1, 0} }
static

Lock for the ast_context list

Definition at line 4484 of file extconf.c.

Referenced by ast_unlock_contexts(), and ast_wrlock_contexts().

◆ contexts

struct ast_context* contexts = NULL
static

◆ days

char* days[]

Definition at line 3777 of file extconf.c.

Referenced by main().

◆ debug_filename

char debug_filename[AST_FILENAME_MAX]

◆ extconfig_conf

char* extconfig_conf = "extconfig.conf"
static

Definition at line 702 of file extconf.c.

◆ global_registrar

char* global_registrar = "conf2ael"
static

Definition at line 2122 of file extconf.c.

◆ globals

struct varshead globals = AST_LIST_HEAD_NOLOCK_INIT_VALUE
static

Definition at line 2069 of file extconf.c.

Referenced by pbx_builtin_setvar_helper().

◆ globalslock

ast_rwlock_t globalslock = { PTHREAD_RWLOCK_INITIALIZER , NULL, {1, 0} }
static

Definition at line 2068 of file extconf.c.

Referenced by pbx_retrieve_variable().

◆ hints

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

◆ lline_buffer

char* lline_buffer
static

A buffer for stuff behind the ;

Definition at line 708 of file extconf.c.

Referenced by config_text_file_load().

◆ lline_buffer_size

int lline_buffer_size
static

Definition at line 709 of file extconf.c.

◆ local_contexts

struct ast_context* local_contexts = NULL
static

Definition at line 3598 of file extconf.c.

◆ months

char* months[]

Definition at line 3789 of file extconf.c.

Referenced by main().

◆ 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:789

Definition at line 794 of file extconf.c.

◆ record_cache_dir

char record_cache_dir[AST_CACHE_DIR_LEN]

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

Referenced by ast_unreplace_sigchld().

◆ safe_system_prev_handler

struct sigaction safe_system_prev_handler
static

Definition at line 786 of file extconf.c.

Referenced by ast_replace_sigchld(), and ast_unreplace_sigchld().

◆ static_config

int static_config = 0
static

Definition at line 2124 of file extconf.c.

◆ 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:3121

Definition at line 2856 of file extconf.c.

Referenced by ast_config_internal_load().

◆ use_local_dir

int use_local_dir = 1
static

Definition at line 3105 of file extconf.c.

◆ userscontext

char userscontext[AST_MAX_EXTENSION] = "default"
static

Definition at line 2123 of file extconf.c.

◆ write_protect_config

int write_protect_config = 1
static

Definition at line 2125 of file extconf.c.