Merge main into claude/project-thread-mxrh5c
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B82eRTRNP9YEnRxydbrw9G
No files matched your search
@@ -172,7 +172,7 @@ jobs:
|
||||
path: build/win7/windows/dmodem.exe
|
||||
|
||||
# The Windows app for Linux and macOS (winport/), over the portable
|
||||
# Win32 layer of clang-retro MFC. First pass: TCP and SSH only.
|
||||
# Win32 layer of clang-retro MFC.
|
||||
winport-linux:
|
||||
name: Windows app on Linux (clang-retro MFC's Win32 layer)
|
||||
runs-on: ubuntu-24.04
|
||||
|
||||
@@ -22,7 +22,7 @@ libdmodemctl. Thus they operate in the same way.
|
||||
- **Call Stats**: the rate, modulation, error control and line figures of the last call (AT#UD, ATI11)
|
||||
- **Line settings**: a SIP account, a USB modem, or a modem that already runs (dmodemd, or a hardware modem such as the MultiTech MT9234MU)
|
||||
- **Windows 95 and later**: plain Win32, built with [clang-retro](https://clang-retro.github.io/). The modem is built in on each Windows. The app can also connect to a modem through TCP or a COM port
|
||||
- **The Windows app on Linux and macOS** (first pass): the same Win32 code, built over the portable Win32 layer of [clang-retro MFC](https://github.com/clang-retro/mfc). At this time, it connects to a modem through TCP only, and the Phone page cannot play or record sound. Refer to "The Windows app on Linux and macOS" in [Design](docs/design.md)
|
||||
- **The Windows app on Linux and macOS**: the same Win32 code, built over the portable Win32 layer of [clang-retro MFC](https://github.com/clang-retro/mfc). It starts dmodemd, or connects to a modem through TCP or a COM port. Refer to "The Windows app on Linux and macOS" in [Design](docs/design.md)
|
||||
|
||||
| | Windows | macOS | Linux |
|
||||
| --- | --- | --- | --- |
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="512" height="512" viewBox="14 14 80 80">
|
||||
<!-- D-Modem's app icon (D-Modem/brand, tools/app_icon.py) on a desktop tile -->
|
||||
<rect x="16" y="16" width="76" height="76" rx="17" fill="#0a0f1c"/>
|
||||
<defs><linearGradient id="stripes" x1="0" y1="0" x2="0" y2="1"><stop offset="0.0000" stop-color="#ff4d5e"/><stop offset="0.1667" stop-color="#ff4d5e"/><stop offset="0.1667" stop-color="#ff8a3d"/><stop offset="0.3333" stop-color="#ff8a3d"/><stop offset="0.3333" stop-color="#ffd23d"/><stop offset="0.5000" stop-color="#ffd23d"/><stop offset="0.5000" stop-color="#3ddc84"/><stop offset="0.6667" stop-color="#3ddc84"/><stop offset="0.6667" stop-color="#3d8bff"/><stop offset="0.8333" stop-color="#3d8bff"/><stop offset="0.8333" stop-color="#a66bff"/><stop offset="1.0000" stop-color="#a66bff"/></linearGradient></defs><path d="M34,34 H74 V66 H62.0 V75.6 H46.0 V66 H34 Z" fill="none" stroke="url(#stripes)" stroke-width="3.4"/><path d="M39.0,50.0 L39.1,49.6 L39.2,49.2 L39.4,48.8 L39.5,48.4 L39.6,48.1 L39.8,47.7 L39.9,47.3 L40.0,47.0 L40.1,46.7 L40.2,46.3 L40.4,46.0 L40.5,45.8 L40.6,45.5 L40.8,45.2 L40.9,45.0 L41.0,44.8 L41.1,44.6 L41.2,44.5 L41.4,44.3 L41.5,44.2 L41.6,44.1 L41.8,44.1 L41.9,44.0 L42.0,44.0 L42.1,44.0 L42.2,44.1 L42.4,44.1 L42.5,44.2 L42.6,44.3 L42.8,44.5 L42.9,44.6 L43.0,44.8 L43.1,45.0 L43.2,45.2 L43.4,45.5 L43.5,45.8 L43.6,46.0 L43.8,46.3 L43.9,46.7 L44.0,47.0 L44.1,47.3 L44.2,47.7 L44.4,48.1 L44.5,48.4 L44.6,48.8 L44.8,49.2 L44.9,49.6 L45.0,50.0 L45.1,50.4 L45.2,50.8 L45.4,51.2 L45.5,51.6 L45.6,51.9 L45.8,52.3 L45.9,52.7 L46.0,53.0 L46.1,53.3 L46.2,53.7 L46.4,54.0 L46.5,54.2 L46.6,54.5 L46.8,54.8 L46.9,55.0 L47.0,55.2 L47.1,55.4 L47.2,55.5 L47.4,55.7 L47.5,55.8 L47.6,55.9 L47.8,55.9 L47.9,56.0 L48.0,56.0 L48.1,56.0 L48.2,55.9 L48.4,55.9 L48.5,55.8 L48.6,55.7 L48.8,55.5 L48.9,55.4 L49.0,55.2 L49.1,55.0 L49.2,54.8 L49.4,54.5 L49.5,54.2 L49.6,54.0 L49.8,53.7 L49.9,53.3 L50.0,53.0 L50.1,52.7 L50.2,52.3 L50.4,51.9 L50.5,51.6 L50.6,51.2 L50.8,50.8 L50.9,50.4 L51.0,50.0 L51.1,49.6 L51.2,49.2 L51.4,48.8 L51.5,48.4 L51.6,48.1 L51.8,47.7 L51.9,47.3 L52.0,47.0 L52.1,46.7 L52.2,46.3 L52.4,46.0 L52.5,45.8 L52.6,45.5 L52.8,45.2 L52.9,45.0 L53.0,44.8 L53.1,44.6 L53.2,44.5 L53.4,44.3 L53.5,44.2 L53.6,44.1 L53.8,44.1 L53.9,44.0 L54.0,44.0 H57.0 V56.0 H63.0 V44.0 H69.0" fill="none" stroke="#e8f0ff" stroke-width="3.4" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="512" height="512" viewBox="0 0 500 500">
|
||||
<!-- D-Modem's mark (D-Modem/brand, avatar/org-avatar.svg) on a desktop tile -->
|
||||
<defs>
|
||||
<linearGradient id="books" gradientUnits="userSpaceOnUse" x1="0" y1="81" x2="0" y2="419"><stop offset="0.0000" stop-color="#ff4d5e"/><stop offset="0.1667" stop-color="#ff4d5e"/><stop offset="0.1667" stop-color="#ff8a3d"/><stop offset="0.3333" stop-color="#ff8a3d"/><stop offset="0.3333" stop-color="#ffd23d"/><stop offset="0.5000" stop-color="#ffd23d"/><stop offset="0.5000" stop-color="#3ddc84"/><stop offset="0.6667" stop-color="#3ddc84"/><stop offset="0.6667" stop-color="#3d8bff"/><stop offset="0.8333" stop-color="#3d8bff"/><stop offset="0.8333" stop-color="#a66bff"/><stop offset="1.0000" stop-color="#a66bff"/></linearGradient>
|
||||
<filter id="glow" x="-30%" y="-30%" width="160%" height="160%">
|
||||
<feGaussianBlur stdDeviation="6" result="b"/>
|
||||
<feMerge><feMergeNode in="b"/><feMergeNode in="SourceGraphic"/></feMerge>
|
||||
</filter>
|
||||
</defs>
|
||||
<rect x="10" y="10" width="480" height="480" rx="108" fill="#0a0f1c"/>
|
||||
<g transform="translate(-15 0)">
|
||||
<path d="M140 100 H240 A150 150 0 0 1 240 400 H140 Z" fill="none" stroke="url(#books)" stroke-width="38" stroke-linejoin="round" filter="url(#glow)"/>
|
||||
<path d="M178.0,250.0 L178.8,246.3 L179.5,242.7 L180.3,239.1 L181.1,235.5 L181.8,232.0 L182.6,228.6 L183.4,225.2 L184.1,222.0 L184.9,218.9 L185.7,215.9 L186.4,213.1 L187.2,210.4 L188.0,207.9 L188.7,205.6 L189.5,203.4 L190.3,201.5 L191.0,199.8 L191.8,198.3 L192.6,197.0 L193.3,195.9 L194.1,195.1 L194.9,194.5 L195.6,194.1 L196.4,194.0 L197.2,194.1 L197.9,194.5 L198.7,195.1 L199.5,195.9 L200.2,197.0 L201.0,198.3 L201.8,199.8 L202.5,201.5 L203.3,203.4 L204.1,205.6 L204.8,207.9 L205.6,210.4 L206.4,213.1 L207.1,215.9 L207.9,218.9 L208.7,222.0 L209.4,225.2 L210.2,228.6 L211.0,232.0 L211.7,235.5 L212.5,239.1 L213.3,242.7 L214.0,246.3 L214.8,250.0 L215.6,253.7 L216.3,257.3 L217.1,260.9 L217.9,264.5 L218.6,268.0 L219.4,271.4 L220.2,274.8 L220.9,278.0 L221.7,281.1 L222.5,284.1 L223.2,286.9 L224.0,289.6 L224.8,292.1 L225.5,294.4 L226.3,296.6 L227.1,298.5 L227.8,300.2 L228.6,301.7 L229.4,303.0 L230.1,304.1 L230.9,304.9 L231.7,305.5 L232.4,305.9 L233.2,306.0 L234.0,305.9 L234.7,305.5 L235.5,304.9 L236.3,304.1 L237.0,303.0 L237.8,301.7 L238.6,300.2 L239.3,298.5 L240.1,296.6 L240.9,294.4 L241.6,292.1 L242.4,289.6 L243.2,286.9 L243.9,284.1 L244.7,281.1 L245.5,278.0 L246.2,274.8 L247.0,271.4 L247.8,268.0 L248.5,264.5 L249.3,260.9 L250.1,257.3 L250.8,253.7 L251.6,250.0 L252.4,246.3 L253.1,242.7 L253.9,239.1 L254.7,235.5 L255.4,232.0 L256.2,228.6 L257.0,225.2 L257.7,222.0 L258.5,218.9 L259.3,215.9 L260.0,213.1 L260.8,210.4 L261.6,207.9 L262.3,205.6 L263.1,203.4 L263.9,201.5 L264.6,199.8 L265.4,198.3 L266.2,197.0 L266.9,195.9 L267.7,195.1 L268.5,194.5 L269.2,194.1 L270.0,194.0 H288.4 V306.0 H325.2 V194.0 H362.0" fill="none" stroke="#e8f0ff" stroke-width="16" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.9 KiB |
@@ -535,43 +535,33 @@ connect to a dmodemd on another machine through TCP.
|
||||
|
||||
## The Windows app on Linux and macOS
|
||||
|
||||
The Windows app also builds for Linux and macOS. This is a first pass.
|
||||
clang-retro MFC has a portable Win32 layer (`port/`, `libwinport.a`). The
|
||||
layer supplies the Win32 API on X11, Wayland and Cocoa. The app links
|
||||
with this layer and not with Windows. Its source code is the same as on
|
||||
Windows.
|
||||
The Windows app also builds for Linux and macOS. clang-retro MFC has a
|
||||
portable Win32 layer (`port/`, `libwinport.a`). The layer supplies the
|
||||
Win32 API on X11, Wayland and Cocoa: windows and controls, Winsock,
|
||||
files, COM ports, processes and pipes, and sound (`waveOut`, `waveIn`
|
||||
and ACM). The app links with this layer and not with Windows. Its source
|
||||
code is the same as on Windows.
|
||||
|
||||
- Use `-DDMODEM_GUI_WINPORT=ON` and set `CLANG_RETRO_MFC` to a checkout of
|
||||
clang-retro MFC. Use clang. `winport/CMakeLists.txt` builds
|
||||
`libwinport.a` with the Makefile of MFC. It converts `app.rc` to C++
|
||||
with `port/tools/res2cpp.py` (this needs `llvm-rc`). The app is
|
||||
`winport/dmodem-win32` in the build directory.
|
||||
`winport/dmodem-win32` in the build directory. `windows/sources.cmake`
|
||||
is the list of sources for the two builds.
|
||||
- `DMODEM_WINPORT` is defined for this build. The app uses it in these
|
||||
locations only:
|
||||
- The settings file is `~/.config/D-Modem/dmodem.ini`.
|
||||
- The line is TCP by default (`127.0.0.1:2323`, a dmodemd that runs).
|
||||
The app does not start dmodemd on these systems yet.
|
||||
- SSH uses `~/.ssh` and `/` in paths.
|
||||
- The path view on the Settings page draws its pictures from Unicode
|
||||
(DejaVu Sans), because these systems do not have Wingdings.
|
||||
- The group boxes go under the other controls. The hit test of the
|
||||
layer stops at a window that answers `HTTRANSPARENT`, and does not
|
||||
try the windows under it. Windows tries them. Thus without this
|
||||
change, a click on a control in a group box goes to the page.
|
||||
- The layer does not have these functions yet. `winport/include` and
|
||||
`winport/src/stubs.cpp` supply stand-ins for them:
|
||||
|
||||
| Function | The stand-in |
|
||||
| --- | --- |
|
||||
| `waveOut*`, `waveIn*` (`mmsystem.h`), `acm*` (`msacm.h`) | Returns `MMSYSERR_NODRIVER`. The Phone page cannot play or record. |
|
||||
| `GetCommState`, `SetCommState`, `SetCommTimeouts`, `SetCommBreak`, `ClearCommBreak` (COM ports) | Returns `FALSE` (`ERROR_NOT_SUPPORTED`). Do not use a COM port. |
|
||||
| `CreatePipe`, `PeekNamedPipe` | Returns `FALSE`. The app cannot start dmodemd. |
|
||||
| `GetEnvironmentStrings`, `GetUserName`, `Beep` | Uses `environ`, `$USER` and `MessageBeep`. |
|
||||
| `ListView_*`, `TabCtrl_*` (`commctrl.h`), `winsock.h` | Macros and an include of `winsock2.h`. |
|
||||
|
||||
When the layer gets these functions, remove the stand-ins (and the
|
||||
group box change). Each stand-in is in `winport/` only, or in a
|
||||
`DMODEM_WINPORT` block.
|
||||
- CI builds the app on Linux and macOS. On Linux, it starts the app in
|
||||
Xvfb with `winport/test/smoke.sh`. The test makes sure that the app
|
||||
stays up and sends AT commands to a test modem through TCP.
|
||||
- The settings file is in the `CSIDL_APPDATA` folder of the layer
|
||||
(`~/.config/D-Modem` on Linux, `~/Library/Application Support/D-Modem`
|
||||
on macOS). On Windows, the app uses `APPDATA`, because Windows 95 has
|
||||
no `SHGetFolderPath`.
|
||||
- The line is dmodemd by default. The layer tells the app that Windows
|
||||
is version 5, and on Windows the app then uses a COM port by default.
|
||||
- dmodemd is `dmodemd` next to the app, or else on the `PATH`.
|
||||
- SSH uses `~/.ssh` and `/` in paths, because libssh uses POSIX paths
|
||||
on these systems.
|
||||
- The layer changes a COM port name to a device: `COM1` is `/dev/ttyS0`.
|
||||
- CI builds the app on Linux and macOS. On Linux, `winport/test/smoke.sh`
|
||||
starts the app in Xvfb two times: with a TCP line, and with a dmodemd
|
||||
that the app starts (`winport/test/dmodemd`, a test dmodemd). Each time,
|
||||
the test makes sure that the app stays up and sends AT commands to a
|
||||
test modem.
|
||||
|
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 7.1 KiB |
|
Before Width: | Height: | Size: 6.4 KiB After Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 538 B After Width: | Height: | Size: 608 B |
|
Before Width: | Height: | Size: 978 B After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 6.4 KiB After Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 42 KiB |
|
Before Width: | Height: | Size: 978 B After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 42 KiB |
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 103 KiB |
@@ -1,4 +1,4 @@
|
||||
// Renders assets/dmodem.svg (D-Modem/brand's app icon on a tile) to the
|
||||
// Renders assets/dmodem.svg (D-Modem/brand's mark, avatar/org-avatar.svg, on a tile) to the
|
||||
// PNGs the apps' icons are made from, with Playwright's Chromium:
|
||||
// node tools/icons.js && python3 tools/icons.py
|
||||
const { chromium } = require('playwright');
|
||||
|
||||
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 39 KiB |
@@ -47,14 +47,16 @@
|
||||
#endif
|
||||
|
||||
/* the separator of paths that libssh and the C library see: Windows', or
|
||||
POSIX on Linux and macOS (winport/); and the name of the folder that
|
||||
holds .ssh */
|
||||
POSIX on Linux and macOS (winport/); the name of the folder that holds
|
||||
.ssh; and dmodemd's file name */
|
||||
#ifdef DMODEM_WINPORT
|
||||
#define DIR_SEP "/"
|
||||
#define PROFILE_NAME "home folder"
|
||||
#define DMODEMD_EXE "dmodemd"
|
||||
#else
|
||||
#define DIR_SEP "\\"
|
||||
#define PROFILE_NAME "profile"
|
||||
#define DMODEMD_EXE "dmodemd.exe"
|
||||
#endif
|
||||
|
||||
/* (older headers, Open Watcom's among them, without the 64-bit names) */
|
||||
|
||||
@@ -13,6 +13,9 @@
|
||||
#include "app.h"
|
||||
#include <commdlg.h>
|
||||
#include "resource.h"
|
||||
#ifdef DMODEM_WINPORT
|
||||
#include <shlobj.h>
|
||||
#endif
|
||||
|
||||
#ifndef OPENFILENAME_SIZE_VERSION_400
|
||||
#define OPENFILENAME_SIZE_VERSION_400 76
|
||||
@@ -22,11 +25,12 @@ void app_data_dir(char *out, int n)
|
||||
{
|
||||
char dir[MAX_PATH];
|
||||
#ifdef DMODEM_WINPORT
|
||||
/* (Linux and macOS, winport/: ~/.config/D-Modem) */
|
||||
const char *home = getenv("HOME");
|
||||
if (home && strlen(home) < sizeof(dir) - 20) {
|
||||
_snprintf(dir, sizeof(dir), "%s/.config", home);
|
||||
CreateDirectory(dir, NULL);
|
||||
/* (Linux and macOS, winport/: the layer's CSIDL_APPDATA, ~/.config or
|
||||
~/Library/Application Support; Windows 95 has no SHGetFolderPath,
|
||||
so Windows uses APPDATA) */
|
||||
if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE,
|
||||
NULL, 0, dir)) &&
|
||||
strlen(dir) < sizeof(dir) - 10) {
|
||||
strcat(dir, "/D-Modem");
|
||||
CreateDirectory(dir, NULL);
|
||||
_snprintf(out, n, "%s", dir);
|
||||
@@ -92,10 +96,10 @@ void config_load(Config *c)
|
||||
GetVersionEx(&v);
|
||||
bool old = v.dwPlatformId != VER_PLATFORM_WIN32_NT || v.dwMajorVersion < 6;
|
||||
#ifdef DMODEM_WINPORT
|
||||
/* (Linux and macOS, winport/: no COM ports or dmodemd started by the
|
||||
app yet, so a dmodemd that runs, through TCP) */
|
||||
/* (Linux and macOS, winport/: dmodemd runs there, whatever Windows
|
||||
version the layer reports) */
|
||||
(void)old;
|
||||
c->line = get_i(ini, "line", LINE_TCP);
|
||||
c->line = get_i(ini, "line", LINE_DMODEMD);
|
||||
#else
|
||||
#ifdef DMODEM_GUI_EMBED
|
||||
/* (the modem built in runs on Windows 98 SE and later) */
|
||||
|
||||
@@ -213,7 +213,7 @@ static bool open_com(const char *name)
|
||||
return true;
|
||||
}
|
||||
|
||||
/* dmodemd.exe: the configured one, or next to this app */
|
||||
/* dmodemd: the configured one, or next to this app */
|
||||
static void dmodemd_path(char *out, int n)
|
||||
{
|
||||
if (app.cfg.dmodemd[0]) {
|
||||
@@ -222,9 +222,17 @@ static void dmodemd_path(char *out, int n)
|
||||
return;
|
||||
}
|
||||
GetModuleFileName(NULL, out, n);
|
||||
char *slash = strrchr(out, '\\');
|
||||
char *slash = strrchr(out, DIR_SEP[0]);
|
||||
if (slash)
|
||||
strcpy(slash + 1, "dmodemd.exe");
|
||||
strcpy(slash + 1, DMODEMD_EXE);
|
||||
#ifdef DMODEM_WINPORT
|
||||
/* (Linux and macOS, winport/: else the one on the PATH) */
|
||||
char found[MAX_PATH];
|
||||
if (GetFileAttributes(out) == (DWORD)-1 &&
|
||||
SearchPath(NULL, DMODEMD_EXE, NULL, sizeof(found), found, NULL))
|
||||
_snprintf(out, n, "%s", found);
|
||||
out[n - 1] = '\0';
|
||||
#endif
|
||||
}
|
||||
|
||||
/* an environment block: ours, and these */
|
||||
@@ -272,7 +280,7 @@ static bool start_dmodemd()
|
||||
dmodemd_path(exe, sizeof(exe));
|
||||
if (GetFileAttributes(exe) == (DWORD)-1) {
|
||||
char m[MAX_PATH + 64];
|
||||
_snprintf(m, sizeof(m), "dmodemd.exe was not found (%s)", exe);
|
||||
_snprintf(m, sizeof(m), DMODEMD_EXE " was not found (%s)", exe);
|
||||
m[sizeof(m) - 1] = '\0';
|
||||
app_message(m);
|
||||
app_log(m);
|
||||
|
||||
@@ -209,22 +209,36 @@ void app_event(const dmc_event *ev)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DMODEM_WINPORT
|
||||
/* (Linux and macOS, winport/: the layer's hit test stops at a group box,
|
||||
which answers HTTRANSPARENT, and does not try the controls under it.
|
||||
Windows tries them. Until the layer does too, put the group boxes
|
||||
under the other controls.) */
|
||||
static BOOL CALLBACK lower_group_box(HWND c, LPARAM lp)
|
||||
/* a page's labels (static controls) and group boxes under its other
|
||||
controls, and clipped by them (WS_CLIPSIBLINGS): a label paints all of
|
||||
its rectangle, and without this it paints over a control that it
|
||||
overlaps. The group boxes go lowest. (Only the pages: in a dialog box,
|
||||
a label's mnemonic goes to the control after it in this order.) */
|
||||
static void lower_labels(HWND page)
|
||||
{
|
||||
char cls[16];
|
||||
(void)lp;
|
||||
if (GetClassName(c, cls, sizeof(cls)) && !lstrcmpi(cls, "BUTTON") &&
|
||||
(GetWindowLong(c, GWL_STYLE) & BS_TYPEMASK) == BS_GROUPBOX)
|
||||
SetWindowPos(c, HWND_BOTTOM, 0, 0, 0, 0,
|
||||
SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
|
||||
return TRUE;
|
||||
HWND kids[128];
|
||||
int n = 0;
|
||||
for (HWND c = GetWindow(page, GW_CHILD); c && n < 128;
|
||||
c = GetWindow(c, GW_HWNDNEXT))
|
||||
kids[n++] = c;
|
||||
for (int pass = 0; pass < 2; pass++) {
|
||||
for (int i = 0; i < n; i++) {
|
||||
char cls[16];
|
||||
if (!GetClassName(kids[i], cls, sizeof(cls)))
|
||||
continue;
|
||||
LONG st = GetWindowLong(kids[i], GWL_STYLE);
|
||||
bool group = !lstrcmpi(cls, "BUTTON") &&
|
||||
(st & BS_TYPEMASK) == BS_GROUPBOX;
|
||||
bool label = !lstrcmpi(cls, "STATIC");
|
||||
if (pass == 0 ? !label : !group)
|
||||
continue;
|
||||
SetWindowLong(kids[i], GWL_STYLE, st | WS_CLIPSIBLINGS);
|
||||
SetWindowPos(kids[i], HWND_BOTTOM, 0, 0, 0, 0,
|
||||
SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE |
|
||||
SWP_FRAMECHANGED);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static int page_now;
|
||||
|
||||
@@ -323,18 +337,33 @@ static LRESULT CALLBACK main_proc(HWND w, UINT m, WPARAM wp, LPARAM lp)
|
||||
app.pages[PAGE_SETTINGS] = settings_page_new(w);
|
||||
app.pages[PAGE_STATS] = stats_page_new(w);
|
||||
app.pages[PAGE_LOG] = log_page_new(w);
|
||||
for (int p = 0; p < PAGES; p++)
|
||||
for (int p = 0; p < PAGES; p++) {
|
||||
SetWindowPos(app.pages[p], HWND_TOP, 0, 0, 0, 0,
|
||||
SWP_NOMOVE | SWP_NOSIZE);
|
||||
#ifdef DMODEM_WINPORT
|
||||
for (int p = 0; p < PAGES; p++)
|
||||
EnumChildWindows(app.pages[p], lower_group_box, 0);
|
||||
#endif
|
||||
lower_labels(app.pages[p]);
|
||||
}
|
||||
show_page(PAGE_MODEM);
|
||||
SetTimer(w, TIMER_PUMP, 50, NULL);
|
||||
app_state();
|
||||
return 0;
|
||||
}
|
||||
case WM_ACTIVATE: {
|
||||
/* the control with the focus kept while another window (a
|
||||
dialog box) is active, and given back after: the default
|
||||
gives the focus to this window */
|
||||
static HWND last_focus;
|
||||
if (LOWORD(wp) == WA_INACTIVE) {
|
||||
HWND f = GetFocus();
|
||||
if (f && IsChild(w, f))
|
||||
last_focus = f;
|
||||
} else if (last_focus && IsWindow(last_focus) &&
|
||||
IsWindowVisible(last_focus) &&
|
||||
IsWindowEnabled(last_focus)) {
|
||||
SetFocus(last_focus);
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WM_SIZE:
|
||||
layout();
|
||||
return 0;
|
||||
|
||||
@@ -53,21 +53,6 @@ static const char *mark(int kind, bool *wingdings)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DMODEM_WINPORT
|
||||
/* (Linux and macOS, winport/: no Wingdings there; the same pictures from
|
||||
Unicode, in a font that the system has) */
|
||||
static const wchar_t *mark_w(const char *m)
|
||||
{
|
||||
switch (m[0]) {
|
||||
case ':': return L"\x2328"; /* a keyboard */
|
||||
case ';': return L"\x25A3"; /* a box */
|
||||
case ')': return L"\x260E"; /* a telephone */
|
||||
case '*': return L"\x2709"; /* an envelope */
|
||||
default: return L"\x260F"; /* a telephone, white */
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void line(HDC dc, int st, int x0, int x1, int y)
|
||||
{
|
||||
bool dashed = st == DMC_STEP_SETUP || st == DMC_STEP_OFF;
|
||||
@@ -133,12 +118,6 @@ static void paint(HWND w)
|
||||
RECT g = { cx - r, cy - r, cx + r, cy + r };
|
||||
SelectObject(dc, wd ? glyph_font : app.font);
|
||||
SetTextColor(dc, state_color(st));
|
||||
#ifdef DMODEM_WINPORT
|
||||
if (wd)
|
||||
DrawTextW(dc, mark_w(m), -1, &g, DT_CENTER | DT_VCENTER |
|
||||
DT_SINGLELINE | DT_NOPREFIX);
|
||||
else
|
||||
#endif
|
||||
DrawText(dc, m, -1, &g, DT_CENTER | DT_VCENTER | DT_SINGLELINE |
|
||||
DT_NOPREFIX);
|
||||
RECT tt = { x, cy + r + 4, x + cw, cy + r + 4 + th };
|
||||
@@ -185,12 +164,8 @@ HWND pathview_new(HWND parent)
|
||||
LOGFONT lf;
|
||||
memset(&lf, 0, sizeof(lf));
|
||||
lf.lfHeight = -20;
|
||||
#ifdef DMODEM_WINPORT
|
||||
strcpy(lf.lfFaceName, "DejaVu Sans");
|
||||
#else
|
||||
lf.lfCharSet = SYMBOL_CHARSET;
|
||||
strcpy(lf.lfFaceName, "Wingdings");
|
||||
#endif
|
||||
glyph_font = CreateFontIndirect(&lf);
|
||||
}
|
||||
path = dmc_path_new();
|
||||
|
||||
@@ -3,12 +3,6 @@
|
||||
#
|
||||
# cmake -B build -DDMODEM_GUI_WINPORT=ON -DCLANG_RETRO_MFC=/path/to/mfc \
|
||||
# -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
|
||||
#
|
||||
# This is a first pass. The layer does not have serial ports, pipes or
|
||||
# audio (waveOut, waveIn and ACM) yet. The files in include/ and
|
||||
# src/stubs.cpp supply stand-ins: these functions fail, so the app uses
|
||||
# the TCP and SSH links only. When the layer gets these functions,
|
||||
# remove the stand-ins.
|
||||
enable_language(CXX)
|
||||
|
||||
if(NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
@@ -64,10 +58,7 @@ set(APP_RES_CPP "${CMAKE_CURRENT_BINARY_DIR}/app-res.cpp")
|
||||
add_custom_command(OUTPUT "${APP_RES_CPP}"
|
||||
COMMAND ${CMAKE_COMMAND} -E env RC=${DMODEM_LLVM_RC} CXX=${CMAKE_CXX_COMPILER}
|
||||
${Python3_EXECUTABLE} "${CLANG_RETRO_MFC}/port/tools/res2cpp.py"
|
||||
-I "${_win}/src" -I "${_win}/res" app.rc -o "${APP_RES_CPP}"
|
||||
# (app.rc by a relative path: llvm-rc takes an absolute macOS path,
|
||||
# /Users/..., for an option)
|
||||
WORKING_DIRECTORY "${_win}/res"
|
||||
-I "${_win}/src" -I "${_win}/res" "${_win}/res/app.rc" -o "${APP_RES_CPP}"
|
||||
DEPENDS "${_win}/res/app.rc" "${_win}/res/app.manifest" "${_win}/res/dmodem.ico"
|
||||
"${_win}/src/resource.h"
|
||||
COMMENT "Converting app.rc to C++"
|
||||
@@ -76,12 +67,10 @@ add_custom_command(OUTPUT "${APP_RES_CPP}"
|
||||
include("${_win}/sources.cmake")
|
||||
add_executable(dmodem-win32
|
||||
${DMODEM_WIN_SOURCES}
|
||||
src/stubs.cpp
|
||||
"${APP_RES_CPP}")
|
||||
set_target_properties(dmodem-win32 PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON)
|
||||
# Our stand-in headers come first, then the layer's headers.
|
||||
target_include_directories(dmodem-win32 BEFORE PRIVATE
|
||||
include "${CLANG_RETRO_MFC}/port/include" "${_win}/src" "${_win}/res")
|
||||
"${CLANG_RETRO_MFC}/port/include" "${_win}/src" "${_win}/res")
|
||||
target_compile_definitions(dmodem-win32 PRIVATE DMODEM_WINPORT)
|
||||
target_compile_options(dmodem-win32 PRIVATE -Wall -Wno-unused-parameter)
|
||||
target_link_libraries(dmodem-win32 PRIVATE dmodemctl winport)
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright (C) 2026 D-Modem Authors
|
||||
*
|
||||
* commctrl.h - the common controls of the Win32 layer (clang-retro MFC's
|
||||
* port/), with the helper macros of the SDK that the app
|
||||
* uses and the layer does not have yet. (<objidl.h> first:
|
||||
* the layer's commctrl.h needs LPSTREAM, which its
|
||||
* <windows.h> gives only without WIN32_LEAN_AND_MEAN.)
|
||||
*/
|
||||
#ifndef DMODEM_WINPORT_COMMCTRL_H
|
||||
#define DMODEM_WINPORT_COMMCTRL_H
|
||||
#include <windows.h>
|
||||
#include <objidl.h>
|
||||
#include_next <commctrl.h>
|
||||
|
||||
#ifndef ListView_InsertColumn
|
||||
#define ListView_InsertColumn(w, i, c) \
|
||||
(int)SendMessage((w), LVM_INSERTCOLUMN, (WPARAM)(int)(i), (LPARAM)(c))
|
||||
#endif
|
||||
#ifndef ListView_InsertItem
|
||||
#define ListView_InsertItem(w, item) \
|
||||
(int)SendMessage((w), LVM_INSERTITEM, 0, (LPARAM)(item))
|
||||
#endif
|
||||
#ifndef ListView_GetItem
|
||||
#define ListView_GetItem(w, item) \
|
||||
(BOOL)SendMessage((w), LVM_GETITEM, 0, (LPARAM)(item))
|
||||
#endif
|
||||
#ifndef ListView_DeleteAllItems
|
||||
#define ListView_DeleteAllItems(w) \
|
||||
(BOOL)SendMessage((w), LVM_DELETEALLITEMS, 0, 0)
|
||||
#endif
|
||||
#ifndef ListView_GetNextItem
|
||||
#define ListView_GetNextItem(w, i, flags) \
|
||||
(int)SendMessage((w), LVM_GETNEXTITEM, (WPARAM)(int)(i), \
|
||||
MAKELPARAM((flags), 0))
|
||||
#endif
|
||||
#ifndef ListView_SetExtendedListViewStyle
|
||||
#define ListView_SetExtendedListViewStyle(w, ex) \
|
||||
(DWORD)SendMessage((w), LVM_SETEXTENDEDLISTVIEWSTYLE, 0, (LPARAM)(ex))
|
||||
#endif
|
||||
#ifndef ListView_SetItemText
|
||||
#define ListView_SetItemText(w, i, sub, text) \
|
||||
do { \
|
||||
LV_ITEM lvi_; \
|
||||
lvi_.iSubItem = (sub); \
|
||||
lvi_.pszText = (text); \
|
||||
SendMessage((w), LVM_SETITEMTEXT, (WPARAM)(i), \
|
||||
(LPARAM)&lvi_); \
|
||||
} while (0)
|
||||
#endif
|
||||
#ifndef TabCtrl_InsertItem
|
||||
#define TabCtrl_InsertItem(w, i, item) \
|
||||
(int)SendMessage((w), TCM_INSERTITEM, (WPARAM)(int)(i), (LPARAM)(item))
|
||||
#endif
|
||||
#ifndef TabCtrl_GetCurSel
|
||||
#define TabCtrl_GetCurSel(w) (int)SendMessage((w), TCM_GETCURSEL, 0, 0)
|
||||
#endif
|
||||
#ifndef TabCtrl_AdjustRect
|
||||
#define TabCtrl_AdjustRect(w, larger, rc) \
|
||||
(void)SendMessage((w), TCM_ADJUSTRECT, (WPARAM)(BOOL)(larger), (LPARAM)(rc))
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,26 +0,0 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright (C) 2026 D-Modem Authors
|
||||
*
|
||||
* mmreg.h - the MP3 format of the ACM, as the app's audio.cpp names it
|
||||
*/
|
||||
#ifndef DMODEM_WINPORT_MMREG_H
|
||||
#define DMODEM_WINPORT_MMREG_H
|
||||
#include <mmsystem.h>
|
||||
|
||||
#define WAVE_FORMAT_MPEGLAYER3 0x0055
|
||||
#define MPEGLAYER3_WFX_EXTRA_BYTES 12
|
||||
#define MPEGLAYER3_ID_MPEG 1
|
||||
#define MPEGLAYER3_FLAG_PADDING_OFF 0x00000002
|
||||
|
||||
#pragma pack(push, 1)
|
||||
typedef struct mpeglayer3waveformat_tag {
|
||||
WAVEFORMATEX wfx;
|
||||
WORD wID;
|
||||
DWORD fdwFlags;
|
||||
WORD nBlockSize;
|
||||
WORD nFramesPerBlock;
|
||||
WORD nCodecDelay;
|
||||
} MPEGLAYER3WAVEFORMAT, *LPMPEGLAYER3WAVEFORMAT;
|
||||
#pragma pack(pop)
|
||||
#endif
|
||||
@@ -1,77 +0,0 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright (C) 2026 D-Modem Authors
|
||||
*
|
||||
* mmsystem.h - the part of the multimedia API that the app's sound
|
||||
* (audio.cpp, voice.cpp) uses, which the Win32 layer does not
|
||||
* have. First pass: the functions are in src/stubs.cpp and
|
||||
* answer MMSYSERR_NODRIVER (no sound device).
|
||||
*/
|
||||
#ifndef DMODEM_WINPORT_MMSYSTEM_H
|
||||
#define DMODEM_WINPORT_MMSYSTEM_H
|
||||
#include <windows.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef UINT MMRESULT;
|
||||
typedef struct dmodem_hwaveout *HWAVEOUT;
|
||||
typedef struct dmodem_hwavein *HWAVEIN;
|
||||
|
||||
#define MMSYSERR_NOERROR 0
|
||||
#define MMSYSERR_ERROR 1
|
||||
#define MMSYSERR_BADDEVICEID 2
|
||||
#define MMSYSERR_NODRIVER 6
|
||||
#define WAVE_MAPPER ((UINT)-1)
|
||||
#define CALLBACK_WINDOW 0x00010000L
|
||||
#define MM_WOM_DONE 0x3BD
|
||||
#define MM_WIM_DATA 0x3C0
|
||||
#define WHDR_DONE 0x00000001
|
||||
#define WHDR_PREPARED 0x00000002
|
||||
#define WAVE_FORMAT_PCM 1
|
||||
|
||||
#pragma pack(push, 1)
|
||||
typedef struct tWAVEFORMATEX {
|
||||
WORD wFormatTag;
|
||||
WORD nChannels;
|
||||
DWORD nSamplesPerSec;
|
||||
DWORD nAvgBytesPerSec;
|
||||
WORD nBlockAlign;
|
||||
WORD wBitsPerSample;
|
||||
WORD cbSize;
|
||||
} WAVEFORMATEX, *PWAVEFORMATEX, *LPWAVEFORMATEX;
|
||||
#pragma pack(pop)
|
||||
typedef const WAVEFORMATEX *LPCWAVEFORMATEX;
|
||||
|
||||
typedef struct wavehdr_tag {
|
||||
LPSTR lpData;
|
||||
DWORD dwBufferLength;
|
||||
DWORD dwBytesRecorded;
|
||||
DWORD_PTR dwUser;
|
||||
DWORD dwFlags;
|
||||
DWORD dwLoops;
|
||||
struct wavehdr_tag *lpNext;
|
||||
DWORD_PTR reserved;
|
||||
} WAVEHDR, *PWAVEHDR, *LPWAVEHDR;
|
||||
|
||||
MMRESULT WINAPI waveOutOpen(HWAVEOUT *, UINT, LPCWAVEFORMATEX, DWORD_PTR,
|
||||
DWORD_PTR, DWORD);
|
||||
MMRESULT WINAPI waveOutClose(HWAVEOUT);
|
||||
MMRESULT WINAPI waveOutPrepareHeader(HWAVEOUT, LPWAVEHDR, UINT);
|
||||
MMRESULT WINAPI waveOutUnprepareHeader(HWAVEOUT, LPWAVEHDR, UINT);
|
||||
MMRESULT WINAPI waveOutWrite(HWAVEOUT, LPWAVEHDR, UINT);
|
||||
MMRESULT WINAPI waveOutReset(HWAVEOUT);
|
||||
MMRESULT WINAPI waveInOpen(HWAVEIN *, UINT, LPCWAVEFORMATEX, DWORD_PTR,
|
||||
DWORD_PTR, DWORD);
|
||||
MMRESULT WINAPI waveInClose(HWAVEIN);
|
||||
MMRESULT WINAPI waveInPrepareHeader(HWAVEIN, LPWAVEHDR, UINT);
|
||||
MMRESULT WINAPI waveInUnprepareHeader(HWAVEIN, LPWAVEHDR, UINT);
|
||||
MMRESULT WINAPI waveInAddBuffer(HWAVEIN, LPWAVEHDR, UINT);
|
||||
MMRESULT WINAPI waveInStart(HWAVEIN);
|
||||
MMRESULT WINAPI waveInReset(HWAVEIN);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,62 +0,0 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright (C) 2026 D-Modem Authors
|
||||
*
|
||||
* msacm.h - the Audio Compression Manager calls that the app's audio.cpp
|
||||
* uses (greetings in MP3 and compressed WAVs). First pass: the
|
||||
* functions are in src/stubs.cpp and answer MMSYSERR_NODRIVER,
|
||||
* so the app reads only the files that libdmodemctl decodes.
|
||||
*/
|
||||
#ifndef DMODEM_WINPORT_MSACM_H
|
||||
#define DMODEM_WINPORT_MSACM_H
|
||||
#include <mmsystem.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct dmodem_hacmstream *HACMSTREAM;
|
||||
typedef HACMSTREAM *LPHACMSTREAM;
|
||||
typedef struct dmodem_hacmdriver *HACMDRIVER;
|
||||
|
||||
#define ACM_FORMATSUGGESTF_WFORMATTAG 0x00010000L
|
||||
#define ACM_FORMATSUGGESTF_NCHANNELS 0x00020000L
|
||||
#define ACM_FORMATSUGGESTF_NSAMPLESPERSEC 0x00040000L
|
||||
#define ACM_FORMATSUGGESTF_WBITSPERSAMPLE 0x00080000L
|
||||
#define ACM_STREAMOPENF_NONREALTIME 0x00000004L
|
||||
#define ACM_STREAMSIZEF_SOURCE 0x00000000L
|
||||
#define ACM_STREAMCONVERTF_BLOCKALIGN 0x00000004
|
||||
#define ACM_STREAMCONVERTF_START 0x00000010
|
||||
#define ACM_STREAMCONVERTF_END 0x00000020
|
||||
|
||||
typedef struct tACMSTREAMHEADER {
|
||||
DWORD cbStruct;
|
||||
DWORD fdwStatus;
|
||||
DWORD_PTR dwUser;
|
||||
LPBYTE pbSrc;
|
||||
DWORD cbSrcLength;
|
||||
DWORD cbSrcLengthUsed;
|
||||
DWORD_PTR dwSrcUser;
|
||||
LPBYTE pbDst;
|
||||
DWORD cbDstLength;
|
||||
DWORD cbDstLengthUsed;
|
||||
DWORD_PTR dwDstUser;
|
||||
DWORD dwReservedDriver[10];
|
||||
} ACMSTREAMHEADER, *LPACMSTREAMHEADER;
|
||||
|
||||
MMRESULT WINAPI acmFormatSuggest(HACMDRIVER, LPWAVEFORMATEX, LPWAVEFORMATEX,
|
||||
DWORD, DWORD);
|
||||
MMRESULT WINAPI acmStreamOpen(LPHACMSTREAM, HACMDRIVER, LPWAVEFORMATEX,
|
||||
LPWAVEFORMATEX, LPVOID, DWORD_PTR, DWORD_PTR,
|
||||
DWORD);
|
||||
MMRESULT WINAPI acmStreamClose(HACMSTREAM, DWORD);
|
||||
MMRESULT WINAPI acmStreamSize(HACMSTREAM, DWORD, LPDWORD, DWORD);
|
||||
MMRESULT WINAPI acmStreamPrepareHeader(HACMSTREAM, LPACMSTREAMHEADER, DWORD);
|
||||
MMRESULT WINAPI acmStreamUnprepareHeader(HACMSTREAM, LPACMSTREAMHEADER,
|
||||
DWORD);
|
||||
MMRESULT WINAPI acmStreamConvert(HACMSTREAM, LPACMSTREAMHEADER, DWORD);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,100 +0,0 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright (C) 2026 D-Modem Authors
|
||||
*
|
||||
* windows.h - the Win32 layer of clang-retro MFC (port/), and the calls of
|
||||
* the app that it does not have yet: serial ports, anonymous
|
||||
* pipes, the environment block, the user name, Beep and
|
||||
* the declaration of WinMain.
|
||||
* First pass: src/stubs.cpp has them. The serial and pipe
|
||||
* calls fail, so the app reaches a modem through TCP only.
|
||||
*/
|
||||
#ifndef DMODEM_WINPORT_WINDOWS_H
|
||||
#define DMODEM_WINPORT_WINDOWS_H
|
||||
#include_next <windows.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* (the SDK's winbase.h declares it, with C linkage; the layer's crt0
|
||||
calls it) */
|
||||
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int);
|
||||
|
||||
/* (newer layers have the serial ports, the pipes, the environment, the
|
||||
user and Beep themselves: CBR_115200 is theirs then) */
|
||||
#ifdef CBR_115200
|
||||
#define DMODEM_WINPORT_LAYER_KERNEL 1
|
||||
#else
|
||||
/* serial ports */
|
||||
#define CBR_115200 115200
|
||||
#define NOPARITY 0
|
||||
#define ONESTOPBIT 0
|
||||
#define DTR_CONTROL_ENABLE 0x01
|
||||
#define RTS_CONTROL_HANDSHAKE 0x02
|
||||
|
||||
typedef struct _DCB {
|
||||
DWORD DCBlength;
|
||||
DWORD BaudRate;
|
||||
DWORD fBinary : 1;
|
||||
DWORD fParity : 1;
|
||||
DWORD fOutxCtsFlow : 1;
|
||||
DWORD fOutxDsrFlow : 1;
|
||||
DWORD fDtrControl : 2;
|
||||
DWORD fDsrSensitivity : 1;
|
||||
DWORD fTXContinueOnXoff : 1;
|
||||
DWORD fOutX : 1;
|
||||
DWORD fInX : 1;
|
||||
DWORD fErrorChar : 1;
|
||||
DWORD fNull : 1;
|
||||
DWORD fRtsControl : 2;
|
||||
DWORD fAbortOnError : 1;
|
||||
DWORD fDummy2 : 17;
|
||||
WORD wReserved;
|
||||
WORD XonLim;
|
||||
WORD XoffLim;
|
||||
BYTE ByteSize;
|
||||
BYTE Parity;
|
||||
BYTE StopBits;
|
||||
char XonChar;
|
||||
char XoffChar;
|
||||
char ErrorChar;
|
||||
char EofChar;
|
||||
char EvtChar;
|
||||
WORD wReserved1;
|
||||
} DCB, *LPDCB;
|
||||
|
||||
typedef struct _COMMTIMEOUTS {
|
||||
DWORD ReadIntervalTimeout;
|
||||
DWORD ReadTotalTimeoutMultiplier;
|
||||
DWORD ReadTotalTimeoutConstant;
|
||||
DWORD WriteTotalTimeoutMultiplier;
|
||||
DWORD WriteTotalTimeoutConstant;
|
||||
} COMMTIMEOUTS, *LPCOMMTIMEOUTS;
|
||||
|
||||
BOOL WINAPI GetCommState(HANDLE, LPDCB);
|
||||
BOOL WINAPI SetCommState(HANDLE, LPDCB);
|
||||
BOOL WINAPI SetCommTimeouts(HANDLE, LPCOMMTIMEOUTS);
|
||||
BOOL WINAPI SetCommBreak(HANDLE);
|
||||
BOOL WINAPI ClearCommBreak(HANDLE);
|
||||
|
||||
/* anonymous pipes */
|
||||
BOOL WINAPI CreatePipe(PHANDLE, PHANDLE, LPSECURITY_ATTRIBUTES, DWORD);
|
||||
BOOL WINAPI PeekNamedPipe(HANDLE, LPVOID, DWORD, LPDWORD, LPDWORD, LPDWORD);
|
||||
|
||||
/* the environment, the user, the speaker */
|
||||
LPSTR WINAPI dmodem_GetEnvironmentStringsA(void);
|
||||
BOOL WINAPI dmodem_FreeEnvironmentStringsA(LPSTR);
|
||||
#define GetEnvironmentStrings dmodem_GetEnvironmentStringsA
|
||||
#define FreeEnvironmentStrings dmodem_FreeEnvironmentStringsA
|
||||
BOOL WINAPI GetUserNameA(LPSTR, LPDWORD);
|
||||
#ifndef UNICODE
|
||||
#define GetUserName GetUserNameA
|
||||
#endif
|
||||
BOOL WINAPI Beep(DWORD, DWORD);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,3 +0,0 @@
|
||||
/* winsock.h - Winsock 1.1: the Win32 layer has the Winsock 2 header,
|
||||
which has each function of 1.1 */
|
||||
#include <winsock2.h>
|
||||
@@ -1,139 +0,0 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright (C) 2026 D-Modem Authors
|
||||
*
|
||||
* stubs.cpp - the Win32 calls of the app that the Win32 layer of
|
||||
* clang-retro MFC does not have yet (include/). First pass:
|
||||
* the sound, ACM, serial and pipe calls fail, so the app
|
||||
* operates through TCP (a dmodemd that already runs) and
|
||||
* SSH, Telnet and rlogin. Remove each one when the layer
|
||||
* has it.
|
||||
*/
|
||||
#include <windows.h>
|
||||
#include <mmsystem.h>
|
||||
#include <msacm.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
extern char **environ;
|
||||
|
||||
extern "C" {
|
||||
|
||||
/* sound: no device */
|
||||
MMRESULT WINAPI waveOutOpen(HWAVEOUT *, UINT, LPCWAVEFORMATEX, DWORD_PTR,
|
||||
DWORD_PTR, DWORD) { return MMSYSERR_NODRIVER; }
|
||||
MMRESULT WINAPI waveOutClose(HWAVEOUT) { return MMSYSERR_NODRIVER; }
|
||||
MMRESULT WINAPI waveOutPrepareHeader(HWAVEOUT, LPWAVEHDR, UINT) { return MMSYSERR_NODRIVER; }
|
||||
MMRESULT WINAPI waveOutUnprepareHeader(HWAVEOUT, LPWAVEHDR, UINT) { return MMSYSERR_NODRIVER; }
|
||||
MMRESULT WINAPI waveOutWrite(HWAVEOUT, LPWAVEHDR, UINT) { return MMSYSERR_NODRIVER; }
|
||||
MMRESULT WINAPI waveOutReset(HWAVEOUT) { return MMSYSERR_NODRIVER; }
|
||||
MMRESULT WINAPI waveInOpen(HWAVEIN *, UINT, LPCWAVEFORMATEX, DWORD_PTR,
|
||||
DWORD_PTR, DWORD) { return MMSYSERR_NODRIVER; }
|
||||
MMRESULT WINAPI waveInClose(HWAVEIN) { return MMSYSERR_NODRIVER; }
|
||||
MMRESULT WINAPI waveInPrepareHeader(HWAVEIN, LPWAVEHDR, UINT) { return MMSYSERR_NODRIVER; }
|
||||
MMRESULT WINAPI waveInUnprepareHeader(HWAVEIN, LPWAVEHDR, UINT) { return MMSYSERR_NODRIVER; }
|
||||
MMRESULT WINAPI waveInAddBuffer(HWAVEIN, LPWAVEHDR, UINT) { return MMSYSERR_NODRIVER; }
|
||||
MMRESULT WINAPI waveInStart(HWAVEIN) { return MMSYSERR_NODRIVER; }
|
||||
MMRESULT WINAPI waveInReset(HWAVEIN) { return MMSYSERR_NODRIVER; }
|
||||
|
||||
/* ACM: no codecs */
|
||||
MMRESULT WINAPI acmFormatSuggest(HACMDRIVER, LPWAVEFORMATEX, LPWAVEFORMATEX,
|
||||
DWORD, DWORD) { return MMSYSERR_NODRIVER; }
|
||||
MMRESULT WINAPI acmStreamOpen(LPHACMSTREAM, HACMDRIVER, LPWAVEFORMATEX,
|
||||
LPWAVEFORMATEX, LPVOID, DWORD_PTR, DWORD_PTR,
|
||||
DWORD) { return MMSYSERR_NODRIVER; }
|
||||
MMRESULT WINAPI acmStreamClose(HACMSTREAM, DWORD) { return MMSYSERR_NODRIVER; }
|
||||
MMRESULT WINAPI acmStreamSize(HACMSTREAM, DWORD, LPDWORD, DWORD) { return MMSYSERR_NODRIVER; }
|
||||
MMRESULT WINAPI acmStreamPrepareHeader(HACMSTREAM, LPACMSTREAMHEADER, DWORD) { return MMSYSERR_NODRIVER; }
|
||||
MMRESULT WINAPI acmStreamUnprepareHeader(HACMSTREAM, LPACMSTREAMHEADER, DWORD) { return MMSYSERR_NODRIVER; }
|
||||
MMRESULT WINAPI acmStreamConvert(HACMSTREAM, LPACMSTREAMHEADER, DWORD) { return MMSYSERR_NODRIVER; }
|
||||
|
||||
#ifndef DMODEM_WINPORT_LAYER_KERNEL
|
||||
/* serial ports: none */
|
||||
BOOL WINAPI GetCommState(HANDLE, LPDCB)
|
||||
{
|
||||
SetLastError(ERROR_NOT_SUPPORTED);
|
||||
return FALSE;
|
||||
}
|
||||
BOOL WINAPI SetCommState(HANDLE, LPDCB)
|
||||
{
|
||||
SetLastError(ERROR_NOT_SUPPORTED);
|
||||
return FALSE;
|
||||
}
|
||||
BOOL WINAPI SetCommTimeouts(HANDLE, LPCOMMTIMEOUTS)
|
||||
{
|
||||
SetLastError(ERROR_NOT_SUPPORTED);
|
||||
return FALSE;
|
||||
}
|
||||
BOOL WINAPI SetCommBreak(HANDLE)
|
||||
{
|
||||
SetLastError(ERROR_NOT_SUPPORTED);
|
||||
return FALSE;
|
||||
}
|
||||
BOOL WINAPI ClearCommBreak(HANDLE)
|
||||
{
|
||||
SetLastError(ERROR_NOT_SUPPORTED);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* anonymous pipes: none (no dmodemd started by the app) */
|
||||
BOOL WINAPI CreatePipe(PHANDLE, PHANDLE, LPSECURITY_ATTRIBUTES, DWORD)
|
||||
{
|
||||
SetLastError(ERROR_NOT_SUPPORTED);
|
||||
return FALSE;
|
||||
}
|
||||
BOOL WINAPI PeekNamedPipe(HANDLE, LPVOID, DWORD, LPDWORD, LPDWORD, LPDWORD)
|
||||
{
|
||||
SetLastError(ERROR_NOT_SUPPORTED);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* the environment block of Windows (NAME=VALUE\0 ... \0) from environ */
|
||||
LPSTR WINAPI dmodem_GetEnvironmentStringsA(void)
|
||||
{
|
||||
size_t n = 1;
|
||||
for (char **e = environ; *e; e++)
|
||||
n += strlen(*e) + 1;
|
||||
char *block = (char *)malloc(n), *p = block;
|
||||
if (!block)
|
||||
return NULL;
|
||||
for (char **e = environ; *e; e++) {
|
||||
size_t l = strlen(*e) + 1;
|
||||
memcpy(p, *e, l);
|
||||
p += l;
|
||||
}
|
||||
*p = '\0';
|
||||
return block;
|
||||
}
|
||||
BOOL WINAPI dmodem_FreeEnvironmentStringsA(LPSTR block)
|
||||
{
|
||||
free(block);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL WINAPI GetUserNameA(LPSTR name, LPDWORD n)
|
||||
{
|
||||
const char *u = getenv("USER");
|
||||
if (!u)
|
||||
u = getlogin();
|
||||
if (!u || strlen(u) + 1 > *n) {
|
||||
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
||||
return FALSE;
|
||||
}
|
||||
strcpy(name, u);
|
||||
*n = (DWORD)strlen(u) + 1;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* (no speaker: the terminal's bell is MessageBeep) */
|
||||
BOOL WINAPI Beep(DWORD, DWORD)
|
||||
{
|
||||
MessageBeep(MB_OK);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
# A dmodemd for the smoke test: it takes --tcp HOST:PORT, says which
|
||||
# port to use as dmodemd does, and starts the test modem on that port.
|
||||
here=$(cd "$(dirname "$0")" && pwd)
|
||||
port=$(echo "$*" | sed -n 's/.*--tcp [0-9.]*:\([0-9]*\).*/\1/p')
|
||||
echo "test dmodemd: $*"
|
||||
(sleep 1; echo "Use TCP 127.0.0.1:$port as the modem") &
|
||||
exec python3 -u "$here/fake_modem.py" "$port" "$DMODEM_TEST_LOG"
|
||||
@@ -1,32 +1,52 @@
|
||||
#!/bin/sh
|
||||
# The smoke test of the Linux build (winport/): starts the app on an X
|
||||
# display with an empty home folder, and makes sure that it stays up and
|
||||
# sends its first AT commands to a test modem on the TCP port that it
|
||||
# uses by default (127.0.0.1:2323).
|
||||
# The smoke test of the Linux build (winport/). It starts the app on an
|
||||
# X display, with an empty home folder, two times:
|
||||
# 1. With a TCP line (127.0.0.1:2323) to a test modem.
|
||||
# 2. With a dmodemd that the app starts: the test dmodemd in this
|
||||
# folder, found on the PATH, through a pipe (CreatePipe,
|
||||
# CreateProcess with STARTF_USESTDHANDLES and PeekNamedPipe).
|
||||
# Each time, the app must stay up and send its first AT commands.
|
||||
#
|
||||
# DISPLAY=:99 winport/test/smoke.sh build/winport/dmodem-win32
|
||||
set -eu
|
||||
app=$1
|
||||
here=$(cd "$(dirname "$0")" && pwd)
|
||||
tmp=$(mktemp -d)
|
||||
trap 'kill $modem $pid 2>/dev/null || true; rm -rf "$tmp"' EXIT
|
||||
pid= modem=
|
||||
trap 'kill $modem $pid 2>/dev/null || true; pkill -f "fake_modem.py .* $tmp/" 2>/dev/null || true; rm -rf "$tmp"' EXIT
|
||||
|
||||
python3 "$here/fake_modem.py" 2323 "$tmp/modem.log" &
|
||||
# run NAME INI: starts the app with this settings file, and waits for AT
|
||||
# commands in $tmp/NAME.log
|
||||
run() {
|
||||
name=$1
|
||||
rm -rf "$tmp/home"
|
||||
mkdir -p "$tmp/home/.config/D-Modem"
|
||||
printf '%b' "$2" > "$tmp/home/.config/D-Modem/dmodem.ini"
|
||||
HOME="$tmp/home" XDG_CONFIG_HOME= PATH="$here:$PATH" \
|
||||
DMODEM_TEST_LOG="$tmp/$name.log" WINPORT_BACKEND=x11 "$app" &
|
||||
pid=$!
|
||||
i=0
|
||||
while [ $i -lt 20 ]; do
|
||||
sleep 1
|
||||
kill -0 $pid 2>/dev/null || { echo "FAIL ($name): the app stopped"; exit 1; }
|
||||
grep -q '^AT' "$tmp/$name.log" 2>/dev/null && break
|
||||
i=$((i + 1))
|
||||
done
|
||||
grep -q '^AT' "$tmp/$name.log" 2>/dev/null ||
|
||||
{ echo "FAIL ($name): no AT commands"; exit 1; }
|
||||
sleep 2
|
||||
kill -0 $pid 2>/dev/null || { echo "FAIL ($name): the app stopped"; exit 1; }
|
||||
echo "$name: the modem got:"
|
||||
cat "$tmp/$name.log"
|
||||
kill $pid
|
||||
wait $pid 2>/dev/null || true
|
||||
pid=
|
||||
}
|
||||
|
||||
python3 "$here/fake_modem.py" 2323 "$tmp/tcp.log" &
|
||||
modem=$!
|
||||
sleep 1
|
||||
HOME="$tmp/home" WINPORT_BACKEND=x11 "$app" &
|
||||
pid=$!
|
||||
|
||||
i=0
|
||||
while [ $i -lt 20 ]; do
|
||||
sleep 1
|
||||
kill -0 $pid 2>/dev/null || { echo "FAIL: the app stopped"; exit 1; }
|
||||
grep -q '^AT' "$tmp/modem.log" 2>/dev/null && break
|
||||
i=$((i + 1))
|
||||
done
|
||||
grep -q '^AT' "$tmp/modem.log" || { echo "FAIL: no AT commands on the TCP port"; exit 1; }
|
||||
sleep 2
|
||||
kill -0 $pid 2>/dev/null || { echo "FAIL: the app stopped"; exit 1; }
|
||||
echo "The modem got:"
|
||||
cat "$tmp/modem.log"
|
||||
run tcp '[line]\nline=1\ntcp=127.0.0.1:2323\n'
|
||||
# (a USB modem: dmodemd needs no SIP account for it)
|
||||
run dmodemd '[line]\nline=0\nusb=test0\n'
|
||||
echo "PASS"
|
||||