From cc57ca6ab355784f4901009184ea95a9f915ef21 Mon Sep 17 00:00:00 2001
From: Laurent Bercot
Date: Fri, 5 Jul 2024 09:07:33 +0000
Subject: Prepare for 2.14.3.0; add mininetstring_read, cplz.h
Signed-off-by: Laurent Bercot
---
NEWS | 9 ++++++++
doc/index.html | 2 +-
doc/license.html | 2 +-
doc/upgrade.html | 4 +++-
package/deps.mak | 3 ++-
package/info | 2 +-
src/include/skalibs/cplz.h | 12 ++++++++++
src/include/skalibs/netstring.h | 3 +++
src/include/skalibs/skalibs.h | 1 +
src/libstddjb/mininetstring_read.c | 45 ++++++++++++++++++++++++++++++++++++++
10 files changed, 78 insertions(+), 5 deletions(-)
create mode 100644 src/include/skalibs/cplz.h
create mode 100644 src/libstddjb/mininetstring_read.c
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
Download
- - The current released version of skalibs is 2.14.2.1.
+ - The current released version of skalibs is 2.14.3.0.
- Alternatively, you can checkout a copy of the
skalibs
git repository:
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.
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. :-)
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 @@
skarnet.org
- in 2.14.2.1
+ in 2.14.3.0
- UNIXMESSAGE_MAXFDS decreased to 253.
+ - New mininetstring_read() function. (Was
+previously removed in 2.7.0.0.)
in 2.14.2.0
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
#include
#include
@@ -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
#include
#include
#include
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
+#include
+
+#include
+#include
+#include
+
+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 ;
+}
--
cgit v1.2.3