Added a per-document compression interface, Daniel.
diff --git a/ChangeLog b/ChangeLog
index 0d9292d..a0d8785 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Thu Sep 24 15:13:29 EDT 1998 Daniel Veillard <Daniel.Veillard@w3.org>
+
+ * tree.c, tree.h: added a per-document compression interface.
+
Tue Sep 22 20:47:38 EDT 1998
* tree.c, tree.h: added saving with compression and added interfaces
diff --git a/include/libxml/tree.h b/include/libxml/tree.h
index 0b27014..b79d4b9 100644
--- a/include/libxml/tree.h
+++ b/include/libxml/tree.h
@@ -112,6 +112,7 @@
char *name; /* name/filename/URI of the document */
const CHAR *version; /* the XML version string */
const CHAR *encoding; /* encoding, if any */
+ int compression;/* level of zlib compression */
int standalone; /* standalone document (no external refs) */
struct xmlDtd *dtd; /* the document DTD if available */
struct xmlNs *oldNs; /* Global namespace, the old way */
@@ -173,6 +174,8 @@
extern void xmlDocDump(FILE *f, xmlDocPtr doc);
int xmlSaveFile(const char *filename, xmlDocPtr cur);
+extern int xmlGetDocCompressMode (xmlDocPtr doc);
+extern void xmlSetDocCompressMode (xmlDocPtr doc, int mode);
extern int xmlGetCompressMode(void);
extern void xmlSetCompressMode(int mode);
diff --git a/tree.c b/tree.c
index c7eba5a..ccd0220 100644
--- a/tree.c
+++ b/tree.c
@@ -25,6 +25,8 @@
int oldXMLWDcompatibility = 0;
int xmlIndentTreeOutput = 1;
+static int xmlCompressMode = 0;
+
/************************************************************************
* *
* Allocation and deallocation of basic structures *
@@ -274,6 +276,7 @@
cur->encoding = NULL;
cur->entities = NULL;
cur->standalone = -1;
+ cur->compression = xmlCompressMode;
return(cur);
}
@@ -1155,17 +1158,31 @@
}
/*
- * Get the compression mode
+ * Get/Set a document compression mode.
*/
-static int xmlCompressMode = 0;
+int xmlGetDocCompressMode (xmlDocPtr doc) {
+ if (doc == NULL) return(-1);
+ return(doc->compression);
+}
+
+void xmlSetDocCompressMode (xmlDocPtr doc, int mode) {
+ if (doc == NULL) return;
+ if (mode < 0) doc->compression = 0;
+ else if (mode > 9) doc->compression = 9;
+ else doc->compression = mode;
+}
+
+/*
+ * Get/Set the global compression mode
+ */
int xmlGetCompressMode(void) {
return(xmlCompressMode);
}
void xmlSetCompressMode(int mode) {
if (mode < 0) xmlCompressMode = 0;
- if (mode > 9) xmlCompressMode = 9;
+ else if (mode > 9) xmlCompressMode = 9;
else xmlCompressMode = mode;
}
diff --git a/tree.h b/tree.h
index 0b27014..b79d4b9 100644
--- a/tree.h
+++ b/tree.h
@@ -112,6 +112,7 @@
char *name; /* name/filename/URI of the document */
const CHAR *version; /* the XML version string */
const CHAR *encoding; /* encoding, if any */
+ int compression;/* level of zlib compression */
int standalone; /* standalone document (no external refs) */
struct xmlDtd *dtd; /* the document DTD if available */
struct xmlNs *oldNs; /* Global namespace, the old way */
@@ -173,6 +174,8 @@
extern void xmlDocDump(FILE *f, xmlDocPtr doc);
int xmlSaveFile(const char *filename, xmlDocPtr cur);
+extern int xmlGetDocCompressMode (xmlDocPtr doc);
+extern void xmlSetDocCompressMode (xmlDocPtr doc, int mode);
extern int xmlGetCompressMode(void);
extern void xmlSetCompressMode(int mode);