diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-10-18 03:02:06 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-10-18 03:02:06 +0000 |
commit | 81205f2fd3ebf7c77c2a3908f46e29066187404c (patch) | |
tree | a13aa237c9473c3455778f6b4e7267546c11f5cf /funcs | |
parent | 865392451a2ed7db77911e79a58ec80f40b4ab6a (diff) |
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
Diffstat (limited to 'funcs')
-rwxr-xr-x | funcs/func_enum.c | 65 |
1 files changed, 60 insertions, 5 deletions
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 <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() |