Asterisk - The Open Source Telephony Project  GIT-master-932eae6
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  ast_mutex_t macrolock; /*!< A lock to implement "exclusive" macros - held whilst a call is executing in the macro */
161  char name[0]; /*!< Name of the context */
162 };
163 
164 #endif
165 
166 struct ast_config *localized_config_load(const char *filename);
167 struct ast_config *localized_config_load_with_comments(const char *filename);
168 struct ast_category *localized_category_get(const struct ast_config *config, const char *category_name);
169 int localized_config_text_file_save(const char *configfile, const struct ast_config *cfg, const char *generator);
170 struct ast_context *localized_walk_contexts(struct ast_context *con);
172  struct ast_exten *exten);
174  struct ast_exten *priority);
176  struct ast_include *inc);
178  struct ast_sw *sw);
179 
180 void localized_context_destroy(struct ast_context *con, const char *registrar);
181 int localized_pbx_load_module(void);
182 
183 /*!
184  * \version 1.6.1 added tab parameter
185  * \version 1.6.1 renamed function from localized_context_create to localized_context_find_or_create
186  */
187 struct ast_context *localized_context_find_or_create(struct ast_context **extcontexts, void *tab, const char *name, const char *registrar);
188 int localized_pbx_builtin_setvar(struct ast_channel *chan, const void *data);
189 int localized_context_add_ignorepat2(struct ast_context *con, const char *value, const char *registrar);
190 int localized_context_add_switch2(struct ast_context *con, const char *value,
191  const char *data, int eval, const char *registrar);
192 int localized_context_add_include2(struct ast_context *con, const char *value,
193  const char *registrar);
194 int localized_add_extension2(struct ast_context *con,
195  int replace, const char *extension, int priority, const char *label, const char *callerid,
196  const char *application, void *data, void (*datad)(void *),
197  const char *registrar);
198 
199 /*!
200  * \version 1.6.1 added tab parameter
201  */
202 void localized_merge_contexts_and_delete(struct ast_context **extcontexts, void *tab, const char *registrar);
204 void localized_use_conf_dir(void);
205 void localized_use_local_dir(void);
206 
207 
208 #ifndef _ASTERISK_PBX_H
209 /*!
210  * When looking up extensions, we can have different requests
211  * identified by the 'action' argument, as follows.
212  * Note that the coding is such that the low 4 bits are the
213  * third argument to extension_match_core.
214  */
216  E_MATCHMORE = 0x00, /* extension can match but only with more 'digits' */
217  E_CANMATCH = 0x01, /* extension can match with or without more 'digits' */
218  E_MATCH = 0x02, /* extension is an exact match */
219  E_MATCH_MASK = 0x03, /* mask for the argument to extension_match_core() */
220  E_SPAWN = 0x12, /* want to spawn an extension. Requires exact match */
221  E_FINDLABEL = 0x22 /* returns the priority for a given label. Requires exact match */
222 };
223 #ifdef LOW_MEMORY
224 #define AST_PBX_MAX_STACK 128
225 #else
226 #define AST_PBX_MAX_STACK 512
227 #endif
228 
229 /* request and result for pbx_find_extension */
231 #if 0
232  const char *context;
233  const char *exten;
234  int priority;
235 #endif
236 
237  char *incstack[AST_PBX_MAX_STACK]; /* filled during the search */
238  int stacklen; /* modified during the search */
239  int status; /* set on return */
240  struct ast_switch *swo; /* set on return */
241  const char *data; /* set on return */
242  const char *foundcontext; /* set on return */
243 };
244 
245 #define STATUS_NO_CONTEXT 1
246 #define STATUS_NO_EXTENSION 2
247 #define STATUS_NO_PRIORITY 3
248 #define STATUS_NO_LABEL 4
249 #define STATUS_SUCCESS 5
250 
251 #endif
252 
253 struct ast_exten *localized_find_extension(struct ast_context *bypass,
254  struct pbx_find_info *q,
255  const char *context,
256  const char *exten,
257  int priority,
258  const char *label,
259  const char *callerid,
260  enum ext_match_t action);
261 
262 
263 #if defined(__cplusplus) || defined(c_plusplus)
264 }
265 #endif
266 
267 #endif /* _ASTERISK_PBX_H */
struct ast_config * localized_config_load_with_comments(const char *filename)
Definition: extconf.c:3305
ast_include: include= support in extensions.conf
Definition: pbx_include.c:37
static const char synopsis[]
Definition: app_mysql.c:64
enum sip_cc_notify_state state
Definition: chan_sip.c:957
static char exten[AST_MAX_EXTENSION]
Definition: chan_alsa.c:118
Main Channel structure associated with a channel.
const char pattern[0]
Definition: pbx_ignorepat.c:39
struct ast_exten * localized_walk_extension_priorities(struct ast_exten *exten, struct ast_exten *priority)
Definition: extconf.c:4071
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&#39;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:4989
static SQLHSTMT execute(struct odbc_obj *obj, void *data, int silent)
Common execution function for SQL queries.
Definition: func_odbc.c:454
struct ast_comment * next
Definition: main/config.c:85
struct ast_context * localized_walk_contexts(struct ast_context *con)
Definition: extconf.c:4032
char * config
Definition: conf2ael.c:66
char cmt[0]
Definition: main/config.c:87
Structure for variables, used for configurations and for channel variables.
int localized_context_add_ignorepat2(struct ast_context *con, const char *value, const char *registrar)
Definition: extconf.c:4601
#define AST_DECLARE_STRING_FIELDS(field_list)
Declare the fields needed in a structure.
Definition: stringfields.h:337
struct ast_exten * localized_walk_context_extensions(struct ast_context *con, struct ast_exten *exten)
Definition: extconf.c:4053
int localized_config_text_file_save(const char *configfile, const struct ast_config *cfg, const char *generator)
Definition: extconf.c:3423
struct ast_config * localized_config_load(const char *filename)
Definition: extconf.c:3287
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:4470
const char * data
int value
Definition: syslog.c:37
char stuff[0]
Definition: pbx.c:257
static int priority
char stuff[0]
Definition: pbx_include.c:47
void localized_use_local_dir(void)
Definition: extconf.c:3110
struct ast_exten * peer
Definition: pbx.c:250
ast_sw: Switch statement in extensions.conf
Definition: pbx_sw.c:37
const char * data
Definition: extconf.h:241
void localized_merge_contexts_and_delete(struct ast_context **extcontexts, void *tab, const char *registrar)
Definition: extconf.c:5618
struct sla_ringing_trunk * last
Definition: app_meetme.c:1092
ast_mutex_t lock
Definition: app_meetme.c:1091
struct ast_sw * localized_walk_context_switches(struct ast_context *con, struct ast_sw *sw)
Definition: extconf.c:4152
#define AST_STRING_FIELD(name)
Declare a string field.
Definition: stringfields.h:299
structure to hold extensions
int localized_context_add_include2(struct ast_context *con, const char *value, const char *registrar)
Definition: extconf.c:4559
struct ast_variable * root
Definition: main/config.c:240
char stuff[0]
Contents of file, name, and value in that order stuffed here.
AST_LIST_HEAD_NOLOCK(contactliststruct, contact)
static struct ast_generator generator
Definition: app_fax.c:359
ast_ignorepat: Ignore patterns in dial plan
Definition: pbx_ignorepat.c:37
int localized_context_add_switch2(struct ast_context *con, const char *value, const char *data, int eval, const char *registrar)
Definition: extconf.c:4702
#define AST_PBX_MAX_STACK
Definition: extconf.h:226
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
Definition: linkedlists.h:409
static char * registrar
Definition: pbx_ael.c:78
static int matchcid(const char *cidpattern, const char *callerid)
Definition: pbx.c:2473
static const char name[]
Definition: cdr_mysql.c:74
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:4898
const char * foundcontext
Definition: extconf.h:242
void localized_context_destroy(struct ast_context *con, const char *registrar)
Definition: extconf.c:5565
struct ast_include * localized_walk_context_includes(struct ast_context *con, struct ast_include *inc)
Definition: extconf.c:4106
int stacklen
Definition: extconf.h:238
int localized_pbx_load_module(void)
Definition: extconf.c:5647
struct ast_category * localized_category_get(const struct ast_config *config, const char *category_name)
Definition: extconf.c:2803
#define AST_RWLIST_ENTRY
Definition: linkedlists.h:414
static int replace(struct ast_channel *chan, const char *cmd, char *data, struct ast_str **buf, ssize_t len)
Definition: func_strings.c:790
Structure for rwlock and tracking information.
Definition: lock.h:156
ast_app: A registered application
Definition: pbx_app.c:45
ext_match_t
Definition: extconf.h:215
int localized_context_verify_includes(struct ast_context *con)
Definition: extconf.c:5640
struct ast_switch * swo
Definition: extconf.h:240
void * data
Definition: pbx.c:248
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
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:116
static const char app[]
Definition: app_mysql.c:62
ast_context: An extension context - must remain in sync with fake_context
Definition: pbx.c:284
Structure for mutex and tracking information.
Definition: lock.h:135
int localized_pbx_builtin_setvar(struct ast_channel *chan, const void *data)
Definition: extconf.c:2607
void localized_use_conf_dir(void)
Definition: extconf.c:3115