From 62171c761c72f7bc515b20361d043bfd239f71c9 Mon Sep 17 00:00:00 2001 From: user Date: Fri, 17 Jul 2026 01:31:38 +0200 Subject: net: wget - real HTTP over the link port via the gateway Grow the link-port demo from echo to actual network access. The Game Boy still only does SLIP framing + display; the host gateway does DNS/TCP/HTTP. - c/netlib.h: SLIP framing factored out (header-only, per-program copy). necho.c now uses it too. - c/wget.c: `wget URL` frames the URL, then prints the reply body. The gateway streams the body back as typed frames: 'D' ... 'E'. - tools/gateway.py: add --mode http (urlopen the frame as a URL, cap the body, chunk it) alongside --mode echo; --cmd runs any gbos command. Verified: `wget example.com` streams back the full Example Domain HTML onto the terminal; `wget sl0p.foo` fetches the real page. A Game Boy on the web, over the link cable. --- c/wget.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 c/wget.c (limited to 'c/wget.c') diff --git a/c/wget.c b/c/wget.c new file mode 100644 index 0000000..013b326 --- /dev/null +++ b/c/wget.c @@ -0,0 +1,18 @@ +#include "netlib.h" +/* wget URL : send the URL to the host gateway over SLIP, print the reply body. + The gateway does the real DNS/TCP/HTTP and streams the body back as frames: + each reply frame is 'D', ending with a single 'E' frame. */ +void main(void) { + char *argv[4]; + unsigned char argc = argv_parse(argv, 4); + char buf[220]; + unsigned char len, i; + if (argc < 1) { puts("usage: wget URL"); nl(); return; } + slip_send(argv[0], strlen(argv[0])); + for (;;) { + len = slip_recv(buf, 219); + if (len >= 1 && buf[0] == 'E') break; /* end of stream */ + for (i = 1; i < len; i++) putc(buf[i]); /* skip the 'D' type byte */ + } + nl(); +} -- cgit v1.3.1-sl0p