| Paste number 54493: | zlib interface |
| Pasted by: | turbo24prg |
| 7 months, 2 weeks ago | |
| #dylan | Context in IRC logs | |
| Paste contents: |
| ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen)); /* Compresses the source buffer into the destination buffer. sourceLen is the byte length of the source buffer. Upon entry, destLen is the total size of the destination buffer, which must be at least the value returned by compressBound(sourceLen). Upon exit, destLen is the actual size of the compressed buffer. This function can be used to compress a whole file at once if the input file is mmap'ed. compress returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR if there was not enough room in the output buffer. */ define C-function zlib-compress parameter destination :: <C-string>; parameter destination-length :: <C-int*>; parameter source :: <C-string>; parameter source-length :: <C-int>; result return-code :: <C-int>; c-name: "compress" end; define C-function zlib-compress-bound parameter source-length :: <C-int>; result return-code :: <C-int>; c-name: "compressBound" end; define function main (name, arguments) let foo = "asdhalsdhald asldhlasdjasda sdajsdbajkd;bhdk bhadjkaSDBASd ujwheiqecvuhxohero"; let bar = make(<C-string>, value: ""); let bar-size :: <C-int*> = make(<C-int*>, value: zlib-compress-bound(size(foo))); format-out("return-code: %d\n", zlib-compress(bar, bar-size, foo, size(foo))); exit-application(0); end function main; |
Annotations for this paste:
| Annotation number 1: | corrected |
| Pasted by: | turbo24prg |
| 7 months, 2 weeks ago | |
| Context in IRC logs | |
| Paste contents: |
| define function main (name, arguments) let foo = "asdhalsdhald asldhlasdjasda sdajsdbajkd;bhdk bhadjkaSDBASd ujwheiqecvuhxohero"; let bar = make(<C-string>, size: 42, fill: ' '); let bar-size :: <C-int*> = make(<C-int*>); bar-size.pointer-value := zlib-compress-bound(size(foo)); format-out("> %d\n", pointer-value(bar-size)); format-out("return-code: %d\n", zlib-compress(bar, bar-size, foo, size(foo))); format-out("> %=\n", bar); exit-application(0); end function main; |
| Annotation number 2: | correction |
| Pasted by: | turbo24prg |
| 7 months, 2 weeks ago | |
| Context in IRC logs | |
| Paste contents: |
| let foo = "asdhalsdhald asldhlasdjasda sdajsdbajkd;bhdk bhadjkaSDBASd ujwheiqecvuhxohero"; let bar-size :: <C-int*> = make(<C-int*>); bar-size.pointer-value := zlib-compress-bound(size(foo)); let bar = make(<C-string>, size: bar-size.pointer-value, fill: ' '); format-out("return-code: %d\n", zlib-compress(bar, bar-size, foo, size(foo))); format-out("> %=\n", bar); |