1999-10-27 00:56:38 +00:00
|
|
|
/*
|
|
|
|
|
* Asterisk -- A telephony toolkit for Linux.
|
|
|
|
|
*
|
|
|
|
|
* Core PBX routines and definitions.
|
|
|
|
|
*
|
1999-12-11 20:09:45 +00:00
|
|
|
* Copyright (C) 1999, Mark Spencer
|
1999-10-27 00:56:38 +00:00
|
|
|
*
|
|
|
|
|
* Mark Spencer <markster@linux-support.net>
|
|
|
|
|
*
|
|
|
|
|
* This program is free software, distributed under the terms of
|
|
|
|
|
* the GNU General Public License
|
|
|
|
|
*/
|
|
|
|
|
#ifndef _ASTERISK_PBX_H
|
|
|
|
|
#define _ASTERISK_PBX_H
|
|
|
|
|
|
|
|
|
|
#include <asterisk/sched.h>
|
|
|
|
|
#include <asterisk/channel.h>
|
|
|
|
|
|
|
|
|
|
#if defined(__cplusplus) || defined(c_plusplus)
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#define AST_PBX_KEEP 0
|
|
|
|
|
#define AST_PBX_REPLACE 1
|
|
|
|
|
|
|
|
|
|
/* Max length of an application */
|
|
|
|
|
#define AST_MAX_APP 32
|
|
|
|
|
|
2000-01-23 01:06:34 +00:00
|
|
|
/* Special return values from applications to the PBX */
|
|
|
|
|
#define AST_PBX_KEEPALIVE 10 /* Destroy the thread, but don't hang up the channel */
|
|
|
|
|
|
1999-10-27 00:56:38 +00:00
|
|
|
struct ast_context;
|
|
|
|
|
|
|
|
|
|
/* Register a new context */
|
2001-04-17 16:49:37 +00:00
|
|
|
struct ast_context *ast_context_create(char *name, char *registrar);
|
1999-10-27 00:56:38 +00:00
|
|
|
|
2001-04-17 16:49:37 +00:00
|
|
|
/* Destroy a context (matches the specified context (or ANY context if
|
|
|
|
|
NULL) */
|
|
|
|
|
void ast_context_destroy(struct ast_context *, char *registrar);
|
1999-10-27 00:56:38 +00:00
|
|
|
|
|
|
|
|
/* Find a context */
|
|
|
|
|
struct ast_context *ast_context_find(char *name);
|
|
|
|
|
|
|
|
|
|
/* Create a new thread and start the PBX (or whatever) */
|
|
|
|
|
int ast_pbx_start(struct ast_channel *c);
|
|
|
|
|
|
2001-03-30 16:31:28 +00:00
|
|
|
/* Execute the PBX in the current thread */
|
|
|
|
|
int ast_pbx_run(struct ast_channel *c);
|
1999-10-27 00:56:38 +00:00
|
|
|
|
|
|
|
|
/* Add an extension to an extension context, this time with an ast_context * */
|
|
|
|
|
int ast_add_extension2(struct ast_context *con,
|
|
|
|
|
int replace, char *extension, int priority,
|
2001-04-17 16:49:37 +00:00
|
|
|
char *application, void *data, void (*datad)(void *),
|
|
|
|
|
char *registrar);
|
1999-10-27 00:56:38 +00:00
|
|
|
|
2001-04-17 16:49:37 +00:00
|
|
|
/* Add an application. The function 'execute' should return non-zero if the line needs to be hung up.
|
|
|
|
|
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
|
|
|
|
|
will return 0 or -1. */
|
|
|
|
|
int ast_register_application(char *app, int (*execute)(struct ast_channel *, void *),
|
|
|
|
|
char *synopsis, char *description);
|
1999-10-27 00:56:38 +00:00
|
|
|
|
|
|
|
|
/* Remove an application */
|
|
|
|
|
int ast_unregister_application(char *app);
|
|
|
|
|
|
|
|
|
|
/* If an extension exists, return non-zero */
|
|
|
|
|
int ast_exists_extension(struct ast_channel *c, char *context, char *exten, int priority);
|
|
|
|
|
|
1999-12-25 22:31:01 +00:00
|
|
|
/* If "exten" *could be* a valid extension in this context with or without
|
|
|
|
|
some more digits, return non-zero. Basically, when this returns 0, no matter
|
|
|
|
|
what you add to exten, it's not going to be a valid extension anymore */
|
|
|
|
|
int ast_canmatch_extension(struct ast_channel *c, char *context, char *exten, int priority);
|
|
|
|
|
|
2001-04-17 16:49:37 +00:00
|
|
|
/* Determine if a given extension matches a given pattern (in NXX format) */
|
|
|
|
|
int ast_extension_match(char *pattern, char *extension);
|
|
|
|
|
|
1999-10-27 00:56:38 +00:00
|
|
|
/* Launch a new extension (i.e. new stack) */
|
|
|
|
|
int ast_spawn_extension(struct ast_channel *c, char *context, char *exten, int priority);
|
|
|
|
|
|
|
|
|
|
/* Execute an extension. If it's not available, do whatever you should do for
|
|
|
|
|
default extensions and halt the thread if necessary. This function does not
|
|
|
|
|
return, except on error. */
|
|
|
|
|
int ast_exec_extension(struct ast_channel *c, char *context, char *exten, int priority);
|
|
|
|
|
/* Longest extension */
|
|
|
|
|
int ast_pbx_longest_extension(char *context);
|
|
|
|
|
|
2001-03-30 16:31:28 +00:00
|
|
|
/* Add an include */
|
2001-04-17 16:49:37 +00:00
|
|
|
int ast_context_add_include(char *context, char *include, char *registrar);
|
|
|
|
|
int ast_context_add_include2(struct ast_context *con, char *include, char *registrar);
|
2001-03-30 16:31:28 +00:00
|
|
|
|
|
|
|
|
/* Remove an include */
|
2001-04-17 16:49:37 +00:00
|
|
|
int ast_context_remove_include(char *context, char *include, char *registrar);
|
|
|
|
|
int ast_context_remove_include2(struct ast_context *con, char *include, char *registrar);
|
2001-03-30 16:31:28 +00:00
|
|
|
|
1999-10-27 00:56:38 +00:00
|
|
|
#if defined(__cplusplus) || defined(c_plusplus)
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|