Tcl Source Code

Check-in [723a16de60]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Assorted minor corrections to the Zlib C API to make it work with the PNG implementation better.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | potential incompatibility
Files: files | file ages | folders
SHA1: 723a16de608c37e4c62e49f521299789cec06491
User & Date: dkf 2008-12-27 00:04:17
Context
2008-12-27
10:07
Fix my silly blunders. [Bug 2470237] check-in: 5ddf0f02bb user: dkf tags: trunk
00:04
Assorted minor corrections to the Zlib C API to make it work with the PNG implementation better. check-in: 723a16de60 user: dkf tags: trunk, potential incompatibility
2008-12-26
09:51
Updated comments in tcl.decls based on code archaeology. check-in: 64cea92e63 user: dkf tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ChangeLog.














1
2
3
4
5
6
7












2008-12-26  Donal K. Fellows  <[email protected]>

	* generic/tcl.decls: Tidy up the commenting style, adding markers for
	each of the big release points under TCT stewardship and noting the
	general purpose of each TIP that added C API. Overall effect is to
	make this file much more informative to read without having to spend
	effort correlating with TIPs and ChangeLogs.
>
>
>
>
>
>
>
>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2008-12-27  Donal K. Fellows  <[email protected]>

	* generic/tclZlib.c (Tcl_ZlibStreamGet): Corrected the semantics of
	this function to be useful to the PNG implementation. If the argument
	object is empty, this gives the previous semantics.
	(Tcl_ZlibStreamChecksum): Corrected name to be less misleading; it
	only produced Adler-32 checksums when the stream was processing the
	right type of compressed data format.
	(Tcl_ZlibAdler32, Tcl_ZlibCRC32): Corrected types so that they work
	naturally with the results of Tcl_GetByteArrayFromObj().
	*** POTENTIAL INCOMPATIBILITY *** for all above changes, but very
	unlikely to be difficult for anyone to deal with.

2008-12-26  Donal K. Fellows  <[email protected]>

	* generic/tcl.decls: Tidy up the commenting style, adding markers for
	each of the big release points under TCT stewardship and noting the
	general purpose of each TIP that added C API. Overall effect is to
	make this file much more informative to read without having to spend
	effort correlating with TIPs and ChangeLogs.

Changes to doc/TclZlib.3.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
..
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56

57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
...
118
119
120
121
122
123
124

125
126
127

128
129


130
131





132
133
134

135
136

137
138
139
140
141
142
143
144
145
146
147
148
'\"
'\" Copyright (c) 2008 Donal K. Fellows
'\"
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\" 
'\" RCS: @(#) $Id: TclZlib.3,v 1.3 2008/12/21 08:17:37 dkf Exp $
'\" 
.so man.macros
.TH TclZlib 3 8.6 Tcl "Tcl Library Procedures"
.BS
'\" Note:  do not modify the .SH NAME line immediately below!
.SH NAME
Tcl_ZlibAdler32, Tcl_ZlibCRC32, Tcl_ZlibDeflate, Tcl_ZlibInflate, Tcl_ZlibStreamAdler32, Tcl_ZlibStreamClose, Tcl_ZlibStreamEof, Tcl_ZlibStreamGet, Tcl_ZlibStreamGetCommandName, Tcl_ZlibStreamInit, Tcl_ZlibStreamPut \- compression and decompression functions
.SH SYNOPSIS
.nf
#include <tcl.h>
.sp
Tcl_Obj *
\fBTcl_ZlibDeflate\fR(\fIinterp, format, dataObj, level, dictObj\fR)
.sp
................................................................................
int
\fBTcl_ZlibStreamEof\fR(\fIzshandle\fR)
.sp
int
\fBTcl_ZlibStreamClose\fR(\fIzshandle\fR)
.sp
int
\fBTcl_ZlibStreamAdler32\fR(\fIzshandle\fR)
.sp
int
\fBTcl_ZlibStreamPut\fR(\fIzshandle, dataObj, flush\fR)
.sp
int
\fBTcl_ZlibStreamGet\fR(\fIzshandle, dataObj, count\fR)
.fi
.SH ARGUMENTS
.AS Tcl_ZlibStream *zshandlePtr out
.AP Tcl_Interp *interp in
The interpreter to store resulting compressed or uncompressed data in. Also
where any error messages are written.

.AP int format in
What format of compressed data to work with. Must be one of
\fBTCL_ZLIB_FORMAT_ZLIB\fR for zlib-format data, \fBTCL_ZLIB_FORMAT_GZIP\fR
for gzip-format data, or \fBTCL_ZLIB_FORMAT_RAW\fR for raw compressed data. In
addition, for decompression only, \fBTCL_ZLIB_FORMAT_AUTO\fR may also be
chosen which can automatically detect whether the compressed data was in zlib
or gzip format.
.AP Tcl_Obj *dataObj in/out
A byte-array object containing the data to be compressed or decompressed, or
which is set to the data extracted from the stream when passed to
\fBTcl_ZlibStreamGet\fR.
.AP int level in
What level of compression to use. Should be a number from 0 to 9 or one of the
following: \fBTCL_ZLIB_COMPRESS_NONE\fR for no compression,
\fBTCL_ZLIB_COMPRESS_FAST\fR for fast but inefficient compression,
\fBTCL_ZLIB_COMPRESS_BEST\fR for slow but maximal compression, or
\fBTCL_ZLIB_COMPRESS_DEFAULT\fR for the level recommended by the zlib library.
................................................................................
.PP
\fBTcl_ZlibAdler32\fR and \fBTcl_ZlibCRC32\fR compute checksums on arrays of
bytes. Typical usage is:
.PP
.CS
checksum = \fBTcl_ZlibCRC32\fR(\fBTcl_ZlibCRC32\fR(0,NULL,0), data, length);
.CE

.PP
\fBTcl_ZlibStreamInit\fR creates a compressing or decompressing stream that is
linked to a Tcl command, according to its arguments, and provides an abstract

token for the stream; \fBTcl_ZlibStreamGetCommandName\fR returns the name of
that command given the stream token. Once a stream has been constructed,


\fBTcl_ZlibStreamPut\fR is used to add data to the stream and
\fBTcl_ZlibStreamGet\fR is used to retrieve data from the stream after





processing. \fBTcl_ZlibStreamAdler32\fR returns the checksum computed over the
uncompressed data, and \fBTcl_ZlibStreamEof\fR returns whether the end of the
uncompressed data has been reached. Finally, \fBTcl_ZlibStreamClose\fR will

clean up the stream and delete the associated command: using
\fBTcl_DeleteCommand\fR on the stream's command is equivalent.

.SH "PORTABILITY NOTES"
These functions will fail gracefully if Tcl is not linked with the zlib
library.
.SH "SEE ALSO"
Tcl_NewByteArrayObj(3), zlib(n)
'\"Tcl_StackChannel(3)
.SH "KEYWORDS"
compress, decompress, deflate, gzip, inflate
'\" Local Variables:
'\" mode: nroff
'\" fill-column: 78
'\" End:





|






|







 







|











|
>









|







 







>



>
|
<
>
>
|
|
>
>
>
>
>
|
|
|
>
|
|
>












1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
..
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
...
119
120
121
122
123
124
125
126
127
128
129
130
131

132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
'\"
'\" Copyright (c) 2008 Donal K. Fellows
'\"
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\" 
'\" RCS: @(#) $Id: TclZlib.3,v 1.4 2008/12/27 00:04:17 dkf Exp $
'\" 
.so man.macros
.TH TclZlib 3 8.6 Tcl "Tcl Library Procedures"
.BS
'\" Note:  do not modify the .SH NAME line immediately below!
.SH NAME
Tcl_ZlibAdler32, Tcl_ZlibCRC32, Tcl_ZlibDeflate, Tcl_ZlibInflate, Tcl_ZlibStreamChecksum, Tcl_ZlibStreamClose, Tcl_ZlibStreamEof, Tcl_ZlibStreamGet, Tcl_ZlibStreamGetCommandName, Tcl_ZlibStreamInit, Tcl_ZlibStreamPut \- compression and decompression functions
.SH SYNOPSIS
.nf
#include <tcl.h>
.sp
Tcl_Obj *
\fBTcl_ZlibDeflate\fR(\fIinterp, format, dataObj, level, dictObj\fR)
.sp
................................................................................
int
\fBTcl_ZlibStreamEof\fR(\fIzshandle\fR)
.sp
int
\fBTcl_ZlibStreamClose\fR(\fIzshandle\fR)
.sp
int
\fBTcl_ZlibStreamChecksum\fR(\fIzshandle\fR)
.sp
int
\fBTcl_ZlibStreamPut\fR(\fIzshandle, dataObj, flush\fR)
.sp
int
\fBTcl_ZlibStreamGet\fR(\fIzshandle, dataObj, count\fR)
.fi
.SH ARGUMENTS
.AS Tcl_ZlibStream *zshandlePtr out
.AP Tcl_Interp *interp in
The interpreter to store resulting compressed or uncompressed data in. Also
where any error messages are written. For \fBTcl_ZlibStreamInit\fR, this can
be NULL to create a stream that is not bound to a command.
.AP int format in
What format of compressed data to work with. Must be one of
\fBTCL_ZLIB_FORMAT_ZLIB\fR for zlib-format data, \fBTCL_ZLIB_FORMAT_GZIP\fR
for gzip-format data, or \fBTCL_ZLIB_FORMAT_RAW\fR for raw compressed data. In
addition, for decompression only, \fBTCL_ZLIB_FORMAT_AUTO\fR may also be
chosen which can automatically detect whether the compressed data was in zlib
or gzip format.
.AP Tcl_Obj *dataObj in/out
A byte-array object containing the data to be compressed or decompressed, or
to which the data extracted from the stream is appended when passed to
\fBTcl_ZlibStreamGet\fR.
.AP int level in
What level of compression to use. Should be a number from 0 to 9 or one of the
following: \fBTCL_ZLIB_COMPRESS_NONE\fR for no compression,
\fBTCL_ZLIB_COMPRESS_FAST\fR for fast but inefficient compression,
\fBTCL_ZLIB_COMPRESS_BEST\fR for slow but maximal compression, or
\fBTCL_ZLIB_COMPRESS_DEFAULT\fR for the level recommended by the zlib library.
................................................................................
.PP
\fBTcl_ZlibAdler32\fR and \fBTcl_ZlibCRC32\fR compute checksums on arrays of
bytes. Typical usage is:
.PP
.CS
checksum = \fBTcl_ZlibCRC32\fR(\fBTcl_ZlibCRC32\fR(0,NULL,0), data, length);
.CE
.SS "ZLIB STREAMS"
.PP
\fBTcl_ZlibStreamInit\fR creates a compressing or decompressing stream that is
linked to a Tcl command, according to its arguments, and provides an abstract
token for the stream and returns a normal Tcl result code;
\fBTcl_ZlibStreamGetCommandName\fR returns the name of that command given the

stream token, or NULL if the stream has no command.
.PP
Once a stream has been constructed, \fBTcl_ZlibStreamPut\fR is used to add
data to the stream and \fBTcl_ZlibStreamGet\fR is used to retrieve data from
the stream after processing. Both return normal Tcl result codes. With
\fBTcl_ZlibStreamPut\fR, the data buffer object passed to it should not be
modified afterwards. With \fBTcl_ZlibStreamGet\fR, the data buffer object
passed to it will have the data bytes appended to it.
.PP
\fBTcl_ZlibStreamChecksum\fR returns the checksum computed over the
uncompressed data according to the format, and \fBTcl_ZlibStreamEof\fR returns
whether the end of the uncompressed data has been reached.
.PP
Finally, \fBTcl_ZlibStreamClose\fR will clean up the stream and delete the
associated command: using \fBTcl_DeleteCommand\fR on the stream's command is
equivalent.
.SH "PORTABILITY NOTES"
These functions will fail gracefully if Tcl is not linked with the zlib
library.
.SH "SEE ALSO"
Tcl_NewByteArrayObj(3), zlib(n)
'\"Tcl_StackChannel(3)
.SH "KEYWORDS"
compress, decompress, deflate, gzip, inflate
'\" Local Variables:
'\" mode: nroff
'\" fill-column: 78
'\" End:

Changes to generic/tcl.decls.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
....
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
# Copyright (c) 1998-1999 by Scriptics Corporation.
# Copyright (c) 2001, 2002 by Kevin B. Kenny.  All rights reserved.
# Copyright (c) 2007 Daniel A. Steffen <[email protected]>
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# RCS: @(#) $Id: tcl.decls,v 1.165 2008/12/26 09:51:11 dkf Exp $

library tcl

# Define the tcl interface with several sub interfaces:
#     tclPlat	 - platform specific public
#     tclInt	 - generic private
#     tclPlatInt - platform specific private
................................................................................
declare 615 generic {
    Tcl_Obj *Tcl_ZlibStreamGetCommandName(Tcl_ZlibStream zshandle)
}
declare 616 generic {
    int Tcl_ZlibStreamEof(Tcl_ZlibStream zshandle)
}
declare 617 generic {
    int Tcl_ZlibStreamAdler32(Tcl_ZlibStream zshandle)
}
declare 618 generic {
    int Tcl_ZlibStreamPut(Tcl_ZlibStream zshandle, Tcl_Obj *data, int flush)
}
declare 619 generic {
    int Tcl_ZlibStreamGet(Tcl_ZlibStream zshandle, Tcl_Obj *data, int count)
}






|







 







|







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
....
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
# Copyright (c) 1998-1999 by Scriptics Corporation.
# Copyright (c) 2001, 2002 by Kevin B. Kenny.  All rights reserved.
# Copyright (c) 2007 Daniel A. Steffen <[email protected]>
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# RCS: @(#) $Id: tcl.decls,v 1.166 2008/12/27 00:04:17 dkf Exp $

library tcl

# Define the tcl interface with several sub interfaces:
#     tclPlat	 - platform specific public
#     tclInt	 - generic private
#     tclPlatInt - platform specific private
................................................................................
declare 615 generic {
    Tcl_Obj *Tcl_ZlibStreamGetCommandName(Tcl_ZlibStream zshandle)
}
declare 616 generic {
    int Tcl_ZlibStreamEof(Tcl_ZlibStream zshandle)
}
declare 617 generic {
    int Tcl_ZlibStreamChecksum(Tcl_ZlibStream zshandle)
}
declare 618 generic {
    int Tcl_ZlibStreamPut(Tcl_ZlibStream zshandle, Tcl_Obj *data, int flush)
}
declare 619 generic {
    int Tcl_ZlibStreamGet(Tcl_ZlibStream zshandle, Tcl_Obj *data, int count)
}

Changes to generic/tclDecls.h.

4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
....
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
....
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
....
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
 *	Declarations of functions in the platform independent public Tcl API.
 *
 * Copyright (c) 1998-1999 by Scriptics Corporation.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tclDecls.h,v 1.166 2008/12/18 06:40:02 nijtmans Exp $
 */

#ifndef _TCLDECLS
#define _TCLDECLS

#undef TCL_STORAGE_CLASS
#ifdef BUILD_tcl
................................................................................
				Tcl_ZlibStream zshandle);
#endif
#ifndef Tcl_ZlibStreamEof_TCL_DECLARED
#define Tcl_ZlibStreamEof_TCL_DECLARED
/* 616 */
EXTERN int		Tcl_ZlibStreamEof (Tcl_ZlibStream zshandle);
#endif
#ifndef Tcl_ZlibStreamAdler32_TCL_DECLARED
#define Tcl_ZlibStreamAdler32_TCL_DECLARED
/* 617 */
EXTERN int		Tcl_ZlibStreamAdler32 (Tcl_ZlibStream zshandle);
#endif
#ifndef Tcl_ZlibStreamPut_TCL_DECLARED
#define Tcl_ZlibStreamPut_TCL_DECLARED
/* 618 */
EXTERN int		Tcl_ZlibStreamPut (Tcl_ZlibStream zshandle,
				Tcl_Obj * data, int flush);
#endif
................................................................................
    int (*tcl_ZlibDeflate) (Tcl_Interp * interp, int format, Tcl_Obj * data, int level, Tcl_Obj * gzipHeaderDictObj); /* 610 */
    int (*tcl_ZlibInflate) (Tcl_Interp * interp, int format, Tcl_Obj * data, int buffersize, Tcl_Obj * gzipHeaderDictObj); /* 611 */
    unsigned int (*tcl_ZlibCRC32) (unsigned int crc, const char * buf, int len); /* 612 */
    unsigned int (*tcl_ZlibAdler32) (unsigned int adler, const char * buf, int len); /* 613 */
    int (*tcl_ZlibStreamInit) (Tcl_Interp * interp, int mode, int format, int level, Tcl_Obj * dictObj, Tcl_ZlibStream * zshandle); /* 614 */
    Tcl_Obj * (*tcl_ZlibStreamGetCommandName) (Tcl_ZlibStream zshandle); /* 615 */
    int (*tcl_ZlibStreamEof) (Tcl_ZlibStream zshandle); /* 616 */
    int (*tcl_ZlibStreamAdler32) (Tcl_ZlibStream zshandle); /* 617 */
    int (*tcl_ZlibStreamPut) (Tcl_ZlibStream zshandle, Tcl_Obj * data, int flush); /* 618 */
    int (*tcl_ZlibStreamGet) (Tcl_ZlibStream zshandle, Tcl_Obj * data, int count); /* 619 */
    int (*tcl_ZlibStreamClose) (Tcl_ZlibStream zshandle); /* 620 */
    int (*tcl_ZlibStreamReset) (Tcl_ZlibStream zshandle); /* 621 */
    void (*tcl_SetStartupScript) (Tcl_Obj * path, const char * encoding); /* 622 */
    Tcl_Obj * (*tcl_GetStartupScript) (const char ** encodingPtr); /* 623 */
    int (*tcl_CloseEx) (Tcl_Interp * interp, Tcl_Channel chan, int flags); /* 624 */
................................................................................
#define Tcl_ZlibStreamGetCommandName \
	(tclStubsPtr->tcl_ZlibStreamGetCommandName) /* 615 */
#endif
#ifndef Tcl_ZlibStreamEof
#define Tcl_ZlibStreamEof \
	(tclStubsPtr->tcl_ZlibStreamEof) /* 616 */
#endif
#ifndef Tcl_ZlibStreamAdler32
#define Tcl_ZlibStreamAdler32 \
	(tclStubsPtr->tcl_ZlibStreamAdler32) /* 617 */
#endif
#ifndef Tcl_ZlibStreamPut
#define Tcl_ZlibStreamPut \
	(tclStubsPtr->tcl_ZlibStreamPut) /* 618 */
#endif
#ifndef Tcl_ZlibStreamGet
#define Tcl_ZlibStreamGet \






|







 







|
|

|







 







|







 







|
|
|







4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
....
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
....
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
....
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
 *	Declarations of functions in the platform independent public Tcl API.
 *
 * Copyright (c) 1998-1999 by Scriptics Corporation.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tclDecls.h,v 1.167 2008/12/27 00:04:17 dkf Exp $
 */

#ifndef _TCLDECLS
#define _TCLDECLS

#undef TCL_STORAGE_CLASS
#ifdef BUILD_tcl
................................................................................
				Tcl_ZlibStream zshandle);
#endif
#ifndef Tcl_ZlibStreamEof_TCL_DECLARED
#define Tcl_ZlibStreamEof_TCL_DECLARED
/* 616 */
EXTERN int		Tcl_ZlibStreamEof (Tcl_ZlibStream zshandle);
#endif
#ifndef Tcl_ZlibStreamChecksum_TCL_DECLARED
#define Tcl_ZlibStreamChecksum_TCL_DECLARED
/* 617 */
EXTERN int		Tcl_ZlibStreamChecksum (Tcl_ZlibStream zshandle);
#endif
#ifndef Tcl_ZlibStreamPut_TCL_DECLARED
#define Tcl_ZlibStreamPut_TCL_DECLARED
/* 618 */
EXTERN int		Tcl_ZlibStreamPut (Tcl_ZlibStream zshandle,
				Tcl_Obj * data, int flush);
#endif
................................................................................
    int (*tcl_ZlibDeflate) (Tcl_Interp * interp, int format, Tcl_Obj * data, int level, Tcl_Obj * gzipHeaderDictObj); /* 610 */
    int (*tcl_ZlibInflate) (Tcl_Interp * interp, int format, Tcl_Obj * data, int buffersize, Tcl_Obj * gzipHeaderDictObj); /* 611 */
    unsigned int (*tcl_ZlibCRC32) (unsigned int crc, const char * buf, int len); /* 612 */
    unsigned int (*tcl_ZlibAdler32) (unsigned int adler, const char * buf, int len); /* 613 */
    int (*tcl_ZlibStreamInit) (Tcl_Interp * interp, int mode, int format, int level, Tcl_Obj * dictObj, Tcl_ZlibStream * zshandle); /* 614 */
    Tcl_Obj * (*tcl_ZlibStreamGetCommandName) (Tcl_ZlibStream zshandle); /* 615 */
    int (*tcl_ZlibStreamEof) (Tcl_ZlibStream zshandle); /* 616 */
    int (*tcl_ZlibStreamChecksum) (Tcl_ZlibStream zshandle); /* 617 */
    int (*tcl_ZlibStreamPut) (Tcl_ZlibStream zshandle, Tcl_Obj * data, int flush); /* 618 */
    int (*tcl_ZlibStreamGet) (Tcl_ZlibStream zshandle, Tcl_Obj * data, int count); /* 619 */
    int (*tcl_ZlibStreamClose) (Tcl_ZlibStream zshandle); /* 620 */
    int (*tcl_ZlibStreamReset) (Tcl_ZlibStream zshandle); /* 621 */
    void (*tcl_SetStartupScript) (Tcl_Obj * path, const char * encoding); /* 622 */
    Tcl_Obj * (*tcl_GetStartupScript) (const char ** encodingPtr); /* 623 */
    int (*tcl_CloseEx) (Tcl_Interp * interp, Tcl_Channel chan, int flags); /* 624 */
................................................................................
#define Tcl_ZlibStreamGetCommandName \
	(tclStubsPtr->tcl_ZlibStreamGetCommandName) /* 615 */
#endif
#ifndef Tcl_ZlibStreamEof
#define Tcl_ZlibStreamEof \
	(tclStubsPtr->tcl_ZlibStreamEof) /* 616 */
#endif
#ifndef Tcl_ZlibStreamChecksum
#define Tcl_ZlibStreamChecksum \
	(tclStubsPtr->tcl_ZlibStreamChecksum) /* 617 */
#endif
#ifndef Tcl_ZlibStreamPut
#define Tcl_ZlibStreamPut \
	(tclStubsPtr->tcl_ZlibStreamPut) /* 618 */
#endif
#ifndef Tcl_ZlibStreamGet
#define Tcl_ZlibStreamGet \

Changes to generic/tclStubInit.c.

4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
....
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
 *	This file contains the initializers for the Tcl stub vectors.
 *
 * Copyright (c) 1998-1999 by Scriptics Corporation.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tclStubInit.c,v 1.177 2008/12/18 04:38:01 dgp Exp $
 */

#include "tclInt.h"
#include "tommath.h"

/*
 * Remove macros that will interfere with the definitions below.
................................................................................
    Tcl_ZlibDeflate, /* 610 */
    Tcl_ZlibInflate, /* 611 */
    Tcl_ZlibCRC32, /* 612 */
    Tcl_ZlibAdler32, /* 613 */
    Tcl_ZlibStreamInit, /* 614 */
    Tcl_ZlibStreamGetCommandName, /* 615 */
    Tcl_ZlibStreamEof, /* 616 */
    Tcl_ZlibStreamAdler32, /* 617 */
    Tcl_ZlibStreamPut, /* 618 */
    Tcl_ZlibStreamGet, /* 619 */
    Tcl_ZlibStreamClose, /* 620 */
    Tcl_ZlibStreamReset, /* 621 */
    Tcl_SetStartupScript, /* 622 */
    Tcl_GetStartupScript, /* 623 */
    Tcl_CloseEx, /* 624 */






|







 







|







4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
....
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
 *	This file contains the initializers for the Tcl stub vectors.
 *
 * Copyright (c) 1998-1999 by Scriptics Corporation.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tclStubInit.c,v 1.178 2008/12/27 00:04:17 dkf Exp $
 */

#include "tclInt.h"
#include "tommath.h"

/*
 * Remove macros that will interfere with the definitions below.
................................................................................
    Tcl_ZlibDeflate, /* 610 */
    Tcl_ZlibInflate, /* 611 */
    Tcl_ZlibCRC32, /* 612 */
    Tcl_ZlibAdler32, /* 613 */
    Tcl_ZlibStreamInit, /* 614 */
    Tcl_ZlibStreamGetCommandName, /* 615 */
    Tcl_ZlibStreamEof, /* 616 */
    Tcl_ZlibStreamChecksum, /* 617 */
    Tcl_ZlibStreamPut, /* 618 */
    Tcl_ZlibStreamGet, /* 619 */
    Tcl_ZlibStreamClose, /* 620 */
    Tcl_ZlibStreamReset, /* 621 */
    Tcl_SetStartupScript, /* 622 */
    Tcl_GetStartupScript, /* 623 */
    Tcl_CloseEx, /* 624 */

Changes to generic/tclZlib.c.

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
814
815
816
817
818
819
820
821
822





823
824
825
826
827
828
829
...
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880

881
882
883
884
885
886
887
...
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
...
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
...
975
976
977
978
979
980
981
982

983
984
985
986
987
988
989
990
991
992
993
994
995
996
997

998
999
1000
1001
1002
1003
1004
1005


1006
1007
1008
1009
1010
1011
1012
....
1014
1015
1016
1017
1018
1019
1020
1021

1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
....
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080

1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
....
1106
1107
1108
1109
1110
1111
1112
1113

1114
1115

1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153

1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
....
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
....
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
 *
 * Parts written by Jean-Claude Wippler, as part of Tclkit, placed in the
 * public domain March 2003.
 *
 * See the file "license.terms" for information on usage and redistribution of
 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tclZlib.c,v 1.18 2008/12/22 01:39:33 patthoyts Exp $
 */

#include "tclInt.h"
#ifdef HAVE_ZLIB
#include <zlib.h>

/*
................................................................................
 */

Tcl_Obj *
Tcl_ZlibStreamGetCommandName(
    Tcl_ZlibStream zshandle) /* as obtained from Tcl_ZlibStreamInit */
{
    ZlibStreamHandle *zsh = (ZlibStreamHandle *) zshandle;
    Tcl_Obj *objPtr = Tcl_NewObj();






    Tcl_GetCommandFullName(zsh->interp, zsh->cmd, objPtr);
    return objPtr;
}
 
/*
 *----------------------------------------------------------------------
 *
................................................................................

    return zsh->streamEnd;
}
 
/*
 *----------------------------------------------------------------------
 *
 * Tcl_ZlibStreamAdler32 --
 *
 *	Return the checksum of the uncompressed data seen so far by the
 *	stream.
 *
 *----------------------------------------------------------------------
 */

int
Tcl_ZlibStreamAdler32(
    Tcl_ZlibStream zshandle)	/* As obtained from Tcl_ZlibStreamInit */
{
    ZlibStreamHandle *zsh = (ZlibStreamHandle *) zshandle;

    return zsh->stream.adler;
}
 
/*
 *----------------------------------------------------------------------
 *
 * Tcl_ZlibStreamPut --
 *
 *	Add data to the stream for compression or decompression.

 *
 *----------------------------------------------------------------------
 */

int
Tcl_ZlibStreamPut(
    Tcl_ZlibStream zshandle,	/* As obtained from Tcl_ZlibStreamInit */
................................................................................

		obj = Tcl_NewByteArrayObj((unsigned char *) dataTmp,
			outSize - zsh->stream.avail_out);
		/*
		 * Now append the compressed data to the outData list.
		 */

		Tcl_ListObjAppendElement(zsh->interp, zsh->outData, obj);
	    }
	    if (outSize < 0xFFFF) {
		outSize = 0xFFFF;	/* There may be *lots* of data left to
					 * output... */
		ckfree(dataTmp);
		dataTmp = ckalloc(outSize);
	    }
................................................................................
	    obj = Tcl_NewByteArrayObj((unsigned char *) dataTmp,
		    outSize - zsh->stream.avail_out);

	    /*
	     * Now append the compressed data to the outData list.
	     */

	    Tcl_ListObjAppendElement(zsh->interp, zsh->outData, obj);
	}
    } else {
	/*
	 * This is easy. Just append to the inData list.
	 */

	Tcl_ListObjAppendElement(zsh->interp, zsh->inData, data);

	/*
	 * and we'll need the flush parameter for the Inflate call.
	 */

	zsh->flush = flush;
    }
................................................................................
}
 
/*
 *----------------------------------------------------------------------
 *
 * Tcl_ZlibStreamGet --
 *
 *	Retrieve data (now compressed or decompressed) from the stream.

 *
 *----------------------------------------------------------------------
 */

int
Tcl_ZlibStreamGet(
    Tcl_ZlibStream zshandle,	/* As obtained from Tcl_ZlibStreamInit */
    Tcl_Obj *data,		/* A place to put the data */
    int count)			/* Number of bytes to grab as a maximum, you
				 * may get less! */
{
    ZlibStreamHandle *zsh = (ZlibStreamHandle *) zshandle;
    int e, i, listLen, itemLen, dataPos = 0;
    Tcl_Obj *itemObj;
    unsigned char *dataPtr, *itemPtr;


    /*
     * Getting beyond the of stream, just return empty string.
     */

    if (zsh->streamEnd) {
	return TCL_OK;
    }



    if (zsh->mode == TCL_ZLIB_STREAM_INFLATE) {
	if (count == -1) {
	    /*
	     * The only safe thing to do is restict to 65k. We might cause a
	     * panic for out of memory if we just kept growing the buffer.
	     */
................................................................................
	    count = 65536;
	}

	/*
	 * Prepare the place to store the data.
	 */

	dataPtr = Tcl_SetByteArrayLength(data, count);


	zsh->stream.next_out = dataPtr;
	zsh->stream.avail_out = count;
	if (zsh->stream.avail_in == 0) {
	    /*
	     * zlib will probably need more data to decompress.
	     */

	    if (zsh->currentInput) {
		Tcl_DecrRefCount(zsh->currentInput);
		zsh->currentInput = NULL;
	    }
	    if (Tcl_ListObjLength(zsh->interp, zsh->inData,
		    &listLen) != TCL_OK) {
		return TCL_ERROR;
	    }
	    if (listLen > 0) {
		/*
		 * There is more input available, get it from the list and
		 * give it to zlib.
		 */

		if (Tcl_ListObjIndex(zsh->interp, zsh->inData, 0,
			&itemObj) != TCL_OK) {
		    return TCL_ERROR;
		}
		itemPtr = Tcl_GetByteArrayFromObj(itemObj, &itemLen);
		Tcl_IncrRefCount(itemObj);
		zsh->currentInput = itemObj;
		zsh->stream.next_in = itemPtr;
		zsh->stream.avail_in = itemLen;

		/*
................................................................................

		Tcl_ListObjReplace(NULL, zsh->inData, 0, 1, 0, NULL);
		listLen--;
	    }
	}

	e = inflate(&zsh->stream, zsh->flush);
	if (Tcl_ListObjLength(zsh->interp, zsh->inData, &listLen) != TCL_OK) {
	    return TCL_ERROR;
	}

	while ((zsh->stream.avail_out > 0) && (e==Z_OK || e==Z_BUF_ERROR)
		&& (listLen > 0)) {
	    /*
	     * State: We have not satisfied the request yet and there may be
	     * more to inflate.
	     */

	    if (zsh->stream.avail_in > 0) {
		if (zsh->interp) {
		    Tcl_SetResult(zsh->interp,
			"Unexpected zlib internal state during decompression",
			TCL_STATIC);
		}

		return TCL_ERROR;
	    }

	    if (zsh->currentInput) {
		Tcl_DecrRefCount(zsh->currentInput);
		zsh->currentInput = 0;
	    }

	    if (Tcl_ListObjIndex(zsh->interp, zsh->inData, 0,
		   &itemObj) != TCL_OK) {
		return TCL_ERROR;
	    }
	    itemPtr = Tcl_GetByteArrayFromObj(itemObj, &itemLen);
	    Tcl_IncrRefCount(itemObj);
	    zsh->currentInput = itemObj;
	    zsh->stream.next_in = itemPtr;
	    zsh->stream.avail_in = itemLen;

	    /*
................................................................................
	    /*
	     * And call inflate again
	     */

	    e = inflate(&zsh->stream, zsh->flush);
	}
	if (zsh->stream.avail_out > 0) {
	    Tcl_SetByteArrayLength(data, count - zsh->stream.avail_out);

	}
	if (!(e==Z_OK || e==Z_STREAM_END || e==Z_BUF_ERROR)) {

	    ConvertError(zsh->interp, e);
	    return TCL_ERROR;
	}
	if (e == Z_STREAM_END) {
	    zsh->streamEnd = 1;
	    if (zsh->currentInput) {
		Tcl_DecrRefCount(zsh->currentInput);
		zsh->currentInput = 0;
	    }
	    inflateEnd(&zsh->stream);
	}
    } else {
	if (Tcl_ListObjLength(zsh->interp, zsh->outData,
		&listLen) != TCL_OK) {
	    return TCL_ERROR;
	}

	if (count == -1) {
	    count = 0;
	    for (i=0; i<listLen; i++) {
		if (Tcl_ListObjIndex(zsh->interp, zsh->outData, i,
			&itemObj) != TCL_OK) {
		    return TCL_ERROR;
		}
		itemPtr = Tcl_GetByteArrayFromObj(itemObj, &itemLen);
		if (i == 0) {
		    count += itemLen - zsh->outPos;
		} else {
		    count += itemLen;
		}
	    }
	}

	/*
	 * Prepare the place to store the data.
	 */

	dataPtr = Tcl_SetByteArrayLength(data, count);


	while ((count > dataPos) && (Tcl_ListObjLength(zsh->interp,
		zsh->outData, &listLen) == TCL_OK) && (listLen > 0)) {
	    Tcl_ListObjIndex(zsh->interp, zsh->outData, 0, &itemObj);
	    itemPtr = Tcl_GetByteArrayFromObj(itemObj, &itemLen);
	    if (itemLen-zsh->outPos >= count-dataPos) {
		unsigned len = count - dataPos;

		memcpy(dataPtr + dataPos, itemPtr + zsh->outPos, len);
		zsh->outPos += len;
		dataPos += len;
................................................................................
		zsh->outPos = 0;
	    }
	    if (zsh->outPos == 0) {
		Tcl_ListObjReplace(NULL, zsh->outData, 0, 1, 0, NULL);
		listLen--;
	    }
	}
	Tcl_SetByteArrayLength(data, dataPos);
    }
    return TCL_OK;
}
 
/*
 *----------------------------------------------------------------------
 *
................................................................................
 *
 *----------------------------------------------------------------------
 */

unsigned int
Tcl_ZlibCRC32(
    unsigned int crc,
    const char *buf,
    int len)
{
    /* Nothing much to do, just wrap the crc32(). */
    return crc32(crc, (Bytef *) buf, (unsigned) len);
}

unsigned int
Tcl_ZlibAdler32(
    unsigned int adler,
    const char *buf,
    int len)
{
    return adler32(adler, (Bytef *) buf, (unsigned) len);
}
 
/*
 *----------------------------------------------------------------------






|







 







|

>
>
>
>
>







 







|








|












|
>







 







|







 







|






|







 







|
>







|







>








>
>







 







|
>












|
<
<
<






|
<
<
<







 







|
<
|
<
|












>








|
<
<
<







 







|
>


>












|
<
<
<
<



|
<
<
<













|
>

|
|
|







 







|







 







|









|







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
...
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
...
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
...
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
...
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
....
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045



1046
1047
1048
1049
1050
1051
1052



1053
1054
1055
1056
1057
1058
1059
....
1062
1063
1064
1065
1066
1067
1068
1069

1070

1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093



1094
1095
1096
1097
1098
1099
1100
....
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131




1132
1133
1134
1135



1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
....
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
....
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
 *
 * Parts written by Jean-Claude Wippler, as part of Tclkit, placed in the
 * public domain March 2003.
 *
 * See the file "license.terms" for information on usage and redistribution of
 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tclZlib.c,v 1.19 2008/12/27 00:04:17 dkf Exp $
 */

#include "tclInt.h"
#ifdef HAVE_ZLIB
#include <zlib.h>

/*
................................................................................
 */

Tcl_Obj *
Tcl_ZlibStreamGetCommandName(
    Tcl_ZlibStream zshandle) /* as obtained from Tcl_ZlibStreamInit */
{
    ZlibStreamHandle *zsh = (ZlibStreamHandle *) zshandle;
    Tcl_Obj *objPtr;

    if (!zsh->interp) {
	return NULL;
    }

    TclNewObj(objPtr);
    Tcl_GetCommandFullName(zsh->interp, zsh->cmd, objPtr);
    return objPtr;
}
 
/*
 *----------------------------------------------------------------------
 *
................................................................................

    return zsh->streamEnd;
}
 
/*
 *----------------------------------------------------------------------
 *
 * Tcl_ZlibStreamChecksum --
 *
 *	Return the checksum of the uncompressed data seen so far by the
 *	stream.
 *
 *----------------------------------------------------------------------
 */

int
Tcl_ZlibStreamChecksum(
    Tcl_ZlibStream zshandle)	/* As obtained from Tcl_ZlibStreamInit */
{
    ZlibStreamHandle *zsh = (ZlibStreamHandle *) zshandle;

    return zsh->stream.adler;
}
 
/*
 *----------------------------------------------------------------------
 *
 * Tcl_ZlibStreamPut --
 *
 *	Add data to the stream for compression or decompression from a
 *	bytearray Tcl_Obj.
 *
 *----------------------------------------------------------------------
 */

int
Tcl_ZlibStreamPut(
    Tcl_ZlibStream zshandle,	/* As obtained from Tcl_ZlibStreamInit */
................................................................................

		obj = Tcl_NewByteArrayObj((unsigned char *) dataTmp,
			outSize - zsh->stream.avail_out);
		/*
		 * Now append the compressed data to the outData list.
		 */

		Tcl_ListObjAppendElement(NULL, zsh->outData, obj);
	    }
	    if (outSize < 0xFFFF) {
		outSize = 0xFFFF;	/* There may be *lots* of data left to
					 * output... */
		ckfree(dataTmp);
		dataTmp = ckalloc(outSize);
	    }
................................................................................
	    obj = Tcl_NewByteArrayObj((unsigned char *) dataTmp,
		    outSize - zsh->stream.avail_out);

	    /*
	     * Now append the compressed data to the outData list.
	     */

	    Tcl_ListObjAppendElement(NULL, zsh->outData, obj);
	}
    } else {
	/*
	 * This is easy. Just append to the inData list.
	 */

	Tcl_ListObjAppendElement(NULL, zsh->inData, data);

	/*
	 * and we'll need the flush parameter for the Inflate call.
	 */

	zsh->flush = flush;
    }
................................................................................
}
 
/*
 *----------------------------------------------------------------------
 *
 * Tcl_ZlibStreamGet --
 *
 *	Retrieve data (now compressed or decompressed) from the stream into a
 *	bytearray Tcl_Obj.
 *
 *----------------------------------------------------------------------
 */

int
Tcl_ZlibStreamGet(
    Tcl_ZlibStream zshandle,	/* As obtained from Tcl_ZlibStreamInit */
    Tcl_Obj *data,		/* A place to append the data. */
    int count)			/* Number of bytes to grab as a maximum, you
				 * may get less! */
{
    ZlibStreamHandle *zsh = (ZlibStreamHandle *) zshandle;
    int e, i, listLen, itemLen, dataPos = 0;
    Tcl_Obj *itemObj;
    unsigned char *dataPtr, *itemPtr;
    int existing;

    /*
     * Getting beyond the of stream, just return empty string.
     */

    if (zsh->streamEnd) {
	return TCL_OK;
    }

    (void) Tcl_GetByteArrayFromObj(data, &existing);

    if (zsh->mode == TCL_ZLIB_STREAM_INFLATE) {
	if (count == -1) {
	    /*
	     * The only safe thing to do is restict to 65k. We might cause a
	     * panic for out of memory if we just kept growing the buffer.
	     */
................................................................................
	    count = 65536;
	}

	/*
	 * Prepare the place to store the data.
	 */

	dataPtr = Tcl_SetByteArrayLength(data, existing+count);
	dataPtr += existing;

	zsh->stream.next_out = dataPtr;
	zsh->stream.avail_out = count;
	if (zsh->stream.avail_in == 0) {
	    /*
	     * zlib will probably need more data to decompress.
	     */

	    if (zsh->currentInput) {
		Tcl_DecrRefCount(zsh->currentInput);
		zsh->currentInput = NULL;
	    }
	    Tcl_ListObjLength(NULL, zsh->inData, &listLen);



	    if (listLen > 0) {
		/*
		 * There is more input available, get it from the list and
		 * give it to zlib.
		 */

		Tcl_ListObjIndex(NULL, zsh->inData, 0, &itemObj);



		itemPtr = Tcl_GetByteArrayFromObj(itemObj, &itemLen);
		Tcl_IncrRefCount(itemObj);
		zsh->currentInput = itemObj;
		zsh->stream.next_in = itemPtr;
		zsh->stream.avail_in = itemLen;

		/*
................................................................................

		Tcl_ListObjReplace(NULL, zsh->inData, 0, 1, 0, NULL);
		listLen--;
	    }
	}

	e = inflate(&zsh->stream, zsh->flush);
	Tcl_ListObjLength(NULL, zsh->inData, &listLen);



	while ((zsh->stream.avail_out > 0) && (e == Z_OK || e == Z_BUF_ERROR)
		&& (listLen > 0)) {
	    /*
	     * State: We have not satisfied the request yet and there may be
	     * more to inflate.
	     */

	    if (zsh->stream.avail_in > 0) {
		if (zsh->interp) {
		    Tcl_SetResult(zsh->interp,
			"Unexpected zlib internal state during decompression",
			TCL_STATIC);
		}
		Tcl_SetByteArrayLength(data, existing);
		return TCL_ERROR;
	    }

	    if (zsh->currentInput) {
		Tcl_DecrRefCount(zsh->currentInput);
		zsh->currentInput = 0;
	    }

	    Tcl_ListObjIndex(zsh->interp, zsh->inData, 0, &itemObj);



	    itemPtr = Tcl_GetByteArrayFromObj(itemObj, &itemLen);
	    Tcl_IncrRefCount(itemObj);
	    zsh->currentInput = itemObj;
	    zsh->stream.next_in = itemPtr;
	    zsh->stream.avail_in = itemLen;

	    /*
................................................................................
	    /*
	     * And call inflate again
	     */

	    e = inflate(&zsh->stream, zsh->flush);
	}
	if (zsh->stream.avail_out > 0) {
	    Tcl_SetByteArrayLength(data,
		    existing + count - zsh->stream.avail_out);
	}
	if (!(e==Z_OK || e==Z_STREAM_END || e==Z_BUF_ERROR)) {
	    Tcl_SetByteArrayLength(data, existing);
	    ConvertError(zsh->interp, e);
	    return TCL_ERROR;
	}
	if (e == Z_STREAM_END) {
	    zsh->streamEnd = 1;
	    if (zsh->currentInput) {
		Tcl_DecrRefCount(zsh->currentInput);
		zsh->currentInput = 0;
	    }
	    inflateEnd(&zsh->stream);
	}
    } else {
	Tcl_ListObjLength(NULL, zsh->outData, &listLen);




	if (count == -1) {
	    count = 0;
	    for (i=0; i<listLen; i++) {
		Tcl_ListObjIndex(NULL, zsh->outData, i, &itemObj);



		itemPtr = Tcl_GetByteArrayFromObj(itemObj, &itemLen);
		if (i == 0) {
		    count += itemLen - zsh->outPos;
		} else {
		    count += itemLen;
		}
	    }
	}

	/*
	 * Prepare the place to store the data.
	 */

	dataPtr = Tcl_SetByteArrayLength(data, existing + count);
	dataPtr += existing;

	while ((count > dataPos) && (Tcl_ListObjLength(NULL, zsh->outData,
		&listLen) == TCL_OK) && (listLen > 0)) {
	    Tcl_ListObjIndex(NULL, zsh->outData, 0, &itemObj);
	    itemPtr = Tcl_GetByteArrayFromObj(itemObj, &itemLen);
	    if (itemLen-zsh->outPos >= count-dataPos) {
		unsigned len = count - dataPos;

		memcpy(dataPtr + dataPos, itemPtr + zsh->outPos, len);
		zsh->outPos += len;
		dataPos += len;
................................................................................
		zsh->outPos = 0;
	    }
	    if (zsh->outPos == 0) {
		Tcl_ListObjReplace(NULL, zsh->outData, 0, 1, 0, NULL);
		listLen--;
	    }
	}
	Tcl_SetByteArrayLength(data, existing + dataPos);
    }
    return TCL_OK;
}
 
/*
 *----------------------------------------------------------------------
 *
................................................................................
 *
 *----------------------------------------------------------------------
 */

unsigned int
Tcl_ZlibCRC32(
    unsigned int crc,
    const unsigned char *buf,
    int len)
{
    /* Nothing much to do, just wrap the crc32(). */
    return crc32(crc, (Bytef *) buf, (unsigned) len);
}

unsigned int
Tcl_ZlibAdler32(
    unsigned int adler,
    const unsigned char *buf,
    int len)
{
    return adler32(adler, (Bytef *) buf, (unsigned) len);
}
 
/*
 *----------------------------------------------------------------------