⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pbx.h

📁 asterisk 是一个很有知名度开源软件
💻 H
📖 第 1 页 / 共 3 页
字号:
/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2006, Digium, Inc. * * Mark Spencer <markster@digium.com> * * 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. * * This program is free software, distributed under the terms of * the GNU General Public License Version 2. See the LICENSE file * at the top of the source tree. *//*! \file * \brief Core PBX routines and definitions. */#ifndef _ASTERISK_PBX_H#define _ASTERISK_PBX_H#include "asterisk/sched.h"#include "asterisk/chanvars.h"#include "asterisk/hashtab.h"#if defined(__cplusplus) || defined(c_plusplus)extern "C" {#endif#define AST_MAX_APP	32	/*!< Max length of an application */#define AST_PBX_KEEP    0#define AST_PBX_REPLACE 1/*! \brief Special return values from applications to the PBX { */#define AST_PBX_HANGUP	        -1	/*!< Jump to the 'h' exten */#define AST_PBX_OK	        0	/*!< No errors */#define AST_PBX_ERROR	        1	/*!< Jump to the 'e' exten *//*! } */#define PRIORITY_HINT	-1	/*!< Special Priority for a hint *//*! \brief Extension states 	\note States can be combined 	- \ref AstExtState*/enum ast_extension_states {	AST_EXTENSION_REMOVED = -2,	/*!< Extension removed */	AST_EXTENSION_DEACTIVATED = -1,	/*!< Extension hint removed */	AST_EXTENSION_NOT_INUSE = 0,	/*!< No device INUSE or BUSY  */	AST_EXTENSION_INUSE = 1 << 0,	/*!< One or more devices INUSE */	AST_EXTENSION_BUSY = 1 << 1,	/*!< All devices BUSY */	AST_EXTENSION_UNAVAILABLE = 1 << 2, /*!< All devices UNAVAILABLE/UNREGISTERED */	AST_EXTENSION_RINGING = 1 << 3,	/*!< All devices RINGING */	AST_EXTENSION_ONHOLD = 1 << 4,	/*!< All devices ONHOLD */};struct ast_context;struct ast_exten;     struct ast_include;struct ast_ignorepat;struct ast_sw;/*! \brief Typedef for devicestate and hint callbacks */typedef int (*ast_state_cb_type)(char *context, char* id, enum ast_extension_states state, void *data);/*! \brief Data structure associated with a custom dialplan function */struct ast_custom_function {	const char *name;		/*!< Name */	const char *synopsis;		/*!< Short description for "show functions" */	const char *desc;		/*!< Help text that explains it all */	const char *syntax;		/*!< Syntax description */	int (*read)(struct ast_channel *, const char *, char *, char *, size_t);	/*!< Read function, if read is supported */	int (*write)(struct ast_channel *, const char *, char *, const char *);		/*!< Write function, if write is supported */	struct ast_module *mod;         /*!< Module this custom function belongs to */	AST_RWLIST_ENTRY(ast_custom_function) acflist;};/*! \brief All switch functions have the same interface, so define a type for them */typedef int (ast_switch_f)(struct ast_channel *chan, const char *context,	const char *exten, int priority, const char *callerid, const char *data);/*!< Data structure associated with an Asterisk switch */struct ast_switch {	AST_LIST_ENTRY(ast_switch) list;	const char *name;			/*!< Name of the switch */	const char *description;		/*!< Description of the switch */		ast_switch_f *exists;	ast_switch_f *canmatch;	ast_switch_f *exec;	ast_switch_f *matchmore;};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 */};int ast_build_timing(struct ast_timing *i, const char *info);int ast_check_timing(const struct ast_timing *i);struct ast_pbx {	int dtimeout;				/*!< Timeout between digits (seconds) */	int rtimeout;				/*!< Timeout for response (seconds) */};/*! * \brief Register an alternative dialplan switch * * \param sw switch to register * * This function registers a populated ast_switch structure with the * asterisk switching architecture. * * \return 0 on success, and other than 0 on failure */int ast_register_switch(struct ast_switch *sw);/*! * \brief Unregister an alternative switch * * \param sw switch to unregister *  * Unregisters a switch from asterisk. * * \return nothing */void ast_unregister_switch(struct ast_switch *sw);/*! * \brief Look up an application * * \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. * * \return the ast_app structure that matches on success, or NULL on failure */struct ast_app *pbx_findapp(const char *app);/*! * \brief Execute an application * * \param c channel to execute on * \param app which app to execute * \param data the data passed into the app * * This application executes an application on a given channel.  It * saves the stack and executes the given application passing in * the given data. * * \return 0 on success, and -1 on failure */int pbx_exec(struct ast_channel *c, struct ast_app *app, void *data);/*! * \brief Register a new context or find an existing one * * \param extcontexts pointer to the ast_context structure pointer * \param exttable pointer to the hashtable that contains all the elements in extcontexts * \param name name of the new context * \param registrar registrar of the context * * This function allows you to play in two environments: the global contexts (active dialplan) * or an external context set of your choosing. To act on the external set, make sure extcontexts * and exttable are set; for the globals, make sure both extcontexts and exttable are NULL. * * 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. * * \return NULL on failure, and an ast_context structure on success */struct ast_context *ast_context_find_or_create(struct ast_context **extcontexts, struct ast_hashtab *exttable, const char *name, const char *registrar);/*! * \brief Merge the temporary contexts into a global contexts list and delete from the  *        global list the ones that are being added * * \param extcontexts pointer to the ast_context structure * \param exttable pointer to the ast_hashtab structure that contains all the elements in extcontexts * \param registrar 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 */void ast_merge_contexts_and_delete(struct ast_context **extcontexts, struct ast_hashtab *exttable, const char *registrar);/*! * \brief Destroy a context (matches the specified context (or ANY context if NULL) * * \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. * * \return nothing */void ast_context_destroy(struct ast_context *con, const char *registrar);/*! * \brief Find a context * * \param name name of the context to find * * Will search for the context with the given name. * * \return the ast_context on success, NULL on failure. */struct ast_context *ast_context_find(const char *name);/*! \brief The result codes when starting the PBX on a channelwith \see ast_pbx_start.	AST_PBX_CALL_LIMIT refers to the maxcalls call limit in asterisk.conf */enum ast_pbx_result {	AST_PBX_SUCCESS = 0,	AST_PBX_FAILED = -1,	AST_PBX_CALL_LIMIT = -2,};/*! * \brief Create a new thread and start the PBX * * \param c channel to start the pbx on * * \see ast_pbx_run for a synchronous function to run the PBX in the * current thread, as opposed to starting a new one. * * \retval Zero on success * \retval non-zero on failure */enum ast_pbx_result ast_pbx_start(struct ast_channel *c);/*! * \brief Execute the PBX in the current thread * * \param c channel to run the pbx on * * This executes the PBX on a given channel. It allocates a new * PBX structure for the channel, and provides all PBX functionality. * See ast_pbx_start for an asynchronous function to run the PBX in a * new thread as opposed to the current one. *  * \retval Zero on success * \retval non-zero on failure */enum ast_pbx_result ast_pbx_run(struct ast_channel *c);/*! * \brief Options for ast_pbx_run() */struct ast_pbx_args {	union {		/*! Pad this out so that we have plenty of room to add options		 *  but still maintain ABI compatibility over time. */		uint64_t __padding;		struct {			/*! Do not hangup the channel when the PBX is complete. */			unsigned int no_hangup_chan:1;		};	};};/*! * \brief Execute the PBX in the current thread * * \param c channel to run the pbx on * \param args options for the pbx * * This executes the PBX on a given channel. It allocates a new * PBX structure for the channel, and provides all PBX functionality. * See ast_pbx_start for an asynchronous function to run the PBX in a * new thread as opposed to the current one. *  * \retval Zero on success * \retval non-zero on failure */enum ast_pbx_result ast_pbx_run_args(struct ast_channel *c, struct ast_pbx_args *args);/*!  * \brief Add and extension to an extension context.   *  * \param context context to add the extension to * \param replace * \param extension extension to add * \param priority priority level of extension addition * \param label extension label * \param callerid pattern to match CallerID, or NULL to match any CallerID * \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 * * \retval 0 success  * \retval -1 failure */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);/*!  * \brief Add an extension to an extension context, this time with an ast_context *. * * \note For details about the arguments, check ast_add_extension() */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);/*!  * \brief Uses hint and devicestate callback to get the state of an extension * * \param c this is not important * \param context which context to look in * \param exten which extension to get state * * \return extension state as defined in the ast_extension_states enum */int ast_extension_state(struct ast_channel *c, const char *context, const char *exten);/*!  * \brief Return string representation of the state of an extension *  * \param extension_state is the numerical state delivered by ast_extension_state * * \return the state of an extension as string */const char *ast_extension_state2str(int extension_state);/*! * \brief Registers a state change callback *  * \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 of an extension is changed. * * \retval -1 on failure * \retval ID on success */ 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -