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