Remove deprecated apps and funcs
authorTilghman Lesher <tilghman@meg.abyt.es>
Thu, 21 Sep 2006 19:35:29 +0000 (19:35 +0000)
committerTilghman Lesher <tilghman@meg.abyt.es>
Thu, 21 Sep 2006 19:35:29 +0000 (19:35 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@43439 65c4cc65-6c06-0410-ace0-fbb531ad65f3

12 files changed:
apps/app_hasnewvoicemail.c [deleted file]
apps/app_lookupblacklist.c [deleted file]
apps/app_lookupcidname.c [deleted file]
apps/app_queue.c
apps/app_random.c [deleted file]
apps/app_realtime.c [deleted file]
funcs/func_blacklist.c [new file with mode: 0644]
funcs/func_language.c [deleted file]
funcs/func_md5.c
funcs/func_moh.c [deleted file]
funcs/func_vmcount.c [new file with mode: 0644]
res/res_realtime.c [new file with mode: 0644]

diff --git a/apps/app_hasnewvoicemail.c b/apps/app_hasnewvoicemail.c
deleted file mode 100644 (file)
index 33204bb..0000000
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
- * Asterisk -- An open source telephony toolkit.
- *
- * Changes Copyright (c) 2004 - 2006 Todd Freeman <freeman@andrews.edu>
- * 
- * 95% based on HasNewVoicemail by:
- * 
- * Copyright (c) 2003 Tilghman Lesher.  All rights reserved.
- * 
- * Tilghman Lesher <asterisk-hasnewvoicemail-app@the-tilghman.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 HasVoicemail application
- *
- * \author Todd Freeman <freeman@andrews.edu>
- *
- * \note 95% based on HasNewVoicemail by
- * Tilghman Lesher <asterisk-hasnewvoicemail-app@the-tilghman.com>
- *
- * \ingroup applications
- */
-
-#include "asterisk.h"
-
-ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <dirent.h>
-#include <sys/types.h>
-
-#include "asterisk/file.h"
-#include "asterisk/logger.h"
-#include "asterisk/channel.h"
-#include "asterisk/pbx.h"
-#include "asterisk/module.h"
-#include "asterisk/lock.h"
-#include "asterisk/utils.h"
-#include "asterisk/app.h"
-#include "asterisk/options.h"
-
-static char *app_hasvoicemail = "HasVoicemail";
-static char *hasvoicemail_synopsis = "Conditionally branches to priority + 101 with the right options set";
-static char *hasvoicemail_descrip =
-"HasVoicemail(vmbox[/folder][@context][|varname[|options]])\n"
-"  Optionally sets <varname> to the number of messages in that folder."
-"  Assumes folder of INBOX if not specified.\n"
-"  The option string may contain zero or the following character:\n"
-"      'j' -- jump to priority n+101, if there is voicemail in the folder indicated.\n"
-"  This application sets the following channel variable upon completion:\n"
-"      HASVMSTATUS             The result of the voicemail check returned as a text string as follows\n"
-"              <# of messages in the folder, 0 for NONE>\n";
-
-static char *app_hasnewvoicemail = "HasNewVoicemail";
-static char *hasnewvoicemail_synopsis = "Conditionally branches to priority + 101 with the right options set";
-static char *hasnewvoicemail_descrip =
-"HasNewVoicemail(vmbox[/folder][@context][|varname[|options]])\n"
-"Assumes folder 'INBOX' if folder is not specified. Optionally sets <varname> to the number of messages\n" 
-"in that folder.\n"
-"  The option string may contain zero of the following character:\n"
-"      'j' -- jump to priority n+101, if there is new voicemail in folder 'folder' or INBOX\n"
-"  This application sets the following channel variable upon completion:\n"
-"      HASVMSTATUS             The result of the new voicemail check returned as a text string as follows\n"
-"              <# of messages in the folder, 0 for NONE>\n";
-
-
-static int hasvoicemail_exec(struct ast_channel *chan, void *data)
-{
-       struct ast_module_user *u;
-       char *input, *varname = NULL, *vmbox, *context = "default";
-       char *vmfolder;
-       int vmcount = 0;
-       static int dep_warning = 0;
-       int priority_jump = 0;
-       char tmp[12];
-       AST_DECLARE_APP_ARGS(args,
-               AST_APP_ARG(vmbox);
-               AST_APP_ARG(varname);
-               AST_APP_ARG(options);
-       );
-
-       if (!dep_warning) {
-               ast_log(LOG_WARNING, "The applications HasVoicemail and HasNewVoicemail have been deprecated.  Please use the VMCOUNT() function instead.\n");
-               dep_warning = 1;
-       }
-       
-       if (!data) {
-               ast_log(LOG_WARNING, "HasVoicemail requires an argument (vm-box[/folder][@context][|varname[|options]])\n");
-               return -1;
-       }
-
-       u = ast_module_user_add(chan);
-
-       input = ast_strdupa(data);
-
-       AST_STANDARD_APP_ARGS(args, input);
-
-       vmbox = strsep(&args.vmbox, "@");
-
-       if (!ast_strlen_zero(args.vmbox))
-               context = args.vmbox;
-
-       vmfolder = strchr(vmbox, '/');
-       if (vmfolder) {
-               *vmfolder = '\0';
-               vmfolder++;
-       } else {
-               vmfolder = "INBOX";
-       }
-
-       if (args.options) {
-               if (strchr(args.options, 'j'))
-                       priority_jump = 1;
-       }
-
-       vmcount = ast_app_messagecount(context, vmbox, vmfolder);
-       /* Set the count in the channel variable */
-       if (varname) {
-               snprintf(tmp, sizeof(tmp), "%d", vmcount);
-               pbx_builtin_setvar_helper(chan, varname, tmp);
-       }
-
-       if (vmcount > 0) {
-               /* Branch to the next extension */
-               if (priority_jump || ast_opt_priority_jumping) {
-                       if (ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101)) 
-                               ast_log(LOG_WARNING, "VM box %s@%s has new voicemail, but extension %s, priority %d doesn't exist\n", vmbox, context, chan->exten, chan->priority + 101);
-               }
-       }
-
-       snprintf(tmp, sizeof(tmp), "%d", vmcount);
-       pbx_builtin_setvar_helper(chan, "HASVMSTATUS", tmp);
-       
-       ast_module_user_remove(u);
-
-       return 0;
-}
-
-static int acf_vmcount_exec(struct ast_channel *chan, char *cmd, char *argsstr, char *buf, size_t len)
-{
-       struct ast_module_user *u;
-       char *context;
-       AST_DECLARE_APP_ARGS(args,
-               AST_APP_ARG(vmbox);
-               AST_APP_ARG(folder);
-       );
-
-       u = ast_module_user_add(chan);
-
-       buf[0] = '\0';
-
-       AST_STANDARD_APP_ARGS(args, argsstr);
-
-       if (strchr(args.vmbox, '@')) {
-               context = args.vmbox;
-               args.vmbox = strsep(&context, "@");
-       } else {
-               context = "default";
-       }
-
-       if (ast_strlen_zero(args.folder)) {
-               args.folder = "INBOX";
-       }
-
-       snprintf(buf, len, "%d", ast_app_messagecount(context, args.vmbox, args.folder));
-
-       ast_module_user_remove(u);
-       
-       return 0;
-}
-
-struct ast_custom_function acf_vmcount = {
-       .name = "VMCOUNT",
-       .synopsis = "Counts the voicemail in a specified mailbox",
-       .syntax = "VMCOUNT(vmbox[@context][|folder])",
-       .desc =
-       "  context - defaults to \"default\"\n"
-       "  folder  - defaults to \"INBOX\"\n",
-       .read = acf_vmcount_exec,
-};
-
-static int unload_module(void)
-{
-       int res;
-       
-       res = ast_custom_function_unregister(&acf_vmcount);
-       res |= ast_unregister_application(app_hasvoicemail);
-       res |= ast_unregister_application(app_hasnewvoicemail);
-       
-       ast_module_user_hangup_all();
-
-       return res;
-}
-
-static int load_module(void)
-{
-       int res;
-
-       res = ast_custom_function_register(&acf_vmcount);
-       res |= ast_register_application(app_hasvoicemail, hasvoicemail_exec, hasvoicemail_synopsis, hasvoicemail_descrip);
-       res |= ast_register_application(app_hasnewvoicemail, hasvoicemail_exec, hasnewvoicemail_synopsis, hasnewvoicemail_descrip);
-
-       return res;
-}
-
-AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Indicator for whether a voice mailbox has messages in a given folder.");
diff --git a/apps/app_lookupblacklist.c b/apps/app_lookupblacklist.c
deleted file mode 100644 (file)
index 2eb1e54..0000000
+++ /dev/null
@@ -1,158 +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 lookup the callerid number, and see if it is blacklisted
- *
- * \author Mark Spencer <markster@digium.com>
- *
- * \ingroup applications
- * 
- */
-
-#include "asterisk.h"
-
-ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "asterisk/lock.h"
-#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/translate.h"
-#include "asterisk/image.h"
-#include "asterisk/callerid.h"
-#include "asterisk/astdb.h"
-#include "asterisk/options.h"
-
-static char *app = "LookupBlacklist";
-
-static char *synopsis = "Look up Caller*ID name/number from blacklist database";
-
-static char *descrip =
-  "  LookupBlacklist(options): Looks up the Caller*ID number on the active\n"
-  "channel in the Asterisk database (family 'blacklist').  \n"
-  "The option string may contain the following character:\n"
-  "    'j' -- jump to n+101 priority if the number/name is found in the blacklist\n"
-  "This application sets the following channel variable upon completion:\n"
-  "    LOOKUPBLSTATUS          The status of the Blacklist lookup as a text string, one of\n"
-  "            FOUND | NOTFOUND\n"
-  "Example: exten => 1234,1,LookupBlacklist()\n";
-
-
-static int blacklist_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
-{
-       char blacklist[1];
-       int bl = 0;
-
-       if (chan->cid.cid_num) {
-               if (!ast_db_get("blacklist", chan->cid.cid_num, blacklist, sizeof (blacklist)))
-                       bl = 1;
-       }
-       if (chan->cid.cid_name) {
-               if (!ast_db_get("blacklist", chan->cid.cid_name, blacklist, sizeof (blacklist)))
-                       bl = 1;
-       }
-
-       snprintf(buf, len, "%d", bl);
-       return 0;
-}
-
-static struct ast_custom_function blacklist_function = {
-       .name = "BLACKLIST",
-       .synopsis = "Check if the callerid is on the blacklist",
-       .desc = "Uses astdb to check if the Caller*ID is in family 'blacklist'.  Returns 1 or 0.\n",
-       .syntax = "BLACKLIST()",
-       .read = blacklist_read,
-};
-
-static int
-lookupblacklist_exec (struct ast_channel *chan, void *data)
-{
-       char blacklist[1];
-       struct ast_module_user *u;
-       int bl = 0;
-       int priority_jump = 0;
-       static int dep_warning = 0;
-
-       u = ast_module_user_add(chan);
-
-       if (!dep_warning) {
-               dep_warning = 1;
-               ast_log(LOG_WARNING, "LookupBlacklist is deprecated.  Please use ${BLACKLIST()} instead.\n");
-       }
-
-       if (!ast_strlen_zero(data)) {
-               if (strchr(data, 'j'))
-                       priority_jump = 1;
-       }
-
-       if (chan->cid.cid_num) {
-               if (!ast_db_get("blacklist", chan->cid.cid_num, blacklist, sizeof (blacklist))) {
-                       if (option_verbose > 2)
-                               ast_log(LOG_NOTICE, "Blacklisted number %s found\n",chan->cid.cid_num);
-                       bl = 1;
-               }
-       }
-       if (chan->cid.cid_name) {
-               if (!ast_db_get("blacklist", chan->cid.cid_name, blacklist, sizeof (blacklist))) {
-                       if (option_verbose > 2)
-                               ast_log (LOG_NOTICE,"Blacklisted name \"%s\" found\n",chan->cid.cid_name);
-                       bl = 1;
-               }
-       }
-
-       if (bl) {
-               if (priority_jump || ast_opt_priority_jumping) 
-                       ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
-               pbx_builtin_setvar_helper(chan, "LOOKUPBLSTATUS", "FOUND");
-       } else
-               pbx_builtin_setvar_helper(chan, "LOOKUPBLSTATUS", "NOTFOUND");  
-
-       ast_module_user_remove(u);
-
-       return 0;
-}
-
-static int unload_module(void)
-{
-       int res;
-
-       res = ast_unregister_application(app);
-       res |= ast_custom_function_unregister(&blacklist_function);
-
-       ast_module_user_hangup_all();
-
-       return res;     
-}
-
-static int load_module(void)
-{
-       int res = ast_custom_function_register(&blacklist_function);
-       res |= ast_register_application (app, lookupblacklist_exec, synopsis,descrip);
-       return res;
-}
-
-AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Look up Caller*ID name/number from blacklist database");
diff --git a/apps/app_lookupcidname.c b/apps/app_lookupcidname.c
deleted file mode 100644 (file)
index 5a0042a..0000000
+++ /dev/null
@@ -1,101 +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 name from database, based on directory number
- *
- * \author Mark Spencer <markster@digium.com>
- * 
- * \ingroup applications
- */
-
-#include "asterisk.h"
-
-ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "asterisk/lock.h"
-#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/translate.h"
-#include "asterisk/image.h"
-#include "asterisk/callerid.h"
-#include "asterisk/astdb.h"
-
-static char *app = "LookupCIDName";
-
-static char *synopsis = "Look up CallerID Name from local database";
-
-static char *descrip =
-  "  LookupCIDName: Looks up the Caller*ID number on the active\n"
-  "channel in the Asterisk database (family 'cidname') and sets the\n"
-  "Caller*ID name.  Does nothing if no Caller*ID was received on the\n"
-  "channel.  This is useful if you do not subscribe to Caller*ID\n"
-  "name delivery, or if you want to change the names on some incoming\n"
-  "calls.\n";
-
-
-static int lookupcidname_exec (struct ast_channel *chan, void *data)
-{
-       char dbname[64];
-       struct ast_module_user *u;
-       static int dep_warning = 0;
-
-       u = ast_module_user_add(chan);
-       if (!dep_warning) {
-               dep_warning = 1;
-               ast_log(LOG_WARNING, "LookupCIDName is deprecated.  Please use ${DB(cidname/${CALLERID(num)})} instead.\n");
-       }
-       if (chan->cid.cid_num) {
-               if (!ast_db_get ("cidname", chan->cid.cid_num, dbname, sizeof (dbname))) {
-                       ast_set_callerid (chan, NULL, dbname, NULL);
-                       if (option_verbose > 2)
-                               ast_verbose (VERBOSE_PREFIX_3 "Changed Caller*ID name to %s\n",
-                                            dbname);
-               }
-       }
-       ast_module_user_remove(u);
-
-       return 0;
-}
-
-static int unload_module(void)
-{
-       int res;
-
-       res = ast_unregister_application (app);
-
-       ast_module_user_hangup_all();
-
-       return res;
-}
-
-static int load_module(void)
-{
-       return ast_register_application (app, lookupcidname_exec, synopsis, descrip);
-}
-
-AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Look up CallerID Name from local database");
index a8eda76..2e43f25 100644 (file)
@@ -3646,16 +3646,6 @@ static int queue_function_queuememberlist(struct ast_channel *chan, char *cmd, c
        return 0;
 }
 
-static struct ast_custom_function queueagentcount_function = {
-       .name = "QUEUEAGENTCOUNT",
-       .synopsis = "Count number of agents answering a queue",
-       .syntax = "QUEUEAGENTCOUNT(<queuename>)",
-       .desc =
-"Returns the number of members currently associated with the specified queue.\n"
-"This function is deprecated.  You should use QUEUE_MEMBER_COUNT() instead.\n",
-       .read = queue_function_qac,
-};
-
 static struct ast_custom_function queuemembercount_function = {
        .name = "QUEUE_MEMBER_COUNT",
        .synopsis = "Count number of members answering a queue",
@@ -4438,7 +4428,6 @@ static int unload_module(void)
        res |= ast_unregister_application(app_upqm);
        res |= ast_unregister_application(app_ql);
        res |= ast_unregister_application(app);
-       res |= ast_custom_function_unregister(&queueagentcount_function);
        res |= ast_custom_function_unregister(&queuemembercount_function);
        res |= ast_custom_function_unregister(&queuememberlist_function);
        res |= ast_custom_function_unregister(&queuewaitingcount_function);
@@ -4469,7 +4458,6 @@ static int load_module(void)
        res |= ast_manager_register("QueueAdd", EVENT_FLAG_AGENT, manager_add_queue_member, "Add interface to queue.");
        res |= ast_manager_register("QueueRemove", EVENT_FLAG_AGENT, manager_remove_queue_member, "Remove interface from queue.");
        res |= ast_manager_register("QueuePause", EVENT_FLAG_AGENT, manager_pause_queue_member, "Makes a queue member temporarily unavailable");
-       res |= ast_custom_function_register(&queueagentcount_function);
        res |= ast_custom_function_register(&queuemembercount_function);
        res |= ast_custom_function_register(&queuememberlist_function);
        res |= ast_custom_function_register(&queuewaitingcount_function);
diff --git a/apps/app_random.c b/apps/app_random.c
deleted file mode 100644 (file)
index 8484f65..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Asterisk -- An open source telephony toolkit.
- *
- * Copyright (c) 2003 - 2005 Tilghman Lesher.  All rights reserved.
- *
- * Tilghman Lesher <asterisk__app_random__200508@the-tilghman.com>
- *
- * This code is released by the author with no restrictions on usage or distribution.
- *
- * 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 Random application
- *
- * \author Tilghman Lesher <asterisk__app_random__200508@the-tilghman.com>
- * \ingroup applications
- */
-
-#include "asterisk.h"
-
-ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-
-#include "asterisk/file.h"
-#include "asterisk/logger.h"
-#include "asterisk/options.h"
-#include "asterisk/channel.h"
-#include "asterisk/pbx.h"
-#include "asterisk/module.h"
-
-/*! \todo The Random() app should be removed from trunk following the release of 1.4 */
-
-static char *app_random = "Random";
-
-static char *random_synopsis = "Conditionally branches, based upon a probability";
-
-static char *random_descrip =
-"Random([probability]:[[context|]extension|]priority)\n"
-"  probability := INTEGER in the range 1 to 100\n"
-"DEPRECATED: Use GotoIf($[${RAND(1,100)} > <number>]?<label>)\n";
-
-
-static int random_exec(struct ast_channel *chan, void *data)
-{
-       int res=0;
-       struct ast_module_user *u;
-
-       char *s;
-       char *prob;
-       int probint;
-       static int deprecated = 0;
-
-       if (ast_strlen_zero(data)) {
-               ast_log(LOG_WARNING, "Random requires an argument ([probability]:[[context|]extension|]priority)\n");
-               return -1;
-       }
-       
-       u = ast_module_user_add(chan);
-
-       s = ast_strdupa(data);
-
-       prob = strsep(&s,":");
-       if ((!prob) || (sscanf(prob, "%d", &probint) != 1))
-               probint = 0;
-
-       if (!deprecated) {
-               deprecated = 1;
-               ast_log(LOG_WARNING, "Random is deprecated in Asterisk 1.4.  Replace with GotoIf($[${RAND(0,99)} + %d >= 100]?%s)\n", probint, s);
-       }
-
-       if ((ast_random() % 100) + probint >= 100) {
-               res = ast_parseable_goto(chan, s);
-               if (option_verbose > 2)
-                       ast_verbose( VERBOSE_PREFIX_3 "Random branches to (%s,%s,%d)\n",
-                               chan->context,chan->exten, chan->priority+1);
-       }
-       ast_module_user_remove(u);
-       return res;
-}
-
-static int unload_module(void)
-{
-       int res;
-       
-       res = ast_unregister_application(app_random);
-       
-       ast_module_user_hangup_all();
-
-       return res;     
-}
-
-static int load_module(void)
-{
-       return ast_register_application(app_random, random_exec, random_synopsis, random_descrip);
-}
-
-AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Random goto");
diff --git a/apps/app_realtime.c b/apps/app_realtime.c
deleted file mode 100644 (file)
index 48e1dca..0000000
+++ /dev/null
@@ -1,261 +0,0 @@
-/*
- * Asterisk -- An open source telephony toolkit.
- *
- * Copyright (C) 1999 - 2005, Digium, Inc.
- *
- * Anthony Minessale <anthmct@yahoo.com>
- * 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 RealTime App
- *
- * \author Anthony Minessale <anthmct@yahoo.com>
- * \author Mark Spencer <markster@digium.com>
- * 
- * \ingroup applications
- */
-
-#include "asterisk.h"
-
-ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "asterisk/file.h"
-#include "asterisk/logger.h"
-#include "asterisk/channel.h"
-#include "asterisk/options.h"
-#include "asterisk/pbx.h"
-#include "asterisk/config.h"
-#include "asterisk/module.h"
-#include "asterisk/lock.h"
-#include "asterisk/cli.h"
-
-#define next_one(var) var = var->next
-#define crop_data(str) { *(str) = '\0' ; (str)++; }
-
-static char *app = "RealTime";
-static char *uapp = "RealTimeUpdate";
-static char *synopsis = "Realtime Data Lookup";
-static char *usynopsis = "Realtime Data Rewrite";
-static char *USAGE = "RealTime(<family>|<colmatch>|<value>[|<prefix>])";
-static char *UUSAGE = "RealTimeUpdate(<family>|<colmatch>|<value>|<newcol>|<newval>)";
-static char *desc =
-"Use the RealTime config handler system to read data into channel variables.\n"
-"RealTime(<family>|<colmatch>|<value>[|<prefix>])\n\n"
-"All unique column names will be set as channel variables with optional prefix\n"
-"to the name.  For example, a prefix of 'var_' would make the column 'name'\n"
-"become the variable ${var_name}.  REALTIMECOUNT will be set with the number\n"
-"of values read.\n";
-static char *udesc = "Use the RealTime config handler system to update a value\n"
-"RealTimeUpdate(<family>|<colmatch>|<value>|<newcol>|<newval>)\n\n"
-"The column <newcol> in 'family' matching column <colmatch>=<value> will be\n"
-"updated to <newval>.  REALTIMECOUNT will be set with the number of rows\n"
-"updated or -1 if an error occurs.\n";
-
-
-static int cli_realtime_load(int fd, int argc, char **argv) 
-{
-       char *header_format = "%30s  %-30s\n";
-       struct ast_variable *var=NULL;
-
-       if(argc<5) {
-               ast_cli(fd, "You must supply a family name, a column to match on, and a value to match to.\n");
-               return RESULT_FAILURE;
-       }
-
-       var = ast_load_realtime(argv[2], argv[3], argv[4], NULL);
-
-       if(var) {
-               ast_cli(fd, header_format, "Column Name", "Column Value");
-               ast_cli(fd, header_format, "--------------------", "--------------------");
-               while(var) {
-                       ast_cli(fd, header_format, var->name, var->value);
-                       var = var->next;
-               }
-       } else {
-               ast_cli(fd, "No rows found matching search criteria.\n");
-       }
-       return RESULT_SUCCESS;
-}
-
-static int cli_realtime_update(int fd, int argc, char **argv) {
-       int res = 0;
-
-       if(argc<7) {
-               ast_cli(fd, "You must supply a family name, a column to update on, a new value, column to match, and value to to match.\n");
-               ast_cli(fd, "Ex: realtime update sipfriends name bobsphone port 4343\n will execute SQL as UPDATE sipfriends SET port = 4343 WHERE name = bobsphone\n");
-               return RESULT_FAILURE;
-       }
-
-       res = ast_update_realtime(argv[2], argv[3], argv[4], argv[5], argv[6], NULL);
-
-       if(res < 0) {
-               ast_cli(fd, "Failed to update. Check the debug log for possible SQL related entries.\n");
-               return RESULT_SUCCESS;
-       }
-
-       ast_cli(fd, "Updated %d RealTime record%s.\n", res, (res != 1) ? "s" : "");
-
-       return RESULT_SUCCESS;
-}
-
-static char cli_realtime_load_usage[] =
-"Usage: realtime load <family> <colmatch> <value>\n"
-"       Prints out a list of variables using the RealTime driver.\n";
-
-static char cli_realtime_update_usage[] =
-"Usage: realtime update <family> <colmatch> <value>\n"
-"       Update a single variable using the RealTime driver.\n";
-
-static struct ast_cli_entry cli_realtime[] = {
-       { { "realtime", "load", NULL, NULL },
-       cli_realtime_load, "Used to print out RealTime variables.",
-       cli_realtime_load_usage, NULL },
-
-       { { "realtime", "update", NULL, NULL },
-       cli_realtime_update, "Used to update RealTime variables.",
-       cli_realtime_update_usage, NULL },
-};
-
-static int realtime_update_exec(struct ast_channel *chan, void *data) 
-{
-       char *family=NULL, *colmatch=NULL, *value=NULL, *newcol=NULL, *newval=NULL;
-       struct ast_module_user *u;
-       int res = 0, count = 0;
-       char countc[13];
-
-        ast_log(LOG_WARNING, "The RealTimeUpdate application has been deprecated in favor of the REALTIME dialplan function.\n");
-
-       if (ast_strlen_zero(data)) {
-               ast_log(LOG_ERROR,"Invalid input: usage %s\n",UUSAGE);
-               return -1;
-       }
-       
-       u = ast_module_user_add(chan);
-
-       family = ast_strdupa(data);
-       if ((colmatch = strchr(family,'|'))) {
-               crop_data(colmatch);
-               if ((value = strchr(colmatch,'|'))) {
-                       crop_data(value);
-                       if ((newcol = strchr(value,'|'))) {
-                               crop_data(newcol);
-                               if ((newval = strchr(newcol,'|'))) 
-                                       crop_data(newval);
-                       }
-               }
-       }
-       if (! (family && value && colmatch && newcol && newval) ) {
-               ast_log(LOG_ERROR,"Invalid input: usage %s\n",UUSAGE);
-               res = -1;
-       } else {
-               count = ast_update_realtime(family,colmatch,value,newcol,newval,NULL);
-       }
-
-       snprintf(countc, sizeof(countc), "%d", count);
-       pbx_builtin_setvar_helper(chan, "REALTIMECOUNT", countc);
-
-       ast_module_user_remove(u);
-       
-       return res;
-}
-
-
-static int realtime_exec(struct ast_channel *chan, void *data)
-{
-       int res=0, count=0;
-       struct ast_module_user *u;
-       struct ast_variable *var, *itt;
-       char *family=NULL, *colmatch=NULL, *value=NULL, *prefix=NULL, *vname=NULL;
-       char countc[13];
-       size_t len;
-               
-        ast_log(LOG_WARNING, "The RealTime application has been deprecated in favor of the REALTIME dialplan function.\n");
-
-       if (ast_strlen_zero(data)) {
-               ast_log(LOG_ERROR,"Invalid input: usage %s\n",USAGE);
-               return -1;
-       }
-       
-       u = ast_module_user_add(chan);
-
-       family = ast_strdupa(data);
-       if ((colmatch = strchr(family,'|'))) {
-               crop_data(colmatch);
-               if ((value = strchr(colmatch,'|'))) {
-                       crop_data(value);
-                       if ((prefix = strchr(value,'|')))
-                               crop_data(prefix);
-               }
-       }
-       if (! (family && value && colmatch) ) {
-               ast_log(LOG_ERROR,"Invalid input: usage %s\n",USAGE);
-               res = -1;
-       } else {
-               if (option_verbose > 3)
-                       ast_verbose(VERBOSE_PREFIX_4"Realtime Lookup: family:'%s' colmatch:'%s' value:'%s'\n",family,colmatch,value);
-               if ((var = ast_load_realtime(family, colmatch, value, NULL))) {
-                       for (itt = var; itt; itt = itt->next) {
-                               if(prefix) {
-                                       len = strlen(prefix) + strlen(itt->name) + 2;
-                                       vname = alloca(len);
-                                       snprintf(vname,len,"%s%s",prefix,itt->name);
-                                       
-                               } else 
-                                       vname = itt->name;
-
-                               pbx_builtin_setvar_helper(chan, vname, itt->value);
-                               count++;
-                       }
-                       ast_variables_destroy(var);
-               } else if (option_verbose > 3)
-                       ast_verbose(VERBOSE_PREFIX_4"No Realtime Matches Found.\n");
-       }
-       snprintf(countc, sizeof(countc), "%d", count);
-       pbx_builtin_setvar_helper(chan, "REALTIMECOUNT", countc);
-       
-       ast_module_user_remove(u);
-       return res;
-}
-
-static int unload_module(void)
-{
-       int res;
-
-       ast_cli_unregister_multiple(cli_realtime, sizeof(cli_realtime) / sizeof(struct ast_cli_entry));
-       res = ast_unregister_application(uapp);
-       res |= ast_unregister_application(app);
-
-       ast_module_user_hangup_all();
-
-       return res;
-}
-
-static int load_module(void)
-{
-       int res;
-
-       ast_cli_register_multiple(cli_realtime, sizeof(cli_realtime) / sizeof(struct ast_cli_entry));
-       res = ast_register_application(uapp, realtime_update_exec, usynopsis, udesc);
-       res |= ast_register_application(app, realtime_exec, synopsis, desc);
-
-       return res;
-}
-
-AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Realtime Data Lookup/Rewrite");
diff --git a/funcs/func_blacklist.c b/funcs/func_blacklist.c
new file mode 100644 (file)
index 0000000..2d12919
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * 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 Function to lookup the callerid number, and see if it is blacklisted
+ *
+ * \author Mark Spencer <markster@digium.com>
+ *
+ * \ingroup functions
+ * 
+ */
+
+#include "asterisk.h"
+
+ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "asterisk/lock.h"
+#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/translate.h"
+#include "asterisk/image.h"
+#include "asterisk/callerid.h"
+#include "asterisk/astdb.h"
+#include "asterisk/options.h"
+
+static int blacklist_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
+{
+       char blacklist[1];
+       int bl = 0;
+
+       if (chan->cid.cid_num) {
+               if (!ast_db_get("blacklist", chan->cid.cid_num, blacklist, sizeof (blacklist)))
+                       bl = 1;
+       }
+       if (chan->cid.cid_name) {
+               if (!ast_db_get("blacklist", chan->cid.cid_name, blacklist, sizeof (blacklist)))
+                       bl = 1;
+       }
+
+       snprintf(buf, len, "%d", bl);
+       return 0;
+}
+
+static struct ast_custom_function blacklist_function = {
+       .name = "BLACKLIST",
+       .synopsis = "Check if the callerid is on the blacklist",
+       .desc = "Uses astdb to check if the Caller*ID is in family 'blacklist'.  Returns 1 or 0.\n",
+       .syntax = "BLACKLIST()",
+       .read = blacklist_read,
+};
+
+static int unload_module(void)
+{
+       int res = ast_custom_function_unregister(&blacklist_function);
+       ast_module_user_hangup_all();
+       return res;     
+}
+
+static int load_module(void)
+{
+       return ast_custom_function_register(&blacklist_function);
+}
+
+AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Look up Caller*ID name/number from blacklist database");
diff --git a/funcs/func_language.c b/funcs/func_language.c
deleted file mode 100644 (file)
index af6f9d0..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Asterisk -- An open source telephony toolkit.
- *
- * Copyright (C) 1999 - 2006, 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 "asterisk.h"
-
-ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-
-#include "asterisk/module.h"
-#include "asterisk/channel.h"
-#include "asterisk/pbx.h"
-#include "asterisk/logger.h"
-#include "asterisk/utils.h"
-#include "asterisk/app.h"
-#include "asterisk/stringfields.h"
-
-static int depwarning = 0;
-
-static int language_read(struct ast_channel *chan, char *cmd, char *data,
-                        char *buf, size_t len)
-{
-       if (!depwarning) {
-               depwarning = 1;
-               ast_log(LOG_WARNING,
-                               "LANGUAGE() is deprecated; use CHANNEL(language) instead.\n");
-       }
-
-       ast_copy_string(buf, chan->language, len);
-
-       return 0;
-}
-
-static int language_write(struct ast_channel *chan, char *cmd, char *data,
-                         const char *value)
-{
-       if (!depwarning) {
-               depwarning = 1;
-               ast_log(LOG_WARNING,
-                               "LANGUAGE() is deprecated; use CHANNEL(language) instead.\n");
-       }
-
-       if (value)
-               ast_string_field_set(chan, language, value);
-
-       return 0;
-}
-
-static struct ast_custom_function language_function = {
-       .name = "LANGUAGE",
-       .synopsis = "Gets or sets the channel's language.",
-       .syntax = "LANGUAGE()",
-       .desc = "Deprecated. Use CHANNEL(language) instead.\n",
-       .read = language_read,
-       .write = language_write,
-};
-
-static int unload_module(void)
-{
-       return ast_custom_function_unregister(&language_function);
-}
-
-static int load_module(void)
-{
-       return ast_custom_function_register(&language_function);
-}
-
-AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Channel language dialplan function");
index db6be8f..9b58693 100644 (file)
@@ -54,42 +54,6 @@ static int md5(struct ast_channel *chan, char *cmd, char *data,
        return 0;
 }
 
-static int checkmd5(struct ast_channel *chan, char *cmd, char *parse,
-                   char *buf, size_t len)
-{
-       char newmd5[33];
-       static int deprecated = 0;
-       AST_DECLARE_APP_ARGS(args, AST_APP_ARG(digest); AST_APP_ARG(data););
-
-       if (ast_strlen_zero(parse)) {
-               ast_log(LOG_WARNING,
-                               "Syntax: CHECK_MD5(<digest>,<data>) - missing argument!\n");
-               return -1;
-       }
-
-       AST_STANDARD_APP_ARGS(args, parse);
-
-       if (args.argc < 2) {
-               ast_log(LOG_WARNING,
-                               "Syntax: CHECK_MD5(<digest>,<data>) - missing argument!\n");
-               return -1;
-       }
-
-       if (!deprecated) {
-               deprecated = 1;
-               ast_log(LOG_WARNING, "CHECK_MD5() is deprecated in Asterisk 1.4 and later.\n");
-       }
-
-       ast_md5_hash(newmd5, args.data);
-
-       if (!strcasecmp(newmd5, args.digest))   /* they match */
-               ast_copy_string(buf, "1", len);
-       else
-               ast_copy_string(buf, "0", len);
-
-       return 0;
-}
-
 static struct ast_custom_function md5_function = {
        .name = "MD5",
        .synopsis = "Computes an MD5 digest",
@@ -97,24 +61,14 @@ static struct ast_custom_function md5_function = {
        .read = md5,
 };
 
-static 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 = checkmd5,
-};
-
 static int unload_module(void)
 {
-       return ast_custom_function_unregister(&md5_function) |
-               ast_custom_function_unregister(&checkmd5_function);
+       return ast_custom_function_unregister(&md5_function);
 }
 
 static int load_module(void)
 {
-       return ast_custom_function_register(&md5_function) |
-               ast_custom_function_register(&checkmd5_function);
+       return ast_custom_function_register(&md5_function);
 }
 
 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "MD5 digest dialplan functions");
diff --git a/funcs/func_moh.c b/funcs/func_moh.c
deleted file mode 100644 (file)
index c8e29a7..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Asterisk -- An open source telephony toolkit.
- *
- * Copyright (C) 1999 - 2006, 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
- *
- * \author Russell Bryant <russelb@clemson.edu> 
- */
-
-#include "asterisk.h"
-
-ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "asterisk/module.h"
-#include "asterisk/channel.h"
-#include "asterisk/pbx.h"
-#include "asterisk/utils.h"
-#include "asterisk/stringfields.h"
-
-static int depwarning = 0;
-
-static int moh_read(struct ast_channel *chan, char *cmd, char *data,
-                   char *buf, size_t len)
-{
-       if (!depwarning) {
-               depwarning = 1;
-               ast_log(LOG_WARNING, "MUSICCLASS() is deprecated; use CHANNEL(musicclass) instead.\n");
-       }
-
-       ast_copy_string(buf, chan->musicclass, len);
-
-       return 0;
-}
-
-static int moh_write(struct ast_channel *chan, char *cmd, char *data,
-                    const char *value)
-{
-       if (!depwarning) {
-               depwarning = 1;
-               ast_log(LOG_WARNING, "MUSICCLASS() is deprecated; use CHANNEL(musicclass) instead.\n");
-       }
-
-       ast_string_field_set(chan, musicclass, value);
-
-       return 0;
-}
-
-static struct ast_custom_function moh_function = {
-       .name = "MUSICCLASS",
-       .synopsis = "Read or Set the MusicOnHold class",
-       .syntax = "MUSICCLASS()",
-       .desc = "Deprecated. Use CHANNEL(musicclass) instead.\n",
-       .read = moh_read,
-       .write = moh_write,
-};
-
-static int unload_module(void)
-{
-       return ast_custom_function_unregister(&moh_function);
-}
-
-static int load_module(void)
-{
-       return ast_custom_function_register(&moh_function);
-}
-
-AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Music-on-hold dialplan function");
diff --git a/funcs/func_vmcount.c b/funcs/func_vmcount.c
new file mode 100644 (file)
index 0000000..10ff000
--- /dev/null
@@ -0,0 +1,104 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (c) 2006 Tilghman Lesher.  All rights reserved.
+ * 
+ * Tilghman Lesher <asterisk-vmcount-func@the-tilghman.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 VMCOUNT dialplan function
+ *
+ * \author Tilghman Lesher <asterisk-vmcount-func@the-tilghman.com>
+ *
+ * \ingroup functions
+ */
+
+#include "asterisk.h"
+
+ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <dirent.h>
+#include <sys/types.h>
+
+#include "asterisk/file.h"
+#include "asterisk/channel.h"
+#include "asterisk/pbx.h"
+#include "asterisk/module.h"
+#include "asterisk/lock.h"
+#include "asterisk/utils.h"
+#include "asterisk/app.h"
+#include "asterisk/options.h"
+
+static int acf_vmcount_exec(struct ast_channel *chan, char *cmd, char *argsstr, char *buf, size_t len)
+{
+       struct ast_module_user *u;
+       char *context;
+       AST_DECLARE_APP_ARGS(args,
+               AST_APP_ARG(vmbox);
+               AST_APP_ARG(folder);
+       );
+
+       u = ast_module_user_add(chan);
+
+       buf[0] = '\0';
+
+       AST_STANDARD_APP_ARGS(args, argsstr);
+
+       if (strchr(args.vmbox, '@')) {
+               context = args.vmbox;
+               args.vmbox = strsep(&context, "@");
+       } else {
+               context = "default";
+       }
+
+       if (ast_strlen_zero(args.folder)) {
+               args.folder = "INBOX";
+       }
+
+       snprintf(buf, len, "%d", ast_app_messagecount(context, args.vmbox, args.folder));
+
+       ast_module_user_remove(u);
+       
+       return 0;
+}
+
+struct ast_custom_function acf_vmcount = {
+       .name = "VMCOUNT",
+       .synopsis = "Counts the voicemail in a specified mailbox",
+       .syntax = "VMCOUNT(vmbox[@context][|folder])",
+       .desc =
+       "  context - defaults to \"default\"\n"
+       "  folder  - defaults to \"INBOX\"\n",
+       .read = acf_vmcount_exec,
+};
+
+static int unload_module(void)
+{
+       int res = ast_custom_function_unregister(&acf_vmcount);
+       ast_module_user_hangup_all();
+
+       return res;
+}
+
+static int load_module(void)
+{
+       return ast_custom_function_register(&acf_vmcount);
+}
+
+AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Indicator for whether a voice mailbox has messages in a given folder.");
diff --git a/res/res_realtime.c b/res/res_realtime.c
new file mode 100644 (file)
index 0000000..8f382fe
--- /dev/null
@@ -0,0 +1,127 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 1999 - 2005, Digium, Inc.
+ *
+ * Anthony Minessale <anthmct@yahoo.com>
+ * 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 RealTime CLI
+ *
+ * \author Anthony Minessale <anthmct@yahoo.com>
+ * \author Mark Spencer <markster@digium.com>
+ * 
+ * \ingroup applications
+ */
+
+#include "asterisk.h"
+
+ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "asterisk/file.h"
+#include "asterisk/logger.h"
+#include "asterisk/channel.h"
+#include "asterisk/options.h"
+#include "asterisk/pbx.h"
+#include "asterisk/config.h"
+#include "asterisk/module.h"
+#include "asterisk/lock.h"
+#include "asterisk/cli.h"
+
+
+static int cli_realtime_load(int fd, int argc, char **argv) 
+{
+       char *header_format = "%30s  %-30s\n";
+       struct ast_variable *var=NULL;
+
+       if(argc<5) {
+               ast_cli(fd, "You must supply a family name, a column to match on, and a value to match to.\n");
+               return RESULT_FAILURE;
+       }
+
+       var = ast_load_realtime(argv[2], argv[3], argv[4], NULL);
+
+       if(var) {
+               ast_cli(fd, header_format, "Column Name", "Column Value");
+               ast_cli(fd, header_format, "--------------------", "--------------------");
+               while(var) {
+                       ast_cli(fd, header_format, var->name, var->value);
+                       var = var->next;
+               }
+       } else {
+               ast_cli(fd, "No rows found matching search criteria.\n");
+       }
+       return RESULT_SUCCESS;
+}
+
+static int cli_realtime_update(int fd, int argc, char **argv) {
+       int res = 0;
+
+       if(argc<7) {
+               ast_cli(fd, "You must supply a family name, a column to update on, a new value, column to match, and value to to match.\n");
+               ast_cli(fd, "Ex: realtime update sipfriends name bobsphone port 4343\n will execute SQL as UPDATE sipfriends SET port = 4343 WHERE name = bobsphone\n");
+               return RESULT_FAILURE;
+       }
+
+       res = ast_update_realtime(argv[2], argv[3], argv[4], argv[5], argv[6], NULL);
+
+       if(res < 0) {
+               ast_cli(fd, "Failed to update. Check the debug log for possible SQL related entries.\n");
+               return RESULT_SUCCESS;
+       }
+
+       ast_cli(fd, "Updated %d RealTime record%s.\n", res, (res != 1) ? "s" : "");
+
+       return RESULT_SUCCESS;
+}
+
+static char cli_realtime_load_usage[] =
+"Usage: realtime load <family> <colmatch> <value>\n"
+"       Prints out a list of variables using the RealTime driver.\n";
+
+static char cli_realtime_update_usage[] =
+"Usage: realtime update <family> <colmatch> <value>\n"
+"       Update a single variable using the RealTime driver.\n";
+
+static struct ast_cli_entry cli_realtime[] = {
+       { { "realtime", "load", NULL, NULL },
+       cli_realtime_load, "Used to print out RealTime variables.",
+       cli_realtime_load_usage, NULL },
+
+       { { "realtime", "update", NULL, NULL },
+       cli_realtime_update, "Used to update RealTime variables.",
+       cli_realtime_update_usage, NULL },
+};
+
+static int unload_module(void)
+{
+       ast_cli_unregister_multiple(cli_realtime, sizeof(cli_realtime) / sizeof(struct ast_cli_entry));
+       ast_module_user_hangup_all();
+       return 0;
+}
+
+static int load_module(void)
+{
+       ast_cli_register_multiple(cli_realtime, sizeof(cli_realtime) / sizeof(struct ast_cli_entry));
+       return 0;
+}
+
+AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Realtime Data Lookup/Rewrite");