From 81205f2fd3ebf7c77c2a3908f46e29066187404c Mon Sep 17 00:00:00 2001 From: russell Date: Tue, 18 Oct 2005 03:02:06 +0000 Subject: implement TXTCIDNAME as a dialplan function and mark the application deprecated git-svn-id: http://svn.digium.com/svn/asterisk/trunk@6813 f38db490-d61c-443f-a65b-d21fe96a405b --- funcs/func_enum.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 60 insertions(+), 5 deletions(-) (limited to 'funcs/func_enum.c') diff --git a/funcs/func_enum.c b/funcs/func_enum.c index 51d96e85a..01623e545 100755 --- a/funcs/func_enum.c +++ b/funcs/func_enum.c @@ -1,9 +1,11 @@ /* * Asterisk -- An open source telephony toolkit. * - * Copyright (C) 2005 + * Copyright (C) 1999 - 2005 * + * Mark Spencer * Oleksiy Krivoshey + * Russell Bryant * * 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()", + .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() -- cgit v1.2.3