]> gitweb.hhaalo.de Git - feierabend.git/commitdiff
add read saldo out memory stream
authorBastian Dehn <hhaalo@arcor.de>
Mon, 9 Dec 2024 17:45:10 +0000 (18:45 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Mon, 9 Dec 2024 17:45:10 +0000 (18:45 +0100)
src/xml.c

index c9f71f33fac04be201ba055bc9450e3808346e92..af5b89785677fb09b4fd4a2e992b0c16ad5aa122 100644 (file)
--- 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);