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

Defines

#define AST_PBX_MAX_STACK   128
#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, 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_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)


Detailed Description

External configuration handlers (realtime and static configuration).

Author:
Steve Murphy <murf@digium.com>

Definition in file extconf.h.


Define Documentation

#define AST_PBX_MAX_STACK   128

#define STATUS_NO_CONTEXT   1

Definition at line 241 of file extconf.h.

Referenced by pbx_extension_helper(), and pbx_find_extension().

#define STATUS_NO_EXTENSION   2

Definition at line 242 of file extconf.h.

Referenced by pbx_extension_helper(), and pbx_find_extension().

#define STATUS_NO_LABEL   4

Definition at line 244 of file extconf.h.

Referenced by pbx_extension_helper(), and pbx_find_extension().

#define STATUS_NO_PRIORITY   3

Definition at line 243 of file extconf.h.

Referenced by pbx_extension_helper(), and pbx_find_extension().

#define STATUS_SUCCESS   5

Definition at line 245 of file extconf.h.

Referenced by check_goto(), check_pval_item(), and pbx_find_extension().


Enumeration Type Documentation

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 
E_MATCHMORE 
E_CANMATCH 
E_MATCH 
E_MATCH_MASK 
E_SPAWN 
E_FINDLABEL 

Definition at line 215 of file extconf.h.

00215                  {
00216    E_MATCHMORE =  0x00, /* extension can match but only with more 'digits' */
00217    E_CANMATCH =   0x01, /* extension can match with or without more 'digits' */
00218    E_MATCH =   0x02, /* extension is an exact match */
00219    E_MATCH_MASK = 0x03, /* mask for the argument to extension_match_core() */
00220    E_SPAWN =   0x12, /* want to spawn an extension. Requires exact match */
00221    E_FINDLABEL =  0x22  /* returns the priority for a given label. Requires exact match */
00222 };


Function Documentation

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

References ast_add_extension2(), and ast_exten::datad.

Referenced by ast_add_extension2().

05143 {
05144    return ast_add_extension2(con, replace, extension, priority, label, callerid, application, data, datad, registrar);
05145 }

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

Definition at line 3074 of file extconf.c.

References category_get().

03075 {
03076    return category_get(config, category_name, 0);
03077 }

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

Definition at line 3583 of file extconf.c.

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

Referenced by pbx_load_config().

03584 {
03585    struct ast_config *cfg;
03586    struct ast_config *result;
03587 
03588    cfg = ast_config_new();
03589    if (!cfg)
03590       return NULL;
03591 
03592    result = ast_config_internal_load(filename, cfg, 0, "");
03593    if (!result)
03594       ast_config_destroy(cfg);
03595 
03596    return result;
03597 }

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

Definition at line 3601 of file extconf.c.

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

03602 {
03603    struct ast_config *cfg;
03604    struct ast_config *result;
03605 
03606    cfg = ast_config_new();
03607    if (!cfg)
03608       return NULL;
03609 
03610    result = ast_config_internal_load(filename, cfg, 1, "");
03611    if (!result)
03612       ast_config_destroy(cfg);
03613 
03614    return result;
03615 }

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

Definition at line 3719 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, f, 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_category::next, ast_variable::next, ast_comment::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.

03720 {
03721    FILE *f;
03722    char fn[256];
03723    struct ast_variable *var;
03724    struct ast_category *cat;
03725    struct ast_comment *cmt;
03726    struct ast_config_include *incl;
03727    int blanklines = 0;
03728    
03729    /* reset all the output flags, in case this isn't our first time saving this data */
03730    
03731    for (incl=cfg->includes; incl; incl = incl->next)
03732       incl->output = 0;
03733    
03734    /* go thru all the inclusions and make sure all the files involved (configfile plus all its inclusions)
03735       are all truncated to zero bytes and have that nice header*/
03736    
03737    for (incl=cfg->includes; incl; incl = incl->next)
03738    {
03739       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*/
03740          FILE *f1;
03741          
03742          set_fn(fn, sizeof(fn), incl->included_file, configfile); /* normally, fn is just set to incl->included_file, prepended with config dir if relative */
03743          f1 = fopen(fn,"w");
03744          if (f1) {
03745             gen_header(f1, configfile, fn, generator);
03746             fclose(f1); /* this should zero out the file */
03747          } else {
03748             ast_verbose(VERBOSE_PREFIX_2 "Unable to write %s (%s)", fn, strerror(errno));
03749          }
03750       }
03751    }
03752    
03753    set_fn(fn, sizeof(fn), 0, configfile); /* just set fn to absolute ver of configfile */
03754 #ifdef __CYGWIN__ 
03755    if ((f = fopen(fn, "w+"))) {
03756 #else
03757    if ((f = fopen(fn, "w"))) {
03758 #endif       
03759       if (option_verbose > 1)
03760          ast_verbose(VERBOSE_PREFIX_2 "Saving '%s': ", fn);
03761 
03762       gen_header(f, configfile, fn, generator);
03763       cat = cfg->root;
03764       fclose(f);
03765         
03766       /* from here out, we open each involved file and concat the stuff we need to add to the end and immediately close... */
03767       /* since each var, cat, and associated comments can come from any file, we have to be 
03768          mobile, and open each file, print, and close it on an entry-by-entry basis */
03769       
03770       while(cat) {
03771          set_fn(fn, sizeof(fn), cat->file, configfile);
03772          f = fopen(fn, "a");
03773          if (!f)
03774          {
03775             ast_verbose(VERBOSE_PREFIX_2 "Unable to write %s (%s)", fn, strerror(errno));
03776             return -1;
03777          }
03778          
03779          /* dump any includes that happen before this category header */
03780          for (incl=cfg->includes; incl; incl = incl->next) {
03781             if (strcmp(incl->include_location_file, cat->file) == 0){
03782                if (cat->lineno > incl->include_location_lineno && !incl->output) {
03783                   if (incl->exec)
03784                      fprintf(f,"#exec \"%s\"\n", incl->exec_file);
03785                   else
03786                      fprintf(f,"#include \"%s\"\n", incl->included_file);
03787                   incl->output = 1;
03788                }
03789             }
03790          }
03791             
03792          /* Dump section with any appropriate comment */
03793          for (cmt = cat->precomments; cmt; cmt=cmt->next) {
03794             if (cmt->cmt[0] != ';' || cmt->cmt[1] != '!')
03795                fprintf(f,"%s", cmt->cmt);
03796          }
03797          if (!cat->precomments)
03798             fprintf(f,"\n");
03799          fprintf(f, "[%s]", cat->name);
03800          for(cmt = cat->sameline; cmt; cmt=cmt->next) {
03801             fprintf(f,"%s", cmt->cmt);
03802          }
03803          if (!cat->sameline)
03804             fprintf(f,"\n");
03805          fclose(f);
03806             
03807          var = cat->root;
03808          while(var) {
03809             set_fn(fn, sizeof(fn), var->file, configfile);
03810             f = fopen(fn, "a");
03811             if (!f)
03812             {
03813                ast_verbose(VERBOSE_PREFIX_2 "Unable to write %s (%s)", fn, strerror(errno));
03814                return -1;
03815             }
03816                 
03817             /* dump any includes that happen before this category header */
03818             for (incl=cfg->includes; incl; incl = incl->next) {
03819                if (strcmp(incl->include_location_file, var->file) == 0){
03820                   if (var->lineno > incl->include_location_lineno && !incl->output) {
03821                      if (incl->exec)
03822                         fprintf(f,"#exec \"%s\"\n", incl->exec_file);
03823                      else
03824                         fprintf(f,"#include \"%s\"\n", incl->included_file);
03825                      incl->output = 1;
03826                   }
03827                }
03828             }
03829                 
03830             for (cmt = var->precomments; cmt; cmt=cmt->next) {
03831                if (cmt->cmt[0] != ';' || cmt->cmt[1] != '!')
03832                   fprintf(f,"%s", cmt->cmt);
03833             }
03834             if (var->sameline) 
03835                fprintf(f, "%s %s %s  %s", var->name, (var->object ? "=>" : "="), var->value, var->sameline->cmt);
03836             else  
03837                fprintf(f, "%s %s %s\n", var->name, (var->object ? "=>" : "="), var->value);
03838             if (var->blanklines) {
03839                blanklines = var->blanklines;
03840                while (blanklines--)
03841                   fprintf(f, "\n");
03842             }
03843             
03844             fclose(f);
03845                 
03846             
03847             var = var->next;
03848          }
03849          cat = cat->next;
03850       }
03851       if ((option_verbose > 1) && !option_debug)
03852          ast_verbose("Saved\n");
03853    } else {
03854       if (option_debug)
03855          ast_log(LOG_DEBUG, "Unable to open for writing: %s\n", fn);
03856       if (option_verbose > 1)
03857          ast_verbose(VERBOSE_PREFIX_2 "Unable to write (%s)", strerror(errno));
03858       return -1;
03859    }
03860 
03861    /* Now, for files with trailing #include/#exec statements,
03862       we have to make sure every entry is output */
03863    
03864    for (incl=cfg->includes; incl; incl = incl->next) {
03865       if (!incl->output) {
03866          /* open the respective file */
03867          set_fn(fn, sizeof(fn), incl->include_location_file, configfile);
03868          f = fopen(fn, "a");
03869          if (!f)
03870          {
03871             ast_verbose(VERBOSE_PREFIX_2 "Unable to write %s (%s)", fn, strerror(errno));
03872             return -1;
03873          }
03874             
03875          /* output the respective include */
03876          if (incl->exec)
03877             fprintf(f,"#exec \"%s\"\n", incl->exec_file);
03878          else
03879             fprintf(f,"#include \"%s\"\n", incl->included_file);
03880          fclose(f);
03881          incl->output = 1;
03882       }
03883    }
03884    
03885    return 0;
03886 }

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

Definition at line 4842 of file extconf.c.

References ast_context_add_ignorepat2().

Referenced by ast_context_add_ignorepat2().

04843 {
04844    return ast_context_add_ignorepat2(con, value, registrar);
04845 }

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

Definition at line 4800 of file extconf.c.

References ast_context_add_include2().

Referenced by ast_context_add_include2().

04802 {
04803    return  ast_context_add_include2(con, value, registrar);
04804 }

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

Definition at line 4943 of file extconf.c.

References ast_context_add_switch2().

Referenced by ast_context_add_switch2().

04945 {
04946    return ast_context_add_switch2(con, value, data, eval, registrar);
04947 }

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

Definition at line 5806 of file extconf.c.

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

Referenced by ast_context_destroy().

05807 {
05808    ast_wrlock_contexts();
05809    __ast_context_destroy(con,registrar);
05810    ast_unlock_contexts();
05811 }

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

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

References __ast_context_create().

Referenced by ast_context_find_or_create().

05231 {
05232    return __ast_context_create(extcontexts, name, registrar, 1);
05233 }

int localized_context_verify_includes ( struct ast_context con  ) 

Definition at line 5881 of file extconf.c.

References ast_context_verify_includes().

Referenced by ast_context_verify_includes().

05882 {
05883    return ast_context_verify_includes(con);
05884 }

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

Definition at line 4711 of file extconf.c.

References NULL, and pbx_find_extension().

Referenced by pbx_find_extension().

04719 {
04720    return pbx_find_extension(NULL, bypass, q, context, exten, priority, label, callerid, action);
04721 }

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

Version:
1.6.1 added tab parameter

Definition at line 5859 of file extconf.c.

References ast_merge_contexts_and_delete().

Referenced by ast_merge_contexts_and_delete().

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

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

Definition at line 2878 of file extconf.c.

References pbx_builtin_setvar().

Referenced by pbx_builtin_setvar().

02879 {
02880    return pbx_builtin_setvar(chan, data);
02881 }

int localized_pbx_load_module ( void   ) 

Definition at line 5888 of file extconf.c.

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

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

05889 {
05890    struct ast_context *con;
05891 
05892    if(!pbx_load_config(config_filename))
05893       return -1 /* AST_MODULE_LOAD_DECLINE*/;
05894 
05895    /* pbx_load_users(); */ /* does this affect the dialplan? */
05896 
05897    ast_merge_contexts_and_delete(&local_contexts, global_registrar);
05898 
05899    for (con = NULL; (con = ast_walk_contexts(con));)
05900       ast_context_verify_includes(con);
05901 
05902    printf("=== Loading extensions.conf ===\n");
05903    con = 0;
05904    while ((con = ast_walk_contexts(con)) ) {
05905       printf("Context: %s\n", con->name);
05906    }
05907    printf("=========\n");
05908    
05909    return 0;
05910 }

void localized_use_conf_dir ( void   ) 

Definition at line 3380 of file extconf.c.

Referenced by main().

03381 {
03382    use_local_dir = 0;
03383 }

void localized_use_local_dir ( void   ) 

Definition at line 3375 of file extconf.c.

Referenced by main().

03376 {
03377    use_local_dir = 1;
03378 }

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

Definition at line 4349 of file extconf.c.

References ast_walk_context_extensions().

Referenced by main().

04351 {
04352    return ast_walk_context_extensions(con,exten);
04353 }

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

Definition at line 4389 of file extconf.c.

References ast_walk_context_includes().

04391 {
04392    return ast_walk_context_includes(con, inc);
04393 }

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

Definition at line 4410 of file extconf.c.

References ast_walk_context_switches().

Referenced by main().

04412 {
04413    return ast_walk_context_switches(con, sw);
04414 }

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

Definition at line 4328 of file extconf.c.

References ast_walk_contexts().

Referenced by ast_walk_contexts(), and main().

04329 {
04330    return ast_walk_contexts(con);
04331 }

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

Definition at line 4367 of file extconf.c.

References ast_walk_extension_priorities().

Referenced by main().

04369 {
04370    return ast_walk_extension_priorities(exten, priority);
04371 }


Generated on Thu Apr 16 06:30:56 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6