From b806fc9a73e79b561fad9e40e34d44d86031e4a1 Mon Sep 17 00:00:00 2001
From: Guillem Jover <guillem@debian.org>
Date: Sun, 16 Feb 2014 02:25:10 +0100
Subject: [PATCH 1/4] Pass member_base as an argument to get_compression_type()

Allow other member base names, instead of hardcoding data.tar.
---
 udpkg.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/udpkg.c b/udpkg.c
index 2adfd16..73fa9d8 100644
--- a/udpkg.c
+++ b/udpkg.c
@@ -163,7 +163,9 @@ static const char *decompression_tool (const compression_type t) {
 	}
 }
 
-static compression_type get_compression_type (struct package_t *pkg) {
+static compression_type get_compression_type(struct package_t *pkg,
+	const char *member_base)
+{
 	FILE *infp = NULL;
 	char buf[1024];
 	char *extension = NULL;
@@ -177,8 +179,8 @@ static compression_type get_compression_type (struct package_t *pkg) {
 	}
 
 	while (fgets(buf, sizeof(buf), infp)) {
-		if (strncmp(buf, data_member_base, strlen(data_member_base)) == 0) {
-			extension = buf + strlen(data_member_base);
+		if (strncmp(buf, member_base, strlen(member_base)) == 0) {
+			extension = buf + strlen(member_base);
 			if (extension[strlen(extension) - 1] == '\n')
 				extension[strlen(extension) - 1] = '\0';
 			break;
@@ -188,7 +190,7 @@ static compression_type get_compression_type (struct package_t *pkg) {
 
 	if (extension == NULL) {
 		FPRINTF(stderr, "No %s* found in %s\n",
-			data_member_base, pkg->file);
+			member_base, pkg->file);
 		return unknown_compression;
 	}
 
@@ -200,7 +202,7 @@ static compression_type get_compression_type (struct package_t *pkg) {
 	}
 	else {
 		FPRINTF(stderr, "Invalid compression type for %s* of %s\n",
-			data_member_base, pkg->file);
+			member_base, pkg->file);
 		return unknown_compression;
 	}
 }
@@ -226,7 +228,7 @@ static int dpkg_dounpack(struct package_t *pkg)
 
 	DPRINTF("Unpacking %s\n", pkg->package);
 
-	compression_type = get_compression_type(pkg);
+	compression_type = get_compression_type(pkg, data_member_base);
 	if (compression_type == unknown_compression)
 		return 1;
 
@@ -556,7 +558,7 @@ static int dpkg_contents(struct package_t *pkg)
 
 	reqarg(pkg);
 
-	compression_type = get_compression_type(pkg);
+	compression_type = get_compression_type(pkg, data_member_base);
 	if (compression_type == unknown_compression)
 		return 1;
 
-- 
1.9.0.rc3.244.g3497008

