aboutsummaryrefslogtreecommitdiffstats
path: root/frame.c
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2005-09-29 17:40:24 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2005-09-29 17:40:24 +0000
commit0fdee4f59cb1e46bf5a1057800c84cff8353f3d6 (patch)
tree26cb286c262d61acbb5df15fbefd655db9141ef6 /frame.c
parent27aa525896fbc6cbb581621ea21eb5fc7088e225 (diff)
code cleanups
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@6696 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'frame.c')
-rwxr-xr-xframe.c50
1 files changed, 25 insertions, 25 deletions
diff --git a/frame.c b/frame.c
index 428a052f2..27afa34ce 100755
--- a/frame.c
+++ b/frame.c
@@ -1001,36 +1001,36 @@ int ast_codec_choose(struct ast_codec_pref *pref, int formats, int find_best)
return find_best ? ast_best_codec(formats) : 0;
}
-void ast_parse_allow_disallow(struct ast_codec_pref *pref, int *mask, char *list, int allowing)
+void ast_parse_allow_disallow(struct ast_codec_pref *pref, int *mask, const char *list, int allowing)
{
- int format_i = 0;
- char *next_format = NULL, *last_format = NULL;
-
- last_format = ast_strdupa(list);
- while(last_format) {
- if((next_format = strchr(last_format, ','))) {
- *next_format = '\0';
- next_format++;
+ char *parse;
+ char *this;
+ int format;
+
+ parse = ast_strdupa(list);
+ while ((this = strsep(&parse, ","))) {
+ if (!(format = ast_getformatbyname(this))) {
+ ast_log(LOG_WARNING, "Cannot %s unknown format '%s'\n", allowing ? "allow" : "disallow", this);
+ continue;
+ }
+
+ if (mask) {
+ if (allowing)
+ *mask |= format;
+ else
+ *mask &= ~format;
}
- if ((format_i = ast_getformatbyname(last_format)) > 0) {
- if (mask) {
+
+ if (pref) {
+ if (strcasecmp(this, "all")) {
if (allowing)
- (*mask) |= format_i;
+ ast_codec_pref_append(pref, format);
else
- (*mask) &= ~format_i;
+ ast_codec_pref_remove(pref, format);
+ } else if (!allowing) {
+ memset(pref, 0, sizeof(*pref));
}
- /* can't consider 'all' a prefered codec*/
- if(pref && strcasecmp(last_format, "all")) {
- if(allowing)
- ast_codec_pref_append(pref, format_i);
- else
- ast_codec_pref_remove(pref, format_i);
- } else if(!allowing) /* disallow all must clear your prefs or it makes no sense */
- memset(pref, 0, sizeof(struct ast_codec_pref));
- } else
- ast_log(LOG_WARNING, "Cannot %s unknown format '%s'\n", allowing ? "allow" : "disallow", last_format);
-
- last_format = next_format;
+ }
}
}