From 51a4ec0fa2339041685efecf11d17b2541880c91 Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Mon, 9 Dec 2024 18:45:10 +0100 Subject: [PATCH] add read saldo out memory stream --- src/xml.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/xml.c b/src/xml.c index c9f71f3..af5b897 100644 --- a/src/xml.c +++ b/src/xml.c @@ -322,13 +322,13 @@ void createEntry(int begin_hour, xmlWriter = NULL; } -void readLastSaldo(const char* file_path, char* value) +void readLastSaldo(memFile* mem, char* value) { xmlInitParser(); - xmlDocPtr xmldoc = xmlReadFile(file_path, "UTF-8", 0); + xmlDocPtr xmldoc = xmlReadMemory(*mem->data, *mem->size, NULL, "UTF-8", 0); if (xmldoc == NULL) { - printf("ERROR: could not open file: %s\n", file_path); + printf("ERROR: could not open memstream\n"); exit(EXIT_FAILURE); } @@ -400,7 +400,7 @@ void addEntry(const char* date, char* saldostr = malloc(sizeof(char) * MAX_STRING_LENGTH); memset(saldostr, 0, MAX_STRING_LENGTH); - readLastSaldo(file_path, saldostr); + readLastSaldo(fileContent, saldostr); xmlChar* xmlElemContent = NULL; xmlTextWriterPtr xmlwriter = xmlNewTextWriterFilename("/dev/stdout", 0); -- 2.39.5