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