Asterisk - The Open Source Telephony Project  21.4.1
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)
28 extern "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 
37 struct ast_comment {
38  struct ast_comment *next;
39  char cmt[0];
40 };
41 
42 struct 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 */
48  struct ast_comment *precomments;
49  struct ast_comment *sameline;
50  struct ast_variable *next;
51  char stuff[0];
52 };
53 
54 struct ast_category {
55  char name[80];
56  int ignored; /*!< do not let user of the config see this category */
57  int include_level;
58  struct ast_comment *precomments;
59  struct ast_comment *sameline;
60  struct ast_variable *root;
61  struct ast_variable *last;
62  struct ast_category *next;
63 };
64 
65 struct 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;
71  int max_include_level;
72 };
73 
74 /* ================== above: the config world; below, the dialplan world */
75 
76 /*! \brief A registered application */
77 struct 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 */
97 struct 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 */
114 typedef int (*ast_state_cb_type)(const char *context, const char *exten, enum ast_extension_states state, void *data);
115 struct 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 */
123 struct 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 */
134 struct ast_sw {
135  char *name;
136  const char *registrar; /*!< Registrar */
137  char *data; /*!< Data load */
138  int eval;
139  AST_LIST_ENTRY(ast_sw) list;
140  char *tmpdata;
141  char stuff[0];
142 };
143 
144 /*! \brief Ignore patterns in dial plan */
145 struct ast_ignorepat {
146  const char *registrar;
147  struct ast_ignorepat *next;
148  const char pattern[0];
149 };
150 
151 /*! \brief An extension context */
152 struct 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 
165 struct ast_config *localized_config_load(const char *filename);
166 struct ast_config *localized_config_load_with_comments(const char *filename);
167 struct ast_category *localized_category_get(const struct ast_config *config, const char *category_name);
168 int localized_config_text_file_save(const char *configfile, const struct ast_config *cfg, const char *generator);
169 struct ast_context *localized_walk_contexts(struct ast_context *con);
170 struct ast_exten *localized_walk_context_extensions(struct ast_context *con,
171  struct ast_exten *exten);
172 struct ast_exten *localized_walk_extension_priorities(struct ast_exten *exten,
173  struct ast_exten *priority);
174 struct ast_include *localized_walk_context_includes(struct ast_context *con,
175  struct ast_include *inc);
176 struct ast_sw *localized_walk_context_switches(struct ast_context *con,
177  struct ast_sw *sw);
178 
179 void localized_context_destroy(struct ast_context *con, const char *registrar);
180 int localized_pbx_load_module(void);
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  */
186 struct ast_context *localized_context_find_or_create(struct ast_context **extcontexts, void *tab, const char *name, const char *registrar);
187 int localized_pbx_builtin_setvar(struct ast_channel *chan, const void *data);
188 int localized_context_add_ignorepat2(struct ast_context *con, const char *value, const char *registrar);
189 int localized_context_add_switch2(struct ast_context *con, const char *value,
190  const char *data, int eval, const char *registrar);
191 int localized_context_add_include2(struct ast_context *con, const char *value,
192  const char *registrar);
193 int localized_add_extension2(struct ast_context *con,
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  */
201 void localized_merge_contexts_and_delete(struct ast_context **extcontexts, void *tab, const char *registrar);
202 int localized_context_verify_includes(struct ast_context *con);
203 void localized_use_conf_dir(void);
204 void 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 */
221 };
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 
252 struct 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 */
ast_include: include= support in extensions.conf
Definition: pbx_include.c:37
struct ast_variable * next
struct ast_category * next
Definition: main/config.c:246
const ast_string_field description
Definition: pbx_app.c:53
Main Channel structure associated with a channel.
ast_extension_states
Extension states.
Definition: pbx.h:61
ast_exten: An extension The dialplan is saved as a linked list with each context having it's own link...
Definition: pbx.c:237
Structure to keep comments for rewriting configuration files.
Definition: main/config.c:84
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_include * next
Definition: extconf.c:2370
const ast_string_field synopsis
Definition: pbx_app.c:53
char cmt[0]
Definition: main/config.c:87
Structure for variables, used for configurations and for channel variables.
#define AST_DECLARE_STRING_FIELDS(field_list)
Declare the fields needed in a structure.
Definition: stringfields.h:341
const char * data
const char * registrar
Definition: pbx.c:253
struct ast_context * next
Definition: pbx.c:292
struct ast_category * last
Definition: main/config.c:253
struct ast_exten * next
Definition: pbx.c:256
int priority
Definition: pbx.c:243
struct ast_exten * peer
Definition: pbx.c:250
ast_sw: Switch statement in extensions.conf
Definition: pbx_sw.c:37
ast_mutex_t lock
void localized_merge_contexts_and_delete(struct ast_context **extcontexts, void *tab, const char *registrar)
Definition: extconf.c:5615
#define AST_STRING_FIELD(name)
Declare a string field.
Definition: stringfields.h:303
structure to hold extensions
struct ast_variable * root
Definition: main/config.c:240
char stuff[0]
Contents of file, name, and value in that order stuffed here.
struct ast_category * last_browse
Definition: main/config.c:255
#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
char * exten
Definition: pbx.c:238
const ast_string_field syntax
Definition: pbx_app.c:53
ast_ignorepat: Ignore patterns in dial plan
Definition: pbx_ignorepat.c:37
const ast_string_field name
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
Definition: linkedlists.h:410
enum ast_doc_src docsrc
Definition: pbx_app.c:55
struct ast_variable * last
Definition: main/config.c:242
Structure for rwlock and tracking information.
Definition: lock.h:157
ast_app: A registered application
Definition: pbx_app.c:45
ext_match_t
Definition: extconf.h:214
const ast_string_field seealso
Definition: pbx_app.c:53
void * data
Definition: pbx.c:248
struct ast_category * root
Definition: main/config.c:251
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_context: An extension context
Definition: pbx.c:284
char exten[AST_MAX_EXTENSION]
const ast_string_field arguments
Definition: pbx_app.c:53