write.c (224650) | write.c (248612) |
---|---|
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 224650 2011-08-04 14:18:09Z emaste $"); | 28__FBSDID("$FreeBSD: head/usr.bin/ar/write.c 248612 2013-03-22 10:17:42Z mm $"); |
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> --- 235 unchanged lines hidden (view full) --- 272 const char *bname; 273 char *buff; 274 char **av; 275 size_t size; 276 int i, r, find; 277 278 if ((a = archive_read_new()) == NULL) 279 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> --- 235 unchanged lines hidden (view full) --- 272 const char *bname; 273 char *buff; 274 char **av; 275 size_t size; 276 int i, r, find; 277 278 if ((a = archive_read_new()) == NULL) 279 bsdar_errc(bsdar, EX_SOFTWARE, 0, "archive_read_new failed"); |
280 archive_read_support_compression_none(a); | |
281 archive_read_support_format_ar(a); 282 AC(archive_read_open_filename(a, archive, DEF_BLKSZ)); 283 for (;;) { 284 r = archive_read_next_header(a, &entry); 285 if (r == ARCHIVE_FATAL) 286 bsdar_errc(bsdar, EX_DATAERR, 0, "%s", 287 archive_error_string(a)); 288 if (r == ARCHIVE_EOF) --- 69 unchanged lines hidden (view full) --- 358 /* 359 * Objects from archive have obj->fd set to -1, 360 * for the ease of cleaning up. 361 */ 362 obj->fd = -1; 363 TAILQ_INSERT_TAIL(&bsdar->v_obj, obj, objs); 364 } 365 AC(archive_read_close(a)); | 280 archive_read_support_format_ar(a); 281 AC(archive_read_open_filename(a, archive, DEF_BLKSZ)); 282 for (;;) { 283 r = archive_read_next_header(a, &entry); 284 if (r == ARCHIVE_FATAL) 285 bsdar_errc(bsdar, EX_DATAERR, 0, "%s", 286 archive_error_string(a)); 287 if (r == ARCHIVE_EOF) --- 69 unchanged lines hidden (view full) --- 357 /* 358 * Objects from archive have obj->fd set to -1, 359 * for the ease of cleaning up. 360 */ 361 obj->fd = -1; 362 TAILQ_INSERT_TAIL(&bsdar->v_obj, obj, objs); 363 } 364 AC(archive_read_close(a)); |
366 AC(archive_read_finish(a)); | 365 AC(archive_read_free(a)); |
367} 368 369/* 370 * Determine the constitution of resulting archive. 371 */ 372static void 373write_archive(struct bsdar *bsdar, char mode) 374{ --- 248 unchanged lines hidden (view full) --- 623 *(bsdar->s_so + i) = htobe32(*(bsdar->s_so + i) + 624 pm_sz); 625 } 626 627 if ((a = archive_write_new()) == NULL) 628 bsdar_errc(bsdar, EX_SOFTWARE, 0, "archive_write_new failed"); 629 630 archive_write_set_format_ar_svr4(a); | 366} 367 368/* 369 * Determine the constitution of resulting archive. 370 */ 371static void 372write_archive(struct bsdar *bsdar, char mode) 373{ --- 248 unchanged lines hidden (view full) --- 622 *(bsdar->s_so + i) = htobe32(*(bsdar->s_so + i) + 623 pm_sz); 624 } 625 626 if ((a = archive_write_new()) == NULL) 627 bsdar_errc(bsdar, EX_SOFTWARE, 0, "archive_write_new failed"); 628 629 archive_write_set_format_ar_svr4(a); |
631 archive_write_set_compression_none(a); | |
632 633 AC(archive_write_open_filename(a, bsdar->filename)); 634 635 /* 636 * write the archive symbol table, if there is one. 637 * If options -s is explicitly specified or we are invoked 638 * as ranlib, write the symbol table even if it is empty. 639 */ --- 37 unchanged lines hidden (view full) --- 677 archive_entry_set_ino(entry, obj->ino); 678 archive_entry_set_filetype(entry, AE_IFREG); 679 AC(archive_write_header(a, entry)); 680 write_data(bsdar, a, obj->maddr, obj->size); 681 archive_entry_free(entry); 682 } 683 684 AC(archive_write_close(a)); | 630 631 AC(archive_write_open_filename(a, bsdar->filename)); 632 633 /* 634 * write the archive symbol table, if there is one. 635 * If options -s is explicitly specified or we are invoked 636 * as ranlib, write the symbol table even if it is empty. 637 */ --- 37 unchanged lines hidden (view full) --- 675 archive_entry_set_ino(entry, obj->ino); 676 archive_entry_set_filetype(entry, AE_IFREG); 677 AC(archive_write_header(a, entry)); 678 write_data(bsdar, a, obj->maddr, obj->size); 679 archive_entry_free(entry); 680 } 681 682 AC(archive_write_close(a)); |
685 AC(archive_write_finish(a)); | 683 AC(archive_write_free(a)); |
686} 687 688/* 689 * Extract global symbols from ELF binary members. 690 */ 691static void 692create_symtab_entry(struct bsdar *bsdar, void *maddr, size_t size) 693{ --- 181 unchanged lines hidden --- | 684} 685 686/* 687 * Extract global symbols from ELF binary members. 688 */ 689static void 690create_symtab_entry(struct bsdar *bsdar, void *maddr, size_t size) 691{ --- 181 unchanged lines hidden --- |