diff options
author | Steve Murphy <murf@digium.com> | 2007-05-04 17:49:20 +0000 |
---|---|---|
committer | Steve Murphy <murf@digium.com> | 2007-05-04 17:49:20 +0000 |
commit | 02337303ef22d5b79967286b4a4b004401e3efff (patch) | |
tree | e8908066fd2741b51f6c348afd1217c9c56d54c7 | |
parent | 3ee0077f0410d80e9c4f40c5915c32d8dfed2c2c (diff) |
a small upgrade to the coding standard, and an update to the code that triggered the upgrade.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@63048 65c4cc65-6c06-0410-ace0-fbb531ad65f3
-rw-r--r-- | channels/chan_sip.c | 2 | ||||
-rw-r--r-- | doc/CODING-GUIDELINES | 18 | ||||
-rw-r--r-- | include/asterisk/features.h | 4 | ||||
-rw-r--r-- | res/res_features.c | 10 |
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; } |