mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-03 03:20:57 +00:00
implement TXTCIDNAME as a dialplan function and mark the application deprecated
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6813 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -61,9 +61,15 @@ static int txtcidname_exec(struct ast_channel *chan, void *data)
|
||||
char tech[80];
|
||||
char txt[256] = "";
|
||||
char dest[80];
|
||||
|
||||
struct localuser *u;
|
||||
if (!data || !strlen(data)) {
|
||||
static int dep_warning = 0;
|
||||
|
||||
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 (!data || ast_strlen_zero(data)) {
|
||||
ast_log(LOG_WARNING, "TXTCIDName requires an argument (extension)\n");
|
||||
res = 1;
|
||||
}
|
||||
|
@@ -1,9 +1,11 @@
|
||||
/*
|
||||
* Asterisk -- An open source telephony toolkit.
|
||||
*
|
||||
* Copyright (C) 2005
|
||||
* Copyright (C) 1999 - 2005
|
||||
*
|
||||
* Mark Spencer <markster@digium.com>
|
||||
* Oleksiy Krivoshey <oleksiyk@gmail.com>
|
||||
* Russell Bryant <russelb@clemson.edu>
|
||||
*
|
||||
* See http://www.asterisk.org for more information about
|
||||
* the Asterisk project. Please do not directly contact
|
||||
@@ -137,7 +139,6 @@ static char *function_enum(struct ast_channel *chan, char *cmd, char *data, char
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
#ifndef BUILTIN_FUNC
|
||||
static
|
||||
#endif
|
||||
@@ -153,18 +154,68 @@ struct ast_custom_function enum_function = {
|
||||
.read = function_enum,
|
||||
};
|
||||
|
||||
static char *function_txtcidname(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
|
||||
{
|
||||
int res;
|
||||
char tech[80];
|
||||
char txt[256] = "";
|
||||
char dest[80];
|
||||
struct localuser *u;
|
||||
|
||||
LOCAL_USER_ACF_ADD(u);
|
||||
|
||||
buf[0] = '\0';
|
||||
|
||||
if (!data || ast_strlen_zero(data)) {
|
||||
ast_log(LOG_WARNING, "TXTCIDNAME requires an argument (number)\n");
|
||||
LOCAL_USER_REMOVE(u);
|
||||
return buf;
|
||||
}
|
||||
|
||||
res = ast_get_txt(chan, data, dest, sizeof(dest), tech, sizeof(tech), txt, sizeof(txt));
|
||||
|
||||
if (!ast_strlen_zero(txt))
|
||||
ast_copy_string(buf, txt, len);
|
||||
|
||||
LOCAL_USER_REMOVE(u);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
#ifndef BUILTIN_FUNC
|
||||
static
|
||||
#endif
|
||||
struct ast_custom_function txtcidname_function = {
|
||||
.name = "TXTCIDNAME",
|
||||
.synopsis = "TXTCIDNAME looks up a caller name via DNS",
|
||||
.syntax = "TXTCIDNAME(<number>)",
|
||||
.desc = "This function looks up the given phone number in DNS to retrieve\n"
|
||||
"the caller id name. The result will either be blank or be the value\n"
|
||||
"found in the TXT record in DNS.\n",
|
||||
.read = function_txtcidname,
|
||||
};
|
||||
|
||||
#ifndef BUILTIN_FUNC
|
||||
|
||||
static char *tdesc = "ENUMLOOKUP allows for general or specific querying of NAPTR records or counts of NAPTR types for ENUM or ENUM-like DNS pointers";
|
||||
|
||||
int unload_module(void)
|
||||
{
|
||||
return ast_custom_function_unregister(&enum_function);
|
||||
ast_custom_function_unregister(&enum_function);
|
||||
ast_custom_function_unregister(&txtcidname_function);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int load_module(void)
|
||||
{
|
||||
return ast_custom_function_register(&enum_function);
|
||||
int res;
|
||||
|
||||
res = ast_custom_function_register(&enum_function);
|
||||
if (!res)
|
||||
ast_custom_function_register(&txtcidname_function);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
char *description(void)
|
||||
@@ -174,7 +225,11 @@ char *description(void)
|
||||
|
||||
int usecount(void)
|
||||
{
|
||||
return 0;
|
||||
int res;
|
||||
|
||||
STANDARD_USECOUNT(res);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
char *key()
|
||||
|
Reference in New Issue
Block a user