Files
snark13 c71e249a4e Add full compiler toolchain, libc, examples and reference docs
First substantive commit: the entire Sprinter C compiler tree on top of
the bare README+gitignore initial commit.

What's in here:
  bin/sprinter-cc        — driver script invoking SDCC + linker + mkexe
  libc/                  — Sprinter-specific libc layer over ESTEX/BIOS
                           (conio, gfx, io, mem, stdio + headers)
  runtime/               — crt0 variants (default/small/banked/minimal)
                           + heap + bank trampolines
  toolchain/             — mkexe (SprintEXE packer, C + tests)
  examples/              — 30 demo programs (gfx, file I/O, env, time, …)
  lib/Makefile           — builds the libc archive (sprinter.lib)
  docs/                  — converted Sprinter manuals + asm reference samples
  third_party/           — solid-c reference compiler dump + sdcc setup script
  release_docs/          — packaging / release notes

gitignore overhaul:
  • Drop dangerous blanket patterns: *.asm (would hide docs/samples/*.asm)
    and *.exe (case-insensitive match was hiding third_party/solid-c/*.EXE
    on macOS APFS).  Replaced with examples/*/*.{asm,exe,…} and lib/*.lib.
  • Restore tracking of toolchain/mkexe/tests/{one,big}.bin — those are
    INPUT fixtures, not build outputs.
  • Collapse the duplicated SDCC/C/Sdcc sections into one section per
    concern (build outputs / vendored / OS-junk).
  • Add .sprinter-cc-*/, build/ (catches lib/build/ too), .claude/.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-03 16:13:21 +03:00

52 lines
1.9 KiB
C

/*
* dir.h — directory iteration via ESTEX F_FIRST / F_NEXT ($19 / $1A).
*
* ffirst(pattern, &buf, attrib)
* Initialises the search. The pattern is a DOS wildcard like
* `*.TXT` or `DATA\\*`. attrib is the search mask (use FA_NORMAL
* to match plain files, OR in FA_DIREC to include subdirectories).
* Returns 0 on success (buf is populated), -1 on failure (errno set).
*
* fnext(&buf)
* Steps to the next matching entry, reusing the same buf. Returns
* 0 on success, -1 when no more files match (errno = ENOENT) or on
* other errors.
*
* The buffer fields below mirror ESTEX's layout exactly so we can hand
* it straight to the kernel. Use `buf.found_name` (NUL-terminated DOS
* "name.ext" form) to display results.
*/
#ifndef DIR_H
#define DIR_H
#include <stdint.h>
/* File attribute bits (ESTEX / DOS standard). */
#define FA_NORMAL 0x00
#define FA_RDONLY 0x01
#define FA_HIDDEN 0x02
#define FA_SYSTEM 0x04
#define FA_LABEL 0x08
#define FA_DIREC 0x10
#define FA_ARCH 0x20
/* 256-byte work buffer for ESTEX F_FIRST / F_NEXT (B=1 mode). */
typedef struct {
char name[8]; /* +0 pattern: 8-byte filename */
char ext[3]; /* +8 pattern: 3-byte extension */
uint8_t attrib; /* +11 search attribute */
char reserved[10]; /* +12 DSS internal state */
uint16_t time; /* +22 time of last write */
uint16_t date; /* +24 date of last write */
uint16_t first_cluster; /* +26 first cluster */
uint32_t size; /* +28 file size in bytes */
uint8_t found_attr; /* +32 attribute of the matched file */
char found_name[223]; /* +33 NUL-terminated "name.ext" */
} ffblk_t;
int ffirst(const char *pattern, ffblk_t *buf, uint8_t attrib);
int fnext (ffblk_t *buf);
#endif