# Design ## One library, three native shells The apps share everything that is not drawing. `core/` is libdmodemctl, a small C library with no I/O and no threads ("sans-I/O"): each app opens the modem in its own way, hands the bytes it reads to `dmc_feed()`, writes what `dmc_output()` gives it, and calls `dmc_poll()` from a 50 ms timer. That keeps it easy to call from C (GTK), C++ (Win32) and Swift, and easy to test (`core/test`, run by CI with ASan and UBSan). | Part | What it does | | --- | --- | | `dmc_session` | The AT conversation: a queue of commands and their responses, the call's state from the result codes (RING, CONNECT, NO CARRIER), caller ID, the escape (`+++` with its guard times) and hanging up, and the byte stream for the terminal | | `dmc_model` | The modem's settings from AT!M, with each setting's check and the command that sets it | | `dmc_diag` | The last call's statistics from AT#UD, as labelled rows (the V.58 code tables decoded) | | `dmc_vt` | A small VT100/ANSI screen, for Windows and macOS, whose toolkits have no terminal widget | | `dmc_daemon_*` | Reading what dmodemd prints when it starts: the device it made, or its error | ## Where the settings come from dmodemd's core has one settings model (`Config::model`), which already drives its configurators (AT!CF, AT!CT, AT!C). AT!M prints that model as tab-separated lines: each setting's key, kind (pick, number or text), value, default, range, AT form, group, label and help, then each choice. The Settings page builds its controls from it, so a setting added to the modem shows in every app with no change here. A change is checked by the library, sent as its AT command, and kept once the modem says OK. The modem keeps no stored profile, so the page shows AT!R's init string and its **Keep** button saves it in the app's line settings, to be sent each time the modem opens. ## The same screens everywhere Each app has the same five pages, with the same words: | Page | Contents | | --- | --- | | Modem | The state ("Idle", "Dialling", "Online") and its detail (the CONNECT line, the caller), Dial, Answer, Hang Up, the line and the device, Start or Stop | | Terminal | The AT console; the buttons **Full-screen setup** (AT!CF) and **Command-line setup** (AT!CT) | | Settings | Groups of settings as native controls, changed ones marked; Defaults (ATZ), the init string and Keep | | Call Stats | AT#UD's rows and ATI11's report, refreshed after each call | | Log | What dmodemd printed, and the command line it was started with | The terminal sends Backspace as BS (0x08), the modem's S5: it does not take DEL. Colours are the brand's: background `#0a0f1c`, text `#e8f0ff`. ## Starting dmodemd | | Linux | macOS | Windows | | --- | --- | --- | --- | | Started with | GSubprocess | Process | CreateProcess | | Its DTE | a pty (it prints "Use `/dev/pts/N' as modem device") | a pty | `--tcp 127.0.0.1:port` | | Settings kept in | `~/.config/dmodem-gui/settings.ini` (mode 0600) | user defaults, the SIP password in the keychain | `%APPDATA%\D-Modem\dmodem.ini` | The SIP account goes to dmodemd in its environment (`SIP_LOGIN`, `SIP_T38`, `SIP_V152`, `SIP_V150`, `SIP_SRTP`); the country, USB modem and debug level as flags. On Linux and macOS the pty is made in the user's own group (`-g`), so that dmodemd needs no root. Each app can instead use a modem that already runs: a device path on Linux and macOS; a TCP address or a COM port on Windows. ## Windows 95 and later The Windows app is plain Win32 in C++98, so that one binary runs from Windows 95 to Windows 11: - ANSI APIs, with UTF-8 from the library converted by hand (no `CP_UTF8` on 9x); the terminal draws with `ExtTextOutW`, which 9x has. - The Windows 95 common controls (tabs, list views, the status bar), Winsock 1.1 (`wsock32`, `WSAAsyncSelect`) and the 4.0 `OPENFILENAME`. - No `SetHandleInformation` (NT only): the pipe from dmodemd is made non-inheritable with `DuplicateHandle`. - Built by Open Watcom 2.0 (`windows/build-watcom.sh`: `runtime windows=4.0`, the static C library), as CI does; MinGW and MSVC build the same code with CMake. dmodemd itself needs Windows 7 or later. On Windows 9x and NT 4 the app defaults to a COM port, and can reach a dmodemd on another machine over TCP.