[svn-commits] branch russell/codetest - r7724 in /team/russell/codetest: ./ include/asterisk/

svn-commits at lists.digium.com svn-commits at lists.digium.com
Mon Jan 2 17:01:44 CST 2006


Author: russell
Date: Mon Jan  2 17:01:37 2006
New Revision: 7724

URL: http://svn.digium.com/view/asterisk?rev=7724&view=rev
Log:
add doxygen docs

Modified:
    team/russell/codetest/codetest.c
    team/russell/codetest/include/asterisk/codetest.h

Modified: team/russell/codetest/codetest.c
URL: http://svn.digium.com/view/asterisk/team/russell/codetest/codetest.c?rev=7724&r1=7723&r2=7724&view=diff
==============================================================================
--- team/russell/codetest/codetest.c (original)
+++ team/russell/codetest/codetest.c Mon Jan  2 17:01:37 2006
@@ -29,19 +29,29 @@
 
 #include "asterisk.h"
 
-ASTERISK_FILE_VERSION(__FILE__, "$Revision: 1 $")
+ASTERISK_FILE_VERSION(__FILE__, "$Revision: $")
 
 #include "asterisk/channel.h"
 #include "asterisk/logger.h"
 #include "asterisk/cli.h"
 #include "asterisk/codetest.h"
 
+/*!
+  \brief A file that has registered tests
+
+  We store all registered tests by keeping track of whick file has
+  registered each test.
+*/
 struct testfile {
+	/*! The name of the file that has a list of registered tests */
 	const char *filename;
+	/*! The list of tests registered by this file */
 	AST_LIST_HEAD_NOLOCK(, ast_codetest) codetests;
+	/*! Link testfile's together */
 	AST_LIST_ENTRY(testfile) list;
 };
 
+/*! The list of testfile structures */
 static AST_LIST_HEAD_STATIC(testfile_list, testfile);
 
 /* Prototypes for non-exported functions */
@@ -71,9 +81,7 @@
 		ast_log(LOG_ERROR, "Memory Allocation Error!\n");
 		return NULL;
 	}
-
 	tf->filename = test->filename;
-
 	AST_LIST_INSERT_HEAD(&testfile_list, tf, list);
 
 	return tf;
@@ -101,18 +109,14 @@
 	struct testfile *cur;
 
 	AST_LIST_LOCK(&testfile_list);
-	
 	cur = find_testfile_by_name(test->filename);
-
 	if (!cur)
 		cur = add_testfile(test);
 	if (!cur) {
 		AST_LIST_UNLOCK(&testfile_list);
 		return -1;
 	}
-
 	AST_LIST_INSERT_HEAD(&cur->codetests, test, list);
-
 	AST_LIST_UNLOCK(&testfile_list);
 
 	return 0;
@@ -123,20 +127,16 @@
 	struct testfile *cur;
 
 	AST_LIST_LOCK(&testfile_list);
-
 	if (!(cur = find_testfile_by_name(test->filename))) {
 		ast_log(LOG_WARNING, "File '%s' not found in list of files with registered tests!\n", test->filename);
 		AST_LIST_UNLOCK(&testfile_list);
 		return -1;
 	}
-	
 	AST_LIST_REMOVE(&cur->codetests, test, list);
-
 	if (AST_LIST_EMPTY(&cur->codetests)) {
 		AST_LIST_REMOVE(&testfile_list, cur, list);
 		free(cur);
 	}
-
 	AST_LIST_UNLOCK(&testfile_list);
 
 	return 0;
@@ -167,12 +167,10 @@
 	ast_cli(fd, "--------------------------------\n");
 
 	AST_LIST_LOCK(&testfile_list);
-
 	AST_LIST_TRAVERSE(&testfile_list, cur, list) {
 		count = count_tests(cur);
 		ast_cli(fd, "Filename: '%s'  (%d %s)\n", cur->filename, count, count > 1 ? "tests" : "test");
 	}
-
 	AST_LIST_UNLOCK(&testfile_list);
 
 	return RESULT_SUCCESS;
@@ -197,23 +195,18 @@
 		return RESULT_SHOWUSAGE;
 
 	AST_LIST_LOCK(&testfile_list);
-
 	if (!(cur = find_testfile_by_name(argv[3]))) {
 		ast_cli(fd, "File '%s' not found in list of files with registered code tests!\n", argv[3]);
 		AST_LIST_UNLOCK(&testfile_list);
 		return RESULT_SHOWUSAGE;
 	}
-
 	ast_cli(fd, "Registered Code Tests for File '%s'\n", cur->filename);
 	ast_cli(fd, "---------------------------------------------\n");
-
 	AST_LIST_TRAVERSE(&cur->codetests, test, list) {
 		count++;
 		ast_cli(fd, "Test Name: '%s'\n", test->testname);
 	}
-
 	ast_cli(fd, "\n(Total Tests Registered: %d)\n", count);
-
 	AST_LIST_UNLOCK(&testfile_list);
 
 	return RESULT_SUCCESS;
@@ -223,27 +216,19 @@
 {
 	struct testfile *cur;
 	int match = 0;
-	int wordlen;
-	char *file;
-
-	wordlen = strlen(word);
-
-	AST_LIST_LOCK(&testfile_list);
-
+	int wordlen = strlen(word);
+	char *file = NULL;
+
+	AST_LIST_LOCK(&testfile_list);
 	AST_LIST_TRAVERSE(&testfile_list, cur, list) {	
-		if (!strncasecmp(word, cur->filename, wordlen)) {
-			match++;
-			if (match > state) {
-				file = strdup(cur->filename);
-				AST_LIST_UNLOCK(&testfile_list);
-				return file;
-			}
+		if (!strncasecmp(word, cur->filename, wordlen) && ++match > state) {
+			file = strdup(cur->filename);
+			break;
 		}
 	}
-
-	AST_LIST_UNLOCK(&testfile_list);
-
-	return NULL;
+	AST_LIST_UNLOCK(&testfile_list);
+
+	return file;
 
 }
 
@@ -293,13 +278,11 @@
 		return RESULT_SHOWUSAGE;
 
 	AST_LIST_LOCK(&testfile_list);
-
 	if (!(tf = find_testfile_by_name(argv[2]))) {
 		ast_cli(fd, "File '%s' not found in list of files with code tests.\n", argv[2]);
 		AST_LIST_UNLOCK(&testfile_list);
 		return RESULT_SHOWUSAGE;
 	}
-
 	AST_LIST_TRAVERSE(&tf->codetests, test, list) {
 		if (!ast_strlen_zero(testname)) {
 			if (!strcmp(test->testname, testname)) {
@@ -316,7 +299,6 @@
 			test_executed = 1;
 		}
 	}
-
 	AST_LIST_UNLOCK(&testfile_list);
 
 	if (!test_executed && !ast_strlen_zero(testname)) {
@@ -334,34 +316,28 @@
 	struct ast_codetest *test;
 	struct testfile *tf;
 	int match = 0;
-	int wordlen;
-
-	file = ast_strdupa(line);
-	if (!file) {
+	int wordlen = strlen(word);
+
+	if (!(file = ast_strdupa(line))) {
 		ast_log(LOG_ERROR, "Memory Allocation Error!\n");
 		return NULL;
 	}
-
-	wordlen = strlen(word);
 
 	strsep(&file, " ");
 	strsep(&file, " ");
 	file = strsep(&file, " ");
 
 	AST_LIST_LOCK(&testfile_list);
-
 	if (!(tf = find_testfile_by_name(file))) {
 		AST_LIST_UNLOCK(&testfile_list);
 		return NULL;
 	}
-
 	AST_LIST_TRAVERSE(&tf->codetests, test, list) {
 		if (!strncasecmp(word, test->filename, wordlen) && ++match > state) {
 			ret = strdup(test->filename);
 			break;
 		}
 	}	
-
 	AST_LIST_UNLOCK(&testfile_list);
 
 	return ret;

Modified: team/russell/codetest/include/asterisk/codetest.h
URL: http://svn.digium.com/view/asterisk/team/russell/codetest/include/asterisk/codetest.h?rev=7724&r1=7723&r2=7724&view=diff
==============================================================================
--- team/russell/codetest/include/asterisk/codetest.h (original)
+++ team/russell/codetest/include/asterisk/codetest.h Mon Jan  2 17:01:37 2006
@@ -46,10 +46,38 @@
 	AST_LIST_ENTRY(ast_codetest) list;
 };
 
+/*!
+  \brief Define a Code Test
+  \param name  This is the name that will be used to refer to the test when
+               calling the register/unregister functions
+  \param tname This is the text name of the test.  It will be the name that
+               is used to refer to the test at the CLI.
+  \param func  This is the callback for the test, which will be stored in the
+               member 'codetest' in the ast_codetest structure.
+*/
 #define AST_DEFINE_CODE_TEST(name, tname, func) \
 	static struct ast_codetest name = { __FILE__, tname, func }
 
+/*!
+  \brief Reigster a Code Test
+  \param test The test to register.
+
+  If the code test was defined using the following macro:
+	AST_DEFINE_CODE_TEST(my_test, "my-test", my_test_handler);
+  Then, this function would be called like:
+	ast_register_codetest(&my_test);
+*/
 int ast_register_codetest(struct ast_codetest *test);
+
+/*!
+  \brief Unreigster a Code Test
+  \param test The test to unregister.
+
+  If the code test was defined using the following macro:
+	AST_DEFINE_CODE_TEST(my_test, "my-test", my_test_handler);
+  Then, this function would be called like:
+	ast_unregister_codetest(&my_test);
+*/
 int ast_unregister_codetest(struct ast_codetest *test);
 
 #else



More information about the svn-commits mailing list