diff options
| author | Louis Burda <quent.burda@gmail.com> | 2024-03-21 23:07:08 +0100 |
|---|---|---|
| committer | Louis Burda <quent.burda@gmail.com> | 2024-03-21 23:07:08 +0100 |
| commit | 50c6cf07c71367828f8c32eba4427071a3fb24f1 (patch) | |
| tree | 112d8ff6217dbbcd3f491a7b627aa73d710de956 | |
| parent | 99df364525c9a6119769f01f43c7836890f75ff1 (diff) | |
| download | vtwrap-master.tar.gz vtwrap-master.zip | |
| -rw-r--r-- | .gitignore | 2 | ||||
| -rw-r--r-- | Makefile | 10 | ||||
| -rw-r--r-- | vtwrap.c (renamed from apty.c) | 13 |
3 files changed, 14 insertions, 11 deletions
@@ -1 +1 @@ -apty +vtwrap @@ -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" @@ -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; |
