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