$ show FDOS/freecom
FreeCOM is a COMMAND.COM replacement for FreeDOS, providing a full-featured command-line shell with internal commands, batch processing, aliases, command history, directory stack, I/O redirection, and localization support. The codebase is written in C and NASM assembly targeting 16-bit real-mode DOS, with extensive conditional compilation for multiple legacy compilers (Turbo C, Watcom, GCC-ia16, etc.). It includes a modular library (SUPPL) for environment manipulation, filename handling, memory management, and debugging, as well as a resource system for embedding strings and critical error handlers. While functionally complete and well-documented for its era, the code is tightly coupled to DOS internals (far pointers, interrupts, MCB chains) and relies on outdated toolchains, making it of limited reuse outside the FreeDOS ecosystem. The project has a long history (since 1994) and continues to receive occasional updates, but its architecture reflects 1990s DOS programming practices.
The LLM identified 4 files worth highlighting for reuse:
The SUPPL library is a collection of portable DOS support functions that can be reused by other DOS programs. It provides environment variable manipulation (env_*.c), filename path utilities (dfn*.c), memory control block walking (mcb*.c), NLS-sensitive string operations (toupperx.c, nlstime.c), and a debug logging framework (dbgf_*.c). The library is designed to be compiler-independent (with portability headers p-*.h) and is loosely coupled to FreeCOM, making it extractable for other DOS projects.
The context management system (ctxt_create, ctxt_set, ctxt_get, ctxt_push, ctxt_pop, etc.) implements a generic tagged-item storage mechanism using DOS environment blocks. It supports multiple stacks (history, directory stack, aliases, batch info) with a consistent API. The pattern is self-contained and could be reused in any DOS program needing hierarchical or scoped storage of named items.
The option scanning framework provides a callback-based parser for command-line options (boolean, string, integer). It supports leading options (e.g., /A, /O:sort) and is used consistently across all internal commands. The pattern is well-isolated and could be extracted for use in other DOS command-line tools.
The fixstrs utility compiles .lng language files into a binary string table (strings.dat) and a C header (strings.h). It validates version IDs, handles escape sequences, and supports prompt metakeys for interactive responses. This pattern of generating a resource from structured text files is reusable for any DOS program needing embedded localized strings.