mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-08-08 17:42:14 +03:00
Implemented detection of compressed files, setting doc->compressed
* xmlIO.c include/libxml/xmlIO.h parser.c: Implemented detection of compressed files, setting doc->compressed appropriately (bug #120503).
This commit is contained in:
@@ -1,3 +1,9 @@
|
|||||||
|
Sun Sep 7 19:58:33 PTD 2003 William Brack <wbrack@mmm.com.hk>
|
||||||
|
|
||||||
|
* xmlIO.c include/libxml/xmlIO.h parser.c: Implemented detection
|
||||||
|
of compressed files, setting doc->compressed appropriately
|
||||||
|
(bug #120503).
|
||||||
|
|
||||||
Sun Sep 7 22:53:06 CEST 2003 Daniel Veillard <daniel@veillard.com>
|
Sun Sep 7 22:53:06 CEST 2003 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
* parser.c: try to cope with the fact that apps may still
|
* parser.c: try to cope with the fact that apps may still
|
||||||
|
@@ -129,6 +129,7 @@ struct _xmlParserInputBuffer {
|
|||||||
|
|
||||||
xmlBufferPtr buffer; /* Local buffer encoded in UTF-8 */
|
xmlBufferPtr buffer; /* Local buffer encoded in UTF-8 */
|
||||||
xmlBufferPtr raw; /* if encoder != NULL buffer for raw input */
|
xmlBufferPtr raw; /* if encoder != NULL buffer for raw input */
|
||||||
|
int compressed; /* -1=unknown, 0=not compressed, 1=compressed */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
10
parser.c
10
parser.c
@@ -2923,7 +2923,7 @@ get_more:
|
|||||||
SHRINK;
|
SHRINK;
|
||||||
GROW;
|
GROW;
|
||||||
in = ctxt->input->cur;
|
in = ctxt->input->cur;
|
||||||
} while ((*in >= 0x20) && (*in <= 0x7F) || (*in == 0x09));
|
} while (((*in >= 0x20) && (*in <= 0x7F)) || (*in == 0x09));
|
||||||
nbchar = 0;
|
nbchar = 0;
|
||||||
}
|
}
|
||||||
ctxt->input->line = line;
|
ctxt->input->line = line;
|
||||||
@@ -11345,7 +11345,13 @@ xmlSAXParseFileWithData(xmlSAXHandlerPtr sax, const char *filename,
|
|||||||
|
|
||||||
xmlParseDocument(ctxt);
|
xmlParseDocument(ctxt);
|
||||||
|
|
||||||
if ((ctxt->wellFormed) || recovery) ret = ctxt->myDoc;
|
if ((ctxt->wellFormed) || recovery) {
|
||||||
|
ret = ctxt->myDoc;
|
||||||
|
if (ctxt->input->buf->compressed > 0)
|
||||||
|
ret->compression = 9;
|
||||||
|
else
|
||||||
|
ret->compression = ctxt->input->buf->compressed;
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
ret = NULL;
|
ret = NULL;
|
||||||
xmlFreeDoc(ctxt->myDoc);
|
xmlFreeDoc(ctxt->myDoc);
|
||||||
|
26
xmlIO.c
26
xmlIO.c
@@ -1588,6 +1588,7 @@ xmlAllocParserInputBuffer(xmlCharEncoding enc) {
|
|||||||
ret->readcallback = NULL;
|
ret->readcallback = NULL;
|
||||||
ret->closecallback = NULL;
|
ret->closecallback = NULL;
|
||||||
ret->context = NULL;
|
ret->context = NULL;
|
||||||
|
ret->compressed = -1;
|
||||||
|
|
||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
@@ -1698,13 +1699,6 @@ xmlOutputBufferClose(xmlOutputBufferPtr out) {
|
|||||||
return( ( err_rc == 0 ) ? written : err_rc );
|
return( ( err_rc == 0 ) ? written : err_rc );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* xmlParserInputBufferCreateFname:
|
|
||||||
* @URI: a C string containing the URI or filename
|
|
||||||
* @enc: the charset encoding if known
|
|
||||||
*
|
|
||||||
* Returns the new parser input or NULL
|
|
||||||
*/
|
|
||||||
/**
|
/**
|
||||||
* xmlParserInputBufferCreateFilename:
|
* xmlParserInputBufferCreateFilename:
|
||||||
* @URI: a C string containing the URI or filename
|
* @URI: a C string containing the URI or filename
|
||||||
@@ -1729,9 +1723,6 @@ xmlParserInputBufferCreateFilename(const char *URI, xmlCharEncoding enc) {
|
|||||||
|
|
||||||
if (URI == NULL) return(NULL);
|
if (URI == NULL) return(NULL);
|
||||||
|
|
||||||
#ifdef LIBXML_CATALOG_ENABLED
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Try to find one of the input accept method accepting that scheme
|
* Try to find one of the input accept method accepting that scheme
|
||||||
* Go in reverse to give precedence to user defined handlers.
|
* Go in reverse to give precedence to user defined handlers.
|
||||||
@@ -1758,6 +1749,21 @@ xmlParserInputBufferCreateFilename(const char *URI, xmlCharEncoding enc) {
|
|||||||
ret->context = context;
|
ret->context = context;
|
||||||
ret->readcallback = xmlInputCallbackTable[i].readcallback;
|
ret->readcallback = xmlInputCallbackTable[i].readcallback;
|
||||||
ret->closecallback = xmlInputCallbackTable[i].closecallback;
|
ret->closecallback = xmlInputCallbackTable[i].closecallback;
|
||||||
|
#ifdef HAVE_ZLIB_H
|
||||||
|
if (xmlInputCallbackTable[i].opencallback == xmlGzfileOpen) {
|
||||||
|
if (((z_stream *)context)->avail_in > 4) {
|
||||||
|
char *cptr, buff4[4];
|
||||||
|
cptr = ((z_stream *)context)->next_in;
|
||||||
|
if (gzread(context, buff4, 4) == 4) {
|
||||||
|
if (strncmp(buff4, cptr, 4) == 0)
|
||||||
|
ret->compressed = 0;
|
||||||
|
else
|
||||||
|
ret->compressed = 1;
|
||||||
|
gzrewind(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user