[svn-commits] tzafrir: branch tools/tzafrir/sysfs r8697 - /tools/team/tzafrir/sysfs/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu May 27 05:45:39 CDT 2010


Author: tzafrir
Date: Thu May 27 05:45:38 2010
New Revision: 8697

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=8697
Log:
dahdi_cfg: accept multiple '!' (and replace them with '/')

Modified:
    tools/team/tzafrir/sysfs/dahdi_cfg.c

Modified: tools/team/tzafrir/sysfs/dahdi_cfg.c
URL: http://svnview.digium.com/svn/dahdi/tools/team/tzafrir/sysfs/dahdi_cfg.c?view=diff&rev=8697&r1=8696&r2=8697
==============================================================================
--- tools/team/tzafrir/sysfs/dahdi_cfg.c (original)
+++ tools/team/tzafrir/sysfs/dahdi_cfg.c Thu May 27 05:45:38 2010
@@ -467,7 +467,7 @@
 
 	if(!relative_path)
 		return relative_index;	/* identify map */
-	//fprintf(stderr, "DEBUG: %s!%d\n", relative_path, relative_index);
+	//fprintf(stderr, "DEBUG(%s): %s!%d\n", __func__, relative_path, relative_index);
 	snprintf(path, sizeof(path), "/dev/dahdi/%s/%d", relative_path, relative_index);
 	if (stat(path, &stbuf) < 0) {
 		perror(path);
@@ -480,6 +480,15 @@
 	channo = minor(stbuf.st_rdev);
 	path_channels++;
 	return channo;
+}
+
+static void str_replace(char *str, int char1, int char2)
+{
+	char *p;
+
+	for(p = str; *p; p++)
+		if(*p == char1)
+			*p = char2;
 }
 
 int apply_channels(int chans[], char *argstr)
@@ -491,16 +500,15 @@
 	int start, finish;
 	char argcopy[256];
 	char *pname;
-
-	pname = strtok(argstr, "!");
+	char prefix[PATH_MAX];
+
+	dahdi_copy_string(prefix, argstr, sizeof(prefix));
+	pname = strrchr(prefix, '!');
 	if (pname) {
-		argstr += strlen(pname) + 1;
-		if(argstr[0] == '\0') {
-			argstr = pname;
-			pname = NULL;
-		} else {
-			pname = strdup(pname);
-		}
+		*pname = '\0';
+		argstr = pname + 1;
+		str_replace(prefix, '!', '/');
+		pname = prefix;
 	}
 	res = parseargs(argstr, args, DAHDI_MAX_CHANNELS, ',');
 	if (res < 0) {




More information about the svn-commits mailing list