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