[Gd-chatter] r11643 - in trunk/libraries: registry/generic zlib

turbo24prg at gwydiondylan.org turbo24prg at gwydiondylan.org
Sat Jan 19 23:11:04 CET 2008


Author: turbo24prg
Date: Sat Jan 19 23:11:04 2008
New Revision: 11643

Added:
   trunk/libraries/registry/generic/zlib   (contents, props changed)
   trunk/libraries/zlib/
   trunk/libraries/zlib/library.dylan   (contents, props changed)
   trunk/libraries/zlib/main.dylan   (contents, props changed)
   trunk/libraries/zlib/zlib.lid   (contents, props changed)
Log:
Job: minor
* implemented very simple interface to zlib


Added: trunk/libraries/registry/generic/zlib
==============================================================================
--- (empty file)
+++ trunk/libraries/registry/generic/zlib	Sat Jan 19 23:11:04 2008
@@ -0,0 +1 @@
+abstract://dylan/zlib/zlib.lid

Added: trunk/libraries/zlib/library.dylan
==============================================================================
--- (empty file)
+++ trunk/libraries/zlib/library.dylan	Sat Jan 19 23:11:04 2008
@@ -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;

Added: trunk/libraries/zlib/main.dylan
==============================================================================
--- (empty file)
+++ trunk/libraries/zlib/main.dylan	Sat Jan 19 23:11:04 2008
@@ -0,0 +1,32 @@
+module: zlib
+
+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 compress (string :: <string>)
+ => (compressed-string :: <string>);
+  let destination-length :: <C-int*> = make(<C-int*>);
+  destination-length.pointer-value := zlib-compress-bound(size(string));
+  let result = make(<C-string>, 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));
+*/

Added: trunk/libraries/zlib/zlib.lid
==============================================================================
--- (empty file)
+++ trunk/libraries/zlib/zlib.lid	Sat Jan 19 23:11:04 2008
@@ -0,0 +1,5 @@
+library: zlib
+executable: zlib
+c-libraries: -lz 
+files: library
+  main



More information about the chatter mailing list