amiga-bootcamp/07_dos/pattern_matching.md
Ilia Sharin 21751c0025 docs(amiga): complete AmigaOS 3.1/3.2 developer reference — 172 files across 17 sections
Comprehensive technical documentation covering:
- Hardware: OCS/ECS/AGA custom chip registers, Copper & Blitter deep dives
- Boot sequence: cold boot through startup-sequence
- Binary format: HUNK executable spec, relocation, debug info
- Linking & ABI: .fd files, LVO tables, register calling conventions
- Exec kernel: tasks, interrupts, memory, signals, semaphores
- AmigaDOS: file I/O, FFS/OFS layout, CLI/Shell scripting
- Graphics: planar bitmaps, Copper programming, HAM/EHB modes
- Intuition: screens, windows, IDCMP, BOOPSI
- Devices: trackdisk, SCSI, serial, timer, audio, keyboard
- Libraries: utility, expansion, IFFParse, locale, ARexx
- Networking: bsdsocket API, SANA-II, TCP/IP stack comparison
- Toolchain: GCC, vasm/vlink, SAS/C, NDK, debugging
- Reverse engineering: IDA/Ghidra setup, compiler fingerprints, case studies
- CPU & MMU: 68040/060 emulation libs, PMMU, cache management
- Driver development: SANA-II, Picasso96/RTG, AHI audio

All files include breadcrumb navigation. No local paths or proprietary content.
2026-04-23 12:17:35 -04:00

2 KiB

← Home · AmigaDOS

Pattern Matching — ParsePattern, MatchPattern

Overview

AmigaDOS provides built-in wildcard/pattern matching for file operations. Patterns are compiled into token streams via ParsePattern and matched via MatchPattern.


Wildcard Syntax

Pattern Meaning Example
? Match exactly one character file?.txt matches file1.txt
# Match zero or more of the following #?.info matches anything ending in .info
#? Match any string (equivalent to *) #? matches everything
(a|b) Alternation — match a or b (read|write)
~ Negation — match if NOT ~(#?.info) matches non-info files
[abc] Character class [abc] matches a, b, or c
[a-z] Character range [0-9] matches digits
' Quote next character literally '# matches literal #

API

/* dos/dos.h — NDK39 */

/* Compile a pattern into tokenised form: */
LONG ParsePattern(STRPTR pat, STRPTR buf, LONG buflen);
/* Returns: 1 = pattern has wildcards, 0 = plain string, -1 = error */

/* Test a name against a compiled pattern: */
BOOL MatchPattern(STRPTR pat_compiled, STRPTR name);

/* Case-insensitive variants: */
LONG ParsePatternNoCase(STRPTR pat, STRPTR buf, LONG buflen);
BOOL MatchPatternNoCase(STRPTR pat_compiled, STRPTR name);

Usage Example

char pat[256], buf[256];
LONG is_wild;

is_wild = ParsePatternNoCase("#?.txt", pat, sizeof(pat));
if (is_wild >= 0) {
    if (MatchPatternNoCase(pat, "readme.txt"))
        Printf("Match!\n");
    if (!MatchPatternNoCase(pat, "readme.doc"))
        Printf("No match\n");
}

Common Patterns

Pattern Matches
#? Everything (wildcard all)
#?.info All .info icon files
~(#?.info) Everything except .info files
(#?.c|#?.h) All C source and header files
file[0-9] file0 through file9

References

  • NDK39: dos/dos.h
  • ADCD 2.1: ParsePattern, MatchPattern