diff options
Diffstat (limited to 'c/wget.c')
| -rw-r--r-- | c/wget.c | 18 |
1 files changed, 18 insertions, 0 deletions
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'<chunk>, 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(); +} |
