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