1999-10-27 00:56:38 +00:00
/*
2005-08-30 18:32:10 +00:00
* Asterisk - - An open source telephony toolkit .
1999-10-27 00:56:38 +00:00
*
2005-08-30 18:32:10 +00:00
* Copyright ( C ) 1999 - 2005 , Digium , Inc .
*
* Mark Spencer < markster @ digium . com >
1999-10-27 00:56:38 +00:00
*
2005-08-30 18:32:10 +00:00
* See http : //www.asterisk.org for more information about
* the Asterisk project . Please do not directly contact
* any of the maintainers of this project for assistance ;
* the project provides a web site , mailing lists and IRC
* channels for your use .
1999-10-27 00:56:38 +00:00
*
* This program is free software , distributed under the terms of
2005-08-30 18:32:10 +00:00
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree .
1999-10-27 00:56:38 +00:00
*/
2005-08-30 18:32:10 +00:00
2005-10-24 20:12:06 +00:00
/*! \file
* \ brief Core PBX routines and definitions .
2005-08-30 18:32:10 +00:00
*/
1999-10-27 00:56:38 +00:00
# ifndef _ASTERISK_PBX_H
# define _ASTERISK_PBX_H
2005-04-21 06:02:45 +00:00
# include "asterisk/sched.h"
# include "asterisk/channel.h"
1999-10-27 00:56:38 +00:00
# if defined(__cplusplus) || defined(c_plusplus)
extern " C " {
# endif
# define AST_PBX_KEEP 0
# define AST_PBX_REPLACE 1
2005-01-15 23:48:12 +00:00
/*! Max length of an application */
1999-10-27 00:56:38 +00:00
# define AST_MAX_APP 32
2005-01-15 23:48:12 +00:00
/*! Special return values from applications to the PBX */
2000-01-23 01:06:34 +00:00
# define AST_PBX_KEEPALIVE 10 /* Destroy the thread, but don't hang up the channel */
2003-07-02 14:06:12 +00:00
# define AST_PBX_NO_HANGUP_PEER 11
2000-01-23 01:06:34 +00:00
2005-01-15 23:48:12 +00:00
/*! Special Priority for an hint */
2003-03-30 22:55:42 +00:00
# define PRIORITY_HINT -1
2005-01-15 23:48:12 +00:00
/*! Extension states */
2005-08-27 23:55:14 +00:00
enum ast_extension_states {
/*! Extension removed */
AST_EXTENSION_REMOVED = - 2 ,
/*! Extension hint removed */
AST_EXTENSION_DEACTIVATED = - 1 ,
/*! No device INUSE or BUSY */
AST_EXTENSION_NOT_INUSE = 0 ,
/*! One or more devices INUSE */
2005-08-29 23:53:29 +00:00
AST_EXTENSION_INUSE = 1 < < 0 ,
2005-08-27 23:55:14 +00:00
/*! All devices BUSY */
2005-08-29 23:53:29 +00:00
AST_EXTENSION_BUSY = 1 < < 1 ,
2005-08-27 23:55:14 +00:00
/*! All devices UNAVAILABLE/UNREGISTERED */
2005-08-29 23:53:29 +00:00
AST_EXTENSION_UNAVAILABLE = 1 < < 2 ,
/*! All devices RINGING */
AST_EXTENSION_RINGING = 1 < < 3 ,
} ;
static const struct cfextension_states {
int extension_state ;
const char * const text ;
} extension_states [ ] = {
{ AST_EXTENSION_NOT_INUSE , " Idle " } ,
{ AST_EXTENSION_INUSE , " InUse " } ,
{ AST_EXTENSION_BUSY , " Busy " } ,
{ AST_EXTENSION_UNAVAILABLE , " Unavailable " } ,
{ AST_EXTENSION_RINGING , " Ringing " } ,
{ AST_EXTENSION_INUSE | AST_EXTENSION_RINGING , " InUse&Ringing " }
2005-08-27 23:55:14 +00:00
} ;
2003-03-30 22:55:42 +00:00
1999-10-27 00:56:38 +00:00
struct ast_context ;
2001-09-19 14:40:16 +00:00
struct ast_exten ;
struct ast_include ;
struct ast_ignorepat ;
struct ast_sw ;
2005-08-27 23:55:14 +00:00
typedef int ( * ast_state_cb_type ) ( char * context , char * id , enum ast_extension_states state , void * data ) ;
2003-03-30 22:55:42 +00:00
2005-05-05 05:39:33 +00:00
/*! Data structure associated with a custom function */
struct ast_custom_function {
2005-03-04 06:36:18 +00:00
char * name ;
2005-05-05 05:39:33 +00:00
char * synopsis ;
2005-03-04 06:36:18 +00:00
char * desc ;
char * syntax ;
2005-03-29 06:16:49 +00:00
char * ( * read ) ( struct ast_channel * , char * , char * , char * , size_t ) ;
void ( * write ) ( struct ast_channel * , char * , char * , const char * ) ;
2005-05-05 05:39:33 +00:00
struct ast_custom_function * next ;
2005-03-04 06:36:18 +00:00
} ;
2005-01-15 23:48:12 +00:00
/*! Data structure associated with an asterisk switch */
2001-09-19 14:40:16 +00:00
struct ast_switch {
2001-11-06 17:34:13 +00:00
/*! NULL */
struct ast_switch * next ;
/*! Name of the switch */
2004-10-03 04:19:59 +00:00
const char * name ;
2001-11-06 17:34:13 +00:00
/*! Description of the switch */
2004-10-03 04:19:59 +00:00
const char * description ;
2001-11-06 17:34:13 +00:00
2004-10-03 04:19:59 +00:00
int ( * exists ) ( struct ast_channel * chan , const char * context , const char * exten , int priority , const char * callerid , const char * data ) ;
2001-11-06 17:34:13 +00:00
2004-10-03 04:19:59 +00:00
int ( * canmatch ) ( struct ast_channel * chan , const char * context , const char * exten , int priority , const char * callerid , const char * data ) ;
2001-11-06 17:34:13 +00:00
2004-10-03 04:19:59 +00:00
int ( * exec ) ( struct ast_channel * chan , const char * context , const char * exten , int priority , const char * callerid , int newstack , const char * data ) ;
2002-11-10 03:20:35 +00:00
2004-10-03 04:19:59 +00:00
int ( * matchmore ) ( struct ast_channel * chan , const char * context , const char * exten , int priority , const char * callerid , const char * data ) ;
2001-09-19 14:40:16 +00:00
} ;
2004-11-11 21:23:45 +00:00
struct ast_timing {
int hastime ; /* If time construct exists */
unsigned int monthmask ; /* Mask for month */
unsigned int daymask ; /* Mask for date */
unsigned int dowmask ; /* Mask for day of week (mon-sun) */
unsigned int minmask [ 24 ] ; /* Mask for minute */
} ;
extern int ast_build_timing ( struct ast_timing * i , char * info ) ;
extern int ast_check_timing ( struct ast_timing * i ) ;
2003-06-11 12:14:38 +00:00
struct ast_pbx {
int dtimeout ; /* Timeout between digits (seconds) */
int rtimeout ; /* Timeout for response
( seconds ) */
} ;
2005-01-15 23:48:12 +00:00
/*! Register an alternative switch */
2001-11-06 17:34:13 +00:00
/*!
* \ param sw switch to register
* This function registers a populated ast_switch structure with the
* asterisk switching architecture .
* It returns 0 on success , and other than 0 on failure
*/
2001-09-19 14:40:16 +00:00
extern int ast_register_switch ( struct ast_switch * sw ) ;
2005-01-15 23:48:12 +00:00
/*! Unregister an alternative switch */
2001-11-06 17:34:13 +00:00
/*!
* \ param sw switch to unregister
* Unregisters a switch from asterisk .
* Returns nothing
*/
2001-09-19 14:40:16 +00:00
extern void ast_unregister_switch ( struct ast_switch * sw ) ;
2005-01-15 23:48:12 +00:00
/*! Look up an application */
2001-11-06 17:34:13 +00:00
/*!
* \ param app name of the app
* This function searches for the ast_app structure within
* the apps that are registered for the one with the name
* you passed in .
* Returns the ast_app structure that matches on success , or NULL on failure
*/
2004-10-03 04:19:59 +00:00
extern struct ast_app * pbx_findapp ( const char * app ) ;
2001-09-19 14:40:16 +00:00
2005-01-15 23:48:12 +00:00
/*! executes an application */
2001-11-06 17:34:13 +00:00
/*!
* \ param c channel to execute on
* \ param app which app to execute
* \ param data the data passed into the app
* \ param newstack stack pointer
* This application executes an application on a given channel . It
* saves the stack and executes the given appliation passing in
* the given data .
* It returns 0 on success , and - 1 on failure
*/
2001-09-19 14:40:16 +00:00
int pbx_exec ( struct ast_channel * c , struct ast_app * app , void * data , int newstack ) ;
1999-10-27 00:56:38 +00:00
2005-01-15 23:48:12 +00:00
/*! Register a new context */
2001-11-06 17:34:13 +00:00
/*!
2003-07-14 15:33:21 +00:00
* \ param extcontexts pointer to the ast_context structure pointer
2001-11-06 17:34:13 +00:00
* \ param name name of the new context
* \ param registrar registrar of the context
* This will first search for a context with your name . If it exists already , it will not
* create a new one . If it does not exist , it will create a new one with the given name
* and registrar .
* It returns NULL on failure , and an ast_context structure on success
*/
2004-10-03 04:19:59 +00:00
struct ast_context * ast_context_create ( struct ast_context * * extcontexts , const char * name , const char * registrar ) ;
2003-07-14 15:33:21 +00:00
2005-01-15 23:48:12 +00:00
/*! Merge the temporary contexts into a global contexts list and delete from the global list the ones that are being added */
2003-07-14 15:33:21 +00:00
/*!
* \ param extcontexts pointer to the ast_context structure pointer
2003-07-14 17:16:47 +00:00
* \ param registar of the context ; if it ' s set the routine will delete all contexts that belong to that registrar ; if NULL only the contexts that are specified in extcontexts
2003-07-14 15:33:21 +00:00
*/
2004-10-03 04:19:59 +00:00
void ast_merge_contexts_and_delete ( struct ast_context * * extcontexts , const char * registrar ) ;
1999-10-27 00:56:38 +00:00
2005-01-15 23:48:12 +00:00
/*! Destroy a context (matches the specified context (or ANY context if NULL) */
2001-11-06 17:34:13 +00:00
/*!
* \ param con context to destroy
* \ param registrar who registered it
* You can optionally leave out either parameter . It will find it
* based on either the ast_context or the registrar name .
* Returns nothing
*/
2004-10-03 04:19:59 +00:00
void ast_context_destroy ( struct ast_context * con , const char * registrar ) ;
1999-10-27 00:56:38 +00:00
2005-01-15 23:48:12 +00:00
/*! Find a context */
2001-11-06 17:34:13 +00:00
/*!
* \ param name name of the context to find
* Will search for the context with the given name .
* Returns the ast_context on success , NULL on failure .
*/
2004-10-03 04:19:59 +00:00
struct ast_context * ast_context_find ( const char * name ) ;
1999-10-27 00:56:38 +00:00
2005-09-13 21:59:45 +00:00
enum ast_pbx_result {
AST_PBX_SUCCESS = 0 ,
AST_PBX_FAILED = - 1 ,
AST_PBX_CALL_LIMIT = - 2 ,
} ;
2005-01-15 23:48:12 +00:00
/*! Create a new thread and start the PBX (or whatever) */
2001-11-06 17:34:13 +00:00
/*!
* \ param c channel to start the pbx on
2005-09-13 21:59:45 +00:00
* \ return Zero on success , non - zero on failure
2001-11-06 17:34:13 +00:00
*/
2005-09-13 21:59:45 +00:00
enum ast_pbx_result ast_pbx_start ( struct ast_channel * c ) ;
1999-10-27 00:56:38 +00:00
2005-01-15 23:48:12 +00:00
/*! Execute the PBX in the current thread */
2001-11-06 17:34:13 +00:00
/*!
* \ param c channel to run the pbx on
2005-09-13 21:59:45 +00:00
* \ return Zero on success , non - zero on failure
* This executes the PBX on a given channel . It allocates a new
2001-11-06 17:34:13 +00:00
* PBX structure for the channel , and provides all PBX functionality .
*/
2005-09-13 21:59:45 +00:00
enum ast_pbx_result ast_pbx_run ( struct ast_channel * c ) ;
1999-10-27 00:56:38 +00:00
2001-11-06 17:34:13 +00:00
/*!
* \ param context context to add the extension to
* \ param replace
* \ param extension extension to add
* \ param priority priority level of extension addition
* \ param callerid callerid of extension
* \ param application application to run on the extension with that priority level
* \ param data data to pass to the application
* \ param datad
* \ param registrar who registered the extension
* Add and extension to an extension context .
* Callerid is a pattern to match CallerID , or NULL to match any callerid
* Returns 0 on success , - 1 on failure
*/
2004-10-03 04:19:59 +00:00
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 ) ;
2001-09-19 14:40:16 +00:00
2005-01-15 23:48:12 +00:00
/*! Add an extension to an extension context, this time with an ast_context *. CallerID is a pattern to match on callerid, or NULL to not care about callerid */
2001-11-06 17:34:13 +00:00
/*!
* For details about the arguements , check ast_add_extension ( )
*/
1999-10-27 00:56:38 +00:00
int ast_add_extension2 ( struct ast_context * con ,
2004-10-03 04:19:59 +00:00
int replace , const char * extension , int priority , const char * label , const char * callerid ,
const char * application , void * data , void ( * datad ) ( void * ) ,
const char * registrar ) ;
1999-10-27 00:56:38 +00:00
2005-01-15 23:48:12 +00:00
/*! Add an application. The function 'execute' should return non-zero if the line needs to be hung up. */
2001-11-06 17:34:13 +00:00
/*!
\ param app Short name of the application
\ param execute a function callback to execute the application
\ param synopsis a short description of the application
\ param description long description of the application
2001-04-17 16:49:37 +00:00
Include a one - line synopsis ( e . g . ' hangs up a channel ' ) and a more lengthy , multiline
description with more detail , including under what conditions the application
2001-11-06 17:34:13 +00:00
will return 0 or - 1.
This registers an application with asterisks internal application list . Please note :
The individual applications themselves are responsible for registering and unregistering
CLI commands .
It returns 0 on success , - 1 on failure .
*/
2004-10-03 04:19:59 +00:00
int ast_register_application ( const char * app , int ( * execute ) ( struct ast_channel * , void * ) ,
const char * synopsis , const char * description ) ;
1999-10-27 00:56:38 +00:00
2005-01-15 23:48:12 +00:00
/*! Remove an application */
2001-11-06 17:34:13 +00:00
/*!
* \ param app name of the application ( does not have to be the same string as the one that was registered )
* This unregisters an application from asterisk ' s internal registration mechanisms .
* It returns 0 on success , and - 1 on failure .
*/
2004-10-03 04:19:59 +00:00
int ast_unregister_application ( const char * app ) ;
1999-10-27 00:56:38 +00:00
2005-01-15 23:48:12 +00:00
/*! Uses hint and devicestate callback to get the state of an extension */
2003-03-30 22:55:42 +00:00
/*!
* \ param c this is not important
* \ param context which context to look in
* \ param exten which extension to get state
* Returns extension state ! ! = AST_EXTENSION_ ? ? ?
*/
int ast_extension_state ( struct ast_channel * c , char * context , char * exten ) ;
2005-08-29 23:53:29 +00:00
/*! Return string of the state of an extension */
/*!
* \ param extension_state is the numerical state delivered by ast_extension_state
* Returns the state of an extension as string
*/
const char * ast_extension_state2str ( int extension_state ) ;
2005-01-15 23:48:12 +00:00
/*! Registers a state change callback */
2003-03-30 22:55:42 +00:00
/*!
* \ param context which context to look in
* \ param exten which extension to get state
* \ param callback callback to call if state changed
* \ param data to pass to callback
* The callback is called if the state for extension is changed
* Return - 1 on failure , ID on success
*/
2004-10-03 04:19:59 +00:00
int ast_extension_state_add ( const char * context , const char * exten ,
2003-04-06 18:19:51 +00:00
ast_state_cb_type callback , void * data ) ;
2003-03-30 22:55:42 +00:00
2005-01-15 23:48:12 +00:00
/*! Deletes a registered state change callback by ID */
2003-03-30 22:55:42 +00:00
/*!
* \ param id of the callback to delete
* Removes the callback from list of callbacks
* Return 0 on success , - 1 on failure
*/
2003-04-06 18:19:51 +00:00
int ast_extension_state_del ( int id , ast_state_cb_type callback ) ;
2003-03-30 22:55:42 +00:00
2005-01-15 23:48:12 +00:00
/*! If an extension exists, return non-zero */
2003-03-30 22:55:42 +00:00
/*!
* \ param hint buffer for hint
* \ param maxlen size of hint buffer
2005-02-01 01:53:25 +00:00
* \ param hint buffer for name portion of hint
* \ param maxlen size of name buffer
2003-03-30 22:55:42 +00:00
* \ param c this is not important
* \ param context which context to look in
* \ param exten which extension to search for
* If an extension within the given context with the priority PRIORITY_HINT
* is found a non zero value will be returned .
* Otherwise , 0 is returned .
*/
2005-02-01 01:53:25 +00:00
int ast_get_hint ( char * hint , int maxlen , char * name , int maxnamelen , struct ast_channel * c , const char * context , const char * exten ) ;
2003-03-30 22:55:42 +00:00
2005-01-15 23:48:12 +00:00
/*! If an extension exists, return non-zero */
/* work */
2001-11-06 17:34:13 +00:00
/*!
* \ param c this is not important
* \ param context which context to look in
* \ param exten which extension to search for
* \ param priority priority of the action within the extension
* \ param callerid callerid to search for
* If an extension within the given context ( or callerid ) with the given priority is found a non zero value will be returned .
* Otherwise , 0 is returned .
*/
2004-10-03 04:19:59 +00:00
int ast_exists_extension ( struct ast_channel * c , const char * context , const char * exten , int priority , const char * callerid ) ;
2005-01-15 23:48:12 +00:00
/*! If an extension exists, return non-zero */
/* work */
2004-10-03 04:19:59 +00:00
/*!
* \ param c this is not important
* \ param context which context to look in
* \ param exten which extension to search for
* \ param labellabel of the action within the extension to match to priority
* \ param callerid callerid to search for
* If an priority which matches given label in extension or - 1 if not found .
\ */
int ast_findlabel_extension ( struct ast_channel * c , const char * context , const char * exten , const char * label , const char * callerid ) ;
1999-10-27 00:56:38 +00:00
2004-10-03 16:15:44 +00:00
int ast_findlabel_extension2 ( struct ast_channel * c , struct ast_context * con , const char * exten , const char * label , const char * callerid ) ;
2005-01-15 23:48:12 +00:00
/*! Looks for a valid matching extension */
2001-11-06 17:34:13 +00:00
/*!
\ param c not really important
\ param context context to serach within
\ param exten extension to check
\ param priority priority of extension path
\ param callerid callerid of extension being searched for
If " exten " * could be * a valid extension in this context with or without
1999-12-25 22:31:01 +00:00
some more digits , return non - zero . Basically , when this returns 0 , no matter
2001-11-06 17:34:13 +00:00
what you add to exten , it ' s not going to be a valid extension anymore
*/
2004-10-03 04:19:59 +00:00
int ast_canmatch_extension ( struct ast_channel * c , const char * context , const char * exten , int priority , const char * callerid ) ;
1999-12-25 22:31:01 +00:00
2005-01-15 23:48:12 +00:00
/*! Looks to see if adding anything to this extension might match something. (exists ^ canmatch) */
2002-11-10 03:20:35 +00:00
/*!
\ param c not really important
\ param context context to serach within
\ param exten extension to check
\ param priority priority of extension path
\ param callerid callerid of extension being searched for
If " exten " * could match * a valid extension in this context with
some more digits , return non - zero . Does NOT return non - zero if this is
an exact - match only . Basically , when this returns 0 , no matter
what you add to exten , it ' s not going to be a valid extension anymore
*/
2004-10-03 04:19:59 +00:00
int ast_matchmore_extension ( struct ast_channel * c , const char * context , const char * exten , int priority , const char * callerid ) ;
2002-11-10 03:20:35 +00:00
2005-01-15 23:48:12 +00:00
/*! Determine if a given extension matches a given pattern (in NXX format) */
2001-11-06 17:34:13 +00:00
/*!
* \ param pattern pattern to match
* \ param extension extension to check against the pattern .
* Checks whether or not the given extension matches the given pattern .
* Returns 1 on match , 0 on failure
*/
2004-10-03 04:19:59 +00:00
int ast_extension_match ( const char * pattern , const char * extension ) ;
2004-11-24 03:07:08 +00:00
int ast_extension_close ( const char * pattern , const char * data , int needmore ) ;
2005-01-15 23:48:12 +00:00
/*! Launch a new extension (i.e. new stack) */
2001-11-06 17:34:13 +00:00
/*!
* \ param c not important
* \ param context which context to generate the extension within
* \ param exten new extension to add
* \ param priority priority of new extension
* \ param callerid callerid of extension
* This adds a new extension to the asterisk extension list .
* It returns 0 on success , - 1 on failure .
*/
2004-10-03 04:19:59 +00:00
int ast_spawn_extension ( struct ast_channel * c , const char * context , const char * exten , int priority , const char * callerid ) ;
1999-10-27 00:56:38 +00:00
2005-01-15 23:48:12 +00:00
/*! Execute an extension. */
2001-11-06 17:34:13 +00:00
/*!
\ param c channel to execute upon
\ param context which context extension is in
\ param exten extension to execute
\ param priority priority to execute within the given extension
If it ' s not available , do whatever you should do for
1999-10-27 00:56:38 +00:00
default extensions and halt the thread if necessary . This function does not
2001-11-06 17:34:13 +00:00
return , except on error .
*/
2004-10-03 04:19:59 +00:00
int ast_exec_extension ( struct ast_channel * c , const char * context , const char * exten , int priority , const char * callerid ) ;
1999-10-27 00:56:38 +00:00
2005-01-15 23:48:12 +00:00
/*! Add an include */
2001-11-06 17:34:13 +00:00
/*!
\ param context context to add include to
\ param include new include to add
\ param registrar who ' s registering it
Adds an include taking a char * string as the context parameter
Returns 0 on success , - 1 on error
*/
2004-10-03 04:19:59 +00:00
int ast_context_add_include ( const char * context , const char * include , const char * registrar ) ;
2001-11-06 17:34:13 +00:00
2005-01-15 23:48:12 +00:00
/*! Add an include */
2001-11-06 17:34:13 +00:00
/*!
\ param con context to add the include to
\ param include include to add
\ param registrar who registered the context
Adds an include taking a struct ast_context as the first parameter
Returns 0 on success , - 1 on failure
*/
2004-10-03 04:19:59 +00:00
int ast_context_add_include2 ( struct ast_context * con , const char * include , const char * registrar ) ;
2001-03-30 16:31:28 +00:00
2005-01-15 23:48:12 +00:00
/*! Removes an include */
2001-11-06 17:34:13 +00:00
/*!
* See add_include
*/
2004-10-03 04:19:59 +00:00
int ast_context_remove_include ( const char * context , const char * include , const char * registrar ) ;
2005-01-15 23:48:12 +00:00
/*! Removes an include by an ast_context structure */
2001-11-06 17:34:13 +00:00
/*!
* See add_include2
*/
2004-10-03 04:19:59 +00:00
int ast_context_remove_include2 ( struct ast_context * con , const char * include , const char * registrar ) ;
2001-03-30 16:31:28 +00:00
2005-01-15 23:48:12 +00:00
/*! Verifies includes in an ast_contect structure */
2003-10-25 17:50:06 +00:00
/*!
* \ param con context in which to verify the includes
* Returns 0 if no problems found , - 1 if there were any missing context
*/
int ast_context_verify_includes ( struct ast_context * con ) ;
2005-01-15 23:48:12 +00:00
/*! Add a switch */
2001-11-06 17:34:13 +00:00
/*!
* \ param context context to which to add the switch
* \ param sw switch to add
* \ param data data to pass to switch
2005-01-13 05:14:56 +00:00
* \ param eval whether to evaluate variables when running switch
2001-11-06 17:34:13 +00:00
* \ param registrar whoever registered the switch
* This function registers a switch with the asterisk switch architecture
* It returns 0 on success , - 1 on failure
*/
2005-01-13 05:14:56 +00:00
int ast_context_add_switch ( const char * context , const char * sw , const char * data , int eval , const char * registrar ) ;
2005-01-15 23:48:12 +00:00
/*! Adds a switch (first param is a ast_context) */
2001-11-06 17:34:13 +00:00
/*!
* See ast_context_add_switch ( )
*/
2005-01-13 05:14:56 +00:00
int ast_context_add_switch2 ( struct ast_context * con , const char * sw , const char * data , int eval , const char * registrar ) ;
2001-09-19 14:40:16 +00:00
2005-01-15 23:48:12 +00:00
/*! Remove a switch */
2001-11-06 17:34:13 +00:00
/*!
* Removes a switch with the given parameters
* Returns 0 on success , - 1 on failure
*/
2004-10-03 04:19:59 +00:00
int ast_context_remove_switch ( const char * context , const char * sw , const char * data , const char * registrar ) ;
int ast_context_remove_switch2 ( struct ast_context * con , const char * sw , const char * data , const char * registrar ) ;
2001-09-19 14:40:16 +00:00
2005-01-15 23:48:12 +00:00
/*! Simply remove extension from context */
2001-11-06 17:34:13 +00:00
/*!
* \ param context context to remove extension from
* \ param extension which extension to remove
* \ param priority priority of extension to remove
* \ param registrar registrar of the extension
* This function removes an extension from a given context .
* Returns 0 on success , - 1 on failure
*/
2004-10-03 04:19:59 +00:00
int ast_context_remove_extension ( const char * context , const char * extension , int priority ,
const char * registrar ) ;
int ast_context_remove_extension2 ( struct ast_context * con , const char * extension ,
int priority , const char * registrar ) ;
2001-09-19 14:40:16 +00:00
2005-01-15 23:48:12 +00:00
/*! Add an ignorepat */
2001-11-06 17:34:13 +00:00
/*!
* \ param context which context to add the ignorpattern to
* \ param ignorpat ignorepattern to set up for the extension
* \ param registrar registrar of the ignore pattern
* Adds an ignore pattern to a particular context .
* Returns 0 on success , - 1 on failure
*/
2004-10-03 04:19:59 +00:00
int ast_context_add_ignorepat ( const char * context , const char * ignorepat , const char * registrar ) ;
int ast_context_add_ignorepat2 ( struct ast_context * con , const char * ignorepat , const char * registrar ) ;
2001-09-19 14:40:16 +00:00
/* Remove an ignorepat */
2001-11-06 17:34:13 +00:00
/*!
* \ param context context from which to remove the pattern
* \ param ignorepat the pattern to remove
* \ param registrar the registrar of the ignore pattern
* This removes the given ignorepattern
* Returns 0 on success , - 1 on failure
*/
2004-10-03 04:19:59 +00:00
int ast_context_remove_ignorepat ( const char * context , const char * ignorepat , const char * registrar ) ;
int ast_context_remove_ignorepat2 ( struct ast_context * con , const char * ignorepat , const char * registrar ) ;
2001-09-19 14:40:16 +00:00
2005-01-15 23:48:12 +00:00
/*! Checks to see if a number should be ignored */
2001-11-06 17:34:13 +00:00
/*!
* \ param context context to search within
* \ param extension to check whether it should be ignored or not
* Check if a number should be ignored with respect to dialtone cancellation .
* Returns 0 if the pattern should not be ignored , or non - zero if the pattern should be ignored
*/
2004-10-03 04:19:59 +00:00
int ast_ignore_pattern ( const char * context , const char * pattern ) ;
2001-09-19 14:40:16 +00:00
/* Locking functions for outer modules, especially for completion functions */
2005-01-15 23:48:12 +00:00
/*! Locks the contexts */
2001-11-06 17:34:13 +00:00
/*! Locks the context list
* Returns 0 on success , - 1 on error
*/
2001-09-19 14:40:16 +00:00
int ast_lock_contexts ( void ) ;
2001-11-06 17:34:13 +00:00
2005-01-15 23:48:12 +00:00
/*! Unlocks contexts */
2001-11-06 17:34:13 +00:00
/*!
* Returns 0 on success , - 1 on failure
*/
2001-09-19 14:40:16 +00:00
int ast_unlock_contexts ( void ) ;
2005-01-15 23:48:12 +00:00
/*! Locks a given context */
2001-11-06 17:34:13 +00:00
/*!
* \ param con context to lock
* Locks the context .
* Returns 0 on success , - 1 on failure
*/
2001-09-19 14:40:16 +00:00
int ast_lock_context ( struct ast_context * con ) ;
2005-01-15 23:48:12 +00:00
/*! Unlocks the given context */
2001-11-06 17:34:13 +00:00
/*!
* \ param con context to unlock
* Unlocks the given context
* Returns 0 on success , - 1 on failure
*/
2001-09-19 14:40:16 +00:00
int ast_unlock_context ( struct ast_context * con ) ;
2002-09-09 15:05:28 +00:00
2004-10-03 04:19:59 +00:00
int ast_async_goto ( struct ast_channel * chan , const char * context , const char * exten , int priority ) ;
2002-09-09 15:05:28 +00:00
2004-10-03 04:19:59 +00:00
int ast_async_goto_by_name ( const char * chan , const char * context , const char * exten , int priority ) ;
2002-09-09 15:05:28 +00:00
/* Synchronously or asynchronously make an outbound call and send it to a
particular extension */
2005-07-15 23:24:51 +00:00
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 , struct ast_channel * * locked_channel ) ;
2002-09-09 15:05:28 +00:00
/* Synchronously or asynchronously make an outbound call and send it to a
particular application with given extension */
2005-07-15 23:24:51 +00:00
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 , struct ast_channel * * locked_channel ) ;
2002-09-09 15:05:28 +00:00
2001-09-19 14:40:16 +00:00
/* Functions for returning values from structures */
2004-10-03 04:19:59 +00:00
const char * ast_get_context_name ( struct ast_context * con ) ;
const char * ast_get_extension_name ( struct ast_exten * exten ) ;
const char * ast_get_include_name ( struct ast_include * include ) ;
const char * ast_get_ignorepat_name ( struct ast_ignorepat * ip ) ;
const char * ast_get_switch_name ( struct ast_sw * sw ) ;
const char * ast_get_switch_data ( struct ast_sw * sw ) ;
2001-09-19 14:40:16 +00:00
/* Other extension stuff */
int ast_get_extension_priority ( struct ast_exten * exten ) ;
2004-08-21 18:55:39 +00:00
int ast_get_extension_matchcid ( struct ast_exten * e ) ;
2004-10-03 04:19:59 +00:00
const char * ast_get_extension_cidmatch ( struct ast_exten * e ) ;
const char * ast_get_extension_app ( struct ast_exten * e ) ;
const char * ast_get_extension_label ( struct ast_exten * e ) ;
2001-09-19 14:40:16 +00:00
void * ast_get_extension_app_data ( struct ast_exten * e ) ;
/* Registrar info functions ... */
2004-10-03 04:19:59 +00:00
const char * ast_get_context_registrar ( struct ast_context * c ) ;
const char * ast_get_extension_registrar ( struct ast_exten * e ) ;
const char * ast_get_include_registrar ( struct ast_include * i ) ;
const char * ast_get_ignorepat_registrar ( struct ast_ignorepat * ip ) ;
const char * ast_get_switch_registrar ( struct ast_sw * sw ) ;
2001-09-19 14:40:16 +00:00
/* Walking functions ... */
struct ast_context * ast_walk_contexts ( struct ast_context * con ) ;
struct ast_exten * ast_walk_context_extensions ( struct ast_context * con ,
struct ast_exten * priority ) ;
struct ast_exten * ast_walk_extension_priorities ( struct ast_exten * exten ,
struct ast_exten * priority ) ;
struct ast_include * ast_walk_context_includes ( struct ast_context * con ,
struct ast_include * inc ) ;
struct ast_ignorepat * ast_walk_context_ignorepats ( struct ast_context * con ,
struct ast_ignorepat * ip ) ;
struct ast_sw * ast_walk_context_switches ( struct ast_context * con , struct ast_sw * sw ) ;
2002-11-10 03:20:35 +00:00
2004-10-22 20:59:38 +00:00
int pbx_builtin_serialize_variables ( struct ast_channel * chan , char * buf , size_t size ) ;
2005-03-29 06:16:49 +00:00
extern char * pbx_builtin_getvar_helper ( struct ast_channel * chan , const char * name ) ;
extern void pbx_builtin_setvar_helper ( struct ast_channel * chan , const char * name , const char * value ) ;
2004-12-23 02:47:01 +00:00
extern void pbx_retrieve_variable ( struct ast_channel * c , const char * var , char * * ret , char * workspace , int workspacelen , struct varshead * headp ) ;
2003-02-12 13:59:15 +00:00
extern void pbx_builtin_clear_globals ( void ) ;
2003-09-22 15:27:09 +00:00
extern int pbx_builtin_setvar ( struct ast_channel * chan , void * data ) ;
2003-06-04 15:02:38 +00:00
extern void pbx_substitute_variables_helper ( struct ast_channel * c , const char * cp1 , char * cp2 , int count ) ;
2004-10-24 02:53:24 +00:00
extern void pbx_substitute_variables_varshead ( struct varshead * headp , const char * cp1 , char * cp2 , int count ) ;
2003-02-12 13:59:15 +00:00
2003-09-13 20:51:48 +00:00
int ast_extension_patmatch ( const char * pattern , const char * data ) ;
2004-10-16 19:46:02 +00:00
/* Set "autofallthrough" flag, if newval is <0, does not acutally set. If
set to 1 , sets to auto fall through . If newval set to 0 , sets to no auto
fall through ( reads extension instead ) . Returns previous value . */
extern int pbx_set_autofallthrough ( int newval ) ;
2004-11-22 22:11:10 +00:00
int ast_goto_if_exists ( struct ast_channel * chan , char * context , char * exten , int priority ) ;
/* I can find neither parsable nor parseable at dictionary.com, but google gives me 169000 hits for parseable and only 49,800 for parsable */
int ast_parseable_goto ( struct ast_channel * chan , const char * goto_string ) ;
2004-11-23 20:25:02 +00:00
int ast_explicit_goto ( struct ast_channel * chan , const char * context , const char * exten , int priority ) ;
int ast_async_goto_if_exists ( struct ast_channel * chan , char * context , char * exten , int priority ) ;
2005-05-05 05:39:33 +00:00
struct ast_custom_function * ast_custom_function_find ( char * name ) ;
int ast_custom_function_unregister ( struct ast_custom_function * acf ) ;
int ast_custom_function_register ( struct ast_custom_function * acf ) ;
2005-05-18 01:49:13 +00:00
/* Number of active calls */
int ast_active_calls ( void ) ;
2005-05-05 15:07:49 +00:00
/*! executes a read operation on a function */
/*!
* \ param chan Channel to execute on
* \ param in Data containing the function call string
* \ param workspace A pointer to safe memory to use for a return value
* \ param len the number of bytes in workspace
* This application executes an function in read mode on a given channel .
* It returns a pointer to workspace if the buffer contains any new data
* or NULL if there was a problem .
*/
char * ast_func_read ( struct ast_channel * chan , const char * in , char * workspace , size_t len ) ;
/*! executes a write operation on a function */
/*!
* \ param chan Channel to execute on
* \ param in Data containing the function call string
* \ param value A value parameter to pass for writing
* This application executes an function in write mode on a given channel .
* It has no return value .
*/
void ast_func_write ( struct ast_channel * chan , const char * in , const char * value ) ;
2005-03-04 06:36:18 +00:00
2005-07-08 21:14:34 +00:00
void ast_hint_state_changed ( const char * device ) ;
1999-10-27 00:56:38 +00:00
# if defined(__cplusplus) || defined(c_plusplus)
}
# endif
2005-08-30 18:32:10 +00:00
# endif /* _ASTERISK_PBX_H */