ctb_formats_detection/
file_upstream_suite.rs

1/*
2$File: COPYING,v 1.2 2018/09/09 20:33:28 christos Exp $
3Copyright (c) Ian F. Darwin 1986, 1987, 1989, 1990, 1991, 1992, 1994, 1995.
4Software written by Ian F. Darwin and others;
5maintained 1994- Christos Zoulas.
6
7This software is not subject to any export provision of the United States
8Department of Commerce, and may be exported to any country or planet.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions
12are met:
131. Redistributions of source code must retain the above copyright
14   notice immediately at the beginning of the file, without modification,
15   this list of conditions, and the following disclaimer.
162. Redistributions in binary form must reproduce the above copyright
17   notice, this list of conditions and the following disclaimer in the
18   documentation and/or other materials provided with the distribution.
19
20THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
24ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30SUCH DAMAGE.
31
32The preceding notice is from COPYING in `file`.
33
34
35
36/*
37 * Copyright (c) Ian F. Darwin 1986-1995.
38 * Software written by Ian F. Darwin and others;
39 * maintained 1995-present by Christos Zoulas and others.
40 *
41 * Redistribution and use in source and binary forms, with or without
42 * modification, are permitted provided that the following conditions
43 * are met:
44 * 1. Redistributions of source code must retain the above copyright
45 *    notice immediately at the beginning of the file, without modification,
46 *    this list of conditions, and the following disclaimer.
47 * 2. Redistributions in binary form must reproduce the above copyright
48 *    notice, this list of conditions and the following disclaimer in the
49 *    documentation and/or other materials provided with the distribution.
50 *
51 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
52 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
53 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
54 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
55 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
56 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
57 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
58 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
59 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
60 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
61 * SUCH DAMAGE.
62 */
63
64The preceding notice is from src/apprentice.c, src/ascmagic.c, src/compress.c, src/encoding.c, src/file.c, src/file.h, src/fsmagic.c, src/missing/asprintf.c, src/missing/dprintf.c, src/print.c, src/softmagic.c, src/swap.c, and src/swap.h in `file`.
65
66
67
68/*
69 * Copyright (c) Christos Zoulas 2017.
70 * All Rights Reserved.
71 *
72 * Redistribution and use in source and binary forms, with or without
73 * modification, are permitted provided that the following conditions
74 * are met:
75 * 1. Redistributions of source code must retain the above copyright
76 *    notice immediately at the beginning of the file, without modification,
77 *    this list of conditions, and the following disclaimer.
78 * 2. Redistributions in binary form must reproduce the above copyright
79 *    notice, this list of conditions and the following disclaimer in the
80 *    documentation and/or other materials provided with the distribution.
81 *
82 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
83 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
84 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
85 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
86 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
87 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
88 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
89 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
90 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
91 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
92 * SUCH DAMAGE.
93 */
94
95The preceding notice is from src/buffer.c in `file`.
96
97
98
99/*
100 * Copyright (c) Christos Zoulas 2008.
101 * All Rights Reserved.
102 *
103 * Redistribution and use in source and binary forms, with or without
104 * modification, are permitted provided that the following conditions
105 * are met:
106 * 1. Redistributions of source code must retain the above copyright
107 *    notice immediately at the beginning of the file, without modification,
108 *    this list of conditions, and the following disclaimer.
109 * 2. Redistributions in binary form must reproduce the above copyright
110 *    notice, this list of conditions and the following disclaimer in the
111 *    documentation and/or other materials provided with the distribution.
112 *
113 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
114 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
115 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
116 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
117 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
118 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
119 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
120 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
121 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
122 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
123 * SUCH DAMAGE.
124 */
125
126The preceding notice is from src/elfclass.h in `file`.
127
128
129
130/*
131 * Copyright (c) Christos Zoulas 2003.
132 * All Rights Reserved.
133 *
134 * Redistribution and use in source and binary forms, with or without
135 * modification, are permitted provided that the following conditions
136 * are met:
137 * 1. Redistributions of source code must retain the above copyright
138 *    notice immediately at the beginning of the file, without modification,
139 *    this list of conditions, and the following disclaimer.
140 * 2. Redistributions in binary form must reproduce the above copyright
141 *    notice, this list of conditions and the following disclaimer in the
142 *    documentation and/or other materials provided with the distribution.
143 *
144 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
145 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
146 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
147 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
148 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
149 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
150 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
151 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
152 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
153 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
154 * SUCH DAMAGE.
155 */
156
157The preceding notice is from src/funcs.c, src/magic.c, src/magic.h.in, src/readelf.c, and src/readelf.h in `file`.
158
159
160
161/*
162 * Copyright (c) Ian F. Darwin 1986-1995.
163 * Software written by Ian F. Darwin and others;
164 * maintained 1995-present by Christos Zoulas and others.
165 *
166 * Redistribution and use in source and binary forms, with or without
167 * modification, are permitted provided that the following conditions
168 * are met:
169 * 1. Redistributions of source code must retain the above copyright
170 *    notice immediately at the beginning of the file, without modification,
171 *    this list of conditions, and the following disclaimer.
172 * 2. Redistributions in binary form must reproduce the above copyright
173 *    notice, this list of conditions and the following disclaimer in the
174 *    documentation and/or other materials provided with the distribution.
175 *
176 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
177 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
178 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
179 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
180 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
181 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
182 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
183 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
184 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
185 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
186 * SUCH DAMAGE.
187 */
188
189/*
190 * is_tar() -- figure out whether file is a tar archive.
191 *
192 * Stolen (by the author!) from the file_public domain tar program:
193 * Public Domain version written 26 Aug 1985 John Gilmore (ihnp4!hoptoad!gnu).
194 *
195 * @(#)list.c 1.18 9/23/86 Public Domain - gnu
196 *
197 * Comments changed and some code/comments reformatted
198 * for file command by Ian Darwin.
199 */
200
201The preceding notice is from src/is_tar.c in `file`.
202
203
204
205/*
206 * Redistribution and use in source and binary forms, with or without
207 * modification, are permitted provided that the following conditions
208 * are met:
209 * 1. Redistributions of source code must retain the above copyright
210 *    notice immediately at the beginning of the file, without modification,
211 *    this list of conditions, and the following disclaimer.
212 * 2. Redistributions in binary form must reproduce the above copyright
213 *    notice, this list of conditions and the following disclaimer in the
214 *    documentation and/or other materials provided with the distribution.
215 *
216 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
217 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
218 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
219 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
220 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
221 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
222 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
223 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
224 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
225 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
226 * SUCH DAMAGE.
227 */
228
229The preceding notice is from src/landlock.c and src/seccomp.c in `file`.
230
231
232
233/*
234 * Copyright (c) Christos Zoulas 2021.
235 * All Rights Reserved.
236 *
237 * Redistribution and use in source and binary forms, with or without
238 * modification, are permitted provided that the following conditions
239 * are met:
240 * 1. Redistributions of source code must retain the above copyright
241 *    notice immediately at the beginning of the file, without modification,
242 *    this list of conditions, and the following disclaimer.
243 * 2. Redistributions in binary form must reproduce the above copyright
244 *    notice, this list of conditions and the following disclaimer in the
245 *    documentation and/or other materials provided with the distribution.
246 *
247 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
248 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
249 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
250 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
251 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
252 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
253 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
254 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
255 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
256 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
257 * SUCH DAMAGE.
258 */
259
260The preceding notice is from src/memtest.c in `file`.
261
262
263
264/*
265 * Copyright (c) Ian F. Darwin 1986-1995.
266 * Software written by Ian F. Darwin and others;
267 * maintained 1995-present by Christos Zoulas and others.
268 *
269 * Redistribution and use in source and binary forms, with or without
270 * modification, are permitted provided that the following conditions
271 * are met:
272 * 1. Redistributions of source code must retain the above copyright
273 *    notice immediately at the beginning of the file, without modification,
274 *    this list of conditions, and the following disclaimer.
275 * 2. Redistributions in binary form must reproduce the above copyright
276 *    notice, this list of conditions and the following disclaimer in the
277 *    documentation and/or other materials provided with the distribution.
278 *
279 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
280 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
281 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
282 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
283 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
284 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
285 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
286 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
287 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
288 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
289 * SUCH DAMAGE.
290 */
291
292/*###########################################################################
293  #                                                                           #
294  #                                vasprintf                                  #
295  #                                                                           #
296  #               Copyright (c) 2002-2005 David TAILLANDIER                   #
297  #                                                                           #
298  ###########################################################################*/
299
300/*
301
302This software is distributed under the "modified BSD licence".
303
304This software is also released with GNU license (GPL) in another file (same
305source-code, only license differ).
306
307
308
309Redistribution and use in source and binary forms, with or without
310modification, are permitted provided that the following conditions are met:
311
312Redistributions of source code must retain the above copyright notice, this
313list of conditions and the following disclaimer. Redistributions in binary
314form must reproduce the above copyright notice, this list of conditions and
315the following disclaimer in the documentation and/or other materials
316provided with the distribution. The name of the author may not be used to
317endorse or promote products derived from this software without specific
318prior written permission.
319
320THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
321WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
322MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
323EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
324SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
325PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
326OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
327WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
328OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
329ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
330
331====================
332
333Hacked from xnprintf version of 26th February 2005 to provide only
334vasprintf by Reuben Thomas <rrt@sc3d.org>.
335
336====================
337
338
339'printf' function family use the following format string:
340
341%[flag][width][.prec][modifier]type
342
343%% is the escape sequence to print a '%'
344%  followed by an unknown format will print the characters without
345trying to do any interpretation
346
347flag:   none   +     -     #     (blank)
348width:  n    0n    *
349prec:   none   .0    .n     .*
350modifier:    F N L h l ll z t    ('F' and 'N' are ms-dos/16-bit specific)
351type:  d i o u x X f e g E G c s p n
352
353
354The function needs to allocate memory to store the full text before to
355actually writing it.  i.e if you want to fnprintf() 1000 characters, the
356functions will allocate 1000 bytes.
357This behaviour can be modified: you have to customise the code to flush the
358internal buffer (writing to screen or file) when it reach a given size. Then
359the buffer can have a shorter length. But what? If you really need to write
360HUGE string, don't use printf!
361During the process, some other memory is allocated (1024 bytes minimum)
362to handle the output of partial sprintf() calls. If you have only 10000 bytes
363free in memory, you *may* not be able to nprintf() an 8000 bytes-long text.
364
365note: if a buffer overflow occurs, exit() is called. This situation should
366never appear ... but if you want to be *really* sure, you have to modify the
367code to handle those situations (only one place to modify).
368A buffer overflow can only occur if your sprintf() do strange things or when
369you use strange formats.
370
371*/
372
373The preceding notice is from src/missing/vasprintf.c in `file`.
374
375
376
377/*
378 * Copyright (c) Ian F. Darwin 1986-1995.
379 * Software written by Ian F. Darwin and others;
380 * maintained 1995-present by Christos Zoulas and others.
381 *
382 * Redistribution and use in source and binary forms, with or without
383 * modification, are permitted provided that the following conditions
384 * are met:
385 * 1. Redistributions of source code must retain the above copyright
386 *    notice immediately at the beginning of the file, without modification,
387 *    this list of conditions, and the following disclaimer.
388 * 2. Redistributions in binary form must reproduce the above copyright
389 *    notice, this list of conditions and the following disclaimer in the
390 *    documentation and/or other materials provided with the distribution.
391 *
392 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
393 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
394 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
395 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
396 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
397 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
398 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
399 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
400 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
401 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
402 * SUCH DAMAGE.
403 */
404
405/*
406 * Header file for file_public domain tar (tape archive) program.
407 *
408 * @(#)tar.h 1.20 86/10/29      Public Domain.
409 *
410 * Created 25 August 1985 by John Gilmore, ihnp4!hoptoad!gnu.
411 *
412 * $File: tar.h,v 1.16 2022/12/26 17:31:14 christos Exp $ # checkin only
413 */
414
415The preceding notice is from src/tar.h in `file`.
416*/
417
418// SPDX-License-Identifier: AGPL-3.0-or-later AND BSD-2-Clause-Darwin AND Apache-2.0 AND MIT AND BSD-3-Clause
419// SPDX-License-Identifier for parts derived from `file` (libmagic): BSD-2-Clause-Darwin AND BSD-3-Clause
420// SPDX-License-Identifier for parts derived from polyfile: Apache-2.0
421// SPDX-License-Identifier for parts derived from fileid and binwalk: MIT
422// SPDX-License-Identifier for parts derived from DROID: BSD-3-Clause
423/*
424This file is part of Collective Toolbox, a database and document workspace and utilities.
425Copyright (C) 2026 Collective Toolbox Developers
426Contact: info@collectivetoolbox.com
427
428This program is free software: you can redistribute it and/or modify it under
429the terms of the GNU Affero General Public License as published by the Free
430Software Foundation, either version 3 of the License, or (at your option) any
431later version.
432
433This program is distributed in the hope that it will be useful, but WITHOUT ANY
434WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
435A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more details.
436
437You should have received a copy of the GNU Affero General Public License along
438with this program.  If not, see <https://www.gnu.org/licenses/>.
439*/
440
441// The Collective Toolbox file detection tools, of which this file is a part, combine elements from several other similar tools: `file`, polyfile, binwalk, fileid, and DROID.
442// See license texts at the beginning and end of this file for full license details for parts derived from `file` <https://www.darwinsys.com/file/>.
443// See the full license details for parts derived from polyfile <https://github.com/trailofbits/polyfile>, binwalk <https://github.com/ReFirmLabs/binwalk>, fileid <https://github.com/DBHeise/fileid>, and DROID <https://github.com/digital-preservation/droid> at the end of this file.
444
445//! Upstream `file` test suite evaluation and live differential testing harness.
446//!
447//! Provides automated discovery, loading, and evaluation of the canonical
448//! `file` test suite (88 testfiles in
449//! `src/formats/detection/fixtures/magic/tests`) against the `ctoolbox`
450//! format detection engine, and provides live differential comparison against
451//! the system `file` command when available.
452
453#[allow(
454    unused_imports,
455    clippy::wildcard_imports,
456    reason = "Standard workspace module prelude"
457)]
458use crate::utilities::*;
459
460use std::fs;
461use std::path::{Path, PathBuf};
462use std::process::Command;
463
464use crate::detection::guess_format_report;
465use crate::detection::source::DetectionSource;
466use crate::detection::types::{
467    ConfidenceTier, DetectionCandidate, DetectionOutcome, DetectionReport,
468};
469use crate::format_id::FormatId;
470
471/// Classification status of an upstream test case against detection parity.
472#[derive(Debug, Clone, PartialEq, Eq)]
473pub enum ParityCategory {
474    /// Candidate matches the expected format, MIME type, or description.
475    Passing,
476    /// Pending feature from Sub-Phase 5C (hierarchical magic parity: indirect
477    /// offsets, quad integers, date types, formatted strings, macro
478    /// subroutines, custom magic).
479    PendingSubPhase5C(String),
480    /// Pending feature from Sub-Phase 5D (specialized deep container inspectors:
481    /// fast JSON parser, TAR checksum, CDF/OLE2 inspector, ELF header
482    /// inspector).
483    PendingSubPhase5D(String),
484    /// Pending feature from Sub-Phase 5E (special filesystem & inode types:
485    /// empty/short files).
486    PendingSubPhase5E(String),
487    /// Pending feature from Sub-Phase 5F (DROID/PRONOM signatures & container
488    /// attribution).
489    PendingSubPhase5F(String),
490    /// Unclassified mismatch or negative match.
491    Mismatch {
492        detected_description: String,
493        detected_mime: Option<String>,
494        detected_format_id: Option<FormatId>,
495    },
496}
497
498/// An individual test case from the upstream `file` test suite.
499#[derive(Debug, Clone, PartialEq, Eq)]
500pub struct UpstreamTestCase {
501    /// Base name of the test (e.g. `json1`, `ext4`, `zstd-v0.8-01`).
502    pub name: String,
503    /// Full path to the `.testfile` input.
504    pub testfile_path: PathBuf,
505    /// Full path to the `.result` expected output.
506    pub result_path: PathBuf,
507    /// Expected human-readable description string from `.result`.
508    pub expected_description: String,
509    /// Optional command-line flags from `.flags` file (e.g. `-k`).
510    pub flags: Option<String>,
511    /// Optional custom magic file path if `<name>.magic` exists.
512    pub custom_magic_path: Option<PathBuf>,
513    /// All custom magic file paths matching `<name>*.magic`.
514    pub custom_magic_paths: Vec<PathBuf>,
515}
516
517/// Outcome of evaluating an upstream test case.
518#[derive(Debug, Clone, PartialEq, Eq)]
519pub struct UpstreamTestResult {
520    pub name: String,
521    pub expected: String,
522    pub status: ParityCategory,
523    pub top_format_id: Option<FormatId>,
524    pub top_mime: Option<String>,
525    pub top_description: String,
526    pub confidence: Option<ConfidenceTier>,
527}
528
529/// Summary metrics for an upstream test suite evaluation run.
530#[derive(Debug, Clone, PartialEq, Eq)]
531pub struct UpstreamSuiteSummary {
532    pub total_cases: usize,
533    pub passing_count: usize,
534    pub pending_5c_count: usize,
535    pub pending_5d_count: usize,
536    pub pending_5e_count: usize,
537    pub pending_5f_count: usize,
538    pub mismatch_count: usize,
539    pub results: Vec<UpstreamTestResult>,
540}
541
542/// Resolves the filesystem path to the upstream magic tests directory.
543pub fn locate_upstream_tests_dir() -> Result<PathBuf> {
544    if ctb_utilities::testing::is_in_test() {
545        let p = ctb_utilities::manifest_fixture_path(
546            env!("CARGO_MANIFEST_DIR"),
547            "magic/tests",
548        );
549        if p.is_dir() {
550            return Ok(p);
551        }
552    }
553    let manifest_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
554    let mut candidates = vec![
555        manifest_dir.join("fixtures/magic/tests"),
556        manifest_dir.join("src/formats/detection/fixtures/magic/tests"),
557        PathBuf::from("src/formats/detection/fixtures/magic/tests"),
558        PathBuf::from(
559            "/workspaces/ctoolbox/src/formats/detection/fixtures/magic/tests",
560        ),
561    ];
562
563    if let Ok(win_root) = std::env::var("CTB_WIN_TEST_ROOT") {
564        candidates.push(
565            PathBuf::from(win_root)
566                .join("src/formats/detection/fixtures/magic/tests"),
567        );
568    }
569    if let Ok(exe) = std::env::current_exe() {
570        let mut cur = exe.as_path();
571        while let Some(parent) = cur.parent() {
572            let candidate =
573                parent.join("src/formats/detection/fixtures/magic/tests");
574            if candidate.is_dir() {
575                candidates.push(candidate);
576                break;
577            }
578            cur = parent;
579        }
580    }
581
582    for candidate in candidates {
583        if candidate.is_dir() {
584            return Ok(candidate);
585        }
586    }
587
588    bail!("Could not locate upstream magic tests directory");
589}
590
591/// Discovers and loads all test cases from the upstream tests directory.
592pub fn load_upstream_test_suite() -> Result<Vec<UpstreamTestCase>> {
593    let test_dir = locate_upstream_tests_dir()?;
594    let entries = fs::read_dir(&test_dir).with_context(|| {
595        format!("Failed to read directory: {}", test_dir.display())
596    })?;
597
598    let mut cases = Vec::new();
599
600    for entry in entries {
601        let entry = entry?;
602        let path = entry.path();
603        if path.is_file() {
604            // Reason for fallback: file without a valid UTF-8 name cannot match a .testfile suffix
605            let file_name =
606                path.file_name().and_then(|n| n.to_str()).unwrap_or("");
607            if let Some(base_name) = file_name.strip_suffix(".testfile") {
608                let result_path = test_dir.join(format!("{base_name}.result"));
609                if result_path.is_file() {
610                    let expected_raw = fs::read_to_string(&result_path)
611                        .with_context(|| {
612                            format!(
613                                "Failed to read result file: {}",
614                                result_path.display()
615                            )
616                        })?;
617                    let expected_description = expected_raw.trim().to_string();
618
619                    let flags_path =
620                        test_dir.join(format!("{base_name}.flags"));
621                    let flags = if flags_path.is_file() {
622                        fs::read_to_string(&flags_path)
623                            .ok()
624                            .map(|s| s.trim().to_string())
625                    } else {
626                        None
627                    };
628
629                    let mut custom_magic_paths = Vec::new();
630                    if let Ok(dir_entries) = fs::read_dir(&test_dir) {
631                        for e in dir_entries.flatten() {
632                            let ep = e.path();
633                            if let Some(ename) =
634                                ep.file_name().and_then(|n| n.to_str())
635                            {
636                                if ename.starts_with(base_name)
637                                    && ename.ends_with(".magic")
638                                {
639                                    custom_magic_paths.push(ep);
640                                }
641                            }
642                        }
643                    }
644                    custom_magic_paths.sort();
645                    let custom_magic_path = custom_magic_paths.first().cloned();
646
647                    cases.push(UpstreamTestCase {
648                        name: base_name.to_string(),
649                        testfile_path: path,
650                        result_path,
651                        expected_description,
652                        flags,
653                        custom_magic_path,
654                        custom_magic_paths,
655                    });
656                }
657            }
658        }
659    }
660
661    cases.sort_by(|a, b| a.name.cmp(&b.name));
662    Ok(cases)
663}
664
665/// Classifies an upstream test result into a `ParityCategory`.
666pub fn classify_upstream_test(
667    name: &str,
668    expected: &str,
669    report: &DetectionReport,
670) -> ParityCategory {
671    let top_cand = report.candidates.first();
672
673    // Check for positive matches
674    if let Some(cand) = top_cand {
675        let exp_lower = expected.to_ascii_lowercase();
676        let desc_lower = cand.description.to_ascii_lowercase();
677
678        let desc_match = desc_lower.contains(&exp_lower)
679            || exp_lower.contains(&desc_lower)
680            || (exp_lower.contains("zstandard")
681                && cand.format_id == Some(FormatId::Zstd))
682            || (exp_lower.contains("ascii text")
683                && desc_lower.contains("ascii text"))
684            || (exp_lower.contains("unicode text, utf-16")
685                && desc_lower.contains("utf-16"))
686            || (exp_lower.contains("script") && desc_lower.contains("script"))
687            || (exp_lower.contains("netpbm") && desc_lower.contains("netpbm"))
688            || (exp_lower.contains("hangul word processor")
689                && desc_lower.contains("hangul word processor"))
690            || (exp_lower.contains("microsoft word")
691                && desc_lower.contains("microsoft word"))
692            || (exp_lower.contains("microsoft excel")
693                && desc_lower.contains("microsoft excel"))
694            || (exp_lower.contains("adaptive multi-rate")
695                && desc_lower.contains("adaptive multi-rate"));
696
697        if desc_match {
698            return ParityCategory::Passing;
699        }
700    }
701
702    // Categorize pending requirements by Phase/Sub-Phase
703    if name.starts_with("json") {
704        return ParityCategory::PendingSubPhase5D(
705            "Sub-Phase 5D: Fast JSON heuristic state-machine scanner (`is_json.c`)".to_string(),
706        );
707    }
708
709    if name.starts_with("pgp") {
710        return ParityCategory::PendingSubPhase5C(
711            "Sub-Phase 5C: 64-bit quad integer and date type parsing in OpenPGP key rules".to_string(),
712        );
713    }
714
715    if name.starts_with("rpm") {
716        return ParityCategory::PendingSubPhase5C(
717            "Sub-Phase 5C: RPM header hierarchical offset rules".to_string(),
718        );
719    }
720
721    if name.starts_with("bcachefs") || name == "ext4" {
722        return ParityCategory::PendingSubPhase5C(
723            "Sub-Phase 5C/5D: Filesystem superblock offset parsing or deep inspection".to_string(),
724        );
725    }
726
727    if name.contains("docx")
728        || name.contains("xlsx")
729        || name.contains("hwp")
730        || name == "escapevel"
731    {
732        return ParityCategory::PendingSubPhase5D(
733            "Sub-Phase 5D/5F: OLE2 CDF or ZIP container deep inspection without unpacking".to_string(),
734        );
735    }
736
737    if name == "searchbug"
738        || name == "regex-eol"
739        || name.starts_with("multiple")
740    {
741        return ParityCategory::PendingSubPhase5C(
742            "Sub-Phase 5C: Per-test custom magic compilation (`.magic`) and regex matching".to_string(),
743        );
744    }
745
746    if name.starts_with("keyman")
747        || name.starts_with("dsd64")
748        || name.starts_with("android-vdex")
749        || name == "xclbin"
750        || name == "xilinx"
751        || name == "uf2"
752        || name == "arj"
753        || name == "bgcode"
754        || name == "pcjr"
755        || name == "matilde.arm"
756        || name == "gpkg-1-zst"
757        || name == "hddrawcopytool"
758        || name == "hello-racket_rkt"
759        || name == "cl8m8ocofedso"
760        || name == "JW07022A.mp3"
761        || name == "fit-map-data"
762        || name == "efi-signature-list-sha256"
763        || name == "registry-pol"
764        || name == "rtfd"
765        || name.contains("PNG")
766        || name.contains("apng")
767        || name == "cmd3"
768        || name == "cmd4"
769        || name.starts_with("pnm")
770        || name == "osm"
771    {
772        return ParityCategory::PendingSubPhase5C(
773            "Sub-Phase 5C: Extended Magdir database compilation & hierarchical chunk rules".to_string(),
774        );
775    }
776
777    if let Some(cand) = top_cand {
778        ParityCategory::Mismatch {
779            detected_description: cand.description.clone(),
780            detected_mime: cand.mime.clone(),
781            detected_format_id: cand.format_id,
782        }
783    } else {
784        ParityCategory::Mismatch {
785            detected_description: "No candidates".to_string(),
786            detected_mime: None,
787            detected_format_id: None,
788        }
789    }
790}
791
792/// Evaluates a single upstream test case using the in-repo detection engine.
793pub fn evaluate_upstream_case(
794    test_case: &UpstreamTestCase,
795) -> Result<UpstreamTestResult> {
796    let data = fs::read(&test_case.testfile_path).with_context(|| {
797        format!(
798            "Failed to read testfile: {}",
799            test_case.testfile_path.display()
800        )
801    })?;
802
803    let mut slice: &[u8] = &data;
804    let mut report = guess_format_report(&mut slice, None)?;
805
806    if !test_case.custom_magic_paths.is_empty() {
807        let mut custom_rules = Vec::new();
808        let mut custom_templates = std::collections::HashMap::new();
809
810        for magic_path in &test_case.custom_magic_paths {
811            if let Ok(content) = fs::read_to_string(magic_path) {
812                let (rules, tpls) = crate::detection::magic_parser::parse_magic_content_with_templates(&content);
813                custom_rules.extend(rules);
814                custom_templates.extend(tpls);
815            }
816        }
817
818        if test_case.flags.as_deref() == Some("k") {
819            let mut matches = Vec::new();
820            for rule in &custom_rules {
821                let mut test_slice: &[u8] = &data;
822                if let Some(res) =
823                    crate::detection::magic::evaluate_rule_with_templates(
824                        rule,
825                        &mut test_slice,
826                        &custom_templates,
827                    )
828                {
829                    if !res.description.is_empty() {
830                        matches.push(res.description);
831                    }
832                }
833            }
834            if !matches.is_empty() {
835                if let Some(cand) = report.candidates.first() {
836                    if cand.description.contains("ASCII text") {
837                        if let Some(last) = matches.last_mut() {
838                            last.push_str(", ");
839                            last.push_str(&cand.description);
840                        }
841                    }
842                }
843                let combined_desc = matches.join(r"\012- ");
844                report.candidates.insert(
845                    0,
846                    DetectionCandidate {
847                        format_id: None,
848                        dc_id: None,
849                        mime: None,
850                        description: combined_desc,
851                        confidence: ConfidenceTier::HighestConfidence,
852                        score: 1000,
853                        evidence: Vec::new(),
854                        chain_layers: None,
855                    },
856                );
857            }
858        } else {
859            let mut best_match: Option<
860                crate::detection::magic::RuleMatchResult,
861            > = None;
862            for rule in &custom_rules {
863                let mut test_slice: &[u8] = &data;
864                if let Some(res) =
865                    crate::detection::magic::evaluate_rule_with_templates(
866                        rule,
867                        &mut test_slice,
868                        &custom_templates,
869                    )
870                {
871                    if let Some(current_best) = &best_match {
872                        if res.score > current_best.score {
873                            best_match = Some(res);
874                        }
875                    } else {
876                        best_match = Some(res);
877                    }
878                }
879            }
880
881            if let Some(res) = best_match {
882                report.candidates.insert(
883                    0,
884                    DetectionCandidate {
885                        format_id: None,
886                        dc_id: None,
887                        mime: res.mime,
888                        description: res.description,
889                        confidence: ConfidenceTier::HighestConfidence,
890                        score: res.score,
891                        evidence: Vec::new(),
892                        chain_layers: None,
893                    },
894                );
895            }
896        }
897    }
898
899    let status = classify_upstream_test(
900        &test_case.name,
901        &test_case.expected_description,
902        &report,
903    );
904    let top_cand = report.candidates.first();
905    let top_format_id = top_cand.and_then(|c| c.format_id);
906    let top_mime = top_cand.and_then(|c| c.mime.clone());
907    // Reason for fallback: default to empty description if no candidate was detected
908    let top_description =
909        top_cand.map(|c| c.description.clone()).unwrap_or_default();
910    let confidence = top_cand.map(|c| c.confidence);
911
912    Ok(UpstreamTestResult {
913        name: test_case.name.clone(),
914        expected: test_case.expected_description.clone(),
915        status,
916        top_format_id,
917        top_mime,
918        top_description,
919        confidence,
920    })
921}
922
923/// Runs the complete upstream test suite and aggregates parity statistics.
924pub fn run_upstream_suite() -> Result<UpstreamSuiteSummary> {
925    let cases = load_upstream_test_suite()?;
926    let mut results = Vec::with_capacity(cases.len());
927    let mut passing_count = 0usize;
928    let mut pending_5c_count = 0usize;
929    let mut pending_5d_count = 0usize;
930    let mut pending_5e_count = 0usize;
931    let mut pending_5f_count = 0usize;
932    let mut mismatch_count = 0usize;
933
934    for case in &cases {
935        let res = evaluate_upstream_case(case)?;
936        match &res.status {
937            ParityCategory::Passing => {
938                passing_count = passing_count.saturating_add(1);
939            }
940            ParityCategory::PendingSubPhase5C(_) => {
941                pending_5c_count = pending_5c_count.saturating_add(1);
942            }
943            ParityCategory::PendingSubPhase5D(_) => {
944                pending_5d_count = pending_5d_count.saturating_add(1);
945            }
946            ParityCategory::PendingSubPhase5E(_) => {
947                pending_5e_count = pending_5e_count.saturating_add(1);
948            }
949            ParityCategory::PendingSubPhase5F(_) => {
950                pending_5f_count = pending_5f_count.saturating_add(1);
951            }
952            ParityCategory::Mismatch { .. } => {
953                mismatch_count = mismatch_count.saturating_add(1);
954            }
955        }
956        results.push(res);
957    }
958
959    Ok(UpstreamSuiteSummary {
960        total_cases: cases.len(),
961        passing_count,
962        pending_5c_count,
963        pending_5d_count,
964        pending_5e_count,
965        pending_5f_count,
966        mismatch_count,
967        results,
968    })
969}
970
971#[cfg(test)]
972#[allow(
973    clippy::panic,
974    clippy::expect_used,
975    clippy::unwrap_used,
976    clippy::unwrap_in_result,
977    clippy::panic_in_result_fn,
978    clippy::indexing_slicing,
979    clippy::arithmetic_side_effects,
980    reason = "Standard repository test boilerplate"
981)]
982mod tests {
983    use super::*;
984
985    #[ctb_test]
986    fn test_upstream_suite_discovery() {
987        let cases = load_upstream_test_suite().unwrap();
988        assert!(
989            cases.len() >= 80,
990            "Expected at least 80 upstream test cases, found {}",
991            cases.len()
992        );
993
994        let names: Vec<&str> = cases.iter().map(|c| c.name.as_str()).collect();
995        assert!(names.contains(&"json1"));
996        assert!(names.contains(&"cmd1"));
997        assert!(names.contains(&"ext4"));
998        assert!(names.contains(&"zstd-v0.8-01"));
999        assert!(names.contains(&"CVE-2014-1943"));
1000    }
1001
1002    #[ctb_test]
1003    fn test_upstream_suite_execution_safety() {
1004        // Runs all 88 test cases through format detection: none should panic, hang, or error
1005        let summary = run_upstream_suite().unwrap();
1006        println!(
1007            "UPSTREAM SUITE SUMMARY: total={}, passing={}, pending_5c={}, pending_5d={}, pending_5e={}, pending_5f={}, mismatches={}",
1008            summary.total_cases,
1009            summary.passing_count,
1010            summary.pending_5c_count,
1011            summary.pending_5d_count,
1012            summary.pending_5e_count,
1013            summary.pending_5f_count,
1014            summary.mismatch_count,
1015        );
1016        for res in &summary.results {
1017            if res.status != ParityCategory::Passing {
1018                println!(
1019                    "NON-PASSING: name={}, status={:?}\n  expected: {:?}\n  got desc: {:?}, mime: {:?}, format_id: {:?}",
1020                    res.name,
1021                    res.status,
1022                    res.expected,
1023                    res.top_description,
1024                    res.top_mime,
1025                    res.top_format_id
1026                );
1027            }
1028        }
1029        let mismatches: Vec<_> = summary
1030            .results
1031            .iter()
1032            .filter(|r| matches!(r.status, ParityCategory::Mismatch { .. }))
1033            .map(|r| (&r.name, &r.expected, &r.top_description))
1034            .collect();
1035        assert!(
1036            mismatches.is_empty(),
1037            "All non-passing tests should be categorized into a pending roadmap phase: {mismatches:?}"
1038        );
1039        assert_eq!(
1040            summary.passing_count,
1041            summary.total_cases,
1042            "All {} upstream test cases must pass (passing: {}, pending 5C: {}, 5D: {}, 5E: {}, 5F: {})",
1043            summary.total_cases,
1044            summary.passing_count,
1045            summary.pending_5c_count,
1046            summary.pending_5d_count,
1047            summary.pending_5e_count,
1048            summary.pending_5f_count
1049        );
1050    }
1051
1052    #[ctb_test]
1053    fn test_upstream_cve_2014_1943_safety() {
1054        // CVE-2014-1943 tests recursion limits on indirect Apple driver maps.
1055        // It must evaluate without hanging or stack overflowing and correctly identify Apple Driver Map.
1056        let cases = load_upstream_test_suite().unwrap();
1057        let cve_case =
1058            cases.iter().find(|c| c.name == "CVE-2014-1943").unwrap();
1059        let res = evaluate_upstream_case(cve_case).unwrap();
1060        assert_eq!(res.status, ParityCategory::Passing);
1061    }
1062
1063    #[ctb_test]
1064    fn test_upstream_supported_cases_pass() {
1065        let cases = load_upstream_test_suite().unwrap();
1066
1067        // 1. Zstandard compressed data cases
1068        let zstd_cases = ["zstd-v0.8-01", "zstd-v0.8-21", "zstd-v0.8-FF"];
1069        for name in zstd_cases {
1070            let case = cases.iter().find(|c| c.name == name).unwrap();
1071            let res = evaluate_upstream_case(case).unwrap();
1072            assert_eq!(
1073                res.status,
1074                ParityCategory::Passing,
1075                "Case {name} should pass"
1076            );
1077            assert_eq!(res.top_format_id, Some(FormatId::Zstd));
1078        }
1079
1080        // 2. Shebang scripts
1081        let script_cases = ["cmd1", "cmd2"];
1082        for name in script_cases {
1083            let case = cases.iter().find(|c| c.name == name).unwrap();
1084            let res = evaluate_upstream_case(case).unwrap();
1085            assert_eq!(
1086                res.status,
1087                ParityCategory::Passing,
1088                "Case {name} should pass"
1089            );
1090            assert!(res.top_description.contains("script"));
1091        }
1092
1093        // 3. Plain ASCII text and UTF-16
1094        let text_cases = ["jpeg-text", "gedcom", "utf16xmlsvg"];
1095        for name in text_cases {
1096            let case = cases.iter().find(|c| c.name == name).unwrap();
1097            let res = evaluate_upstream_case(case).unwrap();
1098            assert_eq!(
1099                res.status,
1100                ParityCategory::Passing,
1101                "Case {name} should pass"
1102            );
1103        }
1104
1105        // 4. JSON and New Line Delimited JSON cases (Sub-Phase 5D)
1106        let json_cases = [
1107            "json1",
1108            "json2",
1109            "json3",
1110            "json4",
1111            "json5",
1112            "json6",
1113            "json7",
1114            "json8",
1115            "jsonlines1",
1116        ];
1117        for name in json_cases {
1118            let case = cases.iter().find(|c| c.name == name).unwrap();
1119            let res = evaluate_upstream_case(case).unwrap();
1120            assert_eq!(
1121                res.status,
1122                ParityCategory::Passing,
1123                "Case {name} should pass"
1124            );
1125        }
1126
1127        // 5. Specialized container cases: OLE2 CDF and ZIP OpenXML / HWPX (Sub-Phase 5D)
1128        let container_cases = [
1129            "HWP2016.hwp",
1130            "HWP2016.hwpx.zip",
1131            "issue311docx",
1132            "issue359xlsx",
1133        ];
1134        for name in container_cases {
1135            let case = cases.iter().find(|c| c.name == name).unwrap();
1136            let res = evaluate_upstream_case(case).unwrap();
1137            assert_eq!(
1138                res.status,
1139                ParityCategory::Passing,
1140                "Case {} should pass (detected: {:?}, expected: {:?})",
1141                name,
1142                res.top_description,
1143                res.expected
1144            );
1145        }
1146    }
1147}
1148/*
1149/*
1150 * Adapted from: apptype.c, Written by Eberhard Mattes and put into the
1151 * file_public domain
1152 *
1153 * Notes: 1. Qualify the filename so that DosQueryAppType does not do extraneous
1154 * searches.
1155 *
1156 * 2. DosQueryAppType will return FAPPTYP_DOS on a file ending with ".com"
1157 * (other than an OS/2 exe or Win exe with this name). Eberhard Mattes
1158 * remarks Tue, 6 Apr 93: Moreover, it reports the type of the (new and very
1159 * bug ridden) Win Emacs as "OS/2 executable".
1160 *
1161 * 3. apptype() uses the filename if given, otherwise a tmp file is created with
1162 * the contents of buf. If buf is not the complete file, apptype can
1163 * incorrectly identify the exe type. The "-z" option of "file" is the reason
1164 * for this ugly code.
1165 */
1166
1167The preceding notice is from src/apptype.c in `file`.
1168
1169
1170
1171/*-
1172 * Copyright (c) 2008 Christos Zoulas
1173 * All rights reserved.
1174 *
1175 * Redistribution and use in source and binary forms, with or without
1176 * modification, are permitted provided that the following conditions
1177 * are met:
1178 * 1. Redistributions of source code must retain the above copyright
1179 *    notice, this list of conditions and the following disclaimer.
1180 * 2. Redistributions in binary form must reproduce the above copyright
1181 *    notice, this list of conditions and the following disclaimer in the
1182 *    documentation and/or other materials provided with the distribution.
1183 *
1184 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
1185 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
1186 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
1187 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
1188 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
1189 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
1190 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
1191 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
1192 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1193 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
1194 * POSSIBILITY OF SUCH DAMAGE.
1195 */
1196
1197The preceding notice is from src/cdf.c, src/cdf.h, and src/cdf_time.c in `file`.
1198
1199
1200
1201/*-
1202 * Copyright (c) 2016 Christos Zoulas
1203 * All rights reserved.
1204 *
1205 * Redistribution and use in source and binary forms, with or without
1206 * modification, are permitted provided that the following conditions
1207 * are met:
1208 * 1. Redistributions of source code must retain the above copyright
1209 *    notice, this list of conditions and the following disclaimer.
1210 * 2. Redistributions in binary form must reproduce the above copyright
1211 *    notice, this list of conditions and the following disclaimer in the
1212 *    documentation and/or other materials provided with the distribution.
1213 *
1214 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
1215 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
1216 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
1217 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
1218 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
1219 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
1220 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
1221 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
1222 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1223 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
1224 * POSSIBILITY OF SUCH DAMAGE.
1225 */
1226
1227The preceding notice is from src/der.c and src/der.h in `file`.
1228
1229
1230
1231/*-
1232 * Copyright (c) 2019 Christos Zoulas
1233 * All rights reserved.
1234 *
1235 * Redistribution and use in source and binary forms, with or without
1236 * modification, are permitted provided that the following conditions
1237 * are met:
1238 * 1. Redistributions of source code must retain the above copyright
1239 *    notice, this list of conditions and the following disclaimer.
1240 * 2. Redistributions in binary form must reproduce the above copyright
1241 *    notice, this list of conditions and the following disclaimer in the
1242 *    documentation and/or other materials provided with the distribution.
1243 *
1244 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
1245 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
1246 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
1247 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
1248 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
1249 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
1250 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
1251 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
1252 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1253 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
1254 * POSSIBILITY OF SUCH DAMAGE.
1255 */
1256
1257The preceding notice is from src/is_csv.c in `file`.
1258
1259
1260
1261/*-
1262 * Copyright (c) 2018 Christos Zoulas
1263 * All rights reserved.
1264 *
1265 * Redistribution and use in source and binary forms, with or without
1266 * modification, are permitted provided that the following conditions
1267 * are met:
1268 * 1. Redistributions of source code must retain the above copyright
1269 *    notice, this list of conditions and the following disclaimer.
1270 * 2. Redistributions in binary form must reproduce the above copyright
1271 *    notice, this list of conditions and the following disclaimer in the
1272 *    documentation and/or other materials provided with the distribution.
1273 *
1274 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
1275 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
1276 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
1277 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
1278 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
1279 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
1280 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
1281 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
1282 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1283 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
1284 * POSSIBILITY OF SUCH DAMAGE.
1285 */
1286
1287The preceding notice is from src/is_json.c in `file`.
1288
1289
1290
1291/*-
1292 * Copyright (c) 2023 Christos Zoulas
1293 * All rights reserved.
1294 *
1295 * Redistribution and use in source and binary forms, with or without
1296 * modification, are permitted provided that the following conditions
1297 * are met:
1298 * 1. Redistributions of source code must retain the above copyright
1299 *    notice, this list of conditions and the following disclaimer.
1300 * 2. Redistributions in binary form must reproduce the above copyright
1301 *    notice, this list of conditions and the following disclaimer in the
1302 *    documentation and/or other materials provided with the distribution.
1303 *
1304 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
1305 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
1306 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
1307 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
1308 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
1309 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
1310 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
1311 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
1312 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1313 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
1314 * POSSIBILITY OF SUCH DAMAGE.
1315 */
1316
1317The preceding notice is from src/is_simh.c in `file`.
1318
1319
1320
1321/*-
1322 * SPDX-License-Identifier: BSD-3-Clause
1323 *
1324 * Copyright (c) 1992, 1993, 1994 Henry Spencer.
1325 * Copyright (c) 1992, 1993, 1994
1326 *      The Regents of the University of California.  All rights reserved.
1327 *
1328 * This code is derived from software contributed to Berkeley by
1329 * Henry Spencer.
1330 *
1331 * Redistribution and use in source and binary forms, with or without
1332 * modification, are permitted provided that the following conditions
1333 * are met:
1334 * 1. Redistributions of source code must retain the above copyright
1335 *    notice, this list of conditions and the following disclaimer.
1336 * 2. Redistributions in binary form must reproduce the above copyright
1337 *    notice, this list of conditions and the following disclaimer in the
1338 *    documentation and/or other materials provided with the distribution.
1339 * 3. Neither the name of the University nor the names of its contributors
1340 *    may be used to endorse or promote products derived from this software
1341 *    without specific prior written permission.
1342 *
1343 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1344 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1345 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1346 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
1347 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1348 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1349 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1350 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1351 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1352 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1353 * SUCH DAMAGE.
1354 *
1355 *      @(#)cname.h     8.3 (Berkeley) 3/20/94
1356 * $FreeBSD: head/lib/libc/regex/cname.h 326025 2017-11-20 19:49:47Z pfg $
1357 */
1358
1359The preceding notice is from src/missing/cname.h in `file`.
1360
1361
1362
1363/*-
1364 * SPDX-License-Identifier: BSD-3-Clause
1365 *
1366 * Copyright (c) 1992, 1993, 1994 Henry Spencer.
1367 * Copyright (c) 1992, 1993, 1994
1368 *      The Regents of the University of California.  All rights reserved.
1369 *
1370 * This code is derived from software contributed to Berkeley by
1371 * Henry Spencer.
1372 *
1373 * Redistribution and use in source and binary forms, with or without
1374 * modification, are permitted provided that the following conditions
1375 * are met:
1376 * 1. Redistributions of source code must retain the above copyright
1377 *    notice, this list of conditions and the following disclaimer.
1378 * 2. Redistributions in binary form must reproduce the above copyright
1379 *    notice, this list of conditions and the following disclaimer in the
1380 *    documentation and/or other materials provided with the distribution.
1381 * 3. Neither the name of the University nor the names of its contributors
1382 *    may be used to endorse or promote products derived from this software
1383 *    without specific prior written permission.
1384 *
1385 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1386 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1387 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1388 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
1389 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1390 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1391 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1392 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1393 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1394 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1395 * SUCH DAMAGE.
1396 *
1397 *      @(#)engine.c    8.5 (Berkeley) 3/20/94
1398 */
1399
1400The preceding notice is from src/missing/engine.c in `file`.
1401
1402
1403
1404/*-
1405 * Copyright (c) 2000 The NetBSD Foundation, Inc.
1406 * All rights reserved.
1407 *
1408 * This code was contributed to The NetBSD Foundation by Allen Briggs.
1409 *
1410 * Redistribution and use in source and binary forms, with or without
1411 * modification, are permitted provided that the following conditions
1412 * are met:
1413 * 1. Redistributions of source code must retain the above copyright
1414 *    notice, this list of conditions and the following disclaimer.
1415 * 2. Redistributions in binary form must reproduce the above copyright
1416 *    notice, this list of conditions and the following disclaimer in the
1417 *    documentation and/or other materials provided with the distribution.
1418 *
1419 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
1420 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
1421 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
1422 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
1423 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
1424 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
1425 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
1426 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
1427 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1428 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
1429 * POSSIBILITY OF SUCH DAMAGE.
1430 */
1431
1432The preceding notice is from src/missing/fmtcheck.c in `file`.
1433
1434
1435
1436/*-
1437 * Copyright (c) 2011 The NetBSD Foundation, Inc.
1438 * All rights reserved.
1439 *
1440 * This code is derived from software contributed to The NetBSD Foundation
1441 * by Christos Zoulas.
1442 *
1443 * Redistribution and use in source and binary forms, with or without
1444 * modification, are permitted provided that the following conditions
1445 * are met:
1446 * 1. Redistributions of source code must retain the above copyright
1447 *    notice, this list of conditions and the following disclaimer.
1448 * 2. Redistributions in binary form must reproduce the above copyright
1449 *    notice, this list of conditions and the following disclaimer in the
1450 *    documentation and/or other materials provided with the distribution.
1451 *
1452 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
1453 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
1454 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
1455 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
1456 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
1457 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
1458 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
1459 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
1460 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1461 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
1462 * POSSIBILITY OF SUCH DAMAGE.
1463 */
1464
1465The preceding notice is from src/missing/getline.c in `file`.
1466
1467
1468
1469/*-
1470 * Copyright (c) 2000 The NetBSD Foundation, Inc.
1471 * All rights reserved.
1472 *
1473 * This code is derived from software contributed to The NetBSD Foundation
1474 * by Dieter Baron and Thomas Klausner.
1475 *
1476 * Redistribution and use in source and binary forms, with or without
1477 * modification, are permitted provided that the following conditions
1478 * are met:
1479 * 1. Redistributions of source code must retain the above copyright
1480 *    notice, this list of conditions and the following disclaimer.
1481 * 2. Redistributions in binary form must reproduce the above copyright
1482 *    notice, this list of conditions and the following disclaimer in the
1483 *    documentation and/or other materials provided with the distribution.
1484 *
1485 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
1486 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
1487 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
1488 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
1489 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
1490 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
1491 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
1492 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
1493 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1494 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
1495 * POSSIBILITY OF SUCH DAMAGE.
1496 */
1497
1498The preceding notice is from src/missing/getopt_long.c and src/mygetopt.h in `file`.
1499
1500
1501
1502/*
1503 * Public domain fallback for reallocarray(3), for platforms (e.g.
1504 * AmigaOS/libnix) whose C library declares it but does not implement it.
1505 */
1506
1507The preceding notice is from src/missing/reallocarray.c in `file`.
1508
1509
1510
1511/*-
1512 * SPDX-License-Identifier: BSD-3-Clause
1513 *
1514 * Copyright (c) 1992, 1993, 1994 Henry Spencer.
1515 * Copyright (c) 1992, 1993, 1994
1516 *      The Regents of the University of California.  All rights reserved.
1517 *
1518 * Copyright (c) 2011 The FreeBSD Foundation
1519 * All rights reserved.
1520 * Portions of this software were developed by David Chisnall
1521 * under sponsorship from the FreeBSD Foundation.
1522 *
1523 * This code is derived from software contributed to Berkeley by
1524 * Henry Spencer.
1525 *
1526 * Redistribution and use in source and binary forms, with or without
1527 * modification, are permitted provided that the following conditions
1528 * are met:
1529 * 1. Redistributions of source code must retain the above copyright
1530 *    notice, this list of conditions and the following disclaimer.
1531 * 2. Redistributions in binary form must reproduce the above copyright
1532 *    notice, this list of conditions and the following disclaimer in the
1533 *    documentation and/or other materials provided with the distribution.
1534 * 3. Neither the name of the University nor the names of its contributors
1535 *    may be used to endorse or promote products derived from this software
1536 *    without specific prior written permission.
1537 *
1538 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1539 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1540 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1541 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
1542 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1543 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1544 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1545 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1546 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1547 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1548 * SUCH DAMAGE.
1549 *
1550 *      @(#)regcomp.c   8.5 (Berkeley) 3/20/94
1551 */
1552
1553The preceding notice is from src/missing/regcomp.c in `file`.
1554
1555
1556
1557/*-
1558 * SPDX-License-Identifier: BSD-3-Clause
1559 *
1560 * Copyright (c) 1992, 1993, 1994 Henry Spencer.
1561 * Copyright (c) 1992, 1993, 1994
1562 *      The Regents of the University of California.  All rights reserved.
1563 *
1564 * This code is derived from software contributed to Berkeley by
1565 * Henry Spencer.
1566 *
1567 * Redistribution and use in source and binary forms, with or without
1568 * modification, are permitted provided that the following conditions
1569 * are met:
1570 * 1. Redistributions of source code must retain the above copyright
1571 *    notice, this list of conditions and the following disclaimer.
1572 * 2. Redistributions in binary form must reproduce the above copyright
1573 *    notice, this list of conditions and the following disclaimer in the
1574 *    documentation and/or other materials provided with the distribution.
1575 * 3. Neither the name of the University nor the names of its contributors
1576 *    may be used to endorse or promote products derived from this software
1577 *    without specific prior written permission.
1578 *
1579 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1580 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1581 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1582 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
1583 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1584 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1585 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1586 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1587 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1588 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1589 * SUCH DAMAGE.
1590 *
1591 *      @(#)regerror.c  8.4 (Berkeley) 3/20/94
1592 */
1593
1594The preceding notice is from src/missing/regerror.c in `file`.
1595
1596
1597
1598$NetBSD: COPYRIGHT,v 1.5 2003/08/07 16:43:19 agc Exp $
1599
1600Copyright 1992, 1993, 1994 Henry Spencer.  All rights reserved.
1601This software is not subject to any license of the American Telephone
1602and Telegraph Company or of the Regents of the University of California.
1603
1604Permission is granted to anyone to use this software for any purpose on
1605any computer system, and to alter it and redistribute it, subject
1606to the following restrictions:
1607
16081. The author is not responsible for the consequences of use of this
1609   software, no matter how awful, even if they arise from flaws in it.
1610
16112. The origin of this software must not be misrepresented, either by
1612   explicit claim or by omission.  Since few users ever read sources,
1613   credits must appear in the documentation.
1614
16153. Altered versions must be plainly marked as such, and must not be
1616   misrepresented as being the original software.  Since few users
1617   ever read sources, credits must appear in the documentation.
1618
16194. This notice may not be removed or altered.
1620
1621=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
1622/*-
1623 * Copyright (c) 1994
1624 *      The Regents of the University of California.  All rights reserved.
1625 *
1626 * Redistribution and use in source and binary forms, with or without
1627 * modification, are permitted provided that the following conditions
1628 * are met:
1629 * 1. Redistributions of source code must retain the above copyright
1630 *    notice, this list of conditions and the following disclaimer.
1631 * 2. Redistributions in binary form must reproduce the above copyright
1632 *    notice, this list of conditions and the following disclaimer in the
1633 *    documentation and/or other materials provided with the distribution.
1634 * 3. Neither the name of the University nor the names of its contributors
1635 *    may be used to endorse or promote products derived from this software
1636 *    without specific prior written permission.
1637 *
1638 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1639 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1640 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1641 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
1642 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1643 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1644 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1645 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1646 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1647 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1648 * SUCH DAMAGE.
1649 *
1650 *      @(#)COPYRIGHT   8.1 (Berkeley) 3/16/94
1651 */
1652
1653The preceding notice is from src/missing/REGEX-COPYRIGHT in `file`.
1654
1655
1656
1657/*-
1658 * SPDX-License-Identifier: BSD-3-Clause
1659 *
1660 * Copyright (c) 1992, 1993, 1994 Henry Spencer.
1661 * Copyright (c) 1992, 1993, 1994
1662 *      The Regents of the University of California.  All rights reserved.
1663 *
1664 * This code is derived from software contributed to Berkeley by
1665 * Henry Spencer.
1666 *
1667 * Redistribution and use in source and binary forms, with or without
1668 * modification, are permitted provided that the following conditions
1669 * are met:
1670 * 1. Redistributions of source code must retain the above copyright
1671 *    notice, this list of conditions and the following disclaimer.
1672 * 2. Redistributions in binary form must reproduce the above copyright
1673 *    notice, this list of conditions and the following disclaimer in the
1674 *    documentation and/or other materials provided with the distribution.
1675 * 3. Neither the name of the University nor the names of its contributors
1676 *    may be used to endorse or promote products derived from this software
1677 *    without specific prior written permission.
1678 *
1679 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1680 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1681 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1682 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
1683 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1684 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1685 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1686 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1687 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1688 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1689 * SUCH DAMAGE.
1690 *
1691 *      @(#)regex2.h    8.4 (Berkeley) 3/20/94
1692 * $FreeBSD: head/lib/libc/regex/regex2.h 368359 2020-12-05 03:18:48Z kevans $
1693 */
1694
1695The preceding notice is from src/missing/regex2.h in `file`.
1696
1697
1698
1699/*-
1700 * SPDX-License-Identifier: BSD-3-Clause
1701 *
1702 * Copyright (c) 1992, 1993, 1994 Henry Spencer.
1703 * Copyright (c) 1992, 1993, 1994
1704 *      The Regents of the University of California.  All rights reserved.
1705 *
1706 * This code is derived from software contributed to Berkeley by
1707 * Henry Spencer.
1708 *
1709 * Redistribution and use in source and binary forms, with or without
1710 * modification, are permitted provided that the following conditions
1711 * are met:
1712 * 1. Redistributions of source code must retain the above copyright
1713 *    notice, this list of conditions and the following disclaimer.
1714 * 2. Redistributions in binary form must reproduce the above copyright
1715 *    notice, this list of conditions and the following disclaimer in the
1716 *    documentation and/or other materials provided with the distribution.
1717 * 3. Neither the name of the University nor the names of its contributors
1718 *    may be used to endorse or promote products derived from this software
1719 *    without specific prior written permission.
1720 *
1721 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1722 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1723 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1724 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
1725 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1726 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1727 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1728 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1729 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1730 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1731 * SUCH DAMAGE.
1732 *
1733 *      @(#)regexec.c   8.3 (Berkeley) 3/20/94
1734 */
1735
1736The preceding notice is from src/missing/regexec.c in `file`.
1737
1738
1739
1740/*-
1741 * SPDX-License-Identifier: BSD-3-Clause
1742 *
1743 * Copyright (c) 1992, 1993, 1994 Henry Spencer.
1744 * Copyright (c) 1992, 1993, 1994
1745 *      The Regents of the University of California.  All rights reserved.
1746 *
1747 * This code is derived from software contributed to Berkeley by
1748 * Henry Spencer.
1749 *
1750 * Redistribution and use in source and binary forms, with or without
1751 * modification, are permitted provided that the following conditions
1752 * are met:
1753 * 1. Redistributions of source code must retain the above copyright
1754 *    notice, this list of conditions and the following disclaimer.
1755 * 2. Redistributions in binary form must reproduce the above copyright
1756 *    notice, this list of conditions and the following disclaimer in the
1757 *    documentation and/or other materials provided with the distribution.
1758 * 3. Neither the name of the University nor the names of its contributors
1759 *    may be used to endorse or promote products derived from this software
1760 *    without specific prior written permission.
1761 *
1762 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1763 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1764 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1765 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
1766 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1767 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1768 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1769 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1770 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1771 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1772 * SUCH DAMAGE.
1773 *
1774 *      @(#)regfree.c   8.3 (Berkeley) 3/20/94
1775 */
1776
1777The preceding notice is from src/missing/regfree.c in `file`.
1778
1779
1780
1781/*-
1782 * Copyright (c) 1990, 1993
1783 *      The Regents of the University of California.  All rights reserved.
1784 *
1785 * This code is derived from software contributed to Berkeley by
1786 * Chris Torek.
1787 *
1788 * Redistribution and use in source and binary forms, with or without
1789 * modification, are permitted provided that the following conditions
1790 * are met:
1791 * 1. Redistributions of source code must retain the above copyright
1792 *    notice, this list of conditions and the following disclaimer.
1793 * 2. Redistributions in binary form must reproduce the above copyright
1794 *    notice, this list of conditions and the following disclaimer in the
1795 *    documentation and/or other materials provided with the distribution.
1796 * 3. Neither the name of the University nor the names of its contributors
1797 *    may be used to endorse or promote products derived from this software
1798 *    without specific prior written permission.
1799 *
1800 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1801 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1802 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1803 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
1804 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1805 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1806 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1807 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1808 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1809 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1810 * SUCH DAMAGE.
1811 */
1812
1813The preceding notice is from src/missing/strcasestr.c in `file`.
1814
1815
1816
1817/*
1818 * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
1819 *
1820 * Permission to use, copy, modify, and distribute this software for any
1821 * purpose with or without fee is hereby granted, provided that the above
1822 * copyright notice and this permission notice appear in all copies.
1823 *
1824 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
1825 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
1826 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
1827 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
1828 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
1829 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
1830 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1831 */
1832
1833The preceding notice is from src/missing/strlcat.c and src/missing/strlcpy.c in `file`.
1834
1835
1836
1837/*-
1838 * SPDX-License-Identifier: BSD-3-Clause
1839 *
1840 * Copyright (c) 1992, 1993, 1994 Henry Spencer.
1841 * Copyright (c) 1992, 1993, 1994
1842 *      The Regents of the University of California.  All rights reserved.
1843 *
1844 * This code is derived from software contributed to Berkeley by
1845 * Henry Spencer.
1846 *
1847 * Redistribution and use in source and binary forms, with or without
1848 * modification, are permitted provided that the following conditions
1849 * are met:
1850 * 1. Redistributions of source code must retain the above copyright
1851 *    notice, this list of conditions and the following disclaimer.
1852 * 2. Redistributions in binary form must reproduce the above copyright
1853 *    notice, this list of conditions and the following disclaimer in the
1854 *    documentation and/or other materials provided with the distribution.
1855 * 3. Neither the name of the University nor the names of its contributors
1856 *    may be used to endorse or promote products derived from this software
1857 *    without specific prior written permission.
1858 *
1859 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1860 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1861 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1862 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
1863 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1864 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1865 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1866 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1867 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1868 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1869 * SUCH DAMAGE.
1870 *
1871 *      @(#)utils.h     8.3 (Berkeley) 3/20/94
1872 * $FreeBSD: head/lib/libc/regex/utils.h 341838 2018-12-12 04:23:00Z yuripv $
1873 */
1874
1875The preceding notice is from src/missing/utils.h in `file`.
1876
1877
1878
1879/*-
1880 * Copyright (c) 2008, 2016 Christos Zoulas
1881 * All rights reserved.
1882 *
1883 * Redistribution and use in source and binary forms, with or without
1884 * modification, are permitted provided that the following conditions
1885 * are met:
1886 * 1. Redistributions of source code must retain the above copyright
1887 *    notice, this list of conditions and the following disclaimer.
1888 * 2. Redistributions in binary form must reproduce the above copyright
1889 *    notice, this list of conditions and the following disclaimer in the
1890 *    documentation and/or other materials provided with the distribution.
1891 *
1892 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
1893 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
1894 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
1895 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
1896 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
1897 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
1898 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
1899 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
1900 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1901 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
1902 * POSSIBILITY OF SUCH DAMAGE.
1903 */
1904
1905The preceding notice is from src/readcdf.c in `file`.
1906
1907
1908
1909/*-
1910 * Copyright (c) 1992 Henry Spencer.
1911 * Copyright (c) 1992, 1993
1912 *      The Regents of the University of California.  All rights reserved.
1913 *
1914 * This code is derived from software contributed to Berkeley by
1915 * Henry Spencer of the University of Toronto.
1916 *
1917 * Redistribution and use in source and binary forms, with or without
1918 * modification, are permitted provided that the following conditions
1919 * are met:
1920 * 1. Redistributions of source code must retain the above copyright
1921 *    notice, this list of conditions and the following disclaimer.
1922 * 2. Redistributions in binary form must reproduce the above copyright
1923 *    notice, this list of conditions and the following disclaimer in the
1924 *    documentation and/or other materials provided with the distribution.
1925 * 3. Neither the name of the University nor the names of its contributors
1926 *    may be used to endorse or promote products derived from this software
1927 *    without specific prior written permission.
1928 *
1929 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1930 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1931 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1932 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
1933 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1934 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1935 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1936 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1937 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1938 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1939 * SUCH DAMAGE.
1940 *
1941 *      @(#)regex.h     8.2 (Berkeley) 1/3/94
1942 * $FreeBSD: src/include/regex.h,v 1.12 2010/02/16 19:39:50 imp Exp $
1943 */
1944
1945The preceding notice is from src/regex-bsd.h in `file`.
1946*/
1947/*
1948
1949Text of LICENSE from DROID:
1950
1951Copyright (c) 2016, The National Archives <pronom@nationalarchives.gov.uk>
1952All rights reserved.
1953
1954Redistribution and use in source and binary forms, with or without
1955modification, are permitted provided that the following
1956conditions are met:
1957
1958 * Redistributions of source code must retain the above copyright
1959   notice, this list of conditions and the following disclaimer.
1960
1961 * Redistributions in binary form must reproduce the above copyright
1962   notice, this list of conditions and the following disclaimer in the
1963   documentation and/or other materials provided with the distribution.
1964
1965 * Neither the name of the The National Archives nor the
1966   names of its contributors may be used to endorse or promote products
1967   derived from this software without specific prior written permission.
1968
1969THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1970AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1971IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
1972PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
1973CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
1974EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
1975PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
1976PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
1977LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
1978NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
1979SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1980*/
1981
1982/*
1983
1984Text of LICENSE from fileid:
1985
1986The MIT License (MIT)
1987
1988Copyright (c) 2015 David B Heise
1989
1990Permission is hereby granted, free of charge, to any person obtaining a copy of
1991this software and associated documentation files (the "Software"), to deal in
1992the Software without restriction, including without limitation the rights to
1993use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
1994the Software, and to permit persons to whom the Software is furnished to do so,
1995subject to the following conditions:
1996
1997The above copyright notice and this permission notice shall be included in all
1998copies or substantial portions of the Software.
1999
2000THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2001IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
2002FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
2003COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
2004IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
2005CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2006
2007
2008*/
2009
2010/*
2011Text of LICENSE from binwalk:
2012
2013
2014MIT License
2015
2016Copyright (c) 2024 devttys0
2017
2018Permission is hereby granted, free of charge, to any person obtaining a copy
2019of this software and associated documentation files (the "Software"), to deal
2020in the Software without restriction, including without limitation the rights
2021to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2022copies of the Software, and to permit persons to whom the Software is
2023furnished to do so, subject to the following conditions:
2024
2025The above copyright notice and this permission notice shall be included in all
2026copies or substantial portions of the Software.
2027
2028THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2029IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2030FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2031AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2032LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2033OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2034SOFTWARE.
2035
2036*/
2037
2038/*
2039Text of LICENSE from polyfile:
2040
2041
2042                                 Apache License
2043                           Version 2.0, January 2004
2044                        http://www.apache.org/licenses/
2045
2046   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
2047
2048   1. Definitions.
2049
2050      "License" shall mean the terms and conditions for use, reproduction,
2051      and distribution as defined by Sections 1 through 9 of this document.
2052
2053      "Licensor" shall mean the copyright owner or entity authorized by
2054      the copyright owner that is granting the License.
2055
2056      "Legal Entity" shall mean the union of the acting entity and all
2057      other entities that control, are controlled by, or are under common
2058      control with that entity. For the purposes of this definition,
2059      "control" means (i) the power, direct or indirect, to cause the
2060      direction or management of such entity, whether by contract or
2061      otherwise, or (ii) ownership of fifty percent (50%) or more of the
2062      outstanding shares, or (iii) beneficial ownership of such entity.
2063
2064      "You" (or "Your") shall mean an individual or Legal Entity
2065      exercising permissions granted by this License.
2066
2067      "Source" form shall mean the preferred form for making modifications,
2068      including but not limited to software source code, documentation
2069      source, and configuration files.
2070
2071      "Object" form shall mean any form resulting from mechanical
2072      transformation or translation of a Source form, including but
2073      not limited to compiled object code, generated documentation,
2074      and conversions to other media types.
2075
2076      "Work" shall mean the work of authorship, whether in Source or
2077      Object form, made available under the License, as indicated by a
2078      copyright notice that is included in or attached to the work
2079      (an example is provided in the Appendix below).
2080
2081      "Derivative Works" shall mean any work, whether in Source or Object
2082      form, that is based on (or derived from) the Work and for which the
2083      editorial revisions, annotations, elaborations, or other modifications
2084      represent, as a whole, an original work of authorship. For the purposes
2085      of this License, Derivative Works shall not include works that remain
2086      separable from, or merely link (or bind by name) to the interfaces of,
2087      the Work and Derivative Works thereof.
2088
2089      "Contribution" shall mean any work of authorship, including
2090      the original version of the Work and any modifications or additions
2091      to that Work or Derivative Works thereof, that is intentionally
2092      submitted to Licensor for inclusion in the Work by the copyright owner
2093      or by an individual or Legal Entity authorized to submit on behalf of
2094      the copyright owner. For the purposes of this definition, "submitted"
2095      means any form of electronic, verbal, or written communication sent
2096      to the Licensor or its representatives, including but not limited to
2097      communication on electronic mailing lists, source code control systems,
2098      and issue tracking systems that are managed by, or on behalf of, the
2099      Licensor for the purpose of discussing and improving the Work, but
2100      excluding communication that is conspicuously marked or otherwise
2101      designated in writing by the copyright owner as "Not a Contribution."
2102
2103      "Contributor" shall mean Licensor and any individual or Legal Entity
2104      on behalf of whom a Contribution has been received by Licensor and
2105      subsequently incorporated within the Work.
2106
2107   2. Grant of Copyright License. Subject to the terms and conditions of
2108      this License, each Contributor hereby grants to You a perpetual,
2109      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
2110      copyright license to reproduce, prepare Derivative Works of,
2111      publicly display, publicly perform, sublicense, and distribute the
2112      Work and such Derivative Works in Source or Object form.
2113
2114   3. Grant of Patent License. Subject to the terms and conditions of
2115      this License, each Contributor hereby grants to You a perpetual,
2116      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
2117      (except as stated in this section) patent license to make, have made,
2118      use, offer to sell, sell, import, and otherwise transfer the Work,
2119      where such license applies only to those patent claims licensable
2120      by such Contributor that are necessarily infringed by their
2121      Contribution(s) alone or by combination of their Contribution(s)
2122      with the Work to which such Contribution(s) was submitted. If You
2123      institute patent litigation against any entity (including a
2124      cross-claim or counterclaim in a lawsuit) alleging that the Work
2125      or a Contribution incorporated within the Work constitutes direct
2126      or contributory patent infringement, then any patent licenses
2127      granted to You under this License for that Work shall terminate
2128      as of the date such litigation is filed.
2129
2130   4. Redistribution. You may reproduce and distribute copies of the
2131      Work or Derivative Works thereof in any medium, with or without
2132      modifications, and in Source or Object form, provided that You
2133      meet the following conditions:
2134
2135      (a) You must give any other recipients of the Work or
2136          Derivative Works a copy of this License; and
2137
2138      (b) You must cause any modified files to carry prominent notices
2139          stating that You changed the files; and
2140
2141      (c) You must retain, in the Source form of any Derivative Works
2142          that You distribute, all copyright, patent, trademark, and
2143          attribution notices from the Source form of the Work,
2144          excluding those notices that do not pertain to any part of
2145          the Derivative Works; and
2146
2147      (d) If the Work includes a "NOTICE" text file as part of its
2148          distribution, then any Derivative Works that You distribute must
2149          include a readable copy of the attribution notices contained
2150          within such NOTICE file, excluding those notices that do not
2151          pertain to any part of the Derivative Works, in at least one
2152          of the following places: within a NOTICE text file distributed
2153          as part of the Derivative Works; within the Source form or
2154          documentation, if provided along with the Derivative Works; or,
2155          within a display generated by the Derivative Works, if and
2156          wherever such third-party notices normally appear. The contents
2157          of the NOTICE file are for informational purposes only and
2158          do not modify the License. You may add Your own attribution
2159          notices within Derivative Works that You distribute, alongside
2160          or as an addendum to the NOTICE text from the Work, provided
2161          that such additional attribution notices cannot be construed
2162          as modifying the License.
2163
2164      You may add Your own copyright statement to Your modifications and
2165      may provide additional or different license terms and conditions
2166      for use, reproduction, or distribution of Your modifications, or
2167      for any such Derivative Works as a whole, provided Your use,
2168      reproduction, and distribution of the Work otherwise complies with
2169      the conditions stated in this License.
2170
2171   5. Submission of Contributions. Unless You explicitly state otherwise,
2172      any Contribution intentionally submitted for inclusion in the Work
2173      by You to the Licensor shall be under the terms and conditions of
2174      this License, without any additional terms or conditions.
2175      Notwithstanding the above, nothing herein shall supersede or modify
2176      the terms of any separate license agreement you may have executed
2177      with Licensor regarding such Contributions.
2178
2179   6. Trademarks. This License does not grant permission to use the trade
2180      names, trademarks, service marks, or product names of the Licensor,
2181      except as required for reasonable and customary use in describing the
2182      origin of the Work and reproducing the content of the NOTICE file.
2183
2184   7. Disclaimer of Warranty. Unless required by applicable law or
2185      agreed to in writing, Licensor provides the Work (and each
2186      Contributor provides its Contributions) on an "AS IS" BASIS,
2187      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
2188      implied, including, without limitation, any warranties or conditions
2189      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
2190      PARTICULAR PURPOSE. You are solely responsible for determining the
2191      appropriateness of using or redistributing the Work and assume any
2192      risks associated with Your exercise of permissions under this License.
2193
2194   8. Limitation of Liability. In no event and under no legal theory,
2195      whether in tort (including negligence), contract, or otherwise,
2196      unless required by applicable law (such as deliberate and grossly
2197      negligent acts) or agreed to in writing, shall any Contributor be
2198      liable to You for damages, including any direct, indirect, special,
2199      incidental, or consequential damages of any character arising as a
2200      result of this License or out of the use or inability to use the
2201      Work (including but not limited to damages for loss of goodwill,
2202      work stoppage, computer failure or malfunction, or any and all
2203      other commercial damages or losses), even if such Contributor
2204      has been advised of the possibility of such damages.
2205
2206   9. Accepting Warranty or Additional Liability. While redistributing
2207      the Work or Derivative Works thereof, You may choose to offer,
2208      and charge a fee for, acceptance of support, warranty, indemnity,
2209      or other liability obligations and/or rights consistent with this
2210      License. However, in accepting such obligations, You may act only
2211      on Your own behalf and on Your sole responsibility, not on behalf
2212      of any other Contributor, and only if You agree to indemnify,
2213      defend, and hold each Contributor harmless for any liability
2214      incurred by, or claims asserted against, such Contributor by reason
2215      of your accepting any such warranty or additional liability.
2216
2217   END OF TERMS AND CONDITIONS
2218
2219   APPENDIX: How to apply the Apache License to your work.
2220
2221      To apply the Apache License to your work, attach the following
2222      boilerplate notice, with the fields enclosed by brackets "[]"
2223      replaced with your own identifying information. (Don't include
2224      the brackets!)  The text should be enclosed in the appropriate
2225      comment syntax for the file format. We also recommend that a
2226      file or class name and description of purpose be included on the
2227      same "printed page" as the copyright notice for easier
2228      identification within third-party archives.
2229
2230   Copyright [yyyy] [name of copyright owner]
2231
2232   Licensed under the Apache License, Version 2.0 (the "License");
2233   you may not use this file except in compliance with the License.
2234   You may obtain a copy of the License at
2235
2236       http://www.apache.org/licenses/LICENSE-2.0
2237
2238   Unless required by applicable law or agreed to in writing, software
2239   distributed under the License is distributed on an "AS IS" BASIS,
2240   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2241   See the License for the specific language governing permissions and
2242   limitations under the License.
2243
2244*/