Asterisk - The Open Source Telephony Project GIT-master-f36a736
extconf.h
Go to the documentation of this file.
1/*
2 * Asterisk -- An open source telephony toolkit.
3 *
4 * Copyright (C) 2007, Digium, Inc.
5 *
6 * Steve Murphy <murf@digium.com>
7 *
8 * See http://www.asterisk.org for more information about
9 * the Asterisk project. Please do not directly contact
10 * any of the maintainers of this project for assistance;
11 * the project provides a web site, mailing lists and IRC
12 * channels for your use.
13 *
14 * This program is free software, distributed under the terms of
15 * the GNU General Public License Version 2. See the LICENSE file
16 * at the top of the source tree.
17 */
18/*! \file
19 * \brief External configuration handlers (realtime and static configuration)
20 * \author Steve Murphy <murf@digium.com>
21 *
22 */
23
24#ifndef _ASTERISK_EXTCONF_H
25#define _ASTERISK_EXTCONF_H
26
27#if defined(__cplusplus) || defined(c_plusplus)
28extern "C" {
29#endif
30
31#ifdef NOTYET
32/* I'm going to define all the structs mentioned below, to avoid
33 possible conflicts in declarations that might be introduced,
34 if we just include the files that define them-- this may be
35 unnecessary */
36
37struct ast_comment {
38 struct ast_comment *next;
39 char cmt[0];
40};
41
42struct ast_variable {
43 char *name;
44 char *value;
45 int lineno;
46 int object; /*!< 0 for variable, 1 for object */
47 int blanklines; /*!< Number of blanklines following entry */
49 struct ast_comment *sameline;
50 struct ast_variable *next;
51 char stuff[0];
52};
53
54struct ast_category {
55 char name[80];
56 int ignored; /*!< do not let user of the config see this category */
57 int include_level;
59 struct ast_comment *sameline;
60 struct ast_variable *root;
61 struct ast_variable *last;
62 struct ast_category *next;
63};
64
65struct ast_config {
66 struct ast_category *root;
67 struct ast_category *last;
68 struct ast_category *current;
69 struct ast_category *last_browse; /*!< used to cache the last category supplied via category_browse */
70 int include_level;
72};
73
74/* ================== above: the config world; below, the dialplan world */
75
76/*! \brief A registered application */
77struct ast_app {
78 int (*execute)(struct ast_channel *chan, void *data);
80 AST_STRING_FIELD(synopsis); /*!< Synopsis text for 'show applications' */
81 AST_STRING_FIELD(description); /*!< Description (help text) for 'show application &lt;name&gt;' */
82 AST_STRING_FIELD(syntax); /*!< Syntax text for 'core show applications' */
83 AST_STRING_FIELD(arguments); /*!< Arguments description */
84 AST_STRING_FIELD(seealso); /*!< See also */
85 );
86 enum ast_xmldoc_src docsrc; /*!< Where the documentation come from. */
87 AST_RWLIST_ENTRY(ast_app) list; /*!< Next app in list */
88 void *module; /*!< Module this app belongs to */
89 char name[0]; /*!< Name of the application */
90};
91/*!
92 \brief An extension
93 The dialplan is saved as a linked list with each context
94 having it's own linked list of extensions - one item per
95 priority.
96*/
97struct ast_exten {
98 char *exten; /*!< Extension name */
99 int matchcid; /*!< Match caller id ? */
100 const char *cidmatch; /*!< Caller id to match for this extension */
101 int priority; /*!< Priority */
102 const char *label; /*!< Label */
103 struct ast_context *parent; /*!< The context this extension belongs to */
104 const char *app; /*!< Application to execute */
105 struct ast_app *cached_app; /*!< Cached location of application */
106 void *data; /*!< Data to use (arguments) */
107 void (*datad)(void *); /*!< Data destructor */
108 struct ast_exten *peer; /*!< Next higher priority with our extension */
109 const char *registrar; /*!< Registrar */
110 struct ast_exten *next; /*!< Extension with a greater ID */
111 char stuff[0];
112};
113/* from pbx.h */
114typedef int (*ast_state_cb_type)(const char *context, const char *exten, enum ast_extension_states state, void *data);
115struct ast_timing {
116 int hastime; /*!< If time construct exists */
117 unsigned int monthmask; /*!< Mask for month */
118 unsigned int daymask; /*!< Mask for date */
119 unsigned int dowmask; /*!< Mask for day of week (mon-sun) */
120 unsigned int minmask[24]; /*!< Mask for minute */
121};
122/*! \brief include= support in extensions.conf */
123struct ast_include {
124 const char *name;
125 const char *rname; /*!< Context to include */
126 const char *registrar; /*!< Registrar */
127 int hastime; /*!< If time construct exists */
128 struct ast_timing timing; /*!< time construct */
129 struct ast_include *next; /*!< Link them together */
130 char stuff[0];
131};
132
133/*! \brief Switch statement in extensions.conf */
134struct ast_sw {
135 char *name;
136 const char *registrar; /*!< Registrar */
137 char *data; /*!< Data load */
138 int eval;
140 char *tmpdata;
141 char stuff[0];
142};
143
144/*! \brief Ignore patterns in dial plan */
145struct ast_ignorepat {
146 const char *registrar;
147 struct ast_ignorepat *next;
148 const char pattern[0];
149};
150
151/*! \brief An extension context */
152struct ast_context {
153 ast_rwlock_t lock; /*!< A lock to prevent multiple threads from clobbering the context */
154 struct ast_exten *root; /*!< The root of the list of extensions */
155 struct ast_context *next; /*!< Link them together */
156 struct ast_include *includes; /*!< Include other contexts */
157 struct ast_ignorepat *ignorepats; /*!< Patterns for which to continue playing dialtone */
158 const char *registrar; /*!< Registrar */
159 AST_LIST_HEAD_NOLOCK(, ast_sw) alts; /*!< Alternative switches */
160 char name[0]; /*!< Name of the context */
161};
162
163#endif
164
165struct ast_config *localized_config_load(const char *filename);
166struct ast_config *localized_config_load_with_comments(const char *filename);
167struct ast_category *localized_category_get(const struct ast_config *config, const char *category_name);
168int localized_config_text_file_save(const char *configfile, const struct ast_config *cfg, const char *generator);
171 struct ast_exten *exten);
173 struct ast_exten *priority);
175 struct ast_include *inc);
177 struct ast_sw *sw);
178
179void localized_context_destroy(struct ast_context *con, const char *registrar);
181
182/*!
183 * \version 1.6.1 added tab parameter
184 * \version 1.6.1 renamed function from localized_context_create to localized_context_find_or_create
185 */
186struct ast_context *localized_context_find_or_create(struct ast_context **extcontexts, void *tab, const char *name, const char *registrar);
187int localized_pbx_builtin_setvar(struct ast_channel *chan, const void *data);
188int localized_context_add_ignorepat2(struct ast_context *con, const char *value, const char *registrar);
189int localized_context_add_switch2(struct ast_context *con, const char *value,
190 const char *data, int eval, const char *registrar);
191int localized_context_add_include2(struct ast_context *con, const char *value,
192 const char *registrar);
194 int replace, const char *extension, int priority, const char *label, const char *callerid,
195 const char *application, void *data, void (*datad)(void *),
196 const char *registrar);
197
198/*!
199 * \version 1.6.1 added tab parameter
200 */
201void localized_merge_contexts_and_delete(struct ast_context **extcontexts, void *tab, const char *registrar);
203void localized_use_conf_dir(void);
204void localized_use_local_dir(void);
205
206
207#ifndef _ASTERISK_PBX_H
208/*!
209 * When looking up extensions, we can have different requests
210 * identified by the 'action' argument, as follows.
211 * Note that the coding is such that the low 4 bits are the
212 * third argument to extension_match_core.
213 */
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 */
222#ifdef LOW_MEMORY
223#define AST_PBX_MAX_STACK 128
224#else
225#define AST_PBX_MAX_STACK 512
226#endif
227
228/* request and result for pbx_find_extension */
230#if 0
231 const char *context;
232 const char *exten;
233 int priority;
234#endif
235
236 char *incstack[AST_PBX_MAX_STACK]; /* filled during the search */
237 int stacklen; /* modified during the search */
238 int status; /* set on return */
239 struct ast_switch *swo; /* set on return */
240 const char *data; /* set on return */
241 const char *foundcontext; /* set on return */
242};
243
244#define STATUS_NO_CONTEXT 1
245#define STATUS_NO_EXTENSION 2
246#define STATUS_NO_PRIORITY 3
247#define STATUS_NO_LABEL 4
248#define STATUS_SUCCESS 5
249
250#endif
251
252struct ast_exten *localized_find_extension(struct ast_context *bypass,
253 struct pbx_find_info *q,
254 const char *context,
255 const char *exten,
256 int priority,
257 const char *label,
258 const char *callerid,
259 enum ext_match_t action);
260
261
262#if defined(__cplusplus) || defined(c_plusplus)
263}
264#endif
265
266#endif /* _ASTERISK_PBX_H */
enum cc_state state
Definition: ccss.c:393
static int priority
static const char config[]
Definition: chan_ooh323.c:111
#define AST_PBX_MAX_STACK
Definition: extconf.h:225
int localized_context_add_ignorepat2(struct ast_context *con, const char *value, const char *registrar)
Definition: extconf.c:4599
int localized_context_add_include2(struct ast_context *con, const char *value, const char *registrar)
Definition: extconf.c:4557
struct ast_sw * localized_walk_context_switches(struct ast_context *con, struct ast_sw *sw)
Definition: extconf.c:4150
int localized_pbx_builtin_setvar(struct ast_channel *chan, const void *data)
Definition: extconf.c:2605
struct ast_context * localized_walk_contexts(struct ast_context *con)
Definition: extconf.c:4030
struct ast_include * localized_walk_context_includes(struct ast_context *con, struct ast_include *inc)
Definition: extconf.c:4104
struct ast_exten * localized_walk_context_extensions(struct ast_context *con, struct ast_exten *exten)
Definition: extconf.c:4051
ext_match_t
Definition: extconf.h:214
@ 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
struct ast_exten * localized_walk_extension_priorities(struct ast_exten *exten, struct ast_exten *priority)
Definition: extconf.c:4069
int localized_context_add_switch2(struct ast_context *con, const char *value, const char *data, int eval, const char *registrar)
Definition: extconf.c:4700
int localized_context_verify_includes(struct ast_context *con)
Definition: extconf.c:5637
struct ast_config * localized_config_load_with_comments(const char *filename)
Definition: extconf.c:3303
void localized_merge_contexts_and_delete(struct ast_context **extcontexts, void *tab, const char *registrar)
Definition: extconf.c:5615
void localized_context_destroy(struct ast_context *con, const char *registrar)
Definition: extconf.c:5562
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)
Definition: extconf.c:4895
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: extconf.c:4468
int localized_config_text_file_save(const char *configfile, const struct ast_config *cfg, const char *generator)
Definition: extconf.c:3421
void localized_use_conf_dir(void)
Definition: extconf.c:3113
int localized_pbx_load_module(void)
Definition: extconf.c:5644
struct ast_config * localized_config_load(const char *filename)
Definition: extconf.c:3285
void localized_use_local_dir(void)
Definition: extconf.c:3108
struct ast_context * localized_context_find_or_create(struct ast_context **extcontexts, void *tab, const char *name, const char *registrar)
Definition: extconf.c:4986
struct ast_category * localized_category_get(const struct ast_config *config, const char *category_name)
Definition: extconf.c:2801
static const char name[]
Definition: format_mp3.c:68
static int replace(struct ast_channel *chan, const char *cmd, char *data, struct ast_str **buf, ssize_t len)
Definition: func_strings.c:888
#define AST_LIST_HEAD_NOLOCK(name, type)
Defines a structure to be used to hold a list of specified type (with no lock).
Definition: linkedlists.h:225
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
Definition: linkedlists.h:410
#define AST_RWLIST_ENTRY
Definition: linkedlists.h:415
int(* ast_state_cb_type)(const char *context, const char *exten, struct ast_state_cb_info *info, void *data)
Typedef for devicestate and hint callbacks.
Definition: pbx.h:112
ast_extension_states
Extension states.
Definition: pbx.h:61
static char * registrar
Definition: pbx_ael.c:78
#define AST_DECLARE_STRING_FIELDS(field_list)
Declare the fields needed in a structure.
Definition: stringfields.h:341
#define AST_STRING_FIELD(name)
Declare a string field.
Definition: stringfields.h:303
ast_app: A registered application
Definition: pbx_app.c:45
const ast_string_field description
Definition: pbx_app.c:53
const ast_string_field synopsis
Definition: pbx_app.c:53
enum ast_doc_src docsrc
Definition: pbx_app.c:55
const ast_string_field seealso
Definition: pbx_app.c:53
const ast_string_field syntax
Definition: pbx_app.c:53
const ast_string_field arguments
Definition: pbx_app.c:53
int(* execute)(struct ast_channel *chan, const char *data)
Definition: pbx_app.c:46
struct ast_comment * precomments
Definition: main/config.c:237
char name[80]
Definition: main/config.c:227
struct ast_category * next
Definition: main/config.c:247
struct ast_variable * last
Definition: main/config.c:243
struct ast_variable * root
Definition: main/config.c:241
struct ast_comment * sameline
Definition: main/config.c:238
Main Channel structure associated with a channel.
const char * data
Structure to keep comments for rewriting configuration files.
Definition: main/config.c:85
char cmt[0]
Definition: main/config.c:88
struct ast_comment * next
Definition: main/config.c:86
struct ast_category * current
Definition: main/config.c:255
int include_level
Definition: main/config.c:257
int max_include_level
Definition: main/config.c:258
struct ast_category * last
Definition: main/config.c:254
struct ast_category * root
Definition: main/config.c:252
struct ast_category * last_browse
Definition: main/config.c:256
ast_context: An extension context
Definition: pbx.c:284
struct ast_sws alts
Definition: pbx.c:295
struct ast_exten * root
Definition: pbx.c:289
struct ast_ignorepats ignorepats
Definition: pbx.c:294
struct ast_includes includes
Definition: pbx.c:293
const char * registrar
Definition: pbx.c:286
char data[]
Definition: pbx.c:304
struct ast_context * next
Definition: pbx.c:292
ast_rwlock_t lock
Definition: pbx.c:288
const char * name
Definition: pbx.c:285
ast_exten: An extension The dialplan is saved as a linked list with each context having it's own link...
Definition: pbx.c:237
char * exten
Definition: pbx.c:238
char stuff[0]
Definition: pbx.c:257
const char * app
Definition: pbx.c:246
struct ast_app * cached_app
Definition: pbx.c:247
const char * registrar
Definition: pbx.c:253
const char * cidmatch
Definition: pbx.c:241
struct ast_context * parent
Definition: pbx.c:245
struct ast_exten * peer
Definition: pbx.c:250
void * data
Definition: pbx.c:248
struct ast_exten * next
Definition: pbx.c:256
int priority
Definition: pbx.c:243
void(* datad)(void *)
Definition: pbx.c:249
const char * label
Definition: pbx.c:244
int matchcid
Definition: pbx.c:240
ast_ignorepat: Ignore patterns in dial plan
Definition: pbx_ignorepat.c:37
const char pattern[0]
Definition: pbx_ignorepat.c:39
const char * registrar
Definition: pbx_ignorepat.c:38
struct ast_ignorepat * next
Definition: extconf.c:2388
ast_include: include= support in extensions.conf
Definition: pbx_include.c:37
struct ast_timing timing
Definition: pbx_include.c:46
const char * rname
Definition: pbx_include.c:40
char stuff[0]
Definition: pbx_include.c:47
const char * registrar
Definition: pbx_include.c:42
struct ast_include * next
Definition: extconf.c:2370
const char * name
Definition: pbx_include.c:38
Structure for rwlock and tracking information.
Definition: lock.h:157
ast_sw: Switch statement in extensions.conf
Definition: pbx_sw.c:37
char stuff[0]
Definition: pbx_sw.c:45
int eval
Definition: pbx_sw.c:43
char * tmpdata
Definition: extconf.c:2381
const char * registrar
Definition: pbx_sw.c:40
const char * data
Definition: pbx_sw.c:42
const char * name
Definition: pbx_sw.c:38
struct ast_sw::@379 list
unsigned int monthmask
Definition: pbx.h:173
unsigned int daymask
Definition: pbx.h:174
unsigned int minmask[48]
Definition: pbx.h:176
int hastime
Definition: pbx.h:172
unsigned int dowmask
Definition: pbx.h:175
Structure for variables, used for configurations and for channel variables.
char stuff[0]
Contents of file, name, and value in that order stuffed here.
struct ast_comment * precomments
struct ast_comment * sameline
struct ast_variable * next
structure to hold extensions
int stacklen
Definition: extconf.h:237
struct ast_switch * swo
Definition: extconf.h:239
char * incstack[AST_PBX_MAX_STACK]
Definition: extconf.h:236
const char * foundcontext
Definition: extconf.h:241
const char * data
Definition: extconf.h:240
int value
Definition: syslog.c:37