summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS9
-rw-r--r--doc/index.html2
-rw-r--r--doc/license.html2
-rw-r--r--doc/upgrade.html4
-rw-r--r--package/deps.mak3
-rw-r--r--package/info2
-rw-r--r--src/include/skalibs/cplz.h12
-rw-r--r--src/include/skalibs/netstring.h3
-rw-r--r--src/include/skalibs/skalibs.h1
-rw-r--r--src/libstddjb/mininetstring_read.c45
10 files changed, 78 insertions, 5 deletions
diff --git a/NEWS b/NEWS
index b9fcab4..e0e040f 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,14 @@
Changelog for skalibs.
+In 2.4.3.0
+----------
+
+ - Bugfixes.
+ - Newish function: mininetstring_read().
+ (was previously removed in 2.7.0.0)
+ - New header: cplz.h
+
+
In 2.4.2.0
----------
diff --git a/doc/index.html b/doc/index.html
index a4e5773..8b82012 100644
--- a/doc/index.html
+++ b/doc/index.html
@@ -60,7 +60,7 @@ with a standard C development environment </li>
<h3> Download </h3>
<ul>
- <li> The current released version of skalibs is <a href="skalibs-2.14.2.1.tar.gz">2.14.2.1</a>. </li>
+ <li> The current released version of skalibs is <a href="skalibs-2.14.3.0.tar.gz">2.14.3.0</a>. </li>
<li> Alternatively, you can checkout a copy of the
<a href="//git.skarnet.org/cgi-bin/cgit.cgi/skalibs/">skalibs
git repository</a>:
diff --git a/doc/license.html b/doc/license.html
index ccc9d88..5a19ec1 100644
--- a/doc/license.html
+++ b/doc/license.html
@@ -74,7 +74,7 @@ color, or different text font. </li>
<p>
<em>I am aware that the previous restrictions sound completely
ridiculous while the official skalibs documentation is incomplete.
-As of 2.14.2.1, I'm not going to enforce those restrictions, but if you're
+As of 2.14.3.0, I'm not going to enforce those restrictions, but if you're
going to provide documentation for skalibs, don't keep it to yourself,
please send it to me instead. :-) </em>
</p>
diff --git a/doc/upgrade.html b/doc/upgrade.html
index 1ced277..2a93362 100644
--- a/doc/upgrade.html
+++ b/doc/upgrade.html
@@ -16,10 +16,12 @@
<a href="//skarnet.org/">skarnet.org</a>
</p>
-<h2> in 2.14.2.1 </h2>
+<h2> in 2.14.3.0 </h2>
<ul>
<li> <tt>UNIXMESSAGE_MAXFDS</tt> decreased to 253. </li>
+ <li> New <tt>mininetstring_read()</tt> function. (Was
+previously removed in 2.7.0.0.) </li>
</ul>
<h2> in 2.14.2.0 </h2>
diff --git a/package/deps.mak b/package/deps.mak
index 461d97f..e325d61 100644
--- a/package/deps.mak
+++ b/package/deps.mak
@@ -41,7 +41,7 @@ src/include/skalibs/sha512.h: src/include/skalibs/uint64.h
src/include/skalibs/sig.h: src/include/skalibs/gccattributes.h
src/include/skalibs/siovec.h: src/include/skalibs/gccattributes.h
src/include/skalibs/skaclient.h: src/include/skalibs/kolbak.h src/include/skalibs/tai.h src/include/skalibs/unixmessage.h
-src/include/skalibs/skalibs.h: src/include/skalibs/datastruct.h src/include/skalibs/posixplz.h src/include/skalibs/random.h src/include/skalibs/stdcrypto.h src/include/skalibs/stddjb.h src/include/skalibs/strerr.h src/include/skalibs/unixonacid.h
+src/include/skalibs/skalibs.h: src/include/skalibs/cplz.h src/include/skalibs/datastruct.h src/include/skalibs/posixplz.h src/include/skalibs/random.h src/include/skalibs/stdcrypto.h src/include/skalibs/stddjb.h src/include/skalibs/strerr.h src/include/skalibs/unixonacid.h
src/include/skalibs/skamisc.h: src/include/skalibs/buffer.h src/include/skalibs/stralloc.h
src/include/skalibs/socket.h: src/include/skalibs/fcntl.h src/include/skalibs/gccattributes.h src/include/skalibs/posixplz.h src/include/skalibs/tai.h
src/include/skalibs/stat.h: src/include/skalibs/sysdeps.h
@@ -435,6 +435,7 @@ src/libstddjb/ltm64_from_localtm.o src/libstddjb/ltm64_from_localtm.lo: src/libs
src/libstddjb/ltm64_from_sysclock.o src/libstddjb/ltm64_from_sysclock.lo: src/libstddjb/ltm64_from_sysclock.c src/include/skalibs/config.h src/include/skalibs/djbtime.h src/include/skalibs/tai.h
src/libstddjb/ltm64_from_tai.o src/libstddjb/ltm64_from_tai.lo: src/libstddjb/ltm64_from_tai.c src/libstddjb/djbtime-internal.h src/include/skalibs/djbtime.h
src/libstddjb/ltm64_from_utc.o src/libstddjb/ltm64_from_utc.lo: src/libstddjb/ltm64_from_utc.c src/libstddjb/djbtime-internal.h src/include/skalibs/djbtime.h src/include/skalibs/uint64.h
+src/libstddjb/mininetstring_read.o src/libstddjb/mininetstring_read.lo: src/libstddjb/mininetstring_read.c src/include/skalibs/allreadwrite.h src/include/skalibs/netstring.h src/include/skalibs/stralloc.h
src/libstddjb/ndelay_off.o src/libstddjb/ndelay_off.lo: src/libstddjb/ndelay_off.c src/include/skalibs/djbunix.h src/include/skalibs/fcntl.h
src/libstddjb/ndelay_on.o src/libstddjb/ndelay_on.lo: src/libstddjb/ndelay_on.c src/include/skalibs/djbunix.h src/include/skalibs/fcntl.h
src/libstddjb/netstring_append.o src/libstddjb/netstring_append.lo: src/libstddjb/netstring_append.c src/include/skalibs/netstring.h src/include/skalibs/stralloc.h src/include/skalibs/uint64.h
diff --git a/package/info b/package/info
index 89f88b4..49f061c 100644
--- a/package/info
+++ b/package/info
@@ -1,4 +1,4 @@
package=skalibs
-version=2.14.2.1
+version=2.14.3.0
category=prog
package_macro_name=SKALIBS
diff --git a/src/include/skalibs/cplz.h b/src/include/skalibs/cplz.h
new file mode 100644
index 0000000..232c2e0
--- /dev/null
+++ b/src/include/skalibs/cplz.h
@@ -0,0 +1,12 @@
+/* ISC license. */
+
+#ifndef SKALIBS_CPLZ_H
+#define SKALIBS_CPLZ_H
+
+ /*
+ Tricks to work around misdesigns of C.
+ */
+
+#define LAUNDER(p) do { void *_p = p ; asm volatile("" : "+r"(_p) ::) ; _p ; } while (0)
+
+#endif
diff --git a/src/include/skalibs/netstring.h b/src/include/skalibs/netstring.h
index 24879c2..92a64d1 100644
--- a/src/include/skalibs/netstring.h
+++ b/src/include/skalibs/netstring.h
@@ -3,6 +3,7 @@
#ifndef SKALIBS_NETSTRING_H
#define SKALIBS_NETSTRING_H
+#include <stdint.h>
#include <string.h>
#include <sys/uio.h>
@@ -23,4 +24,6 @@ extern int netstring_put (buffer *, char const *, size_t, size_t *) ;
#define netstring_putba(ba, s, n) netstring_appendb(&(ba)->x, s, n)
#define netstring_putbav(ba, v, n) netstring_appendv(&(ba)->x, v, n)
+extern int mininetstring_read (int, stralloc *, uint32_t *) ;
+
#endif
diff --git a/src/include/skalibs/skalibs.h b/src/include/skalibs/skalibs.h
index 60c9577..2c55ef2 100644
--- a/src/include/skalibs/skalibs.h
+++ b/src/include/skalibs/skalibs.h
@@ -13,6 +13,7 @@
- skalibs/posixishard.h: post-system headers workarounds for conformance failures
*/
+#include <skalibs/cplz.h>
#include <skalibs/posixplz.h>
#include <skalibs/stddjb.h>
#include <skalibs/strerr.h>
diff --git a/src/libstddjb/mininetstring_read.c b/src/libstddjb/mininetstring_read.c
new file mode 100644
index 0000000..b4439c9
--- /dev/null
+++ b/src/libstddjb/mininetstring_read.c
@@ -0,0 +1,45 @@
+/* ISC license. */
+
+#include <stdint.h>
+#include <errno.h>
+
+#include <skalibs/allreadwrite.h>
+#include <skalibs/stralloc.h>
+#include <skalibs/netstring.h>
+
+int mininetstring_read (int fd, stralloc *sa, uint32_t *w)
+{
+ if (!*w)
+ {
+ unsigned char pack[2] ;
+ switch (fd_read(fd, (char *)pack, 2))
+ {
+ case -1 : return -1 ;
+ case 0 : return 0 ;
+ case 1 : *w = ((uint32_t)pack[0] << 8) | (1U << 31) ; break ;
+ case 2 : *w = ((uint32_t)pack[0] << 8) | (uint32_t)pack[1] | (1U << 30) ; break ;
+ default : return (errno = EDOM, -1) ;
+ }
+ }
+ if (*w & (1U << 31))
+ {
+ unsigned char c ;
+ switch (fd_read(fd, (char *)&c, 1))
+ {
+ case -1 : return -1 ;
+ case 0 : return (errno = EPIPE, -1) ;
+ case 1 : *w |= (uint32_t)c | (1U << 30) ; *w &= ~(1U << 31) ; break ;
+ default : return (errno = EDOM, -1) ;
+ }
+ }
+ if (*w & (1U << 30))
+ {
+ if (!stralloc_readyplus(sa, *w & ~(1U << 30))) return -1 ;
+ *w &= ~(1U << 30) ;
+ }
+ {
+ size_t r = allread(fd, sa->s + sa->len, *w) ;
+ sa->len += r ; *w -= r ;
+ }
+ return *w ? -1 : 1 ;
+}