aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCem Keylan <cem@ckyln.com>2020-10-16 17:41:25 +0300
committerCem Keylan <cem@ckyln.com>2020-10-16 17:41:25 +0300
commite2abcdca396661cbe0ae2ddb13d5c2b85682c13a (patch)
treeacf9b5c80b645617f882c45224c6e07251711842
downloadotools-e2abcdca396661cbe0ae2ddb13d5c2b85682c13a.tar.gz
initial commit
-rw-r--r--.gitignore11
-rw-r--r--LICENSE6
-rw-r--r--Makefile364
-rw-r--r--README36
-rw-r--r--config.mk29
-rw-r--r--include/CVS/Entries93
-rw-r--r--include/CVS/Repository1
-rw-r--r--include/CVS/Root1
-rw-r--r--include/Makefile163
-rw-r--r--include/a.out.h44
-rw-r--r--include/ar.h66
-rw-r--r--include/arpa/CVS/Entries6
-rw-r--r--include/arpa/CVS/Repository1
-rw-r--r--include/arpa/CVS/Root1
-rw-r--r--include/arpa/ftp.h108
-rw-r--r--include/arpa/inet.h147
-rw-r--r--include/arpa/nameser.h369
-rw-r--r--include/arpa/telnet.h339
-rw-r--r--include/arpa/tftp.h83
-rw-r--r--include/asr.h90
-rw-r--r--include/assert.h68
-rw-r--r--include/bitstring.h128
-rw-r--r--include/blf.h82
-rw-r--r--include/bsd_auth.h105
-rw-r--r--include/complex.h120
-rw-r--r--include/cpio.h59
-rw-r--r--include/ctype.h304
-rw-r--r--include/curses.h13
-rw-r--r--include/db.h161
-rw-r--r--include/dirent.h104
-rw-r--r--include/disktab.h60
-rw-r--r--include/dlfcn.h98
-rw-r--r--include/elf.h12
-rw-r--r--include/elf_abi.h33
-rw-r--r--include/err.h3
-rw-r--r--include/errno.h59
-rw-r--r--include/fenv.h60
-rw-r--r--include/float.h95
-rw-r--r--include/fnmatch.h57
-rw-r--r--include/fstab.h78
-rw-r--r--include/fts.h127
-rw-r--r--include/ftw.h60
-rw-r--r--include/getopt.h76
-rw-r--r--include/glob.h103
-rw-r--r--include/grp.h4
-rw-r--r--include/icdb.h44
-rw-r--r--include/ieeefp.h23
-rw-r--r--include/ifaddrs.h56
-rw-r--r--include/inttypes.h262
-rw-r--r--include/iso646.h26
-rw-r--r--include/kvm.h79
-rw-r--r--include/langinfo.h88
-rw-r--r--include/libgen.h29
-rw-r--r--include/limits.h117
-rw-r--r--include/link.h149
-rw-r--r--include/link_elf.h42
-rw-r--r--include/locale.h112
-rw-r--r--include/login_cap.h110
-rw-r--r--include/machine/endian.h1
-rw-r--r--include/math.h497
-rw-r--r--include/md5.h49
-rw-r--r--include/memory.h35
-rw-r--r--include/ndbm.h78
-rw-r--r--include/netdb.h329
-rw-r--r--include/netgroup.h67
-rw-r--r--include/netinet/ip.h9
-rw-r--r--include/nl_types.h91
-rw-r--r--include/nlist.h87
-rw-r--r--include/paths.h81
-rw-r--r--include/poll.h9
-rw-r--r--include/protocols/CVS/Entries6
-rw-r--r--include/protocols/CVS/Repository1
-rw-r--r--include/protocols/CVS/Root1
-rw-r--r--include/protocols/dumprestore.h159
-rw-r--r--include/protocols/routed.h152
-rw-r--r--include/protocols/rwhod.h67
-rw-r--r--include/protocols/talkd.h120
-rw-r--r--include/protocols/timed.h101
-rw-r--r--include/pthread.h315
-rw-r--r--include/pthread_np.h56
-rw-r--r--include/pwd.h4
-rw-r--r--include/ranlib.h49
-rw-r--r--include/readpassphrase.h40
-rw-r--r--include/regex.h104
-rw-r--r--include/resolv.h3
-rw-r--r--include/rmd160.h60
-rw-r--r--include/rpc/CVS/Entries14
-rw-r--r--include/rpc/CVS/Repository1
-rw-r--r--include/rpc/CVS/Root1
-rw-r--r--include/rpc/auth.h184
-rw-r--r--include/rpc/auth_unix.h84
-rw-r--r--include/rpc/clnt.h361
-rw-r--r--include/rpc/pmap_clnt.h85
-rw-r--r--include/rpc/pmap_prot.h106
-rw-r--r--include/rpc/pmap_rmt.h65
-rw-r--r--include/rpc/rpc.h108
-rw-r--r--include/rpc/rpc_des.h135
-rw-r--r--include/rpc/rpc_msg.h200
-rw-r--r--include/rpc/svc.h326
-rw-r--r--include/rpc/svc_auth.h1
-rw-r--r--include/rpc/types.h66
-rw-r--r--include/rpc/xdr.h316
-rw-r--r--include/rpcsvc/CVS/Entries3
-rw-r--r--include/rpcsvc/CVS/Repository1
-rw-r--r--include/rpcsvc/CVS/Root1
-rw-r--r--include/rpcsvc/yp_prot.h316
-rw-r--r--include/rpcsvc/ypclnt.h82
-rw-r--r--include/sched.h75
-rw-r--r--include/search.h57
-rw-r--r--include/semaphore.h62
-rw-r--r--include/setjmp.h67
-rw-r--r--include/sha1.h57
-rw-r--r--include/sha2.h156
-rw-r--r--include/signal.h140
-rw-r--r--include/siphash.h83
-rw-r--r--include/sndio.h205
-rw-r--r--include/spawn.h103
-rw-r--r--include/stdbool.h45
-rw-r--r--include/stddef.h84
-rw-r--r--include/stdio.h435
-rw-r--r--include/stdlib.h12
-rw-r--r--include/string.h5
-rw-r--r--include/strings.h83
-rw-r--r--include/sys/cdefs.h5
-rw-r--r--include/sys/param.h3
-rw-r--r--include/sys/time.h14
-rw-r--r--include/sysexits.h119
-rw-r--r--include/tar.h66
-rw-r--r--include/tgmath.h169
-rw-r--r--include/tib.h258
-rw-r--r--include/time.h191
-rw-r--r--include/ttyent.h73
-rw-r--r--include/unistd.h3
-rw-r--r--include/utime.h55
-rw-r--r--include/utmp.h69
-rw-r--r--include/uuid.h69
-rw-r--r--include/vis.h93
-rw-r--r--include/wchar.h239
-rw-r--r--include/wctype.h107
-rw-r--r--includedir/err.h3
-rw-r--r--includedir/grp.h4
-rw-r--r--includedir/machine/endian.h1
-rw-r--r--includedir/netinet/ip.h9
-rw-r--r--includedir/pwd.h4
-rw-r--r--includedir/readpassphrase.h40
-rw-r--r--includedir/resolv.h3
-rw-r--r--includedir/stdlib.h12
-rw-r--r--includedir/string.h5
-rw-r--r--includedir/sys/cdefs.h5
-rw-r--r--includedir/sys/compat.h59
-rw-r--r--includedir/sys/param.h3
-rw-r--r--includedir/sys/time.h14
-rw-r--r--includedir/unistd.h3
-rw-r--r--lib/libc/crypt/arc4random.c198
-rw-r--r--lib/libc/crypt/arc4random_uniform.c57
-rw-r--r--lib/libc/crypt/blowfish.c698
-rw-r--r--lib/libc/crypt/chacha_private.h222
-rw-r--r--lib/libc/gen/fts.c1053
-rw-r--r--lib/libc/gen/getprogname.c24
-rw-r--r--lib/libc/gen/pwcache.c433
-rw-r--r--lib/libc/gen/readpassphrase.c190
-rw-r--r--lib/libc/gen/setprogname.c31
-rw-r--r--lib/libc/gen/unvis.c286
-rw-r--r--lib/libc/gen/vis.c243
-rw-r--r--lib/libc/gen/vwarnc.c47
-rw-r--r--lib/libc/gen/warnc.c43
-rw-r--r--lib/libc/hash/helper.c118
-rw-r--r--lib/libc/hash/md5.c252
-rw-r--r--lib/libc/hash/rmd160.c375
-rw-r--r--lib/libc/hash/sha1.c179
-rw-r--r--lib/libc/hash/sha2.c977
-rw-r--r--lib/libc/net/base64.c315
-rw-r--r--lib/libc/stdlib/freezero.c32
-rw-r--r--lib/libc/stdlib/reallocarray.c39
-rw-r--r--lib/libc/stdlib/recallocarray.c81
-rw-r--r--lib/libc/stdlib/strtonum.c66
-rw-r--r--lib/libc/string/strmode.c141
-rw-r--r--lib/libc/string/timingsafe_bcmp.c30
-rw-r--r--lib/libc/string/timingsafe_memcmp.c47
-rw-r--r--lib/libcrypto/arc4random/arc4random_linux.h88
-rw-r--r--lib/libcrypto/md32_common.h345
-rw-r--r--lib/libcrypto/sha/sha256.c284
-rw-r--r--lib/libcrypto/sha/sha512.c547
-rw-r--r--lib/libutil/bcrypt_pbkdf.c176
-rw-r--r--lib/libutil/ohash.c328
-rw-r--r--lib/libutil/ohash.h74
-rw-r--r--lib/libutil/pidfile.c106
-rw-r--r--lib/libutil/util.h127
-rw-r--r--lib/libz/CVS/Entries30
-rw-r--r--lib/libz/CVS/Repository1
-rw-r--r--lib/libz/CVS/Root1
-rw-r--r--lib/libz/ChangeLog855
-rw-r--r--lib/libz/Makefile30
-rw-r--r--lib/libz/README125
-rw-r--r--lib/libz/adler32.c148
-rw-r--r--lib/libz/algorithm.doc209
-rw-r--r--lib/libz/compress.32810
-rw-r--r--lib/libz/compress.c79
-rw-r--r--lib/libz/compress.cat31556
-rw-r--r--lib/libz/crc32.c422
-rw-r--r--lib/libz/crc32.h441
-rw-r--r--lib/libz/deflate.c1734
-rw-r--r--lib/libz/deflate.h331
-rw-r--r--lib/libz/generate_pkgconfig.sh70
-rw-r--r--lib/libz/gzio.c1003
-rw-r--r--lib/libz/infback.c637
-rw-r--r--lib/libz/inffast.c331
-rw-r--r--lib/libz/inffast.h12
-rw-r--r--lib/libz/inffixed.h95
-rw-r--r--lib/libz/inflate.c1447
-rw-r--r--lib/libz/inflate.h115
-rw-r--r--lib/libz/inftrees.c328
-rw-r--r--lib/libz/inftrees.h56
-rw-r--r--lib/libz/shlib_version2
-rw-r--r--lib/libz/trees.c1219
-rw-r--r--lib/libz/trees.h129
-rw-r--r--lib/libz/uncompr.c61
-rw-r--r--lib/libz/zconf.h330
-rw-r--r--lib/libz/zlib.h1359
-rw-r--r--lib/libz/zutil.c319
-rw-r--r--lib/libz/zutil.h273
-rw-r--r--patches/0001-fts-Avoid-d_namlen.patch49
-rw-r--r--patches/0002-fts-Add-some-includes.patch46
-rw-r--r--patches/0003-pax-Set-listf-to-stderr-in-main.patch34
-rw-r--r--patches/0004-pax-Add-some-includes.patch86
-rw-r--r--patches/0005-tar-Default-to-stdin.patch25
-rw-r--r--patches/0006-yacc-Add-some-includes.patch24
-rw-r--r--patches/0007-diff-Add-missing-includes.patch37
-rw-r--r--patches/0008-patch-Add-missing-includes.patch24
-rw-r--r--patches/0009-patch-Avoid-d_namlen.patch25
-rw-r--r--patches/0010-patch-Fix-with-musl-s-basename-dirname.patch46
-rw-r--r--patches/0011-pax-Fix-GNU-long-name-handling-with-short-read.patch176
-rw-r--r--patches/0012-pax-Support-xz-compression-with-J-flag.patch90
-rw-r--r--patches/0013-setprogname-Explicitly-discard-const-qualifier.patch23
-rw-r--r--patches/0014-readpassphrase-Support-systems-without-VSTATUS-and-T.patch38
-rw-r--r--patches/0015-Remove-getpass-definition.patch36
-rw-r--r--patches/0016-doas-Port-to-linux-musl.patch435
-rw-r--r--patches/0017-pwcache-Don-t-use-fixed-buffer-sizes.patch92
-rw-r--r--patches/0018-yacc-Remove-__unused.patch27
-rw-r--r--patches/0019-Add-standalone-freezero.patch51
-rw-r--r--patches/0020-m4-Use-hand-written-lexer-to-avoid-cycle-in-bootstra.patch327
-rw-r--r--patches/0021-m4-Use-_Noreturn-instead-of-__dead.patch25
-rw-r--r--patches/0022-m4-Add-missing-includes.patch50
-rw-r--r--patches/0023-libutil-Add-missing-includes.patch24
-rw-r--r--patches/0024-acme-client-Add-missing-includes.patch25
-rw-r--r--patches/0025-rsync-Add-missing-includes.patch40
-rw-r--r--patches/0026-rsync-Use-standard-S_ISVTX-instead-of-S_ISTXT.patch34
-rw-r--r--patches/0027-rsync-Use-1-instead-of-INFTIM-for-poll-timeout.patch25
-rw-r--r--patches/0028-rsync-Avoid-pointer-arithmetic-on-void.patch148
-rw-r--r--patches/0029-Include-sys-sysmacros.h-if-necessary.patch73
-rw-r--r--patches/0030-nc-Portability-fixes-from-libressl-portable.patch194
-rw-r--r--patches/0031-pax-Ignore-EOPNOTSUPP-from-fchmodat.patch26
-rw-r--r--patches/0032-acme-client-Fix-build-with-old-bison-versions.patch24
-rw-r--r--patches/0033-rsync-Add-implementation-of-MD4.patch414
-rw-r--r--patches/0034-pax-Fix-some-incorrect-format-specifiers.patch48
-rw-r--r--patches/0035-pax-Use-memcpy-to-set-TMAGIC-and-TVERSION-to-avoid-w.patch27
-rw-r--r--patches/0036-rsync-Fix-some-incorrect-format-specifiers.patch25
-rw-r--r--patches/0037-m4-Declare-dopaste-only-when-it-s-used.patch26
-rw-r--r--patches/0038-sha2-add-missing-include.patch11
-rw-r--r--patches/0039-bcrypt-add-cdefs.patch10
-rw-r--r--patches/0040-mandoc-port-to-musl.patch159
-rw-r--r--patches/0041-pidfile-add-cdefs.patch10
-rw-r--r--patches/0042-doas-define-gnu-source.patch13
-rw-r--r--patches/0043-signify-add-headers.patch34
-rw-r--r--patches/0044-fix-hash-objects.patch40
-rw-r--r--patches/0045-md5-add-headers.patch19
-rw-r--r--sys/sys/CVS/Entries139
-rw-r--r--sys/sys/CVS/Repository1
-rw-r--r--sys/sys/CVS/Root1
-rw-r--r--sys/sys/_endian.h179
-rw-r--r--sys/sys/_lock.h70
-rw-r--r--sys/sys/_null.h18
-rw-r--r--sys/sys/_time.h64
-rw-r--r--sys/sys/_types.h78
-rw-r--r--sys/sys/acct.h79
-rw-r--r--sys/sys/ataio.h48
-rw-r--r--sys/sys/atomic.h258
-rw-r--r--sys/sys/audioio.h231
-rw-r--r--sys/sys/buf.h374
-rw-r--r--sys/sys/cdefs.h413
-rw-r--r--sys/sys/cdio.h435
-rw-r--r--sys/sys/chio.h176
-rw-r--r--sys/sys/conf.h633
-rw-r--r--sys/sys/core.h99
-rw-r--r--sys/sys/ctf.h186
-rw-r--r--sys/sys/device.h224
-rw-r--r--sys/sys/dir.h65
-rw-r--r--sys/sys/dirent.h100
-rw-r--r--sys/sys/disk.h160
-rw-r--r--sys/sys/disklabel.h533
-rw-r--r--sys/sys/dkio.h80
-rw-r--r--sys/sys/domain.h78
-rw-r--r--sys/sys/endian.h124
-rw-r--r--sys/sys/errno.h182
-rw-r--r--sys/sys/evcount.h50
-rw-r--r--sys/sys/event.h224
-rw-r--r--sys/sys/eventvar.h64
-rw-r--r--sys/sys/exec.h386
-rw-r--r--sys/sys/exec_elf.h785
-rw-r--r--sys/sys/exec_script.h43
-rw-r--r--sys/sys/extent.h130
-rw-r--r--sys/sys/fcntl.h220
-rw-r--r--sys/sys/file.h136
-rw-r--r--sys/sys/filedesc.h157
-rw-r--r--sys/sys/filio.h54
-rw-r--r--sys/sys/fusebuf.h148
-rw-r--r--sys/sys/futex.h41
-rw-r--r--sys/sys/gmon.h175
-rw-r--r--sys/sys/gpio.h80
-rw-r--r--sys/sys/hibernate.h159
-rw-r--r--sys/sys/hotplug.h40
-rw-r--r--sys/sys/ioccom.h68
-rw-r--r--sys/sys/ioctl.h55
-rw-r--r--sys/sys/ipc.h95
-rw-r--r--sys/sys/kcore.h65
-rw-r--r--sys/sys/kcov.h40
-rw-r--r--sys/sys/kernel.h65
-rw-r--r--sys/sys/kthread.h50
-rw-r--r--sys/sys/ktrace.h254
-rw-r--r--sys/sys/limits.h125
-rw-r--r--sys/sys/lock.h55
-rw-r--r--sys/sys/lockf.h45
-rw-r--r--sys/sys/malloc.h406
-rw-r--r--sys/sys/mbuf.h550
-rw-r--r--sys/sys/memrange.h97
-rw-r--r--sys/sys/mman.h165
-rw-r--r--sys/sys/mount.h637
-rw-r--r--sys/sys/mplock.h75
-rw-r--r--sys/sys/msg.h177
-rw-r--r--sys/sys/msgbuf.h53
-rw-r--r--sys/sys/mtio.h147
-rw-r--r--sys/sys/mutex.h165
-rw-r--r--sys/sys/namei.h279
-rw-r--r--sys/sys/param.h223
-rw-r--r--sys/sys/pciio.h78
-rw-r--r--sys/sys/percpu.h198
-rw-r--r--sys/sys/pipe.h96
-rw-r--r--sys/sys/pledge.h147
-rw-r--r--sys/sys/poll.h89
-rw-r--r--sys/sys/pool.h295
-rw-r--r--sys/sys/proc.h655
-rw-r--r--sys/sys/protosw.h237
-rw-r--r--sys/sys/ptrace.h137
-rw-r--r--sys/sys/queue.h536
-rw-r--r--sys/sys/radioio.h76
-rw-r--r--sys/sys/reboot.h106
-rw-r--r--sys/sys/refcnt.h38
-rw-r--r--sys/sys/resource.h128
-rw-r--r--sys/sys/resourcevar.h107
-rw-r--r--sys/sys/rwlock.h191
-rw-r--r--sys/sys/sched.h244
-rw-r--r--sys/sys/scsiio.h74
-rw-r--r--sys/sys/select.h137
-rw-r--r--sys/sys/selinfo.h57
-rw-r--r--sys/sys/sem.h198
-rw-r--r--sys/sys/sensors.h177
-rw-r--r--sys/sys/shm.h151
-rw-r--r--sys/sys/siginfo.h199
-rw-r--r--sys/sys/sigio.h95
-rw-r--r--sys/sys/signal.h202
-rw-r--r--sys/sys/signalvar.h144
-rw-r--r--sys/sys/smr.h440
-rw-r--r--sys/sys/socket.h572
-rw-r--r--sys/sys/socketvar.h365
-rw-r--r--sys/sys/sockio.h230
-rw-r--r--sys/sys/specdev.h113
-rw-r--r--sys/sys/srp.h190
-rw-r--r--sys/sys/stacktrace.h40
-rw-r--r--sys/sys/stat.h222
-rw-r--r--sys/sys/statvfs.h48
-rw-r--r--sys/sys/stdarg.h51
-rw-r--r--sys/sys/stdint.h231
-rw-r--r--sys/sys/swap.h62
-rw-r--r--sys/sys/syscall.h708
-rw-r--r--sys/sys/syscall_mi.h191
-rw-r--r--sys/sys/syscallargs.h1362
-rw-r--r--sys/sys/sysctl.h1061
-rw-r--r--sys/sys/syslimits.h77
-rw-r--r--sys/sys/syslog.h221
-rw-r--r--sys/sys/systm.h409
-rw-r--r--sys/sys/task.h60
-rw-r--r--sys/sys/termios.h299
-rw-r--r--sys/sys/time.h418
-rw-r--r--sys/sys/timeout.h137
-rw-r--r--sys/sys/times.h63
-rw-r--r--sys/sys/timetc.h107
-rw-r--r--sys/sys/tprintf.h41
-rw-r--r--sys/sys/tracepoint.h36
-rw-r--r--sys/sys/tree.h1006
-rw-r--r--sys/sys/tty.h336
-rw-r--r--sys/sys/ttycom.h151
-rw-r--r--sys/sys/ttydefaults.h95
-rw-r--r--sys/sys/types.h261
-rw-r--r--sys/sys/ucred.h84
-rw-r--r--sys/sys/uio.h108
-rw-r--r--sys/sys/un.h65
-rw-r--r--sys/sys/unistd.h106
-rw-r--r--sys/sys/unpcb.h111
-rw-r--r--sys/sys/user.h48
-rw-r--r--sys/sys/utsname.h59
-rw-r--r--sys/sys/uuid.h75
-rw-r--r--sys/sys/varargs.h56
-rw-r--r--sys/sys/videoio.h3372
-rw-r--r--sys/sys/vmmeter.h97
-rw-r--r--sys/sys/vnode.h665
-rw-r--r--sys/sys/wait.h103
-rw-r--r--sys/sys/witness.h156
407 files changed, 72894 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..5bacaf8
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,11 @@
+*.a
+*.o
+diff
+doas
+m4
+mandoc
+md5
+nc
+patch
+pax
+signify
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..0d615e0
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,6 @@
+bin/ include/ lib/ sys/ usr.bin/ come from OpenBSD with the modifications from
+ patches folder.
+includedir/ patches/00[01-37]-* come from OasisLinux
+includedir/sys/compat.h taken from https://github.com/aperezdc/signify
+
+The Makefile, config.mk and other patches are on the public domain.
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..246d9f1
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,364 @@
+include config.mk
+BIN = \
+ diff \
+ doas \
+ m4 \
+ mandoc \
+ md5 \
+ nc \
+ patch \
+ pax \
+ signify
+
+LIB = lib/libbsd.a
+LIBOBJ = \
+ lib/libc/crypt/arc4random.o \
+ lib/libc/crypt/arc4random_uniform.o \
+ lib/libc/crypt/blowfish.o \
+ lib/libc/gen/fts.o \
+ lib/libc/gen/getprogname.o \
+ lib/libc/gen/pwcache.o \
+ lib/libc/gen/readpassphrase.o \
+ lib/libc/gen/setprogname.o \
+ lib/libc/gen/unvis.o \
+ lib/libc/gen/vis.o \
+ lib/libc/gen/vwarnc.o \
+ lib/libc/gen/warnc.o \
+ lib/libc/hash/md5.o \
+ lib/libc/hash/md5hl.o \
+ lib/libc/hash/rmd160.o \
+ lib/libc/hash/rmd160hl.o \
+ lib/libc/hash/sha1.o \
+ lib/libc/hash/sha2.o \
+ lib/libc/hash/sha1hl.o \
+ lib/libc/hash/sha224hl.o \
+ lib/libc/hash/sha256hl.o \
+ lib/libc/hash/sha384hl.o \
+ lib/libc/hash/sha512_256hl.o \
+ lib/libc/hash/sha512hl.o \
+ lib/libc/net/base64.o \
+ lib/libc/stdlib/freezero.o \
+ lib/libc/stdlib/reallocarray.o \
+ lib/libc/stdlib/recallocarray.o \
+ lib/libc/stdlib/strtonum.o \
+ lib/libc/string/strmode.o \
+ lib/libc/string/timingsafe_bcmp.o \
+ lib/libc/string/timingsafe_memcmp.o \
+ lib/libcrypto/sha/sha256.o \
+ lib/libcrypto/sha/sha512.o \
+ lib/libutil/bcrypt_pbkdf.o \
+ lib/libutil/ohash.o \
+ lib/libutil/pidfile.o
+
+
+MAN = \
+ usr.bin/diff/diff.1 \
+ usr.bin/doas/doas.1 \
+ usr.bin/doas/doas.conf.5 \
+ usr.bin/mandoc/apropos.1 \
+ usr.bin/mandoc/makewhatis.8 \
+ usr.bin/mandoc/man.1 \
+ usr.bin/mandoc/man.conf.5 \
+ usr.bin/mandoc/mandoc.1 \
+ usr.bin/m4/m4.1 \
+ usr.bin/nc/nc.1 \
+ usr.bin/patch/patch.1 \
+ bin/md5/md5.1 \
+ bin/md5/cksum.1 \
+ bin/pax/cpio.1 \
+ bin/pax/pax.1 \
+ bin/pax/tar.1 \
+ usr.bin/signify/signify.1
+
+.y.c:
+ ${YACC} -o $@ $<
+.c.o:
+ ${CC} ${CFLAGS} -c -o $@ $<
+
+.o: ${LIB}
+
+all: ${BIN}
+${BINOBJ}: ${LIB}
+
+# ------------------------------------------------------------------------------
+# diff
+DIFFOBJ = \
+ usr.bin/diff/diff.o \
+ usr.bin/diff/diffdir.o \
+ usr.bin/diff/diffreg.o \
+ usr.bin/diff/xmalloc.o
+BINOBJ += ${DIFFOBJ}
+diff: ${DIFFOBJ} ${LIB}
+ ${CC} ${LDFLAGS} -o $@ ${DIFFOBJ} ${LIB}
+
+# ------------------------------------------------------------------------------
+# doas
+DOASOBJ = \
+ usr.bin/doas/parse.o \
+ usr.bin/doas/doas.o \
+ usr.bin/doas/env.o \
+ usr.bin/doas/persist.o
+
+BINOBJ += ${DOASOBJ} parse.c
+${DOASOBJ}: usr.bin/doas/parse.tab.h
+usr.bin/doas/parse.c usr.bin/doas/parse.tab.h: usr.bin/doas/parse.y
+ ${YACC} -o usr.bin/doas/parse.c -dH usr.bin/doas/parse.tab.h $<
+usr.bin/doas/env.o: usr.bin/doas/env.c
+ ${CC} ${CFLAGS} -include sys/sys/tree.h -c -o $@ $<
+doas: ${DOASOBJ} ${LIB}
+ ${CC} ${LDFLAGS} -o $@ ${DOASOBJ} ${LIB}
+
+
+# ------------------------------------------------------------------------------
+# m4
+M4OBJ = \
+ usr.bin/m4/eval.o \
+ usr.bin/m4/expr.o \
+ usr.bin/m4/look.o \
+ usr.bin/m4/main.o \
+ usr.bin/m4/misc.o \
+ usr.bin/m4/gnum4.o \
+ usr.bin/m4/trace.o \
+ usr.bin/m4/tokenizer.o \
+ usr.bin/m4/parser.o
+BINOBJ += ${M4OBJ} parser.c
+
+usr.bin/m4/parser.c usr.bin/m4/parser.tab.h: usr.bin/m4/parser.y
+ ${YACC} -o usr.bin/m4/parser.c -dH usr.bin/m4/parser.tab.h $<
+usr.bin/m4/tokenizer.o: usr.bin/m4/tokenizer.c usr.bin/m4/parser.tab.h
+ ${CC} ${CFLAGS} -I${PWD}/usr.bin/m4 -include usr.bin/m4/parser.tab.h \
+ -c -o $@ usr.bin/m4/tokenizer.c
+
+m4: ${M4OBJ} ${LIB}
+ ${CC} ${LDFLAGS} -o $@ ${M4OBJ} ${LIB}
+
+# ------------------------------------------------------------------------------
+# mandoc
+MANDOCLINK = makewhatis whatis apropos man
+MANDOCOBJ = \
+ usr.bin/mandoc/arch.o \
+ usr.bin/mandoc/att.o \
+ usr.bin/mandoc/chars.o \
+ usr.bin/mandoc/dba.o \
+ usr.bin/mandoc/dba_array.o \
+ usr.bin/mandoc/dba_read.o \
+ usr.bin/mandoc/dba_write.o \
+ usr.bin/mandoc/dbm.o \
+ usr.bin/mandoc/dbm_map.o \
+ usr.bin/mandoc/eqn.o \
+ usr.bin/mandoc/eqn_html.o \
+ usr.bin/mandoc/eqn_term.o \
+ usr.bin/mandoc/html.o \
+ usr.bin/mandoc/main.o \
+ usr.bin/mandoc/man.o \
+ usr.bin/mandoc/man_html.o \
+ usr.bin/mandoc/man_macro.o \
+ usr.bin/mandoc/man_term.o \
+ usr.bin/mandoc/man_validate.o \
+ usr.bin/mandoc/mandoc.o \
+ usr.bin/mandoc/mandoc_aux.o \
+ usr.bin/mandoc/mandoc_msg.o \
+ usr.bin/mandoc/mandoc_ohash.o \
+ usr.bin/mandoc/mandoc_xr.o \
+ usr.bin/mandoc/mandocdb.o \
+ usr.bin/mandoc/manpath.o \
+ usr.bin/mandoc/mansearch.o \
+ usr.bin/mandoc/mdoc.o \
+ usr.bin/mandoc/mdoc_argv.o \
+ usr.bin/mandoc/mdoc_html.o \
+ usr.bin/mandoc/mdoc_macro.o \
+ usr.bin/mandoc/mdoc_man.o \
+ usr.bin/mandoc/mdoc_markdown.o \
+ usr.bin/mandoc/mdoc_state.o \
+ usr.bin/mandoc/mdoc_term.o \
+ usr.bin/mandoc/mdoc_validate.o \
+ usr.bin/mandoc/msec.o \
+ usr.bin/mandoc/out.o \
+ usr.bin/mandoc/preconv.o \
+ usr.bin/mandoc/read.o \
+ usr.bin/mandoc/roff.o \
+ usr.bin/mandoc/roff_html.o \
+ usr.bin/mandoc/roff_term.o \
+ usr.bin/mandoc/roff_validate.o \
+ usr.bin/mandoc/st.o \
+ usr.bin/mandoc/tag.o \
+ usr.bin/mandoc/tbl.o \
+ usr.bin/mandoc/tbl_data.o \
+ usr.bin/mandoc/tbl_html.o \
+ usr.bin/mandoc/tbl_layout.o \
+ usr.bin/mandoc/tbl_opts.o \
+ usr.bin/mandoc/tbl_term.o \
+ usr.bin/mandoc/term.o \
+ usr.bin/mandoc/term_ascii.o \
+ usr.bin/mandoc/term_ps.o \
+ usr.bin/mandoc/term_tab.o \
+ usr.bin/mandoc/term_tag.o \
+ usr.bin/mandoc/tree.o
+BINOBJ += ${MANDOCOBJ}
+mandoc: ${MANDOCOBJ} ${LIB}
+ ${CC} ${LDFLAGS} -o $@ ${MANDOCOBJ} ${LIB} ${ZLIB}
+
+# ------------------------------------------------------------------------------
+# md5
+MD5LINK = sha1 sha224 sha256 sha384 sha512 rmd160 cksum
+MD5MAN = sha1.1 sha224.1 sha256.1 sha384.1 sha512.1 rmd160.1
+MD5OBJ = \
+ bin/md5/crc.o \
+ bin/md5/md5.o
+BINOBJ += ${MD5OBJ}
+md5: ${MD5OBJ} ${LIB}
+ ${CC} ${LDFLAGS} -o $@ ${MD5OBJ} ${LIB}
+
+# ------------------------------------------------------------------------------
+# nc
+NCOBJ = \
+ usr.bin/nc/atomicio.o \
+ usr.bin/nc/netcat.o \
+ usr.bin/nc/socks.o
+BINOBJ += ${NCOBJ}
+usr.bin/nc/netcat.o: usr.bin/nc/netcat.c
+ ${CC} ${CFLAGS} -include /usr/include/tls.h -c -o $@ $<
+nc: ${NCOBJ} ${LIB}
+ ${CC} ${LDFLAGS} -o $@ ${NCOBJ} ${LIB} ${TLSLIB}
+
+# ------------------------------------------------------------------------------
+# pax
+PAXOBJ = \
+ bin/pax/ar_io.o \
+ bin/pax/ar_subs.o \
+ bin/pax/buf_subs.o \
+ bin/pax/cpio.o \
+ bin/pax/file_subs.o \
+ bin/pax/ftree.o \
+ bin/pax/gen_subs.o \
+ bin/pax/getoldopt.o \
+ bin/pax/options.o \
+ bin/pax/pat_rep.o \
+ bin/pax/pax.o \
+ bin/pax/sel_subs.o \
+ bin/pax/tables.o \
+ bin/pax/tar.o \
+ bin/pax/tty_subs.o
+BINOBJ += ${PAXOBJ}
+pax: ${PAXOBJ} ${LIB}
+ ${CC} ${LDFLAGS} -o $@ ${PAXOBJ} ${LIB}
+
+# ------------------------------------------------------------------------------
+# patch
+PATCHOBJ = \
+ usr.bin/patch/patch.o \
+ usr.bin/patch/pch.o \
+ usr.bin/patch/inp.o \
+ usr.bin/patch/util.o \
+ usr.bin/patch/backupfile.o \
+ usr.bin/patch/mkpath.o \
+ usr.bin/patch/ed.o
+BINOBJ += ${PATCHOBJ}
+patch: ${PATCHOBJ} ${LIB}
+ ${CC} ${LDFLAGS} -o $@ ${PATCHOBJ} ${LIB}
+
+# -----------------------------------------------------------------------------
+# signify
+SIGNIFYOBJ = \
+ usr.bin/signify/signify.o \
+ usr.bin/signify/zsig.o \
+ usr.bin/signify/fe25519.o \
+ usr.bin/signify/sc25519.o \
+ usr.bin/signify/mod_ed25519.o \
+ usr.bin/signify/mod_ge25519.o \
+ usr.bin/signify/crypto_api.o
+BINOBJ += ${SIGNIFYOBJ}
+signify: ${SIGNIFYOBJ} ${LIB}
+ ${CC} ${LDFLAGS} -o $@ ${SIGNIFYOBJ} ${LIB}
+
+# ------------------------------------------------------------------------------
+# hash helpers
+HELPER = lib/libc/hash/helper.c
+HASHOBJ = \
+ lib/libc/hash/md5hl.c \
+ lib/libc/hash/rmd160hl.c \
+ lib/libc/hash/sha1hl.c \
+ lib/libc/hash/sha224hl.c \
+ lib/libc/hash/sha256hl.c \
+ lib/libc/hash/sha384hl.c \
+ lib/libc/hash/sha512hl.c \
+ lib/libc/hash/sha512_256hl.c
+BINOBJ += ${HASHOBJ}
+${HASHOBJ}: ${HELPER}
+lib/libc/hash/md5hl.c:
+ sed 's|HASH|MD5|g;s|hashinc|md5.h|' < ${HELPER} > $@
+lib/libc/hash/rmd160hl.c:
+ sed 's|HASH|RMD160|g;s|hashinc|rmd160.h|' < ${HELPER} > $@
+lib/libc/hash/sha1hl.c:
+ sed 's|HASH|SHA1|g;s|hashinc|sha1.h|' < ${HELPER} > $@
+lib/libc/hash/sha224hl.c:
+ sed 's|HASH|SHA224|g;s|hashinc|sha2.h|' < ${HELPER} | sed 's,SHA224_CTX,SHA2_CTX,g' > $@
+lib/libc/hash/sha256hl.c:
+ sed 's|HASH|SHA256|g;s|hashinc|sha2.h|' < ${HELPER} | sed 's,SHA256_CTX,SHA2_CTX,g' > $@
+lib/libc/hash/sha384hl.c:
+ sed 's|HASH|SHA384|g;s|hashinc|sha2.h|' < ${HELPER} | sed 's,SHA384_CTX,SHA2_CTX,g' > $@
+lib/libc/hash/sha512hl.c:
+ sed 's|HASH|SHA512|g;s|hashinc|sha2.h|' < ${HELPER} | sed 's,SHA512_CTX,SHA2_CTX,g' > $@
+lib/libc/hash/sha512_256hl.c:
+ sed 's|HASH|SHA512_256|g;s|hashinc|sha2.h|' < ${HELPER} | sed 's,SHA512_256_CTX,SHA2_CTX,g' > $@
+
+# ------------------------------------------------------------------------------
+# libz
+LIBZOBJ = \
+ lib/libz/adler32.o \
+ lib/libz/compress.o \
+ lib/libz/crc32.o \
+ lib/libz/deflate.o \
+ lib/libz/gzio.o \
+ lib/libz/infback.o \
+ lib/libz/inffast.o \
+ lib/libz/inflate.o \
+ lib/libz/inftrees.o \
+ lib/libz/trees.o \
+ lib/libz/uncompr.o \
+ lib/libz/zutil.o
+BINOBJ += ${LIBZOBJ}
+lib/libz/libz.a: ${LIBZOBJ}
+ ${AR} rc $@ $?
+ ${RANLIB} $@
+
+# ------------------------------------------------------------------------------
+# libbsd
+
+lib/libc/crypt/arc4random.o: lib/libc/crypt/arc4random.c lib/libcrypto/arc4random/arc4random_linux.h
+ mkdir -p arc4random
+ cp lib/libc/crypt/arc4random.c arc4random
+ cp lib/libcrypto/arc4random/arc4random_linux.h arc4random/arc4random.h
+ cp lib/libc/crypt/chacha_private.h arc4random
+ ${CC} ${CFLAGS} -c -o $@ arc4random/arc4random.c
+ ${RM} -r -- arc4random
+
+lib/libbsd.a: ${LIBOBJ}
+ ${AR} rc $@ $?
+ ${RANLIB} $@
+
+
+getobj:
+ @printf '%s\n' ${LIBOBJ}
+
+install:
+ mkdir -p ${DESTDIR}${BINDIR}
+ for bin in ${BIN}; do \
+ cp $${bin} ${DESTDIR}${BINDIR}; \
+ chmod 755 ${DESTDIR}${BINDIR}/$${bin##*/}; done
+ chmod u+x ${DESTDIR}${BINDIR}/doas
+ for bin in ${MANDOCLINK}; do \
+ ln -s mandoc ${DESTDIR}${BINDIR}/$${bin}; done
+ for bin in ${MD5LINK}; do \
+ ln -s md5 ${DESTDIR}${BINDIR}/$${bin}; done
+ for man in ${MAN}; do \
+ mkdir -p ${DESTDIR}${MANPREFIX}/man$${man##*.}; \
+ cp $${man} ${DESTDIR}${MANPREFIX}/man$${man##*.}; \
+ chmod 644 ${DESTDIR}${MANPREFIX}/man$${man##*.}/$${man##*/}; done
+ for man in ${MD5MAN}; do \
+ ln -s md5.1 ${DESTDIR}${MANPREFIX}/man1/$${man}; done
+
+clean:
+ ${RM} ${LIBOBJ} ${LIB} ${BIN} ${BINOBJ} lib/libz/libz.a
+
+.PHONY: all clean
diff --git a/README b/README
new file mode 100644
index 0000000..b8515eb
--- /dev/null
+++ b/README
@@ -0,0 +1,36 @@
+otools
+------
+
+Some OpenBSD userland utilities meant to be included in Carbs Linux base.
+
+Currently includes the following software:
+- diff
+- doas
+- m4
+- mandoc
+- md5
+- nc
+- patch
+- pax
+- signify
+
+You can build software individually by calling 'make <program>', and the
+program will be built to the root directory of the source. The Makefile
+is bsdmake compatible.
+
+requirements
+------------
+
+In order to build 'mandoc', you need to either have zlib installed, or edit
+config.mk to use the in-source zlib.
+
+In order to build 'nc', you need to have a libtls implementation. Carbs Linux
+uses libtls-bearssl by default.
+
+
+patch directory
+---------------
+
+The patch directory doesn't serve any function but to keep track of the applied
+patches under revision control. The sources here are already patched.
+
diff --git a/config.mk b/config.mk
new file mode 100644
index 0000000..c064088
--- /dev/null
+++ b/config.mk
@@ -0,0 +1,29 @@
+PREFIX = /usr/local
+BINDIR = ${PREFIX}/bin
+MANPREFIX = ${PREFIX}/share/man
+
+AR = ar
+CC = cc
+RANLIB = ranlib
+RM = rm -f
+YACC = yacc
+
+
+# You can uncomment the latter if you aren't using libtls-bearssl. If you
+# aren't linking statically, '-ltls' should be suffice.
+TLSLIB = -ltls -lbearssl
+#TLSLIB = `pkgconf --static --libs libtls`
+
+# You can replace the following to 'lib/libz/libz.a' in order to build with the
+# in-source zlib.
+ZLIB = -lz
+
+CFLAGS = -Wall -Wno-pointer-sign -Wno-maybe-uninitialized \
+ -Wno-attributes -I${PWD}/includedir \
+ -D 'DEF_WEAK(n)=_Static_assert(1, "")' \
+ -idirafter ${PWD}/include \
+ -idirafter ${PWD}/sys \
+ -idirafter ${PWD}/lib/libutil \
+ -idirafter ${PWD}/lib/libcrypto
+
+LDFLAGS = -static
diff --git a/include/CVS/Entries b/include/CVS/Entries
new file mode 100644
index 0000000..97f2910
--- /dev/null
+++ b/include/CVS/Entries
@@ -0,0 +1,93 @@
+/Makefile/1.226/Thu Nov 14 21:14:53 2019//
+/a.out.h/1.3/Mon Jun 2 19:34:12 2003//
+/ar.h/1.3/Mon Jun 2 19:34:12 2003//
+/asr.h/1.2/Thu Oct 24 05:57:41 2019//
+/assert.h/1.13/Sun Jun 26 21:11:41 2011//
+/bitstring.h/1.5/Mon Jun 2 19:34:12 2003//
+/blf.h/1.7/Wed Mar 14 17:59:41 2007//
+/bsd_auth.h/1.11/Thu Mar 9 10:13:03 2017//
+/complex.h/1.5/Sun Mar 16 18:38:30 2014//
+/cpio.h/1.3/Thu Jun 26 05:42:04 2008//
+/ctype.h/1.25/Tue Sep 5 03:16:13 2017//
+/curses.h/1.5/Fri Jan 25 00:19:25 2019//
+/db.h/1.12/Sat Oct 17 21:48:42 2015//
+/dirent.h/1.34/Fri Sep 9 18:12:37 2016//
+/disktab.h/1.3/Mon Jun 2 19:34:12 2003//
+/dlfcn.h/1.14/Tue Nov 28 17:19:47 2017//
+/elf.h/1.1/Tue Oct 17 09:34:52 2017//
+/elf_abi.h/1.4/Wed May 22 07:46:22 1996//
+/err.h/1.13/Mon Aug 31 02:53:56 2015//
+/errno.h/1.3/Thu Aug 10 13:34:46 2017//
+/fenv.h/1.2/Wed May 25 21:46:49 2011//
+/float.h/1.1/Tue Jun 26 16:16:16 2012//
+/fnmatch.h/1.8/Tue Dec 13 00:35:22 2005//
+/fstab.h/1.5/Mon Jun 2 19:34:12 2003//
+/fts.h/1.14/Wed Dec 5 23:19:57 2012//
+/ftw.h/1.2/Fri Jan 25 00:19:25 2019//
+/getopt.h/1.3/Fri Nov 22 21:32:49 2013//
+/glob.h/1.14/Mon Feb 4 16:45:40 2019//
+/grp.h/1.13/Thu Sep 13 12:31:15 2018//
+/icdb.h/1.4/Sun Sep 4 14:51:39 2016//
+/ieeefp.h/1.4/Sun Sep 27 21:23:55 2009//
+/ifaddrs.h/1.4/Thu Jan 22 21:48:02 2004//
+/inttypes.h/1.13/Fri Jan 25 00:19:25 2019//
+/iso646.h/1.3/Thu Oct 11 00:05:21 2001//
+/kvm.h/1.18/Tue Oct 22 16:40:25 2013//
+/langinfo.h/1.8/Tue Sep 5 03:16:13 2017//
+/libgen.h/1.9/Fri Jan 25 00:19:25 2019//
+/limits.h/1.19/Tue Jan 20 22:09:50 2015//
+/link.h/1.15/Sat Oct 19 09:00:18 2013//
+/link_elf.h/1.7/Tue Sep 20 18:24:55 2016//
+/locale.h/1.11/Tue Sep 5 03:16:13 2017//
+/login_cap.h/1.16/Sun Jul 29 19:40:41 2018//
+/math.h/1.36/Sat Mar 10 20:52:58 2018//
+/md5.h/1.17/Wed Dec 5 23:19:57 2012//
+/memory.h/1.3/Mon Jun 2 19:34:12 2003//
+/ndbm.h/1.6/Mon May 3 17:27:50 2004//
+/netdb.h/1.33/Sun Jan 18 20:29:31 2015//
+/netgroup.h/1.8/Thu Sep 10 18:59:34 2015//
+/nl_types.h/1.8/Thu Jun 26 05:42:04 2008//
+/nlist.h/1.4/Mon Jun 2 19:34:12 2003//
+/paths.h/1.26/Thu Jul 11 03:54:17 2019//
+/poll.h/1.3/Wed Oct 29 16:41:13 2003//
+/pthread.h/1.4/Mon Mar 5 01:15:26 2018//
+/pthread_np.h/1.3/Tue May 28 10:33:03 2019//
+/pwd.h/1.26/Thu Sep 13 12:31:15 2018//
+/ranlib.h/1.3/Mon Jun 2 19:34:12 2003//
+/readpassphrase.h/1.6/Fri Jan 25 00:19:25 2019//
+/regex.h/1.7/Wed Dec 5 23:19:57 2012//
+/resolv.h/1.22/Mon Jan 14 06:23:06 2019//
+/rmd160.h/1.17/Wed Dec 5 23:19:57 2012//
+/sched.h/1.1/Sun Oct 15 23:40:33 2017//
+/search.h/1.10/Fri Jul 18 04:16:09 2014//
+/semaphore.h/1.1/Sun Oct 15 23:40:33 2017//
+/setjmp.h/1.7/Mon May 23 00:18:56 2016//
+/sha1.h/1.24/Wed Dec 5 23:19:57 2012//
+/sha2.h/1.10/Sat Sep 3 17:00:29 2016//
+/signal.h/1.26/Wed May 30 13:20:38 2018//
+/siphash.h/1.3/Fri Feb 20 11:51:03 2015//
+/sndio.h/1.10/Wed Feb 26 13:53:58 2020//
+/spawn.h/1.3/Wed May 20 22:50:07 2015//
+/stdbool.h/1.7/Fri Sep 4 23:47:09 2015//
+/stddef.h/1.14/Fri Jan 6 14:36:50 2017//
+/stdio.h/1.53/Fri Sep 9 18:12:37 2016//
+/stdlib.h/1.76/Fri May 10 15:03:24 2019//
+/string.h/1.32/Tue Sep 5 03:16:13 2017//
+/strings.h/1.6/Sun Sep 10 21:50:36 2017//
+/sysexits.h/1.5/Mon Jun 2 19:34:12 2003//
+/tar.h/1.3/Thu Jun 26 05:42:04 2008//
+/tgmath.h/1.1/Fri Jul 8 19:28:06 2011//
+/tib.h/1.7/Fri May 10 13:29:21 2019//
+/time.h/1.31/Tue Oct 30 16:28:42 2018//
+/ttyent.h/1.4/Mon Jun 2 19:34:12 2003//
+/unistd.h/1.106/Fri Jul 13 09:25:22 2018//
+/utime.h/1.7/Tue Apr 2 05:16:14 2013//
+/utmp.h/1.6/Wed Jan 8 06:50:57 2014//
+/uuid.h/1.1/Sun Aug 31 09:36:36 2014//
+/vis.h/1.15/Mon Jul 20 01:52:27 2015//
+/wchar.h/1.31/Tue Sep 5 03:16:13 2017//
+/wctype.h/1.6/Tue Sep 5 03:16:13 2017//
+D/arpa////
+D/protocols////
+D/rpc////
+D/rpcsvc////
diff --git a/include/CVS/Repository b/include/CVS/Repository
new file mode 100644
index 0000000..e4484e2
--- /dev/null
+++ b/include/CVS/Repository
@@ -0,0 +1 @@
+src/include
diff --git a/include/CVS/Root b/include/CVS/Root
new file mode 100644
index 0000000..3811072
--- /dev/null
+++ b/include/CVS/Root
@@ -0,0 +1 @@
+/cvs
diff --git a/include/Makefile b/include/Makefile
new file mode 100644
index 0000000..30d4f65
--- /dev/null
+++ b/include/Makefile
@@ -0,0 +1,163 @@
+# $OpenBSD: Makefile,v 1.226 2019/11/14 21:14:53 djm Exp $
+# $NetBSD: Makefile,v 1.59 1996/05/15 21:36:43 jtc Exp $
+
+# @(#)Makefile 5.45.1.1 (Berkeley) 5/6/91
+
+# The ``rm -rf''s used below are safe because rm doesn't follow symbolic
+# links.
+
+
+.include <bsd.own.mk>
+
+FILES= a.out.h ar.h asr.h assert.h \
+ bitstring.h blf.h bsd_auth.h \
+ complex.h cpio.h ctype.h curses.h \
+ db.h dirent.h disktab.h dlfcn.h \
+ elf.h elf_abi.h err.h errno.h \
+ fenv.h float.h fnmatch.h fstab.h fts.h ftw.h \
+ getopt.h glob.h grp.h \
+ icdb.h ieeefp.h ifaddrs.h inttypes.h iso646.h \
+ kvm.h \
+ langinfo.h libgen.h limits.h link.h link_elf.h locale.h login_cap.h \
+ math.h md5.h memory.h \
+ ndbm.h netdb.h netgroup.h nlist.h nl_types.h \
+ paths.h poll.h pthread.h pthread_np.h pwd.h \
+ ranlib.h readpassphrase.h regex.h resolv.h rmd160.h \
+ sched.h search.h setjmp.h semaphore.h sha1.h sha2.h \
+ signal.h siphash.h sndio.h spawn.h stdbool.h stddef.h \
+ stdio.h stdlib.h string.h strings.h sysexits.h \
+ tar.h tgmath.h tib.h time.h ttyent.h \
+ unistd.h utime.h utmp.h uuid.h \
+ vis.h \
+ wchar.h wctype.h
+
+MFILES= frame.h
+LFILES= endian.h fcntl.h syslog.h termios.h stdarg.h stdint.h varargs.h
+
+DIRS= arpa protocols rpc rpcsvc
+LDIRS= crypto ddb dev isofs miscfs msdosfs net netinet netinet6 \
+ netmpls net80211 nfs ntfs scsi sys ufs uvm
+
+# Places that need a prerequisite target met before includes
+PRDIRS= ../lib/libcrypto ../lib/librpcsvc
+
+# Directories with an includes target
+RDIRS= ../lib/libcbor ../lib/libcurses ../lib/libedit ../lib/libelf \
+ ../lib/libevent ../lib/libexpat ../lib/libfido2 ../lib/libform \
+ ../lib/libfuse ../lib/libkeynote ../lib/libmenu \
+ ../lib/libossaudio ../lib/libpanel ../lib/libpcap \
+ ../lib/libradius \
+ ../lib/libskey ../lib/libssl ../lib/libtls \
+ ../lib/libusbhid ../lib/libutil ../lib/libz \
+ ../usr.bin/lex ../gnu/lib/libreadline \
+ ../sys/arch/${MACHINE}
+
+.if ${BUILD_GCC3:L} == "yes"
+RDIRS+= ../gnu/usr.bin/gcc
+PRDIRS+= ../gnu/lib/libstdc++
+.endif
+.if ${BUILD_GCC4:L} == "yes"
+PRDIRS+= ../gnu/lib/libstdc++-v3 ../gnu/usr.bin/cc/include
+.endif
+.if ${BUILD_CLANG:L} == "yes"
+RDIRS+= ../lib/libcxxabi ../lib/libcxx \
+ ../gnu/usr.bin/clang/libLLVM
+.endif
+
+# prereq implies includes
+RDIRS += ${PRDIRS}
+
+NOOBJ= noobj
+
+# Change SYS_INCLUDE in bsd.own.mk to "symlinks" if you don't want copies
+SYS_INCLUDE?= copies
+
+RUN_MAKE = if test -f Makefile.bsd-wrapper; then ${MAKE} -f Makefile.bsd-wrapper $@; else ${MAKE} $@; fi
+
+prereq:
+ @for i in ${PRDIRS}; do \
+ echo preparing in ${.CURDIR}/$$i; \
+ cd ${.CURDIR}/$$i && ${RUN_MAKE}; \
+ done
+
+includes:
+ @echo installing ${FILES}
+ @for i in ${FILES}; do \
+ cmp -s $$i ${DESTDIR}/usr/include/$$i || \
+ ${INSTALL} ${INSTALL_COPY} -m 444 $$i ${DESTDIR}/usr/include/$$i; \
+ done
+ @echo installing ${DIRS}
+ @for i in ${DIRS}; do \
+ ${INSTALL} -d -o ${BINOWN} -g ${BINGRP} -m 755 \
+ ${DESTDIR}/usr/include/$$i; \
+ cd ${.CURDIR}/$$i && for j in *.[ih]; do \
+ cmp -s $$j ${DESTDIR}/usr/include/$$i/$$j || \
+ ${INSTALL} ${INSTALL_COPY} -m 444 $$j ${DESTDIR}/usr/include/$$i/$$j; \
+ done; \
+ done
+ @echo installing ${LFILES}
+ @for i in ${LFILES}; do \
+ rm -f ${DESTDIR}/usr/include/$$i && \
+ ln -s sys/$$i ${DESTDIR}/usr/include/$$i; \
+ done
+ @echo installing ${MFILES}
+ @for i in ${MFILES}; do \
+ rm -f ${DESTDIR}/usr/include/$$i && \
+ ln -s machine/$$i ${DESTDIR}/usr/include/$$i; \
+ done
+ @for i in ${RDIRS}; do \
+ echo installing in ${.CURDIR}/$$i; \
+ cd ${.CURDIR}/$$i && ${RUN_MAKE}; \
+ done
+ chown -RP ${BINOWN}:${BINGRP} ${DESTDIR}/usr/include
+ find ${DESTDIR}/usr/include \
+ -type f -exec chmod a=r {} + -o \
+ \( -type d -o -type l \) -exec chmod -h u=rwx,go=rx {} +
+
+copies:
+ @echo copies: ${LDIRS}
+ @for i in ${LDIRS}; do \
+ rm -rf ${DESTDIR}/usr/include/$$i && \
+ ${INSTALL} -d -o ${BINOWN} -g ${BINGRP} -m 755 \
+ ${DESTDIR}/usr/include/$$i ; \
+ done
+ cd ../sys; \
+ pax -rw -pa -L \
+ `find ${LDIRS} -follow -type f -name '*.h' '!' \
+ '(' -path 'dev/microcode/*' -or -path 'dev/pci/drm/*' ')' \
+ -print` ${DESTDIR}/usr/include
+ cd ${DESTDIR}/usr/include && rm -rf ${MACHINE} ${MACHINE_CPU} machine
+ ${INSTALL} -d -o ${BINOWN} -g ${BINGRP} -m 755 \
+ ${DESTDIR}/usr/include/${MACHINE}
+ pax -rw -pa -s "|\.\./sys/arch/${MACHINE}/include||" \
+ ../sys/arch/${MACHINE}/include/*.h \
+ ${DESTDIR}/usr/include/${MACHINE}
+ if test ${MACHINE} != ${MACHINE_CPU} -a \
+ -d ../sys/arch/${MACHINE_CPU}/include; then \
+ ${INSTALL} -d -o ${BINOWN} -g ${BINGRP} -m 755 \
+ ${DESTDIR}/usr/include/${MACHINE_CPU}; \
+ pax -rw -pa -s "|\.\./sys/arch/${MACHINE_CPU}/include||" \
+ ../sys/arch/${MACHINE_CPU}/include/*.h \
+ ${DESTDIR}/usr/include/${MACHINE_CPU}; \
+ fi
+ ln -sf ${MACHINE} ${DESTDIR}/usr/include/machine; \
+
+symlinks:
+ @echo symlinks: ${LDIRS}
+ @for i in ${LDIRS}; do \
+ rm -rf ${DESTDIR}/usr/include/$$i && \
+ ln -s /sys/$$i ${DESTDIR}/usr/include/$$i; \
+ done
+ cd ${DESTDIR}/usr/include && rm -rf ${MACHINE} ${MACHINE_CPU} machine
+ ln -s /sys/arch/${MACHINE}/include ${DESTDIR}/usr/include/${MACHINE}
+ if test ${MACHINE} != ${MACHINE_CPU} -a \
+ -d ../sys/arch/${MACHINE_CPU}/include ; then \
+ ln -s /sys/arch/${MACHINE_CPU}/include \
+ ${DESTDIR}/usr/include/${MACHINE_CPU} ; \
+ fi
+ ln -sf ${MACHINE} ${DESTDIR}/usr/include/machine
+
+includes: ${SYS_INCLUDE}
+
+.PHONY: prereq includes copies symlink
+.include <bsd.prog.mk>
diff --git a/include/a.out.h b/include/a.out.h
new file mode 100644
index 0000000..8191d17
--- /dev/null
+++ b/include/a.out.h
@@ -0,0 +1,44 @@
+/* $OpenBSD: a.out.h,v 1.3 2003/06/02 19:34:12 millert Exp $ */
+/* $NetBSD: a.out.h,v 1.15 1994/10/26 00:55:42 cgd Exp $ */
+
+/*-
+ * Copyright (c) 1993 Theo de Raadt
+ * Copyright (c) 1991 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)a.out.h 5.6 (Berkeley) 4/30/91
+ */
+
+#ifndef _AOUT_H_
+#define _AOUT_H_
+
+#include <sys/exec.h>
+
+#define _AOUT_INCLUDE_
+#include <nlist.h>
+
+#endif /* !_AOUT_H_ */
diff --git a/include/ar.h b/include/ar.h
new file mode 100644
index 0000000..835290b
--- /dev/null
+++ b/include/ar.h
@@ -0,0 +1,66 @@
+/* $OpenBSD: ar.h,v 1.3 2003/06/02 19:34:12 millert Exp $ */
+/* $NetBSD: ar.h,v 1.4 1994/10/26 00:55:43 cgd Exp $ */
+
+/*-
+ * Copyright (c) 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Hugh Smith at The University of Guelph.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)ar.h 8.2 (Berkeley) 1/21/94
+ */
+
+#ifndef _AR_H_
+#define _AR_H_
+
+/* Pre-4BSD archives had these magic numbers in them. */
+#define OARMAG1 0177555
+#define OARMAG2 0177545
+
+#define ARMAG "!<arch>\n" /* ar "magic number" */
+#define SARMAG 8 /* strlen(ARMAG); */
+
+#define AR_EFMT1 "#1/" /* extended format #1 */
+
+struct ar_hdr {
+ char ar_name[16]; /* name */
+ char ar_date[12]; /* modification time */
+ char ar_uid[6]; /* user id */
+ char ar_gid[6]; /* group id */
+ char ar_mode[8]; /* octal file permissions */
+ char ar_size[10]; /* size in bytes */
+#define ARFMAG "`\n"
+ char ar_fmag[2]; /* consistency check */
+};
+
+#endif /* !_AR_H_ */
diff --git a/include/arpa/CVS/Entries b/include/arpa/CVS/Entries
new file mode 100644
index 0000000..386f7f7
--- /dev/null
+++ b/include/arpa/CVS/Entries
@@ -0,0 +1,6 @@
+/ftp.h/1.3/Mon Jun 2 19:34:12 2003//
+/inet.h/1.21/Sat Feb 4 19:16:25 2017//
+/nameser.h/1.14/Fri Mar 16 12:31:09 2018//
+/telnet.h/1.7/Mon Jun 2 19:34:12 2003//
+/tftp.h/1.8/Wed Jul 26 16:43:30 2006//
+D
diff --git a/include/arpa/CVS/Repository b/include/arpa/CVS/Repository
new file mode 100644
index 0000000..f62618c
--- /dev/null
+++ b/include/arpa/CVS/Repository
@@ -0,0 +1 @@
+src/include/arpa
diff --git a/include/arpa/CVS/Root b/include/arpa/CVS/Root
new file mode 100644
index 0000000..3811072
--- /dev/null
+++ b/include/arpa/CVS/Root
@@ -0,0 +1 @@
+/cvs
diff --git a/include/arpa/ftp.h b/include/arpa/ftp.h
new file mode 100644
index 0000000..90703ba
--- /dev/null
+++ b/include/arpa/ftp.h
@@ -0,0 +1,108 @@
+/* $OpenBSD: ftp.h,v 1.3 2003/06/02 19:34:12 millert Exp $ */
+/* $NetBSD: ftp.h,v 1.3 1994/10/26 00:56:43 cgd Exp $ */
+
+/*
+ * Copyright (c) 1983, 1989 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)ftp.h 5.6 (Berkeley) 4/3/91
+ */
+
+#ifndef _FTP_H_
+#define _FTP_H_
+
+/* Definitions for FTP; see RFC-765. */
+
+/*
+ * Reply codes.
+ */
+#define PRELIM 1 /* positive preliminary */
+#define COMPLETE 2 /* positive completion */
+#define CONTINUE 3 /* positive intermediate */
+#define TRANSIENT 4 /* transient negative completion */
+#define ERROR 5 /* permanent negative completion */
+
+/*
+ * Type codes
+ */
+#define TYPE_A 1 /* ASCII */
+#define TYPE_E 2 /* EBCDIC */
+#define TYPE_I 3 /* image */
+#define TYPE_L 4 /* local byte size */
+
+#ifdef FTP_NAMES
+char *typenames[] = {"0", "ASCII", "EBCDIC", "Image", "Local" };
+#endif
+
+/*
+ * Form codes
+ */
+#define FORM_N 1 /* non-print */
+#define FORM_T 2 /* telnet format effectors */
+#define FORM_C 3 /* carriage control (ASA) */
+#ifdef FTP_NAMES
+char *formnames[] = {"0", "Nonprint", "Telnet", "Carriage-control" };
+#endif
+
+/*
+ * Structure codes
+ */
+#define STRU_F 1 /* file (no record structure) */
+#define STRU_R 2 /* record structure */
+#define STRU_P 3 /* page structure */
+#ifdef FTP_NAMES
+char *strunames[] = {"0", "File", "Record", "Page" };
+#endif
+
+/*
+ * Mode types
+ */
+#define MODE_S 1 /* stream */
+#define MODE_B 2 /* block */
+#define MODE_C 3 /* compressed */
+#ifdef FTP_NAMES
+char *modenames[] = {"0", "Stream", "Block", "Compressed" };
+#endif
+
+/*
+ * Record Tokens
+ */
+#define REC_ESC '\377' /* Record-mode Escape */
+#define REC_EOR '\001' /* Record-mode End-of-Record */
+#define REC_EOF '\002' /* Record-mode End-of-File */
+
+/*
+ * Block Header
+ */
+#define BLK_EOR 0x80 /* Block is End-of-Record */
+#define BLK_EOF 0x40 /* Block is End-of-File */
+#define BLK_ERRORS 0x20 /* Block is suspected of containing errors */
+#define BLK_RESTART 0x10 /* Block is Restart Marker */
+
+#define BLK_BYTECOUNT 2 /* Bytes in this block */
+
+#endif /* !_FTP_H_ */
diff --git a/include/arpa/inet.h b/include/arpa/inet.h
new file mode 100644
index 0000000..8d6ac63
--- /dev/null
+++ b/include/arpa/inet.h
@@ -0,0 +1,147 @@
+/* $OpenBSD: inet.h,v 1.21 2017/02/04 19:16:25 guenther Exp $ */
+
+/*
+ * ++Copyright++ 1983, 1993
+ * -
+ * Copyright (c) 1983, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * -
+ * Portions Copyright (c) 1993 by Digital Equipment Corporation.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies, and that
+ * the name of Digital Equipment Corporation not be used in advertising or
+ * publicity pertaining to distribution of the document or software without
+ * specific, written prior permission.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
+ * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ * -
+ * --Copyright--
+ */
+
+/*
+ * @(#)inet.h 8.1 (Berkeley) 6/2/93
+ * $From: inet.h,v 8.6 1996/08/08 06:54:29 vixie Exp $
+ */
+
+#ifndef _INET_H_
+#define _INET_H_
+
+/* External definitions for functions in inet(3) */
+
+#include <sys/cdefs.h>
+#include <sys/_endian.h>
+
+#ifndef htons
+#define htons(x) __htobe16(x)
+#define htonl(x) __htobe32(x)
+#define ntohs(x) __htobe16(x)
+#define ntohl(x) __htobe32(x)
+#endif
+
+#ifndef _UINT16_T_DEFINED_
+#define _UINT16_T_DEFINED_
+typedef __uint16_t uint16_t;
+#endif
+
+#ifndef _UINT32_T_DEFINED_
+#define _UINT32_T_DEFINED_
+typedef __uint32_t uint32_t;
+#endif
+
+#ifndef _SOCKLEN_T_DEFINED_
+#define _SOCKLEN_T_DEFINED_
+typedef __socklen_t socklen_t; /* length type for network syscalls */
+#endif
+
+#ifndef _IN_TYPES_DEFINED_
+#define _IN_TYPES_DEFINED_
+typedef __in_addr_t in_addr_t; /* base type for internet address */
+typedef __in_port_t in_port_t; /* IP port type */
+#endif
+
+/*
+ * Buffer lengths for strings containing printable IP addresses
+ */
+#ifndef INET_ADDRSTRLEN
+#define INET_ADDRSTRLEN 16
+#endif
+#ifndef INET6_ADDRSTRLEN
+#define INET6_ADDRSTRLEN 46
+#endif
+
+#ifndef _IN_ADDR_DECLARED
+#define _IN_ADDR_DECLARED
+/*
+ * IP Version 4 Internet address (a structure for historical reasons)
+ */
+struct in_addr {
+ in_addr_t s_addr;
+};
+#endif
+
+
+#if __BSD_VISIBLE
+/* need this for the non-standard stuff */
+#ifndef _SIZE_T_DEFINED_
+#define _SIZE_T_DEFINED_
+typedef __size_t size_t;
+#endif
+#endif
+
+
+__BEGIN_DECLS
+in_addr_t inet_addr(const char *);
+char *inet_ntoa(struct in_addr);
+const char *inet_ntop(int, const void *__restrict, char *__restrict,
+ socklen_t) __attribute__ ((__bounded__(__string__,3,4)));
+int inet_pton(int, const char *__restrict, void *__restrict);
+
+#if __BSD_VISIBLE
+int inet_aton(const char *, struct in_addr *);
+in_addr_t inet_lnaof(struct in_addr);
+struct in_addr inet_makeaddr(in_addr_t , in_addr_t);
+char * inet_neta(in_addr_t, char *, size_t)
+ __attribute__((__bounded__(__string__,2,3)));
+in_addr_t inet_netof(struct in_addr);
+in_addr_t inet_network(const char *);
+char *inet_net_ntop(int, const void *, int, char *, size_t)
+ __attribute__((__bounded__(__string__,4,5)));
+int inet_net_pton(int, const char *, void *, size_t)
+ __attribute__((__bounded__(__string__,3,4)));
+#endif /* __BSD_VISIBLE */
+__END_DECLS
+
+#endif /* !_INET_H_ */
diff --git a/include/arpa/nameser.h b/include/arpa/nameser.h
new file mode 100644
index 0000000..ead11b7
--- /dev/null
+++ b/include/arpa/nameser.h
@@ -0,0 +1,369 @@
+/* $OpenBSD: nameser.h,v 1.14 2018/03/16 12:31:09 mpi Exp $ */
+
+/*
+ * ++Copyright++ 1983, 1989, 1993
+ * -
+ * Copyright (c) 1983, 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * -
+ * Portions Copyright (c) 1993 by Digital Equipment Corporation.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies, and that
+ * the name of Digital Equipment Corporation not be used in advertising or
+ * publicity pertaining to distribution of the document or software without
+ * specific, written prior permission.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
+ * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ * -
+ * Portions Copyright (c) 1995 by International Business Machines, Inc.
+ *
+ * International Business Machines, Inc. (hereinafter called IBM) grants
+ * permission under its copyrights to use, copy, modify, and distribute this
+ * Software with or without fee, provided that the above copyright notice and
+ * all paragraphs of this notice appear in all copies, and that the name of IBM
+ * not be used in connection with the marketing of any product incorporating
+ * the Software or modifications thereof, without specific, written prior
+ * permission.
+ *
+ * To the extent it has a right to do so, IBM grants an immunity from suit
+ * under its patents, if any, for the use, sale or manufacture of products to
+ * the extent that such products are used for performing Domain Name System
+ * dynamic updates in TCP/IP networks by means of the Software. No immunity is
+ * granted for any product per se or for any other function of any product.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", AND IBM DISCLAIMS ALL WARRANTIES,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL,
+ * DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ARISING
+ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE, EVEN
+ * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ * --Copyright--
+ */
+
+/*
+ * @(#)nameser.h 8.1 (Berkeley) 6/2/93
+ * $From: nameser.h,v 8.11 1996/10/08 04:51:02 vixie Exp $
+ */
+
+#ifndef _NAMESER_H_
+#define _NAMESER_H_
+
+#include <sys/types.h>
+
+/*
+ * revision information. this is the release date in YYYYMMDD format.
+ * it can change every day so the right thing to do with it is use it
+ * in preprocessor commands such as "#if (__BIND > 19931104)". do not
+ * compare for equality; rather, use it to determine whether your resolver
+ * is new enough to contain a certain feature.
+ */
+
+#define __BIND 19960801 /* interface version stamp */
+
+/*
+ * Define constants based on rfc883
+ */
+#define PACKETSZ 512 /* maximum packet size */
+#define MAXDNAME 1025 /* maximum presentation domain name */
+#define MAXCDNAME 255 /* maximum compressed domain name */
+#define MAXLABEL 63 /* maximum length of domain label */
+#define HFIXEDSZ 12 /* #/bytes of fixed data in header */
+#define QFIXEDSZ 4 /* #/bytes of fixed data in query */
+#define RRFIXEDSZ 10 /* #/bytes of fixed data in r record */
+#define INT32SZ 4 /* for systems without 32-bit ints */
+#define INT16SZ 2 /* for systems without 16-bit ints */
+#define INADDRSZ 4 /* IPv4 T_A */
+#define IN6ADDRSZ 16 /* IPv6 T_AAAA */
+
+/*
+ * Internet nameserver port number
+ */
+#define NAMESERVER_PORT 53
+
+/*
+ * Currently defined opcodes
+ */
+#define QUERY 0x0 /* standard query */
+#define IQUERY 0x1 /* inverse query */
+#define STATUS 0x2 /* nameserver status query */
+/*#define xxx 0x3*/ /* 0x3 reserved */
+#define NS_NOTIFY_OP 0x4 /* notify secondary of SOA change */
+/*
+ * Currently defined response codes
+ */
+#define NOERROR 0 /* no error */
+#define FORMERR 1 /* format error */
+#define SERVFAIL 2 /* server failure */
+#define NXDOMAIN 3 /* non existent domain */
+#define NOTIMP 4 /* not implemented */
+#define REFUSED 5 /* query refused */
+
+/*
+ * Type values for resources and queries
+ */
+#define T_A 1 /* host address */
+#define T_NS 2 /* authoritative server */
+#define T_MD 3 /* mail destination */
+#define T_MF 4 /* mail forwarder */
+#define T_CNAME 5 /* canonical name */
+#define T_SOA 6 /* start of authority zone */
+#define T_MB 7 /* mailbox domain name */
+#define T_MG 8 /* mail group member */
+#define T_MR 9 /* mail rename name */
+#define T_NULL 10 /* null resource record */
+#define T_WKS 11 /* well known service */
+#define T_PTR 12 /* domain name pointer */
+#define T_HINFO 13 /* host information */
+#define T_MINFO 14 /* mailbox information */
+#define T_MX 15 /* mail routing information */
+#define T_TXT 16 /* text strings */
+#define T_RP 17 /* responsible person */
+#define T_AFSDB 18 /* AFS cell database */
+#define T_X25 19 /* X_25 calling address */
+#define T_ISDN 20 /* ISDN calling address */
+#define T_RT 21 /* router */
+#define T_NSAP 22 /* NSAP address */
+#define T_NSAP_PTR 23 /* reverse NSAP lookup (deprecated) */
+#define T_SIG 24 /* security signature */
+#define T_KEY 25 /* security key */
+#define T_PX 26 /* X.400 mail mapping */
+#define T_GPOS 27 /* geographical position (withdrawn) */
+#define T_AAAA 28 /* IP6 Address */
+#define T_LOC 29 /* Location Information */
+#define T_NXT 30 /* Next Valid Name in Zone */
+#define T_EID 31 /* Endpoint identifier */
+#define T_NIMLOC 32 /* Nimrod locator */
+#define T_SRV 33 /* Server selection */
+#define T_ATMA 34 /* ATM Address */
+#define T_NAPTR 35 /* Naming Authority PoinTeR */
+#define T_KX 36 /* Key Exchanger */
+#define T_CERT 37 /* CERT */
+#define T_A6 38 /* A6 */
+#define T_DNAME 39 /* DNAME */
+#define T_SINK 40 /* SINK */
+#define T_OPT 41 /* OPT pseudo-RR, RFC2671 */
+#define T_APL 42 /* APL */
+#define T_DS 43 /* Delegation Signer */
+#define T_SSHFP 44 /* SSH Key Fingerprint */
+#define T_RRSIG 46 /* RRSIG */
+#define T_NSEC 47 /* NSEC */
+#define T_DNSKEY 48 /* DNSKEY */
+ /* non standard */
+#define T_UINFO 100 /* user (finger) information */
+#define T_UID 101 /* user ID */
+#define T_GID 102 /* group ID */
+#define T_UNSPEC 103 /* Unspecified format (binary data) */
+ /* Query type values which do not appear in resource records */
+#define T_TKEY 249 /* Transaction Key */
+#define T_TSIG 250 /* Transaction Signature */
+#define T_IXFR 251 /* incremental zone transfer */
+#define T_AXFR 252 /* transfer zone of authority */
+#define T_MAILB 253 /* transfer mailbox records */
+#define T_MAILA 254 /* transfer mail agent records */
+#define T_ANY 255 /* wildcard match */
+
+/*
+ * Values for class field
+ */
+
+#define C_IN 1 /* the arpa internet */
+#define C_CHAOS 3 /* for chaos net (MIT) */
+#define C_HS 4 /* for Hesiod name server (MIT) (XXX) */
+ /* Query class values which do not appear in resource records */
+#define C_ANY 255 /* wildcard match */
+
+/*
+ * Flags field of the KEY RR rdata
+ */
+#define KEYFLAG_TYPEMASK 0xC000 /* Mask for "type" bits */
+#define KEYFLAG_TYPE_AUTH_CONF 0x0000 /* Key usable for both */
+#define KEYFLAG_TYPE_CONF_ONLY 0x8000 /* Key usable for confidentiality */
+#define KEYFLAG_TYPE_AUTH_ONLY 0x4000 /* Key usable for authentication */
+#define KEYFLAG_TYPE_NO_KEY 0xC000 /* No key usable for either; no key */
+/* The type bits can also be interpreted independently, as single bits: */
+#define KEYFLAG_NO_AUTH 0x8000 /* Key not usable for authentication */
+#define KEYFLAG_NO_CONF 0x4000 /* Key not usable for confidentiality */
+
+#define KEYFLAG_EXPERIMENTAL 0x2000 /* Security is *mandatory* if bit=0 */
+#define KEYFLAG_RESERVED3 0x1000 /* reserved - must be zero */
+#define KEYFLAG_RESERVED4 0x0800 /* reserved - must be zero */
+#define KEYFLAG_USERACCOUNT 0x0400 /* key is assoc. with a user acct */
+#define KEYFLAG_ENTITY 0x0200 /* key is assoc. with entity eg host */
+#define KEYFLAG_ZONEKEY 0x0100 /* key is zone key for the zone named */
+#define KEYFLAG_IPSEC 0x0080 /* key is for IPsec use (host or user)*/
+#define KEYFLAG_EMAIL 0x0040 /* key is for email (MIME security) */
+#define KEYFLAG_RESERVED10 0x0020 /* reserved - must be zero */
+#define KEYFLAG_RESERVED11 0x0010 /* reserved - must be zero */
+#define KEYFLAG_SIGNATORYMASK 0x000F /* key can sign DNS RR's of same name */
+
+#define KEYFLAG_RESERVED_BITMASK ( KEYFLAG_RESERVED3 | \
+ KEYFLAG_RESERVED4 | \
+ KEYFLAG_RESERVED10| KEYFLAG_RESERVED11)
+
+/* The Algorithm field of the KEY and SIG RR's is an integer, {1..254} */
+#define ALGORITHM_MD5RSA 1 /* MD5 with RSA */
+#define ALGORITHM_EXPIRE_ONLY 253 /* No alg, no security */
+#define ALGORITHM_PRIVATE_OID 254 /* Key begins with OID indicating alg */
+
+/* Signatures */
+ /* Size of a mod or exp in bits */
+#define MIN_MD5RSA_KEY_PART_BITS 512
+#define MAX_MD5RSA_KEY_PART_BITS 2552
+ /* Total of binary mod and exp, bytes */
+#define MAX_MD5RSA_KEY_BYTES ((MAX_MD5RSA_KEY_PART_BITS+7/8)*2+3)
+ /* Max length of text sig block */
+#define MAX_KEY_BASE64 (((MAX_MD5RSA_KEY_BYTES+2)/3)*4)
+
+/*
+ * EDNS0 Z-field extended flags
+ */
+#define DNS_MESSAGEEXTFLAG_DO 0x8000U
+
+/*
+ * Status return codes for T_UNSPEC conversion routines
+ */
+#define CONV_SUCCESS 0
+#define CONV_OVERFLOW (-1)
+#define CONV_BADFMT (-2)
+#define CONV_BADCKSUM (-3)
+#define CONV_BADBUFLEN (-4)
+
+#if !defined(_BYTE_ORDER) || \
+ (_BYTE_ORDER != _BIG_ENDIAN && _BYTE_ORDER != _LITTLE_ENDIAN && \
+ _BYTE_ORDER != _PDP_ENDIAN)
+ /* you must determine what the correct bit order is for
+ * your compiler - the next line is an intentional error
+ * which will force your compiles to bomb until you fix
+ * the above macros.
+ */
+#error "Undefined or invalid _BYTE_ORDER";
+#endif
+
+/*
+ * Structure for query header. The order of the fields is machine- and
+ * compiler-dependent, depending on the byte/bit order and the layout
+ * of bit fields. We use bit fields only in int variables, as this
+ * is all ANSI requires. This requires a somewhat confusing rearrangement.
+ */
+
+typedef struct {
+ unsigned id :16; /* query identification number */
+#if _BYTE_ORDER == _BIG_ENDIAN
+ /* fields in third byte */
+ unsigned qr: 1; /* response flag */
+ unsigned opcode: 4; /* purpose of message */
+ unsigned aa: 1; /* authoritive answer */
+ unsigned tc: 1; /* truncated message */
+ unsigned rd: 1; /* recursion desired */
+ /* fields in fourth byte */
+ unsigned ra: 1; /* recursion available */
+ unsigned unused :1; /* unused bits (MBZ as of 4.9.3a3) */
+ unsigned ad: 1; /* authentic data from named */
+ unsigned cd: 1; /* checking disabled by resolver */
+ unsigned rcode :4; /* response code */
+#endif
+#if _BYTE_ORDER == _LITTLE_ENDIAN || _BYTE_ORDER == _PDP_ENDIAN
+ /* fields in third byte */
+ unsigned rd :1; /* recursion desired */
+ unsigned tc :1; /* truncated message */
+ unsigned aa :1; /* authoritive answer */
+ unsigned opcode :4; /* purpose of message */
+ unsigned qr :1; /* response flag */
+ /* fields in fourth byte */
+ unsigned rcode :4; /* response code */
+ unsigned cd: 1; /* checking disabled by resolver */
+ unsigned ad: 1; /* authentic data from named */
+ unsigned unused :1; /* unused bits (MBZ as of 4.9.3a3) */
+ unsigned ra :1; /* recursion available */
+#endif
+ /* remaining bytes */
+ unsigned qdcount :16; /* number of question entries */
+ unsigned ancount :16; /* number of answer entries */
+ unsigned nscount :16; /* number of authority entries */
+ unsigned arcount :16; /* number of resource entries */
+} HEADER;
+
+/*
+ * Defines for handling compressed domain names
+ */
+#define INDIR_MASK 0xc0
+
+extern u_int16_t _getshort(const unsigned char *);
+extern u_int32_t _getlong(const unsigned char *);
+
+/*
+ * Inline versions of get/put short/long. Pointer is advanced.
+ *
+ * These macros demonstrate the property of C whereby it can be
+ * portable or it can be elegant but rarely both.
+ */
+#define GETSHORT(s, cp) { \
+ unsigned char *t_cp = (unsigned char *)(cp); \
+ (s) = ((u_int16_t)t_cp[0] << 8) \
+ | ((u_int16_t)t_cp[1]) \
+ ; \
+ (cp) += INT16SZ; \
+}
+
+#define GETLONG(l, cp) { \
+ unsigned char *t_cp = (unsigned char *)(cp); \
+ (l) = ((u_int32_t)t_cp[0] << 24) \
+ | ((u_int32_t)t_cp[1] << 16) \
+ | ((u_int32_t)t_cp[2] << 8) \
+ | ((u_int32_t)t_cp[3]) \
+ ; \
+ (cp) += INT32SZ; \
+}
+
+#define PUTSHORT(s, cp) { \
+ u_int16_t t_s = (u_int16_t)(s); \
+ unsigned char *t_cp = (unsigned char *)(cp); \
+ *t_cp++ = t_s >> 8; \
+ *t_cp = t_s; \
+ (cp) += INT16SZ; \
+}
+
+#define PUTLONG(l, cp) { \
+ u_int32_t t_l = (u_int32_t)(l); \
+ unsigned char *t_cp = (unsigned char *)(cp); \
+ *t_cp++ = t_l >> 24; \
+ *t_cp++ = t_l >> 16; \
+ *t_cp++ = t_l >> 8; \
+ *t_cp = t_l; \
+ (cp) += INT32SZ; \
+}
+
+#endif /* !_NAMESER_H_ */
diff --git a/include/arpa/telnet.h b/include/arpa/telnet.h
new file mode 100644
index 0000000..f8c0cf4
--- /dev/null
+++ b/include/arpa/telnet.h
@@ -0,0 +1,339 @@
+/* $OpenBSD: telnet.h,v 1.7 2003/06/02 19:34:12 millert Exp $ */
+/* $NetBSD: telnet.h,v 1.4 1994/10/26 00:56:46 cgd Exp $ */
+
+/*
+ * Copyright (c) 1983, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)telnet.h 8.1 (Berkeley) 6/2/93
+ */
+
+#ifndef _TELNET_H_
+#define _TELNET_H_
+
+/*
+ * Definitions for the TELNET protocol.
+ */
+#define IAC 255 /* interpret as command: */
+#define DONT 254 /* you are not to use option */
+#define DO 253 /* please, you use option */
+#define WONT 252 /* I won't use option */
+#define WILL 251 /* I will use option */
+#define SB 250 /* interpret as subnegotiation */
+#define GA 249 /* you may reverse the line */
+#define EL 248 /* erase the current line */
+#define EC 247 /* erase the current character */
+#define AYT 246 /* are you there */
+#define AO 245 /* abort output--but let prog finish */
+#define IP 244 /* interrupt process--permanently */
+#define BREAK 243 /* break */
+#define DM 242 /* data mark--for connect. cleaning */
+#define NOP 241 /* nop */
+#define SE 240 /* end sub negotiation */
+#define EOR 239 /* end of record (transparent mode) */
+#define ABORT 238 /* Abort process */
+#define SUSP 237 /* Suspend process */
+#define xEOF 236 /* End of file: EOF is already used... */
+
+#define SYNCH 242 /* for telfunc calls */
+
+#ifdef TELCMDS
+char *telcmds[] = {
+ "EOF", "SUSP", "ABORT", "EOR",
+ "SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC",
+ "EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC",
+ 0
+};
+#else
+extern char *telcmds[];
+#endif
+
+#define TELCMD_FIRST xEOF
+#define TELCMD_LAST IAC
+#define TELCMD_OK(x) ((unsigned int)(x) <= TELCMD_LAST && \
+ (unsigned int)(x) >= TELCMD_FIRST)
+#define TELCMD(x) telcmds[(x)-TELCMD_FIRST]
+
+/* telnet options */
+#define TELOPT_BINARY 0 /* 8-bit data path */
+#define TELOPT_ECHO 1 /* echo */
+#define TELOPT_RCP 2 /* prepare to reconnect */
+#define TELOPT_SGA 3 /* suppress go ahead */
+#define TELOPT_NAMS 4 /* approximate message size */
+#define TELOPT_STATUS 5 /* give status */
+#define TELOPT_TM 6 /* timing mark */
+#define TELOPT_RCTE 7 /* remote controlled transmission and echo */
+#define TELOPT_NAOL 8 /* negotiate about output line width */
+#define TELOPT_NAOP 9 /* negotiate about output page size */
+#define TELOPT_NAOCRD 10 /* negotiate about CR disposition */
+#define TELOPT_NAOHTS 11 /* negotiate about horizontal tabstops */
+#define TELOPT_NAOHTD 12 /* negotiate about horizontal tab disposition */
+#define TELOPT_NAOFFD 13 /* negotiate about formfeed disposition */
+#define TELOPT_NAOVTS 14 /* negotiate about vertical tab stops */
+#define TELOPT_NAOVTD 15 /* negotiate about vertical tab disposition */
+#define TELOPT_NAOLFD 16 /* negotiate about output LF disposition */
+#define TELOPT_XASCII 17 /* extended ascic character set */
+#define TELOPT_LOGOUT 18 /* force logout */
+#define TELOPT_BM 19 /* byte macro */
+#define TELOPT_DET 20 /* data entry terminal */
+#define TELOPT_SUPDUP 21 /* supdup protocol */
+#define TELOPT_SUPDUPOUTPUT 22 /* supdup output */
+#define TELOPT_SNDLOC 23 /* send location */
+#define TELOPT_TTYPE 24 /* terminal type */
+#define TELOPT_EOR 25 /* end or record */
+#define TELOPT_TUID 26 /* TACACS user identification */
+#define TELOPT_OUTMRK 27 /* output marking */
+#define TELOPT_TTYLOC 28 /* terminal location number */
+#define TELOPT_3270REGIME 29 /* 3270 regime */
+#define TELOPT_X3PAD 30 /* X.3 PAD */
+#define TELOPT_NAWS 31 /* window size */
+#define TELOPT_TSPEED 32 /* terminal speed */
+#define TELOPT_LFLOW 33 /* remote flow control */
+#define TELOPT_LINEMODE 34 /* Linemode option */
+#define TELOPT_XDISPLOC 35 /* X Display Location */
+#define TELOPT_OLD_ENVIRON 36 /* Old - Environment variables */
+#define TELOPT_AUTHENTICATION 37/* Authenticate */
+#define TELOPT_ENCRYPT 38 /* Encryption option */
+#define TELOPT_NEW_ENVIRON 39 /* New - Environment variables */
+#define TELOPT_EXOPL 255 /* extended-options-list */
+
+
+#define NTELOPTS (1+TELOPT_NEW_ENVIRON)
+#ifdef TELOPTS
+char *telopts[NTELOPTS+1] = {
+ "BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME",
+ "STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP",
+ "NAOCRD", "NAOHTS", "NAOHTD", "NAOFFD", "NAOVTS",
+ "NAOVTD", "NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO",
+ "DATA ENTRY TERMINAL", "SUPDUP", "SUPDUP OUTPUT",
+ "SEND LOCATION", "TERMINAL TYPE", "END OF RECORD",
+ "TACACS UID", "OUTPUT MARKING", "TTYLOC",
+ "3270 REGIME", "X.3 PAD", "NAWS", "TSPEED", "LFLOW",
+ "LINEMODE", "XDISPLOC", "OLD-ENVIRON", "AUTHENTICATION",
+ "ENCRYPT", "NEW-ENVIRON",
+ 0
+};
+#define TELOPT_FIRST TELOPT_BINARY
+#define TELOPT_LAST TELOPT_NEW_ENVIRON
+#define TELOPT_OK(x) ((unsigned int)(x) <= TELOPT_LAST)
+#define TELOPT(x) telopts[(x)-TELOPT_FIRST]
+#endif
+
+/* sub-option qualifiers */
+#define TELQUAL_IS 0 /* option is... */
+#define TELQUAL_SEND 1 /* send option */
+#define TELQUAL_INFO 2 /* ENVIRON: informational version of IS */
+#define TELQUAL_REPLY 2 /* AUTHENTICATION: client version of IS */
+#define TELQUAL_NAME 3 /* AUTHENTICATION: client version of IS */
+
+#define LFLOW_OFF 0 /* Disable remote flow control */
+#define LFLOW_ON 1 /* Enable remote flow control */
+#define LFLOW_RESTART_ANY 2 /* Restart output on any char */
+#define LFLOW_RESTART_XON 3 /* Restart output only on XON */
+
+/*
+ * LINEMODE suboptions
+ */
+
+#define LM_MODE 1
+#define LM_FORWARDMASK 2
+#define LM_SLC 3
+
+#define MODE_EDIT 0x01
+#define MODE_TRAPSIG 0x02
+#define MODE_ACK 0x04
+#define MODE_SOFT_TAB 0x08
+#define MODE_LIT_ECHO 0x10
+
+#define MODE_MASK 0x1f
+
+/* Not part of protocol, but needed to simplify things... */
+#define MODE_FLOW 0x0100
+#define MODE_ECHO 0x0200
+#define MODE_INBIN 0x0400
+#define MODE_OUTBIN 0x0800
+#define MODE_FORCE 0x1000
+
+#define SLC_SYNCH 1
+#define SLC_BRK 2
+#define SLC_IP 3
+#define SLC_AO 4
+#define SLC_AYT 5
+#define SLC_EOR 6
+#define SLC_ABORT 7
+#define SLC_EOF 8
+#define SLC_SUSP 9
+#define SLC_EC 10
+#define SLC_EL 11
+#define SLC_EW 12
+#define SLC_RP 13
+#define SLC_LNEXT 14
+#define SLC_XON 15
+#define SLC_XOFF 16
+#define SLC_FORW1 17
+#define SLC_FORW2 18
+#define SLC_MCL 19
+#define SLC_MCR 20
+#define SLC_MCWL 21
+#define SLC_MCWR 22
+#define SLC_MCBOL 23
+#define SLC_MCEOL 24
+#define SLC_INSRT 25
+#define SLC_OVER 26
+#define SLC_ECR 27
+#define SLC_EWR 28
+#define SLC_EBOL 29
+#define SLC_EEOL 30
+
+#define NSLC 30
+
+/*
+ * For backwards compatibility, we define SLC_NAMES to be the
+ * list of names if SLC_NAMES is not defined.
+ */
+#define SLC_NAMELIST "0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR", \
+ "ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP", \
+ "LNEXT", "XON", "XOFF", "FORW1", "FORW2", \
+ "MCL", "MCR", "MCWL", "MCWR", "MCBOL", \
+ "MCEOL", "INSRT", "OVER", "ECR", "EWR", \
+ "EBOL", "EEOL", \
+ 0
+
+#ifdef SLC_NAMES
+char *slc_names[] = {
+ SLC_NAMELIST
+};
+#else
+extern char *slc_names[];
+#define SLC_NAMES SLC_NAMELIST
+#endif
+
+#define SLC_NAME_OK(x) ((unsigned)(x) > 0 && (unsigned)(x) <= NSLC)
+#define SLC_NAME(x) slc_names[x]
+
+#define SLC_NOSUPPORT 0
+#define SLC_CANTCHANGE 1
+#define SLC_VARIABLE 2
+#define SLC_DEFAULT 3
+#define SLC_LEVELBITS 0x03
+
+#define SLC_FUNC 0
+#define SLC_FLAGS 1
+#define SLC_VALUE 2
+
+#define SLC_ACK 0x80
+#define SLC_FLUSHIN 0x40
+#define SLC_FLUSHOUT 0x20
+
+#define OLD_ENV_VAR 1
+#define OLD_ENV_VALUE 0
+#define NEW_ENV_VAR 0
+#define NEW_ENV_VALUE 1
+#define ENV_ESC 2
+#define ENV_USERVAR 3
+
+/*
+ * AUTHENTICATION suboptions
+ */
+
+/*
+ * Who is authenticating who ...
+ */
+#define AUTH_WHO_CLIENT 0 /* Client authenticating server */
+#define AUTH_WHO_SERVER 1 /* Server authenticating client */
+#define AUTH_WHO_MASK 1
+
+/*
+ * amount of authentication done
+ */
+#define AUTH_HOW_ONE_WAY 0
+#define AUTH_HOW_MUTUAL 2
+#define AUTH_HOW_MASK 2
+
+#define AUTHTYPE_NULL 0
+#define AUTHTYPE_KERBEROS_V4 1
+#define AUTHTYPE_KERBEROS_V5 2
+#define AUTHTYPE_SPX 3
+#define AUTHTYPE_MINK 4
+#define AUTHTYPE_CNT 5
+
+#define AUTHTYPE_TEST 99
+
+#ifdef AUTH_NAMES
+char *authtype_names[] = {
+ "NULL", "KERBEROS_V4", "KERBEROS_V5", "SPX", "MINK",
+ 0
+};
+#else
+extern char *authtype_names[];
+#endif
+
+#define AUTHTYPE_NAME_OK(x) ((unsigned int)(x) < AUTHTYPE_CNT)
+#define AUTHTYPE_NAME(x) authtype_names[x]
+
+/*
+ * ENCRYPTion suboptions
+ */
+#define ENCRYPT_IS 0 /* I pick encryption type ... */
+#define ENCRYPT_SUPPORT 1 /* I support encryption types ... */
+#define ENCRYPT_REPLY 2 /* Initial setup response */
+#define ENCRYPT_START 3 /* Am starting to send encrypted */
+#define ENCRYPT_END 4 /* Am ending encrypted */
+#define ENCRYPT_REQSTART 5 /* Request you start encrypting */
+#define ENCRYPT_REQEND 6 /* Request you end encrypting */
+#define ENCRYPT_ENC_KEYID 7
+#define ENCRYPT_DEC_KEYID 8
+#define ENCRYPT_CNT 9
+
+#define ENCTYPE_ANY 0
+#define ENCTYPE_DES_CFB64 1
+#define ENCTYPE_DES_OFB64 2
+#define ENCTYPE_CNT 3
+
+#ifdef ENCRYPT_NAMES
+char *encrypt_names[] = {
+ "IS", "SUPPORT", "REPLY", "START", "END",
+ "REQUEST-START", "REQUEST-END", "ENC-KEYID", "DEC-KEYID",
+ 0
+};
+char *enctype_names[] = {
+ "ANY", "DES_CFB64", "DES_OFB64",
+ 0
+};
+#else
+extern char *encrypt_names[];
+extern char *enctype_names[];
+#endif
+
+
+#define ENCRYPT_NAME_OK(x) ((unsigned int)(x) < ENCRYPT_CNT)
+#define ENCRYPT_NAME(x) encrypt_names[x]
+
+#define ENCTYPE_NAME_OK(x) ((unsigned int)(x) < ENCTYPE_CNT)
+#define ENCTYPE_NAME(x) enctype_names[x]
+
+#endif /* !_TELNET_H_ */
diff --git a/include/arpa/tftp.h b/include/arpa/tftp.h
new file mode 100644
index 0000000..c1e6b7e
--- /dev/null
+++ b/include/arpa/tftp.h
@@ -0,0 +1,83 @@
+/* $OpenBSD: tftp.h,v 1.8 2006/07/26 16:43:30 deraadt Exp $ */
+/* $NetBSD: tftp.h,v 1.3 1994/10/26 00:56:48 cgd Exp $ */
+
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)tftp.h 5.4 (Berkeley) 4/3/91
+ */
+
+#ifndef _TFTP_H_
+#define _TFTP_H_
+
+/*
+ * Trivial File Transfer Protocol (IEN-133)
+ */
+#define SEGSIZE 512 /* data segment size */
+#define SEGSIZE_MIN 8 /* minimal data segment size */
+#define SEGSIZE_MAX 65464 /* maximal data segment size */
+
+/*
+ * Packet types.
+ */
+#define RRQ 01 /* read request */
+#define WRQ 02 /* write request */
+#define DATA 03 /* data packet */
+#define ACK 04 /* acknowledgement */
+#define ERROR 05 /* error code */
+#define OACK 06 /* option acknowledgement */
+
+struct tftphdr {
+ u_int16_t th_opcode; /* packet type */
+ union {
+ u_int16_t tu_block; /* block # */
+ u_int16_t tu_code; /* error code */
+ char tu_stuff[1]; /* request packet stuff */
+ } th_u;
+ char th_data[1]; /* data or error string */
+};
+
+#define th_block th_u.tu_block
+#define th_code th_u.tu_code
+#define th_stuff th_u.tu_stuff
+#define th_msg th_data
+
+/*
+ * Error codes.
+ */
+#define EUNDEF 0 /* not defined */
+#define ENOTFOUND 1 /* file not found */
+#define EACCESS 2 /* access violation */
+#define ENOSPACE 3 /* disk full or allocation exceeded */
+#define EBADOP 4 /* illegal TFTP operation */
+#define EBADID 5 /* unknown transfer ID */
+#define EEXISTS 6 /* file already exists */
+#define ENOUSER 7 /* no such user */
+#define EOPTNEG 8 /* option negotiation failed */
+
+#endif /* !_TFTP_H_ */
diff --git a/include/asr.h b/include/asr.h
new file mode 100644
index 0000000..0e38d55
--- /dev/null
+++ b/include/asr.h
@@ -0,0 +1,90 @@
+/* $OpenBSD: asr.h,v 1.2 2019/10/24 05:57:41 otto Exp $ */
+/*
+ * Copyright (c) 2012-2014 Eric Faurot <eric@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/*
+ * Expected fd conditions
+ */
+#define ASR_WANT_READ 1
+#define ASR_WANT_WRITE 2
+
+/*
+ * Structure through which asynchronous query results are returned when
+ * calling asr_run().
+ */
+struct asr_result {
+ /* Fields set if the query is not done yet (asr_run returns 0) */
+ int ar_cond; /* ASR_WANT_READ or ASR_WANT_WRITE */
+ int ar_fd; /* the fd waiting for io condition */
+ int ar_timeout; /* time to wait for in milliseconds */
+
+ /* Error fields. Depends on the query type. */
+ int ar_errno;
+ int ar_h_errno;
+ int ar_gai_errno;
+ int ar_rrset_errno;
+
+ /* Result for res_*_async() calls */
+ int ar_count; /* number of answers in the dns reply */
+ int ar_rcode; /* response code in the dns reply */
+ void *ar_data; /* raw reply packet (must be freed) */
+ int ar_datalen; /* reply packet length */
+ struct sockaddr_storage ar_ns; /* nameserver that responded */
+
+ /* Result for other calls. Must be freed properly. */
+ struct addrinfo *ar_addrinfo;
+ struct rrsetinfo *ar_rrsetinfo;
+ struct hostent *ar_hostent;
+ struct netent *ar_netent;
+};
+
+/*
+ * Asynchronous query management.
+ */
+
+/* Forward declaration. The API uses opaque pointers as query handles. */
+struct asr_query;
+
+void *asr_resolver_from_string(const char *);
+void asr_resolver_free(void *);
+int asr_run(struct asr_query *, struct asr_result *);
+int asr_run_sync(struct asr_query *, struct asr_result *);
+void asr_abort(struct asr_query *);
+
+/*
+ * Asynchronous version of the resolver functions. Similar prototypes, with
+ * an extra context parameter at the end which must currently be set to NULL.
+ * All functions return a handle suitable for use with the management functions
+ * above.
+ */
+struct asr_query *res_send_async(const unsigned char *, int, void *);
+struct asr_query *res_query_async(const char *, int, int, void *);
+struct asr_query *res_search_async(const char *, int, int, void *);
+
+struct asr_query *getrrsetbyname_async(const char *, unsigned int, unsigned int,
+ unsigned int, void *);
+
+struct asr_query *gethostbyname_async(const char *, void *);
+struct asr_query *gethostbyname2_async(const char *, int, void *);
+struct asr_query *gethostbyaddr_async(const void *, socklen_t, int, void *);
+
+struct asr_query *getnetbyname_async(const char *, void *);
+struct asr_query *getnetbyaddr_async(in_addr_t, int, void *);
+
+struct asr_query *getaddrinfo_async(const char *, const char *,
+ const struct addrinfo *, void *);
+struct asr_query *getnameinfo_async(const struct sockaddr *, socklen_t, char *,
+ size_t, char *, size_t, int, void *);
diff --git a/include/assert.h b/include/assert.h
new file mode 100644
index 0000000..c885a13
--- /dev/null
+++ b/include/assert.h
@@ -0,0 +1,68 @@
+/* $OpenBSD: assert.h,v 1.13 2011/06/26 21:11:41 espie Exp $ */
+/* $NetBSD: assert.h,v 1.6 1994/10/26 00:55:44 cgd Exp $ */
+
+/*-
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)assert.h 8.2 (Berkeley) 1/21/94
+ */
+
+/*
+ * Unlike other ANSI header files, <assert.h> may usefully be included
+ * multiple times, with and without NDEBUG defined.
+ */
+
+#include <sys/cdefs.h>
+
+#undef assert
+#undef _assert
+
+#ifdef NDEBUG
+# define assert(e) ((void)0)
+# define _assert(e) ((void)0)
+#else
+# define _assert(e) assert(e)
+# if __ISO_C_VISIBLE >= 1999
+# define assert(e) ((e) ? (void)0 : __assert2(__FILE__, __LINE__, __func__, #e))
+# else
+# define assert(e) ((e) ? (void)0 : __assert(__FILE__, __LINE__, #e))
+# endif
+#endif
+
+#ifndef _ASSERT_H_
+#define _ASSERT_H_
+__BEGIN_DECLS
+__dead void __assert(const char *, int, const char *);
+__dead void __assert2(const char *, int, const char *, const char *);
+__END_DECLS
+#endif
diff --git a/include/bitstring.h b/include/bitstring.h
new file mode 100644
index 0000000..8fc3423
--- /dev/null
+++ b/include/bitstring.h
@@ -0,0 +1,128 @@
+/* $OpenBSD: bitstring.h,v 1.5 2003/06/02 19:34:12 millert Exp $ */
+/* $NetBSD: bitstring.h,v 1.5 1997/05/14 15:49:55 pk Exp $ */
+
+/*
+ * Copyright (c) 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Paul Vixie.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)bitstring.h 8.1 (Berkeley) 7/19/93
+ */
+
+#ifndef _BITSTRING_H_
+#define _BITSTRING_H_
+
+/* modified for SV/AT and bitstring bugfix by M.R.Murphy, 11oct91
+ * bitstr_size changed gratuitously, but shorter
+ * bit_alloc spelling error fixed
+ * the following were efficient, but didn't work, they've been made to
+ * work, but are no longer as efficient :-)
+ * bit_nclear, bit_nset, bit_ffc, bit_ffs
+ */
+typedef unsigned char bitstr_t;
+
+/* internal macros */
+ /* byte of the bitstring bit is in */
+#define _bit_byte(bit) \
+ ((bit) >> 3)
+
+ /* mask for the bit within its byte */
+#define _bit_mask(bit) \
+ (1 << ((bit)&0x7))
+
+/* external macros */
+ /* bytes in a bitstring of nbits bits */
+#define bitstr_size(nbits) \
+ (((nbits) + 7) >> 3)
+
+ /* allocate a bitstring */
+#define bit_alloc(nbits) \
+ (bitstr_t *)calloc((size_t)bitstr_size(nbits), sizeof(bitstr_t))
+
+ /* allocate a bitstring on the stack */
+#define bit_decl(name, nbits) \
+ ((name)[bitstr_size(nbits)])
+
+ /* is bit N of bitstring name set? */
+#define bit_test(name, bit) \
+ ((name)[_bit_byte(bit)] & _bit_mask(bit))
+
+ /* set bit N of bitstring name */
+#define bit_set(name, bit) \
+ ((name)[_bit_byte(bit)] |= _bit_mask(bit))
+
+ /* clear bit N of bitstring name */
+#define bit_clear(name, bit) \
+ ((name)[_bit_byte(bit)] &= ~_bit_mask(bit))
+
+ /* clear bits start ... stop in bitstring */
+#define bit_nclear(name, start, stop) do { \
+ register bitstr_t *_name = name; \
+ register int _start = start, _stop = stop; \
+ while (_start <= _stop) { \
+ bit_clear(_name, _start); \
+ _start++; \
+ } \
+} while(0)
+
+ /* set bits start ... stop in bitstring */
+#define bit_nset(name, start, stop) do { \
+ register bitstr_t *_name = name; \
+ register int _start = start, _stop = stop; \
+ while (_start <= _stop) { \
+ bit_set(_name, _start); \
+ _start++; \
+ } \
+} while(0)
+
+ /* find first bit clear in name */
+#define bit_ffc(name, nbits, value) do { \
+ register bitstr_t *_name = name; \
+ register int _bit, _nbits = nbits, _value = -1; \
+ for (_bit = 0; _bit < _nbits; ++_bit) \
+ if (!bit_test(_name, _bit)) { \
+ _value = _bit; \
+ break; \
+ } \
+ *(value) = _value; \
+} while(0)
+
+ /* find first bit set in name */
+#define bit_ffs(name, nbits, value) do { \
+ register bitstr_t *_name = name; \
+ register int _bit, _nbits = nbits, _value = -1; \
+ for (_bit = 0; _bit < _nbits; ++_bit) \
+ if (bit_test(_name, _bit)) { \
+ _value = _bit; \
+ break; \
+ } \
+ *(value) = _value; \
+} while(0)
+
+#endif /* !_BITSTRING_H_ */
diff --git a/include/blf.h b/include/blf.h
new file mode 100644
index 0000000..ec42b41
--- /dev/null
+++ b/include/blf.h
@@ -0,0 +1,82 @@
+/* $OpenBSD: blf.h,v 1.7 2007/03/14 17:59:41 grunk Exp $ */
+/*
+ * Blowfish - a fast block cipher designed by Bruce Schneier
+ *
+ * Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Niels Provos.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _BLF_H_
+#define _BLF_H_
+
+/* Schneier specifies a maximum key length of 56 bytes.
+ * This ensures that every key bit affects every cipher
+ * bit. However, the subkeys can hold up to 72 bytes.
+ * Warning: For normal blowfish encryption only 56 bytes
+ * of the key affect all cipherbits.
+ */
+
+#define BLF_N 16 /* Number of Subkeys */
+#define BLF_MAXKEYLEN ((BLF_N-2)*4) /* 448 bits */
+#define BLF_MAXUTILIZED ((BLF_N+2)*4) /* 576 bits */
+
+/* Blowfish context */
+typedef struct BlowfishContext {
+ u_int32_t S[4][256]; /* S-Boxes */
+ u_int32_t P[BLF_N + 2]; /* Subkeys */
+} blf_ctx;
+
+/* Raw access to customized Blowfish
+ * blf_key is just:
+ * Blowfish_initstate( state )
+ * Blowfish_expand0state( state, key, keylen )
+ */
+
+void Blowfish_encipher(blf_ctx *, u_int32_t *, u_int32_t *);
+void Blowfish_decipher(blf_ctx *, u_int32_t *, u_int32_t *);
+void Blowfish_initstate(blf_ctx *);
+void Blowfish_expand0state(blf_ctx *, const u_int8_t *, u_int16_t);
+void Blowfish_expandstate
+(blf_ctx *, const u_int8_t *, u_int16_t, const u_int8_t *, u_int16_t);
+
+/* Standard Blowfish */
+
+void blf_key(blf_ctx *, const u_int8_t *, u_int16_t);
+void blf_enc(blf_ctx *, u_int32_t *, u_int16_t);
+void blf_dec(blf_ctx *, u_int32_t *, u_int16_t);
+
+void blf_ecb_encrypt(blf_ctx *, u_int8_t *, u_int32_t);
+void blf_ecb_decrypt(blf_ctx *, u_int8_t *, u_int32_t);
+
+void blf_cbc_encrypt(blf_ctx *, u_int8_t *, u_int8_t *, u_int32_t);
+void blf_cbc_decrypt(blf_ctx *, u_int8_t *, u_int8_t *, u_int32_t);
+
+/* Converts u_int8_t to u_int32_t */
+u_int32_t Blowfish_stream2word(const u_int8_t *, u_int16_t , u_int16_t *);
+
+#endif
diff --git a/include/bsd_auth.h b/include/bsd_auth.h
new file mode 100644
index 0000000..19c5fbc
--- /dev/null
+++ b/include/bsd_auth.h
@@ -0,0 +1,105 @@
+/* $OpenBSD: bsd_auth.h,v 1.11 2017/03/09 10:13:03 fcambus Exp $ */
+
+/*-
+ * Copyright (c) 1997 Berkeley Software Design, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Berkeley Software Design,
+ * Inc.
+ * 4. The name of Berkeley Software Design, Inc. may not be used to endorse
+ * or promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN, INC. ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL BERKELEY SOFTWARE DESIGN, INC. BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * BSDI $From: bsd_auth.h,v 2.3 1999/09/08 22:13:08 prb Exp $
+ */
+
+#ifndef _BSD_AUTH_H_
+#define _BSD_AUTH_H_
+
+#include <machine/_types.h> /* for __va_list */
+
+typedef struct auth_session_t auth_session_t;
+
+typedef enum {
+ AUTHV_ALL,
+ AUTHV_CHALLENGE,
+ AUTHV_CLASS,
+ AUTHV_NAME,
+ AUTHV_SERVICE,
+ AUTHV_STYLE,
+ AUTHV_INTERACTIVE
+} auth_item_t;
+
+#include <sys/cdefs.h>
+__BEGIN_DECLS
+struct passwd;
+struct login_cap;
+
+char *auth_getitem(auth_session_t *, auth_item_t);
+int auth_setitem(auth_session_t *, auth_item_t, char *);
+
+auth_session_t *auth_open(void);
+auth_session_t *auth_verify(auth_session_t *, char *, char *, ...)
+ __attribute__((__sentinel__));
+
+auth_session_t *auth_userchallenge(char *, char *, char *, char **);
+auth_session_t *auth_usercheck(char *, char *, char *, char *);
+
+int auth_userresponse(auth_session_t *, char *, int);
+int auth_userokay(char *, char *, char *, char *);
+int auth_approval(auth_session_t *, struct login_cap *, char *, char *);
+
+int auth_close(auth_session_t *);
+void auth_clean(auth_session_t *);
+
+char *auth_getvalue(auth_session_t *, char *);
+int auth_getstate(auth_session_t *);
+char *auth_challenge(auth_session_t *);
+void auth_setenv(auth_session_t *);
+void auth_clrenv(auth_session_t *);
+
+void auth_setstate(auth_session_t *, int);
+int auth_call(auth_session_t *, char *, ...)
+ __attribute__((__sentinel__));
+
+int auth_setdata(auth_session_t *, void *, size_t);
+int auth_setoption(auth_session_t *, char *, char *);
+int auth_setpwd(auth_session_t *, struct passwd *);
+void auth_set_va_list(auth_session_t *, __va_list);
+
+struct passwd *auth_getpwd(auth_session_t *);
+
+quad_t auth_check_expire(auth_session_t *);
+quad_t auth_check_change(auth_session_t *);
+
+void auth_clroptions(auth_session_t *);
+void auth_clroption(auth_session_t *, char *);
+
+char *auth_mkvalue(char *);
+void auth_checknologin(struct login_cap *);
+int auth_cat(char *);
+
+__END_DECLS
+
+#endif /* _BSD_AUTH_H_ */
diff --git a/include/complex.h b/include/complex.h
new file mode 100644
index 0000000..b29f5a7
--- /dev/null
+++ b/include/complex.h
@@ -0,0 +1,120 @@
+/* $OpenBSD: complex.h,v 1.5 2014/03/16 18:38:30 guenther Exp $ */
+/*
+ * Copyright (c) 2008 Martynas Venckus <martynas@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef _COMPLEX_H_
+#define _COMPLEX_H_
+
+#include <sys/cdefs.h>
+
+/*
+ * C99
+ */
+#ifdef __GNUC__
+#if __STDC_VERSION__ < 199901
+#define _Complex __complex__
+#endif
+#define _Complex_I 1.0fi
+#endif
+
+#define complex _Complex
+
+/* XXX switch to _Imaginary_I */
+#undef I
+#define I _Complex_I
+
+__BEGIN_DECLS
+/*
+ * Double versions of C99 functions
+ */
+double complex cacos(double complex);
+double complex casin(double complex);
+double complex catan(double complex);
+double complex ccos(double complex);
+double complex csin(double complex);
+double complex ctan(double complex);
+double complex cacosh(double complex);
+double complex casinh(double complex);
+double complex catanh(double complex);
+double complex ccosh(double complex);
+double complex csinh(double complex);
+double complex ctanh(double complex);
+double complex cexp(double complex);
+double complex clog(double complex);
+double cabs(double complex);
+double complex cpow(double complex, double complex);
+double complex csqrt(double complex);
+double carg(double complex);
+double cimag(double complex);
+double complex conj(double complex);
+double complex cproj(double complex);
+double creal(double complex);
+
+/*
+ * Float versions of C99 functions
+ */
+float complex cacosf(float complex);
+float complex casinf(float complex);
+float complex catanf(float complex);
+float complex ccosf(float complex);
+float complex csinf(float complex);
+float complex ctanf(float complex);
+float complex cacoshf(float complex);
+float complex casinhf(float complex);
+float complex catanhf(float complex);
+float complex ccoshf(float complex);
+float complex csinhf(float complex);
+float complex ctanhf(float complex);
+float complex cexpf(float complex);
+float complex clogf(float complex);
+float cabsf(float complex);
+float complex cpowf(float complex, float complex);
+float complex csqrtf(float complex);
+float cargf(float complex);
+float cimagf(float complex);
+float complex conjf(float complex);
+float complex cprojf(float complex);
+float crealf(float complex);
+
+/*
+ * Long double versions of C99 functions
+ */
+long double complex cacosl(long double complex);
+long double complex casinl(long double complex);
+long double complex catanl(long double complex);
+long double complex ccosl(long double complex);
+long double complex csinl(long double complex);
+long double complex ctanl(long double complex);
+long double complex cacoshl(long double complex);
+long double complex casinhl(long double complex);
+long double complex catanhl(long double complex);
+long double complex ccoshl(long double complex);
+long double complex csinhl(long double complex);
+long double complex ctanhl(long double complex);
+long double complex cexpl(long double complex);
+long double complex clogl(long double complex);
+long double cabsl(long double complex);
+long double complex cpowl(long double complex,
+ long double complex);
+long double complex csqrtl(long double complex);
+long double cargl(long double complex);
+long double cimagl(long double complex);
+long double complex conjl(long double complex);
+long double complex cprojl(long double complex);
+long double creall(long double complex);
+__END_DECLS
+
+#endif /* !_COMPLEX_H_ */
diff --git a/include/cpio.h b/include/cpio.h
new file mode 100644
index 0000000..c38d59f
--- /dev/null
+++ b/include/cpio.h
@@ -0,0 +1,59 @@
+/* $OpenBSD: cpio.h,v 1.3 2008/06/26 05:42:04 ray Exp $ */
+/* $NetBSD: cpio.h,v 1.1 1996/02/05 22:34:11 jtc Exp $ */
+
+/*-
+ * Copyright (c) 1996 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by J.T. Conklin.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _CPIO_H_
+#define _CPIO_H_
+
+#define C_IRUSR 0000400
+#define C_IWUSR 0000200
+#define C_IXUSR 0000100
+#define C_IRGRP 0000040
+#define C_IWGRP 0000020
+#define C_IXGRP 0000010
+#define C_IROTH 0000004
+#define C_IWOTH 0000002
+#define C_IXOTH 0000001
+#define C_ISUID 0004000
+#define C_ISGID 0002000
+#define C_ISVTX 0001000
+#define C_ISDIR 0040000
+#define C_ISFIFO 0010000
+#define C_ISREG 0100000
+#define C_ISBLK 0060000
+#define C_ISCHR 0020000
+#define C_ISCTG 0110000
+#define C_ISLNK 0120000
+#define C_ISSOCK 0140000
+
+#define MAGIC "070707"
+
+#endif /* _CPIO_H_ */
diff --git a/include/ctype.h b/include/ctype.h
new file mode 100644
index 0000000..e90d375
--- /dev/null
+++ b/include/ctype.h
@@ -0,0 +1,304 @@
+/* $OpenBSD: ctype.h,v 1.25 2017/09/05 03:16:13 schwarze Exp $ */
+/* $NetBSD: ctype.h,v 1.14 1994/10/26 00:55:47 cgd Exp $ */
+
+/*
+ * Copyright (c) 1989 The Regents of the University of California.
+ * All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)ctype.h 5.3 (Berkeley) 4/3/91
+ */
+
+#ifndef _CTYPE_H_
+#define _CTYPE_H_
+
+#include <sys/cdefs.h>
+
+#define _U 0x01
+#define _L 0x02
+#define _N 0x04
+#define _S 0x08
+#define _P 0x10
+#define _C 0x20
+#define _X 0x40
+#define _B 0x80
+
+#if __POSIX_VISIBLE >= 200809
+#ifndef _LOCALE_T_DEFINED_
+#define _LOCALE_T_DEFINED_
+typedef void *locale_t;
+#endif
+#endif
+
+__BEGIN_DECLS
+
+extern const char *_ctype_;
+extern const short *_tolower_tab_;
+extern const short *_toupper_tab_;
+
+#if defined(__GNUC__) || defined(_ANSI_LIBRARY)
+int isalnum(int);
+int isalpha(int);
+int iscntrl(int);
+int isdigit(int);
+int isgraph(int);
+int islower(int);
+int isprint(int);
+int ispunct(int);
+int isspace(int);
+int isupper(int);
+int isxdigit(int);
+int tolower(int);
+int toupper(int);
+
+#if __BSD_VISIBLE || __ISO_C_VISIBLE >= 1999 || __POSIX_VISIBLE > 200112 \
+ || __XPG_VISIBLE > 600
+int isblank(int);
+#endif
+
+#if __BSD_VISIBLE || __XPG_VISIBLE
+int isascii(int);
+int toascii(int);
+int _tolower(int);
+int _toupper(int);
+#endif /* __BSD_VISIBLE || __XPG_VISIBLE */
+
+#if __POSIX_VISIBLE >= 200809
+int isalnum_l(int, locale_t);
+int isalpha_l(int, locale_t);
+int isblank_l(int, locale_t);
+int iscntrl_l(int, locale_t);
+int isdigit_l(int, locale_t);
+int isgraph_l(int, locale_t);
+int islower_l(int, locale_t);
+int isprint_l(int, locale_t);
+int ispunct_l(int, locale_t);
+int isspace_l(int, locale_t);
+int isupper_l(int, locale_t);
+int isxdigit_l(int, locale_t);
+int tolower_l(int, locale_t);
+int toupper_l(int, locale_t);
+#endif
+
+#endif /* __GNUC__ || _ANSI_LIBRARY */
+
+#if !defined(_ANSI_LIBRARY) && !defined(__cplusplus)
+
+__only_inline int isalnum(int _c)
+{
+ return (_c == -1 ? 0 : ((_ctype_ + 1)[(unsigned char)_c] & (_U|_L|_N)));
+}
+
+__only_inline int isalpha(int _c)
+{
+ return (_c == -1 ? 0 : ((_ctype_ + 1)[(unsigned char)_c] & (_U|_L)));
+}
+
+__only_inline int iscntrl(int _c)
+{
+ return (_c == -1 ? 0 : ((_ctype_ + 1)[(unsigned char)_c] & _C));
+}
+
+__only_inline int isdigit(int _c)
+{
+ return (_c == -1 ? 0 : ((_ctype_ + 1)[(unsigned char)_c] & _N));
+}
+
+__only_inline int isgraph(int _c)
+{
+ return (_c == -1 ? 0 : ((_ctype_ + 1)[(unsigned char)_c] & (_P|_U|_L|_N)));
+}
+
+__only_inline int islower(int _c)
+{
+ return (_c == -1 ? 0 : ((_ctype_ + 1)[(unsigned char)_c] & _L));
+}
+
+__only_inline int isprint(int _c)
+{
+ return (_c == -1 ? 0 : ((_ctype_ + 1)[(unsigned char)_c] & (_P|_U|_L|_N|_B)));
+}
+
+__only_inline int ispunct(int _c)
+{
+ return (_c == -1 ? 0 : ((_ctype_ + 1)[(unsigned char)_c] & _P));
+}
+
+__only_inline int isspace(int _c)
+{
+ return (_c == -1 ? 0 : ((_ctype_ + 1)[(unsigned char)_c] & _S));
+}
+
+__only_inline int isupper(int _c)
+{
+ return (_c == -1 ? 0 : ((_ctype_ + 1)[(unsigned char)_c] & _U));
+}
+
+__only_inline int isxdigit(int _c)
+{
+ return (_c == -1 ? 0 : ((_ctype_ + 1)[(unsigned char)_c] & (_N|_X)));
+}
+
+__only_inline int tolower(int _c)
+{
+ if ((unsigned int)_c > 255)
+ return (_c);
+ return ((_tolower_tab_ + 1)[_c]);
+}
+
+__only_inline int toupper(int _c)
+{
+ if ((unsigned int)_c > 255)
+ return (_c);
+ return ((_toupper_tab_ + 1)[_c]);
+}
+
+#if __BSD_VISIBLE || __ISO_C_VISIBLE >= 1999 || __POSIX_VISIBLE > 200112 \
+ || __XPG_VISIBLE > 600
+__only_inline int isblank(int _c)
+{
+ return (_c == ' ' || _c == '\t');
+}
+#endif
+
+#if __BSD_VISIBLE || __XPG_VISIBLE
+__only_inline int isascii(int _c)
+{
+ return ((unsigned int)_c <= 0177);
+}
+
+__only_inline int toascii(int _c)
+{
+ return (_c & 0177);
+}
+
+__only_inline int _tolower(int _c)
+{
+ return (_c - 'A' + 'a');
+}
+
+__only_inline int _toupper(int _c)
+{
+ return (_c - 'a' + 'A');
+}
+#endif /* __BSD_VISIBLE || __XPG_VISIBLE */
+
+#if __POSIX_VISIBLE >= 200809
+__only_inline int
+isalnum_l(int _c, locale_t _l __attribute__((__unused__)))
+{
+ return isalnum(_c);
+}
+
+__only_inline int
+isalpha_l(int _c, locale_t _l __attribute__((__unused__)))
+{
+ return isalpha(_c);
+}
+
+__only_inline int
+isblank_l(int _c, locale_t _l __attribute__((__unused__)))
+{
+ return isblank(_c);
+}
+
+__only_inline int
+iscntrl_l(int _c, locale_t _l __attribute__((__unused__)))
+{
+ return iscntrl(_c);
+}
+
+__only_inline int
+isdigit_l(int _c, locale_t _l __attribute__((__unused__)))
+{
+ return isdigit(_c);
+}
+
+__only_inline int
+isgraph_l(int _c, locale_t _l __attribute__((__unused__)))
+{
+ return isgraph(_c);
+}
+
+__only_inline int
+islower_l(int _c, locale_t _l __attribute__((__unused__)))
+{
+ return islower(_c);
+}
+
+__only_inline int
+isprint_l(int _c, locale_t _l __attribute__((__unused__)))
+{
+ return isprint(_c);
+}
+
+__only_inline int
+ispunct_l(int _c, locale_t _l __attribute__((__unused__)))
+{
+ return ispunct(_c);
+}
+
+__only_inline int
+isspace_l(int _c, locale_t _l __attribute__((__unused__)))
+{
+ return isspace(_c);
+}
+
+__only_inline int
+isupper_l(int _c, locale_t _l __attribute__((__unused__)))
+{
+ return isupper(_c);
+}
+
+__only_inline int
+isxdigit_l(int _c, locale_t _l __attribute__((__unused__)))
+{
+ return isxdigit(_c);
+}
+
+__only_inline int
+tolower_l(int _c, locale_t _l __attribute__((__unused__)))
+{
+ return tolower(_c);
+}
+
+__only_inline int
+toupper_l(int _c, locale_t _l __attribute__((__unused__)))
+{
+ return toupper(_c);
+}
+#endif /* __POSIX_VISIBLE >= 200809 */
+
+#endif /* !_ANSI_LIBRARY */
+
+__END_DECLS
+
+#endif /* !_CTYPE_H_ */
diff --git a/include/curses.h b/include/curses.h
new file mode 100644
index 0000000..8105fb7
--- /dev/null
+++ b/include/curses.h
@@ -0,0 +1,13 @@
+/* $OpenBSD: curses.h,v 1.5 2019/01/25 00:19:25 millert Exp $ */
+
+/*
+ * Placed in the public domain by Todd C. Miller <millert@openbsd.org>
+ * on June 17, 2003.
+ */
+
+#ifndef _CURSES_H_
+#define _CURSES_H_
+
+#include <ncurses.h>
+
+#endif /* _CURSES_H_ */
diff --git a/include/db.h b/include/db.h
new file mode 100644
index 0000000..4381efe
--- /dev/null
+++ b/include/db.h
@@ -0,0 +1,161 @@
+/* $OpenBSD: db.h,v 1.12 2015/10/17 21:48:42 guenther Exp $ */
+/* $NetBSD: db.h,v 1.13 1994/10/26 00:55:48 cgd Exp $ */
+
+/*-
+ * Copyright (c) 1990, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)db.h 8.7 (Berkeley) 6/16/94
+ */
+
+#ifndef _DB_H_
+#define _DB_H_
+
+#include <sys/types.h>
+
+#include <limits.h>
+
+#define RET_ERROR -1 /* Return values. */
+#define RET_SUCCESS 0
+#define RET_SPECIAL 1
+
+#define MAX_PAGE_NUMBER 0xffffffff /* >= # of pages in a file */
+typedef u_int32_t pgno_t;
+#define MAX_PAGE_OFFSET 65535 /* >= # of bytes in a page */
+typedef u_int16_t indx_t;
+#define MAX_REC_NUMBER 0xffffffff /* >= # of records in a tree */
+typedef u_int32_t recno_t;
+
+/* Key/data structure -- a Data-Base Thang. */
+typedef struct {
+ void *data; /* data */
+ size_t size; /* data length */
+} DBT;
+
+/* Routine flags. */
+#define R_CURSOR 1 /* del, put, seq */
+#define __R_UNUSED 2 /* UNUSED */
+#define R_FIRST 3 /* seq */
+#define R_IAFTER 4 /* put (RECNO) */
+#define R_IBEFORE 5 /* put (RECNO) */
+#define R_LAST 6 /* seq (BTREE, RECNO) */
+#define R_NEXT 7 /* seq */
+#define R_NOOVERWRITE 8 /* put */
+#define R_PREV 9 /* seq (BTREE, RECNO) */
+#define R_SETCURSOR 10 /* put (RECNO) */
+#define R_RECNOSYNC 11 /* sync (RECNO) */
+
+typedef enum { DB_BTREE, DB_HASH, DB_RECNO } DBTYPE;
+
+/*
+ * !!!
+ * The following flags are included in the dbopen(3) call as part of the
+ * open(2) flags. In order to avoid conflicts with the open flags, start
+ * at the top of the 16 or 32-bit number space and work our way down. If
+ * the open flags were significantly expanded in the future, it could be
+ * a problem. Wish I'd left another flags word in the dbopen call.
+ *
+ * !!!
+ * None of this stuff is implemented yet. The only reason that it's here
+ * is so that the access methods can skip copying the key/data pair when
+ * the DB_LOCK flag isn't set.
+ */
+#if UINT_MAX > 65535
+#define DB_LOCK 0x20000000 /* Do locking. */
+#define DB_SHMEM 0x40000000 /* Use shared memory. */
+#define DB_TXN 0x80000000 /* Do transactions. */
+#else
+#define DB_LOCK 0x2000 /* Do locking. */
+#define DB_SHMEM 0x4000 /* Use shared memory. */
+#define DB_TXN 0x8000 /* Do transactions. */
+#endif
+
+/* Access method description structure. */
+typedef struct __db {
+ DBTYPE type; /* Underlying db type. */
+ int (*close)(struct __db *);
+ int (*del)(const struct __db *, const DBT *, unsigned int);
+ int (*get)(const struct __db *, const DBT *, DBT *, unsigned int);
+ int (*put)(const struct __db *, DBT *, const DBT *, unsigned int);
+ int (*seq)(const struct __db *, DBT *, DBT *, unsigned int);
+ int (*sync)(const struct __db *, unsigned int);
+ void *internal; /* Access method private. */
+ int (*fd)(const struct __db *);
+} DB;
+
+#define BTREEMAGIC 0x053162
+#define BTREEVERSION 3
+
+/* Structure used to pass parameters to the btree routines. */
+typedef struct {
+#define R_DUP 0x01 /* duplicate keys */
+ unsigned long flags;
+ unsigned int cachesize; /* bytes to cache */
+ int maxkeypage; /* maximum keys per page */
+ int minkeypage; /* minimum keys per page */
+ unsigned int psize; /* page size */
+ int (*compare) /* comparison function */
+ (const DBT *, const DBT *);
+ size_t (*prefix) /* prefix function */
+ (const DBT *, const DBT *);
+ int lorder; /* byte order */
+} BTREEINFO;
+
+#define HASHMAGIC 0x061561
+#define HASHVERSION 2
+
+/* Structure used to pass parameters to the hashing routines. */
+typedef struct {
+ unsigned int bsize; /* bucket size */
+ unsigned int ffactor; /* fill factor */
+ unsigned int nelem; /* number of elements */
+ unsigned int cachesize; /* bytes to cache */
+ u_int32_t /* hash function */
+ (*hash)(const void *, size_t);
+ int lorder; /* byte order */
+} HASHINFO;
+
+/* Structure used to pass parameters to the record routines. */
+typedef struct {
+#define R_FIXEDLEN 0x01 /* fixed-length records */
+#define R_NOKEY 0x02 /* key not required */
+#define R_SNAPSHOT 0x04 /* snapshot the input */
+ unsigned long flags;
+ unsigned int cachesize; /* bytes to cache */
+ unsigned int psize; /* page size */
+ int lorder; /* byte order */
+ size_t reclen; /* record length
+ (fixed-length records) */
+ unsigned char bval; /* delimiting byte
+ (variable-length records) */
+ char *bfname; /* btree file name */
+} RECNOINFO;
+
+__BEGIN_DECLS
+DB *dbopen(const char *, int, int, DBTYPE, const void *);
+__END_DECLS
+#endif /* !_DB_H_ */
diff --git a/include/dirent.h b/include/dirent.h
new file mode 100644
index 0000000..61a5e01
--- /dev/null
+++ b/include/dirent.h
@@ -0,0 +1,104 @@
+/* $OpenBSD: dirent.h,v 1.34 2016/09/09 18:12:37 millert Exp $ */
+/* $NetBSD: dirent.h,v 1.9 1995/03/26 20:13:37 jtc Exp $ */
+
+/*-
+ * Copyright (c) 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)dirent.h 8.2 (Berkeley) 7/28/94
+ */
+
+#ifndef _DIRENT_H_
+#define _DIRENT_H_
+
+#include <sys/cdefs.h>
+
+/*
+ * POSIX doesn't mandate this, but X/Open XPG 4.2 does.
+ */
+#if __BSD_VISIBLE || __XPG_VISIBLE >= 400
+#include <sys/types.h>
+#else
+#include <sys/_types.h>
+#endif
+
+/*
+ * The kernel defines the format of directory entries returned by
+ * the getdents(2) system call.
+ */
+#include <sys/dirent.h>
+
+#if __BSD_VISIBLE || __XPG_VISIBLE
+#define d_ino d_fileno /* backward compatibility */
+#endif
+
+typedef struct _dirdesc DIR;
+
+#if __BSD_VISIBLE
+
+/* definitions for library routines operating on directories. */
+#define DIRBLKSIZ 1024
+
+#include <sys/_null.h>
+
+#endif /* __BSD_VISIBLE */
+
+__BEGIN_DECLS
+DIR *opendir(const char *);
+#if __POSIX_VISIBLE >= 200809
+DIR *fdopendir(int);
+#endif
+struct dirent *readdir(DIR *);
+void rewinddir(DIR *);
+int closedir(DIR *);
+#if __BSD_VISIBLE
+int getdents(int, void *, size_t)
+ __attribute__ ((__bounded__(__string__,2,3)));
+#endif /* __BSD_VISIBLE */
+#if __XPG_VISIBLE
+long telldir(DIR *);
+void seekdir(DIR *, long);
+#endif
+#if __POSIX_VISIBLE >= 199506 || __XPG_VISIBLE >= 500
+int readdir_r(DIR *__restrict, struct dirent *__restrict,
+ struct dirent **__restrict);
+#endif
+#if __POSIX_VISIBLE >= 200809
+int scandir(const char *, struct dirent ***, int (*)(const struct dirent *),
+ int (*)(const struct dirent **, const struct dirent **));
+int alphasort(const struct dirent **, const struct dirent **);
+#elif __BSD_VISIBLE
+int scandir(const char *, struct dirent ***, int (*)(struct dirent *),
+ int (*)(const void *, const void *));
+int alphasort(const void *, const void *);
+#endif
+#if __POSIX_VISIBLE >= 200809 || __XPG_VISIBLE > 600
+int dirfd(DIR *);
+#endif
+__END_DECLS
+
+#endif /* !_DIRENT_H_ */
diff --git a/include/disktab.h b/include/disktab.h
new file mode 100644
index 0000000..4a1b8ec
--- /dev/null
+++ b/include/disktab.h
@@ -0,0 +1,60 @@
+/* $OpenBSD: disktab.h,v 1.3 2003/06/02 19:34:12 millert Exp $ */
+/* $NetBSD: disktab.h,v 1.3 1994/10/26 00:55:51 cgd Exp $ */
+
+/*
+ * Copyright (c) 1983 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)disktab.h 5.6 (Berkeley) 4/20/91
+ */
+
+#ifndef _DISKTAB_H_
+#define _DISKTAB_H_
+
+/*
+ * Disk description table, see disktab(5)
+ */
+#define DISKTAB "/etc/disktab"
+
+struct disktab {
+ char *d_name; /* drive name */
+ char *d_type; /* drive type */
+ int d_secsize; /* sector size in bytes */
+ int d_ntracks; /* # tracks/cylinder */
+ int d_nsectors; /* # sectors/track */
+ int d_ncylinders; /* # cylinders */
+ int d_rpm; /* revolutions/minute */
+ int d_badsectforw; /* supports DEC bad144 std */
+ int d_sectoffset; /* use sect rather than cyl offsets */
+ struct partition {
+ int p_size; /* #sectors in partition */
+ short p_bsize; /* block size in bytes */
+ short p_fsize; /* frag size in bytes */
+ } d_partitions[8];
+};
+
+#endif /* !_DISKTAB_H_ */
diff --git a/include/dlfcn.h b/include/dlfcn.h
new file mode 100644
index 0000000..431065f
--- /dev/null
+++ b/include/dlfcn.h
@@ -0,0 +1,98 @@
+/* $OpenBSD: dlfcn.h,v 1.14 2017/11/28 17:19:47 kettenis Exp $ */
+/* $NetBSD: dlfcn.h,v 1.2 1995/06/05 19:38:00 pk Exp $ */
+
+/*
+ * Copyright (c) 1995 Paul Kranenburg
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Paul Kranenburg.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _DLFCN_H_
+#define _DLFCN_H_
+
+#include <sys/cdefs.h>
+
+/* Values for dlopen `mode'. */
+#define RTLD_LAZY 1
+#define RTLD_NOW 2
+#define RTLD_GLOBAL 0x100
+#define RTLD_LOCAL 0x000
+#define RTLD_TRACE 0x200
+
+/*
+ * Special handle arguments for dlsym().
+ */
+#define RTLD_NEXT ((void *) -1) /* Search subsequent objects. */
+#define RTLD_DEFAULT ((void *) -2) /* Use default search algorithm. */
+#define RTLD_SELF ((void *) -3) /* Search the caller itself. */
+
+#if __BSD_VISIBLE
+
+/*
+ * Structure filled in by dladdr().
+ */
+typedef struct dl_info {
+ const char *dli_fname; /* Pathname of shared object. */
+ void *dli_fbase; /* Base address of shared object. */
+ const char *dli_sname; /* Name of nearest symbol. */
+ void *dli_saddr; /* Address of nearest symbol. */
+} Dl_info;
+
+/*
+ * dlctl() commands
+ */
+#define DL_GETERRNO 1
+#define DL_SETSRCHPATH x
+#define DL_GETLIST x
+#define DL_GETREFCNT x
+#define DL_GETLOADADDR x
+#define DL_SETTHREADLCK 2
+#define DL_SETBINDLCK 3
+#define DL_REFERENCE 4
+
+#define DL_LAZY RTLD_LAZY /* Compat */
+
+#endif /* __BSD_VISIBLE */
+
+
+/*
+ * User interface to the run-time linker.
+ */
+__BEGIN_DECLS
+void *dlopen(const char *, int);
+int dlclose(void *);
+void *dlsym(void *__restrict, const char *__restrict);
+char *dlerror(void);
+
+#if __BSD_VISIBLE
+int dladdr(const void *, Dl_info *);
+int dlctl(void *, int, void *);
+#endif /* __BSD_VISIBLE */
+
+__END_DECLS
+
+#endif /* _DLFCN_H_ */
diff --git a/include/elf.h b/include/elf.h
new file mode 100644
index 0000000..8b1273e
--- /dev/null
+++ b/include/elf.h
@@ -0,0 +1,12 @@
+/* $OpenBSD: elf.h,v 1.1 2017/10/17 09:34:52 mpi Exp $ */
+
+/*
+ * Public domain.
+ */
+
+#ifndef _ELF_H_
+#define _ELF_H_
+
+#include <sys/exec_elf.h>
+
+#endif /* _ELF_H_ */
diff --git a/include/elf_abi.h b/include/elf_abi.h
new file mode 100644
index 0000000..489869b
--- /dev/null
+++ b/include/elf_abi.h
@@ -0,0 +1,33 @@
+/* $OpenBSD: elf_abi.h,v 1.4 1996/05/22 07:46:22 etheisen Exp $ */
+/*
+ * Copyright (c) 1996 Erik Theisen
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef _ELF_ABI_H_
+#define _ELF_ABI_H_
+
+#include <sys/exec_elf.h>
+
+#endif /* _ELF_ABI_H_ */
diff --git a/include/err.h b/include/err.h
new file mode 100644
index 0000000..c537811
--- /dev/null
+++ b/include/err.h
@@ -0,0 +1,3 @@
+#include_next <err.h>
+void warnc(int, const char *, ...) __attribute__((__format__ (printf, 2, 3)));
+void vwarnc(int, const char *, va_list) __attribute__((__format__ (printf, 2, 0)));
diff --git a/include/errno.h b/include/errno.h
new file mode 100644
index 0000000..7694025
--- /dev/null
+++ b/include/errno.h
@@ -0,0 +1,59 @@
+/* $OpenBSD: errno.h,v 1.3 2017/08/10 13:34:46 guenther Exp $ */
+
+/*
+ * Copyright (c) 1982, 1986, 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)errno.h 8.5 (Berkeley) 1/21/94
+ */
+
+#ifndef _ERRNO_H_
+#define _ERRNO_H_
+
+#include <sys/errno.h>
+
+__BEGIN_DECLS
+#if __BSD_VISIBLE
+#ifndef __SYS_ERRLIST
+#define __SYS_ERRLIST
+extern int sys_nerr;
+extern char *sys_errlist[];
+#endif /* __SYS_ERRLIST */
+#endif /* __BSD_VISIBLE */
+
+#ifndef errno
+int *__errno(void);
+#define errno (*__errno())
+#endif /* errno */
+__END_DECLS
+
+#endif /* _ERRNO_H_ */
diff --git a/include/fenv.h b/include/fenv.h
new file mode 100644
index 0000000..1368ab3
--- /dev/null
+++ b/include/fenv.h
@@ -0,0 +1,60 @@
+/* $OpenBSD: fenv.h,v 1.2 2011/05/25 21:46:49 martynas Exp $ */
+/* $NetBSD: fenv.h,v 1.2.4.1 2011/02/08 16:18:55 bouyer Exp $ */
+
+/*
+ * Copyright (c) 2010 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _FENV_H_
+#define _FENV_H_
+
+#include <sys/cdefs.h>
+#include <machine/fenv.h>
+
+__BEGIN_DECLS
+
+int feclearexcept(int);
+int fegetexceptflag(fexcept_t *, int);
+int feraiseexcept(int);
+int fesetexceptflag(const fexcept_t *, int);
+int fetestexcept(int);
+
+int fegetround(void);
+int fesetround(int);
+
+int fegetenv(fenv_t *);
+int feholdexcept(fenv_t *);
+int fesetenv(const fenv_t *);
+int feupdateenv(const fenv_t *);
+
+#if __BSD_VISIBLE
+int feenableexcept(int);
+int fedisableexcept(int);
+int fegetexcept(void);
+#endif /* __BSD_VISIBLE */
+
+__END_DECLS
+
+#endif /* ! _FENV_H_ */
diff --git a/include/float.h b/include/float.h
new file mode 100644
index 0000000..24ffe8b
--- /dev/null
+++ b/include/float.h
@@ -0,0 +1,95 @@
+/* $OpenBSD: float.h,v 1.1 2012/06/26 16:16:16 deraadt Exp $ */
+
+/*
+ * Copyright (c) 1989 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _FLOAT_H_
+#define _FLOAT_H_
+
+#include <sys/cdefs.h>
+#include <machine/_float.h>
+
+__BEGIN_DECLS
+int __flt_rounds(void);
+__END_DECLS
+
+#define FLT_RADIX __FLT_RADIX /* b */
+#define FLT_ROUNDS __FLT_ROUNDS
+
+#if __ISO_C_VISIBLE >= 1999
+#define FLT_EVAL_METHOD __FLT_EVAL_METHOD /* long double */
+#endif
+
+#define FLT_MANT_DIG __FLT_MANT_DIG /* p */
+#define FLT_EPSILON __FLT_EPSILON /* b**(1-p) */
+#ifndef FLT_DIG
+#define FLT_DIG __FLT_DIG /* floor((p-1)*log10(b))+(b == 10) */
+#endif
+#define FLT_MIN_EXP __FLT_MIN_EXP /* emin */
+#ifndef FLT_MIN
+#define FLT_MIN __FLT_MIN /* b**(emin-1) */
+#endif
+#define FLT_MIN_10_EXP __FLT_MIN_10_EXP /* ceil(log10(b**(emin-1))) */
+#define FLT_MAX_EXP __FLT_MAX_EXP /* emax */
+#ifndef FLT_MAX
+#define FLT_MAX __FLT_MAX /* (1-b**(-p))*b**emax */
+#endif
+#define FLT_MAX_10_EXP __FLT_MAX_10_EXP /* floor(log10((1-b**(-p))*b**emax)) */
+
+#define DBL_MANT_DIG __DBL_MANT_DIG
+#define DBL_EPSILON __DBL_EPSILON
+#ifndef DBL_DIG
+#define DBL_DIG __DBL_DIG
+#endif
+#define DBL_MIN_EXP __DBL_MIN_EXP
+#ifndef DBL_MIN
+#define DBL_MIN __DBL_MIN
+#endif
+#define DBL_MIN_10_EXP __DBL_MIN_10_EXP
+#define DBL_MAX_EXP __DBL_MAX_EXP
+#ifndef DBL_MAX
+#define DBL_MAX __DBL_MAX
+#endif
+#define DBL_MAX_10_EXP __DBL_MAX_10_EXP
+
+#define LDBL_MANT_DIG __LDBL_MANT_DIG
+#define LDBL_EPSILON __LDBL_EPSILON
+#define LDBL_DIG __LDBL_DIG
+#define LDBL_MIN_EXP __LDBL_MIN_EXP
+#define LDBL_MIN __LDBL_MIN
+#define LDBL_MIN_10_EXP __LDBL_MIN_10_EXP
+#define LDBL_MAX_EXP __LDBL_MAX_EXP
+#define LDBL_MAX __LDBL_MAX
+#define LDBL_MAX_10_EXP __LDBL_MAX_10_EXP
+
+#if __ISO_C_VISIBLE >= 1999
+#define DECIMAL_DIG __DECIMAL_DIG
+#endif
+
+#endif /* _FLOAT_H_ */
diff --git a/include/fnmatch.h b/include/fnmatch.h
new file mode 100644
index 0000000..4b27d06
--- /dev/null
+++ b/include/fnmatch.h
@@ -0,0 +1,57 @@
+/* $OpenBSD: fnmatch.h,v 1.8 2005/12/13 00:35:22 millert Exp $ */
+/* $NetBSD: fnmatch.h,v 1.5 1994/10/26 00:55:53 cgd Exp $ */
+
+/*-
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)fnmatch.h 8.1 (Berkeley) 6/2/93
+ */
+
+#ifndef _FNMATCH_H_
+#define _FNMATCH_H_
+
+#include <sys/cdefs.h>
+
+#define FNM_NOMATCH 1 /* Match failed. */
+#define FNM_NOSYS 2 /* Function not supported (unused). */
+
+#define FNM_NOESCAPE 0x01 /* Disable backslash escaping. */
+#define FNM_PATHNAME 0x02 /* Slash must be matched by slash. */
+#define FNM_PERIOD 0x04 /* Period must be matched by period. */
+#if __BSD_VISIBLE
+#define FNM_LEADING_DIR 0x08 /* Ignore /<tail> after Imatch. */
+#define FNM_CASEFOLD 0x10 /* Case insensitive search. */
+#define FNM_IGNORECASE FNM_CASEFOLD
+#define FNM_FILE_NAME FNM_PATHNAME
+#endif
+
+__BEGIN_DECLS
+int fnmatch(const char *, const char *, int);
+__END_DECLS
+
+#endif /* !_FNMATCH_H_ */
diff --git a/include/fstab.h b/include/fstab.h
new file mode 100644
index 0000000..ebb955e
--- /dev/null
+++ b/include/fstab.h
@@ -0,0 +1,78 @@
+/* $OpenBSD: fstab.h,v 1.5 2003/06/02 19:34:12 millert Exp $ */
+/* $NetBSD: fstab.h,v 1.3 1994/10/26 00:55:53 cgd Exp $ */
+
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)fstab.h 5.12 (Berkeley) 4/3/91
+ */
+
+#ifndef _FSTAB_H_
+#define _FSTAB_H_
+
+/*
+ * File system table, see fstab(5).
+ *
+ * Used by dump, mount, umount, swapon, fsck, df, ...
+ *
+ * For ufs fs_spec field is the block special name. Programs that want to
+ * use the character special name must create that name by prepending a 'r'
+ * after the right most slash. Quota files are always named "quotas", so
+ * if type is "rq", then use concatenation of fs_file and "quotas" to locate
+ * quota file.
+ */
+#define _PATH_FSTAB "/etc/fstab"
+#define FSTAB "/etc/fstab" /* deprecated */
+
+#define FSTAB_RW "rw" /* read/write device */
+#define FSTAB_RQ "rq" /* read/write with quotas */
+#define FSTAB_RO "ro" /* read-only device */
+#define FSTAB_SW "sw" /* swap device */
+#define FSTAB_XX "xx" /* ignore totally */
+
+struct fstab {
+ char *fs_spec; /* block special device name */
+ char *fs_file; /* file system path prefix */
+ char *fs_vfstype; /* File system type, ufs, nfs */
+ char *fs_mntops; /* Mount options ala -o */
+ char *fs_type; /* FSTAB_* from fs_mntops */
+ int fs_freq; /* dump frequency, in days */
+ int fs_passno; /* pass number on parallel fsck */
+};
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+struct fstab *getfsent(void);
+struct fstab *getfsspec(const char *);
+struct fstab *getfsfile(const char *);
+int setfsent(void);
+void endfsent(void);
+__END_DECLS
+
+#endif /* !_FSTAB_H_ */
diff --git a/include/fts.h b/include/fts.h
new file mode 100644
index 0000000..a5b3aff
--- /dev/null
+++ b/include/fts.h
@@ -0,0 +1,127 @@
+/* $OpenBSD: fts.h,v 1.14 2012/12/05 23:19:57 deraadt Exp $ */
+/* $NetBSD: fts.h,v 1.5 1994/12/28 01:41:50 mycroft Exp $ */
+
+/*
+ * Copyright (c) 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)fts.h 8.3 (Berkeley) 8/14/94
+ */
+
+#ifndef _FTS_H_
+#define _FTS_H_
+
+#include <sys/cdefs.h>
+
+typedef struct {
+ struct _ftsent *fts_cur; /* current node */
+ struct _ftsent *fts_child; /* linked list of children */
+ struct _ftsent **fts_array; /* sort array */
+ dev_t fts_dev; /* starting device # */
+ char *fts_path; /* path for this descent */
+ int fts_rfd; /* fd for root */
+ size_t fts_pathlen; /* sizeof(path) */
+ int fts_nitems; /* elements in the sort array */
+ int (*fts_compar)(); /* compare function */
+
+#define FTS_COMFOLLOW 0x0001 /* follow command line symlinks */
+#define FTS_LOGICAL 0x0002 /* logical walk */
+#define FTS_NOCHDIR 0x0004 /* don't change directories */
+#define FTS_NOSTAT 0x0008 /* don't get stat info */
+#define FTS_PHYSICAL 0x0010 /* physical walk */
+#define FTS_SEEDOT 0x0020 /* return dot and dot-dot */
+#define FTS_XDEV 0x0040 /* don't cross devices */
+#define FTS_OPTIONMASK 0x00ff /* valid user option mask */
+
+#define FTS_NAMEONLY 0x1000 /* (private) child names only */
+#define FTS_STOP 0x2000 /* (private) unrecoverable error */
+ int fts_options; /* fts_open options, global flags */
+} FTS;
+
+typedef struct _ftsent {
+ struct _ftsent *fts_cycle; /* cycle node */
+ struct _ftsent *fts_parent; /* parent directory */
+ struct _ftsent *fts_link; /* next file in directory */
+ long fts_number; /* local numeric value */
+ void *fts_pointer; /* local address value */
+ char *fts_accpath; /* access path */
+ char *fts_path; /* root path */
+ int fts_errno; /* errno for this node */
+ int fts_symfd; /* fd for symlink */
+ size_t fts_pathlen; /* strlen(fts_path) */
+ size_t fts_namelen; /* strlen(fts_name) */
+
+ ino_t fts_ino; /* inode */
+ dev_t fts_dev; /* device */
+ nlink_t fts_nlink; /* link count */
+
+#define FTS_ROOTPARENTLEVEL -1
+#define FTS_ROOTLEVEL 0
+#define FTS_MAXLEVEL 0x7fffffff
+ int fts_level; /* depth (-1 to N) */
+
+#define FTS_D 1 /* preorder directory */
+#define FTS_DC 2 /* directory that causes cycles */
+#define FTS_DEFAULT 3 /* none of the above */
+#define FTS_DNR 4 /* unreadable directory */
+#define FTS_DOT 5 /* dot or dot-dot */
+#define FTS_DP 6 /* postorder directory */
+#define FTS_ERR 7 /* error; errno is set */
+#define FTS_F 8 /* regular file */
+#define FTS_INIT 9 /* initialized only */
+#define FTS_NS 10 /* stat(2) failed */
+#define FTS_NSOK 11 /* no stat(2) requested */
+#define FTS_SL 12 /* symbolic link */
+#define FTS_SLNONE 13 /* symbolic link without target */
+ unsigned short fts_info; /* user flags for FTSENT structure */
+
+#define FTS_DONTCHDIR 0x01 /* don't chdir .. to the parent */
+#define FTS_SYMFOLLOW 0x02 /* followed a symlink to get here */
+ unsigned short fts_flags; /* private flags for FTSENT structure */
+
+#define FTS_AGAIN 1 /* read node again */
+#define FTS_FOLLOW 2 /* follow symbolic link */
+#define FTS_NOINSTR 3 /* no instructions */
+#define FTS_SKIP 4 /* discard node */
+ unsigned short fts_instr; /* fts_set() instructions */
+
+ unsigned short fts_spare; /* unused */
+
+ struct stat *fts_statp; /* stat(2) information */
+ char fts_name[1]; /* file name */
+} FTSENT;
+
+__BEGIN_DECLS
+FTSENT *fts_children(FTS *, int);
+int fts_close(FTS *);
+FTS *fts_open(char * const *, int,
+ int (*)(const FTSENT **, const FTSENT **));
+FTSENT *fts_read(FTS *);
+int fts_set(FTS *, FTSENT *, int);
+__END_DECLS
+
+#endif /* !_FTS_H_ */
diff --git a/include/ftw.h b/include/ftw.h
new file mode 100644
index 0000000..9947815
--- /dev/null
+++ b/include/ftw.h
@@ -0,0 +1,60 @@
+/* $OpenBSD: ftw.h,v 1.2 2019/01/25 00:19:25 millert Exp $ */
+
+/*
+ * Copyright (c) 2003 Todd C. Miller <millert@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Sponsored in part by the Defense Advanced Research Projects
+ * Agency (DARPA) and Air Force Research Laboratory, Air Force
+ * Materiel Command, USAF, under agreement number F39502-99-1-0512.
+ */
+
+#ifndef _FTW_H
+#define _FTW_H
+
+#include <sys/types.h>
+#include <sys/stat.h>
+
+/*
+ * Valid flags for the 3rd argument to the function that is passed as the
+ * second argument to ftw(3) and nftw(3). Say it three times fast!
+ */
+#define FTW_F 0 /* File. */
+#define FTW_D 1 /* Directory. */
+#define FTW_DNR 2 /* Directory without read permission. */
+#define FTW_DP 3 /* Directory with subdirectories visited. */
+#define FTW_NS 4 /* Unknown type; stat() failed. */
+#define FTW_SL 5 /* Symbolic link. */
+#define FTW_SLN 6 /* Sym link that names a nonexistent file. */
+
+/*
+ * Flags for use as the 4th argument to nftw(3). These may be ORed together.
+ */
+#define FTW_PHYS 0x01 /* Physical walk, don't follow sym links. */
+#define FTW_MOUNT 0x02 /* The walk does not cross a mount point. */
+#define FTW_DEPTH 0x04 /* Subdirs visited before the dir itself. */
+#define FTW_CHDIR 0x08 /* Change to a directory before reading it. */
+
+struct FTW {
+ int base;
+ int level;
+};
+
+__BEGIN_DECLS
+int ftw(const char *, int (*)(const char *, const struct stat *, int), int);
+int nftw(const char *, int (*)(const char *, const struct stat *, int,
+ struct FTW *), int, int);
+__END_DECLS
+
+#endif /* !_FTW_H */
diff --git a/include/getopt.h b/include/getopt.h
new file mode 100644
index 0000000..dd51864
--- /dev/null
+++ b/include/getopt.h
@@ -0,0 +1,76 @@
+/* $OpenBSD: getopt.h,v 1.3 2013/11/22 21:32:49 millert Exp $ */
+/* $NetBSD: getopt.h,v 1.4 2000/07/07 10:43:54 ad Exp $ */
+
+/*-
+ * Copyright (c) 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Dieter Baron and Thomas Klausner.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _GETOPT_H_
+#define _GETOPT_H_
+
+#include <sys/cdefs.h>
+
+/*
+ * GNU-like getopt_long()
+ */
+#define no_argument 0
+#define required_argument 1
+#define optional_argument 2
+
+struct option {
+ /* name of long option */
+ const char *name;
+ /*
+ * one of no_argument, required_argument, and optional_argument:
+ * whether option takes an argument
+ */
+ int has_arg;
+ /* if not NULL, set *flag to val when option found */
+ int *flag;
+ /* if flag not NULL, value to set *flag to; else return value */
+ int val;
+};
+
+__BEGIN_DECLS
+int getopt_long(int, char * const *, const char *,
+ const struct option *, int *);
+int getopt_long_only(int, char * const *, const char *,
+ const struct option *, int *);
+#ifndef _GETOPT_DEFINED_
+#define _GETOPT_DEFINED_
+int getopt(int, char * const *, const char *);
+
+extern char *optarg; /* getopt(3) external variables */
+extern int opterr;
+extern int optind;
+extern int optopt;
+extern int optreset;
+#endif
+__END_DECLS
+
+#endif /* !_GETOPT_H_ */
diff --git a/include/glob.h b/include/glob.h
new file mode 100644
index 0000000..6e64bca
--- /dev/null
+++ b/include/glob.h
@@ -0,0 +1,103 @@
+/* $OpenBSD: glob.h,v 1.14 2019/02/04 16:45:40 millert Exp $ */
+/* $NetBSD: glob.h,v 1.5 1994/10/26 00:55:56 cgd Exp $ */
+
+/*
+ * Copyright (c) 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Guido van Rossum.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)glob.h 8.1 (Berkeley) 6/2/93
+ */
+
+#ifndef _GLOB_H_
+#define _GLOB_H_
+
+#include <sys/stat.h>
+#include <machine/_types.h>
+
+#ifndef _SIZE_T_DEFINED_
+#define _SIZE_T_DEFINED_
+typedef __size_t size_t;
+#endif
+
+struct stat;
+typedef struct {
+ size_t gl_pathc; /* Count of total paths so far. */
+ size_t gl_matchc; /* Count of paths matching pattern. */
+ size_t gl_offs; /* Reserved at beginning of gl_pathv. */
+ int gl_flags; /* Copy of flags parameter to glob. */
+ char **gl_pathv; /* List of paths matching pattern. */
+ struct stat **gl_statv; /* Stat entries corresponding to gl_pathv */
+ /* Copy of errfunc parameter to glob. */
+ int (*gl_errfunc)(const char *, int);
+
+ /*
+ * Alternate filesystem access methods for glob; replacement
+ * versions of closedir(3), readdir(3), opendir(3), stat(2)
+ * and lstat(2).
+ */
+ void (*gl_closedir)(void *);
+ struct dirent *(*gl_readdir)(void *);
+ void *(*gl_opendir)(const char *);
+ int (*gl_lstat)(const char *, struct stat *);
+ int (*gl_stat)(const char *, struct stat *);
+} glob_t;
+
+#define GLOB_APPEND 0x0001 /* Append to output from previous call. */
+#define GLOB_DOOFFS 0x0002 /* Use gl_offs. */
+#define GLOB_ERR 0x0004 /* Return on error. */
+#define GLOB_MARK 0x0008 /* Append / to matching directories. */
+#define GLOB_NOCHECK 0x0010 /* Return pattern itself if nothing matches. */
+#define GLOB_NOSORT 0x0020 /* Don't sort. */
+#define GLOB_NOESCAPE 0x1000 /* Disable backslash escaping. */
+
+#define GLOB_NOSPACE (-1) /* Malloc call failed. */
+#define GLOB_ABORTED (-2) /* Unignored error. */
+#define GLOB_NOMATCH (-3) /* No match and GLOB_NOCHECK not set. */
+#define GLOB_NOSYS (-4) /* Function not supported. */
+
+#if __BSD_VISIBLE
+#define GLOB_ALTDIRFUNC 0x0040 /* Use alternately specified directory funcs. */
+#define GLOB_BRACE 0x0080 /* Expand braces ala csh. */
+#define GLOB_MAGCHAR 0x0100 /* Pattern had globbing characters. */
+#define GLOB_NOMAGIC 0x0200 /* GLOB_NOCHECK without magic chars (csh). */
+#define GLOB_QUOTE 0x0400 /* Quote special chars with \. */
+#define GLOB_TILDE 0x0800 /* Expand tilde names from the passwd file. */
+#define GLOB_LIMIT 0x2000 /* Limit pattern match output to ARG_MAX */
+#define GLOB_KEEPSTAT 0x4000 /* Retain stat data for paths in gl_statv. */
+#define GLOB_ABEND GLOB_ABORTED /* backward compatibility */
+#endif
+
+__BEGIN_DECLS
+int glob(const char *__restrict, int, int (*)(const char *, int),
+ glob_t *__restrict);
+void globfree(glob_t *);
+__END_DECLS
+
+#endif /* !_GLOB_H_ */
diff --git a/include/grp.h b/include/grp.h
new file mode 100644
index 0000000..c59cf96
--- /dev/null
+++ b/include/grp.h
@@ -0,0 +1,4 @@
+#include_next <grp.h>
+#define setgroupent(n) setgrent()
+const char *group_from_gid(gid_t, int);
+int gid_from_group(const char *, gid_t *);
diff --git a/include/icdb.h b/include/icdb.h
new file mode 100644
index 0000000..921e4ed
--- /dev/null
+++ b/include/icdb.h
@@ -0,0 +1,44 @@
+/* $OpenBSD: icdb.h,v 1.4 2016/09/04 14:51:39 nicm Exp $ */
+/*
+ * Copyright (c) 2015 Ted Unangst <tedu@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef _ICDB_H_
+#define _ICDB_H_
+
+#include <sys/types.h>
+
+__BEGIN_DECLS
+
+struct icdb;
+
+struct icdb *icdb_new(uint32_t version, uint32_t nentries, uint32_t entrysize,
+ uint32_t nkeys, const uint32_t *keysizes, const uint32_t *keyoffsets);
+
+struct icdb *icdb_open(const char *name, int flags, uint32_t version);
+int icdb_get(struct icdb *db, void *entry, uint32_t idx);
+int icdb_lookup(struct icdb *db, int keynum, const void *key, void *entry,
+ uint32_t *idxp);
+int icdb_nentries(struct icdb *db);
+const void *icdb_entries(struct icdb *db);
+int icdb_update(struct icdb *db, const void *entry, int offset);
+int icdb_add(struct icdb *db, const void *entry);
+int icdb_rehash(struct icdb *db);
+int icdb_save(struct icdb *db, int fd);
+int icdb_close(struct icdb *db);
+
+__END_DECLS
+
+#endif /* !_ICDB_H_ */
diff --git a/include/ieeefp.h b/include/ieeefp.h
new file mode 100644
index 0000000..627ce50
--- /dev/null
+++ b/include/ieeefp.h
@@ -0,0 +1,23 @@
+/* $OpenBSD: ieeefp.h,v 1.4 2009/09/27 21:23:55 martynas Exp $ */
+
+/*
+ * Written by J.T. Conklin, Apr 6, 1995
+ * Public domain.
+ */
+
+#ifndef _IEEEFP_H_
+#define _IEEEFP_H_
+
+#include <sys/cdefs.h>
+#include <machine/ieeefp.h>
+
+__BEGIN_DECLS
+extern fp_rnd fpgetround(void);
+extern fp_rnd fpsetround(fp_rnd);
+extern fp_except fpgetmask(void);
+extern fp_except fpsetmask(fp_except);
+extern fp_except fpgetsticky(void);
+extern fp_except fpsetsticky(fp_except);
+__END_DECLS
+
+#endif /* _IEEEFP_H_ */
diff --git a/include/ifaddrs.h b/include/ifaddrs.h
new file mode 100644
index 0000000..9baa159
--- /dev/null
+++ b/include/ifaddrs.h
@@ -0,0 +1,56 @@
+/* $OpenBSD: ifaddrs.h,v 1.4 2004/01/22 21:48:02 espie Exp $ */
+
+/*
+ * Copyright (c) 1995, 1999
+ * Berkeley Software Design, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Berkeley Software Design, Inc. ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL Berkeley Software Design, Inc. BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * BSDI ifaddrs.h,v 2.5 2000/02/23 14:51:59 dab Exp
+ */
+
+#ifndef _IFADDRS_H_
+#define _IFADDRS_H_
+
+struct ifaddrs {
+ struct ifaddrs *ifa_next;
+ char *ifa_name;
+ unsigned int ifa_flags;
+ struct sockaddr *ifa_addr;
+ struct sockaddr *ifa_netmask;
+ struct sockaddr *ifa_dstaddr;
+ void *ifa_data;
+};
+
+/*
+ * This may have been defined in <net/if.h>. Note that if <net/if.h> is
+ * to be included it must be included before this header file.
+ */
+#ifndef ifa_broadaddr
+#define ifa_broadaddr ifa_dstaddr /* broadcast address interface */
+#endif
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+extern int getifaddrs(struct ifaddrs **);
+extern void freeifaddrs(struct ifaddrs *);
+__END_DECLS
+
+#endif
diff --git a/include/inttypes.h b/include/inttypes.h
new file mode 100644
index 0000000..b8f4507
--- /dev/null
+++ b/include/inttypes.h
@@ -0,0 +1,262 @@
+/* $OpenBSD: inttypes.h,v 1.13 2019/01/25 00:19:25 millert Exp $ */
+
+/*
+ * Copyright (c) 1997, 2005 Todd C. Miller <millert@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef _INTTYPES_H_
+#define _INTTYPES_H_
+
+#include <sys/stdint.h>
+
+#ifdef __cplusplus
+#define __wchar_t wchar_t
+#endif
+
+/*
+ * 7.8.1 Macros for format specifiers
+ *
+ * Each of the following object-like macros expands to a string
+ * literal containing a conversion specifier, possibly modified by
+ * a prefix such as hh, h, l, or ll, suitable for use within the
+ * format argument of a formatted input/output function when
+ * converting the corresponding integer type. These macro names
+ * have the general form of PRI (character string literals for the
+ * fprintf family) or SCN (character string literals for the fscanf
+ * family), followed by the conversion specifier, followed by a
+ * name corresponding to a similar typedef name. For example,
+ * PRIdFAST32 can be used in a format string to print the value of
+ * an integer of type int_fast32_t.
+ */
+
+/* fprintf macros for signed integers */
+#define PRId8 "d" /* int8_t */
+#define PRId16 "d" /* int16_t */
+#define PRId32 "d" /* int32_t */
+#define PRId64 "lld" /* int64_t */
+
+#define PRIdLEAST8 "d" /* int_least8_t */
+#define PRIdLEAST16 "d" /* int_least16_t */
+#define PRIdLEAST32 "d" /* int_least32_t */
+#define PRIdLEAST64 "lld" /* int_least64_t */
+
+#define PRIdFAST8 "d" /* int_fast8_t */
+#define PRIdFAST16 "d" /* int_fast16_t */
+#define PRIdFAST32 "d" /* int_fast32_t */
+#define PRIdFAST64 "lld" /* int_fast64_t */
+
+#define PRIdMAX "jd" /* intmax_t */
+#define PRIdPTR "ld" /* intptr_t */
+
+#define PRIi8 "i" /* int8_t */
+#define PRIi16 "i" /* int16_t */
+#define PRIi32 "i" /* int32_t */
+#define PRIi64 "lli" /* int64_t */
+
+#define PRIiLEAST8 "i" /* int_least8_t */
+#define PRIiLEAST16 "i" /* int_least16_t */
+#define PRIiLEAST32 "i" /* int_least32_t */
+#define PRIiLEAST64 "lli" /* int_least64_t */
+
+#define PRIiFAST8 "i" /* int_fast8_t */
+#define PRIiFAST16 "i" /* int_fast16_t */
+#define PRIiFAST32 "i" /* int_fast32_t */
+#define PRIiFAST64 "lli" /* int_fast64_t */
+
+#define PRIiMAX "ji" /* intmax_t */
+#define PRIiPTR "li" /* intptr_t */
+
+/* fprintf macros for unsigned integers */
+#define PRIo8 "o" /* int8_t */
+#define PRIo16 "o" /* int16_t */
+#define PRIo32 "o" /* int32_t */
+#define PRIo64 "llo" /* int64_t */
+
+#define PRIoLEAST8 "o" /* int_least8_t */
+#define PRIoLEAST16 "o" /* int_least16_t */
+#define PRIoLEAST32 "o" /* int_least32_t */
+#define PRIoLEAST64 "llo" /* int_least64_t */
+
+#define PRIoFAST8 "o" /* int_fast8_t */
+#define PRIoFAST16 "o" /* int_fast16_t */
+#define PRIoFAST32 "o" /* int_fast32_t */
+#define PRIoFAST64 "llo" /* int_fast64_t */
+
+#define PRIoMAX "jo" /* intmax_t */
+#define PRIoPTR "lo" /* intptr_t */
+
+#define PRIu8 "u" /* uint8_t */
+#define PRIu16 "u" /* uint16_t */
+#define PRIu32 "u" /* uint32_t */
+#define PRIu64 "llu" /* uint64_t */
+
+#define PRIuLEAST8 "u" /* uint_least8_t */
+#define PRIuLEAST16 "u" /* uint_least16_t */
+#define PRIuLEAST32 "u" /* uint_least32_t */
+#define PRIuLEAST64 "llu" /* uint_least64_t */
+
+#define PRIuFAST8 "u" /* uint_fast8_t */
+#define PRIuFAST16 "u" /* uint_fast16_t */
+#define PRIuFAST32 "u" /* uint_fast32_t */
+#define PRIuFAST64 "llu" /* uint_fast64_t */
+
+#define PRIuMAX "ju" /* uintmax_t */
+#define PRIuPTR "lu" /* uintptr_t */
+
+#define PRIx8 "x" /* uint8_t */
+#define PRIx16 "x" /* uint16_t */
+#define PRIx32 "x" /* uint32_t */
+#define PRIx64 "llx" /* uint64_t */
+
+#define PRIxLEAST8 "x" /* uint_least8_t */
+#define PRIxLEAST16 "x" /* uint_least16_t */
+#define PRIxLEAST32 "x" /* uint_least32_t */
+#define PRIxLEAST64 "llx" /* uint_least64_t */
+
+#define PRIxFAST8 "x" /* uint_fast8_t */
+#define PRIxFAST16 "x" /* uint_fast16_t */
+#define PRIxFAST32 "x" /* uint_fast32_t */
+#define PRIxFAST64 "llx" /* uint_fast64_t */
+
+#define PRIxMAX "jx" /* uintmax_t */
+#define PRIxPTR "lx" /* uintptr_t */
+
+#define PRIX8 "X" /* uint8_t */
+#define PRIX16 "X" /* uint16_t */
+#define PRIX32 "X" /* uint32_t */
+#define PRIX64 "llX" /* uint64_t */
+
+#define PRIXLEAST8 "X" /* uint_least8_t */
+#define PRIXLEAST16 "X" /* uint_least16_t */
+#define PRIXLEAST32 "X" /* uint_least32_t */
+#define PRIXLEAST64 "llX" /* uint_least64_t */
+
+#define PRIXFAST8 "X" /* uint_fast8_t */
+#define PRIXFAST16 "X" /* uint_fast16_t */
+#define PRIXFAST32 "X" /* uint_fast32_t */
+#define PRIXFAST64 "llX" /* uint_fast64_t */
+
+#define PRIXMAX "jX" /* uintmax_t */
+#define PRIXPTR "lX" /* uintptr_t */
+
+/* fscanf macros for signed integers */
+#define SCNd8 "hhd" /* int8_t */
+#define SCNd16 "hd" /* int16_t */
+#define SCNd32 "d" /* int32_t */
+#define SCNd64 "lld" /* int64_t */
+
+#define SCNdLEAST8 "hhd" /* int_least8_t */
+#define SCNdLEAST16 "hd" /* int_least16_t */
+#define SCNdLEAST32 "d" /* int_least32_t */
+#define SCNdLEAST64 "lld" /* int_least64_t */
+
+#define SCNdFAST8 "d" /* int_fast8_t */
+#define SCNdFAST16 "d" /* int_fast16_t */
+#define SCNdFAST32 "d" /* int_fast32_t */
+#define SCNdFAST64 "lld" /* int_fast64_t */
+
+#define SCNdMAX "jd" /* intmax_t */
+#define SCNdPTR "ld" /* intptr_t */
+
+#define SCNi8 "hhi" /* int8_t */
+#define SCNi16 "hi" /* int16_t */
+#define SCNi32 "i" /* int32_t */
+#define SCNi64 "lli" /* int64_t */
+
+#define SCNiLEAST8 "hhi" /* int_least8_t */
+#define SCNiLEAST16 "hi" /* int_least16_t */
+#define SCNiLEAST32 "i" /* int_least32_t */
+#define SCNiLEAST64 "lli" /* int_least64_t */
+
+#define SCNiFAST8 "i" /* int_fast8_t */
+#define SCNiFAST16 "i" /* int_fast16_t */
+#define SCNiFAST32 "i" /* int_fast32_t */
+#define SCNiFAST64 "lli" /* int_fast64_t */
+
+#define SCNiMAX "ji" /* intmax_t */
+#define SCNiPTR "li" /* intptr_t */
+
+/* fscanf macros for unsigned integers */
+#define SCNo8 "hho" /* uint8_t */
+#define SCNo16 "ho" /* uint16_t */
+#define SCNo32 "o" /* uint32_t */
+#define SCNo64 "llo" /* uint64_t */
+
+#define SCNoLEAST8 "hho" /* uint_least8_t */
+#define SCNoLEAST16 "ho" /* uint_least16_t */
+#define SCNoLEAST32 "o" /* uint_least32_t */
+#define SCNoLEAST64 "llo" /* uint_least64_t */
+
+#define SCNoFAST8 "o" /* uint_fast8_t */
+#define SCNoFAST16 "o" /* uint_fast16_t */
+#define SCNoFAST32 "o" /* uint_fast32_t */
+#define SCNoFAST64 "llo" /* uint_fast64_t */
+
+#define SCNoMAX "jo" /* uintmax_t */
+#define SCNoPTR "lo" /* uintptr_t */
+
+#define SCNu8 "hhu" /* uint8_t */
+#define SCNu16 "hu" /* uint16_t */
+#define SCNu32 "u" /* uint32_t */
+#define SCNu64 "llu" /* uint64_t */
+
+#define SCNuLEAST8 "hhu" /* uint_least8_t */
+#define SCNuLEAST16 "hu" /* uint_least16_t */
+#define SCNuLEAST32 "u" /* uint_least32_t */
+#define SCNuLEAST64 "llu" /* uint_least64_t */
+
+#define SCNuFAST8 "u" /* uint_fast8_t */
+#define SCNuFAST16 "u" /* uint_fast16_t */
+#define SCNuFAST32 "u" /* uint_fast32_t */
+#define SCNuFAST64 "llu" /* uint_fast64_t */
+
+#define SCNuMAX "ju" /* uintmax_t */
+#define SCNuPTR "lu" /* uintptr_t */
+
+#define SCNx8 "hhx" /* uint8_t */
+#define SCNx16 "hx" /* uint16_t */
+#define SCNx32 "x" /* uint32_t */
+#define SCNx64 "llx" /* uint64_t */
+
+#define SCNxLEAST8 "hhx" /* uint_least8_t */
+#define SCNxLEAST16 "hx" /* uint_least16_t */
+#define SCNxLEAST32 "x" /* uint_least32_t */
+#define SCNxLEAST64 "llx" /* uint_least64_t */
+
+#define SCNxFAST8 "x" /* uint_fast8_t */
+#define SCNxFAST16 "x" /* uint_fast16_t */
+#define SCNxFAST32 "x" /* uint_fast32_t */
+#define SCNxFAST64 "llx" /* uint_fast64_t */
+
+#define SCNxMAX "jx" /* uintmax_t */
+#define SCNxPTR "lx" /* uintptr_t */
+
+typedef struct {
+ intmax_t quot; /* quotient */
+ intmax_t rem; /* remainder */
+} imaxdiv_t;
+
+__BEGIN_DECLS
+intmax_t imaxabs(intmax_t);
+imaxdiv_t imaxdiv(intmax_t, intmax_t);
+intmax_t strtoimax(const char *, char **, int);
+uintmax_t strtoumax(const char *, char **, int);
+intmax_t wcstoimax(const __wchar_t * __restrict,
+ __wchar_t ** __restrict, int);
+uintmax_t wcstoumax(const __wchar_t * __restrict,
+ __wchar_t ** __restrict, int);
+__END_DECLS
+
+#endif /* _INTTYPES_H_ */
diff --git a/include/iso646.h b/include/iso646.h
new file mode 100644
index 0000000..535e96b
--- /dev/null
+++ b/include/iso646.h
@@ -0,0 +1,26 @@
+/* $OpenBSD: iso646.h,v 1.3 2001/10/11 00:05:21 espie Exp $ */
+/* $NetBSD: iso646.h,v 1.1 1995/02/17 09:08:10 jtc Exp $ */
+
+/*
+ * Written by J.T. Conklin <jtc@wimsey.com> 02/16/95.
+ * Public domain.
+ */
+
+#ifndef _ISO646_H_
+#define _ISO646_H_
+
+#ifndef __cplusplus
+#define and &&
+#define and_eq &=
+#define bitand &
+#define bitor |
+#define compl ~
+#define not !
+#define not_eq !=
+#define or ||
+#define or_eq |=
+#define xor ^
+#define xor_eq ^=
+#endif
+
+#endif /* !_ISO646_H_ */
diff --git a/include/kvm.h b/include/kvm.h
new file mode 100644
index 0000000..9c83239
--- /dev/null
+++ b/include/kvm.h
@@ -0,0 +1,79 @@
+/* $OpenBSD: kvm.h,v 1.18 2013/10/22 16:40:25 guenther Exp $ */
+/* $NetBSD: kvm.h,v 1.7 1996/04/19 12:02:50 leo Exp $ */
+
+/*-
+ * Copyright (c) 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)kvm.h 8.1 (Berkeley) 6/2/93
+ */
+
+#ifndef _KVM_H_
+#define _KVM_H_
+
+/* Default version symbol. */
+#define VRS_SYM "_version"
+#define VRS_KEY "VERSION"
+
+/*
+ * Flag for kvm_open* that disables opening of any files. We're just
+ * interested in a handle to run sysctls.
+ */
+#define KVM_NO_FILES 0x80000000
+
+#include <nlist.h>
+#include <stdio.h>
+
+__BEGIN_DECLS
+
+typedef struct __kvm kvm_t;
+
+struct kinfo_proc;
+int kvm_close(kvm_t *);
+int kvm_dump_inval(kvm_t *);
+int kvm_dump_mkheader(kvm_t *, off_t);
+int kvm_dump_wrtheader(kvm_t *, FILE *, int);
+char **kvm_getargv(kvm_t *, const struct kinfo_proc *, int);
+char **kvm_getenvv(kvm_t *, const struct kinfo_proc *, int);
+char *kvm_geterr(kvm_t *);
+int kvm_getloadavg(kvm_t *, double [], int);
+struct kinfo_file *
+ kvm_getfiles(kvm_t *, int, int, size_t, int *);
+struct kinfo_proc *
+ kvm_getprocs(kvm_t *, int, int, size_t, int *);
+int kvm_nlist(kvm_t *, struct nlist *);
+kvm_t *kvm_open(const char *, const char *, const char *, int, const char *);
+kvm_t *kvm_openfiles(const char *, const char *, const char *,
+ int, char *);
+ssize_t kvm_read(kvm_t *, unsigned long, void *, size_t)
+ __attribute__((__bounded__(__buffer__,3,4)));
+ssize_t kvm_write(kvm_t *, unsigned long, const void *, size_t)
+ __attribute__((__bounded__(__buffer__,3,4)));
+
+__END_DECLS
+
+#endif /* !_KVM_H_ */
diff --git a/include/langinfo.h b/include/langinfo.h
new file mode 100644
index 0000000..dd37bfc
--- /dev/null
+++ b/include/langinfo.h
@@ -0,0 +1,88 @@
+/* $OpenBSD: langinfo.h,v 1.8 2017/09/05 03:16:13 schwarze Exp $ */
+/* $NetBSD: langinfo.h,v 1.3 1995/04/28 23:30:54 jtc Exp $ */
+
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>
+ * Public domain.
+ */
+
+#ifndef _LANGINFO_H_
+#define _LANGINFO_H_
+
+#include <nl_types.h>
+
+#define D_T_FMT 0 /* String for formatting date and time */
+#define D_FMT 1 /* Date format string */
+#define T_FMT 2 /* Time format string */
+#define T_FMT_AMPM 3 /* Time format string with 12 hour clock */
+#define AM_STR 4 /* Ante Meridiem afix */
+#define PM_STR 5 /* Post Meridiem afix */
+
+#define DAY_1 6 /* Name of the first day of the week */
+#define DAY_2 7
+#define DAY_3 8
+#define DAY_4 9
+#define DAY_5 10
+#define DAY_6 11
+#define DAY_7 12
+
+#define ABDAY_1 13 /* Abbrev. name of the first day of the week */
+#define ABDAY_2 14
+#define ABDAY_3 15
+#define ABDAY_4 16
+#define ABDAY_5 17
+#define ABDAY_6 18
+#define ABDAY_7 19
+
+#define MON_1 20 /* Name of the first month */
+#define MON_2 21
+#define MON_3 22
+#define MON_4 23
+#define MON_5 24
+#define MON_6 25
+#define MON_7 26
+#define MON_8 27
+#define MON_9 28
+#define MON_10 29
+#define MON_11 30
+#define MON_12 31
+
+#define ABMON_1 32 /* Abbrev. name of the first month */
+#define ABMON_2 33
+#define ABMON_3 34
+#define ABMON_4 35
+#define ABMON_5 36
+#define ABMON_6 37
+#define ABMON_7 38
+#define ABMON_8 39
+#define ABMON_9 40
+#define ABMON_10 41
+#define ABMON_11 42
+#define ABMON_12 43
+
+#define RADIXCHAR 44 /* Radix character */
+#define THOUSEP 45 /* Separator for thousands */
+#define YESSTR 46 /* Affirmative response for yes/no queries */
+#define YESEXPR 47 /* Affirmative response for yes/no queries */
+#define NOSTR 48 /* Negative response for yes/no queries */
+#define NOEXPR 49 /* Negative response for yes/no queries */
+#define CRNCYSTR 50 /* Currency symbol */
+
+#define CODESET 51 /* Codeset name */
+
+#if __POSIX_VISIBLE >= 200809
+#ifndef _LOCALE_T_DEFINED_
+#define _LOCALE_T_DEFINED_
+typedef void *locale_t;
+#endif
+#endif
+
+__BEGIN_DECLS
+char *nl_langinfo(nl_item);
+
+#if __POSIX_VISIBLE >= 200809
+char *nl_langinfo_l(nl_item, locale_t);
+#endif
+__END_DECLS
+
+#endif /* _LANGINFO_H_ */
diff --git a/include/libgen.h b/include/libgen.h
new file mode 100644
index 0000000..4312373
--- /dev/null
+++ b/include/libgen.h
@@ -0,0 +1,29 @@
+/* $OpenBSD: libgen.h,v 1.9 2019/01/25 00:19:25 millert Exp $ */
+
+/*
+ * Copyright (c) 1997 Todd C. Miller <millert@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef _LIBGEN_H_
+#define _LIBGEN_H_
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+char *basename(const char *);
+char *dirname(const char *);
+__END_DECLS
+
+#endif /* _LIBGEN_H_ */
diff --git a/include/limits.h b/include/limits.h
new file mode 100644
index 0000000..08913b4
--- /dev/null
+++ b/include/limits.h
@@ -0,0 +1,117 @@
+/* $OpenBSD: limits.h,v 1.19 2015/01/20 22:09:50 tedu Exp $ */
+/* $NetBSD: limits.h,v 1.7 1994/10/26 00:56:00 cgd Exp $ */
+
+/*
+ * Copyright (c) 1988 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)limits.h 5.9 (Berkeley) 4/3/91
+ */
+
+#ifndef _LIMITS_H_
+#define _LIMITS_H_
+
+#include <sys/cdefs.h>
+
+#if __POSIX_VISIBLE
+#define _POSIX_ARG_MAX 4096
+#define _POSIX_CHILD_MAX 25
+#define _POSIX_LINK_MAX 8
+#define _POSIX_MAX_CANON 255
+#define _POSIX_MAX_INPUT 255
+#define _POSIX_NAME_MAX 14
+#define _POSIX_PATH_MAX 256
+#define _POSIX_PIPE_BUF 512
+#define _POSIX_RE_DUP_MAX 255
+#define _POSIX_SEM_NSEMS_MAX 256
+#define _POSIX_SEM_VALUE_MAX 32767
+#define _POSIX_SSIZE_MAX 32767
+#define _POSIX_STREAM_MAX 8
+#define _POSIX_SYMLINK_MAX 255
+#define _POSIX_SYMLOOP_MAX 8
+#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
+#define _POSIX_THREAD_KEYS_MAX 128
+#define _POSIX_THREAD_THREADS_MAX 4
+
+#if __POSIX_VISIBLE >= 200112
+#define _POSIX_CLOCKRES_MIN 20000000
+#define _POSIX_NGROUPS_MAX 8
+#define _POSIX_OPEN_MAX 20
+#define _POSIX_TZNAME_MAX 6
+#else
+#define _POSIX_NGROUPS_MAX 0
+#define _POSIX_OPEN_MAX 16
+#define _POSIX_TZNAME_MAX 3
+#endif
+
+#define _POSIX2_BC_BASE_MAX 99
+#define _POSIX2_BC_DIM_MAX 2048
+#define _POSIX2_BC_SCALE_MAX 99
+#define _POSIX2_BC_STRING_MAX 1000
+#define _POSIX2_COLL_WEIGHTS_MAX 2
+#define _POSIX2_EXPR_NEST_MAX 32
+#define _POSIX2_LINE_MAX 2048
+#define _POSIX2_RE_DUP_MAX _POSIX_RE_DUP_MAX
+#define _POSIX2_CHARCLASS_NAME_MAX 14
+
+#if __POSIX_VISIBLE >= 200112
+#define _POSIX_HOST_NAME_MAX 255
+#define _POSIX_LOGIN_NAME_MAX 9 /* includes trailing NUL */
+#define _POSIX_TTY_NAME_MAX 9 /* includes trailing NUL */
+#endif /* __POSIX_VISIBLE >= 200112 */
+#endif /* __POSIX_VISIBLE */
+
+#if __XPG_VISIBLE || __POSIX_VISIBLE >= 200809
+#define NL_ARGMAX 9
+#define NL_LANGMAX 14
+#define NL_MSGMAX 32767
+#define NL_SETMAX 255
+#define NL_TEXTMAX 255
+#endif
+
+#if __XPG_VISIBLE
+# if __XPG_VISIBLE < 600
+# define PASS_MAX 128 /* _PASSWORD_LEN from <pwd.h> */
+# define TMP_MAX 0x7fffffff /* more, but don't overflow int */
+# endif
+
+# if __XPG_VISIBLE < 700
+# define NL_NMAX 1
+# endif
+
+#define _XOPEN_IOV_MAX 16
+#define _XOPEN_NAME_MAX 255
+#define _XOPEN_PATH_MAX 1024
+#endif /* __XPG_VISIBLE */
+
+#include <sys/limits.h>
+
+#if __POSIX_VISIBLE
+#include <sys/syslimits.h>
+#endif
+
+#endif /* !_LIMITS_H_ */
diff --git a/include/link.h b/include/link.h
new file mode 100644
index 0000000..cee7157
--- /dev/null
+++ b/include/link.h
@@ -0,0 +1,149 @@
+/* $OpenBSD: link.h,v 1.15 2013/10/19 09:00:18 deraadt Exp $ */
+/* $NetBSD: link.h,v 1.10 1996/01/09 00:00:11 pk Exp $ */
+
+/*
+ * Copyright (c) 1993 Paul Kranenburg
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Paul Kranenburg.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#ifndef _LINK_H_
+#define _LINK_H_
+
+#ifdef __ELF__
+#include <link_elf.h>
+#endif
+
+/*
+ * A `Shared Object Descriptor' describes a shared object that is needed
+ * to complete the link edit process of the object containing it.
+ * A list of such objects (chained through `sod_next') is pointed at
+ * by `sdt_sods' in the section_dispatch_table structure.
+ */
+
+struct sod { /* Shared Object Descriptor */
+ long sod_name; /* name (relative to load address) */
+ unsigned int sod_library : 1,/* Searched for by library rules */
+ sod_reserved : 31;
+ short sod_major; /* major version number */
+ short sod_minor; /* minor version number */
+ long sod_next; /* next sod */
+};
+
+/*
+ * `Shared Object Map's are used by the run-time link editor (ld.so) to
+ * keep track of all shared objects loaded into a process' address space.
+ * These structures are only used at run-time and do not occur within
+ * the text or data segment of an executable or shared library.
+ */
+struct so_map { /* Shared Object Map */
+ caddr_t som_addr; /* Address at which object mapped */
+ char *som_path; /* Path to mmap'ed file */
+ struct so_map *som_next; /* Next map in chain */
+ struct sod *som_sod; /* Sod responsible for this map */
+ caddr_t som_sodbase; /* Base address of this sod */
+ unsigned int som_write : 1; /* Text is currently writable */
+ struct _dynamic *som_dynamic; /* _dynamic structure */
+ caddr_t som_spd; /* Private data */
+};
+
+
+/*
+ * Debug rendezvous struct. Pointer to this is set up in the
+ * target code pointed by the DT_DEBUG tag. If it is
+ * defined.
+ */
+struct r_debug {
+ int r_version; /* Protocol version. */
+ struct link_map *r_map; /* Head of list of loaded objects. */
+
+ /*
+ * This is the address of a function internal to the run-time linker,
+ * that will always be called when the linker begins to map in a
+ * library or unmap it, and again when the mapping change is complete.
+ * The debugger can set a breakpoint at this address if it wants to
+ * notice shared object mapping changes.
+ */
+ unsigned long r_brk;
+ enum {
+ /*
+ * This state value describes the mapping change taking place
+ * when the `r_brk' address is called.
+ */
+ RT_CONSISTENT, /* Mapping change is complete. */
+ RT_ADD, /* Adding a new object. */
+ RT_DELETE /* Removing an object mapping. */
+ } r_state;
+
+ unsigned long r_ldbase; /* Base address the linker is loaded at. */
+};
+
+
+
+/*
+ * Maximum number of recognized shared object version numbers.
+ */
+#define MAXDEWEY 8
+
+/*
+ * Header of the hints file.
+ */
+struct hints_header {
+ long hh_magic;
+#define HH_MAGIC 011421044151
+ long hh_version; /* Interface version number */
+#define LD_HINTS_VERSION_1 1
+#define LD_HINTS_VERSION_2 2
+ long hh_hashtab; /* Location of hash table */
+ long hh_nbucket; /* Number of buckets in hashtab */
+ long hh_strtab; /* Location of strings */
+ long hh_strtab_sz; /* Size of strings */
+ long hh_ehints; /* End of hints (max offset in file) */
+ long hh_dirlist; /* Colon-separated list of srch dirs */
+};
+
+#define HH_BADMAG(hdr) ((hdr).hh_magic != HH_MAGIC)
+
+/*
+ * Hash table element in hints file.
+ */
+struct hints_bucket {
+ /* namex and pathx are indices into the string table */
+ int hi_namex; /* Library name */
+ int hi_pathx; /* Full path */
+ int hi_dewey[MAXDEWEY]; /* The versions */
+ int hi_ndewey; /* Number of version numbers */
+#define hi_major hi_dewey[0]
+#define hi_minor hi_dewey[1]
+ int hi_next; /* Next in this bucket */
+};
+
+#define _PATH_LD_HINTS "/var/run/ld.so.hints"
+
+#endif /* _LINK_H_ */
+
diff --git a/include/link_elf.h b/include/link_elf.h
new file mode 100644
index 0000000..45fc1b9
--- /dev/null
+++ b/include/link_elf.h
@@ -0,0 +1,42 @@
+/* $OpenBSD: link_elf.h,v 1.7 2016/09/20 18:24:55 kettenis Exp $ */
+
+/*
+ * Public domain.
+ */
+
+#ifndef _LINK_ELF_H
+#define _LINK_ELF_H
+
+#include <elf_abi.h>
+
+#ifndef DT_PROCNUM
+#define DT_PROCNUM 0
+#endif
+
+/*
+ * struct link_map is a part of the protocol between the debugger and
+ * ld.so. ld.so may have additional fields in it's version of this
+ * structure but those are ld.so private fields.
+ */
+struct link_map {
+ caddr_t l_addr; /* Base address of library */
+ const char *l_name; /* Absolute path to library */
+ void *l_ld; /* pointer to _DYNAMIC */
+ struct link_map *l_next;
+ struct link_map *l_prev;
+};
+
+struct dl_phdr_info {
+ Elf_Addr dlpi_addr;
+ const char *dlpi_name;
+ const Elf_Phdr *dlpi_phdr;
+ Elf_Half dlpi_phnum;
+};
+
+__BEGIN_DECLS
+int dl_iterate_phdr (int (*)(struct dl_phdr_info *, size_t, void *),
+ void *);
+void *dl_unwind_find_exidx(const void *, int *);
+__END_DECLS
+
+#endif /* !_LINK_ELF_H */
diff --git a/include/locale.h b/include/locale.h
new file mode 100644
index 0000000..7818996
--- /dev/null
+++ b/include/locale.h
@@ -0,0 +1,112 @@
+/* $OpenBSD: locale.h,v 1.11 2017/09/05 03:16:13 schwarze Exp $ */
+/* $NetBSD: locale.h,v 1.6 1994/10/26 00:56:02 cgd Exp $ */
+
+/*
+ * Copyright (c) 1991 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)locale.h 5.2 (Berkeley) 2/24/91
+ */
+
+#ifndef _LOCALE_H_
+#define _LOCALE_H_
+
+#include <sys/_null.h>
+
+struct lconv {
+ char *decimal_point;
+ char *thousands_sep;
+ char *grouping;
+ char *int_curr_symbol;
+ char *currency_symbol;
+ char *mon_decimal_point;
+ char *mon_thousands_sep;
+ char *mon_grouping;
+ char *positive_sign;
+ char *negative_sign;
+ char int_frac_digits;
+ char frac_digits;
+ char p_cs_precedes;
+ char p_sep_by_space;
+ char n_cs_precedes;
+ char n_sep_by_space;
+ char p_sign_posn;
+ char n_sign_posn;
+ char int_p_cs_precedes;
+ char int_p_sep_by_space;
+ char int_n_cs_precedes;
+ char int_n_sep_by_space;
+ char int_p_sign_posn;
+ char int_n_sign_posn;
+};
+
+#define LC_ALL 0
+#define LC_COLLATE 1
+#define LC_CTYPE 2
+#define LC_MONETARY 3
+#define LC_NUMERIC 4
+#define LC_TIME 5
+#define LC_MESSAGES 6
+
+#define _LC_LAST 7 /* marks end */
+
+#include <sys/cdefs.h>
+
+#if __POSIX_VISIBLE >= 200809
+
+#ifndef _LOCALE_T_DEFINED_
+#define _LOCALE_T_DEFINED_
+typedef void *locale_t;
+#endif
+
+#define LC_COLLATE_MASK (1 << LC_COLLATE)
+#define LC_CTYPE_MASK (1 << LC_CTYPE)
+#define LC_MONETARY_MASK (1 << LC_MONETARY)
+#define LC_NUMERIC_MASK (1 << LC_NUMERIC)
+#define LC_TIME_MASK (1 << LC_TIME)
+#define LC_MESSAGES_MASK (1 << LC_MESSAGES)
+
+#define LC_ALL_MASK ((1 << _LC_LAST) - 2)
+
+#define LC_GLOBAL_LOCALE ((locale_t)-1)
+
+#endif /* __POSIX_VISIBLE >= 200809 */
+
+
+__BEGIN_DECLS
+struct lconv *localeconv(void);
+char *setlocale(int, const char *);
+
+#if __POSIX_VISIBLE >= 200809
+locale_t duplocale(locale_t);
+void freelocale(locale_t);
+locale_t newlocale(int, const char *, locale_t);
+locale_t uselocale(locale_t);
+#endif
+__END_DECLS
+
+#endif /* _LOCALE_H_ */
diff --git a/include/login_cap.h b/include/login_cap.h
new file mode 100644
index 0000000..46a8bb6
--- /dev/null
+++ b/include/login_cap.h
@@ -0,0 +1,110 @@
+/* $OpenBSD: login_cap.h,v 1.16 2018/07/29 19:40:41 deraadt Exp $ */
+
+/*-
+ * Copyright (c) 1995,1997 Berkeley Software Design, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Berkeley Software Design,
+ * Inc.
+ * 4. The name of Berkeley Software Design, Inc. may not be used to endorse
+ * or promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN, INC. ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL BERKELEY SOFTWARE DESIGN, INC. BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * BSDI $From: login_cap.h,v 2.11 1999/09/08 18:11:57 prb Exp $
+ */
+
+#ifndef _LOGIN_CAP_H_
+#define _LOGIN_CAP_H_
+
+#define LOGIN_DEFCLASS "default"
+#define LOGIN_DEFSTYLE "passwd"
+#define LOGIN_DEFSERVICE "login"
+#define LOGIN_DEFUMASK 022
+#define _PATH_LOGIN_CONF "/etc/login.conf"
+#define _PATH_AUTHPROGDIR "/usr/libexec/auth"
+#define _PATH_AUTHPROG "/usr/libexec/auth/login_"
+
+#define LOGIN_SETGROUP 0x0001 /* Set group */
+#define LOGIN_SETLOGIN 0x0002 /* Set login */
+#define LOGIN_SETPATH 0x0004 /* Set path */
+#define LOGIN_SETPRIORITY 0x0008 /* Set priority */
+#define LOGIN_SETRESOURCES 0x0010 /* Set resource limits */
+#define LOGIN_SETUMASK 0x0020 /* Set umask */
+#define LOGIN_SETUSER 0x0040 /* Set user */
+#define LOGIN_SETENV 0x0080 /* Set environment */
+#define LOGIN_SETALL 0x00ff /* Set all. */
+
+#define BI_AUTH "authorize" /* Accepted authentication */
+#define BI_REJECT "reject" /* Rejected authentication */
+#define BI_CHALLENGE "reject challenge" /* Reject with a challenge */
+#define BI_SILENT "reject silent" /* Reject silently */
+#define BI_REMOVE "remove" /* remove file on error */
+#define BI_ROOTOKAY "authorize root" /* root authenticated */
+#define BI_SECURE "authorize secure" /* okay on non-secure line */
+#define BI_SETENV "setenv" /* set environment variable */
+#define BI_UNSETENV "unsetenv" /* unset environment variable */
+#define BI_VALUE "value" /* set local variable */
+#define BI_EXPIRED "reject expired" /* account expired */
+#define BI_PWEXPIRED "reject pwexpired" /* password expired */
+#define BI_FDPASS "fd" /* child is passing an fd */
+
+/*
+ * bits which can be returned by authenticate()/auth_scan()
+ */
+#define AUTH_OKAY 0x01 /* user authenticated */
+#define AUTH_ROOTOKAY 0x02 /* authenticated as root */
+#define AUTH_SECURE 0x04 /* secure login */
+#define AUTH_SILENT 0x08 /* silent rejection */
+#define AUTH_CHALLENGE 0x10 /* a challenge was given */
+#define AUTH_EXPIRED 0x20 /* account expired */
+#define AUTH_PWEXPIRED 0x40 /* password expired */
+
+#define AUTH_ALLOW (AUTH_OKAY | AUTH_ROOTOKAY | AUTH_SECURE)
+
+typedef struct login_cap {
+ char *lc_class;
+ char *lc_cap;
+ char *lc_style;
+} login_cap_t;
+
+#include <sys/cdefs.h>
+__BEGIN_DECLS
+struct passwd;
+
+login_cap_t *login_getclass(char *);
+void login_close(login_cap_t *);
+int login_getcapbool(login_cap_t *, char *, unsigned int);
+quad_t login_getcapnum(login_cap_t *, char *, quad_t, quad_t);
+quad_t login_getcapsize(login_cap_t *, char *, quad_t, quad_t);
+char *login_getcapstr(login_cap_t *, char *, char *, char *);
+quad_t login_getcaptime(login_cap_t *, char *, quad_t, quad_t);
+char *login_getstyle(login_cap_t *, char *, char *);
+
+int secure_path(char *);
+int setclasscontext(char *, unsigned int);
+int setusercontext(login_cap_t *, struct passwd *, uid_t, unsigned int);
+
+__END_DECLS
+
+#endif /* _LOGIN_CAP_H_ */
diff --git a/include/machine/endian.h b/include/machine/endian.h
new file mode 100644
index 0000000..2dc4d83
--- /dev/null
+++ b/include/machine/endian.h
@@ -0,0 +1 @@
+#include <endian.h>
diff --git a/include/math.h b/include/math.h
new file mode 100644
index 0000000..e6dd268
--- /dev/null
+++ b/include/math.h
@@ -0,0 +1,497 @@
+/* $OpenBSD: math.h,v 1.36 2018/03/10 20:52:58 kettenis Exp $ */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+/*
+ * from: @(#)fdlibm.h 5.1 93/09/24
+ */
+
+#ifndef _MATH_H_
+#define _MATH_H_
+
+#include <sys/_types.h>
+#include <sys/limits.h>
+
+__BEGIN_DECLS
+/*
+ * ANSI/POSIX
+ */
+extern char __infinity[];
+#if __GNUC_PREREQ__(3, 3)
+#define HUGE_VAL __builtin_huge_val()
+#else /* __GNUC_PREREQ__(3, 3) */
+#define HUGE_VAL (*(double *)(void *)__infinity)
+#endif /* __GNUC_PREREQ__(3, 3) */
+
+/*
+ * C99
+ */
+#if __ISO_C_VISIBLE >= 1999
+typedef __double_t double_t;
+typedef __float_t float_t;
+
+#if __GNUC_PREREQ__(3, 3)
+#define HUGE_VALF __builtin_huge_valf()
+#define HUGE_VALL __builtin_huge_vall()
+#define INFINITY __builtin_inff()
+#define NAN __builtin_nanf("")
+#else /* __GNUC_PREREQ__(3, 3) */
+#define HUGE_VALF ((float)HUGE_VAL)
+#define HUGE_VALL ((long double)HUGE_VAL)
+#define INFINITY HUGE_VALF
+extern char __nan[];
+#define NAN (*(float *)(void *)__nan)
+#endif /* __GNUC_PREREQ__(3, 3) */
+
+#define FP_INFINITE 0x01
+#define FP_NAN 0x02
+#define FP_NORMAL 0x04
+#define FP_SUBNORMAL 0x08
+#define FP_ZERO 0x10
+
+#define FP_ILOGB0 (-INT_MAX)
+#define FP_ILOGBNAN INT_MAX
+
+#ifdef __FP_FAST_FMA
+#define FP_FAST_FMA 1
+#endif /* __FP_FAST_FMA */
+
+#ifdef __FP_FAST_FMAF
+#define FP_FAST_FMAF 1
+#endif /* __FP_FAST_FMAF */
+
+#ifdef __FP_FAST_FMAL
+#define FP_FAST_FMAL 1
+#endif /* __FP_FAST_FMAL */
+
+#define MATH_ERRNO 1
+#define MATH_ERREXCEPT 2
+#define math_errhandling MATH_ERREXCEPT
+
+#define fpclassify(x) \
+ ((sizeof (x) == sizeof (float)) ? \
+ __fpclassifyf(x) \
+ : (sizeof (x) == sizeof (double)) ? \
+ __fpclassify(x) \
+ : __fpclassifyl(x))
+#define isfinite(x) \
+ ((sizeof (x) == sizeof (float)) ? \
+ __isfinitef(x) \
+ : (sizeof (x) == sizeof (double)) ? \
+ __isfinite(x) \
+ : __isfinitel(x))
+#define isnormal(x) \
+ ((sizeof (x) == sizeof (float)) ? \
+ __isnormalf(x) \
+ : (sizeof (x) == sizeof (double)) ? \
+ __isnormal(x) \
+ : __isnormall(x))
+#define signbit(x) \
+ ((sizeof (x) == sizeof (float)) ? \
+ __signbitf(x) \
+ : (sizeof (x) == sizeof (double)) ? \
+ __signbit(x) \
+ : __signbitl(x))
+
+#define isgreater(x, y) (!isunordered((x), (y)) && (x) > (y))
+#define isgreaterequal(x, y) (!isunordered((x), (y)) && (x) >= (y))
+#define isless(x, y) (!isunordered((x), (y)) && (x) < (y))
+#define islessequal(x, y) (!isunordered((x), (y)) && (x) <= (y))
+#define islessgreater(x, y) (!isunordered((x), (y)) && \
+ ((x) > (y) || (y) > (x)))
+#define isunordered(x, y) (isnan(x) || isnan(y))
+#endif /* __ISO_C_VISIBLE >= 1999 */
+
+#define isinf(x) \
+ ((sizeof (x) == sizeof (float)) ? \
+ __isinff(x) \
+ : (sizeof (x) == sizeof (double)) ? \
+ __isinf(x) \
+ : __isinfl(x))
+#define isnan(x) \
+ ((sizeof (x) == sizeof (float)) ? \
+ __isnanf(x) \
+ : (sizeof (x) == sizeof (double)) ? \
+ __isnan(x) \
+ : __isnanl(x))
+
+/*
+ * XOPEN/SVID
+ */
+#if __BSD_VISIBLE || __XPG_VISIBLE
+#define M_E ((double)2.7182818284590452354) /* e */
+#define M_LOG2E ((double)1.4426950408889634074) /* log 2e */
+#define M_LOG10E ((double)0.43429448190325182765) /* log 10e */
+#define M_LN2 ((double)0.69314718055994530942) /* log e2 */
+#define M_LN10 ((double)2.30258509299404568402) /* log e10 */
+#define M_PI ((double)3.14159265358979323846) /* pi */
+#define M_PI_2 ((double)1.57079632679489661923) /* pi/2 */
+#define M_PI_4 ((double)0.78539816339744830962) /* pi/4 */
+#define M_1_PI ((double)0.31830988618379067154) /* 1/pi */
+#define M_2_PI ((double)0.63661977236758134308) /* 2/pi */
+#define M_2_SQRTPI ((double)1.12837916709551257390) /* 2/sqrt(pi) */
+#define M_SQRT2 ((double)1.41421356237309504880) /* sqrt(2) */
+#define M_SQRT1_2 ((double)0.70710678118654752440) /* 1/sqrt(2) */
+
+#define MAXFLOAT ((float)3.40282346638528860e+38)
+
+extern int signgam;
+#endif /* __BSD_VISIBLE || __XPG_VISIBLE */
+
+#if __POSIX_VISIBLE >= 201403
+#define M_El 2.718281828459045235360287471352662498L /* e */
+#define M_LOG2El 1.442695040888963407359924681001892137L /* log 2e */
+#define M_LOG10El 0.434294481903251827651128918916605082L /* log 10e */
+#define M_LN2l 0.693147180559945309417232121458176568L /* log e2 */
+#define M_LN10l 2.302585092994045684017991454684364208L /* log e10 */
+#define M_PIl 3.141592653589793238462643383279502884L /* pi */
+#define M_PI_2l 1.570796326794896619231321691639751442L /* pi/2 */
+#define M_PI_4l 0.785398163397448309615660845819875721L /* pi/4 */
+#define M_1_PIl 0.318309886183790671537767526745028724L /* 1/pi */
+#define M_2_PIl 0.636619772367581343075535053490057448L /* 2/pi */
+#define M_2_SQRTPIl 1.128379167095512573896158903121545172L /* 2/sqrt(pi) */
+#define M_SQRT2l 1.414213562373095048801688724209698079L /* sqrt(2) */
+#define M_SQRT1_2l 0.707106781186547524400844362104849039L /* 1/sqrt(2) */
+#endif /* __POSIX_VISIBLE >= 201403 */
+
+#if __BSD_VISIBLE
+#define HUGE MAXFLOAT
+#endif /* __BSD_VISIBLE */
+
+/*
+ * ANSI/POSIX
+ */
+double acos(double);
+double asin(double);
+double atan(double);
+double atan2(double, double);
+double cos(double);
+double sin(double);
+double tan(double);
+
+double cosh(double);
+double sinh(double);
+double tanh(double);
+
+double exp(double);
+double frexp(double, int *);
+double ldexp(double, int);
+double log(double);
+double log10(double);
+double modf(double, double *);
+
+double pow(double, double);
+double sqrt(double);
+
+double ceil(double);
+double fabs(double);
+double floor(double);
+double fmod(double, double);
+
+/*
+ * C99
+ */
+#if __BSD_VISIBLE || __ISO_C_VISIBLE >= 1999 || __XPG_VISIBLE
+double acosh(double);
+double asinh(double);
+double atanh(double);
+
+double exp2(double);
+double expm1(double);
+int ilogb(double);
+double log1p(double);
+double log2(double);
+double logb(double);
+double scalbn(double, int);
+double scalbln(double, long int);
+
+double cbrt(double);
+double hypot(double, double);
+
+double erf(double);
+double erfc(double);
+double lgamma(double);
+double tgamma(double);
+
+double nearbyint(double);
+double rint(double);
+long int lrint(double);
+long long int llrint(double);
+double round(double);
+long int lround(double);
+long long int llround(double);
+double trunc(double);
+
+double remainder(double, double);
+double remquo(double, double, int *);
+
+double copysign(double, double);
+double nan(const char *);
+double nextafter(double, double);
+double nexttoward(double, long double);
+
+double fdim(double, double);
+double fmax(double, double);
+double fmin(double, double);
+
+double fma(double, double, double);
+#endif /* __BSD_VISIBLE || __ISO_C_VISIBLE >= 1999 || __XPG_VISIBLE */
+
+#if __BSD_VISIBLE || __XPG_VISIBLE
+double j0(double);
+double j1(double);
+double jn(int, double);
+double scalb(double, double);
+double y0(double);
+double y1(double);
+double yn(int, double);
+#endif /* __BSD_VISIBLE || __XPG_VISIBLE */
+
+#if __BSD_VISIBLE || __XPG_VISIBLE <= 500
+double gamma(double);
+#endif /* __BSD_VISIBLE || __XPG_VISIBLE <= 500 */
+
+/*
+ * BSD math library entry points
+ */
+#if __BSD_VISIBLE
+double drem(double, double);
+int finite(double);
+
+/*
+ * Reentrant version of gamma & lgamma; passes signgam back by reference
+ * as the second argument; user must allocate space for signgam.
+ */
+double gamma_r(double, int *);
+double lgamma_r(double, int *);
+
+void sincos(double, double *, double *);
+
+/*
+ * IEEE Test Vector
+ */
+double significand(double);
+#endif /* __BSD_VISIBLE */
+
+/*
+ * Float versions of C99 functions
+ */
+#if __ISO_C_VISIBLE >= 1999
+float acosf(float);
+float asinf(float);
+float atanf(float);
+float atan2f(float, float);
+float cosf(float);
+float sinf(float);
+float tanf(float);
+
+float acoshf(float);
+float asinhf(float);
+float atanhf(float);
+float coshf(float);
+float sinhf(float);
+float tanhf(float);
+
+float expf(float);
+float exp2f(float);
+float expm1f(float);
+float frexpf(float, int *);
+int ilogbf(float);
+float ldexpf(float, int);
+float logf(float);
+float log10f(float);
+float log1pf(float);
+float log2f(float);
+float logbf(float);
+float modff(float, float *);
+float scalbnf(float, int);
+float scalblnf(float, long int);
+
+float cbrtf(float);
+float fabsf(float);
+float hypotf(float, float);
+float powf(float, float);
+float sqrtf(float);
+
+float erff(float);
+float erfcf(float);
+float lgammaf(float);
+float tgammaf(float);
+
+float ceilf(float);
+float floorf(float);
+float nearbyintf(float);
+float rintf(float);
+long int lrintf(float);
+long long int llrintf(float);
+float roundf(float);
+long int lroundf(float);
+long long int llroundf(float);
+float truncf(float);
+
+float fmodf(float, float);
+float remainderf(float, float);
+float remquof(float, float, int *);
+
+float copysignf(float, float);
+float nanf(const char *);
+float nextafterf(float, float);
+float nexttowardf(float, long double);
+
+float fdimf(float, float);
+float fmaxf(float, float);
+float fminf(float, float);
+
+float fmaf(float, float, float);
+#endif /* __ISO_C_VISIBLE >= 1999 */
+
+#if __BSD_VISIBLE || __XPG_VISIBLE
+float j0f(float);
+float j1f(float);
+float jnf(int, float);
+float scalbf(float, float);
+float y0f(float);
+float y1f(float);
+float ynf(int, float);
+#endif /* __BSD_VISIBLE || __XPG_VISIBLE */
+
+#if __BSD_VISIBLE || __XPG_VISIBLE <= 500
+float gammaf(float);
+#endif /* __BSD_VISIBLE || __XPG_VISIBLE <= 500 */
+
+/*
+ * Float versions of BSD math library entry points
+ */
+#if __BSD_VISIBLE
+float dremf(float, float);
+int finitef(float);
+int isinff(float);
+int isnanf(float);
+
+/*
+ * Float versions of reentrant version of gamma & lgamma; passes
+ * signgam back by reference as the second argument; user must
+ * allocate space for signgam.
+ */
+float gammaf_r(float, int *);
+float lgammaf_r(float, int *);
+
+void sincosf(float, float *, float *);
+
+/*
+ * Float version of IEEE Test Vector
+ */
+float significandf(float);
+#endif /* __BSD_VISIBLE */
+
+/*
+ * Long double versions of C99 functions
+ */
+#if __ISO_C_VISIBLE >= 1999
+long double acosl(long double);
+long double asinl(long double);
+long double atanl(long double);
+long double atan2l(long double, long double);
+long double cosl(long double);
+long double sinl(long double);
+long double tanl(long double);
+
+long double acoshl(long double);
+long double asinhl(long double);
+long double atanhl(long double);
+long double coshl(long double);
+long double sinhl(long double);
+long double tanhl(long double);
+
+long double expl(long double);
+long double exp2l(long double);
+long double expm1l(long double);
+long double frexpl(long double, int *);
+int ilogbl(long double);
+long double ldexpl(long double, int);
+long double logl(long double);
+long double log10l(long double);
+long double log1pl(long double);
+long double log2l(long double);
+long double logbl(long double);
+long double modfl(long double, long double *);
+long double scalbnl(long double, int);
+long double scalblnl(long double, long int);
+
+long double cbrtl(long double);
+long double fabsl(long double);
+long double hypotl(long double, long double);
+long double powl(long double, long double);
+long double sqrtl(long double);
+
+long double erfl(long double);
+long double erfcl(long double);
+long double lgammal(long double);
+long double tgammal(long double);
+
+long double ceill(long double);
+long double floorl(long double);
+long double nearbyintl(long double);
+long double rintl(long double);
+long int lrintl(long double);
+long long int llrintl(long double);
+long double roundl(long double);
+long int lroundl(long double);
+long long int llroundl(long double);
+long double truncl(long double);
+
+long double fmodl(long double, long double);
+long double remainderl(long double, long double);
+long double remquol(long double, long double, int *);
+
+long double copysignl(long double, long double);
+long double nanl(const char *);
+long double nextafterl(long double, long double);
+long double nexttowardl(long double, long double);
+
+long double fdiml(long double, long double);
+long double fmaxl(long double, long double);
+long double fminl(long double, long double);
+
+long double fmal(long double, long double, long double);
+#endif /* __ISO_C_VISIBLE >= 1999 */
+
+/*
+ * Long double versions of BSD math library entry points
+ */
+#if __BSD_VISIBLE
+void sincosl(long double, long double *, long double *);
+#endif
+
+/*
+ * Library implementation
+ */
+int __fpclassify(double);
+int __fpclassifyf(float);
+int __fpclassifyl(long double);
+int __isfinite(double);
+int __isfinitef(float);
+int __isfinitel(long double);
+int __isinf(double);
+int __isinff(float);
+int __isinfl(long double);
+int __isnan(double);
+int __isnanf(float);
+int __isnanl(long double);
+int __isnormal(double);
+int __isnormalf(float);
+int __isnormall(long double);
+int __signbit(double);
+int __signbitf(float);
+int __signbitl(long double);
+__END_DECLS
+
+#endif /* !_MATH_H_ */
diff --git a/include/md5.h b/include/md5.h
new file mode 100644
index 0000000..2fa7de8
--- /dev/null
+++ b/include/md5.h
@@ -0,0 +1,49 @@
+/* $OpenBSD: md5.h,v 1.17 2012/12/05 23:19:57 deraadt Exp $ */
+
+/*
+ * This code implements the MD5 message-digest algorithm.
+ * The algorithm is due to Ron Rivest. This code was
+ * written by Colin Plumb in 1993, no copyright is claimed.
+ * This code is in the public domain; do with it what you wish.
+ *
+ * Equivalent code is available from RSA Data Security, Inc.
+ * This code has been tested against that, and is equivalent,
+ * except that you don't need to include two pages of legalese
+ * with every copy.
+ */
+
+#ifndef _MD5_H_
+#define _MD5_H_
+
+#define MD5_BLOCK_LENGTH 64
+#define MD5_DIGEST_LENGTH 16
+#define MD5_DIGEST_STRING_LENGTH (MD5_DIGEST_LENGTH * 2 + 1)
+
+typedef struct MD5Context {
+ u_int32_t state[4]; /* state */
+ u_int64_t count; /* number of bits, mod 2^64 */
+ u_int8_t buffer[MD5_BLOCK_LENGTH]; /* input buffer */
+} MD5_CTX;
+
+__BEGIN_DECLS
+void MD5Init(MD5_CTX *);
+void MD5Update(MD5_CTX *, const u_int8_t *, size_t)
+ __attribute__((__bounded__(__string__,2,3)));
+void MD5Pad(MD5_CTX *);
+void MD5Final(u_int8_t [MD5_DIGEST_LENGTH], MD5_CTX *)
+ __attribute__((__bounded__(__minbytes__,1,MD5_DIGEST_LENGTH)));
+void MD5Transform(u_int32_t [4], const u_int8_t [MD5_BLOCK_LENGTH])
+ __attribute__((__bounded__(__minbytes__,1,4)))
+ __attribute__((__bounded__(__minbytes__,2,MD5_BLOCK_LENGTH)));
+char *MD5End(MD5_CTX *, char *)
+ __attribute__((__bounded__(__minbytes__,2,MD5_DIGEST_STRING_LENGTH)));
+char *MD5File(const char *, char *)
+ __attribute__((__bounded__(__minbytes__,2,MD5_DIGEST_STRING_LENGTH)));
+char *MD5FileChunk(const char *, char *, off_t, off_t)
+ __attribute__((__bounded__(__minbytes__,2,MD5_DIGEST_STRING_LENGTH)));
+char *MD5Data(const u_int8_t *, size_t, char *)
+ __attribute__((__bounded__(__string__,1,2)))
+ __attribute__((__bounded__(__minbytes__,3,MD5_DIGEST_STRING_LENGTH)));
+__END_DECLS
+
+#endif /* _MD5_H_ */
diff --git a/include/memory.h b/include/memory.h
new file mode 100644
index 0000000..b7fadca
--- /dev/null
+++ b/include/memory.h
@@ -0,0 +1,35 @@
+/* $OpenBSD: memory.h,v 1.3 2003/06/02 19:34:12 millert Exp $ */
+/* $NetBSD: memory.h,v 1.3 1994/10/26 00:56:06 cgd Exp $ */
+
+/*
+ * Copyright (c) 1988 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)memory.h 5.5 (Berkeley) 6/1/90
+ */
+
+#include <string.h>
diff --git a/include/ndbm.h b/include/ndbm.h
new file mode 100644
index 0000000..4c1efa9
--- /dev/null
+++ b/include/ndbm.h
@@ -0,0 +1,78 @@
+/* $OpenBSD: ndbm.h,v 1.6 2004/05/03 17:27:50 millert Exp $ */
+/* $NetBSD: ndbm.h,v 1.6 1995/07/20 23:31:11 jtc Exp $ */
+
+/*-
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Margo Seltzer.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)ndbm.h 8.1 (Berkeley) 6/2/93
+ */
+
+#ifndef _NDBM_H_
+#define _NDBM_H_
+
+#include <db.h>
+
+/* Map dbm interface onto db(3). */
+#define DBM_RDONLY O_RDONLY
+
+/* Flags to dbm_store(). */
+#define DBM_INSERT 0
+#define DBM_REPLACE 1
+
+/*
+ * The db(3) support for ndbm(3) always appends this suffix to the
+ * file name to avoid overwriting the user's original database.
+ */
+#define DBM_SUFFIX ".db"
+
+typedef struct {
+ void *dptr;
+ size_t dsize;
+} datum;
+
+typedef DB DBM;
+#define dbm_pagfno(a) DBM_PAGFNO_NOT_AVAILABLE
+
+__BEGIN_DECLS
+int dbm_clearerr(DBM *);
+void dbm_close(DBM *);
+int dbm_delete(DBM *, datum);
+int dbm_error(DBM *);
+datum dbm_fetch(DBM *, datum);
+datum dbm_firstkey(DBM *);
+datum dbm_nextkey(DBM *);
+DBM *dbm_open(const char *, int, mode_t);
+int dbm_store(DBM *, datum, datum, int);
+int dbm_dirfno(DBM *);
+int dbm_rdonly(DBM *);
+__END_DECLS
+
+#endif /* !_NDBM_H_ */
diff --git a/include/netdb.h b/include/netdb.h
new file mode 100644
index 0000000..0f7303e
--- /dev/null
+++ b/include/netdb.h
@@ -0,0 +1,329 @@
+/* $OpenBSD: netdb.h,v 1.33 2015/01/18 20:29:31 deraadt Exp $ */
+
+/*
+ * ++Copyright++ 1980, 1983, 1988, 1993
+ * -
+ * Copyright (c) 1980, 1983, 1988, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * -
+ * Portions Copyright (c) 1993 by Digital Equipment Corporation.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies, and that
+ * the name of Digital Equipment Corporation not be used in advertising or
+ * publicity pertaining to distribution of the document or software without
+ * specific, written prior permission.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
+ * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ * -
+ * --Copyright--
+ */
+
+/*
+ * Copyright (c) 1995, 1996, 1997, 1998, 1999 Craig Metz. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * @(#)netdb.h 8.1 (Berkeley) 6/2/93
+ * $From: netdb.h,v 8.7 1996/05/09 05:59:09 vixie Exp $
+ */
+
+#ifndef _NETDB_H_
+#define _NETDB_H_
+
+#include <netinet/in.h>
+
+#ifndef _SOCKLEN_T_DEFINED_
+#define _SOCKLEN_T_DEFINED_
+typedef __socklen_t socklen_t; /* length type for network syscalls */
+#endif
+
+#define _PATH_HEQUIV "/etc/hosts.equiv"
+#define _PATH_HOSTS "/etc/hosts"
+#define _PATH_NETWORKS "/etc/networks"
+#define _PATH_PROTOCOLS "/etc/protocols"
+#define _PATH_SERVICES "/etc/services"
+
+/*
+ * Structures returned by network data base library. All addresses are
+ * supplied in host order, and returned in network order (suitable for
+ * use in system calls).
+ */
+struct hostent {
+ char *h_name; /* official name of host */
+ char **h_aliases; /* alias list */
+ int h_addrtype; /* host address type */
+ int h_length; /* length of address */
+ char **h_addr_list; /* list of addresses from name server */
+#define h_addr h_addr_list[0] /* address, for backward compatibility */
+};
+
+/*
+ * Assumption here is that a network number
+ * fits in an in_addr_t -- probably a poor one.
+ */
+struct netent {
+ char *n_name; /* official name of net */
+ char **n_aliases; /* alias list */
+ int n_addrtype; /* net address type */
+ in_addr_t n_net; /* network # */
+};
+
+struct servent {
+ char *s_name; /* official service name */
+ char **s_aliases; /* alias list */
+ int s_port; /* port # */
+ char *s_proto; /* protocol to use */
+};
+
+struct protoent {
+ char *p_name; /* official protocol name */
+ char **p_aliases; /* alias list */
+ int p_proto; /* protocol # */
+};
+
+#if __BSD_VISIBLE || __POSIX_VISIBLE < 200809
+extern int h_errno;
+
+/*
+ * Error return codes from gethostbyname() and gethostbyaddr()
+ * (left in extern int h_errno).
+ */
+
+#define NETDB_INTERNAL -1 /* see errno */
+#define NETDB_SUCCESS 0 /* no problem */
+#define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found */
+#define TRY_AGAIN 2 /* Non-Authoritative Host not found, or SERVERFAIL */
+#define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
+#define NO_DATA 4 /* Valid name, no data record of requested type */
+#define NO_ADDRESS NO_DATA /* no address */
+#endif /* __BSD_VISIBLE || __POSIX_VISIBLE < 200809 */
+
+/* Values for getaddrinfo() and getnameinfo() */
+#define AI_PASSIVE 1 /* socket address is intended for bind() */
+#define AI_CANONNAME 2 /* request for canonical name */
+#define AI_NUMERICHOST 4 /* don't ever try hostname lookup */
+#define AI_EXT 8 /* enable non-portable extensions */
+#define AI_NUMERICSERV 16 /* don't ever try servname lookup */
+#define AI_FQDN 32 /* return the FQDN that was resolved */
+#define AI_ADDRCONFIG 64 /* return configured address families only */
+/* valid flags for addrinfo */
+#define AI_MASK \
+ (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_NUMERICSERV | AI_FQDN | \
+ AI_ADDRCONFIG)
+
+#define NI_NUMERICHOST 1 /* return the host address, not the name */
+#define NI_NUMERICSERV 2 /* return the service address, not the name */
+#define NI_NOFQDN 4 /* return a short name if in the local domain */
+#define NI_NAMEREQD 8 /* fail if either host or service name is unknown */
+#define NI_DGRAM 16 /* look up datagram service instead of stream */
+/* #define NI_NUMERICSCOPE 32 return the scope number, not the name */
+
+#if __BSD_VISIBLE
+#define NI_MAXHOST 256 /* max host name from getnameinfo (MAXHOSTNAMELEN) */
+#define NI_MAXSERV 32 /* max serv. name length returned by getnameinfo */
+
+/*
+ * Scope delimit character (KAME hack)
+ */
+#define SCOPE_DELIMITER '%'
+#endif
+
+#define EAI_BADFLAGS -1 /* invalid value for ai_flags */
+#define EAI_NONAME -2 /* name or service is not known */
+#define EAI_AGAIN -3 /* temporary failure in name resolution */
+#define EAI_FAIL -4 /* non-recoverable failure in name resolution */
+#define EAI_NODATA -5 /* no address associated with name */
+#define EAI_FAMILY -6 /* ai_family not supported */
+#define EAI_SOCKTYPE -7 /* ai_socktype not supported */
+#define EAI_SERVICE -8 /* service not supported for ai_socktype */
+#define EAI_ADDRFAMILY -9 /* address family for name not supported */
+#define EAI_MEMORY -10 /* memory allocation failure */
+#define EAI_SYSTEM -11 /* system error (code indicated in errno) */
+#define EAI_BADHINTS -12 /* invalid value for hints */
+#define EAI_PROTOCOL -13 /* resolved protocol is unknown */
+#define EAI_OVERFLOW -14 /* argument buffer overflow */
+
+struct addrinfo {
+ int ai_flags; /* input flags */
+ int ai_family; /* protocol family for socket */
+ int ai_socktype; /* socket type */
+ int ai_protocol; /* protocol for socket */
+ socklen_t ai_addrlen; /* length of socket-address */
+ struct sockaddr *ai_addr; /* socket-address for socket */
+ char *ai_canonname; /* canonical name for service location (iff req) */
+ struct addrinfo *ai_next; /* pointer to next in list */
+};
+
+#if __BSD_VISIBLE
+/*
+ * Flags for getrrsetbyname()
+ */
+#define RRSET_VALIDATED 1
+
+/*
+ * Return codes for getrrsetbyname()
+ */
+#define ERRSET_SUCCESS 0
+#define ERRSET_NOMEMORY 1
+#define ERRSET_FAIL 2
+#define ERRSET_INVAL 3
+#define ERRSET_NONAME 4
+#define ERRSET_NODATA 5
+
+/*
+ * Structures used by getrrsetbyname() and freerrset()
+ */
+struct rdatainfo {
+ unsigned int rdi_length; /* length of data */
+ unsigned char *rdi_data; /* record data */
+};
+
+struct rrsetinfo {
+ unsigned int rri_flags; /* RRSET_VALIDATED ... */
+ unsigned int rri_rdclass; /* class number */
+ unsigned int rri_rdtype; /* RR type number */
+ unsigned int rri_ttl; /* time to live */
+ unsigned int rri_nrdatas; /* size of rdatas array */
+ unsigned int rri_nsigs; /* size of sigs array */
+ char *rri_name; /* canonical name */
+ struct rdatainfo *rri_rdatas; /* individual records */
+ struct rdatainfo *rri_sigs; /* individual signatures */
+};
+
+struct servent_data {
+ void *fp;
+ char **aliases;
+ int maxaliases;
+ int stayopen;
+ char *line;
+};
+
+struct protoent_data {
+ void *fp;
+ char **aliases;
+ int maxaliases;
+ int stayopen;
+ char *line;
+};
+#endif
+
+__BEGIN_DECLS
+void endhostent(void);
+void endnetent(void);
+void endprotoent(void);
+void endservent(void);
+#if __BSD_VISIBLE || __POSIX_VISIBLE < 200809
+struct hostent *gethostbyaddr(const void *, socklen_t, int);
+struct hostent *gethostbyname(const char *);
+#endif
+#if __BSD_VISIBLE
+struct hostent *gethostbyname2(const char *, int);
+#endif
+struct hostent *gethostent(void);
+struct netent *getnetbyaddr(in_addr_t, int);
+struct netent *getnetbyname(const char *);
+struct netent *getnetent(void);
+struct protoent *getprotobyname(const char *);
+struct protoent *getprotobynumber(int);
+struct protoent *getprotoent(void);
+struct servent *getservbyname(const char *, const char *);
+struct servent *getservbyport(int, const char *);
+struct servent *getservent(void);
+#if __BSD_VISIBLE
+void herror(const char *);
+const char *hstrerror(int);
+#endif
+void sethostent(int);
+/* void sethostfile(const char *); */
+void setnetent(int);
+void setprotoent(int);
+void setservent(int);
+
+#if __BSD_VISIBLE
+void endprotoent_r(struct protoent_data *);
+void endservent_r(struct servent_data *);
+int getprotobyname_r(const char *, struct protoent *,
+ struct protoent_data *);
+int getprotobynumber_r(int, struct protoent *,
+ struct protoent_data *);
+int getservbyname_r(const char *, const char *, struct servent *,
+ struct servent_data *);
+int getservbyport_r(int, const char *, struct servent *,
+ struct servent_data *);
+int getservent_r(struct servent *, struct servent_data *);
+int getprotoent_r(struct protoent *, struct protoent_data *);
+void setprotoent_r(int, struct protoent_data *);
+void setservent_r(int, struct servent_data *);
+#endif
+
+int getaddrinfo(const char *, const char *,
+ const struct addrinfo *, struct addrinfo **);
+void freeaddrinfo(struct addrinfo *);
+int getnameinfo(const struct sockaddr *, socklen_t,
+ char *, size_t, char *, size_t, int);
+const char *gai_strerror(int);
+
+#if __BSD_VISIBLE
+int getrrsetbyname(const char *, unsigned int, unsigned int, unsigned int, struct rrsetinfo **);
+void freerrset(struct rrsetinfo *);
+#endif
+__END_DECLS
+
+#endif /* !_NETDB_H_ */
diff --git a/include/netgroup.h b/include/netgroup.h
new file mode 100644
index 0000000..ce29367
--- /dev/null
+++ b/include/netgroup.h
@@ -0,0 +1,67 @@
+/* $OpenBSD: netgroup.h,v 1.8 2015/09/10 18:59:34 deraadt Exp $ */
+/*
+ * Copyright (c) 1994 Christos Zoulas
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Christos Zoulas.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+#ifndef _NETGROUP_H_
+#define _NETGROUP_H_
+
+#define _PATH_NETGROUP "/etc/netgroup"
+
+#define _PATH_NETGROUP_DB "/etc/netgroup.db"
+
+#define _PATH_NETGROUP_MKDB "/usr/sbin/netgroup_mkdb"
+
+#define _NG_KEYBYNAME '1' /* stored by name */
+#define _NG_KEYBYUSER '2' /* stored by user */
+#define _NG_KEYBYHOST '3' /* stored by host */
+
+#define _NG_ERROR -1
+#define _NG_NONE 0
+#define _NG_NAME 1
+#define _NG_GROUP 2
+
+struct netgroup {
+ char *ng_host; /* host name */
+ char *ng_user; /* user name */
+ char *ng_domain; /* domain name */
+ struct netgroup *ng_next; /* thread */
+};
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+void setnetgrent(const char *);
+int getnetgrent(const char **, const char **, const char **);
+void endnetgrent(void);
+int innetgr(const char *, const char *, const char *, const char *);
+__END_DECLS
+
+#endif /* !_NETGROUP_H_ */
diff --git a/include/netinet/ip.h b/include/netinet/ip.h
new file mode 100644
index 0000000..238358c
--- /dev/null
+++ b/include/netinet/ip.h
@@ -0,0 +1,9 @@
+#include_next <netinet/ip.h>
+#define IPTOS_DSCP_CS0 0x00
+#define IPTOS_DSCP_CS1 0x20
+#define IPTOS_DSCP_CS2 0x40
+#define IPTOS_DSCP_CS3 0x60
+#define IPTOS_DSCP_CS4 0x80
+#define IPTOS_DSCP_CS5 0xa0
+#define IPTOS_DSCP_CS6 0xc0
+#define IPTOS_DSCP_CS7 0xe0
diff --git a/include/nl_types.h b/include/nl_types.h
new file mode 100644
index 0000000..5d03c06
--- /dev/null
+++ b/include/nl_types.h
@@ -0,0 +1,91 @@
+/* $OpenBSD: nl_types.h,v 1.8 2008/06/26 05:42:04 ray Exp $ */
+/* $NetBSD: nl_types.h,v 1.6 1996/05/13 23:11:15 jtc Exp $ */
+
+/*-
+ * Copyright (c) 1996 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by J.T. Conklin.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _NL_TYPES_H_
+#define _NL_TYPES_H_
+#include <sys/cdefs.h>
+
+#ifdef _NLS_PRIVATE
+/*
+ * MESSAGE CATALOG FILE FORMAT.
+ *
+ * The NetBSD message catalog format is similar to the format used by
+ * Svr4 systems. The differences are:
+ * * fixed byte order (big endian)
+ * * fixed data field sizes
+ *
+ * A message catalog contains four data types: a catalog header, one
+ * or more set headers, one or more message headers, and one or more
+ * text strings.
+ */
+
+#define _NLS_MAGIC 0xff88ff89
+
+struct _nls_cat_hdr {
+ int32_t __magic;
+ int32_t __nsets;
+ int32_t __mem;
+ int32_t __msg_hdr_offset;
+ int32_t __msg_txt_offset;
+} ;
+
+struct _nls_set_hdr {
+ int32_t __setno; /* set number: 0 < x <= NL_SETMAX */
+ int32_t __nmsgs; /* number of messages in the set */
+ int32_t __index; /* index of first msg_hdr in msg_hdr table */
+} ;
+
+struct _nls_msg_hdr {
+ int32_t __msgno; /* msg number: 0 < x <= NL_MSGMAX */
+ int32_t __msglen;
+ int32_t __offset;
+} ;
+
+#endif
+
+#define NL_SETD 1
+#define NL_CAT_LOCALE 1
+
+typedef struct _nl_catd {
+ void *__data;
+ int __size;
+} *nl_catd;
+
+typedef long nl_item;
+
+__BEGIN_DECLS
+extern nl_catd catopen(const char *, int);
+extern char *catgets(nl_catd, int, int, const char *);
+extern int catclose(nl_catd);
+__END_DECLS
+
+#endif /* _NL_TYPES_H_ */
diff --git a/include/nlist.h b/include/nlist.h
new file mode 100644
index 0000000..279582c
--- /dev/null
+++ b/include/nlist.h
@@ -0,0 +1,87 @@
+/* $OpenBSD: nlist.h,v 1.4 2003/06/02 19:34:12 millert Exp $ */
+/* $NetBSD: nlist.h,v 1.5 1994/10/26 00:56:11 cgd Exp $ */
+
+/*-
+ * Copyright (c) 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)nlist.h 8.2 (Berkeley) 1/21/94
+ */
+
+#ifndef _NLIST_H_
+#define _NLIST_H_
+
+/*
+ * Symbol table entry format. The #ifdef's are so that programs including
+ * nlist.h can initialize nlist structures statically.
+ */
+struct nlist {
+#ifdef _AOUT_INCLUDE_
+ union {
+ char *n_name; /* symbol name (in memory) */
+ long n_strx; /* file string table offset (on disk) */
+ } n_un;
+#else
+ char *n_name; /* symbol name (in memory) */
+#endif
+
+#define N_UNDF 0x00 /* undefined */
+#define N_ABS 0x02 /* absolute address */
+#define N_TEXT 0x04 /* text segment */
+#define N_DATA 0x06 /* data segment */
+#define N_BSS 0x08 /* bss segment */
+#define N_INDR 0x0a /* alias definition */
+#define N_SIZE 0x0c /* pseudo type, defines a symbol's size */
+#define N_COMM 0x12 /* common reference */
+#define N_FN 0x1e /* file name (N_EXT on) */
+#define N_WARN 0x1e /* warning message (N_EXT off) */
+
+#define N_EXT 0x01 /* external (global) bit, OR'ed in */
+#define N_TYPE 0x1e /* mask for all the type bits */
+ unsigned char n_type; /* type defines */
+
+ char n_other; /* spare */
+#define n_hash n_desc /* used internally by ld(1); XXX */
+ short n_desc; /* used by stab entries */
+ unsigned long n_value; /* address/value of the symbol */
+};
+
+#define N_FORMAT "%08x" /* namelist value format; XXX */
+#define N_STAB 0x0e0 /* mask for debugger symbols -- stab(5) */
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+int nlist(const char *, struct nlist *);
+__END_DECLS
+
+#endif /* !_NLIST_H_ */
diff --git a/include/paths.h b/include/paths.h
new file mode 100644
index 0000000..129d0c1
--- /dev/null
+++ b/include/paths.h
@@ -0,0 +1,81 @@
+/* $OpenBSD: paths.h,v 1.26 2019/07/11 03:54:17 tedu Exp $ */
+/* $NetBSD: paths.h,v 1.7 1994/10/26 00:56:12 cgd Exp $ */
+
+/*
+ * Copyright (c) 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)paths.h 8.1 (Berkeley) 6/2/93
+ */
+
+#ifndef _PATHS_H_
+#define _PATHS_H_
+
+/* Default search path. */
+#define _PATH_DEFPATH "/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin"
+/* All standard utilities path. */
+#define _PATH_STDPATH "/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin"
+
+#define _PATH_BSHELL "/bin/sh"
+#define _PATH_CONSOLE "/dev/console"
+#define _PATH_CSHELL "/bin/csh"
+#define _PATH_DEFTAPE "/dev/rst0"
+#define _PATH_DEVDB "/var/run/dev.db"
+#define _PATH_DEVNULL "/dev/null"
+#define _PATH_FSIRAND "/sbin/fsirand"
+#define _PATH_KLOG "/dev/klog"
+#define _PATH_KMEM "/dev/kmem"
+#define _PATH_KSHELL "/bin/ksh"
+#define _PATH_KSYMS "/dev/ksyms"
+#define _PATH_KVMDB "/var/db/kvm_bsd.db"
+#define _PATH_LOCALE "/usr/share/locale"
+#define _PATH_LOGCONF "/etc/syslog.conf"
+#define _PATH_LOGPID "/var/run/syslog.pid"
+#define _PATH_MAILDIR "/var/mail"
+#define _PATH_MAN "/usr/share/man"
+#define _PATH_MEM "/dev/mem"
+#define _PATH_NOLOGIN "/etc/nologin"
+#define _PATH_RSH "/usr/bin/ssh"
+#define _PATH_SENDMAIL "/usr/sbin/sendmail"
+#define _PATH_SHELLS "/etc/shells"
+#define _PATH_TTY "/dev/tty"
+#define _PATH_UNIX "/bsd"
+#define _PATH_VI "/usr/bin/vi"
+
+
+/* Provide trailing slash, since mostly used for building pathnames. */
+#define _PATH_BOOTDIR "/usr/mdec/"
+#define _PATH_DEV "/dev/"
+#define _PATH_DEVFD "/dev/fd/"
+#define _PATH_TMP "/tmp/"
+#define _PATH_UUCPLOCK "/var/spool/lock/"
+#define _PATH_VARDB "/var/db/"
+#define _PATH_VAREMPTY "/var/empty/"
+#define _PATH_VARRUN "/var/run/"
+#define _PATH_VARTMP "/var/tmp/"
+
+#endif /* !_PATHS_H_ */
diff --git a/include/poll.h b/include/poll.h
new file mode 100644
index 0000000..cea7b04
--- /dev/null
+++ b/include/poll.h
@@ -0,0 +1,9 @@
+/* $OpenBSD: poll.h,v 1.3 2003/10/29 16:41:13 deraadt Exp $ */
+
+/*
+ * Written by Theo de Raadt, Public Domain
+ *
+ * Typical poll() implementations expect poll.h to be in /usr/include.
+ * However this is not a convenient place for the real definitions.
+ */
+#include <sys/poll.h>
diff --git a/include/protocols/CVS/Entries b/include/protocols/CVS/Entries
new file mode 100644
index 0000000..f53456b
--- /dev/null
+++ b/include/protocols/CVS/Entries
@@ -0,0 +1,6 @@
+/dumprestore.h/1.10/Fri Jul 11 16:01:40 2014//
+/routed.h/1.3/Mon Jun 2 19:34:12 2003//
+/rwhod.h/1.4/Mon Jun 2 19:34:12 2003//
+/talkd.h/1.5/Wed Jan 21 02:23:14 2015//
+/timed.h/1.4/Fri Jan 16 00:27:00 2015//
+D
diff --git a/include/protocols/CVS/Repository b/include/protocols/CVS/Repository
new file mode 100644
index 0000000..c49ead8
--- /dev/null
+++ b/include/protocols/CVS/Repository
@@ -0,0 +1 @@
+src/include/protocols
diff --git a/include/protocols/CVS/Root b/include/protocols/CVS/Root
new file mode 100644
index 0000000..3811072
--- /dev/null
+++ b/include/protocols/CVS/Root
@@ -0,0 +1 @@
+/cvs
diff --git a/include/protocols/dumprestore.h b/include/protocols/dumprestore.h
new file mode 100644
index 0000000..9a94a0c
--- /dev/null
+++ b/include/protocols/dumprestore.h
@@ -0,0 +1,159 @@
+/* $OpenBSD: dumprestore.h,v 1.10 2014/07/11 16:01:40 halex Exp $ */
+/* $NetBSD: dumprestore.h,v 1.14 2005/12/26 19:01:47 perry Exp $ */
+
+/*
+ * Copyright (c) 1980, 1993
+ * The Regents of the University of California. All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)dumprestore.h 8.2 (Berkeley) 1/21/94
+ */
+
+#ifndef _PROTOCOLS_DUMPRESTORE_H_
+#define _PROTOCOLS_DUMPRESTORE_H_
+
+/*
+ * TP_BSIZE is the size of file blocks on the dump tapes.
+ * Note that TP_BSIZE must be a multiple of DEV_BSIZE.
+ *
+ * NTREC is the number of TP_BSIZE blocks that are written
+ * in each tape record. HIGHDENSITYTREC is the number of
+ * TP_BSIZE blocks that are written in each tape record on
+ * 6250 BPI or higher density tapes.
+ *
+ * TP_NINDIR is the number of indirect pointers in a TS_INODE
+ * or TS_ADDR record. Note that it must be a power of two.
+ */
+#define TP_BSIZE 1024
+#define NTREC 10
+#define HIGHDENSITYTREC 32
+#define TP_NINDIR (TP_BSIZE/2)
+#define LBLSIZE 16
+#define NAMELEN 64
+
+#define OFS_MAGIC (int)60011
+#define NFS_MAGIC (int)60012
+#ifndef FS_UFS2_MAGIC
+#define FS_UFS2_MAGIC (int)0x19540119
+#endif
+#define CHECKSUM (int)84446
+
+union u_spcl {
+ char dummy[TP_BSIZE];
+ struct s_spcl {
+ int32_t c_type; /* record type (see below) */
+ int32_t c_old_date; /* date of this dump */
+ int32_t c_old_ddate; /* date of previous dump */
+ int32_t c_volume; /* dump volume number */
+ int32_t c_old_tapea; /* logical block of this record */
+ uint32_t c_inumber; /* number of inode */
+ int32_t c_magic; /* magic number (see above) */
+ int32_t c_checksum; /* record checksum */
+ union {
+ struct ufs1_dinode __uc_dinode;
+ struct {
+ uint16_t __uc_mode;
+ int16_t __uc_spare1[3];
+ uint64_t __uc_size;
+ int32_t __uc_old_atime;
+ int32_t __uc_atimensec;
+ int32_t __uc_old_mtime;
+ int32_t __uc_mtimensec;
+ int32_t __uc_spare2[2];
+ int32_t __uc_rdev;
+ int32_t __uc_birthtimensec;
+ int64_t __uc_birthtime;
+ int64_t __uc_atime;
+ int64_t __uc_mtime;
+ int32_t __uc_spare4[7];
+ uint32_t __uc_file_flags;
+ int32_t __uc_spare5[2];
+ uint32_t __uc_uid;
+ uint32_t __uc_gid;
+ int32_t __uc_spare6[2];
+ } __uc_ino;
+ } __c_ino;
+ int32_t c_count; /* number of valid c_addr entries */
+ char c_addr[TP_NINDIR]; /* 1 => data; 0 => hole in inode */
+ char c_label[LBLSIZE]; /* dump label */
+ int32_t c_level; /* level of this dump */
+ char c_filesys[NAMELEN]; /* name of dumped file system */
+ char c_dev[NAMELEN]; /* name of dumped device */
+ char c_host[NAMELEN]; /* name of dumped host */
+ int32_t c_flags; /* additional information */
+ int32_t c_old_firstrec; /* first record on volume */
+ int64_t c_date; /* date of this dump */
+ int64_t c_ddate; /* date of previous dump */
+ int64_t c_tapea; /* logical block of this record */
+ int64_t c_firstrec; /* first record on volume */
+ int32_t c_spare[24]; /* reserved for future uses */
+ } s_spcl;
+} u_spcl;
+#define spcl u_spcl.s_spcl
+
+#define c_dinode __c_ino.__uc_dinode
+#define c_mode __c_ino.__uc_ino.__uc_mode
+#define c_spare1 __c_ino.__uc_ino.__uc_spare1
+#define c_size __c_ino.__uc_ino.__uc_size
+#define c_old_atime __c_ino.__uc_ino.__uc_old_atime
+#define c_atime __c_ino.__uc_ino.__uc_atime
+#define c_atimensec __c_ino.__uc_ino.__uc_atimensec
+#define c_mtime __c_ino.__uc_ino.__uc_mtime
+#define c_mtimensec __c_ino.__uc_ino.__uc_mtimensec
+#define c_birthtime __c_ino.__uc_ino.__uc_birthtime
+#define c_birthtimensec __c_ino.__uc_ino.__uc_birthtimensec
+#define c_old_mtime __c_ino.__uc_ino.__uc_old_mtime
+#define c_rdev __c_ino.__uc_ino.__uc_rdev
+#define c_file_flags __c_ino.__uc_ino.__uc_file_flags
+#define c_uid __c_ino.__uc_ino.__uc_uid
+#define c_gid __c_ino.__uc_ino.__uc_gid
+
+/*
+ * special record types
+ */
+#define TS_TAPE 1 /* dump tape header */
+#define TS_INODE 2 /* beginning of file record */
+#define TS_ADDR 4 /* continuation of file record */
+#define TS_BITS 3 /* map of inodes on tape */
+#define TS_CLRI 6 /* map of inodes deleted since last dump */
+#define TS_END 5 /* end of volume marker */
+
+/*
+ * flag values
+ */
+#define DR_NEWHEADER 0x0001 /* new format tape header */
+#define DR_NEWINODEFMT 0x0002 /* new format inodes on tape */
+
+#define DUMPOUTFMT "%-18s %c %s" /* for printf */
+ /* name, level, ctime(date) */
+#define DUMPINFMT "%18s %c %[^\n]\n" /* inverse for scanf */
+
+#endif /* !_PROTOCOLS_DUMPRESTORE_H_ */
diff --git a/include/protocols/routed.h b/include/protocols/routed.h
new file mode 100644
index 0000000..83331a4
--- /dev/null
+++ b/include/protocols/routed.h
@@ -0,0 +1,152 @@
+/* $OpenBSD: routed.h,v 1.3 2003/06/02 19:34:12 millert Exp $ */
+
+/*-
+ * Copyright (c) 1983, 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)routed.h 8.1 (Berkeley) 6/2/93
+ *
+ */
+
+#ifndef _ROUTED_H_
+#define _ROUTED_H_
+
+/*
+ * Routing Information Protocol
+ *
+ * Derived from Xerox NS Routing Information Protocol
+ * by changing 32-bit net numbers to sockaddr's and
+ * padding stuff to 32-bit boundaries.
+ */
+
+#define RIPv1 1
+#define RIPv2 2
+#ifndef RIPVERSION
+#define RIPVERSION RIPv1
+#endif
+
+#define RIP_PORT 520
+
+#if RIPVERSION == 1
+/* Note that this so called sockaddr has a 2-byte sa_family and no sa_len.
+ * It is not a UNIX sockaddr, but the shape of an address as defined
+ * in RIPv1. It is still defined to allow old versions of programs
+ * such as `gated` to use this file to define RIPv1.
+ */
+struct netinfo {
+ struct sockaddr rip_dst; /* destination net/host */
+ u_int32_t rip_metric; /* cost of route */
+};
+#else
+struct netinfo {
+ u_int16_t n_family;
+#define RIP_AF_INET htons(AF_INET)
+#define RIP_AF_UNSPEC 0
+#define RIP_AF_AUTH 0xffff
+ u_int16_t n_tag; /* optional in RIPv2 */
+ u_int32_t n_dst; /* destination net or host */
+#define RIP_DEFAULT 0
+ u_int32_t n_mask; /* netmask in RIPv2 */
+ u_int32_t n_nhop; /* optional next hop in RIPv2 */
+ u_int32_t n_metric; /* cost of route */
+};
+#endif
+
+/* RIPv2 authentication */
+struct netauth {
+ u_int16_t a_type;
+#define RIP_AUTH_PW htons(2) /* password type */
+ union {
+#define RIP_AUTH_PW_LEN 16
+ int8_t au_pw[RIP_AUTH_PW_LEN];
+ } au;
+};
+
+struct rip {
+ u_int8_t rip_cmd; /* request/response */
+ u_int8_t rip_vers; /* protocol version # */
+ u_int16_t rip_res1; /* pad to 32-bit boundary */
+ union { /* variable length... */
+ struct netinfo ru_nets[1];
+ int8_t ru_tracefile[1];
+ struct netauth ru_auth[1];
+ } ripun;
+#define rip_nets ripun.ru_nets
+#define rip_tracefile ripun.ru_tracefile
+};
+
+/* Packet types.
+ */
+#define RIPCMD_REQUEST 1 /* want info */
+#define RIPCMD_RESPONSE 2 /* responding to request */
+#define RIPCMD_TRACEON 3 /* turn tracing on */
+#define RIPCMD_TRACEOFF 4 /* turn it off */
+
+/* Gated extended RIP to include a "poll" command instead of using
+ * RIPCMD_REQUEST with (RIP_AF_UNSPEC, RIP_DEFAULT). RFC 1058 says
+ * command 5 is used by Sun Microsystems for its own purposes.
+ */
+#define RIPCMD_POLL 5
+
+#define RIPCMD_MAX 6
+
+#ifdef RIPCMDS
+char *ripcmds[RIPCMD_MAX] = {
+ "#0", "REQUEST", "RESPONSE", "TRACEON", "TRACEOFF"
+};
+#endif
+
+#define HOPCNT_INFINITY 16
+#define MAXPACKETSIZE 512 /* max broadcast size */
+#define NETS_LEN ((MAXPACKETSIZE-sizeof(struct rip)) \
+ / sizeof(struct netinfo) +1)
+
+#define INADDR_RIP_GROUP __IPADDR(0xe0000009) /* 224.0.0.9 */
+
+
+/* Timer values used in managing the routing table.
+ *
+ * Complete tables are broadcast every SUPPLY_INTERVAL seconds.
+ * If changes occur between updates, dynamic updates containing only changes
+ * may be sent. When these are sent, a timer is set for a random value
+ * between MIN_WAITTIME and MAX_WAITTIME, and no additional dynamic updates
+ * are sent until the timer expires.
+ *
+ * Every update of a routing entry forces an entry's timer to be reset.
+ * After EXPIRE_TIME without updates, the entry is marked invalid,
+ * but held onto until GARBAGE_TIME so that others may see it, to
+ * "poison" the bad route.
+ */
+#define SUPPLY_INTERVAL 30 /* time to supply tables */
+#define MIN_WAITTIME 2 /* min sec until next flash updates */
+#define MAX_WAITTIME 5 /* max sec until flash update */
+
+#define STALE_TIME 90 /* switch to a new gateway */
+#define EXPIRE_TIME 180 /* time to mark entry invalid */
+#define GARBAGE_TIME 240 /* time to garbage collect */
+
+#endif /* !_ROUTED_H_ */
diff --git a/include/protocols/rwhod.h b/include/protocols/rwhod.h
new file mode 100644
index 0000000..c182e96
--- /dev/null
+++ b/include/protocols/rwhod.h
@@ -0,0 +1,67 @@
+/* $OpenBSD: rwhod.h,v 1.4 2003/06/02 19:34:12 millert Exp $ */
+/* $NetBSD: rwhod.h,v 1.3 1994/10/26 00:56:51 cgd Exp $ */
+
+/*
+ * Copyright (c) 1983 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)rwhod.h 5.6 (Berkeley) 4/3/91
+ */
+
+#ifndef _RWHOD_H_
+#define _RWHOD_H_
+
+/*
+ * rwho protocol packet format.
+ */
+struct outmp {
+ char out_line[8]; /* tty name */
+ char out_name[8]; /* user id */
+ int32_t out_time; /* time on */
+};
+
+struct whod {
+ char wd_vers; /* protocol version # */
+ char wd_type; /* packet type, see below */
+ char wd_pad[2];
+ int32_t wd_sendtime; /* time stamp by sender */
+ int32_t wd_recvtime; /* time stamp applied by receiver */
+ char wd_hostname[32]; /* hosts's name */
+ int32_t wd_loadav[3]; /* load average as in uptime */
+ int32_t wd_boottime; /* time system booted */
+ struct whoent {
+ struct outmp we_utmp; /* active tty info */
+ int32_t we_idle; /* tty idle time */
+ } wd_we[1024 / sizeof (struct whoent)];
+};
+
+#define WHODVERSION 1
+#define WHODTYPE_STATUS 1 /* host status */
+
+#define _PATH_RWHODIR "/var/rwho"
+
+#endif /* !_RWHOD_H_ */
diff --git a/include/protocols/talkd.h b/include/protocols/talkd.h
new file mode 100644
index 0000000..fae2b42
--- /dev/null
+++ b/include/protocols/talkd.h
@@ -0,0 +1,120 @@
+/* $OpenBSD: talkd.h,v 1.5 2015/01/21 02:23:14 guenther Exp $ */
+/* $NetBSD: talkd.h,v 1.5 1995/03/04 07:59:30 cgd Exp $ */
+
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)talkd.h 5.7 (Berkeley) 4/3/91
+ */
+
+#ifndef _TALKD_H_
+#define _TALKD_H_
+
+/*
+ * This describes the protocol used by the talk server and clients.
+ *
+ * The talk server acts a repository of invitations, responding to
+ * requests by clients wishing to rendezvous for the purpose of
+ * holding a conversation. In normal operation, a client, the caller,
+ * initiates a rendezvous by sending a CTL_MSG to the server of
+ * type LOOK_UP. This causes the server to search its invitation
+ * tables to check if an invitation currently exists for the caller
+ * (to speak to the callee specified in the message). If the lookup
+ * fails, the caller then sends an ANNOUNCE message causing the server
+ * to broadcast an announcement on the callee's login ports requesting
+ * contact. When the callee responds, the local server uses the
+ * recorded invitation to respond with the appropriate rendezvous
+ * address and the caller and callee client programs establish a
+ * stream connection through which the conversation takes place.
+ */
+
+struct osockaddr {
+ unsigned short sa_family; /* address family */
+ char sa_data[14]; /* up to 14 bytes of direct address */
+};
+
+/*
+ * Client->server request message format.
+ */
+typedef struct {
+ unsigned char vers; /* protocol version */
+ unsigned char type; /* request type, see below */
+ unsigned char answer; /* not used */
+ unsigned char pad;
+ u_int32_t id_num; /* message id */
+ struct osockaddr addr; /* old (4.3) style */
+ struct osockaddr ctl_addr; /* old (4.3) style */
+ int32_t pid; /* caller's process id */
+#define NAME_SIZE 12
+ char l_name[NAME_SIZE]; /* caller's name */
+ char r_name[NAME_SIZE]; /* callee's name */
+#define TTY_SIZE 16
+ char r_tty[TTY_SIZE]; /* callee's tty name */
+} CTL_MSG;
+
+/*
+ * Server->client response message format.
+ */
+typedef struct {
+ unsigned char vers; /* protocol version */
+ unsigned char type; /* type of request message, see below */
+ unsigned char answer; /* response to request message,
+ see below */
+ unsigned char pad;
+ u_int32_t id_num; /* message id */
+ struct osockaddr addr; /* address for establishing
+ conversation */
+} CTL_RESPONSE;
+
+#define TALK_VERSION 1 /* protocol version */
+
+/* message type values */
+#define LEAVE_INVITE 0 /* leave invitation with server */
+#define LOOK_UP 1 /* check for invitation by callee */
+#define DELETE 2 /* delete invitation by caller */
+#define ANNOUNCE 3 /* announce invitation by caller */
+
+/* answer values */
+#define SUCCESS 0 /* operation completed properly */
+#define NOT_HERE 1 /* callee not logged in */
+#define FAILED 2 /* operation failed for unexplained reason */
+#define MACHINE_UNKNOWN 3 /* caller's machine name unknown */
+#define PERMISSION_DENIED 4 /* callee's tty doesn't permit announce */
+#define UNKNOWN_REQUEST 5 /* request has invalid type value */
+#define BADVERSION 6 /* request has invalid protocol version */
+#define BADADDR 7 /* request has invalid addr value */
+#define BADCTLADDR 8 /* request has invalid ctl_addr value */
+
+/*
+ * Operational parameters.
+ */
+#define MAX_LIFE 60 /* max time daemon saves invitations */
+/* RING_WAIT should be 10's of seconds less than MAX_LIFE */
+#define RING_WAIT 30 /* time to wait before resending invitation */
+
+#endif /* !_TALKD_H_ */
diff --git a/include/protocols/timed.h b/include/protocols/timed.h
new file mode 100644
index 0000000..12531d1
--- /dev/null
+++ b/include/protocols/timed.h
@@ -0,0 +1,101 @@
+/* $OpenBSD: timed.h,v 1.4 2015/01/16 00:27:00 deraadt Exp $ */
+/* $NetBSD: timed.h,v 1.5 1996/04/09 20:40:32 cgd Exp $ */
+
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)timed.h 1.10 (Berkeley) 4/3/91
+ */
+
+#ifndef _TIMED_H_
+#define _TIMED_H_
+
+/*
+ * Time Synchronization Protocol
+ */
+
+#define TSPVERSION 1
+#define ANYADDR NULL
+
+struct tsp {
+ u_int8_t tsp_type;
+ u_int8_t tsp_vers;
+ u_int16_t tsp_seq;
+ union {
+ struct {
+ int32_t tv_sec;
+ int32_t tv_usec;
+ } tspu_time;
+ char tspu_hopcnt;
+ } tsp_u;
+ char tsp_name[256];
+};
+
+#define tsp_time tsp_u.tspu_time
+#define tsp_hopcnt tsp_u.tspu_hopcnt
+
+/*
+ * Command types.
+ */
+#define TSP_ANY 0 /* match any types */
+#define TSP_ADJTIME 1 /* send adjtime */
+#define TSP_ACK 2 /* generic acknowledgement */
+#define TSP_MASTERREQ 3 /* ask for master's name */
+#define TSP_MASTERACK 4 /* acknowledge master request */
+#define TSP_SETTIME 5 /* send network time */
+#define TSP_MASTERUP 6 /* inform slaves that master is up */
+#define TSP_SLAVEUP 7 /* slave is up but not polled */
+#define TSP_ELECTION 8 /* advance candidature for master */
+#define TSP_ACCEPT 9 /* support candidature of master */
+#define TSP_REFUSE 10 /* reject candidature of master */
+#define TSP_CONFLICT 11 /* two or more masters present */
+#define TSP_RESOLVE 12 /* masters' conflict resolution */
+#define TSP_QUIT 13 /* reject candidature if master is up */
+#define TSP_DATE 14 /* reset the time (date command) */
+#define TSP_DATEREQ 15 /* remote request to reset the time */
+#define TSP_DATEACK 16 /* acknowledge time setting */
+#define TSP_TRACEON 17 /* turn tracing on */
+#define TSP_TRACEOFF 18 /* turn tracing off */
+#define TSP_MSITE 19 /* find out master's site */
+#define TSP_MSITEREQ 20 /* remote master's site request */
+#define TSP_TEST 21 /* for testing election algo */
+#define TSP_SETDATE 22 /* New from date command */
+#define TSP_SETDATEREQ 23 /* New remote for above */
+#define TSP_LOOP 24 /* loop detection packet */
+
+#define TSPTYPENUMBER 25
+
+#ifdef TSPTYPES
+char *tsptype[TSPTYPENUMBER] =
+ { "ANY", "ADJTIME", "ACK", "MASTERREQ", "MASTERACK", "SETTIME", "MASTERUP",
+ "SLAVEUP", "ELECTION", "ACCEPT", "REFUSE", "CONFLICT", "RESOLVE", "QUIT",
+ "DATE", "DATEREQ", "DATEACK", "TRACEON", "TRACEOFF", "MSITE", "MSITEREQ",
+ "TEST", "SETDATE", "SETDATEREQ", "LOOP" };
+#endif
+
+#endif /* !_TIMED_H_ */
diff --git a/include/pthread.h b/include/pthread.h
new file mode 100644
index 0000000..cfb1356
--- /dev/null
+++ b/include/pthread.h
@@ -0,0 +1,315 @@
+/* $OpenBSD: pthread.h,v 1.4 2018/03/05 01:15:26 deraadt Exp $ */
+
+/*
+ * Copyright (c) 1993, 1994 by Chris Provenzano, proven@mit.edu
+ * Copyright (c) 1995-1998 by John Birrell <jb@cimlogic.com.au>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Chris Provenzano.
+ * 4. The name of Chris Provenzano may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY CHRIS PROVENZANO ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL CHRIS PROVENZANO BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD: pthread.h,v 1.13 1999/07/31 08:36:07 rse Exp $
+ */
+#ifndef _PTHREAD_H_
+#define _PTHREAD_H_
+
+/*
+ * Header files.
+ */
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/signal.h>
+#include <limits.h>
+#include <sched.h>
+
+/*
+ * Run-time invariant values:
+ */
+#define PTHREAD_DESTRUCTOR_ITERATIONS 4
+#define PTHREAD_KEYS_MAX 256
+#define PTHREAD_STACK_MIN (1U << _MAX_PAGE_SHIFT)
+#define PTHREAD_THREADS_MAX ULONG_MAX
+
+/*
+ * Flags for threads and thread attributes.
+ */
+#define PTHREAD_DETACHED 0x1
+#define PTHREAD_SCOPE_SYSTEM 0x2
+#define PTHREAD_INHERIT_SCHED 0x4
+#define PTHREAD_NOFLOAT 0x8
+
+#define PTHREAD_CREATE_DETACHED PTHREAD_DETACHED
+#define PTHREAD_CREATE_JOINABLE 0
+#define PTHREAD_SCOPE_PROCESS 0
+#define PTHREAD_EXPLICIT_SCHED 0
+
+/*
+ * Flags for read/write lock attributes
+ */
+#define PTHREAD_PROCESS_PRIVATE 0
+#define PTHREAD_PROCESS_SHARED 1
+
+/*
+ * Flags for cancelling threads
+ */
+#define PTHREAD_CANCEL_ENABLE 0
+#define PTHREAD_CANCEL_DISABLE 1
+#define PTHREAD_CANCEL_DEFERRED 0
+#define PTHREAD_CANCEL_ASYNCHRONOUS 2
+#define PTHREAD_CANCELED ((void *) 1)
+
+/*
+ * Barrier flags
+ */
+#define PTHREAD_BARRIER_SERIAL_THREAD -1
+
+/*
+ * Forward structure definitions.
+ *
+ * These are mostly opaque to the user.
+ */
+struct pthread;
+struct pthread_attr;
+struct pthread_cond;
+struct pthread_cond_attr;
+struct pthread_mutex;
+struct pthread_mutex_attr;
+struct pthread_once;
+struct pthread_rwlock;
+struct pthread_rwlockattr;
+
+/*
+ * Primitive system data type definitions required by P1003.1c.
+ *
+ * Note that P1003.1c specifies that there are no defined comparison
+ * or assignment operators for the types pthread_attr_t, pthread_cond_t,
+ * pthread_condattr_t, pthread_mutex_t, pthread_mutexattr_t.
+ */
+typedef struct pthread *pthread_t;
+typedef struct pthread_attr *pthread_attr_t;
+typedef volatile struct pthread_mutex *pthread_mutex_t;
+typedef struct pthread_mutex_attr *pthread_mutexattr_t;
+typedef struct pthread_cond *pthread_cond_t;
+typedef struct pthread_cond_attr *pthread_condattr_t;
+typedef int pthread_key_t;
+typedef struct pthread_once pthread_once_t;
+typedef struct pthread_rwlock *pthread_rwlock_t;
+typedef struct pthread_rwlockattr *pthread_rwlockattr_t;
+typedef struct pthread_barrier *pthread_barrier_t;
+typedef struct pthread_barrierattr *pthread_barrierattr_t;
+typedef struct pthread_spinlock *pthread_spinlock_t;
+
+/*
+ * Additional type definitions:
+ *
+ * Note that P1003.1c reserves the prefixes pthread_ and PTHREAD_ for
+ * use in header symbols.
+ */
+typedef void *pthread_addr_t;
+typedef void *(*pthread_startroutine_t)(void *);
+
+/*
+ * Once definitions.
+ */
+struct pthread_once {
+ int state;
+ pthread_mutex_t mutex;
+};
+
+/*
+ * Flags for once initialization.
+ */
+#define PTHREAD_NEEDS_INIT 0
+#define PTHREAD_DONE_INIT 1
+
+/*
+ * Static once initialization values.
+ */
+#define PTHREAD_ONCE_INIT { PTHREAD_NEEDS_INIT, PTHREAD_MUTEX_INITIALIZER }
+
+/*
+ * Static initialization values.
+ */
+#define PTHREAD_MUTEX_INITIALIZER NULL
+#define PTHREAD_COND_INITIALIZER NULL
+#define PTHREAD_RWLOCK_INITIALIZER NULL
+
+#define PTHREAD_PRIO_NONE 0
+#define PTHREAD_PRIO_INHERIT 1
+#define PTHREAD_PRIO_PROTECT 2
+
+/*
+ * Mutex types.
+ */
+enum pthread_mutextype {
+ PTHREAD_MUTEX_ERRORCHECK = 1, /* Error checking mutex */
+ PTHREAD_MUTEX_RECURSIVE = 2, /* Recursive mutex */
+ PTHREAD_MUTEX_NORMAL = 3, /* No error checking */
+ PTHREAD_MUTEX_STRICT_NP = 4, /* Strict error checking */
+ PTHREAD_MUTEX_TYPE_MAX
+};
+
+#define PTHREAD_MUTEX_ERRORCHECK PTHREAD_MUTEX_ERRORCHECK
+#define PTHREAD_MUTEX_RECURSIVE PTHREAD_MUTEX_RECURSIVE
+#define PTHREAD_MUTEX_NORMAL PTHREAD_MUTEX_NORMAL
+#define PTHREAD_MUTEX_STRICT_NP PTHREAD_MUTEX_STRICT_NP
+#define PTHREAD_MUTEX_DEFAULT PTHREAD_MUTEX_STRICT_NP
+
+/*
+ * Thread function prototype definitions:
+ */
+__BEGIN_DECLS
+int pthread_atfork(void (*)(void), void (*)(void), void (*)(void));
+int pthread_attr_destroy(pthread_attr_t *);
+int pthread_attr_getstack(const pthread_attr_t *,
+ void **, size_t *);
+int pthread_attr_getstacksize(const pthread_attr_t *, size_t *);
+int pthread_attr_getstackaddr(const pthread_attr_t *, void **);
+int pthread_attr_getguardsize(const pthread_attr_t *, size_t *);
+int pthread_attr_getdetachstate(const pthread_attr_t *, int *);
+int pthread_attr_init(pthread_attr_t *);
+int pthread_attr_setstacksize(pthread_attr_t *, size_t);
+int pthread_attr_setstack(pthread_attr_t *, void *, size_t);
+int pthread_attr_setstackaddr(pthread_attr_t *, void *);
+int pthread_attr_setguardsize(pthread_attr_t *, size_t);
+int pthread_attr_setdetachstate(pthread_attr_t *, int);
+void pthread_cleanup_pop(int);
+void pthread_cleanup_push(void (*) (void *), void *routine_arg);
+int pthread_condattr_destroy(pthread_condattr_t *);
+int pthread_condattr_init(pthread_condattr_t *);
+
+int pthread_cond_broadcast(pthread_cond_t *);
+int pthread_cond_destroy(pthread_cond_t *);
+int pthread_cond_init(pthread_cond_t *,
+ const pthread_condattr_t *);
+int pthread_cond_signal(pthread_cond_t *);
+int pthread_cond_timedwait(pthread_cond_t *,
+ pthread_mutex_t *, const struct timespec *);
+int pthread_cond_wait(pthread_cond_t *, pthread_mutex_t *);
+int pthread_create(pthread_t *, const pthread_attr_t *,
+ void *(*) (void *), void *);
+int pthread_detach(pthread_t);
+int pthread_equal(pthread_t, pthread_t);
+__dead void pthread_exit(void *);
+void *pthread_getspecific(pthread_key_t);
+int pthread_join(pthread_t, void **);
+int pthread_key_create(pthread_key_t *,
+ void (*) (void *));
+int pthread_key_delete(pthread_key_t);
+int pthread_kill(pthread_t, int);
+int pthread_mutexattr_init(pthread_mutexattr_t *);
+int pthread_mutexattr_destroy(pthread_mutexattr_t *);
+int pthread_mutexattr_gettype(pthread_mutexattr_t *, int *);
+int pthread_mutexattr_settype(pthread_mutexattr_t *, int);
+int pthread_mutex_destroy(pthread_mutex_t *);
+int pthread_mutex_init(pthread_mutex_t *,
+ const pthread_mutexattr_t *);
+int pthread_mutex_lock(pthread_mutex_t *);
+int pthread_mutex_timedlock(pthread_mutex_t *,
+ const struct timespec *);
+int pthread_mutex_trylock(pthread_mutex_t *);
+int pthread_mutex_unlock(pthread_mutex_t *);
+int pthread_once(pthread_once_t *, void (*) (void));
+int pthread_rwlock_destroy(pthread_rwlock_t *);
+int pthread_rwlock_init(pthread_rwlock_t *,
+ const pthread_rwlockattr_t *);
+int pthread_rwlock_rdlock(pthread_rwlock_t *);
+int pthread_rwlock_timedrdlock(pthread_rwlock_t *,
+ const struct timespec *);
+int pthread_rwlock_timedwrlock(pthread_rwlock_t *,
+ const struct timespec *);
+int pthread_rwlock_tryrdlock(pthread_rwlock_t *);
+int pthread_rwlock_trywrlock(pthread_rwlock_t *);
+int pthread_rwlock_unlock(pthread_rwlock_t *);
+int pthread_rwlock_wrlock(pthread_rwlock_t *);
+int pthread_rwlockattr_init(pthread_rwlockattr_t *);
+int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *,
+ int *);
+int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *, int);
+int pthread_rwlockattr_destroy(pthread_rwlockattr_t *);
+pthread_t pthread_self(void);
+int pthread_setspecific(pthread_key_t, const void *);
+
+int pthread_cancel(pthread_t);
+int pthread_setcancelstate(int, int *);
+int pthread_setcanceltype(int, int *);
+void pthread_testcancel(void);
+
+int pthread_getprio(pthread_t);
+int pthread_setprio(pthread_t, int);
+void pthread_yield(void);
+
+int pthread_mutexattr_getprioceiling(pthread_mutexattr_t *,
+ int *);
+int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *,
+ int);
+int pthread_mutex_getprioceiling(pthread_mutex_t *, int *);
+int pthread_mutex_setprioceiling(pthread_mutex_t *, int, int *);
+
+int pthread_mutexattr_getprotocol(pthread_mutexattr_t *, int *);
+int pthread_mutexattr_setprotocol(pthread_mutexattr_t *, int);
+
+int pthread_condattr_getclock(const pthread_condattr_t *,
+ clockid_t *);
+int pthread_condattr_setclock(pthread_condattr_t *, clockid_t);
+
+int pthread_attr_getinheritsched(const pthread_attr_t *, int *);
+int pthread_attr_getschedparam(const pthread_attr_t *,
+ struct sched_param *);
+int pthread_attr_getschedpolicy(const pthread_attr_t *, int *);
+int pthread_attr_getscope(const pthread_attr_t *, int *);
+int pthread_attr_setinheritsched(pthread_attr_t *, int);
+int pthread_attr_setschedparam(pthread_attr_t *,
+ const struct sched_param *);
+int pthread_attr_setschedpolicy(pthread_attr_t *, int);
+int pthread_attr_setscope(pthread_attr_t *, int);
+int pthread_getschedparam(pthread_t pthread, int *,
+ struct sched_param *);
+int pthread_setschedparam(pthread_t, int,
+ const struct sched_param *);
+int pthread_getconcurrency(void);
+int pthread_setconcurrency(int);
+int pthread_barrier_init(pthread_barrier_t *,
+ pthread_barrierattr_t *, unsigned int);
+int pthread_barrier_destroy(pthread_barrier_t *);
+int pthread_barrier_wait(pthread_barrier_t *);
+int pthread_barrierattr_init(pthread_barrierattr_t *);
+int pthread_barrierattr_destroy(pthread_barrierattr_t *);
+int pthread_barrierattr_getpshared(pthread_barrierattr_t *, int *);
+int pthread_barrierattr_setpshared(pthread_barrierattr_t *, int);
+int pthread_spin_init(pthread_spinlock_t *, int);
+int pthread_spin_destroy(pthread_spinlock_t *);
+int pthread_spin_trylock(pthread_spinlock_t *);
+int pthread_spin_lock(pthread_spinlock_t *);
+int pthread_spin_unlock(pthread_spinlock_t *);
+
+#if __POSIX_VISIBLE >= 200112
+int pthread_getcpuclockid(pthread_t, clockid_t *);
+#endif
+__END_DECLS
+
+#endif /* _PTHREAD_H_ */
diff --git a/include/pthread_np.h b/include/pthread_np.h
new file mode 100644
index 0000000..fb7e962
--- /dev/null
+++ b/include/pthread_np.h
@@ -0,0 +1,56 @@
+/* $OpenBSD: pthread_np.h,v 1.3 2019/05/28 10:33:03 jca Exp $ */
+/*
+ * Copyright (c) 1996-98 John Birrell <jb@cimlogic.com.au>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by John Birrell.
+ * 4. Neither the name of the author nor the names of any co-contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+#ifndef _PTHREAD_NP_H_
+#define _PTHREAD_NP_H_
+
+#include <pthread.h>
+
+/*
+ * Non-POSIX type definitions:
+ */
+typedef void (*pthread_switch_routine_t)(pthread_t, pthread_t);
+
+/*
+ * Non-POSIX thread function prototype definitions:
+ */
+__BEGIN_DECLS
+int pthread_mutexattr_getkind_np(pthread_mutexattr_t);
+int pthread_mutexattr_setkind_np(pthread_mutexattr_t *, int);
+void pthread_get_name_np(pthread_t, char *, size_t);
+void pthread_set_name_np(pthread_t, const char *);
+int pthread_stackseg_np(pthread_t, stack_t *);
+int pthread_main_np(void);
+__END_DECLS
+
+#endif
diff --git a/include/pwd.h b/include/pwd.h
new file mode 100644
index 0000000..c1aabba
--- /dev/null
+++ b/include/pwd.h
@@ -0,0 +1,4 @@
+#include_next <pwd.h>
+#define setpassent(n) setpwent()
+const char *user_from_uid(uid_t, int);
+int uid_from_user(const char *, uid_t *);
diff --git a/include/ranlib.h b/include/ranlib.h
new file mode 100644
index 0000000..d56d120
--- /dev/null
+++ b/include/ranlib.h
@@ -0,0 +1,49 @@
+/* $OpenBSD: ranlib.h,v 1.3 2003/06/02 19:34:12 millert Exp $ */
+/* $NetBSD: ranlib.h,v 1.4 1994/10/26 00:56:14 cgd Exp $ */
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)ranlib.h 5.2 (Berkeley) 4/3/91
+ */
+
+#ifndef _RANLIB_H_
+#define _RANLIB_H_
+
+#define RANLIBMAG "__.SYMDEF" /* archive file name */
+#define RANLIBSKEW 3 /* creation time offset */
+
+struct ranlib {
+ union {
+ long ran_strx; /* string table index */
+ char *ran_name; /* in memory symbol name */
+ } ran_un;
+ long ran_off; /* archive file offset */
+};
+
+#endif /* !_RANLIB_H_ */
diff --git a/include/readpassphrase.h b/include/readpassphrase.h
new file mode 100644
index 0000000..cef36f0
--- /dev/null
+++ b/include/readpassphrase.h
@@ -0,0 +1,40 @@
+/* $OpenBSD: readpassphrase.h,v 1.5 2003/06/17 21:56:23 millert Exp $ */
+
+/*
+ * Copyright (c) 2000, 2002 Todd C. Miller <Todd.Miller@courtesan.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Sponsored in part by the Defense Advanced Research Projects
+ * Agency (DARPA) and Air Force Research Laboratory, Air Force
+ * Materiel Command, USAF, under agreement number F39502-99-1-0512.
+ */
+
+#ifndef _READPASSPHRASE_H_
+#define _READPASSPHRASE_H_
+
+#define RPP_ECHO_OFF 0x00 /* Turn off echo (default). */
+#define RPP_ECHO_ON 0x01 /* Leave echo on. */
+#define RPP_REQUIRE_TTY 0x02 /* Fail if there is no tty. */
+#define RPP_FORCELOWER 0x04 /* Force input to lower case. */
+#define RPP_FORCEUPPER 0x08 /* Force input to upper case. */
+#define RPP_SEVENBIT 0x10 /* Strip the high bit from input. */
+#define RPP_STDIN 0x20 /* Read from stdin, not /dev/tty */
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+char * readpassphrase(const char *, char *, size_t, int);
+__END_DECLS
+
+#endif /* !_READPASSPHRASE_H_ */
diff --git a/include/regex.h b/include/regex.h
new file mode 100644
index 0000000..e24d9ae
--- /dev/null
+++ b/include/regex.h
@@ -0,0 +1,104 @@
+/* $OpenBSD: regex.h,v 1.7 2012/12/05 23:19:57 deraadt Exp $ */
+/* $NetBSD: regex.h,v 1.4.6.1 1996/06/10 18:57:07 explorer Exp $ */
+
+/*-
+ * Copyright (c) 1992 Henry Spencer.
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Henry Spencer of the University of Toronto.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)regex.h 8.1 (Berkeley) 6/2/93
+ */
+
+#ifndef _REGEX_H_
+#define _REGEX_H_
+
+#include <sys/types.h>
+
+/* types */
+typedef off_t regoff_t;
+
+typedef struct {
+ int re_magic;
+ size_t re_nsub; /* number of parenthesized subexpressions */
+ const char *re_endp; /* end pointer for REG_PEND */
+ struct re_guts *re_g; /* none of your business :-) */
+} regex_t;
+
+typedef struct {
+ regoff_t rm_so; /* start of match */
+ regoff_t rm_eo; /* end of match */
+} regmatch_t;
+
+/* regcomp() flags */
+#define REG_BASIC 0000
+#define REG_EXTENDED 0001
+#define REG_ICASE 0002
+#define REG_NOSUB 0004
+#define REG_NEWLINE 0010
+#define REG_NOSPEC 0020
+#define REG_PEND 0040
+#define REG_DUMP 0200
+
+/* regerror() flags */
+#define REG_NOMATCH 1
+#define REG_BADPAT 2
+#define REG_ECOLLATE 3
+#define REG_ECTYPE 4
+#define REG_EESCAPE 5
+#define REG_ESUBREG 6
+#define REG_EBRACK 7
+#define REG_EPAREN 8
+#define REG_EBRACE 9
+#define REG_BADBR 10
+#define REG_ERANGE 11
+#define REG_ESPACE 12
+#define REG_BADRPT 13
+#define REG_EMPTY 14
+#define REG_ASSERT 15
+#define REG_INVARG 16
+#define REG_ATOI 255 /* convert name to number (!) */
+#define REG_ITOA 0400 /* convert number to name (!) */
+
+/* regexec() flags */
+#define REG_NOTBOL 00001
+#define REG_NOTEOL 00002
+#define REG_STARTEND 00004
+#define REG_TRACE 00400 /* tracing of execution */
+#define REG_LARGE 01000 /* force large representation */
+#define REG_BACKR 02000 /* force use of backref code */
+
+__BEGIN_DECLS
+int regcomp(regex_t *, const char *, int);
+size_t regerror(int, const regex_t *, char *, size_t);
+int regexec(const regex_t *, const char *, size_t, regmatch_t [], int);
+void regfree(regex_t *);
+__END_DECLS
+
+#endif /* !_REGEX_H_ */
diff --git a/include/resolv.h b/include/resolv.h
new file mode 100644
index 0000000..23f19f9
--- /dev/null
+++ b/include/resolv.h
@@ -0,0 +1,3 @@
+#include_next <resolv.h>
+int b64_ntop(unsigned char const *, size_t, char *, size_t);
+int b64_pton(char const *, unsigned char *, size_t);
diff --git a/include/rmd160.h b/include/rmd160.h
new file mode 100644
index 0000000..5137c59
--- /dev/null
+++ b/include/rmd160.h
@@ -0,0 +1,60 @@
+/* $OpenBSD: rmd160.h,v 1.17 2012/12/05 23:19:57 deraadt Exp $ */
+/*
+ * Copyright (c) 2001 Markus Friedl. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef _RMD160_H
+#define _RMD160_H
+
+#define RMD160_BLOCK_LENGTH 64
+#define RMD160_DIGEST_LENGTH 20
+#define RMD160_DIGEST_STRING_LENGTH (RMD160_DIGEST_LENGTH * 2 + 1)
+
+/* RMD160 context. */
+typedef struct RMD160Context {
+ u_int32_t state[5]; /* state */
+ u_int64_t count; /* number of bits, mod 2^64 */
+ u_int8_t buffer[RMD160_BLOCK_LENGTH]; /* input buffer */
+} RMD160_CTX;
+
+__BEGIN_DECLS
+void RMD160Init(RMD160_CTX *);
+void RMD160Transform(u_int32_t [5], const u_int8_t [RMD160_BLOCK_LENGTH])
+ __attribute__((__bounded__(__minbytes__,1,5)))
+ __attribute__((__bounded__(__minbytes__,2,RMD160_BLOCK_LENGTH)));
+void RMD160Update(RMD160_CTX *, const u_int8_t *, size_t)
+ __attribute__((__bounded__(__string__,2,3)));
+void RMD160Pad(RMD160_CTX *);
+void RMD160Final(u_int8_t [RMD160_DIGEST_LENGTH], RMD160_CTX *)
+ __attribute__((__bounded__(__minbytes__,1,RMD160_DIGEST_LENGTH)));
+char *RMD160End(RMD160_CTX *, char *)
+ __attribute__((__bounded__(__minbytes__,2,RMD160_DIGEST_STRING_LENGTH)));
+char *RMD160File(const char *, char *)
+ __attribute__((__bounded__(__minbytes__,2,RMD160_DIGEST_STRING_LENGTH)));
+char *RMD160FileChunk(const char *, char *, off_t, off_t)
+ __attribute__((__bounded__(__minbytes__,2,RMD160_DIGEST_STRING_LENGTH)));
+char *RMD160Data(const u_int8_t *, size_t, char *)
+ __attribute__((__bounded__(__string__,1,2)))
+ __attribute__((__bounded__(__minbytes__,3,RMD160_DIGEST_STRING_LENGTH)));
+__END_DECLS
+
+#endif /* _RMD160_H */
diff --git a/include/rpc/CVS/Entries b/include/rpc/CVS/Entries
new file mode 100644
index 0000000..da29e02
--- /dev/null
+++ b/include/rpc/CVS/Entries
@@ -0,0 +1,14 @@
+/auth.h/1.8/Sun Sep 13 12:29:03 2015//
+/auth_unix.h/1.5/Wed Sep 1 14:43:34 2010//
+/clnt.h/1.11/Wed Sep 1 14:43:34 2010//
+/pmap_clnt.h/1.7/Wed Sep 1 14:43:34 2010//
+/pmap_prot.h/1.6/Wed Sep 1 14:43:34 2010//
+/pmap_rmt.h/1.5/Wed Sep 1 14:43:34 2010//
+/rpc.h/1.11/Wed Sep 1 14:43:34 2010//
+/rpc_des.h/1.4/Wed Sep 1 14:43:34 2010//
+/rpc_msg.h/1.7/Wed Oct 29 04:34:21 2014//
+/svc.h/1.16/Sat Aug 27 04:28:28 2016//
+/svc_auth.h/1.5/Sun Sep 13 15:36:57 2015//
+/types.h/1.3/Wed Sep 1 14:43:34 2010//
+/xdr.h/1.12/Wed Sep 1 14:43:34 2010//
+D
diff --git a/include/rpc/CVS/Repository b/include/rpc/CVS/Repository
new file mode 100644
index 0000000..f7a5a0b
--- /dev/null
+++ b/include/rpc/CVS/Repository
@@ -0,0 +1 @@
+src/include/rpc
diff --git a/include/rpc/CVS/Root b/include/rpc/CVS/Root
new file mode 100644
index 0000000..3811072
--- /dev/null
+++ b/include/rpc/CVS/Root
@@ -0,0 +1 @@
+/cvs
diff --git a/include/rpc/auth.h b/include/rpc/auth.h
new file mode 100644
index 0000000..1cd94bb
--- /dev/null
+++ b/include/rpc/auth.h
@@ -0,0 +1,184 @@
+/* $OpenBSD: auth.h,v 1.8 2015/09/13 12:29:03 guenther Exp $ */
+/* $NetBSD: auth.h,v 1.7 1995/04/29 05:27:55 cgd Exp $ */
+
+/*
+ * Copyright (c) 2010, Oracle America, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ * * Neither the name of the "Oracle America, Inc." nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * from: @(#)auth.h 1.17 88/02/08 SMI
+ * @(#)auth.h 2.3 88/08/07 4.0 RPCSRC
+ */
+
+/*
+ * auth.h, Authentication interface.
+ *
+ * The data structures are completely opaque to the client. The client
+ * is required to pass a AUTH * to routines that create rpc
+ * "sessions".
+ */
+
+#ifndef _RPC_AUTH_H
+#define _RPC_AUTH_H
+#include <sys/cdefs.h>
+
+#define MAX_AUTH_BYTES 400
+#define MAXNETNAMELEN 255 /* maximum length of network user's name */
+
+/*
+ * Status returned from authentication check
+ */
+enum auth_stat {
+ AUTH_OK=0,
+ /*
+ * failed at remote end
+ */
+ AUTH_BADCRED=1, /* bogus credentials (seal broken) */
+ AUTH_REJECTEDCRED=2, /* client should begin new session */
+ AUTH_BADVERF=3, /* bogus verifier (seal broken) */
+ AUTH_REJECTEDVERF=4, /* verifier expired or was replayed */
+ AUTH_TOOWEAK=5, /* rejected due to security reasons */
+ /*
+ * failed locally
+ */
+ AUTH_INVALIDRESP=6, /* bogus response verifier */
+ AUTH_FAILED=7 /* some unknown reason */
+};
+
+typedef u_int32_t u_int32; /* 32-bit unsigned integers */
+
+union des_block {
+ struct {
+ u_int32 high;
+ u_int32 low;
+ } key;
+ char c[8];
+};
+typedef union des_block des_block;
+__BEGIN_DECLS
+extern bool_t xdr_des_block(XDR *, des_block *);
+__END_DECLS
+
+/*
+ * Authentication info. Opaque to client.
+ */
+struct opaque_auth {
+ enum_t oa_flavor; /* flavor of auth */
+ caddr_t oa_base; /* address of more auth stuff */
+ unsigned int oa_length; /* not to exceed MAX_AUTH_BYTES */
+};
+
+
+/*
+ * Auth handle, interface to client side authenticators.
+ */
+typedef struct __rpc_auth {
+ struct opaque_auth ah_cred;
+ struct opaque_auth ah_verf;
+ union des_block ah_key;
+ struct auth_ops {
+ void (*ah_nextverf)(struct __rpc_auth *);
+ /* nextverf & serialize */
+ int (*ah_marshal)(struct __rpc_auth *, XDR *);
+ /* validate varifier */
+ int (*ah_validate)(struct __rpc_auth *,
+ struct opaque_auth *);
+ /* refresh credentials */
+ int (*ah_refresh)(struct __rpc_auth *);
+ /* destroy this structure */
+ void (*ah_destroy)(struct __rpc_auth *);
+ } *ah_ops;
+ caddr_t ah_private;
+} AUTH;
+
+
+/*
+ * Authentication ops.
+ * The ops and the auth handle provide the interface to the authenticators.
+ *
+ * AUTH *auth;
+ * XDR *xdrs;
+ * struct opaque_auth verf;
+ */
+#define AUTH_NEXTVERF(auth) \
+ ((*((auth)->ah_ops->ah_nextverf))(auth))
+#define auth_nextverf(auth) \
+ ((*((auth)->ah_ops->ah_nextverf))(auth))
+
+#define AUTH_MARSHALL(auth, xdrs) \
+ ((*((auth)->ah_ops->ah_marshal))(auth, xdrs))
+#define auth_marshall(auth, xdrs) \
+ ((*((auth)->ah_ops->ah_marshal))(auth, xdrs))
+
+#define AUTH_VALIDATE(auth, verfp) \
+ ((*((auth)->ah_ops->ah_validate))((auth), verfp))
+#define auth_validate(auth, verfp) \
+ ((*((auth)->ah_ops->ah_validate))((auth), verfp))
+
+#define AUTH_REFRESH(auth) \
+ ((*((auth)->ah_ops->ah_refresh))(auth))
+#define auth_refresh(auth) \
+ ((*((auth)->ah_ops->ah_refresh))(auth))
+
+#define AUTH_DESTROY(auth) \
+ ((*((auth)->ah_ops->ah_destroy))(auth))
+#define auth_destroy(auth) \
+ ((*((auth)->ah_ops->ah_destroy))(auth))
+
+
+extern struct opaque_auth _null_auth;
+
+
+/*
+ * These are the various implementations of client side authenticators.
+ */
+
+/*
+ * Unix style authentication
+ * AUTH *authunix_create(machname, uid, gid, len, aup_gids)
+ * char *machname;
+ * int uid;
+ * int gid;
+ * int len;
+ * int *aup_gids;
+ */
+__BEGIN_DECLS
+struct sockaddr_in;
+extern AUTH *authunix_create(char *, int, int, int, int *);
+extern AUTH *authunix_create_default(void);
+extern AUTH *authnone_create(void);
+extern void set_rpc_maxgrouplist(int);
+__END_DECLS
+
+#define AUTH_NONE 0 /* no authentication */
+#define AUTH_NULL 0 /* backward compatibility */
+#define AUTH_UNIX 1 /* unix style (uid, gids) */
+#define AUTH_SHORT 2 /* short hand unix style */
+#define AUTH_DES 3 /* des style (encrypted timestamps) */
+
+#endif /* !_RPC_AUTH_H */
diff --git a/include/rpc/auth_unix.h b/include/rpc/auth_unix.h
new file mode 100644
index 0000000..1ebf92c
--- /dev/null
+++ b/include/rpc/auth_unix.h
@@ -0,0 +1,84 @@
+/* $OpenBSD: auth_unix.h,v 1.5 2010/09/01 14:43:34 millert Exp $ */
+/* $NetBSD: auth_unix.h,v 1.4 1994/10/26 00:56:56 cgd Exp $ */
+
+/*
+ * Copyright (c) 2010, Oracle America, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ * * Neither the name of the "Oracle America, Inc." nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * from: @(#)auth_unix.h 1.8 88/02/08 SMI
+ * @(#)auth_unix.h 2.2 88/07/29 4.0 RPCSRC
+ */
+
+/*
+ * auth_unix.h, Protocol for UNIX style authentication parameters for RPC
+ */
+
+/*
+ * The system is very weak. The client uses no encryption for it
+ * credentials and only sends null verifiers. The server sends backs
+ * null verifiers or optionally a verifier that suggests a new short hand
+ * for the credentials.
+ */
+
+#ifndef _RPC_AUTH_UNIX_H
+#define _RPC_AUTH_UNIX_H
+#include <sys/cdefs.h>
+
+/* The machine name is part of a credential; it may not exceed 255 bytes */
+#define MAX_MACHINE_NAME 255
+
+/* gids compose part of a credential; there may not be more than 16 of them */
+#define NGRPS 16
+
+/*
+ * Unix style credentials.
+ */
+struct authunix_parms {
+ unsigned long aup_time;
+ char *aup_machname;
+ int aup_uid;
+ int aup_gid;
+ unsigned int aup_len;
+ int *aup_gids;
+};
+
+__BEGIN_DECLS
+extern bool_t xdr_authunix_parms(XDR *, struct authunix_parms *);
+__END_DECLS
+
+/*
+ * If a response verifier has flavor AUTH_SHORT,
+ * then the body of the response verifier encapsulates the following structure;
+ * again it is serialized in the obvious fashion.
+ */
+struct short_hand_verf {
+ struct opaque_auth new_cred;
+};
+
+#endif /* !_RPC_AUTH_UNIX_H */
diff --git a/include/rpc/clnt.h b/include/rpc/clnt.h
new file mode 100644
index 0000000..e5a62e3
--- /dev/null
+++ b/include/rpc/clnt.h
@@ -0,0 +1,361 @@
+/* $OpenBSD: clnt.h,v 1.11 2010/09/01 14:43:34 millert Exp $ */
+/* $NetBSD: clnt.h,v 1.6 1995/04/29 05:27:58 cgd Exp $ */
+
+/*
+ * Copyright (c) 2010, Oracle America, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ * * Neither the name of the "Oracle America, Inc." nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * from: @(#)clnt.h 1.31 88/02/08 SMI
+ * @(#)clnt.h 2.1 88/07/29 4.0 RPCSRC
+ */
+
+/*
+ * clnt.h - Client side remote procedure call interface.
+ */
+
+#ifndef _RPC_CLNT_H_
+#define _RPC_CLNT_H_
+#include <sys/cdefs.h>
+
+/*
+ * Rpc calls return an enum clnt_stat. This should be looked at more,
+ * since each implementation is required to live with this (implementation
+ * independent) list of errors.
+ */
+enum clnt_stat {
+ RPC_SUCCESS=0, /* call succeeded */
+ /*
+ * local errors
+ */
+ RPC_CANTENCODEARGS=1, /* can't encode arguments */
+ RPC_CANTDECODERES=2, /* can't decode results */
+ RPC_CANTSEND=3, /* failure in sending call */
+ RPC_CANTRECV=4, /* failure in receiving result */
+ RPC_TIMEDOUT=5, /* call timed out */
+ /*
+ * remote errors
+ */
+ RPC_VERSMISMATCH=6, /* rpc versions not compatible */
+ RPC_AUTHERROR=7, /* authentication error */
+ RPC_PROGUNAVAIL=8, /* program not available */
+ RPC_PROGVERSMISMATCH=9, /* program version mismatched */
+ RPC_PROCUNAVAIL=10, /* procedure unavailable */
+ RPC_CANTDECODEARGS=11, /* decode arguments error */
+ RPC_SYSTEMERROR=12, /* generic "other problem" */
+
+ /*
+ * callrpc & clnt_create errors
+ */
+ RPC_UNKNOWNHOST=13, /* unknown host name */
+ RPC_UNKNOWNPROTO=17, /* unknown protocol */
+
+ /*
+ * _ create errors
+ */
+ RPC_PMAPFAILURE=14, /* the pmapper failed in its call */
+ RPC_PROGNOTREGISTERED=15, /* remote program is not registered */
+ /*
+ * unspecified error
+ */
+ RPC_FAILED=16
+};
+
+
+/*
+ * Error info.
+ */
+struct rpc_err {
+ enum clnt_stat re_status;
+ union {
+ int RE_errno; /* related system error */
+ enum auth_stat RE_why; /* why the auth error occurred */
+ struct {
+ u_int32_t low; /* lowest verion supported */
+ u_int32_t high; /* highest verion supported */
+ } RE_vers;
+ struct { /* maybe meaningful if RPC_FAILED */
+ int32_t s1;
+ int32_t s2;
+ } RE_lb; /* life boot & debugging only */
+ } ru;
+#define re_errno ru.RE_errno
+#define re_why ru.RE_why
+#define re_vers ru.RE_vers
+#define re_lb ru.RE_lb
+};
+
+
+/*
+ * Client rpc handle.
+ * Created by individual implementations, see e.g. rpc_udp.c.
+ * Client is responsible for initializing auth, see e.g. auth_none.c.
+ */
+typedef struct __rpc_client {
+ AUTH *cl_auth; /* authenticator */
+ struct clnt_ops {
+ /* call remote procedure */
+ enum clnt_stat (*cl_call)(struct __rpc_client *,
+ unsigned long, xdrproc_t, caddr_t,
+ xdrproc_t, caddr_t, struct timeval);
+ /* abort a call */
+ void (*cl_abort)(struct __rpc_client *);
+ /* get specific error code */
+ void (*cl_geterr)(struct __rpc_client *,
+ struct rpc_err *);
+ /* frees results */
+ bool_t (*cl_freeres)(struct __rpc_client *,
+ xdrproc_t, caddr_t);
+ /* destroy this structure */
+ void (*cl_destroy)(struct __rpc_client *);
+ /* the ioctl() of rpc */
+ bool_t (*cl_control)(struct __rpc_client *,
+ unsigned int, void *);
+ } *cl_ops;
+ caddr_t cl_private; /* private stuff */
+} CLIENT;
+
+
+/*
+ * client side rpc interface ops
+ *
+ * Parameter types are:
+ *
+ */
+
+/*
+ * enum clnt_stat
+ * CLNT_CALL(rh, proc, xargs, argsp, xres, resp, timeout)
+ * CLIENT *rh;
+ * unsigned long proc;
+ * xdrproc_t xargs;
+ * caddr_t argsp;
+ * xdrproc_t xres;
+ * caddr_t resp;
+ * struct timeval timeout;
+ */
+#define CLNT_CALL(rh, proc, xargs, argsp, xres, resp, secs) \
+ ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, (caddr_t)argsp, \
+ xres, (caddr_t)resp, secs))
+#define clnt_call(rh, proc, xargs, argsp, xres, resp, secs) \
+ ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, (caddr_t)argsp, \
+ xres, (caddr_t)resp, secs))
+
+/*
+ * void
+ * CLNT_ABORT(rh);
+ * CLIENT *rh;
+ */
+#define CLNT_ABORT(rh) ((*(rh)->cl_ops->cl_abort)(rh))
+#define clnt_abort(rh) ((*(rh)->cl_ops->cl_abort)(rh))
+
+/*
+ * struct rpc_err
+ * CLNT_GETERR(rh);
+ * CLIENT *rh;
+ */
+#define CLNT_GETERR(rh,errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp))
+#define clnt_geterr(rh,errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp))
+
+
+/*
+ * bool_t
+ * CLNT_FREERES(rh, xres, resp);
+ * CLIENT *rh;
+ * xdrproc_t xres;
+ * caddr_t resp;
+ */
+#define CLNT_FREERES(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp))
+#define clnt_freeres(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp))
+
+/*
+ * bool_t
+ * CLNT_CONTROL(cl, request, info)
+ * CLIENT *cl;
+ * unsigned int request;
+ * char *info;
+ */
+#define CLNT_CONTROL(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in))
+#define clnt_control(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in))
+
+/*
+ * control operations that apply to both udp and tcp transports
+ */
+#define CLSET_TIMEOUT 1 /* set timeout (timeval) */
+#define CLGET_TIMEOUT 2 /* get timeout (timeval) */
+#define CLGET_SERVER_ADDR 3 /* get server's address (sockaddr) */
+/*
+ * udp only control operations
+ */
+#define CLSET_RETRY_TIMEOUT 4 /* set retry timeout (timeval) */
+#define CLGET_RETRY_TIMEOUT 5 /* get retry timeout (timeval) */
+
+/*
+ * void
+ * CLNT_DESTROY(rh);
+ * CLIENT *rh;
+ */
+#define CLNT_DESTROY(rh) ((*(rh)->cl_ops->cl_destroy)(rh))
+#define clnt_destroy(rh) ((*(rh)->cl_ops->cl_destroy)(rh))
+
+
+/*
+ * RPCTEST is a test program which is accessable on every rpc
+ * transport/port. It is used for testing, performance evaluation,
+ * and network administration.
+ */
+
+#define RPCTEST_PROGRAM ((unsigned long)1)
+#define RPCTEST_VERSION ((unsigned long)1)
+#define RPCTEST_NULL_PROC ((unsigned long)2)
+#define RPCTEST_NULL_BATCH_PROC ((unsigned long)3)
+
+/*
+ * By convention, procedure 0 takes null arguments and returns them
+ */
+
+#define NULLPROC ((unsigned int)0)
+
+/*
+ * Below are the client handle creation routines for the various
+ * implementations of client side rpc. They can return NULL if a
+ * creation failure occurs.
+ */
+
+/*
+ * Memory based rpc (for speed check and testing)
+ * CLIENT *
+ * clntraw_create(prog, vers)
+ * unsigned long prog;
+ * unsigned long vers;
+ */
+__BEGIN_DECLS
+extern CLIENT *clntraw_create(unsigned long, unsigned long);
+__END_DECLS
+
+
+/*
+ * Generic client creation routine. Supported protocols are "udp" and "tcp"
+ * CLIENT *
+ * clnt_create(host, prog, vers, prot);
+ * char *host; -- hostname
+ * unsigned long prog; -- program number
+ * unsigned long vers; -- version number
+ * char *prot; -- protocol
+ */
+__BEGIN_DECLS
+extern CLIENT *clnt_create(char *, unsigned long, unsigned long, char *);
+__END_DECLS
+
+
+/*
+ * TCP based rpc
+ * CLIENT *
+ * clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz)
+ * struct sockaddr_in *raddr;
+ * unsigned long prog;
+ * unsigned long version;
+ * int *sockp;
+ * unsigned int sendsz;
+ * unsigned int recvsz;
+ */
+__BEGIN_DECLS
+extern CLIENT *clnttcp_create(struct sockaddr_in *, unsigned long,
+ unsigned long, int *, unsigned int, unsigned int);
+__END_DECLS
+
+
+/*
+ * UDP based rpc.
+ * CLIENT *
+ * clntudp_create(raddr, program, version, wait, sockp)
+ * struct sockaddr_in *raddr;
+ * unsigned long program;
+ * unsigned long version;
+ * struct timeval wait;
+ * int *sockp;
+ *
+ * Same as above, but you specify max packet sizes.
+ * CLIENT *
+ * clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz)
+ * struct sockaddr_in *raddr;
+ * unsigned long program;
+ * unsigned long version;
+ * struct timeval wait;
+ * int *sockp;
+ * unsigned int sendsz;
+ * unsigned int recvsz;
+ */
+__BEGIN_DECLS
+extern CLIENT *clntudp_create(struct sockaddr_in *, unsigned long,
+ unsigned long, struct timeval, int *);
+extern CLIENT *clntudp_bufcreate(struct sockaddr_in *, unsigned long,
+ unsigned long, struct timeval, int *, unsigned int, unsigned int);
+__END_DECLS
+
+
+/*
+ * Print why creation failed
+ */
+__BEGIN_DECLS
+extern void clnt_pcreateerror(char *); /* stderr */
+extern char *clnt_spcreateerror(char *); /* string */
+__END_DECLS
+
+/*
+ * Like clnt_perror(), but is more verbose in its output
+ */
+__BEGIN_DECLS
+extern void clnt_perrno(enum clnt_stat); /* stderr */
+extern char *clnt_sperrno(enum clnt_stat); /* string */
+__END_DECLS
+
+/*
+ * Print an English error message, given the client error code
+ */
+__BEGIN_DECLS
+extern void clnt_perror(CLIENT *, char *); /* stderr */
+extern char *clnt_sperror(CLIENT *, char *); /* string */
+__END_DECLS
+
+
+/*
+ * If a creation fails, the following allows the user to figure out why.
+ */
+struct rpc_createerr {
+ enum clnt_stat cf_stat;
+ struct rpc_err cf_error; /* useful when cf_stat == RPC_PMAPFAILURE */
+};
+
+extern struct rpc_createerr rpc_createerr;
+
+
+#define UDPMSGSIZE 8800 /* rpc imposed limit on udp msg size */
+#define RPCSMALLMSGSIZE 400 /* a more reasonable packet size */
+
+#endif /* !_RPC_CLNT_H */
diff --git a/include/rpc/pmap_clnt.h b/include/rpc/pmap_clnt.h
new file mode 100644
index 0000000..06aa27f
--- /dev/null
+++ b/include/rpc/pmap_clnt.h
@@ -0,0 +1,85 @@
+/* $OpenBSD: pmap_clnt.h,v 1.7 2010/09/01 14:43:34 millert Exp $ */
+/* $NetBSD: pmap_clnt.h,v 1.5 1994/12/04 01:12:42 cgd Exp $ */
+
+/*
+ * Copyright (c) 2010, Oracle America, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ * * Neither the name of the "Oracle America, Inc." nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * from: @(#)pmap_clnt.h 1.11 88/02/08 SMI
+ * @(#)pmap_clnt.h 2.1 88/07/29 4.0 RPCSRC
+ */
+
+/*
+ * pmap_clnt.h
+ * Supplies C routines to get to portmap services.
+ */
+
+/*
+ * Usage:
+ * success = pmap_set(program, version, protocol, port);
+ * success = pmap_unset(program, version);
+ * port = pmap_getport(address, program, version, protocol);
+ * head = pmap_getmaps(address);
+ * clnt_stat = pmap_rmtcall(address, program, version, procedure,
+ * xdrargs, argsp, xdrres, resp, tout, port_ptr)
+ * (works for udp only.)
+ * clnt_stat = clnt_broadcast(program, version, procedure,
+ * xdrargs, argsp, xdrres, resp, eachresult)
+ * (like pmap_rmtcall, except the call is broadcasted to all
+ * locally connected nets. For each valid response received,
+ * the procedure eachresult is called. Its form is:
+ * done = eachresult(resp, raddr)
+ * bool_t done;
+ * caddr_t resp;
+ * struct sockaddr_in raddr;
+ * where resp points to the results of the call and raddr is the
+ * address if the responder to the broadcast.
+ */
+
+#ifndef _RPC_PMAPCLNT_H
+#define _RPC_PMAPCLNT_H
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+extern bool_t pmap_set(unsigned long, unsigned long, unsigned int,
+ int);
+extern bool_t pmap_unset(unsigned long, unsigned long);
+extern struct pmaplist *pmap_getmaps(struct sockaddr_in *);
+extern enum clnt_stat pmap_rmtcall(struct sockaddr_in *, unsigned long,
+ unsigned long, unsigned long, xdrproc_t, caddr_t,
+ xdrproc_t, caddr_t, struct timeval,
+ unsigned long *);
+extern enum clnt_stat clnt_broadcast(unsigned long, unsigned long,
+ unsigned long, xdrproc_t, char *, xdrproc_t, char *,
+ bool_t (*)(caddr_t, struct sockaddr_in *));
+extern unsigned short pmap_getport(struct sockaddr_in *, unsigned long,
+ unsigned long, unsigned int);
+__END_DECLS
+
+#endif /* !_RPC_PMAPCLNT_H */
diff --git a/include/rpc/pmap_prot.h b/include/rpc/pmap_prot.h
new file mode 100644
index 0000000..58e4fa7
--- /dev/null
+++ b/include/rpc/pmap_prot.h
@@ -0,0 +1,106 @@
+/* $OpenBSD: pmap_prot.h,v 1.6 2010/09/01 14:43:34 millert Exp $ */
+/* $NetBSD: pmap_prot.h,v 1.4 1994/10/26 00:57:00 cgd Exp $ */
+
+/*
+ * Copyright (c) 2010, Oracle America, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ * * Neither the name of the "Oracle America, Inc." nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * from: @(#)pmap_prot.h 1.14 88/02/08 SMI
+ * @(#)pmap_prot.h 2.1 88/07/29 4.0 RPCSRC
+ */
+
+/*
+ * pmap_prot.h
+ * Protocol for the local binder service, or pmap.
+ *
+ * The following procedures are supported by the protocol:
+ *
+ * PMAPPROC_NULL() returns ()
+ * takes nothing, returns nothing
+ *
+ * PMAPPROC_SET(struct pmap) returns (bool_t)
+ * TRUE is success, FALSE is failure. Registers the tuple
+ * [prog, vers, prot, port].
+ *
+ * PMAPPROC_UNSET(struct pmap) returns (bool_t)
+ * TRUE is success, FALSE is failure. Un-registers pair
+ * [prog, vers]. prot and port are ignored.
+ *
+ * PMAPPROC_GETPORT(struct pmap) returns (unsigned long).
+ * 0 is failure. Otherwise returns the port number where the pair
+ * [prog, vers] is registered. It may lie!
+ *
+ * PMAPPROC_DUMP() RETURNS (struct pmaplist *)
+ *
+ * PMAPPROC_CALLIT(unsigned int, unsigned int, unsigned int, string<>)
+ * RETURNS (port, string<>);
+ * usage: encapsulatedresults = PMAPPROC_CALLIT(prog, vers, proc, encapsulatedargs);
+ * Calls the procedure on the local machine. If it is not registered,
+ * this procedure is quite; ie it does not return error information!!!
+ * This procedure only is supported on rpc/udp and calls via
+ * rpc/udp. This routine only passes null authentication parameters.
+ * This file has no interface to xdr routines for PMAPPROC_CALLIT.
+ *
+ * The service supports remote procedure calls on udp/ip or tcp/ip socket 111.
+ */
+
+#ifndef _RPC_PMAPPROT_H
+#define _RPC_PMAPPROT_H
+#include <sys/cdefs.h>
+
+#define PMAPPORT ((unsigned short)111)
+#define PMAPPROG ((unsigned long)100000)
+#define PMAPVERS ((unsigned long)2)
+#define PMAPVERS_PROTO ((unsigned long)2)
+#define PMAPVERS_ORIG ((unsigned long)1)
+#define PMAPPROC_NULL ((unsigned long)0)
+#define PMAPPROC_SET ((unsigned long)1)
+#define PMAPPROC_UNSET ((unsigned long)2)
+#define PMAPPROC_GETPORT ((unsigned long)3)
+#define PMAPPROC_DUMP ((unsigned long)4)
+#define PMAPPROC_CALLIT ((unsigned long)5)
+
+struct pmap {
+ unsigned long pm_prog;
+ unsigned long pm_vers;
+ unsigned long pm_prot;
+ unsigned long pm_port;
+};
+
+struct pmaplist {
+ struct pmap pml_map;
+ struct pmaplist *pml_next;
+};
+
+__BEGIN_DECLS
+extern bool_t xdr_pmap(XDR *, struct pmap *);
+extern bool_t xdr_pmaplist(XDR *, struct pmaplist **);
+__END_DECLS
+
+#endif /* !_RPC_PMAPPROT_H */
diff --git a/include/rpc/pmap_rmt.h b/include/rpc/pmap_rmt.h
new file mode 100644
index 0000000..5d65136
--- /dev/null
+++ b/include/rpc/pmap_rmt.h
@@ -0,0 +1,65 @@
+/* $OpenBSD: pmap_rmt.h,v 1.5 2010/09/01 14:43:34 millert Exp $ */
+/* $NetBSD: pmap_rmt.h,v 1.4 1994/10/26 00:57:01 cgd Exp $ */
+
+/*
+ * Copyright (c) 2010, Oracle America, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ * * Neither the name of the "Oracle America, Inc." nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * from: @(#)pmap_rmt.h 1.2 88/02/08 SMI
+ * @(#)pmap_rmt.h 2.1 88/07/29 4.0 RPCSRC
+ */
+
+/*
+ * Structures and XDR routines for parameters to and replies from
+ * the portmapper remote-call-service.
+ */
+
+#ifndef _RPC_PMAPRMT_H
+#define _RPC_PMAPRMT_H
+#include <sys/cdefs.h>
+
+struct rmtcallargs {
+ unsigned long prog, vers, proc, arglen;
+ caddr_t args_ptr;
+ xdrproc_t xdr_args;
+};
+
+struct rmtcallres {
+ unsigned long *port_ptr;
+ unsigned long resultslen;
+ caddr_t results_ptr;
+ xdrproc_t xdr_results;
+};
+
+__BEGIN_DECLS
+extern bool_t xdr_rmtcall_args(XDR *, struct rmtcallargs *);
+extern bool_t xdr_rmtcallres(XDR *, struct rmtcallres *);
+__END_DECLS
+
+#endif /* !_RPC_PMAPRMT_H */
diff --git a/include/rpc/rpc.h b/include/rpc/rpc.h
new file mode 100644
index 0000000..be9a3dc
--- /dev/null
+++ b/include/rpc/rpc.h
@@ -0,0 +1,108 @@
+/* $OpenBSD: rpc.h,v 1.11 2010/09/01 14:43:34 millert Exp $ */
+/* $NetBSD: rpc.h,v 1.5 1994/12/04 01:15:30 cgd Exp $ */
+
+/*
+ * Copyright (c) 2010, Oracle America, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ * * Neither the name of the "Oracle America, Inc." nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * from: @(#)rpc.h 1.9 88/02/08 SMI
+ * @(#)rpc.h 2.4 89/07/11 4.0 RPCSRC
+ */
+
+/*
+ * rpc.h, Just includes the billions of rpc header files necessary to
+ * do remote procedure calling.
+ */
+#ifndef _RPC_RPC_H
+#define _RPC_RPC_H
+
+#include <rpc/types.h> /* some typedefs */
+#include <netinet/in.h>
+
+/* external data representation interfaces */
+#include <rpc/xdr.h> /* generic (de)serializer */
+
+/* Client side only authentication */
+#include <rpc/auth.h> /* generic authenticator (client side) */
+
+/* Client side (mostly) remote procedure call */
+#include <rpc/clnt.h> /* generic rpc stuff */
+
+/* Client side (mostly) pmap functions */
+#include <rpc/pmap_clnt.h> /* generic pmap stuff */
+
+/* semi-private protocol headers */
+#include <rpc/rpc_msg.h> /* protocol for rpc messages */
+#include <rpc/auth_unix.h> /* protocol for unix style cred */
+/*
+ * Uncomment-out the next line if you are building the rpc library with
+ * DES Authentication (see the README file in the secure_rpc/ directory).
+ */
+#ifdef notdef
+#include <rpc/auth_des.h> /* protocol for des style cred */
+#endif
+
+/* Server side only remote procedure callee */
+#include <rpc/svc.h> /* service manager and multiplexer */
+#include <rpc/svc_auth.h> /* service side authenticator */
+
+/*
+ * COMMENT OUT THE NEXT INCLUDE (or add to the #ifndef) IF RUNNING ON
+ * A VERSION OF UNIX THAT USES SUN'S NFS SOURCE. These systems will
+ * already have the structures defined by <rpc/netdb.h> included in <netdb.h>.
+ */
+/* routines for parsing /etc/rpc */
+
+struct rpcent {
+ char *r_name; /* name of server for this rpc program */
+ char **r_aliases; /* alias list */
+ int r_number; /* rpc program number */
+};
+
+__BEGIN_DECLS
+extern struct rpcent *getrpcbyname(char *);
+extern struct rpcent *getrpcbynumber(int);
+extern struct rpcent *getrpcent(void);
+extern void setrpcent(int);
+extern void endrpcent(void);
+
+extern int get_myaddress(struct sockaddr_in *);
+extern int registerrpc(int, int, int, char *(*)(char [UDPMSGSIZE]),
+ xdrproc_t, xdrproc_t);
+extern int callrpc(char *, int, int, int, xdrproc_t, char *,
+ xdrproc_t , char *);
+extern int getrpcport(char *, int, int, int);
+
+extern bool_t xdr_opaque_auth(XDR *, struct opaque_auth *);
+
+extern int _rpc_dtablesize(void);
+
+__END_DECLS
+
+#endif /* !_RPC_RPC_H */
diff --git a/include/rpc/rpc_des.h b/include/rpc/rpc_des.h
new file mode 100644
index 0000000..92f5a85
--- /dev/null
+++ b/include/rpc/rpc_des.h
@@ -0,0 +1,135 @@
+/* $OpenBSD: rpc_des.h,v 1.4 2010/09/01 14:43:34 millert Exp $ */
+
+/* crypto/des/rpc_des.h */
+/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@mincom.oz.au).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@mincom.oz.au).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@mincom.oz.au)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@mincom.oz.au)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+/* @(#)des.h 2.2 88/08/10 4.0 RPCSRC; from 2.7 88/02/08 SMI */
+/*
+ * Copyright (c) 2010, Oracle America, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ * * Neither the name of the "Oracle America, Inc." nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Generic DES driver interface
+ * Keep this file hardware independent!
+ */
+
+#define DES_MAXLEN 65536 /* maximum # of bytes to encrypt */
+#define DES_QUICKLEN 16 /* maximum # of bytes to encrypt quickly */
+
+#ifdef HEADER_DES_H
+#undef ENCRYPT
+#undef DECRYPT
+#endif
+
+enum desdir { ENCRYPT, DECRYPT };
+enum desmode { CBC, ECB };
+
+/*
+ * parameters to ioctl call
+ */
+struct desparams {
+ unsigned char des_key[8]; /* key (with low bit parity) */
+ enum desdir des_dir; /* direction */
+ enum desmode des_mode; /* mode */
+ unsigned char des_ivec[8]; /* input vector */
+ unsigned int des_len; /* number of bytes to crypt */
+ union {
+ unsigned char UDES_data[DES_QUICKLEN];
+ unsigned char *UDES_buf;
+ } UDES;
+# define des_data UDES.UDES_data /* direct data here if quick */
+# define des_buf UDES.UDES_buf /* otherwise, pointer to data */
+};
+
+/*
+ * Encrypt an arbitrary sized buffer
+ */
+#define DESIOCBLOCK _IOWR(d, 6, struct desparams)
+
+/*
+ * Encrypt of small amount of data, quickly
+ */
+#define DESIOCQUICK _IOWR(d, 7, struct desparams)
+
diff --git a/include/rpc/rpc_msg.h b/include/rpc/rpc_msg.h
new file mode 100644
index 0000000..1e40dbe
--- /dev/null
+++ b/include/rpc/rpc_msg.h
@@ -0,0 +1,200 @@
+/* $OpenBSD: rpc_msg.h,v 1.7 2014/10/29 04:34:21 guenther Exp $ */
+/* $NetBSD: rpc_msg.h,v 1.5 1995/04/29 05:28:00 cgd Exp $ */
+
+/*
+ * Copyright (c) 2010, Oracle America, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ * * Neither the name of the "Oracle America, Inc." nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * from: @(#)rpc_msg.h 1.7 86/07/16 SMI
+ * @(#)rpc_msg.h 2.1 88/07/29 4.0 RPCSRC
+ */
+
+/*
+ * rpc_msg.h
+ * rpc message definition
+ */
+
+#ifndef _RPC_RPCMSG_H
+#define _RPC_RPCMSG_H
+
+#define RPC_MSG_VERSION ((unsigned long) 2)
+#define RPC_SERVICE_PORT ((unsigned short) 2048)
+
+/*
+ * Bottom up definition of an rpc message.
+ * NOTE: call and reply use the same overall struct but
+ * different parts of unions within it.
+ */
+
+enum msg_type {
+ CALL=0,
+ REPLY=1
+};
+
+enum reply_stat {
+ MSG_ACCEPTED=0,
+ MSG_DENIED=1
+};
+
+enum accept_stat {
+ SUCCESS=0,
+ PROG_UNAVAIL=1,
+ PROG_MISMATCH=2,
+ PROC_UNAVAIL=3,
+ GARBAGE_ARGS=4,
+ SYSTEM_ERR=5
+};
+
+enum reject_stat {
+ RPC_MISMATCH=0,
+ AUTH_ERROR=1
+};
+
+/*
+ * Reply part of an rpc exchange
+ */
+
+/*
+ * Reply to an rpc request that was accepted by the server.
+ * Note: there could be an error even though the request was
+ * accepted.
+ */
+struct accepted_reply {
+ struct opaque_auth ar_verf;
+ enum accept_stat ar_stat;
+ union {
+ struct {
+ u_int32_t low;
+ u_int32_t high;
+ } AR_versions;
+ struct {
+ caddr_t where;
+ xdrproc_t proc;
+ } AR_results;
+ /* and many other null cases */
+ } ru;
+#define ar_results ru.AR_results
+#define ar_vers ru.AR_versions
+};
+
+/*
+ * Reply to an rpc request that was rejected by the server.
+ */
+struct rejected_reply {
+ enum reject_stat rj_stat;
+ union {
+ struct {
+ u_int32_t low;
+ u_int32_t high;
+ } RJ_versions;
+ enum auth_stat RJ_why; /* why authentication did not work */
+ } ru;
+#define rj_vers ru.RJ_versions
+#define rj_why ru.RJ_why
+};
+
+/*
+ * Body of a reply to an rpc request.
+ */
+struct reply_body {
+ enum reply_stat rp_stat;
+ union {
+ struct accepted_reply RP_ar;
+ struct rejected_reply RP_dr;
+ } ru;
+#define rp_acpt ru.RP_ar
+#define rp_rjct ru.RP_dr
+};
+
+/*
+ * Body of an rpc request call.
+ */
+struct call_body {
+ u_int32_t cb_rpcvers; /* must be equal to two */
+ u_int32_t cb_prog;
+ u_int32_t cb_vers;
+ u_int32_t cb_proc;
+ struct opaque_auth cb_cred;
+ struct opaque_auth cb_verf; /* protocol specific - provided by client */
+};
+
+/*
+ * The rpc message
+ */
+struct rpc_msg {
+ u_int32_t rm_xid;
+ enum msg_type rm_direction;
+ union {
+ struct call_body RM_cmb;
+ struct reply_body RM_rmb;
+ } ru;
+#define rm_call ru.RM_cmb
+#define rm_reply ru.RM_rmb
+};
+#define acpted_rply ru.RM_rmb.ru.RP_ar
+#define rjcted_rply ru.RM_rmb.ru.RP_dr
+
+__BEGIN_DECLS
+/*
+ * XDR routine to handle a rpc message.
+ * xdr_callmsg(xdrs, cmsg)
+ * XDR *xdrs;
+ * struct rpc_msg *cmsg;
+ */
+extern bool_t xdr_callmsg(XDR *, struct rpc_msg *);
+
+/*
+ * XDR routine to pre-serialize the static part of a rpc message.
+ * xdr_callhdr(xdrs, cmsg)
+ * XDR *xdrs;
+ * struct rpc_msg *cmsg;
+ */
+extern bool_t xdr_callhdr(XDR *, struct rpc_msg *);
+
+/*
+ * XDR routine to handle a rpc reply.
+ * xdr_replymsg(xdrs, rmsg)
+ * XDR *xdrs;
+ * struct rpc_msg *rmsg;
+ */
+extern bool_t xdr_replymsg(XDR *, struct rpc_msg *);
+
+extern bool_t xdr_accepted_reply(XDR *, struct accepted_reply *);
+extern bool_t xdr_rejected_reply(XDR *, struct rejected_reply *);
+
+/*
+ * Fills in the error part of a reply message.
+ * _seterr_reply(msg, error)
+ * struct rpc_msg *msg;
+ * struct rpc_err *error;
+ */
+extern void _seterr_reply(struct rpc_msg *, struct rpc_err *);
+__END_DECLS
+
+#endif /* !_RPC_RPCMSG_H */
diff --git a/include/rpc/svc.h b/include/rpc/svc.h
new file mode 100644
index 0000000..7402420
--- /dev/null
+++ b/include/rpc/svc.h
@@ -0,0 +1,326 @@
+/* $OpenBSD: svc.h,v 1.16 2016/08/27 04:28:28 guenther Exp $ */
+/* $NetBSD: svc.h,v 1.9 1995/04/29 05:28:01 cgd Exp $ */
+
+/*
+ * Copyright (c) 2010, Oracle America, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ * * Neither the name of the "Oracle America, Inc." nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * from: @(#)svc.h 1.20 88/02/08 SMI
+ * @(#)svc.h 2.2 88/07/29 4.0 RPCSRC
+ */
+
+/*
+ * svc.h, Server-side remote procedure call interface.
+ */
+
+#ifndef _RPC_SVC_H
+#define _RPC_SVC_H
+#include <sys/cdefs.h>
+#include <poll.h>
+
+/*
+ * This interface must manage two items concerning remote procedure calling:
+ *
+ * 1) An arbitrary number of transport connections upon which rpc requests
+ * are received. The two most notable transports are TCP and UDP; they are
+ * created and registered by routines in svc_tcp.c and svc_udp.c, respectively;
+ * they in turn call xprt_register and xprt_unregister.
+ *
+ * 2) An arbitrary number of locally registered services. Services are
+ * described by the following four data: program number, version number,
+ * "service dispatch" function, a transport handle, and a boolean that
+ * indicates whether or not the exported program should be registered with a
+ * local binder service; if true the program's number and version and the
+ * port number from the transport handle are registered with the binder.
+ * These data are registered with the rpc svc system via svc_register.
+ *
+ * A service's dispatch function is called whenever an rpc request comes in
+ * on a transport. The request's program and version numbers must match
+ * those of the registered service. The dispatch function is passed two
+ * parameters, struct svc_req * and SVCXPRT *, defined below.
+ */
+
+enum xprt_stat {
+ XPRT_DIED,
+ XPRT_MOREREQS,
+ XPRT_IDLE
+};
+
+/*
+ * Server side transport handle
+ */
+typedef struct __rpc_svcxprt {
+ int xp_sock;
+ unsigned short xp_port; /* associated port number */
+ struct xp_ops {
+ /* receive incoming requests */
+ bool_t (*xp_recv)(struct __rpc_svcxprt *,
+ struct rpc_msg *);
+ /* get transport status */
+ enum xprt_stat (*xp_stat)(struct __rpc_svcxprt *);
+ /* get arguments */
+ bool_t (*xp_getargs)(struct __rpc_svcxprt *, xdrproc_t,
+ caddr_t);
+ /* send reply */
+ bool_t (*xp_reply)(struct __rpc_svcxprt *, struct rpc_msg *);
+ /* free mem allocated for args */
+ bool_t (*xp_freeargs)(struct __rpc_svcxprt *, xdrproc_t,
+ caddr_t);
+ /* destroy this struct */
+ void (*xp_destroy)(struct __rpc_svcxprt *);
+ } *xp_ops;
+ socklen_t xp_addrlen; /* length of remote address */
+ struct sockaddr_in xp_raddr; /* remote address */
+ struct opaque_auth xp_verf; /* raw response verifier */
+ caddr_t xp_p1; /* private */
+ caddr_t xp_p2; /* private */
+} SVCXPRT;
+
+/*
+ * Approved way of getting address of caller
+ */
+#define svc_getcaller(x) (&(x)->xp_raddr)
+
+/*
+ * Operations defined on an SVCXPRT handle
+ *
+ * SVCXPRT *xprt;
+ * struct rpc_msg *msg;
+ * xdrproc_t xargs;
+ * caddr_t argsp;
+ */
+#define SVC_RECV(xprt, msg) \
+ (*(xprt)->xp_ops->xp_recv)((xprt), (msg))
+#define svc_recv(xprt, msg) \
+ (*(xprt)->xp_ops->xp_recv)((xprt), (msg))
+
+#define SVC_STAT(xprt) \
+ (*(xprt)->xp_ops->xp_stat)(xprt)
+#define svc_stat(xprt) \
+ (*(xprt)->xp_ops->xp_stat)(xprt)
+
+#define SVC_GETARGS(xprt, xargs, argsp) \
+ (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp))
+#define svc_getargs(xprt, xargs, argsp) \
+ (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp))
+
+#define SVC_REPLY(xprt, msg) \
+ (*(xprt)->xp_ops->xp_reply) ((xprt), (msg))
+#define svc_reply(xprt, msg) \
+ (*(xprt)->xp_ops->xp_reply) ((xprt), (msg))
+
+#define SVC_FREEARGS(xprt, xargs, argsp) \
+ (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp))
+#define svc_freeargs(xprt, xargs, argsp) \
+ (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp))
+
+#define SVC_DESTROY(xprt) \
+ (*(xprt)->xp_ops->xp_destroy)(xprt)
+#define svc_destroy(xprt) \
+ (*(xprt)->xp_ops->xp_destroy)(xprt)
+
+
+/*
+ * Service request
+ */
+struct svc_req {
+ u_int32_t rq_prog; /* service program number */
+ u_int32_t rq_vers; /* service protocol version */
+ u_int32_t rq_proc; /* the desired procedure */
+ struct opaque_auth rq_cred; /* raw creds from the wire */
+ caddr_t rq_clntcred; /* read only cooked cred */
+ SVCXPRT *rq_xprt; /* associated transport */
+};
+
+
+/*
+ * Service registration
+ *
+ * svc_register(xprt, prog, vers, dispatch, protocol)
+ * SVCXPRT *xprt;
+ * unsigned long prog;
+ * unsigned long vers;
+ * void (*dispatch)();
+ * int protocol; like TCP or UDP, zero means do not register
+ */
+__BEGIN_DECLS
+extern bool_t svc_register(SVCXPRT *, unsigned long, unsigned long,
+ void (*)(struct svc_req *, SVCXPRT *), int);
+__END_DECLS
+
+/*
+ * Service un-registration
+ *
+ * svc_unregister(prog, vers)
+ * unsigned long prog;
+ * unsigned long vers;
+ */
+__BEGIN_DECLS
+extern void svc_unregister(unsigned long, unsigned long);
+__END_DECLS
+
+/*
+ * Transport registration.
+ *
+ * xprt_register(xprt)
+ * SVCXPRT *xprt;
+ */
+__BEGIN_DECLS
+extern void xprt_register(SVCXPRT *);
+__END_DECLS
+
+/*
+ * Transport un-register
+ *
+ * xprt_unregister(xprt)
+ * SVCXPRT *xprt;
+ */
+__BEGIN_DECLS
+extern void xprt_unregister(SVCXPRT *);
+__END_DECLS
+
+
+
+
+/*
+ * When the service routine is called, it must first check to see if it
+ * knows about the procedure; if not, it should call svcerr_noproc
+ * and return. If so, it should deserialize its arguments via
+ * SVC_GETARGS (defined above). If the deserialization does not work,
+ * svcerr_decode should be called followed by a return. Successful
+ * decoding of the arguments should be followed the execution of the
+ * procedure's code and a call to svc_sendreply.
+ *
+ * Also, if the service refuses to execute the procedure due to too-
+ * weak authentication parameters, svcerr_weakauth should be called.
+ * Note: do not confuse access-control failure with weak authentication!
+ *
+ * NB: In pure implementations of rpc, the caller always waits for a reply
+ * msg. This message is sent when svc_sendreply is called.
+ * Therefore pure service implementations should always call
+ * svc_sendreply even if the function logically returns void; use
+ * xdr.h - xdr_void for the xdr routine. HOWEVER, tcp based rpc allows
+ * for the abuse of pure rpc via batched calling or pipelining. In the
+ * case of a batched call, svc_sendreply should NOT be called since
+ * this would send a return message, which is what batching tries to avoid.
+ * It is the service/protocol writer's responsibility to know which calls are
+ * batched and which are not. Warning: responding to batch calls may
+ * deadlock the caller and server processes!
+ */
+
+__BEGIN_DECLS
+extern bool_t svc_sendreply(SVCXPRT *, xdrproc_t, char *);
+extern void svcerr_decode(SVCXPRT *);
+extern void svcerr_weakauth(SVCXPRT *);
+extern void svcerr_noproc(SVCXPRT *);
+extern void svcerr_progvers(SVCXPRT *, unsigned long, unsigned long);
+extern void svcerr_auth(SVCXPRT *, enum auth_stat);
+extern void svcerr_noprog(SVCXPRT *);
+extern void svcerr_systemerr(SVCXPRT *);
+__END_DECLS
+
+/*
+ * Lowest level dispatching -OR- who owns this process anyway.
+ * Somebody has to wait for incoming requests and then call the correct
+ * service routine. The routine svc_run does infinite waiting; i.e.,
+ * svc_run never returns.
+ * Since another (co-existent) package may wish to selectively wait for
+ * incoming calls or other events outside of the rpc architecture, the
+ * routine svc_getreq is provided. It must be passed readfds, the
+ * "in-place" results of a select system call (see select, section 2).
+ */
+
+/*
+ * Global keeper of rpc service descriptors in use
+ * dynamic; must be inspected before each call to select
+ */
+#include <sys/select.h> /* for fd_set */
+extern fd_set svc_fdset;
+#define svc_fds svc_fdset.fds_bits[0] /* compatibility */
+extern struct pollfd *svc_pollfd;
+extern int svc_max_pollfd;
+extern int svc_maxfd; /* non-standard */
+
+/*
+ * a small program implemented by the svc_rpc implementation itself;
+ * also see clnt.h for protocol numbers.
+ */
+extern void rpctest_service(); /* XXX relic? */
+
+__BEGIN_DECLS
+extern void svc_getreq(int);
+extern void svc_getreq_common(int);
+extern void svc_getreq_poll(struct pollfd *, const int);
+extern void svc_getreqset(fd_set *);
+extern void svc_getreqset2(fd_set *, int);
+extern void svc_run(void);
+__END_DECLS
+
+/*
+ * Socket to use on svcxxx_create call to get default socket
+ */
+#define RPC_ANYSOCK -1
+
+/*
+ * These are the existing service side transport implementations
+ */
+
+/*
+ * Memory based rpc for testing and timing.
+ */
+__BEGIN_DECLS
+extern SVCXPRT *svcraw_create(void);
+__END_DECLS
+
+
+/*
+ * Udp based rpc.
+ */
+__BEGIN_DECLS
+extern SVCXPRT *svcudp_create(int);
+extern SVCXPRT *svcudp_bufcreate(int, unsigned int, unsigned int);
+extern int svcudp_enablecache(SVCXPRT *, u_long);
+__END_DECLS
+
+
+/*
+ * Tcp based rpc.
+ */
+__BEGIN_DECLS
+extern SVCXPRT *svctcp_create(int, unsigned int, unsigned int);
+__END_DECLS
+
+/*
+ * Fd based rpc.
+ */
+__BEGIN_DECLS
+extern SVCXPRT *svcfd_create(int, unsigned int, unsigned int);
+__END_DECLS
+
+#endif /* !_RPC_SVC_H */
diff --git a/include/rpc/svc_auth.h b/include/rpc/svc_auth.h
new file mode 100644
index 0000000..cc6b56d
--- /dev/null
+++ b/include/rpc/svc_auth.h
@@ -0,0 +1 @@
+/* this file intentionally left blank */
diff --git a/include/rpc/types.h b/include/rpc/types.h
new file mode 100644
index 0000000..b904831
--- /dev/null
+++ b/include/rpc/types.h
@@ -0,0 +1,66 @@
+/* $OpenBSD: types.h,v 1.3 2010/09/01 14:43:34 millert Exp $ */
+/* $NetBSD: types.h,v 1.8 1995/04/29 05:28:05 cgd Exp $ */
+
+/*
+ * Copyright (c) 2010, Oracle America, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ * * Neither the name of the "Oracle America, Inc." nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * from: @(#)types.h 1.18 87/07/24 SMI
+ * @(#)types.h 2.3 88/08/15 4.0 RPCSRC
+ */
+
+/*
+ * Rpc additions to <sys/types.h>
+ */
+#ifndef _RPC_TYPES_H
+#define _RPC_TYPES_H
+
+#define bool_t int32_t
+#define enum_t int32_t
+#define __dontcare__ -1
+
+#ifndef FALSE
+# define FALSE (0)
+#endif
+#ifndef TRUE
+# define TRUE (1)
+#endif
+#ifndef NULL
+# define NULL 0
+#endif
+
+#define mem_alloc(bsize) malloc(bsize)
+#define mem_free(ptr, bsize) free(ptr)
+
+#ifndef makedev /* ie, we haven't already included it */
+#include <sys/types.h>
+#endif
+#include <sys/time.h>
+
+#endif /* !_RPC_TYPES_H */
diff --git a/include/rpc/xdr.h b/include/rpc/xdr.h
new file mode 100644
index 0000000..1f0532a
--- /dev/null
+++ b/include/rpc/xdr.h
@@ -0,0 +1,316 @@
+/* $OpenBSD: xdr.h,v 1.12 2010/09/01 14:43:34 millert Exp $ */
+/* $NetBSD: xdr.h,v 1.7 1995/04/29 05:28:06 cgd Exp $ */
+
+/*
+ * Copyright (c) 2010, Oracle America, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ * * Neither the name of the "Oracle America, Inc." nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * from: @(#)xdr.h 1.19 87/04/22 SMI
+ * @(#)xdr.h 2.2 88/07/29 4.0 RPCSRC
+ */
+
+/*
+ * xdr.h, External Data Representation Serialization Routines.
+ */
+
+#ifndef _RPC_XDR_H
+#define _RPC_XDR_H
+#include <sys/cdefs.h>
+
+/*
+ * XDR provides a conventional way for converting between C data
+ * types and an external bit-string representation. Library supplied
+ * routines provide for the conversion on built-in C data types. These
+ * routines and utility routines defined here are used to help implement
+ * a type encode/decode routine for each user-defined type.
+ *
+ * Each data type provides a single procedure which takes two arguments:
+ *
+ * bool_t
+ * xdrproc(xdrs, argresp)
+ * XDR *xdrs;
+ * <type> *argresp;
+ *
+ * xdrs is an instance of a XDR handle, to which or from which the data
+ * type is to be converted. argresp is a pointer to the structure to be
+ * converted. The XDR handle contains an operation field which indicates
+ * which of the operations (ENCODE, DECODE * or FREE) is to be performed.
+ *
+ * XDR_DECODE may allocate space if the pointer argresp is null. This
+ * data can be freed with the XDR_FREE operation.
+ *
+ * We write only one procedure per data type to make it easy
+ * to keep the encode and decode procedures for a data type consistent.
+ * In many cases the same code performs all operations on a user defined type,
+ * because all the hard work is done in the component type routines.
+ * decode as a series of calls on the nested data types.
+ */
+
+/*
+ * Xdr operations. XDR_ENCODE causes the type to be encoded into the
+ * stream. XDR_DECODE causes the type to be extracted from the stream.
+ * XDR_FREE can be used to release the space allocated by an XDR_DECODE
+ * request.
+ */
+enum xdr_op {
+ XDR_ENCODE=0,
+ XDR_DECODE=1,
+ XDR_FREE=2
+};
+
+/*
+ * This is the number of bytes per unit of external data.
+ */
+#define BYTES_PER_XDR_UNIT (4)
+#define RNDUP(x) ((((x) + BYTES_PER_XDR_UNIT - 1) / BYTES_PER_XDR_UNIT) \
+ * BYTES_PER_XDR_UNIT)
+
+/*
+ * The XDR handle.
+ * Contains operation which is being applied to the stream,
+ * an operations vector for the paticular implementation (e.g. see xdr_mem.c),
+ * and two private fields for the use of the particular impelementation.
+ */
+typedef struct __rpc_xdr {
+ enum xdr_op x_op; /* operation; fast additional param */
+ struct xdr_ops {
+ /* get a long from underlying stream */
+ bool_t (*x_getlong)(struct __rpc_xdr *, long *);
+ /* put a long to " */
+ bool_t (*x_putlong)(struct __rpc_xdr *, long *);
+ /* get some bytes from " */
+ bool_t (*x_getbytes)(struct __rpc_xdr *, caddr_t,
+ unsigned int);
+ /* put some bytes to " */
+ bool_t (*x_putbytes)(struct __rpc_xdr *, caddr_t,
+ unsigned int);
+ /* returns bytes off from beginning */
+ unsigned int (*x_getpostn)(struct __rpc_xdr *);
+ /* lets you reposition the stream */
+ bool_t (*x_setpostn)(struct __rpc_xdr *, unsigned int);
+ /* buf quick ptr to buffered data */
+ int32_t *(*x_inline)(struct __rpc_xdr *, unsigned int);
+ /* free privates of this xdr_stream */
+ void (*x_destroy)(struct __rpc_xdr *);
+ bool_t (*x_control)(struct __rpc_xdr *, int, void *);
+ } *x_ops;
+ caddr_t x_public; /* users' data */
+ caddr_t x_private; /* pointer to private data */
+ caddr_t x_base; /* private used for position info */
+ unsigned int x_handy; /* extra private word */
+} XDR;
+
+/*
+ * A xdrproc_t exists for each data type which is to be encoded or decoded.
+ *
+ * The second argument to the xdrproc_t is a pointer to an opaque pointer.
+ * The opaque pointer generally points to a structure of the data type
+ * to be decoded. If this pointer is 0, then the type routines should
+ * allocate dynamic storage of the appropriate size and return it.
+ *
+ * XXX can't actually prototype it, because some take three args!!!
+ */
+typedef bool_t (*xdrproc_t)(/* XDR *, void *, unsigned int */);
+
+/*
+ * Operations defined on a XDR handle
+ *
+ * XDR *xdrs;
+ * long *longp;
+ * caddr_t addr;
+ * unsigned int len;
+ * unsigned int pos;
+ */
+#define XDR_GETLONG(xdrs, longp) \
+ (*(xdrs)->x_ops->x_getlong)(xdrs, longp)
+#define xdr_getlong(xdrs, longp) \
+ (*(xdrs)->x_ops->x_getlong)(xdrs, longp)
+
+#define XDR_PUTLONG(xdrs, longp) \
+ (*(xdrs)->x_ops->x_putlong)(xdrs, longp)
+#define xdr_putlong(xdrs, longp) \
+ (*(xdrs)->x_ops->x_putlong)(xdrs, longp)
+
+#define XDR_GETBYTES(xdrs, addr, len) \
+ (*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len)
+#define xdr_getbytes(xdrs, addr, len) \
+ (*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len)
+
+#define XDR_PUTBYTES(xdrs, addr, len) \
+ (*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len)
+#define xdr_putbytes(xdrs, addr, len) \
+ (*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len)
+
+#define XDR_GETPOS(xdrs) \
+ (*(xdrs)->x_ops->x_getpostn)(xdrs)
+#define xdr_getpos(xdrs) \
+ (*(xdrs)->x_ops->x_getpostn)(xdrs)
+
+#define XDR_SETPOS(xdrs, pos) \
+ (*(xdrs)->x_ops->x_setpostn)(xdrs, pos)
+#define xdr_setpos(xdrs, pos) \
+ (*(xdrs)->x_ops->x_setpostn)(xdrs, pos)
+
+#define XDR_INLINE(xdrs, len) \
+ (*(xdrs)->x_ops->x_inline)(xdrs, len)
+#define xdr_inline(xdrs, len) \
+ (*(xdrs)->x_ops->x_inline)(xdrs, len)
+
+#define XDR_DESTROY(xdrs) \
+ if ((xdrs)->x_ops->x_destroy) \
+ (*(xdrs)->x_ops->x_destroy)(xdrs)
+#define xdr_destroy(xdrs) \
+ if ((xdrs)->x_ops->x_destroy) \
+ (*(xdrs)->x_ops->x_destroy)(xdrs)
+
+/*
+ * Support struct for discriminated unions.
+ * You create an array of xdrdiscrim structures, terminated with
+ * a entry with a null procedure pointer. The xdr_union routine gets
+ * the discriminant value and then searches the array of structures
+ * for a matching value. If a match is found the associated xdr routine
+ * is called to handle that part of the union. If there is
+ * no match, then a default routine may be called.
+ * If there is no match and no default routine it is an error.
+ */
+#define NULL_xdrproc_t ((xdrproc_t)0)
+struct xdr_discrim {
+ int value;
+ xdrproc_t proc;
+};
+
+/*
+ * In-line routines for fast encode/decode of primitive data types.
+ * Caveat emptor: these use single memory cycles to get the
+ * data from the underlying buffer, and will fail to operate
+ * properly if the data is not aligned. The standard way to use these
+ * is to say:
+ * if ((buf = XDR_INLINE(xdrs, count)) == NULL)
+ * return (FALSE);
+ * <<< macro calls >>>
+ * where ``count'' is the number of bytes of data occupied
+ * by the primitive data types.
+ *
+ * N.B. and frozen for all time: each data type here uses 4 bytes
+ * of external representation.
+ */
+#define IXDR_GET_LONG(buf) ((long)ntohl((unsigned long)*(buf)++))
+#define IXDR_PUT_LONG(buf, v) (*(buf)++ = (long)htonl((unsigned long)v))
+
+#define IXDR_GET_BOOL(buf) ((bool_t)IXDR_GET_LONG(buf))
+#define IXDR_GET_ENUM(buf, t) ((t)IXDR_GET_LONG(buf))
+#define IXDR_GET_U_LONG(buf) ((unsigned long)IXDR_GET_LONG(buf))
+#define IXDR_GET_SHORT(buf) ((short)IXDR_GET_LONG(buf))
+#define IXDR_GET_U_SHORT(buf) ((unsigned short)IXDR_GET_LONG(buf))
+
+#define IXDR_PUT_BOOL(buf, v) IXDR_PUT_LONG((buf), ((long)(v)))
+#define IXDR_PUT_ENUM(buf, v) IXDR_PUT_LONG((buf), ((long)(v)))
+#define IXDR_PUT_U_LONG(buf, v) IXDR_PUT_LONG((buf), ((long)(v)))
+#define IXDR_PUT_SHORT(buf, v) IXDR_PUT_LONG((buf), ((long)(v)))
+#define IXDR_PUT_U_SHORT(buf, v) IXDR_PUT_LONG((buf), ((long)(v)))
+
+/*
+ * These are the "generic" xdr routines.
+ */
+__BEGIN_DECLS
+extern bool_t xdr_void(void);
+extern bool_t xdr_int(XDR *, int *);
+extern bool_t xdr_u_int(XDR *, unsigned int *);
+extern bool_t xdr_long(XDR *, long *);
+extern bool_t xdr_u_long(XDR *, unsigned long *);
+extern bool_t xdr_short(XDR *, short *);
+extern bool_t xdr_u_short(XDR *, unsigned short *);
+extern bool_t xdr_int16_t(XDR *, int16_t *);
+extern bool_t xdr_u_int16_t(XDR *, u_int16_t *);
+extern bool_t xdr_int32_t(XDR *, int32_t *);
+extern bool_t xdr_u_int32_t(XDR *, u_int32_t *);
+extern bool_t xdr_int64_t(XDR *, int64_t *);
+extern bool_t xdr_u_int64_t(XDR *, u_int64_t *);
+extern bool_t xdr_bool(XDR *, bool_t *);
+extern bool_t xdr_enum(XDR *, enum_t *);
+extern bool_t xdr_array(XDR *, char **, unsigned int *, unsigned int,
+ unsigned int, xdrproc_t);
+extern bool_t xdr_bytes(XDR *, char **, unsigned int *, unsigned int);
+extern bool_t xdr_opaque(XDR *, caddr_t, unsigned int);
+extern bool_t xdr_string(XDR *, char **, unsigned int);
+extern bool_t xdr_union(XDR *, enum_t *, char *, struct xdr_discrim *,
+ xdrproc_t);
+extern bool_t xdr_char(XDR *, char *);
+extern bool_t xdr_u_char(XDR *, unsigned char *);
+extern bool_t xdr_vector(XDR *, char *, unsigned int, unsigned int,
+ xdrproc_t);
+extern bool_t xdr_float(XDR *, float *);
+extern bool_t xdr_double(XDR *, double *);
+extern bool_t xdr_reference(XDR *, caddr_t *, unsigned int, xdrproc_t);
+extern bool_t xdr_pointer(XDR *, caddr_t *, unsigned int, xdrproc_t);
+extern bool_t xdr_wrapstring(XDR *, char **);
+extern void xdr_free(xdrproc_t, char *);
+__END_DECLS
+
+/*
+ * Common opaque bytes objects used by many rpc protocols;
+ * declared here due to commonality.
+ */
+#define MAX_NETOBJ_SZ 1024
+struct netobj {
+ unsigned int n_len;
+ char *n_bytes;
+};
+typedef struct netobj netobj;
+extern bool_t xdr_netobj(XDR *, struct netobj *);
+
+/*
+ * These are the public routines for the various implementations of
+ * xdr streams.
+ */
+__BEGIN_DECLS
+/* XDR using memory buffers */
+extern void xdrmem_create(XDR *, char *, unsigned int, enum xdr_op);
+
+#ifdef _STDIO_H_
+/* XDR using stdio library */
+extern void xdrstdio_create(XDR *, FILE *, enum xdr_op);
+#endif
+
+/* XDR pseudo records for tcp */
+extern void xdrrec_create(XDR *, unsigned int, unsigned int, char *,
+ int (*)(caddr_t, caddr_t, int),
+ int (*)(caddr_t, caddr_t, int));
+
+/* make end of xdr record */
+extern bool_t xdrrec_endofrecord(XDR *, int);
+
+/* move to beginning of next record */
+extern bool_t xdrrec_skiprecord(XDR *);
+
+/* true if no more input */
+extern bool_t xdrrec_eof(XDR *);
+__END_DECLS
+
+#endif /* !_RPC_XDR_H */
diff --git a/include/rpcsvc/CVS/Entries b/include/rpcsvc/CVS/Entries
new file mode 100644
index 0000000..9e2706a
--- /dev/null
+++ b/include/rpcsvc/CVS/Entries
@@ -0,0 +1,3 @@
+/yp_prot.h/1.10/Mon May 30 02:53:29 2016//
+/ypclnt.h/1.10/Mon May 30 02:53:29 2016//
+D
diff --git a/include/rpcsvc/CVS/Repository b/include/rpcsvc/CVS/Repository
new file mode 100644
index 0000000..f8b2ea3
--- /dev/null
+++ b/include/rpcsvc/CVS/Repository
@@ -0,0 +1 @@
+src/include/rpcsvc
diff --git a/include/rpcsvc/CVS/Root b/include/rpcsvc/CVS/Root
new file mode 100644
index 0000000..3811072
--- /dev/null
+++ b/include/rpcsvc/CVS/Root
@@ -0,0 +1 @@
+/cvs
diff --git a/include/rpcsvc/yp_prot.h b/include/rpcsvc/yp_prot.h
new file mode 100644
index 0000000..243cf52
--- /dev/null
+++ b/include/rpcsvc/yp_prot.h
@@ -0,0 +1,316 @@
+/* $OpenBSD: yp_prot.h,v 1.10 2016/05/30 02:53:29 guenther Exp $ */
+/* $NetBSD: yp_prot.h,v 1.6 1995/07/14 21:10:58 christos Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993 Theo de Raadt <deraadt@openbsd.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _RPCSVC_YP_PROT_H_
+#define _RPCSVC_YP_PROT_H_
+
+/*
+ * YPSERV PROTOCOL:
+ *
+ * ypserv supports the following procedures:
+ *
+ * YPPROC_NULL takes (void), returns (void).
+ * called to check if server is alive.
+ * YPPROC_DOMAIN takes (char *), returns (bool_t).
+ * true if ypserv serves the named domain.
+ * YPPROC_DOMAIN_NOACK takes (char *), returns (bool_t).
+ * true if ypserv serves the named domain.
+ * used for broadcasts, does not ack if ypserv
+ * doesn't handle named domain.
+ * YPPROC_MATCH takes (struct ypreq_key), returns (struct ypresp_val)
+ * does a lookup.
+ * YPPROC_FIRST takes (struct ypreq_nokey) returns (ypresp_key_val).
+ * gets the first key/datum from the map.
+ * YPPROC_NEXT takes (struct ypreq_key) returns (ypresp_key_val).
+ * gets the next key/datum from the map.
+ * YPPROC_XFR takes (struct ypreq_xfr), returns (void).
+ * tells ypserv to check if there is a new version of
+ * the map.
+ * YPPROC_CLEAR takes (void), returns (void).
+ * tells ypserv to flush it's file cache, so that
+ * newly transferred files will get read.
+ * YPPROC_ALL takes (struct ypreq_nokey), returns (bool_t and
+ * struct ypresp_key_val).
+ * returns an array of data, with the bool_t being
+ * false on the last datum. read the source, it's
+ * convoluted.
+ * YPPROC_MASTER takes (struct ypreq_nokey), returns (ypresp_master).
+ * YPPROC_ORDER takes (struct ypreq_nokey), returns (ypresp_order).
+ * YPPROC_MAPLIST takes (char *), returns (struct ypmaplist *).
+ */
+
+#ifndef BOOL_DEFINED
+typedef unsigned int bool;
+#define BOOL_DEFINED
+#endif
+
+
+/* Program and version symbols, magic numbers */
+#define YPPROG ((unsigned long)100004)
+#define YPVERS ((unsigned long)2)
+#define YPVERS_ORIG ((unsigned long)1)
+#define YPMAXRECORD ((unsigned long)1024)
+#define YPMAXDOMAIN ((unsigned long)64)
+#define YPMAXMAP ((unsigned long)64)
+#define YPMAXPEER ((unsigned long)256)
+
+/*
+ * I don't know if anything of sun's depends on this, or if they
+ * simply defined it so that their own code wouldn't try to send
+ * packets over the ethernet MTU. This YP code doesn't use it.
+ */
+#define YPMSGSZ 1600
+
+#ifndef DATUM
+typedef struct {
+ const char *dptr;
+ int dsize;
+} datum;
+#define DATUM
+#endif
+
+struct ypmap_parms {
+ const char *domain;
+ const char *map;
+ unsigned long ordernum;
+ char *owner;
+};
+
+struct ypreq_key {
+ const char *domain;
+ const char *map;
+ datum keydat;
+};
+
+struct ypreq_nokey {
+ const char *domain;
+ const char *map;
+};
+
+struct ypreq_xfr {
+ struct ypmap_parms map_parms;
+ unsigned long transid;
+ unsigned long proto;
+ unsigned short port;
+};
+#define ypxfr_domain map_parms.domain
+#define ypxfr_map map_parms.map
+#define ypxfr_ordernum map_parms.ordernum
+#define ypxfr_owner map_parms.owner
+
+struct ypresp_val {
+ unsigned long status;
+ datum valdat;
+};
+
+struct ypresp_key_val {
+ unsigned long status;
+ datum keydat;
+ datum valdat;
+};
+
+struct ypresp_master {
+ unsigned long status;
+ char *master;
+};
+
+struct ypresp_order {
+ unsigned long status;
+ unsigned long ordernum;
+};
+
+struct ypresp_all {
+ bool_t more;
+ union {
+ struct ypresp_key_val val;
+ } ypresp_all_u;
+};
+
+struct ypmaplist {
+ char ypml_name[YPMAXMAP + 1];
+ struct ypmaplist *ypml_next;
+};
+
+struct ypresp_maplist {
+ unsigned long status;
+ struct ypmaplist *list;
+};
+
+/* ypserv procedure numbers */
+#define YPPROC_NULL ((unsigned long)0)
+#define YPPROC_DOMAIN ((unsigned long)1)
+#define YPPROC_DOMAIN_NONACK ((unsigned long)2)
+#define YPPROC_MATCH ((unsigned long)3)
+#define YPPROC_FIRST ((unsigned long)4)
+#define YPPROC_NEXT ((unsigned long)5)
+#define YPPROC_XFR ((unsigned long)6)
+#define YPPROC_CLEAR ((unsigned long)7)
+#define YPPROC_ALL ((unsigned long)8)
+#define YPPROC_MASTER ((unsigned long)9)
+#define YPPROC_ORDER ((unsigned long)10)
+#define YPPROC_MAPLIST ((unsigned long)11)
+
+/* ypserv procedure return status values */
+#define YP_TRUE ((unsigned long)1) /* general purpose success code */
+#define YP_NOMORE ((unsigned long)2) /* no more entries in map */
+#define YP_FALSE ((unsigned long)0) /* general purpose failure code */
+#define YP_NOMAP ((unsigned long)-1) /* no such map in domain */
+#define YP_NODOM ((unsigned long)-2) /* domain not supported */
+#define YP_NOKEY ((unsigned long)-3) /* no such key in map */
+#define YP_BADOP ((unsigned long)-4) /* invalid operation */
+#define YP_BADDB ((unsigned long)-5) /* server data base is bad */
+#define YP_YPERR ((unsigned long)-6) /* YP server error */
+#define YP_BADARGS ((unsigned long)-7) /* request arguments bad */
+#define YP_VERS ((unsigned long)-8) /* YP server version mismatch */
+
+/*
+ * YPBIND PROTOCOL:
+ *
+ * ypbind supports the following procedures:
+ *
+ * YPBINDPROC_NULL takes (void), returns (void).
+ * to check if ypbind is running.
+ * YPBINDPROC_DOMAIN takes (char *), returns (struct ypbind_resp).
+ * requests that ypbind start to serve the
+ * named domain (if it doesn't already)
+ * YPBINDPROC_SETDOM takes (struct ypbind_setdom), returns (void).
+ * used by ypset.
+ */
+
+#define YPBINDPROG ((unsigned long)100007)
+#define YPBINDVERS ((unsigned long)2)
+#define YPBINDVERS_ORIG ((unsigned long)1)
+
+/* ypbind procedure numbers */
+#define YPBINDPROC_NULL ((unsigned long)0)
+#define YPBINDPROC_DOMAIN ((unsigned long)1)
+#define YPBINDPROC_SETDOM ((unsigned long)2)
+
+/* error code in ypbind_resp.ypbind_status */
+enum ypbind_resptype {
+ YPBIND_SUCC_VAL = 1,
+ YPBIND_FAIL_VAL = 2
+};
+
+/* network order, of course */
+struct ypbind_binding {
+ struct in_addr ypbind_binding_addr;
+ unsigned short ypbind_binding_port;
+};
+
+struct ypbind_resp {
+ enum ypbind_resptype ypbind_status;
+ union {
+ unsigned long ypbind_error;
+ struct ypbind_binding ypbind_bindinfo;
+ } ypbind_respbody;
+};
+
+/* error code in ypbind_resp.ypbind_respbody.ypbind_error */
+#define YPBIND_ERR_ERR 1 /* internal error */
+#define YPBIND_ERR_NOSERV 2 /* no bound server for passed domain */
+#define YPBIND_ERR_RESC 3 /* system resource allocation failure */
+
+/*
+ * Request data structure for ypbind "Set domain" procedure.
+ */
+struct ypbind_setdom {
+ char ypsetdom_domain[YPMAXDOMAIN + 1];
+ struct ypbind_binding ypsetdom_binding;
+ unsigned short ypsetdom_vers;
+};
+#define ypsetdom_addr ypsetdom_binding.ypbind_binding_addr
+#define ypsetdom_port ypsetdom_binding.ypbind_binding_port
+
+/*
+ * YPPUSH PROTOCOL:
+ *
+ * Sun says:
+ * "Protocol between clients (ypxfr, only) and yppush
+ * yppush speaks a protocol in the transient range, which
+ * is supplied to ypxfr as a command-line parameter when it
+ * is activated by ypserv."
+ *
+ * This protocol is not implemented, naturally, because this YP
+ * implementation only does the client side.
+ */
+#define YPPUSHVERS ((unsigned long)1)
+#define YPPUSHVERS_ORIG ((unsigned long)1)
+
+/* yppush procedure numbers */
+#define YPPUSHPROC_NULL ((unsigned long)0)
+#define YPPUSHPROC_XFRRESP ((unsigned long)1)
+
+struct yppushresp_xfr {
+ unsigned long transid;
+ unsigned long status;
+};
+
+/* yppush status value in yppushresp_xfr.status */
+#define YPPUSH_SUCC ((unsigned long)1) /* Success */
+#define YPPUSH_AGE ((unsigned long)2) /* Master's version not newer */
+#define YPPUSH_NOMAP ((unsigned long)-1) /* Can't find server for map */
+#define YPPUSH_NODOM ((unsigned long)-2) /* Domain not supported */
+#define YPPUSH_RSRC ((unsigned long)-3) /* Local resouce alloc failure */
+#define YPPUSH_RPC ((unsigned long)-4) /* RPC failure talking to server */
+#define YPPUSH_MADDR ((unsigned long)-5) /* Can't get master address */
+#define YPPUSH_YPERR ((unsigned long)-6) /* YP server/map db error */
+#define YPPUSH_BADARGS ((unsigned long)-7) /* Request arguments bad */
+#define YPPUSH_DBM ((unsigned long)-8) /* Local dbm operation failed */
+#define YPPUSH_FILE ((unsigned long)-9) /* Local file I/O operation failed */
+#define YPPUSH_SKEW ((unsigned long)-10) /* Map version skew during transfer */
+#define YPPUSH_CLEAR ((unsigned long)-11) /* Can't send "Clear" req to local ypserv */
+#define YPPUSH_FORCE ((unsigned long)-12) /* No local order number in map - use -f */
+#define YPPUSH_XFRERR ((unsigned long)-13) /* ypxfr error */
+#define YPPUSH_REFUSED ((unsigned long)-14) /* Transfer request refused by ypserv */
+
+__BEGIN_DECLS
+bool_t xdr_domainname(XDR *, char *);
+bool_t xdr_peername(XDR *, char *);
+bool_t xdr_datum(XDR *, datum *);
+bool_t xdr_mapname(XDR *, char *);
+bool_t xdr_ypreq_key(XDR *, struct ypreq_key *);
+bool_t xdr_ypreq_nokey(XDR *, struct ypreq_nokey *);
+bool_t xdr_yp_inaddr(XDR *, struct in_addr *);
+bool_t xdr_ypbind_binding(XDR *, struct ypbind_binding *);
+bool_t xdr_ypbind_resptype(XDR *, enum ypbind_resptype *);
+bool_t xdr_ypstat(XDR *, enum ypbind_resptype *);
+bool_t xdr_ypbind_resp(XDR *, struct ypbind_resp *);
+bool_t xdr_ypresp_val(XDR *, struct ypresp_val *);
+bool_t xdr_ypbind_setdom(XDR *, struct ypbind_setdom *);
+bool_t xdr_ypresp_key_val(XDR *, struct ypresp_key_val *);
+bool_t xdr_ypresp_all(XDR *, struct ypresp_all *);
+bool_t xdr_ypresp_master(XDR *, struct ypresp_master *);
+bool_t xdr_ypmaplist_str(XDR *, char *);
+bool_t xdr_ypmaplist(XDR *, struct ypmaplist *);
+bool_t xdr_ypresp_maplist(XDR *, struct ypresp_maplist *);
+bool_t xdr_ypresp_order(XDR *, struct ypresp_order *);
+__END_DECLS
+
+#endif /* _RPCSVC_YP_PROT_H_ */
diff --git a/include/rpcsvc/ypclnt.h b/include/rpcsvc/ypclnt.h
new file mode 100644
index 0000000..f7af7c3
--- /dev/null
+++ b/include/rpcsvc/ypclnt.h
@@ -0,0 +1,82 @@
+/* $OpenBSD: ypclnt.h,v 1.10 2016/05/30 02:53:29 guenther Exp $ */
+/* $NetBSD: ypclnt.h,v 1.7 1995/07/14 21:11:10 christos Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993 Theo de Raadt <deraadt@openbsd.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _RPCSVC_YPCLNT_H_
+#define _RPCSVC_YPCLNT_H_
+
+#define YPERR_BADARGS 1 /* args to function are bad */
+#define YPERR_RPC 2 /* RPC failure */
+#define YPERR_DOMAIN 3 /* can't bind to a server for domain */
+#define YPERR_MAP 4 /* no such map in server's domain */
+#define YPERR_KEY 5 /* no such key in map */
+#define YPERR_YPERR 6 /* some internal YP server or client error */
+#define YPERR_RESRC 7 /* local resource allocation failure */
+#define YPERR_NOMORE 8 /* no more records in map database */
+#define YPERR_PMAP 9 /* can't communicate with portmapper */
+#define YPERR_YPBIND 10 /* can't communicate with ypbind */
+#define YPERR_YPSERV 11 /* can't communicate with ypserv */
+#define YPERR_NODOM 12 /* local domain name not set */
+#define YPERR_BADDB 13 /* YP data base is bad */
+#define YPERR_VERS 14 /* YP version mismatch */
+#define YPERR_ACCESS 15 /* access violation */
+#define YPERR_BUSY 16 /* database is busy */
+
+/*
+ * Types of update operations
+ */
+#define YPOP_CHANGE 1 /* change, do not add */
+#define YPOP_INSERT 2 /* add, do not change */
+#define YPOP_DELETE 3 /* delete this entry */
+#define YPOP_STORE 4 /* add, or change */
+
+struct ypall_callback {
+ /* return non-0 to stop getting called */
+ int (*foreach)(unsigned long, char *, int, char *, int, void *);
+ char *data; /* opaque pointer for use of callback fn */
+};
+
+__BEGIN_DECLS
+int yp_bind(const char *);
+void yp_unbind(const char *);
+int yp_get_default_domain(char **);
+int yp_match(const char *, const char *, const char *, int , char **,
+ int *);
+int yp_first(const char *, const char *, char **, int *, char **, int *);
+int yp_next(const char *, const char *, const char *, int, char **, int *,
+ char **, int *);
+int yp_master(const char *, const char *, char **);
+int yp_order(const char *, const char *, int *);
+int yp_all(const char *, const char *, struct ypall_callback *);
+char * yperr_string(int);
+int ypprot_err(unsigned int);
+struct ypmaplist;
+int yp_maplist(const char *, struct ypmaplist **);
+__END_DECLS
+
+#endif /* _RPCSVC_YPCLNT_H_ */
diff --git a/include/sched.h b/include/sched.h
new file mode 100644
index 0000000..8e468b4
--- /dev/null
+++ b/include/sched.h
@@ -0,0 +1,75 @@
+/* $OpenBSD: sched.h,v 1.1 2017/10/15 23:40:33 guenther Exp $ */
+
+/* sched.h: POSIX 1003.1b Process Scheduling header */
+
+/*-
+ * Copyright (c) 1996, 1997
+ * HD Associates, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by HD Associates, Inc
+ * and Jukka Antero Ukkonen.
+ * 4. Neither the name of the author nor the names of any co-contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY HD ASSOCIATES AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL HD ASSOCIATES OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+
+#ifndef _SCHED_H_
+#define _SCHED_H_
+
+#include <sys/types.h> /* For pid_t */
+#include <time.h> /* Per P1003.4 */
+
+/* Scheduling policies
+ */
+#define SCHED_FIFO 1
+#define SCHED_OTHER 2
+#define SCHED_RR 3
+
+struct sched_param
+{
+ int sched_priority;
+};
+
+__BEGIN_DECLS
+#if 0 /* not yet */
+int sched_setparam(pid_t, const struct sched_param *);
+int sched_getparam(pid_t, struct sched_param *);
+
+int sched_setscheduler(pid_t, int, const struct sched_param *);
+int sched_getscheduler(pid_t);
+#endif
+
+int sched_yield(void);
+int sched_get_priority_max(int);
+int sched_get_priority_min(int);
+
+#if 0 /* not yet */
+struct timespec;
+int sched_rr_get_interval(pid_t, struct timespec *);
+#endif
+__END_DECLS
+
+#endif /* _SCHED_H_ */
diff --git a/include/search.h b/include/search.h
new file mode 100644
index 0000000..37f2e60
--- /dev/null
+++ b/include/search.h
@@ -0,0 +1,57 @@
+/* $OpenBSD: search.h,v 1.10 2014/07/18 04:16:09 matthew Exp $ */
+/* $NetBSD: search.h,v 1.9 1995/08/08 21:14:45 jtc Exp $ */
+
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>
+ * Public domain.
+ */
+
+#ifndef _SEARCH_H_
+#define _SEARCH_H_
+
+#include <sys/cdefs.h>
+#include <machine/_types.h>
+
+#ifndef _SIZE_T_DEFINED_
+#define _SIZE_T_DEFINED_
+typedef __size_t size_t;
+#endif
+
+typedef struct entry {
+ char *key;
+ void *data;
+} ENTRY;
+
+typedef enum {
+ FIND, ENTER
+} ACTION;
+
+typedef enum {
+ preorder,
+ postorder,
+ endorder,
+ leaf
+} VISIT;
+
+__BEGIN_DECLS
+int hcreate(size_t);
+void hdestroy(void);
+ENTRY *hsearch(ENTRY, ACTION);
+
+void *lfind(const void *, const void *, size_t *, size_t,
+ int (*)(const void *, const void *));
+void *lsearch(const void *, void *, size_t *, size_t,
+ int (*)(const void *, const void *));
+void insque(void *, void *);
+void remque(void *);
+
+void *tdelete(const void * __restrict, void ** __restrict,
+ int (*)(const void *, const void *));
+void *tfind(const void *, void * const *,
+ int (*)(const void *, const void *));
+void *tsearch(const void *, void **,
+ int (*)(const void *, const void *));
+void twalk(const void *, void (*)(const void *, VISIT, int));
+__END_DECLS
+
+#endif /* !_SEARCH_H_ */
diff --git a/include/semaphore.h b/include/semaphore.h
new file mode 100644
index 0000000..21dc1a2
--- /dev/null
+++ b/include/semaphore.h
@@ -0,0 +1,62 @@
+/* $OpenBSD: semaphore.h,v 1.1 2017/10/15 23:40:33 guenther Exp $ */
+
+/* semaphore.h: POSIX 1003.1b semaphores */
+
+/*-
+ * Copyright (c) 1996, 1997
+ * HD Associates, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by HD Associates, Inc
+ * 4. Neither the name of the author nor the names of any co-contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY HD ASSOCIATES AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL HD ASSOCIATES OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _SEMAPHORE_H_
+#define _SEMAPHORE_H_
+
+#include <sys/cdefs.h>
+
+/* Opaque type definition. */
+struct __sem;
+typedef struct __sem *sem_t;
+struct timespec;
+
+#define SEM_FAILED ((sem_t *)0)
+
+__BEGIN_DECLS
+int sem_init(sem_t *, int, unsigned int);
+int sem_destroy(sem_t *);
+sem_t *sem_open(const char *, int, ...);
+int sem_close(sem_t *);
+int sem_unlink(const char *);
+int sem_wait(sem_t *);
+int sem_timedwait(sem_t * __restrict, const struct timespec * __restrict);
+int sem_trywait(sem_t *);
+int sem_post(sem_t *);
+int sem_getvalue(sem_t * __restrict, int * __restrict);
+__END_DECLS
+
+#endif /* _SEMAPHORE_H_ */
diff --git a/include/setjmp.h b/include/setjmp.h
new file mode 100644
index 0000000..c278650
--- /dev/null
+++ b/include/setjmp.h
@@ -0,0 +1,67 @@
+/* $OpenBSD: setjmp.h,v 1.7 2016/05/23 00:18:56 guenther Exp $ */
+/* $NetBSD: setjmp.h,v 1.11 1994/12/20 10:35:44 cgd Exp $ */
+
+/*-
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)setjmp.h 8.2 (Berkeley) 1/21/94
+ */
+
+#ifndef _SETJMP_H_
+#define _SETJMP_H_
+
+#include <sys/cdefs.h>
+#include <machine/setjmp.h>
+
+#if __BSD_VISIBLE || __POSIX_VISIBLE || __XPG_VISIBLE
+typedef long sigjmp_buf[_JBLEN + 1];
+#endif /* __BSD_VISIBLE || __POSIX_VISIBLE || __XPG_VISIBLE */
+
+typedef long jmp_buf[_JBLEN];
+
+__BEGIN_DECLS
+__returns_twice int setjmp(jmp_buf);
+__dead void longjmp(jmp_buf, int);
+
+#if __BSD_VISIBLE || __POSIX_VISIBLE || __XPG_VISIBLE
+__returns_twice int sigsetjmp(sigjmp_buf, int);
+__dead void siglongjmp(sigjmp_buf, int);
+#endif /* __BSD_VISIBLE || __POSIX_VISIBLE || __XPG_VISIBLE */
+
+#if __BSD_VISIBLE || __XPG_VISIBLE
+__returns_twice int _setjmp(jmp_buf);
+__dead void _longjmp(jmp_buf, int);
+#endif /* __BSD_VISIBLE || __XPG_VISIBLE */
+__END_DECLS
+
+#endif /* !_SETJMP_H_ */
diff --git a/include/sha1.h b/include/sha1.h
new file mode 100644
index 0000000..f596be6
--- /dev/null
+++ b/include/sha1.h
@@ -0,0 +1,57 @@
+/* $OpenBSD: sha1.h,v 1.24 2012/12/05 23:19:57 deraadt Exp $ */
+
+/*
+ * SHA-1 in C
+ * By Steve Reid <steve@edmweb.com>
+ * 100% Public Domain
+ */
+
+#ifndef _SHA1_H
+#define _SHA1_H
+
+#define SHA1_BLOCK_LENGTH 64
+#define SHA1_DIGEST_LENGTH 20
+#define SHA1_DIGEST_STRING_LENGTH (SHA1_DIGEST_LENGTH * 2 + 1)
+
+typedef struct {
+ u_int32_t state[5];
+ u_int64_t count;
+ u_int8_t buffer[SHA1_BLOCK_LENGTH];
+} SHA1_CTX;
+
+__BEGIN_DECLS
+void SHA1Init(SHA1_CTX *);
+void SHA1Pad(SHA1_CTX *);
+void SHA1Transform(u_int32_t [5], const u_int8_t [SHA1_BLOCK_LENGTH])
+ __attribute__((__bounded__(__minbytes__,1,5)))
+ __attribute__((__bounded__(__minbytes__,2,SHA1_BLOCK_LENGTH)));
+void SHA1Update(SHA1_CTX *, const u_int8_t *, size_t)
+ __attribute__((__bounded__(__string__,2,3)));
+void SHA1Final(u_int8_t [SHA1_DIGEST_LENGTH], SHA1_CTX *)
+ __attribute__((__bounded__(__minbytes__,1,SHA1_DIGEST_LENGTH)));
+char *SHA1End(SHA1_CTX *, char *)
+ __attribute__((__bounded__(__minbytes__,2,SHA1_DIGEST_STRING_LENGTH)));
+char *SHA1File(const char *, char *)
+ __attribute__((__bounded__(__minbytes__,2,SHA1_DIGEST_STRING_LENGTH)));
+char *SHA1FileChunk(const char *, char *, off_t, off_t)
+ __attribute__((__bounded__(__minbytes__,2,SHA1_DIGEST_STRING_LENGTH)));
+char *SHA1Data(const u_int8_t *, size_t, char *)
+ __attribute__((__bounded__(__string__,1,2)))
+ __attribute__((__bounded__(__minbytes__,3,SHA1_DIGEST_STRING_LENGTH)));
+__END_DECLS
+
+#define HTONDIGEST(x) do { \
+ x[0] = htonl(x[0]); \
+ x[1] = htonl(x[1]); \
+ x[2] = htonl(x[2]); \
+ x[3] = htonl(x[3]); \
+ x[4] = htonl(x[4]); } while (0)
+
+#define NTOHDIGEST(x) do { \
+ x[0] = ntohl(x[0]); \
+ x[1] = ntohl(x[1]); \
+ x[2] = ntohl(x[2]); \
+ x[3] = ntohl(x[3]); \
+ x[4] = ntohl(x[4]); } while (0)
+
+#endif /* _SHA1_H */
diff --git a/include/sha2.h b/include/sha2.h
new file mode 100644
index 0000000..52ddb3f
--- /dev/null
+++ b/include/sha2.h
@@ -0,0 +1,156 @@
+/* $OpenBSD: sha2.h,v 1.10 2016/09/03 17:00:29 tedu Exp $ */
+
+/*
+ * FILE: sha2.h
+ * AUTHOR: Aaron D. Gifford <me@aarongifford.com>
+ *
+ * Copyright (c) 2000-2001, Aaron D. Gifford
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTOR(S) ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTOR(S) BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $From: sha2.h,v 1.1 2001/11/08 00:02:01 adg Exp adg $
+ */
+
+#ifndef _SHA2_H
+#define _SHA2_H
+
+
+/*** SHA-256/384/512 Various Length Definitions ***********************/
+#define SHA224_BLOCK_LENGTH 64
+#define SHA224_DIGEST_LENGTH 28
+#define SHA224_DIGEST_STRING_LENGTH (SHA224_DIGEST_LENGTH * 2 + 1)
+#define SHA256_BLOCK_LENGTH 64
+#define SHA256_DIGEST_LENGTH 32
+#define SHA256_DIGEST_STRING_LENGTH (SHA256_DIGEST_LENGTH * 2 + 1)
+#define SHA384_BLOCK_LENGTH 128
+#define SHA384_DIGEST_LENGTH 48
+#define SHA384_DIGEST_STRING_LENGTH (SHA384_DIGEST_LENGTH * 2 + 1)
+#define SHA512_BLOCK_LENGTH 128
+#define SHA512_DIGEST_LENGTH 64
+#define SHA512_DIGEST_STRING_LENGTH (SHA512_DIGEST_LENGTH * 2 + 1)
+#define SHA512_256_BLOCK_LENGTH 128
+#define SHA512_256_DIGEST_LENGTH 32
+#define SHA512_256_DIGEST_STRING_LENGTH (SHA512_256_DIGEST_LENGTH * 2 + 1)
+
+
+/*** SHA-224/256/384/512 Context Structure *******************************/
+typedef struct _SHA2_CTX {
+ union {
+ u_int32_t st32[8];
+ u_int64_t st64[8];
+ } state;
+ u_int64_t bitcount[2];
+ u_int8_t buffer[SHA512_BLOCK_LENGTH];
+} SHA2_CTX;
+
+__BEGIN_DECLS
+void SHA224Init(SHA2_CTX *);
+void SHA224Transform(u_int32_t state[8], const u_int8_t [SHA224_BLOCK_LENGTH]);
+void SHA224Update(SHA2_CTX *, const u_int8_t *, size_t)
+ __attribute__((__bounded__(__string__,2,3)));
+void SHA224Pad(SHA2_CTX *);
+void SHA224Final(u_int8_t [SHA224_DIGEST_LENGTH], SHA2_CTX *)
+ __attribute__((__bounded__(__minbytes__,1,SHA224_DIGEST_LENGTH)));
+char *SHA224End(SHA2_CTX *, char *)
+ __attribute__((__bounded__(__minbytes__,2,SHA224_DIGEST_STRING_LENGTH)));
+char *SHA224File(const char *, char *)
+ __attribute__((__bounded__(__minbytes__,2,SHA224_DIGEST_STRING_LENGTH)));
+char *SHA224FileChunk(const char *, char *, off_t, off_t)
+ __attribute__((__bounded__(__minbytes__,2,SHA224_DIGEST_STRING_LENGTH)));
+char *SHA224Data(const u_int8_t *, size_t, char *)
+ __attribute__((__bounded__(__string__,1,2)))
+ __attribute__((__bounded__(__minbytes__,3,SHA224_DIGEST_STRING_LENGTH)));
+
+void SHA256Init(SHA2_CTX *);
+void SHA256Transform(u_int32_t state[8], const u_int8_t [SHA256_BLOCK_LENGTH]);
+void SHA256Update(SHA2_CTX *, const u_int8_t *, size_t)
+ __attribute__((__bounded__(__string__,2,3)));
+void SHA256Pad(SHA2_CTX *);
+void SHA256Final(u_int8_t [SHA256_DIGEST_LENGTH], SHA2_CTX *)
+ __attribute__((__bounded__(__minbytes__,1,SHA256_DIGEST_LENGTH)));
+char *SHA256End(SHA2_CTX *, char *)
+ __attribute__((__bounded__(__minbytes__,2,SHA256_DIGEST_STRING_LENGTH)));
+char *SHA256File(const char *, char *)
+ __attribute__((__bounded__(__minbytes__,2,SHA256_DIGEST_STRING_LENGTH)));
+char *SHA256FileChunk(const char *, char *, off_t, off_t)
+ __attribute__((__bounded__(__minbytes__,2,SHA256_DIGEST_STRING_LENGTH)));
+char *SHA256Data(const u_int8_t *, size_t, char *)
+ __attribute__((__bounded__(__string__,1,2)))
+ __attribute__((__bounded__(__minbytes__,3,SHA256_DIGEST_STRING_LENGTH)));
+
+void SHA384Init(SHA2_CTX *);
+void SHA384Transform(u_int64_t state[8], const u_int8_t [SHA384_BLOCK_LENGTH]);
+void SHA384Update(SHA2_CTX *, const u_int8_t *, size_t)
+ __attribute__((__bounded__(__string__,2,3)));
+void SHA384Pad(SHA2_CTX *);
+void SHA384Final(u_int8_t [SHA384_DIGEST_LENGTH], SHA2_CTX *)
+ __attribute__((__bounded__(__minbytes__,1,SHA384_DIGEST_LENGTH)));
+char *SHA384End(SHA2_CTX *, char *)
+ __attribute__((__bounded__(__minbytes__,2,SHA384_DIGEST_STRING_LENGTH)));
+char *SHA384File(const char *, char *)
+ __attribute__((__bounded__(__minbytes__,2,SHA384_DIGEST_STRING_LENGTH)));
+char *SHA384FileChunk(const char *, char *, off_t, off_t)
+ __attribute__((__bounded__(__minbytes__,2,SHA384_DIGEST_STRING_LENGTH)));
+char *SHA384Data(const u_int8_t *, size_t, char *)
+ __attribute__((__bounded__(__string__,1,2)))
+ __attribute__((__bounded__(__minbytes__,3,SHA384_DIGEST_STRING_LENGTH)));
+
+void SHA512Init(SHA2_CTX *);
+void SHA512Transform(u_int64_t state[8], const u_int8_t [SHA512_BLOCK_LENGTH]);
+void SHA512Update(SHA2_CTX *, const u_int8_t *, size_t)
+ __attribute__((__bounded__(__string__,2,3)));
+void SHA512Pad(SHA2_CTX *);
+void SHA512Final(u_int8_t [SHA512_DIGEST_LENGTH], SHA2_CTX *)
+ __attribute__((__bounded__(__minbytes__,1,SHA512_DIGEST_LENGTH)));
+char *SHA512End(SHA2_CTX *, char *)
+ __attribute__((__bounded__(__minbytes__,2,SHA512_DIGEST_STRING_LENGTH)));
+char *SHA512File(const char *, char *)
+ __attribute__((__bounded__(__minbytes__,2,SHA512_DIGEST_STRING_LENGTH)));
+char *SHA512FileChunk(const char *, char *, off_t, off_t)
+ __attribute__((__bounded__(__minbytes__,2,SHA512_DIGEST_STRING_LENGTH)));
+char *SHA512Data(const u_int8_t *, size_t, char *)
+ __attribute__((__bounded__(__string__,1,2)))
+ __attribute__((__bounded__(__minbytes__,3,SHA512_DIGEST_STRING_LENGTH)));
+
+void SHA512_256Init(SHA2_CTX *);
+void SHA512_256Transform(u_int64_t state[8], const u_int8_t [SHA512_256_BLOCK_LENGTH]);
+void SHA512_256Update(SHA2_CTX *, const u_int8_t *, size_t)
+ __attribute__((__bounded__(__string__,2,3)));
+void SHA512_256Pad(SHA2_CTX *);
+void SHA512_256Final(u_int8_t [SHA512_256_DIGEST_LENGTH], SHA2_CTX *)
+ __attribute__((__bounded__(__minbytes__,1,SHA512_256_DIGEST_LENGTH)));
+char *SHA512_256End(SHA2_CTX *, char *)
+ __attribute__((__bounded__(__minbytes__,2,SHA512_256_DIGEST_STRING_LENGTH)));
+char *SHA512_256File(const char *, char *)
+ __attribute__((__bounded__(__minbytes__,2,SHA512_256_DIGEST_STRING_LENGTH)));
+char *SHA512_256FileChunk(const char *, char *, off_t, off_t)
+ __attribute__((__bounded__(__minbytes__,2,SHA512_256_DIGEST_STRING_LENGTH)));
+char *SHA512_256Data(const u_int8_t *, size_t, char *)
+ __attribute__((__bounded__(__string__,1,2)))
+ __attribute__((__bounded__(__minbytes__,3,SHA512_256_DIGEST_STRING_LENGTH)));
+__END_DECLS
+
+#endif /* _SHA2_H */
diff --git a/include/signal.h b/include/signal.h
new file mode 100644
index 0000000..07982bd
--- /dev/null
+++ b/include/signal.h
@@ -0,0 +1,140 @@
+/* $OpenBSD: signal.h,v 1.26 2018/05/30 13:20:38 bluhm Exp $ */
+/* $NetBSD: signal.h,v 1.8 1996/02/29 00:04:57 jtc Exp $ */
+
+/*-
+ * Copyright (c) 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)signal.h 8.3 (Berkeley) 3/30/94
+ */
+
+#ifndef _USER_SIGNAL_H
+#define _USER_SIGNAL_H
+
+#include <sys/signal.h>
+
+#if __BSD_VISIBLE || __POSIX_VISIBLE || __XPG_VISIBLE
+#include <sys/types.h>
+#endif
+
+__BEGIN_DECLS
+#if __BSD_VISIBLE
+extern const char *const sys_signame[_NSIG];
+extern const char *const sys_siglist[_NSIG];
+#endif
+
+int raise(int);
+#if __BSD_VISIBLE || __POSIX_VISIBLE || __XPG_VISIBLE
+#if __BSD_VISIBLE || (__XPG_VISIBLE >= 500 && __XPG_VISIBLE < 700)
+void (*bsd_signal(int, void (*)(int)))(int);
+#endif
+int kill(pid_t, int);
+int sigaction(int, const struct sigaction *__restrict,
+ struct sigaction *__restrict);
+int sigaddset(sigset_t *, int);
+int sigdelset(sigset_t *, int);
+int sigemptyset(sigset_t *);
+int sigfillset(sigset_t *);
+int sigismember(const sigset_t *, int);
+int sigpending(sigset_t *);
+int sigprocmask(int, const sigset_t *__restrict, sigset_t *__restrict);
+#if __POSIX_VISIBLE >= 199506
+int pthread_sigmask(int, const sigset_t *__restrict, sigset_t *__restrict);
+#endif
+int sigsuspend(const sigset_t *);
+
+#if !defined(_ANSI_LIBRARY)
+
+extern int *__errno(void);
+
+__only_inline int sigaddset(sigset_t *__set, int __signo)
+{
+ if (__signo <= 0 || __signo >= _NSIG) {
+ *__errno() = 22; /* EINVAL */
+ return -1;
+ }
+ *__set |= (1U << ((__signo)-1)); /* sigmask(__signo) */
+ return (0);
+}
+
+__only_inline int sigdelset(sigset_t *__set, int __signo)
+{
+ if (__signo <= 0 || __signo >= _NSIG) {
+ *__errno() = 22; /* EINVAL */
+ return -1;
+ }
+ *__set &= ~(1U << ((__signo)-1)); /* sigmask(__signo) */
+ return (0);
+}
+
+__only_inline int sigismember(const sigset_t *__set, int __signo)
+{
+ if (__signo <= 0 || __signo >= _NSIG) {
+ *__errno() = 22; /* EINVAL */
+ return -1;
+ }
+ return ((*__set & (1U << ((__signo)-1))) != 0);
+}
+
+__only_inline int sigemptyset(sigset_t *__set)
+{
+ *__set = 0;
+ return (0);
+}
+
+__only_inline int sigfillset(sigset_t *__set)
+{
+ *__set = ~(sigset_t)0;
+ return (0);
+}
+
+#endif /* !_ANSI_LIBRARY */
+
+#if __BSD_VISIBLE || __XPG_VISIBLE >= 420
+int killpg(pid_t, int);
+int siginterrupt(int, int);
+int sigaltstack(const struct sigaltstack *__restrict,
+ struct sigaltstack *__restrict);
+#if __BSD_VISIBLE
+int sigblock(int);
+/* This is the traditional BSD sigpause() and not the XPG/POSIX sigpause(). */
+int sigpause(int);
+int sigsetmask(int);
+int sigvec(int, struct sigvec *, struct sigvec *);
+int thrkill(pid_t _tid, int _signum, void *_tcb);
+#endif
+#endif /* __BSD_VISIBLE || __XPG_VISIBLE >= 420 */
+#if __BSD_VISIBLE || __POSIX_VISIBLE >= 199309 || __XPG_VISIBLE >= 500
+int sigwait(const sigset_t *__restrict, int *__restrict);
+#endif
+#if __BSD_VISIBLE || __POSIX_VISIBLE >= 200809
+void psignal(unsigned int, const char *);
+#endif
+#endif /* __BSD_VISIBLE || __POSIX_VISIBLE || __XPG_VISIBLE */
+__END_DECLS
+
+#endif /* !_USER_SIGNAL_H */
diff --git a/include/siphash.h b/include/siphash.h
new file mode 100644
index 0000000..7a5990c
--- /dev/null
+++ b/include/siphash.h
@@ -0,0 +1,83 @@
+/*-
+ * Copyright (c) 2013 Andre Oppermann <andre@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $OpenBSD: siphash.h,v 1.3 2015/02/20 11:51:03 tedu Exp $
+ */
+
+/*
+ * SipHash is a family of pseudorandom functions (a.k.a. keyed hash functions)
+ * optimized for speed on short messages returning a 64bit hash/digest value.
+ *
+ * The number of rounds is defined during the initialization:
+ * SipHash24_Init() for the fast and resonable strong version
+ * SipHash48_Init() for the strong version (half as fast)
+ *
+ * struct SIPHASH_CTX ctx;
+ * SipHash24_Init(&ctx);
+ * SipHash_SetKey(&ctx, "16bytes long key");
+ * SipHash_Update(&ctx, pointer_to_string, length_of_string);
+ * SipHash_Final(output, &ctx);
+ */
+
+#ifndef _SIPHASH_H_
+#define _SIPHASH_H_
+
+#define SIPHASH_BLOCK_LENGTH 8
+#define SIPHASH_KEY_LENGTH 16
+#define SIPHASH_DIGEST_LENGTH 8
+
+typedef struct _SIPHASH_CTX {
+ uint64_t v[4];
+ uint8_t buf[SIPHASH_BLOCK_LENGTH];
+ uint32_t bytes;
+} SIPHASH_CTX;
+
+typedef struct {
+ uint64_t k0;
+ uint64_t k1;
+} SIPHASH_KEY;
+
+void SipHash_Init(SIPHASH_CTX *, const SIPHASH_KEY *);
+void SipHash_Update(SIPHASH_CTX *, int, int, const void *, size_t);
+uint64_t SipHash_End(SIPHASH_CTX *, int, int);
+void SipHash_Final(void *, SIPHASH_CTX *, int, int);
+uint64_t SipHash(const SIPHASH_KEY *, int, int, const void *, size_t);
+
+#define SipHash24_Init(_c, _k) SipHash_Init((_c), (_k))
+#define SipHash24_Update(_c, _p, _l) SipHash_Update((_c), 2, 4, (_p), (_l))
+#define SipHash24_End(_d) SipHash_End((_d), 2, 4)
+#define SipHash24_Final(_d, _c) SipHash_Final((_d), (_c), 2, 4)
+#define SipHash24(_k, _p, _l) SipHash((_k), 2, 4, (_p), (_l))
+
+#define SipHash48_Init(_c, _k) SipHash_Init((_c), (_k))
+#define SipHash48_Update(_c, _p, _l) SipHash_Update((_c), 4, 8, (_p), (_l))
+#define SipHash48_End(_d) SipHash_End((_d), 4, 8)
+#define SipHash48_Final(_d, _c) SipHash_Final((_d), (_c), 4, 8)
+#define SipHash48(_k, _p, _l) SipHash((_k), 4, 8, (_p), (_l))
+
+#endif /* _SIPHASH_H_ */
diff --git a/include/sndio.h b/include/sndio.h
new file mode 100644
index 0000000..4fed3d5
--- /dev/null
+++ b/include/sndio.h
@@ -0,0 +1,205 @@
+/* $OpenBSD: sndio.h,v 1.10 2020/02/26 13:53:58 ratchov Exp $ */
+/*
+ * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+#ifndef SNDIO_H
+#define SNDIO_H
+
+#include <sys/types.h>
+
+/*
+ * default audio device and MIDI port
+ */
+#define SIO_DEVANY "default"
+#define MIO_PORTANY "default"
+
+/*
+ * limits
+ */
+#define SIOCTL_NAMEMAX 12 /* max name length */
+
+/*
+ * private ``handle'' structure
+ */
+struct sio_hdl;
+struct mio_hdl;
+struct sioctl_hdl;
+
+/*
+ * parameters of a full-duplex stream
+ */
+struct sio_par {
+ unsigned int bits; /* bits per sample */
+ unsigned int bps; /* bytes per sample */
+ unsigned int sig; /* 1 = signed, 0 = unsigned */
+ unsigned int le; /* 1 = LE, 0 = BE byte order */
+ unsigned int msb; /* 1 = MSB, 0 = LSB aligned */
+ unsigned int rchan; /* number channels for recording direction */
+ unsigned int pchan; /* number channels for playback direction */
+ unsigned int rate; /* frames per second */
+ unsigned int bufsz; /* end-to-end buffer size */
+#define SIO_IGNORE 0 /* pause during xrun */
+#define SIO_SYNC 1 /* resync after xrun */
+#define SIO_ERROR 2 /* terminate on xrun */
+ unsigned int xrun; /* what to do on overruns/underruns */
+ unsigned int round; /* optimal bufsz divisor */
+ unsigned int appbufsz; /* minimum buffer size */
+ int __pad[3]; /* for future use */
+ unsigned int __magic; /* for internal/debug purposes only */
+};
+
+/*
+ * capabilities of a stream
+ */
+struct sio_cap {
+#define SIO_NENC 8
+#define SIO_NCHAN 8
+#define SIO_NRATE 16
+#define SIO_NCONF 4
+ struct sio_enc { /* allowed sample encodings */
+ unsigned int bits;
+ unsigned int bps;
+ unsigned int sig;
+ unsigned int le;
+ unsigned int msb;
+ } enc[SIO_NENC];
+ unsigned int rchan[SIO_NCHAN]; /* allowed values for rchan */
+ unsigned int pchan[SIO_NCHAN]; /* allowed values for pchan */
+ unsigned int rate[SIO_NRATE]; /* allowed rates */
+ int __pad[7]; /* for future use */
+ unsigned int nconf; /* number of elements in confs[] */
+ struct sio_conf {
+ unsigned int enc; /* mask of enc[] indexes */
+ unsigned int rchan; /* mask of chan[] indexes (rec) */
+ unsigned int pchan; /* mask of chan[] indexes (play) */
+ unsigned int rate; /* mask of rate[] indexes */
+ } confs[SIO_NCONF];
+};
+
+#define SIO_XSTRINGS { "ignore", "sync", "error" }
+
+/*
+ * controlled component of the device
+ */
+struct sioctl_node {
+ char name[SIOCTL_NAMEMAX]; /* ex. "spkr" */
+ int unit; /* optional number or -1 */
+};
+
+/*
+ * description of a control (index, value) pair
+ */
+struct sioctl_desc {
+ unsigned int addr; /* control address */
+#define SIOCTL_NONE 0 /* deleted */
+#define SIOCTL_NUM 2 /* integer in the 0..127 range */
+#define SIOCTL_SW 3 /* on/off switch (0 or 1) */
+#define SIOCTL_VEC 4 /* number, element of vector */
+#define SIOCTL_LIST 5 /* switch, element of a list */
+ unsigned int type; /* one of above */
+ char func[SIOCTL_NAMEMAX]; /* function name, ex. "level" */
+ char group[SIOCTL_NAMEMAX]; /* group this control belongs to */
+ struct sioctl_node node0; /* affected node */
+ struct sioctl_node node1; /* dito for SIOCTL_{VEC,LIST} */
+ unsigned int maxval; /* max value for SIOCTL_{NUM,VEC} */
+ int __pad[3];
+};
+
+/*
+ * mode bitmap
+ */
+#define SIO_PLAY 1
+#define SIO_REC 2
+#define MIO_OUT 4
+#define MIO_IN 8
+#define SIOCTL_READ 0x100
+#define SIOCTL_WRITE 0x200
+
+/*
+ * default bytes per sample for the given bits per sample
+ */
+#define SIO_BPS(bits) (((bits) <= 8) ? 1 : (((bits) <= 16) ? 2 : 4))
+
+/*
+ * default value of "sio_par->le" flag
+ */
+#if BYTE_ORDER == LITTLE_ENDIAN
+#define SIO_LE_NATIVE 1
+#else
+#define SIO_LE_NATIVE 0
+#endif
+
+/*
+ * maximum value of volume, eg. for sio_setvol()
+ */
+#define SIO_MAXVOL 127
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct pollfd;
+
+void sio_initpar(struct sio_par *);
+struct sio_hdl *sio_open(const char *, unsigned int, int);
+void sio_close(struct sio_hdl *);
+int sio_setpar(struct sio_hdl *, struct sio_par *);
+int sio_getpar(struct sio_hdl *, struct sio_par *);
+int sio_getcap(struct sio_hdl *, struct sio_cap *);
+void sio_onmove(struct sio_hdl *, void (*)(void *, int), void *);
+size_t sio_write(struct sio_hdl *, const void *, size_t);
+size_t sio_read(struct sio_hdl *, void *, size_t);
+int sio_start(struct sio_hdl *);
+int sio_stop(struct sio_hdl *);
+int sio_nfds(struct sio_hdl *);
+int sio_pollfd(struct sio_hdl *, struct pollfd *, int);
+int sio_revents(struct sio_hdl *, struct pollfd *);
+int sio_eof(struct sio_hdl *);
+int sio_setvol(struct sio_hdl *, unsigned int);
+int sio_onvol(struct sio_hdl *, void (*)(void *, unsigned int), void *);
+
+struct mio_hdl *mio_open(const char *, unsigned int, int);
+void mio_close(struct mio_hdl *);
+size_t mio_write(struct mio_hdl *, const void *, size_t);
+size_t mio_read(struct mio_hdl *, void *, size_t);
+int mio_nfds(struct mio_hdl *);
+int mio_pollfd(struct mio_hdl *, struct pollfd *, int);
+int mio_revents(struct mio_hdl *, struct pollfd *);
+int mio_eof(struct mio_hdl *);
+
+struct sioctl_hdl *sioctl_open(const char *, unsigned int, int);
+void sioctl_close(struct sioctl_hdl *);
+int sioctl_ondesc(struct sioctl_hdl *,
+ void (*)(void *, struct sioctl_desc *, int), void *);
+int sioctl_onval(struct sioctl_hdl *,
+ void (*)(void *, unsigned int, unsigned int), void *);
+int sioctl_setval(struct sioctl_hdl *, unsigned int, unsigned int);
+int sioctl_nfds(struct sioctl_hdl *);
+int sioctl_pollfd(struct sioctl_hdl *, struct pollfd *, int);
+int sioctl_revents(struct sioctl_hdl *, struct pollfd *);
+int sioctl_eof(struct sioctl_hdl *);
+
+int mio_rmidi_getfd(const char *, unsigned int, int);
+struct mio_hdl *mio_rmidi_fdopen(int, unsigned int, int);
+int sio_sun_getfd(const char *, unsigned int, int);
+struct sio_hdl *sio_sun_fdopen(int, unsigned int, int);
+int sioctl_sun_getfd(const char *, unsigned int, int);
+struct sioctl_hdl *sioctl_sun_fdopen(int, unsigned int, int);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* !defined(SNDIO_H) */
diff --git a/include/spawn.h b/include/spawn.h
new file mode 100644
index 0000000..374a18b
--- /dev/null
+++ b/include/spawn.h
@@ -0,0 +1,103 @@
+/* $OpenBSD: spawn.h,v 1.3 2015/05/20 22:50:07 millert Exp $ */
+/*-
+ * Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD: src/include/spawn.h,v 1.3.2.1.6.1 2010/12/21 17:09:25 kensmith Exp $
+ */
+
+#ifndef _SPAWN_H_
+#define _SPAWN_H_
+
+#include <sys/types.h>
+#include <sys/signal.h>
+
+struct sched_param;
+
+typedef struct __posix_spawnattr *posix_spawnattr_t;
+typedef struct __posix_spawn_file_actions *posix_spawn_file_actions_t;
+
+#define POSIX_SPAWN_RESETIDS 0x01
+#define POSIX_SPAWN_SETPGROUP 0x02
+#define POSIX_SPAWN_SETSCHEDPARAM 0x04
+#define POSIX_SPAWN_SETSCHEDULER 0x08
+#define POSIX_SPAWN_SETSIGDEF 0x10
+#define POSIX_SPAWN_SETSIGMASK 0x20
+
+__BEGIN_DECLS
+/*
+ * Spawn routines
+ *
+ * XXX both arrays should be __restrict, but this does not work when GCC
+ * is invoked with -std=c99.
+ */
+int posix_spawn(pid_t *__restrict, const char *__restrict,
+ const posix_spawn_file_actions_t *, const posix_spawnattr_t *__restrict,
+ char *const [], char *const []);
+int posix_spawnp(pid_t *__restrict, const char *__restrict,
+ const posix_spawn_file_actions_t *, const posix_spawnattr_t *__restrict,
+ char *const [], char *const []);
+
+/*
+ * File descriptor actions
+ */
+int posix_spawn_file_actions_init(posix_spawn_file_actions_t *);
+int posix_spawn_file_actions_destroy(posix_spawn_file_actions_t *);
+
+int posix_spawn_file_actions_addopen(posix_spawn_file_actions_t *__restrict,
+ int, const char *__restrict, int, mode_t);
+int posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t *, int, int);
+int posix_spawn_file_actions_addclose(posix_spawn_file_actions_t *, int);
+
+/*
+ * Spawn attributes
+ */
+int posix_spawnattr_init(posix_spawnattr_t *);
+int posix_spawnattr_destroy(posix_spawnattr_t *);
+
+int posix_spawnattr_getflags(const posix_spawnattr_t *__restrict,
+ short *__restrict);
+int posix_spawnattr_getpgroup(const posix_spawnattr_t *__restrict,
+ pid_t *__restrict);
+int posix_spawnattr_getschedparam(const posix_spawnattr_t *__restrict,
+ struct sched_param *__restrict);
+int posix_spawnattr_getschedpolicy(const posix_spawnattr_t *__restrict,
+ int *__restrict);
+int posix_spawnattr_getsigdefault(const posix_spawnattr_t *__restrict,
+ sigset_t *__restrict);
+int posix_spawnattr_getsigmask(const posix_spawnattr_t *__restrict,
+ sigset_t *__restrict);
+
+int posix_spawnattr_setflags(posix_spawnattr_t *, short);
+int posix_spawnattr_setpgroup(posix_spawnattr_t *, pid_t);
+int posix_spawnattr_setschedparam(posix_spawnattr_t *__restrict,
+ const struct sched_param *__restrict);
+int posix_spawnattr_setschedpolicy(posix_spawnattr_t *, int);
+int posix_spawnattr_setsigdefault(posix_spawnattr_t *__restrict,
+ const sigset_t *__restrict);
+int posix_spawnattr_setsigmask(posix_spawnattr_t *__restrict,
+ const sigset_t *__restrict);
+__END_DECLS
+
+#endif /* !_SPAWN_H_ */
diff --git a/include/stdbool.h b/include/stdbool.h
new file mode 100644
index 0000000..077c12a
--- /dev/null
+++ b/include/stdbool.h
@@ -0,0 +1,45 @@
+/* $OpenBSD: stdbool.h,v 1.7 2015/09/04 23:47:09 daniel Exp $ */
+
+/*
+ * Written by Marc Espie, September 25, 1999
+ * Public domain.
+ */
+
+#ifndef _STDBOOL_H_
+#define _STDBOOL_H_
+
+#ifndef __cplusplus
+
+#if defined(__GNUC__) || \
+ (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901)
+/* Support for C99: type _Bool is already built-in. */
+#define false 0
+#define true 1
+
+#else
+/* `_Bool' type must promote to `int' or `unsigned int'. */
+typedef enum {
+ false = 0,
+ true = 1
+} _Bool;
+
+/* And those constants must also be available as macros. */
+#define false false
+#define true true
+
+#endif
+
+/* User visible type `bool' is provided as a macro which may be redefined */
+#define bool _Bool
+
+#else /* __cplusplus */
+#define _Bool bool
+#define bool bool
+#define false false
+#define true true
+#endif /* __cplusplus */
+
+/* Inform that everything is fine */
+#define __bool_true_false_are_defined 1
+
+#endif /* _STDBOOL_H_ */
diff --git a/include/stddef.h b/include/stddef.h
new file mode 100644
index 0000000..391fbc2
--- /dev/null
+++ b/include/stddef.h
@@ -0,0 +1,84 @@
+/* $OpenBSD: stddef.h,v 1.14 2017/01/06 14:36:50 kettenis Exp $ */
+/* $NetBSD: stddef.h,v 1.4 1994/10/26 00:56:26 cgd Exp $ */
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)stddef.h 5.5 (Berkeley) 4/3/91
+ */
+
+#ifndef _STDDEF_H_
+#define _STDDEF_H_
+
+#include <sys/cdefs.h>
+#include <sys/_null.h>
+#include <sys/_types.h>
+
+#ifndef _PTRDIFF_T_DEFINED_
+#define _PTRDIFF_T_DEFINED_
+typedef __ptrdiff_t ptrdiff_t;
+#endif
+
+#ifndef _SIZE_T_DEFINED_
+#define _SIZE_T_DEFINED_
+typedef __size_t size_t;
+#endif
+
+/* in C++, wchar_t is a built-in type */
+#if !defined(_WCHAR_T_DEFINED_) && !defined(__cplusplus)
+#define _WCHAR_T_DEFINED_
+typedef __wchar_t wchar_t;
+#endif
+
+#ifndef _WINT_T_DEFINED_
+#define _WINT_T_DEFINED_
+typedef __wint_t wint_t;
+#endif
+
+#ifndef _MBSTATE_T_DEFINED_
+#define _MBSTATE_T_DEFINED_
+typedef __mbstate_t mbstate_t;
+#endif
+
+#if __GNUC_PREREQ__(4, 0)
+#define offsetof(type, member) __builtin_offsetof(type, member)
+#else
+#define offsetof(type, member) ((size_t)(&((type *)0)->member))
+#endif
+
+#if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103
+#ifndef __CLANG_MAX_ALIGN_T_DEFINED
+#define __CLANG_MAX_ALIGN_T_DEFINED
+typedef struct {
+ long long __max_align_ll __aligned(__alignof__(long long));
+ long double __max_align_ld __aligned(__alignof__(long double));
+} max_align_t;
+#endif
+#endif
+
+#endif /* _STDDEF_H_ */
diff --git a/include/stdio.h b/include/stdio.h
new file mode 100644
index 0000000..3f39a21
--- /dev/null
+++ b/include/stdio.h
@@ -0,0 +1,435 @@
+/* $OpenBSD: stdio.h,v 1.53 2016/09/09 18:12:37 millert Exp $ */
+/* $NetBSD: stdio.h,v 1.18 1996/04/25 18:29:21 jtc Exp $ */
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)stdio.h 5.17 (Berkeley) 6/3/91
+ */
+
+#ifndef _STDIO_H_
+#define _STDIO_H_
+
+#include <sys/cdefs.h>
+#include <sys/_null.h>
+#include <sys/_types.h>
+
+#if __BSD_VISIBLE || __POSIX_VISIBLE || __XPG_VISIBLE
+#include <sys/types.h> /* XXX should be removed */
+#endif
+
+#ifndef _SIZE_T_DEFINED_
+#define _SIZE_T_DEFINED_
+typedef __size_t size_t;
+#endif
+
+#ifndef _OFF_T_DEFINED_
+#define _OFF_T_DEFINED_
+typedef __off_t off_t;
+#endif
+
+#define _FSTDIO /* Define for new stdio with functions. */
+
+typedef off_t fpos_t; /* stdio file position type */
+
+/*
+ * NB: to fit things in six character monocase externals, the stdio
+ * code uses the prefix `__s' for stdio objects, typically followed
+ * by a three-character attempt at a mnemonic.
+ */
+
+/* stdio buffers */
+struct __sbuf {
+ unsigned char *_base;
+ int _size;
+};
+
+/*
+ * stdio state variables.
+ *
+ * The following always hold:
+ *
+ * if (_flags&(__SLBF|__SWR)) == (__SLBF|__SWR),
+ * _lbfsize is -_bf._size, else _lbfsize is 0
+ * if _flags&__SRD, _w is 0
+ * if _flags&__SWR, _r is 0
+ *
+ * This ensures that the getc and putc macros (or inline functions) never
+ * try to write or read from a file that is in `read' or `write' mode.
+ * (Moreover, they can, and do, automatically switch from read mode to
+ * write mode, and back, on "r+" and "w+" files.)
+ *
+ * _lbfsize is used only to make the inline line-buffered output stream
+ * code as compact as possible.
+ *
+ * _ub, _up, and _ur are used when ungetc() pushes back more characters
+ * than fit in the current _bf, or when ungetc() pushes back a character
+ * that does not match the previous one in _bf. When this happens,
+ * _ub._base becomes non-nil (i.e., a stream has ungetc() data iff
+ * _ub._base!=NULL) and _up and _ur save the current values of _p and _r.
+ */
+typedef struct __sFILE {
+ unsigned char *_p; /* current position in (some) buffer */
+ int _r; /* read space left for getc() */
+ int _w; /* write space left for putc() */
+ short _flags; /* flags, below; this FILE is free if 0 */
+ short _file; /* fileno, if Unix descriptor, else -1 */
+ struct __sbuf _bf; /* the buffer (at least 1 byte, if !NULL) */
+ int _lbfsize; /* 0 or -_bf._size, for inline putc */
+
+ /* operations */
+ void *_cookie; /* cookie passed to io functions */
+ int (*_close)(void *);
+ int (*_read)(void *, char *, int);
+ fpos_t (*_seek)(void *, fpos_t, int);
+ int (*_write)(void *, const char *, int);
+
+ /* extension data, to avoid further ABI breakage */
+ struct __sbuf _ext;
+ /* data for long sequences of ungetc() */
+ unsigned char *_up; /* saved _p when _p is doing ungetc data */
+ int _ur; /* saved _r when _r is counting ungetc data */
+
+ /* tricks to meet minimum requirements even when malloc() fails */
+ unsigned char _ubuf[3]; /* guarantee an ungetc() buffer */
+ unsigned char _nbuf[1]; /* guarantee a getc() buffer */
+
+ /* separate buffer for fgetln() when line crosses buffer boundary */
+ struct __sbuf _lb; /* buffer for fgetln() */
+
+ /* Unix stdio files get aligned to block boundaries on fseek() */
+ int _blksize; /* stat.st_blksize (may be != _bf._size) */
+ fpos_t _offset; /* current lseek offset */
+} FILE;
+
+__BEGIN_DECLS
+extern FILE __sF[];
+__END_DECLS
+
+#define __SLBF 0x0001 /* line buffered */
+#define __SNBF 0x0002 /* unbuffered */
+#define __SRD 0x0004 /* OK to read */
+#define __SWR 0x0008 /* OK to write */
+ /* RD and WR are never simultaneously asserted */
+#define __SRW 0x0010 /* open for reading & writing */
+#define __SEOF 0x0020 /* found EOF */
+#define __SERR 0x0040 /* found error */
+#define __SMBF 0x0080 /* _buf is from malloc */
+#define __SAPP 0x0100 /* fdopen()ed in append mode */
+#define __SSTR 0x0200 /* this is an sprintf/snprintf string */
+#define __SOPT 0x0400 /* do fseek() optimisation */
+#define __SNPT 0x0800 /* do not do fseek() optimisation */
+#define __SOFF 0x1000 /* set iff _offset is in fact correct */
+#define __SMOD 0x2000 /* true => fgetln modified _p text */
+#define __SALC 0x4000 /* allocate string space dynamically */
+#define __SIGN 0x8000 /* ignore this file in _fwalk */
+
+/*
+ * The following three definitions are for ANSI C, which took them
+ * from System V, which brilliantly took internal interface macros and
+ * made them official arguments to setvbuf(), without renaming them.
+ * Hence, these ugly _IOxxx names are *supposed* to appear in user code.
+ *
+ * Although numbered as their counterparts above, the implementation
+ * does not rely on this.
+ */
+#define _IOFBF 0 /* setvbuf should set fully buffered */
+#define _IOLBF 1 /* setvbuf should set line buffered */
+#define _IONBF 2 /* setvbuf should set unbuffered */
+
+#define BUFSIZ 1024 /* size of buffer used by setbuf */
+
+#define EOF (-1)
+
+/*
+ * FOPEN_MAX is a minimum maximum, and should be the number of descriptors
+ * that the kernel can provide without allocation of a resource that can
+ * fail without the process sleeping. Do not use this for anything.
+ */
+#define FOPEN_MAX 20 /* must be <= OPEN_MAX <sys/syslimits.h> */
+#define FILENAME_MAX 1024 /* must be <= PATH_MAX <sys/syslimits.h> */
+
+/* System V/ANSI C; this is the wrong way to do this, do *not* use these. */
+#if __BSD_VISIBLE || __XPG_VISIBLE
+#define P_tmpdir "/tmp/"
+#endif
+#define L_tmpnam 1024 /* XXX must be == PATH_MAX */
+#define TMP_MAX 0x7fffffff /* more, but don't overflow int */
+
+#ifndef SEEK_SET
+#define SEEK_SET 0 /* set file offset to offset */
+#endif
+#ifndef SEEK_CUR
+#define SEEK_CUR 1 /* set file offset to current plus offset */
+#endif
+#ifndef SEEK_END
+#define SEEK_END 2 /* set file offset to EOF plus offset */
+#endif
+
+#define stdin (&__sF[0])
+#define stdout (&__sF[1])
+#define stderr (&__sF[2])
+
+/*
+ * Functions defined in ANSI C standard.
+ */
+__BEGIN_DECLS
+void clearerr(FILE *);
+#if __POSIX_VISIBLE >= 200809
+int dprintf(int, const char * __restrict, ...);
+#endif
+int fclose(FILE *);
+int feof(FILE *);
+int ferror(FILE *);
+int fflush(FILE *);
+int fgetc(FILE *);
+int fgetpos(FILE *, fpos_t *);
+char *fgets(char *, int, FILE *)
+ __attribute__((__bounded__ (__string__,1,2)));
+FILE *fopen(const char *, const char *);
+int fprintf(FILE *, const char *, ...);
+int fputc(int, FILE *);
+int fputs(const char *, FILE *);
+size_t fread(void *, size_t, size_t, FILE *)
+ __attribute__((__bounded__ (__size__,1,3,2)));
+FILE *freopen(const char *, const char *, FILE *);
+int fscanf(FILE *, const char *, ...);
+int fseek(FILE *, long, int);
+int fseeko(FILE *, off_t, int);
+int fsetpos(FILE *, const fpos_t *);
+long ftell(FILE *);
+off_t ftello(FILE *);
+size_t fwrite(const void *, size_t, size_t, FILE *)
+ __attribute__((__bounded__ (__size__,1,3,2)));
+int getc(FILE *);
+int getchar(void);
+#if __POSIX_VISIBLE >= 200809
+ssize_t getdelim(char ** __restrict, size_t * __restrict, int,
+ FILE * __restrict);
+ssize_t getline(char ** __restrict, size_t * __restrict,
+ FILE * __restrict);
+#endif
+#if __BSD_VISIBLE && !defined(__SYS_ERRLIST)
+#define __SYS_ERRLIST
+
+extern int sys_nerr; /* perror(3) external variables */
+extern char *sys_errlist[];
+#endif
+void perror(const char *);
+int printf(const char *, ...);
+int putc(int, FILE *);
+int putchar(int);
+int puts(const char *);
+int remove(const char *);
+int rename(const char *, const char *);
+#if __POSIX_VISIBLE >= 200809
+int renameat(int, const char *, int, const char *);
+#endif
+void rewind(FILE *);
+int scanf(const char *, ...);
+void setbuf(FILE *, char *);
+int setvbuf(FILE *, char *, int, size_t);
+int sprintf(char *, const char *, ...);
+int sscanf(const char *, const char *, ...);
+FILE *tmpfile(void);
+char *tmpnam(char *);
+int ungetc(int, FILE *);
+int vfprintf(FILE *, const char *, __va_list);
+int vprintf(const char *, __va_list);
+int vsprintf(char *, const char *, __va_list);
+#if __POSIX_VISIBLE >= 200809
+int vdprintf(int, const char * __restrict, __va_list);
+#endif
+
+#if __ISO_C_VISIBLE >= 1999 || __XPG_VISIBLE >= 500 || __BSD_VISIBLE
+int snprintf(char *, size_t, const char *, ...)
+ __attribute__((__format__ (printf, 3, 4)))
+ __attribute__((__nonnull__ (3)))
+ __attribute__((__bounded__ (__string__,1,2)));
+int vsnprintf(char *, size_t, const char *, __va_list)
+ __attribute__((__format__ (printf, 3, 0)))
+ __attribute__((__nonnull__ (3)))
+ __attribute__((__bounded__(__string__,1,2)));
+#endif /* __ISO_C_VISIBLE >= 1999 || __XPG_VISIBLE >= 500 || __BSD_VISIBLE */
+
+#if __ISO_C_VISIBLE >= 1999 || __BSD_VISIBLE
+int vfscanf(FILE *, const char *, __va_list)
+ __attribute__((__format__ (scanf, 2, 0)))
+ __attribute__((__nonnull__ (2)));
+int vscanf(const char *, __va_list)
+ __attribute__((__format__ (scanf, 1, 0)))
+ __attribute__((__nonnull__ (1)));
+int vsscanf(const char *, const char *, __va_list)
+ __attribute__((__format__ (scanf, 2, 0)))
+ __attribute__((__nonnull__ (2)));
+#endif /* __ISO_C_VISIBLE >= 1999 || __BSD_VISIBLE */
+
+__END_DECLS
+
+
+/*
+ * Functions defined in POSIX 1003.1.
+ */
+#if __BSD_VISIBLE || __POSIX_VISIBLE || __XPG_VISIBLE
+#define L_ctermid 1024 /* size for ctermid(); PATH_MAX */
+
+__BEGIN_DECLS
+char *ctermid(char *);
+FILE *fdopen(int, const char *);
+int fileno(FILE *);
+
+#if __POSIX_VISIBLE >= 199209
+int pclose(FILE *);
+FILE *popen(const char *, const char *);
+#endif
+
+#if __POSIX_VISIBLE >= 199506
+void flockfile(FILE *);
+int ftrylockfile(FILE *);
+void funlockfile(FILE *);
+
+/*
+ * These are normally used through macros as defined below, but POSIX
+ * requires functions as well.
+ */
+int getc_unlocked(FILE *);
+int getchar_unlocked(void);
+int putc_unlocked(int, FILE *);
+int putchar_unlocked(int);
+#endif /* __POSIX_VISIBLE >= 199506 */
+
+#if __POSIX_VISIBLE >= 200809
+FILE *fmemopen(void *, size_t, const char *);
+FILE *open_memstream(char **, size_t *);
+#endif /* __POSIX_VISIBLE >= 200809 */
+
+#if __XPG_VISIBLE
+char *tempnam(const char *, const char *);
+#endif
+__END_DECLS
+
+#endif /* __BSD_VISIBLE || __POSIX_VISIBLE || __XPG_VISIBLE */
+
+/*
+ * Routines that are purely local.
+ */
+#if __BSD_VISIBLE
+__BEGIN_DECLS
+int asprintf(char **, const char *, ...)
+ __attribute__((__format__ (printf, 2, 3)))
+ __attribute__((__nonnull__ (2)));
+char *fgetln(FILE *, size_t *);
+int fpurge(FILE *);
+int getw(FILE *);
+int putw(int, FILE *);
+void setbuffer(FILE *, char *, int);
+int setlinebuf(FILE *);
+int vasprintf(char **, const char *, __va_list)
+ __attribute__((__format__ (printf, 2, 0)))
+ __attribute__((__nonnull__ (2)));
+__END_DECLS
+
+/*
+ * Stdio function-access interface.
+ */
+__BEGIN_DECLS
+FILE *funopen(const void *,
+ int (*)(void *, char *, int),
+ int (*)(void *, const char *, int),
+ fpos_t (*)(void *, fpos_t, int),
+ int (*)(void *));
+__END_DECLS
+#define fropen(cookie, fn) funopen(cookie, fn, 0, 0, 0)
+#define fwopen(cookie, fn) funopen(cookie, 0, fn, 0, 0)
+#endif /* __BSD_VISIBLE */
+
+/*
+ * Functions internal to the implementation.
+ */
+__BEGIN_DECLS
+int __srget(FILE *);
+int __swbuf(int, FILE *);
+__END_DECLS
+
+/*
+ * The __sfoo macros are here so that we can
+ * define function versions in the C library.
+ */
+#define __sgetc(p) (--(p)->_r < 0 ? __srget(p) : (int)(*(p)->_p++))
+static __inline int __sputc(int _c, FILE *_p) {
+ if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n'))
+ return (*_p->_p++ = _c);
+ else
+ return (__swbuf(_c, _p));
+}
+
+#define __sfeof(p) (((p)->_flags & __SEOF) != 0)
+#define __sferror(p) (((p)->_flags & __SERR) != 0)
+#define __sclearerr(p) ((void)((p)->_flags &= ~(__SERR|__SEOF)))
+#define __sfileno(p) ((p)->_file)
+
+extern int __isthreaded;
+
+#define feof(p) (!__isthreaded ? __sfeof(p) : (feof)(p))
+#define ferror(p) (!__isthreaded ? __sferror(p) : (ferror)(p))
+#define clearerr(p) (!__isthreaded ? __sclearerr(p) : (clearerr)(p))
+
+#if __POSIX_VISIBLE
+#define fileno(p) (!__isthreaded ? __sfileno(p) : (fileno)(p))
+#endif
+
+#define getc(fp) (!__isthreaded ? __sgetc(fp) : (getc)(fp))
+
+#if __BSD_VISIBLE
+/*
+ * The macro implementations of putc and putc_unlocked are not
+ * fully POSIX compliant; they do not set errno on failure
+ */
+#define putc(x, fp) (!__isthreaded ? __sputc(x, fp) : (putc)(x, fp))
+#endif /* __BSD_VISIBLE */
+
+#if __POSIX_VISIBLE >= 199506
+#define getc_unlocked(fp) __sgetc(fp)
+/*
+ * The macro implementations of putc and putc_unlocked are not
+ * fully POSIX compliant; they do not set errno on failure
+ */
+#if __BSD_VISIBLE
+#define putc_unlocked(x, fp) __sputc(x, fp)
+#endif /* __BSD_VISIBLE */
+#endif /* __POSIX_VISIBLE >= 199506 */
+
+#define getchar() getc(stdin)
+#define putchar(x) putc(x, stdout)
+#define getchar_unlocked() getc_unlocked(stdin)
+#define putchar_unlocked(c) putc_unlocked(c, stdout)
+
+#endif /* _STDIO_H_ */
diff --git a/include/stdlib.h b/include/stdlib.h
new file mode 100644
index 0000000..652bba4
--- /dev/null
+++ b/include/stdlib.h
@@ -0,0 +1,12 @@
+#include_next <stdlib.h>
+#include <stdint.h>
+void freezero(void *, size_t);
+void *reallocarray(void *, size_t, size_t);
+void *recallocarray(void *, size_t, size_t, size_t);
+long long strtonum(const char *, long long, long long, const char **);
+uint32_t arc4random(void);
+uint32_t arc4random_uniform(uint32_t);
+void arc4random_buf(void *, size_t);
+void setprogname(const char *);
+const char *getprogname(void);
+extern char *__progname;
diff --git a/include/string.h b/include/string.h
new file mode 100644
index 0000000..9cf9ac9
--- /dev/null
+++ b/include/string.h
@@ -0,0 +1,5 @@
+#include_next <string.h>
+char *strcasestr(const char *, const char *);
+void strmode(int, char *);
+int timingsafe_memcmp(const void *, const void *, size_t);
+int timingsafe_bcmp(const void *, const void *, size_t);
diff --git a/include/strings.h b/include/strings.h
new file mode 100644
index 0000000..e72fb77
--- /dev/null
+++ b/include/strings.h
@@ -0,0 +1,83 @@
+/* $OpenBSD: strings.h,v 1.6 2017/09/10 21:50:36 schwarze Exp $ */
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)strings.h 5.8 (Berkeley) 5/15/90
+ */
+
+#ifndef _STRINGS_H_
+#define _STRINGS_H_
+
+#include <sys/cdefs.h>
+#include <machine/_types.h>
+
+/*
+ * POSIX mandates that certain string functions not present in ISO C
+ * be prototyped in strings.h.
+ */
+
+#ifndef _SIZE_T_DEFINED_
+#define _SIZE_T_DEFINED_
+typedef __size_t size_t;
+#endif
+
+#if __POSIX_VISIBLE >= 200809
+#ifndef _LOCALE_T_DEFINED_
+#define _LOCALE_T_DEFINED_
+typedef void *locale_t;
+#endif
+#endif
+
+__BEGIN_DECLS
+#if __BSD_VISIBLE || (__XPG_VISIBLE >= 420 && __POSIX_VISIBLE <= 200112)
+/*
+ * The following functions were removed from IEEE Std 1003.1-2008
+ */
+int bcmp(const void *, const void *, size_t);
+void bcopy(const void *, void *, size_t)
+ __attribute__ ((__bounded__(__buffer__,1,3)))
+ __attribute__ ((__bounded__(__buffer__,2,3)));
+void bzero(void *, size_t)
+ __attribute__ ((__bounded__(__buffer__,1,2)));
+char *index(const char *, int);
+char *rindex(const char *, int);
+#endif
+
+#if __XPG_VISIBLE >= 420
+int ffs(int);
+int strcasecmp(const char *, const char *);
+int strncasecmp(const char *, const char *, size_t);
+#endif
+#if __POSIX_VISIBLE >= 200809
+int strcasecmp_l(const char *, const char *, locale_t);
+int strncasecmp_l(const char *, const char *, size_t, locale_t);
+#endif
+__END_DECLS
+
+#endif /* _STRINGS_H_ */
diff --git a/include/sys/cdefs.h b/include/sys/cdefs.h
new file mode 100644
index 0000000..70258b8
--- /dev/null
+++ b/include/sys/cdefs.h
@@ -0,0 +1,5 @@
+/* only needed for C++ */
+#define __BEGIN_DECLS
+#define __END_DECLS
+
+#define __dead __attribute__((__noreturn__))
diff --git a/include/sys/param.h b/include/sys/param.h
new file mode 100644
index 0000000..3167713
--- /dev/null
+++ b/include/sys/param.h
@@ -0,0 +1,3 @@
+#include_next <sys/param.h>
+#define ALIGNBYTES (sizeof(uintptr_t) - 1)
+#define ALIGN(p) (((uintptr_t)(p) + ALIGNBYTES) &~ ALIGNBYTES)
diff --git a/include/sys/time.h b/include/sys/time.h
new file mode 100644
index 0000000..f4f151f
--- /dev/null
+++ b/include/sys/time.h
@@ -0,0 +1,14 @@
+#include_next <sys/time.h>
+#define timespeccmp(tsp, usp, cmp) \
+ (((tsp)->tv_sec == (usp)->tv_sec) ? \
+ ((tsp)->tv_nsec cmp (usp)->tv_nsec) : \
+ ((tsp)->tv_sec cmp (usp)->tv_sec))
+#define timespecsub(tsp, usp, vsp) \
+ do { \
+ (vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec; \
+ (vsp)->tv_nsec = (tsp)->tv_nsec - (usp)->tv_nsec; \
+ if ((vsp)->tv_nsec < 0) { \
+ (vsp)->tv_sec--; \
+ (vsp)->tv_nsec += 1000000000L; \
+ } \
+ } while (0)
diff --git a/include/sysexits.h b/include/sysexits.h
new file mode 100644
index 0000000..e244836
--- /dev/null
+++ b/include/sysexits.h
@@ -0,0 +1,119 @@
+/* $OpenBSD: sysexits.h,v 1.5 2003/06/02 19:34:12 millert Exp $ */
+/* $NetBSD: sysexits.h,v 1.4 1994/10/26 00:56:33 cgd Exp $ */
+
+/*
+ * Copyright (c) 1987 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)sysexits.h 4.8 (Berkeley) 4/3/91
+ */
+
+#ifndef _SYSEXITS_H_
+#define _SYSEXITS_H_
+
+/*
+ * SYSEXITS.H -- Exit status codes for system programs.
+ *
+ * This include file attempts to categorize possible error
+ * exit statuses for system programs, notably delivermail
+ * and the Berkeley network.
+ *
+ * Error numbers begin at EX__BASE to reduce the possibility of
+ * clashing with other exit statuses that random programs may
+ * already return. The meaning of the codes is approximately
+ * as follows:
+ *
+ * EX_USAGE -- The command was used incorrectly, e.g., with
+ * the wrong number of arguments, a bad flag, a bad
+ * syntax in a parameter, or whatever.
+ * EX_DATAERR -- The input data was incorrect in some way.
+ * This should only be used for user's data & not
+ * system files.
+ * EX_NOINPUT -- An input file (not a system file) did not
+ * exist or was not readable. This could also include
+ * errors like "No message" to a mailer (if it cared
+ * to catch it).
+ * EX_NOUSER -- The user specified did not exist. This might
+ * be used for mail addresses or remote logins.
+ * EX_NOHOST -- The host specified did not exist. This is used
+ * in mail addresses or network requests.
+ * EX_UNAVAILABLE -- A service is unavailable. This can occur
+ * if a support program or file does not exist. This
+ * can also be used as a catchall message when something
+ * you wanted to do doesn't work, but you don't know
+ * why.
+ * EX_SOFTWARE -- An internal software error has been detected.
+ * This should be limited to non-operating system related
+ * errors as possible.
+ * EX_OSERR -- An operating system error has been detected.
+ * This is intended to be used for such things as "cannot
+ * fork", "cannot create pipe", or the like. It includes
+ * things like getuid returning a user that does not
+ * exist in the passwd file.
+ * EX_OSFILE -- Some system file (e.g., /etc/passwd, /var/run/utmp,
+ * etc.) does not exist, cannot be opened, or has some
+ * sort of error (e.g., syntax error).
+ * EX_CANTCREAT -- A (user specified) output file cannot be
+ * created.
+ * EX_IOERR -- An error occurred while doing I/O on some file.
+ * EX_TEMPFAIL -- temporary failure, indicating something that
+ * is not really an error. In sendmail, this means
+ * that a mailer (e.g.) could not create a connection,
+ * and the request should be reattempted later.
+ * EX_PROTOCOL -- the remote system returned something that
+ * was "not possible" during a protocol exchange.
+ * EX_NOPERM -- You did not have sufficient permission to
+ * perform the operation. This is not intended for
+ * file system problems, which should use EX_NOINPUT or
+ * EX_CANTCREAT, but rather for higher level permissions.
+ * EX_CONFIG -- Something was found in an unconfigured or
+ * misconfigured state.
+ */
+
+#define EX_OK 0 /* successful termination */
+
+#define EX__BASE 64 /* base value for error messages */
+
+#define EX_USAGE 64 /* command line usage error */
+#define EX_DATAERR 65 /* data format error */
+#define EX_NOINPUT 66 /* cannot open input */
+#define EX_NOUSER 67 /* addressee unknown */
+#define EX_NOHOST 68 /* host name unknown */
+#define EX_UNAVAILABLE 69 /* service unavailable */
+#define EX_SOFTWARE 70 /* internal software error */
+#define EX_OSERR 71 /* system error (e.g., can't fork) */
+#define EX_OSFILE 72 /* critical OS file missing */
+#define EX_CANTCREAT 73 /* can't create (user) output file */
+#define EX_IOERR 74 /* input/output error */
+#define EX_TEMPFAIL 75 /* temp failure; user is invited to retry */
+#define EX_PROTOCOL 76 /* remote error in protocol */
+#define EX_NOPERM 77 /* permission denied */
+#define EX_CONFIG 78 /* configuration error */
+
+#define EX__MAX 78 /* maximum listed value */
+
+#endif /* !_SYSEXITS_H_ */
diff --git a/include/tar.h b/include/tar.h
new file mode 100644
index 0000000..17f5124
--- /dev/null
+++ b/include/tar.h
@@ -0,0 +1,66 @@
+/* $OpenBSD: tar.h,v 1.3 2008/06/26 05:42:04 ray Exp $ */
+/* $NetBSD: tar.h,v 1.1 1996/02/05 22:34:13 jtc Exp $ */
+
+/*-
+ * Copyright (c) 1996 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by J.T. Conklin.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _TAR_H_
+#define _TAR_H_
+
+#define TMAGIC "ustar"
+#define TMAGLEN 6
+#define TVERSION "00"
+#define TVERSLEN 2
+
+/* Typeflag field definitions */
+#define REGTYPE '0'
+#define AREGTYPE '\0'
+#define LNKTYPE '1'
+#define SYMTYPE '2'
+#define CHRTYPE '3'
+#define BLKTYPE '4'
+#define DIRTYPE '5'
+#define FIFOTYPE '6'
+#define CONTTYPE '7'
+
+/* Mode field bit definitions */
+#define TSUID 04000
+#define TSGID 02000
+#define TSVTX 01000
+#define TUREAD 00400
+#define TUWRITE 00200
+#define TUEXEC 00100
+#define TGREAD 00040
+#define TGWRITE 00020
+#define TGEXEC 00010
+#define TOREAD 00004
+#define TOWRITE 00002
+#define TOEXEC 00001
+
+#endif /* _TAR_H_ */
diff --git a/include/tgmath.h b/include/tgmath.h
new file mode 100644
index 0000000..46fade4
--- /dev/null
+++ b/include/tgmath.h
@@ -0,0 +1,169 @@
+/* $OpenBSD: tgmath.h,v 1.1 2011/07/08 19:28:06 martynas Exp $ */
+
+/*-
+ * Copyright (c) 2004 Stefan Farfeleder.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD: src/include/tgmath.h,v 1.5 2007/02/02 18:30:23 schweikh Exp $
+ */
+
+#ifndef _TGMATH_H_
+#define _TGMATH_H_
+
+#include <complex.h>
+#include <math.h>
+
+/*
+ * This implementation of <tgmath.h> requires two implementation-dependent
+ * macros to be defined:
+ * __tg_impl_simple(x, y, z, fn, fnf, fnl, ...)
+ * Invokes fnl() if the corresponding real type of x, y or z is long
+ * double, fn() if it is double or any has an integer type, and fnf()
+ * otherwise.
+ * __tg_impl_full(x, y, z, fn, fnf, fnl, cfn, cfnf, cfnl, ...)
+ * Invokes [c]fnl() if the corresponding real type of x, y or z is long
+ * double, [c]fn() if it is double or any has an integer type, and
+ * [c]fnf() otherwise. The function with the 'c' prefix is called if
+ * any of x, y or z is a complex number.
+ * Both macros call the chosen function with all additional arguments passed
+ * to them, as given by __VA_ARGS__.
+ *
+ * Note that these macros cannot be implemented with C's ?: operator,
+ * because the return type of the whole expression would incorrectly be long
+ * double complex regardless of the argument types.
+ */
+
+#if __GNUC_PREREQ__(3, 1)
+#define __tg_type(e, t) __builtin_types_compatible_p(__typeof__(e), t)
+#define __tg_type3(e1, e2, e3, t) \
+ (__tg_type(e1, t) || __tg_type(e2, t) || __tg_type(e3, t))
+#define __tg_type_corr(e1, e2, e3, t) \
+ (__tg_type3(e1, e2, e3, t) || __tg_type3(e1, e2, e3, t _Complex))
+#define __tg_integer(e1, e2, e3) \
+ (((__typeof__(e1))1.5 == 1) || ((__typeof__(e2))1.5 == 1) || \
+ ((__typeof__(e3))1.5 == 1))
+#define __tg_is_complex(e1, e2, e3) \
+ (__tg_type3(e1, e2, e3, float _Complex) || \
+ __tg_type3(e1, e2, e3, double _Complex) || \
+ __tg_type3(e1, e2, e3, long double _Complex) || \
+ __tg_type3(e1, e2, e3, __typeof__(_Complex_I)))
+
+#define __tg_impl_simple(x, y, z, fn, fnf, fnl, ...) \
+ __builtin_choose_expr(__tg_type_corr(x, y, z, long double), \
+ fnl(__VA_ARGS__), __builtin_choose_expr( \
+ __tg_type_corr(x, y, z, double) || __tg_integer(x, y, z),\
+ fn(__VA_ARGS__), fnf(__VA_ARGS__)))
+
+#define __tg_impl_full(x, y, z, fn, fnf, fnl, cfn, cfnf, cfnl, ...) \
+ __builtin_choose_expr(__tg_is_complex(x, y, z), \
+ __tg_impl_simple(x, y, z, cfn, cfnf, cfnl, __VA_ARGS__), \
+ __tg_impl_simple(x, y, z, fn, fnf, fnl, __VA_ARGS__))
+
+#else /* __GNUC__ */
+#error "<tgmath.h> not implemented for this compiler"
+#endif /* !__GNUC__ */
+
+/* Macros to save lots of repetition below */
+#define __tg_simple(x, fn) \
+ __tg_impl_simple(x, x, x, fn, fn##f, fn##l, x)
+#define __tg_simple2(x, y, fn) \
+ __tg_impl_simple(x, x, y, fn, fn##f, fn##l, x, y)
+#define __tg_simplev(x, fn, ...) \
+ __tg_impl_simple(x, x, x, fn, fn##f, fn##l, __VA_ARGS__)
+#define __tg_full(x, fn) \
+ __tg_impl_full(x, x, x, fn, fn##f, fn##l, c##fn, c##fn##f, c##fn##l, x)
+
+/* 7.22#4 -- These macros expand to real or complex functions, depending on
+ * the type of their arguments. */
+#define acos(x) __tg_full(x, acos)
+#define asin(x) __tg_full(x, asin)
+#define atan(x) __tg_full(x, atan)
+#define acosh(x) __tg_full(x, acosh)
+#define asinh(x) __tg_full(x, asinh)
+#define atanh(x) __tg_full(x, atanh)
+#define cos(x) __tg_full(x, cos)
+#define sin(x) __tg_full(x, sin)
+#define tan(x) __tg_full(x, tan)
+#define cosh(x) __tg_full(x, cosh)
+#define sinh(x) __tg_full(x, sinh)
+#define tanh(x) __tg_full(x, tanh)
+#define exp(x) __tg_full(x, exp)
+#define log(x) __tg_full(x, log)
+#define pow(x, y) __tg_impl_full(x, x, y, pow, powf, powl, \
+ cpow, cpowf, cpowl, x, y)
+#define sqrt(x) __tg_full(x, sqrt)
+
+/* "The corresponding type-generic macro for fabs and cabs is fabs." */
+#define fabs(x) __tg_impl_full(x, x, x, fabs, fabsf, fabsl, \
+ cabs, cabsf, cabsl, x)
+
+/* 7.22#5 -- These macros are only defined for arguments with real type. */
+#define atan2(x, y) __tg_simple2(x, y, atan2)
+#define cbrt(x) __tg_simple(x, cbrt)
+#define ceil(x) __tg_simple(x, ceil)
+#define copysign(x, y) __tg_simple2(x, y, copysign)
+#define erf(x) __tg_simple(x, erf)
+#define erfc(x) __tg_simple(x, erfc)
+#define exp2(x) __tg_simple(x, exp2)
+#define expm1(x) __tg_simple(x, expm1)
+#define fdim(x, y) __tg_simple2(x, y, fdim)
+#define floor(x) __tg_simple(x, floor)
+#define fma(x, y, z) __tg_impl_simple(x, y, z, fma, fmaf, fmal, x, y, z)
+#define fmax(x, y) __tg_simple2(x, y, fmax)
+#define fmin(x, y) __tg_simple2(x, y, fmin)
+#define fmod(x, y) __tg_simple2(x, y, fmod)
+#define frexp(x, y) __tg_simplev(x, frexp, x, y)
+#define hypot(x, y) __tg_simple2(x, y, hypot)
+#define ilogb(x) __tg_simple(x, ilogb)
+#define ldexp(x, y) __tg_simplev(x, ldexp, x, y)
+#define lgamma(x) __tg_simple(x, lgamma)
+#define llrint(x) __tg_simple(x, llrint)
+#define llround(x) __tg_simple(x, llround)
+#define log10(x) __tg_simple(x, log10)
+#define log1p(x) __tg_simple(x, log1p)
+#define log2(x) __tg_simple(x, log2)
+#define logb(x) __tg_simple(x, logb)
+#define lrint(x) __tg_simple(x, lrint)
+#define lround(x) __tg_simple(x, lround)
+#define nearbyint(x) __tg_simple(x, nearbyint)
+#define nextafter(x, y) __tg_simple2(x, y, nextafter)
+#define nexttoward(x, y) __tg_simplev(x, nexttoward, x, y)
+#define remainder(x, y) __tg_simple2(x, y, remainder)
+#define remquo(x, y, z) __tg_impl_simple(x, x, y, remquo, remquof, \
+ remquol, x, y, z)
+#define rint(x) __tg_simple(x, rint)
+#define round(x) __tg_simple(x, round)
+#define scalbn(x, y) __tg_simplev(x, scalbn, x, y)
+#define scalbln(x, y) __tg_simplev(x, scalbln, x, y)
+#define tgamma(x) __tg_simple(x, tgamma)
+#define trunc(x) __tg_simple(x, trunc)
+
+/* 7.22#6 -- These macros always expand to complex functions. */
+#define carg(x) __tg_simple(x, carg)
+#define cimag(x) __tg_simple(x, cimag)
+#define conj(x) __tg_simple(x, conj)
+#define cproj(x) __tg_simple(x, cproj)
+#define creal(x) __tg_simple(x, creal)
+
+#endif /* !_TGMATH_H_ */
diff --git a/include/tib.h b/include/tib.h
new file mode 100644
index 0000000..8d9216f
--- /dev/null
+++ b/include/tib.h
@@ -0,0 +1,258 @@
+/* $OpenBSD: tib.h,v 1.7 2019/05/10 13:29:21 guenther Exp $ */
+/*
+ * Copyright (c) 2011,2014 Philip Guenther <guenther@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/*
+ * Thread Information Block (TIB) and Thread Local Storage (TLS) handling
+ * (the TCB, Thread Control Block, is part of the TIB)
+ */
+
+#ifndef _TIB_H_
+#define _TIB_H_
+
+#include <sys/types.h>
+#include <machine/tcb.h>
+
+#include <stddef.h>
+
+
+/*
+ * This header defines struct tib and at least eight macros:
+ * TLS_VARIANT
+ * Either 1 or 2 (Actually defined by <machine/tcb.h>)
+ *
+ * TCB_SET(tcb)
+ * Set the TCB pointer for this thread to 'tcb'
+ *
+ * TCB_GET()
+ * Return the TCB pointer for this thread
+ *
+ * TCB_TO_TIB(tcb)
+ * Given a TCB pointer, return the matching TIB pointer
+ *
+ * TIB_TO_TCB(tib)
+ * Given a TIB pointer, return the matching TCB pointer
+ *
+ * TIB_INIT(tib, dtv, thread)
+ * Initializes a TIB for a new thread, using the supplied
+ * values for its dtv and thread pointers
+ *
+ * TIB_GET()
+ * Short-hand for TCB_TO_TIB(TCB_GET())
+ *
+ * TIB_EXTRA_ALIGN
+ * On TLS varaint 2 archs, what alignment is sufficient
+ * for the extra space that will be used for struct pthread?
+ *
+ * The following functions are provided by either ld.so (dynamic) or
+ * libc (static) for allocating and freeing a common memory block that
+ * will hold both the TIB and the pthread structure:
+ * _dl_allocate_tib(sizeof(struct pthread))
+ * Allocates a combined TIB and pthread memory region.
+ * The argument is the amount of space to reserve
+ * for the pthread structure. Returns a pointer to
+ * the TIB inside the allocated block.
+ *
+ * _dl_free_tib(tib, sizeof(struct pthread))
+ * Frees a TIB and pthread block previously allocated
+ * with _dl_allocate_tib(). Must be passed the return
+ * value of that previous call.
+ */
+
+/*
+ * Regarding <machine/tcb.h>:
+ * - it must define the TLS_VARIANT macro
+ * - it may define TCB_OFFSET if the TCB address in the kernel and/or
+ * register is offset from the actual TCB address. TCB_OFFSET > 0
+ * means the kernel/register points to *after* the real data.
+ * - if there's a faster way to get or set the TCB pointer for the thread
+ * than the __{get,set}_tcb() syscalls, it should define either or both
+ * the TCB_{GET,SET} macros to do so.
+ */
+
+
+/* All archs but mips64 have fast TCB_GET() and don't need caching */
+#ifndef __mips64__
+# define TCB_HAVE_MD_GET 1
+#endif
+#ifdef TCB_SET
+# define TCB_HAVE_MD_SET 1
+#else
+# define TCB_SET(tcb) __set_tcb(tcb)
+#endif
+#ifndef TCB_OFFSET
+# define TCB_OFFSET 0
+#endif
+
+/*
+ * tib_cantcancel values is non-zero if the thread should skip all
+ * cancellation processing
+ */
+#define CANCEL_DISABLED 1
+#define CANCEL_DYING 2
+
+/*
+ * tib_cancel_point is non-zero if we're in a cancel point; its modified
+ * by the cancel point code and read by the cancellation signal handler
+ */
+#define CANCEL_POINT 1
+#define CANCEL_POINT_DELAYED 2
+
+
+#if TLS_VARIANT == 1
+/*
+ * ABI specifies that the static TLS data starts two words after the
+ * (notional) thread pointer, with the first of those two words being
+ * the TLS dtv pointer. The other (second) word is reserved for the
+ * implementation, so we place the pointer to the thread structure there,
+ * but we place our actual thread bits before the TCB, at negative offsets
+ * from the TCB pointer. Ergo, memory is laid out, low to high, as:
+ *
+ * [pthread structure]
+ * TIB {
+ * ...cancelation and other int-sized info...
+ * int errno
+ * void *locale
+ * TCB (- TCB_OFFSET) {
+ * void *dtv
+ * struct pthread *thread
+ * }
+ * }
+ * static TLS data
+ */
+
+struct tib {
+ void *tib_atexit;
+ int tib_thread_flags; /* internal to libpthread */
+ pid_t tib_tid;
+ int tib_cantcancel;
+ int tib_cancel_point;
+ int tib_canceled;
+ int tib_errno;
+ void *tib_locale;
+ void *tib_dtv; /* internal to the runtime linker */
+ void *tib_thread;
+};
+
+
+#elif TLS_VARIANT == 2
+/*
+ * ABI specifies that the static TLS data occupies the memory before
+ * the TCB pointer, at negative offsets, and that on i386 and amd64
+ * the word the TCB points to contains a pointer to itself. So,
+ * we place errno and our thread bits after that. Memory is laid
+ * out, low to high, as:
+ * static TLS data
+ * TIB {
+ * TCB (- TCB_OFFSET) {
+ * self pointer [i386/amd64 only]
+ * void *dtv
+ * }
+ * struct pthread *thread
+ * void *locale
+ * int errno
+ * ...cancelation and other int-sized info...
+ * }
+ * [pthread structure]
+ */
+
+struct tib {
+#if defined(__i386) || defined(__amd64)
+ struct tib *__tib_self;
+# define __tib_tcb __tib_self
+#endif
+ void *tib_dtv; /* internal to the runtime linker */
+ void *tib_thread;
+ void *tib_locale;
+ int tib_errno;
+ int tib_canceled;
+ int tib_cancel_point;
+ int tib_cantcancel;
+ pid_t tib_tid;
+ int tib_thread_flags; /* internal to libpthread */
+ void *tib_atexit;
+};
+
+#if defined(__i386) || defined(__amd64)
+# define _TIB_PREP(tib) \
+ ((void)((tib)->__tib_self = (tib)))
+#endif
+
+#define TIB_EXTRA_ALIGN sizeof(void *)
+
+#else
+# error "unknown TLS variant"
+#endif
+
+/* nothing to do by default */
+#ifndef _TIB_PREP
+# define _TIB_PREP(tib) ((void)0)
+#endif
+
+#define TIB_INIT(tib, dtv, thread) do { \
+ (tib)->tib_thread = (thread); \
+ (tib)->tib_atexit = NULL; \
+ (tib)->tib_locale = NULL; \
+ (tib)->tib_cantcancel = 0; \
+ (tib)->tib_cancel_point = 0; \
+ (tib)->tib_canceled = 0; \
+ (tib)->tib_dtv = (dtv); \
+ (tib)->tib_errno = 0; \
+ _TIB_PREP(tib); \
+ } while (0)
+
+#ifndef __tib_tcb
+# define __tib_tcb tib_dtv
+#endif
+#define _TIBO_TCB (offsetof(struct tib, __tib_tcb) + TCB_OFFSET)
+
+#define TCB_TO_TIB(tcb) ((struct tib *)((char *)(tcb) - _TIBO_TCB))
+#define TIB_TO_TCB(tib) ((char *)(tib) + _TIBO_TCB)
+#define TIB_GET() TCB_TO_TIB(TCB_GET())
+
+
+__BEGIN_DECLS
+struct dl_info;
+struct dl_phdr_info;
+struct dl_cb_0 {
+ void *(*dl_allocate_tib)(size_t);
+ void (*dl_free_tib)(void *, size_t);
+ void (*dl_clean_boot)(void);
+ void *(*dlopen)(const char *, int);
+ int (*dlclose)(void *);
+ void *(*dlsym)(void *, const char *);
+ int (*dladdr)(const void *, struct dl_info *);
+ int (*dlctl)(void *, int, void *);
+ char *(*dlerror)(void);
+ int (*dl_iterate_phdr)(int (*)(struct dl_phdr_info *,
+ size_t, void *), void *);
+};
+
+#define DL_CB_CUR 0
+typedef struct dl_cb_0 dl_cb;
+
+/* type of function passed to init functions that returns a dl_cb */
+typedef const void *dl_cb_cb(int _version);
+
+void *_dl_allocate_tib(size_t _extra) __dso_public;
+void _dl_free_tib(void *_tib, size_t _extra) __dso_public;
+
+/* The actual syscalls */
+void *__get_tcb(void);
+void __set_tcb(void *_tcb);
+__END_DECLS
+
+#endif /* _TIB_H_ */
diff --git a/include/time.h b/include/time.h
new file mode 100644
index 0000000..51bee8f
--- /dev/null
+++ b/include/time.h
@@ -0,0 +1,191 @@
+/* $OpenBSD: time.h,v 1.31 2018/10/30 16:28:42 guenther Exp $ */
+/* $NetBSD: time.h,v 1.9 1994/10/26 00:56:35 cgd Exp $ */
+
+/*
+ * Copyright (c) 1989 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)time.h 5.12 (Berkeley) 3/9/91
+ */
+
+#ifndef _TIME_H_
+#define _TIME_H_
+
+#include <sys/cdefs.h>
+#include <sys/_null.h>
+#include <sys/_types.h>
+
+#ifndef _CLOCK_T_DEFINED_
+#define _CLOCK_T_DEFINED_
+typedef __clock_t clock_t;
+#endif
+
+#ifndef _TIME_T_DEFINED_
+#define _TIME_T_DEFINED_
+typedef __time_t time_t;
+#endif
+
+#ifndef _SIZE_T_DEFINED_
+#define _SIZE_T_DEFINED_
+typedef __size_t size_t;
+#endif
+
+#if __POSIX_VISIBLE > 0 && __POSIX_VISIBLE < 200112 || __BSD_VISIBLE
+/*
+ * Frequency of the clock ticks reported by times(). Deprecated - use
+ * sysconf(_SC_CLK_TCK) instead. (Removed in 1003.1-2001.)
+ */
+#define CLK_TCK 100
+#endif
+
+#define CLOCKS_PER_SEC 100 /* frequency of ticks reported by clock(). */
+
+#if __POSIX_VISIBLE >= 199309 || __ISO_C_VISIBLE >= 2011
+#ifndef _TIMESPEC_DECLARED
+#define _TIMESPEC_DECLARED
+struct timespec {
+ time_t tv_sec; /* seconds */
+ long tv_nsec; /* and nanoseconds */
+};
+#endif
+#endif
+
+#if __POSIX_VISIBLE >= 199309
+#include <sys/_time.h>
+
+#ifndef _CLOCKID_T_DEFINED_
+#define _CLOCKID_T_DEFINED_
+typedef __clockid_t clockid_t;
+#endif
+
+#ifndef _TIMER_T_DEFINED_
+#define _TIMER_T_DEFINED_
+typedef __timer_t timer_t;
+#endif
+#endif
+
+#if __POSIX_VISIBLE >= 200112
+#ifndef _PID_T_DEFINED_
+#define _PID_T_DEFINED_
+typedef __pid_t pid_t;
+#endif
+#endif
+
+#if __POSIX_VISIBLE >= 200809
+#ifndef _LOCALE_T_DEFINED_
+#define _LOCALE_T_DEFINED_
+typedef void *locale_t;
+#endif
+#endif
+
+struct tm {
+ int tm_sec; /* seconds after the minute [0-60] */
+ int tm_min; /* minutes after the hour [0-59] */
+ int tm_hour; /* hours since midnight [0-23] */
+ int tm_mday; /* day of the month [1-31] */
+ int tm_mon; /* months since January [0-11] */
+ int tm_year; /* years since 1900 */
+ int tm_wday; /* days since Sunday [0-6] */
+ int tm_yday; /* days since January 1 [0-365] */
+ int tm_isdst; /* Daylight Saving Time flag */
+ long tm_gmtoff; /* offset from UTC in seconds */
+ char *tm_zone; /* timezone abbreviation */
+};
+
+__BEGIN_DECLS
+char *asctime(const struct tm *);
+clock_t clock(void);
+char *ctime(const time_t *);
+double difftime(time_t, time_t);
+struct tm *gmtime(const time_t *);
+struct tm *localtime(const time_t *);
+time_t mktime(struct tm *);
+size_t strftime(char *__restrict, size_t, const char *__restrict,
+ const struct tm *__restrict)
+ __attribute__ ((__bounded__(__string__,1,2)));
+time_t time(time_t *);
+
+#if __XPG_VISIBLE >= 300
+extern int daylight;
+extern long timezone;
+#endif
+#if __XPG_VISIBLE >= 400
+char *strptime(const char *__restrict, const char *__restrict,
+ struct tm *__restrict);
+#endif
+
+#if __POSIX_VISIBLE >= 199506
+char *asctime_r(const struct tm *__restrict, char *__restrict)
+ __attribute__ ((__bounded__(__minbytes__,2,26)));
+char *ctime_r(const time_t *, char *)
+ __attribute__ ((__bounded__(__minbytes__,2,26)));
+struct tm *gmtime_r(const time_t *__restrict, struct tm *__restrict);
+struct tm *localtime_r(const time_t *__restrict, struct tm *__restrict);
+#endif
+
+#if __POSIX_VISIBLE
+extern char *tzname[2];
+void tzset(void);
+#endif
+
+#if __POSIX_VISIBLE >= 199309
+int clock_getres(clockid_t, struct timespec *);
+int clock_gettime(clockid_t, struct timespec *);
+int clock_settime(clockid_t, const struct timespec *);
+int nanosleep(const struct timespec *, struct timespec *);
+#endif
+
+#if __POSIX_VISIBLE >= 200112
+int clock_getcpuclockid(pid_t, clockid_t *);
+#endif
+
+#if __POSIX_VISIBLE >= 200809
+size_t strftime_l(char *__restrict, size_t, const char *__restrict,
+ const struct tm *__restrict, locale_t)
+ __attribute__ ((__bounded__(__string__,1,2)));
+#endif
+
+#if __ISO_C_VISIBLE >= 2011
+#define TIME_UTC 1 /* time elapsed since epoch */
+int timespec_get(struct timespec *_ts, int _base);
+#endif
+
+#if __BSD_VISIBLE
+void tzsetwall(void);
+time_t timelocal(struct tm *);
+time_t timegm(struct tm *);
+time_t timeoff(struct tm *, const long);
+#endif
+__END_DECLS
+
+#endif /* !_TIME_H_ */
diff --git a/include/ttyent.h b/include/ttyent.h
new file mode 100644
index 0000000..406d466
--- /dev/null
+++ b/include/ttyent.h
@@ -0,0 +1,73 @@
+/* $OpenBSD: ttyent.h,v 1.4 2003/06/02 19:34:12 millert Exp $ */
+/* $NetBSD: ttyent.h,v 1.5 1994/10/26 00:56:36 cgd Exp $ */
+
+/*
+ * Copyright (c) 1989 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)ttyent.h 5.7 (Berkeley) 4/3/91
+ */
+
+#ifndef _TTYENT_H_
+#define _TTYENT_H_
+
+#define _PATH_TTYS "/etc/ttys"
+
+#define _TTYS_OFF "off"
+#define _TTYS_ON "on"
+#define _TTYS_SECURE "secure"
+#define _TTYS_WINDOW "window"
+#define _TTYS_LOCAL "local"
+#define _TTYS_RTSCTS "rtscts"
+#define _TTYS_SOFTCAR "softcar"
+#define _TTYS_MDMBUF "mdmbuf"
+
+struct ttyent {
+ char *ty_name; /* terminal device name */
+ char *ty_getty; /* command to execute, usually getty */
+ char *ty_type; /* terminal type for termcap */
+#define TTY_ON 0x01 /* enable logins (start ty_getty program) */
+#define TTY_SECURE 0x02 /* allow uid of 0 to login */
+#define TTY_LOCAL 0x04 /* set 'CLOCAL' on open (dev. specific) */
+#define TTY_RTSCTS 0x08 /* set 'CRTSCTS' on open (dev. specific) */
+#define TTY_SOFTCAR 0x10 /* ignore hardware carrier (dev. spec.) */
+#define TTY_MDMBUF 0x20 /* set 'MDMBUF' on open (dev. specific) */
+ int ty_status; /* status flags */
+ char *ty_window; /* command to start up window manager */
+ char *ty_comment; /* comment field */
+};
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+struct ttyent *getttyent(void);
+struct ttyent *getttynam(const char *);
+int setttyent(void);
+int endttyent(void);
+__END_DECLS
+
+#endif /* !_TTYENT_H_ */
diff --git a/include/unistd.h b/include/unistd.h
new file mode 100644
index 0000000..a715077
--- /dev/null
+++ b/include/unistd.h
@@ -0,0 +1,3 @@
+#include_next <unistd.h>
+#define pledge(request, paths) 0 /* linux doesn't have pledge */
+#define unveil(path, permissions) 0 /* linux doesn't have unveil */
diff --git a/include/utime.h b/include/utime.h
new file mode 100644
index 0000000..f617865
--- /dev/null
+++ b/include/utime.h
@@ -0,0 +1,55 @@
+/* $OpenBSD: utime.h,v 1.7 2013/04/02 05:16:14 guenther Exp $ */
+/* $NetBSD: utime.h,v 1.3 1994/10/26 00:56:39 cgd Exp $ */
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)utime.h 5.4 (Berkeley) 4/3/91
+ */
+
+#ifndef _UTIME_H_
+#define _UTIME_H_
+
+#include <sys/cdefs.h>
+#include <sys/_types.h>
+
+#ifndef _TIME_T_DEFINED_
+#define _TIME_T_DEFINED_
+typedef __time_t time_t;
+#endif
+
+struct utimbuf {
+ time_t actime; /* Access time */
+ time_t modtime; /* Modification time */
+};
+
+__BEGIN_DECLS
+int utime(const char *, const struct utimbuf *);
+__END_DECLS
+
+#endif /* !_UTIME_H_ */
diff --git a/include/utmp.h b/include/utmp.h
new file mode 100644
index 0000000..b946a2d
--- /dev/null
+++ b/include/utmp.h
@@ -0,0 +1,69 @@
+/* $OpenBSD: utmp.h,v 1.6 2014/01/08 06:50:57 guenther Exp $ */
+/* $NetBSD: utmp.h,v 1.6 1994/10/26 00:56:40 cgd Exp $ */
+
+/*
+ * Copyright (c) 1988, 1993
+ * The Regents of the University of California. All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)utmp.h 8.2 (Berkeley) 1/21/94
+ */
+
+#ifndef _UTMP_H_
+#define _UTMP_H_
+
+#define _PATH_UTMP "/var/run/utmp"
+#define _PATH_WTMP "/var/log/wtmp"
+#define _PATH_LASTLOG "/var/log/lastlog"
+
+#define UT_NAMESIZE 32
+#define UT_LINESIZE 8
+#define UT_HOSTSIZE 256
+
+/*
+ * Note that these are *not* C strings and thus are not
+ * guaranteed to be NUL-terminated.
+ */
+
+struct lastlog {
+ time_t ll_time;
+ char ll_line[UT_LINESIZE];
+ char ll_host[UT_HOSTSIZE];
+};
+
+struct utmp {
+ char ut_line[UT_LINESIZE];
+ char ut_name[UT_NAMESIZE];
+ char ut_host[UT_HOSTSIZE];
+ time_t ut_time;
+};
+
+#endif /* !_UTMP_H_ */
diff --git a/include/uuid.h b/include/uuid.h
new file mode 100644
index 0000000..3e10b9e
--- /dev/null
+++ b/include/uuid.h
@@ -0,0 +1,69 @@
+/* $OpenBSD: uuid.h,v 1.1 2014/08/31 09:36:36 miod Exp $ */
+/* $NetBSD: uuid.h,v 1.2 2008/04/23 07:52:32 plunky Exp $ */
+
+/*
+ * Copyright (c) 2002 Marcel Moolenaar
+ * Copyright (c) 2002 Hiten Mahesh Pandya
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD: src/include/uuid.h,v 1.2 2002/11/05 10:55:16 jmallett Exp $
+ */
+
+#ifndef _UUID_H_
+#define _UUID_H_
+
+#include <sys/types.h>
+#include <sys/uuid.h>
+
+/* Status codes returned by the functions. */
+#define uuid_s_ok 0
+#define uuid_s_bad_version 1
+#define uuid_s_invalid_string_uuid 2
+#define uuid_s_no_memory 3
+
+/* Length of a printed UUID. */
+#define UUID_BUF_LEN _UUID_BUF_LEN
+
+/* Length of a UUID. */
+#define UUID_STR_LEN 36
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+int32_t uuid_compare(const uuid_t *, const uuid_t *, uint32_t *);
+void uuid_create(uuid_t *, uint32_t *);
+void uuid_create_nil(uuid_t *, uint32_t *);
+int32_t uuid_equal(const uuid_t *, const uuid_t *, uint32_t *);
+void uuid_from_string(const char *, uuid_t *, uint32_t *);
+uint16_t uuid_hash(const uuid_t *, uint32_t *);
+int32_t uuid_is_nil(const uuid_t *, uint32_t *);
+void uuid_to_string(const uuid_t *, char **, uint32_t *);
+
+void uuid_enc_le(void *, const uuid_t *);
+void uuid_dec_le(const void *, uuid_t *);
+void uuid_enc_be(void *, const uuid_t *);
+void uuid_dec_be(const void *, uuid_t *);
+__END_DECLS
+
+#endif /* _UUID_H_ */
diff --git a/include/vis.h b/include/vis.h
new file mode 100644
index 0000000..8804417
--- /dev/null
+++ b/include/vis.h
@@ -0,0 +1,93 @@
+/* $OpenBSD: vis.h,v 1.15 2015/07/20 01:52:27 millert Exp $ */
+/* $NetBSD: vis.h,v 1.4 1994/10/26 00:56:41 cgd Exp $ */
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)vis.h 5.9 (Berkeley) 4/3/91
+ */
+
+#ifndef _VIS_H_
+#define _VIS_H_
+
+/*
+ * to select alternate encoding format
+ */
+#define VIS_OCTAL 0x01 /* use octal \ddd format */
+#define VIS_CSTYLE 0x02 /* use \[nrft0..] where appropriate */
+
+/*
+ * to alter set of characters encoded (default is to encode all
+ * non-graphic except space, tab, and newline).
+ */
+#define VIS_SP 0x04 /* also encode space */
+#define VIS_TAB 0x08 /* also encode tab */
+#define VIS_NL 0x10 /* also encode newline */
+#define VIS_WHITE (VIS_SP | VIS_TAB | VIS_NL)
+#define VIS_SAFE 0x20 /* only encode "unsafe" characters */
+#define VIS_DQ 0x200 /* backslash-escape double quotes */
+#define VIS_ALL 0x400 /* encode all characters */
+
+/*
+ * other
+ */
+#define VIS_NOSLASH 0x40 /* inhibit printing '\' */
+#define VIS_GLOB 0x100 /* encode glob(3) magics and '#' */
+
+/*
+ * unvis return codes
+ */
+#define UNVIS_VALID 1 /* character valid */
+#define UNVIS_VALIDPUSH 2 /* character valid, push back passed char */
+#define UNVIS_NOCHAR 3 /* valid sequence, no character produced */
+#define UNVIS_SYNBAD -1 /* unrecognized escape sequence */
+#define UNVIS_ERROR -2 /* decoder in unknown state (unrecoverable) */
+
+/*
+ * unvis flags
+ */
+#define UNVIS_END 1 /* no more characters */
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+char *vis(char *, int, int, int);
+int strvis(char *, const char *, int);
+int stravis(char **, const char *, int);
+int strnvis(char *, const char *, size_t, int)
+ __attribute__ ((__bounded__(__string__,1,3)));
+int strvisx(char *, const char *, size_t, int)
+ __attribute__ ((__bounded__(__string__,1,3)));
+int strunvis(char *, const char *);
+int unvis(char *, char, int *, int);
+ssize_t strnunvis(char *, const char *, size_t)
+ __attribute__ ((__bounded__(__string__,1,3)));
+
+__END_DECLS
+
+#endif /* !_VIS_H_ */
diff --git a/include/wchar.h b/include/wchar.h
new file mode 100644
index 0000000..309f812
--- /dev/null
+++ b/include/wchar.h
@@ -0,0 +1,239 @@
+/* $OpenBSD: wchar.h,v 1.31 2017/09/05 03:16:13 schwarze Exp $ */
+/* $NetBSD: wchar.h,v 1.16 2003/03/07 07:11:35 tshiozak Exp $ */
+
+/*-
+ * Copyright (c)1999 Citrus Project,
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*-
+ * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Julian Coleman.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _WCHAR_H_
+#define _WCHAR_H_
+
+#include <sys/cdefs.h>
+#include <sys/_null.h>
+#include <sys/_types.h>
+
+#include <stdio.h> /* for FILE* */
+
+#if !defined(_WCHAR_T_DEFINED_) && !defined(__cplusplus)
+#define _WCHAR_T_DEFINED_
+typedef __wchar_t wchar_t;
+#endif
+
+#ifndef _MBSTATE_T_DEFINED_
+#define _MBSTATE_T_DEFINED_
+typedef __mbstate_t mbstate_t;
+#endif
+
+#ifndef _WINT_T_DEFINED_
+#define _WINT_T_DEFINED_
+typedef __wint_t wint_t;
+#endif
+
+#ifndef _SIZE_T_DEFINED_
+#define _SIZE_T_DEFINED_
+typedef __size_t size_t;
+#endif
+
+#ifndef WEOF
+#define WEOF ((wint_t)-1)
+#endif
+
+#ifndef WCHAR_MIN
+#define WCHAR_MIN (-0x7fffffff - 1)
+#endif
+#ifndef WCHAR_MAX
+#define WCHAR_MAX 0x7fffffff
+#endif
+
+#if __POSIX_VISIBLE >= 200809
+#ifndef _LOCALE_T_DEFINED_
+#define _LOCALE_T_DEFINED_
+typedef void *locale_t;
+#endif
+#endif
+
+__BEGIN_DECLS
+wint_t btowc(int);
+size_t mbrlen(const char * __restrict, size_t, mbstate_t * __restrict);
+size_t mbrtowc(wchar_t * __restrict, const char * __restrict, size_t,
+ mbstate_t * __restrict);
+int mbsinit(const mbstate_t *);
+size_t mbsrtowcs(wchar_t * __restrict, const char ** __restrict, size_t,
+ mbstate_t * __restrict)
+ __attribute__ ((__bounded__(__wcstring__,1,3)));
+size_t wcrtomb(char * __restrict, wchar_t, mbstate_t * __restrict);
+wchar_t *wcscat(wchar_t * __restrict, const wchar_t * __restrict);
+wchar_t *wcschr(const wchar_t *, wchar_t);
+int wcscmp(const wchar_t *, const wchar_t *);
+int wcscoll(const wchar_t *, const wchar_t *);
+wchar_t *wcscpy(wchar_t * __restrict, const wchar_t * __restrict);
+size_t wcscspn(const wchar_t *, const wchar_t *);
+size_t wcslen(const wchar_t *);
+wchar_t *wcsncat(wchar_t * __restrict, const wchar_t * __restrict,
+ size_t)
+ __attribute__ ((__bounded__(__wcstring__,1,3)));
+int wcsncmp(const wchar_t *, const wchar_t *, size_t);
+wchar_t *wcsncpy(wchar_t * __restrict , const wchar_t * __restrict,
+ size_t)
+ __attribute__ ((__bounded__(__wcstring__,1,3)));
+wchar_t *wcspbrk(const wchar_t *, const wchar_t *);
+wchar_t *wcsrchr(const wchar_t *, wchar_t);
+size_t wcsrtombs(char * __restrict, const wchar_t ** __restrict, size_t,
+ mbstate_t * __restrict)
+ __attribute__ ((__bounded__(__wcstring__,1,3)));
+size_t wcsspn(const wchar_t *, const wchar_t *);
+wchar_t *wcsstr(const wchar_t *, const wchar_t *);
+wchar_t *wcstok(wchar_t * __restrict, const wchar_t * __restrict,
+ wchar_t ** __restrict);
+size_t wcsxfrm(wchar_t *, const wchar_t *, size_t);
+wchar_t *wcswcs(const wchar_t *, const wchar_t *);
+wchar_t *wmemchr(const wchar_t *, wchar_t, size_t);
+int wmemcmp(const wchar_t *, const wchar_t *, size_t);
+wchar_t *wmemcpy(wchar_t * __restrict, const wchar_t * __restrict,
+ size_t)
+ __attribute__ ((__bounded__(__wcstring__,1,3)))
+ __attribute__ ((__bounded__(__wcstring__,2,3)));
+wchar_t *wmemmove(wchar_t *, const wchar_t *, size_t)
+ __attribute__ ((__bounded__(__wcstring__,1,3)))
+ __attribute__ ((__bounded__(__wcstring__,2,3)));
+wchar_t *wmemset(wchar_t *, wchar_t, size_t)
+ __attribute__ ((__bounded__(__wcstring__,1,3)));
+
+int wcswidth(const wchar_t *, size_t);
+int wctob(wint_t);
+int wcwidth(wchar_t);
+
+double wcstod(const wchar_t * __restrict, wchar_t ** __restrict);
+long int wcstol(const wchar_t * __restrict, wchar_t ** __restrict, int base);
+unsigned long int wcstoul(const wchar_t * __restrict, wchar_t ** __restrict,
+ int base);
+
+#if __POSIX_VISIBLE >= 200809
+FILE *open_wmemstream(wchar_t **, size_t *);
+
+int wcscoll_l(const wchar_t *, const wchar_t *, locale_t);
+wchar_t *wcsdup(const wchar_t *);
+int wcscasecmp(const wchar_t *, const wchar_t *);
+int wcscasecmp_l(const wchar_t *, const wchar_t *, locale_t);
+int wcsncasecmp(const wchar_t *, const wchar_t *, size_t);
+int wcsncasecmp_l(const wchar_t *, const wchar_t *, size_t, locale_t);
+size_t wcsxfrm_l(wchar_t *, const wchar_t *, size_t, locale_t);
+
+size_t mbsnrtowcs(wchar_t * __restrict, const char ** __restrict, size_t,
+ size_t, mbstate_t * __restrict)
+ __attribute__ ((__bounded__(__wcstring__,1,4)));
+size_t wcsnrtombs(char * __restrict, const wchar_t ** __restrict, size_t,
+ size_t, mbstate_t * __restrict)
+ __attribute__ ((__bounded__(__wcstring__,1,4)));
+#endif
+
+#if __ISO_C_VISIBLE >= 1999
+float wcstof(const wchar_t * __restrict, wchar_t ** __restrict);
+long double wcstold(const wchar_t * __restrict, wchar_t ** __restrict);
+
+struct tm;
+size_t wcsftime(wchar_t * __restrict, size_t, const wchar_t *__restrict,
+ const struct tm *__restrict);
+#endif
+
+#if !defined(__STRICT_ANSI__) || __ISO_C_VISIBLE >= 1999
+long long int wcstoll(const wchar_t * __restrict,
+ wchar_t ** __restrict, int base);
+unsigned long long int wcstoull(const wchar_t * __restrict,
+ wchar_t ** __restrict, int base);
+#endif
+
+wint_t ungetwc(wint_t, FILE *);
+wint_t fgetwc(FILE *);
+wchar_t *fgetws(wchar_t * __restrict, int, FILE * __restrict)
+ __attribute__ ((__bounded__(__wcstring__,1,2)));
+wint_t getwc(FILE *);
+wint_t getwchar(void);
+wint_t fputwc(wchar_t, FILE *);
+int fputws(const wchar_t * __restrict, FILE * __restrict);
+wint_t putwc(wchar_t, FILE *);
+wint_t putwchar(wchar_t);
+
+int fwide(FILE *, int);
+
+int fwprintf(FILE * __restrict, const wchar_t * __restrict, ...);
+int swprintf(wchar_t * __restrict, size_t, const wchar_t * __restrict, ...);
+int vfwprintf(FILE * __restrict, const wchar_t * __restrict, __va_list);
+int vswprintf(wchar_t * __restrict, size_t, const wchar_t * __restrict,
+ __va_list);
+int vwprintf(const wchar_t * __restrict, __va_list);
+int wprintf(const wchar_t * __restrict, ...);
+
+int fwscanf(FILE * __restrict, const wchar_t * __restrict, ...);
+int swscanf(const wchar_t * __restrict, const wchar_t * __restrict, ...);
+int vfwscanf(FILE * __restrict, const wchar_t * __restrict, __va_list);
+int vswscanf(const wchar_t * __restrict, const wchar_t * __restrict, __va_list);
+int vwscanf(const wchar_t * __restrict, __va_list);
+int wscanf(const wchar_t * __restrict, ...);
+
+#if __BSD_VISIBLE
+wchar_t *fgetwln(FILE * __restrict, size_t * __restrict);
+size_t wcslcat(wchar_t *, const wchar_t *, size_t)
+ __attribute__ ((__bounded__(__wcstring__,1,3)));
+size_t wcslcpy(wchar_t *, const wchar_t *, size_t)
+ __attribute__ ((__bounded__(__wcstring__,1,3)));
+#endif
+
+#define getwc(f) fgetwc(f)
+#define getwchar() getwc(stdin)
+#define putwc(wc, f) fputwc((wc), (f))
+#define putwchar(wc) putwc((wc), stdout)
+__END_DECLS
+
+#endif /* !_WCHAR_H_ */
diff --git a/include/wctype.h b/include/wctype.h
new file mode 100644
index 0000000..bf61d25
--- /dev/null
+++ b/include/wctype.h
@@ -0,0 +1,107 @@
+/* $OpenBSD: wctype.h,v 1.6 2017/09/05 03:16:13 schwarze Exp $ */
+/* $NetBSD: wctype.h,v 1.5 2003/03/02 22:18:11 tshiozak Exp $ */
+
+/*-
+ * Copyright (c)1999 Citrus Project,
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * citrus Id: wctype.h,v 1.4 2000/12/21 01:50:21 itojun Exp
+ */
+
+#ifndef _WCTYPE_H_
+#define _WCTYPE_H_
+
+#include <sys/cdefs.h>
+#include <machine/_types.h>
+
+#ifndef _WINT_T_DEFINED_
+#define _WINT_T_DEFINED_
+typedef __wint_t wint_t;
+#endif
+
+#ifndef _WCTRANS_T_DEFINED_
+#define _WCTRANS_T_DEFINED_
+typedef __wctrans_t wctrans_t;
+#endif
+
+#ifndef _WCTYPE_T_DEFINED_
+#define _WCTYPE_T_DEFINED_
+typedef __wctype_t wctype_t;
+#endif
+
+#ifndef WEOF
+#define WEOF ((wint_t)-1)
+#endif
+
+#if __POSIX_VISIBLE >= 200809
+#ifndef _LOCALE_T_DEFINED_
+#define _LOCALE_T_DEFINED_
+typedef void *locale_t;
+#endif
+#endif
+
+__BEGIN_DECLS
+int iswalnum(wint_t);
+int iswalpha(wint_t);
+int iswblank(wint_t);
+int iswcntrl(wint_t);
+int iswdigit(wint_t);
+int iswgraph(wint_t);
+int iswlower(wint_t);
+int iswprint(wint_t);
+int iswpunct(wint_t);
+int iswspace(wint_t);
+int iswupper(wint_t);
+int iswxdigit(wint_t);
+int iswctype(wint_t, wctype_t);
+wint_t towctrans(wint_t, wctrans_t);
+wint_t towlower(wint_t);
+wint_t towupper(wint_t);
+wctrans_t wctrans(const char *);
+wctype_t wctype(const char *);
+
+#if __POSIX_VISIBLE >= 200809
+int iswalnum_l(wint_t, locale_t);
+int iswalpha_l(wint_t, locale_t);
+int iswblank_l(wint_t, locale_t);
+int iswcntrl_l(wint_t, locale_t);
+int iswdigit_l(wint_t, locale_t);
+int iswgraph_l(wint_t, locale_t);
+int iswlower_l(wint_t, locale_t);
+int iswprint_l(wint_t, locale_t);
+int iswpunct_l(wint_t, locale_t);
+int iswspace_l(wint_t, locale_t);
+int iswupper_l(wint_t, locale_t);
+int iswxdigit_l(wint_t, locale_t);
+int iswctype_l(wint_t, wctype_t, locale_t);
+wint_t towctrans_l(wint_t, wctrans_t, locale_t);
+wint_t towlower_l(wint_t, locale_t);
+wint_t towupper_l(wint_t, locale_t);
+wctrans_t wctrans_l(const char *, locale_t);
+wctype_t wctype_l(const char *, locale_t);
+#endif
+
+__END_DECLS
+
+#endif /* _WCTYPE_H_ */
diff --git a/includedir/err.h b/includedir/err.h
new file mode 100644
index 0000000..c537811
--- /dev/null
+++ b/includedir/err.h
@@ -0,0 +1,3 @@
+#include_next <err.h>
+void warnc(int, const char *, ...) __attribute__((__format__ (printf, 2, 3)));
+void vwarnc(int, const char *, va_list) __attribute__((__format__ (printf, 2, 0)));
diff --git a/includedir/grp.h b/includedir/grp.h
new file mode 100644
index 0000000..c59cf96
--- /dev/null
+++ b/includedir/grp.h
@@ -0,0 +1,4 @@
+#include_next <grp.h>
+#define setgroupent(n) setgrent()
+const char *group_from_gid(gid_t, int);
+int gid_from_group(const char *, gid_t *);
diff --git a/includedir/machine/endian.h b/includedir/machine/endian.h
new file mode 100644
index 0000000..2dc4d83
--- /dev/null
+++ b/includedir/machine/endian.h
@@ -0,0 +1 @@
+#include <endian.h>
diff --git a/includedir/netinet/ip.h b/includedir/netinet/ip.h
new file mode 100644
index 0000000..238358c
--- /dev/null
+++ b/includedir/netinet/ip.h
@@ -0,0 +1,9 @@
+#include_next <netinet/ip.h>
+#define IPTOS_DSCP_CS0 0x00
+#define IPTOS_DSCP_CS1 0x20
+#define IPTOS_DSCP_CS2 0x40
+#define IPTOS_DSCP_CS3 0x60
+#define IPTOS_DSCP_CS4 0x80
+#define IPTOS_DSCP_CS5 0xa0
+#define IPTOS_DSCP_CS6 0xc0
+#define IPTOS_DSCP_CS7 0xe0
diff --git a/includedir/pwd.h b/includedir/pwd.h
new file mode 100644
index 0000000..c1aabba
--- /dev/null
+++ b/includedir/pwd.h
@@ -0,0 +1,4 @@
+#include_next <pwd.h>
+#define setpassent(n) setpwent()
+const char *user_from_uid(uid_t, int);
+int uid_from_user(const char *, uid_t *);
diff --git a/includedir/readpassphrase.h b/includedir/readpassphrase.h
new file mode 100644
index 0000000..cef36f0
--- /dev/null
+++ b/includedir/readpassphrase.h
@@ -0,0 +1,40 @@
+/* $OpenBSD: readpassphrase.h,v 1.5 2003/06/17 21:56:23 millert Exp $ */
+
+/*
+ * Copyright (c) 2000, 2002 Todd C. Miller <Todd.Miller@courtesan.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Sponsored in part by the Defense Advanced Research Projects
+ * Agency (DARPA) and Air Force Research Laboratory, Air Force
+ * Materiel Command, USAF, under agreement number F39502-99-1-0512.
+ */
+
+#ifndef _READPASSPHRASE_H_
+#define _READPASSPHRASE_H_
+
+#define RPP_ECHO_OFF 0x00 /* Turn off echo (default). */
+#define RPP_ECHO_ON 0x01 /* Leave echo on. */
+#define RPP_REQUIRE_TTY 0x02 /* Fail if there is no tty. */
+#define RPP_FORCELOWER 0x04 /* Force input to lower case. */
+#define RPP_FORCEUPPER 0x08 /* Force input to upper case. */
+#define RPP_SEVENBIT 0x10 /* Strip the high bit from input. */
+#define RPP_STDIN 0x20 /* Read from stdin, not /dev/tty */
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+char * readpassphrase(const char *, char *, size_t, int);
+__END_DECLS
+
+#endif /* !_READPASSPHRASE_H_ */
diff --git a/includedir/resolv.h b/includedir/resolv.h
new file mode 100644
index 0000000..23f19f9
--- /dev/null
+++ b/includedir/resolv.h
@@ -0,0 +1,3 @@
+#include_next <resolv.h>
+int b64_ntop(unsigned char const *, size_t, char *, size_t);
+int b64_pton(char const *, unsigned char *, size_t);
diff --git a/includedir/stdlib.h b/includedir/stdlib.h
new file mode 100644
index 0000000..652bba4
--- /dev/null
+++ b/includedir/stdlib.h
@@ -0,0 +1,12 @@
+#include_next <stdlib.h>
+#include <stdint.h>
+void freezero(void *, size_t);
+void *reallocarray(void *, size_t, size_t);
+void *recallocarray(void *, size_t, size_t, size_t);
+long long strtonum(const char *, long long, long long, const char **);
+uint32_t arc4random(void);
+uint32_t arc4random_uniform(uint32_t);
+void arc4random_buf(void *, size_t);
+void setprogname(const char *);
+const char *getprogname(void);
+extern char *__progname;
diff --git a/includedir/string.h b/includedir/string.h
new file mode 100644
index 0000000..9cf9ac9
--- /dev/null
+++ b/includedir/string.h
@@ -0,0 +1,5 @@
+#include_next <string.h>
+char *strcasestr(const char *, const char *);
+void strmode(int, char *);
+int timingsafe_memcmp(const void *, const void *, size_t);
+int timingsafe_bcmp(const void *, const void *, size_t);
diff --git a/includedir/sys/cdefs.h b/includedir/sys/cdefs.h
new file mode 100644
index 0000000..70258b8
--- /dev/null
+++ b/includedir/sys/cdefs.h
@@ -0,0 +1,5 @@
+/* only needed for C++ */
+#define __BEGIN_DECLS
+#define __END_DECLS
+
+#define __dead __attribute__((__noreturn__))
diff --git a/includedir/sys/compat.h b/includedir/sys/compat.h
new file mode 100644
index 0000000..af03c4f
--- /dev/null
+++ b/includedir/sys/compat.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2015, Adrián Pérez de Castro <aperez@igalia.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef COMPAT_H
+#define COMPAT_H
+
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE 1
+#endif /* !_GNU_SOURCE */
+
+#ifndef COMPAT_BOUNDS_CHECKING
+#define __bounded__(a, b, c)
+#endif /* !COMPAT_BOUNDS_CHECKING */
+
+#ifndef __dead
+#if defined(__GNUC__) && (__GNUC__ > 3)
+#define __dead __attribute__((noreturn))
+#else
+#define __dead
+#endif
+#endif /* !__dead */
+
+#define DEF_WEAK(x)
+#define MAKE_CLONE(dst, src) typeof(dst) dst \
+ __attribute__((alias (#src)))
+
+#define u_int8_t uint8_t
+#define u_int16_t uint16_t
+#define u_int32_t uint32_t
+#define u_int64_t uint64_t
+
+#include <stdint.h>
+#include <stddef.h>
+
+extern int timingsafe_bcmp(const void *b1, const void *b2, size_t n);
+extern int pledge (const char *promises, const char *execpromises);
+extern int bcrypt_pbkdf(const char *pass, size_t passlen,
+ const uint8_t *salt, size_t saltlen,
+ uint8_t *key, size_t keylen,
+ unsigned int rounds);
+
+#ifdef BUNDLED_BZERO
+extern void explicit_bzero(void *buf, size_t len);
+#endif /* BUNDLED_BZERO */
+
+#endif /* !COMPAT_H */
diff --git a/includedir/sys/param.h b/includedir/sys/param.h
new file mode 100644
index 0000000..3167713
--- /dev/null
+++ b/includedir/sys/param.h
@@ -0,0 +1,3 @@
+#include_next <sys/param.h>
+#define ALIGNBYTES (sizeof(uintptr_t) - 1)
+#define ALIGN(p) (((uintptr_t)(p) + ALIGNBYTES) &~ ALIGNBYTES)
diff --git a/includedir/sys/time.h b/includedir/sys/time.h
new file mode 100644
index 0000000..f4f151f
--- /dev/null
+++ b/includedir/sys/time.h
@@ -0,0 +1,14 @@
+#include_next <sys/time.h>
+#define timespeccmp(tsp, usp, cmp) \
+ (((tsp)->tv_sec == (usp)->tv_sec) ? \
+ ((tsp)->tv_nsec cmp (usp)->tv_nsec) : \
+ ((tsp)->tv_sec cmp (usp)->tv_sec))
+#define timespecsub(tsp, usp, vsp) \
+ do { \
+ (vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec; \
+ (vsp)->tv_nsec = (tsp)->tv_nsec - (usp)->tv_nsec; \
+ if ((vsp)->tv_nsec < 0) { \
+ (vsp)->tv_sec--; \
+ (vsp)->tv_nsec += 1000000000L; \
+ } \
+ } while (0)
diff --git a/includedir/unistd.h b/includedir/unistd.h
new file mode 100644
index 0000000..a715077
--- /dev/null
+++ b/includedir/unistd.h
@@ -0,0 +1,3 @@
+#include_next <unistd.h>
+#define pledge(request, paths) 0 /* linux doesn't have pledge */
+#define unveil(path, permissions) 0 /* linux doesn't have unveil */
diff --git a/lib/libc/crypt/arc4random.c b/lib/libc/crypt/arc4random.c
new file mode 100644
index 0000000..1a16bd3
--- /dev/null
+++ b/lib/libc/crypt/arc4random.c
@@ -0,0 +1,198 @@
+/* $OpenBSD: arc4random.c,v 1.55 2019/03/24 17:56:54 deraadt Exp $ */
+
+/*
+ * Copyright (c) 1996, David Mazieres <dm@uun.org>
+ * Copyright (c) 2008, Damien Miller <djm@openbsd.org>
+ * Copyright (c) 2013, Markus Friedl <markus@openbsd.org>
+ * Copyright (c) 2014, Theo de Raadt <deraadt@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/*
+ * ChaCha based random number generator for OpenBSD.
+ */
+
+#include <fcntl.h>
+#include <limits.h>
+#include <signal.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/time.h>
+
+#define KEYSTREAM_ONLY
+#include "chacha_private.h"
+
+#define minimum(a, b) ((a) < (b) ? (a) : (b))
+
+#if defined(__GNUC__) || defined(_MSC_VER)
+#define inline __inline
+#else /* __GNUC__ || _MSC_VER */
+#define inline
+#endif /* !__GNUC__ && !_MSC_VER */
+
+#define KEYSZ 32
+#define IVSZ 8
+#define BLOCKSZ 64
+#define RSBUFSZ (16*BLOCKSZ)
+
+/* Marked MAP_INHERIT_ZERO, so zero'd out in fork children. */
+static struct _rs {
+ size_t rs_have; /* valid bytes at end of rs_buf */
+ size_t rs_count; /* bytes till reseed */
+} *rs;
+
+/* Maybe be preserved in fork children, if _rs_allocate() decides. */
+static struct _rsx {
+ chacha_ctx rs_chacha; /* chacha context for random keystream */
+ u_char rs_buf[RSBUFSZ]; /* keystream blocks */
+} *rsx;
+
+static inline int _rs_allocate(struct _rs **, struct _rsx **);
+static inline void _rs_forkdetect(void);
+#include "arc4random.h"
+
+static inline void _rs_rekey(u_char *dat, size_t datlen);
+
+static inline void
+_rs_init(u_char *buf, size_t n)
+{
+ if (n < KEYSZ + IVSZ)
+ return;
+
+ if (rs == NULL) {
+ if (_rs_allocate(&rs, &rsx) == -1)
+ _exit(1);
+ }
+
+ chacha_keysetup(&rsx->rs_chacha, buf, KEYSZ * 8, 0);
+ chacha_ivsetup(&rsx->rs_chacha, buf + KEYSZ);
+}
+
+static void
+_rs_stir(void)
+{
+ u_char rnd[KEYSZ + IVSZ];
+
+ if (getentropy(rnd, sizeof rnd) == -1)
+ _getentropy_fail();
+
+ if (!rs)
+ _rs_init(rnd, sizeof(rnd));
+ else
+ _rs_rekey(rnd, sizeof(rnd));
+ explicit_bzero(rnd, sizeof(rnd)); /* discard source seed */
+
+ /* invalidate rs_buf */
+ rs->rs_have = 0;
+ memset(rsx->rs_buf, 0, sizeof(rsx->rs_buf));
+
+ rs->rs_count = 1600000;
+}
+
+static inline void
+_rs_stir_if_needed(size_t len)
+{
+ _rs_forkdetect();
+ if (!rs || rs->rs_count <= len)
+ _rs_stir();
+ if (rs->rs_count <= len)
+ rs->rs_count = 0;
+ else
+ rs->rs_count -= len;
+}
+
+static inline void
+_rs_rekey(u_char *dat, size_t datlen)
+{
+#ifndef KEYSTREAM_ONLY
+ memset(rsx->rs_buf, 0, sizeof(rsx->rs_buf));
+#endif
+ /* fill rs_buf with the keystream */
+ chacha_encrypt_bytes(&rsx->rs_chacha, rsx->rs_buf,
+ rsx->rs_buf, sizeof(rsx->rs_buf));
+ /* mix in optional user provided data */
+ if (dat) {
+ size_t i, m;
+
+ m = minimum(datlen, KEYSZ + IVSZ);
+ for (i = 0; i < m; i++)
+ rsx->rs_buf[i] ^= dat[i];
+ }
+ /* immediately reinit for backtracking resistance */
+ _rs_init(rsx->rs_buf, KEYSZ + IVSZ);
+ memset(rsx->rs_buf, 0, KEYSZ + IVSZ);
+ rs->rs_have = sizeof(rsx->rs_buf) - KEYSZ - IVSZ;
+}
+
+static inline void
+_rs_random_buf(void *_buf, size_t n)
+{
+ u_char *buf = (u_char *)_buf;
+ u_char *keystream;
+ size_t m;
+
+ _rs_stir_if_needed(n);
+ while (n > 0) {
+ if (rs->rs_have > 0) {
+ m = minimum(n, rs->rs_have);
+ keystream = rsx->rs_buf + sizeof(rsx->rs_buf)
+ - rs->rs_have;
+ memcpy(buf, keystream, m);
+ memset(keystream, 0, m);
+ buf += m;
+ n -= m;
+ rs->rs_have -= m;
+ }
+ if (rs->rs_have == 0)
+ _rs_rekey(NULL, 0);
+ }
+}
+
+static inline void
+_rs_random_u32(uint32_t *val)
+{
+ u_char *keystream;
+
+ _rs_stir_if_needed(sizeof(*val));
+ if (rs->rs_have < sizeof(*val))
+ _rs_rekey(NULL, 0);
+ keystream = rsx->rs_buf + sizeof(rsx->rs_buf) - rs->rs_have;
+ memcpy(val, keystream, sizeof(*val));
+ memset(keystream, 0, sizeof(*val));
+ rs->rs_have -= sizeof(*val);
+}
+
+uint32_t
+arc4random(void)
+{
+ uint32_t val;
+
+ _ARC4_LOCK();
+ _rs_random_u32(&val);
+ _ARC4_UNLOCK();
+ return val;
+}
+DEF_WEAK(arc4random);
+
+void
+arc4random_buf(void *buf, size_t n)
+{
+ _ARC4_LOCK();
+ _rs_random_buf(buf, n);
+ _ARC4_UNLOCK();
+}
+DEF_WEAK(arc4random_buf);
diff --git a/lib/libc/crypt/arc4random_uniform.c b/lib/libc/crypt/arc4random_uniform.c
new file mode 100644
index 0000000..a18b5b1
--- /dev/null
+++ b/lib/libc/crypt/arc4random_uniform.c
@@ -0,0 +1,57 @@
+/* $OpenBSD: arc4random_uniform.c,v 1.3 2019/01/20 02:59:07 bcook Exp $ */
+
+/*
+ * Copyright (c) 2008, Damien Miller <djm@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <stdint.h>
+#include <stdlib.h>
+
+/*
+ * Calculate a uniformly distributed random number less than upper_bound
+ * avoiding "modulo bias".
+ *
+ * Uniformity is achieved by generating new random numbers until the one
+ * returned is outside the range [0, 2**32 % upper_bound). This
+ * guarantees the selected random number will be inside
+ * [2**32 % upper_bound, 2**32) which maps back to [0, upper_bound)
+ * after reduction modulo upper_bound.
+ */
+uint32_t
+arc4random_uniform(uint32_t upper_bound)
+{
+ uint32_t r, min;
+
+ if (upper_bound < 2)
+ return 0;
+
+ /* 2**32 % x == (2**32 - x) % x */
+ min = -upper_bound % upper_bound;
+
+ /*
+ * This could theoretically loop forever but each retry has
+ * p > 0.5 (worst case, usually far better) of selecting a
+ * number inside the range we need, so it should rarely need
+ * to re-roll.
+ */
+ for (;;) {
+ r = arc4random();
+ if (r >= min)
+ break;
+ }
+
+ return r % upper_bound;
+}
+DEF_WEAK(arc4random_uniform);
diff --git a/lib/libc/crypt/blowfish.c b/lib/libc/crypt/blowfish.c
new file mode 100644
index 0000000..a658e60
--- /dev/null
+++ b/lib/libc/crypt/blowfish.c
@@ -0,0 +1,698 @@
+/* $OpenBSD: blowfish.c,v 1.19 2015/09/11 09:18:27 guenther Exp $ */
+/*
+ * Blowfish block cipher for OpenBSD
+ * Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de>
+ * All rights reserved.
+ *
+ * Implementation advice by David Mazieres <dm@lcs.mit.edu>.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Niels Provos.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * This code is derived from section 14.3 and the given source
+ * in section V of Applied Cryptography, second edition.
+ * Blowfish is an unpatented fast block cipher designed by
+ * Bruce Schneier.
+ */
+
+#if 0
+#include <stdio.h> /* used for debugging */
+#include <string.h>
+#endif
+
+#include <sys/types.h>
+#include <blf.h>
+
+#undef inline
+#ifdef __GNUC__
+#define inline __inline
+#else /* !__GNUC__ */
+#define inline
+#endif /* !__GNUC__ */
+
+/* Function for Feistel Networks */
+
+#define F(s, x) ((((s)[ (((x)>>24)&0xFF)] \
+ + (s)[0x100 + (((x)>>16)&0xFF)]) \
+ ^ (s)[0x200 + (((x)>> 8)&0xFF)]) \
+ + (s)[0x300 + ( (x) &0xFF)])
+
+#define BLFRND(s,p,i,j,n) (i ^= F(s,j) ^ (p)[n])
+
+void
+Blowfish_encipher(blf_ctx *c, u_int32_t *xl, u_int32_t *xr)
+{
+ u_int32_t Xl;
+ u_int32_t Xr;
+ u_int32_t *s = c->S[0];
+ u_int32_t *p = c->P;
+
+ Xl = *xl;
+ Xr = *xr;
+
+ Xl ^= p[0];
+ BLFRND(s, p, Xr, Xl, 1); BLFRND(s, p, Xl, Xr, 2);
+ BLFRND(s, p, Xr, Xl, 3); BLFRND(s, p, Xl, Xr, 4);
+ BLFRND(s, p, Xr, Xl, 5); BLFRND(s, p, Xl, Xr, 6);
+ BLFRND(s, p, Xr, Xl, 7); BLFRND(s, p, Xl, Xr, 8);
+ BLFRND(s, p, Xr, Xl, 9); BLFRND(s, p, Xl, Xr, 10);
+ BLFRND(s, p, Xr, Xl, 11); BLFRND(s, p, Xl, Xr, 12);
+ BLFRND(s, p, Xr, Xl, 13); BLFRND(s, p, Xl, Xr, 14);
+ BLFRND(s, p, Xr, Xl, 15); BLFRND(s, p, Xl, Xr, 16);
+
+ *xl = Xr ^ p[17];
+ *xr = Xl;
+}
+DEF_WEAK(Blowfish_encipher);
+
+void
+Blowfish_decipher(blf_ctx *c, u_int32_t *xl, u_int32_t *xr)
+{
+ u_int32_t Xl;
+ u_int32_t Xr;
+ u_int32_t *s = c->S[0];
+ u_int32_t *p = c->P;
+
+ Xl = *xl;
+ Xr = *xr;
+
+ Xl ^= p[17];
+ BLFRND(s, p, Xr, Xl, 16); BLFRND(s, p, Xl, Xr, 15);
+ BLFRND(s, p, Xr, Xl, 14); BLFRND(s, p, Xl, Xr, 13);
+ BLFRND(s, p, Xr, Xl, 12); BLFRND(s, p, Xl, Xr, 11);
+ BLFRND(s, p, Xr, Xl, 10); BLFRND(s, p, Xl, Xr, 9);
+ BLFRND(s, p, Xr, Xl, 8); BLFRND(s, p, Xl, Xr, 7);
+ BLFRND(s, p, Xr, Xl, 6); BLFRND(s, p, Xl, Xr, 5);
+ BLFRND(s, p, Xr, Xl, 4); BLFRND(s, p, Xl, Xr, 3);
+ BLFRND(s, p, Xr, Xl, 2); BLFRND(s, p, Xl, Xr, 1);
+
+ *xl = Xr ^ p[0];
+ *xr = Xl;
+}
+DEF_WEAK(Blowfish_decipher);
+
+void
+Blowfish_initstate(blf_ctx *c)
+{
+ /* P-box and S-box tables initialized with digits of Pi */
+
+ static const blf_ctx initstate =
+ { {
+ {
+ 0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7,
+ 0xb8e1afed, 0x6a267e96, 0xba7c9045, 0xf12c7f99,
+ 0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16,
+ 0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e,
+ 0x0d95748f, 0x728eb658, 0x718bcd58, 0x82154aee,
+ 0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013,
+ 0xc5d1b023, 0x286085f0, 0xca417918, 0xb8db38ef,
+ 0x8e79dcb0, 0x603a180e, 0x6c9e0e8b, 0xb01e8a3e,
+ 0xd71577c1, 0xbd314b27, 0x78af2fda, 0x55605c60,
+ 0xe65525f3, 0xaa55ab94, 0x57489862, 0x63e81440,
+ 0x55ca396a, 0x2aab10b6, 0xb4cc5c34, 0x1141e8ce,
+ 0xa15486af, 0x7c72e993, 0xb3ee1411, 0x636fbc2a,
+ 0x2ba9c55d, 0x741831f6, 0xce5c3e16, 0x9b87931e,
+ 0xafd6ba33, 0x6c24cf5c, 0x7a325381, 0x28958677,
+ 0x3b8f4898, 0x6b4bb9af, 0xc4bfe81b, 0x66282193,
+ 0x61d809cc, 0xfb21a991, 0x487cac60, 0x5dec8032,
+ 0xef845d5d, 0xe98575b1, 0xdc262302, 0xeb651b88,
+ 0x23893e81, 0xd396acc5, 0x0f6d6ff3, 0x83f44239,
+ 0x2e0b4482, 0xa4842004, 0x69c8f04a, 0x9e1f9b5e,
+ 0x21c66842, 0xf6e96c9a, 0x670c9c61, 0xabd388f0,
+ 0x6a51a0d2, 0xd8542f68, 0x960fa728, 0xab5133a3,
+ 0x6eef0b6c, 0x137a3be4, 0xba3bf050, 0x7efb2a98,
+ 0xa1f1651d, 0x39af0176, 0x66ca593e, 0x82430e88,
+ 0x8cee8619, 0x456f9fb4, 0x7d84a5c3, 0x3b8b5ebe,
+ 0xe06f75d8, 0x85c12073, 0x401a449f, 0x56c16aa6,
+ 0x4ed3aa62, 0x363f7706, 0x1bfedf72, 0x429b023d,
+ 0x37d0d724, 0xd00a1248, 0xdb0fead3, 0x49f1c09b,
+ 0x075372c9, 0x80991b7b, 0x25d479d8, 0xf6e8def7,
+ 0xe3fe501a, 0xb6794c3b, 0x976ce0bd, 0x04c006ba,
+ 0xc1a94fb6, 0x409f60c4, 0x5e5c9ec2, 0x196a2463,
+ 0x68fb6faf, 0x3e6c53b5, 0x1339b2eb, 0x3b52ec6f,
+ 0x6dfc511f, 0x9b30952c, 0xcc814544, 0xaf5ebd09,
+ 0xbee3d004, 0xde334afd, 0x660f2807, 0x192e4bb3,
+ 0xc0cba857, 0x45c8740f, 0xd20b5f39, 0xb9d3fbdb,
+ 0x5579c0bd, 0x1a60320a, 0xd6a100c6, 0x402c7279,
+ 0x679f25fe, 0xfb1fa3cc, 0x8ea5e9f8, 0xdb3222f8,
+ 0x3c7516df, 0xfd616b15, 0x2f501ec8, 0xad0552ab,
+ 0x323db5fa, 0xfd238760, 0x53317b48, 0x3e00df82,
+ 0x9e5c57bb, 0xca6f8ca0, 0x1a87562e, 0xdf1769db,
+ 0xd542a8f6, 0x287effc3, 0xac6732c6, 0x8c4f5573,
+ 0x695b27b0, 0xbbca58c8, 0xe1ffa35d, 0xb8f011a0,
+ 0x10fa3d98, 0xfd2183b8, 0x4afcb56c, 0x2dd1d35b,
+ 0x9a53e479, 0xb6f84565, 0xd28e49bc, 0x4bfb9790,
+ 0xe1ddf2da, 0xa4cb7e33, 0x62fb1341, 0xcee4c6e8,
+ 0xef20cada, 0x36774c01, 0xd07e9efe, 0x2bf11fb4,
+ 0x95dbda4d, 0xae909198, 0xeaad8e71, 0x6b93d5a0,
+ 0xd08ed1d0, 0xafc725e0, 0x8e3c5b2f, 0x8e7594b7,
+ 0x8ff6e2fb, 0xf2122b64, 0x8888b812, 0x900df01c,
+ 0x4fad5ea0, 0x688fc31c, 0xd1cff191, 0xb3a8c1ad,
+ 0x2f2f2218, 0xbe0e1777, 0xea752dfe, 0x8b021fa1,
+ 0xe5a0cc0f, 0xb56f74e8, 0x18acf3d6, 0xce89e299,
+ 0xb4a84fe0, 0xfd13e0b7, 0x7cc43b81, 0xd2ada8d9,
+ 0x165fa266, 0x80957705, 0x93cc7314, 0x211a1477,
+ 0xe6ad2065, 0x77b5fa86, 0xc75442f5, 0xfb9d35cf,
+ 0xebcdaf0c, 0x7b3e89a0, 0xd6411bd3, 0xae1e7e49,
+ 0x00250e2d, 0x2071b35e, 0x226800bb, 0x57b8e0af,
+ 0x2464369b, 0xf009b91e, 0x5563911d, 0x59dfa6aa,
+ 0x78c14389, 0xd95a537f, 0x207d5ba2, 0x02e5b9c5,
+ 0x83260376, 0x6295cfa9, 0x11c81968, 0x4e734a41,
+ 0xb3472dca, 0x7b14a94a, 0x1b510052, 0x9a532915,
+ 0xd60f573f, 0xbc9bc6e4, 0x2b60a476, 0x81e67400,
+ 0x08ba6fb5, 0x571be91f, 0xf296ec6b, 0x2a0dd915,
+ 0xb6636521, 0xe7b9f9b6, 0xff34052e, 0xc5855664,
+ 0x53b02d5d, 0xa99f8fa1, 0x08ba4799, 0x6e85076a},
+ {
+ 0x4b7a70e9, 0xb5b32944, 0xdb75092e, 0xc4192623,
+ 0xad6ea6b0, 0x49a7df7d, 0x9cee60b8, 0x8fedb266,
+ 0xecaa8c71, 0x699a17ff, 0x5664526c, 0xc2b19ee1,
+ 0x193602a5, 0x75094c29, 0xa0591340, 0xe4183a3e,
+ 0x3f54989a, 0x5b429d65, 0x6b8fe4d6, 0x99f73fd6,
+ 0xa1d29c07, 0xefe830f5, 0x4d2d38e6, 0xf0255dc1,
+ 0x4cdd2086, 0x8470eb26, 0x6382e9c6, 0x021ecc5e,
+ 0x09686b3f, 0x3ebaefc9, 0x3c971814, 0x6b6a70a1,
+ 0x687f3584, 0x52a0e286, 0xb79c5305, 0xaa500737,
+ 0x3e07841c, 0x7fdeae5c, 0x8e7d44ec, 0x5716f2b8,
+ 0xb03ada37, 0xf0500c0d, 0xf01c1f04, 0x0200b3ff,
+ 0xae0cf51a, 0x3cb574b2, 0x25837a58, 0xdc0921bd,
+ 0xd19113f9, 0x7ca92ff6, 0x94324773, 0x22f54701,
+ 0x3ae5e581, 0x37c2dadc, 0xc8b57634, 0x9af3dda7,
+ 0xa9446146, 0x0fd0030e, 0xecc8c73e, 0xa4751e41,
+ 0xe238cd99, 0x3bea0e2f, 0x3280bba1, 0x183eb331,
+ 0x4e548b38, 0x4f6db908, 0x6f420d03, 0xf60a04bf,
+ 0x2cb81290, 0x24977c79, 0x5679b072, 0xbcaf89af,
+ 0xde9a771f, 0xd9930810, 0xb38bae12, 0xdccf3f2e,
+ 0x5512721f, 0x2e6b7124, 0x501adde6, 0x9f84cd87,
+ 0x7a584718, 0x7408da17, 0xbc9f9abc, 0xe94b7d8c,
+ 0xec7aec3a, 0xdb851dfa, 0x63094366, 0xc464c3d2,
+ 0xef1c1847, 0x3215d908, 0xdd433b37, 0x24c2ba16,
+ 0x12a14d43, 0x2a65c451, 0x50940002, 0x133ae4dd,
+ 0x71dff89e, 0x10314e55, 0x81ac77d6, 0x5f11199b,
+ 0x043556f1, 0xd7a3c76b, 0x3c11183b, 0x5924a509,
+ 0xf28fe6ed, 0x97f1fbfa, 0x9ebabf2c, 0x1e153c6e,
+ 0x86e34570, 0xeae96fb1, 0x860e5e0a, 0x5a3e2ab3,
+ 0x771fe71c, 0x4e3d06fa, 0x2965dcb9, 0x99e71d0f,
+ 0x803e89d6, 0x5266c825, 0x2e4cc978, 0x9c10b36a,
+ 0xc6150eba, 0x94e2ea78, 0xa5fc3c53, 0x1e0a2df4,
+ 0xf2f74ea7, 0x361d2b3d, 0x1939260f, 0x19c27960,
+ 0x5223a708, 0xf71312b6, 0xebadfe6e, 0xeac31f66,
+ 0xe3bc4595, 0xa67bc883, 0xb17f37d1, 0x018cff28,
+ 0xc332ddef, 0xbe6c5aa5, 0x65582185, 0x68ab9802,
+ 0xeecea50f, 0xdb2f953b, 0x2aef7dad, 0x5b6e2f84,
+ 0x1521b628, 0x29076170, 0xecdd4775, 0x619f1510,
+ 0x13cca830, 0xeb61bd96, 0x0334fe1e, 0xaa0363cf,
+ 0xb5735c90, 0x4c70a239, 0xd59e9e0b, 0xcbaade14,
+ 0xeecc86bc, 0x60622ca7, 0x9cab5cab, 0xb2f3846e,
+ 0x648b1eaf, 0x19bdf0ca, 0xa02369b9, 0x655abb50,
+ 0x40685a32, 0x3c2ab4b3, 0x319ee9d5, 0xc021b8f7,
+ 0x9b540b19, 0x875fa099, 0x95f7997e, 0x623d7da8,
+ 0xf837889a, 0x97e32d77, 0x11ed935f, 0x16681281,
+ 0x0e358829, 0xc7e61fd6, 0x96dedfa1, 0x7858ba99,
+ 0x57f584a5, 0x1b227263, 0x9b83c3ff, 0x1ac24696,
+ 0xcdb30aeb, 0x532e3054, 0x8fd948e4, 0x6dbc3128,
+ 0x58ebf2ef, 0x34c6ffea, 0xfe28ed61, 0xee7c3c73,
+ 0x5d4a14d9, 0xe864b7e3, 0x42105d14, 0x203e13e0,
+ 0x45eee2b6, 0xa3aaabea, 0xdb6c4f15, 0xfacb4fd0,
+ 0xc742f442, 0xef6abbb5, 0x654f3b1d, 0x41cd2105,
+ 0xd81e799e, 0x86854dc7, 0xe44b476a, 0x3d816250,
+ 0xcf62a1f2, 0x5b8d2646, 0xfc8883a0, 0xc1c7b6a3,
+ 0x7f1524c3, 0x69cb7492, 0x47848a0b, 0x5692b285,
+ 0x095bbf00, 0xad19489d, 0x1462b174, 0x23820e00,
+ 0x58428d2a, 0x0c55f5ea, 0x1dadf43e, 0x233f7061,
+ 0x3372f092, 0x8d937e41, 0xd65fecf1, 0x6c223bdb,
+ 0x7cde3759, 0xcbee7460, 0x4085f2a7, 0xce77326e,
+ 0xa6078084, 0x19f8509e, 0xe8efd855, 0x61d99735,
+ 0xa969a7aa, 0xc50c06c2, 0x5a04abfc, 0x800bcadc,
+ 0x9e447a2e, 0xc3453484, 0xfdd56705, 0x0e1e9ec9,
+ 0xdb73dbd3, 0x105588cd, 0x675fda79, 0xe3674340,
+ 0xc5c43465, 0x713e38d8, 0x3d28f89e, 0xf16dff20,
+ 0x153e21e7, 0x8fb03d4a, 0xe6e39f2b, 0xdb83adf7},
+ {
+ 0xe93d5a68, 0x948140f7, 0xf64c261c, 0x94692934,
+ 0x411520f7, 0x7602d4f7, 0xbcf46b2e, 0xd4a20068,
+ 0xd4082471, 0x3320f46a, 0x43b7d4b7, 0x500061af,
+ 0x1e39f62e, 0x97244546, 0x14214f74, 0xbf8b8840,
+ 0x4d95fc1d, 0x96b591af, 0x70f4ddd3, 0x66a02f45,
+ 0xbfbc09ec, 0x03bd9785, 0x7fac6dd0, 0x31cb8504,
+ 0x96eb27b3, 0x55fd3941, 0xda2547e6, 0xabca0a9a,
+ 0x28507825, 0x530429f4, 0x0a2c86da, 0xe9b66dfb,
+ 0x68dc1462, 0xd7486900, 0x680ec0a4, 0x27a18dee,
+ 0x4f3ffea2, 0xe887ad8c, 0xb58ce006, 0x7af4d6b6,
+ 0xaace1e7c, 0xd3375fec, 0xce78a399, 0x406b2a42,
+ 0x20fe9e35, 0xd9f385b9, 0xee39d7ab, 0x3b124e8b,
+ 0x1dc9faf7, 0x4b6d1856, 0x26a36631, 0xeae397b2,
+ 0x3a6efa74, 0xdd5b4332, 0x6841e7f7, 0xca7820fb,
+ 0xfb0af54e, 0xd8feb397, 0x454056ac, 0xba489527,
+ 0x55533a3a, 0x20838d87, 0xfe6ba9b7, 0xd096954b,
+ 0x55a867bc, 0xa1159a58, 0xcca92963, 0x99e1db33,
+ 0xa62a4a56, 0x3f3125f9, 0x5ef47e1c, 0x9029317c,
+ 0xfdf8e802, 0x04272f70, 0x80bb155c, 0x05282ce3,
+ 0x95c11548, 0xe4c66d22, 0x48c1133f, 0xc70f86dc,
+ 0x07f9c9ee, 0x41041f0f, 0x404779a4, 0x5d886e17,
+ 0x325f51eb, 0xd59bc0d1, 0xf2bcc18f, 0x41113564,
+ 0x257b7834, 0x602a9c60, 0xdff8e8a3, 0x1f636c1b,
+ 0x0e12b4c2, 0x02e1329e, 0xaf664fd1, 0xcad18115,
+ 0x6b2395e0, 0x333e92e1, 0x3b240b62, 0xeebeb922,
+ 0x85b2a20e, 0xe6ba0d99, 0xde720c8c, 0x2da2f728,
+ 0xd0127845, 0x95b794fd, 0x647d0862, 0xe7ccf5f0,
+ 0x5449a36f, 0x877d48fa, 0xc39dfd27, 0xf33e8d1e,
+ 0x0a476341, 0x992eff74, 0x3a6f6eab, 0xf4f8fd37,
+ 0xa812dc60, 0xa1ebddf8, 0x991be14c, 0xdb6e6b0d,
+ 0xc67b5510, 0x6d672c37, 0x2765d43b, 0xdcd0e804,
+ 0xf1290dc7, 0xcc00ffa3, 0xb5390f92, 0x690fed0b,
+ 0x667b9ffb, 0xcedb7d9c, 0xa091cf0b, 0xd9155ea3,
+ 0xbb132f88, 0x515bad24, 0x7b9479bf, 0x763bd6eb,
+ 0x37392eb3, 0xcc115979, 0x8026e297, 0xf42e312d,
+ 0x6842ada7, 0xc66a2b3b, 0x12754ccc, 0x782ef11c,
+ 0x6a124237, 0xb79251e7, 0x06a1bbe6, 0x4bfb6350,
+ 0x1a6b1018, 0x11caedfa, 0x3d25bdd8, 0xe2e1c3c9,
+ 0x44421659, 0x0a121386, 0xd90cec6e, 0xd5abea2a,
+ 0x64af674e, 0xda86a85f, 0xbebfe988, 0x64e4c3fe,
+ 0x9dbc8057, 0xf0f7c086, 0x60787bf8, 0x6003604d,
+ 0xd1fd8346, 0xf6381fb0, 0x7745ae04, 0xd736fccc,
+ 0x83426b33, 0xf01eab71, 0xb0804187, 0x3c005e5f,
+ 0x77a057be, 0xbde8ae24, 0x55464299, 0xbf582e61,
+ 0x4e58f48f, 0xf2ddfda2, 0xf474ef38, 0x8789bdc2,
+ 0x5366f9c3, 0xc8b38e74, 0xb475f255, 0x46fcd9b9,
+ 0x7aeb2661, 0x8b1ddf84, 0x846a0e79, 0x915f95e2,
+ 0x466e598e, 0x20b45770, 0x8cd55591, 0xc902de4c,
+ 0xb90bace1, 0xbb8205d0, 0x11a86248, 0x7574a99e,
+ 0xb77f19b6, 0xe0a9dc09, 0x662d09a1, 0xc4324633,
+ 0xe85a1f02, 0x09f0be8c, 0x4a99a025, 0x1d6efe10,
+ 0x1ab93d1d, 0x0ba5a4df, 0xa186f20f, 0x2868f169,
+ 0xdcb7da83, 0x573906fe, 0xa1e2ce9b, 0x4fcd7f52,
+ 0x50115e01, 0xa70683fa, 0xa002b5c4, 0x0de6d027,
+ 0x9af88c27, 0x773f8641, 0xc3604c06, 0x61a806b5,
+ 0xf0177a28, 0xc0f586e0, 0x006058aa, 0x30dc7d62,
+ 0x11e69ed7, 0x2338ea63, 0x53c2dd94, 0xc2c21634,
+ 0xbbcbee56, 0x90bcb6de, 0xebfc7da1, 0xce591d76,
+ 0x6f05e409, 0x4b7c0188, 0x39720a3d, 0x7c927c24,
+ 0x86e3725f, 0x724d9db9, 0x1ac15bb4, 0xd39eb8fc,
+ 0xed545578, 0x08fca5b5, 0xd83d7cd3, 0x4dad0fc4,
+ 0x1e50ef5e, 0xb161e6f8, 0xa28514d9, 0x6c51133c,
+ 0x6fd5c7e7, 0x56e14ec4, 0x362abfce, 0xddc6c837,
+ 0xd79a3234, 0x92638212, 0x670efa8e, 0x406000e0},
+ {
+ 0x3a39ce37, 0xd3faf5cf, 0xabc27737, 0x5ac52d1b,
+ 0x5cb0679e, 0x4fa33742, 0xd3822740, 0x99bc9bbe,
+ 0xd5118e9d, 0xbf0f7315, 0xd62d1c7e, 0xc700c47b,
+ 0xb78c1b6b, 0x21a19045, 0xb26eb1be, 0x6a366eb4,
+ 0x5748ab2f, 0xbc946e79, 0xc6a376d2, 0x6549c2c8,
+ 0x530ff8ee, 0x468dde7d, 0xd5730a1d, 0x4cd04dc6,
+ 0x2939bbdb, 0xa9ba4650, 0xac9526e8, 0xbe5ee304,
+ 0xa1fad5f0, 0x6a2d519a, 0x63ef8ce2, 0x9a86ee22,
+ 0xc089c2b8, 0x43242ef6, 0xa51e03aa, 0x9cf2d0a4,
+ 0x83c061ba, 0x9be96a4d, 0x8fe51550, 0xba645bd6,
+ 0x2826a2f9, 0xa73a3ae1, 0x4ba99586, 0xef5562e9,
+ 0xc72fefd3, 0xf752f7da, 0x3f046f69, 0x77fa0a59,
+ 0x80e4a915, 0x87b08601, 0x9b09e6ad, 0x3b3ee593,
+ 0xe990fd5a, 0x9e34d797, 0x2cf0b7d9, 0x022b8b51,
+ 0x96d5ac3a, 0x017da67d, 0xd1cf3ed6, 0x7c7d2d28,
+ 0x1f9f25cf, 0xadf2b89b, 0x5ad6b472, 0x5a88f54c,
+ 0xe029ac71, 0xe019a5e6, 0x47b0acfd, 0xed93fa9b,
+ 0xe8d3c48d, 0x283b57cc, 0xf8d56629, 0x79132e28,
+ 0x785f0191, 0xed756055, 0xf7960e44, 0xe3d35e8c,
+ 0x15056dd4, 0x88f46dba, 0x03a16125, 0x0564f0bd,
+ 0xc3eb9e15, 0x3c9057a2, 0x97271aec, 0xa93a072a,
+ 0x1b3f6d9b, 0x1e6321f5, 0xf59c66fb, 0x26dcf319,
+ 0x7533d928, 0xb155fdf5, 0x03563482, 0x8aba3cbb,
+ 0x28517711, 0xc20ad9f8, 0xabcc5167, 0xccad925f,
+ 0x4de81751, 0x3830dc8e, 0x379d5862, 0x9320f991,
+ 0xea7a90c2, 0xfb3e7bce, 0x5121ce64, 0x774fbe32,
+ 0xa8b6e37e, 0xc3293d46, 0x48de5369, 0x6413e680,
+ 0xa2ae0810, 0xdd6db224, 0x69852dfd, 0x09072166,
+ 0xb39a460a, 0x6445c0dd, 0x586cdecf, 0x1c20c8ae,
+ 0x5bbef7dd, 0x1b588d40, 0xccd2017f, 0x6bb4e3bb,
+ 0xdda26a7e, 0x3a59ff45, 0x3e350a44, 0xbcb4cdd5,
+ 0x72eacea8, 0xfa6484bb, 0x8d6612ae, 0xbf3c6f47,
+ 0xd29be463, 0x542f5d9e, 0xaec2771b, 0xf64e6370,
+ 0x740e0d8d, 0xe75b1357, 0xf8721671, 0xaf537d5d,
+ 0x4040cb08, 0x4eb4e2cc, 0x34d2466a, 0x0115af84,
+ 0xe1b00428, 0x95983a1d, 0x06b89fb4, 0xce6ea048,
+ 0x6f3f3b82, 0x3520ab82, 0x011a1d4b, 0x277227f8,
+ 0x611560b1, 0xe7933fdc, 0xbb3a792b, 0x344525bd,
+ 0xa08839e1, 0x51ce794b, 0x2f32c9b7, 0xa01fbac9,
+ 0xe01cc87e, 0xbcc7d1f6, 0xcf0111c3, 0xa1e8aac7,
+ 0x1a908749, 0xd44fbd9a, 0xd0dadecb, 0xd50ada38,
+ 0x0339c32a, 0xc6913667, 0x8df9317c, 0xe0b12b4f,
+ 0xf79e59b7, 0x43f5bb3a, 0xf2d519ff, 0x27d9459c,
+ 0xbf97222c, 0x15e6fc2a, 0x0f91fc71, 0x9b941525,
+ 0xfae59361, 0xceb69ceb, 0xc2a86459, 0x12baa8d1,
+ 0xb6c1075e, 0xe3056a0c, 0x10d25065, 0xcb03a442,
+ 0xe0ec6e0e, 0x1698db3b, 0x4c98a0be, 0x3278e964,
+ 0x9f1f9532, 0xe0d392df, 0xd3a0342b, 0x8971f21e,
+ 0x1b0a7441, 0x4ba3348c, 0xc5be7120, 0xc37632d8,
+ 0xdf359f8d, 0x9b992f2e, 0xe60b6f47, 0x0fe3f11d,
+ 0xe54cda54, 0x1edad891, 0xce6279cf, 0xcd3e7e6f,
+ 0x1618b166, 0xfd2c1d05, 0x848fd2c5, 0xf6fb2299,
+ 0xf523f357, 0xa6327623, 0x93a83531, 0x56cccd02,
+ 0xacf08162, 0x5a75ebb5, 0x6e163697, 0x88d273cc,
+ 0xde966292, 0x81b949d0, 0x4c50901b, 0x71c65614,
+ 0xe6c6c7bd, 0x327a140a, 0x45e1d006, 0xc3f27b9a,
+ 0xc9aa53fd, 0x62a80f00, 0xbb25bfe2, 0x35bdd2f6,
+ 0x71126905, 0xb2040222, 0xb6cbcf7c, 0xcd769c2b,
+ 0x53113ec0, 0x1640e3d3, 0x38abbd60, 0x2547adf0,
+ 0xba38209c, 0xf746ce76, 0x77afa1c5, 0x20756060,
+ 0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e,
+ 0x1948c25c, 0x02fb8a8c, 0x01c36ae4, 0xd6ebe1f9,
+ 0x90d4f869, 0xa65cdea0, 0x3f09252d, 0xc208e69f,
+ 0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6}
+ },
+ {
+ 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344,
+ 0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89,
+ 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c,
+ 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917,
+ 0x9216d5d9, 0x8979fb1b
+ } };
+
+ *c = initstate;
+}
+DEF_WEAK(Blowfish_initstate);
+
+u_int32_t
+Blowfish_stream2word(const u_int8_t *data, u_int16_t databytes,
+ u_int16_t *current)
+{
+ u_int8_t i;
+ u_int16_t j;
+ u_int32_t temp;
+
+ temp = 0x00000000;
+ j = *current;
+
+ for (i = 0; i < 4; i++, j++) {
+ if (j >= databytes)
+ j = 0;
+ temp = (temp << 8) | data[j];
+ }
+
+ *current = j;
+ return temp;
+}
+DEF_WEAK(Blowfish_stream2word);
+
+void
+Blowfish_expand0state(blf_ctx *c, const u_int8_t *key, u_int16_t keybytes)
+{
+ u_int16_t i;
+ u_int16_t j;
+ u_int16_t k;
+ u_int32_t temp;
+ u_int32_t datal;
+ u_int32_t datar;
+
+ j = 0;
+ for (i = 0; i < BLF_N + 2; i++) {
+ /* Extract 4 int8 to 1 int32 from keystream */
+ temp = Blowfish_stream2word(key, keybytes, &j);
+ c->P[i] = c->P[i] ^ temp;
+ }
+
+ j = 0;
+ datal = 0x00000000;
+ datar = 0x00000000;
+ for (i = 0; i < BLF_N + 2; i += 2) {
+ Blowfish_encipher(c, &datal, &datar);
+
+ c->P[i] = datal;
+ c->P[i + 1] = datar;
+ }
+
+ for (i = 0; i < 4; i++) {
+ for (k = 0; k < 256; k += 2) {
+ Blowfish_encipher(c, &datal, &datar);
+
+ c->S[i][k] = datal;
+ c->S[i][k + 1] = datar;
+ }
+ }
+}
+DEF_WEAK(Blowfish_expand0state);
+
+
+void
+Blowfish_expandstate(blf_ctx *c, const u_int8_t *data, u_int16_t databytes,
+ const u_int8_t *key, u_int16_t keybytes)
+{
+ u_int16_t i;
+ u_int16_t j;
+ u_int16_t k;
+ u_int32_t temp;
+ u_int32_t datal;
+ u_int32_t datar;
+
+ j = 0;
+ for (i = 0; i < BLF_N + 2; i++) {
+ /* Extract 4 int8 to 1 int32 from keystream */
+ temp = Blowfish_stream2word(key, keybytes, &j);
+ c->P[i] = c->P[i] ^ temp;
+ }
+
+ j = 0;
+ datal = 0x00000000;
+ datar = 0x00000000;
+ for (i = 0; i < BLF_N + 2; i += 2) {
+ datal ^= Blowfish_stream2word(data, databytes, &j);
+ datar ^= Blowfish_stream2word(data, databytes, &j);
+ Blowfish_encipher(c, &datal, &datar);
+
+ c->P[i] = datal;
+ c->P[i + 1] = datar;
+ }
+
+ for (i = 0; i < 4; i++) {
+ for (k = 0; k < 256; k += 2) {
+ datal ^= Blowfish_stream2word(data, databytes, &j);
+ datar ^= Blowfish_stream2word(data, databytes, &j);
+ Blowfish_encipher(c, &datal, &datar);
+
+ c->S[i][k] = datal;
+ c->S[i][k + 1] = datar;
+ }
+ }
+
+}
+DEF_WEAK(Blowfish_expandstate);
+
+void
+blf_key(blf_ctx *c, const u_int8_t *k, u_int16_t len)
+{
+ /* Initialize S-boxes and subkeys with Pi */
+ Blowfish_initstate(c);
+
+ /* Transform S-boxes and subkeys with key */
+ Blowfish_expand0state(c, k, len);
+}
+DEF_WEAK(blf_key);
+
+void
+blf_enc(blf_ctx *c, u_int32_t *data, u_int16_t blocks)
+{
+ u_int32_t *d;
+ u_int16_t i;
+
+ d = data;