archive_write.c (228763) | archive_write.c (228773) |
---|---|
1/*- 2 * Copyright (c) 2003-2007 Tim Kientzle 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 --- 10 unchanged lines hidden (view full) --- 19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26#include "archive_platform.h" | 1/*- 2 * Copyright (c) 2003-2007 Tim Kientzle 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 --- 10 unchanged lines hidden (view full) --- 19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26#include "archive_platform.h" |
27__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_write.c 228763 2011-12-21 11:13:29Z mm $"); | 27__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_write.c 228773 2011-12-21 15:18:52Z mm $"); |
28 29/* 30 * This file contains the "essential" portions of the write API, that 31 * is, stuff that will essentially always be used by any client that 32 * actually needs to write a archive. Optional pieces have been, as 33 * far as possible, separated out into separate files to reduce 34 * needlessly bloating statically-linked clients. 35 */ --- 19 unchanged lines hidden (view full) --- 55#include "archive.h" 56#include "archive_entry.h" 57#include "archive_private.h" 58#include "archive_write_private.h" 59 60static struct archive_vtable *archive_write_vtable(void); 61 62static int _archive_write_close(struct archive *); | 28 29/* 30 * This file contains the "essential" portions of the write API, that 31 * is, stuff that will essentially always be used by any client that 32 * actually needs to write a archive. Optional pieces have been, as 33 * far as possible, separated out into separate files to reduce 34 * needlessly bloating statically-linked clients. 35 */ --- 19 unchanged lines hidden (view full) --- 55#include "archive.h" 56#include "archive_entry.h" 57#include "archive_private.h" 58#include "archive_write_private.h" 59 60static struct archive_vtable *archive_write_vtable(void); 61 62static int _archive_write_close(struct archive *); |
63static int _archive_write_finish(struct archive *); | 63static int _archive_write_free(struct archive *); |
64static int _archive_write_header(struct archive *, struct archive_entry *); 65static int _archive_write_finish_entry(struct archive *); 66static ssize_t _archive_write_data(struct archive *, const void *, size_t); 67 68static struct archive_vtable * 69archive_write_vtable(void) 70{ 71 static struct archive_vtable av; 72 static int inited = 0; 73 74 if (!inited) { 75 av.archive_close = _archive_write_close; | 64static int _archive_write_header(struct archive *, struct archive_entry *); 65static int _archive_write_finish_entry(struct archive *); 66static ssize_t _archive_write_data(struct archive *, const void *, size_t); 67 68static struct archive_vtable * 69archive_write_vtable(void) 70{ 71 static struct archive_vtable av; 72 static int inited = 0; 73 74 if (!inited) { 75 av.archive_close = _archive_write_close; |
76 av.archive_finish = _archive_write_finish; | 76 av.archive_free = _archive_write_free; |
77 av.archive_write_header = _archive_write_header; 78 av.archive_write_finish_entry = _archive_write_finish_entry; 79 av.archive_write_data = _archive_write_data; 80 } 81 return (&av); 82} 83 84/* --- 293 unchanged lines hidden (view full) --- 378 a->archive.state = ARCHIVE_STATE_CLOSED; 379 return (r); 380} 381 382/* 383 * Destroy the archive structure. 384 */ 385static int | 77 av.archive_write_header = _archive_write_header; 78 av.archive_write_finish_entry = _archive_write_finish_entry; 79 av.archive_write_data = _archive_write_data; 80 } 81 return (&av); 82} 83 84/* --- 293 unchanged lines hidden (view full) --- 378 a->archive.state = ARCHIVE_STATE_CLOSED; 379 return (r); 380} 381 382/* 383 * Destroy the archive structure. 384 */ 385static int |
386_archive_write_finish(struct archive *_a) | 386_archive_write_free(struct archive *_a) |
387{ 388 struct archive_write *a = (struct archive_write *)_a; 389 int r = ARCHIVE_OK; 390 391 __archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC, | 387{ 388 struct archive_write *a = (struct archive_write *)_a; 389 int r = ARCHIVE_OK; 390 391 __archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC, |
392 ARCHIVE_STATE_ANY, "archive_write_finish"); | 392 ARCHIVE_STATE_ANY, "archive_write_free"); |
393 if (a->archive.state != ARCHIVE_STATE_CLOSED) 394 r = archive_write_close(&a->archive); 395 396 /* Release various dynamic buffers. */ 397 free((void *)(uintptr_t)(const void *)a->nulls); 398 archive_string_free(&a->archive.error_string); 399 a->archive.magic = 0; 400 free(a); --- 66 unchanged lines hidden --- | 393 if (a->archive.state != ARCHIVE_STATE_CLOSED) 394 r = archive_write_close(&a->archive); 395 396 /* Release various dynamic buffers. */ 397 free((void *)(uintptr_t)(const void *)a->nulls); 398 archive_string_free(&a->archive.error_string); 399 a->archive.magic = 0; 400 free(a); --- 66 unchanged lines hidden --- |