[Asterisk-cvs] asterisk channel.c,1.73.2.3,1.73.2.4

citats at lists.digium.com citats at lists.digium.com
Fri Feb 27 01:26:50 CST 2004


Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv11447

Modified Files:
      Tag: v1-0_stable
	channel.c 
Log Message:
Move ast_get_group from res_parking.c to channel.c



Index: channel.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channel.c,v
retrieving revision 1.73.2.3
retrieving revision 1.73.2.4
diff -u -d -r1.73.2.3 -r1.73.2.4
--- channel.c	20 Feb 2004 20:01:41 -0000	1.73.2.3
+++ channel.c	27 Feb 2004 06:16:07 -0000	1.73.2.4
@@ -2496,3 +2496,36 @@
 	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;
+}




More information about the svn-commits mailing list