Fri Jun 19 12:09:43 2009

Asterisk developer's documentation


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    const char *synopsis;         /*!< Synopsis text for 'show applications' */
00080    const char *description;      /*!< Description (help text) for 'show application &lt;name&gt;' */
00081    AST_RWLIST_ENTRY(ast_app) list;     /*!< Next app in list */
00082    void *module;        /*!< Module this app belongs to */
00083    char name[0];           /*!< Name of the application */
00084 };
00085 /*!
00086    \brief An extension
00087    The dialplan is saved as a linked list with each context
00088    having it's own linked list of extensions - one item per
00089    priority.
00090 */
00091 struct ast_exten {
00092    char *exten;         /*!< Extension name */
00093    int matchcid;        /*!< Match caller id ? */
00094    const char *cidmatch;      /*!< Caller id to match for this extension */
00095    int priority;        /*!< Priority */
00096    const char *label;      /*!< Label */
00097    struct ast_context *parent;   /*!< The context this extension belongs to  */
00098    const char *app;     /*!< Application to execute */
00099    struct ast_app *cached_app;     /*!< Cached location of application */
00100    void *data;       /*!< Data to use (arguments) */
00101    void (*datad)(void *);     /*!< Data destructor */
00102    struct ast_exten *peer;    /*!< Next higher priority with our extension */
00103    const char *registrar;     /*!< Registrar */
00104    struct ast_exten *next;    /*!< Extension with a greater ID */
00105    char stuff[0];
00106 };
00107 /* from pbx.h */
00108 typedef int (*ast_state_cb_type)(char *context, char* id, enum ast_extension_states state, void *data);
00109 struct ast_timing {
00110    int hastime;            /*!< If time construct exists */
00111    unsigned int monthmask;       /*!< Mask for month */
00112    unsigned int daymask;         /*!< Mask for date */
00113    unsigned int dowmask;         /*!< Mask for day of week (mon-sun) */
00114    unsigned int minmask[24];     /*!< Mask for minute */
00115 };
00116 /*! \brief include= support in extensions.conf */
00117 struct ast_include {
00118    const char *name;
00119    const char *rname;         /*!< Context to include */
00120    const char *registrar;        /*!< Registrar */
00121    int hastime;            /*!< If time construct exists */
00122    struct ast_timing timing;               /*!< time construct */
00123    struct ast_include *next;     /*!< Link them together */
00124    char stuff[0];
00125 };
00126 
00127 /*! \brief Switch statement in extensions.conf */
00128 struct ast_sw {
00129    char *name;
00130    const char *registrar;        /*!< Registrar */
00131    char *data;          /*!< Data load */
00132    int eval;
00133    AST_LIST_ENTRY(ast_sw) list;
00134    char *tmpdata;
00135    char stuff[0];
00136 };
00137 
00138 *! \brief Ignore patterns in dial plan */
00139 struct ast_ignorepat {
00140    const char *registrar;
00141    struct ast_ignorepat *next;
00142    const char pattern[0];
00143 };
00144 
00145 /*! \brief An extension context */
00146 struct ast_context {
00147    ast_rwlock_t lock;         /*!< A lock to prevent multiple threads from clobbering the context */
00148    struct ast_exten *root;       /*!< The root of the list of extensions */
00149    struct ast_context *next;     /*!< Link them together */
00150    struct ast_include *includes;    /*!< Include other contexts */
00151    struct ast_ignorepat *ignorepats;   /*!< Patterns for which to continue playing dialtone */
00152    const char *registrar;        /*!< Registrar */
00153    AST_LIST_HEAD_NOLOCK(, ast_sw) alts;   /*!< Alternative switches */
00154    ast_mutex_t macrolock;        /*!< A lock to implement "exclusive" macros - held whilst a call is executing in the macro */
00155    char name[0];           /*!< Name of the context */
00156 };
00157 
00158 #endif
00159 
00160 struct ast_config *localized_config_load(const char *filename);
00161 struct ast_config *localized_config_load_with_comments(const char *filename);
00162 struct ast_category *localized_category_get(const struct ast_config *config, const char *category_name);
00163 int localized_config_text_file_save(const char *configfile, const struct ast_config *cfg, const char *generator);
00164 struct ast_context *localized_walk_contexts(struct ast_context *con);
00165 struct ast_exten *localized_walk_context_extensions(struct ast_context *con,
00166                                        struct ast_exten *exten);
00167 struct ast_exten *localized_walk_extension_priorities(struct ast_exten *exten,
00168                                          struct ast_exten *priority);
00169 struct ast_include *localized_walk_context_includes(struct ast_context *con,
00170                                        struct ast_include *inc);
00171 struct ast_sw *localized_walk_context_switches(struct ast_context *con,
00172                                     struct ast_sw *sw);
00173 
00174 void localized_context_destroy(struct ast_context *con, const char *registrar);
00175 int localized_pbx_load_module(void);
00176 
00177 /*!
00178  * \version 1.6.1 added tab parameter
00179  * \version 1.6.1 renamed function from localized_context_create to localized_context_find_or_create
00180  */
00181 struct ast_context *localized_context_find_or_create(struct ast_context **extcontexts, void *tab, const char *name, const char *registrar);
00182 int localized_pbx_builtin_setvar(struct ast_channel *chan, void *data);
00183 int localized_context_add_ignorepat2(struct ast_context *con, const char *value, const char *registrar);
00184 int localized_context_add_switch2(struct ast_context *con, const char *value,
00185                          const char *data, int eval, const char *registrar);
00186 int localized_context_add_include2(struct ast_context *con, const char *value,
00187                           const char *registrar);
00188 int localized_add_extension2(struct ast_context *con,
00189                       int replace, const char *extension, int priority, const char *label, const char *callerid,
00190                       const char *application, void *data, void (*datad)(void *),
00191                       const char *registrar);
00192 
00193 /*!
00194  * \version 1.6.1 added tab parameter
00195  */
00196 void localized_merge_contexts_and_delete(struct ast_context **extcontexts, void *tab, const char *registrar);
00197 int localized_context_verify_includes(struct ast_context *con);
00198 void localized_use_conf_dir(void);
00199 void localized_use_local_dir(void);
00200 
00201 
00202 #ifndef _ASTERISK_PBX_H
00203 /*!
00204  * When looking up extensions, we can have different requests
00205  * identified by the 'action' argument, as follows.
00206  * Note that the coding is such that the low 4 bits are the
00207  * third argument to extension_match_core.
00208  */
00209 enum ext_match_t {
00210    E_MATCHMORE =  0x00, /* extension can match but only with more 'digits' */
00211    E_CANMATCH =   0x01, /* extension can match with or without more 'digits' */
00212    E_MATCH =   0x02, /* extension is an exact match */
00213    E_MATCH_MASK = 0x03, /* mask for the argument to extension_match_core() */
00214    E_SPAWN =   0x12, /* want to spawn an extension. Requires exact match */
00215    E_FINDLABEL =  0x22  /* returns the priority for a given label. Requires exact match */
00216 };
00217 #define AST_PBX_MAX_STACK  128
00218 
00219 /* request and result for pbx_find_extension */
00220 struct pbx_find_info {
00221 #if 0
00222    const char *context;
00223    const char *exten;
00224    int priority;
00225 #endif
00226 
00227    char *incstack[AST_PBX_MAX_STACK];      /* filled during the search */
00228    int stacklen;                   /* modified during the search */
00229    int status;                     /* set on return */
00230    struct ast_switch *swo;         /* set on return */
00231    const char *data;               /* set on return */
00232    const char *foundcontext;       /* set on return */
00233 };
00234 
00235 #define STATUS_NO_CONTEXT  1
00236 #define STATUS_NO_EXTENSION   2
00237 #define STATUS_NO_PRIORITY 3
00238 #define STATUS_NO_LABEL    4
00239 #define STATUS_SUCCESS     5
00240 
00241 #endif
00242 
00243 struct ast_exten *localized_find_extension(struct ast_context *bypass,
00244                                 struct pbx_find_info *q,
00245                                 const char *context,
00246                                 const char *exten,
00247                                 int priority,
00248                                 const char *label,
00249                                 const char *callerid,
00250                                 enum ext_match_t action);
00251 
00252 
00253 #if defined(__cplusplus) || defined(c_plusplus)
00254 }
00255 #endif
00256 
00257 #endif /* _ASTERISK_PBX_H */

Generated on Fri Jun 19 12:09:43 2009 for Asterisk - the Open Source PBX by  doxygen 1.4.7