Added a per-document compression interface, Daniel.

This commit is contained in:
Daniel Veillard 1998-09-24 19:15:06 +00:00
parent 52965fa2bc
commit 15a8df4b82
4 changed files with 30 additions and 3 deletions

View File

@ -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

View File

@ -112,6 +112,7 @@ typedef struct xmlDoc {
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 xmlDocDumpMemory(xmlDocPtr cur, CHAR**mem, int *size);
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);

23
tree.c
View File

@ -25,6 +25,8 @@ static CHAR xmlStringText[] = { 't', 'e', 'x', 't', 0 };
int oldXMLWDcompatibility = 0;
int xmlIndentTreeOutput = 1;
static int xmlCompressMode = 0;
/************************************************************************
* *
* Allocation and deallocation of basic structures *
@ -274,6 +276,7 @@ xmlDocPtr xmlNewDoc(const CHAR *version) {
cur->encoding = NULL;
cur->entities = NULL;
cur->standalone = -1;
cur->compression = xmlCompressMode;
return(cur);
}
@ -1155,17 +1158,31 @@ void xmlDocDumpMemory(xmlDocPtr cur, CHAR**mem, int *size) {
}
/*
* 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;
}

3
tree.h
View File

@ -112,6 +112,7 @@ typedef struct xmlDoc {
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 xmlDocDumpMemory(xmlDocPtr cur, CHAR**mem, int *size);
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);