Asterisk - The Open Source Telephony Project  GIT-master-1f78ee9
pbx.h
Go to the documentation of this file.
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 1999 - 2006, Digium, Inc.
5  *
6  * Mark Spencer <markster@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 
19 /*! \file
20  * \brief Core PBX routines and definitions.
21  */
22 
23 #ifndef _ASTERISK_PBX_H
24 #define _ASTERISK_PBX_H
25 
26 #include "asterisk/channel.h"
27 #include "asterisk/sched.h"
28 #include "asterisk/devicestate.h"
29 #include "asterisk/presencestate.h"
30 #include "asterisk/chanvars.h"
31 #include "asterisk/hashtab.h"
32 #include "asterisk/stringfields.h"
33 #include "asterisk/xmldoc.h"
34 #include "asterisk/format.h"
35 
36 #if defined(__cplusplus) || defined(c_plusplus)
37 extern "C" {
38 #endif
39 
40 #define AST_MAX_APP 32 /*!< Max length of an application */
41 
42 #define AST_PBX_GOTO_FAILED -3
43 #define AST_PBX_KEEP 0
44 #define AST_PBX_REPLACE 1
45 
46 /*! \brief Special return values from applications to the PBX
47  * @{ */
48 #define AST_PBX_HANGUP -1 /*!< Jump to the 'h' exten */
49 #define AST_PBX_OK 0 /*!< No errors */
50 #define AST_PBX_ERROR 1 /*!< Jump to the 'e' exten */
51 #define AST_PBX_INCOMPLETE 12 /*!< Return to PBX matching, allowing more digits for the extension */
52 /*! @} */
53 
54 #define PRIORITY_HINT -1 /*!< Special Priority for a hint */
55 
56 /*!
57  * \brief Extension states
58  * \note States can be combined
59  * \ref AstExtState
60  */
62  AST_EXTENSION_REMOVED = -2, /*!< Extension removed */
63  AST_EXTENSION_DEACTIVATED = -1, /*!< Extension hint removed */
64  AST_EXTENSION_NOT_INUSE = 0, /*!< No device INUSE or BUSY */
65  AST_EXTENSION_INUSE = 1 << 0, /*!< One or more devices INUSE */
66  AST_EXTENSION_BUSY = 1 << 1, /*!< All devices BUSY */
67  AST_EXTENSION_UNAVAILABLE = 1 << 2, /*!< All devices UNAVAILABLE/UNREGISTERED */
68  AST_EXTENSION_RINGING = 1 << 3, /*!< All devices RINGING */
69  AST_EXTENSION_ONHOLD = 1 << 4, /*!< All devices ONHOLD */
70 };
71 
72 /*!
73  * \brief extension matchcid types
74  * \note matchcid in ast_exten retains 0/1, this adds 3rd state for functions to specify all
75  * \see ast_context_remove_extension_callerid
76  */
78  AST_EXT_MATCHCID_OFF = 0, /*!< Match only extensions with matchcid=0 */
79  AST_EXT_MATCHCID_ON = 1, /*!< Match only extensions with matchcid=1 AND cidmatch matches */
80  AST_EXT_MATCHCID_ANY = 2, /*!< Match both - used only in functions manipulating ast_exten's */
81 };
82 
83 struct ast_context;
84 struct ast_exten;
85 struct ast_include;
86 struct ast_ignorepat;
87 struct ast_sw;
88 
90  /*! The extension state update is a result of a device state changing on the extension. */
92  /*! The extension state update is a result of presence state changing on the extension. */
94 };
95 
99  char device_name[1];
100 };
101 
104  enum ast_extension_states exten_state;
105  struct ao2_container *device_state_info; /* holds ast_device_state_info, must be referenced by callback if stored */
106  enum ast_presence_state presence_state;
107  const char *presence_subtype;
108  const char *presence_message;
109 };
110 
111 /*! \brief Typedef for devicestate and hint callbacks */
112 typedef int (*ast_state_cb_type)(const char *context, const char *exten, struct ast_state_cb_info *info, void *data);
113 
114 /*! \brief Typedef for devicestate and hint callback removal indication callback */
115 typedef void (*ast_state_cb_destroy_type)(int id, void *data);
116 
117 /*! \brief Data structure associated with a custom dialplan function */
119  const char *name; /*!< Name */
121  AST_STRING_FIELD(synopsis); /*!< Synopsis text for 'show functions' */
122  AST_STRING_FIELD(desc); /*!< Description (help text) for 'show functions &lt;name&gt;' */
123  AST_STRING_FIELD(syntax); /*!< Syntax text for 'core show functions' */
124  AST_STRING_FIELD(arguments); /*!< Arguments description */
125  AST_STRING_FIELD(seealso); /*!< See also */
126  );
127  enum ast_doc_src docsrc; /*!< Where the documentation come from */
128  /*! Read function, if read is supported */
129  ast_acf_read_fn_t read; /*!< Read function, if read is supported */
130  /*! Read function, if read is supported. Note: only one of read or read2
131  * needs to be implemented. In new code, read2 should be implemented as
132  * the way forward, but they should return identical results, within the
133  * constraints of buffer size, if both are implemented. That is, if the
134  * read function is handed a 16-byte buffer, and the result is 17 bytes
135  * long, then the first 15 bytes (remember NULL terminator) should be
136  * the same for both the read and the read2 methods. */
138  /*! If no read2 function is provided, what maximum size? */
139  size_t read_max;
140  /*! Write function, if write is supported */
141  ast_acf_write_fn_t write; /*!< Write function, if write is supported */
142  struct ast_module *mod; /*!< Module this custom function belongs to */
143  unsigned int read_escalates:1; /*!< The read function is to be considered
144  * 'dangerous', and should not be run directly
145  * from external interfaces (AMI, ARI, etc.)
146  * \since 12 */
147  unsigned int write_escalates:1; /*!< The write function is to be considerd
148  * 'dangerous', and should not be run directly
149  * from external interfaces (AMI, ARI, etc.)
150  * \since 12 */
151 
153 };
154 
155 /*! \brief All switch functions have the same interface, so define a type for them */
156 typedef int (ast_switch_f)(struct ast_channel *chan, const char *context,
157  const char *exten, int priority, const char *callerid, const char *data);
158 
159 /*!< Data structure associated with an Asterisk switch */
160 struct ast_switch {
162  const char *name; /*!< Name of the switch */
163  const char *description; /*!< Description of the switch */
164 
169 };
170 
171 struct ast_timing {
172  int hastime; /*!< If time construct exists */
173  unsigned int monthmask; /*!< Mask for month */
174  unsigned int daymask; /*!< Mask for date */
175  unsigned int dowmask; /*!< Mask for day of week (sun-sat) */
176  unsigned int minmask[48]; /*!< Mask for minute */
177  char *timezone; /*!< NULL, or zoneinfo style timezone */
178 };
179 
180 /*!
181  * \brief Construct a timing bitmap, for use in time-based conditionals.
182  * \param i Pointer to an ast_timing structure.
183  * \param info Standard string containing a timerange, weekday range, monthday range, and month range, as well as an optional timezone.
184  * \retval Returns 1 on success or 0 on failure.
185  */
186 int ast_build_timing(struct ast_timing *i, const char *info);
187 
188 /*!
189  * \brief Evaluate a pre-constructed bitmap as to whether the current time falls within the range specified.
190  * \param i Pointer to an ast_timing structure.
191  * \retval Returns 1, if the time matches or 0, if the current time falls outside of the specified range.
192  */
193 int ast_check_timing(const struct ast_timing *i);
194 
195 /*!
196  * \brief Evaluate a pre-constructed bitmap as to whether a particular time falls within the range specified.
197  * \param i Pointer to an ast_timing structure.
198  * \param tv Specified time
199  * \retval Returns 1, if the time matches or 0, if the time falls outside of the specified range.
200  */
201 int ast_check_timing2(const struct ast_timing *i, const struct timeval tv);
202 
203 /*!
204  * \brief Deallocates memory structures associated with a timing bitmap.
205  * \param i Pointer to an ast_timing structure.
206  * \retval 0 success
207  * \retval non-zero failure (number suitable to pass to \see strerror)
208  */
209 int ast_destroy_timing(struct ast_timing *i);
210 
211 struct ast_pbx {
212  int dtimeoutms; /*!< Timeout between digits (milliseconds) */
213  int rtimeoutms; /*!< Timeout for response (milliseconds) */
214 };
215 
216 
217 /*!
218  * \brief Register an alternative dialplan switch
219  *
220  * \param sw switch to register
221  *
222  * This function registers a populated ast_switch structure with the
223  * asterisk switching architecture.
224  *
225  * \retval 0 success
226  * \retval non-zero failure
227  */
228 int ast_register_switch(struct ast_switch *sw);
229 
230 /*!
231  * \brief Unregister an alternative switch
232  *
233  * \param sw switch to unregister
234  *
235  * Unregisters a switch from asterisk.
236  *
237  * \return nothing
238  */
239 void ast_unregister_switch(struct ast_switch *sw);
240 
241 /*!
242  * \brief Look up an application
243  *
244  * \param app name of the app
245  *
246  * This function searches for the ast_app structure within
247  * the apps that are registered for the one with the name
248  * you passed in.
249  *
250  * \return the ast_app structure that matches on success, or NULL on failure
251  */
252 struct ast_app *pbx_findapp(const char *app);
253 
254 /*!
255  * \brief Execute an application
256  *
257  * \param c channel to execute on
258  * \param app which app to execute
259  * \param data the data passed into the app
260  *
261  * This application executes an application on a given channel. It
262  * saves the stack and executes the given application passing in
263  * the given data.
264  *
265  * \retval 0 success
266  * \retval -1 failure
267  */
268 int pbx_exec(struct ast_channel *c, struct ast_app *app, const char *data);
269 
270 /*!
271  * \brief Register a new context or find an existing one
272  *
273  * \param extcontexts pointer to the ast_context structure pointer
274  * \param exttable pointer to the hashtable that contains all the elements in extcontexts
275  * \param name name of the new context
276  * \param registrar registrar of the context
277  *
278  * This function allows you to play in two environments: the global contexts (active dialplan)
279  * or an external context set of your choosing. To act on the external set, make sure extcontexts
280  * and exttable are set; for the globals, make sure both extcontexts and exttable are NULL.
281  *
282  * This will first search for a context with your name. If it exists already, it will not
283  * create a new one. If it does not exist, it will create a new one with the given name
284  * and registrar.
285  *
286  * \return NULL on failure, and an ast_context structure on success
287  */
288 struct ast_context *ast_context_find_or_create(struct ast_context **extcontexts, struct ast_hashtab *exttable, const char *name, const char *registrar);
289 
290 /*!
291  * \brief Enable or disable autohints support on a context
292  *
293  * \param con pointer to the context
294  * \param enabled whether autohints are enabled
295  *
296  */
297 void ast_context_set_autohints(struct ast_context *con, int enabled);
298 
299 /*!
300  * \brief Merge the temporary contexts into a global contexts list and delete from the
301  * global list the ones that are being added
302  *
303  * \param extcontexts pointer to the ast_context structure
304  * \param exttable pointer to the ast_hashtab structure that contains all the elements in extcontexts
305  * \param registrar of the context; if it's set the routine will delete all contexts
306  * that belong to that registrar; if NULL only the contexts that are specified
307  * in extcontexts
308  */
309 void ast_merge_contexts_and_delete(struct ast_context **extcontexts, struct ast_hashtab *exttable, const char *registrar);
310 
311 /*!
312  * \brief Destroy a context by name
313  *
314  * \param context Name of the context to destroy
315  * \param registrar who registered it
316  *
317  * You can optionally leave out the registrar parameter. It will find it
318  * based on the context name.
319  *
320  * \retval -1 context not found
321  * \retval 0 Success
322  */
323 int ast_context_destroy_by_name(const char *context, const char *registrar);
324 
325 /*!
326  * \brief Destroy a context (matches the specified context or ANY context if NULL)
327  *
328  * \param con context to destroy
329  * \param registrar who registered it
330  *
331  * You can optionally leave out either parameter. It will find it
332  * based on either the ast_context or the registrar name.
333  *
334  * \return nothing
335  */
336 void ast_context_destroy(struct ast_context *con, const char *registrar);
337 
338 /*!
339  * \brief Find a context
340  *
341  * \param name name of the context to find
342  *
343  * Will search for the context with the given name.
344  *
345  * \return the ast_context on success, NULL on failure.
346  */
347 struct ast_context *ast_context_find(const char *name);
348 
349 /*!
350  * \brief The result codes when starting the PBX on a channel with ast_pbx_start.
351  * \note AST_PBX_CALL_LIMIT refers to the maxcalls call limit in asterisk.conf
352  * \see ast_pbx_start
353  */
358 };
359 
360 /*!
361  * \brief Create a new thread and start the PBX
362  *
363  * \param c channel to start the pbx on
364  *
365  * \see ast_pbx_run for a synchronous function to run the PBX in the
366  * current thread, as opposed to starting a new one.
367  *
368  * \retval Zero on success
369  * \retval non-zero on failure
370  */
372 
373 /*!
374  * \brief Execute the PBX in the current thread
375  *
376  * \param c channel to run the pbx on
377  *
378  * This executes the PBX on a given channel. It allocates a new
379  * PBX structure for the channel, and provides all PBX functionality.
380  * See ast_pbx_start for an asynchronous function to run the PBX in a
381  * new thread as opposed to the current one.
382  *
383  * \retval Zero on success
384  * \retval non-zero on failure
385  */
387 
388 /*!
389  * \brief Options for ast_pbx_run()
390  */
391 struct ast_pbx_args {
392  union {
393  /*! Pad this out so that we have plenty of room to add options
394  * but still maintain ABI compatibility over time. */
395  uint64_t __padding;
396  struct {
397  /*! Do not hangup the channel when the PBX is complete. */
398  unsigned int no_hangup_chan:1;
399  };
400  };
401 };
402 
403 /*!
404  * \brief Execute the PBX in the current thread
405  *
406  * \param c channel to run the pbx on
407  * \param args options for the pbx
408  *
409  * This executes the PBX on a given channel. It allocates a new
410  * PBX structure for the channel, and provides all PBX functionality.
411  * See ast_pbx_start for an asynchronous function to run the PBX in a
412  * new thread as opposed to the current one.
413  *
414  * \retval Zero on success
415  * \retval non-zero on failure
416  */
418 
419 /*!
420  * \brief Run the h exten from the given context.
421  * \since 11.0
422  *
423  * \param chan Channel to run the h exten on.
424  * \param context Context the h exten is in.
425  *
426  * \return Nothing
427  */
428 void ast_pbx_h_exten_run(struct ast_channel *chan, const char *context);
429 
430 /*!
431  * \brief Run all hangup handlers on the channel.
432  * \since 11.0
433  *
434  * \param chan Channel to run the hangup handlers on.
435  *
436  * \note Absolutely _NO_ channel locks should be held before calling this function.
437  *
438  * \retval Zero if no hangup handlers run.
439  * \retval non-zero if hangup handlers were run.
440  */
441 int ast_pbx_hangup_handler_run(struct ast_channel *chan);
442 
443 /*!
444  * \brief Init the hangup handler container on a channel.
445  * \since 11.0
446  *
447  * \param chan Channel to init the hangup handler container on.
448  *
449  * \return Nothing
450  */
451 void ast_pbx_hangup_handler_init(struct ast_channel *chan);
452 
453 /*!
454  * \brief Destroy the hangup handler container on a channel.
455  * \since 11.0
456  *
457  * \param chan Channel to destroy the hangup handler container on.
458  *
459  * \return Nothing
460  */
462 
463 /*!
464  * \brief Pop the top of the channel hangup handler stack.
465  * \since 11.0
466  *
467  * \param chan Channel to push the hangup handler onto.
468  *
469  * \retval TRUE if a handler was popped off of the stack.
470  */
471 int ast_pbx_hangup_handler_pop(struct ast_channel *chan);
472 
473 /*!
474  * \brief Push the given hangup handler onto the channel hangup handler stack.
475  * \since 11.0
476  *
477  * \param chan Channel to push the hangup handler onto.
478  * \param handler Gosub application parameter string.
479  *
480  * \return Nothing
481  */
482 void ast_pbx_hangup_handler_push(struct ast_channel *chan, const char *handler);
483 
484 /*!
485  * \brief Add and extension to an extension context.
486  *
487  * \param context context to add the extension to
488  * \param replace
489  * \param extension extension to add
490  * \param priority priority level of extension addition
491  * \param label extension label
492  * \param callerid pattern to match CallerID, or NULL to match any CallerID
493  * \param application application to run on the extension with that priority level
494  * \param data data to pass to the application
495  * \param datad
496  * \param registrar who registered the extension
497  *
498  * \retval 0 success
499  * \retval -1 failure
500  */
501 int ast_add_extension(const char *context, int replace, const char *extension,
502  int priority, const char *label, const char *callerid,
503  const char *application, void *data, void (*datad)(void *), const char *registrar);
504 
505 /*!
506  * \brief Add an extension to an extension context, this time with an ast_context *.
507  *
508  * \param registrar_file optional configuration file that defines this extension
509  * \param registrar_line optional line number of configuration file that defines extension
510  *
511  * \note For details about the other arguments, check ast_add_extension()
512  */
513 int ast_add_extension2(struct ast_context *con, int replace, const char *extension,
514  int priority, const char *label, const char *callerid,
515  const char *application, void *data, void (*datad)(void *), const char *registrar,
516  const char *registrar_file, int registrar_line);
517 
518 /*!
519  * \brief Same as ast_add_extension2, but assumes you have already locked context
520  * \since 12.0.0
521  *
522  * \note con must be write locked prior to calling. For details about the arguments,
523  * check ast_add_extension2()
524  */
525 int ast_add_extension2_nolock(struct ast_context *con, int replace, const char *extension,
526  int priority, const char *label, const char *callerid,
527  const char *application, void *data, void (*datad)(void *), const char *registrar,
528  const char *registrar_file, int registrar_line);
529 
530 /*!
531  * \brief Map devstate to an extension state.
532  *
533  * \param[in] devstate device state
534  *
535  * \return the extension state mapping.
536  */
538 
539 /*!
540  * \brief Uses hint and devicestate callback to get the state of an extension
541  *
542  * \param c this is not important
543  * \param context which context to look in
544  * \param exten which extension to get state
545  *
546  * \return extension state as defined in the ast_extension_states enum
547  */
548 int ast_extension_state(struct ast_channel *c, const char *context, const char *exten);
549 
550 /*!
551  * \brief Uses hint and devicestate callback to get the extended state of an extension
552  * \since 11
553  *
554  * \param c this is not important
555  * \param context which context to look in
556  * \param exten which extension to get state
557  * \param[out] device_state_info ptr to an ao2_container with extended state info, must be unref'd after use.
558  *
559  * \return extension state as defined in the ast_extension_states enum
560  */
561 int ast_extension_state_extended(struct ast_channel *c, const char *context, const char *exten,
562  struct ao2_container **device_state_info);
563 
564 /*!
565  * \brief Uses hint and presence state callback to get the presence state of an extension
566  *
567  * \param c this is not important
568  * \param context which context to look in
569  * \param exten which extension to get state
570  * \param[out] subtype Further information regarding the presence returned
571  * \param[out] message Custom message further describing current presence
572  *
573  * \note The subtype and message are dynamically allocated and must be freed by
574  * the caller of this function.
575  *
576  * \return returns the presence state value.
577  */
578 int ast_hint_presence_state(struct ast_channel *c, const char *context, const char *exten, char **subtype, char **message);
579 
580 /*!
581  * \brief Return string representation of the state of an extension
582  *
583  * \param extension_state is the numerical state delivered by ast_extension_state
584  *
585  * \return the state of an extension as string
586  */
587 const char *ast_extension_state2str(int extension_state);
588 
589 /*!
590  * \brief Add watcher for extension states with destructor.
591  * \since 1.8.9
592  * \since 10.1.0
593  *
594  * \param context which context to look in
595  * \param exten which extension to get state
596  * \param change_cb callback to call if state changed
597  * \param destroy_cb callback to call when the watcher is destroyed.
598  * \param data to pass to callbacks
599  *
600  * \note If context and exten are NULL then the added watcher is global.
601  * The change_cb is called for every extension's state change.
602  *
603  * \note The change_cb is called if the state of an extension is changed.
604  *
605  * \note The destroy_cb is called when the watcher is deleted so the
606  * watcher can release any associated resources.
607  *
608  * \retval -1 on failure
609  * \retval 0 Global watcher added successfully
610  * \retval ID on success
611  */
612 int ast_extension_state_add_destroy(const char *context, const char *exten,
613  ast_state_cb_type change_cb, ast_state_cb_destroy_type destroy_cb, void *data);
614 
615 /*!
616  * \brief Add watcher for extended extension states with destructor.
617  * \since 11
618  *
619  * \param context which context to look in
620  * \param exten which extension to get state
621  * \param change_cb callback to call if state changed
622  * \param destroy_cb callback to call when the watcher is destroyed.
623  * \param data to pass to callbacks
624  *
625  * \note If context and exten are NULL then the added watcher is global.
626  * The change_cb is called for every extension's state change.
627  *
628  * \note The change_cb is called if the state of an extension is changed.
629  * The extended state is passed to the callback in the device_state_info
630  * member of ast_state_cb_info.
631  *
632  * \note The destroy_cb is called when the watcher is deleted so the
633  * watcher can release any associated resources.
634  *
635  * \retval -1 on failure
636  * \retval 0 Global watcher added successfully
637  * \retval ID on success
638  */
639 int ast_extension_state_add_destroy_extended(const char *context, const char *exten,
640  ast_state_cb_type change_cb, ast_state_cb_destroy_type destroy_cb, void *data);
641 
642 /*!
643  * \brief Add watcher for extension states.
644  *
645  * \param context which context to look in
646  * \param exten which extension to get state
647  * \param change_cb callback to call if state changed
648  * \param data to pass to callback
649  *
650  * \note If context and exten are NULL then the added watcher is global.
651  * The change_cb is called for every extension's state change.
652  *
653  * \note The change_cb is called if the state of an extension is changed.
654  *
655  * \retval -1 on failure
656  * \retval 0 Global watcher added successfully
657  * \retval ID on success
658  */
659 int ast_extension_state_add(const char *context, const char *exten,
660  ast_state_cb_type change_cb, void *data);
661 
662 /*!
663  * \brief Add watcher for extended extension states.
664  * \since 11
665  *
666  * \param context which context to look in
667  * \param exten which extension to get state
668  * \param change_cb callback to call if state changed
669  * \param data to pass to callback
670  *
671  * \note If context and exten are NULL then the added watcher is global.
672  * The change_cb is called for every extension's state change.
673  *
674  * \note The change_cb is called if the state of an extension is changed.
675  * The extended state is passed to the callback in the device_state_info
676  * member of ast_state_cb_info.
677  *
678  * \retval -1 on failure
679  * \retval 0 Global watcher added successfully
680  * \retval ID on success
681  */
682 int ast_extension_state_add_extended(const char *context, const char *exten,
683  ast_state_cb_type change_cb, void *data);
684 
685 /*!
686  * \brief Deletes a state change watcher by ID
687  *
688  * \param id of the state watcher to delete (0 for global watcher)
689  * \param change_cb callback to call if state changed (Used if id == 0 (global))
690  *
691  * \retval 0 success
692  * \retval -1 failure
693  */
694 int ast_extension_state_del(int id, ast_state_cb_type change_cb);
695 
696 /*!
697  * \brief If an extension hint exists, return non-zero
698  *
699  * \param hint buffer for hint
700  * \param hintsize size of hint buffer, in bytes
701  * \param name buffer for name portion of hint
702  * \param namesize size of name buffer
703  * \param c Channel from which to return the hint. This is only important when the hint or name contains an expression to be expanded.
704  * \param context which context to look in
705  * \param exten which extension to search for
706  *
707  * \return If an extension within the given context with the priority PRIORITY_HINT
708  * is found, a non zero value will be returned.
709  * Otherwise, 0 is returned.
710  */
711 int ast_get_hint(char *hint, int hintsize, char *name, int namesize,
712  struct ast_channel *c, const char *context, const char *exten);
713 
714 /*!
715  * \brief If an extension hint exists, return non-zero
716  *
717  * \param hint buffer for hint
718  * \param hintsize Maximum size of hint buffer (<0 to prevent growth, >0 to limit growth to that number of bytes, or 0 for unlimited growth)
719  * \param name buffer for name portion of hint
720  * \param namesize Maximum size of name buffer (<0 to prevent growth, >0 to limit growth to that number of bytes, or 0 for unlimited growth)
721  * \param c Channel from which to return the hint. This is only important when the hint or name contains an expression to be expanded.
722  * \param context which context to look in
723  * \param exten which extension to search for
724  *
725  * \return If an extension within the given context with the priority PRIORITY_HINT
726  * is found, a non zero value will be returned.
727  * Otherwise, 0 is returned.
728  */
729 int ast_str_get_hint(struct ast_str **hint, ssize_t hintsize, struct ast_str **name, ssize_t namesize,
730  struct ast_channel *c, const char *context, const char *exten);
731 
732 /*!
733  * \brief Determine whether an extension exists
734  *
735  * \param c this is not important
736  * \param context which context to look in
737  * \param exten which extension to search for
738  * \param priority priority of the action within the extension
739  * \param callerid callerid to search for
740  *
741  * \note It is possible for autoservice to be started and stopped on c during this
742  * function call, it is important that c is not locked prior to calling this. Otherwise
743  * a deadlock may occur
744  *
745  * \return If an extension within the given context(or callerid) with the given priority
746  * is found a non zero value will be returned. Otherwise, 0 is returned.
747  */
748 int ast_exists_extension(struct ast_channel *c, const char *context, const char *exten,
749  int priority, const char *callerid);
750 
751 /*!
752  * \brief Find the priority of an extension that has the specified label
753  *
754  * \param c this is not important
755  * \param context which context to look in
756  * \param exten which extension to search for
757  * \param label label of the action within the extension to match to priority
758  * \param callerid callerid to search for
759  *
760  * \note It is possible for autoservice to be started and stopped on c during this
761  * function call, it is important that c is not locked prior to calling this. Otherwise
762  * a deadlock may occur
763  *
764  * \retval the priority which matches the given label in the extension
765  * \retval -1 if not found.
766  */
767 int ast_findlabel_extension(struct ast_channel *c, const char *context,
768  const char *exten, const char *label, const char *callerid);
769 
770 /*!
771  * \brief Find the priority of an extension that has the specified label
772  *
773  * \note It is possible for autoservice to be started and stopped on c during this
774  * function call, it is important that c is not locked prior to calling this. Otherwise
775  * a deadlock may occur
776  *
777  * \note This function is the same as ast_findlabel_extension, except that it accepts
778  * a pointer to an ast_context structure to specify the context instead of the
779  * name of the context. Otherwise, the functions behave the same.
780  */
781 int ast_findlabel_extension2(struct ast_channel *c, struct ast_context *con,
782  const char *exten, const char *label, const char *callerid);
783 
784 /*!
785  * \brief Looks for a valid matching extension
786  *
787  * \param c not really important
788  * \param context context to serach within
789  * \param exten extension to check
790  * \param priority priority of extension path
791  * \param callerid callerid of extension being searched for
792  *
793  * \note It is possible for autoservice to be started and stopped on c during this
794  * function call, it is important that c is not locked prior to calling this. Otherwise
795  * a deadlock may occur
796  *
797  * \return If "exten" *could be* a valid extension in this context with or without
798  * some more digits, return non-zero. Basically, when this returns 0, no matter
799  * what you add to exten, it's not going to be a valid extension anymore
800  */
801 int ast_canmatch_extension(struct ast_channel *c, const char *context,
802  const char *exten, int priority, const char *callerid);
803 
804 /*!
805  * \brief Looks to see if adding anything to this extension might match something. (exists ^ canmatch)
806  *
807  * \param c not really important XXX
808  * \param context context to serach within
809  * \param exten extension to check
810  * \param priority priority of extension path
811  * \param callerid callerid of extension being searched for
812  *
813  * \note It is possible for autoservice to be started and stopped on c during this
814  * function call, it is important that c is not locked prior to calling this. Otherwise
815  * a deadlock may occur
816  *
817  * \return If "exten" *could match* a valid extension in this context with
818  * some more digits, return non-zero. Does NOT return non-zero if this is
819  * an exact-match only. Basically, when this returns 0, no matter
820  * what you add to exten, it's not going to be a valid extension anymore
821  */
822 int ast_matchmore_extension(struct ast_channel *c, const char *context,
823  const char *exten, int priority, const char *callerid);
824 
825 /*!
826  * \brief Determine if a given extension matches a given pattern (in NXX format)
827  *
828  * \param pattern pattern to match
829  * \param extension extension to check against the pattern.
830  *
831  * Checks whether or not the given extension matches the given pattern.
832  *
833  * \retval 1 on match
834  * \retval 0 on failure
835  */
836 int ast_extension_match(const char *pattern, const char *extension);
837 
838 int ast_extension_close(const char *pattern, const char *data, int needmore);
839 
840 /*!
841  * \brief Determine if one extension should match before another
842  *
843  * \param a extension to compare with b
844  * \param b extension to compare with a
845  *
846  * Checks whether or extension a should match before extension b
847  *
848  * \retval 0 if the two extensions have equal matching priority
849  * \retval 1 on a > b
850  * \retval -1 on a < b
851  */
852 int ast_extension_cmp(const char *a, const char *b);
853 
854 /*!
855  * \brief Launch a new extension (i.e. new stack)
856  *
857  * \param c not important
858  * \param context which context to generate the extension within
859  * \param exten new extension to add
860  * \param priority priority of new extension
861  * \param callerid callerid of extension
862  * \param found
863  * \param combined_find_spawn
864  *
865  * This adds a new extension to the asterisk extension list.
866  *
867  * \note It is possible for autoservice to be started and stopped on c during this
868  * function call, it is important that c is not locked prior to calling this. Otherwise
869  * a deadlock may occur
870  *
871  * \retval 0 on success
872  * \retval -1 on failure.
873  */
874 int ast_spawn_extension(struct ast_channel *c, const char *context,
875  const char *exten, int priority, const char *callerid, int *found, int combined_find_spawn);
876 
877 /*!
878  * \brief Add a context include
879  *
880  * \param context context to add include to
881  * \param include new include to add
882  * \param registrar who's registering it
883  *
884  * Adds an include taking a char * string as the context parameter
885  *
886  * \retval 0 on success
887  * \retval -1 on error
888 */
889 int ast_context_add_include(const char *context, const char *include,
890  const char *registrar);
891 
892 /*!
893  * \brief Add a context include
894  *
895  * \param con context to add the include to
896  * \param value include value to add
897  * \param registrar who registered the context
898  *
899  * Adds an include taking a struct ast_context as the first parameter
900  *
901  * \retval 0 on success
902  * \retval -1 on failure
903  */
904 int ast_context_add_include2(struct ast_context *con, const char *include,
905  const char *registrar);
906 
907 /*!
908  * \brief Remove a context include
909  *
910  * \note See ast_context_add_include for information on arguments
911  *
912  * \retval 0 on success
913  * \retval -1 on failure
914  */
915 int ast_context_remove_include(const char *context, const char *include,
916  const char *registrar);
917 
918 /*!
919  * \brief Removes an include by an ast_context structure
920  *
921  * \note See ast_context_add_include2 for information on arguments
922  *
923  * \retval 0 on success
924  * \retval -1 on success
925  */
926 int ast_context_remove_include2(struct ast_context *con, const char *include,
927  const char *registrar);
928 
929 /*!
930  * \brief Verifies includes in an ast_contect structure
931  *
932  * \param con context in which to verify the includes
933  *
934  * \retval 0 if no problems found
935  * \retval -1 if there were any missing context
936  */
938 
939 /*!
940  * \brief Add a switch
941  *
942  * \param context context to which to add the switch
943  * \param sw switch to add
944  * \param data data to pass to switch
945  * \param eval whether to evaluate variables when running switch
946  * \param registrar whoever registered the switch
947  *
948  * This function registers a switch with the asterisk switch architecture
949  *
950  * \retval 0 on success
951  * \retval -1 on failure
952  */
953 int ast_context_add_switch(const char *context, const char *sw, const char *data,
954  int eval, const char *registrar);
955 
956 /*!
957  * \brief Adds a switch (first param is a ast_context)
958  *
959  * \note See ast_context_add_switch() for argument information, with the exception of
960  * the first argument. In this case, it's a pointer to an ast_context structure
961  * as opposed to the name.
962  */
963 int ast_context_add_switch2(struct ast_context *con, const char *sw, const char *data,
964  int eval, const char *registrar);
965 
966 /*!
967  * \brief Remove a switch
968  *
969  * Removes a switch with the given parameters
970  *
971  * \retval 0 on success
972  * \retval -1 on failure
973  */
974 int ast_context_remove_switch(const char *context, const char *sw,
975  const char *data, const char *registrar);
976 
977 int ast_context_remove_switch2(struct ast_context *con, const char *sw,
978  const char *data, const char *registrar);
979 
980 /*!
981  * \brief Simply remove extension from context
982  *
983  * \param context context to remove extension from
984  * \param extension which extension to remove
985  * \param priority priority of extension to remove (0 to remove all)
986  * \param registrar registrar of the extension
987  *
988  * This function removes an extension from a given context.
989  *
990  * \retval 0 on success
991  * \retval -1 on failure
992  *
993  * @{
994  */
995 int ast_context_remove_extension(const char *context, const char *extension, int priority,
996  const char *registrar);
997 
998 int ast_context_remove_extension2(struct ast_context *con, const char *extension,
999  int priority, const char *registrar, int already_locked);
1000 
1001 int ast_context_remove_extension_callerid(const char *context, const char *extension,
1002  int priority, const char *callerid, int matchcid, const char *registrar);
1003 
1004 int ast_context_remove_extension_callerid2(struct ast_context *con, const char *extension,
1005  int priority, const char *callerid, int matchcid, const char *registrar,
1006  int already_locked);
1007 /*! @} */
1008 
1009 /*!
1010  * \brief Add an ignorepat
1011  *
1012  * \param context which context to add the ignorpattern to
1013  * \param ignorepat ignorepattern to set up for the extension
1014  * \param registrar registrar of the ignore pattern
1015  *
1016  * Adds an ignore pattern to a particular context.
1017  *
1018  * \retval 0 on success
1019  * \retval -1 on failure
1020  */
1021 int ast_context_add_ignorepat(const char *context, const char *ignorepat, const char *registrar);
1022 
1023 int ast_context_add_ignorepat2(struct ast_context *con, const char *ignorepat, const char *registrar);
1024 
1025 /*
1026  * \brief Remove an ignorepat
1027  *
1028  * \param context context from which to remove the pattern
1029  * \param ignorepat the pattern to remove
1030  * \param registrar the registrar of the ignore pattern
1031  *
1032  * This removes the given ignorepattern
1033  *
1034  * \retval 0 on success
1035  * \retval -1 on failure
1036  */
1037 int ast_context_remove_ignorepat(const char *context, const char *ignorepat, const char *registrar);
1038 
1039 int ast_context_remove_ignorepat2(struct ast_context *con, const char *ignorepat, const char *registrar);
1040 
1041 /*!
1042  * \brief Checks to see if a number should be ignored
1043  *
1044  * \param context context to search within
1045  * \param pattern to check whether it should be ignored or not
1046  *
1047  * Check if a number should be ignored with respect to dialtone cancellation.
1048  *
1049  * \retval 0 if the pattern should not be ignored
1050  * \retval non-zero if the pattern should be ignored
1051  */
1052 int ast_ignore_pattern(const char *context, const char *pattern);
1053 
1054 /* Locking functions for outer modules, especially for completion functions */
1055 
1056 /*!
1057  * \brief Write locks the context list
1058  *
1059  * \retval 0 on success
1060  * \retval -1 on error
1061  */
1062 int ast_wrlock_contexts(void);
1063 
1064 /*!
1065  * \brief Read locks the context list
1066  *
1067  * \retval 0 on success
1068  * \retval -1 on error
1069  */
1070 int ast_rdlock_contexts(void);
1071 
1072 /*!
1073  * \brief Unlocks contexts
1074  *
1075  * \retval 0 on success
1076  * \retval -1 on failure
1077  */
1078 int ast_unlock_contexts(void);
1079 
1080 /*!
1081  * \brief Write locks a given context
1082  *
1083  * \param con context to lock
1084  *
1085  * \retval 0 on success
1086  * \retval -1 on failure
1087  */
1088 int ast_wrlock_context(struct ast_context *con);
1089 
1090 /*!
1091  * \brief Read locks a given context
1092  *
1093  * \param con context to lock
1094  *
1095  * \retval 0 on success
1096  * \retval -1 on failure
1097  */
1098 int ast_rdlock_context(struct ast_context *con);
1099 
1100 /*!
1101  * \retval Unlocks the given context
1102  *
1103  * \param con context to unlock
1104  *
1105  * \retval 0 on success
1106  * \retval -1 on failure
1107  */
1108 int ast_unlock_context(struct ast_context *con);
1109 
1110 /*!
1111  * \brief locks the macrolock in the given context
1112  *
1113  * \param macrocontext name of the macro-context to lock
1114  *
1115  * Locks the given macro-context to ensure only one thread (call) can execute it at a time
1116  *
1117  * \retval 0 on success
1118  * \retval -1 on failure
1119  */
1120 int ast_context_lockmacro(const char *macrocontext);
1121 
1122 /*!
1123  * \brief Unlocks the macrolock in the given context
1124  *
1125  * \param macrocontext name of the macro-context to unlock
1126  *
1127  * Unlocks the given macro-context so that another thread (call) can execute it
1128  *
1129  * \retval 0 on success
1130  * \retval -1 on failure
1131  */
1132 int ast_context_unlockmacro(const char *macrocontext);
1133 
1134 /*!
1135  * \brief Set the channel to next execute the specified dialplan location.
1136  * \see ast_async_parseable_goto, ast_async_goto_if_exists
1137  *
1138  * \note Do _NOT_ hold any channel locks when calling this function.
1139  */
1140 int ast_async_goto(struct ast_channel *chan, const char *context, const char *exten, int priority);
1141 
1142 /*!
1143  * \brief Set the channel to next execute the specified dialplan location.
1144  */
1145 int ast_async_goto_by_name(const char *chan, const char *context, const char *exten, int priority);
1146 
1148  AST_OUTGOING_NO_WAIT = 0, /*!< Don't wait for originated call to answer */
1149  AST_OUTGOING_WAIT = 1, /*!< Wait for originated call to answer */
1150  AST_OUTGOING_WAIT_COMPLETE = 2, /*!< Wait for originated call to answer and hangup */
1151 };
1152 
1153 /*!
1154  * \brief Synchronously or asynchronously make an outbound call and send it to a
1155  * particular extension
1156  *
1157  * \param type The channel technology to create
1158  * \param cap The format capabilities for the channel
1159  * \param addr Address data to pass to the channel technology driver
1160  * \param timeout How long we should attempt to dial the outbound channel
1161  * \param context The destination context for the outbound channel
1162  * \param exten The destination extension for the outbound channel
1163  * \param priority The destination priority for the outbound channel
1164  * \param reason Optional. If provided, the dialed status of the outgoing channel.
1165  * Codes are AST_CONTROL_xxx values. Valid only if synchronous is non-zero.
1166  * \param synchronous defined by the ast_pbx_outgoing_sync enum.
1167  * If \c AST_OUTGOING_NO_WAIT then don't wait for anything.
1168  * If \c AST_OUTGOING_WAIT then block until the outbound channel answers or
1169  * the call fails.
1170  * If \c AST_OUTGOING_WAIT_COMPLETE then wait for the call to complete or
1171  * fail.
1172  * If \c AST_OUTGOING_WAIT or \c AST_OUTGOING_WAIT_COMPLETE is specified,
1173  * the call doesn't answer, and \c failed@context exists then run a channel
1174  * named \c OutgoingSpoolFailed at \c failed@context.
1175  * \param cid_num The caller ID number to set on the outbound channel
1176  * \param cid_name The caller ID name to set on the outbound channel
1177  * \param vars Variables to set on the outbound channel
1178  * \param account The accountcode for the outbound channel
1179  * \param locked_channel Optional. The outbound channel that was created if success
1180  * is returned. Otherwise it is set to NULL. This is returned both locked
1181  * and reference bumped.
1182  * \param early_media If non-zero the channel "answers" when progress is indicated.
1183  * \param assignedids Optional. The uniqueid(s) to assign the channel(s) that are created.
1184  *
1185  * \retval 0 on success
1186  * \retval -1 on failure
1187  */
1188 int ast_pbx_outgoing_exten(const char *type, struct ast_format_cap *cap, const char *addr,
1189  int timeout, const char *context, const char *exten, int priority, int *reason,
1190  int synchronous, const char *cid_num, const char *cid_name, struct ast_variable *vars,
1191  const char *account, struct ast_channel **locked_channel, int early_media,
1192  const struct ast_assigned_ids *assignedids);
1193 
1194 int ast_pbx_outgoing_exten_predial(const char *type, struct ast_format_cap *cap, const char *addr,
1195  int timeout, const char *context, const char *exten, int priority, int *reason,
1196  int synchronous, const char *cid_num, const char *cid_name, struct ast_variable *vars,
1197  const char *account, struct ast_channel **locked_channel, int early_media,
1198  const struct ast_assigned_ids *assignedids, const char *predial_callee);
1199 
1200 /*!
1201  * \brief Synchronously or asynchronously make an outbound call and execute an
1202  * application on the channel.
1203  *
1204  * Note that when the application stops executing, the channel is hungup.
1205  *
1206  * \param type The channel technology to create
1207  * \param cap The format capabilities for the channel
1208  * \param addr Address data to pass to the channel technology driver
1209  * \param timeout How long we should attempt to dial the outbound channel
1210  * \param app The name of the application to execute
1211  * \param appdata Data to pass to the application
1212  * \param reason Optional. If provided, the dialed status of the outgoing channel.
1213  * Codes are AST_CONTROL_xxx values. Valid only if synchronous is non-zero.
1214  * \param synchronous defined by the ast_pbx_outgoing_sync enum.
1215  * If \c AST_OUTGOING_NO_WAIT then don't wait for anything.
1216  * If \c AST_OUTGOING_WAIT then block until the outbound channel answers or
1217  * the call fails.
1218  * If \c AST_OUTGOING_WAIT_COMPLETE then wait for the call to complete or
1219  * fail.
1220  * \param cid_num The caller ID number to set on the outbound channel
1221  * \param cid_name The caller ID name to set on the outbound channel
1222  * \param vars Variables to set on the outbound channel
1223  * \param account The accountcode for the outbound channel
1224  * \param locked_channel Optional. The outbound channel that was created if success
1225  * is returned. Otherwise it is set to NULL. This is returned both locked
1226  * and reference bumped.
1227  * \param assignedids Optional. The uniqueid(s) to assign the channel(s) that are created.
1228  *
1229  * \retval 0 on success
1230  * \retval -1 on failure
1231  */
1232 int ast_pbx_outgoing_app(const char *type, struct ast_format_cap *cap, const char *addr,
1233  int timeout, const char *app, const char *appdata, int *reason, int synchronous,
1234  const char *cid_num, const char *cid_name, struct ast_variable *vars,
1235  const char *account, struct ast_channel **locked_channel,
1236  const struct ast_assigned_ids *assignedids);
1237 
1238 int ast_pbx_outgoing_app_predial(const char *type, struct ast_format_cap *cap, const char *addr,
1239  int timeout, const char *app, const char *appdata, int *reason, int synchronous,
1240  const char *cid_num, const char *cid_name, struct ast_variable *vars,
1241  const char *account, struct ast_channel **locked_channel,
1242  const struct ast_assigned_ids *assignedids, const char *predial_callee);
1243 
1244 /*!
1245  * \brief Evaluate a condition
1246  *
1247  * \retval 0 if the condition is NULL or of zero length
1248  * \retval int If the string is an integer, the integer representation of
1249  * the integer is returned
1250  * \retval 1 Any other non-empty string
1251  */
1252 int pbx_checkcondition(const char *condition);
1253 
1254 /*! @name
1255  * Functions for returning values from structures */
1256 /*! @{ */
1257 const char *ast_get_context_name(struct ast_context *con);
1258 const char *ast_get_extension_name(struct ast_exten *exten);
1259 struct ast_context *ast_get_extension_context(struct ast_exten *exten);
1260 const char *ast_get_include_name(const struct ast_include *include);
1261 const char *ast_get_ignorepat_name(const struct ast_ignorepat *ip);
1262 const char *ast_get_switch_name(const struct ast_sw *sw);
1263 const char *ast_get_switch_data(const struct ast_sw *sw);
1264 int ast_get_switch_eval(const struct ast_sw *sw);
1265 
1266 /*! @} */
1267 
1268 /*! @name Other Extension stuff */
1269 /*! @{ */
1270 int ast_get_extension_priority(struct ast_exten *exten);
1271 int ast_get_extension_matchcid(struct ast_exten *e);
1272 const char *ast_get_extension_cidmatch(struct ast_exten *e);
1273 const char *ast_get_extension_app(struct ast_exten *e);
1274 const char *ast_get_extension_label(struct ast_exten *e);
1275 void *ast_get_extension_app_data(struct ast_exten *e);
1276 /*! @} */
1277 
1278 /*! @name Registrar info functions ... */
1279 /*! @{ */
1280 const char *ast_get_context_registrar(struct ast_context *c);
1281 const char *ast_get_extension_registrar(struct ast_exten *e);
1282 const char *ast_get_include_registrar(const struct ast_include *i);
1283 const char *ast_get_ignorepat_registrar(const struct ast_ignorepat *ip);
1284 const char *ast_get_switch_registrar(const struct ast_sw *sw);
1285 /*! @} */
1286 
1287 /*!
1288  * \brief Get name of configuration file used by registrar to register this extension
1289  *
1290  * \retval NULL if registrar did not indicate config file when registering the extension
1291  * \retval name of the file used to register the extension
1292  */
1293 const char *ast_get_extension_registrar_file(struct ast_exten *e);
1294 
1295 /*!
1296  * \brief Get line number of configuration file used by registrar to register this extension
1297  *
1298  * \retval 0 if the line wasn't indicated when the extension was registered
1299  * \retval positive integer indicating what line in the config file was responsible for
1300  * registering the extension.
1301  */
1303 
1304 /*! @name Walking functions ... */
1305 /*! @{ */
1306 struct ast_context *ast_walk_contexts(struct ast_context *con);
1308  struct ast_exten *priority);
1309 struct ast_exten *ast_walk_extension_priorities(struct ast_exten *exten,
1310  struct ast_exten *priority);
1311 const struct ast_include *ast_walk_context_includes(const struct ast_context *con,
1312  const struct ast_include *inc);
1313 const struct ast_ignorepat *ast_walk_context_ignorepats(const struct ast_context *con,
1314  const struct ast_ignorepat *ip);
1315 const struct ast_sw *ast_walk_context_switches(const struct ast_context *con,
1316  const struct ast_sw *sw);
1317 /*! @} */
1318 
1319 /*! @name Iterator functions ... */
1320 /*! @{ */
1321 int ast_context_includes_count(const struct ast_context *con);
1322 const struct ast_include *ast_context_includes_get(const struct ast_context *con, int idx);
1323 int ast_context_ignorepats_count(const struct ast_context *con);
1324 const struct ast_ignorepat *ast_context_ignorepats_get(const struct ast_context *con, int idx);
1325 int ast_context_switches_count(const struct ast_context *con);
1326 const struct ast_sw *ast_context_switches_get(const struct ast_context *con, int idx);
1327 /*! @} */
1328 
1329 /*!
1330  * \brief Create a human-readable string, specifying all variables and their corresponding values.
1331  * \param chan Channel from which to read variables
1332  * \param buf Dynamic string in which to place the result (should be allocated with ast_str_create).
1333  * \see ast_str_create
1334  * \note Will lock the channel.
1335  */
1336 int pbx_builtin_serialize_variables(struct ast_channel *chan, struct ast_str **buf);
1337 
1338 /*!
1339  * \brief Return a pointer to the value of the corresponding channel variable.
1340  * \note Will lock the channel.
1341  *
1342  * \note This function will return a pointer to the buffer inside the channel
1343  * variable. This value should only be accessed with the channel locked. If
1344  * the value needs to be kept around, it should be done by using the following
1345  * thread-safe code:
1346  * \code
1347  * const char *var;
1348  *
1349  * ast_channel_lock(chan);
1350  * if ((var = pbx_builtin_getvar_helper(chan, "MYVAR"))) {
1351  * var = ast_strdupa(var);
1352  * }
1353  * ast_channel_unlock(chan);
1354  * \endcode
1355  */
1356 const char *pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name);
1357 
1358 /*!
1359  * \brief Add a variable to the channel variable stack, without removing any previously set value.
1360  * \note Will lock the channel.
1361  */
1362 void pbx_builtin_pushvar_helper(struct ast_channel *chan, const char *name, const char *value);
1363 
1364 /*!
1365  * \brief Add a variable to the channel variable stack, removing the most recently set value for the same name.
1366  * \note Will lock the channel. May also be used to set a channel dialplan function to a particular value.
1367  * \see ast_func_write
1368  * \return -1 if the dialplan function fails to be set
1369  * \version 1.8 changed the function to return an error code
1370  */
1371 int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value);
1372 
1373 /*!
1374  * \brief Retrieve the value of a builtin variable or variable from the channel variable stack.
1375  * \note Will lock the channel.
1376  */
1377 void pbx_retrieve_variable(struct ast_channel *c, const char *var, char **ret, char *workspace, int workspacelen, struct varshead *headp);
1378 void pbx_builtin_clear_globals(void);
1379 
1380 /*!
1381  * \brief Parse and set a single channel variable, where the name and value are separated with an '=' character.
1382  * \note Will lock the channel.
1383  */
1384 int pbx_builtin_setvar(struct ast_channel *chan, const char *data);
1385 
1386 /*!
1387  * \brief Parse and set multiple channel variables, where the pairs are separated by the ',' character, and name and value are separated with an '=' character.
1388  * \note Will lock the channel.
1389  */
1390 int pbx_builtin_setvar_multiple(struct ast_channel *chan, const char *data);
1391 
1392 int pbx_builtin_raise_exception(struct ast_channel *chan, const char *data);
1393 
1394 /*! @name Substitution routines, using static string buffers
1395  * @{ */
1396 void pbx_substitute_variables_helper(struct ast_channel *c, const char *cp1, char *cp2, int count);
1397 void pbx_substitute_variables_varshead(struct varshead *headp, const char *cp1, char *cp2, int count);
1398 void pbx_substitute_variables_helper_full(struct ast_channel *c, struct varshead *headp, const char *cp1, char *cp2, int cp2_size, size_t *used);
1399 /*! @} */
1400 /*! @} */
1401 
1402 /*! @name Substitution routines, using dynamic string buffers */
1403 
1404 /*!
1405  * \param buf Result will be placed in this buffer.
1406  * \param maxlen -1 if the buffer should not grow, 0 if the buffer may grow to any size, and >0 if the buffer should grow only to that number of bytes.
1407  * \param chan Channel variables from which to extract values, and channel to pass to any dialplan functions.
1408  * \param headp If no channel is specified, a channel list from which to extract variable values
1409  * \param var Variable name to retrieve.
1410  */
1411 const char *ast_str_retrieve_variable(struct ast_str **buf, ssize_t maxlen, struct ast_channel *chan, struct varshead *headp, const char *var);
1412 
1413 /*!
1414  * \param buf Result will be placed in this buffer.
1415  * \param maxlen -1 if the buffer should not grow, 0 if the buffer may grow to any size, and >0 if the buffer should grow only to that number of bytes.
1416  * \param chan Channel variables from which to extract values, and channel to pass to any dialplan functions.
1417  * \param templ Variable template to expand.
1418  */
1419 void ast_str_substitute_variables(struct ast_str **buf, ssize_t maxlen, struct ast_channel *chan, const char *templ);
1420 
1421 /*!
1422  * \param buf Result will be placed in this buffer.
1423  * \param maxlen -1 if the buffer should not grow, 0 if the buffer may grow to any size, and >0 if the buffer should grow only to that number of bytes.
1424  * \param headp If no channel is specified, a channel list from which to extract variable values
1425  * \param templ Variable template to expand.
1426  */
1427 void ast_str_substitute_variables_varshead(struct ast_str **buf, ssize_t maxlen, struct varshead *headp, const char *templ);
1428 
1429 /*!
1430  * \param buf Result will be placed in this buffer.
1431  * \param maxlen -1 if the buffer should not grow, 0 if the buffer may grow to any size, and >0 if the buffer should grow only to that number of bytes.
1432  * \param c Channel variables from which to extract values, and channel to pass to any dialplan functions.
1433  * \param headp If no channel is specified, a channel list from which to extract variable values
1434  * \param templ Variable template to expand.
1435  * \param used Number of bytes read from the template. (May be NULL)
1436  */
1437 void ast_str_substitute_variables_full(struct ast_str **buf, ssize_t maxlen, struct ast_channel *c, struct varshead *headp, const char *templ, size_t *used);
1438 /*! @} */
1439 
1440 int ast_extension_patmatch(const char *pattern, const char *data);
1441 
1442 /*! Set "autofallthrough" flag, if newval is <0, does not actually set. If
1443  set to 1, sets to auto fall through. If newval set to 0, sets to no auto
1444  fall through (reads extension instead). Returns previous value. */
1445 int pbx_set_autofallthrough(int newval);
1446 
1447 /*! Set "extenpatternmatchnew" flag, if newval is <0, does not actually set. If
1448  set to 1, sets to use the new Trie-based pattern matcher. If newval set to 0, sets to use
1449  the old linear-search algorithm. Returns previous value. */
1450 int pbx_set_extenpatternmatchnew(int newval);
1451 
1452 /*! Set "overrideswitch" field. If set and of nonzero length, all contexts
1453  * will be tried directly through the named switch prior to any other
1454  * matching within that context.
1455  * \since 1.6.1
1456  */
1457 void pbx_set_overrideswitch(const char *newval);
1458 
1459 /*!
1460  * \note This function will handle locking the channel as needed.
1461  */
1462 int ast_goto_if_exists(struct ast_channel *chan, const char *context, const char *exten, int priority);
1463 
1464 /*!
1465  * \note This function will handle locking the channel as needed.
1466  */
1467 int ast_parseable_goto(struct ast_channel *chan, const char *goto_string);
1468 
1469 /*!
1470  * \note This function will handle locking the channel as needed.
1471  */
1472 int ast_async_parseable_goto(struct ast_channel *chan, const char *goto_string);
1473 
1474 /*!
1475  * \note This function will handle locking the channel as needed.
1476  */
1477 int ast_explicit_goto(struct ast_channel *chan, const char *context, const char *exten, int priority);
1478 
1479 /*!
1480  * \note This function will handle locking the channel as needed.
1481  */
1482 int ast_async_goto_if_exists(struct ast_channel *chan, const char *context, const char *exten, int priority);
1483 
1484 struct ast_custom_function* ast_custom_function_find(const char *name);
1485 
1486 /*!
1487  * \brief Unregister a custom function
1488  */
1490 
1491 /*!
1492  * \brief Description of the ways in which a function may escalate privileges.
1493  */
1499 };
1500 
1501 /*!
1502  * \brief Register a custom function
1503  */
1504 #define ast_custom_function_register(acf) __ast_custom_function_register(acf, AST_MODULE_SELF)
1505 
1506 /*!
1507  * \brief Register a custom function which requires escalated privileges.
1508  *
1509  * Examples would be SHELL() (for which a read needs permission to execute
1510  * arbitrary code) or FILE() (for which write needs permission to change files
1511  * on the filesystem).
1512  */
1513 #define ast_custom_function_register_escalating(acf, escalation) __ast_custom_function_register_escalating(acf, escalation, AST_MODULE_SELF)
1514 
1515 /*!
1516  * \brief Register a custom function
1517  */
1519 
1520 /*!
1521  * \brief Register a custom function which requires escalated privileges.
1522  *
1523  * Examples would be SHELL() (for which a read needs permission to execute
1524  * arbitrary code) or FILE() (for which write needs permission to change files
1525  * on the filesystem).
1526  */
1528 
1529 /*!
1530  * \brief Retrieve the number of active calls
1531  */
1532 int ast_active_calls(void);
1533 
1534 /*!
1535  * \brief Retrieve the total number of calls processed through the PBX since last restart
1536  */
1537 int ast_processed_calls(void);
1538 
1539 /*!
1540  * \brief executes a read operation on a function
1541  *
1542  * \param chan Channel to execute on
1543  * \param function Data containing the function call string (will be modified)
1544  * \param workspace A pointer to safe memory to use for a return value
1545  * \param len the number of bytes in workspace
1546  *
1547  * This application executes a function in read mode on a given channel.
1548  *
1549  * \retval 0 success
1550  * \retval non-zero failure
1551  */
1552 int ast_func_read(struct ast_channel *chan, const char *function, char *workspace, size_t len);
1553 
1554 /*!
1555  * \brief executes a read operation on a function
1556  *
1557  * \param chan Channel to execute on
1558  * \param function Data containing the function call string (will be modified)
1559  * \param str A dynamic string buffer into which to place the result.
1560  * \param maxlen <0 if the dynamic buffer should not grow; >0 if the dynamic buffer should be limited to that number of bytes; 0 if the dynamic buffer has no upper limit
1561  *
1562  * This application executes a function in read mode on a given channel.
1563  *
1564  * \retval 0 success
1565  * \retval non-zero failure
1566  */
1567 int ast_func_read2(struct ast_channel *chan, const char *function, struct ast_str **str, ssize_t maxlen);
1568 
1569 /*!
1570  * \brief executes a write operation on a function
1571  *
1572  * \param chan Channel to execute on
1573  * \param function Data containing the function call string (will be modified)
1574  * \param value A value parameter to pass for writing
1575  *
1576  * This application executes a function in write mode on a given channel.
1577  *
1578  * \retval 0 success
1579  * \retval non-zero failure
1580  */
1581 int ast_func_write(struct ast_channel *chan, const char *function, const char *value);
1582 
1583 /*!
1584  * \details
1585  * When looking up extensions, we can have different requests
1586  * identified by the 'action' argument, as follows.
1587  *
1588  * \note that the coding is such that the low 4 bits are the
1589  * third argument to extension_match_core.
1590  */
1592  E_MATCHMORE = 0x00, /* extension can match but only with more 'digits' */
1593  E_CANMATCH = 0x01, /* extension can match with or without more 'digits' */
1594  E_MATCH = 0x02, /* extension is an exact match */
1595  E_MATCH_MASK = 0x03, /* mask for the argument to extension_match_core() */
1596  E_SPAWN = 0x12, /* want to spawn an extension. Requires exact match */
1597  E_FINDLABEL = 0x22 /* returns the priority for a given label. Requires exact match */
1598 };
1599 
1600 #define STATUS_NO_CONTEXT 1
1601 #define STATUS_NO_EXTENSION 2
1602 #define STATUS_NO_PRIORITY 3
1603 #define STATUS_NO_LABEL 4
1604 #define STATUS_SUCCESS 5
1605 
1606 #ifdef LOW_MEMORY
1607 #define AST_PBX_MAX_STACK 128
1608 #else
1609 #define AST_PBX_MAX_STACK 512
1610 #endif
1611 
1612 /* request and result for pbx_find_extension */
1613 struct pbx_find_info {
1614 #if 0
1615  const char *context;
1616  const char *exten;
1617  int priority;
1618 #endif
1619 
1620  char *incstack[AST_PBX_MAX_STACK]; /* filled during the search */
1621  int stacklen; /* modified during the search */
1622  int status; /* set on return */
1623  struct ast_switch *swo; /* set on return */
1624  const char *data; /* set on return */
1625  const char *foundcontext; /* set on return */
1626 };
1627 
1628 struct ast_exten *pbx_find_extension(struct ast_channel *chan,
1629  struct ast_context *bypass, struct pbx_find_info *q,
1630  const char *context, const char *exten, int priority,
1631  const char *label, const char *callerid, enum ext_match_t action);
1632 
1633 /*! \brief hashtable functions for contexts */
1634 /*! @{ */
1635 int ast_hashtab_compare_contexts(const void *ah_a, const void *ah_b);
1636 unsigned int ast_hashtab_hash_contexts(const void *obj);
1637 /*! @} */
1638 
1639 /*!
1640  * \brief Command completion for the list of installed applications.
1641  *
1642  * This can be called from a CLI command completion function that wants to
1643  * complete from the list of available applications.
1644  */
1645 char *ast_complete_applications(const char *line, const char *word, int state);
1646 
1647 /*!
1648  * \brief Enable/disable the execution of 'dangerous' functions from external
1649  * protocols (AMI, etc.).
1650  *
1651  * These dialplan functions (such as \c SHELL) provide an opportunity for
1652  * privilege escalation. They are okay to invoke from the dialplan, but external
1653  * protocols with permission controls should not normally invoke them.
1654  *
1655  * This function can globally enable/disable the execution of dangerous
1656  * functions from external protocols.
1657  *
1658  * \param new_live_dangerously If true, enable the execution of escalating
1659  * functions from external protocols.
1660  */
1661 void pbx_live_dangerously(int new_live_dangerously);
1662 
1663 /*!
1664  * \brief Inhibit (in the current thread) the execution of dialplan functions
1665  * which cause privilege escalations. If pbx_live_dangerously() has been
1666  * called, this function has no effect.
1667  *
1668  * \return 0 if successfuly marked current thread.
1669  * \return Non-zero if marking current thread failed.
1670  */
1672 
1673 /*!
1674  * \brief Swap the current thread escalation inhibit setting.
1675  * \since 11.24.0
1676  *
1677  * \param inhibit New setting. Non-zero to inhibit.
1678  *
1679  * \retval 1 if dangerous function execution was inhibited.
1680  * \retval 0 if dangerous function execution was allowed.
1681  * \retval -1 on error.
1682  */
1683 int ast_thread_inhibit_escalations_swap(int inhibit);
1684 
1685 #if defined(__cplusplus) || defined(c_plusplus)
1686 }
1687 #endif
1688 
1689 #endif /* _ASTERISK_PBX_H */
const char * name
Definition: pbx.h:119
ast_include: include= support in extensions.conf
Definition: pbx_include.c:37
static const char synopsis[]
Definition: app_mysql.c:64
int ast_hashtab_compare_contexts(const void *ah_a, const void *ah_b)
hashtable functions for contexts
Definition: ael_main.c:589
static const char type[]
Definition: chan_ooh323.c:109
int hastime
Definition: pbx.h:172
int ast_unlock_context(struct ast_context *con)
Definition: pbx.c:8511
Options for ast_pbx_run()
Definition: pbx.h:391
int ast_get_hint(char *hint, int hintsize, char *name, int namesize, struct ast_channel *c, const char *context, const char *exten)
If an extension hint exists, return non-zero.
Definition: pbx.c:4132
void ast_pbx_h_exten_run(struct ast_channel *chan, const char *context)
Run the h exten from the given context.
Definition: pbx.c:4200
const char * ast_get_switch_name(const struct ast_sw *sw)
Definition: pbx_sw.c:48
const char * ast_get_switch_registrar(const struct ast_sw *sw)
Definition: pbx_sw.c:63
int ast_extension_state_add_destroy_extended(const char *context, const char *exten, ast_state_cb_type change_cb, ast_state_cb_destroy_type destroy_cb, void *data)
Add watcher for extended extension states with destructor.
Definition: pbx.c:3822
int ast_matchmore_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Looks to see if adding anything to this extension might match something. (exists ^ canmatch) ...
Definition: pbx.c:4190
int ast_func_read(struct ast_channel *chan, const char *function, char *workspace, size_t len)
executes a read operation on a function
static char exten[AST_MAX_EXTENSION]
Definition: chan_alsa.c:118
Main Channel structure associated with a channel.
int ast_check_timing2(const struct ast_timing *i, const struct timeval tv)
Evaluate a pre-constructed bitmap as to whether a particular time falls within the range specified...
Definition: pbx_timing.c:251
ast_device_state
Device States.
Definition: devicestate.h:52
unsigned int daymask
Definition: pbx.h:174
int ast_get_extension_priority(struct ast_exten *exten)
Definition: pbx.c:8539
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
int ast_extension_state_add_extended(const char *context, const char *exten, ast_state_cb_type change_cb, void *data)
Add watcher for extended extension states.
Definition: pbx.c:3828
int ast_context_remove_include(const char *context, const char *include, const char *registrar)
Remove a context include.
Definition: pbx.c:4831
const char * presence_message
Definition: pbx.h:108
int ast_context_remove_ignorepat(const char *context, const char *ignorepat, const char *registrar)
Definition: pbx.c:6828
int ast_active_calls(void)
Retrieve the number of active calls.
Definition: pbx.c:4755
const struct ast_sw * ast_walk_context_switches(const struct ast_context *con, const struct ast_sw *sw)
Definition: pbx.c:8604
void pbx_builtin_clear_globals(void)
const char * ast_get_extension_registrar(struct ast_exten *e)
Definition: pbx.c:8552
const char * ast_get_context_name(struct ast_context *con)
Definition: ael_main.c:421
ast_switch_f * exec
Definition: pbx.h:167
int pbx_exec(struct ast_channel *c, struct ast_app *app, const char *data)
Execute an application.
Definition: pbx_app.c:471
const char * ast_get_ignorepat_registrar(const struct ast_ignorepat *ip)
Definition: pbx_ignorepat.c:47
int __ast_custom_function_register_escalating(struct ast_custom_function *acf, enum ast_custom_function_escalation escalation, struct ast_module *mod)
Register a custom function which requires escalated privileges.
int ast_findlabel_extension2(struct ast_channel *c, struct ast_context *con, const char *exten, const char *label, const char *callerid)
Find the priority of an extension that has the specified label.
Definition: extconf.c:4978
Device state management.
int ast_context_lockmacro(const char *macrocontext)
locks the macrolock in the given context
Definition: pbx.c:5153
int ast_extension_state_del(int id, ast_state_cb_type change_cb)
Deletes a state change watcher by ID.
Definition: pbx.c:3849
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
int ast_func_read2(struct ast_channel *chan, const char *function, struct ast_str **str, ssize_t maxlen)
executes a read operation on a function
Channel Variables.
ast_switch_f * matchmore
Definition: pbx.h:168
char device_name[1]
Definition: pbx.h:99
enum ast_pbx_result ast_pbx_start(struct ast_channel *c)
Create a new thread and start the PBX.
Definition: pbx.c:4703
int ast_extension_cmp(const char *a, const char *b)
Determine if one extension should match before another.
Definition: pbx.c:2183
void ast_pbx_hangup_handler_init(struct ast_channel *chan)
Init the hangup handler container on a channel.
int ast_context_switches_count(const struct ast_context *con)
Definition: pbx.c:8633
const char * ast_get_extension_app(struct ast_exten *e)
Definition: pbx.c:8577
uint64_t __padding
Definition: pbx.h:395
ast_custom_function_escalation
Description of the ways in which a function may escalate privileges.
Definition: pbx.h:1494
char * ast_complete_applications(const char *line, const char *word, int state)
Command completion for the list of installed applications.
Definition: pbx_app.c:429
static int timeout
Definition: cdr_mysql.c:86
Generic (perhaps overly so) hashtable implementation Hash Table support in Asterisk.
Structure for variables, used for configurations and for channel variables.
int ast_context_add_switch2(struct ast_context *con, const char *sw, const char *data, int eval, const char *registrar)
Adds a switch (first param is a ast_context)
Definition: ael_main.c:370
#define var
Definition: ast_expr2f.c:614
int pbx_checkcondition(const char *condition)
Evaluate a condition.
Definition: pbx.c:8302
void ast_str_substitute_variables(struct ast_str **buf, ssize_t maxlen, struct ast_channel *chan, const char *templ)
struct ast_context * ast_walk_contexts(struct ast_context *con)
Definition: conf2ael.c:618
static const char desc[]
Definition: cdr_mysql.c:73
Structure to pass both assignedid values to channel drivers.
Definition: channel.h:605
int ast_ignore_pattern(const char *context, const char *pattern)
Checks to see if a number should be ignored.
Definition: pbx.c:6912
int ast_pbx_outgoing_exten_predial(const char *type, struct ast_format_cap *cap, const char *addr, int timeout, const char *context, const char *exten, int priority, int *reason, int synchronous, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel, int early_media, const struct ast_assigned_ids *assignedids, const char *predial_callee)
Definition: pbx.c:7942
void ast_unregister_switch(struct ast_switch *sw)
Unregister an alternative switch.
Definition: pbx_switch.c:76
void * ast_get_extension_app_data(struct ast_exten *e)
Definition: pbx.c:8582
int ast_rdlock_contexts(void)
Read locks the context list.
Definition: pbx.c:8488
const char * ast_get_extension_label(struct ast_exten *e)
Definition: pbx.c:8534
const char * ast_get_include_registrar(const struct ast_include *i)
Definition: pbx_include.c:60
int ast_pbx_hangup_handler_pop(struct ast_channel *chan)
Pop the top of the channel hangup handler stack.
#define AST_DECLARE_STRING_FIELDS(field_list)
Declare the fields needed in a structure.
Definition: stringfields.h:337
int ast_explicit_goto(struct ast_channel *chan, const char *context, const char *exten, int priority)
Definition: pbx.c:6978
struct ast_module * mod
Definition: pbx.h:142
int ast_wrlock_contexts(void)
Write locks the context list.
Definition: pbx.c:8483
static struct test_val c
int ast_context_remove_extension_callerid2(struct ast_context *con, const char *extension, int priority, const char *callerid, int matchcid, const char *registrar, int already_locked)
Definition: pbx.c:4978
int ast_context_remove_include2(struct ast_context *con, const char *include, const char *registrar)
Removes an include by an ast_context structure.
Definition: pbx.c:4854
const char * str
Definition: app_jack.c:147
const char * args
void pbx_builtin_pushvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, without removing any previously set value...
const char * data
const char * ast_get_context_registrar(struct ast_context *c)
Definition: pbx.c:8547
unsigned int write_escalates
Definition: pbx.h:147
int value
Definition: syslog.c:37
int ast_str_get_hint(struct ast_str **hint, ssize_t hintsize, struct ast_str **name, ssize_t namesize, struct ast_channel *c, const char *context, const char *exten)
If an extension hint exists, return non-zero.
Definition: pbx.c:4150
int ast_hint_presence_state(struct ast_channel *c, const char *context, const char *exten, char **subtype, char **message)
Uses hint and presence state callback to get the presence state of an extension.
Definition: pbx.c:3221
int ast_pbx_outgoing_exten(const char *type, struct ast_format_cap *cap, const char *addr, int timeout, const char *context, const char *exten, int priority, int *reason, int synchronous, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel, int early_media, const struct ast_assigned_ids *assignedids)
Synchronously or asynchronously make an outbound call and send it to a particular extension...
Definition: pbx.c:7932
static int priority
static char cid_num[AST_MAX_EXTENSION]
Definition: chan_mgcp.c:164
ast_doc_src
From where the documentation come from, this structure is useful for use it inside application/functi...
Definition: xmldoc.h:30
int ast_context_add_include(const char *context, const char *include, const char *registrar)
Add a context include.
Definition: pbx.c:6697
ast_switch_f * exists
Definition: pbx.h:165
ast_switch_f * canmatch
Definition: pbx.h:166
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
int ast_canmatch_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Looks for a valid matching extension.
Definition: pbx.c:4185
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
int ast_context_remove_extension(const char *context, const char *extension, int priority, const char *registrar)
Simply remove extension from context.
Definition: pbx.c:4943
Media Format API.
int ast_context_destroy_by_name(const char *context, const char *registrar)
Destroy a context by name.
Definition: pbx.c:8225
const char * name
Definition: pbx.h:162
unsigned int monthmask
Definition: pbx.h:173
int ast_context_remove_switch(const char *context, const char *sw, const char *data, const char *registrar)
Remove a switch.
Definition: pbx.c:4889
int ast_get_switch_eval(const struct ast_sw *sw)
Definition: pbx_sw.c:58
const struct ast_include * ast_walk_context_includes(const struct ast_context *con, const struct ast_include *inc)
Definition: conf2ael.c:657
int ast_context_add_include2(struct ast_context *con, const char *include, const char *registrar)
Add a context include.
Definition: ael_main.c:359
Definition: pbx.h:211
const struct ast_sw * ast_context_switches_get(const struct ast_context *con, int idx)
Definition: pbx.c:8638
struct ast_channel * causing_channel
Definition: pbx.h:98
struct ast_context * ast_context_find(const char *name)
Find a context.
Definition: extconf.c:4174
ast_sw: Switch statement in extensions.conf
Definition: pbx_sw.c:37
General Asterisk PBX channel definitions.
int pbx_builtin_raise_exception(struct ast_channel *chan, const char *data)
Definition: pbx_builtins.c:672
ast_state_cb_update_reason
Definition: pbx.h:89
int ast_context_add_ignorepat(const char *context, const char *ignorepat, const char *registrar)
Add an ignorepat.
Definition: pbx.c:6868
ast_presence_state
Definition: presencestate.h:26
Data structure associated with a custom dialplan function.
Definition: pbx.h:118
int(* ast_acf_write_fn_t)(struct ast_channel *chan, const char *function, char *data, const char *value)
Typedef for a custom write function.
Definition: channel.h:587
enum ast_pbx_result ast_pbx_run_args(struct ast_channel *c, struct ast_pbx_args *args)
Execute the PBX in the current thread.
Definition: pbx.c:4730
void(* ast_state_cb_destroy_type)(int id, void *data)
Typedef for devicestate and hint callback removal indication callback.
Definition: pbx.h:115
int ast_parseable_goto(struct ast_channel *chan, const char *goto_string)
Definition: pbx.c:8840
int pbx_set_extenpatternmatchnew(int newval)
Definition: pbx.c:4772
Definition: pbx.h:1596
unsigned int read_escalates
Definition: pbx.h:143
Scheduler Routines (derived from cheops)
#define AST_STRING_FIELD(name)
Declare a string field.
Definition: stringfields.h:299
structure to hold extensions
ast_ext_matchcid_types
extension matchcid types
Definition: pbx.h:77
const char * ast_extension_state2str(int extension_state)
Return string representation of the state of an extension.
Definition: pbx.c:3126
const char * presence_subtype
Definition: pbx.h:107
size_t read_max
Definition: pbx.h:139
enum ast_device_state device_state
Definition: pbx.h:97
int ast_extension_state_add_destroy(const char *context, const char *exten, ast_state_cb_type change_cb, ast_state_cb_destroy_type destroy_cb, void *data)
Add watcher for extension states with destructor.
Definition: pbx.c:3810
ast_acf_write_fn_t write
Definition: pbx.h:141
void ast_str_substitute_variables_full(struct ast_str **buf, ssize_t maxlen, struct ast_channel *c, struct varshead *headp, const char *templ, size_t *used)
int pbx_set_autofallthrough(int newval)
Definition: pbx.c:4765
const char * ast_get_extension_cidmatch(struct ast_exten *e)
Definition: pbx.c:8572
int ast_exists_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Determine whether an extension exists.
Definition: pbx.c:4170
int() ast_switch_f(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)
All switch functions have the same interface, so define a type for them.
Definition: pbx.h:156
ast_pbx_result
The result codes when starting the PBX on a channel with ast_pbx_start.
Definition: pbx.h:354
#define AST_PBX_MAX_STACK
Definition: pbx.h:1609
int ast_extension_state_extended(struct ast_channel *c, const char *context, const char *exten, struct ao2_container **device_state_info)
Uses hint and devicestate callback to get the extended state of an extension.
Definition: pbx.c:3171
const char * ast_get_ignorepat_name(const struct ast_ignorepat *ip)
Definition: pbx_ignorepat.c:42
struct ao2_container * device_state_info
Definition: pbx.h:105
int ast_context_includes_count(const struct ast_context *con)
Definition: pbx.c:8678
Presence state management.
struct ast_custom_function * ast_custom_function_find(const char *name)
Definition: ael_main.c:173
int ast_processed_calls(void)
Retrieve the total number of calls processed through the PBX since last restart.
Definition: pbx.c:4760
unsigned int dowmask
Definition: pbx.h:175
ast_pbx_outgoing_sync
Definition: pbx.h:1147
ast_acf_read2_fn_t read2
Definition: pbx.h:137
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
Definition: strings.h:584
Format capabilities structure, holds formats + preference order + etc.
Definition: format_cap.c:54
void ast_str_substitute_variables_varshead(struct ast_str **buf, ssize_t maxlen, struct varshead *headp, const char *templ)
void pbx_retrieve_variable(struct ast_channel *c, const char *var, char **ret, char *workspace, int workspacelen, struct varshead *headp)
Retrieve the value of a builtin variable or variable from the channel variable stack.
void ast_merge_contexts_and_delete(struct ast_context **extcontexts, struct ast_hashtab *exttable, const char *registrar)
Merge the temporary contexts into a global contexts list and delete from the global list the ones tha...
Definition: conf2ael.c:639
int ast_check_timing(const struct ast_timing *i)
Evaluate a pre-constructed bitmap as to whether the current time falls within the range specified...
Definition: extconf.c:4002
ast_ignorepat: Ignore patterns in dial plan
Definition: pbx_ignorepat.c:37
int ast_unlock_contexts(void)
Unlocks contexts.
Definition: pbx.c:8493
int ast_findlabel_extension(struct ast_channel *c, const char *context, const char *exten, const char *label, const char *callerid)
Find the priority of an extension that has the specified label.
Definition: pbx.c:4175
def info(msg)
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
int ast_thread_inhibit_escalations_swap(int inhibit)
Swap the current thread escalation inhibit setting.
int ast_extension_patmatch(const char *pattern, const char *data)
int pbx_builtin_setvar_multiple(struct ast_channel *chan, const char *data)
Parse and set multiple channel variables, where the pairs are separated by the &#39;,&#39; character...
int ast_context_remove_extension_callerid(const char *context, const char *extension, int priority, const char *callerid, int matchcid, const char *registrar)
Definition: pbx.c:4948
const char * ast_get_extension_name(struct ast_exten *exten)
Definition: pbx.c:8529
int ast_wrlock_context(struct ast_context *con)
Write locks a given context.
Definition: pbx.c:8501
int ast_goto_if_exists(struct ast_channel *chan, const char *context, const char *exten, int priority)
Definition: pbx.c:8774
int ast_pbx_outgoing_app(const char *type, struct ast_format_cap *cap, const char *addr, int timeout, const char *app, const char *appdata, int *reason, int synchronous, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel, const struct ast_assigned_ids *assignedids)
Synchronously or asynchronously make an outbound call and execute an application on the channel...
Definition: pbx.c:7996
struct ast_exten * ast_walk_context_extensions(struct ast_context *con, struct ast_exten *priority)
Definition: ael_main.c:427
#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
enum ast_extension_states ast_devstate_to_extenstate(enum ast_device_state devstate)
Map devstate to an extension state.
Definition: pbx.c:3006
int ast_destroy_timing(struct ast_timing *i)
Deallocates memory structures associated with a timing bitmap.
Definition: pbx_timing.c:285
static int matchcid(const char *cidpattern, const char *callerid)
Definition: pbx.c:2473
int ast_extension_match(const char *pattern, const char *extension)
Determine if a given extension matches a given pattern (in NXX format)
Definition: extconf.c:4297
unsigned int ast_hashtab_hash_contexts(const void *obj)
Definition: ael_main.c:596
void pbx_live_dangerously(int new_live_dangerously)
Enable/disable the execution of &#39;dangerous&#39; functions from external protocols (AMI, etc.).
int ast_register_switch(struct ast_switch *sw)
Register an alternative dialplan switch.
Definition: pbx_switch.c:58
void ast_pbx_hangup_handler_push(struct ast_channel *chan, const char *handler)
Push the given hangup handler onto the channel hangup handler stack.
int ast_extension_close(const char *pattern, const char *data, int needmore)
Definition: pbx.c:2418
Asterisk XML Documentation API.
const char * ast_get_switch_data(const struct ast_sw *sw)
Definition: pbx_sw.c:53
int pbx_builtin_setvar(struct ast_channel *chan, const char *data)
Parse and set a single channel variable, where the name and value are separated with an &#39;=&#39; character...
int ast_async_goto_if_exists(struct ast_channel *chan, const char *context, const char *exten, int priority)
Definition: pbx.c:8779
int ast_build_timing(struct ast_timing *i, const char *info)
Construct a timing bitmap, for use in time-based conditionals.
Definition: extconf.c:3808
int ast_spawn_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid, int *found, int combined_find_spawn)
Launch a new extension (i.e. new stack)
Definition: pbx.c:4195
static char cid_name[AST_MAX_EXTENSION]
Definition: chan_mgcp.c:165
#define AST_RWLIST_ENTRY
Definition: linkedlists.h:414
const struct ast_ignorepat * ast_walk_context_ignorepats(const struct ast_context *con, const struct ast_ignorepat *ip)
Definition: pbx.c:8688
int(* ast_acf_read2_fn_t)(struct ast_channel *chan, const char *cmd, char *data, struct ast_str **str, ssize_t len)
Typedef for a custom read2 function.
Definition: channel.h:581
int ast_pbx_hangup_handler_run(struct ast_channel *chan)
Run all hangup handlers on the channel.
static int replace(struct ast_channel *chan, const char *cmd, char *data, struct ast_str **buf, ssize_t len)
Definition: func_strings.c:790
int ast_async_parseable_goto(struct ast_channel *chan, const char *goto_string)
Definition: pbx.c:8845
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name...
int(* ast_acf_read_fn_t)(struct ast_channel *chan, const char *function, char *data, char *buf, size_t len)
Typedef for a custom read function.
Definition: channel.h:575
const char * ast_get_include_name(const struct ast_include *include)
Definition: pbx_include.c:50
int ast_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, const char *registrar_file, int registrar_line)
Add an extension to an extension context, this time with an ast_context *.
Definition: pbx.c:7290
const char * ast_str_retrieve_variable(struct ast_str **buf, ssize_t maxlen, struct ast_channel *chan, struct varshead *headp, const char *var)
char * timezone
Definition: pbx.h:177
int ast_add_extension(const char *context, int replace, const char *extension, int priority, const char *label, const char *callerid, const char *application, void *data, void(*datad)(void *), const char *registrar)
Add and extension to an extension context.
Definition: pbx.c:6961
int dtimeoutms
Definition: pbx.h:212
Definition: pbx.h:1594
ast_acf_read_fn_t read
Definition: pbx.h:129
struct ast_exten * ast_walk_extension_priorities(struct ast_exten *exten, struct ast_exten *priority)
Definition: extconf.c:4063
int ast_extension_state(struct ast_channel *c, const char *context, const char *exten)
Uses hint and devicestate callback to get the state of an extension.
Definition: pbx.c:3165
ast_app: A registered application
Definition: pbx_app.c:45
ext_match_t
Definition: extconf.h:215
static void handler(const char *name, int response_code, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
Definition: test_ari.c:59
void ast_pbx_hangup_handler_destroy(struct ast_channel *chan)
Destroy the hangup handler container on a channel.
int ast_async_goto(struct ast_channel *chan, const char *context, const char *exten, int priority)
Set the channel to next execute the specified dialplan location.
Definition: pbx.c:7002
void pbx_substitute_variables_helper(struct ast_channel *c, const char *cp1, char *cp2, int count)
Definition: ael_main.c:211
int ast_get_extension_registrar_line(struct ast_exten *e)
Get line number of configuration file used by registrar to register this extension.
Definition: pbx.c:8562
void pbx_set_overrideswitch(const char *newval)
Definition: pbx.c:4779
int ast_thread_inhibit_escalations(void)
Inhibit (in the current thread) the execution of dialplan functions which cause privilege escalations...
enum ast_pbx_result ast_pbx_run(struct ast_channel *c)
Execute the PBX in the current thread.
Definition: pbx.c:4750
int ast_context_remove_extension2(struct ast_context *con, const char *extension, int priority, const char *registrar, int already_locked)
This functionc locks given context, search for the right extension and fires out all peer in this ext...
Definition: pbx.c:4973
int __ast_custom_function_register(struct ast_custom_function *acf, struct ast_module *mod)
Register a custom function.
void ast_context_destroy(struct ast_context *con, const char *registrar)
Destroy a context (matches the specified context or ANY context if NULL)
Definition: conf2ael.c:625
int ast_context_ignorepats_count(const struct ast_context *con)
Definition: pbx.c:8721
int ast_pbx_outgoing_app_predial(const char *type, struct ast_format_cap *cap, const char *addr, int timeout, const char *app, const char *appdata, int *reason, int synchronous, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel, const struct ast_assigned_ids *assignedids, const char *predial_callee)
Definition: pbx.c:8006
static struct test_val b
void pbx_substitute_variables_helper_full(struct ast_channel *c, struct varshead *headp, const char *cp1, char *cp2, int cp2_size, size_t *used)
enum queue_result id
Definition: app_queue.c:1510
int ast_context_verify_includes(struct ast_context *con)
Verifies includes in an ast_contect structure.
Definition: conf2ael.c:632
int ast_context_add_ignorepat2(struct ast_context *con, const char *ignorepat, const char *registrar)
Definition: ael_main.c:348
Generic container type.
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
struct ast_context * ast_context_find_or_create(struct ast_context **extcontexts, struct ast_hashtab *exttable, const char *name, const char *registrar)
Register a new context or find an existing one.
Definition: pbx.c:6189
int ast_extension_state_add(const char *context, const char *exten, ast_state_cb_type change_cb, void *data)
Add watcher for extension states.
Definition: pbx.c:3816
void ast_context_set_autohints(struct ast_context *con, int enabled)
Enable or disable autohints support on a context.
Definition: pbx.c:6263
int ast_context_add_switch(const char *context, const char *sw, const char *data, int eval, const char *registrar)
Add a switch.
Definition: pbx.c:6762
struct ast_app * pbx_findapp(const char *app)
Look up an application.
Definition: ael_main.c:165
static const char app[]
Definition: app_mysql.c:62
int ast_get_extension_matchcid(struct ast_exten *e)
Definition: pbx.c:8567
unsigned int no_hangup_chan
Definition: pbx.h:398
struct ast_exten * pbx_find_extension(struct ast_channel *chan, 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: ael_main.c:152
int ast_context_remove_switch2(struct ast_context *con, const char *sw, const char *data, const char *registrar)
This function locks given context, removes switch, unlock context and return.
Definition: pbx.c:4911
int ast_func_write(struct ast_channel *chan, const char *function, const char *value)
executes a write operation on a function
ast_context: An extension context - must remain in sync with fake_context
Definition: pbx.c:284
int ast_context_remove_ignorepat2(struct ast_context *con, const char *ignorepat, const char *registrar)
Definition: pbx.c:6841
int ast_context_unlockmacro(const char *macrocontext)
Unlocks the macrolock in the given context.
Definition: pbx.c:5175
const struct ast_include * ast_context_includes_get(const struct ast_context *con, int idx)
Definition: pbx.c:8683
int ast_async_goto_by_name(const char *chan, const char *context, const char *exten, int priority)
Set the channel to next execute the specified dialplan location.
Definition: pbx.c:7035
int ast_add_extension2_nolock(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, const char *registrar_file, int registrar_line)
Same as ast_add_extension2, but assumes you have already locked context.
Definition: pbx.c:7299
void pbx_substitute_variables_varshead(struct varshead *headp, const char *cp1, char *cp2, int count)
jack_status_t status
Definition: app_jack.c:146
struct ast_context * ast_get_extension_context(struct ast_exten *exten)
Definition: pbx.c:8524
int ast_rdlock_context(struct ast_context *con)
Read locks a given context.
Definition: pbx.c:8506
const struct ast_ignorepat * ast_context_ignorepats_get(const struct ast_context *con, int idx)
Definition: pbx.c:8726
short word
int pbx_builtin_serialize_variables(struct ast_channel *chan, struct ast_str **buf)
Create a human-readable string, specifying all variables and their corresponding values.
const char * ast_get_extension_registrar_file(struct ast_exten *e)
Get name of configuration file used by registrar to register this extension.
Definition: pbx.c:8557
int rtimeoutms
Definition: pbx.h:213
static int enabled
Definition: dnsmgr.c:91
const char * description
Definition: pbx.h:163
static struct test_val a