write.c (183218) | write.c (208189) |
---|---|
1/*- 2 * Copyright (c) 2007 Kai Wang 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2007 Kai Wang 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/usr.bin/ar/write.c 183218 2008-09-20 22:10:10Z kaiw $"); | 28__FBSDID("$FreeBSD: head/usr.bin/ar/write.c 208189 2010-05-17 09:37:59Z kaiw $"); |
29 30#include <sys/endian.h> 31#include <sys/mman.h> 32#include <sys/queue.h> 33#include <sys/stat.h> 34#include <archive.h> 35#include <archive_entry.h> 36#include <errno.h> --- 205 unchanged lines hidden (view full) --- 242 const char *bname; 243 char *buff; 244 char **av; 245 size_t size; 246 int i, r, find; 247 248 if ((a = archive_read_new()) == NULL) 249 bsdar_errc(bsdar, EX_SOFTWARE, 0, "archive_read_new failed"); | 29 30#include <sys/endian.h> 31#include <sys/mman.h> 32#include <sys/queue.h> 33#include <sys/stat.h> 34#include <archive.h> 35#include <archive_entry.h> 36#include <errno.h> --- 205 unchanged lines hidden (view full) --- 242 const char *bname; 243 char *buff; 244 char **av; 245 size_t size; 246 int i, r, find; 247 248 if ((a = archive_read_new()) == NULL) 249 bsdar_errc(bsdar, EX_SOFTWARE, 0, "archive_read_new failed"); |
250 archive_read_support_compression_all(a); | 250 archive_read_support_compression_none(a); |
251 archive_read_support_format_ar(a); 252 AC(archive_read_open_filename(a, archive, DEF_BLKSZ)); 253 for (;;) { 254 r = archive_read_next_header(a, &entry); 255 if (r == ARCHIVE_FATAL) 256 bsdar_errc(bsdar, EX_DATAERR, 0, "%s", 257 archive_error_string(a)); 258 if (r == ARCHIVE_EOF) 259 break; 260 if (r == ARCHIVE_WARN || r == ARCHIVE_RETRY) 261 bsdar_warnc(bsdar, 0, "%s", archive_error_string(a)); 262 if (r == ARCHIVE_RETRY) { 263 bsdar_warnc(bsdar, 0, "Retrying..."); 264 continue; 265 } 266 | 251 archive_read_support_format_ar(a); 252 AC(archive_read_open_filename(a, archive, DEF_BLKSZ)); 253 for (;;) { 254 r = archive_read_next_header(a, &entry); 255 if (r == ARCHIVE_FATAL) 256 bsdar_errc(bsdar, EX_DATAERR, 0, "%s", 257 archive_error_string(a)); 258 if (r == ARCHIVE_EOF) 259 break; 260 if (r == ARCHIVE_WARN || r == ARCHIVE_RETRY) 261 bsdar_warnc(bsdar, 0, "%s", archive_error_string(a)); 262 if (r == ARCHIVE_RETRY) { 263 bsdar_warnc(bsdar, 0, "Retrying..."); 264 continue; 265 } 266 |
267 /* 268 * Remember the compression mode of existing archive. 269 * If neither -j nor -z is specified, this mode will 270 * be used for resulting archive. 271 */ 272 bsdar->compression = archive_compression(a); 273 | |
274 name = archive_entry_pathname(entry); 275 276 /* 277 * skip pseudo members. 278 */ 279 if (strcmp(name, "/") == 0 || strcmp(name, "//") == 0) 280 continue; 281 --- 73 unchanged lines hidden (view full) --- 355 char **av; 356 int i; 357 358 TAILQ_INIT(&bsdar->v_obj); 359 nobj = NULL; 360 pos = NULL; 361 memset(&sb, 0, sizeof(sb)); 362 | 267 name = archive_entry_pathname(entry); 268 269 /* 270 * skip pseudo members. 271 */ 272 if (strcmp(name, "/") == 0 || strcmp(name, "//") == 0) 273 continue; 274 --- 73 unchanged lines hidden (view full) --- 348 char **av; 349 int i; 350 351 TAILQ_INIT(&bsdar->v_obj); 352 nobj = NULL; 353 pos = NULL; 354 memset(&sb, 0, sizeof(sb)); 355 |
363 /* By default, no compression is assumed. */ 364 bsdar->compression = ARCHIVE_COMPRESSION_NONE; 365 | |
366 /* 367 * Test if the specified archive exists, to figure out 368 * whether we are creating one here. 369 */ 370 if (stat(bsdar->filename, &sb) != 0) { 371 if (errno != ENOENT) { 372 bsdar_warnc(bsdar, 0, "stat %s failed", 373 bsdar->filename); --- 239 unchanged lines hidden (view full) --- 613 *(bsdar->s_so + i) = htobe32(*(bsdar->s_so + i) + 614 pm_sz); 615 } 616 617 if ((a = archive_write_new()) == NULL) 618 bsdar_errc(bsdar, EX_SOFTWARE, 0, "archive_write_new failed"); 619 620 archive_write_set_format_ar_svr4(a); | 356 /* 357 * Test if the specified archive exists, to figure out 358 * whether we are creating one here. 359 */ 360 if (stat(bsdar->filename, &sb) != 0) { 361 if (errno != ENOENT) { 362 bsdar_warnc(bsdar, 0, "stat %s failed", 363 bsdar->filename); --- 239 unchanged lines hidden (view full) --- 603 *(bsdar->s_so + i) = htobe32(*(bsdar->s_so + i) + 604 pm_sz); 605 } 606 607 if ((a = archive_write_new()) == NULL) 608 bsdar_errc(bsdar, EX_SOFTWARE, 0, "archive_write_new failed"); 609 610 archive_write_set_format_ar_svr4(a); |
611 archive_write_set_compression_none(a); |
|
621 | 612 |
622 /* The compression mode of the existing archive is used 623 * for the result archive or if creating a new archive, we 624 * do not compress archive by default. This default behavior can 625 * be overrided by compression mode specified explicitly 626 * through command line option `-j' or `-z'. 627 */ 628 if (bsdar->options & AR_J) 629 bsdar->compression = ARCHIVE_COMPRESSION_BZIP2; 630 if (bsdar->options & AR_Z) 631 bsdar->compression = ARCHIVE_COMPRESSION_GZIP; 632 if (bsdar->compression == ARCHIVE_COMPRESSION_BZIP2) 633 archive_write_set_compression_bzip2(a); 634 else if (bsdar->compression == ARCHIVE_COMPRESSION_GZIP) 635 archive_write_set_compression_gzip(a); 636 else 637 archive_write_set_compression_none(a); 638 | |
639 AC(archive_write_open_filename(a, bsdar->filename)); 640 641 /* 642 * write the archive symbol table, if there is one. 643 * If options -s is explicitly specified or we are invoked 644 * as ranlib, write the symbol table even if it is empty. 645 */ 646 if ((bsdar->s_cnt != 0 && !(bsdar->options & AR_SS)) || --- 233 unchanged lines hidden --- | 613 AC(archive_write_open_filename(a, bsdar->filename)); 614 615 /* 616 * write the archive symbol table, if there is one. 617 * If options -s is explicitly specified or we are invoked 618 * as ranlib, write the symbol table even if it is empty. 619 */ 620 if ((bsdar->s_cnt != 0 && !(bsdar->options & AR_SS)) || --- 233 unchanged lines hidden --- |