ctb_formats_detection/extra_rules.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//! Detection of small specialized formats including IP address strings,
446//! checksums, UUIDs, mathematical expressions/relations, and base numerals.
447
448#[allow(
449 unused_imports,
450 clippy::wildcard_imports,
451 reason = "Standard workspace module prelude"
452)]
453use crate::utilities::*;
454
455use crate::mime_derivation::FORMAT_CATALOG;
456use crate::types::{
457 ConfidenceTier, DetectionCandidate, DetectionEvidence, DetectionHint,
458};
459use ctb_utilities::FormatId;
460
461/// Evaluates small textual sources to produce candidate classifications for
462/// IP addresses, UUIDs, checksums, math expressions/relations, and base numerals.
463#[must_use]
464pub fn detect_small_format_candidates(
465 sample: &[u8],
466 total_len: Option<u64>,
467 hint: Option<&DetectionHint>,
468) -> Vec<DetectionCandidate> {
469 // Only inspect samples that are valid text and within reasonable size bounds
470 // Reason for fallback: if conversion fails, default to 0
471 let sample_len = u64::try_from(sample.len()).unwrap_or(0);
472 // Reason for fallback: if total length is unspecified, use sample length to bound inspection size
473 let max_inspect_len = total_len.unwrap_or(sample_len);
474 if max_inspect_len > 65_536 {
475 return Vec::new();
476 }
477
478 let Ok(sample_str) = std::str::from_utf8(sample) else {
479 return Vec::new();
480 };
481
482 let trimmed = sample_str.trim();
483 if trimmed.is_empty() {
484 return Vec::new();
485 }
486
487 let mut candidates = Vec::new();
488
489 // 1. UUID detection (via ctb-formats-uuid)
490 let mut has_uuid_hex32 = false;
491 if let Some(uuid_det) = ctb_formats_uuid::detect_uuid_format(trimmed) {
492 let fmt = uuid_det.format_id;
493 let mapping = FORMAT_CATALOG.lookup_ident(fmt.ident());
494 let dc_id = mapping.map(|m| m.dc_id);
495 let mime = mapping.and_then(|m| m.mime_types.first().cloned());
496 let mut score = if fmt == FormatId::UuidHex32 {
497 80u32
498 } else {
499 90u32
500 };
501 let mut evidence = vec![DetectionEvidence::CtbRule {
502 description: uuid_det.description.clone(),
503 score,
504 }];
505
506 if let Some(h) = hint {
507 if let Some(exp_cat) = h.expected_category {
508 if fmt.category() == exp_cat {
509 score = score.saturating_add(20);
510 evidence.push(DetectionEvidence::CategoryMatch {
511 category: exp_cat,
512 score: 20,
513 });
514 }
515 }
516 }
517
518 candidates.push(DetectionCandidate {
519 format_id: Some(fmt),
520 dc_id,
521 mime,
522 description: uuid_det.description,
523 confidence: if score >= 85 {
524 ConfidenceTier::HighestConfidence
525 } else {
526 ConfidenceTier::Strong
527 },
528 score,
529 evidence,
530 chain_layers: None,
531 });
532
533 if fmt != FormatId::UuidHex32 {
534 return candidates;
535 }
536 has_uuid_hex32 = true;
537 }
538
539 // 2. URI and URI Scheme/Protocol detection (via ctb-formats-uri)
540 if let Ok(Some(uri_det)) = ctb_formats_uri::detect_uri(trimmed) {
541 let fmt = uri_det.format_id;
542 let mapping = FORMAT_CATALOG.lookup_ident(fmt.ident());
543 let dc_id = mapping.map(|m| m.dc_id);
544 let mime = mapping.and_then(|m| m.mime_types.first().cloned());
545 let mut score = if uri_det.is_scheme_only { 80u32 } else { 85u32 };
546 let mut evidence = vec![DetectionEvidence::CtbRule {
547 description: uri_det.description.clone(),
548 score,
549 }];
550
551 if let Some(h) = hint {
552 if let Some(exp_cat) = h.expected_category {
553 if fmt.category() == exp_cat {
554 score = score.saturating_add(20);
555 evidence.push(DetectionEvidence::CategoryMatch {
556 category: exp_cat,
557 score: 20,
558 });
559 }
560 }
561 }
562
563 candidates.push(DetectionCandidate {
564 format_id: Some(fmt),
565 dc_id,
566 mime,
567 description: uri_det.description,
568 confidence: if score >= 85 {
569 ConfidenceTier::HighestConfidence
570 } else {
571 ConfidenceTier::Strong
572 },
573 score,
574 evidence,
575 chain_layers: None,
576 });
577 return candidates;
578 }
579
580 // 3. Apple Uniform Type Identifier (UTI) detection (via ctb-formats-apple-types)
581 if let Some(uti_det) = ctb_formats_apple_types::detect_apple_uti(trimmed) {
582 if let Some(mapping) = FORMAT_CATALOG.lookup_apple_uti(&uti_det.uti) {
583 let fmt = mapping.format_id;
584 let mut score = 90u32;
585 let mut evidence = vec![DetectionEvidence::CtbRule {
586 description: uti_det.description.clone(),
587 score: 90,
588 }];
589
590 if let (Some(h), Some(fid)) = (hint, fmt) {
591 if let Some(exp_cat) = h.expected_category {
592 if fid.category() == exp_cat {
593 score = score.saturating_add(20);
594 evidence.push(DetectionEvidence::CategoryMatch {
595 category: exp_cat,
596 score: 20,
597 });
598 }
599 }
600 }
601
602 candidates.push(DetectionCandidate {
603 format_id: fmt,
604 dc_id: Some(mapping.dc_id),
605 mime: mapping.mime_types.first().cloned(),
606 description: uti_det.description,
607 confidence: ConfidenceTier::HighestConfidence,
608 score,
609 evidence,
610 chain_layers: None,
611 });
612 return candidates;
613 }
614 }
615
616 // 4. MIME type string detection (via ctb-formats-mime)
617 if let Some(mime_det) = ctb_formats_mime::parse_mime_type(trimmed) {
618 if let Some(mapping) = FORMAT_CATALOG.lookup_mime(&mime_det.media_type)
619 {
620 let fmt = mapping.format_id;
621 let mut score = 90u32;
622 let mut evidence = vec![DetectionEvidence::CtbRule {
623 description: mime_det.description.clone(),
624 score: 90,
625 }];
626
627 if let (Some(h), Some(fid)) = (hint, fmt) {
628 if let Some(exp_cat) = h.expected_category {
629 if fid.category() == exp_cat {
630 score = score.saturating_add(20);
631 evidence.push(DetectionEvidence::CategoryMatch {
632 category: exp_cat,
633 score: 20,
634 });
635 }
636 }
637 }
638
639 candidates.push(DetectionCandidate {
640 format_id: fmt,
641 dc_id: Some(mapping.dc_id),
642 mime: Some(mime_det.media_type),
643 description: mime_det.description,
644 confidence: ConfidenceTier::HighestConfidence,
645 score,
646 evidence,
647 chain_layers: None,
648 });
649 return candidates;
650 }
651 }
652
653 // 5. Apple OS / Creator Type detection (via ctb-formats-apple-types)
654 if let Some(type_code_det) =
655 ctb_formats_apple_types::detect_apple_type_code(trimmed)
656 {
657 if let Some(mapping) =
658 FORMAT_CATALOG.lookup_apple_type_code(&type_code_det.code)
659 {
660 let fmt = mapping.format_id;
661 let mut score = 85u32;
662 let mut evidence = vec![DetectionEvidence::CtbRule {
663 description: type_code_det.description.clone(),
664 score: 85,
665 }];
666
667 if let (Some(h), Some(fid)) = (hint, fmt) {
668 if let Some(exp_cat) = h.expected_category {
669 if fid.category() == exp_cat {
670 score = score.saturating_add(20);
671 evidence.push(DetectionEvidence::CategoryMatch {
672 category: exp_cat,
673 score: 20,
674 });
675 }
676 }
677 }
678
679 candidates.push(DetectionCandidate {
680 format_id: fmt,
681 dc_id: Some(mapping.dc_id),
682 mime: mapping.mime_types.first().cloned(),
683 description: type_code_det.description,
684 confidence: ConfidenceTier::HighestConfidence,
685 score,
686 evidence,
687 chain_layers: None,
688 });
689 return candidates;
690 }
691 }
692
693 // 6. Numeric formats check (prioritize decimal integer and prefixed base numerals over 8-char CRC32)
694 let is_prefixed_numeral = trimmed.starts_with("0x")
695 || trimmed.starts_with("0X")
696 || trimmed.starts_with("0b")
697 || trimmed.starts_with("0B")
698 || trimmed.starts_with("0o")
699 || trimmed.starts_with("0O");
700 if is_prefixed_numeral || trimmed.bytes().all(|b| b.is_ascii_digit()) {
701 if let Some(num_det) = ctb_formats_math::detect_numeric_format(trimmed)
702 {
703 let fmt = num_det.format_id;
704 let mapping = FORMAT_CATALOG.lookup_ident(fmt.ident());
705 let dc_id = mapping.map(|m| m.dc_id);
706 let mime = mapping.and_then(|m| m.mime_types.first().cloned());
707 let mut score = 85u32;
708 let mut evidence = vec![DetectionEvidence::CtbRule {
709 description: num_det.description.clone(),
710 score: 85,
711 }];
712
713 if let Some(h) = hint {
714 if let Some(exp_cat) = h.expected_category {
715 if fmt.category() == exp_cat {
716 score = score.saturating_add(20);
717 evidence.push(DetectionEvidence::CategoryMatch {
718 category: exp_cat,
719 score: 20,
720 });
721 }
722 }
723 }
724
725 candidates.push(DetectionCandidate {
726 format_id: Some(fmt),
727 dc_id,
728 mime,
729 description: num_det.description,
730 confidence: ConfidenceTier::HighestConfidence,
731 score,
732 evidence,
733 chain_layers: None,
734 });
735 return candidates;
736 }
737 }
738
739 // 7. IP address detection (via ctb-formats-ipaddr)
740 if let Some(ip_det) = ctb_formats_ipaddr::detect_ip_format(trimmed) {
741 let fmt = ip_det.format_id;
742 let mapping = FORMAT_CATALOG.lookup_ident(fmt.ident());
743 let dc_id = mapping.map(|m| m.dc_id);
744 let mime = mapping.and_then(|m| m.mime_types.first().cloned());
745 let mut score = 90u32;
746 let mut evidence = vec![DetectionEvidence::CtbRule {
747 description: ip_det.description.clone(),
748 score: 90,
749 }];
750
751 if let Some(h) = hint {
752 if let Some(exp_cat) = h.expected_category {
753 if fmt.category() == exp_cat {
754 score = score.saturating_add(20);
755 evidence.push(DetectionEvidence::CategoryMatch {
756 category: exp_cat,
757 score: 20,
758 });
759 }
760 }
761 }
762
763 candidates.push(DetectionCandidate {
764 format_id: Some(fmt),
765 dc_id,
766 mime,
767 description: ip_det.description,
768 confidence: ConfidenceTier::HighestConfidence,
769 score,
770 evidence,
771 chain_layers: None,
772 });
773 return candidates;
774 }
775
776 // 8. Checksum detection (via ctb-formats-checksum)
777 if let Some(csum_det) = ctb_formats_checksum::detect_checksum(trimmed) {
778 let fmt = csum_det.format_id;
779 let mapping = FORMAT_CATALOG.lookup_ident(fmt.ident());
780 let dc_id = mapping.map(|m| m.dc_id);
781 let mime = mapping.and_then(|m| m.mime_types.first().cloned());
782 let base_score = if csum_det.is_manifest {
783 85u32
784 } else if has_uuid_hex32 {
785 80u32
786 } else {
787 85u32
788 };
789 let mut score = base_score;
790 let mut evidence = vec![DetectionEvidence::CtbRule {
791 description: csum_det.description.clone(),
792 score: base_score,
793 }];
794
795 if let Some(h) = hint {
796 if let Some(exp_cat) = h.expected_category {
797 if fmt.category() == exp_cat {
798 score = score.saturating_add(20);
799 evidence.push(DetectionEvidence::CategoryMatch {
800 category: exp_cat,
801 score: 20,
802 });
803 }
804 }
805 }
806
807 let confidence = if score >= 85 {
808 ConfidenceTier::HighestConfidence
809 } else {
810 ConfidenceTier::Strong
811 };
812
813 candidates.push(DetectionCandidate {
814 format_id: Some(fmt),
815 dc_id,
816 mime,
817 description: csum_det.description,
818 confidence,
819 score,
820 evidence,
821 chain_layers: None,
822 });
823 if !has_uuid_hex32 {
824 return candidates;
825 }
826 }
827
828 if has_uuid_hex32 {
829 return candidates;
830 }
831
832 // 9. Mathematical expressions and relations (via ctb-formats-math)
833 if let Some(math_det) = ctb_formats_math::detect_math_format(trimmed) {
834 let fmt = math_det.format_id;
835 let mapping = FORMAT_CATALOG.lookup_ident(fmt.ident());
836 let dc_id = mapping.map(|m| m.dc_id);
837 let mime = mapping.and_then(|m| m.mime_types.first().cloned());
838 let mut score = 85u32;
839 let mut evidence = vec![DetectionEvidence::CtbRule {
840 description: math_det.description.clone(),
841 score: 85,
842 }];
843
844 if let Some(h) = hint {
845 if let Some(exp_cat) = h.expected_category {
846 if fmt.category() == exp_cat {
847 score = score.saturating_add(20);
848 evidence.push(DetectionEvidence::CategoryMatch {
849 category: exp_cat,
850 score: 20,
851 });
852 }
853 }
854 }
855
856 candidates.push(DetectionCandidate {
857 format_id: Some(fmt),
858 dc_id,
859 mime,
860 description: math_det.description,
861 confidence: ConfidenceTier::HighestConfidence,
862 score,
863 evidence,
864 chain_layers: None,
865 });
866 return candidates;
867 }
868
869 // 10. Numeric and base numeral formats (via ctb-formats-math)
870 if let Some(num_det) = ctb_formats_math::detect_numeric_format(trimmed) {
871 let fmt = num_det.format_id;
872 let mapping = FORMAT_CATALOG.lookup_ident(fmt.ident());
873 let dc_id = mapping.map(|m| m.dc_id);
874 let mime = mapping.and_then(|m| m.mime_types.first().cloned());
875 let mut score = 75u32;
876 let mut evidence = vec![DetectionEvidence::CtbRule {
877 description: num_det.description.clone(),
878 score: 75,
879 }];
880
881 if let Some(h) = hint {
882 if let Some(exp_cat) = h.expected_category {
883 if fmt.category() == exp_cat {
884 score = score.saturating_add(20);
885 evidence.push(DetectionEvidence::CategoryMatch {
886 category: exp_cat,
887 score: 20,
888 });
889 }
890 }
891 }
892
893 candidates.push(DetectionCandidate {
894 format_id: Some(fmt),
895 dc_id,
896 mime,
897 description: num_det.description,
898 confidence: ConfidenceTier::Strong,
899 score,
900 evidence,
901 chain_layers: None,
902 });
903 return candidates;
904 }
905
906 candidates
907}
908
909/// Detects custom text document formats (such as DcText with `@<token>@` tokens
910/// or `DcIntegerList` / Dcal integer lists) within `sample`.
911///
912/// In compat mode (`hint.compat == true`), this returns `None` so that output
913/// strictly matches upstream UNIX `file`.
914#[must_use]
915pub fn detect_custom_text_format_candidate(
916 sample: &[u8],
917 hint: Option<&DetectionHint>,
918) -> Option<DetectionCandidate> {
919 if hint.is_some_and(|h| h.compat) {
920 return None;
921 }
922
923 let Ok(sample_str) = std::str::from_utf8(sample) else {
924 return None;
925 };
926
927 // 1. Check for @...@ token document formats (DcText, Dcts, CdceLegacy, Cdce)
928 if sample_str.contains('@') {
929 let parts: Vec<&str> = sample_str.split('@').collect();
930 if parts.len() >= 3 {
931 let mut has_dctext_token = false;
932 let mut has_dcts_prefix_token = false;
933 let mut has_legacy_cdce_token = false;
934
935 let closed_parts_end = parts.len().saturating_sub(1);
936 for (idx, part) in parts.iter().enumerate() {
937 if idx < closed_parts_end
938 && idx.checked_rem(2) == Some(1)
939 && !part.is_empty()
940 {
941 if part.chars().all(|c| c.is_ascii_digit()) {
942 has_dctext_token = true;
943 if let Ok(val) = part.parse::<u32>()
944 && (1..=12).contains(&val)
945 {
946 has_legacy_cdce_token = true;
947 }
948 } else if part.starts_with('L')
949 && part.len() > 1
950 && part.get(1..).is_some_and(|s| {
951 s.chars().all(|c| c.is_ascii_digit())
952 })
953 {
954 has_dctext_token = true;
955 } else if (part.starts_with('l')
956 && part.len() > 1
957 && part.get(1..).is_some_and(|s| {
958 s.chars().all(|c| c.is_ascii_digit())
959 }))
960 || ((part.starts_with('u') || part.starts_with('U'))
961 && part.len() > 1
962 && part.get(1..).is_some_and(|s| {
963 s.chars().all(|c| c.is_ascii_hexdigit())
964 }))
965 || ((part.starts_with('f') || part.starts_with('F'))
966 && part.len() > 1
967 && part.get(1..).is_some_and(|s| {
968 s.chars().all(|c| c.is_ascii_digit())
969 }))
970 {
971 has_dctext_token = true;
972 has_dcts_prefix_token = true;
973 }
974 }
975 }
976
977 if has_dctext_token {
978 let hint_ext = hint.and_then(|h| {
979 h.extension.as_deref().or_else(|| {
980 h.filename.as_deref().and_then(|f| {
981 f.rsplit(['/', '\\'])
982 .next()?
983 .rsplit_once('.')
984 .map(|(_, ext)| ext)
985 })
986 })
987 });
988 let fmt = if hint_ext
989 .is_some_and(|ext| ext.eq_ignore_ascii_case("legacy_cdce"))
990 && has_legacy_cdce_token
991 {
992 FormatId::CdceLegacy
993 } else if hint_ext
994 .is_some_and(|ext| ext.eq_ignore_ascii_case("cdce"))
995 {
996 FormatId::Cdce
997 } else if hint_ext
998 .is_some_and(|ext| ext.eq_ignore_ascii_case("edceditable"))
999 && !has_dcts_prefix_token
1000 {
1001 FormatId::EdfEditableDcList
1002 } else if hint_ext
1003 .is_some_and(|ext| ext.eq_ignore_ascii_case("dcts"))
1004 || has_dcts_prefix_token
1005 {
1006 FormatId::Dcts
1007 } else {
1008 FormatId::DcText
1009 };
1010
1011 let mapping = FORMAT_CATALOG.lookup_ident(fmt.ident());
1012 let dc_id = mapping.map(|m| m.dc_id);
1013 let mime = mapping
1014 .and_then(|m| m.mime_types.first().cloned())
1015 .or_else(|| Some("text/plain".to_string()));
1016 // Reason for fallback: unmapped format identifier falls back to standard DcText document label
1017 let description = mapping.map_or_else(
1018 || "DcText document".to_string(),
1019 |m| format!("{} document", m.label),
1020 );
1021 let mut score = 85u32;
1022 let mut evidence = vec![DetectionEvidence::CtbRule {
1023 description: format!("{} @token@ document", fmt.ident()),
1024 score: 85,
1025 }];
1026
1027 if let Some(h) = hint {
1028 if let Some(exp_cat) = h.expected_category {
1029 if fmt.category() == exp_cat {
1030 score = score.saturating_add(20);
1031 evidence.push(DetectionEvidence::CategoryMatch {
1032 category: exp_cat,
1033 score: 20,
1034 });
1035 }
1036 }
1037 }
1038
1039 return Some(DetectionCandidate {
1040 format_id: Some(fmt),
1041 dc_id,
1042 mime,
1043 description,
1044 confidence: ConfidenceTier::Strong,
1045 score,
1046 evidence,
1047 chain_layers: None,
1048 });
1049 }
1050 }
1051 }
1052
1053 None
1054}
1055
1056#[cfg(test)]
1057#[allow(
1058 clippy::panic,
1059 clippy::expect_used,
1060 clippy::unwrap_used,
1061 clippy::unwrap_in_result,
1062 clippy::panic_in_result_fn,
1063 clippy::indexing_slicing,
1064 clippy::arithmetic_side_effects,
1065 reason = "Standard repository test boilerplate"
1066)]
1067mod tests {
1068 use super::*;
1069
1070 #[crate::ctb_test]
1071 fn test_detect_small_format_ip() {
1072 let cands = detect_small_format_candidates(b"192.168.1.1", None, None);
1073 assert!(!cands.is_empty());
1074 assert_eq!(cands[0].format_id, Some(FormatId::IpV4String));
1075
1076 let cands6 = detect_small_format_candidates(b"::1", None, None);
1077 assert!(!cands6.is_empty());
1078 assert_eq!(cands6[0].format_id, Some(FormatId::IpV6String));
1079 }
1080
1081 #[crate::ctb_test]
1082 fn test_detect_small_format_uuid() {
1083 let cands = detect_small_format_candidates(
1084 b"550e8400-e29b-41d4-a716-446655440000",
1085 None,
1086 None,
1087 );
1088 assert!(!cands.is_empty());
1089 assert_eq!(cands[0].format_id, Some(FormatId::UuidCanonical));
1090
1091 let urn = detect_small_format_candidates(
1092 b"urn:uuid:550e8400-e29b-41d4-a716-446655440000",
1093 None,
1094 None,
1095 );
1096 assert_eq!(urn[0].format_id, Some(FormatId::UuidUrn));
1097 }
1098
1099 #[crate::ctb_test]
1100 fn test_detect_small_format_checksum() {
1101 let sha256 =
1102 b"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
1103 let cands = detect_small_format_candidates(sha256, None, None);
1104 assert!(!cands.is_empty());
1105 assert_eq!(cands[0].format_id, Some(FormatId::Sha256));
1106 }
1107
1108 #[crate::ctb_test]
1109 fn test_detect_small_format_math() {
1110 let eq = detect_small_format_candidates(b"2x = 6", None, None);
1111 assert_eq!(eq[0].format_id, Some(FormatId::Equation));
1112
1113 let ineq =
1114 detect_small_format_candidates(b"x^2 + y^2 <= 1", None, None);
1115 assert_eq!(ineq[0].format_id, Some(FormatId::Inequality));
1116
1117 let approx =
1118 detect_small_format_candidates(b"1 oz ~= 28 g", None, None);
1119 assert_eq!(approx[0].format_id, Some(FormatId::Approximation));
1120
1121 let arith =
1122 detect_small_format_candidates(b"(23 mod 2) + 6", None, None);
1123 assert_eq!(arith[0].format_id, Some(FormatId::ArithmeticExpression));
1124
1125 let symb = detect_small_format_candidates(b"1 + 2x", None, None);
1126 assert_eq!(symb[0].format_id, Some(FormatId::SymbolicExpression));
1127 }
1128
1129 #[crate::ctb_test]
1130 fn test_detect_small_format_numbers() {
1131 let int_cand = detect_small_format_candidates(b"12345", None, None);
1132 assert_eq!(int_cand[0].format_id, Some(FormatId::Integer));
1133
1134 let hex_cand =
1135 detect_small_format_candidates(b"0xDEADBEEF", None, None);
1136 assert_eq!(hex_cand[0].format_id, Some(FormatId::HexadecimalNumeral));
1137 }
1138
1139 #[crate::ctb_test]
1140 fn test_detect_small_format_uri_and_scheme() {
1141 let scheme_cand = detect_small_format_candidates(b"http", None, None);
1142 assert_eq!(scheme_cand[0].format_id, Some(FormatId::UriProtocol));
1143
1144 let uri_cand = detect_small_format_candidates(
1145 b"https://collectivetoolbox.com",
1146 None,
1147 None,
1148 );
1149 assert_eq!(uri_cand[0].format_id, Some(FormatId::Uri));
1150
1151 let magnet_cand = detect_small_format_candidates(
1152 b"magnet:?xt=urn:btih:c12fe1c06bba254a9dc9f519b335aa7c1367a88a",
1153 None,
1154 None,
1155 );
1156 assert_eq!(magnet_cand[0].format_id, Some(FormatId::Magnet));
1157 }
1158
1159 #[crate::ctb_test]
1160 fn test_detect_small_format_uti_and_mime_and_creator() {
1161 let uti_cand =
1162 detect_small_format_candidates(b"com.apple.alias-file", None, None);
1163 assert_eq!(uti_cand[0].format_id, Some(FormatId::MacAlias));
1164
1165 let mime_cand =
1166 detect_small_format_candidates(b"application/json", None, None);
1167 assert_eq!(mime_cand[0].format_id, Some(FormatId::Json));
1168
1169 let creator_cand = detect_small_format_candidates(b"alis", None, None);
1170 assert_eq!(creator_cand[0].format_id, Some(FormatId::MacAlias));
1171 }
1172
1173 #[crate::ctb_test]
1174 fn test_detect_custom_text_format_dctext() {
1175 let input = b"Hello @65@ world";
1176 let cand = detect_custom_text_format_candidate(input, None)
1177 .expect("detect dctext");
1178 assert_eq!(cand.format_id, Some(FormatId::DcText));
1179
1180 let dcts_input = b"Hello @u0041@ world";
1181 let dcts_cand = detect_custom_text_format_candidate(dcts_input, None)
1182 .expect("detect dcts");
1183 assert_eq!(dcts_cand.format_id, Some(FormatId::Dcts));
1184
1185 let cdce_hint = DetectionHint {
1186 filename: Some("datetime_string.legacy_cdce".to_string()),
1187 ..Default::default()
1188 };
1189 let cdce_cand = detect_custom_text_format_candidate(
1190 b"@9@@2@1@3@@10@2012",
1191 Some(&cdce_hint),
1192 )
1193 .expect("detect legacy_cdce");
1194 assert_eq!(cdce_cand.format_id, Some(FormatId::CdceLegacy));
1195
1196 let edceditable_hint = DetectionHint {
1197 filename: Some("doc.edceditable".to_string()),
1198 ..Default::default()
1199 };
1200 let edceditable_cand = detect_custom_text_format_candidate(
1201 b"Hello @1@ World!",
1202 Some(&edceditable_hint),
1203 )
1204 .expect("detect edceditable");
1205 assert_eq!(
1206 edceditable_cand.format_id,
1207 Some(FormatId::EdfEditableDcList)
1208 );
1209
1210 let compat_hint = DetectionHint {
1211 compat: true,
1212 ..Default::default()
1213 };
1214 assert!(
1215 detect_custom_text_format_candidate(input, Some(&compat_hint))
1216 .is_none()
1217 );
1218 }
1219}
1220/*
1221/*
1222 * Adapted from: apptype.c, Written by Eberhard Mattes and put into the
1223 * file_public domain
1224 *
1225 * Notes: 1. Qualify the filename so that DosQueryAppType does not do extraneous
1226 * searches.
1227 *
1228 * 2. DosQueryAppType will return FAPPTYP_DOS on a file ending with ".com"
1229 * (other than an OS/2 exe or Win exe with this name). Eberhard Mattes
1230 * remarks Tue, 6 Apr 93: Moreover, it reports the type of the (new and very
1231 * bug ridden) Win Emacs as "OS/2 executable".
1232 *
1233 * 3. apptype() uses the filename if given, otherwise a tmp file is created with
1234 * the contents of buf. If buf is not the complete file, apptype can
1235 * incorrectly identify the exe type. The "-z" option of "file" is the reason
1236 * for this ugly code.
1237 */
1238
1239The preceding notice is from src/apptype.c in `file`.
1240
1241
1242
1243/*-
1244 * Copyright (c) 2008 Christos Zoulas
1245 * All rights reserved.
1246 *
1247 * Redistribution and use in source and binary forms, with or without
1248 * modification, are permitted provided that the following conditions
1249 * are met:
1250 * 1. Redistributions of source code must retain the above copyright
1251 * notice, this list of conditions and the following disclaimer.
1252 * 2. Redistributions in binary form must reproduce the above copyright
1253 * notice, this list of conditions and the following disclaimer in the
1254 * documentation and/or other materials provided with the distribution.
1255 *
1256 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
1257 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
1258 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
1259 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
1260 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
1261 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
1262 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
1263 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
1264 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1265 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
1266 * POSSIBILITY OF SUCH DAMAGE.
1267 */
1268
1269The preceding notice is from src/cdf.c, src/cdf.h, and src/cdf_time.c in `file`.
1270
1271
1272
1273/*-
1274 * Copyright (c) 2016 Christos Zoulas
1275 * All rights reserved.
1276 *
1277 * Redistribution and use in source and binary forms, with or without
1278 * modification, are permitted provided that the following conditions
1279 * are met:
1280 * 1. Redistributions of source code must retain the above copyright
1281 * notice, this list of conditions and the following disclaimer.
1282 * 2. Redistributions in binary form must reproduce the above copyright
1283 * notice, this list of conditions and the following disclaimer in the
1284 * documentation and/or other materials provided with the distribution.
1285 *
1286 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
1287 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
1288 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
1289 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
1290 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
1291 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
1292 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
1293 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
1294 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1295 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
1296 * POSSIBILITY OF SUCH DAMAGE.
1297 */
1298
1299The preceding notice is from src/der.c and src/der.h in `file`.
1300
1301
1302
1303/*-
1304 * Copyright (c) 2019 Christos Zoulas
1305 * All rights reserved.
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 *
1316 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
1317 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
1318 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
1319 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
1320 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
1321 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
1322 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
1323 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
1324 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1325 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
1326 * POSSIBILITY OF SUCH DAMAGE.
1327 */
1328
1329The preceding notice is from src/is_csv.c in `file`.
1330
1331
1332
1333/*-
1334 * Copyright (c) 2018 Christos Zoulas
1335 * All rights reserved.
1336 *
1337 * Redistribution and use in source and binary forms, with or without
1338 * modification, are permitted provided that the following conditions
1339 * are met:
1340 * 1. Redistributions of source code must retain the above copyright
1341 * notice, this list of conditions and the following disclaimer.
1342 * 2. Redistributions in binary form must reproduce the above copyright
1343 * notice, this list of conditions and the following disclaimer in the
1344 * documentation and/or other materials provided with the distribution.
1345 *
1346 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
1347 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
1348 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
1349 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
1350 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
1351 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
1352 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
1353 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
1354 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1355 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
1356 * POSSIBILITY OF SUCH DAMAGE.
1357 */
1358
1359The preceding notice is from src/is_json.c in `file`.
1360
1361
1362
1363/*-
1364 * Copyright (c) 2023 Christos Zoulas
1365 * All rights reserved.
1366 *
1367 * Redistribution and use in source and binary forms, with or without
1368 * modification, are permitted provided that the following conditions
1369 * are met:
1370 * 1. Redistributions of source code must retain the above copyright
1371 * notice, this list of conditions and the following disclaimer.
1372 * 2. Redistributions in binary form must reproduce the above copyright
1373 * notice, this list of conditions and the following disclaimer in the
1374 * documentation and/or other materials provided with the distribution.
1375 *
1376 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
1377 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
1378 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
1379 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
1380 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
1381 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
1382 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
1383 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
1384 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1385 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
1386 * POSSIBILITY OF SUCH DAMAGE.
1387 */
1388
1389The preceding notice is from src/is_simh.c in `file`.
1390
1391
1392
1393/*-
1394 * SPDX-License-Identifier: BSD-3-Clause
1395 *
1396 * Copyright (c) 1992, 1993, 1994 Henry Spencer.
1397 * Copyright (c) 1992, 1993, 1994
1398 * The Regents of the University of California. All rights reserved.
1399 *
1400 * This code is derived from software contributed to Berkeley by
1401 * Henry Spencer.
1402 *
1403 * Redistribution and use in source and binary forms, with or without
1404 * modification, are permitted provided that the following conditions
1405 * are met:
1406 * 1. Redistributions of source code must retain the above copyright
1407 * notice, this list of conditions and the following disclaimer.
1408 * 2. Redistributions in binary form must reproduce the above copyright
1409 * notice, this list of conditions and the following disclaimer in the
1410 * documentation and/or other materials provided with the distribution.
1411 * 3. Neither the name of the University nor the names of its contributors
1412 * may be used to endorse or promote products derived from this software
1413 * without specific prior written permission.
1414 *
1415 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1416 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1417 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1418 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
1419 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1420 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1421 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1422 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1423 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1424 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1425 * SUCH DAMAGE.
1426 *
1427 * @(#)cname.h 8.3 (Berkeley) 3/20/94
1428 * $FreeBSD: head/lib/libc/regex/cname.h 326025 2017-11-20 19:49:47Z pfg $
1429 */
1430
1431The preceding notice is from src/missing/cname.h in `file`.
1432
1433
1434
1435/*-
1436 * SPDX-License-Identifier: BSD-3-Clause
1437 *
1438 * Copyright (c) 1992, 1993, 1994 Henry Spencer.
1439 * Copyright (c) 1992, 1993, 1994
1440 * The Regents of the University of California. All rights reserved.
1441 *
1442 * This code is derived from software contributed to Berkeley by
1443 * Henry Spencer.
1444 *
1445 * Redistribution and use in source and binary forms, with or without
1446 * modification, are permitted provided that the following conditions
1447 * are met:
1448 * 1. Redistributions of source code must retain the above copyright
1449 * notice, this list of conditions and the following disclaimer.
1450 * 2. Redistributions in binary form must reproduce the above copyright
1451 * notice, this list of conditions and the following disclaimer in the
1452 * documentation and/or other materials provided with the distribution.
1453 * 3. Neither the name of the University nor the names of its contributors
1454 * may be used to endorse or promote products derived from this software
1455 * without specific prior written permission.
1456 *
1457 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1458 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1459 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1460 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
1461 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1462 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1463 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1464 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1465 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1466 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1467 * SUCH DAMAGE.
1468 *
1469 * @(#)engine.c 8.5 (Berkeley) 3/20/94
1470 */
1471
1472The preceding notice is from src/missing/engine.c in `file`.
1473
1474
1475
1476/*-
1477 * Copyright (c) 2000 The NetBSD Foundation, Inc.
1478 * All rights reserved.
1479 *
1480 * This code was contributed to The NetBSD Foundation by Allen Briggs.
1481 *
1482 * Redistribution and use in source and binary forms, with or without
1483 * modification, are permitted provided that the following conditions
1484 * are met:
1485 * 1. Redistributions of source code must retain the above copyright
1486 * notice, this list of conditions and the following disclaimer.
1487 * 2. Redistributions in binary form must reproduce the above copyright
1488 * notice, this list of conditions and the following disclaimer in the
1489 * documentation and/or other materials provided with the distribution.
1490 *
1491 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
1492 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
1493 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
1494 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
1495 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
1496 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
1497 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
1498 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
1499 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1500 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
1501 * POSSIBILITY OF SUCH DAMAGE.
1502 */
1503
1504The preceding notice is from src/missing/fmtcheck.c in `file`.
1505
1506
1507
1508/*-
1509 * Copyright (c) 2011 The NetBSD Foundation, Inc.
1510 * All rights reserved.
1511 *
1512 * This code is derived from software contributed to The NetBSD Foundation
1513 * by Christos Zoulas.
1514 *
1515 * Redistribution and use in source and binary forms, with or without
1516 * modification, are permitted provided that the following conditions
1517 * are met:
1518 * 1. Redistributions of source code must retain the above copyright
1519 * notice, this list of conditions and the following disclaimer.
1520 * 2. Redistributions in binary form must reproduce the above copyright
1521 * notice, this list of conditions and the following disclaimer in the
1522 * documentation and/or other materials provided with the distribution.
1523 *
1524 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
1525 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
1526 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
1527 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
1528 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
1529 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
1530 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
1531 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
1532 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1533 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
1534 * POSSIBILITY OF SUCH DAMAGE.
1535 */
1536
1537The preceding notice is from src/missing/getline.c in `file`.
1538
1539
1540
1541/*-
1542 * Copyright (c) 2000 The NetBSD Foundation, Inc.
1543 * All rights reserved.
1544 *
1545 * This code is derived from software contributed to The NetBSD Foundation
1546 * by Dieter Baron and Thomas Klausner.
1547 *
1548 * Redistribution and use in source and binary forms, with or without
1549 * modification, are permitted provided that the following conditions
1550 * are met:
1551 * 1. Redistributions of source code must retain the above copyright
1552 * notice, this list of conditions and the following disclaimer.
1553 * 2. Redistributions in binary form must reproduce the above copyright
1554 * notice, this list of conditions and the following disclaimer in the
1555 * documentation and/or other materials provided with the distribution.
1556 *
1557 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
1558 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
1559 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
1560 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
1561 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
1562 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
1563 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
1564 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
1565 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1566 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
1567 * POSSIBILITY OF SUCH DAMAGE.
1568 */
1569
1570The preceding notice is from src/missing/getopt_long.c and src/mygetopt.h in `file`.
1571
1572
1573
1574/*
1575 * Public domain fallback for reallocarray(3), for platforms (e.g.
1576 * AmigaOS/libnix) whose C library declares it but does not implement it.
1577 */
1578
1579The preceding notice is from src/missing/reallocarray.c in `file`.
1580
1581
1582
1583/*-
1584 * SPDX-License-Identifier: BSD-3-Clause
1585 *
1586 * Copyright (c) 1992, 1993, 1994 Henry Spencer.
1587 * Copyright (c) 1992, 1993, 1994
1588 * The Regents of the University of California. All rights reserved.
1589 *
1590 * Copyright (c) 2011 The FreeBSD Foundation
1591 * All rights reserved.
1592 * Portions of this software were developed by David Chisnall
1593 * under sponsorship from the FreeBSD Foundation.
1594 *
1595 * This code is derived from software contributed to Berkeley by
1596 * Henry Spencer.
1597 *
1598 * Redistribution and use in source and binary forms, with or without
1599 * modification, are permitted provided that the following conditions
1600 * are met:
1601 * 1. Redistributions of source code must retain the above copyright
1602 * notice, this list of conditions and the following disclaimer.
1603 * 2. Redistributions in binary form must reproduce the above copyright
1604 * notice, this list of conditions and the following disclaimer in the
1605 * documentation and/or other materials provided with the distribution.
1606 * 3. Neither the name of the University nor the names of its contributors
1607 * may be used to endorse or promote products derived from this software
1608 * without specific prior written permission.
1609 *
1610 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1611 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1612 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1613 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
1614 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1615 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1616 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1617 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1618 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1619 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1620 * SUCH DAMAGE.
1621 *
1622 * @(#)regcomp.c 8.5 (Berkeley) 3/20/94
1623 */
1624
1625The preceding notice is from src/missing/regcomp.c in `file`.
1626
1627
1628
1629/*-
1630 * SPDX-License-Identifier: BSD-3-Clause
1631 *
1632 * Copyright (c) 1992, 1993, 1994 Henry Spencer.
1633 * Copyright (c) 1992, 1993, 1994
1634 * The Regents of the University of California. All rights reserved.
1635 *
1636 * This code is derived from software contributed to Berkeley by
1637 * Henry Spencer.
1638 *
1639 * Redistribution and use in source and binary forms, with or without
1640 * modification, are permitted provided that the following conditions
1641 * are met:
1642 * 1. Redistributions of source code must retain the above copyright
1643 * notice, this list of conditions and the following disclaimer.
1644 * 2. Redistributions in binary form must reproduce the above copyright
1645 * notice, this list of conditions and the following disclaimer in the
1646 * documentation and/or other materials provided with the distribution.
1647 * 3. Neither the name of the University nor the names of its contributors
1648 * may be used to endorse or promote products derived from this software
1649 * without specific prior written permission.
1650 *
1651 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1652 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1653 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1654 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
1655 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1656 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1657 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1658 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1659 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1660 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1661 * SUCH DAMAGE.
1662 *
1663 * @(#)regerror.c 8.4 (Berkeley) 3/20/94
1664 */
1665
1666The preceding notice is from src/missing/regerror.c in `file`.
1667
1668
1669
1670$NetBSD: COPYRIGHT,v 1.5 2003/08/07 16:43:19 agc Exp $
1671
1672Copyright 1992, 1993, 1994 Henry Spencer. All rights reserved.
1673This software is not subject to any license of the American Telephone
1674and Telegraph Company or of the Regents of the University of California.
1675
1676Permission is granted to anyone to use this software for any purpose on
1677any computer system, and to alter it and redistribute it, subject
1678to the following restrictions:
1679
16801. The author is not responsible for the consequences of use of this
1681 software, no matter how awful, even if they arise from flaws in it.
1682
16832. The origin of this software must not be misrepresented, either by
1684 explicit claim or by omission. Since few users ever read sources,
1685 credits must appear in the documentation.
1686
16873. Altered versions must be plainly marked as such, and must not be
1688 misrepresented as being the original software. Since few users
1689 ever read sources, credits must appear in the documentation.
1690
16914. This notice may not be removed or altered.
1692
1693=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
1694/*-
1695 * Copyright (c) 1994
1696 * The Regents of the University of California. All rights reserved.
1697 *
1698 * Redistribution and use in source and binary forms, with or without
1699 * modification, are permitted provided that the following conditions
1700 * are met:
1701 * 1. Redistributions of source code must retain the above copyright
1702 * notice, this list of conditions and the following disclaimer.
1703 * 2. Redistributions in binary form must reproduce the above copyright
1704 * notice, this list of conditions and the following disclaimer in the
1705 * documentation and/or other materials provided with the distribution.
1706 * 3. Neither the name of the University nor the names of its contributors
1707 * may be used to endorse or promote products derived from this software
1708 * without specific prior written permission.
1709 *
1710 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1711 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1712 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1713 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
1714 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1715 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1716 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1717 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1718 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1719 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1720 * SUCH DAMAGE.
1721 *
1722 * @(#)COPYRIGHT 8.1 (Berkeley) 3/16/94
1723 */
1724
1725The preceding notice is from src/missing/REGEX-COPYRIGHT in `file`.
1726
1727
1728
1729/*-
1730 * SPDX-License-Identifier: BSD-3-Clause
1731 *
1732 * Copyright (c) 1992, 1993, 1994 Henry Spencer.
1733 * Copyright (c) 1992, 1993, 1994
1734 * The Regents of the University of California. All rights reserved.
1735 *
1736 * This code is derived from software contributed to Berkeley by
1737 * Henry Spencer.
1738 *
1739 * Redistribution and use in source and binary forms, with or without
1740 * modification, are permitted provided that the following conditions
1741 * are met:
1742 * 1. Redistributions of source code must retain the above copyright
1743 * notice, this list of conditions and the following disclaimer.
1744 * 2. Redistributions in binary form must reproduce the above copyright
1745 * notice, this list of conditions and the following disclaimer in the
1746 * documentation and/or other materials provided with the distribution.
1747 * 3. Neither the name of the University nor the names of its contributors
1748 * may be used to endorse or promote products derived from this software
1749 * without specific prior written permission.
1750 *
1751 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1752 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1753 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1754 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
1755 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1756 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1757 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1758 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1759 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1760 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1761 * SUCH DAMAGE.
1762 *
1763 * @(#)regex2.h 8.4 (Berkeley) 3/20/94
1764 * $FreeBSD: head/lib/libc/regex/regex2.h 368359 2020-12-05 03:18:48Z kevans $
1765 */
1766
1767The preceding notice is from src/missing/regex2.h in `file`.
1768
1769
1770
1771/*-
1772 * SPDX-License-Identifier: BSD-3-Clause
1773 *
1774 * Copyright (c) 1992, 1993, 1994 Henry Spencer.
1775 * Copyright (c) 1992, 1993, 1994
1776 * The Regents of the University of California. All rights reserved.
1777 *
1778 * This code is derived from software contributed to Berkeley by
1779 * Henry Spencer.
1780 *
1781 * Redistribution and use in source and binary forms, with or without
1782 * modification, are permitted provided that the following conditions
1783 * are met:
1784 * 1. Redistributions of source code must retain the above copyright
1785 * notice, this list of conditions and the following disclaimer.
1786 * 2. Redistributions in binary form must reproduce the above copyright
1787 * notice, this list of conditions and the following disclaimer in the
1788 * documentation and/or other materials provided with the distribution.
1789 * 3. Neither the name of the University nor the names of its contributors
1790 * may be used to endorse or promote products derived from this software
1791 * without specific prior written permission.
1792 *
1793 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1794 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1795 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1796 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
1797 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1798 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1799 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1800 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1801 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1802 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1803 * SUCH DAMAGE.
1804 *
1805 * @(#)regexec.c 8.3 (Berkeley) 3/20/94
1806 */
1807
1808The preceding notice is from src/missing/regexec.c in `file`.
1809
1810
1811
1812/*-
1813 * SPDX-License-Identifier: BSD-3-Clause
1814 *
1815 * Copyright (c) 1992, 1993, 1994 Henry Spencer.
1816 * Copyright (c) 1992, 1993, 1994
1817 * The Regents of the University of California. All rights reserved.
1818 *
1819 * This code is derived from software contributed to Berkeley by
1820 * Henry Spencer.
1821 *
1822 * Redistribution and use in source and binary forms, with or without
1823 * modification, are permitted provided that the following conditions
1824 * are met:
1825 * 1. Redistributions of source code must retain the above copyright
1826 * notice, this list of conditions and the following disclaimer.
1827 * 2. Redistributions in binary form must reproduce the above copyright
1828 * notice, this list of conditions and the following disclaimer in the
1829 * documentation and/or other materials provided with the distribution.
1830 * 3. Neither the name of the University nor the names of its contributors
1831 * may be used to endorse or promote products derived from this software
1832 * without specific prior written permission.
1833 *
1834 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1835 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1836 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1837 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
1838 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1839 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1840 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1841 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1842 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1843 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1844 * SUCH DAMAGE.
1845 *
1846 * @(#)regfree.c 8.3 (Berkeley) 3/20/94
1847 */
1848
1849The preceding notice is from src/missing/regfree.c in `file`.
1850
1851
1852
1853/*-
1854 * Copyright (c) 1990, 1993
1855 * The Regents of the University of California. All rights reserved.
1856 *
1857 * This code is derived from software contributed to Berkeley by
1858 * Chris Torek.
1859 *
1860 * Redistribution and use in source and binary forms, with or without
1861 * modification, are permitted provided that the following conditions
1862 * are met:
1863 * 1. Redistributions of source code must retain the above copyright
1864 * notice, this list of conditions and the following disclaimer.
1865 * 2. Redistributions in binary form must reproduce the above copyright
1866 * notice, this list of conditions and the following disclaimer in the
1867 * documentation and/or other materials provided with the distribution.
1868 * 3. Neither the name of the University nor the names of its contributors
1869 * may be used to endorse or promote products derived from this software
1870 * without specific prior written permission.
1871 *
1872 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1873 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1874 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1875 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
1876 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1877 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1878 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1879 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1880 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1881 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1882 * SUCH DAMAGE.
1883 */
1884
1885The preceding notice is from src/missing/strcasestr.c in `file`.
1886
1887
1888
1889/*
1890 * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
1891 *
1892 * Permission to use, copy, modify, and distribute this software for any
1893 * purpose with or without fee is hereby granted, provided that the above
1894 * copyright notice and this permission notice appear in all copies.
1895 *
1896 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
1897 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
1898 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
1899 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
1900 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
1901 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
1902 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1903 */
1904
1905The preceding notice is from src/missing/strlcat.c and src/missing/strlcpy.c in `file`.
1906
1907
1908
1909/*-
1910 * SPDX-License-Identifier: BSD-3-Clause
1911 *
1912 * Copyright (c) 1992, 1993, 1994 Henry Spencer.
1913 * Copyright (c) 1992, 1993, 1994
1914 * The Regents of the University of California. All rights reserved.
1915 *
1916 * This code is derived from software contributed to Berkeley by
1917 * Henry Spencer.
1918 *
1919 * Redistribution and use in source and binary forms, with or without
1920 * modification, are permitted provided that the following conditions
1921 * are met:
1922 * 1. Redistributions of source code must retain the above copyright
1923 * notice, this list of conditions and the following disclaimer.
1924 * 2. Redistributions in binary form must reproduce the above copyright
1925 * notice, this list of conditions and the following disclaimer in the
1926 * documentation and/or other materials provided with the distribution.
1927 * 3. Neither the name of the University nor the names of its contributors
1928 * may be used to endorse or promote products derived from this software
1929 * without specific prior written permission.
1930 *
1931 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1932 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1933 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1934 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
1935 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1936 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1937 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1938 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1939 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1940 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1941 * SUCH DAMAGE.
1942 *
1943 * @(#)utils.h 8.3 (Berkeley) 3/20/94
1944 * $FreeBSD: head/lib/libc/regex/utils.h 341838 2018-12-12 04:23:00Z yuripv $
1945 */
1946
1947The preceding notice is from src/missing/utils.h in `file`.
1948
1949
1950
1951/*-
1952 * Copyright (c) 2008, 2016 Christos Zoulas
1953 * All rights reserved.
1954 *
1955 * Redistribution and use in source and binary forms, with or without
1956 * modification, are permitted provided that the following conditions
1957 * are met:
1958 * 1. Redistributions of source code must retain the above copyright
1959 * notice, this list of conditions and the following disclaimer.
1960 * 2. Redistributions in binary form must reproduce the above copyright
1961 * notice, this list of conditions and the following disclaimer in the
1962 * documentation and/or other materials provided with the distribution.
1963 *
1964 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
1965 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
1966 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
1967 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
1968 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
1969 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
1970 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
1971 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
1972 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1973 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
1974 * POSSIBILITY OF SUCH DAMAGE.
1975 */
1976
1977The preceding notice is from src/readcdf.c in `file`.
1978
1979
1980
1981/*-
1982 * Copyright (c) 1992 Henry Spencer.
1983 * Copyright (c) 1992, 1993
1984 * The Regents of the University of California. All rights reserved.
1985 *
1986 * This code is derived from software contributed to Berkeley by
1987 * Henry Spencer of the University of Toronto.
1988 *
1989 * Redistribution and use in source and binary forms, with or without
1990 * modification, are permitted provided that the following conditions
1991 * are met:
1992 * 1. Redistributions of source code must retain the above copyright
1993 * notice, this list of conditions and the following disclaimer.
1994 * 2. Redistributions in binary form must reproduce the above copyright
1995 * notice, this list of conditions and the following disclaimer in the
1996 * documentation and/or other materials provided with the distribution.
1997 * 3. Neither the name of the University nor the names of its contributors
1998 * may be used to endorse or promote products derived from this software
1999 * without specific prior written permission.
2000 *
2001 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2002 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2003 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2004 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2005 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2006 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2007 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2008 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2009 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2010 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2011 * SUCH DAMAGE.
2012 *
2013 * @(#)regex.h 8.2 (Berkeley) 1/3/94
2014 * $FreeBSD: src/include/regex.h,v 1.12 2010/02/16 19:39:50 imp Exp $
2015 */
2016
2017The preceding notice is from src/regex-bsd.h in `file`.
2018*/
2019/*
2020
2021Text of LICENSE from DROID:
2022
2023Copyright (c) 2016, The National Archives <pronom@nationalarchives.gov.uk>
2024All rights reserved.
2025
2026Redistribution and use in source and binary forms, with or without
2027modification, are permitted provided that the following
2028conditions are met:
2029
2030 * Redistributions of source code must retain the above copyright
2031 notice, this list of conditions and the following disclaimer.
2032
2033 * Redistributions in binary form must reproduce the above copyright
2034 notice, this list of conditions and the following disclaimer in the
2035 documentation and/or other materials provided with the distribution.
2036
2037 * Neither the name of the The National Archives nor the
2038 names of its contributors may be used to endorse or promote products
2039 derived from this software without specific prior written permission.
2040
2041THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
2042AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2043IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2044PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
2045CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
2046EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
2047PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
2048PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
2049LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
2050NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
2051SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2052*/
2053
2054/*
2055
2056Text of LICENSE from fileid:
2057
2058The MIT License (MIT)
2059
2060Copyright (c) 2015 David B Heise
2061
2062Permission is hereby granted, free of charge, to any person obtaining a copy of
2063this software and associated documentation files (the "Software"), to deal in
2064the Software without restriction, including without limitation the rights to
2065use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
2066the Software, and to permit persons to whom the Software is furnished to do so,
2067subject to the following conditions:
2068
2069The above copyright notice and this permission notice shall be included in all
2070copies or substantial portions of the Software.
2071
2072THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2073IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
2074FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
2075COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
2076IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
2077CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2078
2079
2080*/
2081
2082/*
2083Text of LICENSE from binwalk:
2084
2085
2086MIT License
2087
2088Copyright (c) 2024 devttys0
2089
2090Permission is hereby granted, free of charge, to any person obtaining a copy
2091of this software and associated documentation files (the "Software"), to deal
2092in the Software without restriction, including without limitation the rights
2093to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2094copies of the Software, and to permit persons to whom the Software is
2095furnished to do so, subject to the following conditions:
2096
2097The above copyright notice and this permission notice shall be included in all
2098copies or substantial portions of the Software.
2099
2100THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2101IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2102FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2103AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2104LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2105OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2106SOFTWARE.
2107
2108*/
2109
2110/*
2111Text of LICENSE from polyfile:
2112
2113
2114 Apache License
2115 Version 2.0, January 2004
2116 http://www.apache.org/licenses/
2117
2118 TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
2119
2120 1. Definitions.
2121
2122 "License" shall mean the terms and conditions for use, reproduction,
2123 and distribution as defined by Sections 1 through 9 of this document.
2124
2125 "Licensor" shall mean the copyright owner or entity authorized by
2126 the copyright owner that is granting the License.
2127
2128 "Legal Entity" shall mean the union of the acting entity and all
2129 other entities that control, are controlled by, or are under common
2130 control with that entity. For the purposes of this definition,
2131 "control" means (i) the power, direct or indirect, to cause the
2132 direction or management of such entity, whether by contract or
2133 otherwise, or (ii) ownership of fifty percent (50%) or more of the
2134 outstanding shares, or (iii) beneficial ownership of such entity.
2135
2136 "You" (or "Your") shall mean an individual or Legal Entity
2137 exercising permissions granted by this License.
2138
2139 "Source" form shall mean the preferred form for making modifications,
2140 including but not limited to software source code, documentation
2141 source, and configuration files.
2142
2143 "Object" form shall mean any form resulting from mechanical
2144 transformation or translation of a Source form, including but
2145 not limited to compiled object code, generated documentation,
2146 and conversions to other media types.
2147
2148 "Work" shall mean the work of authorship, whether in Source or
2149 Object form, made available under the License, as indicated by a
2150 copyright notice that is included in or attached to the work
2151 (an example is provided in the Appendix below).
2152
2153 "Derivative Works" shall mean any work, whether in Source or Object
2154 form, that is based on (or derived from) the Work and for which the
2155 editorial revisions, annotations, elaborations, or other modifications
2156 represent, as a whole, an original work of authorship. For the purposes
2157 of this License, Derivative Works shall not include works that remain
2158 separable from, or merely link (or bind by name) to the interfaces of,
2159 the Work and Derivative Works thereof.
2160
2161 "Contribution" shall mean any work of authorship, including
2162 the original version of the Work and any modifications or additions
2163 to that Work or Derivative Works thereof, that is intentionally
2164 submitted to Licensor for inclusion in the Work by the copyright owner
2165 or by an individual or Legal Entity authorized to submit on behalf of
2166 the copyright owner. For the purposes of this definition, "submitted"
2167 means any form of electronic, verbal, or written communication sent
2168 to the Licensor or its representatives, including but not limited to
2169 communication on electronic mailing lists, source code control systems,
2170 and issue tracking systems that are managed by, or on behalf of, the
2171 Licensor for the purpose of discussing and improving the Work, but
2172 excluding communication that is conspicuously marked or otherwise
2173 designated in writing by the copyright owner as "Not a Contribution."
2174
2175 "Contributor" shall mean Licensor and any individual or Legal Entity
2176 on behalf of whom a Contribution has been received by Licensor and
2177 subsequently incorporated within the Work.
2178
2179 2. Grant of Copyright License. Subject to the terms and conditions of
2180 this License, each Contributor hereby grants to You a perpetual,
2181 worldwide, non-exclusive, no-charge, royalty-free, irrevocable
2182 copyright license to reproduce, prepare Derivative Works of,
2183 publicly display, publicly perform, sublicense, and distribute the
2184 Work and such Derivative Works in Source or Object form.
2185
2186 3. Grant of Patent License. Subject to the terms and conditions of
2187 this License, each Contributor hereby grants to You a perpetual,
2188 worldwide, non-exclusive, no-charge, royalty-free, irrevocable
2189 (except as stated in this section) patent license to make, have made,
2190 use, offer to sell, sell, import, and otherwise transfer the Work,
2191 where such license applies only to those patent claims licensable
2192 by such Contributor that are necessarily infringed by their
2193 Contribution(s) alone or by combination of their Contribution(s)
2194 with the Work to which such Contribution(s) was submitted. If You
2195 institute patent litigation against any entity (including a
2196 cross-claim or counterclaim in a lawsuit) alleging that the Work
2197 or a Contribution incorporated within the Work constitutes direct
2198 or contributory patent infringement, then any patent licenses
2199 granted to You under this License for that Work shall terminate
2200 as of the date such litigation is filed.
2201
2202 4. Redistribution. You may reproduce and distribute copies of the
2203 Work or Derivative Works thereof in any medium, with or without
2204 modifications, and in Source or Object form, provided that You
2205 meet the following conditions:
2206
2207 (a) You must give any other recipients of the Work or
2208 Derivative Works a copy of this License; and
2209
2210 (b) You must cause any modified files to carry prominent notices
2211 stating that You changed the files; and
2212
2213 (c) You must retain, in the Source form of any Derivative Works
2214 that You distribute, all copyright, patent, trademark, and
2215 attribution notices from the Source form of the Work,
2216 excluding those notices that do not pertain to any part of
2217 the Derivative Works; and
2218
2219 (d) If the Work includes a "NOTICE" text file as part of its
2220 distribution, then any Derivative Works that You distribute must
2221 include a readable copy of the attribution notices contained
2222 within such NOTICE file, excluding those notices that do not
2223 pertain to any part of the Derivative Works, in at least one
2224 of the following places: within a NOTICE text file distributed
2225 as part of the Derivative Works; within the Source form or
2226 documentation, if provided along with the Derivative Works; or,
2227 within a display generated by the Derivative Works, if and
2228 wherever such third-party notices normally appear. The contents
2229 of the NOTICE file are for informational purposes only and
2230 do not modify the License. You may add Your own attribution
2231 notices within Derivative Works that You distribute, alongside
2232 or as an addendum to the NOTICE text from the Work, provided
2233 that such additional attribution notices cannot be construed
2234 as modifying the License.
2235
2236 You may add Your own copyright statement to Your modifications and
2237 may provide additional or different license terms and conditions
2238 for use, reproduction, or distribution of Your modifications, or
2239 for any such Derivative Works as a whole, provided Your use,
2240 reproduction, and distribution of the Work otherwise complies with
2241 the conditions stated in this License.
2242
2243 5. Submission of Contributions. Unless You explicitly state otherwise,
2244 any Contribution intentionally submitted for inclusion in the Work
2245 by You to the Licensor shall be under the terms and conditions of
2246 this License, without any additional terms or conditions.
2247 Notwithstanding the above, nothing herein shall supersede or modify
2248 the terms of any separate license agreement you may have executed
2249 with Licensor regarding such Contributions.
2250
2251 6. Trademarks. This License does not grant permission to use the trade
2252 names, trademarks, service marks, or product names of the Licensor,
2253 except as required for reasonable and customary use in describing the
2254 origin of the Work and reproducing the content of the NOTICE file.
2255
2256 7. Disclaimer of Warranty. Unless required by applicable law or
2257 agreed to in writing, Licensor provides the Work (and each
2258 Contributor provides its Contributions) on an "AS IS" BASIS,
2259 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
2260 implied, including, without limitation, any warranties or conditions
2261 of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
2262 PARTICULAR PURPOSE. You are solely responsible for determining the
2263 appropriateness of using or redistributing the Work and assume any
2264 risks associated with Your exercise of permissions under this License.
2265
2266 8. Limitation of Liability. In no event and under no legal theory,
2267 whether in tort (including negligence), contract, or otherwise,
2268 unless required by applicable law (such as deliberate and grossly
2269 negligent acts) or agreed to in writing, shall any Contributor be
2270 liable to You for damages, including any direct, indirect, special,
2271 incidental, or consequential damages of any character arising as a
2272 result of this License or out of the use or inability to use the
2273 Work (including but not limited to damages for loss of goodwill,
2274 work stoppage, computer failure or malfunction, or any and all
2275 other commercial damages or losses), even if such Contributor
2276 has been advised of the possibility of such damages.
2277
2278 9. Accepting Warranty or Additional Liability. While redistributing
2279 the Work or Derivative Works thereof, You may choose to offer,
2280 and charge a fee for, acceptance of support, warranty, indemnity,
2281 or other liability obligations and/or rights consistent with this
2282 License. However, in accepting such obligations, You may act only
2283 on Your own behalf and on Your sole responsibility, not on behalf
2284 of any other Contributor, and only if You agree to indemnify,
2285 defend, and hold each Contributor harmless for any liability
2286 incurred by, or claims asserted against, such Contributor by reason
2287 of your accepting any such warranty or additional liability.
2288
2289 END OF TERMS AND CONDITIONS
2290
2291 APPENDIX: How to apply the Apache License to your work.
2292
2293 To apply the Apache License to your work, attach the following
2294 boilerplate notice, with the fields enclosed by brackets "[]"
2295 replaced with your own identifying information. (Don't include
2296 the brackets!) The text should be enclosed in the appropriate
2297 comment syntax for the file format. We also recommend that a
2298 file or class name and description of purpose be included on the
2299 same "printed page" as the copyright notice for easier
2300 identification within third-party archives.
2301
2302 Copyright [yyyy] [name of copyright owner]
2303
2304 Licensed under the Apache License, Version 2.0 (the "License");
2305 you may not use this file except in compliance with the License.
2306 You may obtain a copy of the License at
2307
2308 http://www.apache.org/licenses/LICENSE-2.0
2309
2310 Unless required by applicable law or agreed to in writing, software
2311 distributed under the License is distributed on an "AS IS" BASIS,
2312 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2313 See the License for the specific language governing permissions and
2314 limitations under the License.
2315
2316*/