summaryrefslogtreecommitdiff
path: root/channel.c
diff options
context:
space:
mode:
authorJames Golovich <james@gnuinter.net>2004-02-27 06:15:49 +0000
committerJames Golovich <james@gnuinter.net>2004-02-27 06:15:49 +0000
commita232d8e060566fdcaaaa89eebc493fba0c0423b2 (patch)
tree1270b50ac008379ff718c225171242b923cc0eb7 /channel.c
parentcf854246fac8f1d6404b13a5c1e02098a0f8b548 (diff)
Move ast_get_group from res_parking.c to channel.c
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@2263 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channel.c')
-rwxr-xr-xchannel.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/channel.c b/channel.c
index b05ea7589..e4a572af3 100755
--- a/channel.c
+++ b/channel.c
@@ -2496,3 +2496,36 @@ int ast_tonepair(struct ast_channel *chan, int freq1, int freq2, int duration, i
return 0;
}
+unsigned int ast_get_group(char *s)
+{
+ char *copy;
+ char *piece;
+ char *c=NULL;
+ int start=0, finish=0,x;
+ unsigned int group = 0;
+ copy = ast_strdupa(s);
+ if (!copy) {
+ ast_log(LOG_ERROR, "Out of memory\n");
+ return 0;
+ }
+ c = copy;
+
+ while((piece = strsep(&c, ","))) {
+ if (sscanf(piece, "%d-%d", &start, &finish) == 2) {
+ /* Range */
+ } else if (sscanf(piece, "%d", &start)) {
+ /* Just one */
+ finish = start;
+ } else {
+ ast_log(LOG_ERROR, "Syntax error parsing '%s' at '%s'. Using '0'\n", s,piece);
+ return 0;
+ }
+ for (x=start;x<=finish;x++) {
+ if ((x > 31) || (x < 0)) {
+ ast_log(LOG_WARNING, "Ignoring invalid group %d\n", x);
+ } else
+ group |= (1 << x);
+ }
+ }
+ return group;
+}