diff mpffs/xtr.c @ 40:7ceab8bfacb3

mpffs-cat and mpffs-xtr converted to use the new extra chunk handling
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Mon, 01 Jul 2013 07:04:01 +0000
parents 390be89892c4
children
line wrap: on
line diff
--- a/mpffs/xtr.c	Mon Jul 01 06:49:50 2013 +0000
+++ b/mpffs/xtr.c	Mon Jul 01 07:04:01 2013 +0000
@@ -49,9 +49,11 @@
 }
 
 void
-dump_extra_chunk(fd, ch)
+dump_extra_chunk(ch, opaque)
 	struct objinfo *ch;
+	u_long opaque;
 {
+	int fd = (int) opaque;
 	u8 *endchunk;
 
 	endchunk = find_end_of_chunk(ch);
@@ -62,8 +64,6 @@
 	struct objinfo *head;
 {
 	int fd;
-	int ent;
-	struct objinfo ch;
 
 	fd = open(workpath + 1, O_WRONLY|O_CREAT|O_TRUNC, 0666);
 	if (fd < 0) {
@@ -71,21 +71,7 @@
 		exit(1);
 	}
 	dump_head_chunk(fd, head);
-	for (ent = head->descend; ent != 0xFFFF; ent = ch.descend) {
-		ch.entryno = ent;
-		get_index_entry(&ch);
-		if (ch.type != 0xF4) {
-			fprintf(stderr,
-	"file continuation object at index %x: type %02X != expected F4\n",
-				ent, ch.type);
-			exit(1);
-		}
-		validate_chunk(&ch);
-		dump_extra_chunk(fd, &ch);
-		if (ch.sibling != 0xFFFF)
-			printf("warning: file continuation object (index %x) has a non-nil sibling pointer\n",
-				ent);
-	}
+	iterate_extra_chunks(head->descend, dump_extra_chunk, (u_long) fd);
 	close(fd);
 }