-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* implemented very simple interface to zlib
- Loading branch information
Bastian Müller
committed
Jan 19, 2008
0 parents
commit 1d9ee8b
Showing
3 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)); | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
library: zlib | ||
executable: zlib | ||
c-libraries: -lz | ||
files: library | ||
main |