mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-02 19:16:15 +00:00
build function modules independently (no more pbx_functions.so)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@9469 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -28,26 +28,26 @@
|
||||
|
||||
#include "asterisk.h"
|
||||
|
||||
/* ASTERISK_FILE_VERSION(__FILE__, "$Revision$") */
|
||||
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
||||
|
||||
#include "asterisk/module.h"
|
||||
#include "asterisk/channel.h"
|
||||
#include "asterisk/pbx.h"
|
||||
#include "asterisk/logger.h"
|
||||
#include "asterisk/utils.h"
|
||||
#include "asterisk/app.h"
|
||||
#include "asterisk/config.h" /* for ast_true */
|
||||
|
||||
static char *builtin_function_isnull(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
|
||||
static char *isnull(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
|
||||
{
|
||||
return data && *data ? "0" : "1";
|
||||
}
|
||||
|
||||
static char *builtin_function_exists(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
|
||||
static char *exists(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
|
||||
{
|
||||
return data && *data ? "1" : "0";
|
||||
}
|
||||
|
||||
static char *builtin_function_iftime(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
|
||||
static char *iftime(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
|
||||
{
|
||||
struct ast_timing timing;
|
||||
char *ret;
|
||||
@@ -86,7 +86,7 @@ static char *builtin_function_iftime(struct ast_channel *chan, char *cmd, char *
|
||||
return ret;
|
||||
}
|
||||
|
||||
static char *builtin_function_if(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
|
||||
static char *acf_if(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
|
||||
{
|
||||
char *ret;
|
||||
char *expr;
|
||||
@@ -120,7 +120,7 @@ static char *builtin_function_if(struct ast_channel *chan, char *cmd, char *data
|
||||
return ret;
|
||||
}
|
||||
|
||||
static char *builtin_function_set(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
|
||||
static char *set(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
|
||||
{
|
||||
char *varname;
|
||||
char *val;
|
||||
@@ -144,53 +144,80 @@ static char *builtin_function_set(struct ast_channel *chan, char *cmd, char *dat
|
||||
return buf;
|
||||
}
|
||||
|
||||
#ifndef BUILTIN_FUNC
|
||||
static
|
||||
#endif
|
||||
struct ast_custom_function isnull_function = {
|
||||
static struct ast_custom_function isnull_function = {
|
||||
.name = "ISNULL",
|
||||
.synopsis = "NULL Test: Returns 1 if NULL or 0 otherwise",
|
||||
.syntax = "ISNULL(<data>)",
|
||||
.read = builtin_function_isnull,
|
||||
.read = isnull,
|
||||
};
|
||||
|
||||
#ifndef BUILTIN_FUNC
|
||||
static
|
||||
#endif
|
||||
struct ast_custom_function set_function = {
|
||||
static struct ast_custom_function set_function = {
|
||||
.name = "SET",
|
||||
.synopsis = "SET assigns a value to a channel variable",
|
||||
.syntax = "SET(<varname>=[<value>])",
|
||||
.read = builtin_function_set,
|
||||
.read = set,
|
||||
};
|
||||
|
||||
#ifndef BUILTIN_FUNC
|
||||
static
|
||||
#endif
|
||||
struct ast_custom_function exists_function = {
|
||||
static struct ast_custom_function exists_function = {
|
||||
.name = "EXISTS",
|
||||
.synopsis = "Existence Test: Returns 1 if exists, 0 otherwise",
|
||||
.syntax = "EXISTS(<data>)",
|
||||
.read = builtin_function_exists,
|
||||
.read = exists,
|
||||
};
|
||||
|
||||
#ifndef BUILTIN_FUNC
|
||||
static
|
||||
#endif
|
||||
struct ast_custom_function if_function = {
|
||||
static struct ast_custom_function if_function = {
|
||||
.name = "IF",
|
||||
.synopsis = "Conditional: Returns the data following '?' if true else the data following ':'",
|
||||
.syntax = "IF(<expr>?[<true>][:<false>])",
|
||||
.read = builtin_function_if,
|
||||
.read = acf_if,
|
||||
};
|
||||
|
||||
|
||||
#ifndef BUILTIN_FUNC
|
||||
static
|
||||
#endif
|
||||
struct ast_custom_function if_time_function = {
|
||||
static struct ast_custom_function if_time_function = {
|
||||
.name = "IFTIME",
|
||||
.synopsis = "Temporal Conditional: Returns the data following '?' if true else the data following ':'",
|
||||
.syntax = "IFTIME(<timespec>?[<true>][:<false>])",
|
||||
.read = builtin_function_iftime,
|
||||
.read = iftime,
|
||||
};
|
||||
|
||||
static char *tdesc = "Logical dialplan functions";
|
||||
|
||||
int unload_module(void)
|
||||
{
|
||||
int res = 0;
|
||||
|
||||
res |= ast_custom_function_unregister(&isnull_function);
|
||||
res |= ast_custom_function_unregister(&set_function);
|
||||
res |= ast_custom_function_unregister(&exists_function);
|
||||
res |= ast_custom_function_unregister(&if_function);
|
||||
res |= ast_custom_function_unregister(&if_time_function);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
int load_module(void)
|
||||
{
|
||||
int res = 0;
|
||||
|
||||
res |= ast_custom_function_register(&isnull_function);
|
||||
res |= ast_custom_function_register(&set_function);
|
||||
res |= ast_custom_function_register(&exists_function);
|
||||
res |= ast_custom_function_register(&if_function);
|
||||
res |= ast_custom_function_register(&if_time_function);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
char *description(void)
|
||||
{
|
||||
return tdesc;
|
||||
}
|
||||
|
||||
int usecount(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *key()
|
||||
{
|
||||
return ASTERISK_GPL_KEY;
|
||||
}
|
||||
|
Reference in New Issue
Block a user