From 9aff9036035fbed074e8e711b96c5c934e668884 Mon Sep 17 00:00:00 2001 From: Glenn L McGrath Date: Wed, 13 Jun 2001 07:26:39 +0000 Subject: Reorganise archive extraction code --- libbb/get_ar_headers.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'libbb/get_ar_headers.c') diff --git a/libbb/get_ar_headers.c b/libbb/get_ar_headers.c index 151caafe1..414498b4f 100644 --- a/libbb/get_ar_headers.c +++ b/libbb/get_ar_headers.c @@ -30,7 +30,7 @@ #include #include "libbb.h" -extern ar_headers_t *get_ar_headers(FILE *in_file) +file_headers_t *get_ar_headers(FILE *in_file) { typedef struct raw_ar_header_s { /* Byte Offset */ char name[16]; /* 0-15 */ @@ -44,7 +44,7 @@ extern ar_headers_t *get_ar_headers(FILE *in_file) raw_ar_header_t raw_ar_header; - ar_headers_t *ar_list, *ar_tmp, *ar_entry; + file_headers_t *ar_list, *ar_entry; char ar_magic[8]; char *long_name=NULL; @@ -59,10 +59,10 @@ extern ar_headers_t *get_ar_headers(FILE *in_file) return(NULL); } - ar_list = (ar_headers_t *) xcalloc(1, sizeof(ar_headers_t)); + ar_list = (file_headers_t *) xcalloc(1, sizeof(file_headers_t)); while (fread((char *) &raw_ar_header, 1, 60, in_file) == 60) { - ar_entry = (ar_headers_t *) xcalloc(1, sizeof(ar_headers_t)); + ar_entry = (file_headers_t *) xcalloc(1, sizeof(file_headers_t)); /* check the end of header markers are valid */ if ((raw_ar_header.fmag[0] != '`') || (raw_ar_header.fmag[1] != '\n')) { char newline; @@ -113,12 +113,7 @@ extern ar_headers_t *get_ar_headers(FILE *in_file) fseek(in_file, (off_t) ar_entry->size, SEEK_CUR); - ar_tmp = (ar_headers_t *) xcalloc(1, sizeof(ar_headers_t)); - *ar_tmp = *ar_list; - *ar_list = *ar_entry; - free(ar_entry); - ar_list->next = ar_tmp; + ar_list = append_archive_list(ar_list, ar_entry); } - return(ar_list); } -- cgit v1.2.3