From 1d9ee8b342d27d93494aeee5c1770260dc2cc5e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20M=C3=BCller?= Date: Sat, 19 Jan 2008 22:11:04 +0000 Subject: [PATCH] * implemented very simple interface to zlib --- library.dylan | 13 +++++++++++++ main.dylan | 32 ++++++++++++++++++++++++++++++++ zlib.lid | 5 +++++ 3 files changed, 50 insertions(+) create mode 100644 library.dylan create mode 100644 main.dylan create mode 100644 zlib.lid diff --git a/library.dylan b/library.dylan new file mode 100644 index 0000000..bad31a2 --- /dev/null +++ b/library.dylan @@ -0,0 +1,13 @@ +module: dylan-user + +define library zlib + use common-dylan; + use c-ffi; + export zlib; +end library; + +define module zlib + use common-dylan; + use c-ffi; + export compress; +end module; diff --git a/main.dylan b/main.dylan new file mode 100644 index 0000000..2a969fb --- /dev/null +++ b/main.dylan @@ -0,0 +1,32 @@ +module: zlib + +define C-function zlib-compress + parameter destination :: ; + parameter destination-length :: ; + parameter source :: ; + parameter source-length :: ; + result return-code :: ; + c-name: "compress" +end; + +define C-function zlib-compress-bound + parameter source-length :: ; + result return-code :: ; + c-name: "compressBound" +end; + +define function compress (string :: ) + => (compressed-string :: ); + let destination-length :: = make(); + destination-length.pointer-value := zlib-compress-bound(size(string)); + let result = make(, size: destination-length.pointer-value, fill: ' '); + if (zlib-compress(result, destination-length, string, size(string)) ~= 0) + error("zlib compress failed."); + else + result; + end if; +end; +/* +define variable foobar = "foobar"; +format-out("%= => %=\n", foobar, compress(foobar)); +*/ diff --git a/zlib.lid b/zlib.lid new file mode 100644 index 0000000..c659072 --- /dev/null +++ b/zlib.lid @@ -0,0 +1,5 @@ +library: zlib +executable: zlib +c-libraries: -lz +files: library + main