summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLouis Burda <quent.burda@gmail.com>2024-03-21 23:07:08 +0100
committerLouis Burda <quent.burda@gmail.com>2024-03-21 23:07:08 +0100
commit50c6cf07c71367828f8c32eba4427071a3fb24f1 (patch)
tree112d8ff6217dbbcd3f491a7b627aa73d710de956
parent99df364525c9a6119769f01f43c7836890f75ff1 (diff)
downloadvtwrap-master.tar.gz
vtwrap-master.zip
Rename to vtwrapHEADmaster
-rw-r--r--.gitignore2
-rw-r--r--Makefile10
-rw-r--r--vtwrap.c (renamed from apty.c)13
3 files changed, 14 insertions, 11 deletions
diff --git a/.gitignore b/.gitignore
index e1994b5..c0edc06 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1 @@
-apty
+vtwrap
diff --git a/Makefile b/Makefile
index f3a3e0c..657bb4f 100644
--- a/Makefile
+++ b/Makefile
@@ -6,16 +6,16 @@ endif
.PHONY: all clean install uninstall
-all: apty
+all: vtwrap
-apty: apty.c
+vtwrap: vtwrap.c
$(CC) -o $@ $< $(CFLAGS) $(EXTRA_CFLAGS)
clean:
- rm -f apty
+ rm -f vtwrap
install:
- install -m755 apty -t "$(DESTDIR)$(PREFIX)$(BINDIR)"
+ install -m755 vtwrap -t "$(DESTDIR)$(PREFIX)$(BINDIR)"
uninstall:
- rm -f "$(DESTDIR)$(PREFIX)$(BINDIR)/apty"
+ rm -f "$(DESTDIR)$(PREFIX)$(BINDIR)/vtwrap"
diff --git a/apty.c b/vtwrap.c
index 56c3098..be21433 100644
--- a/apty.c
+++ b/vtwrap.c
@@ -1,4 +1,3 @@
-#include <asm-generic/ioctls.h>
#define _XOPEN_SOURCE 600
#define _DEFAULT_SOURCE
@@ -9,15 +8,14 @@
#include <termios.h>
#include <unistd.h>
#include <pty.h>
-#include <err.h>
#include <errno.h>
+
+#include <err.h>
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdlib.h>
-#define MAX_EVENTS 10
-
static char buf[BUFSIZ] = { 0 };
static int
@@ -38,9 +36,14 @@ writeall(int fd, char *buffer, size_t size)
static int
fwd(int in, int out)
{
- static char buffer[8194];
+ static char *buffer = NULL;
ssize_t got, i, last;
+ if (!buffer) {
+ buffer = malloc(BUFSIZ);
+ if (!buffer) err(1, "malloc");
+ }
+
do {
got = read(in, buffer, sizeof(buffer));
if (got < 0) return 1;