Package: afio
Version: 2.5-3-kissg-1
Severity: wishlist
Tags: patch

This patch allows variables in '!' prefixed device (i.e. pipe) names.
- %V will be replaced with current volume number
- %S will be replaced with volume size (in bytes)
- %% stands for % itself

-- System Information:
Debian Release: 3.1
  APT prefers testing
  APT policy: (101, 'testing')
Architecture: i386 (i686)
Kernel: Linux 2.6.11.10
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)

Versions of packages afio depends on:
ii  libc6                       2.3.2.ds1-22 GNU C Library: Shared libraries an

-- no debconf information
diff -urw afio-2.5-orig/afio.c afio-2.5/afio.c
--- afio-2.5-orig/afio.c	2003-12-20 23:16:13.000000000 +0100
+++ afio-2.5/afio.c	2005-01-04 15:08:56.000000000 +0100
@@ -261,6 +261,7 @@
      STATIC char *arname;	/* Expanded archive name */
      STATIC uint arpad;		/* Final archive block padding boundary */
      STATIC char arspec[PATHSIZE];	/* Specified archive name */
+     STATIC char command_line[PATHSIZE];/* Subprocess command line */
      STATIC ulonglong aruntil;	/* Volume size limit */
      STATIC int roundaruntil=1; /* Round aruntil to multiple of arbsize? */
      STATIC ulonglong maxsizetocompress=200L*1024L*1024L; /* ==0, then no max */
@@ -4166,6 +4167,51 @@
   return (ifd);
 }
 
+STATIC char *
+prepare_command_line (template)
+char *template;
+{
+	int remain, len;
+	char *sptr, *dptr;
+
+	sptr=template;
+	dptr=command_line;
+	remain = sizeof(command_line);
+
+	for (sptr=template,
+			dptr=command_line,
+			remain=sizeof(command_line); remain>=0; sptr++) {
+		*dptr = '\0';
+		if (*sptr == '%') {
+			switch (*++sptr) {
+			case '%':		/* the % char itself */
+				*dptr++ = '%';
+				remain--;
+				break;
+			case 'V':		/* volume number */
+				if (remain < 10) break;	/* length of 2^32 */
+				len = sprintf(dptr,"%lu", arvolume);
+				dptr += len;
+				remain -= len;
+				break;
+			case 'S':		/* volume size */
+				if (remain < 20) break;	/* length of 2^64 */
+				len = sprintf(dptr,"%llu", aruntil);
+				dptr += len;
+				remain -= len;
+				break;
+			}
+		}
+		else {
+			*dptr++ = *sptr;
+			remain--;
+		}
+		if (*sptr == '\0') break;
+	}
+
+	return command_line;
+}
+
 /*
  * pipechld()
  *
@@ -4185,7 +4231,8 @@
   else
     *av++ = "/bin/sh";
   *av++ = "-c";
-  *av++ = arname + 1;
+  prepare_command_line(arname + 1);
+  *av++ = command_line;
   *av = NULL;
   if (mode)
     {
diff -urw afio-2.5-orig/afio.h afio-2.5/afio.h
--- afio-2.5-orig/afio.h	2003-12-20 14:59:42.000000000 +0100
+++ afio-2.5/afio.h	2005-01-04 15:11:05.000000000 +0100
@@ -472,6 +472,7 @@
 int pipechld (int, int *);
 int pipeopen (int );
 void pipewait (void);
+char *prepare_command_line (char *);
 void prsize (FILE *, ulonglong);
 VOIDFN readcheck (char **);
 #ifndef MKDIR

Reply via email to