summaryrefslogtreecommitdiff
path: root/src/user/app/netdog
diff options
context:
space:
mode:
authordzwdz2023-08-14 18:51:07 +0200
committerdzwdz2023-08-14 18:51:07 +0200
commit642b5fb0007b64c77d186fcb018d571152ee1d47 (patch)
tree1c466461f3602d306be309a053edae558ef2568e /src/user/app/netdog
parent8050069c57b729c18c19b1a03ab6e4bf63b4735e (diff)
reorganization: first steps
Diffstat (limited to 'src/user/app/netdog')
-rw-r--r--src/user/app/netdog/nd.c48
1 files changed, 0 insertions, 48 deletions
diff --git a/src/user/app/netdog/nd.c b/src/user/app/netdog/nd.c
deleted file mode 100644
index af5c264..0000000
--- a/src/user/app/netdog/nd.c
+++ /dev/null
@@ -1,48 +0,0 @@
-#include <camellia.h>
-#include <camellia/syscalls.h>
-#include <stdio.h>
-#include <string.h>
-#include <thread.h>
-
-#define eprintf(fmt, ...) fprintf(stderr, "netdog: "fmt"\n" __VA_OPT__(,) __VA_ARGS__)
-
-hid_t conn;
-
-void send_stdin(void *arg) { (void)arg;
- static char buf[4096];
- for (;;) {
- // TODO define STDIN_FILENO
- long ret = _sys_read(0, buf, sizeof buf, -1);
- if (ret <= 0) return; /* instead of sending an empty packet, quit. */
- ret = _sys_write(conn, buf, ret, -1, 0);
- if (ret < 0) return;
- }
-}
-
-void recv_stdout(void *arg) { (void)arg;
- static char buf[4096];
- for (;;) {
- long ret = _sys_read(conn, buf, sizeof buf, -1);
- if (ret < 0) return;
- ret = _sys_write(1, buf, ret, -1, 0);
- if (ret < 0) return;
- }
-}
-
-int main(int argc, char **argv) {
- if (argc < 2) {
- eprintf("no argument");
- return 1;
- }
-
- conn = camellia_open(argv[1], OPEN_RW);
- if (conn < 0) {
- eprintf("couldn't open '%s', err %u", argv[1], -conn);
- return -conn;
- }
-
- thread_create(0, send_stdin, NULL);
- thread_create(0, recv_stdout, NULL);
- _sys_await();
- return 0;
-}