ctb_formats_detection/
extension.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//! File extension registry and matching utilities for format identification.
446//!
447//! Adapted from extension and multi-layer disambiguation logic in
448//! `old/filedetect/polyfile` and `old/filedetect/binwalk`.
449
450#[allow(
451    unused_imports,
452    clippy::wildcard_imports,
453    reason = "Standard workspace module prelude"
454)]
455use ctb_utilities::*;
456
457pub use ctb_formats_utilities::extension_rule::{
458    CaseSensitivity, ExtensionRule,
459};
460
461/// Resolves candidate `FormatId` variants and scores for a given file extension,
462/// taking into account database OS associations and platform priors.
463#[must_use]
464pub fn resolve_extension_candidates(
465    ext: &str,
466    platform: Option<crate::format_id::FormatId>,
467) -> Vec<(crate::format_id::FormatId, u32)> {
468    use crate::format_id::FormatId;
469
470    let trimmed = ext.trim().trim_start_matches('.').to_ascii_lowercase();
471    let mut results = Vec::new();
472
473    for mapping in
474        super::mime_derivation::FORMAT_CATALOG.lookup_extension(&trimmed)
475    {
476        if let Some(fmt) = mapping.format_id {
477            if !results.iter().any(|(f, _)| *f == fmt) {
478                let mut score: u32 = 50;
479                if let Some(target_os) = platform {
480                    if mapping.os_associations.iter().any(|&cand_os| {
481                        crate::detection::is_os_match(cand_os, target_os)
482                    }) {
483                        score = score.saturating_add(20);
484                    }
485                }
486                results.push((fmt, score));
487            }
488        }
489    }
490
491    // Fallback for .m (Objective-C source files mapped to C format)
492    if trimmed == "m" && results.is_empty() {
493        let score: u32 = match platform {
494            Some(FormatId::MacOs | FormatId::MacOsDarwin) => 75,
495            _ => 50,
496        };
497        results.push((FormatId::C, score));
498    }
499
500    results.sort_by(|a, b| b.1.cmp(&a.1));
501    results
502}
503
504#[cfg(test)]
505#[allow(
506    clippy::panic,
507    clippy::expect_used,
508    clippy::unwrap_used,
509    clippy::unwrap_in_result,
510    clippy::panic_in_result_fn,
511    clippy::indexing_slicing,
512    clippy::arithmetic_side_effects,
513    reason = "Standard repository test boilerplate"
514)]
515mod tests {
516    use super::*;
517    use crate::format_id::FormatId;
518
519    #[ctb_test]
520    fn test_resolve_extension_candidates_os_prior() {
521        // .as has both AppleSingle (@os(f405)) and ActionScript (no os)
522        let mac_candidates =
523            resolve_extension_candidates("as", Some(FormatId::MacOs));
524        assert!(!mac_candidates.is_empty());
525        assert_eq!(mac_candidates[0].0, FormatId::AppleSingle);
526        assert_eq!(mac_candidates[0].1, 70);
527
528        let generic_candidates = resolve_extension_candidates("as", None);
529        assert!(!generic_candidates.is_empty());
530        assert_eq!(generic_candidates[0].1, 50);
531    }
532
533    #[ctb_test]
534    fn test_extension_rule_matching() {
535        let sens_z = ExtensionRule::sensitive("Z");
536        assert!(sens_z.matches("file.txt.Z"));
537        assert!(sens_z.matches("Z"));
538        assert!(!sens_z.matches("file.txt.z"));
539
540        let sens_lower_z = ExtensionRule::sensitive("z");
541        assert!(sens_lower_z.matches("file.txt.z"));
542        assert!(!sens_lower_z.matches("file.txt.Z"));
543
544        let insens_gz = ExtensionRule::insensitive("gz");
545        assert!(insens_gz.matches("archive.tar.gz"));
546        assert!(insens_gz.matches("archive.tar.GZ"));
547        assert!(insens_gz.matches("gz"));
548    }
549}
550/*
551/*
552 * Adapted from: apptype.c, Written by Eberhard Mattes and put into the
553 * file_public domain
554 *
555 * Notes: 1. Qualify the filename so that DosQueryAppType does not do extraneous
556 * searches.
557 *
558 * 2. DosQueryAppType will return FAPPTYP_DOS on a file ending with ".com"
559 * (other than an OS/2 exe or Win exe with this name). Eberhard Mattes
560 * remarks Tue, 6 Apr 93: Moreover, it reports the type of the (new and very
561 * bug ridden) Win Emacs as "OS/2 executable".
562 *
563 * 3. apptype() uses the filename if given, otherwise a tmp file is created with
564 * the contents of buf. If buf is not the complete file, apptype can
565 * incorrectly identify the exe type. The "-z" option of "file" is the reason
566 * for this ugly code.
567 */
568
569The preceding notice is from src/apptype.c in `file`.
570
571
572
573/*-
574 * Copyright (c) 2008 Christos Zoulas
575 * All rights reserved.
576 *
577 * Redistribution and use in source and binary forms, with or without
578 * modification, are permitted provided that the following conditions
579 * are met:
580 * 1. Redistributions of source code must retain the above copyright
581 *    notice, this list of conditions and the following disclaimer.
582 * 2. Redistributions in binary form must reproduce the above copyright
583 *    notice, this list of conditions and the following disclaimer in the
584 *    documentation and/or other materials provided with the distribution.
585 *
586 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
587 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
588 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
589 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
590 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
591 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
592 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
593 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
594 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
595 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
596 * POSSIBILITY OF SUCH DAMAGE.
597 */
598
599The preceding notice is from src/cdf.c, src/cdf.h, and src/cdf_time.c in `file`.
600
601
602
603/*-
604 * Copyright (c) 2016 Christos Zoulas
605 * All rights reserved.
606 *
607 * Redistribution and use in source and binary forms, with or without
608 * modification, are permitted provided that the following conditions
609 * are met:
610 * 1. Redistributions of source code must retain the above copyright
611 *    notice, this list of conditions and the following disclaimer.
612 * 2. Redistributions in binary form must reproduce the above copyright
613 *    notice, this list of conditions and the following disclaimer in the
614 *    documentation and/or other materials provided with the distribution.
615 *
616 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
617 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
618 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
619 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
620 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
621 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
622 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
623 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
624 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
625 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
626 * POSSIBILITY OF SUCH DAMAGE.
627 */
628
629The preceding notice is from src/der.c and src/der.h in `file`.
630
631
632
633/*-
634 * Copyright (c) 2019 Christos Zoulas
635 * All rights reserved.
636 *
637 * Redistribution and use in source and binary forms, with or without
638 * modification, are permitted provided that the following conditions
639 * are met:
640 * 1. Redistributions of source code must retain the above copyright
641 *    notice, this list of conditions and the following disclaimer.
642 * 2. Redistributions in binary form must reproduce the above copyright
643 *    notice, this list of conditions and the following disclaimer in the
644 *    documentation and/or other materials provided with the distribution.
645 *
646 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
647 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
648 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
649 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
650 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
651 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
652 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
653 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
654 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
655 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
656 * POSSIBILITY OF SUCH DAMAGE.
657 */
658
659The preceding notice is from src/is_csv.c in `file`.
660
661
662
663/*-
664 * Copyright (c) 2018 Christos Zoulas
665 * All rights reserved.
666 *
667 * Redistribution and use in source and binary forms, with or without
668 * modification, are permitted provided that the following conditions
669 * are met:
670 * 1. Redistributions of source code must retain the above copyright
671 *    notice, this list of conditions and the following disclaimer.
672 * 2. Redistributions in binary form must reproduce the above copyright
673 *    notice, this list of conditions and the following disclaimer in the
674 *    documentation and/or other materials provided with the distribution.
675 *
676 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
677 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
678 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
679 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
680 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
681 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
682 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
683 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
684 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
685 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
686 * POSSIBILITY OF SUCH DAMAGE.
687 */
688
689The preceding notice is from src/is_json.c in `file`.
690
691
692
693/*-
694 * Copyright (c) 2023 Christos Zoulas
695 * All rights reserved.
696 *
697 * Redistribution and use in source and binary forms, with or without
698 * modification, are permitted provided that the following conditions
699 * are met:
700 * 1. Redistributions of source code must retain the above copyright
701 *    notice, this list of conditions and the following disclaimer.
702 * 2. Redistributions in binary form must reproduce the above copyright
703 *    notice, this list of conditions and the following disclaimer in the
704 *    documentation and/or other materials provided with the distribution.
705 *
706 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
707 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
708 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
709 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
710 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
711 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
712 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
713 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
714 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
715 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
716 * POSSIBILITY OF SUCH DAMAGE.
717 */
718
719The preceding notice is from src/is_simh.c in `file`.
720
721
722
723/*-
724 * SPDX-License-Identifier: BSD-3-Clause
725 *
726 * Copyright (c) 1992, 1993, 1994 Henry Spencer.
727 * Copyright (c) 1992, 1993, 1994
728 *      The Regents of the University of California.  All rights reserved.
729 *
730 * This code is derived from software contributed to Berkeley by
731 * Henry Spencer.
732 *
733 * Redistribution and use in source and binary forms, with or without
734 * modification, are permitted provided that the following conditions
735 * are met:
736 * 1. Redistributions of source code must retain the above copyright
737 *    notice, this list of conditions and the following disclaimer.
738 * 2. Redistributions in binary form must reproduce the above copyright
739 *    notice, this list of conditions and the following disclaimer in the
740 *    documentation and/or other materials provided with the distribution.
741 * 3. Neither the name of the University nor the names of its contributors
742 *    may be used to endorse or promote products derived from this software
743 *    without specific prior written permission.
744 *
745 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
746 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
747 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
748 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
749 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
750 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
751 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
752 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
753 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
754 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
755 * SUCH DAMAGE.
756 *
757 *      @(#)cname.h     8.3 (Berkeley) 3/20/94
758 * $FreeBSD: head/lib/libc/regex/cname.h 326025 2017-11-20 19:49:47Z pfg $
759 */
760
761The preceding notice is from src/missing/cname.h in `file`.
762
763
764
765/*-
766 * SPDX-License-Identifier: BSD-3-Clause
767 *
768 * Copyright (c) 1992, 1993, 1994 Henry Spencer.
769 * Copyright (c) 1992, 1993, 1994
770 *      The Regents of the University of California.  All rights reserved.
771 *
772 * This code is derived from software contributed to Berkeley by
773 * Henry Spencer.
774 *
775 * Redistribution and use in source and binary forms, with or without
776 * modification, are permitted provided that the following conditions
777 * are met:
778 * 1. Redistributions of source code must retain the above copyright
779 *    notice, this list of conditions and the following disclaimer.
780 * 2. Redistributions in binary form must reproduce the above copyright
781 *    notice, this list of conditions and the following disclaimer in the
782 *    documentation and/or other materials provided with the distribution.
783 * 3. Neither the name of the University nor the names of its contributors
784 *    may be used to endorse or promote products derived from this software
785 *    without specific prior written permission.
786 *
787 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
788 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
789 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
790 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
791 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
792 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
793 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
794 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
795 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
796 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
797 * SUCH DAMAGE.
798 *
799 *      @(#)engine.c    8.5 (Berkeley) 3/20/94
800 */
801
802The preceding notice is from src/missing/engine.c in `file`.
803
804
805
806/*-
807 * Copyright (c) 2000 The NetBSD Foundation, Inc.
808 * All rights reserved.
809 *
810 * This code was contributed to The NetBSD Foundation by Allen Briggs.
811 *
812 * Redistribution and use in source and binary forms, with or without
813 * modification, are permitted provided that the following conditions
814 * are met:
815 * 1. Redistributions of source code must retain the above copyright
816 *    notice, this list of conditions and the following disclaimer.
817 * 2. Redistributions in binary form must reproduce the above copyright
818 *    notice, this list of conditions and the following disclaimer in the
819 *    documentation and/or other materials provided with the distribution.
820 *
821 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
822 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
823 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
824 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
825 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
826 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
827 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
828 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
829 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
830 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
831 * POSSIBILITY OF SUCH DAMAGE.
832 */
833
834The preceding notice is from src/missing/fmtcheck.c in `file`.
835
836
837
838/*-
839 * Copyright (c) 2011 The NetBSD Foundation, Inc.
840 * All rights reserved.
841 *
842 * This code is derived from software contributed to The NetBSD Foundation
843 * by Christos Zoulas.
844 *
845 * Redistribution and use in source and binary forms, with or without
846 * modification, are permitted provided that the following conditions
847 * are met:
848 * 1. Redistributions of source code must retain the above copyright
849 *    notice, this list of conditions and the following disclaimer.
850 * 2. Redistributions in binary form must reproduce the above copyright
851 *    notice, this list of conditions and the following disclaimer in the
852 *    documentation and/or other materials provided with the distribution.
853 *
854 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
855 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
856 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
857 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
858 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
859 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
860 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
861 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
862 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
863 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
864 * POSSIBILITY OF SUCH DAMAGE.
865 */
866
867The preceding notice is from src/missing/getline.c in `file`.
868
869
870
871/*-
872 * Copyright (c) 2000 The NetBSD Foundation, Inc.
873 * All rights reserved.
874 *
875 * This code is derived from software contributed to The NetBSD Foundation
876 * by Dieter Baron and Thomas Klausner.
877 *
878 * Redistribution and use in source and binary forms, with or without
879 * modification, are permitted provided that the following conditions
880 * are met:
881 * 1. Redistributions of source code must retain the above copyright
882 *    notice, this list of conditions and the following disclaimer.
883 * 2. Redistributions in binary form must reproduce the above copyright
884 *    notice, this list of conditions and the following disclaimer in the
885 *    documentation and/or other materials provided with the distribution.
886 *
887 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
888 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
889 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
890 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
891 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
892 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
893 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
894 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
895 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
896 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
897 * POSSIBILITY OF SUCH DAMAGE.
898 */
899
900The preceding notice is from src/missing/getopt_long.c and src/mygetopt.h in `file`.
901
902
903
904/*
905 * Public domain fallback for reallocarray(3), for platforms (e.g.
906 * AmigaOS/libnix) whose C library declares it but does not implement it.
907 */
908
909The preceding notice is from src/missing/reallocarray.c in `file`.
910
911
912
913/*-
914 * SPDX-License-Identifier: BSD-3-Clause
915 *
916 * Copyright (c) 1992, 1993, 1994 Henry Spencer.
917 * Copyright (c) 1992, 1993, 1994
918 *      The Regents of the University of California.  All rights reserved.
919 *
920 * Copyright (c) 2011 The FreeBSD Foundation
921 * All rights reserved.
922 * Portions of this software were developed by David Chisnall
923 * under sponsorship from the FreeBSD Foundation.
924 *
925 * This code is derived from software contributed to Berkeley by
926 * Henry Spencer.
927 *
928 * Redistribution and use in source and binary forms, with or without
929 * modification, are permitted provided that the following conditions
930 * are met:
931 * 1. Redistributions of source code must retain the above copyright
932 *    notice, this list of conditions and the following disclaimer.
933 * 2. Redistributions in binary form must reproduce the above copyright
934 *    notice, this list of conditions and the following disclaimer in the
935 *    documentation and/or other materials provided with the distribution.
936 * 3. Neither the name of the University nor the names of its contributors
937 *    may be used to endorse or promote products derived from this software
938 *    without specific prior written permission.
939 *
940 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
941 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
942 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
943 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
944 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
945 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
946 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
947 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
948 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
949 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
950 * SUCH DAMAGE.
951 *
952 *      @(#)regcomp.c   8.5 (Berkeley) 3/20/94
953 */
954
955The preceding notice is from src/missing/regcomp.c in `file`.
956
957
958
959/*-
960 * SPDX-License-Identifier: BSD-3-Clause
961 *
962 * Copyright (c) 1992, 1993, 1994 Henry Spencer.
963 * Copyright (c) 1992, 1993, 1994
964 *      The Regents of the University of California.  All rights reserved.
965 *
966 * This code is derived from software contributed to Berkeley by
967 * Henry Spencer.
968 *
969 * Redistribution and use in source and binary forms, with or without
970 * modification, are permitted provided that the following conditions
971 * are met:
972 * 1. Redistributions of source code must retain the above copyright
973 *    notice, this list of conditions and the following disclaimer.
974 * 2. Redistributions in binary form must reproduce the above copyright
975 *    notice, this list of conditions and the following disclaimer in the
976 *    documentation and/or other materials provided with the distribution.
977 * 3. Neither the name of the University nor the names of its contributors
978 *    may be used to endorse or promote products derived from this software
979 *    without specific prior written permission.
980 *
981 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
982 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
983 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
984 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
985 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
986 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
987 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
988 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
989 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
990 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
991 * SUCH DAMAGE.
992 *
993 *      @(#)regerror.c  8.4 (Berkeley) 3/20/94
994 */
995
996The preceding notice is from src/missing/regerror.c in `file`.
997
998
999
1000$NetBSD: COPYRIGHT,v 1.5 2003/08/07 16:43:19 agc Exp $
1001
1002Copyright 1992, 1993, 1994 Henry Spencer.  All rights reserved.
1003This software is not subject to any license of the American Telephone
1004and Telegraph Company or of the Regents of the University of California.
1005
1006Permission is granted to anyone to use this software for any purpose on
1007any computer system, and to alter it and redistribute it, subject
1008to the following restrictions:
1009
10101. The author is not responsible for the consequences of use of this
1011   software, no matter how awful, even if they arise from flaws in it.
1012
10132. The origin of this software must not be misrepresented, either by
1014   explicit claim or by omission.  Since few users ever read sources,
1015   credits must appear in the documentation.
1016
10173. Altered versions must be plainly marked as such, and must not be
1018   misrepresented as being the original software.  Since few users
1019   ever read sources, credits must appear in the documentation.
1020
10214. This notice may not be removed or altered.
1022
1023=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
1024/*-
1025 * Copyright (c) 1994
1026 *      The Regents of the University of California.  All rights reserved.
1027 *
1028 * Redistribution and use in source and binary forms, with or without
1029 * modification, are permitted provided that the following conditions
1030 * are met:
1031 * 1. Redistributions of source code must retain the above copyright
1032 *    notice, this list of conditions and the following disclaimer.
1033 * 2. Redistributions in binary form must reproduce the above copyright
1034 *    notice, this list of conditions and the following disclaimer in the
1035 *    documentation and/or other materials provided with the distribution.
1036 * 3. Neither the name of the University nor the names of its contributors
1037 *    may be used to endorse or promote products derived from this software
1038 *    without specific prior written permission.
1039 *
1040 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1041 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1042 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1043 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
1044 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1045 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1046 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1047 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1048 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1049 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1050 * SUCH DAMAGE.
1051 *
1052 *      @(#)COPYRIGHT   8.1 (Berkeley) 3/16/94
1053 */
1054
1055The preceding notice is from src/missing/REGEX-COPYRIGHT in `file`.
1056
1057
1058
1059/*-
1060 * SPDX-License-Identifier: BSD-3-Clause
1061 *
1062 * Copyright (c) 1992, 1993, 1994 Henry Spencer.
1063 * Copyright (c) 1992, 1993, 1994
1064 *      The Regents of the University of California.  All rights reserved.
1065 *
1066 * This code is derived from software contributed to Berkeley by
1067 * Henry Spencer.
1068 *
1069 * Redistribution and use in source and binary forms, with or without
1070 * modification, are permitted provided that the following conditions
1071 * are met:
1072 * 1. Redistributions of source code must retain the above copyright
1073 *    notice, this list of conditions and the following disclaimer.
1074 * 2. Redistributions in binary form must reproduce the above copyright
1075 *    notice, this list of conditions and the following disclaimer in the
1076 *    documentation and/or other materials provided with the distribution.
1077 * 3. Neither the name of the University nor the names of its contributors
1078 *    may be used to endorse or promote products derived from this software
1079 *    without specific prior written permission.
1080 *
1081 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1082 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1083 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1084 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
1085 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1086 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1087 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1088 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1089 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1090 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1091 * SUCH DAMAGE.
1092 *
1093 *      @(#)regex2.h    8.4 (Berkeley) 3/20/94
1094 * $FreeBSD: head/lib/libc/regex/regex2.h 368359 2020-12-05 03:18:48Z kevans $
1095 */
1096
1097The preceding notice is from src/missing/regex2.h in `file`.
1098
1099
1100
1101/*-
1102 * SPDX-License-Identifier: BSD-3-Clause
1103 *
1104 * Copyright (c) 1992, 1993, 1994 Henry Spencer.
1105 * Copyright (c) 1992, 1993, 1994
1106 *      The Regents of the University of California.  All rights reserved.
1107 *
1108 * This code is derived from software contributed to Berkeley by
1109 * Henry Spencer.
1110 *
1111 * Redistribution and use in source and binary forms, with or without
1112 * modification, are permitted provided that the following conditions
1113 * are met:
1114 * 1. Redistributions of source code must retain the above copyright
1115 *    notice, this list of conditions and the following disclaimer.
1116 * 2. Redistributions in binary form must reproduce the above copyright
1117 *    notice, this list of conditions and the following disclaimer in the
1118 *    documentation and/or other materials provided with the distribution.
1119 * 3. Neither the name of the University nor the names of its contributors
1120 *    may be used to endorse or promote products derived from this software
1121 *    without specific prior written permission.
1122 *
1123 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1124 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1125 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1126 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
1127 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1128 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1129 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1130 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1131 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1132 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1133 * SUCH DAMAGE.
1134 *
1135 *      @(#)regexec.c   8.3 (Berkeley) 3/20/94
1136 */
1137
1138The preceding notice is from src/missing/regexec.c in `file`.
1139
1140
1141
1142/*-
1143 * SPDX-License-Identifier: BSD-3-Clause
1144 *
1145 * Copyright (c) 1992, 1993, 1994 Henry Spencer.
1146 * Copyright (c) 1992, 1993, 1994
1147 *      The Regents of the University of California.  All rights reserved.
1148 *
1149 * This code is derived from software contributed to Berkeley by
1150 * Henry Spencer.
1151 *
1152 * Redistribution and use in source and binary forms, with or without
1153 * modification, are permitted provided that the following conditions
1154 * are met:
1155 * 1. Redistributions of source code must retain the above copyright
1156 *    notice, this list of conditions and the following disclaimer.
1157 * 2. Redistributions in binary form must reproduce the above copyright
1158 *    notice, this list of conditions and the following disclaimer in the
1159 *    documentation and/or other materials provided with the distribution.
1160 * 3. Neither the name of the University nor the names of its contributors
1161 *    may be used to endorse or promote products derived from this software
1162 *    without specific prior written permission.
1163 *
1164 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1165 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1166 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1167 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
1168 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1169 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1170 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1171 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1172 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1173 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1174 * SUCH DAMAGE.
1175 *
1176 *      @(#)regfree.c   8.3 (Berkeley) 3/20/94
1177 */
1178
1179The preceding notice is from src/missing/regfree.c in `file`.
1180
1181
1182
1183/*-
1184 * Copyright (c) 1990, 1993
1185 *      The Regents of the University of California.  All rights reserved.
1186 *
1187 * This code is derived from software contributed to Berkeley by
1188 * Chris Torek.
1189 *
1190 * Redistribution and use in source and binary forms, with or without
1191 * modification, are permitted provided that the following conditions
1192 * are met:
1193 * 1. Redistributions of source code must retain the above copyright
1194 *    notice, this list of conditions and the following disclaimer.
1195 * 2. Redistributions in binary form must reproduce the above copyright
1196 *    notice, this list of conditions and the following disclaimer in the
1197 *    documentation and/or other materials provided with the distribution.
1198 * 3. Neither the name of the University nor the names of its contributors
1199 *    may be used to endorse or promote products derived from this software
1200 *    without specific prior written permission.
1201 *
1202 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1203 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1204 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1205 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
1206 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1207 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1208 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1209 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1210 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1211 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1212 * SUCH DAMAGE.
1213 */
1214
1215The preceding notice is from src/missing/strcasestr.c in `file`.
1216
1217
1218
1219/*
1220 * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
1221 *
1222 * Permission to use, copy, modify, and distribute this software for any
1223 * purpose with or without fee is hereby granted, provided that the above
1224 * copyright notice and this permission notice appear in all copies.
1225 *
1226 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
1227 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
1228 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
1229 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
1230 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
1231 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
1232 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1233 */
1234
1235The preceding notice is from src/missing/strlcat.c and src/missing/strlcpy.c in `file`.
1236
1237
1238
1239/*-
1240 * SPDX-License-Identifier: BSD-3-Clause
1241 *
1242 * Copyright (c) 1992, 1993, 1994 Henry Spencer.
1243 * Copyright (c) 1992, 1993, 1994
1244 *      The Regents of the University of California.  All rights reserved.
1245 *
1246 * This code is derived from software contributed to Berkeley by
1247 * Henry Spencer.
1248 *
1249 * Redistribution and use in source and binary forms, with or without
1250 * modification, are permitted provided that the following conditions
1251 * are met:
1252 * 1. Redistributions of source code must retain the above copyright
1253 *    notice, this list of conditions and the following disclaimer.
1254 * 2. Redistributions in binary form must reproduce the above copyright
1255 *    notice, this list of conditions and the following disclaimer in the
1256 *    documentation and/or other materials provided with the distribution.
1257 * 3. Neither the name of the University nor the names of its contributors
1258 *    may be used to endorse or promote products derived from this software
1259 *    without specific prior written permission.
1260 *
1261 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1262 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1263 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1264 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
1265 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1266 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1267 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1268 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1269 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1270 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1271 * SUCH DAMAGE.
1272 *
1273 *      @(#)utils.h     8.3 (Berkeley) 3/20/94
1274 * $FreeBSD: head/lib/libc/regex/utils.h 341838 2018-12-12 04:23:00Z yuripv $
1275 */
1276
1277The preceding notice is from src/missing/utils.h in `file`.
1278
1279
1280
1281/*-
1282 * Copyright (c) 2008, 2016 Christos Zoulas
1283 * All rights reserved.
1284 *
1285 * Redistribution and use in source and binary forms, with or without
1286 * modification, are permitted provided that the following conditions
1287 * are met:
1288 * 1. Redistributions of source code must retain the above copyright
1289 *    notice, this list of conditions and the following disclaimer.
1290 * 2. Redistributions in binary form must reproduce the above copyright
1291 *    notice, this list of conditions and the following disclaimer in the
1292 *    documentation and/or other materials provided with the distribution.
1293 *
1294 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
1295 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
1296 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
1297 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
1298 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
1299 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
1300 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
1301 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
1302 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1303 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
1304 * POSSIBILITY OF SUCH DAMAGE.
1305 */
1306
1307The preceding notice is from src/readcdf.c in `file`.
1308
1309
1310
1311/*-
1312 * Copyright (c) 1992 Henry Spencer.
1313 * Copyright (c) 1992, 1993
1314 *      The Regents of the University of California.  All rights reserved.
1315 *
1316 * This code is derived from software contributed to Berkeley by
1317 * Henry Spencer of the University of Toronto.
1318 *
1319 * Redistribution and use in source and binary forms, with or without
1320 * modification, are permitted provided that the following conditions
1321 * are met:
1322 * 1. Redistributions of source code must retain the above copyright
1323 *    notice, this list of conditions and the following disclaimer.
1324 * 2. Redistributions in binary form must reproduce the above copyright
1325 *    notice, this list of conditions and the following disclaimer in the
1326 *    documentation and/or other materials provided with the distribution.
1327 * 3. Neither the name of the University nor the names of its contributors
1328 *    may be used to endorse or promote products derived from this software
1329 *    without specific prior written permission.
1330 *
1331 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1332 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1333 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1334 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
1335 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1336 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1337 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1338 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1339 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1340 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1341 * SUCH DAMAGE.
1342 *
1343 *      @(#)regex.h     8.2 (Berkeley) 1/3/94
1344 * $FreeBSD: src/include/regex.h,v 1.12 2010/02/16 19:39:50 imp Exp $
1345 */
1346
1347The preceding notice is from src/regex-bsd.h in `file`.
1348*/
1349/*
1350
1351Text of LICENSE from DROID:
1352
1353Copyright (c) 2016, The National Archives <pronom@nationalarchives.gov.uk>
1354All rights reserved.
1355
1356Redistribution and use in source and binary forms, with or without
1357modification, are permitted provided that the following
1358conditions are met:
1359
1360 * Redistributions of source code must retain the above copyright
1361   notice, this list of conditions and the following disclaimer.
1362
1363 * Redistributions in binary form must reproduce the above copyright
1364   notice, this list of conditions and the following disclaimer in the
1365   documentation and/or other materials provided with the distribution.
1366
1367 * Neither the name of the The National Archives nor the
1368   names of its contributors may be used to endorse or promote products
1369   derived from this software without specific prior written permission.
1370
1371THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1372AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1373IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
1374PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
1375CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
1376EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
1377PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
1378PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
1379LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
1380NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
1381SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1382*/
1383
1384/*
1385
1386Text of LICENSE from fileid:
1387
1388The MIT License (MIT)
1389
1390Copyright (c) 2015 David B Heise
1391
1392Permission is hereby granted, free of charge, to any person obtaining a copy of
1393this software and associated documentation files (the "Software"), to deal in
1394the Software without restriction, including without limitation the rights to
1395use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
1396the Software, and to permit persons to whom the Software is furnished to do so,
1397subject to the following conditions:
1398
1399The above copyright notice and this permission notice shall be included in all
1400copies or substantial portions of the Software.
1401
1402THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1403IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
1404FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
1405COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
1406IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
1407CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1408
1409
1410*/
1411
1412/*
1413Text of LICENSE from binwalk:
1414
1415
1416MIT License
1417
1418Copyright (c) 2024 devttys0
1419
1420Permission is hereby granted, free of charge, to any person obtaining a copy
1421of this software and associated documentation files (the "Software"), to deal
1422in the Software without restriction, including without limitation the rights
1423to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1424copies of the Software, and to permit persons to whom the Software is
1425furnished to do so, subject to the following conditions:
1426
1427The above copyright notice and this permission notice shall be included in all
1428copies or substantial portions of the Software.
1429
1430THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1431IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1432FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1433AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1434LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1435OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1436SOFTWARE.
1437
1438*/
1439
1440/*
1441Text of LICENSE from polyfile:
1442
1443
1444                                 Apache License
1445                           Version 2.0, January 2004
1446                        http://www.apache.org/licenses/
1447
1448   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1449
1450   1. Definitions.
1451
1452      "License" shall mean the terms and conditions for use, reproduction,
1453      and distribution as defined by Sections 1 through 9 of this document.
1454
1455      "Licensor" shall mean the copyright owner or entity authorized by
1456      the copyright owner that is granting the License.
1457
1458      "Legal Entity" shall mean the union of the acting entity and all
1459      other entities that control, are controlled by, or are under common
1460      control with that entity. For the purposes of this definition,
1461      "control" means (i) the power, direct or indirect, to cause the
1462      direction or management of such entity, whether by contract or
1463      otherwise, or (ii) ownership of fifty percent (50%) or more of the
1464      outstanding shares, or (iii) beneficial ownership of such entity.
1465
1466      "You" (or "Your") shall mean an individual or Legal Entity
1467      exercising permissions granted by this License.
1468
1469      "Source" form shall mean the preferred form for making modifications,
1470      including but not limited to software source code, documentation
1471      source, and configuration files.
1472
1473      "Object" form shall mean any form resulting from mechanical
1474      transformation or translation of a Source form, including but
1475      not limited to compiled object code, generated documentation,
1476      and conversions to other media types.
1477
1478      "Work" shall mean the work of authorship, whether in Source or
1479      Object form, made available under the License, as indicated by a
1480      copyright notice that is included in or attached to the work
1481      (an example is provided in the Appendix below).
1482
1483      "Derivative Works" shall mean any work, whether in Source or Object
1484      form, that is based on (or derived from) the Work and for which the
1485      editorial revisions, annotations, elaborations, or other modifications
1486      represent, as a whole, an original work of authorship. For the purposes
1487      of this License, Derivative Works shall not include works that remain
1488      separable from, or merely link (or bind by name) to the interfaces of,
1489      the Work and Derivative Works thereof.
1490
1491      "Contribution" shall mean any work of authorship, including
1492      the original version of the Work and any modifications or additions
1493      to that Work or Derivative Works thereof, that is intentionally
1494      submitted to Licensor for inclusion in the Work by the copyright owner
1495      or by an individual or Legal Entity authorized to submit on behalf of
1496      the copyright owner. For the purposes of this definition, "submitted"
1497      means any form of electronic, verbal, or written communication sent
1498      to the Licensor or its representatives, including but not limited to
1499      communication on electronic mailing lists, source code control systems,
1500      and issue tracking systems that are managed by, or on behalf of, the
1501      Licensor for the purpose of discussing and improving the Work, but
1502      excluding communication that is conspicuously marked or otherwise
1503      designated in writing by the copyright owner as "Not a Contribution."
1504
1505      "Contributor" shall mean Licensor and any individual or Legal Entity
1506      on behalf of whom a Contribution has been received by Licensor and
1507      subsequently incorporated within the Work.
1508
1509   2. Grant of Copyright License. Subject to the terms and conditions of
1510      this License, each Contributor hereby grants to You a perpetual,
1511      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
1512      copyright license to reproduce, prepare Derivative Works of,
1513      publicly display, publicly perform, sublicense, and distribute the
1514      Work and such Derivative Works in Source or Object form.
1515
1516   3. Grant of Patent License. Subject to the terms and conditions of
1517      this License, each Contributor hereby grants to You a perpetual,
1518      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
1519      (except as stated in this section) patent license to make, have made,
1520      use, offer to sell, sell, import, and otherwise transfer the Work,
1521      where such license applies only to those patent claims licensable
1522      by such Contributor that are necessarily infringed by their
1523      Contribution(s) alone or by combination of their Contribution(s)
1524      with the Work to which such Contribution(s) was submitted. If You
1525      institute patent litigation against any entity (including a
1526      cross-claim or counterclaim in a lawsuit) alleging that the Work
1527      or a Contribution incorporated within the Work constitutes direct
1528      or contributory patent infringement, then any patent licenses
1529      granted to You under this License for that Work shall terminate
1530      as of the date such litigation is filed.
1531
1532   4. Redistribution. You may reproduce and distribute copies of the
1533      Work or Derivative Works thereof in any medium, with or without
1534      modifications, and in Source or Object form, provided that You
1535      meet the following conditions:
1536
1537      (a) You must give any other recipients of the Work or
1538          Derivative Works a copy of this License; and
1539
1540      (b) You must cause any modified files to carry prominent notices
1541          stating that You changed the files; and
1542
1543      (c) You must retain, in the Source form of any Derivative Works
1544          that You distribute, all copyright, patent, trademark, and
1545          attribution notices from the Source form of the Work,
1546          excluding those notices that do not pertain to any part of
1547          the Derivative Works; and
1548
1549      (d) If the Work includes a "NOTICE" text file as part of its
1550          distribution, then any Derivative Works that You distribute must
1551          include a readable copy of the attribution notices contained
1552          within such NOTICE file, excluding those notices that do not
1553          pertain to any part of the Derivative Works, in at least one
1554          of the following places: within a NOTICE text file distributed
1555          as part of the Derivative Works; within the Source form or
1556          documentation, if provided along with the Derivative Works; or,
1557          within a display generated by the Derivative Works, if and
1558          wherever such third-party notices normally appear. The contents
1559          of the NOTICE file are for informational purposes only and
1560          do not modify the License. You may add Your own attribution
1561          notices within Derivative Works that You distribute, alongside
1562          or as an addendum to the NOTICE text from the Work, provided
1563          that such additional attribution notices cannot be construed
1564          as modifying the License.
1565
1566      You may add Your own copyright statement to Your modifications and
1567      may provide additional or different license terms and conditions
1568      for use, reproduction, or distribution of Your modifications, or
1569      for any such Derivative Works as a whole, provided Your use,
1570      reproduction, and distribution of the Work otherwise complies with
1571      the conditions stated in this License.
1572
1573   5. Submission of Contributions. Unless You explicitly state otherwise,
1574      any Contribution intentionally submitted for inclusion in the Work
1575      by You to the Licensor shall be under the terms and conditions of
1576      this License, without any additional terms or conditions.
1577      Notwithstanding the above, nothing herein shall supersede or modify
1578      the terms of any separate license agreement you may have executed
1579      with Licensor regarding such Contributions.
1580
1581   6. Trademarks. This License does not grant permission to use the trade
1582      names, trademarks, service marks, or product names of the Licensor,
1583      except as required for reasonable and customary use in describing the
1584      origin of the Work and reproducing the content of the NOTICE file.
1585
1586   7. Disclaimer of Warranty. Unless required by applicable law or
1587      agreed to in writing, Licensor provides the Work (and each
1588      Contributor provides its Contributions) on an "AS IS" BASIS,
1589      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
1590      implied, including, without limitation, any warranties or conditions
1591      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
1592      PARTICULAR PURPOSE. You are solely responsible for determining the
1593      appropriateness of using or redistributing the Work and assume any
1594      risks associated with Your exercise of permissions under this License.
1595
1596   8. Limitation of Liability. In no event and under no legal theory,
1597      whether in tort (including negligence), contract, or otherwise,
1598      unless required by applicable law (such as deliberate and grossly
1599      negligent acts) or agreed to in writing, shall any Contributor be
1600      liable to You for damages, including any direct, indirect, special,
1601      incidental, or consequential damages of any character arising as a
1602      result of this License or out of the use or inability to use the
1603      Work (including but not limited to damages for loss of goodwill,
1604      work stoppage, computer failure or malfunction, or any and all
1605      other commercial damages or losses), even if such Contributor
1606      has been advised of the possibility of such damages.
1607
1608   9. Accepting Warranty or Additional Liability. While redistributing
1609      the Work or Derivative Works thereof, You may choose to offer,
1610      and charge a fee for, acceptance of support, warranty, indemnity,
1611      or other liability obligations and/or rights consistent with this
1612      License. However, in accepting such obligations, You may act only
1613      on Your own behalf and on Your sole responsibility, not on behalf
1614      of any other Contributor, and only if You agree to indemnify,
1615      defend, and hold each Contributor harmless for any liability
1616      incurred by, or claims asserted against, such Contributor by reason
1617      of your accepting any such warranty or additional liability.
1618
1619   END OF TERMS AND CONDITIONS
1620
1621   APPENDIX: How to apply the Apache License to your work.
1622
1623      To apply the Apache License to your work, attach the following
1624      boilerplate notice, with the fields enclosed by brackets "[]"
1625      replaced with your own identifying information. (Don't include
1626      the brackets!)  The text should be enclosed in the appropriate
1627      comment syntax for the file format. We also recommend that a
1628      file or class name and description of purpose be included on the
1629      same "printed page" as the copyright notice for easier
1630      identification within third-party archives.
1631
1632   Copyright [yyyy] [name of copyright owner]
1633
1634   Licensed under the Apache License, Version 2.0 (the "License");
1635   you may not use this file except in compliance with the License.
1636   You may obtain a copy of the License at
1637
1638       http://www.apache.org/licenses/LICENSE-2.0
1639
1640   Unless required by applicable law or agreed to in writing, software
1641   distributed under the License is distributed on an "AS IS" BASIS,
1642   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1643   See the License for the specific language governing permissions and
1644   limitations under the License.
1645
1646*/