[svn-commits] trunk - r7339 /trunk/pbx.c

svn-commits at lists.digium.com svn-commits at lists.digium.com
Sun Dec 4 18:39:17 CST 2005


Author: russell
Date: Sun Dec  4 18:39:15 2005
New Revision: 7339

URL: http://svn.digium.com/view/asterisk?rev=7339&view=rev
Log:
add support for 'show functions like <text>' (issue #5923)

Modified:
    trunk/pbx.c

Modified: trunk/pbx.c
URL: http://svn.digium.com/view/asterisk/trunk/pbx.c?rev=7339&r1=7338&r2=7339&view=diff
==============================================================================
--- trunk/pbx.c (original)
+++ trunk/pbx.c Sun Dec  4 18:39:15 2005
@@ -1163,13 +1163,36 @@
 {
 	struct ast_custom_function *acf;
 	int count_acf = 0;
-
-	ast_cli(fd, "Installed Custom Functions:\n--------------------------------------------------------------------------------\n");
+	int print_acf = 0;
+	int like = 0;
+
+	if (argc == 4 && (!strcmp(argv[2], "like")) ) {
+		like = 1;
+	} else if (argc != 2) {
+		return RESULT_SHOWUSAGE;
+	}
+
+	ast_cli(fd, "%s Custom Functions:\n--------------------------------------------------------------------------------\n", like ? "Matching" : "Installed");
+	
 	for (acf = acf_root ; acf; acf = acf->next) {
-		ast_cli(fd, "%-20.20s  %-35.35s  %s\n", acf->name, acf->syntax, acf->synopsis);
-		count_acf++;
-	}
-	ast_cli(fd, "%d custom functions installed.\n", count_acf);
+		print_acf = 0;
+		if (like) {
+			if (strstr(acf->name, argv[3])) {
+				print_acf = 1;
+				count_acf++;
+			}
+		} else {
+			print_acf = 1;
+			count_acf++;
+		} 
+
+		if (print_acf) {
+			ast_cli(fd, "%-20.20s  %-35.35s  %s\n", acf->name, acf->syntax, acf->synopsis);
+		}
+	}
+
+	ast_cli(fd, "%d %scustom functions installed.\n", count_acf, like ? "matching " : "");
+
 	return 0;
 }
 
@@ -2966,8 +2989,8 @@
 "       Describes a particular application.\n";
 
 static char show_functions_help[] =
-"Usage: show functions\n"
-"       List builtin functions accessable as $(function args)\n";
+"Usage: show functions [like <text>]\n"
+"       List builtin functions, optionally only those matching a given string\n";
 
 static char show_function_help[] =
 "Usage: show function <function>\n"



More information about the svn-commits mailing list