From: Bastian Dehn Date: Tue, 10 Dec 2024 18:00:32 +0000 (+0100) Subject: change read from stdin X-Git-Tag: 1.3.4^2~1 X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=67a5765ba5ad7edfd92989e1843934006c866922;p=feierabend.git change read from stdin --- diff --git a/src/xml.c b/src/xml.c index 8896fe7..de0e524 100644 --- 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);