aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--channels/chan_sip.c2
-rw-r--r--doc/CODING-GUIDELINES18
-rw-r--r--include/asterisk/features.h4
-rw-r--r--res/res_features.c10
4 files changed, 21 insertions, 13 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 919912853..d4f2558f8 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -11647,7 +11647,7 @@ static void handle_request_info(struct sip_pvt *p, struct sip_request *req)
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");
diff --git a/doc/CODING-GUIDELINES b/doc/CODING-GUIDELINES
index c0aa5ed91..9c2942b7b 100644
--- a/doc/CODING-GUIDELINES
+++ b/doc/CODING-GUIDELINES
@@ -206,6 +206,18 @@ alloca(), and similar functions do not _ever_ need to be cast to a specific
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 @@ options that they are in fact intended to be global.
- 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'.
diff --git a/include/asterisk/features.h b/include/asterisk/features.h
index 02b8fa5fd..2174e99e1 100644
--- a/include/asterisk/features.h
+++ b/include/asterisk/features.h
@@ -94,8 +94,8 @@ void ast_register_feature(struct ast_call_feature *feature);
\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 */
diff --git a/res/res_features.c b/res/res_features.c
index 7cc4686c4..a0df92447 100644
--- a/res/res_features.c
+++ b/res/res_features.c
@@ -1055,8 +1055,8 @@ static void ast_unregister_features(void)
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 @@ static int ast_feature_interpret(struct ast_channel *chan, struct ast_channel *p
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 @@ static void set_config_flags(struct ast_channel *chan, struct ast_channel *peer,
/* 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 @@ static int load_config(void)
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;
}