From: Sergey Poznyakoff Date: Fri, 20 Feb 2004 15:32:12 +0000 (+0000) Subject: (start_private_header): Removed static qualifier. X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=93a4273b66545b6c072567d01c8846dc0840d2ed;p=chaz%2Ftar (start_private_header): Removed static qualifier. (write_extended): Removed superfluous last argument. Use xheader_write() (simple_finish_header): New function. (finish_header): Use simple_finish_header() to break recursive dependency between this function and write_extended(). --- diff --git a/src/create.c b/src/create.c index 7884755..cc75bb8 100644 --- a/src/create.c +++ b/src/create.c @@ -371,7 +371,7 @@ tar_copy_str (char *dst, const char *src, size_t len) } /* Write a "private" header */ -static union block * +union block * start_private_header (const char *name, size_t size) { time_t t; @@ -534,9 +534,9 @@ write_long_name (struct tar_stat_info *st) } return write_short_name (st); } - + static union block * -write_extended (struct tar_stat_info *st, union block *old_header, char type) +write_extended (struct tar_stat_info *st, union block *old_header) { union block *header, hp; size_t size; @@ -546,36 +546,10 @@ write_extended (struct tar_stat_info *st, union block *old_header, char type) return old_header; xheader_finish (&extended_header); - size = extended_header.size; - memcpy (hp.buffer, old_header, sizeof (hp)); - - header = start_private_header (p = xheader_xhdr_name (st), size); + p = xheader_xhdr_name (st); + xheader_write (XHDTYPE, p, &extended_header); free (p); - header->header.typeflag = type; - - finish_header (st, header, -1); - - p = extended_header.buffer; - - do - { - size_t len; - - header = find_next_block (); - len = BLOCKSIZE; - if (len > size) - len = size; - memcpy (header->buffer, p, len); - if (len < BLOCKSIZE) - memset (header->buffer + len, 0, BLOCKSIZE - len); - p += len; - size -= len; - set_next_block_after (header); - } - while (size > 0); - - xheader_destroy (&extended_header); header = find_next_block (); memcpy (header, &hp.buffer, sizeof (hp.buffer)); return header; @@ -743,35 +717,13 @@ start_header (struct tar_stat_info *st) return header; } -/* Finish off a filled-in header block and write it out. We also - print the file name and/or full info if verbose is on. If BLOCK_ORDINAL - is not negative, is the block ordinal of the first record for this - file, which may be a preceding long name or long link record. */ void -finish_header (struct tar_stat_info *st, - union block *header, off_t block_ordinal) +simple_finish_header (union block *header) { size_t i; int sum; char *p; - /* Note: It is important to do this before the call to write_extended(), - so that the actual ustar header is printed */ - if (verbose_option - && header->header.typeflag != GNUTYPE_LONGLINK - && header->header.typeflag != GNUTYPE_LONGNAME - && header->header.typeflag != XHDTYPE - && header->header.typeflag != XGLTYPE) - { - /* These globals are parameters to print_header, sigh. */ - - current_header = header; - current_format = archive_format; - print_header (st, block_ordinal); - } - - header = write_extended (st, header, XHDTYPE); - memcpy (header->header.chksum, CHKBLANKS, sizeof header->header.chksum); sum = 0; @@ -794,6 +746,37 @@ finish_header (struct tar_stat_info *st, set_next_block_after (header); } + +/* Finish off a filled-in header block and write it out. We also + print the file name and/or full info if verbose is on. If BLOCK_ORDINAL + is not negative, is the block ordinal of the first record for this + file, which may be a preceding long name or long link record. */ +void +finish_header (struct tar_stat_info *st, + union block *header, off_t block_ordinal) +{ + size_t i; + int sum; + char *p; + + /* Note: It is important to do this before the call to write_extended(), + so that the actual ustar header is printed */ + if (verbose_option + && header->header.typeflag != GNUTYPE_LONGLINK + && header->header.typeflag != GNUTYPE_LONGNAME + && header->header.typeflag != XHDTYPE + && header->header.typeflag != XGLTYPE) + { + /* These globals are parameters to print_header, sigh. */ + + current_header = header; + current_format = archive_format; + print_header (st, block_ordinal); + } + + header = write_extended (st, header); + simple_finish_header (header); +} void @@ -1069,7 +1052,8 @@ create_archive (void) char *p; open_archive (ACCESS_WRITE); - + xheader_write_global (); + if (incremental_option) { size_t buffer_size = 1000;