diff options
author | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-02-11 03:14:05 +0000 |
---|---|---|
committer | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-02-11 03:14:05 +0000 |
commit | 5f90b9bebddfa06f9d08b63e9c48830071480f38 (patch) | |
tree | 47f92d29e3216d69801be7bdb5d15fef7aab9a4d /funcs/func_logic.c | |
parent | 7acc893dad48c008eaced05bfbedb0d17735bc47 (diff) |
build function modules independently (no more pbx_functions.so)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@9469 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'funcs/func_logic.c')
-rw-r--r-- | funcs/func_logic.c | 93 |
1 files changed, 60 insertions, 33 deletions
diff --git a/funcs/func_logic.c b/funcs/func_logic.c index 642a4d45c..b3c7eb2b5 100644 --- a/funcs/func_logic.c +++ b/funcs/func_logic.c @@ -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; +} |