1228753Smm/*-
2228753Smm * Copyright (c) 2003-2011 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_read_support_format_all.c 342361 2018-12-21 23:33:28Z mm $");
28228753Smm
29228753Smm#include "archive.h"
30232153Smm#include "archive_private.h"
31228753Smm
32228753Smmint
33228753Smmarchive_read_support_format_all(struct archive *a)
34228753Smm{
35232153Smm	archive_check_magic(a, ARCHIVE_READ_MAGIC,
36232153Smm	    ARCHIVE_STATE_NEW, "archive_read_support_format_all");
37232153Smm
38232153Smm	/* TODO: It would be nice to compute the ordering
39232153Smm	 * here automatically so that people who enable just
40232153Smm	 * a few formats can still get the benefits.  That
41232153Smm	 * may just require the format registration to include
42232153Smm	 * a "maximum read-ahead" value (anything that uses seek
43232153Smm	 * would be essentially infinite read-ahead).  The core
44232153Smm	 * bid management can then sort the bidders before calling
45232153Smm	 * them.
46232153Smm	 *
47232153Smm	 * If you implement the above, please return the list below
48232153Smm	 * to alphabetic order.
49232153Smm	 */
50232153Smm
51232153Smm	/*
52232153Smm	 * These bidders are all pretty cheap; they just examine a
53232153Smm	 * small initial part of the archive.  If one of these bids
54232153Smm	 * high, we can maybe avoid running any of the more expensive
55232153Smm	 * bidders below.
56232153Smm	 */
57228753Smm	archive_read_support_format_ar(a);
58228753Smm	archive_read_support_format_cpio(a);
59228753Smm	archive_read_support_format_empty(a);
60232153Smm	archive_read_support_format_lha(a);
61228753Smm	archive_read_support_format_mtree(a);
62228753Smm	archive_read_support_format_tar(a);
63228753Smm	archive_read_support_format_xar(a);
64302001Smm	archive_read_support_format_warc(a);
65232153Smm
66232153Smm	/*
67232153Smm	 * Install expensive bidders last.  By doing them last, we
68232153Smm	 * increase the chance that a high bid from someone else will
69232153Smm	 * make it unnecessary for these to do anything at all.
70232153Smm	 */
71232153Smm	/* These three have potentially large look-ahead. */
72232153Smm	archive_read_support_format_7zip(a);
73232153Smm	archive_read_support_format_cab(a);
74232153Smm	archive_read_support_format_rar(a);
75342361Smm	archive_read_support_format_rar5(a);
76232153Smm	archive_read_support_format_iso9660(a);
77232153Smm	/* Seek is really bad, since it forces the read-ahead
78232153Smm	 * logic to discard buffered data. */
79228753Smm	archive_read_support_format_zip(a);
80228753Smm
81228753Smm	/* Note: We always return ARCHIVE_OK here, even if some of the
82228753Smm	 * above return ARCHIVE_WARN.  The intent here is to enable
83228753Smm	 * "as much as possible."  Clients who need specific
84228753Smm	 * compression should enable those individually so they can
85228753Smm	 * verify the level of support. */
86228753Smm	/* Clear any warning messages set by the above functions. */
87228753Smm	archive_clear_error(a);
88228753Smm	return (ARCHIVE_OK);
89228753Smm}
90