diff --git a/apps/Makefile b/apps/Makefile index 12d503245931fef02a9dc72092396559bbf73d25..272414f74d9ffc090974a85b17cf1f47b4306c54 100644 --- a/apps/Makefile +++ b/apps/Makefile @@ -11,25 +11,20 @@ # the GNU General Public License # -APPS=app_dial.so app_playback.so app_voicemail.so app_directory.so app_mp3.so\ - app_system.so app_echo.so app_record.so app_image.so app_url.so app_disa.so \ - app_adsiprog.so app_getcpeid.so app_milliwatt.so \ - app_zapateller.so app_setcallerid.so app_festival.so \ - app_queue.so app_senddtmf.so app_parkandannounce.so \ - app_setcidname.so app_lookupcidname.so app_macro.so \ - app_authenticate.so app_softhangup.so app_lookupblacklist.so \ - app_waitforring.so app_privacy.so app_db.so app_chanisavail.so \ - app_enumlookup.so app_transfer.so app_setcidnum.so app_cdr.so \ - app_hasnewvoicemail.so app_sayunixtime.so app_cut.so app_read.so \ - app_setcdruserfield.so app_random.so app_ices.so app_eval.so \ - app_nbscat.so app_sendtext.so app_exec.so \ - app_groupcount.so app_txtcidname.so app_controlplayback.so \ - app_talkdetect.so app_alarmreceiver.so app_userevent.so app_verbose.so \ - app_test.so app_forkcdr.so app_math.so app_realtime.so \ - app_dumpchan.so app_waitforsilence.so app_while.so app_setrdnis.so \ - app_md5.so app_readfile.so app_chanspy.so app_settransfercapability.so \ - app_dictate.so app_externalivr.so app_directed_pickup.so \ - app_mixmonitor.so app_stack.so +APPS=app_adsiprog.so app_alarmreceiver.so app_authenticate.so app_cdr.so \ + app_chanisavail.so app_chanspy.so app_controlplayback.so app_db.so \ + app_dial.so app_dictate.so app_directed_pickup.so app_directory.so \ + app_disa.so app_dumpchan.so app_echo.so app_exec.so app_externalivr.so \ + app_festival.so app_forkcdr.so app_getcpeid.so app_hasnewvoicemail.so \ + app_ices.so app_image.so app_lookupblacklist.so app_lookupcidname.so \ + app_macro.so app_milliwatt.so app_mixmonitor.so app_mp3.so app_nbscat.so \ + app_parkandannounce.so app_playback.so app_privacy.so app_queue.so \ + app_random.so app_read.so app_readfile.so app_realtime.so app_record.so \ + app_sayunixtime.so app_senddtmf.so app_sendtext.so app_setcdruserfield.so \ + app_settransfercapability.so app_softhangup.so app_stack.so app_system.so \ + app_talkdetect.so app_test.so app_transfer.so app_userevent.so app_url.so \ + app_verbose.so app_voicemail.so app_waitforring.so app_waitforsilence.so \ + app_while.so app_zapateller.so # # Obsolete things... diff --git a/apps/app_curl.c b/apps/app_curl.c index 227bea2ddfc8604acccadbc30dbc2a127cbff9fe..02cbd93dc744e3f53cefb74e38c6cd43b3b224f7 100644 --- a/apps/app_curl.c +++ b/apps/app_curl.c @@ -44,20 +44,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") static char *tdesc = "Load external URL"; -static char *app = "Curl"; - -static char *synopsis = "Load an external URL"; - -static char *descrip = -" Curl(URL[|postdata]): This application will request the specified URL.\n" -"It is mainly used for signalling external applications of an event.\n" -"Parameters:\n" -" URL - This is the external URL to request.\n" -" postdata - This information will be treated as POST data.\n" -"This application will set the following variable:\n" -" CURL - This variable will contain the resulting page.\n" -"This application has been deprecated in favor of the CURL function.\n"; - STANDARD_LOCAL_USER; LOCAL_USER_DECL; @@ -117,57 +103,6 @@ static int curl_internal(struct MemoryStruct *chunk, char *url, char *post) return 0; } -static int curl_exec(struct ast_channel *chan, void *data) -{ - int res = 0; - struct localuser *u; - char *info; - struct MemoryStruct chunk = { NULL, 0 }; - static int dep_warning = 0; - AST_DECLARE_APP_ARGS(args, - AST_APP_ARG(url); - AST_APP_ARG(postdata); - ); - - if (!dep_warning) { - ast_log(LOG_WARNING, "The application Curl is deprecated. Please use the CURL() function instead.\n"); - dep_warning = 1; - } - - if (ast_strlen_zero(data)) { - ast_log(LOG_WARNING, "Curl requires an argument (URL)\n"); - return -1; - } - - LOCAL_USER_ADD(u); - - if ((info = ast_strdupa(data))) { - AST_STANDARD_APP_ARGS(args, info); - } else { - ast_log(LOG_ERROR, "Out of memory\n"); - LOCAL_USER_REMOVE(u); - return -1; - } - - if (! curl_internal(&chunk, args.url, args.postdata)) { - if (chunk.memory) { - chunk.memory[chunk.size] = '\0'; - if (chunk.memory[chunk.size - 1] == 10) - chunk.memory[chunk.size - 1] = '\0'; - - pbx_builtin_setvar_helper(chan, "CURL", chunk.memory); - - free(chunk.memory); - } - } else { - ast_log(LOG_ERROR, "Cannot allocate curl structure\n"); - res = -1; - } - - LOCAL_USER_REMOVE(u); - return res; -} - static char *acf_curl_exec(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) { struct localuser *u; @@ -228,7 +163,6 @@ int unload_module(void) int res; res = ast_custom_function_unregister(&acf_curl); - res |= ast_unregister_application(app); STANDARD_HANGUP_LOCALUSERS; @@ -240,7 +174,6 @@ int load_module(void) int res; res = ast_custom_function_register(&acf_curl); - res |= ast_register_application(app, curl_exec, synopsis, descrip); return res; } diff --git a/apps/app_cut.c b/apps/app_cut.c index b6b457ab7d031778871305600d4312bfc7bc5e95..6922fc31397a4fe53e8198a2da007fa07f5c66d9 100644 --- a/apps/app_cut.c +++ b/apps/app_cut.c @@ -43,31 +43,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") static char *tdesc = "Cut out information from a string"; -static char *app_cut = "Cut"; - -static char *cut_synopsis = "Splits a variable's contents using the specified delimiter"; - -static char *cut_descrip = -" Cut(newvar=varname,delimiter,fieldspec): This applicaiton will split the\n" -"contents of a variable based on the given delimeter and store the result in\n" -"a new variable.\n" -"Parameters:\n" -" newvar - new variable created from result string\n" -" varname - variable you want cut\n" -" delimiter - defaults to '-'\n" -" fieldspec - number of the field you want (1-based offset)\n" -" may also be specified as a range (with -)\n" -" or group of ranges and fields (with &)\n" -"This application has been deprecated in favor of the CUT function.\n"; - -static char *app_sort = "Sort"; -static char *app_sort_synopsis = "Sorts a list of keywords and values"; -static char *app_sort_descrip = -" Sort(newvar=key1:val1[,key2:val2[[...],keyN:valN]]): This application will\n" -"sort the list provided in ascending order. The result will be stored in the\n" -"specified variable name.\n" -" This applicaiton has been deprecated in favor of the SORT function.\n"; - STANDARD_LOCAL_USER; LOCAL_USER_DECL; @@ -258,105 +233,6 @@ static int cut_internal(struct ast_channel *chan, char *data, char *buffer, size return 0; } -static int sort_exec(struct ast_channel *chan, void *data) -{ - int res=0; - struct localuser *u; - char *varname, *strings, result[512] = ""; - static int dep_warning=0; - - if (!dep_warning) { - ast_log(LOG_WARNING, "The application Sort is deprecated. Please use the SORT() function instead.\n"); - dep_warning=1; - } - - if (!data) { - ast_log(LOG_ERROR, "Sort() requires an argument\n"); - return 0; - } - - LOCAL_USER_ADD(u); - - strings = ast_strdupa((char *)data); - if (!strings) { - ast_log(LOG_ERROR, "Out of memory\n"); - LOCAL_USER_REMOVE(u); - return 0; - } - - varname = strsep(&strings, "="); - switch (sort_internal(chan, strings, result, sizeof(result))) { - case ERROR_NOARG: - ast_log(LOG_ERROR, "Sort() requires an argument\n"); - res = 0; - break; - case ERROR_NOMEM: - ast_log(LOG_ERROR, "Out of memory\n"); - res = -1; - break; - case 0: - pbx_builtin_setvar_helper(chan, varname, result); - res = 0; - break; - default: - ast_log(LOG_ERROR, "Unknown internal error\n"); - res = -1; - } - LOCAL_USER_REMOVE(u); - return res; -} - -static int cut_exec(struct ast_channel *chan, void *data) -{ - int res=0; - struct localuser *u; - char *s, *newvar=NULL, result[512]; - static int dep_warning = 0; - - LOCAL_USER_ADD(u); - - if (!dep_warning) { - ast_log(LOG_WARNING, "The application Cut is deprecated. Please use the CUT() function instead.\n"); - dep_warning=1; - } - - /* Check and parse arguments */ - if (data) { - s = ast_strdupa((char *)data); - if (s) { - newvar = strsep(&s, "="); - } else { - ast_log(LOG_ERROR, "Out of memory\n"); - LOCAL_USER_REMOVE(u); - return -1; - } - } - - switch (cut_internal(chan, s, result, sizeof(result))) { - case ERROR_NOARG: - ast_log(LOG_ERROR, "Cut() requires an argument\n"); - res = 0; - break; - case ERROR_NOMEM: - ast_log(LOG_ERROR, "Out of memory\n"); - res = -1; - break; - case ERROR_USAGE: - ast_log(LOG_ERROR, "Usage: %s\n", cut_synopsis); - res = 0; - break; - case 0: - pbx_builtin_setvar_helper(chan, newvar, result); - res = 0; - break; - default: - ast_log(LOG_ERROR, "Unknown internal error\n"); - res = -1; - } - LOCAL_USER_REMOVE(u); - return res; -} - static char *acf_sort_exec(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) { struct localuser *u; @@ -434,8 +310,6 @@ int unload_module(void) res = ast_custom_function_unregister(&acf_cut); res |= ast_custom_function_unregister(&acf_sort); - res |= ast_unregister_application(app_sort); - res |= ast_unregister_application(app_cut); STANDARD_HANGUP_LOCALUSERS; @@ -448,8 +322,6 @@ int load_module(void) res = ast_custom_function_register(&acf_cut); res |= ast_custom_function_register(&acf_sort); - res |= ast_register_application(app_sort, sort_exec, app_sort_synopsis, app_sort_descrip); - res |= ast_register_application(app_cut, cut_exec, cut_synopsis, cut_descrip); return res; } diff --git a/apps/app_db.c b/apps/app_db.c index e633cbfce814948f875efe38ab5f700c67216e1c..24f78f083ec98859bbfdf4bbc836fa471a8abcce 100644 --- a/apps/app_db.c +++ b/apps/app_db.c @@ -47,21 +47,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") static char *tdesc = "Database Access Functions"; -static char *g_descrip = -" DBget(varname=family/key[|options]): This application will retrieve a value\n" -"from the Asterisk database and store it in the given variable.\n" -" Options:\n" -" j - Jump to priority n+101 if the requested family/key isn't found.\n" -" This application sets the following channel variable upon completion:\n" -" DBGETSTATUS - This variable will contain the status of the attempt\n" -" FOUND | NOTFOUND \n" -" This application has been deprecated in favor of the DB function.\n"; - -static char *p_descrip = -" DBput(family/key=value): This application will store the given value in the\n" -"specified location in the Asterisk database.\n" -" This application has been deprecated in favor of the DB function.\n"; - static char *d_descrip = " DBdel(family/key): This applicaiton will delete a key from the Asterisk\n" "database.\n"; @@ -70,13 +55,9 @@ static char *dt_descrip = " DBdeltree(family[/keytree]): This application will delete a family or keytree\n" "from the Asterisk database\n"; -static char *g_app = "DBget"; -static char *p_app = "DBput"; static char *d_app = "DBdel"; static char *dt_app = "DBdeltree"; -static char *g_synopsis = "Retrieve a value from the database"; -static char *p_synopsis = "Store a value in the database"; static char *d_synopsis = "Delete a key from the database"; static char *dt_synopsis = "Delete a family or keytree from the database"; @@ -167,126 +148,12 @@ static int del_exec(struct ast_channel *chan, void *data) return 0; } -static int put_exec(struct ast_channel *chan, void *data) -{ - char *argv, *value, *family, *key; - static int dep_warning = 0; - struct localuser *u; - - LOCAL_USER_ADD(u); - - if (!dep_warning) { - ast_log(LOG_WARNING, "This application has been deprecated, please use the ${DB(family/key)} function instead.\n"); - dep_warning = 1; - } - - argv = ast_strdupa(data); - if (!argv) { - ast_log(LOG_ERROR, "Memory allocation failed\n"); - LOCAL_USER_REMOVE(u); - return 0; - } - - if (strchr(argv, '/') && strchr(argv, '=')) { - family = strsep(&argv, "/"); - key = strsep(&argv, "="); - value = strsep(&argv, "\0"); - if (!value || !family || !key) { - ast_log(LOG_DEBUG, "Ignoring; Syntax error in argument\n"); - LOCAL_USER_REMOVE(u); - return 0; - } - if (option_verbose > 2) - ast_verbose(VERBOSE_PREFIX_3 "DBput: family=%s, key=%s, value=%s\n", family, key, value); - if (ast_db_put(family, key, value)) { - if (option_verbose > 2) - ast_verbose(VERBOSE_PREFIX_3 "DBput: Error writing value to database.\n"); - } - - } else { - ast_log (LOG_DEBUG, "Ignoring, no parameters\n"); - } - - LOCAL_USER_REMOVE(u); - - return 0; -} - -static int get_exec(struct ast_channel *chan, void *data) -{ - char *argv, *varname, *family, *key, *options = NULL; - char dbresult[256]; - static int dep_warning = 0; - int priority_jump = 0; - struct localuser *u; - - LOCAL_USER_ADD(u); - - if (!dep_warning) { - ast_log(LOG_WARNING, "This application has been deprecated, please use the ${DB(family/key)} function instead.\n"); - dep_warning = 1; - } - - argv = ast_strdupa(data); - if (!argv) { - ast_log(LOG_ERROR, "Memory allocation failed\n"); - LOCAL_USER_REMOVE(u); - return 0; - } - - if (strchr(argv, '=') && strchr(argv, '/')) { - varname = strsep(&argv, "="); - family = strsep(&argv, "/"); - if (strchr((void *)&argv, '|')) { - key = strsep(&argv, "|"); - options = strsep(&argv, "\0"); - } else - key = strsep(&argv, "\0"); - - if (!varname || !family || !key) { - ast_log(LOG_DEBUG, "Ignoring; Syntax error in argument\n"); - LOCAL_USER_REMOVE(u); - return 0; - } - - if (options) { - if (strchr(options, 'j')) - priority_jump = 1; - } - - if (option_verbose > 2) - ast_verbose(VERBOSE_PREFIX_3 "DBget: varname=%s, family=%s, key=%s\n", varname, family, key); - if (!ast_db_get(family, key, dbresult, sizeof (dbresult) - 1)) { - pbx_builtin_setvar_helper(chan, varname, dbresult); - if (option_verbose > 2) - ast_verbose(VERBOSE_PREFIX_3 "DBget: set variable %s to %s\n", varname, dbresult); - pbx_builtin_setvar_helper(chan, "DBGETSTATUS", "FOUND"); - } else { - if (option_verbose > 2) - ast_verbose(VERBOSE_PREFIX_3 "DBget: Value not found in database.\n"); - if (priority_jump || ast_opt_priority_jumping) { - /* Send the call to n+101 priority, where n is the current priority */ - ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101); - } - pbx_builtin_setvar_helper(chan, "DBGETSTATUS", "NOTFOUND"); - } - } else { - ast_log(LOG_DEBUG, "Ignoring, no parameters\n"); - } - - LOCAL_USER_REMOVE(u); - - return 0; -} - int unload_module(void) { int retval; retval = ast_unregister_application(dt_app); retval |= ast_unregister_application(d_app); - retval |= ast_unregister_application(p_app); - retval |= ast_unregister_application(g_app); STANDARD_HANGUP_LOCALUSERS; @@ -297,8 +164,6 @@ int load_module(void) { int retval; - retval = ast_register_application(g_app, get_exec, g_synopsis, g_descrip); - retval |= ast_register_application(p_app, put_exec, p_synopsis, p_descrip); retval |= ast_register_application(d_app, del_exec, d_synopsis, d_descrip); retval |= ast_register_application(dt_app, deltree_exec, dt_synopsis, dt_descrip); diff --git a/apps/app_enumlookup.c b/apps/app_enumlookup.c deleted file mode 100644 index 98e66e1a82faf33824734017a4add3396dd83dd9..0000000000000000000000000000000000000000 --- a/apps/app_enumlookup.c +++ /dev/null @@ -1,270 +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 Enumlookup - lookup entry in ENUM - * - * \ingroup applications - */ - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <unistd.h> -#include <ctype.h> - -#include "asterisk.h" - -ASTERISK_FILE_VERSION(__FILE__, "$Revision$") - -#include "asterisk/lock.h" -#include "asterisk/file.h" -#include "asterisk/logger.h" -#include "asterisk/channel.h" -#include "asterisk/pbx.h" -#include "asterisk/options.h" -#include "asterisk/config.h" -#include "asterisk/module.h" -#include "asterisk/enum.h" -#include "asterisk/utils.h" -#include "asterisk/app.h" -#include "asterisk/options.h" - -static char *tdesc = "ENUM Lookup"; - -static char *app = "EnumLookup"; - -static char *synopsis = "Lookup number in ENUM"; - -static char *descrip = -" EnumLookup(exten[|option]): Looks up an extension via ENUM and sets\n" -"the variable 'ENUM'. For VoIP URIs this variable will \n" -"look like 'TECHNOLOGY/URI' with the appropriate technology.\n" -"Currently, the enumservices SIP, H323, IAX, IAX2 and TEL are recognized. \n" -"\nReturns status in the ENUMSTATUS channel variable:\n" -" ERROR Failed to do a lookup\n" -" <tech> Technology of the successful lookup: SIP, H323, IAX, IAX2 or TEL\n" -" BADURI Got URI Asterisk does not understand.\n" -" The option string may contain zero or the following character:\n" -" 'j' -- jump to +101 priority if the lookup isn't successful.\n" -" and jump to +51 priority on a TEL entry.\n"; - -#define ENUM_CONFIG "enum.conf" - -static char h323driver[80] = ""; -#define H323DRIVERDEFAULT "H323" - -STANDARD_LOCAL_USER; - -LOCAL_USER_DECL; - -/*--- enumlookup_exec: Look up number in ENUM and return result */ -static int enumlookup_exec(struct ast_channel *chan, void *data) -{ - int res=0,priority_jump=0; - char tech[80]; - char dest[80]; - char tmp[256]; - char *c,*t = NULL; - static int dep_warning=0; - struct localuser *u; - char *parse; - AST_DECLARE_APP_ARGS(args, - AST_APP_ARG(d); - AST_APP_ARG(o); - ); - - if (ast_strlen_zero(data)) { - ast_log(LOG_WARNING, "EnumLookup requires an argument (extension)\n"); - return -1; - } - - if (!dep_warning) { - ast_log(LOG_WARNING, "The application EnumLookup is deprecated. Please use the ENUMLOOKUP() function instead.\n"); - dep_warning = 1; - } - - LOCAL_USER_ADD(u); - - parse = ast_strdupa(data); - if (!parse) { - ast_log(LOG_ERROR, "Out of memory!\n"); - LOCAL_USER_REMOVE(u); - return -1; - } - - AST_STANDARD_APP_ARGS(args, parse); - - tech[0] = '\0'; - dest[0] = '\0'; - - if (args.o) { - if (strchr(args.o, 'j')) - priority_jump = 1; - } - - res = ast_get_enum(chan, args.d, dest, sizeof(dest), tech, sizeof(tech), NULL, NULL); - - if (!res) { /* Failed to do a lookup */ - if (priority_jump || ast_opt_priority_jumping) { - /* Look for a "busy" place */ - ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101); - } - pbx_builtin_setvar_helper(chan, "ENUMSTATUS", "ERROR"); - LOCAL_USER_REMOVE(u); - return 0; - } - pbx_builtin_setvar_helper(chan, "ENUMSTATUS", tech); - /* Parse it out */ - if (res > 0) { - if (!strcasecmp(tech, "SIP")) { - c = dest; - if (!strncmp(c, "sip:", 4)) - c += 4; - snprintf(tmp, sizeof(tmp), "SIP/%s", c); - pbx_builtin_setvar_helper(chan, "ENUM", tmp); - } else if (!strcasecmp(tech, "h323")) { - c = dest; - if (!strncmp(c, "h323:", 5)) - c += 5; - snprintf(tmp, sizeof(tmp), "%s/%s", h323driver, c); -/* do a s!;.*!! on the H323 URI */ - t = strchr(c,';'); - if (t) - *t = 0; - pbx_builtin_setvar_helper(chan, "ENUM", tmp); - } else if (!strcasecmp(tech, "iax")) { - c = dest; - if (!strncmp(c, "iax:", 4)) - c += 4; - snprintf(tmp, sizeof(tmp), "IAX/%s", c); - pbx_builtin_setvar_helper(chan, "ENUM", tmp); - } else if (!strcasecmp(tech, "iax2")) { - c = dest; - if (!strncmp(c, "iax2:", 5)) - c += 5; - snprintf(tmp, sizeof(tmp), "IAX2/%s", c); - pbx_builtin_setvar_helper(chan, "ENUM", tmp); - } else if (!strcasecmp(tech, "tel")) { - c = dest; - if (!strncmp(c, "tel:", 4)) - c += 4; - - if (c[0] != '+') { - ast_log(LOG_NOTICE, "tel: uri must start with a \"+\" (got '%s')\n", c); - res = 0; - } else { -/* now copy over the number, skipping all non-digits and stop at ; or NULL */ - t = tmp; - while( *c && (*c != ';') && (t - tmp < (sizeof(tmp) - 1))) { - if (isdigit(*c)) - *t++ = *c; - c++; - } - *t = 0; - pbx_builtin_setvar_helper(chan, "ENUM", tmp); - ast_log(LOG_NOTICE, "tel: ENUM set to \"%s\"\n", tmp); - if (priority_jump || ast_opt_priority_jumping) { - if (ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 51)) - res = 0; - } - } - } else if (!ast_strlen_zero(tech)) { - ast_log(LOG_NOTICE, "Don't know how to handle technology '%s'\n", tech); - pbx_builtin_setvar_helper(chan, "ENUMSTATUS", "BADURI"); - res = 0; - } - } - - LOCAL_USER_REMOVE(u); - - return 0; -} - -/*--- load_config: Load enum.conf and find out how to handle H.323 */ -static int load_config(void) -{ - struct ast_config *cfg; - char *s; - - cfg = ast_config_load(ENUM_CONFIG); - if (cfg) { - if (!(s=ast_variable_retrieve(cfg, "general", "h323driver"))) { - strncpy(h323driver, H323DRIVERDEFAULT, sizeof(h323driver) - 1); - } else { - strncpy(h323driver, s, sizeof(h323driver) - 1); - } - ast_config_destroy(cfg); - return 0; - } - ast_log(LOG_NOTICE, "No ENUM Config file, using defaults\n"); - return 0; -} - - -/*--- unload_module: Unload this application from PBX */ -int unload_module(void) -{ - int res; - - res = ast_unregister_application(app); - - STANDARD_HANGUP_LOCALUSERS; - - return res; -} - -/*--- load_module: Load this application into PBX */ -int load_module(void) -{ - int res; - - res = ast_register_application(app, enumlookup_exec, synopsis, descrip); - - if (!res) - res = load_config(); - - return res; -} - -/*--- reload: Reload configuration file */ -int reload(void) -{ - return load_config(); -} - - -/*--- description: Describe module */ -char *description(void) -{ - return tdesc; -} - -int usecount(void) -{ - int res; - STANDARD_USECOUNT(res); - return res; -} - -char *key() -{ - return ASTERISK_GPL_KEY; -} - diff --git a/apps/app_eval.c b/apps/app_eval.c deleted file mode 100644 index 13ab0ddbc72b75c154f4b86683e6e3732af9c2ca..0000000000000000000000000000000000000000 --- a/apps/app_eval.c +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Asterisk -- An open source telephony toolkit. - * - * Copyright (c) 2004 - 2005, Tilghman Lesher. All rights reserved. - * - * Tilghman Lesher <app_eval__v001@the-tilghman.com> - * - * This code is released by the author with no restrictions on usage. - * - * 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. - * - */ - -/*! \file - * \brief Eval application - * - * \author Tilghman Lesher <app_eval__v001@the-tilghman.com> - * - * \ingroup applications - */ - -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <string.h> - -#include "asterisk.h" - -ASTERISK_FILE_VERSION(__FILE__, "$Revision$") - -#include "asterisk/file.h" -#include "asterisk/logger.h" -#include "asterisk/options.h" -#include "asterisk/channel.h" -#include "asterisk/pbx.h" -#include "asterisk/module.h" - -/* Maximum length of any variable */ -#define MAXRESULT 1024 - -static char *tdesc = "Reevaluates strings"; - -static char *app_eval = "Eval"; - -static char *eval_synopsis = "Evaluates a string"; - -static char *eval_descrip = -"Usage: Eval(newvar=somestring)\n" -" Normally Asterisk evaluates variables inline. But what if you want to\n" -"store variable offsets in a database, to be evaluated later? Eval is\n" -"the answer, by allowing a string to be evaluated twice in the dialplan,\n" -"the first time as part of the normal dialplan, and the second using Eval.\n"; - -STANDARD_LOCAL_USER; - -LOCAL_USER_DECL; - -static int eval_exec(struct ast_channel *chan, void *data) -{ - int res=0; - struct localuser *u; - char *s, *newvar=NULL, tmp[MAXRESULT]; - static int dep_warning = 0; - - LOCAL_USER_ADD(u); - - if (!dep_warning) { - ast_log(LOG_WARNING, "This application has been deprecated in favor of the dialplan function, EVAL\n"); - dep_warning = 1; - } - - /* Check and parse arguments */ - if (data) { - s = ast_strdupa((char *)data); - if (s) { - newvar = strsep(&s, "="); - if (newvar && (newvar[0] != '\0')) { - memset(tmp, 0, MAXRESULT); - pbx_substitute_variables_helper(chan, s, tmp, MAXRESULT - 1); - pbx_builtin_setvar_helper(chan, newvar, tmp); - } - } else { - ast_log(LOG_ERROR, "Out of memory\n"); - res = -1; - } - } - - LOCAL_USER_REMOVE(u); - return res; -} - -int unload_module(void) -{ - int res; - - res = ast_unregister_application(app_eval); - - STANDARD_HANGUP_LOCALUSERS; - - return res; -} - -int load_module(void) -{ - return ast_register_application(app_eval, eval_exec, eval_synopsis, eval_descrip); -} - -char *description(void) -{ - return tdesc; -} - -int usecount(void) -{ - int res; - STANDARD_USECOUNT(res); - return res; -} - -char *key() -{ - return ASTERISK_GPL_KEY; -} diff --git a/apps/app_groupcount.c b/apps/app_groupcount.c deleted file mode 100644 index a8528602342e287b6fc55e31ffab27f66013341e..0000000000000000000000000000000000000000 --- a/apps/app_groupcount.c +++ /dev/null @@ -1,339 +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 Group Manipulation Applications - * - * \ingroup applications - */ - -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <string.h> -#include <sys/types.h> -#include <regex.h> - -#include "asterisk.h" - -ASTERISK_FILE_VERSION(__FILE__, "$Revision$") - -#include "asterisk/file.h" -#include "asterisk/logger.h" -#include "asterisk/options.h" -#include "asterisk/channel.h" -#include "asterisk/pbx.h" -#include "asterisk/module.h" -#include "asterisk/utils.h" -#include "asterisk/cli.h" -#include "asterisk/app.h" - -STANDARD_LOCAL_USER; - -LOCAL_USER_DECL; - -static int group_count_exec(struct ast_channel *chan, void *data) -{ - int res = 0; - int count; - struct localuser *u; - char group[80] = ""; - char category[80] = ""; - char ret[80] = ""; - static int deprecation_warning = 0; - - LOCAL_USER_ADD(u); - - if (!deprecation_warning) { - ast_log(LOG_WARNING, "The GetGroupCount application has been deprecated, please use the GROUP_COUNT function.\n"); - deprecation_warning = 1; - } - - ast_app_group_split_group(data, group, sizeof(group), category, sizeof(category)); - - if (ast_strlen_zero(group)) { - const char *grp = pbx_builtin_getvar_helper(chan, category); - strncpy(group, grp, sizeof(group) - 1); - } - - count = ast_app_group_get_count(group, category); - snprintf(ret, sizeof(ret), "%d", count); - pbx_builtin_setvar_helper(chan, "GROUPCOUNT", ret); - - LOCAL_USER_REMOVE(u); - - return res; -} - -static int group_match_count_exec(struct ast_channel *chan, void *data) -{ - int res = 0; - int count; - struct localuser *u; - char group[80] = ""; - char category[80] = ""; - char ret[80] = ""; - static int deprecation_warning = 0; - - LOCAL_USER_ADD(u); - - if (!deprecation_warning) { - ast_log(LOG_WARNING, "The GetGroupMatchCount application has been deprecated, please use the GROUP_MATCH_COUNT function.\n"); - deprecation_warning = 1; - } - - 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(ret, sizeof(ret), "%d", count); - pbx_builtin_setvar_helper(chan, "GROUPCOUNT", ret); - } - - LOCAL_USER_REMOVE(u); - - return res; -} - -static int group_set_exec(struct ast_channel *chan, void *data) -{ - int res = 0; - struct localuser *u; - static int deprecation_warning = 0; - - LOCAL_USER_ADD(u); - - if (!deprecation_warning) { - ast_log(LOG_WARNING, "The SetGroup application has been deprecated, please use the GROUP() function.\n"); - deprecation_warning = 1; - } - - if (ast_app_group_set_channel(chan, data)) - ast_log(LOG_WARNING, "SetGroup requires an argument (group name)\n"); - - LOCAL_USER_REMOVE(u); - return res; -} - -static int group_check_exec(struct ast_channel *chan, void *data) -{ - int res = 0; - int max, count; - struct localuser *u; - char limit[80]=""; - char category[80]=""; - static int deprecation_warning = 0; - char *parse; - int priority_jump = 0; - AST_DECLARE_APP_ARGS(args, - AST_APP_ARG(max); - AST_APP_ARG(options); - ); - - LOCAL_USER_ADD(u); - - if (!deprecation_warning) { - ast_log(LOG_WARNING, "The CheckGroup application has been deprecated, please use a combination of the GotoIf application and the GROUP_COUNT() function.\n"); - deprecation_warning = 1; - } - - if (!(parse = ast_strdupa(data))) { - ast_log(LOG_WARNING, "Memory Error!\n"); - LOCAL_USER_REMOVE(u); - return -1; - } - - AST_STANDARD_APP_ARGS(args, parse); - - if (args.options) { - if (strchr(args.options, 'j')) - priority_jump = 1; - } - - if (ast_strlen_zero(args.max)) { - ast_log(LOG_WARNING, "CheckGroup requires an argument(max[@category][|options])\n"); - return res; - } - - ast_app_group_split_group(args.max, limit, sizeof(limit), category, sizeof(category)); - - if ((sscanf(limit, "%d", &max) == 1) && (max > -1)) { - count = ast_app_group_get_count(pbx_builtin_getvar_helper(chan, category), category); - if (count > max) { - pbx_builtin_setvar_helper(chan, "CHECKGROUPSTATUS", "OVERMAX"); - if (priority_jump || ast_opt_priority_jumping) { - if (!ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101)) - res = -1; - } - } else - pbx_builtin_setvar_helper(chan, "CHECKGROUPSTATUS", "OK"); - } else - ast_log(LOG_WARNING, "CheckGroup requires a positive integer argument (max)\n"); - - LOCAL_USER_REMOVE(u); - return res; -} - -static int group_show_channels(int fd, int argc, char *argv[]) -{ -#define FORMAT_STRING "%-25s %-20s %-20s\n" - - struct ast_channel *c = NULL; - int numchans = 0; - struct ast_var_t *current; - struct varshead *headp; - regex_t regexbuf; - int havepattern = 0; - - if (argc < 3 || argc > 4) - return RESULT_SHOWUSAGE; - - if (argc == 4) { - if (regcomp(®exbuf, argv[3], REG_EXTENDED | REG_NOSUB)) - return RESULT_SHOWUSAGE; - havepattern = 1; - } - - ast_cli(fd, FORMAT_STRING, "Channel", "Group", "Category"); - while ( (c = ast_channel_walk_locked(c)) != NULL) { - headp=&c->varshead; - AST_LIST_TRAVERSE(headp,current,entries) { - if (!strncmp(ast_var_name(current), GROUP_CATEGORY_PREFIX "_", strlen(GROUP_CATEGORY_PREFIX) + 1)) { - if (!havepattern || !regexec(®exbuf, ast_var_value(current), 0, NULL, 0)) { - ast_cli(fd, FORMAT_STRING, c->name, ast_var_value(current), - (ast_var_name(current) + strlen(GROUP_CATEGORY_PREFIX) + 1)); - numchans++; - } - } else if (!strcmp(ast_var_name(current), GROUP_CATEGORY_PREFIX)) { - if (!havepattern || !regexec(®exbuf, ast_var_value(current), 0, NULL, 0)) { - ast_cli(fd, FORMAT_STRING, c->name, ast_var_value(current), "(default)"); - numchans++; - } - } - } - numchans++; - ast_mutex_unlock(&c->lock); - } - - if (havepattern) - regfree(®exbuf); - - ast_cli(fd, "%d active channel%s\n", numchans, (numchans != 1) ? "s" : ""); - return RESULT_SUCCESS; -#undef FORMAT_STRING -} - -static char *tdesc = "Group Management Routines"; - -static char *app_group_count = "GetGroupCount"; -static char *app_group_set = "SetGroup"; -static char *app_group_check = "CheckGroup"; -static char *app_group_match_count = "GetGroupMatchCount"; - -static char *group_count_synopsis = "Get the channel count of a group"; -static char *group_set_synopsis = "Set the channel's group"; -static char *group_check_synopsis = "Check the channel count of a group against a limit"; -static char *group_match_count_synopsis = "Get the channel count of all groups that match a pattern"; - -static char *group_count_descrip = -"Usage: GetGroupCount([groupname][@category])\n" -" Calculates the group count for the specified group, or uses\n" -"the current channel's group if not specifed (and non-empty).\n" -"Stores result in GROUPCOUNT. \n" -"This application has been deprecated, please use the function\n" -"GroupCount.\n"; - -static char *group_set_descrip = -"Usage: SetGroup(groupname[@category])\n" -" Sets the channel group to the specified value. Equivalent to\n" -"Set(GROUP=group). Always returns 0.\n"; - -static char *group_check_descrip = -"Usage: CheckGroup(max[@category][|options])\n" -" Checks that the current number of total channels in the\n" -"current channel's group does not exceed 'max'. If the number\n" -"does not exceed 'max', we continue to the next step. \n" -" The option string may contain zero of the following character:\n" -" 'j' -- jump to n+101 priority if the number does in fact exceed max,\n" -" and priority n+101 exists. Execuation then continues at that\n" -" step, otherwise -1 is returned.\n" -" This application sets the following channel variable upon successful completion:\n" -" CHECKGROUPSTATUS The status of the check that the current channel's\n" -" group does not exceed 'max'. It's value is one of\n" -" OK | OVERMAX \n"; - -static char *group_match_count_descrip = -"Usage: GetGroupMatchCount(groupmatch[@category])\n" -" Calculates the group count for all groups that match the specified\n" -"pattern. Uses standard regular expression matching (see regex(7)).\n" -"Stores result in GROUPCOUNT. Always returns 0.\n" -"This application has been deprecated, please use the function\n" -"GroupMatchCount.\n"; - -static char show_channels_usage[] = -"Usage: group show channels [pattern]\n" -" Lists all currently active channels with channel group(s) specified.\n Optional regular expression pattern is matched to group names for each channel.\n"; - -static struct ast_cli_entry cli_show_channels = - { { "group", "show", "channels", NULL }, group_show_channels, "Show active channels with group(s)", show_channels_usage}; - -int unload_module(void) -{ - int res; - - res = ast_cli_unregister(&cli_show_channels); - res |= ast_unregister_application(app_group_count); - res |= ast_unregister_application(app_group_set); - res |= ast_unregister_application(app_group_check); - res |= ast_unregister_application(app_group_match_count); - - STANDARD_HANGUP_LOCALUSERS; - - return res; -} - -int load_module(void) -{ - int res; - - res = ast_register_application(app_group_count, group_count_exec, group_count_synopsis, group_count_descrip); - res |= ast_register_application(app_group_set, group_set_exec, group_set_synopsis, group_set_descrip); - res |= ast_register_application(app_group_check, group_check_exec, group_check_synopsis, group_check_descrip); - res |= ast_register_application(app_group_match_count, group_match_count_exec, group_match_count_synopsis, group_match_count_descrip); - res |= ast_cli_register(&cli_show_channels); - - return res; -} - -char *description(void) -{ - return tdesc; -} - -int usecount(void) -{ - int res; - STANDARD_USECOUNT(res); - return res; -} - -char *key() -{ - return ASTERISK_GPL_KEY; -} diff --git a/apps/app_math.c b/apps/app_math.c deleted file mode 100644 index f1be8d4d1d073856f7c2666a47b0784576c177ab..0000000000000000000000000000000000000000 --- a/apps/app_math.c +++ /dev/null @@ -1,297 +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 A simple math application - * - * \ingroup applications - */ - -#include <stdlib.h> -#include <errno.h> -#include <unistd.h> -#include <string.h> -#include <stdlib.h> -#include <stdio.h> -#include <sys/time.h> -#include <sys/stat.h> -#include <sys/types.h> -#include <time.h> -#include <dirent.h> -#include <ctype.h> -#include <sys/file.h> - -#include "asterisk.h" - -ASTERISK_FILE_VERSION(__FILE__, "$Revision$") - -#include "asterisk/lock.h" -#include "asterisk/file.h" -#include "asterisk/logger.h" -#include "asterisk/channel.h" -#include "asterisk/pbx.h" -#include "asterisk/options.h" -#include "asterisk/config.h" -#include "asterisk/say.h" -#include "asterisk/module.h" -#include "asterisk/app.h" -#include "asterisk/manager.h" -#include "asterisk/localtime.h" -#include "asterisk/cli.h" -#include "asterisk/utils.h" -#include "asterisk/module.h" -#include "asterisk/translate.h" - -static char *tdesc = "Basic Math Functions"; - -static char *app_math = "Math"; - -static char *math_synopsis = "Performs Mathematical Functions"; - -static char *math_descrip = -"Math(returnvar,<number1><op><number 2>\n\n" -"Perform floating point calculation on number 1 to number 2 and \n" -"store the result in returnvar. Valid ops are: \n" -" +,-,/,*,%,<,>,>=,<=,==\n" -"and behave as their C equivalents.\n"; - -#define ADDFUNCTION 0 -#define DIVIDEFUNCTION 1 -#define MULTIPLYFUNCTION 2 -#define SUBTRACTFUNCTION 3 -#define MODULUSFUNCTION 4 - -#define GTFUNCTION 5 -#define LTFUNCTION 6 -#define GTEFUNCTION 7 -#define LTEFUNCTION 8 -#define EQFUNCTION 9 - -STANDARD_LOCAL_USER; - -LOCAL_USER_DECL; - -static int math_exec(struct ast_channel *chan, void *data) -{ - float fnum1; - float fnum2; - float ftmp = 0; - char *op; - int iaction=-1; - static int deprecation_warning = 0; - - /* dunno, big calulations :D */ - char user_result[30]; - - char *s; - char *mvar, *mvalue1, *mvalue2=NULL; - - struct localuser *u; - - if (!deprecation_warning) { - ast_log(LOG_WARNING, "Math() is deprecated, please use Set(var=${MATH(...)} instead.\n"); - deprecation_warning = 1; - } - - if (ast_strlen_zero(data)) { - ast_log(LOG_WARNING, "No parameters passed. !\n"); - return -1; - } - - LOCAL_USER_ADD(u); - - s = ast_strdupa(data); - if (!s) { - ast_log(LOG_ERROR, "Out of memory\n"); - LOCAL_USER_REMOVE(u); - return -1; - } - - mvar = strsep(&s, "|"); - mvalue1 = strsep(&s, "|"); - - 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 = GTFUNCTION; - *op = '\0'; - if (*(op+1) == '=') { - op++; - *op = '\0'; - iaction = GTEFUNCTION; - } - } else if ((op = strchr(mvalue1, '<'))) { - iaction = LTFUNCTION; - *op = '\0'; - if (*(op+1) == '=') { - op++; - *op = '\0'; - iaction = LTEFUNCTION; - } - } else if ((op = strchr(mvalue1, '='))) { - iaction = GTFUNCTION; - *op = '\0'; - if (*(op+1) == '=') { - op++; - *op = '\0'; - iaction = EQFUNCTION; - } else - op = NULL; - } - - if (op) - mvalue2 = op + 1; - - if (!mvar || !mvalue1 || !mvalue2) { - ast_log(LOG_WARNING, "Supply all the parameters - just this once, please\n"); - LOCAL_USER_REMOVE(u); - return -1; - } - - if (!strcmp(mvar,"")) { - ast_log(LOG_WARNING, "No return variable set.\n"); - LOCAL_USER_REMOVE(u); - return -1; - } - - if (sscanf(mvalue1, "%f", &fnum1) != 1) { - ast_log(LOG_WARNING, "'%s' is not a valid number\n", mvalue1); - LOCAL_USER_REMOVE(u); - return -1; - } - - if (sscanf(mvalue2, "%f", &fnum2) != 1) { - ast_log(LOG_WARNING, "'%s' is not a valid number\n", mvalue2); - LOCAL_USER_REMOVE(u); - return -1; - } - - 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 : - if (fnum1 > fnum2) - strcpy(user_result, "TRUE"); - else - strcpy(user_result, "FALSE"); - break; - case LTFUNCTION : - if (fnum1 < fnum2) - strcpy(user_result, "TRUE"); - else - strcpy(user_result, "FALSE"); - break; - case GTEFUNCTION : - if (fnum1 >= fnum2) - strcpy(user_result, "TRUE"); - else - strcpy(user_result, "FALSE"); - break; - case LTEFUNCTION : - if (fnum1 <= fnum2) - strcpy(user_result, "TRUE"); - else - strcpy(user_result, "FALSE"); - break; - case EQFUNCTION : - if (fnum1 == fnum2) - strcpy(user_result, "TRUE"); - else - strcpy(user_result, "FALSE"); - break; - default : - ast_log(LOG_WARNING, "Something happened that neither of us should be proud of %d\n", iaction); - LOCAL_USER_REMOVE(u); - return -1; - } - - if (iaction < GTFUNCTION || iaction > EQFUNCTION) - snprintf(user_result,sizeof(user_result),"%f",ftmp); - - pbx_builtin_setvar_helper(chan, mvar, user_result); - - LOCAL_USER_REMOVE(u); - return 0; -} - -int unload_module(void) -{ - int res; - - res = ast_unregister_application(app_math); - - STANDARD_HANGUP_LOCALUSERS; - - return res; -} - -int load_module(void) -{ - return ast_register_application(app_math, math_exec, math_synopsis, math_descrip); -} - -char *description(void) -{ - return tdesc; -} - -int usecount(void) -{ - int res; - STANDARD_USECOUNT(res); - return res; -} - -char *key() -{ - return ASTERISK_GPL_KEY; -} - -/* Fading everything to black and blue... */ diff --git a/apps/app_md5.c b/apps/app_md5.c deleted file mode 100644 index 127b3d7e8e3d13e26ab3f5262aee2437acf72d4c..0000000000000000000000000000000000000000 --- a/apps/app_md5.c +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Asterisk -- An open source telephony toolkit. - * - * Copyright (C) 2005, 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 MD5 checksum application - * - * \todo Remove this deprecated application in 1.3dev - * \ingroup applications - */ - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <unistd.h> - -#include "asterisk.h" - -ASTERISK_FILE_VERSION(__FILE__, "$Revision$") - -#include "asterisk/file.h" -#include "asterisk/logger.h" -#include "asterisk/utils.h" -#include "asterisk/options.h" -#include "asterisk/channel.h" -#include "asterisk/pbx.h" -#include "asterisk/module.h" -#include "asterisk/lock.h" -#include "asterisk/app.h" - -static char *tdesc_md5 = "MD5 checksum applications"; -static char *app_md5 = "MD5"; -static char *desc_md5 = "Calculate MD5 checksum"; -static char *synopsis_md5 = -" MD5(<var>=<string>): Calculates a MD5 checksum on <string>.\n" -"Returns hash value in a channel variable. \n"; - -static char *app_md5check = "MD5Check"; -static char *desc_md5check = "Check MD5 checksum"; -static char *synopsis_md5check = -" MD5Check(<md5hash>|<string>[|options]): Calculates a MD5 checksum on <string>\n" -"and compares it with the hash. Returns 0 if <md5hash> is correct for <string>.\n" -"The option string may contain zero or more of the following characters:\n" -" 'j' -- jump to priority n+101 if the hash and string do not match \n" -"This application sets the following channel variable upon completion:\n" -" CHECKMD5STATUS The status of the MD5 check, one of the following\n" -" MATCH | NOMATCH\n"; - -STANDARD_LOCAL_USER; - -LOCAL_USER_DECL; - -/*--- md5_exec: Calculate MD5 checksum (hash) on given string and - return it in channel variable ---*/ -static int md5_exec(struct ast_channel *chan, void *data) -{ - int res=0; - struct localuser *u; - char *varname= NULL; /* Variable to set */ - char *string = NULL; /* String to calculate on */ - char retvar[50]; /* Return value */ - static int dep_warning = 0; - - if (!dep_warning) { - ast_log(LOG_WARNING, "This application has been deprecated, please use the MD5 function instead.\n"); - dep_warning = 1; - } - - if (ast_strlen_zero(data)) { - ast_log(LOG_WARNING, "Syntax: md5(<varname>=<string>) - missing argument!\n"); - return -1; - } - - LOCAL_USER_ADD(u); - - memset(retvar,0, sizeof(retvar)); - string = ast_strdupa(data); - varname = strsep(&string,"="); - if (ast_strlen_zero(varname)) { - ast_log(LOG_WARNING, "Syntax: md5(<varname>=<string>) - missing argument!\n"); - LOCAL_USER_REMOVE(u); - return -1; - } - ast_md5_hash(retvar, string); - pbx_builtin_setvar_helper(chan, varname, retvar); - LOCAL_USER_REMOVE(u); - return res; -} - -/*--- md5check_exec: Calculate MD5 checksum and compare it with - existing checksum. ---*/ -static int md5check_exec(struct ast_channel *chan, void *data) -{ - int res=0; - struct localuser *u; - char *string = NULL; /* String to calculate on */ - char newhash[50]; /* Return value */ - static int dep_warning = 0; - int priority_jump = 0; - AST_DECLARE_APP_ARGS(args, - AST_APP_ARG(md5hash); - AST_APP_ARG(string); - AST_APP_ARG(options); - ); - - if (!dep_warning) { - ast_log(LOG_WARNING, "This application has been deprecated, please use the CHECK_MD5 function instead.\n"); - dep_warning = 1; - } - - LOCAL_USER_ADD(u); - - if (!(string = ast_strdupa(data))) { - ast_log(LOG_WARNING, "Memory Error!\n"); - LOCAL_USER_REMOVE(u); - return -1; - } - - AST_STANDARD_APP_ARGS(args, string); - - if (args.options) { - if (strchr(args.options, 'j')) - priority_jump = 1; - } - - if (ast_strlen_zero(args.md5hash) || ast_strlen_zero(args.string)) { - ast_log(LOG_WARNING, "Syntax: MD5Check(<md5hash>|<string>[|options]) - missing argument!\n"); - LOCAL_USER_REMOVE(u); - return -1; - } - - memset(newhash,0, sizeof(newhash)); - - ast_md5_hash(newhash, args.string); - if (!strcmp(newhash, args.md5hash)) { /* Verification ok */ - if (option_debug > 2) - ast_log(LOG_DEBUG, "MD5 verified ok: %s -- %s\n", args.md5hash, args.string); - pbx_builtin_setvar_helper(chan, "CHECKMD5STATUS", "MATCH"); - LOCAL_USER_REMOVE(u); - return 0; - } - if (option_debug > 2) - ast_log(LOG_DEBUG, "ERROR: MD5 not verified: %s -- %s\n", args.md5hash, args.string); - pbx_builtin_setvar_helper(chan, "CHECKMD5STATUS", "NOMATCH"); - if (priority_jump || ast_opt_priority_jumping) { - if (ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101)) - if (option_debug > 2) - ast_log(LOG_DEBUG, "ERROR: Can't jump to exten+101 (e%s,p%d), sorry\n", chan->exten,chan->priority+101); - } - LOCAL_USER_REMOVE(u); - return res; -} - -int unload_module(void) -{ - int res; - - res = ast_unregister_application(app_md5); - res |= ast_unregister_application(app_md5check); - - STANDARD_HANGUP_LOCALUSERS; - - return res; -} - -int load_module(void) -{ - int res; - - res = ast_register_application(app_md5check, md5check_exec, desc_md5check, synopsis_md5check); - res |= ast_register_application(app_md5, md5_exec, desc_md5, synopsis_md5); - - return res; -} - -char *description(void) -{ - return tdesc_md5; -} - -int usecount(void) -{ - int res; - STANDARD_USECOUNT(res); - return res; -} - -char *key() -{ - return ASTERISK_GPL_KEY; -} diff --git a/apps/app_setcallerid.c b/apps/app_setcallerid.c deleted file mode 100644 index 877efb53393f92674bfebf5b08f5c7b05e259e61..0000000000000000000000000000000000000000 --- a/apps/app_setcallerid.c +++ /dev/null @@ -1,178 +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 App to set callerid - * - * \ingroup applications - */ - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> - -#include "asterisk.h" - -ASTERISK_FILE_VERSION(__FILE__, "$Revision$") - -#include "asterisk/lock.h" -#include "asterisk/file.h" -#include "asterisk/logger.h" -#include "asterisk/channel.h" -#include "asterisk/pbx.h" -#include "asterisk/module.h" -#include "asterisk/translate.h" -#include "asterisk/image.h" -#include "asterisk/callerid.h" - -static char *app2 = "SetCallerPres"; - -static char *synopsis2 = "Set CallerID Presentation"; - -STANDARD_LOCAL_USER; - -LOCAL_USER_DECL; - -static char *descrip2 = -" SetCallerPres(presentation): Set Caller*ID presentation on a call.\n" -" Valid presentations are:\n" -"\n" -" allowed_not_screened : Presentation Allowed, Not Screened\n" -" allowed_passed_screen : Presentation Allowed, Passed Screen\n" -" allowed_failed_screen : Presentation Allowed, Failed Screen\n" -" allowed : Presentation Allowed, Network Number\n" -" prohib_not_screened : Presentation Prohibited, Not Screened\n" -" prohib_passed_screen : Presentation Prohibited, Passed Screen\n" -" prohib_failed_screen : Presentation Prohibited, Failed Screen\n" -" prohib : Presentation Prohibited, Network Number\n" -" unavailable : Number Unavailable\n" -"\n" -; - -static int setcallerid_pres_exec(struct ast_channel *chan, void *data) -{ - struct localuser *u; - int pres = -1; - - LOCAL_USER_ADD(u); - - pres = ast_parse_caller_presentation(data); - - if (pres < 0) { - ast_log(LOG_WARNING, "'%s' is not a valid presentation (see 'show application SetCallerPres')\n", - (char *) data); - LOCAL_USER_REMOVE(u); - return 0; - } - - chan->cid.cid_pres = pres; - LOCAL_USER_REMOVE(u); - return 0; -} - - - -static char *tdesc = "Set CallerID Application"; - -static char *app = "SetCallerID"; - -static char *synopsis = "Set CallerID"; - -static char *descrip = -" SetCallerID(clid[|a]): Set Caller*ID on a call to a new\n" -"value. Sets ANI as well if a flag is used. \n"; - -static int setcallerid_exec(struct ast_channel *chan, void *data) -{ - int res = 0; - char *tmp = NULL; - char name[256]; - char num[256]; - struct localuser *u; - char *opt; - int anitoo = 0; - - if (ast_strlen_zero(data)) { - ast_log(LOG_WARNING, "SetCallerID requires an argument!\n"); - return 0; - } - - LOCAL_USER_ADD(u); - - tmp = ast_strdupa(data); - if (!tmp) { - ast_log(LOG_ERROR, "Out of memory\n"); - LOCAL_USER_REMOVE(u); - return -1; - } - - opt = strchr(tmp, '|'); - if (opt) { - *opt = '\0'; - opt++; - if (*opt == 'a') - anitoo = 1; - } - - ast_callerid_split(tmp, name, sizeof(name), num, sizeof(num)); - ast_set_callerid(chan, num, name, anitoo ? num : NULL); - - LOCAL_USER_REMOVE(u); - - return res; -} - -int unload_module(void) -{ - int res; - - res = ast_unregister_application(app2); - res |= ast_unregister_application(app); - - STANDARD_HANGUP_LOCALUSERS; - - return res; -} - -int load_module(void) -{ - int res; - - res = ast_register_application(app2, setcallerid_pres_exec, synopsis2, descrip2); - res |= ast_register_application(app, setcallerid_exec, synopsis, descrip); - - return res; -} - -char *description(void) -{ - return tdesc; -} - -int usecount(void) -{ - int res; - STANDARD_USECOUNT(res); - return res; -} - -char *key() -{ - return ASTERISK_GPL_KEY; -} diff --git a/apps/app_setcidname.c b/apps/app_setcidname.c deleted file mode 100644 index 6906c132a65073a0c5c687a2b27198e93df9cd87..0000000000000000000000000000000000000000 --- a/apps/app_setcidname.c +++ /dev/null @@ -1,132 +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 App to set callerid - * - * \ingroup applications - */ - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> - -#include "asterisk.h" - -ASTERISK_FILE_VERSION(__FILE__, "$Revision$") - -#include "asterisk/lock.h" -#include "asterisk/file.h" -#include "asterisk/logger.h" -#include "asterisk/channel.h" -#include "asterisk/pbx.h" -#include "asterisk/module.h" -#include "asterisk/translate.h" -#include "asterisk/image.h" -#include "asterisk/callerid.h" -#include "asterisk/utils.h" - -static char *tdesc = "Set CallerID Name"; - -static char *app = "SetCIDName"; - -static char *synopsis = "Set CallerID Name"; - -static char *descrip = -" SetCIDName(cname[|a]): Set Caller*ID Name on a call to a new\n" -"value, while preserving the original Caller*ID number. This is\n" -"useful for providing additional information to the called\n" -"party. \n" -"SetCIDName has been deprecated in favor of the function\n" -"CALLERID(name)\n"; - -STANDARD_LOCAL_USER; - -LOCAL_USER_DECL; - -static int setcallerid_exec(struct ast_channel *chan, void *data) -{ - char *tmp = NULL; - struct localuser *u; - char *opt; - static int deprecation_warning = 0; - - if (!deprecation_warning) { - ast_log(LOG_WARNING, "SetCIDName is deprecated, please use Set(CALLERID(name)=value) instead.\n"); - deprecation_warning = 1; - } - - if (ast_strlen_zero(data)) { - ast_log(LOG_ERROR, "SetCIDName requires an argument!\n"); - return 0; - } - - LOCAL_USER_ADD(u); - - tmp = ast_strdupa(data); - if (!tmp) { - ast_log(LOG_ERROR, "Out of memory\n"); - LOCAL_USER_REMOVE(u); - return -1; - } - - opt = strchr(tmp, '|'); - if (opt) { - *opt = '\0'; - } - - ast_set_callerid(chan, NULL, tmp, NULL); - - LOCAL_USER_REMOVE(u); - - return 0; -} - -int unload_module(void) -{ - int res; - - res = ast_unregister_application(app); - - STANDARD_HANGUP_LOCALUSERS; - - return res; -} - -int load_module(void) -{ - return ast_register_application(app, setcallerid_exec, synopsis, descrip); -} - -char *description(void) -{ - return tdesc; -} - -int usecount(void) -{ - int res; - STANDARD_USECOUNT(res); - return res; -} - -char *key() -{ - return ASTERISK_GPL_KEY; -} diff --git a/apps/app_setcidnum.c b/apps/app_setcidnum.c deleted file mode 100644 index a8a7e070625636df9699696989d965f31ff8d428..0000000000000000000000000000000000000000 --- a/apps/app_setcidnum.c +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Asterisk -- An open source telephony toolkit. - * - * Copyright (C) 1999 - 2005, Digium, Inc. - * - * Mark Spencer <markster@digium.com> - * Oliver Daudey <traveler@xs4all.nl> - * - * 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 App to set callerid number - * - * \ingroup applications - */ - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> - -#include "asterisk.h" - -ASTERISK_FILE_VERSION(__FILE__, "$Revision$") - -#include "asterisk/lock.h" -#include "asterisk/file.h" -#include "asterisk/logger.h" -#include "asterisk/channel.h" -#include "asterisk/pbx.h" -#include "asterisk/module.h" -#include "asterisk/translate.h" -#include "asterisk/image.h" -#include "asterisk/callerid.h" -#include "asterisk/utils.h" - -static char *tdesc = "Set CallerID Number"; - -static char *app = "SetCIDNum"; - -static char *synopsis = "Set CallerID Number"; - -static char *descrip = -" SetCIDNum(cnum[|a]): Set Caller*ID Number on a call to a new\n" -"value, while preserving the original Caller*ID name. This is\n" -"useful for providing additional information to the called\n" -"party. Sets ANI as well if a flag is used.\n" -"SetCIDNum has been deprecated in favor of the function\n" -"CALLERID(number)\n"; - -STANDARD_LOCAL_USER; - -LOCAL_USER_DECL; - -static int setcallerid_exec(struct ast_channel *chan, void *data) -{ - int res = 0; - struct localuser *u; - char *opt; - int anitoo = 0; - char *tmp = NULL; - static int deprecation_warning = 0; - - LOCAL_USER_ADD(u); - - if (!deprecation_warning) { - ast_log(LOG_WARNING, "SetCIDNum is deprecated, please use Set(CALLERID(number)=value) instead.\n"); - deprecation_warning = 1; - } - - if (data) - tmp = ast_strdupa(data); - else - tmp = ""; - - opt = strchr(tmp, '|'); - if (opt) { - *opt = '\0'; - opt++; - if (*opt == 'a') - anitoo = 1; - } - - ast_set_callerid(chan, tmp, NULL, anitoo ? tmp : NULL); - - LOCAL_USER_REMOVE(u); - - return res; -} - -int unload_module(void) -{ - int res; - - res = ast_unregister_application(app); - - STANDARD_HANGUP_LOCALUSERS; - - return res; -} - -int load_module(void) -{ - return ast_register_application(app, setcallerid_exec, synopsis, descrip); -} - -char *description(void) -{ - return tdesc; -} - -int usecount(void) -{ - int res; - STANDARD_USECOUNT(res); - return res; -} - -char *key() -{ - return ASTERISK_GPL_KEY; -} diff --git a/apps/app_setrdnis.c b/apps/app_setrdnis.c deleted file mode 100644 index 69c3ed568f0d9fdcec19e420ee4ee448937df9d1..0000000000000000000000000000000000000000 --- a/apps/app_setrdnis.c +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Asterisk -- An open source telephony toolkit. - * - * Copyright (C) 1999 - 2005, Digium, Inc. - * - * Mark Spencer <markster@digium.com> - * Oliver Daudey <traveler@xs4all.nl> - * - * 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 App to set rdnis - * - * \ingroup applications - */ - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> - -#include "asterisk.h" - -ASTERISK_FILE_VERSION(__FILE__, "$Revision$") - -#include "asterisk/lock.h" -#include "asterisk/file.h" -#include "asterisk/logger.h" -#include "asterisk/channel.h" -#include "asterisk/pbx.h" -#include "asterisk/module.h" -#include "asterisk/translate.h" -#include "asterisk/image.h" -#include "asterisk/callerid.h" -#include "asterisk/utils.h" - -static char *tdesc = "Set RDNIS Number"; - -static char *app = "SetRDNIS"; - -static char *synopsis = "Set RDNIS Number"; - -static char *descrip = -" SetRDNIS(cnum): Set RDNIS Number on a call to a new\n" -"value.\n" -"SetRDNIS has been deprecated in favor of the function\n" -"CALLERID(rdnis)\n"; - -STANDARD_LOCAL_USER; - -LOCAL_USER_DECL; - -static int setrdnis_exec(struct ast_channel *chan, void *data) -{ - struct localuser *u; - char *opt, *n, *l; - char *tmp = NULL; - static int deprecation_warning = 0; - - LOCAL_USER_ADD(u); - - if (!deprecation_warning) { - ast_log(LOG_WARNING, "SetRDNIS is deprecated, please use Set(CALLERID(rdnis)=value) instead.\n"); - deprecation_warning = 1; - } - - if (data) - tmp = ast_strdupa(data); - else - tmp = ""; - - opt = strchr(tmp, '|'); - if (opt) - *opt = '\0'; - - n = l = NULL; - ast_callerid_parse(tmp, &n, &l); - if (l) { - ast_shrink_phone_number(l); - ast_mutex_lock(&chan->lock); - if (chan->cid.cid_rdnis) - free(chan->cid.cid_rdnis); - chan->cid.cid_rdnis = (l[0]) ? strdup(l) : NULL; - ast_mutex_unlock(&chan->lock); - } - - LOCAL_USER_REMOVE(u); - - return 0; -} - -int unload_module(void) -{ - int res; - - res = ast_unregister_application(app); - - STANDARD_HANGUP_LOCALUSERS; - - return res; -} - -int load_module(void) -{ - return ast_register_application(app, setrdnis_exec, synopsis, descrip); -} - -char *description(void) -{ - return tdesc; -} - -int usecount(void) -{ - int res; - STANDARD_USECOUNT(res); - return res; -} - -char *key() -{ - return ASTERISK_GPL_KEY; -} diff --git a/apps/app_txtcidname.c b/apps/app_txtcidname.c deleted file mode 100644 index f2a65dcb6eac8e929c973716f12c350919ecb930..0000000000000000000000000000000000000000 --- a/apps/app_txtcidname.c +++ /dev/null @@ -1,164 +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 Caller*id name lookup - Look up the caller's name via DNS - * - * \ingroup applications - */ - -#include <stdlib.h> -#include <unistd.h> -#include <string.h> -#include <stdlib.h> -#include <ctype.h> - -#include "asterisk.h" - -ASTERISK_FILE_VERSION(__FILE__, "$Revision$") - -#include "asterisk/logger.h" -#include "asterisk/channel.h" -#include "asterisk/pbx.h" -#include "asterisk/options.h" -#include "asterisk/module.h" -#include "asterisk/enum.h" -#include "asterisk/utils.h" -#include "asterisk/app.h" - -STANDARD_LOCAL_USER; - -LOCAL_USER_DECL; - -static char *tdesc = "TXTCIDName"; - -static char *app = "TXTCIDName"; - -static char *synopsis = "Lookup caller name from TXT record"; - -static char *descrip = -" TXTCIDName(<CallerIDNumber>[|options]): Looks up a Caller Name via DNS and sets\n" -"the variable 'TXTCIDNAME'. TXTCIDName will either be blank\n" -"or return the value found in the TXT record in DNS.\n" -"The option string may contain the following character:\n" -"'j' -- jump to n+101 priority if the lookup fails\n" -"This application sets the following channel variable upon completion:\n" -" TXTCIDNAMESTATUS The status of the lookup as a text string, one of\n" -" SUCCESS | FAILED\n"; - -static int txtcidname_exec(struct ast_channel *chan, void *data) -{ - int res=0; - char tech[80]; - char txt[256] = ""; - char dest[80]; - struct localuser *u; - static int dep_warning = 0; - char *parse = NULL; - int priority_jump = 0; - AST_DECLARE_APP_ARGS(args, - AST_APP_ARG(cidnum); - AST_APP_ARG(options); - ); - - LOCAL_USER_ADD(u); - - if (!dep_warning) { - ast_log(LOG_WARNING, "The TXTCIDName application has been deprecated in favor of the TXTCIDNAME dialplan function.\n"); - dep_warning = 1; - } - - if (ast_strlen_zero(data)) { - ast_log(LOG_WARNING, "TXTCIDName requires an argument (extension[|options])\n"); - LOCAL_USER_REMOVE(u); - return(0); - } - - parse = ast_strdupa(data); - if (!parse) { - ast_log(LOG_ERROR, "Out of memory!\n"); - LOCAL_USER_REMOVE(u); - return -1; - } - - AST_STANDARD_APP_ARGS(args,parse); - - if (args.options) { - if (strchr(args.options, 'j')) - priority_jump = 1; - } - - if (!res) { - res = ast_get_txt(chan, data, dest, sizeof(dest), tech, sizeof(tech), txt, sizeof(txt)); - } - - /* Parse it out */ - if (res > 0) { - if (!ast_strlen_zero(txt)) { - pbx_builtin_setvar_helper(chan, "TXTCIDNAME", txt); - pbx_builtin_setvar_helper(chan, "TXTCIDNAMESTATUS", "SUCCESS"); - if (option_debug > 1) - ast_log(LOG_DEBUG, "TXTCIDNAME got '%s'\n", txt); - } - } - if (!res) { - /* Look for a "busy" place */ - if (priority_jump || ast_opt_priority_jumping) - ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101); - pbx_builtin_setvar_helper(chan, "TXTCIDNAMESTATUS", "FAILED"); - } else if (res > 0) - res = 0; - - LOCAL_USER_REMOVE(u); - - return res; -} - -int unload_module(void) -{ - int res; - - res = ast_unregister_application(app); - - STANDARD_HANGUP_LOCALUSERS; - - return res; -} - -int load_module(void) -{ - return ast_register_application(app, txtcidname_exec, synopsis, descrip); -} - -char *description(void) -{ - return tdesc; -} - -int usecount(void) -{ - int res; - STANDARD_USECOUNT(res); - return res; -} - -char *key() -{ - return ASTERISK_GPL_KEY; -} diff --git a/cli.c b/cli.c index 8ea63ca78963d47ed43149fc14edaaacb7abb114..f1a241e4040c42de6fbd27ee20273e5b0e93e82c 100644 --- a/cli.c +++ b/cli.c @@ -29,6 +29,7 @@ #include <signal.h> #include <string.h> #include <ctype.h> +#include <regex.h> #include "asterisk.h" @@ -42,6 +43,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/channel.h" #include "asterisk/manager.h" #include "asterisk/utils.h" +#include "asterisk/app.h" #include "asterisk/lock.h" /* For rl_filename_completion */ #include "editline/readline/readline.h" @@ -125,6 +127,12 @@ static char softhangup_help[] = " Request that a channel be hung up. The hangup takes effect\n" " the next time the driver reads or writes from the channel\n"; +static char group_show_channels_help[] = +"Usage: group show channels [pattern]\n" +" Lists all currently active channels with channel group(s) specified.\n" +" Optional regular expression pattern is matched to group names for each\n" +" channel.\n"; + static int handle_load(int fd, int argc, char *argv[]) { if (argc != 2) @@ -887,6 +895,55 @@ static char *complete_fn(char *line, char *word, int pos, int state) return c ? strdup(c) : c; } +static int group_show_channels(int fd, int argc, char *argv[]) +{ +#define FORMAT_STRING "%-25s %-20s %-20s\n" + + struct ast_channel *c = NULL; + int numchans = 0; + struct ast_var_t *current; + struct varshead *headp; + regex_t regexbuf; + int havepattern = 0; + + if (argc < 3 || argc > 4) + return RESULT_SHOWUSAGE; + + if (argc == 4) { + if (regcomp(®exbuf, argv[3], REG_EXTENDED | REG_NOSUB)) + return RESULT_SHOWUSAGE; + havepattern = 1; + } + + ast_cli(fd, FORMAT_STRING, "Channel", "Group", "Category"); + while ( (c = ast_channel_walk_locked(c)) != NULL) { + headp=&c->varshead; + AST_LIST_TRAVERSE(headp,current,entries) { + if (!strncmp(ast_var_name(current), GROUP_CATEGORY_PREFIX "_", strlen(GROUP_CATEGORY_PREFIX) + 1)) { + if (!havepattern || !regexec(®exbuf, ast_var_value(current), 0, NULL, 0)) { + ast_cli(fd, FORMAT_STRING, c->name, ast_var_value(current), + (ast_var_name(current) + strlen(GROUP_CATEGORY_PREFIX) + 1)); + numchans++; + } + } else if (!strcmp(ast_var_name(current), GROUP_CATEGORY_PREFIX)) { + if (!havepattern || !regexec(®exbuf, ast_var_value(current), 0, NULL, 0)) { + ast_cli(fd, FORMAT_STRING, c->name, ast_var_value(current), "(default)"); + numchans++; + } + } + } + numchans++; + ast_mutex_unlock(&c->lock); + } + + if (havepattern) + regfree(®exbuf); + + ast_cli(fd, "%d active channel%s\n", numchans, (numchans != 1) ? "s" : ""); + return RESULT_SUCCESS; +#undef FORMAT_STRING +} + static int handle_help(int fd, int argc, char *argv[]); static struct ast_cli_entry builtins[] = { @@ -910,6 +967,7 @@ static struct ast_cli_entry builtins[] = { { { "show", "version", NULL }, handle_version, "Display version info", version_help }, { { "soft", "hangup", NULL }, handle_softhangup, "Request a hangup on a given channel", softhangup_help, complete_ch_3 }, { { "unload", NULL }, handle_unload, "Unload a dynamic module by name", unload_help, complete_fn }, + { { "group", "show", "channels", NULL }, group_show_channels, "Show active channels with group(s)", group_show_channels_help}, { { NULL }, NULL, NULL, NULL } }; diff --git a/pbx.c b/pbx.c index 0c0cb668a7d6886ef8b64e2f7eeed8a288bcc5a2..6b1e3acd392c43a552f382028e4507bd9f0adedf 100644 --- a/pbx.c +++ b/pbx.c @@ -199,14 +199,9 @@ static int pbx_builtin_answer(struct ast_channel *, void *); static int pbx_builtin_goto(struct ast_channel *, void *); static int pbx_builtin_hangup(struct ast_channel *, void *); static int pbx_builtin_background(struct ast_channel *, void *); -static int pbx_builtin_dtimeout(struct ast_channel *, void *); -static int pbx_builtin_rtimeout(struct ast_channel *, void *); -static int pbx_builtin_atimeout(struct ast_channel *, void *); static int pbx_builtin_wait(struct ast_channel *, void *); static int pbx_builtin_waitexten(struct ast_channel *, void *); -static int pbx_builtin_setlanguage(struct ast_channel *, void *); static int pbx_builtin_resetcdr(struct ast_channel *, void *); -static int pbx_builtin_setaccount(struct ast_channel *, void *); static int pbx_builtin_setamaflags(struct ast_channel *, void *); static int pbx_builtin_ringing(struct ast_channel *, void *); static int pbx_builtin_progress(struct ast_channel *, void *); @@ -221,7 +216,6 @@ static int pbx_builtin_saynumber(struct ast_channel *, void *); static int pbx_builtin_saydigits(struct ast_channel *, void *); static int pbx_builtin_saycharacters(struct ast_channel *, void *); static int pbx_builtin_sayphonetic(struct ast_channel *, void *); -static int pbx_builtin_setvar_old(struct ast_channel *, void *); int pbx_builtin_setvar(struct ast_channel *, void *); static int pbx_builtin_importvar(struct ast_channel *, void *); @@ -246,13 +240,6 @@ static struct pbx_builtin { /* These applications are built into the PBX core and do not need separate modules */ - { "AbsoluteTimeout", pbx_builtin_atimeout, - "Set absolute maximum time of call", - " AbsoluteTimeout(seconds): This application will set the absolute maximum\n" - "amount of time permitted for a call. A setting of 0 disables the timeout.\n" - " AbsoluteTimeout has been deprecated in favor of Set(TIMEOUT(absolute)=timeout)\n" - }, - { "Answer", pbx_builtin_answer, "Answer a channel if ringing", " Answer([delay]): If the call has not been answered, this application will\n" @@ -298,19 +285,6 @@ static struct pbx_builtin { "Otherwise, this application will wait until the calling channel hangs up.\n" }, - { "DigitTimeout", pbx_builtin_dtimeout, - "Set maximum timeout between digits", - " DigitTimeout(seconds): Set the maximum amount of time permitted between\n" - "digits when the user is typing in an extension. When this timeout expires,\n" - "after the user has started to type in an extension, the extension will be\n" - "considered complete, and will be interpreted. Note that if an extension\n" - "typed in is valid, it will not have to timeout to be tested, so typically\n" - "at the expiry of this timeout, the extension will be considered invalid\n" - "(and thus control would be passed to the 'i' extension, or if it doesn't\n" - "exist the call would be terminated). The default timeout is 5 seconds.\n" - " DigitTimeout has been deprecated in favor of Set(TIMEOUT(digit)=timeout)\n" - }, - { "Goto", pbx_builtin_goto, "Jump to a particular priority, extension, or context", " Goto([[context|]extension|]priority): This application will cause the\n" @@ -377,15 +351,6 @@ static struct pbx_builtin { " v -- Save CDR variables.\n" }, - { "ResponseTimeout", pbx_builtin_rtimeout, - "Set maximum timeout awaiting response", - " ResponseTimeout(seconds): This will set the maximum amount of time permitted\n" - "to wait for an extension to dialed (see the WaitExten application), before the\n" - "timeout occurs. If this timeout is reached, dialplan execution will continue at\n" - "the 't' extension, if it exists.\n" - " ResponseTimeout has been deprecated in favor of Set(TIMEOUT(response)=timeout)\n" - }, - { "Ringing", pbx_builtin_ringing, "Indicate ringing tone", " Ringing(): This application will request that the channel indicate a ringing\n" @@ -420,13 +385,6 @@ static struct pbx_builtin { "alphabet that correspond to the letters in the given string.\n" }, - { "SetAccount", pbx_builtin_setaccount, - "Set the CDR Account Code", - " SetAccount([account]): This application will set the channel account code for\n" - "billing purposes.\n" - " SetAccount has been deprecated in favor of the Set(CDR(accountcode)=account).\n" - }, - { "SetAMAFlags", pbx_builtin_setamaflags, "Set the AMA Flags", " SetAMAFlags([flag]): This channel will set the channel's AMA Flags for billing\n" @@ -439,19 +397,6 @@ static struct pbx_builtin { "the specified value.\n" }, - { "SetLanguage", pbx_builtin_setlanguage, - "Set the channel's preferred language", - " SetLanguage(language): This will set the channel language to the given value.\n" - "This information is used for the syntax in generation of numbers, and to choose\n" - "a sound file in the given language, when it is available.\n" - " For example, if language is set to 'fr' and the file 'demo-congrats' is \n" - "requested to be played, if the file 'fr/demo-congrats' exists, then\n" - "it will play that file. If not, it will play the normal 'demo-congrats'.\n" - "For some language codes, SetLanguage also changes the syntax of some\n" - "Asterisk functions, like SayNumber.\n" - " SetLanguage has been deprecated in favor of Set(LANGUAGE()=language)\n" - }, - { "Set", pbx_builtin_setvar, "Set channel variable(s) or function value(s)", " Set(name1=value1|name2=value2|..[|options])\n" @@ -466,12 +411,6 @@ static struct pbx_builtin { " (applies only to variables, not functions)\n" }, - { "SetVar", pbx_builtin_setvar_old, - "Set channel variable(s)", - " SetVar(name1=value1|name2=value2|..[|options]): This application has been\n" - "deprecated in favor of using the Set application.\n" - }, - { "ImportVar", pbx_builtin_importvar, "Import a variable from a channel into a new variable", " ImportVar(newvar=channelname|variable): This application imports a variable\n" @@ -5447,25 +5386,6 @@ static int pbx_builtin_answer(struct ast_channel *chan, void *data) return res; } -/*! - * \ingroup applications - */ -static int pbx_builtin_setlanguage(struct ast_channel *chan, void *data) -{ - static int deprecation_warning = 0; - - if (!deprecation_warning) { - ast_log(LOG_WARNING, "SetLanguage is deprecated, please use Set(LANGUAGE()=language) instead.\n"); - deprecation_warning = 1; - } - - /* Copy the language as specified */ - if (!ast_strlen_zero(data)) - ast_copy_string(chan->language, data, sizeof(chan->language)); - - return 0; -} - AST_APP_OPTIONS(resetcdr_opts, { AST_APP_OPTION('w', AST_CDR_FLAG_POSTED), AST_APP_OPTION('a', AST_CDR_FLAG_LOCKED), @@ -5494,19 +5414,6 @@ static int pbx_builtin_resetcdr(struct ast_channel *chan, void *data) return 0; } -/*! - * \ingroup applications - */ -static int pbx_builtin_setaccount(struct ast_channel *chan, void *data) -{ - /* Copy the account code as specified */ - if (data) - ast_cdr_setaccount(chan, (char *)data); - else - ast_cdr_setaccount(chan, ""); - return 0; -} - /*! * \ingroup applications */ @@ -5784,75 +5691,6 @@ static int pbx_builtin_background(struct ast_channel *chan, void *data) } } -/*! AbsoluteTimeout - * \ingroup applications - * \todo Remove in 1.3 dev - */ -static int pbx_builtin_atimeout(struct ast_channel *chan, void *data) -{ - static int deprecation_warning = 0; - int x = atoi((char *) data); - - if (!deprecation_warning) { - ast_log(LOG_WARNING, "AbsoluteTimeout is deprecated, please use Set(TIMEOUT(absolute)=timeout) instead.\n"); - deprecation_warning = 1; - } - - /* Set the absolute maximum time how long a call can be connected */ - ast_channel_setwhentohangup(chan,x); - if (option_verbose > 2) - ast_verbose( VERBOSE_PREFIX_3 "Set Absolute Timeout to %d\n", x); - return 0; -} - -/*! ResponseTimeout - * \ingroup applications - * \todo Remove in 1.3 dev - */ -static int pbx_builtin_rtimeout(struct ast_channel *chan, void *data) -{ - static int deprecation_warning = 0; - - if (!deprecation_warning) { - ast_log(LOG_WARNING, "ResponseTimeout is deprecated, please use Set(TIMEOUT(response)=timeout) instead.\n"); - deprecation_warning = 1; - } - - /* If the channel is not in a PBX, return now */ - if (!chan->pbx) - return 0; - - /* Set the timeout for how long to wait between digits */ - chan->pbx->rtimeout = atoi((char *)data); - if (option_verbose > 2) - ast_verbose( VERBOSE_PREFIX_3 "Set Response Timeout to %d\n", chan->pbx->rtimeout); - return 0; -} - -/*! DigitTimeout - * \ingroup applications - * \todo Remove in 1.3 dev - */ -static int pbx_builtin_dtimeout(struct ast_channel *chan, void *data) -{ - static int deprecation_warning = 0; - - if (!deprecation_warning) { - ast_log(LOG_WARNING, "DigitTimeout is deprecated, please use Set(TIMEOUT(digit)=timeout) instead.\n"); - deprecation_warning = 1; - } - - /* If the channel is not in a PBX, return now */ - if (!chan->pbx) - return 0; - - /* Set the timeout for how long to wait between digits */ - chan->pbx->dtimeout = atoi((char *)data); - if (option_verbose > 2) - ast_verbose( VERBOSE_PREFIX_3 "Set Digit Timeout to %d\n", chan->pbx->dtimeout); - return 0; -} - /*! Goto * \ingroup applications */ @@ -5975,18 +5813,6 @@ void pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const } } -int pbx_builtin_setvar_old(struct ast_channel *chan, void *data) -{ - static int deprecation_warning = 0; - - if (!deprecation_warning) { - ast_log(LOG_WARNING, "SetVar is deprecated, please use Set instead.\n"); - deprecation_warning = 1; - } - - return pbx_builtin_setvar(chan, data); -} - int pbx_builtin_setvar(struct ast_channel *chan, void *data) { char *name, *value, *mydata;