summaryrefslogtreecommitdiff
path: root/src/cmd/netdog
diff options
context:
space:
mode:
authordzwdz2023-09-22 23:42:30 +0200
committerdzwdz2023-09-22 23:42:30 +0200
commit6a4d4a41a664e6a4c406a449ea847abd4a224bcf (patch)
tree0a637697c8697929beb8f4b7ff69d8b74f9e28bb /src/cmd/netdog
parenta3d6aa9f8d427b86a33dc05bed98a2e88229a285 (diff)
build: support single file commands
Diffstat (limited to 'src/cmd/netdog')
-rw-r--r--src/cmd/netdog/nd.c48
1 files changed, 0 insertions, 48 deletions
diff --git a/src/cmd/netdog/nd.c b/src/cmd/netdog/nd.c
deleted file mode 100644
index 221dc9c..0000000
--- a/src/cmd/netdog/nd.c
+++ /dev/null
@@ -1,48 +0,0 @@
-#include <camellia.h>
-#include <camellia/compat.h>
-#include <camellia/syscalls.h>
-#include <err.h>
-#include <stdio.h>
-#include <string.h>
-#include <thread.h>
-
-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) {
- fprintf(stderr, "usage: netdog /net/connect/source/target/proto/port\n");
- return 1;
- }
-
- conn = camellia_open(argv[1], OPEN_RW);
- if (conn < 0) {
- err(1, "open %s", argv[1]);
- return -conn;
- }
-
- thread_create(0, send_stdin, NULL);
- thread_create(0, recv_stdout, NULL);
- _sys_await();
- return 0;
-}