Mon Jul 14 17:24:59 2008

Asterisk developer's documentation


pbx.h

Go to the documentation of this file.
00001 /*
00002  * Asterisk -- An open source telephony toolkit.
00003  *
00004  * Copyright (C) 1999 - 2006, Digium, Inc.
00005  *
00006  * Mark Spencer <markster@digium.com>
00007  *
00008  * See http://www.asterisk.org for more information about
00009  * the Asterisk project. Please do not directly contact
00010  * any of the maintainers of this project for assistance;
00011  * the project provides a web site, mailing lists and IRC
00012  * channels for your use.
00013  *
00014  * This program is free software, distributed under the terms of
00015  * the GNU General Public License Version 2. See the LICENSE file
00016  * at the top of the source tree.
00017  */
00018 
00019 /*! \file
00020  * \brief Core PBX routines and definitions.
00021  */
00022 
00023 #ifndef _ASTERISK_PBX_H
00024 #define _ASTERISK_PBX_H
00025 
00026 #include "asterisk/sched.h"
00027 #include "asterisk/channel.h"
00028 #include "asterisk/linkedlists.h"
00029 
00030 #if defined(__cplusplus) || defined(c_plusplus)
00031 extern "C" {
00032 #endif
00033 
00034 #define AST_MAX_APP  32 /*!< Max length of an application */
00035 
00036 #define AST_PBX_KEEP    0
00037 #define AST_PBX_REPLACE 1
00038 
00039 /*! \brief Special return values from applications to the PBX { */
00040 #define AST_PBX_KEEPALIVE  10 /*!< Destroy the thread, but don't hang up the channel */
00041 #define AST_PBX_NO_HANGUP_PEER   11
00042 /*! } */
00043 
00044 #define PRIORITY_HINT   -1 /*!< Special Priority for a hint */
00045 
00046 /*! \brief Extension states */
00047 enum ast_extension_states {
00048    AST_EXTENSION_REMOVED = -2,   /*!< Extension removed */
00049    AST_EXTENSION_DEACTIVATED = -1,  /*!< Extension hint removed */
00050    AST_EXTENSION_NOT_INUSE = 0,  /*!< No device INUSE or BUSY  */
00051    AST_EXTENSION_INUSE = 1 << 0, /*!< One or more devices INUSE */
00052    AST_EXTENSION_BUSY = 1 << 1,  /*!< All devices BUSY */
00053    AST_EXTENSION_UNAVAILABLE = 1 << 2, /*!< All devices UNAVAILABLE/UNREGISTERED */
00054    AST_EXTENSION_RINGING = 1 << 3,  /*!< All devices RINGING */
00055    AST_EXTENSION_ONHOLD = 1 << 4,   /*!< All devices ONHOLD */
00056 };
00057 
00058 
00059 struct ast_context;
00060 struct ast_exten;     
00061 struct ast_include;
00062 struct ast_ignorepat;
00063 struct ast_sw;
00064 
00065 /*! \brief Typedef for devicestate and hint callbacks */
00066 typedef int (*ast_state_cb_type)(char *context, char* id, enum ast_extension_states state, void *data, char *cid_num, char *cid_name);
00067 
00068 /*! \brief Data structure associated with a custom dialplan function */
00069 struct ast_custom_function {
00070    const char *name;    /*!< Name */
00071    const char *synopsis;      /*!< Short description for "show functions" */
00072    const char *desc;    /*!< Help text that explains it all */
00073    const char *syntax;     /*!< Syntax description */
00074    int (*read)(struct ast_channel *, char *, char *, char *, size_t);   /*!< Read function, if read is supported */
00075    int (*write)(struct ast_channel *, char *, char *, const char *); /*!< Write function, if write is supported */
00076    AST_LIST_ENTRY(ast_custom_function) acflist;
00077 };
00078 
00079 /*! \brief All switch functions have the same interface, so define a type for them */
00080 typedef int (ast_switch_f)(struct ast_channel *chan, const char *context,
00081    const char *exten, int priority, const char *callerid, const char *data);
00082 
00083 /*!< Data structure associated with an Asterisk switch */
00084 struct ast_switch {
00085    AST_LIST_ENTRY(ast_switch) list;
00086    const char *name;       /*!< Name of the switch */
00087    const char *description;      /*!< Description of the switch */
00088    
00089    ast_switch_f *exists;
00090    ast_switch_f *canmatch;
00091    ast_switch_f *exec;
00092    ast_switch_f *matchmore;
00093 };
00094 
00095 struct ast_timing {
00096    int hastime;            /*!< If time construct exists */
00097    unsigned int monthmask;       /*!< Mask for month */
00098    unsigned int daymask;         /*!< Mask for date */
00099    unsigned int dowmask;         /*!< Mask for day of week (mon-sun) */
00100    unsigned int minmask[24];     /*!< Mask for minute */
00101 };
00102 
00103 int ast_build_timing(struct ast_timing *i, const char *info);
00104 int ast_check_timing(const struct ast_timing *i);
00105 
00106 struct ast_pbx {
00107    int dtimeout;           /*!< Timeout between digits (seconds) */
00108    int rtimeout;           /*!< Timeout for response (seconds) */
00109 };
00110 
00111 
00112 /*!
00113  * \brief Register an alternative dialplan switch
00114  *
00115  * \param sw switch to register
00116  *
00117  * This function registers a populated ast_switch structure with the
00118  * asterisk switching architecture.
00119  *
00120  * \return 0 on success, and other than 0 on failure
00121  */
00122 int ast_register_switch(struct ast_switch *sw);
00123 
00124 /*!
00125  * \brief Unregister an alternative switch
00126  *
00127  * \param sw switch to unregister
00128  * 
00129  * Unregisters a switch from asterisk.
00130  *
00131  * \return nothing
00132  */
00133 void ast_unregister_switch(struct ast_switch *sw);
00134 
00135 /*!
00136  * \brief Look up an application
00137  *
00138  * \param app name of the app
00139  *
00140  * This function searches for the ast_app structure within
00141  * the apps that are registered for the one with the name
00142  * you passed in.
00143  *
00144  * \return the ast_app structure that matches on success, or NULL on failure
00145  */
00146 struct ast_app *pbx_findapp(const char *app);
00147 
00148 /*!
00149  * \brief Execute an application
00150  *
00151  * \param c channel to execute on
00152  * \param app which app to execute
00153  * \param data the data passed into the app
00154  *
00155  * This application executes an application on a given channel.  It
00156  * saves the stack and executes the given appliation passing in
00157  * the given data.
00158  *
00159  * \return 0 on success, and -1 on failure
00160  */
00161 int pbx_exec(struct ast_channel *c, struct ast_app *app, void *data);
00162 
00163 /*!
00164  * \brief Register a new context
00165  *
00166  * \param extcontexts pointer to the ast_context structure pointer
00167  * \param name name of the new context
00168  * \param registrar registrar of the context
00169  *
00170  * This will first search for a context with your name.  If it exists already, it will not
00171  * create a new one.  If it does not exist, it will create a new one with the given name
00172  * and registrar.
00173  *
00174  * \return NULL on failure, and an ast_context structure on success
00175  */
00176 struct ast_context *ast_context_create(struct ast_context **extcontexts, const char *name, const char *registrar);
00177 struct ast_context *ast_context_find_or_create(struct ast_context **extcontexts, const char *name, const char *registrar);
00178 
00179 /*!
00180  * \brief Merge the temporary contexts into a global contexts list and delete from the 
00181  *        global list the ones that are being added
00182  *
00183  * \param extcontexts pointer to the ast_context structure pointer
00184  * \param registrar of the context; if it's set the routine will delete all contexts 
00185  *        that belong to that registrar; if NULL only the contexts that are specified 
00186  *        in extcontexts
00187  */
00188 void ast_merge_contexts_and_delete(struct ast_context **extcontexts, const char *registrar);
00189 
00190 /*!
00191  * \brief Destroy a context (matches the specified context (or ANY context if NULL)
00192  *
00193  * \param con context to destroy
00194  * \param registrar who registered it
00195  *
00196  * You can optionally leave out either parameter.  It will find it
00197  * based on either the ast_context or the registrar name.
00198  *
00199  * \return nothing
00200  */
00201 void ast_context_destroy(struct ast_context *con, const char *registrar);
00202 
00203 /*!
00204  * \brief Find a context
00205  *
00206  * \param name name of the context to find
00207  *
00208  * Will search for the context with the given name.
00209  *
00210  * \return the ast_context on success, NULL on failure.
00211  */
00212 struct ast_context *ast_context_find(const char *name);
00213 
00214 enum ast_pbx_result {
00215    AST_PBX_SUCCESS = 0,
00216    AST_PBX_FAILED = -1,
00217    AST_PBX_CALL_LIMIT = -2,
00218 };
00219 
00220 /*!
00221  * \brief Create a new thread and start the PBX
00222  *
00223  * \param c channel to start the pbx on
00224  *
00225  * See ast_pbx_run for a synchronous function to run the PBX in the
00226  * current thread, as opposed to starting a new one.
00227  *
00228  * \return Zero on success, non-zero on failure
00229  */
00230 enum ast_pbx_result ast_pbx_start(struct ast_channel *c);
00231 
00232 /*!
00233  * \brief Execute the PBX in the current thread
00234  *
00235  * \param c channel to run the pbx on
00236  *
00237  * This executes the PBX on a given channel. It allocates a new
00238  * PBX structure for the channel, and provides all PBX functionality.
00239  * See ast_pbx_start for an asynchronous function to run the PBX in a
00240  * new thread as opposed to the current one.
00241  * 
00242  * \return Zero on success, non-zero on failure
00243  */
00244 enum ast_pbx_result ast_pbx_run(struct ast_channel *c);
00245 
00246 /*! 
00247  * \brief Add and extension to an extension context.  
00248  * 
00249  * \param context context to add the extension to
00250  * \param replace
00251  * \param extension extension to add
00252  * \param priority priority level of extension addition
00253  * \param label extension label
00254  * \param callerid pattern to match CallerID, or NULL to match any CallerID
00255  * \param application application to run on the extension with that priority level
00256  * \param data data to pass to the application
00257  * \param datad
00258  * \param registrar who registered the extension
00259  *
00260  * \retval 0 success 
00261  * \retval -1 failure
00262  */
00263 int ast_add_extension(const char *context, int replace, const char *extension, 
00264    int priority, const char *label, const char *callerid,
00265    const char *application, void *data, void (*datad)(void *), const char *registrar);
00266 
00267 /*! 
00268  * \brief Add an extension to an extension context, this time with an ast_context *.
00269  *
00270  * \note For details about the arguments, check ast_add_extension()
00271  */
00272 int ast_add_extension2(struct ast_context *con, int replace, const char *extension,
00273    int priority, const char *label, const char *callerid, 
00274    const char *application, void *data, void (*datad)(void *), const char *registrar);
00275 
00276 
00277 /*! 
00278  * \brief Register an application.
00279  *
00280  * \param app Short name of the application
00281  * \param execute a function callback to execute the application. It should return
00282  *                non-zero if the channel needs to be hung up.
00283  * \param synopsis a short description (one line synopsis) of the application
00284  * \param description long description with all of the details about the use of 
00285  *                    the application
00286  * 
00287  * This registers an application with Asterisk's internal application list. 
00288  * \note The individual applications themselves are responsible for registering and unregistering
00289  *       and unregistering their own CLI commands.
00290  * 
00291  * \retval 0 success 
00292  * \retval -1 failure.
00293  */
00294 int ast_register_application(const char *app, int (*execute)(struct ast_channel *, void *),
00295               const char *synopsis, const char *description);
00296 
00297 /*! 
00298  * \brief Unregister an application
00299  * 
00300  * \param app name of the application (does not have to be the same string as the one that was registered)
00301  * 
00302  * This unregisters an application from Asterisk's internal application list.
00303  * 
00304  * \retval 0 success 
00305  * \retval -1 failure
00306  */
00307 int ast_unregister_application(const char *app);
00308 
00309 /*! 
00310  * \brief Uses hint and devicestate callback to get the state of an extension
00311  *
00312  * \param c this is not important
00313  * \param context which context to look in
00314  * \param exten which extension to get state
00315  *
00316  * \return extension state as defined in the ast_extension_states enum
00317  */
00318 int ast_extension_state(struct ast_channel *c, const char *context, const char *exten);
00319 
00320 /*! 
00321  * \brief Return string representation of the state of an extension
00322  * 
00323  * \param extension_state is the numerical state delivered by ast_extension_state
00324  *
00325  * \return the state of an extension as string
00326  */
00327 const char *ast_extension_state2str(int extension_state);
00328 
00329 /*!
00330  * \brief Registers a state change callback
00331  * 
00332  * \param context which context to look in
00333  * \param exten which extension to get state
00334  * \param callback callback to call if state changed
00335  * \param data to pass to callback
00336  *
00337  * The callback is called if the state of an extension is changed.
00338  *
00339  * \retval -1 on failure
00340  * \retval ID on success
00341  */ 
00342 int ast_extension_state_add(const char *context, const char *exten, 
00343              ast_state_cb_type callback, void *data);
00344 
00345 /*! 
00346  * \brief Deletes a registered state change callback by ID
00347  * 
00348  * \param id of the callback to delete
00349  * \param callback callback
00350  *
00351  * Removes the callback from list of callbacks
00352  *
00353  * \retval 0 success 
00354  * \retval -1 failure
00355  */
00356 int ast_extension_state_del(int id, ast_state_cb_type callback);
00357 
00358 /*! 
00359  * \brief If an extension exists, return non-zero
00360  * 
00361  * \param hint buffer for hint
00362  * \param maxlen size of hint buffer
00363  * \param name buffer for name portion of hint
00364  * \param maxnamelen size of name buffer
00365  * \param c this is not important
00366  * \param context which context to look in
00367  * \param exten which extension to search for
00368  *
00369  * \return If an extension within the given context with the priority PRIORITY_HINT
00370  * is found a non zero value will be returned.
00371  * Otherwise, 0 is returned.
00372  */
00373 int ast_get_hint(char *hint, int maxlen, char *name, int maxnamelen, 
00374    struct ast_channel *c, const char *context, const char *exten);
00375 
00376 /*!
00377  * \brief Determine whether an extension exists
00378  *
00379  * \param c this is not important
00380  * \param context which context to look in
00381  * \param exten which extension to search for
00382  * \param priority priority of the action within the extension
00383  * \param callerid callerid to search for
00384  *
00385  * \return If an extension within the given context(or callerid) with the given priority 
00386  *         is found a non zero value will be returned. Otherwise, 0 is returned.
00387  */
00388 int ast_exists_extension(struct ast_channel *c, const char *context, const char *exten, 
00389    int priority, const char *callerid);
00390 
00391 /*! 
00392  * \brief Find the priority of an extension that has the specified label
00393  * 
00394  * \param c this is not important
00395  * \param context which context to look in
00396  * \param exten which extension to search for
00397  * \param label label of the action within the extension to match to priority
00398  * \param callerid callerid to search for
00399  *
00400  * \return the priority which matches the given label in the extension or -1 if not found.
00401  */
00402 int ast_findlabel_extension(struct ast_channel *c, const char *context, 
00403    const char *exten, const char *label, const char *callerid);
00404 
00405 /*!
00406  * \brief Find the priority of an extension that has the specified label
00407  *
00408  * \note This function is the same as ast_findlabel_extension, except that it accepts
00409  * a pointer to an ast_context structure to specify the context instead of the
00410  * name of the context. Otherwise, the functions behave the same.
00411  */
00412 int ast_findlabel_extension2(struct ast_channel *c, struct ast_context *con, 
00413    const char *exten, const char *label, const char *callerid);
00414 
00415 /*! 
00416  * \brief Looks for a valid matching extension
00417  * 
00418  * \param c not really important
00419  * \param context context to serach within
00420  * \param exten extension to check
00421  * \param priority priority of extension path
00422  * \param callerid callerid of extension being searched for
00423  *
00424  * \return If "exten" *could be* a valid extension in this context with or without
00425  * some more digits, return non-zero.  Basically, when this returns 0, no matter
00426  * what you add to exten, it's not going to be a valid extension anymore
00427  */
00428 int ast_canmatch_extension(struct ast_channel *c, const char *context, 
00429    const char *exten, int priority, const char *callerid);
00430 
00431 /*! 
00432  * \brief Looks to see if adding anything to this extension might match something. (exists ^ canmatch)
00433  *
00434  * \param c not really important XXX
00435  * \param context context to serach within
00436  * \param exten extension to check
00437  * \param priority priority of extension path
00438  * \param callerid callerid of extension being searched for
00439  *
00440  * \return If "exten" *could match* a valid extension in this context with
00441  * some more digits, return non-zero.  Does NOT return non-zero if this is
00442  * an exact-match only.  Basically, when this returns 0, no matter
00443  * what you add to exten, it's not going to be a valid extension anymore
00444  */
00445 int ast_matchmore_extension(struct ast_channel *c, const char *context, 
00446    const char *exten, int priority, const char *callerid);
00447 
00448 /*! 
00449  * \brief Determine if a given extension matches a given pattern (in NXX format)
00450  * 
00451  * \param pattern pattern to match
00452  * \param extension extension to check against the pattern.
00453  *
00454  * Checks whether or not the given extension matches the given pattern.
00455  *
00456  * \retval 1 on match
00457  * \retval 0 on failure
00458  */
00459 int ast_extension_match(const char *pattern, const char *extension);
00460 
00461 int ast_extension_close(const char *pattern, const char *data, int needmore);
00462 
00463 /*! 
00464  * \brief Launch a new extension (i.e. new stack)
00465  * 
00466  * \param c not important
00467  * \param context which context to generate the extension within
00468  * \param exten new extension to add
00469  * \param priority priority of new extension
00470  * \param callerid callerid of extension
00471  *
00472  * This adds a new extension to the asterisk extension list.
00473  *
00474  * \retval 0 on success 
00475  * \retval -1 on failure.
00476  */
00477 int ast_spawn_extension(struct ast_channel *c, const char *context, 
00478    const char *exten, int priority, const char *callerid);
00479 
00480 /*! 
00481  * \brief Add a context include
00482  *
00483  * \param context context to add include to
00484  * \param include new include to add
00485  * \param registrar who's registering it
00486  *
00487  * Adds an include taking a char * string as the context parameter
00488  *
00489  * \retval 0 on success 
00490  * \retval -1 on error
00491 */
00492 int ast_context_add_include(const char *context, const char *include, 
00493    const char *registrar);
00494 
00495 /*! 
00496  * \brief Add a context include
00497  * 
00498  * \param con context to add the include to
00499  * \param include include to add
00500  * \param registrar who registered the context
00501  *
00502  * Adds an include taking a struct ast_context as the first parameter
00503  *
00504  * \retval 0 on success 
00505  * \retval -1 on failure
00506  */
00507 int ast_context_add_include2(struct ast_context *con, const char *include, 
00508    const char *registrar);
00509 
00510 /*! 
00511  * \brief Remove a context include
00512  * 
00513  * \note See ast_context_add_include for information on arguments
00514  *
00515  * \retval 0 on success
00516  * \retval -1 on failure
00517  */
00518 int ast_context_remove_include(const char *context, const char *include, 
00519    const char *registrar);
00520 
00521 /*! 
00522  * \brief Removes an include by an ast_context structure 
00523  * 
00524  * \note See ast_context_add_include2 for information on arguments
00525  *
00526  * \retval 0 on success
00527  * \retval -1 on success
00528  */
00529 int ast_context_remove_include2(struct ast_context *con, const char *include, 
00530    const char *registrar);
00531 
00532 /*! 
00533  * \brief Verifies includes in an ast_contect structure
00534  * 
00535  * \param con context in which to verify the includes
00536  *
00537  * \retval 0 if no problems found 
00538  * \retval -1 if there were any missing context
00539  */
00540 int ast_context_verify_includes(struct ast_context *con);
00541      
00542 /*! 
00543  * \brief Add a switch
00544  * 
00545  * \param context context to which to add the switch
00546  * \param sw switch to add
00547  * \param data data to pass to switch
00548  * \param eval whether to evaluate variables when running switch
00549  * \param registrar whoever registered the switch
00550  *
00551  * This function registers a switch with the asterisk switch architecture
00552  *
00553  * \retval 0 on success 
00554  * \retval -1 on failure
00555  */
00556 int ast_context_add_switch(const char *context, const char *sw, const char *data, 
00557    int eval, const char *registrar);
00558 
00559 /*! 
00560  * \brief Adds a switch (first param is a ast_context)
00561  * 
00562  * \note See ast_context_add_switch() for argument information, with the exception of
00563  *       the first argument. In this case, it's a pointer to an ast_context structure
00564  *       as opposed to the name.
00565  */
00566 int ast_context_add_switch2(struct ast_context *con, const char *sw, const char *data, 
00567    int eval, const char *registrar);
00568 
00569 /*! 
00570  * \brief Remove a switch
00571  * 
00572  * Removes a switch with the given parameters
00573  *
00574  * \retval 0 on success 
00575  * \retval -1 on failure
00576  */
00577 int ast_context_remove_switch(const char *context, const char *sw, 
00578    const char *data, const char *registrar);
00579 
00580 int ast_context_remove_switch2(struct ast_context *con, const char *sw, 
00581    const char *data, const char *registrar);
00582 
00583 /*! 
00584  * \brief Simply remove extension from context
00585  * 
00586  * \param context context to remove extension from
00587  * \param extension which extension to remove
00588  * \param priority priority of extension to remove
00589  * \param registrar registrar of the extension
00590  *
00591  * This function removes an extension from a given context.
00592  *
00593  * \retval 0 on success 
00594  * \retval -1 on failure
00595  */
00596 int ast_context_remove_extension(const char *context, const char *extension, int priority,
00597    const char *registrar);
00598 
00599 int ast_context_remove_extension2(struct ast_context *con, const char *extension,
00600    int priority, const char *registrar);
00601 
00602 /*! 
00603  * \brief Add an ignorepat
00604  * 
00605  * \param context which context to add the ignorpattern to
00606  * \param ignorepat ignorepattern to set up for the extension
00607  * \param registrar registrar of the ignore pattern
00608  *
00609  * Adds an ignore pattern to a particular context.
00610  *
00611  * \retval 0 on success 
00612  * \retval -1 on failure
00613  */
00614 int ast_context_add_ignorepat(const char *context, const char *ignorepat, const char *registrar);
00615 
00616 int ast_context_add_ignorepat2(struct ast_context *con, const char *ignorepat, const char *registrar);
00617 
00618 /* 
00619  * \brief Remove an ignorepat
00620  * 
00621  * \param context context from which to remove the pattern
00622  * \param ignorepat the pattern to remove
00623  * \param registrar the registrar of the ignore pattern
00624  *
00625  * This removes the given ignorepattern
00626  *
00627  * \retval 0 on success 
00628  * \retval -1 on failure
00629  */
00630 int ast_context_remove_ignorepat(const char *context, const char *ignorepat, const char *registrar);
00631 
00632 int ast_context_remove_ignorepat2(struct ast_context *con, const char *ignorepat, const char *registrar);
00633 
00634 /*! 
00635  * \brief Checks to see if a number should be ignored
00636  * 
00637  * \param context context to search within
00638  * \param pattern to check whether it should be ignored or not
00639  *
00640  * Check if a number should be ignored with respect to dialtone cancellation.
00641  *
00642  * \retval 0 if the pattern should not be ignored 
00643  * \retval non-zero if the pattern should be ignored 
00644  */
00645 int ast_ignore_pattern(const char *context, const char *pattern);
00646 
00647 /* Locking functions for outer modules, especially for completion functions */
00648 
00649 /*! 
00650  * \brief Locks the context list
00651  *
00652  * \retval 0 on success 
00653  * \retval -1 on error
00654  */
00655 int ast_lock_contexts(void); /* equivalent to wrlock */
00656 int ast_rdlock_contexts(void);
00657 int ast_wrlock_contexts(void);
00658 
00659 /*! 
00660  * \brief Unlocks contexts
00661  * 
00662  * \retval 0 on success 
00663  * \retval -1 on failure
00664  */
00665 int ast_unlock_contexts(void);
00666 
00667 /*! 
00668  * \brief Locks a given context
00669  * 
00670  * \param con context to lock
00671  *
00672  * \retval 0 on success 
00673  * \retval -1 on failure
00674  */
00675 int ast_lock_context(struct ast_context *con);
00676 
00677 /*! 
00678  * \retval Unlocks the given context
00679  * 
00680  * \param con context to unlock
00681  *
00682  * \retval 0 on success 
00683  * \retval -1 on failure
00684  */
00685 int ast_unlock_context(struct ast_context *con);
00686 
00687 /*! 
00688  * \brief locks the macrolock in the given given context
00689  *
00690  * \param macrocontext name of the macro-context to lock
00691  *
00692  * Locks the given macro-context to ensure only one thread (call) can execute it at a time
00693  *
00694  * \retval 0 on success
00695  * \retval -1 on failure
00696  */
00697 int ast_context_lockmacro(const char *macrocontext);
00698 
00699 /*!
00700  * \brief Unlocks the macrolock in the given context
00701  *
00702  * \param macrocontext name of the macro-context to unlock
00703  *
00704  * Unlocks the given macro-context so that another thread (call) can execute it
00705  *
00706  * \retval 0 on success
00707  * \retval -1 on failure
00708  */
00709 int ast_context_unlockmacro(const char *macrocontext);
00710 
00711 int ast_async_goto(struct ast_channel *chan, const char *context, const char *exten, int priority);
00712 
00713 int ast_async_goto_by_name(const char *chan, const char *context, const char *exten, int priority);
00714 
00715 /*! Synchronously or asynchronously make an outbound call and send it to a
00716    particular extension */
00717 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);
00718 
00719 /*! Synchronously or asynchronously make an outbound call and send it to a
00720    particular extension (extended version with callinpres and uniqueid) */
00721 int ast_pbx_outgoing_exten_uniqueid(const char *type, int format, void *data, int timeout, const char *context, const char *exten, int priority, int *reason, int sync, int callingpres, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel, char *uniqueid);
00722 
00723 /*! Synchronously or asynchronously make an outbound call and send it to a
00724    particular application with given extension */
00725 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);
00726 
00727 /*! Synchronously or asynchronously make an outbound call and send it to a
00728    particular application with given extension (extended version with callinpres and uniqueid) */
00729 int ast_pbx_outgoing_app_uniqueid(const char *type, int format, void *data, int timeout, const char *app, const char *appdata, int *reason, int sync, int callingpres, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel, char *uniqueid);
00730 
00731 /*!
00732  * \brief Evaluate a condition
00733  *
00734  * \retval 0 if the condition is NULL or of zero length
00735  * \retval int If the string is an integer, the integer representation of
00736  *             the integer is returned
00737  * \retval 1 Any other non-empty string
00738  */
00739 int pbx_checkcondition(const char *condition);
00740 
00741 /* Functions for returning values from structures */
00742 const char *ast_get_context_name(struct ast_context *con);
00743 const char *ast_get_extension_name(struct ast_exten *exten);
00744 struct ast_context *ast_get_extension_context(struct ast_exten *exten);
00745 const char *ast_get_include_name(struct ast_include *include);
00746 const char *ast_get_ignorepat_name(struct ast_ignorepat *ip);
00747 const char *ast_get_switch_name(struct ast_sw *sw);
00748 const char *ast_get_switch_data(struct ast_sw *sw);
00749 
00750 /* Other extension stuff */
00751 int ast_get_extension_priority(struct ast_exten *exten);
00752 int ast_get_extension_matchcid(struct ast_exten *e);
00753 const char *ast_get_extension_cidmatch(struct ast_exten *e);
00754 const char *ast_get_extension_app(struct ast_exten *e);
00755 const char *ast_get_extension_label(struct ast_exten *e);
00756 void *ast_get_extension_app_data(struct ast_exten *e);
00757 
00758 /* Registrar info functions ... */
00759 const char *ast_get_context_registrar(struct ast_context *c);
00760 const char *ast_get_extension_registrar(struct ast_exten *e);
00761 const char *ast_get_include_registrar(struct ast_include *i);
00762 const char *ast_get_ignorepat_registrar(struct ast_ignorepat *ip);
00763 const char *ast_get_switch_registrar(struct ast_sw *sw);
00764 
00765 /* Walking functions ... */
00766 struct ast_context *ast_walk_contexts(struct ast_context *con);
00767 struct ast_exten *ast_walk_context_extensions(struct ast_context *con,
00768    struct ast_exten *priority);
00769 struct ast_exten *ast_walk_extension_priorities(struct ast_exten *exten,
00770    struct ast_exten *priority);
00771 struct ast_include *ast_walk_context_includes(struct ast_context *con,
00772    struct ast_include *inc);
00773 struct ast_ignorepat *ast_walk_context_ignorepats(struct ast_context *con,
00774    struct ast_ignorepat *ip);
00775 struct ast_sw *ast_walk_context_switches(struct ast_context *con, struct ast_sw *sw);
00776 
00777 /*!
00778  * \note Will lock the channel.
00779  */
00780 int pbx_builtin_serialize_variables(struct ast_channel *chan, char *buf, size_t size);
00781 
00782 /*!
00783  * \note Will lock the channel.
00784  */
00785 const char *pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name);
00786 
00787 /*!
00788  * \note Will lock the channel.
00789  */
00790 void pbx_builtin_pushvar_helper(struct ast_channel *chan, const char *name, const char *value);
00791 
00792 /*!
00793  * \note Will lock the channel.
00794  */
00795 void pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value);
00796 
00797 /*!
00798  * \note Will lock the channel.
00799  */
00800 void pbx_retrieve_variable(struct ast_channel *c, const char *var, char **ret, char *workspace, int workspacelen, struct varshead *headp);
00801 void pbx_builtin_clear_globals(void);
00802 
00803 /*!
00804  * \note Will lock the channel.
00805  */
00806 int pbx_builtin_setvar(struct ast_channel *chan, void *data);
00807 
00808 void pbx_substitute_variables_helper(struct ast_channel *c,const char *cp1,char *cp2,int count);
00809 void pbx_substitute_variables_varshead(struct varshead *headp, const char *cp1, char *cp2, int count);
00810 
00811 int ast_extension_patmatch(const char *pattern, const char *data);
00812 
00813 /*! Set "autofallthrough" flag, if newval is <0, does not acutally set.  If
00814   set to 1, sets to auto fall through.  If newval set to 0, sets to no auto
00815   fall through (reads extension instead).  Returns previous value. */
00816 int pbx_set_autofallthrough(int newval);
00817 
00818 /*!
00819  * \note This function will handle locking the channel as needed.
00820  */
00821 int ast_goto_if_exists(struct ast_channel *chan, const char *context, const char *exten, int priority);
00822 
00823 /*!
00824  * \note I can find neither parsable nor parseable at dictionary.com, 
00825  *       but google gives me 169000 hits for parseable and only 49,800 
00826  *       for parsable 
00827  *
00828  * \note This function will handle locking the channel as needed.
00829  */
00830 int ast_parseable_goto(struct ast_channel *chan, const char *goto_string);
00831 
00832 /*!
00833  * \note This function will handle locking the channel as needed.
00834  */
00835 int ast_explicit_goto(struct ast_channel *chan, const char *context, const char *exten, int priority);
00836 
00837 /*!
00838  * \note This function will handle locking the channel as needed.
00839  */
00840 int ast_async_goto_if_exists(struct ast_channel *chan, const char *context, const char *exten, int priority);
00841 
00842 struct ast_custom_function* ast_custom_function_find(const char *name);
00843 
00844 /*!
00845  * \brief Unregister a custom function
00846  */
00847 int ast_custom_function_unregister(struct ast_custom_function *acf);
00848 
00849 /*!
00850  * \brief Reigster a custom function
00851  */
00852 int ast_custom_function_register(struct ast_custom_function *acf);
00853 
00854 /*! 
00855  * \brief Retrieve the number of active calls
00856  */
00857 int ast_active_calls(void);
00858    
00859 /*!
00860  * \brief executes a read operation on a function 
00861  *
00862  * \param chan Channel to execute on
00863  * \param function Data containing the function call string (will be modified)
00864  * \param workspace A pointer to safe memory to use for a return value 
00865  * \param len the number of bytes in workspace
00866  *
00867  * This application executes a function in read mode on a given channel.
00868  *
00869  * \return zero on success, non-zero on failure
00870  */
00871 int ast_func_read(struct ast_channel *chan, char *function, char *workspace, size_t len);
00872 
00873 /*!
00874  * \brief executes a write operation on a function
00875  *
00876  * \param chan Channel to execute on
00877  * \param function Data containing the function call string (will be modified)
00878  * \param value A value parameter to pass for writing
00879  *
00880  * This application executes a function in write mode on a given channel.
00881  *
00882  * \return zero on success, non-zero on failure
00883  */
00884 int ast_func_write(struct ast_channel *chan, char *function, const char *value);
00885 
00886 void ast_hint_state_changed(const char *device, char *cid_num, char *cid_name);
00887 
00888 #if defined(__cplusplus) || defined(c_plusplus)
00889 }
00890 #endif
00891 
00892 #endif /* _ASTERISK_PBX_H */

Generated on Mon Jul 14 17:24:59 2008 for Asterisk - the Open Source PBX by  doxygen 1.5.1