mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-19 11:42:27 +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:
@@ -35,6 +35,11 @@ Functions:
|
|||||||
* The function ${CHECK_MD5()} has been deprecated in favor of using an
|
* The function ${CHECK_MD5()} has been deprecated in favor of using an
|
||||||
expression: $[${MD5(<string>)} = ${saved_md5}].
|
expression: $[${MD5(<string>)} = ${saved_md5}].
|
||||||
|
|
||||||
|
* The 'builtin' functions that used to be combined in pbx_functions.so are
|
||||||
|
now built as separate modules. If you are not using 'autoload=yes' in your
|
||||||
|
modules.conf file then you will need to explicitly load the modules that
|
||||||
|
contain the functions you want to use.
|
||||||
|
|
||||||
The SIP channel:
|
The SIP channel:
|
||||||
|
|
||||||
* The "incominglimit" setting is replaced by the "call-limit" setting in sip.conf.
|
* The "incominglimit" setting is replaced by the "call-limit" setting in sip.conf.
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
#
|
#
|
||||||
# Makefile for dialplan functions
|
# Makefile for dialplan functions
|
||||||
#
|
#
|
||||||
# Copyright (C) 2005, Digium
|
# Copyright (C) 2005 - 2006, Digium
|
||||||
#
|
#
|
||||||
# Kevin P. Fleming <kpfleming@digium.com>
|
# Kevin P. Fleming <kpfleming@digium.com>
|
||||||
#
|
#
|
||||||
@@ -11,23 +11,7 @@
|
|||||||
# the GNU General Public License
|
# the GNU General Public License
|
||||||
#
|
#
|
||||||
|
|
||||||
FUNCS=pbx_functions.so
|
AVAILABLE_FUNCS=$(patsubst %.c,%.o,$(wildcard func*.c))
|
||||||
|
|
||||||
BUILTINS=func_md5.o \
|
|
||||||
func_math.o \
|
|
||||||
func_groupcount.o \
|
|
||||||
func_strings.o \
|
|
||||||
func_cdr.o \
|
|
||||||
func_logic.o \
|
|
||||||
func_env.o \
|
|
||||||
func_db.o \
|
|
||||||
func_timeout.o \
|
|
||||||
func_language.o \
|
|
||||||
func_moh.o \
|
|
||||||
func_base64.o \
|
|
||||||
func_sha1.o
|
|
||||||
|
|
||||||
AVAILABLE_FUNCS=$(filter-out $(BUILTINS),$(patsubst %.c,%.o,$(wildcard func*.c)))
|
|
||||||
|
|
||||||
ifeq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/odbcinst.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/odbcinst.h),)
|
ifeq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/odbcinst.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/odbcinst.h),)
|
||||||
STANDALONE_FUNCS=$(filter-out func_odbc.o,$(AVAILABLE_FUNCS))
|
STANDALONE_FUNCS=$(filter-out func_odbc.o,$(AVAILABLE_FUNCS))
|
||||||
@@ -35,11 +19,7 @@ else
|
|||||||
STANDALONE_FUNCS=$(AVAILABLE_FUNCS)
|
STANDALONE_FUNCS=$(AVAILABLE_FUNCS)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
FUNCS+=$(STANDALONE_FUNCS:.o=.so)
|
FUNCS=$(STANDALONE_FUNCS:.o=.so)
|
||||||
|
|
||||||
FUNC_SOURCES=$(BUILTINS:.o=.c)
|
|
||||||
|
|
||||||
FUNC_STRUCTS=$(shell grep 'struct ast_custom_function' $(FUNC_SOURCES) | awk '{print $$3};' | sort)
|
|
||||||
|
|
||||||
ifeq (${OSARCH},CYGWIN)
|
ifeq (${OSARCH},CYGWIN)
|
||||||
CYGSOLINK=-Wl,--out-implib=lib$@.a -Wl,--export-all-symbols
|
CYGSOLINK=-Wl,--out-implib=lib$@.a -Wl,--export-all-symbols
|
||||||
@@ -56,20 +36,6 @@ clean:
|
|||||||
%.so : %.o
|
%.so : %.o
|
||||||
$(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB}
|
$(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB}
|
||||||
|
|
||||||
#$(BUILTINS) : CFLAGS += -DBUILTIN_FUNC
|
|
||||||
|
|
||||||
pbx_functions.h: $(FUNC_SOURCES)
|
|
||||||
@echo "/* Automatically generated - do not edit */" > $@
|
|
||||||
@for f in $(FUNC_SOURCES); do echo "#include \"$$f\"" >> $@; done
|
|
||||||
@echo "static struct ast_custom_function *builtins[] = {" >> $@
|
|
||||||
@for f in $(FUNC_STRUCTS); do echo "&$$f," >> $@; done
|
|
||||||
@echo "};" >> $@
|
|
||||||
|
|
||||||
pbx_functions.o: pbx_functions.h
|
|
||||||
|
|
||||||
pbx_functions.so: pbx_functions.o #$(BUILTINS)
|
|
||||||
$(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB}
|
|
||||||
|
|
||||||
func_odbc.so: func_odbc.o
|
func_odbc.so: func_odbc.o
|
||||||
$(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} -lodbc
|
$(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} -lodbc
|
||||||
|
|
||||||
|
@@ -1,85 +1,117 @@
|
|||||||
/*
|
/*
|
||||||
* Asterisk -- An open source telephony toolkit.
|
* Asterisk -- An open source telephony toolkit.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2005, Digium, Inc.
|
* Copyright (C) 2005 - 2006, Digium, Inc.
|
||||||
* Copyright (C) 2005, Claude Patry
|
* Copyright (C) 2005, Claude Patry
|
||||||
*
|
*
|
||||||
* See http://www.asterisk.org for more information about
|
* See http://www.asterisk.org for more information about
|
||||||
* the Asterisk project. Please do not directly contact
|
* the Asterisk project. Please do not directly contact
|
||||||
* any of the maintainers of this project for assistance;
|
* any of the maintainers of this project for assistance;
|
||||||
* the project provides a web site, mailing lists and IRC
|
* the project provides a web site, mailing lists and IRC
|
||||||
* channels for your use.
|
* channels for your use.
|
||||||
*
|
*
|
||||||
* This program is free software, distributed under the terms of
|
* This program is free software, distributed under the terms of
|
||||||
* the GNU General Public License Version 2. See the LICENSE file
|
* the GNU General Public License Version 2. See the LICENSE file
|
||||||
* at the top of the source tree.
|
* at the top of the source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*! \file
|
/*! \file
|
||||||
*
|
*
|
||||||
* \brief Use the base64 as functions
|
* \brief Use the base64 as functions
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include "asterisk.h"
|
#include "asterisk.h"
|
||||||
|
|
||||||
/* ASTERISK_FILE_VERSION(__FILE__, "Revision: 7221 ") */
|
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
||||||
|
|
||||||
#include "asterisk/channel.h"
|
#include "asterisk/module.h"
|
||||||
#include "asterisk/pbx.h"
|
#include "asterisk/channel.h"
|
||||||
#include "asterisk/logger.h"
|
#include "asterisk/pbx.h"
|
||||||
#include "asterisk/utils.h"
|
#include "asterisk/logger.h"
|
||||||
#include "asterisk/app.h"
|
#include "asterisk/utils.h"
|
||||||
|
#include "asterisk/app.h"
|
||||||
static char *builtin_function_base64_encode(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
|
|
||||||
{
|
static char *base64_encode(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
|
||||||
int res = 0;
|
{
|
||||||
|
int res = 0;
|
||||||
if (ast_strlen_zero(data) ) {
|
|
||||||
ast_log(LOG_WARNING, "Syntax: BASE64_ENCODE(<data>) - missing argument!\n");
|
if (ast_strlen_zero(data) ) {
|
||||||
return NULL;
|
ast_log(LOG_WARNING, "Syntax: BASE64_ENCODE(<data>) - missing argument!\n");
|
||||||
}
|
return NULL;
|
||||||
|
}
|
||||||
ast_log(LOG_DEBUG, "data=%s\n",data);
|
|
||||||
res = ast_base64encode(buf, data, strlen(data), len);
|
ast_log(LOG_DEBUG, "data=%s\n",data);
|
||||||
ast_log(LOG_DEBUG, "res=%d\n", res);
|
res = ast_base64encode(buf, data, strlen(data), len);
|
||||||
return buf;
|
ast_log(LOG_DEBUG, "res=%d\n", res);
|
||||||
}
|
return buf;
|
||||||
|
}
|
||||||
static char *builtin_function_base64_decode(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
|
|
||||||
{
|
static char *base64_decode(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
|
||||||
if (ast_strlen_zero(data) ) {
|
{
|
||||||
ast_log(LOG_WARNING, "Syntax: BASE64_DECODE(<base_64 string>) - missing argument!\n");
|
if (ast_strlen_zero(data) ) {
|
||||||
return NULL;
|
ast_log(LOG_WARNING, "Syntax: BASE64_DECODE(<base_64 string>) - missing argument!\n");
|
||||||
}
|
return NULL;
|
||||||
|
}
|
||||||
ast_log(LOG_DEBUG, "data=%s\n", data);
|
|
||||||
ast_base64decode(buf, data, len);
|
ast_log(LOG_DEBUG, "data=%s\n", data);
|
||||||
return buf;
|
ast_base64decode(buf, data, len);
|
||||||
}
|
return buf;
|
||||||
|
}
|
||||||
#ifndef BUILTIN_FUNC
|
|
||||||
static
|
static struct ast_custom_function base64_encode_function = {
|
||||||
#endif
|
.name = "BASE64_ENCODE",
|
||||||
struct ast_custom_function base64_encode_function = {
|
.synopsis = "Encode a string in base64",
|
||||||
.name = "BASE64_ENCODE",
|
.desc = "Returns the base64 string\n",
|
||||||
.synopsis = "Encode a string in base64",
|
.syntax = "BASE64_ENCODE(<string>)",
|
||||||
.desc = "Returns the base64 string\n",
|
.read = base64_encode,
|
||||||
.syntax = "BASE64_ENCODE(<string>)",
|
};
|
||||||
.read = builtin_function_base64_encode,
|
|
||||||
};
|
static struct ast_custom_function base64_decode_function = {
|
||||||
|
.name = "BASE64_DECODE",
|
||||||
#ifndef BUILTIN_FUNC
|
.synopsis = "Decode a base64 string",
|
||||||
static
|
.desc = "Returns the plain text string\n",
|
||||||
#endif
|
.syntax = "BASE64_DECODE(<base64_string>)",
|
||||||
struct ast_custom_function base64_decode_function = {
|
.read = base64_decode,
|
||||||
.name = "BASE64_DECODE",
|
};
|
||||||
.synopsis = "Decode a base64 string",
|
|
||||||
.desc = "Returns the plain text string\n",
|
static char *tdesc = "base64 encode/decode dialplan functions";
|
||||||
.syntax = "BASE64_DECODE(<base64_string>)",
|
|
||||||
.read = builtin_function_base64_decode,
|
int unload_module(void)
|
||||||
};
|
{
|
||||||
|
return ast_custom_function_unregister(&base64_encode_function) ||
|
||||||
|
ast_custom_function_unregister(&base64_decode_function);
|
||||||
|
}
|
||||||
|
|
||||||
|
int load_module(void)
|
||||||
|
{
|
||||||
|
return ast_custom_function_register(&base64_encode_function) ||
|
||||||
|
ast_custom_function_register(&base64_decode_function);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *description(void)
|
||||||
|
{
|
||||||
|
return tdesc;
|
||||||
|
}
|
||||||
|
|
||||||
|
int usecount(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *key()
|
||||||
|
{
|
||||||
|
return ASTERISK_GPL_KEY;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Local Variables:
|
||||||
|
mode: C
|
||||||
|
c-file-style: "linux"
|
||||||
|
indent-tabs-mode: nil
|
||||||
|
End:
|
||||||
|
*/
|
||||||
|
@@ -29,9 +29,7 @@
|
|||||||
|
|
||||||
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
||||||
|
|
||||||
#ifndef BUILTIN_FUNC
|
|
||||||
#include "asterisk/module.h"
|
#include "asterisk/module.h"
|
||||||
#endif /* BUILTIN_FUNC */
|
|
||||||
#include "asterisk/channel.h"
|
#include "asterisk/channel.h"
|
||||||
#include "asterisk/pbx.h"
|
#include "asterisk/pbx.h"
|
||||||
#include "asterisk/logger.h"
|
#include "asterisk/logger.h"
|
||||||
@@ -120,10 +118,7 @@ static void callerid_write(struct ast_channel *chan, char *cmd, char *data, cons
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef BUILTIN_FUNC
|
static struct ast_custom_function callerid_function = {
|
||||||
static
|
|
||||||
#endif /* BUILTIN_FUNC */
|
|
||||||
struct ast_custom_function callerid_function = {
|
|
||||||
.name = "CALLERID",
|
.name = "CALLERID",
|
||||||
.synopsis = "Gets or sets Caller*ID data on the channel.",
|
.synopsis = "Gets or sets Caller*ID data on the channel.",
|
||||||
.syntax = "CALLERID(datatype[,<optional-CID>])",
|
.syntax = "CALLERID(datatype[,<optional-CID>])",
|
||||||
@@ -134,7 +129,6 @@ struct ast_custom_function callerid_function = {
|
|||||||
.write = callerid_write,
|
.write = callerid_write,
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef BUILTIN_FUNC
|
|
||||||
static char *tdesc = "Caller ID related dialplan function";
|
static char *tdesc = "Caller ID related dialplan function";
|
||||||
|
|
||||||
int unload_module(void)
|
int unload_module(void)
|
||||||
@@ -161,7 +155,6 @@ char *key()
|
|||||||
{
|
{
|
||||||
return ASTERISK_GPL_KEY;
|
return ASTERISK_GPL_KEY;
|
||||||
}
|
}
|
||||||
#endif /* BUILTIN_FUNC */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Local Variables:
|
Local Variables:
|
||||||
|
@@ -29,8 +29,9 @@
|
|||||||
|
|
||||||
#include "asterisk.h"
|
#include "asterisk.h"
|
||||||
|
|
||||||
/* ASTERISK_FILE_VERSION(__FILE__, "$Revision$") */
|
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
||||||
|
|
||||||
|
#include "asterisk/module.h"
|
||||||
#include "asterisk/channel.h"
|
#include "asterisk/channel.h"
|
||||||
#include "asterisk/pbx.h"
|
#include "asterisk/pbx.h"
|
||||||
#include "asterisk/logger.h"
|
#include "asterisk/logger.h"
|
||||||
@@ -46,7 +47,7 @@ AST_APP_OPTIONS(cdr_func_options, {
|
|||||||
AST_APP_OPTION('r', OPT_RECURSIVE),
|
AST_APP_OPTION('r', OPT_RECURSIVE),
|
||||||
});
|
});
|
||||||
|
|
||||||
static char *builtin_function_cdr_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
|
static char *cdr_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
|
||||||
{
|
{
|
||||||
char *ret;
|
char *ret;
|
||||||
char *parse;
|
char *parse;
|
||||||
@@ -76,7 +77,7 @@ static char *builtin_function_cdr_read(struct ast_channel *chan, char *cmd, char
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void builtin_function_cdr_write(struct ast_channel *chan, char *cmd, char *data, const char *value)
|
static void cdr_write(struct ast_channel *chan, char *cmd, char *data, const char *value)
|
||||||
{
|
{
|
||||||
char *parse;
|
char *parse;
|
||||||
struct ast_flags flags = {0};
|
struct ast_flags flags = {0};
|
||||||
@@ -107,15 +108,46 @@ static void builtin_function_cdr_write(struct ast_channel *chan, char *cmd, char
|
|||||||
ast_cdr_setvar(chan->cdr, args.variable, value, (ast_test_flag(&flags,OPT_RECURSIVE) ) ? 1 : 0 );
|
ast_cdr_setvar(chan->cdr, args.variable, value, (ast_test_flag(&flags,OPT_RECURSIVE) ) ? 1 : 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef BUILTIN_FUNC
|
static struct ast_custom_function cdr_function = {
|
||||||
static
|
|
||||||
#endif
|
|
||||||
struct ast_custom_function cdr_function = {
|
|
||||||
.name = "CDR",
|
.name = "CDR",
|
||||||
.synopsis = "Gets or sets a CDR variable",
|
.synopsis = "Gets or sets a CDR variable",
|
||||||
.desc= "Option 'r' searches the entire stack of CDRs on the channel\n",
|
.desc= "Option 'r' searches the entire stack of CDRs on the channel\n",
|
||||||
.syntax = "CDR(<name>[|options])",
|
.syntax = "CDR(<name>[|options])",
|
||||||
.read = builtin_function_cdr_read,
|
.read = cdr_read,
|
||||||
.write = builtin_function_cdr_write,
|
.write = cdr_write,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static char *tdesc = "CDR dialplan function";
|
||||||
|
|
||||||
|
int unload_module(void)
|
||||||
|
{
|
||||||
|
return ast_custom_function_unregister(&cdr_function);
|
||||||
|
}
|
||||||
|
|
||||||
|
int load_module(void)
|
||||||
|
{
|
||||||
|
return ast_custom_function_register(&cdr_function);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *description(void)
|
||||||
|
{
|
||||||
|
return tdesc;
|
||||||
|
}
|
||||||
|
|
||||||
|
int usecount(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *key()
|
||||||
|
{
|
||||||
|
return ASTERISK_GPL_KEY;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Local Variables:
|
||||||
|
mode: C
|
||||||
|
c-file-style: "linux"
|
||||||
|
indent-tabs-mode: nil
|
||||||
|
End:
|
||||||
|
*/
|
||||||
|
@@ -301,9 +301,9 @@ struct ast_custom_function acf_cut = {
|
|||||||
|
|
||||||
int unload_module(void)
|
int unload_module(void)
|
||||||
{
|
{
|
||||||
int res;
|
int res = 0;
|
||||||
|
|
||||||
res = ast_custom_function_unregister(&acf_cut);
|
res |= ast_custom_function_unregister(&acf_cut);
|
||||||
res |= ast_custom_function_unregister(&acf_sort);
|
res |= ast_custom_function_unregister(&acf_sort);
|
||||||
|
|
||||||
STANDARD_HANGUP_LOCALUSERS;
|
STANDARD_HANGUP_LOCALUSERS;
|
||||||
@@ -313,9 +313,9 @@ int unload_module(void)
|
|||||||
|
|
||||||
int load_module(void)
|
int load_module(void)
|
||||||
{
|
{
|
||||||
int res;
|
int res = 0;
|
||||||
|
|
||||||
res = ast_custom_function_register(&acf_cut);
|
res |= ast_custom_function_register(&acf_cut);
|
||||||
res |= ast_custom_function_register(&acf_sort);
|
res |= ast_custom_function_register(&acf_sort);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
@@ -32,8 +32,9 @@
|
|||||||
|
|
||||||
#include "asterisk.h"
|
#include "asterisk.h"
|
||||||
|
|
||||||
/* ASTERISK_FILE_VERSION(__FILE__, "$Revision$") */
|
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
||||||
|
|
||||||
|
#include "asterisk/module.h"
|
||||||
#include "asterisk/channel.h"
|
#include "asterisk/channel.h"
|
||||||
#include "asterisk/pbx.h"
|
#include "asterisk/pbx.h"
|
||||||
#include "asterisk/logger.h"
|
#include "asterisk/logger.h"
|
||||||
@@ -111,10 +112,7 @@ static void function_db_write(struct ast_channel *chan, char *cmd, char *data, c
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef BUILTIN_FUNC
|
static struct ast_custom_function db_function = {
|
||||||
static
|
|
||||||
#endif
|
|
||||||
struct ast_custom_function db_function = {
|
|
||||||
.name = "DB",
|
.name = "DB",
|
||||||
.synopsis = "Read or Write from/to the Asterisk database",
|
.synopsis = "Read or Write from/to the Asterisk database",
|
||||||
.syntax = "DB(<family>/<key>)",
|
.syntax = "DB(<family>/<key>)",
|
||||||
@@ -167,10 +165,7 @@ static char *function_db_exists(struct ast_channel *chan, char *cmd, char *data,
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef BUILTIN_FUNC
|
static struct ast_custom_function db_exists_function = {
|
||||||
static
|
|
||||||
#endif
|
|
||||||
struct ast_custom_function db_exists_function = {
|
|
||||||
.name = "DB_EXISTS",
|
.name = "DB_EXISTS",
|
||||||
.synopsis = "Check to see if a key exists in the Asterisk database",
|
.synopsis = "Check to see if a key exists in the Asterisk database",
|
||||||
.syntax = "DB_EXISTS(<family>/<key>)",
|
.syntax = "DB_EXISTS(<family>/<key>)",
|
||||||
@@ -180,3 +175,41 @@ struct ast_custom_function db_exists_function = {
|
|||||||
"also set the variable DB_RESULT to the key's value if it exists.\n",
|
"also set the variable DB_RESULT to the key's value if it exists.\n",
|
||||||
.read = function_db_exists,
|
.read = function_db_exists,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static char *tdesc = "Database (astdb) related dialplan functions";
|
||||||
|
|
||||||
|
int unload_module(void)
|
||||||
|
{
|
||||||
|
int res = 0;
|
||||||
|
|
||||||
|
res |= ast_custom_function_unregister(&db_function);
|
||||||
|
res |= ast_custom_function_unregister(&db_exists_function);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
int load_module(void)
|
||||||
|
{
|
||||||
|
int res = 0;
|
||||||
|
|
||||||
|
res |= ast_custom_function_register(&db_function);
|
||||||
|
res |= ast_custom_function_register(&db_exists_function);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *description(void)
|
||||||
|
{
|
||||||
|
return tdesc;
|
||||||
|
}
|
||||||
|
|
||||||
|
int usecount(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *key()
|
||||||
|
{
|
||||||
|
return ASTERISK_GPL_KEY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -34,9 +34,9 @@
|
|||||||
|
|
||||||
#include "asterisk.h"
|
#include "asterisk.h"
|
||||||
|
|
||||||
#ifndef BUILTIN_FUNC
|
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
||||||
|
|
||||||
#include "asterisk/module.h"
|
#include "asterisk/module.h"
|
||||||
#endif /* BUILTIN_FUNC */
|
|
||||||
#include "asterisk/channel.h"
|
#include "asterisk/channel.h"
|
||||||
#include "asterisk/pbx.h"
|
#include "asterisk/pbx.h"
|
||||||
#include "asterisk/utils.h"
|
#include "asterisk/utils.h"
|
||||||
@@ -145,10 +145,7 @@ static char *function_enum(struct ast_channel *chan, char *cmd, char *data, char
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef BUILTIN_FUNC
|
static struct ast_custom_function enum_function = {
|
||||||
static
|
|
||||||
#endif
|
|
||||||
struct ast_custom_function enum_function = {
|
|
||||||
.name = "ENUMLOOKUP",
|
.name = "ENUMLOOKUP",
|
||||||
.synopsis = "ENUMLOOKUP allows for general or specific querying of NAPTR records"
|
.synopsis = "ENUMLOOKUP allows for general or specific querying of NAPTR records"
|
||||||
" or counts of NAPTR types for ENUM or ENUM-like DNS pointers",
|
" or counts of NAPTR types for ENUM or ENUM-like DNS pointers",
|
||||||
@@ -188,10 +185,7 @@ static char *function_txtcidname(struct ast_channel *chan, char *cmd, char *data
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef BUILTIN_FUNC
|
static struct ast_custom_function txtcidname_function = {
|
||||||
static
|
|
||||||
#endif
|
|
||||||
struct ast_custom_function txtcidname_function = {
|
|
||||||
.name = "TXTCIDNAME",
|
.name = "TXTCIDNAME",
|
||||||
.synopsis = "TXTCIDNAME looks up a caller name via DNS",
|
.synopsis = "TXTCIDNAME looks up a caller name via DNS",
|
||||||
.syntax = "TXTCIDNAME(<number>)",
|
.syntax = "TXTCIDNAME(<number>)",
|
||||||
@@ -201,27 +195,26 @@ struct ast_custom_function txtcidname_function = {
|
|||||||
.read = function_txtcidname,
|
.read = function_txtcidname,
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef BUILTIN_FUNC
|
static char *tdesc = "ENUM related dialplan functions";
|
||||||
|
|
||||||
static char *tdesc = "ENUM Related Functions";
|
|
||||||
|
|
||||||
int unload_module(void)
|
int unload_module(void)
|
||||||
{
|
{
|
||||||
ast_custom_function_unregister(&enum_function);
|
int res = 0;
|
||||||
ast_custom_function_unregister(&txtcidname_function);
|
|
||||||
|
res |= ast_custom_function_unregister(&enum_function);
|
||||||
|
res |= ast_custom_function_unregister(&txtcidname_function);
|
||||||
|
|
||||||
STANDARD_HANGUP_LOCALUSERS;
|
STANDARD_HANGUP_LOCALUSERS;
|
||||||
|
|
||||||
return 0;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
int load_module(void)
|
int load_module(void)
|
||||||
{
|
{
|
||||||
int res;
|
int res = 0;
|
||||||
|
|
||||||
res = ast_custom_function_register(&enum_function);
|
res |= ast_custom_function_register(&enum_function);
|
||||||
if (!res)
|
res |= ast_custom_function_register(&txtcidname_function);
|
||||||
ast_custom_function_register(&txtcidname_function);
|
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@@ -244,5 +237,4 @@ char *key()
|
|||||||
{
|
{
|
||||||
return ASTERISK_GPL_KEY;
|
return ASTERISK_GPL_KEY;
|
||||||
}
|
}
|
||||||
#endif /* BUILTIN_FUNC */
|
|
||||||
|
|
||||||
|
@@ -27,15 +27,16 @@
|
|||||||
|
|
||||||
#include "asterisk.h"
|
#include "asterisk.h"
|
||||||
|
|
||||||
/* ASTERISK_FILE_VERSION(__FILE__, "$Revision$") */
|
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
||||||
|
|
||||||
|
#include "asterisk/module.h"
|
||||||
#include "asterisk/channel.h"
|
#include "asterisk/channel.h"
|
||||||
#include "asterisk/pbx.h"
|
#include "asterisk/pbx.h"
|
||||||
#include "asterisk/logger.h"
|
#include "asterisk/logger.h"
|
||||||
#include "asterisk/utils.h"
|
#include "asterisk/utils.h"
|
||||||
#include "asterisk/app.h"
|
#include "asterisk/app.h"
|
||||||
|
|
||||||
static char *builtin_function_env_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
|
static char *env_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
|
||||||
{
|
{
|
||||||
char *ret = "";
|
char *ret = "";
|
||||||
|
|
||||||
@@ -49,7 +50,7 @@ static char *builtin_function_env_read(struct ast_channel *chan, char *cmd, char
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void builtin_function_env_write(struct ast_channel *chan, char *cmd, char *data, const char *value)
|
static void env_write(struct ast_channel *chan, char *cmd, char *data, const char *value)
|
||||||
{
|
{
|
||||||
if (!ast_strlen_zero(data)) {
|
if (!ast_strlen_zero(data)) {
|
||||||
if (!ast_strlen_zero(value)) {
|
if (!ast_strlen_zero(value)) {
|
||||||
@@ -60,7 +61,7 @@ static void builtin_function_env_write(struct ast_channel *chan, char *cmd, char
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *builtin_function_stat_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
|
static char *stat_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
|
||||||
{
|
{
|
||||||
char *action;
|
char *action;
|
||||||
struct stat s;
|
struct stat s;
|
||||||
@@ -105,25 +106,19 @@ static char *builtin_function_stat_read(struct ast_channel *chan, char *cmd, cha
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef BUILTIN_FUNC
|
static struct ast_custom_function env_function = {
|
||||||
static
|
|
||||||
#endif
|
|
||||||
struct ast_custom_function env_function = {
|
|
||||||
.name = "ENV",
|
.name = "ENV",
|
||||||
.synopsis = "Gets or sets the environment variable specified",
|
.synopsis = "Gets or sets the environment variable specified",
|
||||||
.syntax = "ENV(<envname>)",
|
.syntax = "ENV(<envname>)",
|
||||||
.read = builtin_function_env_read,
|
.read = env_read,
|
||||||
.write = builtin_function_env_write,
|
.write = env_write,
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef BUILTIN_FUNC
|
static struct ast_custom_function stat_function = {
|
||||||
static
|
|
||||||
#endif
|
|
||||||
struct ast_custom_function stat_function = {
|
|
||||||
.name = "STAT",
|
.name = "STAT",
|
||||||
.synopsis = "Does a check on the specified file",
|
.synopsis = "Does a check on the specified file",
|
||||||
.syntax = "STAT(<flag>,<filename>)",
|
.syntax = "STAT(<flag>,<filename>)",
|
||||||
.read = builtin_function_stat_read,
|
.read = stat_read,
|
||||||
.desc =
|
.desc =
|
||||||
"flag may be one of the following:\n"
|
"flag may be one of the following:\n"
|
||||||
" d - Checks if the file is a directory\n"
|
" d - Checks if the file is a directory\n"
|
||||||
@@ -136,3 +131,48 @@ struct ast_custom_function stat_function = {
|
|||||||
" M - Returns the epoch at which the file was last modified\n",
|
" M - Returns the epoch at which the file was last modified\n",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static char *tdesc = "Environment/filesystem dialplan functions";
|
||||||
|
|
||||||
|
int unload_module(void)
|
||||||
|
{
|
||||||
|
int res = 0;
|
||||||
|
|
||||||
|
res |= ast_custom_function_unregister(&env_function);
|
||||||
|
res |= ast_custom_function_unregister(&stat_function);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
int load_module(void)
|
||||||
|
{
|
||||||
|
int res = 0;
|
||||||
|
|
||||||
|
res |= ast_custom_function_register(&env_function);
|
||||||
|
res |= ast_custom_function_register(&stat_function);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *description(void)
|
||||||
|
{
|
||||||
|
return tdesc;
|
||||||
|
}
|
||||||
|
|
||||||
|
int usecount(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *key()
|
||||||
|
{
|
||||||
|
return ASTERISK_GPL_KEY;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Local Variables:
|
||||||
|
mode: C
|
||||||
|
c-file-style: "linux"
|
||||||
|
indent-tabs-mode: nil
|
||||||
|
End:
|
||||||
|
*/
|
||||||
|
@@ -27,8 +27,9 @@
|
|||||||
|
|
||||||
#include "asterisk.h"
|
#include "asterisk.h"
|
||||||
|
|
||||||
/* ASTERISK_FILE_VERSION(__FILE__, "$Revision$") */
|
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
||||||
|
|
||||||
|
#include "asterisk/module.h"
|
||||||
#include "asterisk/channel.h"
|
#include "asterisk/channel.h"
|
||||||
#include "asterisk/pbx.h"
|
#include "asterisk/pbx.h"
|
||||||
#include "asterisk/logger.h"
|
#include "asterisk/logger.h"
|
||||||
@@ -57,10 +58,7 @@ static char *group_count_function_read(struct ast_channel *chan, char *cmd, char
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef BUILTIN_FUNC
|
static struct ast_custom_function group_count_function = {
|
||||||
static
|
|
||||||
#endif
|
|
||||||
struct ast_custom_function group_count_function = {
|
|
||||||
.name = "GROUP_COUNT",
|
.name = "GROUP_COUNT",
|
||||||
.syntax = "GROUP_COUNT([groupname][@category])",
|
.syntax = "GROUP_COUNT([groupname][@category])",
|
||||||
.synopsis = "Counts the number of channels in the specified group",
|
.synopsis = "Counts the number of channels in the specified group",
|
||||||
@@ -85,10 +83,7 @@ static char *group_match_count_function_read(struct ast_channel *chan, char *cmd
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef BUILTIN_FUNC
|
static struct ast_custom_function group_match_count_function = {
|
||||||
static
|
|
||||||
#endif
|
|
||||||
struct ast_custom_function group_match_count_function = {
|
|
||||||
.name = "GROUP_MATCH_COUNT",
|
.name = "GROUP_MATCH_COUNT",
|
||||||
.syntax = "GROUP_MATCH_COUNT(groupmatch[@category])",
|
.syntax = "GROUP_MATCH_COUNT(groupmatch[@category])",
|
||||||
.synopsis = "Counts the number of channels in the groups matching the specified pattern",
|
.synopsis = "Counts the number of channels in the groups matching the specified pattern",
|
||||||
@@ -130,10 +125,7 @@ static void group_function_write(struct ast_channel *chan, char *cmd, char *data
|
|||||||
ast_log(LOG_WARNING, "Setting a group requires an argument (group name)\n");
|
ast_log(LOG_WARNING, "Setting a group requires an argument (group name)\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef BUILTIN_FUNC
|
static struct ast_custom_function group_function = {
|
||||||
static
|
|
||||||
#endif
|
|
||||||
struct ast_custom_function group_function = {
|
|
||||||
.name = "GROUP",
|
.name = "GROUP",
|
||||||
.syntax = "GROUP([category])",
|
.syntax = "GROUP([category])",
|
||||||
.synopsis = "Gets or sets the channel group.",
|
.synopsis = "Gets or sets the channel group.",
|
||||||
@@ -171,10 +163,7 @@ static char *group_list_function_read(struct ast_channel *chan, char *cmd, char
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef BUILTIN_FUNC
|
static struct ast_custom_function group_list_function = {
|
||||||
static
|
|
||||||
#endif
|
|
||||||
struct ast_custom_function group_list_function = {
|
|
||||||
.name = "GROUP_LIST",
|
.name = "GROUP_LIST",
|
||||||
.syntax = "GROUP_LIST()",
|
.syntax = "GROUP_LIST()",
|
||||||
.synopsis = "Gets a list of the groups set on a channel.",
|
.synopsis = "Gets a list of the groups set on a channel.",
|
||||||
@@ -183,6 +172,47 @@ struct ast_custom_function group_list_function = {
|
|||||||
.write = NULL,
|
.write = NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static char *tdesc = "Channel group dialplan functions";
|
||||||
|
|
||||||
|
int unload_module(void)
|
||||||
|
{
|
||||||
|
int res = 0;
|
||||||
|
|
||||||
|
res |= ast_custom_function_unregister(&group_count_function);
|
||||||
|
res |= ast_custom_function_unregister(&group_match_count_function);
|
||||||
|
res |= ast_custom_function_unregister(&group_list_function);
|
||||||
|
res |= ast_custom_function_unregister(&group_function);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
int load_module(void)
|
||||||
|
{
|
||||||
|
int res = 0;
|
||||||
|
|
||||||
|
res |= ast_custom_function_register(&group_count_function);
|
||||||
|
res |= ast_custom_function_register(&group_match_count_function);
|
||||||
|
res |= ast_custom_function_register(&group_list_function);
|
||||||
|
res |= ast_custom_function_register(&group_function);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *description(void)
|
||||||
|
{
|
||||||
|
return tdesc;
|
||||||
|
}
|
||||||
|
|
||||||
|
int usecount(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *key()
|
||||||
|
{
|
||||||
|
return ASTERISK_GPL_KEY;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Local Variables:
|
Local Variables:
|
||||||
mode: C
|
mode: C
|
||||||
|
@@ -26,8 +26,9 @@
|
|||||||
|
|
||||||
#include "asterisk.h"
|
#include "asterisk.h"
|
||||||
|
|
||||||
/* ASTERISK_FILE_VERSION(__FILE__, "$Revision$") */
|
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
||||||
|
|
||||||
|
#include "asterisk/module.h"
|
||||||
#include "asterisk/channel.h"
|
#include "asterisk/channel.h"
|
||||||
#include "asterisk/pbx.h"
|
#include "asterisk/pbx.h"
|
||||||
#include "asterisk/logger.h"
|
#include "asterisk/logger.h"
|
||||||
@@ -35,23 +36,20 @@
|
|||||||
#include "asterisk/app.h"
|
#include "asterisk/app.h"
|
||||||
#include "asterisk/stringfields.h"
|
#include "asterisk/stringfields.h"
|
||||||
|
|
||||||
static char *builtin_function_language_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
|
static char *language_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
|
||||||
{
|
{
|
||||||
ast_copy_string(buf, chan->language, len);
|
ast_copy_string(buf, chan->language, len);
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void builtin_function_language_write(struct ast_channel *chan, char *cmd, char *data, const char *value)
|
static void language_write(struct ast_channel *chan, char *cmd, char *data, const char *value)
|
||||||
{
|
{
|
||||||
if (value)
|
if (value)
|
||||||
ast_string_field_set(chan, language, value);
|
ast_string_field_set(chan, language, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef BUILTIN_FUNC
|
static struct ast_custom_function language_function = {
|
||||||
static
|
|
||||||
#endif
|
|
||||||
struct ast_custom_function language_function = {
|
|
||||||
.name = "LANGUAGE",
|
.name = "LANGUAGE",
|
||||||
.synopsis = "Gets or sets the channel's language.",
|
.synopsis = "Gets or sets the channel's language.",
|
||||||
.syntax = "LANGUAGE()",
|
.syntax = "LANGUAGE()",
|
||||||
@@ -63,10 +61,37 @@ struct ast_custom_function language_function = {
|
|||||||
"will play the normal 'demo-congrats'. For some language codes,\n"
|
"will play the normal 'demo-congrats'. For some language codes,\n"
|
||||||
"changing the language also changes the syntax of some Asterisk\n"
|
"changing the language also changes the syntax of some Asterisk\n"
|
||||||
"functions, like SayNumber.\n",
|
"functions, like SayNumber.\n",
|
||||||
.read = builtin_function_language_read,
|
.read = language_read,
|
||||||
.write = builtin_function_language_write,
|
.write = language_write,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static char *tdesc = "Channel language dialplan function";
|
||||||
|
|
||||||
|
int unload_module(void)
|
||||||
|
{
|
||||||
|
return ast_custom_function_unregister(&language_function);
|
||||||
|
}
|
||||||
|
|
||||||
|
int load_module(void)
|
||||||
|
{
|
||||||
|
return ast_custom_function_register(&language_function);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *description(void)
|
||||||
|
{
|
||||||
|
return tdesc;
|
||||||
|
}
|
||||||
|
|
||||||
|
int usecount(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *key()
|
||||||
|
{
|
||||||
|
return ASTERISK_GPL_KEY;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Local Variables:
|
Local Variables:
|
||||||
mode: C
|
mode: C
|
||||||
|
@@ -28,26 +28,26 @@
|
|||||||
|
|
||||||
#include "asterisk.h"
|
#include "asterisk.h"
|
||||||
|
|
||||||
/* ASTERISK_FILE_VERSION(__FILE__, "$Revision$") */
|
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
||||||
|
|
||||||
|
#include "asterisk/module.h"
|
||||||
#include "asterisk/channel.h"
|
#include "asterisk/channel.h"
|
||||||
#include "asterisk/pbx.h"
|
#include "asterisk/pbx.h"
|
||||||
#include "asterisk/logger.h"
|
#include "asterisk/logger.h"
|
||||||
#include "asterisk/utils.h"
|
#include "asterisk/utils.h"
|
||||||
#include "asterisk/app.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";
|
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";
|
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;
|
struct ast_timing timing;
|
||||||
char *ret;
|
char *ret;
|
||||||
@@ -86,7 +86,7 @@ static char *builtin_function_iftime(struct ast_channel *chan, char *cmd, char *
|
|||||||
return ret;
|
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 *ret;
|
||||||
char *expr;
|
char *expr;
|
||||||
@@ -120,7 +120,7 @@ static char *builtin_function_if(struct ast_channel *chan, char *cmd, char *data
|
|||||||
return ret;
|
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 *varname;
|
||||||
char *val;
|
char *val;
|
||||||
@@ -144,53 +144,80 @@ static char *builtin_function_set(struct ast_channel *chan, char *cmd, char *dat
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef BUILTIN_FUNC
|
static struct ast_custom_function isnull_function = {
|
||||||
static
|
|
||||||
#endif
|
|
||||||
struct ast_custom_function isnull_function = {
|
|
||||||
.name = "ISNULL",
|
.name = "ISNULL",
|
||||||
.synopsis = "NULL Test: Returns 1 if NULL or 0 otherwise",
|
.synopsis = "NULL Test: Returns 1 if NULL or 0 otherwise",
|
||||||
.syntax = "ISNULL(<data>)",
|
.syntax = "ISNULL(<data>)",
|
||||||
.read = builtin_function_isnull,
|
.read = isnull,
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef BUILTIN_FUNC
|
static struct ast_custom_function set_function = {
|
||||||
static
|
|
||||||
#endif
|
|
||||||
struct ast_custom_function set_function = {
|
|
||||||
.name = "SET",
|
.name = "SET",
|
||||||
.synopsis = "SET assigns a value to a channel variable",
|
.synopsis = "SET assigns a value to a channel variable",
|
||||||
.syntax = "SET(<varname>=[<value>])",
|
.syntax = "SET(<varname>=[<value>])",
|
||||||
.read = builtin_function_set,
|
.read = set,
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef BUILTIN_FUNC
|
static struct ast_custom_function exists_function = {
|
||||||
static
|
|
||||||
#endif
|
|
||||||
struct ast_custom_function exists_function = {
|
|
||||||
.name = "EXISTS",
|
.name = "EXISTS",
|
||||||
.synopsis = "Existence Test: Returns 1 if exists, 0 otherwise",
|
.synopsis = "Existence Test: Returns 1 if exists, 0 otherwise",
|
||||||
.syntax = "EXISTS(<data>)",
|
.syntax = "EXISTS(<data>)",
|
||||||
.read = builtin_function_exists,
|
.read = exists,
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef BUILTIN_FUNC
|
static struct ast_custom_function if_function = {
|
||||||
static
|
|
||||||
#endif
|
|
||||||
struct ast_custom_function if_function = {
|
|
||||||
.name = "IF",
|
.name = "IF",
|
||||||
.synopsis = "Conditional: Returns the data following '?' if true else the data following ':'",
|
.synopsis = "Conditional: Returns the data following '?' if true else the data following ':'",
|
||||||
.syntax = "IF(<expr>?[<true>][:<false>])",
|
.syntax = "IF(<expr>?[<true>][:<false>])",
|
||||||
.read = builtin_function_if,
|
.read = acf_if,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static struct ast_custom_function if_time_function = {
|
||||||
#ifndef BUILTIN_FUNC
|
|
||||||
static
|
|
||||||
#endif
|
|
||||||
struct ast_custom_function if_time_function = {
|
|
||||||
.name = "IFTIME",
|
.name = "IFTIME",
|
||||||
.synopsis = "Temporal Conditional: Returns the data following '?' if true else the data following ':'",
|
.synopsis = "Temporal Conditional: Returns the data following '?' if true else the data following ':'",
|
||||||
.syntax = "IFTIME(<timespec>?[<true>][:<false>])",
|
.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;
|
||||||
|
}
|
||||||
|
@@ -31,8 +31,9 @@
|
|||||||
|
|
||||||
#include "asterisk.h"
|
#include "asterisk.h"
|
||||||
|
|
||||||
/* ASTERISK_FILE_VERSION(__FILE__, "$Revision$") */
|
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
||||||
|
|
||||||
|
#include "asterisk/module.h"
|
||||||
#include "asterisk/channel.h"
|
#include "asterisk/channel.h"
|
||||||
#include "asterisk/pbx.h"
|
#include "asterisk/pbx.h"
|
||||||
#include "asterisk/logger.h"
|
#include "asterisk/logger.h"
|
||||||
@@ -47,7 +48,6 @@ enum TypeOfFunctions
|
|||||||
MULTIPLYFUNCTION,
|
MULTIPLYFUNCTION,
|
||||||
SUBTRACTFUNCTION,
|
SUBTRACTFUNCTION,
|
||||||
MODULUSFUNCTION,
|
MODULUSFUNCTION,
|
||||||
|
|
||||||
GTFUNCTION,
|
GTFUNCTION,
|
||||||
LTFUNCTION,
|
LTFUNCTION,
|
||||||
GTEFUNCTION,
|
GTEFUNCTION,
|
||||||
@@ -64,7 +64,7 @@ enum TypeOfResult
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static char *builtin_function_math(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
|
static char *math(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
|
||||||
{
|
{
|
||||||
float fnum1;
|
float fnum1;
|
||||||
float fnum2;
|
float fnum2;
|
||||||
@@ -237,10 +237,7 @@ static char *builtin_function_math(struct ast_channel *chan, char *cmd, char *da
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef BUILTIN_FUNC
|
static struct ast_custom_function math_function = {
|
||||||
static
|
|
||||||
#endif /* BUILTIN_FUNC */
|
|
||||||
struct ast_custom_function math_function = {
|
|
||||||
.name = "MATH",
|
.name = "MATH",
|
||||||
.synopsis = "Performs Mathematical Functions",
|
.synopsis = "Performs Mathematical Functions",
|
||||||
.syntax = "MATH(<number1><op><number 2>[,<type_of_result>])",
|
.syntax = "MATH(<number1><op><number 2>[,<type_of_result>])",
|
||||||
@@ -253,5 +250,32 @@ struct ast_custom_function math_function = {
|
|||||||
" h, hex - hex,\n"
|
" h, hex - hex,\n"
|
||||||
" c, char - char\n"
|
" c, char - char\n"
|
||||||
"Example: Set(i=${MATH(123%16,int)}) - sets var i=11",
|
"Example: Set(i=${MATH(123%16,int)}) - sets var i=11",
|
||||||
.read = builtin_function_math
|
.read = math
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static char *tdesc = "Mathematical dialplan function";
|
||||||
|
|
||||||
|
int unload_module(void)
|
||||||
|
{
|
||||||
|
return ast_custom_function_unregister(&math_function);
|
||||||
|
}
|
||||||
|
|
||||||
|
int load_module(void)
|
||||||
|
{
|
||||||
|
return ast_custom_function_register(&math_function);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *description(void)
|
||||||
|
{
|
||||||
|
return tdesc;
|
||||||
|
}
|
||||||
|
|
||||||
|
int usecount(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *key()
|
||||||
|
{
|
||||||
|
return ASTERISK_GPL_KEY;
|
||||||
|
}
|
||||||
|
@@ -30,15 +30,16 @@
|
|||||||
|
|
||||||
#include "asterisk.h"
|
#include "asterisk.h"
|
||||||
|
|
||||||
/* ASTERISK_FILE_VERSION(__FILE__, "$Revision$") */
|
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
||||||
|
|
||||||
|
#include "asterisk/module.h"
|
||||||
#include "asterisk/channel.h"
|
#include "asterisk/channel.h"
|
||||||
#include "asterisk/pbx.h"
|
#include "asterisk/pbx.h"
|
||||||
#include "asterisk/logger.h"
|
#include "asterisk/logger.h"
|
||||||
#include "asterisk/utils.h"
|
#include "asterisk/utils.h"
|
||||||
#include "asterisk/app.h"
|
#include "asterisk/app.h"
|
||||||
|
|
||||||
static char *builtin_function_md5(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
|
static char *md5(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
|
||||||
{
|
{
|
||||||
char md5[33];
|
char md5[33];
|
||||||
|
|
||||||
@@ -53,7 +54,7 @@ static char *builtin_function_md5(struct ast_channel *chan, char *cmd, char *dat
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *builtin_function_checkmd5(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
|
static char *checkmd5(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
|
||||||
{
|
{
|
||||||
char newmd5[33];
|
char newmd5[33];
|
||||||
char *parse;
|
char *parse;
|
||||||
@@ -93,23 +94,44 @@ static char *builtin_function_checkmd5(struct ast_channel *chan, char *cmd, char
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef BUILTIN_FUNC
|
static struct ast_custom_function md5_function = {
|
||||||
static
|
|
||||||
#endif
|
|
||||||
struct ast_custom_function md5_function = {
|
|
||||||
.name = "MD5",
|
.name = "MD5",
|
||||||
.synopsis = "Computes an MD5 digest",
|
.synopsis = "Computes an MD5 digest",
|
||||||
.syntax = "MD5(<data>)",
|
.syntax = "MD5(<data>)",
|
||||||
.read = builtin_function_md5,
|
.read = md5,
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef BUILTIN_FUNC
|
static struct ast_custom_function checkmd5_function = {
|
||||||
static
|
|
||||||
#endif
|
|
||||||
struct ast_custom_function checkmd5_function = {
|
|
||||||
.name = "CHECK_MD5",
|
.name = "CHECK_MD5",
|
||||||
.synopsis = "Checks an MD5 digest",
|
.synopsis = "Checks an MD5 digest",
|
||||||
.desc = "Returns 1 on a match, 0 otherwise\n",
|
.desc = "Returns 1 on a match, 0 otherwise\n",
|
||||||
.syntax = "CHECK_MD5(<digest>,<data>)",
|
.syntax = "CHECK_MD5(<digest>,<data>)",
|
||||||
.read = builtin_function_checkmd5,
|
.read = checkmd5,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static char *tdesc = "MD5 digest dialplan functions";
|
||||||
|
|
||||||
|
int unload_module(void)
|
||||||
|
{
|
||||||
|
return ast_custom_function_unregister(&md5_function) || ast_custom_function_unregister(&checkmd5_function);
|
||||||
|
}
|
||||||
|
|
||||||
|
int load_module(void)
|
||||||
|
{
|
||||||
|
return ast_custom_function_register(&md5_function) || ast_custom_function_register(&checkmd5_function);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *description(void)
|
||||||
|
{
|
||||||
|
return tdesc;
|
||||||
|
}
|
||||||
|
|
||||||
|
int usecount(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *key()
|
||||||
|
{
|
||||||
|
return ASTERISK_GPL_KEY;
|
||||||
|
}
|
||||||
|
@@ -27,32 +27,58 @@
|
|||||||
|
|
||||||
#include "asterisk.h"
|
#include "asterisk.h"
|
||||||
|
|
||||||
|
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
||||||
|
|
||||||
|
#include "asterisk/module.h"
|
||||||
#include "asterisk/channel.h"
|
#include "asterisk/channel.h"
|
||||||
#include "asterisk/pbx.h"
|
#include "asterisk/pbx.h"
|
||||||
#include "asterisk/utils.h"
|
#include "asterisk/utils.h"
|
||||||
#include "asterisk/stringfields.h"
|
#include "asterisk/stringfields.h"
|
||||||
|
|
||||||
static char *function_moh_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
|
static char *moh_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
|
||||||
{
|
{
|
||||||
ast_copy_string(buf, chan->musicclass, len);
|
ast_copy_string(buf, chan->musicclass, len);
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void function_moh_write(struct ast_channel *chan, char *cmd, char *data, const char *value)
|
static void moh_write(struct ast_channel *chan, char *cmd, char *data, const char *value)
|
||||||
{
|
{
|
||||||
ast_string_field_set(chan, musicclass, value);
|
ast_string_field_set(chan, musicclass, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef BUILTIN_FUNC
|
static struct ast_custom_function moh_function = {
|
||||||
static
|
|
||||||
#endif
|
|
||||||
struct ast_custom_function moh_function = {
|
|
||||||
.name = "MUSICCLASS",
|
.name = "MUSICCLASS",
|
||||||
.synopsis = "Read or Set the MusicOnHold class",
|
.synopsis = "Read or Set the MusicOnHold class",
|
||||||
.syntax = "MUSICCLASS()",
|
.syntax = "MUSICCLASS()",
|
||||||
.desc = "This function will read or set the music on hold class for a channel.\n",
|
.desc = "This function will read or set the music on hold class for a channel.\n",
|
||||||
.read = function_moh_read,
|
.read = moh_read,
|
||||||
.write = function_moh_write,
|
.write = moh_write,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static char *tdesc = "Music-on-hold dialplan function";
|
||||||
|
|
||||||
|
int unload_module(void)
|
||||||
|
{
|
||||||
|
return ast_custom_function_unregister(&moh_function);
|
||||||
|
}
|
||||||
|
|
||||||
|
int load_module(void)
|
||||||
|
{
|
||||||
|
return ast_custom_function_register(&moh_function);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *description(void)
|
||||||
|
{
|
||||||
|
return tdesc;
|
||||||
|
}
|
||||||
|
|
||||||
|
int usecount(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *key()
|
||||||
|
{
|
||||||
|
return ASTERISK_GPL_KEY;
|
||||||
|
}
|
||||||
|
@@ -1,13 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
* Asterisk -- A telephony toolkit for Linux.
|
* Asterisk -- An open source telephony toolkit.
|
||||||
*
|
*
|
||||||
* func_odbc
|
|
||||||
*
|
|
||||||
* Copyright (c) 2005 Tilghman Lesher
|
* Copyright (c) 2005 Tilghman Lesher
|
||||||
*
|
*
|
||||||
* Tilghman Lesher <func_odbc__200508@the-tilghman.com>
|
* Tilghman Lesher <func_odbc__200508@the-tilghman.com>
|
||||||
*
|
*
|
||||||
* Special thanks to Anthony Minessale II for debugging help.
|
* See http://www.asterisk.org for more information about
|
||||||
|
* the Asterisk project. Please do not directly contact
|
||||||
|
* any of the maintainers of this project for assistance;
|
||||||
|
* the project provides a web site, mailing lists and IRC
|
||||||
|
* channels for your use.
|
||||||
|
*
|
||||||
|
* This program is free software, distributed under the terms of
|
||||||
|
* the GNU General Public License Version 2. See the LICENSE file
|
||||||
|
* at the top of the source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -23,14 +29,20 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <asterisk/file.h>
|
|
||||||
#include <asterisk/logger.h>
|
#include "asterisk.h"
|
||||||
#include <asterisk/options.h>
|
|
||||||
#include <asterisk/channel.h>
|
ASTERISK_FILE_VERSION(__FILE__, "$Revision: 7682 $")
|
||||||
#include <asterisk/pbx.h>
|
|
||||||
#include <asterisk/module.h>
|
#include "asterisk/module.h"
|
||||||
#include <asterisk/config.h>
|
#include "asterisk/file.h"
|
||||||
#include <asterisk/res_odbc.h>
|
#include "asterisk/logger.h"
|
||||||
|
#include "asterisk/options.h"
|
||||||
|
#include "asterisk/channel.h"
|
||||||
|
#include "asterisk/pbx.h"
|
||||||
|
#include "asterisk/module.h"
|
||||||
|
#include "asterisk/config.h"
|
||||||
|
#include "asterisk/res_odbc.h"
|
||||||
|
|
||||||
static char *tdesc = "ODBC lookups";
|
static char *tdesc = "ODBC lookups";
|
||||||
|
|
||||||
@@ -372,7 +384,7 @@ static char *acf_escape(struct ast_channel *chan, char *cmd, char *data, char *b
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ast_custom_function escape_function = {
|
static struct ast_custom_function escape_function = {
|
||||||
.name = "SQL_ESC",
|
.name = "SQL_ESC",
|
||||||
.synopsis = "Escapes single ticks for use in SQL statements",
|
.synopsis = "Escapes single ticks for use in SQL statements",
|
||||||
.syntax = "SQL_ESC(<string>)",
|
.syntax = "SQL_ESC(<string>)",
|
||||||
@@ -497,8 +509,8 @@ static int odbc_load_module(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (catg = ast_category_browse(cfg, NULL);
|
for (catg = ast_category_browse(cfg, NULL);
|
||||||
catg;
|
catg;
|
||||||
catg = ast_category_browse(cfg, catg)) {
|
catg = ast_category_browse(cfg, catg)) {
|
||||||
struct acf_odbc_query *query=NULL;
|
struct acf_odbc_query *query=NULL;
|
||||||
|
|
||||||
if (init_acf_query(cfg, catg, &query)) {
|
if (init_acf_query(cfg, catg, &query)) {
|
||||||
@@ -569,8 +581,8 @@ int reload(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (catg = ast_category_browse(cfg, NULL);
|
for (catg = ast_category_browse(cfg, NULL);
|
||||||
catg;
|
catg;
|
||||||
catg = ast_category_browse(cfg, catg)) {
|
catg = ast_category_browse(cfg, catg)) {
|
||||||
struct acf_odbc_query *query = NULL;
|
struct acf_odbc_query *query = NULL;
|
||||||
|
|
||||||
/* We do this piecemeal, so that we stay in a consistent state, if there's ever an error */
|
/* We do this piecemeal, so that we stay in a consistent state, if there's ever an error */
|
||||||
|
@@ -30,23 +30,19 @@
|
|||||||
|
|
||||||
#include "asterisk.h"
|
#include "asterisk.h"
|
||||||
|
|
||||||
/* ASTERISK_FILE_VERSION(__FILE__, "$Revision: 7682 $") */
|
ASTERISK_FILE_VERSION(__FILE__, "$Revision: 7682 $")
|
||||||
|
|
||||||
|
#include "asterisk/module.h"
|
||||||
#include "asterisk/channel.h"
|
#include "asterisk/channel.h"
|
||||||
#include "asterisk/pbx.h"
|
#include "asterisk/pbx.h"
|
||||||
#include "asterisk/logger.h"
|
#include "asterisk/logger.h"
|
||||||
#include "asterisk/utils.h"
|
#include "asterisk/utils.h"
|
||||||
#include "asterisk/app.h"
|
#include "asterisk/app.h"
|
||||||
#ifndef BUILTIN_FUNC
|
|
||||||
#include "asterisk/module.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
STANDARD_LOCAL_USER;
|
STANDARD_LOCAL_USER;
|
||||||
|
|
||||||
LOCAL_USER_DECL;
|
LOCAL_USER_DECL;
|
||||||
|
|
||||||
|
|
||||||
static char *acf_rand_exec(struct ast_channel *chan, char *cmd, char *data, char *buffer, size_t buflen)
|
static char *acf_rand_exec(struct ast_channel *chan, char *cmd, char *data, char *buffer, size_t buflen)
|
||||||
{
|
{
|
||||||
struct localuser *u;
|
struct localuser *u;
|
||||||
@@ -91,10 +87,7 @@ static char *acf_rand_exec(struct ast_channel *chan, char *cmd, char *data, char
|
|||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef BUILTIN_FUNC
|
static struct ast_custom_function acf_rand = {
|
||||||
static
|
|
||||||
#endif
|
|
||||||
struct ast_custom_function acf_rand = {
|
|
||||||
.name = "RAND",
|
.name = "RAND",
|
||||||
.synopsis = "Choose a random number in a range",
|
.synopsis = "Choose a random number in a range",
|
||||||
.syntax = "RAND([min][,max])",
|
.syntax = "RAND([min][,max])",
|
||||||
@@ -107,16 +100,12 @@ struct ast_custom_function acf_rand = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#ifndef BUILTIN_FUNC
|
static char *tdesc = "Random number dialplan function";
|
||||||
|
|
||||||
static char *tdesc = "Generate a random number";
|
|
||||||
|
|
||||||
int unload_module(void)
|
int unload_module(void)
|
||||||
{
|
{
|
||||||
ast_custom_function_unregister(&acf_rand);
|
ast_custom_function_unregister(&acf_rand);
|
||||||
|
|
||||||
STANDARD_HANGUP_LOCALUSERS;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,16 +121,10 @@ char *description(void)
|
|||||||
|
|
||||||
int usecount(void)
|
int usecount(void)
|
||||||
{
|
{
|
||||||
int res;
|
return 0;
|
||||||
|
|
||||||
STANDARD_USECOUNT(res);
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char *key()
|
char *key()
|
||||||
{
|
{
|
||||||
return ASTERISK_GPL_KEY;
|
return ASTERISK_GPL_KEY;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
@@ -1,68 +1,93 @@
|
|||||||
/*
|
/*
|
||||||
* Asterisk -- An open source telephony toolkit.
|
* Asterisk -- An open source telephony toolkit.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006, Digium, Inc.
|
* Copyright (C) 2006, Digium, Inc.
|
||||||
* Copyright (C) 2006, Claude Patry
|
* Copyright (C) 2006, Claude Patry
|
||||||
*
|
*
|
||||||
* See http://www.asterisk.org for more information about
|
* See http://www.asterisk.org for more information about
|
||||||
* the Asterisk project. Please do not directly contact
|
* the Asterisk project. Please do not directly contact
|
||||||
* any of the maintainers of this project for assistance;
|
* any of the maintainers of this project for assistance;
|
||||||
* the project provides a web site, mailing lists and IRC
|
* the project provides a web site, mailing lists and IRC
|
||||||
* channels for your use.
|
* channels for your use.
|
||||||
*
|
*
|
||||||
* This program is free software, distributed under the terms of
|
* This program is free software, distributed under the terms of
|
||||||
* the GNU General Public License Version 2. See the LICENSE file
|
* the GNU General Public License Version 2. See the LICENSE file
|
||||||
* at the top of the source tree.
|
* at the top of the source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*! \file
|
/*! \file
|
||||||
*
|
*
|
||||||
* \brief SHA1 digest related dialplan functions
|
* \brief SHA1 digest related dialplan functions
|
||||||
*
|
*
|
||||||
* \author Claude Patry <cpatry@gmail.com>
|
* \author Claude Patry <cpatry@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include "asterisk.h"
|
#include "asterisk.h"
|
||||||
|
|
||||||
/* ASTERISK_FILE_VERSION(__FILE__, "$Revision: 8403 $") */
|
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
||||||
|
|
||||||
#include "asterisk/channel.h"
|
#include "asterisk/module.h"
|
||||||
#include "asterisk/pbx.h"
|
#include "asterisk/channel.h"
|
||||||
#include "asterisk/logger.h"
|
#include "asterisk/pbx.h"
|
||||||
#include "asterisk/utils.h"
|
#include "asterisk/logger.h"
|
||||||
#include "asterisk/app.h"
|
#include "asterisk/utils.h"
|
||||||
|
#include "asterisk/app.h"
|
||||||
static char *builtin_function_sha1(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
|
|
||||||
{
|
static char *sha1(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
|
||||||
if (ast_strlen_zero(data)) {
|
{
|
||||||
ast_log(LOG_WARNING, "Syntax: SHA1(<data>) - missing argument!\n");
|
if (ast_strlen_zero(data)) {
|
||||||
return NULL;
|
ast_log(LOG_WARNING, "Syntax: SHA1(<data>) - missing argument!\n");
|
||||||
}
|
return NULL;
|
||||||
|
}
|
||||||
if (len >= 41)
|
|
||||||
ast_sha1_hash(buf, data);
|
if (len >= 41)
|
||||||
else {
|
ast_sha1_hash(buf, data);
|
||||||
ast_log(LOG_ERROR, "Insufficient space to produce SHA1 hash result (%d < 41)\n", len);
|
else {
|
||||||
*buf = '\0';
|
ast_log(LOG_ERROR, "Insufficient space to produce SHA1 hash result (%d < 41)\n", len);
|
||||||
}
|
*buf = '\0';
|
||||||
return buf;
|
}
|
||||||
}
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef BUILTIN_FUNC
|
|
||||||
static
|
static struct ast_custom_function sha1_function = {
|
||||||
#endif
|
.name = "SHA1",
|
||||||
struct ast_custom_function sha1_function = {
|
.synopsis = "Computes a SHA1 digest",
|
||||||
.name = "SHA1",
|
.syntax = "SHA1(<data>)",
|
||||||
.synopsis = "Computes a SHA1 digest",
|
.read = sha1,
|
||||||
.syntax = "SHA1(<data>)",
|
.desc = "Generate a SHA1 digest via the SHA1 algorythm.\n"
|
||||||
.read = builtin_function_sha1,
|
" Example: Set(sha1hash=${SHA1(junky)})\n"
|
||||||
.desc = "Generate a SHA1 digest via the SHA1 algorythm.\n"
|
" Sets the asterisk variable sha1hash to the string '60fa5675b9303eb62f99a9cd47f9f5837d18f9a0'\n"
|
||||||
" Example: Set(sha1hash=${SHA1(junky)})\n"
|
" which is known as his hash\n",
|
||||||
" Sets the asterisk variable sha1hash to the string '60fa5675b9303eb62f99a9cd47f9f5837d18f9a0'\n"
|
};
|
||||||
" which is known as his hash\n",
|
|
||||||
};
|
static char *tdesc = "SHA-1 computation dialplan function";
|
||||||
|
|
||||||
|
int unload_module(void)
|
||||||
|
{
|
||||||
|
return ast_custom_function_unregister(&sha1_function);
|
||||||
|
}
|
||||||
|
|
||||||
|
int load_module(void)
|
||||||
|
{
|
||||||
|
return ast_custom_function_register(&sha1_function);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *description(void)
|
||||||
|
{
|
||||||
|
return tdesc;
|
||||||
|
}
|
||||||
|
|
||||||
|
int usecount(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *key()
|
||||||
|
{
|
||||||
|
return ASTERISK_GPL_KEY;
|
||||||
|
}
|
||||||
|
@@ -32,8 +32,9 @@
|
|||||||
|
|
||||||
#include "asterisk.h"
|
#include "asterisk.h"
|
||||||
|
|
||||||
/* ASTERISK_FILE_VERSION(__FILE__, "$Revision$") */
|
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
||||||
|
|
||||||
|
#include "asterisk/module.h"
|
||||||
#include "asterisk/channel.h"
|
#include "asterisk/channel.h"
|
||||||
#include "asterisk/pbx.h"
|
#include "asterisk/pbx.h"
|
||||||
#include "asterisk/logger.h"
|
#include "asterisk/logger.h"
|
||||||
@@ -69,17 +70,14 @@ static char *function_fieldqty(struct ast_channel *chan, char *cmd, char *data,
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef BUILTIN_FUNC
|
static struct ast_custom_function fieldqty_function = {
|
||||||
static
|
|
||||||
#endif
|
|
||||||
struct ast_custom_function fieldqty_function = {
|
|
||||||
.name = "FIELDQTY",
|
.name = "FIELDQTY",
|
||||||
.synopsis = "Count the fields, with an arbitrary delimiter",
|
.synopsis = "Count the fields, with an arbitrary delimiter",
|
||||||
.syntax = "FIELDQTY(<varname>,<delim>)",
|
.syntax = "FIELDQTY(<varname>,<delim>)",
|
||||||
.read = function_fieldqty,
|
.read = function_fieldqty,
|
||||||
};
|
};
|
||||||
|
|
||||||
static char *builtin_function_filter(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
|
static char *filter(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
|
||||||
{
|
{
|
||||||
char *parse;
|
char *parse;
|
||||||
AST_DECLARE_APP_ARGS(args,
|
AST_DECLARE_APP_ARGS(args,
|
||||||
@@ -109,17 +107,14 @@ static char *builtin_function_filter(struct ast_channel *chan, char *cmd, char *
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef BUILTIN_FUNC
|
static struct ast_custom_function filter_function = {
|
||||||
static
|
|
||||||
#endif
|
|
||||||
struct ast_custom_function filter_function = {
|
|
||||||
.name = "FILTER",
|
.name = "FILTER",
|
||||||
.synopsis = "Filter the string to include only the allowed characters",
|
.synopsis = "Filter the string to include only the allowed characters",
|
||||||
.syntax = "FILTER(<allowed-chars>,<string>)",
|
.syntax = "FILTER(<allowed-chars>,<string>)",
|
||||||
.read = builtin_function_filter,
|
.read = filter,
|
||||||
};
|
};
|
||||||
|
|
||||||
static char *builtin_function_regex(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
|
static char *regex(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
|
||||||
{
|
{
|
||||||
char *parse;
|
char *parse;
|
||||||
AST_DECLARE_APP_ARGS(args,
|
AST_DECLARE_APP_ARGS(args,
|
||||||
@@ -154,17 +149,14 @@ static char *builtin_function_regex(struct ast_channel *chan, char *cmd, char *d
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef BUILTIN_FUNC
|
static struct ast_custom_function regex_function = {
|
||||||
static
|
|
||||||
#endif
|
|
||||||
struct ast_custom_function regex_function = {
|
|
||||||
.name = "REGEX",
|
.name = "REGEX",
|
||||||
.synopsis = "Regular Expression: Returns 1 if data matches regular expression.",
|
.synopsis = "Regular Expression: Returns 1 if data matches regular expression.",
|
||||||
.syntax = "REGEX(\"<regular expression>\" <data>)",
|
.syntax = "REGEX(\"<regular expression>\" <data>)",
|
||||||
.read = builtin_function_regex,
|
.read = regex,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void builtin_function_array(struct ast_channel *chan, char *cmd, char *data, const char *value)
|
static void array(struct ast_channel *chan, char *cmd, char *data, const char *value)
|
||||||
{
|
{
|
||||||
AST_DECLARE_APP_ARGS(arg1,
|
AST_DECLARE_APP_ARGS(arg1,
|
||||||
AST_APP_ARG(var)[100];
|
AST_APP_ARG(var)[100];
|
||||||
@@ -211,14 +203,11 @@ static void builtin_function_array(struct ast_channel *chan, char *cmd, char *da
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef BUILTIN_FUNC
|
static struct ast_custom_function array_function = {
|
||||||
static
|
|
||||||
#endif
|
|
||||||
struct ast_custom_function array_function = {
|
|
||||||
.name = "ARRAY",
|
.name = "ARRAY",
|
||||||
.synopsis = "Allows setting multiple variables at once",
|
.synopsis = "Allows setting multiple variables at once",
|
||||||
.syntax = "ARRAY(var1[,var2[...][,varN]])",
|
.syntax = "ARRAY(var1[,var2[...][,varN]])",
|
||||||
.write = builtin_function_array,
|
.write = array,
|
||||||
.desc =
|
.desc =
|
||||||
"The comma-separated list passed as a value to which the function is set will\n"
|
"The comma-separated list passed as a value to which the function is set will\n"
|
||||||
"be interpreted as a set of values to which the comma-separated list of\n"
|
"be interpreted as a set of values to which the comma-separated list of\n"
|
||||||
@@ -228,7 +217,7 @@ struct ast_custom_function array_function = {
|
|||||||
"entire argument, since Set can take multiple arguments itself.\n",
|
"entire argument, since Set can take multiple arguments itself.\n",
|
||||||
};
|
};
|
||||||
|
|
||||||
static char *builtin_function_len(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
|
static char *len(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
|
||||||
{
|
{
|
||||||
int length = 0;
|
int length = 0;
|
||||||
if (data) {
|
if (data) {
|
||||||
@@ -238,14 +227,11 @@ static char *builtin_function_len(struct ast_channel *chan, char *cmd, char *dat
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef BUILTIN_FUNC
|
static struct ast_custom_function len_function = {
|
||||||
static
|
|
||||||
#endif
|
|
||||||
struct ast_custom_function len_function = {
|
|
||||||
.name = "LEN",
|
.name = "LEN",
|
||||||
.synopsis = "Returns the length of the argument given",
|
.synopsis = "Returns the length of the argument given",
|
||||||
.syntax = "LEN(<string>)",
|
.syntax = "LEN(<string>)",
|
||||||
.read = builtin_function_len,
|
.read = len,
|
||||||
};
|
};
|
||||||
|
|
||||||
static char *acf_strftime(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
|
static char *acf_strftime(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
|
||||||
@@ -286,10 +272,7 @@ static char *acf_strftime(struct ast_channel *chan, char *cmd, char *data, char
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef BUILTIN_FUNC
|
static struct ast_custom_function strftime_function = {
|
||||||
static
|
|
||||||
#endif
|
|
||||||
struct ast_custom_function strftime_function = {
|
|
||||||
.name = "STRFTIME",
|
.name = "STRFTIME",
|
||||||
.synopsis = "Returns the current date/time in a specified format.",
|
.synopsis = "Returns the current date/time in a specified format.",
|
||||||
.syntax = "STRFTIME([<epoch>][,[timezone][,format]])",
|
.syntax = "STRFTIME([<epoch>][,[timezone][,format]])",
|
||||||
@@ -330,10 +313,7 @@ static char *acf_strptime(struct ast_channel *chan, char *cmd, char *data, char
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef BUILTIN_FUNC
|
static struct ast_custom_function strptime_function = {
|
||||||
static
|
|
||||||
#endif
|
|
||||||
struct ast_custom_function strptime_function = {
|
|
||||||
.name = "STRPTIME",
|
.name = "STRPTIME",
|
||||||
.synopsis = "Returns the epoch of the arbitrary date/time string structured as described in the format.",
|
.synopsis = "Returns the epoch of the arbitrary date/time string structured as described in the format.",
|
||||||
.syntax = "STRPTIME(<datetime>|<timezone>|<format>)",
|
.syntax = "STRPTIME(<datetime>|<timezone>|<format>)",
|
||||||
@@ -361,10 +341,7 @@ static char *function_eval(struct ast_channel *chan, char *cmd, char *data, char
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef BUILTIN_FUNC
|
static struct ast_custom_function eval_function = {
|
||||||
static
|
|
||||||
#endif
|
|
||||||
struct ast_custom_function eval_function = {
|
|
||||||
.name = "EVAL",
|
.name = "EVAL",
|
||||||
.synopsis = "Evaluate stored variables.",
|
.synopsis = "Evaluate stored variables.",
|
||||||
.syntax = "EVAL(<variable>)",
|
.syntax = "EVAL(<variable>)",
|
||||||
@@ -380,3 +357,59 @@ struct ast_custom_function eval_function = {
|
|||||||
.read = function_eval,
|
.read = function_eval,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static char *tdesc = "String handling dialplan functions";
|
||||||
|
|
||||||
|
int unload_module(void)
|
||||||
|
{
|
||||||
|
int res = 0;
|
||||||
|
|
||||||
|
res |= ast_custom_function_unregister(&fieldqty_function);
|
||||||
|
res |= ast_custom_function_unregister(&filter_function);
|
||||||
|
res |= ast_custom_function_unregister(®ex_function);
|
||||||
|
res |= ast_custom_function_unregister(&array_function);
|
||||||
|
res |= ast_custom_function_unregister(&len_function);
|
||||||
|
res |= ast_custom_function_unregister(&strftime_function);
|
||||||
|
res |= ast_custom_function_unregister(&strptime_function);
|
||||||
|
res |= ast_custom_function_unregister(&eval_function);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
int load_module(void)
|
||||||
|
{
|
||||||
|
int res = 0;
|
||||||
|
|
||||||
|
res |= ast_custom_function_register(&fieldqty_function);
|
||||||
|
res |= ast_custom_function_register(&filter_function);
|
||||||
|
res |= ast_custom_function_register(®ex_function);
|
||||||
|
res |= ast_custom_function_register(&array_function);
|
||||||
|
res |= ast_custom_function_register(&len_function);
|
||||||
|
res |= ast_custom_function_register(&strftime_function);
|
||||||
|
res |= ast_custom_function_register(&strptime_function);
|
||||||
|
res |= ast_custom_function_register(&eval_function);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *description(void)
|
||||||
|
{
|
||||||
|
return tdesc;
|
||||||
|
}
|
||||||
|
|
||||||
|
int usecount(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *key()
|
||||||
|
{
|
||||||
|
return ASTERISK_GPL_KEY;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Local Variables:
|
||||||
|
mode: C
|
||||||
|
c-file-style: "linux"
|
||||||
|
indent-tabs-mode: nil
|
||||||
|
End:
|
||||||
|
*/
|
||||||
|
@@ -30,8 +30,9 @@
|
|||||||
|
|
||||||
#include "asterisk.h"
|
#include "asterisk.h"
|
||||||
|
|
||||||
/* ASTERISK_FILE_VERSION(__FILE__, "$Revision$") */
|
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
||||||
|
|
||||||
|
#include "asterisk/module.h"
|
||||||
#include "asterisk/channel.h"
|
#include "asterisk/channel.h"
|
||||||
#include "asterisk/pbx.h"
|
#include "asterisk/pbx.h"
|
||||||
#include "asterisk/logger.h"
|
#include "asterisk/logger.h"
|
||||||
@@ -39,7 +40,7 @@
|
|||||||
#include "asterisk/app.h"
|
#include "asterisk/app.h"
|
||||||
#include "asterisk/options.h"
|
#include "asterisk/options.h"
|
||||||
|
|
||||||
static char *builtin_function_timeout_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
|
static char *timeout_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
|
||||||
{
|
{
|
||||||
time_t myt;
|
time_t myt;
|
||||||
|
|
||||||
@@ -81,7 +82,7 @@ static char *builtin_function_timeout_read(struct ast_channel *chan, char *cmd,
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void builtin_function_timeout_write(struct ast_channel *chan, char *cmd, char *data, const char *value)
|
static void timeout_write(struct ast_channel *chan, char *cmd, char *data, const char *value)
|
||||||
{
|
{
|
||||||
int x;
|
int x;
|
||||||
char timestr[64];
|
char timestr[64];
|
||||||
@@ -135,10 +136,7 @@ static void builtin_function_timeout_write(struct ast_channel *chan, char *cmd,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef BUILTIN_FUNC
|
static struct ast_custom_function timeout_function = {
|
||||||
static
|
|
||||||
#endif
|
|
||||||
struct ast_custom_function timeout_function = {
|
|
||||||
.name = "TIMEOUT",
|
.name = "TIMEOUT",
|
||||||
.synopsis = "Gets or sets timeouts on the channel.",
|
.synopsis = "Gets or sets timeouts on the channel.",
|
||||||
.syntax = "TIMEOUT(timeouttype)",
|
.syntax = "TIMEOUT(timeouttype)",
|
||||||
@@ -165,10 +163,37 @@ struct ast_custom_function timeout_function = {
|
|||||||
" extension in this amount of time, control will pass to the\n"
|
" extension in this amount of time, control will pass to the\n"
|
||||||
" 't' extension if it exists, and if not the call would be\n"
|
" 't' extension if it exists, and if not the call would be\n"
|
||||||
" terminated. The default timeout is 10 seconds.\n",
|
" terminated. The default timeout is 10 seconds.\n",
|
||||||
.read = builtin_function_timeout_read,
|
.read = timeout_read,
|
||||||
.write = builtin_function_timeout_write,
|
.write = timeout_write,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static char *tdesc = "Channel timeout dialplan functions";
|
||||||
|
|
||||||
|
int unload_module(void)
|
||||||
|
{
|
||||||
|
return ast_custom_function_unregister(&timeout_function);
|
||||||
|
}
|
||||||
|
|
||||||
|
int load_module(void)
|
||||||
|
{
|
||||||
|
return ast_custom_function_register(&timeout_function);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *description(void)
|
||||||
|
{
|
||||||
|
return tdesc;
|
||||||
|
}
|
||||||
|
|
||||||
|
int usecount(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *key()
|
||||||
|
{
|
||||||
|
return ASTERISK_GPL_KEY;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Local Variables:
|
Local Variables:
|
||||||
mode: C
|
mode: C
|
||||||
|
@@ -34,17 +34,17 @@
|
|||||||
|
|
||||||
#include "asterisk.h"
|
#include "asterisk.h"
|
||||||
|
|
||||||
/* ASTERISK_FILE_VERSION(__FILE__, "$Revision$") */
|
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
||||||
|
|
||||||
|
#include "asterisk/module.h"
|
||||||
#include "asterisk/channel.h"
|
#include "asterisk/channel.h"
|
||||||
#include "asterisk/pbx.h"
|
#include "asterisk/pbx.h"
|
||||||
#include "asterisk/logger.h"
|
#include "asterisk/logger.h"
|
||||||
#include "asterisk/utils.h"
|
#include "asterisk/utils.h"
|
||||||
#include "asterisk/app.h"
|
#include "asterisk/app.h"
|
||||||
#include "asterisk/module.h"
|
|
||||||
|
|
||||||
/*! \brief builtin_function_uriencode: Encode URL according to RFC 2396 */
|
/*! \brief uriencode: Encode URL according to RFC 2396 */
|
||||||
static char *builtin_function_uriencode(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
|
static char *uriencode(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
|
||||||
{
|
{
|
||||||
char uri[BUFSIZ];
|
char uri[BUFSIZ];
|
||||||
|
|
||||||
@@ -59,8 +59,8 @@ static char *builtin_function_uriencode(struct ast_channel *chan, char *cmd, cha
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!\brief builtin_function_uridecode: Decode URI according to RFC 2396 */
|
/*!\brief uridecode: Decode URI according to RFC 2396 */
|
||||||
static char *builtin_function_uridecode(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
|
static char *uridecode(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
|
||||||
{
|
{
|
||||||
if (ast_strlen_zero(data)) {
|
if (ast_strlen_zero(data)) {
|
||||||
ast_log(LOG_WARNING, "Syntax: URIDECODE(<data>) - missing argument!\n");
|
ast_log(LOG_WARNING, "Syntax: URIDECODE(<data>) - missing argument!\n");
|
||||||
@@ -73,28 +73,21 @@ static char *builtin_function_uridecode(struct ast_channel *chan, char *cmd, cha
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef BUILTIN_FUNC
|
static struct ast_custom_function urldecode_function = {
|
||||||
static
|
|
||||||
#endif
|
|
||||||
struct ast_custom_function urldecode_function = {
|
|
||||||
.name = "URIDECODE",
|
.name = "URIDECODE",
|
||||||
.synopsis = "Decodes an URI-encoded string.",
|
.synopsis = "Decodes an URI-encoded string.",
|
||||||
.syntax = "URIDECODE(<data>)",
|
.syntax = "URIDECODE(<data>)",
|
||||||
.read = builtin_function_uridecode,
|
.read = uridecode,
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef BUILTIN_FUNC
|
static struct ast_custom_function urlencode_function = {
|
||||||
static
|
|
||||||
#endif
|
|
||||||
struct ast_custom_function urlencode_function = {
|
|
||||||
.name = "URIENCODE",
|
.name = "URIENCODE",
|
||||||
.synopsis = "Encodes a string to URI-safe encoding.",
|
.synopsis = "Encodes a string to URI-safe encoding.",
|
||||||
.syntax = "URIENCODE(<data>)",
|
.syntax = "URIENCODE(<data>)",
|
||||||
.read = builtin_function_uriencode,
|
.read = uriencode,
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef BUILTIN_FUNC
|
static char *tdesc = "URI encode/decode dialplan functions";
|
||||||
static char *tdesc = "URI encode/decode functions";
|
|
||||||
|
|
||||||
int unload_module(void)
|
int unload_module(void)
|
||||||
{
|
{
|
||||||
@@ -120,4 +113,3 @@ char *key()
|
|||||||
{
|
{
|
||||||
return ASTERISK_GPL_KEY;
|
return ASTERISK_GPL_KEY;
|
||||||
}
|
}
|
||||||
#endif /* BUILTIN_FUNC */
|
|
||||||
|
@@ -1,75 +0,0 @@
|
|||||||
/*
|
|
||||||
* Asterisk -- An open source telephony toolkit.
|
|
||||||
*
|
|
||||||
* Copyright (C) 1999 - 2005, Digium, Inc.
|
|
||||||
*
|
|
||||||
* Kevin P. Fleming <kpfleming@digium.com>
|
|
||||||
*
|
|
||||||
* See http://www.asterisk.org for more information about
|
|
||||||
* the Asterisk project. Please do not directly contact
|
|
||||||
* any of the maintainers of this project for assistance;
|
|
||||||
* the project provides a web site, mailing lists and IRC
|
|
||||||
* channels for your use.
|
|
||||||
*
|
|
||||||
* This program is free software, distributed under the terms of
|
|
||||||
* the GNU General Public License Version 2. See the LICENSE file
|
|
||||||
* at the top of the source tree.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*! \file
|
|
||||||
*
|
|
||||||
* \brief Builtin dialplan functions
|
|
||||||
*
|
|
||||||
* \author Kevin P. Fleming <kpfleming@digium.com>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include "asterisk.h"
|
|
||||||
|
|
||||||
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|
||||||
|
|
||||||
#include "asterisk/module.h"
|
|
||||||
#include "asterisk/pbx.h"
|
|
||||||
#include "pbx_functions.h"
|
|
||||||
|
|
||||||
static char *tdesc = "Builtin dialplan functions";
|
|
||||||
|
|
||||||
int unload_module(void)
|
|
||||||
{
|
|
||||||
int x;
|
|
||||||
|
|
||||||
for (x = 0; x < (sizeof(builtins) / sizeof(builtins[0])); x++) {
|
|
||||||
ast_custom_function_unregister(builtins[x]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int load_module(void)
|
|
||||||
{
|
|
||||||
int x;
|
|
||||||
|
|
||||||
for (x = 0; x < (sizeof(builtins) / sizeof(builtins[0])); x++) {
|
|
||||||
ast_custom_function_register(builtins[x]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *description(void)
|
|
||||||
{
|
|
||||||
return tdesc;
|
|
||||||
}
|
|
||||||
|
|
||||||
int usecount(void)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *key()
|
|
||||||
{
|
|
||||||
return ASTERISK_GPL_KEY;
|
|
||||||
}
|
|
Reference in New Issue
Block a user