8212d7cc057d8043d421c25d4aec0f961f20fccc
[asterisk/asterisk.git] / include / asterisk / pbx.h
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/sched.h"
27 #include "asterisk/channel.h"
28 #include "asterisk/linkedlists.h"
29
30 #if defined(__cplusplus) || defined(c_plusplus)
31 extern "C" {
32 #endif
33
34 #define AST_MAX_APP     32      /*!< Max length of an application */
35
36 #define AST_PBX_KEEP    0
37 #define AST_PBX_REPLACE 1
38
39 /*! \brief Special return values from applications to the PBX { */
40 #define AST_PBX_KEEPALIVE       10      /*!< Destroy the thread, but don't hang up the channel */
41 #define AST_PBX_NO_HANGUP_PEER  11
42 /*! } */
43
44 #define PRIORITY_HINT   -1      /*!< Special Priority for a hint */
45
46 /*! \brief Extension states */
47 enum ast_extension_states {
48         AST_EXTENSION_REMOVED = -2,     /*!< Extension removed */
49         AST_EXTENSION_DEACTIVATED = -1, /*!< Extension hint removed */
50         AST_EXTENSION_NOT_INUSE = 0,    /*!< No device INUSE or BUSY  */
51         AST_EXTENSION_INUSE = 1 << 0,   /*!< One or more devices INUSE */
52         AST_EXTENSION_BUSY = 1 << 1,    /*!< All devices BUSY */
53         AST_EXTENSION_UNAVAILABLE = 1 << 2, /*!< All devices UNAVAILABLE/UNREGISTERED */
54         AST_EXTENSION_RINGING = 1 << 3, /*!< All devices RINGING */
55         AST_EXTENSION_ONHOLD = 1 << 4,  /*!< All devices ONHOLD */
56 };
57
58
59 struct ast_context;
60 struct ast_exten;     
61 struct ast_include;
62 struct ast_ignorepat;
63 struct ast_sw;
64
65 /*! \brief Typedef for devicestate and hint callbacks */
66 typedef int (*ast_state_cb_type)(char *context, char* id, enum ast_extension_states state, void *data);
67
68 /*! \brief Data structure associated with a custom dialplan function */
69 struct ast_custom_function {
70         const char *name;               /*!< Name */
71         const char *synopsis;           /*!< Short description for "show functions" */
72         const char *desc;               /*!< Help text that explains it all */
73         const char *syntax;             /*!< Syntax description */
74         int (*read)(struct ast_channel *, char *, char *, char *, size_t);      /*!< Read function, if read is supported */
75         int (*write)(struct ast_channel *, char *, char *, const char *);       /*!< Write function, if write is supported */
76         AST_LIST_ENTRY(ast_custom_function) acflist;
77 };
78
79 /*! \brief All switch functions have the same interface, so define a type for them */
80 typedef int (ast_switch_f)(struct ast_channel *chan, const char *context,
81         const char *exten, int priority, const char *callerid, const char *data);
82
83 /*!< Data structure associated with an Asterisk switch */
84 struct ast_switch {
85         AST_LIST_ENTRY(ast_switch) list;
86         const char *name;                       /*!< Name of the switch */
87         const char *description;                /*!< Description of the switch */
88         
89         ast_switch_f *exists;
90         ast_switch_f *canmatch;
91         ast_switch_f *exec;
92         ast_switch_f *matchmore;
93 };
94
95 struct ast_timing {
96         int hastime;                            /*!< If time construct exists */
97         unsigned int monthmask;                 /*!< Mask for month */
98         unsigned int daymask;                   /*!< Mask for date */
99         unsigned int dowmask;                   /*!< Mask for day of week (mon-sun) */
100         unsigned int minmask[24];               /*!< Mask for minute */
101 };
102
103 int ast_build_timing(struct ast_timing *i, const char *info);
104 int ast_check_timing(const struct ast_timing *i);
105
106 struct ast_pbx {
107         int dtimeout;                           /*!< Timeout between digits (seconds) */
108         int rtimeout;                           /*!< Timeout for response (seconds) */
109 };
110
111
112 /*!
113  * \brief Register an alternative dialplan switch
114  *
115  * \param sw switch to register
116  *
117  * This function registers a populated ast_switch structure with the
118  * asterisk switching architecture.
119  *
120  * \return 0 on success, and other than 0 on failure
121  */
122 int ast_register_switch(struct ast_switch *sw);
123
124 /*!
125  * \brief Unregister an alternative switch
126  *
127  * \param sw switch to unregister
128  * 
129  * Unregisters a switch from asterisk.
130  *
131  * \return nothing
132  */
133 void ast_unregister_switch(struct ast_switch *sw);
134
135 /*!
136  * \brief Look up an application
137  *
138  * \param app name of the app
139  *
140  * This function searches for the ast_app structure within
141  * the apps that are registered for the one with the name
142  * you passed in.
143  *
144  * \return the ast_app structure that matches on success, or NULL on failure
145  */
146 struct ast_app *pbx_findapp(const char *app);
147
148 /*!
149  * \brief Execute an application
150  *
151  * \param c channel to execute on
152  * \param app which app to execute
153  * \param data the data passed into the app
154  *
155  * This application executes an application on a given channel.  It
156  * saves the stack and executes the given appliation passing in
157  * the given data.
158  *
159  * \return 0 on success, and -1 on failure
160  */
161 int pbx_exec(struct ast_channel *c, struct ast_app *app, void *data);
162
163 /*!
164  * \brief Register a new context
165  *
166  * \param extcontexts pointer to the ast_context structure pointer
167  * \param name name of the new context
168  * \param registrar registrar of the context
169  *
170  * This will first search for a context with your name.  If it exists already, it will not
171  * create a new one.  If it does not exist, it will create a new one with the given name
172  * and registrar.
173  *
174  * \return NULL on failure, and an ast_context structure on success
175  */
176 struct ast_context *ast_context_create(struct ast_context **extcontexts, const char *name, const char *registrar);
177
178 /*!
179  * \brief Merge the temporary contexts into a global contexts list and delete from the 
180  *        global list the ones that are being added
181  *
182  * \param extcontexts pointer to the ast_context structure pointer
183  * \param registrar of the context; if it's set the routine will delete all contexts 
184  *        that belong to that registrar; if NULL only the contexts that are specified 
185  *        in extcontexts
186  */
187 void ast_merge_contexts_and_delete(struct ast_context **extcontexts, const char *registrar);
188
189 /*!
190  * \brief Destroy a context (matches the specified context (or ANY context if NULL)
191  *
192  * \param con context to destroy
193  * \param registrar who registered it
194  *
195  * You can optionally leave out either parameter.  It will find it
196  * based on either the ast_context or the registrar name.
197  *
198  * \return nothing
199  */
200 void ast_context_destroy(struct ast_context *con, const char *registrar);
201
202 /*!
203  * \brief Find a context
204  *
205  * \param name name of the context to find
206  *
207  * Will search for the context with the given name.
208  *
209  * \return the ast_context on success, NULL on failure.
210  */
211 struct ast_context *ast_context_find(const char *name);
212
213 enum ast_pbx_result {
214         AST_PBX_SUCCESS = 0,
215         AST_PBX_FAILED = -1,
216         AST_PBX_CALL_LIMIT = -2,
217 };
218
219 /*!
220  * \brief Create a new thread and start the PBX
221  *
222  * \param c channel to start the pbx on
223  *
224  * See ast_pbx_run for a synchronous function to run the PBX in the
225  * current thread, as opposed to starting a new one.
226  *
227  * \return Zero on success, non-zero on failure
228  */
229 enum ast_pbx_result ast_pbx_start(struct ast_channel *c);
230
231 /*!
232  * \brief Execute the PBX in the current thread
233  *
234  * \param c channel to run the pbx on
235  *
236  * This executes the PBX on a given channel. It allocates a new
237  * PBX structure for the channel, and provides all PBX functionality.
238  * See ast_pbx_start for an asynchronous function to run the PBX in a
239  * new thread as opposed to the current one.
240  * 
241  * \return Zero on success, non-zero on failure
242  */
243 enum ast_pbx_result ast_pbx_run(struct ast_channel *c);
244
245 /*! 
246  * \brief Add and extension to an extension context.  
247  * 
248  * \param context context to add the extension to
249  * \param replace
250  * \param extension extension to add
251  * \param priority priority level of extension addition
252  * \param label extension label
253  * \param callerid pattern to match CallerID, or NULL to match any CallerID
254  * \param application application to run on the extension with that priority level
255  * \param data data to pass to the application
256  * \param datad
257  * \param registrar who registered the extension
258  *
259  * \retval 0 success 
260  * \retval -1 failure
261  */
262 int ast_add_extension(const char *context, int replace, const char *extension, 
263         int priority, const char *label, const char *callerid,
264         const char *application, void *data, void (*datad)(void *), const char *registrar);
265
266 /*! 
267  * \brief Add an extension to an extension context, this time with an ast_context *.
268  *
269  * \note For details about the arguments, check ast_add_extension()
270  */
271 int ast_add_extension2(struct ast_context *con, int replace, const char *extension,
272         int priority, const char *label, const char *callerid, 
273         const char *application, void *data, void (*datad)(void *), const char *registrar);
274
275
276 /*! 
277  * \brief Register an application.
278  *
279  * \param app Short name of the application
280  * \param execute a function callback to execute the application. It should return
281  *                non-zero if the channel needs to be hung up.
282  * \param synopsis a short description (one line synopsis) of the application
283  * \param description long description with all of the details about the use of 
284  *                    the application
285  * 
286  * This registers an application with Asterisk's internal application list. 
287  * \note The individual applications themselves are responsible for registering and unregistering
288  *       and unregistering their own CLI commands.
289  * 
290  * \retval 0 success 
291  * \retval -1 failure.
292  */
293 int ast_register_application(const char *app, int (*execute)(struct ast_channel *, void *),
294                              const char *synopsis, const char *description);
295
296 /*! 
297  * \brief Unregister an application
298  * 
299  * \param app name of the application (does not have to be the same string as the one that was registered)
300  * 
301  * This unregisters an application from Asterisk's internal application list.
302  * 
303  * \retval 0 success 
304  * \retval -1 failure
305  */
306 int ast_unregister_application(const char *app);
307
308 /*! 
309  * \brief Uses hint and devicestate callback to get the state of an extension
310  *
311  * \param c this is not important
312  * \param context which context to look in
313  * \param exten which extension to get state
314  *
315  * \return extension state as defined in the ast_extension_states enum
316  */
317 int ast_extension_state(struct ast_channel *c, const char *context, const char *exten);
318
319 /*! 
320  * \brief Return string representation of the state of an extension
321  * 
322  * \param extension_state is the numerical state delivered by ast_extension_state
323  *
324  * \return the state of an extension as string
325  */
326 const char *ast_extension_state2str(int extension_state);
327
328 /*!
329  * \brief Registers a state change callback
330  * 
331  * \param context which context to look in
332  * \param exten which extension to get state
333  * \param callback callback to call if state changed
334  * \param data to pass to callback
335  *
336  * The callback is called if the state of an extension is changed.
337  *
338  * \retval -1 on failure
339  * \retval ID on success
340  */ 
341 int ast_extension_state_add(const char *context, const char *exten, 
342                             ast_state_cb_type callback, void *data);
343
344 /*! 
345  * \brief Deletes a registered state change callback by ID
346  * 
347  * \param id of the callback to delete
348  * \param callback callback
349  *
350  * Removes the callback from list of callbacks
351  *
352  * \retval 0 success 
353  * \retval -1 failure
354  */
355 int ast_extension_state_del(int id, ast_state_cb_type callback);
356
357 /*! 
358  * \brief If an extension exists, return non-zero
359  * 
360  * \param hint buffer for hint
361  * \param maxlen size of hint buffer
362  * \param name buffer for name portion of hint
363  * \param maxnamelen size of name buffer
364  * \param c this is not important
365  * \param context which context to look in
366  * \param exten which extension to search for
367  *
368  * \return If an extension within the given context with the priority PRIORITY_HINT
369  * is found a non zero value will be returned.
370  * Otherwise, 0 is returned.
371  */
372 int ast_get_hint(char *hint, int maxlen, char *name, int maxnamelen, 
373         struct ast_channel *c, const char *context, const char *exten);
374
375 /*!
376  * \brief Determine whether an extension exists
377  *
378  * \param c this is not important
379  * \param context which context to look in
380  * \param exten which extension to search for
381  * \param priority priority of the action within the extension
382  * \param callerid callerid to search for
383  *
384  * \return If an extension within the given context(or callerid) with the given priority 
385  *         is found a non zero value will be returned. Otherwise, 0 is returned.
386  */
387 int ast_exists_extension(struct ast_channel *c, const char *context, const char *exten, 
388         int priority, const char *callerid);
389
390 /*! 
391  * \brief Find the priority of an extension that has the specified label
392  * 
393  * \param c this is not important
394  * \param context which context to look in
395  * \param exten which extension to search for
396  * \param label label of the action within the extension to match to priority
397  * \param callerid callerid to search for
398  *
399  * \return the priority which matches the given label in the extension or -1 if not found.
400  */
401 int ast_findlabel_extension(struct ast_channel *c, const char *context, 
402         const char *exten, const char *label, const char *callerid);
403
404 /*!
405  * \brief Find the priority of an extension that has the specified label
406  *
407  * \note This function is the same as ast_findlabel_extension, except that it accepts
408  * a pointer to an ast_context structure to specify the context instead of the
409  * name of the context. Otherwise, the functions behave the same.
410  */
411 int ast_findlabel_extension2(struct ast_channel *c, struct ast_context *con, 
412         const char *exten, const char *label, const char *callerid);
413
414 /*! 
415  * \brief Looks for a valid matching extension
416  * 
417  * \param c not really important
418  * \param context context to serach within
419  * \param exten extension to check
420  * \param priority priority of extension path
421  * \param callerid callerid of extension being searched for
422  *
423  * \return If "exten" *could be* a valid extension in this context with or without
424  * some more digits, return non-zero.  Basically, when this returns 0, no matter
425  * what you add to exten, it's not going to be a valid extension anymore
426  */
427 int ast_canmatch_extension(struct ast_channel *c, const char *context, 
428         const char *exten, int priority, const char *callerid);
429
430 /*! 
431  * \brief Looks to see if adding anything to this extension might match something. (exists ^ canmatch)
432  *
433  * \param c not really important XXX
434  * \param context context to serach within
435  * \param exten extension to check
436  * \param priority priority of extension path
437  * \param callerid callerid of extension being searched for
438  *
439  * \return If "exten" *could match* a valid extension in this context with
440  * some more digits, return non-zero.  Does NOT return non-zero if this is
441  * an exact-match only.  Basically, when this returns 0, no matter
442  * what you add to exten, it's not going to be a valid extension anymore
443  */
444 int ast_matchmore_extension(struct ast_channel *c, const char *context, 
445         const char *exten, int priority, const char *callerid);
446
447 /*! 
448  * \brief Determine if a given extension matches a given pattern (in NXX format)
449  * 
450  * \param pattern pattern to match
451  * \param extension extension to check against the pattern.
452  *
453  * Checks whether or not the given extension matches the given pattern.
454  *
455  * \retval 1 on match
456  * \retval 0 on failure
457  */
458 int ast_extension_match(const char *pattern, const char *extension);
459
460 int ast_extension_close(const char *pattern, const char *data, int needmore);
461
462 /*! 
463  * \brief Launch a new extension (i.e. new stack)
464  * 
465  * \param c not important
466  * \param context which context to generate the extension within
467  * \param exten new extension to add
468  * \param priority priority of new extension
469  * \param callerid callerid of extension
470  *
471  * This adds a new extension to the asterisk extension list.
472  *
473  * \retval 0 on success 
474  * \retval -1 on failure.
475  */
476 int ast_spawn_extension(struct ast_channel *c, const char *context, 
477         const char *exten, int priority, const char *callerid);
478
479 /*! 
480  * \brief Add a context include
481  *
482  * \param context context to add include to
483  * \param include new include to add
484  * \param registrar who's registering it
485  *
486  * Adds an include taking a char * string as the context parameter
487  *
488  * \retval 0 on success 
489  * \retval -1 on error
490 */
491 int ast_context_add_include(const char *context, const char *include, 
492         const char *registrar);
493
494 /*! 
495  * \brief Add a context include
496  * 
497  * \param con context to add the include to
498  * \param include include to add
499  * \param registrar who registered the context
500  *
501  * Adds an include taking a struct ast_context as the first parameter
502  *
503  * \retval 0 on success 
504  * \retval -1 on failure
505  */
506 int ast_context_add_include2(struct ast_context *con, const char *include, 
507         const char *registrar);
508
509 /*! 
510  * \brief Remove a context include
511  * 
512  * \note See ast_context_add_include for information on arguments
513  *
514  * \retval 0 on success
515  * \retval -1 on failure
516  */
517 int ast_context_remove_include(const char *context, const char *include, 
518         const char *registrar);
519
520 /*! 
521  * \brief Removes an include by an ast_context structure 
522  * 
523  * \note See ast_context_add_include2 for information on arguments
524  *
525  * \retval 0 on success
526  * \retval -1 on success
527  */
528 int ast_context_remove_include2(struct ast_context *con, const char *include, 
529         const char *registrar);
530
531 /*! 
532  * \brief Verifies includes in an ast_contect structure
533  * 
534  * \param con context in which to verify the includes
535  *
536  * \retval 0 if no problems found 
537  * \retval -1 if there were any missing context
538  */
539 int ast_context_verify_includes(struct ast_context *con);
540           
541 /*! 
542  * \brief Add a switch
543  * 
544  * \param context context to which to add the switch
545  * \param sw switch to add
546  * \param data data to pass to switch
547  * \param eval whether to evaluate variables when running switch
548  * \param registrar whoever registered the switch
549  *
550  * This function registers a switch with the asterisk switch architecture
551  *
552  * \retval 0 on success 
553  * \retval -1 on failure
554  */
555 int ast_context_add_switch(const char *context, const char *sw, const char *data, 
556         int eval, const char *registrar);
557
558 /*! 
559  * \brief Adds a switch (first param is a ast_context)
560  * 
561  * \note See ast_context_add_switch() for argument information, with the exception of
562  *       the first argument. In this case, it's a pointer to an ast_context structure
563  *       as opposed to the name.
564  */
565 int ast_context_add_switch2(struct ast_context *con, const char *sw, const char *data, 
566         int eval, const char *registrar);
567
568 /*! 
569  * \brief Remove a switch
570  * 
571  * Removes a switch with the given parameters
572  *
573  * \retval 0 on success 
574  * \retval -1 on failure
575  */
576 int ast_context_remove_switch(const char *context, const char *sw, 
577         const char *data, const char *registrar);
578
579 int ast_context_remove_switch2(struct ast_context *con, const char *sw, 
580         const char *data, const char *registrar);
581
582 /*! 
583  * \brief Simply remove extension from context
584  * 
585  * \param context context to remove extension from
586  * \param extension which extension to remove
587  * \param priority priority of extension to remove
588  * \param registrar registrar of the extension
589  *
590  * This function removes an extension from a given context.
591  *
592  * \retval 0 on success 
593  * \retval -1 on failure
594  */
595 int ast_context_remove_extension(const char *context, const char *extension, int priority,
596         const char *registrar);
597
598 int ast_context_remove_extension2(struct ast_context *con, const char *extension,
599         int priority, const char *registrar);
600
601 /*! 
602  * \brief Add an ignorepat
603  * 
604  * \param context which context to add the ignorpattern to
605  * \param ignorepat ignorepattern to set up for the extension
606  * \param registrar registrar of the ignore pattern
607  *
608  * Adds an ignore pattern to a particular context.
609  *
610  * \retval 0 on success 
611  * \retval -1 on failure
612  */
613 int ast_context_add_ignorepat(const char *context, const char *ignorepat, const char *registrar);
614
615 int ast_context_add_ignorepat2(struct ast_context *con, const char *ignorepat, const char *registrar);
616
617 /* 
618  * \brief Remove an ignorepat
619  * 
620  * \param context context from which to remove the pattern
621  * \param ignorepat the pattern to remove
622  * \param registrar the registrar of the ignore pattern
623  *
624  * This removes the given ignorepattern
625  *
626  * \retval 0 on success 
627  * \retval -1 on failure
628  */
629 int ast_context_remove_ignorepat(const char *context, const char *ignorepat, const char *registrar);
630
631 int ast_context_remove_ignorepat2(struct ast_context *con, const char *ignorepat, const char *registrar);
632
633 /*! 
634  * \brief Checks to see if a number should be ignored
635  * 
636  * \param context context to search within
637  * \param pattern to check whether it should be ignored or not
638  *
639  * Check if a number should be ignored with respect to dialtone cancellation.
640  *
641  * \retval 0 if the pattern should not be ignored 
642  * \retval non-zero if the pattern should be ignored 
643  */
644 int ast_ignore_pattern(const char *context, const char *pattern);
645
646 /* Locking functions for outer modules, especially for completion functions */
647
648 /*! 
649  * \brief Locks the context list
650  *
651  * \retval 0 on success 
652  * \retval -1 on error
653  */
654 int ast_lock_contexts(void);
655
656 /*! 
657  * \brief Unlocks contexts
658  * 
659  * \retval 0 on success 
660  * \retval -1 on failure
661  */
662 int ast_unlock_contexts(void);
663
664 /*! 
665  * \brief Locks a given context
666  * 
667  * \param con context to lock
668  *
669  * \retval 0 on success 
670  * \retval -1 on failure
671  */
672 int ast_lock_context(struct ast_context *con);
673
674 /*! 
675  * \retval Unlocks the given context
676  * 
677  * \param con context to unlock
678  *
679  * \retval 0 on success 
680  * \retval -1 on failure
681  */
682 int ast_unlock_context(struct ast_context *con);
683
684
685 int ast_async_goto(struct ast_channel *chan, const char *context, const char *exten, int priority);
686
687 int ast_async_goto_by_name(const char *chan, const char *context, const char *exten, int priority);
688
689 /*! Synchronously or asynchronously make an outbound call and send it to a
690    particular extension */
691 int ast_pbx_outgoing_exten(const char *type, int format, void *data, int timeout, const char *context, const char *exten, int priority, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel);
692
693 /*! Synchronously or asynchronously make an outbound call and send it to a
694    particular application with given extension */
695 int ast_pbx_outgoing_app(const char *type, int format, void *data, int timeout, const char *app, const char *appdata, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel);
696
697 /*!
698  * \brief Evaluate a condition
699  *
700  * \retval 0 if the condition is NULL or of zero length
701  * \retval int If the string is an integer, the integer representation of
702  *             the integer is returned
703  * \retval 1 Any other non-empty string
704  */
705 int pbx_checkcondition(const char *condition);
706
707 /* Functions for returning values from structures */
708 const char *ast_get_context_name(struct ast_context *con);
709 const char *ast_get_extension_name(struct ast_exten *exten);
710 struct ast_context *ast_get_extension_context(struct ast_exten *exten);
711 const char *ast_get_include_name(struct ast_include *include);
712 const char *ast_get_ignorepat_name(struct ast_ignorepat *ip);
713 const char *ast_get_switch_name(struct ast_sw *sw);
714 const char *ast_get_switch_data(struct ast_sw *sw);
715
716 /* Other extension stuff */
717 int ast_get_extension_priority(struct ast_exten *exten);
718 int ast_get_extension_matchcid(struct ast_exten *e);
719 const char *ast_get_extension_cidmatch(struct ast_exten *e);
720 const char *ast_get_extension_app(struct ast_exten *e);
721 const char *ast_get_extension_label(struct ast_exten *e);
722 void *ast_get_extension_app_data(struct ast_exten *e);
723
724 /* Registrar info functions ... */
725 const char *ast_get_context_registrar(struct ast_context *c);
726 const char *ast_get_extension_registrar(struct ast_exten *e);
727 const char *ast_get_include_registrar(struct ast_include *i);
728 const char *ast_get_ignorepat_registrar(struct ast_ignorepat *ip);
729 const char *ast_get_switch_registrar(struct ast_sw *sw);
730
731 /* Walking functions ... */
732 struct ast_context *ast_walk_contexts(struct ast_context *con);
733 struct ast_exten *ast_walk_context_extensions(struct ast_context *con,
734         struct ast_exten *priority);
735 struct ast_exten *ast_walk_extension_priorities(struct ast_exten *exten,
736         struct ast_exten *priority);
737 struct ast_include *ast_walk_context_includes(struct ast_context *con,
738         struct ast_include *inc);
739 struct ast_ignorepat *ast_walk_context_ignorepats(struct ast_context *con,
740         struct ast_ignorepat *ip);
741 struct ast_sw *ast_walk_context_switches(struct ast_context *con, struct ast_sw *sw);
742
743 int pbx_builtin_serialize_variables(struct ast_channel *chan, char *buf, size_t size);
744 const char *pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name);
745 void pbx_builtin_pushvar_helper(struct ast_channel *chan, const char *name, const char *value);
746 void pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value);
747 void pbx_retrieve_variable(struct ast_channel *c, const char *var, char **ret, char *workspace, int workspacelen, struct varshead *headp);
748 void pbx_builtin_clear_globals(void);
749 int pbx_builtin_setvar(struct ast_channel *chan, void *data);
750 void pbx_substitute_variables_helper(struct ast_channel *c,const char *cp1,char *cp2,int count);
751 void pbx_substitute_variables_varshead(struct varshead *headp, const char *cp1, char *cp2, int count);
752
753 int ast_extension_patmatch(const char *pattern, const char *data);
754
755 /*! Set "autofallthrough" flag, if newval is <0, does not acutally set.  If
756   set to 1, sets to auto fall through.  If newval set to 0, sets to no auto
757   fall through (reads extension instead).  Returns previous value. */
758 int pbx_set_autofallthrough(int newval);
759 int ast_goto_if_exists(struct ast_channel *chan, const char *context, const char *exten, int priority);
760 /* I can find neither parsable nor parseable at dictionary.com, but google gives me 169000 hits for parseable and only 49,800 for parsable */
761 int ast_parseable_goto(struct ast_channel *chan, const char *goto_string);
762 int ast_explicit_goto(struct ast_channel *chan, const char *context, const char *exten, int priority);
763 int ast_async_goto_if_exists(struct ast_channel *chan, const char *context, const char *exten, int priority);
764
765 struct ast_custom_function* ast_custom_function_find(const char *name);
766
767 /*!
768  * \brief Unregister a custom function
769  */
770 int ast_custom_function_unregister(struct ast_custom_function *acf);
771
772 /*!
773  * \brief Reigster a custom function
774  */
775 int ast_custom_function_register(struct ast_custom_function *acf);
776
777 /*! 
778  * \brief Retrieve the number of active calls
779  */
780 int ast_active_calls(void);
781         
782 /*!
783  * \brief executes a read operation on a function 
784  *
785  * \param chan Channel to execute on
786  * \param function Data containing the function call string (will be modified)
787  * \param workspace A pointer to safe memory to use for a return value 
788  * \param len the number of bytes in workspace
789  *
790  * This application executes a function in read mode on a given channel.
791  *
792  * \return zero on success, non-zero on failure
793  */
794 int ast_func_read(struct ast_channel *chan, char *function, char *workspace, size_t len);
795
796 /*!
797  * \brief executes a write operation on a function
798  *
799  * \param chan Channel to execute on
800  * \param function Data containing the function call string (will be modified)
801  * \param value A value parameter to pass for writing
802  *
803  * This application executes a function in write mode on a given channel.
804  *
805  * \return zero on success, non-zero on failure
806  */
807 int ast_func_write(struct ast_channel *chan, char *function, const char *value);
808
809 void ast_hint_state_changed(const char *device);
810
811 #if defined(__cplusplus) || defined(c_plusplus)
812 }
813 #endif
814
815 #endif /* _ASTERISK_PBX_H */