summaryrefslogtreecommitdiff
path: root/interliner.c
diff options
context:
space:
mode:
Diffstat (limited to 'interliner.c')
-rw-r--r--interliner.c78
1 files changed, 78 insertions, 0 deletions
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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <fcntl.h>
+#include <unistd.h>
+
+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;
+}