OSDN Git Service

Please enter the commit message for your changes. Lines starting
[eos/hostdependX86LINUX64.git] / util / X86LINUX64 / man / man3 / Tcl_ZlibAdler32.3
1 '\"
2 '\" Copyright (c) 2008 Donal K. Fellows
3 '\"
4 '\" See the file "license.terms" for information on usage and redistribution
5 '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
6 '\" 
7 .TH TclZlib 3 8.6 Tcl "Tcl Library Procedures"
8 .\" The -*- nroff -*- definitions below are for supplemental macros used
9 .\" in Tcl/Tk manual entries.
10 .\"
11 .\" .AP type name in/out ?indent?
12 .\"     Start paragraph describing an argument to a library procedure.
13 .\"     type is type of argument (int, etc.), in/out is either "in", "out",
14 .\"     or "in/out" to describe whether procedure reads or modifies arg,
15 .\"     and indent is equivalent to second arg of .IP (shouldn't ever be
16 .\"     needed;  use .AS below instead)
17 .\"
18 .\" .AS ?type? ?name?
19 .\"     Give maximum sizes of arguments for setting tab stops.  Type and
20 .\"     name are examples of largest possible arguments that will be passed
21 .\"     to .AP later.  If args are omitted, default tab stops are used.
22 .\"
23 .\" .BS
24 .\"     Start box enclosure.  From here until next .BE, everything will be
25 .\"     enclosed in one large box.
26 .\"
27 .\" .BE
28 .\"     End of box enclosure.
29 .\"
30 .\" .CS
31 .\"     Begin code excerpt.
32 .\"
33 .\" .CE
34 .\"     End code excerpt.
35 .\"
36 .\" .VS ?version? ?br?
37 .\"     Begin vertical sidebar, for use in marking newly-changed parts
38 .\"     of man pages.  The first argument is ignored and used for recording
39 .\"     the version when the .VS was added, so that the sidebars can be
40 .\"     found and removed when they reach a certain age.  If another argument
41 .\"     is present, then a line break is forced before starting the sidebar.
42 .\"
43 .\" .VE
44 .\"     End of vertical sidebar.
45 .\"
46 .\" .DS
47 .\"     Begin an indented unfilled display.
48 .\"
49 .\" .DE
50 .\"     End of indented unfilled display.
51 .\"
52 .\" .SO ?manpage?
53 .\"     Start of list of standard options for a Tk widget. The manpage
54 .\"     argument defines where to look up the standard options; if
55 .\"     omitted, defaults to "options". The options follow on successive
56 .\"     lines, in three columns separated by tabs.
57 .\"
58 .\" .SE
59 .\"     End of list of standard options for a Tk widget.
60 .\"
61 .\" .OP cmdName dbName dbClass
62 .\"     Start of description of a specific option.  cmdName gives the
63 .\"     option's name as specified in the class command, dbName gives
64 .\"     the option's name in the option database, and dbClass gives
65 .\"     the option's class in the option database.
66 .\"
67 .\" .UL arg1 arg2
68 .\"     Print arg1 underlined, then print arg2 normally.
69 .\"
70 .\" .QW arg1 ?arg2?
71 .\"     Print arg1 in quotes, then arg2 normally (for trailing punctuation).
72 .\"
73 .\" .PQ arg1 ?arg2?
74 .\"     Print an open parenthesis, arg1 in quotes, then arg2 normally
75 .\"     (for trailing punctuation) and then a closing parenthesis.
76 .\"
77 .\"     # Set up traps and other miscellaneous stuff for Tcl/Tk man pages.
78 .if t .wh -1.3i ^B
79 .nr ^l \n(.l
80 .ad b
81 .\"     # Start an argument description
82 .de AP
83 .ie !"\\$4"" .TP \\$4
84 .el \{\
85 .   ie !"\\$2"" .TP \\n()Cu
86 .   el          .TP 15
87 .\}
88 .ta \\n()Au \\n()Bu
89 .ie !"\\$3"" \{\
90 \&\\$1 \\fI\\$2\\fP (\\$3)
91 .\".b
92 .\}
93 .el \{\
94 .br
95 .ie !"\\$2"" \{\
96 \&\\$1  \\fI\\$2\\fP
97 .\}
98 .el \{\
99 \&\\fI\\$1\\fP
100 .\}
101 .\}
102 ..
103 .\"     # define tabbing values for .AP
104 .de AS
105 .nr )A 10n
106 .if !"\\$1"" .nr )A \\w'\\$1'u+3n
107 .nr )B \\n()Au+15n
108 .\"
109 .if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n
110 .nr )C \\n()Bu+\\w'(in/out)'u+2n
111 ..
112 .AS Tcl_Interp Tcl_CreateInterp in/out
113 .\"     # BS - start boxed text
114 .\"     # ^y = starting y location
115 .\"     # ^b = 1
116 .de BS
117 .br
118 .mk ^y
119 .nr ^b 1u
120 .if n .nf
121 .if n .ti 0
122 .if n \l'\\n(.lu\(ul'
123 .if n .fi
124 ..
125 .\"     # BE - end boxed text (draw box now)
126 .de BE
127 .nf
128 .ti 0
129 .mk ^t
130 .ie n \l'\\n(^lu\(ul'
131 .el \{\
132 .\"     Draw four-sided box normally, but don't draw top of
133 .\"     box if the box started on an earlier page.
134 .ie !\\n(^b-1 \{\
135 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
136 .\}
137 .el \}\
138 \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
139 .\}
140 .\}
141 .fi
142 .br
143 .nr ^b 0
144 ..
145 .\"     # VS - start vertical sidebar
146 .\"     # ^Y = starting y location
147 .\"     # ^v = 1 (for troff;  for nroff this doesn't matter)
148 .de VS
149 .if !"\\$2"" .br
150 .mk ^Y
151 .ie n 'mc \s12\(br\s0
152 .el .nr ^v 1u
153 ..
154 .\"     # VE - end of vertical sidebar
155 .de VE
156 .ie n 'mc
157 .el \{\
158 .ev 2
159 .nf
160 .ti 0
161 .mk ^t
162 \h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n'
163 .sp -1
164 .fi
165 .ev
166 .\}
167 .nr ^v 0
168 ..
169 .\"     # Special macro to handle page bottom:  finish off current
170 .\"     # box/sidebar if in box/sidebar mode, then invoked standard
171 .\"     # page bottom macro.
172 .de ^B
173 .ev 2
174 'ti 0
175 'nf
176 .mk ^t
177 .if \\n(^b \{\
178 .\"     Draw three-sided box if this is the box's first page,
179 .\"     draw two sides but no top otherwise.
180 .ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
181 .el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
182 .\}
183 .if \\n(^v \{\
184 .nr ^x \\n(^tu+1v-\\n(^Yu
185 \kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c
186 .\}
187 .bp
188 'fi
189 .ev
190 .if \\n(^b \{\
191 .mk ^y
192 .nr ^b 2
193 .\}
194 .if \\n(^v \{\
195 .mk ^Y
196 .\}
197 ..
198 .\"     # DS - begin display
199 .de DS
200 .RS
201 .nf
202 .sp
203 ..
204 .\"     # DE - end display
205 .de DE
206 .fi
207 .RE
208 .sp
209 ..
210 .\"     # SO - start of list of standard options
211 .de SO
212 'ie '\\$1'' .ds So \\fBoptions\\fR
213 'el .ds So \\fB\\$1\\fR
214 .SH "STANDARD OPTIONS"
215 .LP
216 .nf
217 .ta 5.5c 11c
218 .ft B
219 ..
220 .\"     # SE - end of list of standard options
221 .de SE
222 .fi
223 .ft R
224 .LP
225 See the \\*(So manual entry for details on the standard options.
226 ..
227 .\"     # OP - start of full description for a single option
228 .de OP
229 .LP
230 .nf
231 .ta 4c
232 Command-Line Name:      \\fB\\$1\\fR
233 Database Name:  \\fB\\$2\\fR
234 Database Class: \\fB\\$3\\fR
235 .fi
236 .IP
237 ..
238 .\"     # CS - begin code excerpt
239 .de CS
240 .RS
241 .nf
242 .ta .25i .5i .75i 1i
243 ..
244 .\"     # CE - end code excerpt
245 .de CE
246 .fi
247 .RE
248 ..
249 .\"     # UL - underline word
250 .de UL
251 \\$1\l'|0\(ul'\\$2
252 ..
253 .\"     # QW - apply quotation marks to word
254 .de QW
255 .ie '\\*(lq'"' ``\\$1''\\$2
256 .\"" fix emacs highlighting
257 .el \\*(lq\\$1\\*(rq\\$2
258 ..
259 .\"     # PQ - apply parens and quotation marks to word
260 .de PQ
261 .ie '\\*(lq'"' (``\\$1''\\$2)\\$3
262 .\"" fix emacs highlighting
263 .el (\\*(lq\\$1\\*(rq\\$2)\\$3
264 ..
265 .\"     # QR - quoted range
266 .de QR
267 .ie '\\*(lq'"' ``\\$1''\\-``\\$2''\\$3
268 .\"" fix emacs highlighting
269 .el \\*(lq\\$1\\*(rq\\-\\*(lq\\$2\\*(rq\\$3
270 ..
271 .\"     # MT - "empty" string
272 .de MT
273 .QW ""
274 ..
275 .BS
276 '\" Note:  do not modify the .SH NAME line immediately below!
277 .SH NAME
278 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
279 .SH SYNOPSIS
280 .nf
281 #include <tcl.h>
282 .sp
283 int
284 \fBTcl_ZlibDeflate\fR(\fIinterp, format, dataObj, level, dictObj\fR)
285 .sp
286 int
287 \fBTcl_ZlibInflate\fR(\fIinterp, format, dataObj, dictObj\fR)
288 .sp
289 unsigned int
290 \fBTcl_ZlibCRC32\fR(\fIinitValue, bytes, length\fR)
291 .sp
292 unsigned int
293 \fBTcl_ZlibAdler32\fR(\fIinitValue, bytes, length\fR)
294 .sp
295 int
296 \fBTcl_ZlibStreamInit\fR(\fIinterp, mode, format, level, dictObj, zshandlePtr\fR)
297 .sp
298 Tcl_Obj *
299 \fBTcl_ZlibStreamGetCommandName\fR(\fIzshandle\fR)
300 .sp
301 int
302 \fBTcl_ZlibStreamEof\fR(\fIzshandle\fR)
303 .sp
304 int
305 \fBTcl_ZlibStreamClose\fR(\fIzshandle\fR)
306 .sp
307 int
308 \fBTcl_ZlibStreamReset\fR(\fIzshandle\fR)
309 .sp
310 int
311 \fBTcl_ZlibStreamChecksum\fR(\fIzshandle\fR)
312 .sp
313 int
314 \fBTcl_ZlibStreamPut\fR(\fIzshandle, dataObj, flush\fR)
315 .sp
316 int
317 \fBTcl_ZlibStreamGet\fR(\fIzshandle, dataObj, count\fR)
318 .sp
319 \fBTcl_ZlibStreamSetCompressionDictionary\fR(\fIzshandle, compDict\fR)
320 .fi
321 .SH ARGUMENTS
322 .AS Tcl_ZlibStream zshandle in
323 .AP Tcl_Interp *interp in
324 The interpreter to store resulting compressed or uncompressed data in. Also
325 where any error messages are written. For \fBTcl_ZlibStreamInit\fR, this can
326 be NULL to create a stream that is not bound to a command.
327 .AP int format in
328 What format of compressed data to work with. Must be one of
329 \fBTCL_ZLIB_FORMAT_ZLIB\fR for zlib-format data, \fBTCL_ZLIB_FORMAT_GZIP\fR
330 for gzip-format data, or \fBTCL_ZLIB_FORMAT_RAW\fR for raw compressed data. In
331 addition, for decompression only, \fBTCL_ZLIB_FORMAT_AUTO\fR may also be
332 chosen which can automatically detect whether the compressed data was in zlib
333 or gzip format.
334 .AP Tcl_Obj *dataObj in/out
335 A byte-array value containing the data to be compressed or decompressed, or
336 to which the data extracted from the stream is appended when passed to
337 \fBTcl_ZlibStreamGet\fR.
338 .AP int level in
339 What level of compression to use. Should be a number from 0 to 9 or one of the
340 following: \fBTCL_ZLIB_COMPRESS_NONE\fR for no compression,
341 \fBTCL_ZLIB_COMPRESS_FAST\fR for fast but inefficient compression,
342 \fBTCL_ZLIB_COMPRESS_BEST\fR for slow but maximal compression, or
343 \fBTCL_ZLIB_COMPRESS_DEFAULT\fR for the level recommended by the zlib library.
344 .AP Tcl_Obj *dictObj in/out
345 A dictionary that contains, or which will be updated to contain, a description
346 of the gzip header associated with the compressed data. Only useful when the
347 \fIformat\fR is \fBTCL_ZLIB_FORMAT_GZIP\fR or \fBTCL_ZLIB_FORMAT_AUTO\fR. If
348 a NULL is passed, a default header will be used on compression and the header
349 will be ignored (apart from integrity checks) on decompression. See the
350 section \fBGZIP OPTIONS DICTIONARY\fR for details about the contents of this
351 dictionary.
352 .AP "unsigned int" initValue in
353 The initial value for the checksum algorithm.
354 .AP "unsigned char" *bytes in
355 An array of bytes to run the checksum algorithm over, or NULL to get the
356 recommended initial value for the checksum algorithm.
357 .AP int length in
358 The number of bytes in the array.
359 .AP int mode in
360 What mode to operate the stream in. Should be either
361 \fBTCL_ZLIB_STREAM_DEFLATE\fR for a compressing stream or
362 \fBTCL_ZLIB_STREAM_INFLATE\fR for a decompressing stream.
363 .AP Tcl_ZlibStream *zshandlePtr out
364 A pointer to a variable in which to write the abstract token for the stream
365 upon successful creation.
366 .AP Tcl_ZlibStream zshandle in
367 The abstract token for the stream to operate on.
368 .AP int flush in
369 Whether and how to flush the stream after writing the data to it. Must be one
370 of: \fBTCL_ZLIB_NO_FLUSH\fR if no flushing is to be done, \fBTCL_ZLIB_FLUSH\fR
371 if the currently compressed data must be made available for access using
372 \fBTcl_ZlibStreamGet\fR, \fBTCL_ZLIB_FULLFLUSH\fR if the stream must be put
373 into a state where the decompressor can recover from on corruption, or
374 \fBTCL_ZLIB_FINALIZE\fR to ensure that the stream is finished and that any
375 trailer demanded by the format is written.
376 .AP int count in
377 The maximum number of bytes to get from the stream, or -1 to get all remaining
378 bytes from the stream's buffers.
379 .AP Tcl_Obj *compDict in
380 A byte array value that is the compression dictionary to use with the stream.
381 Note that this is \fInot a Tcl dictionary\fR, and it is recommended that this
382 only ever be used with streams that were created with their \fIformat\fR set
383 to \fBTCL_ZLIB_FORMAT_ZLIB\fR because the other formats have no mechanism to
384 indicate whether a compression dictionary was present other than to fail on
385 decompression.
386 .BE
387 .SH DESCRIPTION
388 These functions form the interface from the Tcl library to the Zlib
389 library by Jean-loup Gailly and Mark Adler.
390 .PP
391 \fBTcl_ZlibDeflate\fR and \fBTcl_ZlibInflate\fR respectively compress and
392 decompress the data contained in the \fIdataObj\fR argument, according to the
393 \fIformat\fR and, for compression, \fIlevel\fR arguments. The dictionary in
394 the \fIdictObj\fR parameter is used to convey additional header information
395 about the compressed data when the compression format supports it; currently,
396 the dictionary is only used when the \fIformat\fR parameter is
397 \fBTCL_ZLIB_FORMAT_GZIP\fR or \fBTCL_ZLIB_FORMAT_AUTO\fR. For details of the
398 contents of the dictionary, see the \fBGZIP OPTIONS DICTIONARY\fR section
399 below. Upon success, both functions leave the resulting compressed or
400 decompressed data in a byte-array value that is the Tcl interpreter's result;
401 the returned value is a standard Tcl result code.
402 .PP
403 \fBTcl_ZlibAdler32\fR and \fBTcl_ZlibCRC32\fR compute checksums on arrays of
404 bytes, returning the computed checksum. Checksums are computed incrementally,
405 allowing data to be processed one block at a time, but this requires the
406 caller to maintain the current checksum and pass it in as the \fIinitValue\fR
407 parameter; the initial value to use for this can be obtained by using NULL for
408 the \fIbytes\fR parameter instead of a pointer to the array of bytes to
409 compute the checksum over. Thus, typical usage in the single data block case
410 is like this:
411 .PP
412 .CS
413 checksum = \fBTcl_ZlibCRC32\fR(\fBTcl_ZlibCRC32\fR(0,NULL,0), data, length);
414 .CE
415 .PP
416 Note that the Adler-32 algorithm is not a real checksum, but instead is a
417 related type of hash that works best on longer data.
418 .SS "ZLIB STREAMS"
419 .PP
420 \fBTcl_ZlibStreamInit\fR creates a compressing or decompressing stream that is
421 linked to a Tcl command, according to its arguments, and provides an abstract
422 token for the stream and returns a normal Tcl result code;
423 \fBTcl_ZlibStreamGetCommandName\fR returns the name of that command given the
424 stream token, or NULL if the stream has no command. Streams are not designed
425 to be thread-safe; each stream should only ever be used from the thread that
426 created it. When working with gzip streams, a dictionary (fields as given in
427 the \fBGZIP OPTIONS DICTIONARY\fR section below) can be given via the
428 \fIdictObj\fR parameter that on compression allows control over the generated
429 headers, and on decompression allows discovery of the existing headers. Note
430 that the dictionary will be written to on decompression once sufficient data
431 has been read to have a complete header. This means that the dictionary must
432 be an unshared value in that case; a blank value created with
433 \fBTcl_NewObj\fR is suggested.
434 .PP
435 Once a stream has been constructed, \fBTcl_ZlibStreamPut\fR is used to add
436 data to the stream and \fBTcl_ZlibStreamGet\fR is used to retrieve data from
437 the stream after processing. Both return normal Tcl result codes and leave an
438 error message in the result of the interpreter that the stream is registered
439 with in the error case (if such a registration has been performed). With
440 \fBTcl_ZlibStreamPut\fR, the data buffer value passed to it should not be
441 modified afterwards. With \fBTcl_ZlibStreamGet\fR, the data buffer value
442 passed to it will have the data bytes appended to it. Internally to the
443 stream, data is kept compressed so as to minimize the cost of buffer space.
444 .PP
445 \fBTcl_ZlibStreamChecksum\fR returns the checksum computed over the
446 uncompressed data according to the format, and \fBTcl_ZlibStreamEof\fR returns
447 a boolean value indicating whether the end of the uncompressed data has been
448 reached.
449 .PP
450 \fBTcl_ZlibStreamSetCompressionDictionary\fR is used to control the
451 compression dictionary used with the stream, a compression dictionary being an
452 array of bytes (such as might be created with \fBTcl_NewByteArrayObj\fR) that
453 is used to initialize the compression engine rather than leaving it to create
454 it on the fly from the data being compressed. Setting a compression dictionary
455 allows for more efficient compression in the case where the start of the data
456 is highly regular, but it does require both the compressor and the
457 decompressor to agreee on the value to use. Compression dictionaries are only
458 fully supported for zlib-format data; on compression, they must be set before
459 any data is sent in with \fBTcl_ZlibStreamPut\fR, and on decompression they
460 should be set when \fBTcl_ZlibStreamGet\fR produces an \fBerror\fR with its
461 \fB\-errorcode\fR set to
462 .QW "\fBZLIB NEED_DICT\fI code\fR" ;
463 the \fIcode\fR will be the Adler-32 checksum (see \fBTcl_ZlibAdler32\fR) of
464 the compression dictionary sought. (Note that this is only true for
465 zlib-format streams; gzip streams ignore compression dictionaries as the
466 format specification doesn't permit them, and raw streams just produce a data
467 error if the compression dictionary is missing or incorrect.)
468 .PP
469 If you wish to clear a stream and reuse it for a new compression or
470 decompression action, \fBTcl_ZlibStreamReset\fR will do this and return a
471 normal Tcl result code to indicate whether it was successful; if the stream is
472 registered with an interpreter, an error message will be left in the
473 interpreter result when this function returns TCL_ERROR.
474 Finally, \fBTcl_ZlibStreamClose\fR will clean up the stream and delete the
475 associated command: using \fBTcl_DeleteCommand\fR on the stream's command is
476 equivalent (when such a command exists).
477 .SH "GZIP OPTIONS DICTIONARY"
478 .PP
479 The \fIdictObj\fR parameter to \fBTcl_ZlibDeflate\fR, \fBTcl_ZlibInflate\fR
480 and \fBTcl_ZlibStreamInit\fR is used to pass a dictionary of options about
481 that is used to describe the gzip header in the compressed data. When creating
482 compressed data, the dictionary is read and when unpacking compressed data the
483 dictionary is written (in which case the \fIdictObj\fR parameter must refer to
484 an unshared dictionary value).
485 .PP
486 The following fields in the dictionary value are understood. All other fields
487 are ignored. No field is required when creating a gzip-format stream.
488 .TP
489 \fBcomment\fR
490 .
491 This holds the comment field of the header, if present. If absent, no comment
492 was supplied (on decompression) or will be created (on compression).
493 .TP
494 \fBcrc\fR
495 .
496 A boolean value describing whether a CRC of the header is computed. Note that
497 the \fBgzip\fR program does \fInot\fR use or allow a CRC on the header.
498 .TP
499 \fBfilename\fR
500 .
501 The name of the file that held the uncompressed data. This should not contain
502 any directory separators, and should be sanitized before use on decompression
503 with \fBfile tail\fR.
504 .TP
505 \fBos\fR
506 .
507 The operating system type code field from the header (if not the
508 .QW unknown
509 value). See RFC 1952 for the meaning of these codes. On compression, if this
510 is absent then the field will be set to the
511 .QW unknown
512 value.
513 .TP
514 \fBsize\fR
515 .
516 The size of the uncompressed data. This is ignored on compression; the size
517 of the data compressed depends on how much data is supplied to the
518 compression engine.
519 .TP
520 \fBtime\fR
521 .
522 The time field from the header if non-zero, expected to be the time that the
523 file named by the \fBfilename\fR field was modified. Suitable for use with
524 \fBclock format\fR. On creation, the right value to use is that from
525 \fBclock seconds\fR or \fBfile mtime\fR.
526 .TP
527 \fBtype\fR
528 .
529 The type of the uncompressed data (either \fBbinary\fR or \fBtext\fR) if
530 known.
531 .SH "PORTABILITY NOTES"
532 These functions will fail gracefully if Tcl is not linked with the zlib
533 library.
534 .SH "SEE ALSO"
535 Tcl_NewByteArrayObj(3), zlib(n)
536 '\"Tcl_StackChannel(3)
537 .SH "KEYWORDS"
538 compress, decompress, deflate, gzip, inflate
539 '\" Local Variables:
540 '\" mode: nroff
541 '\" fill-column: 78
542 '\" End: