extconf.h

Go to the documentation of this file.
00001 /*
00002  * Asterisk -- An open source telephony toolkit.
00003  *
00004  * Copyright (C) 2007, Digium, Inc.
00005  *
00006  * Steve Murphy <murf@digium.com>
00007  *
00008  * See http://www.asterisk.org for more information about
00009  * the Asterisk project. Please do not directly contact
00010  * any of the maintainers of this project for assistance;
00011  * the project provides a web site, mailing lists and IRC
00012  * channels for your use.
00013  *
00014  * This program is free software, distributed under the terms of
00015  * the GNU General Public License Version 2. See the LICENSE file
00016  * at the top of the source tree.
00017  */
00018 /*! \file
00019  * \brief External configuration handlers (realtime and static configuration)
00020  * \author Steve Murphy <murf@digium.com>
00021  *
00022  */
00023 
00024 #ifndef _ASTERISK_EXTCONF_H
00025 #define _ASTERISK_EXTCONF_H
00026 
00027 #if defined(__cplusplus) || defined(c_plusplus)
00028 extern "C" {
00029 #endif
00030 
00031 #ifdef NOTYET
00032 /* I'm going to define all the structs mentioned below, to avoid
00033    possible conflicts in declarations that might be introduced,
00034    if we just include the files that define them-- this may be
00035    unnecessary */
00036 
00037 struct ast_comment {
00038    struct ast_comment *next;
00039    char cmt[0];
00040 };
00041 
00042 struct ast_variable {
00043    char *name;
00044    char *value;
00045    int lineno;
00046    int object;    /*!< 0 for variable, 1 for object */
00047    int blanklines;   /*!< Number of blanklines following entry */
00048    struct ast_comment *precomments;
00049    struct ast_comment *sameline;
00050    struct ast_variable *next;
00051    char stuff[0];
00052 };
00053 
00054 struct ast_category {
00055    char name[80];
00056    int ignored;         /*!< do not let user of the config see this category */
00057    int include_level;
00058    struct ast_comment *precomments;
00059    struct ast_comment *sameline;
00060    struct ast_variable *root;
00061    struct ast_variable *last;
00062    struct ast_category *next;
00063 };
00064 
00065 struct ast_config {
00066    struct ast_category *root;
00067    struct ast_category *last;
00068    struct ast_category *current;
00069    struct ast_category *last_browse;      /*!< used to cache the last category supplied via category_browse */
00070    int include_level;
00071    int max_include_level;
00072 };
00073 
00074 /* ================== above: the config world; below, the dialplan world */
00075 
00076 /*! \brief A registered application */
00077 struct ast_app {
00078    int (*execute)(struct ast_channel *chan, void *data);
00079    AST_DECLARE_STRING_FIELDS(
00080       AST_STRING_FIELD(synopsis);     /*!< Synopsis text for 'show applications' */
00081       AST_STRING_FIELD(description);  /*!< Description (help text) for 'show application &lt;name&gt;' */
00082       AST_STRING_FIELD(syntax);       /*!< Syntax text for 'core show applications' */
00083       AST_STRING_FIELD(arguments);    /*!< Arguments description */
00084       AST_STRING_FIELD(seealso);      /*!< See also */
00085    );
00086    enum ast_xmldoc_src docsrc;      /*!< Where the documentation come from. */
00087    AST_RWLIST_ENTRY(ast_app) list;     /*!< Next app in list */
00088    void *module;        /*!< Module this app belongs to */
00089    char name[0];           /*!< Name of the application */
00090 };
00091 /*!
00092    \brief An extension
00093    The dialplan is saved as a linked list with each context
00094    having it's own linked list of extensions - one item per
00095    priority.
00096 */
00097 struct ast_exten {
00098    char *exten;         /*!< Extension name */
00099    int matchcid;        /*!< Match caller id ? */
00100    const char *cidmatch;      /*!< Caller id to match for this extension */
00101    int priority;        /*!< Priority */
00102    const char *label;      /*!< Label */
00103    struct ast_context *parent;   /*!< The context this extension belongs to  */
00104    const char *app;     /*!< Application to execute */
00105    struct ast_app *cached_app;     /*!< Cached location of application */
00106    void *data;       /*!< Data to use (arguments) */
00107    void (*datad)(void *);     /*!< Data destructor */
00108    struct ast_exten *peer;    /*!< Next higher priority with our extension */
00109    const char *registrar;     /*!< Registrar */
00110    struct ast_exten *next;    /*!< Extension with a greater ID */
00111    char stuff[0];
00112 };
00113 /* from pbx.h */
00114 typedef int (*ast_state_cb_type)(const char *context, const char *exten, enum ast_extension_states state, void *data);
00115 struct ast_timing {
00116    int hastime;            /*!< If time construct exists */
00117    unsigned int monthmask;       /*!< Mask for month */
00118    unsigned int daymask;         /*!< Mask for date */
00119    unsigned int dowmask;         /*!< Mask for day of week (mon-sun) */
00120    unsigned int minmask[24];     /*!< Mask for minute */
00121 };
00122 /*! \brief include= support in extensions.conf */
00123 struct ast_include {
00124    const char *name;
00125    const char *rname;         /*!< Context to include */
00126    const char *registrar;        /*!< Registrar */
00127    int hastime;            /*!< If time construct exists */
00128    struct ast_timing timing;               /*!< time construct */
00129    struct ast_include *next;     /*!< Link them together */
00130    char stuff[0];
00131 };
00132 
00133 /*! \brief Switch statement in extensions.conf */
00134 struct ast_sw {
00135    char *name;
00136    const char *registrar;        /*!< Registrar */
00137    char *data;          /*!< Data load */
00138    int eval;
00139    AST_LIST_ENTRY(ast_sw) list;
00140    char *tmpdata;
00141    char stuff[0];
00142 };
00143 
00144 /*! \brief Ignore patterns in dial plan */
00145 struct ast_ignorepat {
00146    const char *registrar;
00147    struct ast_ignorepat *next;
00148    const char pattern[0];
00149 };
00150 
00151 /*! \brief An extension context */
00152 struct ast_context {
00153    ast_rwlock_t lock;         /*!< A lock to prevent multiple threads from clobbering the context */
00154    struct ast_exten *root;       /*!< The root of the list of extensions */
00155    struct ast_context *next;     /*!< Link them together */
00156    struct ast_include *includes;    /*!< Include other contexts */
00157    struct ast_ignorepat *ignorepats;   /*!< Patterns for which to continue playing dialtone */
00158    const char *registrar;        /*!< Registrar */
00159    AST_LIST_HEAD_NOLOCK(, ast_sw) alts;   /*!< Alternative switches */
00160    ast_mutex_t macrolock;        /*!< A lock to implement "exclusive" macros - held whilst a call is executing in the macro */
00161    char name[0];           /*!< Name of the context */
00162 };
00163 
00164 #endif
00165 
00166 struct ast_config *localized_config_load(const char *filename);
00167 struct ast_config *localized_config_load_with_comments(const char *filename);
00168 struct ast_category *localized_category_get(const struct ast_config *config, const char *category_name);
00169 int localized_config_text_file_save(const char *configfile, const struct ast_config *cfg, const char *generator);
00170 struct ast_context *localized_walk_contexts(struct ast_context *con);
00171 struct ast_exten *localized_walk_context_extensions(struct ast_context *con,
00172                                        struct ast_exten *exten);
00173 struct ast_exten *localized_walk_extension_priorities(struct ast_exten *exten,
00174                                          struct ast_exten *priority);
00175 struct ast_include *localized_walk_context_includes(struct ast_context *con,
00176                                        struct ast_include *inc);
00177 struct ast_sw *localized_walk_context_switches(struct ast_context *con,
00178                                     struct ast_sw *sw);
00179 
00180 void localized_context_destroy(struct ast_context *con, const char *registrar);
00181 int localized_pbx_load_module(void);
00182 
00183 /*!
00184  * \version 1.6.1 added tab parameter
00185  * \version 1.6.1 renamed function from localized_context_create to localized_context_find_or_create
00186  */
00187 struct ast_context *localized_context_find_or_create(struct ast_context **extcontexts, void *tab, const char *name, const char *registrar);
00188 int localized_pbx_builtin_setvar(struct ast_channel *chan, const void *data);
00189 int localized_context_add_ignorepat2(struct ast_context *con, const char *value, const char *registrar);
00190 int localized_context_add_switch2(struct ast_context *con, const char *value,
00191                          const char *data, int eval, const char *registrar);
00192 int localized_context_add_include2(struct ast_context *con, const char *value,
00193                           const char *registrar);
00194 int localized_add_extension2(struct ast_context *con,
00195                       int replace, const char *extension, int priority, const char *label, const char *callerid,
00196                       const char *application, void *data, void (*datad)(void *),
00197                       const char *registrar);
00198 
00199 /*!
00200  * \version 1.6.1 added tab parameter
00201  */
00202 void localized_merge_contexts_and_delete(struct ast_context **extcontexts, void *tab, const char *registrar);
00203 int localized_context_verify_includes(struct ast_context *con);
00204 void localized_use_conf_dir(void);
00205 void localized_use_local_dir(void);
00206 
00207 
00208 #ifndef _ASTERISK_PBX_H
00209 /*!
00210  * When looking up extensions, we can have different requests
00211  * identified by the 'action' argument, as follows.
00212  * Note that the coding is such that the low 4 bits are the
00213  * third argument to extension_match_core.
00214  */
00215 enum ext_match_t {
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 };
00223 #define AST_PBX_MAX_STACK  128
00224 
00225 /* request and result for pbx_find_extension */
00226 struct pbx_find_info {
00227 #if 0
00228    const char *context;
00229    const char *exten;
00230    int priority;
00231 #endif
00232 
00233    char *incstack[AST_PBX_MAX_STACK];      /* filled during the search */
00234    int stacklen;                   /* modified during the search */
00235    int status;                     /* set on return */
00236    struct ast_switch *swo;         /* set on return */
00237    const char *data;               /* set on return */
00238    const char *foundcontext;       /* set on return */
00239 };
00240 
00241 #define STATUS_NO_CONTEXT  1
00242 #define STATUS_NO_EXTENSION   2
00243 #define STATUS_NO_PRIORITY 3
00244 #define STATUS_NO_LABEL    4
00245 #define STATUS_SUCCESS     5
00246 
00247 #endif
00248 
00249 struct ast_exten *localized_find_extension(struct ast_context *bypass,
00250                                 struct pbx_find_info *q,
00251                                 const char *context,
00252                                 const char *exten,
00253                                 int priority,
00254                                 const char *label,
00255                                 const char *callerid,
00256                                 enum ext_match_t action);
00257 
00258 
00259 #if defined(__cplusplus) || defined(c_plusplus)
00260 }
00261 #endif
00262 
00263 #endif /* _ASTERISK_PBX_H */

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