Asterisk - The Open Source Telephony Project GIT-master-57e2743
Loading...
Searching...
No Matches
Data Structures | Macros | Enumerations | Functions
extconf.h File Reference

External configuration handlers (realtime and static configuration) More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  pbx_find_info
 

Macros

#define AST_PBX_MAX_STACK   512
 
#define STATUS_NO_CONTEXT   1
 
#define STATUS_NO_EXTENSION   2
 
#define STATUS_NO_LABEL   4
 
#define STATUS_NO_PRIORITY   3
 
#define STATUS_SUCCESS   5
 

Enumerations

enum  ext_match_t {
  E_MATCHMORE = 0x00 , E_CANMATCH = 0x01 , E_MATCH = 0x02 , E_MATCH_MASK = 0x03 ,
  E_SPAWN = 0x12 , E_FINDLABEL = 0x22
}
 

Functions

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)
 
struct ast_category * localized_category_get (const struct ast_config *config, const char *category_name)
 
struct ast_config * localized_config_load (const char *filename)
 
struct ast_config * localized_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_context * localized_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_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)
 
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_exten * localized_walk_context_extensions (struct ast_context *con, struct ast_exten *exten)
 
struct ast_include * localized_walk_context_includes (struct ast_context *con, struct ast_include *inc)
 
struct ast_sw * localized_walk_context_switches (struct ast_context *con, struct ast_sw *sw)
 
struct ast_context * localized_walk_contexts (struct ast_context *con)
 
struct ast_exten * localized_walk_extension_priorities (struct ast_exten *exten, struct ast_exten *priority)
 

Detailed Description

External configuration handlers (realtime and static configuration)

Author
Steve Murphy murf@.nosp@m.digi.nosp@m.um.co.nosp@m.m

Definition in file extconf.h.

Macro Definition Documentation

◆ AST_PBX_MAX_STACK

#define AST_PBX_MAX_STACK   512

Definition at line 225 of file extconf.h.

◆ STATUS_NO_CONTEXT

#define STATUS_NO_CONTEXT   1

Definition at line 244 of file extconf.h.

◆ STATUS_NO_EXTENSION

#define STATUS_NO_EXTENSION   2

Definition at line 245 of file extconf.h.

◆ STATUS_NO_LABEL

#define STATUS_NO_LABEL   4

Definition at line 247 of file extconf.h.

◆ STATUS_NO_PRIORITY

#define STATUS_NO_PRIORITY   3

Definition at line 246 of file extconf.h.

◆ STATUS_SUCCESS

#define STATUS_SUCCESS   5

Definition at line 248 of file extconf.h.

Enumeration Type Documentation

◆ ext_match_t

When looking up extensions, we can have different requests identified by the 'action' argument, as follows. Note that the coding is such that the low 4 bits are the third argument to extension_match_core.

Enumerator
E_MATCHMORE 
E_CANMATCH 
E_MATCH 
E_MATCH_MASK 
E_SPAWN 
E_FINDLABEL 

Definition at line 214 of file extconf.h.

214 {
215 E_MATCHMORE = 0x00, /* extension can match but only with more 'digits' */
216 E_CANMATCH = 0x01, /* extension can match with or without more 'digits' */
217 E_MATCH = 0x02, /* extension is an exact match */
218 E_MATCH_MASK = 0x03, /* mask for the argument to extension_match_core() */
219 E_SPAWN = 0x12, /* want to spawn an extension. Requires exact match */
220 E_FINDLABEL = 0x22 /* returns the priority for a given label. Requires exact match */
221};
@ E_MATCH_MASK
Definition extconf.h:218
@ E_MATCH
Definition extconf.h:217
@ E_CANMATCH
Definition extconf.h:216
@ E_FINDLABEL
Definition extconf.h:220
@ E_MATCHMORE
Definition extconf.h:215
@ E_SPAWN
Definition extconf.h:219

Function Documentation

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

4895{
4896 return ast_add_extension2(con, replace, extension, priority, label, callerid, application, data, datad, registrar);
4897}
static int priority
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:4769
static const char registrar[]
The static registrar for the added dialplan hints.
static int replace(struct ast_channel *chan, const char *cmd, char *data, struct ast_str **buf, ssize_t len)
structure to hold extensions

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

◆ localized_category_get()

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

Definition at line 2797 of file extconf.c.

2798{
2799 return category_get(config, category_name, 0);
2800}
static const char config[]
static struct ast_category * category_get(const struct ast_config *config, const char *category_name, int ignored)
Definition extconf.c:1190

References category_get(), and config.

◆ localized_config_load()

struct ast_config * localized_config_load ( const char *  filename)

Definition at line 3281 of file extconf.c.

3282{
3283 struct ast_config *cfg;
3284 struct ast_config *result;
3285
3286 cfg = ast_config_new();
3287 if (!cfg)
3288 return NULL;
3289
3290 result = ast_config_internal_load(filename, cfg, 0, "");
3291 if (!result)
3292 ast_config_destroy(cfg);
3293
3294 return result;
3295}
static PGresult * result
Definition cel_pgsql.c:84
static struct ast_config * ast_config_new(void)
Definition extconf.c:3270
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:2858
static void ast_config_destroy(struct ast_config *cfg)
Definition extconf.c:1287
#define NULL
Definition resample.c:96

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

Referenced by pbx_load_config().

◆ localized_config_load_with_comments()

struct ast_config * localized_config_load_with_comments ( const char *  filename)

Definition at line 3299 of file extconf.c.

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

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

◆ localized_config_text_file_save()

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

Definition at line 3417 of file extconf.c.

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

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

◆ localized_context_add_ignorepat2()

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

Definition at line 4595 of file extconf.c.

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

References ast_context_add_ignorepat2(), registrar, and value.

◆ localized_context_add_include2()

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

Definition at line 4553 of file extconf.c.

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

References ast_context_add_include2(), registrar, and value.

◆ localized_context_add_switch2()

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

Definition at line 4696 of file extconf.c.

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

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

◆ localized_context_destroy()

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

Definition at line 5558 of file extconf.c.

5559{
5563}
static int ast_wrlock_contexts(void)
Definition extconf.c:4605
static void __ast_context_destroy(struct ast_context *con, const char *registrar)
Definition extconf.c:5497
static int ast_unlock_contexts(void)
Definition extconf.c:4610

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

◆ localized_context_find_or_create()

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

Definition at line 4982 of file extconf.c.

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

References __ast_context_create(), name, and registrar.

◆ localized_context_verify_includes()

int localized_context_verify_includes ( struct ast_context *  con)

Definition at line 5633 of file extconf.c.

5634{
5635 return ast_context_verify_includes(con);
5636}
void ast_context_verify_includes(void)
Definition ael_main.c:395

References ast_context_verify_includes().

◆ localized_find_extension()

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

Definition at line 4464 of file extconf.c.

4472{
4473 return pbx_find_extension(NULL, bypass, q, context, exten, priority, label, callerid, action);
4474}
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:4328

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

Referenced by pbx_find_extension().

◆ localized_merge_contexts_and_delete()

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

Definition at line 5611 of file extconf.c.

5612{
5614}
void ast_merge_contexts_and_delete(void)
Definition ael_main.c:389

References ast_merge_contexts_and_delete(), and registrar.

◆ localized_pbx_builtin_setvar()

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

Definition at line 2601 of file extconf.c.

2602{
2603 return pbx_builtin_setvar(chan, data);
2604}
static int pbx_builtin_setvar(struct ast_channel *chan, const void *data)
Definition extconf.c:2564

References pbx_builtin_setvar().

◆ localized_pbx_load_module()

int localized_pbx_load_module ( void  )

Definition at line 5640 of file extconf.c.

5641{
5642 struct ast_context *con;
5643
5645 return -1 /* AST_MODULE_LOAD_DECLINE*/;
5646
5647 /* pbx_load_users(); */ /* does this affect the dialplan? */
5648
5650
5651 for (con = NULL; (con = ast_walk_contexts(con));)
5653
5654 printf("=== Loading extensions.conf ===\n");
5655 con = 0;
5656 while ((con = ast_walk_contexts(con)) ) {
5657 printf("Context: %s\n", con->name);
5658 }
5659 printf("=========\n");
5660
5661 return 0;
5662}
struct ast_context * ast_walk_contexts(void)
Definition ael_main.c:401
static struct ast_context * local_contexts
Definition extconf.c:3592
static int pbx_load_config(const char *config_file)
Definition extconf.c:5332
static char * global_registrar
Definition extconf.c:2117
static char * config_filename
Definition extconf.c:2116
ast_context: An extension context
Definition pbx.c:254
const char * name
Definition pbx.c:255

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

◆ localized_use_conf_dir()

void localized_use_conf_dir ( void  )

Definition at line 3109 of file extconf.c.

3110{
3111 use_local_dir = 0;
3112}
static int use_local_dir
Definition extconf.c:3099

References use_local_dir.

Referenced by main().

◆ localized_use_local_dir()

void localized_use_local_dir ( void  )

Definition at line 3104 of file extconf.c.

3105{
3106 use_local_dir = 1;
3107}

References use_local_dir.

Referenced by main().

◆ localized_walk_context_extensions()

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

Definition at line 4047 of file extconf.c.

4049{
4050 return ast_walk_context_extensions(con,exten);
4051}
static struct ast_exten * ast_walk_context_extensions(struct ast_context *con, struct ast_exten *exten)
Definition extconf.c:4036

References ast_walk_context_extensions(), and ast_exten::exten.

◆ localized_walk_context_includes()

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

Definition at line 4100 of file extconf.c.

4102{
4103 return ast_walk_context_includes(con, inc);
4104}
static struct ast_include * ast_walk_context_includes(struct ast_context *con, struct ast_include *inc)
Definition extconf.c:4076

References ast_walk_context_includes().

◆ localized_walk_context_switches()

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

Definition at line 4146 of file extconf.c.

4148{
4149 return ast_walk_context_switches(con, sw);
4150}
static struct ast_sw * ast_walk_context_switches(struct ast_context *con, struct ast_sw *sw)
Definition extconf.c:4135

References ast_walk_context_switches().

◆ localized_walk_contexts()

struct ast_context * localized_walk_contexts ( struct ast_context *  con)

Definition at line 4026 of file extconf.c.

4027{
4028 return ast_walk_contexts(con);
4029}

References ast_walk_contexts().

◆ localized_walk_extension_priorities()

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

Definition at line 4065 of file extconf.c.

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

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