summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/alloc.h12
-rw-r--r--include/base64.h7
-rw-r--r--include/buffer.h63
-rw-r--r--include/byte.h21
-rw-r--r--include/case.h17
-rw-r--r--include/cdbmake.h39
-rw-r--r--include/cdbread.h38
-rw-r--r--include/close.h12
-rw-r--r--include/constmap.h21
-rw-r--r--include/direntry.h10
-rw-r--r--include/dnsresolv.h202
-rw-r--r--include/env.h29
-rw-r--r--include/error.h57
-rw-r--r--include/exit.h13
-rw-r--r--include/fd.h8
-rw-r--r--include/fifo.h12
-rw-r--r--include/fmt.h36
-rw-r--r--include/genalloc.h74
-rw-r--r--include/getln.h10
-rw-r--r--include/getoptb.h28
-rw-r--r--include/iopause.h28
-rw-r--r--include/ip.h107
-rw-r--r--include/lock.h14
-rw-r--r--include/logmsg.h31
-rw-r--r--include/ndelay.h13
-rw-r--r--include/open.h16
-rw-r--r--include/pathexec.h10
-rw-r--r--include/prot.h7
-rw-r--r--include/readclose.h14
-rw-r--r--include/readwrite.h9
-rw-r--r--include/rename.h6
-rw-r--r--include/scan.h12
-rw-r--r--include/seek.h15
-rw-r--r--include/select.h13
-rw-r--r--include/sig.h63
-rw-r--r--include/socket_if.h97
-rw-r--r--include/str.h25
-rw-r--r--include/stralloc.h49
-rw-r--r--include/tai.h74
-rw-r--r--include/taia.h40
-rw-r--r--include/timeout.h7
-rw-r--r--include/timeoutconn.h10
-rw-r--r--include/uint_t.h76
-rw-r--r--include/wait.h20
44 files changed, 1465 insertions, 0 deletions
diff --git a/include/alloc.h b/include/alloc.h
new file mode 100644
index 0000000..56a4a52
--- /dev/null
+++ b/include/alloc.h
@@ -0,0 +1,12 @@
+#ifndef ALLOC_H
+#define ALLOC_H
+
+extern /*@null@*//*@out@*/char *alloc();
+extern void alloc_free();
+extern int alloc_re();
+
+/* use these names in the future */
+#define qfree alloc_free
+#define qrealloc alloc_re
+
+#endif
diff --git a/include/base64.h b/include/base64.h
new file mode 100644
index 0000000..a9164c0
--- /dev/null
+++ b/include/base64.h
@@ -0,0 +1,7 @@
+#ifndef BASE64_H
+#define BASE64_H
+
+extern int b64decode();
+extern int b64encode();
+
+#endif
diff --git a/include/buffer.h b/include/buffer.h
new file mode 100644
index 0000000..57cd960
--- /dev/null
+++ b/include/buffer.h
@@ -0,0 +1,63 @@
+#ifndef BUFFER_H
+#define BUFFER_H
+#include <sys/types.h> /* need type: ssize_t */
+
+typedef struct buffer {
+ char *x;
+ unsigned int p;
+ size_t n;
+ int fd;
+ ssize_t (*op)();
+} buffer;
+
+#define BUFFER_INIT(op,fd,buf,len) { (buf), 0, (len), (fd), (op) }
+#define BUFFER_SMALL 256
+#define BUFFER_INSIZE 8192
+#define BUFFER_OUTSIZE 8192
+#define BUFFER_MTUSIZE 1450
+
+extern void buffer_init(buffer *,ssize_t (*op)(),int,char *,size_t);
+
+extern int buffer_flush(buffer *);
+extern int buffer_put(buffer *,const char *,size_t);
+extern int buffer_putalign(buffer *,const char *,size_t);
+extern int buffer_putflush(buffer *,const char *,size_t);
+extern int buffer_puts(buffer *,const char *);
+extern int buffer_putsalign(buffer *,const char *);
+extern int buffer_putsflush(buffer *,const char *);
+
+#define buffer_PUTC(s,c) \
+ ( ((s)->n != (s)->p) \
+ ? ( (s)->x[(s)->p++] = (c), 0 ) \
+ : buffer_put((s),&(c),1) \
+ )
+
+extern int buffer_get(buffer *,char *,size_t);
+extern int buffer_bget(buffer *,char *,size_t);
+extern int buffer_feed(buffer *);
+
+extern char *buffer_peek(buffer *);
+extern void buffer_seek(buffer *,size_t);
+
+#define buffer_PEEK(s) ( (s)->x + (s)->n )
+#define buffer_SEEK(s,len) ( ( (s)->p -= (len) ) , ( (s)->n += (len) ) )
+
+#define buffer_GETC(s,c) \
+ ( ((s)->p > 0) \
+ ? ( *(c) = (s)->x[(s)->n], buffer_SEEK((s),1), 1 ) \
+ : buffer_get((s),(c),1) \
+ )
+
+extern int buffer_copy(buffer *,buffer *);
+
+extern ssize_t buffer_unixread(int,char *,size_t);
+extern ssize_t buffer_unixwrite(int,char *,size_t);
+
+extern buffer *buffer_0;
+extern buffer *buffer_1;
+extern buffer *buffer_2;
+extern buffer *buffer_0small;
+extern buffer *buffer_1small;
+extern buffer *buffer_2small;
+
+#endif
diff --git a/include/byte.h b/include/byte.h
new file mode 100644
index 0000000..f437341
--- /dev/null
+++ b/include/byte.h
@@ -0,0 +1,21 @@
+#ifndef BYTE_H
+#define BYTE_H
+
+/**
+ @file byte.h
+ @author djb, feh
+ @source s/qmail
+ @comment no declaration of argument types; too many compiler errors
+*/
+
+extern unsigned int byte_chr();
+extern unsigned int byte_rchr();
+extern void byte_copy();
+extern void byte_copyr();
+extern int byte_diff();
+extern void byte_zero();
+extern void byte_fill();
+
+#define byte_equal(s,n,t) (!byte_diff((s),(n),(t)))
+
+#endif
diff --git a/include/case.h b/include/case.h
new file mode 100644
index 0000000..d4cead2
--- /dev/null
+++ b/include/case.h
@@ -0,0 +1,17 @@
+#ifndef CASE_H
+#define CASE_H
+
+extern void case_lowers(char *);
+extern void case_lowerb(char *,unsigned int);
+extern void case_uppers(char *);
+extern void case_upperb(char *,unsigned int);
+extern int case_diffs(char *,char *);
+extern int case_diffrs(char *,char *);
+extern int case_diffb(char *,unsigned int,char *);
+extern int case_starts(char *,char *);
+extern int case_startb(char *,unsigned int,char *);
+
+#define case_equals(s,t) (!case_diffs((s),(t)))
+#define case_equalrs(s,t) (!case_diffrs((s),(t)))
+
+#endif
diff --git a/include/cdbmake.h b/include/cdbmake.h
new file mode 100644
index 0000000..9c20d2d
--- /dev/null
+++ b/include/cdbmake.h
@@ -0,0 +1,39 @@
+/* Public domain. */
+
+#ifndef CDB_MAKE_H
+#define CDB_MAKE_H
+
+#include "buffer.h"
+#include "uint_t.h"
+
+#define CDB_HPLIST 1000
+
+struct cdb_hp { uint32 h; uint32 p; } ;
+
+struct cdb_hplist {
+ struct cdb_hp hp[CDB_HPLIST];
+ struct cdb_hplist *next;
+ int num;
+} ;
+
+struct cdb_make {
+ char bspace[8192];
+ char final[2048];
+ uint32 count[256];
+ uint32 start[256];
+ struct cdb_hplist *head;
+ struct cdb_hp *split; /* includes space for hash */
+ struct cdb_hp *hash;
+ uint32 numentries;
+ buffer b;
+ uint32 pos;
+ int fd;
+} ;
+
+extern int cdb_make_start(struct cdb_make *,int);
+extern int cdb_make_addbegin(struct cdb_make *,unsigned int,unsigned int);
+extern int cdb_make_addend(struct cdb_make *,unsigned int,unsigned int,uint32);
+extern int cdb_make_add(struct cdb_make *,char *,unsigned int,char *,unsigned int);
+extern int cdb_make_finish(struct cdb_make *);
+
+#endif
diff --git a/include/cdbread.h b/include/cdbread.h
new file mode 100644
index 0000000..bee4fd4
--- /dev/null
+++ b/include/cdbread.h
@@ -0,0 +1,38 @@
+/* Public domain. */
+
+#ifndef CDB_H
+#define CDB_H
+
+#include "uint_t.h"
+
+#define CDB_HASHSTART 5381ULL
+extern uint32 cdb_hashadd(uint32,unsigned char);
+extern uint32 cdb_hash(char *,unsigned int);
+extern uint32 cdb_unpack(unsigned char *);
+
+struct cdb {
+ char *map; /* 0 if no map is available */
+ int fd;
+ uint32 size; /* initialized if map is nonzero */
+ uint32 loop; /* number of hash slots searched under this key */
+ uint32 khash; /* initialized if loop is nonzero */
+ uint32 kpos; /* initialized if loop is nonzero */
+ uint32 hpos; /* initialized if loop is nonzero */
+ uint32 hslots; /* initialized if loop is nonzero */
+ uint32 dpos; /* initialized if cdb_findnext() returns 1 */
+ uint32 dlen; /* initialized if cdb_findnext() returns 1 */
+} ;
+
+extern void cdb_free(struct cdb *);
+extern void cdb_init(struct cdb *,int fd);
+
+extern int cdb_read(struct cdb *,char *,unsigned int,uint32);
+
+extern void cdb_findstart(struct cdb *);
+extern int cdb_findnext(struct cdb *,char *,unsigned int);
+extern int cdb_find(struct cdb *,char *,unsigned int);
+
+#define cdb_datapos(c) ((c)->dpos)
+#define cdb_datalen(c) ((c)->dlen)
+
+#endif
diff --git a/include/close.h b/include/close.h
new file mode 100644
index 0000000..fc5b7bb
--- /dev/null
+++ b/include/close.h
@@ -0,0 +1,12 @@
+#ifndef CLOSE_H
+#define CLOSE_H
+
+/*
+ * Revision 20160713, Kai Peter
+ *
+ * (POSIX: 'close' is defined in <unistd.h>)
+*/
+
+extern int close(int __fd);
+
+#endif
diff --git a/include/constmap.h b/include/constmap.h
new file mode 100644
index 0000000..750702e
--- /dev/null
+++ b/include/constmap.h
@@ -0,0 +1,21 @@
+#ifndef CONSTMAP_H
+#define CONSTMAP_H
+
+typedef unsigned long constmap_hash;
+
+struct constmap {
+ int num;
+ constmap_hash mask;
+ constmap_hash *hash;
+ int *first;
+ int *next;
+ char **input;
+ int *inputlen;
+} ;
+
+int constmap_init(struct constmap *,char *,int,int);
+int constmap_init_char(struct constmap *,char *,int,int,char);
+void constmap_free();
+char *constmap();
+
+#endif
diff --git a/include/direntry.h b/include/direntry.h
new file mode 100644
index 0000000..d1628a9
--- /dev/null
+++ b/include/direntry.h
@@ -0,0 +1,10 @@
+#ifndef DIRENTRY_H
+#define DIRENTRY_H
+
+/* sysdep: +dirent */
+
+#include <sys/types.h>
+#include <dirent.h>
+#define direntry struct dirent
+
+#endif
diff --git a/include/dnsresolv.h b/include/dnsresolv.h
new file mode 100644
index 0000000..406af50
--- /dev/null
+++ b/include/dnsresolv.h
@@ -0,0 +1,202 @@
+#ifndef DNSRESOLV_H
+#define DNSRESOLV_H
+
+/*
+ * Revision 20230613, Erwin Hoffmann
+ * - DNS_NXD (return code 0) for NXDOMAIN and NODATA added
+ * - DNS_SOFT as shortcut for DNS_ERR or DNS_COM
+ * - DNS_HARD indicates DNS loop problems
+ * Revision 20221101, Erwin Hoffmann
+ * - DNS_COM has now return code -3 (as documented; tx. Franz S.)
+ * Revision 20210922, Erwin Hoffmann
+ * - Added constants MAXMSGSIZE and MAXSEGMENT - not used yet
+ * Revision 20210401, Erwin Hoffmann
+ * - removed obsolete dns_sortip(); not going to work with GCC-10 anyway
+ * Revision 20200719, Erwin Hoffmann
+ * - added dns_qualify_localhost function including fqdn retrun
+ * Revision 20190730, Erwin Hoffmann
+ * - revised DNS_* return codes to make them compliant with ucspi-*
+ * Revision 20190430, Erwin Hoffmann
+ * - added DNS_SOFT/HARD/MEM complient to s/qmail
+ * - code changes in all decendent modules
+ * Revision 20180222, Erwin Hoffmann
+ * - we consider in total 32 NS IPs (IPv4 + IPv6)
+ * - added dns_transmit_start6
+ * - added uint32 scope_ids[32],
+ * the initial NS scopes read from /etc/resolv.conf et al.
+ * Revision 20180118, Erwin Hoffmann
+ * - included MSGSIZE for DNS messages (instead of MTUSIZE)
+ * Revision 20171231, Erwin Hoffmann
+ * - renamed to dnsresolv.h and removed *qmail declarations
+ * Revision 20170902, Erwin Hoffmann
+ * - added old definitions from *qmail for (temp) backwards compatibility
+ * - added more DNS RR definitions
+*/
+
+#include "stralloc.h"
+#include "iopause.h"
+#include "taia.h"
+
+/* Note: The conventions are subject of change in forthcoming versions */
+
+#define DNS_NXD 0 /* NXDOMAIN, NODATA */
+#define DNS_MEM -1 /* out of memory; fatal */
+#define DNS_ERR -2 /* parsing errors and others */
+#define DNS_COM -3 /* (socket) communication errors: SERVFAIL */
+#define DNS_INT -4 /* internal errors */
+#define DNS_SOFT -5 /* DNS_ERR or DNS_COM */
+#define DNS_HARD -6 /* DNS loop problem */
+
+#define MSGSIZE MTUSIZE /* todays default */
+// #define MSGSIZE 512 /* RFC 1035 */
+#define MAXMSGSIZE 4096 /* 4069 seen with EDNS0 */
+#define MAXSEGMENT 65535 /* Max TCP buffer size */
+
+#define QUERY_MAXNS 32 /* 16 IPv4 + 16 IPv6 NS */
+#define QUERY_MAXIPLEN 512 /* QUERY_MAXNS * 16 */
+
+/* Note: These following definitions are subject of change */
+
+#define DNS_C_IN "\0\1"
+#define DNS_C_ANY "\0\377"
+
+#define DNS_T_A "\0\1"
+#define DNS_T_NS "\0\2"
+#define DNS_T_CNAME "\0\5"
+#define DNS_T_SOA "\0\6"
+#define DNS_T_PTR "\0\14"
+#define DNS_T_HINFO "\0\15"
+#define DNS_T_MX "\0\17"
+#define DNS_T_TXT "\0\20"
+#define DNS_T_RP "\0\21"
+#define DNS_T_SIG "\0\30"
+#define DNS_T_KEY "\0\31"
+#define DNS_T_AAAA "\0\34"
+#define DNS_T_SRV "\0\41"
+#define DNS_T_NAPTR "\0\43"
+#define DNS_T_CERT "\0\45"
+#define DNS_T_OPT "\0\51"
+#define DNS_T_DS "\0\53"
+#define DNS_T_SSHFP "\0\54"
+#define DNS_T_IPSECKEY "\0\55"
+#define DNS_T_RRSIG "\0\56"
+#define DNS_T_NSEC "\0\57"
+#define DNS_T_DNSKEY "\0\60"
+#define DNS_T_NSEC3 "\0\62"
+#define DNS_T_NSEC3PARAM "\0\63"
+#define DNS_T_TLSA "\0\64"
+#define DNS_T_HIP "\0\67"
+#define DNS_T_OPENPGPKEY "\0\75"
+#define DNS_T_SPF "\0\143"
+#define DNS_T_AXFR "\0\374"
+#define DNS_T_ANY "\0\377"
+#define DNS_T_CAA "\1\1"
+
+#define LOCALHOST "localhost" /* no clear distinction IPv4/IPv6 */
+#define IP4_LOOPBACK "ip4-loopback"
+#define IP6_LOOPBACK "ip6-loopback"
+
+struct dns_transmit {
+ char *query; /* 0, or dynamically allocated */
+ unsigned int querylen;
+ char *packet; /* 0, or dynamically allocated */
+ unsigned int packetlen;
+ int s1; /* 0, or 1 + an open file descriptor */
+ int tcpstate;
+ unsigned int udploop;
+ unsigned int curserver;
+ struct taia deadline;
+ unsigned int pos;
+ const char *servers;
+ uint32 scope_id;
+ char localip[16];
+ char qtype[2];
+} ;
+
+/* General */
+
+extern void dns_random_init(const char *);
+extern unsigned int dns_random(unsigned int);
+
+extern void dns_domain_free(char **);
+extern int dns_domain_copy(char **,const char *);
+extern unsigned int dns_domain_length(const char *);
+extern int dns_domain_equal(const char *,const char *);
+extern int dns_domain_suffix(const char *,const char *);
+extern unsigned int dns_domain_suffixpos(const char *,const char *);
+extern int dns_domain_fromdot(char **,const char *,unsigned int);
+extern int dns_domain_todot_cat(stralloc *,const char *);
+extern int dns_ip_qualify(stralloc *,stralloc *,const stralloc *);
+extern int dns_ip_qualify_rules(stralloc *,stralloc *,const stralloc *,const stralloc *);
+extern int dns_ip_qualify_localhost(stralloc *,stralloc *,const stralloc *);
+
+extern unsigned int dns_packet_copy(const char *,unsigned int,unsigned int,char *,unsigned int);
+extern unsigned int dns_packet_getname(const char *,unsigned int,unsigned int,char **);
+extern unsigned int dns_packet_skipname(const char *,unsigned int,unsigned int);
+
+extern struct dns_transmit dns_resolve_tx;
+extern int dns_transmit_start(struct dns_transmit *,const char *,int,const char *,const char *,const char *);
+extern void dns_transmit_free(struct dns_transmit *);
+extern void dns_transmit_io(struct dns_transmit *,iopause_fd *,struct taia *);
+extern int dns_transmit_get(struct dns_transmit *,const iopause_fd *,const struct taia *);
+
+/* Common IPv4 + IPv6 */
+
+extern int dns_resolvconfip(char *,uint32 *);
+extern int dns_resolvconfrewrite(stralloc *);
+extern int dns_resolve(const char *,const char *);
+
+extern int dns_name(stralloc *,const char *);
+extern int dns_name_packet(stralloc *,const char *,unsigned int);
+extern int dns_txt_packet(stralloc *,const char *,unsigned int);
+extern int dns_txt(stralloc *,const stralloc *);
+extern int dns_mx_packet(stralloc *,const char *,unsigned int);
+extern int dns_mx(stralloc *,const stralloc *);
+
+/* IPv4 specific */
+
+extern int dns_ip4_packet(stralloc *,const char *,unsigned int);
+extern int dns_ip4(stralloc *,stralloc *);
+extern void dns_sortip4(char *,unsigned int);
+
+extern int dns_ip4_qualify_rules(stralloc *,stralloc *,const stralloc *,const stralloc *);
+extern int dns_ip4_qualify(stralloc *,stralloc *,const stralloc *);
+
+#define DNS_NAME4_DOMAIN 31
+extern int dns_name4_domain(char *,const char *);
+extern int dns_name4(stralloc *,const char *);
+extern int randombind4(struct dns_transmit *);
+
+/* IPv6 specific */
+
+extern int dns_ip6_packet(stralloc *,const char *,unsigned int);
+extern int dns_ip6(stralloc *,stralloc *);
+extern void dns_sortip6(char *,unsigned int);
+
+extern int dns_ip6_qualify_rules(stralloc *,stralloc *,const stralloc *,const stralloc *);
+extern int dns_ip6_qualify(stralloc *,stralloc *,const stralloc *);
+
+#define DNS_NAME6_DOMAIN (4*16+11)
+extern int dns_name6_domain(char *,const char *);
+extern int dns_name6(stralloc *,const char *);
+
+extern int dns_cname_packet(stralloc *,const char *,unsigned int);
+extern int dns_cname(stralloc *,stralloc *);
+
+extern int dns_transmit_start6(struct dns_transmit *,const char *,int,const char *,const char *,const char *,const uint32 *);
+extern int randombind6(struct dns_transmit *);
+
+/* General */
+
+extern void socketfree(struct dns_transmit *);
+extern void queryfree(struct dns_transmit *);
+extern void packetfree(struct dns_transmit *);
+extern int serverwantstcp(const char *,unsigned int);
+extern int serverfailed(const char *,unsigned int);
+extern int getscopeid(const struct dns_transmit *,const char *);
+extern int firstudp(struct dns_transmit *);
+extern int nextudp(struct dns_transmit *);
+extern int firsttcp(struct dns_transmit *);
+extern int nexttcp(struct dns_transmit *);
+
+#endif
diff --git a/include/env.h b/include/env.h
new file mode 100644
index 0000000..8f6ea87
--- /dev/null
+++ b/include/env.h
@@ -0,0 +1,29 @@
+#ifndef ENV_H
+#define ENV_H
+
+/*
+ * Revision 20171220, Erwin Hoffmann
+ * - removed variable names
+ * Revision 20160628, Kai Peter
+ * - updated code (*env_get) like in ucspi-tcp-0.88
+ * - commented out 'env_pick' and 'env_clear'
+*/
+
+extern char **environ;
+
+extern int env_isinit;
+extern int env_init();
+
+extern /*@null@*/char *env_get(char *);
+extern int env_put(char *,char *);
+extern int env_puts(char *);
+extern int env_set(char *);
+extern int env_unset(char *);
+extern char *env_pick();
+extern void env_clear();
+
+extern char *env_findeq(char *);
+
+#define env_put2 env_put /* backwards compatibility */
+
+#endif
diff --git a/include/error.h b/include/error.h
new file mode 100644
index 0000000..7685c9e
--- /dev/null
+++ b/include/error.h
@@ -0,0 +1,57 @@
+#ifndef ERROR_H
+#define ERROR_H
+
+#include <errno.h>
+
+#ifndef EPROTO /* OpenBSD compat */
+#define EPROTO EINTR
+#endif
+
+#define error_str(i) errstr(i)
+extern char *error_str(int);
+
+/* Exception handling notes:
+ (1) system errors RECEIVED according to <errno.h> during operation and handed over
+ (2) application errors DEFINED internally and ennumerated alongside with <errno.h>
+*/
+
+/* djb backwards compatibility - deprecated form of system errors */
+ /* Comparison of error codes and constants:
+ intern Linux FreeBSD OmniOS */
+#define error_intr EINTR /* -1 4 4 4 */
+#define error_nomem ENOMEM /* -2 12 12 12 */
+#define error_noent ENOENT /* -3 2 2 2 */
+#define error_txtbsy ETXTBSY /* -4 26 26 26 */
+#define error_io EIO /* -5 5 5 5 */
+#define error_exist EEXIST /* -6 17 17 17 */
+#define error_timeout ETIMEDOUT /* -7 110 60 145 */
+#define error_inprogress EINPROGRESS /* -8 115 36 160 */
+#define error_wouldblock EWOULDBLOCK /* -9 EAGAIN EAGAIN EAGAIN */
+#define error_again EAGAIN /* -10 11 35 11 */
+#define error_pipe EPIPE /* -11 32 32 32 */
+#define error_perm EPERM /* -12 1 1 1 */
+#define error_acces EACCES /* -13 13 13 13 */
+#define error_nodevice ENODEV /* -14 (6) (6) 19 */
+#define error_proto EPROTO /* -15 71 92 71 */
+#define error_isdir EISDIR /* -16 21 21 21 */
+#define error_connrefused ECONNREFUSED /* -17 111 61 146 */
+//extern int error_notdir; /* -18 20 20 20 */
+#define error_rofs EROFS /* -19 30 30 30 */
+#define error_connreset ECONNRESET /* -20 104 54 131 */
+
+/* djb uses some internal application error and class definitions -- revised (feh) */
+#define CAT -10 /* raw message w/o terminating \n */
+#define LOG -90 /* generic logging */
+#define INFO -91 /* named logging */
+#define TEMP -97 /* (triggered) temporay alert condition */
+#define ALERT -98 /* (triggered) alert condition */
+#define WARN -99 /* exception condition */
+#define ESOFT -100 /* soft error, reversed negative */
+#define EHARD -111 /* hard error, reversed negative */
+#define USAGE 100 /* usage error on call -- explicit usage() */
+#define SYNTAX 101 /* usage/syntax error on call -- explicit syntaxerror() */
+#define DROP 110 /* connection dropped -- explicit dropped() */
+#define FATAL 111 /* internal error -- all */
+#define ERROR 112 /* application error */
+
+#endif
diff --git a/include/exit.h b/include/exit.h
new file mode 100644
index 0000000..f74b741
--- /dev/null
+++ b/include/exit.h
@@ -0,0 +1,13 @@
+#ifndef EXIT_H
+#define EXIT_H
+
+/**
+ @file exit.h
+ @author djb, feh
+ @source qmail
+ @brief convenience header
+*/
+
+extern void _exit(int);
+
+#endif
diff --git a/include/fd.h b/include/fd.h
new file mode 100644
index 0000000..21047c9
--- /dev/null
+++ b/include/fd.h
@@ -0,0 +1,8 @@
+#ifndef FD_H
+#define FD_H
+
+extern int fd_copy(int,int);
+extern int fd_move(int,int);
+extern int fd_coe(int fd);
+
+#endif
diff --git a/include/fifo.h b/include/fifo.h
new file mode 100644
index 0000000..3c1bf68
--- /dev/null
+++ b/include/fifo.h
@@ -0,0 +1,12 @@
+#ifndef FIFO_H
+#define FIFO_H
+
+/**
+ @file fifo.h
+ @author djb, feh
+ @source s/qmail
+*/
+
+int fifo_make(char *,int);
+
+#endif
diff --git a/include/fmt.h b/include/fmt.h
new file mode 100644
index 0000000..6e68d60
--- /dev/null
+++ b/include/fmt.h
@@ -0,0 +1,36 @@
+#ifndef FMT_H
+#define FMT_H
+
+/**
+ @file fmt.h
+ @author djb, kp, feh
+ @source qmail
+ @brief conversion function declarations
+ */
+
+#define FMT_ULONG 40 /* enough space to hold 2^128 - 1 in decimal, plus \0 */
+#define FMT_LEN ((char *) 0) /* convenient abbreviation */
+
+extern unsigned int fmt_str(char *,char *);
+extern unsigned int fmt_strn(char *,char *,unsigned int);
+extern unsigned int fmt_uint(char *,unsigned int);
+extern unsigned int fmt_uint0(char *,unsigned int,unsigned int);
+extern unsigned int fmt_ulong(char *,unsigned long);
+extern unsigned int fmt_xlong(char *,unsigned long);
+
+extern int fromhex(unsigned char);
+extern char tohex(char);
+
+/* for future releases */
+// extern unsigned int fmt_xint(char *,unsigned int);
+// extern unsigned int fmt_nbbint(char *,unsigned int,unsigned int,unsigned int,unsigned int);
+// extern unsigned int fmt_ushort(char *,unsigned short);
+// extern unsigned int fmt_xshort(char *,unsigned short);
+// extern unsigned int fmt_nbbshort(char *,unsigned int,unsigned int,unsigned int,unsigned short);
+// extern unsigned int fmt_nbblong(char *,unsigned int,unsigned int,unsigned int,unsigned long);
+// extern unsigned int fmt_plusminus(char *,int);
+// extern unsigned int fmt_minus(char *,int);
+// extern unsigned int fmt_0x(char *,int);
+/* to be done */
+
+#endif
diff --git a/include/genalloc.h b/include/genalloc.h
new file mode 100644
index 0000000..ee489af
--- /dev/null
+++ b/include/genalloc.h
@@ -0,0 +1,74 @@
+#ifndef GENALLOC_H
+#define GENALLOC_H
+
+/*
+ * Revision 20210307, Erwin Hoffmann
+ * -
+*/
+
+#include <sys/types.h>
+
+/* GEN_ALLOC demystified:
+
+ GEN_ALLOC generates a list of self-defined types (structs) in an
+ allocated contiguous heap chunk while copying the content of the
+ entire field members or appending the existing field.
+ GEN_ALLOC types care of currently used and/or allocated bytes of field.
+
+Macros:
+ GEN_ALLOC_ready (ta,type,field,len,a,i,n,x,base,ta_ready)
+ GEN_ALLOC_readyplus(ta,type,field,len,a,i,n,x,base,ta_rplus)
+ GEN_ALLOC_append (ta,type,field,len,a,i,n,x,base,ta_rplus,ta_append)
+
+ 0. ta: 'type alloc' - typedef'ed struct name (aka ipalloc et al.)
+ 1. type: defined struct (used for size information)
+ 2. field: declared public name of struct
+ 2. len: used length of string
+ 4. a: allocated size
+ 5. i: current allocated size for member x
+ 6. n: bytes to allocate; in 'ready' mode: +size of one entry;
+ in 'readyplus' mode: +size of +used size of one entry
+ 7. x: local name (alias to field name)
+ 8. base: size of single entry
+ 9. ta_ready/ta_readyplus (operation)
+ 10. ta_append (operation)
+
+*/
+
+/* file: gen_alloc.h */
+#define GEN_ALLOC_typedef(ta,type,field,len,a) \
+ typedef struct ta { type *field; unsigned int len; unsigned int a; } ta;
+
+/* file: gen_allocdefs.h (deprecated) */
+// used in: ipalloc, prioq, qmail-remote, qmail-inject, token822
+#define GEN_ALLOC_ready(ta,type,field,len,a,i,n,x,base,ta_ready) \
+int ta_ready(x,n) register ta *x; register unsigned int n; \
+{ register unsigned int i; \
+ if (x->field) { \
+ i = x->a; \
+ if (n > i) { \
+ x->a = base + n + (n >> 3); \
+ if (alloc_re(&x->field,i * sizeof(type),x->a * sizeof(type))) return 1; \
+ x->a = i; return 0; } \
+ return 1; } \
+ x->len = 0; \
+ return !!(x->field = (type *) alloc((x->a = n) * sizeof(type))); }
+
+#define GEN_ALLOC_readyplus(ta,type,field,len,a,i,n,x,base,ta_rplus) \
+int ta_rplus(x,n) register ta *x; register unsigned int n; \
+{ register unsigned int i; \
+ if (x->field) { \
+ i = x->a; n += x->len; \
+ if (n > i) { \
+ x->a = base + n + (n >> 3); \
+ if (alloc_re(&x->field,i * sizeof(type),x->a * sizeof(type))) return 1; \
+ x->a = i; return 0; } \
+ return 1; } \
+ x->len = 0; \
+ return !!(x->field = (type *) alloc((x->a = n) * sizeof(type))); }
+
+#define GEN_ALLOC_append(ta,type,field,len,a,i,n,x,base,ta_rplus,ta_append) \
+int ta_append(x,i) register ta *x; register type *i; \
+{ if (!ta_rplus(x,1)) return 0; x->field[x->len++] = *i; return 1; }
+
+#endif
diff --git a/include/getln.h b/include/getln.h
new file mode 100644
index 0000000..23eb58b
--- /dev/null
+++ b/include/getln.h
@@ -0,0 +1,10 @@
+#ifndef GETLN_H
+#define GETLN_H
+
+#include "buffer.h"
+#include "stralloc.h"
+
+extern int getln(buffer *,stralloc *,int *,int);
+extern int sgetln(buffer *,stralloc *,char **,unsigned int *,int);
+
+#endif
diff --git a/include/getoptb.h b/include/getoptb.h
new file mode 100644
index 0000000..0338a15
--- /dev/null
+++ b/include/getoptb.h
@@ -0,0 +1,28 @@
+#ifndef BGETOPT_H
+#define BGETOPT_H
+
+/*
+ * Revision 20160714, Kai Peter
+ * - consolidated 'sgetopt.h' and 'subgetopt.h' into '(b)getopt.h'
+*/
+
+#define optarg subgetoptarg
+#define optind subgetoptind
+#define optpos subgetoptpos
+#define optproblem subgetoptproblem
+#define optprogname subgetoptprogname
+#define opteof subgetoptdone
+
+#define SUBGETOPTDONE -1
+
+extern int subgetopt(int,char **,char *);
+extern char *subgetoptarg;
+extern int subgetoptind;
+extern int subgetoptpos;
+extern int subgetoptproblem;
+extern char *subgetoptprogname;
+extern int subgetoptdone;
+
+extern int opterr;
+
+#endif
diff --git a/include/iopause.h b/include/iopause.h
new file mode 100644
index 0000000..e3cfa01
--- /dev/null
+++ b/include/iopause.h
@@ -0,0 +1,28 @@
+#ifndef IOPAUSE_H
+#define IOPAUSE_H
+
+#define IOPAUSE_POLL
+
+#include <sys/types.h>
+#ifdef HAS_POLL_H
+#include <poll.h>
+
+typedef struct pollfd iopause_fd;
+#define IOPAUSE_READ POLLIN
+#define IOPAUSE_WRITE POLLOUT
+#else
+typedef struct {
+ int fd;
+ short events;
+ short revents;
+} iopause_fd;
+#define IOPAUSE_READ 1
+#define IOPAUSE_WRITE 4
+#endif
+
+#include "taia.h"
+
+extern int iopause(iopause_fd *,unsigned int,struct taia *,struct taia *);
+extern unsigned long pollmax;
+
+#endif
diff --git a/include/ip.h b/include/ip.h
new file mode 100644
index 0000000..3f0c299
--- /dev/null
+++ b/include/ip.h
@@ -0,0 +1,107 @@
+#ifndef IP_H
+#define IP_H
+
+/*
+ * Revision 20200603, Erwin Hoffmann
+ * - added V46loopback address
+ * Revision 20190414, Erwin Hoffmann
+ * - removed ip_scan and ip_scanbracket (comp. versions).
+ * - added ia6_fmt and ia4_fmt (for qmail)
+ * Revision 20180314, Erwin Hoffmann
+ * - ip4_cidr added and argument list changed (also for ip6_cidr)
+ * Revision 20180213, Erwin Hoffmann
+ * - ip4_scan/ip6_scan/ip4_scanbracket/ip6_fmt_flat revised
+ * Revision 20180206, Erwin Hoffmann
+ * - added V6linklocal address
+ * Revision 20170319, Kai Peter
+ * - rewrite (consolidation and compatibility)
+ * Revision 20170210, Kai Peter
+ * - added definition 'V4loopback' and redefinition 'ip4loopback'
+ * Revision 20170908, Erwin Hoffmann
+ * - added some definitions from s/qmail + required for djbdns
+*/
+
+/* Consolidated header files ip.h from *qmail (with IPv6) and ip4.h/ip6.h
+ from libowfat. Thus it could be used with 'older' and 'newer' code.
+*/
+
+#include "byte.h"
+#include "stralloc.h"
+
+#define V4MAPPREFIX "::ffff:"
+#define HOSTNAMELEN 1025
+#define IP4MLMTU 512
+#define IP6MLMTU 1280 /* RFC 8200 */
+#define MTUSIZE IP6MLMTU
+
+#define IP4_FMT 20 /* backwards compatibility */
+#define IP6_FMT 40 /* " */
+#define IPFMT 72 /* used in qmail-remote only (temp?) */
+/* may be better: */
+//#define IP4_FMT IPFMT /* backwards compatibility */
+//#define IP6_FMT IPFMT /* " */
+/* deprecated: */
+#define FMT_IP4 IP4_FMT /* more backwards compatibility */
+#define FMT_IP6 IP6_FMT /* " */
+
+/* these structs are going deprecated (should replaced by socket lib) */
+struct ip4_address { unsigned char d[4]; }; /* 4 decimal pieces */
+struct ip6_address { unsigned char d[16]; }; /* 16 hex pieces */
+#define ip_address ip4_address /* backward compatibility */
+
+unsigned int ip4_bytestring(stralloc *,char [4],int);
+unsigned int ip4_cidr(char *,char [4],unsigned long *);
+unsigned int ip4_fmt(char *,char [4]);
+unsigned int ip4_scan(const char *,char [4]);
+unsigned int ip4_scanbracket(const char *,char [4]);
+unsigned int ia4_fmt(char *,char [4]);
+
+const static char V4loopback[4] = {127,0,0,1};
+const static char V4localnet[4] = {0,0,0,0};
+const static char V4broadcast[4] = {-1,-1,-1,-1}; // all bits 1
+
+/***
+ * Compactified IPv6 addresses are really ugly to parse.
+ * Syntax: (h = hex digit) [RFC 5952]
+ * 1. hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh
+ * 2. leading 0s in any octet can be suppressed
+ * 3. any number of 0000 may be abbreviated as "::"
+ * a) but only once;
+ * b) the longest piece or on equal match the first piece,
+ * c) a single instance of 0000 has to displayed as 0
+ * 4. The last two words may be written as IPv4 address
+ *
+ * Flat ip6 address syntax:
+ * hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh (32 hex digits)
+ *
+ * struct ip6_address format:
+ * cccccccccccccccc (16 chars; d[16]) -- each char swallows two hex values
+ *
+ * Bitstring representation with length prefix:
+ * bbbbbbb.........bbbb (max 128 bits); stralloc(ip6string); b = 0 || 1
+ *
+ */
+
+unsigned int ip6_bytestring(stralloc *,char *,int);
+unsigned int ip6_cidr(char *,char [16],unsigned long *);
+unsigned int ip6_fmt(char *,char [16]);
+unsigned int ip6_fmt_flat(char *,char [16]);
+unsigned int ip6_ifscan(char *,char [16],stralloc *);
+unsigned int ip6_scan(const char *,char [16]);
+unsigned int ip6_scanbracket(const char *,char [16]);
+unsigned int ip6_scan_flat(const char *,char [16]);
+unsigned int ia6_fmt(char *,char [16]);
+
+static const unsigned char V4mappedprefix[12] = {0,0,0,0, 0,0,0,0, 0,0,0xff,0xff};
+static const unsigned char V46loopback[16] = {0,0,0,0, 0,0,0,0, 0,0,0xff,0xff, 127,0,0,1};
+static const unsigned char V6loopback[16] = {0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,1};
+static const unsigned char V6localnet[16] = {0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0};
+static const unsigned char V6linklocal[2] = {0xfe,0x80};
+
+int fromhex(unsigned char);
+char tohex(char);
+
+#define V6any V6localnet /* backward compatibility */
+#define ip6_isv4mapped(ip) (byte_equal(ip,12,V4mappedprefix))
+
+#endif
diff --git a/include/lock.h b/include/lock.h
new file mode 100644
index 0000000..74df4c9
--- /dev/null
+++ b/include/lock.h
@@ -0,0 +1,14 @@
+#ifndef LOCK_H
+#define LOCK_H
+
+/**
+ @file lock.h
+ @author djb, feh
+ @source s/qmail
+*/
+
+int lock_ex(int);
+int lock_un(int);
+int lock_exnb(int);
+
+#endif
diff --git a/include/logmsg.h b/include/logmsg.h
new file mode 100644
index 0000000..c480c8b
--- /dev/null
+++ b/include/logmsg.h
@@ -0,0 +1,31 @@
+#ifndef LOGMSG_H
+#define LOGMSG_H
+
+#include <errno.h>
+#include <stdlib.h>
+#include "error.h"
+
+extern void logmsg(const char *who, int ecode, unsigned int class,
+ const char *msg);
+
+/* useful combinations of params */
+/* class: FATAL (hard) - system error */
+#define err_sys(w,e) logmsg(w,e,FATAL,"")
+#define err_sys_plus(w,e,m) logmsg(w,e,FATAL,m)
+/* class: WARN (application) - temporary error */
+#define err_tmp(w,e,m) logmsg(w,e,WARN,m)
+#define err_tmp_plus(w,e,m) logmsg(w,e,WARN,m)
+/* class: facultative ('int'ernal definition */
+#define err_int(w,e,c) logmsg(w,e,c,"")
+#define err_int_plus(w,e,c,m) logmsg(w,e,c,m)
+/* log messages */
+/* #define log(w,m) logmsg(w,0,LOG,m) // obsoleted by */
+#define log_who(w,m) logmsg(w,0,LOG,m)
+#define log_anon(m) logmsg("",0,LOG,m)
+#define log_cat(n) logmsg("",0,CAT,m)
+
+/* build log message from multiple partial strings */
+extern char *build_log_msg(const char *[]);
+#define B(...) build_log_msg((const char *[]){__VA_ARGS__,NULL}) // K/R sect. 7.3
+
+#endif
diff --git a/include/ndelay.h b/include/ndelay.h
new file mode 100644
index 0000000..7a03a8d
--- /dev/null
+++ b/include/ndelay.h
@@ -0,0 +1,13 @@
+#ifndef NDELAY_H
+#define NDELAY_H
+
+/**
+ @brief ndelay.h
+ @author djb, feh
+ @source s/qmail
+*/
+
+int ndelay_on(int);
+int ndelay_off(int);
+
+#endif
diff --git a/include/open.h b/include/open.h
new file mode 100644
index 0000000..428ebfb
--- /dev/null
+++ b/include/open.h
@@ -0,0 +1,16 @@
+#ifndef OPEN_H
+#define OPEN_H
+
+/**
+ @file open.h
+ @author djb, feh
+ @source s/qmail
+*/
+
+int open_read(const char *);
+int open_excl(const char *);
+int open_append(const char *);
+int open_trunc(const char *);
+int open_write(const char *);
+
+#endif
diff --git a/include/pathexec.h b/include/pathexec.h
new file mode 100644
index 0000000..9db6fb4
--- /dev/null
+++ b/include/pathexec.h
@@ -0,0 +1,10 @@
+#ifndef PATHEXEC_H
+#define PATHEXEC_H
+#include "stralloc.h"
+
+extern void pathexec_run(const char *,char *const *,char *const *);
+extern int pathexec_env(const char *,const char *);
+extern int pathexec_multienv(stralloc *);
+extern void pathexec(char *const *);
+
+#endif
diff --git a/include/prot.h b/include/prot.h
new file mode 100644
index 0000000..7dd0503
--- /dev/null
+++ b/include/prot.h
@@ -0,0 +1,7 @@
+#ifndef PROT_H
+#define PROT_H
+
+extern int prot_gid(int);
+extern int prot_uid(int);
+
+#endif
diff --git a/include/readclose.h b/include/readclose.h
new file mode 100644
index 0000000..a95f4f5
--- /dev/null
+++ b/include/readclose.h
@@ -0,0 +1,14 @@
+#ifndef READCLOSE_H
+#define READCLOSE_H
+
+#include "stralloc.h"
+#include "close.h"
+
+extern int readclose_append(int,stralloc *,unsigned int);
+extern int readclose(int,stralloc *,unsigned int);
+
+#define slurpclose readclose /* backwards compatibility */
+
+extern int openreadclose(const char *,stralloc *,unsigned int);
+
+#endif
diff --git a/include/readwrite.h b/include/readwrite.h
new file mode 100644
index 0000000..40b427f
--- /dev/null
+++ b/include/readwrite.h
@@ -0,0 +1,9 @@
+#ifndef READWRITE_H
+#define READWRITE_H
+
+#include <unistd.h>
+
+// extern int read();
+// extern int write();
+
+#endif
diff --git a/include/rename.h b/include/rename.h
new file mode 100644
index 0000000..641f68a
--- /dev/null
+++ b/include/rename.h
@@ -0,0 +1,6 @@
+#ifndef RENAME_H
+#define RENAME_H
+
+extern int rename(const char *, const char *);
+
+#endif
diff --git a/include/scan.h b/include/scan.h
new file mode 100644
index 0000000..f1d4030
--- /dev/null
+++ b/include/scan.h
@@ -0,0 +1,12 @@
+#ifndef SCAN_H
+#define SCAN_H
+
+extern unsigned int scan_0x(const char *,unsigned int *);
+extern unsigned int scan_xint(const char *,unsigned int *);
+extern unsigned int scan_8long(const char *,unsigned long *);
+extern unsigned int scan_uint(const char *,unsigned int *);
+extern unsigned int scan_long(const char *,long *);
+extern unsigned int scan_ulong(const char *,unsigned long *);
+extern unsigned int scan_xlong(const char *,unsigned long *);
+
+#endif
diff --git a/include/seek.h b/include/seek.h
new file mode 100644
index 0000000..06aad97
--- /dev/null
+++ b/include/seek.h
@@ -0,0 +1,15 @@
+#ifndef SEEK_H
+#define SEEK_H
+
+typedef unsigned long seek_pos;
+
+extern seek_pos seek_cur(int);
+
+extern int seek_set(int,seek_pos);
+extern int seek_end(int);
+
+extern int seek_trunc(int,seek_pos);
+
+#define seek_begin(fd) (seek_set((fd),(seek_pos) 0))
+
+#endif
diff --git a/include/select.h b/include/select.h
new file mode 100644
index 0000000..646dd50
--- /dev/null
+++ b/include/select.h
@@ -0,0 +1,13 @@
+#ifndef SELECT_H
+#define SELECT_H
+
+#include <sys/types.h>
+#include <sys/time.h>
+
+#ifdef HAS_SELECT_H
+#include <sys/select.h>
+#endif
+
+extern int select();
+
+#endif
diff --git a/include/sig.h b/include/sig.h
new file mode 100644
index 0000000..3efdd32
--- /dev/null
+++ b/include/sig.h
@@ -0,0 +1,63 @@
+#ifndef SIG_H
+#define SIG_H
+
+/*
+ * Revision 20160714, Kai Peter
+ * - updated some declarations no new(er) one's from ucspi-tcp-0.88
+*/
+
+/* new(er) declarations from ucspi-tcp-0.88: */
+extern int sig_alarm;
+extern int sig_child;
+extern int sig_cont;
+extern int sig_hangup;
+extern int sig_pipe;
+extern int sig_term;
+
+extern void (*sig_defaulthandler)();
+extern void (*sig_ignorehandler)();
+
+extern void sig_catch(int,void (*)());
+#define sig_ignore(s) (sig_catch((s),sig_ignorehandler))
+#define sig_uncatch(s) (sig_catch((s),sig_defaulthandler))
+
+extern void sig_block(int);
+extern void sig_unblock(int);
+extern void sig_blocknone(void);
+extern void sig_pause(void);
+
+extern void sig_dfl(int);
+
+/* declaration of (net)qmail package (untouched) */
+extern void sig_miscignore();
+extern void sig_bugcatch();
+
+extern void sig_pipeignore();
+extern void sig_pipedefault();
+
+extern void sig_contblock();
+extern void sig_contunblock();
+extern void sig_contcatch();
+extern void sig_contdefault();
+
+extern void sig_termblock();
+extern void sig_termunblock();
+extern void sig_termcatch();
+extern void sig_termdefault();
+
+extern void sig_alarmblock();
+extern void sig_alarmunblock();
+extern void sig_alarmcatch();
+extern void sig_alarmdefault();
+
+extern void sig_childblock();
+extern void sig_childunblock();
+extern void sig_childcatch();
+extern void sig_childdefault();
+
+extern void sig_hangupblock();
+extern void sig_hangupunblock();
+extern void sig_hangupcatch();
+extern void sig_hangupdefault();
+
+#endif
diff --git a/include/socket_if.h b/include/socket_if.h
new file mode 100644
index 0000000..54cfa5f
--- /dev/null
+++ b/include/socket_if.h
@@ -0,0 +1,97 @@
+#ifndef SOCKETIF_H
+#define SOCKETIF_H
+
+/* Revsision 20220608
+ * - removed obsolete socket_local4() and socket_remote4()
+ * Revision 20210828, Erwin Hoffmann
+ * - added socket_accept4()
+ * Revision 20210226, Erwin Hoffmann
+ * - removed dependency on ipv4socket (loose coupling)
+ * - only single socket_tcp() and
+ * - single socket_udp() function serving both IPv4 + IPv6
+ * Revision 20181125, Erwin Hoffmann
+ * - switched to 'uint_t.h'
+ * - changed 'socket_tcp' --> 'socket_tcp4', 'socket_udp' --> 'socket_udp4'
+ * - added 'socket_ip6optionskill'
+ * - reordered and included backword compatible IPv6 calls
+ * - commented multicast socket declarations
+ * - enlarged usage for ipv4socket -> dual bind IPv4/IPv6
+*/
+
+#define __APPLE_USE_RFC_3542 /* MacOS Anycast support */
+
+#include "uint_t.h"
+
+/* IPv4 only */
+extern int socket_accept4(int,char [4],uint16 *);
+extern int socket_bind4(int,const char [4],uint16);
+extern int socket_bind4_reuse(int,const char [4],uint16);
+extern int socket_connect4(int,const char [4],uint16);
+extern int socket_send4(int,const char *,unsigned int,const char [4],uint16);
+extern int socket_broadcast(int,const char *,unsigned int,uint16);
+
+/* Backward compatibility */
+#define socket_local4 socket_local
+#define socket_remote4 socket_remote
+
+/* IPv6 only */
+extern int socket_bind6(int,const char [16],uint16,uint32);
+extern int socket_bind6_reuse(int,const char [16],uint16,uint32);
+extern int socket_connect6(int,const char [16],uint16,uint32);
+extern int socket_send6(int,const char *,unsigned int,const char [16],uint16,uint32);
+extern const char* socket_getifname(uint32);
+extern uint32 socket_getifidx(const char *);
+extern int socket_ip6optionskill(int);
+extern int socket_ip6anycast(int);
+
+/* Common IPv4 & IPv6 */
+extern int socket_accept(int,char [16],uint16 *,uint32 *);
+extern int socket_bind(int,const char [16],uint16,uint32);
+extern int socket_bind_reuse(int,const char [16],uint16,uint32);
+extern int socket_connect(int,const char [16],uint16,uint32);
+extern int socket_connected(int);
+extern int socket_listen(int,int);
+extern int socket_local(int,char [16],uint16 *,uint32 *);
+extern int socket_recv(int,char *,unsigned int,char [16],uint16 *,uint32 *);
+extern int socket_remote(int,char [16],uint16 *,uint32 *);
+extern int socket_send(int,const char *,unsigned int,const char [16],uint16,uint32);
+extern void socket_tryreservein(int,int);
+extern int socket_ipoptionskill(int);
+extern int socket_dualstack(int);
+extern int socket_nodualstack(int);
+
+/* Backward compatibility */
+#define socket_accept6 socket_accept
+#define socket_local6 socket_local
+#define socket_recv6 socket_recv
+#define socket_remote6 socket_remote
+
+/* TCP */
+extern int socket_tcp4(void);
+extern int socket_tcp6(void);
+extern int socket_tcp(void);
+extern int socket_tcpnodelay(int);
+
+/* UDP */
+extern int socket_udp4(void);
+extern int socket_udp6(void);
+extern int socket_udp(void);
+
+/*********** For future use ***********************************/
+/* enable sending udp packets to the broadcast address */
+// extern int socket_broadcast(int);
+/* join a multicast group on the given interface */
+// extern int socket_mcjoin4(int,char *,char *);
+// extern int socket_mcjoin6(int,char *,int);
+/* leave a multicast group on the given interface */
+// extern int socket_mcleave4(int,char *);
+// extern int socket_mcleave6(int,char *);
+/* set multicast TTL/hop count for outgoing packets */
+// extern int socket_mcttl4(int,char);
+// extern int socket_mcttl6(int,char);
+/* enable multicast loopback */
+// extern int socket_mcloop4(int,char);
+// extern int socket_mcloop6(int,char);
+/**************************************************************/
+
+#endif
diff --git a/include/str.h b/include/str.h
new file mode 100644
index 0000000..fe36d0b
--- /dev/null
+++ b/include/str.h
@@ -0,0 +1,25 @@
+#ifndef STR_H
+#define STR_H
+
+/*
+ * Revision 20170918, Kai Peter
+ * - added 'str_copyb()', thanks Erwin Hoffmann
+ * Revision 20170501, Kai Peter
+ * - added '*str_append' and 'str_cat'
+*/
+
+extern unsigned int str_copy(char *,const char *);
+extern unsigned int str_copyb(char *,const char *,unsigned int);
+extern int str_diff(const char *,const char *);
+extern int str_diffn(const char *,const char *,unsigned int);
+//extern unsigned int str_len(char *); // --> this produces lot of warnings !!!
+extern unsigned int str_len();
+extern unsigned int str_chr(const char *,int);
+extern unsigned int str_rchr(const char *,int);
+extern int str_start(const char *,const char *);
+extern char *str_append(char *out,const char *s);
+
+#define str_equal(s,t) (!str_diff((s),(t)))
+#define str_cat(s,t) str_append(s,t)
+
+#endif
diff --git a/include/stralloc.h b/include/stralloc.h
new file mode 100644
index 0000000..0f4a7d2
--- /dev/null
+++ b/include/stralloc.h
@@ -0,0 +1,49 @@
+#ifndef STRALLOC_H
+#define STRALLOC_H
+
+/*
+ * Revision 20210307, Erwin Hoffmann
+ * -
+*/
+
+#include <sys/types.h>
+
+/* stralloc is the internal data structure all functions are working on.
+ * s is the string.
+ * len is the used length of the string.
+ * a is the allocated length of the string.
+ */
+
+typedef struct stralloc {
+ char* s;
+ size_t len;
+ size_t a;
+} stralloc;
+
+//extern int stralloc_ready(stralloc *,unsigned int);
+extern int stralloc_ready(stralloc *sa,size_t len);
+//extern int stralloc_readyplus(stralloc *,unsigned int);
+extern int stralloc_readyplus(stralloc *sa,size_t len);
+extern int stralloc_copy(stralloc *,stralloc *);
+extern int stralloc_cat(stralloc *,stralloc *);
+extern int stralloc_copys(stralloc *,const char *);
+extern int stralloc_cats(stralloc *,const char *);
+extern int stralloc_copyb(stralloc *,const char *,unsigned int);
+extern int stralloc_catb(stralloc *,const char *,unsigned int);
+//extern int stralloc_append(stralloc *,char *); /* beware: this takes a pointer to 1 char */
+extern int stralloc_append(stralloc *sa,const char *in); /* beware: this takes a pointer to 1 char */
+extern int stralloc_starts(stralloc *,const char *);
+
+#define stralloc_0(sa) stralloc_append(sa,"")
+
+extern int stralloc_catulong0(stralloc *,unsigned long,unsigned int);
+extern int stralloc_catlong0(stralloc *,long,unsigned int);
+
+extern void stralloc_free(stralloc *);
+
+#define stralloc_catlong(sa,l) (stralloc_catlong0((sa),(l),0))
+#define stralloc_catuint0(sa,i,n) (stralloc_catulong0((sa),(i),(n)))
+#define stralloc_catint0(sa,i,n) (stralloc_catlong0((sa),(i),(n)))
+#define stralloc_catint(sa,i) (stralloc_catlong0((sa),(i),0))
+
+#endif
diff --git a/include/tai.h b/include/tai.h
new file mode 100644
index 0000000..37d24e0
--- /dev/null
+++ b/include/tai.h
@@ -0,0 +1,74 @@
+#ifndef TAI_H
+#define TAI_H
+
+/*
+ * Revision 20160728, Kai Peter
+ * - switched to 'uint_t.h'
+*/
+/* this header file comes from libowfat, http://www.fefe.de/libowfat/ */
+
+/* Times with 1 second precision */
+
+#include "uint_t.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* A struct tai value is an integer between 0 inclusive and 2^64
+ * exclusive. The format of struct tai is designed to speed up common
+ * operations; applications should not look inside struct tai.
+ *
+ * A struct tai variable is commonly used to store a TAI64 label. Each
+ * TAI64 label refers to one second of real time. TAI64 labels span a
+ * range of hundreds of billions of years.
+ *
+ * A struct tai variable may also be used to store the numerical
+ * difference between two TAI64 labels.
+ * See http://cr.yp.to/libtai/tai64.html */
+
+typedef struct tai {
+ uint64 x;
+} tai64;
+
+
+#define tai_unix(t,u) ((void) ((t)->x = 4611686018427387914ULL + (uint64) (u)))
+
+/* tai_now puts the current time into t. More precisely: tai_now puts
+ * into t its best guess as to the TAI64 label for the 1-second interval
+ * that contains the current time.
+ *
+ * This implementation of tai_now assumes that the time_t returned from
+ * the time function represents the number of TAI seconds since
+ * 1970-01-01 00:00:10 TAI. This matches the convention used by the
+ * Olson tz library in ``right'' mode. */
+void tai_now(struct tai *);
+
+/* tai_approx returns a double-precision approximation to t. The result
+ * of tai_approx is always nonnegative. */
+#define tai_approx(t) ((double) ((t)->x))
+
+/* tai_add adds a to b modulo 2^64 and puts the result into t. The
+ * inputs and output may overlap. */
+void tai_add(struct tai *,const struct tai *,const struct tai *);
+/* tai_sub subtracts b from a modulo 2^64 and puts the result into t.
+ * The inputs and output may overlap. */
+void tai_sub(struct tai *,const struct tai *,const struct tai *);
+/* tai_less returns 1 if a is less than b, 0 otherwise. */
+#define tai_less(t,u) ((t)->x < (u)->x)
+
+#define TAI_PACK 8
+/* tai_pack converts a TAI64 label from internal format in t to external
+ * TAI64 format in buf. */
+void tai_pack(char *,const struct tai *);
+/* tai_unpack converts a TAI64 label from external TAI64 format in buf
+ * to internal format in t. */
+void tai_unpack(const char *,struct tai *);
+
+void tai_uint(struct tai *,unsigned int);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/taia.h b/include/taia.h
new file mode 100644
index 0000000..03f455c
--- /dev/null
+++ b/include/taia.h
@@ -0,0 +1,40 @@
+#ifndef TAIA_H
+#define TAIA_H
+
+/*
+ * Revision 20170329, Kai Peter
+ * - changed type of 'taia_now()' from void to int
+*/
+
+/* time with precision of 1 attosecond */
+
+#include "tai.h"
+
+struct taia {
+ struct tai sec;
+ unsigned long nano; /* 0...999999999 */
+ unsigned long atto; /* 0...999999999 */
+} ;
+
+extern void taia_tai(struct taia *,struct tai *);
+
+extern int taia_now(struct taia *);
+
+extern double taia_approx(struct taia *);
+extern double taia_frac(struct taia *);
+
+extern void taia_add(struct taia *,struct taia *,struct taia *);
+extern void taia_sub(struct taia *,struct taia *,struct taia *);
+extern void taia_half(struct taia *,struct taia *);
+extern int taia_less(struct taia *,struct taia *);
+
+#define TAIA_PACK 16
+extern void taia_pack(char *,struct taia *);
+extern void taia_unpack(char *,struct taia *);
+
+#define TAIA_FMTFRAC 19
+extern unsigned int taia_fmtfrac(char *,struct taia *);
+
+extern void taia_uint(struct taia *,unsigned int);
+
+#endif
diff --git a/include/timeout.h b/include/timeout.h
new file mode 100644
index 0000000..1b45e9f
--- /dev/null
+++ b/include/timeout.h
@@ -0,0 +1,7 @@
+#ifndef TIMEOUT_H
+#define TIMEOUT_H
+
+extern int timeoutread(int,int,char *,int);
+extern int timeoutwrite(int,int,char *,int);
+
+#endif
diff --git a/include/timeoutconn.h b/include/timeoutconn.h
new file mode 100644
index 0000000..308ec5a
--- /dev/null
+++ b/include/timeoutconn.h
@@ -0,0 +1,10 @@
+#ifndef TIMEOUTCONN_H
+#define TIMEOUTCONN_H
+
+#include "uint_t.h"
+
+extern int timeoutconn4(int,char *,uint16,unsigned int);
+extern int timeoutconn6(int,char *,uint16,unsigned int,uint32);
+extern int timeoutconn(int,char *,uint16,unsigned int,uint32);
+
+#endif
diff --git a/include/uint_t.h b/include/uint_t.h
new file mode 100644
index 0000000..84eb06e
--- /dev/null
+++ b/include/uint_t.h
@@ -0,0 +1,76 @@
+#include <stdint.h>
+
+/**
+ @file uint_t.h
+ @author djb, kp, feh
+ @source qmail, djbdns6
+ @brief additional types and pack routines
+ @brief define basic integer types and size through <stdint.h>
+*/
+
+#ifndef UINT8_H
+#define UINT8_H
+
+#ifdef HAS_UINT8_H
+typedef uint8_t uint8;
+#else
+typedef unsigned char uint8;
+#endif
+
+#endif
+
+#ifndef UINT16_H
+#define UINT16_H
+
+typedef uint16_t uint16;
+
+extern void uint16_pack(char *,uint16);
+extern void uint16_pack_big(char *,uint16);
+extern void uint16_unpack(char *,uint16 *);
+extern void uint16_unpack_big(char *,uint16 *);
+#endif
+
+#ifndef UINT32_H
+#define UINT32_H
+
+typedef uint32_t uint32;
+
+extern void uint32_pack(char *,uint32);
+extern void uint32_pack_big(char *,uint32);
+extern void uint32_unpack(char *,uint32 *);
+extern void uint32_unpack_big(char *,uint32 *);
+#endif
+
+#ifndef UINT64_H
+#define UINT64_H
+
+#ifdef HAS_UINT64_H
+typedef uint64_t uint64;
+#else
+typedef unsigned long long uint64;
+#endif
+
+extern void uint64_pack(char *,uint64);
+extern void uint64_pack_big(char *,uint64);
+extern void uint64_unpack(char *,uint64 *);
+extern void uint64_unpack_big(char *,uint64 *);
+#endif
+
+#ifndef UINT128_H
+#define UINT128_H
+
+/* uint128 used for native IPv6 address presentation */
+
+struct uint128_t
+{
+ uint64_t hi; /* routing area */
+ uint64_t lo; /* local area */
+};
+
+typedef struct uint128_t uint128;
+
+extern void uint128_pack(char *,uint128);
+extern void uint128_pack_big(char *,uint128);
+extern void uint128_unpack(char *,uint128 *);
+extern void uint128_unpack_big(char *,uint128 *);
+#endif
diff --git a/include/wait.h b/include/wait.h
new file mode 100644
index 0000000..f7cfc60
--- /dev/null
+++ b/include/wait.h
@@ -0,0 +1,20 @@
+#ifndef WAIT_H
+#define WAIT_H
+
+/**
+ @file wait.h
+ @author djb
+ @source s/qmail
+*/
+
+int wait_pid(int *,int);
+int wait_nohang(int *);
+int wait_stop();
+int wait_stopnohang();
+
+#define wait_crashed(w) ((w) & 127)
+#define wait_exitcode(w) ((w) >> 8)
+#define wait_stopsig(w) ((w) >> 8)
+#define wait_stopped(w) (((w) & 127) == 127)
+
+#endif