1228753Smm/*-
2228753Smm * Copyright (c) 2003-2007 Tim Kientzle
3228753Smm * All rights reserved.
4228753Smm *
5228753Smm * Redistribution and use in source and binary forms, with or without
6228753Smm * modification, are permitted provided that the following conditions
7228753Smm * are met:
8228753Smm * 1. Redistributions of source code must retain the above copyright
9228753Smm *    notice, this list of conditions and the following disclaimer.
10228753Smm * 2. Redistributions in binary form must reproduce the above copyright
11228753Smm *    notice, this list of conditions and the following disclaimer in the
12228753Smm *    documentation and/or other materials provided with the distribution.
13228753Smm *
14228753Smm * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
15228753Smm * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16228753Smm * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17228753Smm * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
18228753Smm * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19228753Smm * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20228753Smm * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21228753Smm * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22228753Smm * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23228753Smm * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24228753Smm */
25228753Smm
26228753Smm#include "archive_platform.h"
27228763Smm__FBSDID("$FreeBSD: stable/10/contrib/libarchive/libarchive/archive_virtual.c 337352 2018-08-05 14:36:12Z mm $");
28228753Smm
29228753Smm#include "archive.h"
30228753Smm#include "archive_entry.h"
31228753Smm#include "archive_private.h"
32228753Smm
33228753Smmint
34232153Smmarchive_filter_code(struct archive *a, int n)
35232153Smm{
36232153Smm	return ((a->vtable->archive_filter_code)(a, n));
37232153Smm}
38232153Smm
39232153Smmint
40232153Smmarchive_filter_count(struct archive *a)
41232153Smm{
42232153Smm	return ((a->vtable->archive_filter_count)(a));
43232153Smm}
44232153Smm
45232153Smmconst char *
46232153Smmarchive_filter_name(struct archive *a, int n)
47232153Smm{
48232153Smm	return ((a->vtable->archive_filter_name)(a, n));
49232153Smm}
50232153Smm
51328828Smmla_int64_t
52232153Smmarchive_filter_bytes(struct archive *a, int n)
53232153Smm{
54232153Smm	return ((a->vtable->archive_filter_bytes)(a, n));
55232153Smm}
56232153Smm
57232153Smmint
58302001Smmarchive_free(struct archive *a)
59302001Smm{
60302001Smm	if (a == NULL)
61302001Smm		return (ARCHIVE_OK);
62302001Smm	return ((a->vtable->archive_free)(a));
63302001Smm}
64302001Smm
65302001Smmint
66228753Smmarchive_write_close(struct archive *a)
67228753Smm{
68228753Smm	return ((a->vtable->archive_close)(a));
69228753Smm}
70228753Smm
71228753Smmint
72228753Smmarchive_read_close(struct archive *a)
73228753Smm{
74228753Smm	return ((a->vtable->archive_close)(a));
75228753Smm}
76228753Smm
77228753Smmint
78248616Smmarchive_write_fail(struct archive *a)
79248616Smm{
80248616Smm	a->state = ARCHIVE_STATE_FATAL;
81248616Smm	return a->state;
82248616Smm}
83248616Smm
84248616Smmint
85228773Smmarchive_write_free(struct archive *a)
86228753Smm{
87302001Smm	return archive_free(a);
88228753Smm}
89228773Smm
90228773Smm#if ARCHIVE_VERSION_NUMBER < 4000000
91228773Smm/* For backwards compatibility; will be removed with libarchive 4.0. */
92228773Smmint
93228753Smmarchive_write_finish(struct archive *a)
94228753Smm{
95232153Smm	return archive_write_free(a);
96228753Smm}
97228753Smm#endif
98228753Smm
99228753Smmint
100228773Smmarchive_read_free(struct archive *a)
101228773Smm{
102302001Smm	return archive_free(a);
103228773Smm}
104228773Smm
105228773Smm#if ARCHIVE_VERSION_NUMBER < 4000000
106228773Smm/* For backwards compatibility; will be removed with libarchive 4.0. */
107228773Smmint
108228753Smmarchive_read_finish(struct archive *a)
109228753Smm{
110232153Smm	return archive_read_free(a);
111228753Smm}
112228773Smm#endif
113228753Smm
114228753Smmint
115228753Smmarchive_write_header(struct archive *a, struct archive_entry *entry)
116228753Smm{
117228753Smm	++a->file_count;
118228753Smm	return ((a->vtable->archive_write_header)(a, entry));
119228753Smm}
120228753Smm
121228753Smmint
122228753Smmarchive_write_finish_entry(struct archive *a)
123228753Smm{
124228753Smm	return ((a->vtable->archive_write_finish_entry)(a));
125228753Smm}
126228753Smm
127337352Smmla_ssize_t
128228753Smmarchive_write_data(struct archive *a, const void *buff, size_t s)
129228753Smm{
130228753Smm	return ((a->vtable->archive_write_data)(a, buff, s));
131228753Smm}
132228753Smm
133337352Smmla_ssize_t
134328828Smmarchive_write_data_block(struct archive *a, const void *buff, size_t s,
135328828Smm    la_int64_t o)
136228753Smm{
137232153Smm	if (a->vtable->archive_write_data_block == NULL) {
138232153Smm		archive_set_error(a, ARCHIVE_ERRNO_MISC,
139232153Smm		    "archive_write_data_block not supported");
140232153Smm		a->state = ARCHIVE_STATE_FATAL;
141232153Smm		return (ARCHIVE_FATAL);
142232153Smm	}
143228753Smm	return ((a->vtable->archive_write_data_block)(a, buff, s, o));
144228753Smm}
145232153Smm
146232153Smmint
147232153Smmarchive_read_next_header(struct archive *a, struct archive_entry **entry)
148232153Smm{
149232153Smm	return ((a->vtable->archive_read_next_header)(a, entry));
150232153Smm}
151232153Smm
152232153Smmint
153232153Smmarchive_read_next_header2(struct archive *a, struct archive_entry *entry)
154232153Smm{
155232153Smm	return ((a->vtable->archive_read_next_header2)(a, entry));
156232153Smm}
157232153Smm
158232153Smmint
159232153Smmarchive_read_data_block(struct archive *a,
160328828Smm    const void **buff, size_t *s, la_int64_t *o)
161232153Smm{
162232153Smm	return ((a->vtable->archive_read_data_block)(a, buff, s, o));
163232153Smm}
164