[svn-commits] murf: trunk r63048 - in /trunk: channels/ doc/ include/asterisk/ res/

svn-commits at lists.digium.com svn-commits at lists.digium.com
Fri May 4 10:49:20 MST 2007


Author: murf
Date: Fri May  4 12:49:20 2007
New Revision: 63048

URL: http://svn.digium.com/view/asterisk?view=rev&rev=63048
Log:
a small upgrade to the coding standard, and an update to the code that triggered the upgrade.

Modified:
    trunk/channels/chan_sip.c
    trunk/doc/CODING-GUIDELINES
    trunk/include/asterisk/features.h
    trunk/res/res_features.c

Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?view=diff&rev=63048&r1=63047&r2=63048
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Fri May  4 12:49:20 2007
@@ -11647,7 +11647,7 @@
 		return;
 	} else if (!ast_strlen_zero(c = get_header(req, "Record"))) {
 		/* first, get the feature string, if it exists */
-		struct ast_call_feature *feat = find_feature("automon");
+		struct ast_call_feature *feat = ast_find_call_feature("automon");
 		
 		if (!feat || ast_strlen_zero(feat->exten)) {
 			ast_log(LOG_WARNING,"Recording requested, but no One Touch Monitor registered. (See features.conf)\n");

Modified: trunk/doc/CODING-GUIDELINES
URL: http://svn.digium.com/view/asterisk/trunk/doc/CODING-GUIDELINES?view=diff&rev=63048&r1=63047&r2=63048
==============================================================================
--- trunk/doc/CODING-GUIDELINES (original)
+++ trunk/doc/CODING-GUIDELINES Fri May  4 12:49:20 2007
@@ -206,6 +206,18 @@
 type, and when you are passing a pointer to (for example) a callback function
 that accepts a 'void *' you do not need to cast into that type.
 
+* Function naming
+-----------------
+
+All public functions (those not marked 'static'), must be named "ast_<something>"
+and have a descriptive name.
+
+As an example, suppose you wanted to take a local function "find_feature", defined
+as static in a file, and used only in that file, and make it public, and use it
+in other files. You will have to remove the "static" declaration and define a 
+prototype in an appropriate header file (usually in include/asterisk). A more
+specific name should be given, such as "ast_find_call_feature".
+
 * Variable naming
 -----------------
 
@@ -225,11 +237,7 @@
 - Don't use un-necessary typedef's
 Don't use 'typedef' just to shorten the amount of typing; there is no substantial
 benefit in this:
-
-struct foo {
-	int bar;
-};
-typedef foo_t struct foo;
+struct foo { int bar; }; typedef foo_t struct foo;
 
 In fact, don't use 'variable type' suffixes at all; it's much preferable to
 just type 'struct foo' rather than 'foo_s'.

Modified: trunk/include/asterisk/features.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/features.h?view=diff&rev=63048&r1=63047&r2=63048
==============================================================================
--- trunk/include/asterisk/features.h (original)
+++ trunk/include/asterisk/features.h Fri May  4 12:49:20 2007
@@ -94,8 +94,8 @@
     \param feature the ast_call_feature object which was registered before*/
 void ast_unregister_feature(struct ast_call_feature *feature);
 
-/*! \brief look for a feature entry by its sname
+/*! \brief look for a call feature entry by its sname
 	\param name a string ptr, should match "automon", "blindxfer", "atxfer", etc. */
-struct ast_call_feature *find_feature(char *name);
+struct ast_call_feature *ast_find_call_feature(char *name);
 
 #endif /* _AST_FEATURES_H */

Modified: trunk/res/res_features.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_features.c?view=diff&rev=63048&r1=63047&r2=63048
==============================================================================
--- trunk/res/res_features.c (original)
+++ trunk/res/res_features.c Fri May  4 12:49:20 2007
@@ -1055,8 +1055,8 @@
 	AST_LIST_UNLOCK(&feature_list);
 }
 
-/*! \brief find a feature by name */
-struct ast_call_feature *find_feature(char *name)
+/*! \brief find a call feature by name */
+struct ast_call_feature *ast_find_call_feature(char *name)
 {
 	struct ast_call_feature *tmp;
 
@@ -1197,7 +1197,7 @@
 		char *tok;
 
 		while ((tok = strsep(&tmp, "#")) != NULL) {
-			feature = find_feature(tok);
+			feature = ast_find_call_feature(tok);
 			
 			if (feature) {
 				/* Feature is up for consideration */
@@ -1241,7 +1241,7 @@
 
 			/* while we have a feature */
 			while ((tok = strsep(&tmp, "#"))) {
-				if ((feature = find_feature(tok)) && ast_test_flag(feature, AST_FEATURE_FLAG_NEEDSDTMF)) {
+				if ((feature = ast_find_call_feature(tok)) && ast_test_flag(feature, AST_FEATURE_FLAG_NEEDSDTMF)) {
 					if (ast_test_flag(feature, AST_FEATURE_FLAG_BYCALLER))
 						ast_set_flag(config, AST_BRIDGE_DTMF_CHANNEL_0);
 					if (ast_test_flag(feature, AST_FEATURE_FLAG_BYCALLEE))
@@ -2580,7 +2580,7 @@
 			continue;
 		}
 
-		if ((feature = find_feature(var->name))) {
+		if ((feature = ast_find_call_feature(var->name))) {
 			ast_log(LOG_WARNING, "Dynamic Feature '%s' specified more than once!\n", var->name);
 			continue;
 		}



More information about the svn-commits mailing list