diff options
Diffstat (limited to '1.2-netsec/funcs')
-rw-r--r-- | 1.2-netsec/funcs/Makefile | 82 | ||||
-rw-r--r-- | 1.2-netsec/funcs/func_callerid.c | 153 | ||||
-rw-r--r-- | 1.2-netsec/funcs/func_cdr.c | 108 | ||||
-rw-r--r-- | 1.2-netsec/funcs/func_db.c | 169 | ||||
-rw-r--r-- | 1.2-netsec/funcs/func_enum.c | 243 | ||||
-rw-r--r-- | 1.2-netsec/funcs/func_env.c | 71 | ||||
-rw-r--r-- | 1.2-netsec/funcs/func_groupcount.c | 192 | ||||
-rw-r--r-- | 1.2-netsec/funcs/func_language.c | 75 | ||||
-rw-r--r-- | 1.2-netsec/funcs/func_logic.c | 201 | ||||
-rw-r--r-- | 1.2-netsec/funcs/func_math.c | 251 | ||||
-rw-r--r-- | 1.2-netsec/funcs/func_md5.c | 103 | ||||
-rw-r--r-- | 1.2-netsec/funcs/func_moh.c | 56 | ||||
-rw-r--r-- | 1.2-netsec/funcs/func_strings.c | 229 | ||||
-rw-r--r-- | 1.2-netsec/funcs/func_timeout.c | 177 | ||||
-rw-r--r-- | 1.2-netsec/funcs/func_uri.c | 121 | ||||
-rw-r--r-- | 1.2-netsec/funcs/pbx_functions.c | 74 |
16 files changed, 0 insertions, 2305 deletions
diff --git a/1.2-netsec/funcs/Makefile b/1.2-netsec/funcs/Makefile deleted file mode 100644 index 14bbd80a3..000000000 --- a/1.2-netsec/funcs/Makefile +++ /dev/null @@ -1,82 +0,0 @@ -# -# Asterisk -- A telephony toolkit for Linux. -# -# Makefile for dialplan functions -# -# Copyright (C) 2005, Digium -# -# Kevin P. Fleming <kpfleming@digium.com> -# -# This program is free software, distributed under the terms of -# the GNU General Public License -# - -FUNCS=pbx_functions.so - -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 - -STANDALONE_FUNCS=$(filter-out $(BUILTINS),$(patsubst %.c,%.o,$(wildcard func*.c))) - -FUNCS+=$(STANDALONE_FUNCS:.o=.so) - -FUNC_SOURCES=$(BUILTINS:.o=.c) - -FUNC_STRUCTS=$(shell grep 'struct ast_custom_function' $(FUNC_SOURCES) | awk '{print $$3};') - -ifeq (${OSARCH},CYGWIN) -CYGSOLINK=-Wl,--out-implib=lib$@.a -Wl,--export-all-symbols -CYGSOLIB=-L.. -L. -lasterisk.dll -else -CFLAGS+=-fPIC -endif - -ifeq ($(findstring BSD,${OSARCH}),BSD) - CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include -L$(CROSS_COMPILE_TARGET)/usr/local/lib -endif - -all: $(FUNCS) - -clean: - rm -f *.so *.o .depend pbx_functions.h - -%.so : %.o - $(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} - -install: all - for x in $(FUNCS); do $(INSTALL) -m 755 $$x $(DESTDIR)$(MODULES_DIR) ; done - -ifneq ($(wildcard .depend),) - include .depend -endif - -depend: .depend - -.depend: pbx_functions.h - ../build_tools/mkdep $(CFLAGS) `ls *.c` - -env: - env diff --git a/1.2-netsec/funcs/func_callerid.c b/1.2-netsec/funcs/func_callerid.c deleted file mode 100644 index 264c404dd..000000000 --- a/1.2-netsec/funcs/func_callerid.c +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Asterisk -- An open source telephony toolkit. - * - * Copyright (C) 1999 - 2005, Digium, Inc. - * - * 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 Caller ID related dialplan functions - * - */ - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <sys/types.h> - -#include "asterisk.h" - -ASTERISK_FILE_VERSION(__FILE__, "$Revision$") - -#ifndef BUILTIN_FUNC -#include "asterisk/module.h" -#endif /* BUILTIN_FUNC */ -#include "asterisk/channel.h" -#include "asterisk/pbx.h" -#include "asterisk/logger.h" -#include "asterisk/utils.h" -#include "asterisk/app.h" -#include "asterisk/options.h" -#include "asterisk/callerid.h" - -static char *callerid_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) -{ - if (!strncasecmp("all", data, 3)) { - snprintf(buf, len, "\"%s\" <%s>", chan->cid.cid_name ? chan->cid.cid_name : "", chan->cid.cid_num ? chan->cid.cid_num : ""); - } else if (!strncasecmp("name", data, 4)) { - if (chan->cid.cid_name) { - ast_copy_string(buf, chan->cid.cid_name, len); - } - } else if (!strncasecmp("num", data, 3) || !strncasecmp("number", data, 6)) { - if (chan->cid.cid_num) { - ast_copy_string(buf, chan->cid.cid_num, len); - } - } else if (!strncasecmp("ani", data, 3)) { - if (chan->cid.cid_ani) { - ast_copy_string(buf, chan->cid.cid_ani, len); - } - } else if (!strncasecmp("dnid", data, 4)) { - if (chan->cid.cid_dnid) { - ast_copy_string(buf, chan->cid.cid_dnid, len); - } - } else if (!strncasecmp("rdnis", data, 5)) { - if (chan->cid.cid_rdnis) { - ast_copy_string(buf, chan->cid.cid_rdnis, len); - } - } else { - ast_log(LOG_ERROR, "Unknown callerid data type.\n"); - } - - return buf; -} - -static void callerid_write(struct ast_channel *chan, char *cmd, char *data, const char *value) -{ - if (!value) - return; - - if (!strncasecmp("all", data, 3)) { - char name[256]; - char num[256]; - if (!ast_callerid_split(value, name, sizeof(name), num, sizeof(num))) - ast_set_callerid(chan, num, name, num); - } else if (!strncasecmp("name", data, 4)) { - ast_set_callerid(chan, NULL, value, NULL); - } else if (!strncasecmp("num", data, 3) || !strncasecmp("number", data, 6)) { - ast_set_callerid(chan, value, NULL, NULL); - } else if (!strncasecmp("ani", data, 3)) { - ast_set_callerid(chan, NULL, NULL, value); - } else if (!strncasecmp("dnid", data, 4)) { - /* do we need to lock chan here? */ - if (chan->cid.cid_dnid) - free(chan->cid.cid_dnid); - chan->cid.cid_dnid = ast_strlen_zero(value) ? NULL : strdup(value); - } else if (!strncasecmp("rdnis", data, 5)) { - /* do we need to lock chan here? */ - if (chan->cid.cid_rdnis) - free(chan->cid.cid_rdnis); - chan->cid.cid_rdnis = ast_strlen_zero(value) ? NULL : strdup(value); - } else { - ast_log(LOG_ERROR, "Unknown callerid data type.\n"); - } -} - -#ifndef BUILTIN_FUNC -static -#endif /* BUILTIN_FUNC */ -struct ast_custom_function callerid_function = { - .name = "CALLERID", - .synopsis = "Gets or sets Caller*ID data on the channel.", - .syntax = "CALLERID(datatype)", - .desc = "Gets or sets Caller*ID data on the channel. The allowable datatypes\n" - "are \"all\", \"name\", \"num\", \"ANI\", \"DNID\", \"RDNIS\".\n", - .read = callerid_read, - .write = callerid_write, -}; - -#ifndef BUILTIN_FUNC -static char *tdesc = "Caller ID related dialplan function"; - -int unload_module(void) -{ - return ast_custom_function_unregister(&callerid_function); -} - -int load_module(void) -{ - return ast_custom_function_register(&callerid_function); -} - -char *description(void) -{ - return tdesc; -} - -int usecount(void) -{ - return 0; -} - -char *key() -{ - return ASTERISK_GPL_KEY; -} -#endif /* BUILTIN_FUNC */ - -/* -Local Variables: -mode: C -c-file-style: "linux" -indent-tabs-mode: nil -End: -*/ diff --git a/1.2-netsec/funcs/func_cdr.c b/1.2-netsec/funcs/func_cdr.c deleted file mode 100644 index 3e4696e18..000000000 --- a/1.2-netsec/funcs/func_cdr.c +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Asterisk -- An open source telephony toolkit. - * - * Copyright (C) 1999 - 2005, Digium, Inc. - * - * Portions Copyright (C) 2005, Anthony Minessale II - * - * 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 Call Detail Record related dialplan functions - * - */ - -#include <stdlib.h> -#include <string.h> -#include <sys/types.h> - -#include "asterisk.h" - -/* ASTERISK_FILE_VERSION(__FILE__, "$Revision$") */ - -#include "asterisk/channel.h" -#include "asterisk/pbx.h" -#include "asterisk/logger.h" -#include "asterisk/utils.h" -#include "asterisk/app.h" -#include "asterisk/cdr.h" - -static char *builtin_function_cdr_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) -{ - char *ret; - char *mydata; - int argc; - char *argv[2]; - int recursive = 0; - - if (ast_strlen_zero(data)) - return NULL; - - if (!chan->cdr) - return NULL; - - mydata = ast_strdupa(data); - argc = ast_app_separate_args(mydata, '|', argv, sizeof(argv) / sizeof(argv[0])); - - /* check for a trailing flags argument */ - if (argc > 1) { - argc--; - if (strchr(argv[argc], 'r')) - recursive = 1; - } - - ast_cdr_getvar(chan->cdr, argv[0], &ret, buf, len, recursive); - - return ret; -} - -static void builtin_function_cdr_write(struct ast_channel *chan, char *cmd, char *data, const char *value) -{ - char *mydata; - int argc; - char *argv[2]; - int recursive = 0; - - if (ast_strlen_zero(data) || !value) - return; - - mydata = ast_strdupa(data); - argc = ast_app_separate_args(mydata, '|', argv, sizeof(argv) / sizeof(argv[0])); - - /* check for a trailing flags argument */ - if (argc > 1) { - argc--; - if (strchr(argv[argc], 'r')) - recursive = 1; - } - - if (!strcasecmp(argv[0], "accountcode")) - ast_cdr_setaccount(chan, value); - else if (!strcasecmp(argv[0], "userfield")) - ast_cdr_setuserfield(chan, value); - else if (chan->cdr) - ast_cdr_setvar(chan->cdr, argv[0], value, recursive); -} - -#ifndef BUILTIN_FUNC -static -#endif -struct ast_custom_function cdr_function = { - .name = "CDR", - .synopsis = "Gets or sets a CDR variable", - .desc= "Option 'r' searches the entire stack of CDRs on the channel\n", - .syntax = "CDR(<name>[|options])", - .read = builtin_function_cdr_read, - .write = builtin_function_cdr_write, -}; - diff --git a/1.2-netsec/funcs/func_db.c b/1.2-netsec/funcs/func_db.c deleted file mode 100644 index bc135a6b3..000000000 --- a/1.2-netsec/funcs/func_db.c +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Asterisk -- An open source telephony toolkit. - * - * Copyright (C) 2005, Russell Bryant <russelb@clemson.edu> - * - * func_db.c adapted from the old app_db.c, copyright by the following people - * Copyright (C) 2005, Mark Spencer <markster@digium.com> - * Copyright (C) 2003, Jefferson Noxon <jeff@debian.org> - * - * 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 Functions for interaction with the Asterisk database - * - */ - -#include <stdlib.h> -#include <string.h> -#include <sys/types.h> -#include <regex.h> - -#include "asterisk.h" - -/* ASTERISK_FILE_VERSION(__FILE__, "$Revision$") */ - -#include "asterisk/channel.h" -#include "asterisk/pbx.h" -#include "asterisk/logger.h" -#include "asterisk/options.h" -#include "asterisk/utils.h" -#include "asterisk/app.h" -#include "asterisk/astdb.h" - -static char *function_db_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) -{ - int argc; - char *args; - char *argv[2]; - char *family; - char *key; - - if (ast_strlen_zero(data)) { - ast_log(LOG_WARNING, "DB requires an argument, DB(<family>/<key>)\n"); - return buf; - } - - args = ast_strdupa(data); - argc = ast_app_separate_args(args, '/', argv, sizeof(argv) / sizeof(argv[0])); - - if (argc > 1) { - family = argv[0]; - key = argv[1]; - } else { - ast_log(LOG_WARNING, "DB requires an argument, DB(<family>/<key>)\n"); - return buf; - } - - if (ast_db_get(family, key, buf, len-1)) { - ast_log(LOG_DEBUG, "DB: %s/%s not found in database.\n", family, key); - } else - pbx_builtin_setvar_helper(chan, "DB_RESULT", buf); - - - return buf; -} - -static void function_db_write(struct ast_channel *chan, char *cmd, char *data, const char *value) -{ - int argc; - char *args; - char *argv[2]; - char *family; - char *key; - - if (ast_strlen_zero(data)) { - ast_log(LOG_WARNING, "DB requires an argument, DB(<family>/<key>)=<value>\n"); - return; - } - - args = ast_strdupa(data); - argc = ast_app_separate_args(args, '/', argv, sizeof(argv) / sizeof(argv[0])); - - if (argc > 1) { - family = argv[0]; - key = argv[1]; - } else { - ast_log(LOG_WARNING, "DB requires an argument, DB(<family>/<key>)=value\n"); - return; - } - - if (ast_db_put(family, key, (char*)value)) { - ast_log(LOG_WARNING, "DB: Error writing value to database.\n"); - } -} - -#ifndef BUILTIN_FUNC -static -#endif -struct ast_custom_function db_function = { - .name = "DB", - .synopsis = "Read or Write from/to the Asterisk database", - .syntax = "DB(<family>/<key>)", - .desc = "This function will read or write a value from/to the Asterisk database.\n" - "DB(...) will read a value from the database, while DB(...)=value\n" - "will write a value to the database. On a read, this function\n" - "returns the value from the datase, or NULL if it does not exist.\n" - "On a write, this function will always return NULL. Reading a database value\n" - "will also set the variable DB_RESULT.\n", - .read = function_db_read, - .write = function_db_write, -}; - -static char *function_db_exists(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) -{ - int argc; - char *args; - char *argv[2]; - char *family; - char *key; - - if (ast_strlen_zero(data)) { - ast_log(LOG_WARNING, "DB_EXISTS requires an argument, DB(<family>/<key>)\n"); - return buf; - } - - args = ast_strdupa(data); - argc = ast_app_separate_args(args, '/', argv, sizeof(argv) / sizeof(argv[0])); - - if (argc > 1) { - family = argv[0]; - key = argv[1]; - } else { - ast_log(LOG_WARNING, "DB_EXISTS requires an argument, DB(<family>/<key>)\n"); - return buf; - } - - if (ast_db_get(family, key, buf, len-1)) - ast_copy_string(buf, "0", len); - else { - pbx_builtin_setvar_helper(chan, "DB_RESULT", buf); - ast_copy_string(buf, "1", len); - } - - return buf; -} - -#ifndef BUILTIN_FUNC -static -#endif -struct ast_custom_function db_exists_function = { - .name = "DB_EXISTS", - .synopsis = "Check to see if a key exists in the Asterisk database", - .syntax = "DB_EXISTS(<family>/<key>)", - .desc = "This function will check to see if a key exists in the Asterisk\n" - "database. If it exists, the function will return \"1\". If not,\n" - "it will return \"0\". Checking for existence of a database key will\n" - "also set the variable DB_RESULT to the key's value if it exists.\n", - .read = function_db_exists, -}; diff --git a/1.2-netsec/funcs/func_enum.c b/1.2-netsec/funcs/func_enum.c deleted file mode 100644 index 07655a789..000000000 --- a/1.2-netsec/funcs/func_enum.c +++ /dev/null @@ -1,243 +0,0 @@ -/* - * Asterisk -- An open source telephony toolkit. - * - * Copyright (C) 1999 - 2005 - * - * Mark Spencer <markster@digium.com> - * Oleksiy Krivoshey <oleksiyk@gmail.com> - * Russell Bryant <russelb@clemson.edu> - * - * 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 ENUM Functions - * \arg See also AstENUM - */ - -#include <stdlib.h> -#include <stdio.h> - -#include "asterisk.h" - -#ifndef BUILTIN_FUNC -#include "asterisk/module.h" -#endif /* BUILTIN_FUNC */ -#include "asterisk/channel.h" -#include "asterisk/pbx.h" -#include "asterisk/utils.h" - -#include "asterisk/lock.h" -#include "asterisk/file.h" -#include "asterisk/logger.h" - -#include "asterisk/pbx.h" -#include "asterisk/options.h" - -#include "asterisk/enum.h" - -static char* synopsis = "Syntax: ENUMLOOKUP(number[,Method-type[,options|record#[,zone-suffix]]])\n"; - -STANDARD_LOCAL_USER; - -LOCAL_USER_DECL; - -static char *function_enum(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) -{ - int res=0; - char tech[80]; - char dest[256] = ""; - char *zone; - char *options; - struct localuser *u; - char *params[4]; - char *p = data; - char *s; - int i = 0; - - - if (ast_strlen_zero(data)) { - ast_log(LOG_WARNING, synopsis); - return ""; - } - - do { - if(i>3){ - ast_log(LOG_WARNING, synopsis); - return ""; - } - params[i++] = p; - p = strchr(p, '|'); - if(p){ - *p = '\0'; - p++; - } - } while(p); - - if(i < 1){ - ast_log(LOG_WARNING, synopsis); - return ""; - } - - if( (i > 1 && strlen(params[1]) == 0) || i < 2){ - ast_copy_string(tech, "sip", sizeof(tech)); - } else { - ast_copy_string(tech, params[1], sizeof(tech)); - } - - if( (i > 3 && strlen(params[3]) == 0) || i<4){ - zone = "e164.arpa"; - } else { - zone = params[3]; - } - - if( (i > 2 && strlen(params[2]) == 0) || i<3){ - options = "1"; - } else { - options = params[2]; - } - - /* strip any '-' signs from number */ - p = params[0]; - /* - while(*p == '+'){ - p++; - } - */ - s = p; - i = 0; - while(*p && *s){ - if(*s == '-'){ - s++; - } else { - p[i++] = *s++; - } - } - p[i] = 0; - - LOCAL_USER_ACF_ADD(u); - - res = ast_get_enum(chan, p, dest, sizeof(dest), tech, sizeof(tech), zone, options); - - LOCAL_USER_REMOVE(u); - - p = strchr(dest, ':'); - if(p && strncasecmp(tech, "ALL", sizeof(tech))) { - ast_copy_string(buf, p+1, sizeof(dest)); - } else { - ast_copy_string(buf, dest, sizeof(dest)); - } - - return buf; -} - -#ifndef BUILTIN_FUNC -static -#endif -struct ast_custom_function enum_function = { - .name = "ENUMLOOKUP", - .synopsis = "ENUMLOOKUP allows for general or specific querying of NAPTR records" - " or counts of NAPTR types for ENUM or ENUM-like DNS pointers", - .syntax = "ENUMLOOKUP(number[,Method-type[,options|record#[,zone-suffix]]])", - .desc = "Option 'c' returns an integer count of the number of NAPTRs of a certain RR type.\n" - "Combination of 'c' and Method-type of 'ALL' will return a count of all NAPTRs for the record.\n" - "Defaults are: Method-type=sip, no options, record=1, zone-suffix=e164.arpa\n\n" - "For more information, see README.enum", - .read = function_enum, -}; - -static char *function_txtcidname(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) -{ - int res; - char tech[80]; - char txt[256] = ""; - char dest[80]; - struct localuser *u; - - LOCAL_USER_ACF_ADD(u); - - buf[0] = '\0'; - - if (ast_strlen_zero(data)) { - ast_log(LOG_WARNING, "TXTCIDNAME requires an argument (number)\n"); - LOCAL_USER_REMOVE(u); - return buf; - } - - res = ast_get_txt(chan, data, dest, sizeof(dest), tech, sizeof(tech), txt, sizeof(txt)); - - if (!ast_strlen_zero(txt)) - ast_copy_string(buf, txt, len); - - LOCAL_USER_REMOVE(u); - - return buf; -} - -#ifndef BUILTIN_FUNC -static -#endif -struct ast_custom_function txtcidname_function = { - .name = "TXTCIDNAME", - .synopsis = "TXTCIDNAME looks up a caller name via DNS", - .syntax = "TXTCIDNAME(<number>)", - .desc = "This function looks up the given phone number in DNS to retrieve\n" - "the caller id name. The result will either be blank or be the value\n" - "found in the TXT record in DNS.\n", - .read = function_txtcidname, -}; - -#ifndef BUILTIN_FUNC - -static char *tdesc = "ENUM Related Functions"; - -int unload_module(void) -{ - ast_custom_function_unregister(&enum_function); - ast_custom_function_unregister(&txtcidname_function); - - STANDARD_HANGUP_LOCALUSERS; - - return 0; -} - -int load_module(void) -{ - int res; - - res = ast_custom_function_register(&enum_function); - if (!res) - ast_custom_function_register(&txtcidname_function); - - return res; -} - -char *description(void) -{ - return tdesc; -} - -int usecount(void) -{ - int res; - - STANDARD_USECOUNT(res); - - return res; -} - -char *key() -{ - return ASTERISK_GPL_KEY; -} -#endif /* BUILTIN_FUNC */ - diff --git a/1.2-netsec/funcs/func_env.c b/1.2-netsec/funcs/func_env.c deleted file mode 100644 index 4906c7d11..000000000 --- a/1.2-netsec/funcs/func_env.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Asterisk -- An open source telephony toolkit. - * - * Copyright (C) 1999 - 2005, Digium, Inc. - * - * 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 Environment related dialplan functions - * - */ - -#include <stdlib.h> -#include <string.h> -#include <sys/types.h> - -#include "asterisk.h" - -/* ASTERISK_FILE_VERSION(__FILE__, "$Revision$") */ - -#include "asterisk/channel.h" -#include "asterisk/pbx.h" -#include "asterisk/logger.h" -#include "asterisk/utils.h" -#include "asterisk/app.h" - -static char *builtin_function_env_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) -{ - char *ret = ""; - - if (data) { - ret = getenv(data); - if (!ret) - ret = ""; - } - ast_copy_string(buf, ret, len); - - return buf; -} - -static void builtin_function_env_write(struct ast_channel *chan, char *cmd, char *data, const char *value) -{ - if (!ast_strlen_zero(data)) { - if (!ast_strlen_zero(value)) { - setenv(data, value, 1); - } else { - unsetenv(data); - } - } -} - -#ifndef BUILTIN_FUNC -static -#endif -struct ast_custom_function env_function = { - .name = "ENV", - .synopsis = "Gets or sets the environment variable specified", - .syntax = "ENV(<envname>)", - .read = builtin_function_env_read, - .write = builtin_function_env_write, -}; diff --git a/1.2-netsec/funcs/func_groupcount.c b/1.2-netsec/funcs/func_groupcount.c deleted file mode 100644 index 0f07d8327..000000000 --- a/1.2-netsec/funcs/func_groupcount.c +++ /dev/null @@ -1,192 +0,0 @@ -/* - * Asterisk -- An open source telephony toolkit. - * - * Copyright (C) 1999 - 2005, Digium, Inc. - * - * 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 Channel group related dialplan functions - * - */ - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <sys/types.h> - -#include "asterisk.h" - -/* ASTERISK_FILE_VERSION(__FILE__, "$Revision$") */ - -#include "asterisk/channel.h" -#include "asterisk/pbx.h" -#include "asterisk/logger.h" -#include "asterisk/utils.h" -#include "asterisk/app.h" - -static char *group_count_function_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) -{ - int count; - char group[80] = ""; - char category[80] = ""; - char *grp; - - ast_app_group_split_group(data, group, sizeof(group), category, sizeof(category)); - - if (ast_strlen_zero(group)) { - if ((grp = pbx_builtin_getvar_helper(chan, category))) - ast_copy_string(group, grp, sizeof(group)); - else - ast_log(LOG_NOTICE, "No group could be found for channel '%s'\n", chan->name); - } - - count = ast_app_group_get_count(group, category); - snprintf(buf, len, "%d", count); - - return buf; -} - -#ifndef BUILTIN_FUNC -static -#endif -struct ast_custom_function group_count_function = { - .name = "GROUP_COUNT", - .syntax = "GROUP_COUNT([groupname][@category])", - .synopsis = "Counts the number of channels in the specified group", - .desc = "Calculates the group count for the specified group, or uses the\n" - "channel's current group if not specifed (and non-empty).\n", - .read = group_count_function_read, -}; - -static char *group_match_count_function_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) -{ - int count; - char group[80] = ""; - char category[80] = ""; - - ast_app_group_split_group(data, group, sizeof(group), category, sizeof(category)); - - if (!ast_strlen_zero(group)) { - count = ast_app_group_match_get_count(group, category); - snprintf(buf, len, "%d", count); - } - - return buf; -} - -#ifndef BUILTIN_FUNC -static -#endif -struct ast_custom_function group_match_count_function = { - .name = "GROUP_MATCH_COUNT", - .syntax = "GROUP_MATCH_COUNT(groupmatch[@category])", - .synopsis = "Counts the number of channels in the groups matching the specified pattern", - .desc = "Calculates the group count for all groups that match the specified pattern.\n" - "Uses standard regular expression matching (see regex(7)).\n", - .read = group_match_count_function_read, - .write = NULL, -}; - -static char *group_function_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) -{ - char varname[256]; - char *group; - - if (!ast_strlen_zero(data)) { - snprintf(varname, sizeof(varname), "%s_%s", GROUP_CATEGORY_PREFIX, data); - } else { - ast_copy_string(varname, GROUP_CATEGORY_PREFIX, sizeof(varname)); - } - - group = pbx_builtin_getvar_helper(chan, varname); - if (group) - ast_copy_string(buf, group, len); - - return buf; -} - -static void group_function_write(struct ast_channel *chan, char *cmd, char *data, const char *value) -{ - char grpcat[256]; - - if (!ast_strlen_zero(data)) { - snprintf(grpcat, sizeof(grpcat), "%s@%s", value, data); - } else { - ast_copy_string(grpcat, value, sizeof(grpcat)); - } - - if (ast_app_group_set_channel(chan, grpcat)) - ast_log(LOG_WARNING, "Setting a group requires an argument (group name)\n"); -} - -#ifndef BUILTIN_FUNC -static -#endif -struct ast_custom_function group_function = { - .name = "GROUP", - .syntax = "GROUP([category])", - .synopsis = "Gets or sets the channel group.", - .desc = "Gets or sets the channel group.\n", - .read = group_function_read, - .write = group_function_write, -}; - -static char *group_list_function_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) -{ - struct ast_var_t *current; - struct varshead *headp; - char tmp1[1024] = ""; - char tmp2[1024] = ""; - - headp=&chan->varshead; - AST_LIST_TRAVERSE(headp,current,entries) { - if (!strncmp(ast_var_name(current), GROUP_CATEGORY_PREFIX "_", strlen(GROUP_CATEGORY_PREFIX) + 1)) { - if (!ast_strlen_zero(tmp1)) { - ast_copy_string(tmp2, tmp1, sizeof(tmp2)); - snprintf(tmp1, sizeof(tmp1), "%s %s@%s", tmp2, ast_var_value(current), (ast_var_name(current) + strlen(GROUP_CATEGORY_PREFIX) + 1)); - } else { - snprintf(tmp1, sizeof(tmp1), "%s@%s", ast_var_value(current), (ast_var_name(current) + strlen(GROUP_CATEGORY_PREFIX) + 1)); - } - } else if (!strcmp(ast_var_name(current), GROUP_CATEGORY_PREFIX)) { - if (!ast_strlen_zero(tmp1)) { - ast_copy_string(tmp2, tmp1, sizeof(tmp2)); - snprintf(tmp1, sizeof(tmp1), "%s %s", tmp2, ast_var_value(current)); - } else { - snprintf(tmp1, sizeof(tmp1), "%s", ast_var_value(current)); - } - } - } - ast_copy_string(buf, tmp1, len); - return buf; -} - -#ifndef BUILTIN_FUNC -static -#endif -struct ast_custom_function group_list_function = { - .name = "GROUP_LIST", - .syntax = "GROUP_LIST()", - .synopsis = "Gets a list of the groups set on a channel.", - .desc = "Gets a list of the groups set on a channel.\n", - .read = group_list_function_read, - .write = NULL, -}; - -/* -Local Variables: -mode: C -c-file-style: "linux" -indent-tabs-mode: nil -End: -*/ diff --git a/1.2-netsec/funcs/func_language.c b/1.2-netsec/funcs/func_language.c deleted file mode 100644 index ea829a2f4..000000000 --- a/1.2-netsec/funcs/func_language.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Asterisk -- An open source telephony toolkit. - * - * Copyright (C) 1999 - 2005, Digium, Inc. - * - * 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 Language related dialplan functions - * - */ - -#include <stdlib.h> -#include <string.h> -#include <sys/types.h> - -#include "asterisk.h" - -/* ASTERISK_FILE_VERSION(__FILE__, "$Revision$") */ - -#include "asterisk/channel.h" -#include "asterisk/pbx.h" -#include "asterisk/logger.h" -#include "asterisk/utils.h" -#include "asterisk/app.h" - -static char *builtin_function_language_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) -{ - ast_copy_string(buf, chan->language, len); - - return buf; -} - -static void builtin_function_language_write(struct ast_channel *chan, char *cmd, char *data, const char *value) -{ - if (value) - ast_copy_string(chan->language, value, sizeof(chan->language)); -} - -#ifndef BUILTIN_FUNC -static -#endif -struct ast_custom_function language_function = { - .name = "LANGUAGE", - .synopsis = "Gets or sets the channel's language.", - .syntax = "LANGUAGE()", - .desc = "Gets or sets the channel language. This information is used for the\n" - "syntax in generation of numbers, and to choose a natural language file\n" - "when available. For example, if language is set to 'fr' and the file\n" - "'demo-congrats' is requested to be played, if the file\n" - "'fr/demo-congrats' exists, then it will play that file, and if not\n" - "will play the normal 'demo-congrats'. For some language codes,\n" - "changing the language also changes the syntax of some Asterisk\n" - "functions, like SayNumber.\n", - .read = builtin_function_language_read, - .write = builtin_function_language_write, -}; - -/* -Local Variables: -mode: C -c-file-style: "linux" -indent-tabs-mode: nil -End: -*/ diff --git a/1.2-netsec/funcs/func_logic.c b/1.2-netsec/funcs/func_logic.c deleted file mode 100644 index f748ba939..000000000 --- a/1.2-netsec/funcs/func_logic.c +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Asterisk -- An open source telephony toolkit. - * - * Copyright (C) 1999 - 2005, Digium, Inc. - * Portions Copyright (C) 2005, Anthony Minessale II - * - * 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 Conditional logic dialplan functions - * - */ - -#include <stdlib.h> -#include <string.h> -#include <sys/types.h> - -#include "asterisk.h" - -/* ASTERISK_FILE_VERSION(__FILE__, "$Revision$") */ - -#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) -{ - return data && *data ? "0" : "1"; -} - -static char *builtin_function_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) -{ - struct ast_timing timing; - char *ret; - char *expr; - char *iftrue; - char *iffalse; - - if (!(data = ast_strdupa(data))) { - ast_log(LOG_WARNING, "Memory Error!\n"); - return NULL; - } - - data = ast_strip_quoted(data, "\"", "\""); - expr = strsep(&data, "?"); - iftrue = strsep(&data, ":"); - iffalse = data; - - if (ast_strlen_zero(expr) || !(iftrue || iffalse)) { - ast_log(LOG_WARNING, "Syntax IFTIME(<timespec>?[<true>][:<false>])\n"); - return NULL; - } - - if (!ast_build_timing(&timing, expr)) { - ast_log(LOG_WARNING, "Invalid Time Spec.\n"); - return NULL; - } - - if (iftrue) - iftrue = ast_strip_quoted(iftrue, "\"", "\""); - if (iffalse) - iffalse = ast_strip_quoted(iffalse, "\"", "\""); - - if ((ret = ast_check_timing(&timing) ? iftrue : iffalse)) { - ast_copy_string(buf, ret, len); - ret = buf; - } - - return ret; -} - -static char *builtin_function_if(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) -{ - char *ret; - char *expr; - char *iftrue; - char *iffalse; - - if (!(data = ast_strdupa(data))) { - ast_log(LOG_WARNING, "Memory Error!\n"); - return NULL; - } - - data = ast_strip_quoted(data, "\"", "\""); - expr = strsep(&data, "?"); - iftrue = strsep(&data, ":"); - iffalse = data; - - if (ast_strlen_zero(expr) || !(iftrue || iffalse)) { - ast_log(LOG_WARNING, "Syntax IF(<expr>?[<true>][:<false>])\n"); - return NULL; - } - - expr = ast_strip(expr); - if (iftrue) - iftrue = ast_strip_quoted(iftrue, "\"", "\""); - if (iffalse) - iffalse = ast_strip_quoted(iffalse, "\"", "\""); - - if ((ret = ast_true(expr) ? iftrue : iffalse)) { - ast_copy_string(buf, ret, len); - ret = buf; - } - - return ret; -} - -static char *builtin_function_set(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) -{ - char *varname; - char *val; - - if (!(data = ast_strdupa(data))) { - ast_log(LOG_WARNING, "Memory Error!\n"); - return NULL; - } - - varname = strsep(&data, "="); - val = data; - - if (ast_strlen_zero(varname) || !val) { - ast_log(LOG_WARNING, "Syntax SET(<varname>=[<value>])\n"); - return NULL; - } - - varname = ast_strip(varname); - val = ast_strip(val); - pbx_builtin_setvar_helper(chan, varname, val); - ast_copy_string(buf, val, len); - - return buf; -} - -#ifndef BUILTIN_FUNC -static -#endif -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, -}; - -#ifndef BUILTIN_FUNC -static -#endif -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, -}; - -#ifndef BUILTIN_FUNC -static -#endif -struct ast_custom_function exists_function = { - .name = "EXISTS", - .synopsis = "Existence Test: Returns 1 if exists, 0 otherwise", - .syntax = "EXISTS(<data>)", - .read = builtin_function_exists, -}; - -#ifndef BUILTIN_FUNC -static -#endif -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, -}; - - -#ifndef BUILTIN_FUNC -static -#endif -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, -}; diff --git a/1.2-netsec/funcs/func_math.c b/1.2-netsec/funcs/func_math.c deleted file mode 100644 index e8a49acc8..000000000 --- a/1.2-netsec/funcs/func_math.c +++ /dev/null @@ -1,251 +0,0 @@ -/* - * Asterisk -- An open source telephony toolkit. - * - * Copyright (C) 2004 - 2005, Andy Powell - * - * Updated by Mark Spencer <markster@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 Maths relatad dialplan functions - * - */ - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <sys/types.h> - -#include "asterisk.h" - -/* ASTERISK_FILE_VERSION(__FILE__, "$Revision$") */ - -#include "asterisk/channel.h" -#include "asterisk/pbx.h" -#include "asterisk/logger.h" -#include "asterisk/utils.h" -#include "asterisk/app.h" -#include "asterisk/config.h" - -enum TypeOfFunctions -{ - ADDFUNCTION, - DIVIDEFUNCTION, - MULTIPLYFUNCTION, - SUBTRACTFUNCTION, - MODULUSFUNCTION, - - GTFUNCTION, - LTFUNCTION, - GTEFUNCTION, - LTEFUNCTION, - EQFUNCTION -}; - -enum TypeOfResult -{ - FLOAT_RESULT, - INT_RESULT, - HEX_RESULT, - CHAR_RESULT -}; - - -static char *builtin_function_math(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) -{ - int argc; - char *argv[2]; - char *args; - float fnum1; - float fnum2; - float ftmp = 0; - char *op; - int iaction=-1; - int type_of_result=FLOAT_RESULT; - - /* dunno, big calulations :D */ - char user_result[30]; - - char *mvalue1, *mvalue2=NULL, *mtype_of_result; - - if (ast_strlen_zero(data)) { - ast_log(LOG_WARNING, "Syntax: Math(<number1><op><number 2>[,<type_of_result>]) - missing argument!\n"); - return NULL; - } - - args = ast_strdupa(data); - argc = ast_app_separate_args(args, '|', argv, sizeof(argv) / sizeof(argv[0])); - - if (argc < 1) { - ast_log(LOG_WARNING, "Syntax: Math(<number1><op><number 2>[,<type_of_result>]) - missing argument!\n"); - return NULL; - } - - mvalue1 = argv[0]; - - if ((op = strchr(mvalue1, '+'))) { - iaction = ADDFUNCTION; - *op = '\0'; - } else if ((op = strchr(mvalue1, '-'))) { - iaction = SUBTRACTFUNCTION; - *op = '\0'; - } else if ((op = strchr(mvalue1, '*'))) { - iaction = MULTIPLYFUNCTION; - *op = '\0'; - } else if ((op = strchr(mvalue1, '/'))) { - iaction = DIVIDEFUNCTION; - *op = '\0'; - } else if ((op = strchr(mvalue1, '%'))) { - iaction = MODULUSFUNCTION; - *op = '\0'; - } else if ((op = strchr(mvalue1, '>'))) { - iaction = GTFUNCTION; - *op = '\0'; - if (*(op+1) == '=') { - *++op = '\0'; - iaction = GTEFUNCTION; - } - } else if ((op = strchr(mvalue1, '<'))) { - iaction = LTFUNCTION; - *op = '\0'; - if (*(op+1) == '=') { - *++op = '\0'; - iaction = LTEFUNCTION; - } - } else if ((op = strchr(mvalue1, '='))) { - iaction = GTFUNCTION; - *op = '\0'; - if (*(op+1) == '=') { - *++op = '\0'; - iaction = EQFUNCTION; - } else - op = NULL; - } - - if (op) - mvalue2 = op + 1; - - /* detect wanted type of result */ - mtype_of_result = argv[1]; - if (mtype_of_result) - { - if (!strcasecmp(mtype_of_result,"float") || !strcasecmp(mtype_of_result,"f")) - type_of_result=FLOAT_RESULT; - else if (!strcasecmp(mtype_of_result,"int") || !strcasecmp(mtype_of_result,"i")) - type_of_result=INT_RESULT; - else if (!strcasecmp(mtype_of_result,"hex") || !strcasecmp(mtype_of_result,"h")) - type_of_result=HEX_RESULT; - else if (!strcasecmp(mtype_of_result,"char") || !strcasecmp(mtype_of_result,"c")) - type_of_result=CHAR_RESULT; - else - { - ast_log(LOG_WARNING, "Unknown type of result requested '%s'.\n", mtype_of_result); - return NULL; - } - } - - if (!mvalue1 || !mvalue2) { - ast_log(LOG_WARNING, "Supply all the parameters - just this once, please\n"); - return NULL; - } - - if (sscanf(mvalue1, "%f", &fnum1) != 1) { - ast_log(LOG_WARNING, "'%s' is not a valid number\n", mvalue1); - return NULL; - } - - if (sscanf(mvalue2, "%f", &fnum2) != 1) { - ast_log(LOG_WARNING, "'%s' is not a valid number\n", mvalue2); - return NULL; - } - - switch (iaction) { - case ADDFUNCTION : - ftmp = fnum1 + fnum2; - break; - case DIVIDEFUNCTION : - if (fnum2 <= 0) - ftmp = 0; /* can't do a divide by 0 */ - else - ftmp = (fnum1 / fnum2); - break; - case MULTIPLYFUNCTION : - ftmp = (fnum1 * fnum2); - break; - case SUBTRACTFUNCTION : - ftmp = (fnum1 - fnum2); - break; - case MODULUSFUNCTION : - { - int inum1 = fnum1; - int inum2 = fnum2; - - ftmp = (inum1 % inum2); - - break; - } - case GTFUNCTION : - ast_copy_string (user_result, (fnum1 > fnum2)?"TRUE":"FALSE", sizeof (user_result)); - break; - case LTFUNCTION : - ast_copy_string (user_result, (fnum1 < fnum2)?"TRUE":"FALSE", sizeof (user_result)); - break; - case GTEFUNCTION : - ast_copy_string (user_result, (fnum1 >= fnum2)?"TRUE":"FALSE", sizeof (user_result)); - break; - case LTEFUNCTION : - ast_copy_string (user_result, (fnum1 <= fnum2)?"TRUE":"FALSE", sizeof (user_result)); - break; - case EQFUNCTION : - ast_copy_string (user_result, (fnum1 == fnum2)?"TRUE":"FALSE", sizeof (user_result)); - break; - default : - ast_log(LOG_WARNING, "Something happened that neither of us should be proud of %d\n", iaction); - return NULL; - } - - if (iaction < GTFUNCTION || iaction > EQFUNCTION) { - if (type_of_result == FLOAT_RESULT) - snprintf(user_result, sizeof(user_result), "%f", ftmp); - else if (type_of_result == INT_RESULT) - snprintf(user_result, sizeof(user_result), "%i", (int) ftmp); - else if (type_of_result == HEX_RESULT) - snprintf(user_result, sizeof(user_result), "%x", (unsigned int) ftmp); - else if (type_of_result == CHAR_RESULT) - snprintf(user_result, sizeof(user_result), "%c", (unsigned char) ftmp); - } - - ast_copy_string(buf, user_result, len); - - return buf; -} - -#ifndef BUILTIN_FUNC -static -#endif /* BUILTIN_FUNC */ -struct ast_custom_function math_function = { - .name = "MATH", - .synopsis = "Performs Mathematical Functions", - .syntax = "MATH(<number1><op><number 2>[,<type_of_result>])", - .desc = "Perform calculation on number 1 to number 2. Valid ops are: \n" - " +,-,/,*,%,<,>,>=,<=,==\n" - "and behave as their C equivalents.\n" - "<type_of_result> - wanted type of result:\n" - " f, float - float(default)\n" - " i, int - integer,\n" - " h, hex - hex,\n" - " c, char - char\n" - "Example: Set(i=${MATH(123%16,int)}) - sets var i=11", - .read = builtin_function_math -}; diff --git a/1.2-netsec/funcs/func_md5.c b/1.2-netsec/funcs/func_md5.c deleted file mode 100644 index 910e44260..000000000 --- a/1.2-netsec/funcs/func_md5.c +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Asterisk -- An open source telephony toolkit. - * - * Copyright (C) 2005, Digium, Inc. - * Copyright (C) 2005, Olle E. Johansson, Edvina.net - * Copyright (C) 2005, Russell Bryant <russelb@clemson.edu> - * - * 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 MD5 digest related dialplan functions - * - */ - -#include <stdlib.h> -#include <string.h> -#include <sys/types.h> - -#include "asterisk.h" - -/* ASTERISK_FILE_VERSION(__FILE__, "$Revision$") */ - -#include "asterisk/channel.h" -#include "asterisk/pbx.h" -#include "asterisk/logger.h" -#include "asterisk/utils.h" -#include "asterisk/app.h" - -static char *builtin_function_md5(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) -{ - char md5[33]; - - if (ast_strlen_zero(data)) { - ast_log(LOG_WARNING, "Syntax: MD5(<data>) - missing argument!\n"); - return NULL; - } - - ast_md5_hash(md5, data); - ast_copy_string(buf, md5, len); - - return buf; -} - -static char *builtin_function_checkmd5(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) -{ - int argc; - char *argv[2]; - char *args; - char newmd5[33]; - - if (!data || ast_strlen_zero(data)) { - ast_log(LOG_WARNING, "Syntax: CHECK_MD5(<digest>,<data>) - missing argument!\n"); - return NULL; - } - - args = ast_strdupa(data); - argc = ast_app_separate_args(args, '|', argv, sizeof(argv) / sizeof(argv[0])); - - if (argc < 2) { - ast_log(LOG_WARNING, "Syntax: CHECK_MD5(<digest>,<data>) - missing argument!\n"); - return NULL; - } - - ast_md5_hash(newmd5, argv[1]); - - if (!strcasecmp(newmd5, argv[0])) /* they match */ - ast_copy_string(buf, "1", len); - else - ast_copy_string(buf, "0", len); - - return buf; -} - -#ifndef BUILTIN_FUNC -static -#endif -struct ast_custom_function md5_function = { - .name = "MD5", - .synopsis = "Computes an MD5 digest", - .syntax = "MD5(<data>)", - .read = builtin_function_md5, -}; - -#ifndef BUILTIN_FUNC -static -#endif -struct ast_custom_function checkmd5_function = { - .name = "CHECK_MD5", - .synopsis = "Checks an MD5 digest", - .desc = "Returns 1 on a match, 0 otherwise\n", - .syntax = "CHECK_MD5(<digest>,<data>)", - .read = builtin_function_checkmd5, -}; diff --git a/1.2-netsec/funcs/func_moh.c b/1.2-netsec/funcs/func_moh.c deleted file mode 100644 index 25aa73af7..000000000 --- a/1.2-netsec/funcs/func_moh.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Asterisk -- An open source telephony toolkit. - * - * Copyright (C) 1999 - 2005, Digium, Inc. - * - * Russell Bryant <russelb@clemson.edu> - * - * 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 Functions for reading or setting the MusicOnHold class - * - */ - -#include <stdlib.h> - -#include "asterisk.h" - -#include "asterisk/channel.h" -#include "asterisk/pbx.h" -#include "asterisk/utils.h" - -static char *function_moh_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) -{ - ast_copy_string(buf, chan->musicclass, len); - - return buf; -} - -static void function_moh_write(struct ast_channel *chan, char *cmd, char *data, const char *value) -{ - ast_copy_string(chan->musicclass, value, sizeof(chan->musicclass)); -} - -#ifndef BUILTIN_FUNC -static -#endif -struct ast_custom_function moh_function = { - .name = "MUSICCLASS", - .synopsis = "Read or Set the MusicOnHold class", - .syntax = "MUSICCLASS()", - .desc = "This function will read or set the music on hold class for a channel.\n", - .read = function_moh_read, - .write = function_moh_write, -}; - diff --git a/1.2-netsec/funcs/func_strings.c b/1.2-netsec/funcs/func_strings.c deleted file mode 100644 index 503611bbe..000000000 --- a/1.2-netsec/funcs/func_strings.c +++ /dev/null @@ -1,229 +0,0 @@ -/* - * Asterisk -- An open source telephony toolkit. - * - * Copyright (C) 2005, Digium, Inc. - * Portions Copyright (C) 2005, Tilghman Lesher. All rights reserved. - * Portions Copyright (C) 2005, Anthony Minessale II - * - * 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 String manipulation dialplan functions - * - */ - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <sys/types.h> -#include <regex.h> - -#include "asterisk.h" - -/* ASTERISK_FILE_VERSION(__FILE__, "$Revision$") */ - -#include "asterisk/channel.h" -#include "asterisk/pbx.h" -#include "asterisk/logger.h" -#include "asterisk/utils.h" -#include "asterisk/app.h" -#include "asterisk/localtime.h" - -static char *function_fieldqty(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) -{ - char *varname, *varval, workspace[256]; - char *delim = ast_strdupa(data); - int fieldcount = 0; - - if (delim) { - varname = strsep(&delim, "|"); - pbx_retrieve_variable(chan, varname, &varval, workspace, sizeof(workspace), NULL); - if (delim) { - while (strsep(&varval, delim)) - fieldcount++; - } else if (!ast_strlen_zero(varval)) { - fieldcount = 1; - } - snprintf(buf, len, "%d", fieldcount); - } else { - ast_log(LOG_ERROR, "Out of memory\n"); - strncpy(buf, "1", len); - } - return buf; -} - -#ifndef BUILTIN_FUNC -static -#endif -struct ast_custom_function fieldqty_function = { - .name = "FIELDQTY", - .synopsis = "Count the fields, with an arbitrary delimiter", - .syntax = "FIELDQTY(<varname>,<delim>)", - .read = function_fieldqty, -}; - -static char *builtin_function_regex(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) -{ - char *arg, *earg = NULL, *tmp, errstr[256] = ""; - int errcode; - regex_t regexbuf; - - ast_copy_string(buf, "0", len); - - tmp = ast_strdupa(data); - if (!tmp) { - ast_log(LOG_ERROR, "Out of memory in %s(%s)\n", cmd, data); - return buf; - } - - /* Regex in quotes */ - arg = strchr(tmp, '"'); - if (arg) { - arg++; - earg = strrchr(arg, '"'); - if (earg) { - *earg++ = '\0'; - /* Skip over any spaces before the data we are checking */ - while (*earg == ' ') - earg++; - } - } else { - arg = tmp; - } - - if ((errcode = regcomp(®exbuf, arg, REG_EXTENDED | REG_NOSUB))) { - regerror(errcode, ®exbuf, errstr, sizeof(errstr)); - ast_log(LOG_WARNING, "Malformed input %s(%s): %s\n", cmd, data, errstr); - } else { - if (!regexec(®exbuf, earg ? earg : "", 0, NULL, 0)) - ast_copy_string(buf, "1", len); - } - regfree(®exbuf); - - return buf; -} - -#ifndef BUILTIN_FUNC -static -#endif -struct ast_custom_function regex_function = { - .name = "REGEX", - .synopsis = "Regular Expression: Returns 1 if data matches regular expression.", - .syntax = "REGEX(\"<regular expression>\" <data>)", - .read = builtin_function_regex, -}; - -static char *builtin_function_len(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) -{ - int length = 0; - if (data) { - length = strlen(data); - } - snprintf(buf, len, "%d", length); - return buf; -} - -#ifndef BUILTIN_FUNC -static -#endif -struct ast_custom_function len_function = { - .name = "LEN", - .synopsis = "Returns the length of the argument given", - .syntax = "LEN(<string>)", - .read = builtin_function_len, -}; - -static char *acf_strftime(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) -{ - char *format, *epoch, *timezone = NULL; - long epochi; - struct tm time; - - buf[0] = '\0'; - - if (!data) { - ast_log(LOG_ERROR, "Asterisk function STRFTIME() requires an argument.\n"); - return buf; - } - - format = ast_strdupa(data); - if (!format) { - ast_log(LOG_ERROR, "Out of memory\n"); - return buf; - } - - epoch = strsep(&format, "|"); - timezone = strsep(&format, "|"); - - if (ast_strlen_zero(epoch) || !sscanf(epoch, "%ld", &epochi)) { - struct timeval tv = ast_tvnow(); - epochi = tv.tv_sec; - } - - ast_localtime(&epochi, &time, timezone); - - if (!format) { - format = "%c"; - } - - if (!strftime(buf, len, format, &time)) { - ast_log(LOG_WARNING, "C function strftime() output nothing?!!\n"); - } - buf[len - 1] = '\0'; - - return buf; -} - -#ifndef BUILTIN_FUNC -static -#endif -struct ast_custom_function strftime_function = { - .name = "STRFTIME", - .synopsis = "Returns the current date/time in a specified format.", - .syntax = "STRFTIME([<epoch>][,[timezone][,format]])", - .read = acf_strftime, -}; - -static char *function_eval(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) -{ - memset(buf, 0, len); - - if (ast_strlen_zero(data)) { - ast_log(LOG_WARNING, "EVAL requires an argument: EVAL(<string>)\n"); - return buf; - } - - pbx_substitute_variables_helper(chan, data, buf, len - 1); - - return buf; -} - -#ifndef BUILTIN_FUNC -static -#endif -struct ast_custom_function eval_function = { - .name = "EVAL", - .synopsis = "Evaluate stored variables.", - .syntax = "EVAL(<variable>)", - .desc = "Using EVAL basically causes a string to be evaluated twice.\n" - "When a variable or expression is in the dialplan, it will be\n" - "evaluated at runtime. However, if the result of the evaluation\n" - "is in fact a variable or expression, using EVAL will have it\n" - "evaluated a second time. For example, if the variable ${MYVAR}\n" - "contains \"${OTHERVAR}\", then the result of putting ${EVAL(${MYVAR})}\n" - "in the dialplan will be the contents of the variable, OTHERVAR.\n" - "Normally, by just putting ${MYVAR} in the dialplan, you would be\n" - "left with \"${OTHERVAR}\".\n", - .read = function_eval, -}; - diff --git a/1.2-netsec/funcs/func_timeout.c b/1.2-netsec/funcs/func_timeout.c deleted file mode 100644 index 4e9256ef5..000000000 --- a/1.2-netsec/funcs/func_timeout.c +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Asterisk -- An open source telephony toolkit. - * - * Copyright (C) 1999 - 2005, Digium, Inc. - * - * Mark Spencer <markster@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 Channel timeout related dialplan functions - * - */ - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <sys/types.h> - -#include "asterisk.h" - -/* ASTERISK_FILE_VERSION(__FILE__, "$Revision$") */ - -#include "asterisk/channel.h" -#include "asterisk/pbx.h" -#include "asterisk/logger.h" -#include "asterisk/utils.h" -#include "asterisk/app.h" -#include "asterisk/options.h" - -static char *builtin_function_timeout_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) -{ - time_t myt; - - if (!data) { - ast_log(LOG_ERROR, "Must specify type of timeout to get."); - return NULL; - } - - switch(*data) { - case 'a': - case 'A': - if (chan->whentohangup == 0) { - ast_copy_string(buf, "0", len); - } else { - time(&myt); - snprintf(buf, len, "%d", (int) (chan->whentohangup - myt)); - } - break; - - case 'r': - case 'R': - if (chan->pbx) { - snprintf(buf, len, "%d", chan->pbx->rtimeout); - } - break; - - case 'd': - case 'D': - if (chan->pbx) { - snprintf(buf, len, "%d", chan->pbx->dtimeout); - } - break; - - default: - ast_log(LOG_ERROR, "Unknown timeout type specified."); - break; - } - - return buf; -} - -static void builtin_function_timeout_write(struct ast_channel *chan, char *cmd, char *data, const char *value) -{ - int x; - char timestr[64]; - struct tm myt; - - if (!data) { - ast_log(LOG_ERROR, "Must specify type of timeout to set."); - return; - } - - if (!value) - return; - - x = atoi(value); - - switch(*data) { - case 'a': - case 'A': - ast_channel_setwhentohangup(chan, x); - if (option_verbose > 2) { - if (chan->whentohangup) { - strftime(timestr, sizeof(timestr), "%Y-%m-%d %H:%M:%S UTC", gmtime_r(&chan->whentohangup, &myt)); - ast_verbose( VERBOSE_PREFIX_3 "Channel will hangup at %s.\n", timestr); - } else { - ast_verbose( VERBOSE_PREFIX_3 "Channel hangup cancelled.\n"); - } - } - break; - - case 'r': - case 'R': - if (chan->pbx) { - chan->pbx->rtimeout = x; - if (option_verbose > 2) - ast_verbose( VERBOSE_PREFIX_3 "Response timeout set to %d\n", chan->pbx->rtimeout); - } - break; - - case 'd': - case 'D': - if (chan->pbx) { - chan->pbx->dtimeout = x; - if (option_verbose > 2) - ast_verbose( VERBOSE_PREFIX_3 "Digit timeout set to %d\n", chan->pbx->dtimeout); - } - break; - - default: - ast_log(LOG_ERROR, "Unknown timeout type specified."); - break; - } -} - -#ifndef BUILTIN_FUNC -static -#endif -struct ast_custom_function timeout_function = { - .name = "TIMEOUT", - .synopsis = "Gets or sets timeouts on the channel.", - .syntax = "TIMEOUT(timeouttype)", - .desc = "Gets or sets various channel timeouts. The timeouts that can be\n" - "manipulated are:\n" - "\n" - "absolute: The absolute maximum amount of time permitted for a call. A\n" - " setting of 0 disables the timeout.\n" - "\n" - "digit: The maximum amount of time permitted between digits when the\n" - " user is typing in an extension. When this timeout expires,\n" - " after the user has started to type in an extension, the\n" - " extension will be considered complete, and will be\n" - " interpreted. Note that if an extension typed in is valid,\n" - " it will not have to timeout to be tested, so typically at\n" - " the expiry of this timeout, the extension will be considered\n" - " invalid (and thus control would be passed to the 'i'\n" - " extension, or if it doesn't exist the call would be\n" - " terminated). The default timeout is 5 seconds.\n" - "\n" - "response: The maximum amount of time permitted after falling through a\n" - " series of priorities for a channel in which the user may\n" - " begin typing an extension. If the user does not type an\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" - " terminated. The default timeout is 10 seconds.\n", - .read = builtin_function_timeout_read, - .write = builtin_function_timeout_write, -}; - -/* -Local Variables: -mode: C -c-file-style: "linux" -indent-tabs-mode: nil -End: -*/ diff --git a/1.2-netsec/funcs/func_uri.c b/1.2-netsec/funcs/func_uri.c deleted file mode 100644 index f985f38c1..000000000 --- a/1.2-netsec/funcs/func_uri.c +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Asterisk -- An open source telephony toolkit. - * - * Copyright (C) 1999 - 2005, Digium, Inc. - * - * Created by Olle E. Johansson, Edvina.net - * - * 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 URI encoding / decoding - * - * \note For now this code only supports 8 bit characters, not unicode, - which we ultimately will need to support. - * - */ - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <sys/types.h> - -#include "asterisk.h" - -/* ASTERISK_FILE_VERSION(__FILE__, "$Revision$") */ - -#include "asterisk/channel.h" -#include "asterisk/pbx.h" -#include "asterisk/logger.h" -#include "asterisk/utils.h" -#include "asterisk/app.h" -#include "asterisk/module.h" - -/*! \brief builtin_function_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) -{ - char uri[BUFSIZ]; - - if (ast_strlen_zero(data)) { - ast_log(LOG_WARNING, "Syntax: URIENCODE(<data>) - missing argument!\n"); - return NULL; - } - - ast_uri_encode(data, uri, sizeof(uri), 1); - ast_copy_string(buf, uri, len); - - return buf; -} - -/*!\brief builtin_function_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) -{ - if (ast_strlen_zero(data)) { - ast_log(LOG_WARNING, "Syntax: URIDECODE(<data>) - missing argument!\n"); - return NULL; - } - - - ast_copy_string(buf, data, len); - ast_uri_decode(buf); - return buf; -} - -#ifndef BUILTIN_FUNC -static -#endif -struct ast_custom_function urldecode_function = { - .name = "URIDECODE", - .synopsis = "Decodes an URI-encoded string.", - .syntax = "URIDECODE(<data>)", - .read = builtin_function_uridecode, -}; - -#ifndef BUILTIN_FUNC -static -#endif -struct ast_custom_function urlencode_function = { - .name = "URIENCODE", - .synopsis = "Encodes a string to URI-safe encoding.", - .syntax = "URIENCODE(<data>)", - .read = builtin_function_uriencode, -}; - -#ifndef BUILTIN_FUNC -static char *tdesc = "URI encode/decode functions"; - -int unload_module(void) -{ - return ast_custom_function_unregister(&urldecode_function) || ast_custom_function_unregister(&urlencode_function); -} - -int load_module(void) -{ - return ast_custom_function_register(&urldecode_function) || ast_custom_function_register(&urlencode_function); -} - -char *description(void) -{ - return tdesc; -} - -int usecount(void) -{ - return 0; -} - -char *key() -{ - return ASTERISK_GPL_KEY; -} -#endif /* BUILTIN_FUNC */ diff --git a/1.2-netsec/funcs/pbx_functions.c b/1.2-netsec/funcs/pbx_functions.c deleted file mode 100644 index 2d5c519c9..000000000 --- a/1.2-netsec/funcs/pbx_functions.c +++ /dev/null @@ -1,74 +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 - * - */ - -#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; -} |