From 2eea5bc2684c84aeaeba4a1f374ab96eb74b7885 Mon Sep 17 00:00:00 2001 From: epoch Date: Mon, 6 Apr 2020 05:55:20 -0500 Subject: fixed hackvr_term's pty.c so I don't have to use python for getting a pty. --- share/hackvr/examples/hackvr_term/pty.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'share') diff --git a/share/hackvr/examples/hackvr_term/pty.c b/share/hackvr/examples/hackvr_term/pty.c index 1011e38..d894359 100644 --- a/share/hackvr/examples/hackvr_term/pty.c +++ b/share/hackvr/examples/hackvr_term/pty.c @@ -1,12 +1,17 @@ +#define _XOPEN_SOURCE 500 //ptsname +#define _XOPEN_SOURCE_EXTENDED #include #include #include +#include +#include int main(int argc,char *argv[]) { char *pts; - char in[256];//I dunno. + char in;//I dunno. int r; int pid; + int eof1,eof2; int master,slave; master=open("/dev/ptmx",O_RDWR); if(master == -1) return 1; @@ -42,20 +47,22 @@ int main(int argc,char *argv[]) { default: break; } - for(;;) { + eof1=0; + eof2=0; + for(;!(eof1 || eof2);) { if(waitpid(-1,0,WNOHANG) > 0) { return 0;//fuck if I know. //we got a dead child. let's bail. } switch(r=read(0,&in,1)) { - case 0: return 6;//EOF + case 0: eof1=1;;//EOF case -1: break;//EAGAIN probably. - default: write(master,in,r); + default: write(master,&in,r); } switch(r=read(master,&in,1)) { - case 0: return 7;//EOF + case 0: eof2=1;;//EOF case -1: break;//EAGAIN probably - default: write(1,in,r); + default: write(1,&in,r); } usleep(100);//kek } -- cgit v1.2.3 From cfa28d6442dbb4b8037b5538f7bbd95604c261de Mon Sep 17 00:00:00 2001 From: epoch Date: Mon, 6 Apr 2020 05:59:47 -0500 Subject: lol. the order of the arguments has been backwards the whole time --- share/hackvr/examples/hackvr_term/hackvr_term.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'share') diff --git a/share/hackvr/examples/hackvr_term/hackvr_term.c b/share/hackvr/examples/hackvr_term/hackvr_term.c index 71f2492..40df2d1 100644 --- a/share/hackvr/examples/hackvr_term/hackvr_term.c +++ b/share/hackvr/examples/hackvr_term/hackvr_term.c @@ -151,7 +151,7 @@ void callback(tmt_msg_t m,TMT *vt, const void *a,void *vt_old) { int main(int argc,char *argv[]) { char in[16]; - if(argc < 3) return fprintf(stderr,"usage: ./hackvr_term rows cols\n"),1; + if(argc < 3) return fprintf(stderr,"usage: ./hackvr_term cols rows\n"),1; int r=atoi(argv[2]); int ret=0; int c=atoi(argv[1]); -- cgit v1.2.3 From 48fe341421279208e090f9d25794aa59a02de8ec Mon Sep 17 00:00:00 2001 From: epoch Date: Mon, 6 Apr 2020 06:03:32 -0500 Subject: added better error checking to not just assume EAGAIN --- share/hackvr/examples/hackvr_term/pty.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'share') diff --git a/share/hackvr/examples/hackvr_term/pty.c b/share/hackvr/examples/hackvr_term/pty.c index d894359..6903bc3 100644 --- a/share/hackvr/examples/hackvr_term/pty.c +++ b/share/hackvr/examples/hackvr_term/pty.c @@ -5,6 +5,7 @@ #include #include #include +#include int main(int argc,char *argv[]) { char *pts; @@ -56,12 +57,12 @@ int main(int argc,char *argv[]) { } switch(r=read(0,&in,1)) { case 0: eof1=1;;//EOF - case -1: break;//EAGAIN probably. + case -1: if(errno != EAGAIN) eof1=1; break;//EAGAIN probably. default: write(master,&in,r); } switch(r=read(master,&in,1)) { case 0: eof2=1;;//EOF - case -1: break;//EAGAIN probably + case -1: if(errno != EAGAIN) eof2=1; break;//EAGAIN probably default: write(1,&in,r); } usleep(100);//kek -- cgit v1.2.3 From 2edcce43083ec0437521b294eee545227fb77e59 Mon Sep 17 00:00:00 2001 From: epoch Date: Mon, 6 Apr 2020 06:03:57 -0500 Subject: added a new script to try to just get a single line of test from the user --- share/hackvr/examples/hackvr_term/read_line.sh | 5 +++++ 1 file changed, 5 insertions(+) create mode 100755 share/hackvr/examples/hackvr_term/read_line.sh (limited to 'share') diff --git a/share/hackvr/examples/hackvr_term/read_line.sh b/share/hackvr/examples/hackvr_term/read_line.sh new file mode 100755 index 0000000..c26ebf3 --- /dev/null +++ b/share/hackvr/examples/hackvr_term/read_line.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +./hackvr_data_decode.sh \ + | ./pty `which bash` "-c" 'read -p "type> " line;xmessage $line' \ + | ./hackvr_term 60 2 \ + | sed -u 's/addshape 15 4/addshape 12 4/g' -- cgit v1.2.3 From f43bc654684239198fc793df536319bd73a38d7f Mon Sep 17 00:00:00 2001 From: epoch Date: Mon, 6 Apr 2020 06:04:22 -0500 Subject: added an exec --- share/hackvr/examples/hackvr_term/hackvr_data_decode.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'share') diff --git a/share/hackvr/examples/hackvr_term/hackvr_data_decode.sh b/share/hackvr/examples/hackvr_term/hackvr_data_decode.sh index 0ac04f2..307b6ff 100755 --- a/share/hackvr/examples/hackvr_term/hackvr_data_decode.sh +++ b/share/hackvr/examples/hackvr_term/hackvr_data_decode.sh @@ -1,2 +1,2 @@ #!/bin/sh -grep --line-buffered '^[^ ]* data ' | stdbuf -oL tr -s ' ' | stdbuf -oL cut '-d ' -f3- | stdbuf -o0 xxd -r -p +exec grep --line-buffered '^[^ ]* data ' | stdbuf -oL tr -s ' ' | stdbuf -oL cut '-d ' -f3- | stdbuf -o0 xxd -r -p -- cgit v1.2.3 From 1cca9c35f1837ba0eb324593cdb8d5778fa9b7e3 Mon Sep 17 00:00:00 2001 From: epoch Date: Tue, 7 Apr 2020 06:51:48 -0500 Subject: moved hackvr_coproc into main bin dir. added example uristart.conf file for hackvr URIs. fixed calvr makefile to not do hackvr_coproc --- bin/hackvr_coproc | 2 ++ share/hackvr/examples/calendar/Makefile | 3 +-- share/hackvr/examples/calendar/hackvr_coproc | 2 -- share/hackvr/examples/uristart.conf | 2 ++ 4 files changed, 5 insertions(+), 4 deletions(-) create mode 100755 bin/hackvr_coproc delete mode 100755 share/hackvr/examples/calendar/hackvr_coproc create mode 100644 share/hackvr/examples/uristart.conf (limited to 'share') diff --git a/bin/hackvr_coproc b/bin/hackvr_coproc new file mode 100755 index 0000000..d79de92 --- /dev/null +++ b/bin/hackvr_coproc @@ -0,0 +1,2 @@ +#!/bin/sh +exec socat "exec:hackvr_uri" "exec:$*" diff --git a/share/hackvr/examples/calendar/Makefile b/share/hackvr/examples/calendar/Makefile index 2027b18..1646279 100644 --- a/share/hackvr/examples/calendar/Makefile +++ b/share/hackvr/examples/calendar/Makefile @@ -1,8 +1,7 @@ PREFIX:=/usr/local -all: calvr hackvr_coproc +all: calvr @echo using PREFIX: $(PREFIX) install: install -t $(PREFIX)/bin calvr - install -t $(PREFIX)/bin hackvr_coproc diff --git a/share/hackvr/examples/calendar/hackvr_coproc b/share/hackvr/examples/calendar/hackvr_coproc deleted file mode 100755 index 8d2e127..0000000 --- a/share/hackvr/examples/calendar/hackvr_coproc +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -exec socat exec:hackvr "exec:$*" diff --git a/share/hackvr/examples/uristart.conf b/share/hackvr/examples/uristart.conf new file mode 100644 index 0000000..d48e8d1 --- /dev/null +++ b/share/hackvr/examples/uristart.conf @@ -0,0 +1,2 @@ +hackvr: if [ "%u" ];then USER="%u";fi;ncat '%d' '%P' -c "echo $USER action %p;hackvr_uri" +hackvr+ssh: if [ '%u' ];then u='%u@';fi ; if [ "%P" ];then P='-p %P';fi; hackvr_coproc ssh "$u"'%d' $P "/var/hackvr/hackvr-subsystem" '%p' -- cgit v1.2.3