Update of /usr/cvsroot/asterisk/funcs
In directory mongoose.digium.com:/tmp/cvs-serv2260/funcs

Modified Files:
        func_enum.c 
Log Message:
implement TXTCIDNAME as a dialplan function and mark the application deprecated


Index: func_enum.c
===================================================================
RCS file: /usr/cvsroot/asterisk/funcs/func_enum.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- func_enum.c 14 Sep 2005 20:46:50 -0000      1.2
+++ func_enum.c 18 Oct 2005 03:02:06 -0000      1.3
@@ -1,9 +1,11 @@
 /*
  * Asterisk -- An open source telephony toolkit.
  *
- * Copyright (C) 2005
+ * Copyright (C) 1999 - 2005
  *
+ * Mark Spencer <[EMAIL PROTECTED]>
  * Oleksiy Krivoshey <[EMAIL PROTECTED]>
+ * Russell Bryant <[EMAIL PROTECTED]>
  *
  * See http://www.asterisk.org for more information about
  * the Asterisk project. Please do not directly contact
@@ -137,7 +139,6 @@
        return buf;
 }
 
-
 #ifndef BUILTIN_FUNC
 static
 #endif
@@ -153,18 +154,68 @@
        .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 @@
 
 int usecount(void)
 {
-       return 0;
+       int res;
+       
+       STANDARD_USECOUNT(res);
+
+       return res;
 }
 
 char *key()

_______________________________________________
Asterisk-Cvs mailing list
[email protected]
http://lists.digium.com/mailman/listinfo/asterisk-cvs

Reply via email to