fix for newest carp
This commit is contained in:
@@ -5,7 +5,7 @@ is a high-level wrapper around [zlib](https://zlib.net/).
|
|||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
```clojure
|
```clojure
|
||||||
(load "https://veitheller.de/git/carpentry/zlib.git@0.0.1")
|
(load "git@git.veitheller.de:carpentry/zlib.git@0.0.2")
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
175
docs/ZLib.html
175
docs/ZLib.html
@@ -18,20 +18,32 @@
|
|||||||
<div class="index">
|
<div class="index">
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
<a href="ZLib.html">
|
<details>
|
||||||
ZLib
|
<summary>
|
||||||
</a>
|
<a href="ZLib.html">
|
||||||
|
ZLib
|
||||||
|
</a>
|
||||||
|
</summary>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<a href="ZLib.ZLevel.html">
|
||||||
|
ZLevel
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</details>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<h1>
|
<div class="module">
|
||||||
ZLib
|
<h1>
|
||||||
</h1>
|
ZLib
|
||||||
<div class="module-description">
|
</h1>
|
||||||
<p>is a high-level wrapper around <a href="https://zlib.net/">zlib</a>.</p>
|
<div class="module-description">
|
||||||
|
<p>is a high-level wrapper around <a href="https://zlib.net/">zlib</a>.</p>
|
||||||
<h2>Installation</h2>
|
<h2>Installation</h2>
|
||||||
<pre><code class="language-clojure">(load "https://veitheller.de/git/carpentry/zlib.git@0.0.1")
|
<pre><code class="language-clojure">(load "git@git.veitheller.de:carpentry/zlib.git@0.0.2")
|
||||||
</code></pre>
|
</code></pre>
|
||||||
<h2>Usage</h2>
|
<h2>Usage</h2>
|
||||||
<p>The <code>ZLib</code> module provides only two functions, <a href="#inflate"><code>inflate</code></a> and
|
<p>The <code>ZLib</code> module provides only two functions, <a href="#inflate"><code>inflate</code></a> and
|
||||||
@@ -55,98 +67,101 @@ levels are defined in <a href="#ZLevel"><code>ZLib.ZLevel</code></a>, and are <c
|
|||||||
<code>BestSpeed</code>, <code>BestCompression</code>, and <code>DefaultCompression</code>, which is, well, the
|
<code>BestSpeed</code>, <code>BestCompression</code>, and <code>DefaultCompression</code>, which is, well, the
|
||||||
default.</p>
|
default.</p>
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="binder">
|
|
||||||
<a class="anchor" href="#ZLevel">
|
|
||||||
<h3 id="ZLevel">
|
|
||||||
ZLevel
|
|
||||||
</h3>
|
|
||||||
</a>
|
|
||||||
<div class="description">
|
|
||||||
module
|
|
||||||
</div>
|
</div>
|
||||||
<p class="sig">
|
<div class="binder">
|
||||||
Module
|
<a class="anchor" href="#ZLevel">
|
||||||
</p>
|
<h3 id="ZLevel">
|
||||||
<span>
|
<a href="ZLib.ZLevel.html">
|
||||||
|
ZLevel
|
||||||
|
</a>
|
||||||
|
</h3>
|
||||||
|
</a>
|
||||||
|
<div class="description">
|
||||||
|
module
|
||||||
|
</div>
|
||||||
|
<p class="sig">
|
||||||
|
Module
|
||||||
|
</p>
|
||||||
|
<span>
|
||||||
|
|
||||||
</span>
|
</span>
|
||||||
<p class="doc">
|
<p class="doc">
|
||||||
<p>is a type used in conjunction with
|
<p>is a type used in conjunction with
|
||||||
<a href="#deflate-with"><code>deflate-with</code></a>. It controls the compression level.</p>
|
<a href="#deflate-with"><code>deflate-with</code></a>. It controls the compression level.</p>
|
||||||
<p>The constructors are <code>NoCompression</code>, <code>BestSpeed</code>, <code>BestCompression</code>, and
|
<p>The constructors are <code>NoCompression</code>, <code>BestSpeed</code>, <code>BestCompression</code>, and
|
||||||
<code>DefaultCompression</code>, which is, well, the default.</p>
|
<code>DefaultCompression</code>, which is, well, the default.</p>
|
||||||
|
|
||||||
</p>
|
</p>
|
||||||
</div>
|
|
||||||
<div class="binder">
|
|
||||||
<a class="anchor" href="#deflate">
|
|
||||||
<h3 id="deflate">
|
|
||||||
deflate
|
|
||||||
</h3>
|
|
||||||
</a>
|
|
||||||
<div class="description">
|
|
||||||
defn
|
|
||||||
</div>
|
</div>
|
||||||
<p class="sig">
|
<div class="binder">
|
||||||
(Fn [(Ref String a)] (Result ZBytes String))
|
<a class="anchor" href="#deflate">
|
||||||
</p>
|
<h3 id="deflate">
|
||||||
<pre class="args">
|
deflate
|
||||||
(deflate s)
|
</h3>
|
||||||
</pre>
|
</a>
|
||||||
<p class="doc">
|
<div class="description">
|
||||||
<p>takes a bytes object <code>s</code> and returns a <code>Result</code>.</p>
|
defn
|
||||||
|
</div>
|
||||||
|
<p class="sig">
|
||||||
|
(Fn [(Ref String a)] (Result ZLib.ZBytes String))
|
||||||
|
</p>
|
||||||
|
<pre class="args">
|
||||||
|
(deflate s)
|
||||||
|
</pre>
|
||||||
|
<p class="doc">
|
||||||
|
<p>takes a bytes object <code>s</code> and returns a <code>Result</code>.</p>
|
||||||
<p>The <code>Result</code> will be a <code>Success</code> containing the deflated bytes if all goes
|
<p>The <code>Result</code> will be a <code>Success</code> containing the deflated bytes if all goes
|
||||||
well, and an <code>Error</code> returning an error message otherwise.</p>
|
well, and an <code>Error</code> returning an error message otherwise.</p>
|
||||||
<p>It is equivalent to calling <a href="#deflate-with"><code>deflate-with</code></a> with
|
<p>It is equivalent to calling <a href="#deflate-with"><code>deflate-with</code></a> with
|
||||||
<code>(ZLevel.DefaultCompression)</code>.</p>
|
<code>(ZLevel.DefaultCompression)</code>.</p>
|
||||||
|
|
||||||
</p>
|
</p>
|
||||||
</div>
|
|
||||||
<div class="binder">
|
|
||||||
<a class="anchor" href="#deflate-with">
|
|
||||||
<h3 id="deflate-with">
|
|
||||||
deflate-with
|
|
||||||
</h3>
|
|
||||||
</a>
|
|
||||||
<div class="description">
|
|
||||||
defn
|
|
||||||
</div>
|
</div>
|
||||||
<p class="sig">
|
<div class="binder">
|
||||||
(Fn [(Ref String a), ZLib.ZLevel] (Result ZBytes String))
|
<a class="anchor" href="#deflate-with">
|
||||||
</p>
|
<h3 id="deflate-with">
|
||||||
<pre class="args">
|
deflate-with
|
||||||
(deflate-with s level)
|
</h3>
|
||||||
</pre>
|
</a>
|
||||||
<p class="doc">
|
<div class="description">
|
||||||
<p>takes a bytes object <code>s</code>, a <code>Zlevel</code> <code>level</code> and returns
|
defn
|
||||||
|
</div>
|
||||||
|
<p class="sig">
|
||||||
|
(Fn [(Ref String a), ZLib.ZLevel] (Result ZLib.ZBytes String))
|
||||||
|
</p>
|
||||||
|
<pre class="args">
|
||||||
|
(deflate-with s level)
|
||||||
|
</pre>
|
||||||
|
<p class="doc">
|
||||||
|
<p>takes a bytes object <code>s</code>, a <code>Zlevel</code> <code>level</code> and returns
|
||||||
a <code>Result</code>.</p>
|
a <code>Result</code>.</p>
|
||||||
<p>The <code>Result</code> will be a <code>Success</code> containing the deflated bytes if all goes
|
<p>The <code>Result</code> will be a <code>Success</code> containing the deflated bytes if all goes
|
||||||
well, and an <code>Error</code> returning an error message otherwise.</p>
|
well, and an <code>Error</code> returning an error message otherwise.</p>
|
||||||
|
|
||||||
</p>
|
</p>
|
||||||
</div>
|
|
||||||
<div class="binder">
|
|
||||||
<a class="anchor" href="#inflate">
|
|
||||||
<h3 id="inflate">
|
|
||||||
inflate
|
|
||||||
</h3>
|
|
||||||
</a>
|
|
||||||
<div class="description">
|
|
||||||
defn
|
|
||||||
</div>
|
</div>
|
||||||
<p class="sig">
|
<div class="binder">
|
||||||
(Fn [ZBytes] (Result String String))
|
<a class="anchor" href="#inflate">
|
||||||
</p>
|
<h3 id="inflate">
|
||||||
<pre class="args">
|
inflate
|
||||||
(inflate s)
|
</h3>
|
||||||
</pre>
|
</a>
|
||||||
<p class="doc">
|
<div class="description">
|
||||||
<p>takes a bytes object <code>s</code> and returns a <code>Result</code>.</p>
|
defn
|
||||||
|
</div>
|
||||||
|
<p class="sig">
|
||||||
|
(Fn [ZLib.ZBytes] (Result String String))
|
||||||
|
</p>
|
||||||
|
<pre class="args">
|
||||||
|
(inflate s)
|
||||||
|
</pre>
|
||||||
|
<p class="doc">
|
||||||
|
<p>takes a bytes object <code>s</code> and returns a <code>Result</code>.</p>
|
||||||
<p>The <code>Result</code> will be a <code>Success</code> containing the inflated string if all goes
|
<p>The <code>Result</code> will be a <code>Success</code> containing the inflated string if all goes
|
||||||
well, and an <code>Error</code> returning an error message otherwise.</p>
|
well, and an <code>Error</code> returning an error message otherwise.</p>
|
||||||
|
|
||||||
</p>
|
</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
@@ -7,7 +7,7 @@
|
|||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
```clojure
|
```clojure
|
||||||
(load \"https://veitheller.de/git/carpentry/zlib.git@0.0.1\")
|
(load \"git@git.veitheller.de:carpentry/zlib.git@0.0.2\")
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
@@ -45,17 +45,15 @@ default.")
|
|||||||
len Int
|
len Int
|
||||||
bytes String
|
bytes String
|
||||||
])
|
])
|
||||||
(private ZBytes)
|
|
||||||
(hidden ZBytes)
|
(hidden ZBytes)
|
||||||
|
|
||||||
(register-type ZRes)
|
(register-type ZRes)
|
||||||
(defmodule ZRes
|
(defmodule ZRes
|
||||||
(register ok? (Fn [&ZRes] Bool) "ZRes_is_ok")
|
(register ok? (Fn [&ZRes] Bool) "ZRes_is_ok")
|
||||||
(register bytes (Fn [ZRes] ZBytes) "ZRes_bytes")
|
(register bytes (Fn [ZRes] ZLib.ZBytes) "ZRes_bytes")
|
||||||
(register str (Fn [ZRes] String) "ZRes_str")
|
(register str (Fn [ZRes] String) "ZRes_str")
|
||||||
(register err (Fn [ZRes] String) "ZRes_err")
|
(register err (Fn [ZRes] String) "ZRes_err")
|
||||||
)
|
)
|
||||||
(private ZRes)
|
|
||||||
(hidden ZRes)
|
(hidden ZRes)
|
||||||
|
|
||||||
(deftype ZLevel
|
(deftype ZLevel
|
||||||
@@ -80,7 +78,7 @@ The constructors are `NoCompression`, `BestSpeed`, `BestCompression`, and
|
|||||||
|
|
||||||
(private inflate-)
|
(private inflate-)
|
||||||
(hidden inflate-)
|
(hidden inflate-)
|
||||||
(register inflate- (Fn [ZBytes] ZRes) "ZLib_inflate_c")
|
(register inflate- (Fn [ZLib.ZBytes] ZRes) "ZLib_inflate_c")
|
||||||
(doc inflate "takes a bytes object `s` and returns a `Result`.
|
(doc inflate "takes a bytes object `s` and returns a `Result`.
|
||||||
|
|
||||||
The `Result` will be a `Success` containing the inflated string if all goes
|
The `Result` will be a `Success` containing the inflated string if all goes
|
||||||
|
@@ -5,13 +5,13 @@
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
int len;
|
int len;
|
||||||
char* bytes;
|
char* bytes;
|
||||||
} ZBytes;
|
} ZLibZBytes;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int which;
|
int which;
|
||||||
union {
|
union {
|
||||||
int err;
|
int err;
|
||||||
ZBytes* out;
|
ZLibZBytes* out;
|
||||||
};
|
};
|
||||||
} ZRes;
|
} ZRes;
|
||||||
#define ZRES_OK 0
|
#define ZRES_OK 0
|
||||||
@@ -21,7 +21,7 @@ bool ZRes_is_ok(ZRes* r) {
|
|||||||
return r->which == ZRES_OK;
|
return r->which == ZRES_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
ZBytes ZRes_bytes(ZRes r) {
|
ZLibZBytes ZRes_bytes(ZRes r) {
|
||||||
assert(r.which == ZRES_OK);
|
assert(r.which == ZRES_OK);
|
||||||
return *r.out;
|
return *r.out;
|
||||||
}
|
}
|
||||||
@@ -63,7 +63,7 @@ char* ZRes_err(ZRes r) {
|
|||||||
__typeof__ (b) _b = (b); \
|
__typeof__ (b) _b = (b); \
|
||||||
_a < _b ? _a : _b; })
|
_a < _b ? _a : _b; })
|
||||||
|
|
||||||
ZRes ZLib_inflate_c(ZBytes b) {
|
ZRes ZLib_inflate_c(ZLibZBytes b) {
|
||||||
int ret;
|
int ret;
|
||||||
ZRes res;
|
ZRes res;
|
||||||
unsigned have;
|
unsigned have;
|
||||||
@@ -73,7 +73,7 @@ ZRes ZLib_inflate_c(ZBytes b) {
|
|||||||
int offs = 0;
|
int offs = 0;
|
||||||
int len = b.len;
|
int len = b.len;
|
||||||
char* source = b.bytes;
|
char* source = b.bytes;
|
||||||
ZBytes* bytes = malloc(sizeof(ZBytes));
|
ZLibZBytes* bytes = malloc(sizeof(ZLibZBytes));
|
||||||
bytes->bytes = NULL;
|
bytes->bytes = NULL;
|
||||||
bytes->len = 0;
|
bytes->len = 0;
|
||||||
|
|
||||||
@@ -143,7 +143,7 @@ ZRes ZLib_deflate_c(String* s, int level) {
|
|||||||
unsigned char out[CHUNK];
|
unsigned char out[CHUNK];
|
||||||
int offs = 0;
|
int offs = 0;
|
||||||
int len = strlen(*s);
|
int len = strlen(*s);
|
||||||
ZBytes* bytes = malloc(sizeof(ZBytes));
|
ZLibZBytes* bytes = malloc(sizeof(ZLibZBytes));
|
||||||
bytes->bytes = NULL;
|
bytes->bytes = NULL;
|
||||||
bytes->len = 0;
|
bytes->len = 0;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user