source: project/release/3/lzma/trunk/lzma.scm @ 13063

Last change on this file since 13063 was 13063, checked in by Alaric Snell-Pym, 11 years ago

lzma version 1.0

File size: 1009 bytes
Line 
1(declare (export lzma:compress lzma:decompress))
2
3(use lolevel)
4
5(foreign-declare "#include <lzmalib.h>")
6
7(foreign-declare "static int lzma_return_buffer_len;")
8
9(define-foreign-variable lzma-return-buffer-len int "lzma_return_buffer_len")
10(define _decompress (foreign-lambda* c-pointer ((blob inblob) (int inlen))
11   "C_return (lzma_decompress(inblob, inlen, &lzma_return_buffer_len));"))
12(define _compress (foreign-lambda* c-pointer ((blob inblob) (int inlen))
13   "C_return (lzma_compress(inblob, inlen, &lzma_return_buffer_len));"))
14
15(define (lzma:decompress inblob)
16   (let* ((ptr (_decompress inblob (blob-size inblob)))
17          (outblob (make-blob lzma-return-buffer-len)))
18      (begin
19         (move-memory! ptr outblob lzma-return-buffer-len)
20         outblob)))
21
22(define (lzma:compress inblob)
23   (let* ((ptr (_compress inblob (blob-size inblob)))
24          (outblob (make-blob lzma-return-buffer-len)))
25      (begin
26         (move-memory! ptr outblob lzma-return-buffer-len)
27         outblob)))
Note: See TracBrowser for help on using the repository browser.