]> gitweb.hhaalo.de Git - feierabend.git/commitdiff
change read from stdin
authorBastian Dehn <hhaalo@arcor.de>
Tue, 10 Dec 2024 18:00:32 +0000 (19:00 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Tue, 10 Dec 2024 18:00:32 +0000 (19:00 +0100)
src/xml.c

index 8896fe74179f6d2ab7cdc60ce47819afe7f1cf10..de0e5245759ed8da8dd7341f94dbb78ee9720ef4 100644 (file)
--- a/src/xml.c
+++ b/src/xml.c
@@ -51,11 +51,11 @@ void free_feierabend(feierabend* fabend)
        fabend->timestr = NULL;
 }
 
-void readFileIntoMemory(const char* file_path, memFile* mem)
+void readStdInIntoMemory(memFile* mem)
 {
        char* buf = malloc(sizeof(char));
        FILE* memstream = open_memstream(mem->data, mem->size);
-       FILE* file = fopen(file_path, "r");
+       FILE* file = fdopen(0, "r");
 
        while(fread(buf, sizeof(char), 1, file) != 0) {
                fwrite(buf, sizeof(char), 1, memstream);
@@ -399,7 +399,7 @@ void addEntry(const char* date,
 {
        memFile* fileContent = malloc(sizeof(memFile));
        init_memFile(fileContent);
-       readFileIntoMemory("/dev/stdin", fileContent);
+       readStdInIntoMemory(fileContent);
 
        char* saldostr = malloc(sizeof(char) * MAX_STRING_LENGTH);
        memset(saldostr, 0, MAX_STRING_LENGTH);