lv2 rework, sams ffmpeg icons, elision patch
[goodguy/history.git] / cinelerra-5.1 / cinelerra / filexml.C
index aef297e41adf822d9c697cda88a7cdb05130dbe0..5390617b05782be862a806c66c9579abe9b6ec41 100644 (file)
@@ -58,7 +58,7 @@ XMLBuffer::XMLBuffer(const char *buf, long buf_size, int del)
        destroy = del;
 }
 
-XMLBuffer::XMLBuffer(long buf_size, const char *buf, int del)
+XMLBuffer::XMLBuffer(long buf_size, char *buf, int del)
 {      // writing
        bfr = (unsigned char *)buf;
        bsz = buf_size;
@@ -73,9 +73,10 @@ XMLBuffer::~XMLBuffer()
        if( destroy ) delete [] bfr;
 }
 
-unsigned char *&XMLBuffer::demand(long len)
+int XMLBuffer::demand(long len)
 {
        if( len > bsz ) {
+               if( !destroy ) return 0;
                long sz = inp-bfr;
                len += sz/2 + BCTEXTLEN;
                unsigned char *np = new unsigned char[len];
@@ -85,13 +86,13 @@ unsigned char *&XMLBuffer::demand(long len)
                lmt = np + len;  bsz = len;
                delete [] bfr;   bfr = np;
        }
-       return bfr;
+       return 1;
 }
 
 int XMLBuffer::write(const char *bp, int len)
 {
-       if( !destroy && lmt-inp < len ) len = lmt-inp;
        if( len <= 0 ) return 0;
+       if( !destroy && lmt-inp < len ) len = lmt-inp;
        demand(otell()+len);
        memmove(inp,bp,len);
        inp += len;
@@ -489,7 +490,7 @@ int FileXML::skip_tag()
        return 1;
 }
 
-int FileXML::read_data_until(const char *tag_end, char *out, int len)
+int FileXML::read_data_until(const char *tag_end, char *out, int len, int skip)
 {
        long ipos = buffer->itell();
        int opos = 0, pos = -1;
@@ -518,15 +519,15 @@ int FileXML::read_data_until(const char *tag_end, char *out, int len)
                ++pos;
        }
 // if end tag is reached, pos is left on the < of the end tag
-       if( pos >= 0 && !tag_end[pos] )
+       if( !skip && pos >= 0 && !tag_end[pos] )
                buffer->iseek(ipos);
        return opos;
 }
 
-int FileXML::read_text_until(const char *tag_end, char *out, int len)
+int FileXML::read_text_until(const char *tag_end, char *out, int len, int skip)
 {
        char data[len+1];
-       int opos = read_data_until(tag_end, data, len);
+       int opos = read_data_until(tag_end, data, len, skip);
        decode(out, data, opos);
        return 0;
 }