mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-19 10:53:58 +00:00
Merge r390,r391,r392,r397 from libarchive.googlecode.com: Virtualize
"close" and "finish" across both read and write interfaces. (Someday, "finish" should be renamed to "free" to better reflect what it actually does...)
This commit is contained in:
parent
2ee8325f42
commit
341f2011d8
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=189424
@ -52,8 +52,8 @@
|
|||||||
#define ARCHIVE_STATE_FATAL 0x8000U
|
#define ARCHIVE_STATE_FATAL 0x8000U
|
||||||
|
|
||||||
struct archive_vtable {
|
struct archive_vtable {
|
||||||
int (*archive_write_close)(struct archive *);
|
int (*archive_close)(struct archive *);
|
||||||
int (*archive_write_finish)(struct archive *);
|
int (*archive_finish)(struct archive *);
|
||||||
int (*archive_write_header)(struct archive *,
|
int (*archive_write_header)(struct archive *,
|
||||||
struct archive_entry *);
|
struct archive_entry *);
|
||||||
int (*archive_write_finish_entry)(struct archive *);
|
int (*archive_write_finish_entry)(struct archive *);
|
||||||
|
@ -57,6 +57,22 @@ __FBSDID("$FreeBSD$");
|
|||||||
|
|
||||||
static int build_stream(struct archive_read *);
|
static int build_stream(struct archive_read *);
|
||||||
static int choose_format(struct archive_read *);
|
static int choose_format(struct archive_read *);
|
||||||
|
static struct archive_vtable *archive_read_vtable(void);
|
||||||
|
static int _archive_read_close(struct archive *);
|
||||||
|
static int _archive_read_finish(struct archive *);
|
||||||
|
|
||||||
|
static struct archive_vtable *
|
||||||
|
archive_read_vtable(void)
|
||||||
|
{
|
||||||
|
static struct archive_vtable av;
|
||||||
|
static int inited = 0;
|
||||||
|
|
||||||
|
if (!inited) {
|
||||||
|
av.archive_finish = _archive_read_finish;
|
||||||
|
av.archive_close = _archive_read_close;
|
||||||
|
}
|
||||||
|
return (&av);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Allocate, initialize and return a struct archive object.
|
* Allocate, initialize and return a struct archive object.
|
||||||
@ -74,6 +90,7 @@ archive_read_new(void)
|
|||||||
|
|
||||||
a->archive.state = ARCHIVE_STATE_NEW;
|
a->archive.state = ARCHIVE_STATE_NEW;
|
||||||
a->entry = archive_entry_new();
|
a->entry = archive_entry_new();
|
||||||
|
a->archive.vtable = archive_read_vtable();
|
||||||
|
|
||||||
return (&a->archive);
|
return (&a->archive);
|
||||||
}
|
}
|
||||||
@ -134,6 +151,7 @@ client_close_proxy(struct archive_read_filter *self)
|
|||||||
if (self->archive->client.closer != NULL)
|
if (self->archive->client.closer != NULL)
|
||||||
r = (self->archive->client.closer)((struct archive *)self->archive,
|
r = (self->archive->client.closer)((struct archive *)self->archive,
|
||||||
self->data);
|
self->data);
|
||||||
|
self->data = NULL;
|
||||||
return (r);
|
return (r);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -556,8 +574,8 @@ archive_read_data_block(struct archive *_a,
|
|||||||
* Don't assume we actually read anything or performed any non-trivial
|
* Don't assume we actually read anything or performed any non-trivial
|
||||||
* initialization.
|
* initialization.
|
||||||
*/
|
*/
|
||||||
int
|
static int
|
||||||
archive_read_close(struct archive *_a)
|
_archive_read_close(struct archive *_a)
|
||||||
{
|
{
|
||||||
struct archive_read *a = (struct archive_read *)_a;
|
struct archive_read *a = (struct archive_read *)_a;
|
||||||
int r = ARCHIVE_OK, r1 = ARCHIVE_OK;
|
int r = ARCHIVE_OK, r1 = ARCHIVE_OK;
|
||||||
@ -602,13 +620,8 @@ archive_read_close(struct archive *_a)
|
|||||||
/*
|
/*
|
||||||
* Release memory and other resources.
|
* Release memory and other resources.
|
||||||
*/
|
*/
|
||||||
#if ARCHIVE_API_VERSION > 1
|
|
||||||
int
|
int
|
||||||
#else
|
_archive_read_finish(struct archive *_a)
|
||||||
/* Temporarily allow library to compile with either 1.x or 2.0 API. */
|
|
||||||
void
|
|
||||||
#endif
|
|
||||||
archive_read_finish(struct archive *_a)
|
|
||||||
{
|
{
|
||||||
struct archive_read *a = (struct archive_read *)_a;
|
struct archive_read *a = (struct archive_read *)_a;
|
||||||
int i;
|
int i;
|
||||||
|
@ -33,24 +33,36 @@ __FBSDID("$FreeBSD$");
|
|||||||
int
|
int
|
||||||
archive_write_close(struct archive *a)
|
archive_write_close(struct archive *a)
|
||||||
{
|
{
|
||||||
return ((a->vtable->archive_write_close)(a));
|
return ((a->vtable->archive_close)(a));
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
archive_read_close(struct archive *a)
|
||||||
|
{
|
||||||
|
return ((a->vtable->archive_close)(a));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ARCHIVE_API_VERSION > 1
|
#if ARCHIVE_API_VERSION > 1
|
||||||
int
|
int
|
||||||
archive_write_finish(struct archive *a)
|
archive_write_finish(struct archive *a)
|
||||||
{
|
{
|
||||||
return ((a->vtable->archive_write_finish)(a));
|
return ((a->vtable->archive_finish)(a));
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
/* Temporarily allow library to compile with either 1.x or 2.0 API. */
|
/* Temporarily allow library to compile with either 1.x or 2.0 API. */
|
||||||
void
|
void
|
||||||
archive_write_finish(struct archive *a)
|
archive_write_finish(struct archive *a)
|
||||||
{
|
{
|
||||||
(void)(a->vtable->archive_write_finish)(a);
|
(void)(a->vtable->archive_finish)(a);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
int
|
||||||
|
archive_read_finish(struct archive *a)
|
||||||
|
{
|
||||||
|
return ((a->vtable->archive_finish)(a));
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
archive_write_header(struct archive *a, struct archive_entry *entry)
|
archive_write_header(struct archive *a, struct archive_entry *entry)
|
||||||
{
|
{
|
||||||
|
@ -72,8 +72,8 @@ archive_write_vtable(void)
|
|||||||
static int inited = 0;
|
static int inited = 0;
|
||||||
|
|
||||||
if (!inited) {
|
if (!inited) {
|
||||||
av.archive_write_close = _archive_write_close;
|
av.archive_close = _archive_write_close;
|
||||||
av.archive_write_finish = _archive_write_finish;
|
av.archive_finish = _archive_write_finish;
|
||||||
av.archive_write_header = _archive_write_header;
|
av.archive_write_header = _archive_write_header;
|
||||||
av.archive_write_finish_entry = _archive_write_finish_entry;
|
av.archive_write_finish_entry = _archive_write_finish_entry;
|
||||||
av.archive_write_data = _archive_write_data;
|
av.archive_write_data = _archive_write_data;
|
||||||
|
@ -278,8 +278,8 @@ archive_write_disk_vtable(void)
|
|||||||
static int inited = 0;
|
static int inited = 0;
|
||||||
|
|
||||||
if (!inited) {
|
if (!inited) {
|
||||||
av.archive_write_close = _archive_write_close;
|
av.archive_close = _archive_write_close;
|
||||||
av.archive_write_finish = _archive_write_finish;
|
av.archive_finish = _archive_write_finish;
|
||||||
av.archive_write_header = _archive_write_header;
|
av.archive_write_header = _archive_write_header;
|
||||||
av.archive_write_finish_entry = _archive_write_finish_entry;
|
av.archive_write_finish_entry = _archive_write_finish_entry;
|
||||||
av.archive_write_data = _archive_write_data;
|
av.archive_write_data = _archive_write_data;
|
||||||
|
Loading…
Reference in New Issue
Block a user