From 232c1cb726c809599ce69dbeda7f7f716f106801 Mon Sep 17 00:00:00 2001 From: Mikhail Kobuk Date: Sat, 6 Apr 2024 16:00:01 +0300 Subject: Pre-EUPM build draft TODO: convert to fakeroot TODO: separate most modules TODO: revise config TODO: adjust logging TODO: rework patch listing TODO: update patch selection --- interliner.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 interliner.c (limited to 'interliner.c') diff --git a/interliner.c b/interliner.c new file mode 100644 index 0000000..17937df --- /dev/null +++ b/interliner.c @@ -0,0 +1,78 @@ +#include +#include +#include + +#include +#include + +int +main(int argc, char *argv[]) +{ + //char *string = NULL; + //size_t sz = 0; + + int fd = open("log.log", O_WRONLY | O_CREAT | O_APPEND, 0660); + if (fd < 0) { + return 1; + } + + char msg[100] = "\nnew log =======\n"; + write(fd, &msg, sizeof(msg)); + + char sstring[4096] = {}; + ssize_t pos = 0; + + int c = getchar(); + while (c != EOF) { + switch (c) { + case '\n': + sstring[pos] = '\0'; + printf("\r%s", sstring); + fflush(stdout); + pos = 0; + break; + default: + sstring[pos++] = c; + break; + } + c = getchar(); + } + + putchar('\n'); + + //while (getline(&string, &sz, stdin) > 0) { + // if (!sz) { + // continue; + // } + + // char *reader = string; + // putchar(*reader); + // write(fd, reader, 1); + // fflush(stdout); + // char *writer = string; + + // while ((reader - string) < sz) { + // if (*reader == '\n') { + // *reader = '\0'; + // break; + // } + + // write(fd, "<", 1); + // write(fd, reader, 1); + // write(fd, ">", 1); + // *(reader++) = *(writer++); + // } + + // printf("\r%s", string); + // write(fd, "!", 1); + + // free(string); + // string = NULL; + //} + + close(fd); + + //free(string); + + return 0; +} -- cgit v1.2.3