📄 pbx.h
字号:
/* Locking functions for outer modules, especially for completion functions *//*! * \brief Write locks the context list * * \retval 0 on success * \retval -1 on error */int ast_wrlock_contexts(void);/*! * \brief Read locks the context list * * \retval 0 on success * \retval -1 on error */int ast_rdlock_contexts(void);/*! * \brief Unlocks contexts * * \retval 0 on success * \retval -1 on failure */int ast_unlock_contexts(void);/*! * \brief Write locks a given context * * \param con context to lock * * \retval 0 on success * \retval -1 on failure */int ast_wrlock_context(struct ast_context *con);/*! * \brief Read locks a given context * * \param con context to lock * * \retval 0 on success * \retval -1 on failure */int ast_rdlock_context(struct ast_context *con);/*! * \retval Unlocks the given context * * \param con context to unlock * * \retval 0 on success * \retval -1 on failure */int ast_unlock_context(struct ast_context *con);/*! * \brief locks the macrolock in the given given context * * \param macrocontext name of the macro-context to lock * * Locks the given macro-context to ensure only one thread (call) can execute it at a time * * \retval 0 on success * \retval -1 on failure */int ast_context_lockmacro(const char *macrocontext);/*! * \brief Unlocks the macrolock in the given context * * \param macrocontext name of the macro-context to unlock * * Unlocks the given macro-context so that another thread (call) can execute it * * \retval 0 on success * \retval -1 on failure */int ast_context_unlockmacro(const char *macrocontext);int ast_async_goto(struct ast_channel *chan, const char *context, const char *exten, int priority);int ast_async_goto_by_name(const char *chan, const char *context, const char *exten, int priority);/*! Synchronously or asynchronously make an outbound call and send it to a particular extension */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);/*! Synchronously or asynchronously make an outbound call and send it to a particular application with given extension */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);/*! * \brief Evaluate a condition * * \retval 0 if the condition is NULL or of zero length * \retval int If the string is an integer, the integer representation of * the integer is returned * \retval 1 Any other non-empty string */int pbx_checkcondition(const char *condition);/*! @name * Functions for returning values from structures *//*! @{ */const char *ast_get_context_name(struct ast_context *con);const char *ast_get_extension_name(struct ast_exten *exten);struct ast_context *ast_get_extension_context(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);int ast_get_switch_eval(struct ast_sw *sw); /*! @} *//*! @name Other Extension stuff *//*! @{ */int ast_get_extension_priority(struct ast_exten *exten);int ast_get_extension_matchcid(struct ast_exten *e);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);void *ast_get_extension_app_data(struct ast_exten *e);/*! @} *//*! @name Registrar info functions ... *//*! @{ */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);/*! @} *//* 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);/*! * \note Will lock the channel. */int pbx_builtin_serialize_variables(struct ast_channel *chan, struct ast_str **buf);/*! * \note Will lock the channel. * * \note This function will return a pointer to the buffer inside the channel * variable. This value should only be accessed with the channel locked. If * the value needs to be kept around, it should be done by using the following * thread-safe code: * \code * const char *var; * * ast_channel_lock(chan); * if ((var = pbx_builtin_getvar_helper(chan, "MYVAR"))) { * var = ast_strdupa(var); * } * ast_channel_unlock(chan); * \endcode */const char *pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name);/*! * \note Will lock the channel. */void pbx_builtin_pushvar_helper(struct ast_channel *chan, const char *name, const char *value);/*! * \note Will lock the channel. */void pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value);/*! * \note Will lock the channel. */void pbx_retrieve_variable(struct ast_channel *c, const char *var, char **ret, char *workspace, int workspacelen, struct varshead *headp);void pbx_builtin_clear_globals(void);/*! * \note Will lock the channel. */int pbx_builtin_setvar(struct ast_channel *chan, void *data);int pbx_builtin_setvar_multiple(struct ast_channel *chan, void *data);int pbx_builtin_raise_exception(struct ast_channel *chan, void *data);void pbx_substitute_variables_helper(struct ast_channel *c,const char *cp1,char *cp2,int count);void pbx_substitute_variables_varshead(struct varshead *headp, const char *cp1, char *cp2, int count);int ast_extension_patmatch(const char *pattern, const char *data);/*! 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. */int pbx_set_autofallthrough(int newval);/*! Set "extenpatternmatchnew" flag, if newval is <0, does not acutally set. If set to 1, sets to use the new Trie-based pattern matcher. If newval set to 0, sets to use the old linear-search algorithm. Returns previous value. */int pbx_set_extenpatternmatchnew(int newval);/*! * \note This function will handle locking the channel as needed. */int ast_goto_if_exists(struct ast_channel *chan, const char *context, const char *exten, int priority);/*! * \note I can find neither parsable nor parseable at dictionary.com, * but google gives me 169000 hits for parseable and only 49,800 * for parsable * * \note This function will handle locking the channel as needed. */int ast_parseable_goto(struct ast_channel *chan, const char *goto_string);/*! * \note This function will handle locking the channel as needed. */int ast_async_parseable_goto(struct ast_channel *chan, const char *goto_string);/*! * \note This function will handle locking the channel as needed. */int ast_explicit_goto(struct ast_channel *chan, const char *context, const char *exten, int priority);/*! * \note This function will handle locking the channel as needed. */int ast_async_goto_if_exists(struct ast_channel *chan, const char *context, const char *exten, int priority);struct ast_custom_function* ast_custom_function_find(const char *name);/*! * \brief Unregister a custom function */int ast_custom_function_unregister(struct ast_custom_function *acf);/*! * \brief Register a custom function */#define ast_custom_function_register(acf) __ast_custom_function_register(acf, ast_module_info->self)/*! * \brief Register a custom function */int __ast_custom_function_register(struct ast_custom_function *acf, struct ast_module *mod);/*! * \brief Retrieve the number of active calls */int ast_active_calls(void);/*! * \brief Retrieve the total number of calls processed through the PBX since last restart */int ast_processed_calls(void); /*! * \brief executes a read operation on a function * * \param chan Channel to execute on * \param function Data containing the function call string (will be modified) * \param workspace A pointer to safe memory to use for a return value * \param len the number of bytes in workspace * * This application executes a function in read mode on a given channel. * * \return zero on success, non-zero on failure */int ast_func_read(struct ast_channel *chan, const char *function, char *workspace, size_t len);/*! * \brief executes a write operation on a function * * \param chan Channel to execute on * \param function Data containing the function call string (will be modified) * \param value A value parameter to pass for writing * * This application executes a function in write mode on a given channel. * * \return zero on success, non-zero on failure */int ast_func_write(struct ast_channel *chan, const char *function, const char *value);/*! * When looking up extensions, we can have different requests * identified by the 'action' argument, as follows. * Note that the coding is such that the low 4 bits are the * third argument to extension_match_core. */enum ext_match_t { E_MATCHMORE = 0x00, /* extension can match but only with more 'digits' */ E_CANMATCH = 0x01, /* extension can match with or without more 'digits' */ E_MATCH = 0x02, /* extension is an exact match */ E_MATCH_MASK = 0x03, /* mask for the argument to extension_match_core() */ E_SPAWN = 0x12, /* want to spawn an extension. Requires exact match */ E_FINDLABEL = 0x22 /* returns the priority for a given label. Requires exact match */};#define STATUS_NO_CONTEXT 1#define STATUS_NO_EXTENSION 2#define STATUS_NO_PRIORITY 3#define STATUS_NO_LABEL 4#define STATUS_SUCCESS 5 #define AST_PBX_MAX_STACK 128/* request and result for pbx_find_extension */struct pbx_find_info {#if 0 const char *context; const char *exten; int priority;#endif char *incstack[AST_PBX_MAX_STACK]; /* filled during the search */ int stacklen; /* modified during the search */ int status; /* set on return */ struct ast_switch *swo; /* set on return */ const char *data; /* set on return */ const char *foundcontext; /* set on return */}; 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);/* every time a write lock is obtained for contexts, a counter is incremented. You can check this via the following func */int ast_wrlock_contexts_version(void); /* hashtable functions for contexts */int ast_hashtab_compare_contexts(const void *ah_a, const void *ah_b);unsigned int ast_hashtab_hash_contexts(const void *obj);#if defined(__cplusplus) || defined(c_plusplus)}#endif#endif /* _ASTERISK_PBX_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -