pax_global_header00006660000000000000000000000064145562475430014531gustar00rootroot0000000000000052 comment=09db8b32db61b085030e8be2c6da2e9c2a86a128 skalibs-2.14.1.1/000077500000000000000000000000001455624754300134055ustar00rootroot00000000000000skalibs-2.14.1.1/.gitignore000066400000000000000000000004121455624754300153720ustar00rootroot00000000000000*.o /*.a.xyzzy *.lo /*.so.xyzzy /config.mak /src/include/skalibs/config.h /src/include/skalibs/ip46.h /src/include/skalibs/sysdeps.h /src/include/skalibs/types.h /src/include/skalibs/uint16.h /src/include/skalibs/uint32.h /src/include/skalibs/uint64.h /sysdeps.cfg/ skalibs-2.14.1.1/AUTHORS000066400000000000000000000034461455624754300144640ustar00rootroot00000000000000Main author: Laurent Bercot Contributors: Dan J. Bernstein William E. Baxter Olivier Brunel Lionel Van Bemten Rasmus Villemoes Jesse Young 7heo <7heo@mail.com> John Regan Shengjing Zhu Colin Booth Petr Vanek Peter Shkenev Mobin "Hojjat" Aydinfar Josiah Frentsos Thanks to: Jean Marot Paul Jarc Nicolas George David Madore Taj Khattra Dan Kegel Stefan Karrmann Matthew R. Dempsky Lasse Kliemann Robert Ransom Frans Haarman Vincent De Ribou Jorge Almeida Roman I Khimov Yannick Duchêne Michael Zuo Éric Le Bihan Samuel Holland Jan Bramkamp Johannes Nixdorf Casper Ti. Vector Guillermo Alex Raschi Josuah Demangeon Xavier Stonestreet Jason Donenfeld Amitai Schleier psykose Adam Beardwood Cormac Stephenson Henri Kemppainen skalibs-2.14.1.1/CONTRIBUTING000066400000000000000000000004371455624754300152430ustar00rootroot00000000000000 Please add a Signed-Off-By: line at the end of your commit, which certifies that you have the right and authority to pass it on as an open-source patch, as explicited in the Developer's Certificate of Origin available in this project's DCO file, or at https://developercertificate.org/ skalibs-2.14.1.1/COPYING000066400000000000000000000013701455624754300144410ustar00rootroot00000000000000Copyright (c) 2011-2024 Laurent Bercot 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. skalibs-2.14.1.1/DCO000066400000000000000000000026151455624754300137410ustar00rootroot00000000000000Developer Certificate of Origin Version 1.1 Copyright (C) 2004, 2006 The Linux Foundation and its contributors. 1 Letterman Drive Suite D4700 San Francisco, CA, 94129 Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Developer's Certificate of Origin 1.1 By making a contribution to this project, I certify that: (a) The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or (b) The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file; or (c) The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it. (d) I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the open source license(s) involved. skalibs-2.14.1.1/INSTALL000066400000000000000000000157251455624754300144500ustar00rootroot00000000000000Build Instructions ------------------ * Requirements ------------ - A POSIX-compliant C development environment - GNU make version 3.81 or later - If cross-compiling: you have to know the correct value for some non-autodetectable sysdeps for your target architecture. See the "Cross-compilation" section below. This software will install on any operating system that implements POSIX.1-2008, available at: https://pubs.opengroup.org/onlinepubs/9699919799/ * Standard usage -------------- ./configure && make && sudo make install will work for most users. It will install the static libraries in /usr/lib/skalibs, the shared libraries in /lib, and the sysdeps in /usr/lib/skalibs/sysdeps. Please note that static libraries in /usr/lib/skalibs *will not* be found by a default linker invocation: you need -L/usr/lib/skalibs. Other skarnet.org software automatically handles that case if the default configuration is used, but if you change the configuration, remember to use the appropriate --with-lib configure option. You can strip the libraries of their extra symbols via "make strip" before the "make install" phase. It will shave a few bytes off them. * Customization ------------- You can customize the installation process via flags given to configure. See ./configure --help for a list of all available configure options. * Environment variables --------------------- Controlling a build process via environment variables is a big and dangerous hammer. You should try and pass flags to configure instead; nevertheless, a few standard environment variables are recognized. If the CC environment variable is set, its value will override compiler detection by configure. The --host=HOST option will still add a HOST- prefix to the value of CC. The values of CFLAGS, CPPFLAGS and LDFLAGS will be appended to the default flags set by configure. To override those defaults instead of appending to them, use the CPPFLAGS, CFLAGS and LDFLAGS _make variables_ instead of environment variables. * Make variables -------------- You can invoke make with a few variables for more configuration. CC, CFLAGS, CPPFLAGS, LDFLAGS, LDLIBS, AR, RANLIB, STRIP, INSTALL and CROSS_COMPILE can all be overridden on the make command line. This is an even bigger hammer than running ./configure with environment variables, so it is advised to only do this when it is the only way of obtaining the behaviour you want. DESTDIR can be given on the "make install" command line in order to install to a staging directory. * Shared libraries ---------------- Software from skarnet.org is small enough that shared libraries are generally not worth using. Static linking is simpler and incurs less runtime overhead and less points of failure: but since skalibs only provides libraries, both versions are built by default. Nevertheless, you can: * avoid building shared libraries: --disable-shared * avoid building static libraries: --disable-static If you are using a GNU/Linux system, be aware that the GNU libc behaves badly with static linking and produces huge executables, so if you plan on making static executables, you should consider using another libc, which you also need to use when compiling skalibs. musl is recommended: http://musl-libc.org/ * Cross-compilation ----------------- skarnet.org centralizes all the difficulty of cross-compilation in skalibs. The native skalibs build process runs some tests to gather "sysdeps", i.e. system-dependent properties of the target, and stores those into a sysdeps directory; software depending on skalibs is provided the name of the sysdeps directory at build time, and can depend on its contents - that's how skarnet.org packages are easily made portable. However, when the host differs from the target - the cross-compilation case - some of those build-time tests, i.e. the ones that require code execution on the target, are invalid. So you must manually provide configure with appropriate values for the list of sysdeps that cannot be autodetected. For a sysdep named K with a value V, the correct option to give to configure is: --with-sysdep-K=V Most of the time, sysdeps have a boolean value, so the correct V is "yes" or "no". For instance, to say that the target has a working pseudorandom number generator in /dev/urandom, you would give the following option to configure: --with-sysdep-devurandom=yes If there are additional arguments to the sysdep, such as linker flags, give them separated by commas. Example: --with-sysdep-posixspawn=yes,-lrt ./configure --help lists all the sysdeps you need to manually provide a value for when cross-compiling. Note that you can provide manual sysdeps values at any time, for any existing sysdep, to bypass autodetection - and you can even do it when building natively. It's just not recommended (you should let skalibs autodetect everything it can), and and it's only mandatory for a small subset of sysdeps in the cross-compilation case. * The slashpackage convention --------------------------- The slashpackage convention (http://cr.yp.to/slashpackage.html) is a package installation scheme that provides a few guarantees over other conventions such as the FHS, for instance fixed absolute pathnames. skarnet.org packages support it: use the --enable-slashpackage option to configure, or --enable-slashpackage=DIR for a prefixed DIR/package tree. This option will activate slashpackage support during the build and set slashpackage-compatible installation directories. If $version is the current skalibs version number: --bindir will be set to /package/prog/skalibs-$version/command --includedir will be set to /package/prog/skalibs-$version/include --libdir will be set to /package/prog/skalibs-$version/library --dynlibdir will be set to /package/prog/skalibs-$version/library.so --sysdepdir will be set to /package/prog/skalibs-$version/sysdeps Note that --datadir will be unchanged, because the data exported by skalibs, i.e. the leap second table, is system-wide. You should manually specify --datadir=... if you want to deviate from the default. --prefix is pretty much ignored when you use --enable-slashpackage: it will only impact --datadir. You should probably not use both --enable-slashpackage and --prefix. When using slashpackage, two additional Makefile targets are available after "make install": - "make -L update" changes the default version of the software to the freshly installed one. (This is useful when you have several installed versions of the same software, which slashpackage supports.) - "make -L global-links" adds links from DIR/command and DIR/library.so to the default version of the binaries and shared libraries. The "-L" option to make is necessary because targets are symbolic links, and the default make behaviour is to check the pointed file's timestamp and not the symlink's timestamp. * Out-of-tree builds ------------------ skarnet.org packages do not support out-of-tree builds. They are small, so it does not cost much to duplicate the entire source tree if parallel builds are needed. skalibs-2.14.1.1/Makefile000066400000000000000000000141621455624754300150510ustar00rootroot00000000000000# # This Makefile requires GNU make. # # Do not make changes here. # Use the included .mak files. # it: all make_need := 3.81 ifeq "" "$(strip $(filter $(make_need), $(firstword $(sort $(make_need) $(MAKE_VERSION)))))" $(error Your make ($(MAKE_VERSION)) is too old. You need $(make_need) or newer) endif CC = $(error Please use ./configure first) -include config.mak include package/deps.mak version_m := $(basename $(version)) version_M := $(basename $(version_m)) version_l := $(basename $(version_M)) CPPFLAGS_ALL := $(CPPFLAGS_AUTO) $(CPPFLAGS) CFLAGS_ALL := $(CFLAGS_AUTO) $(CFLAGS) LDFLAGS_ALL := $(LDFLAGS_AUTO) $(LDFLAGS) LDLIBS_ALL := $(LDLIBS_AUTO) $(LDLIBS) AR := $(CROSS_COMPILE)ar RANLIB := $(CROSS_COMPILE)ranlib STRIP := $(CROSS_COMPILE)strip INSTALL := ./tools/install.sh TYPES := size uid gid pid time dev ino ALL_SRCS := $(sort $(wildcard src/lib*/*.c)) ALL_DOBJS := $(ALL_SRCS:%.c=%.lo) ifeq ($(strip $(STATIC_LIBS_ARE_PIC)),) ALL_SOBJS := $(ALL_SRCS:%.c=%.o) CFLAGS_SHARED := -fPIC else ALL_SOBJS := $(ALL_DOBJS) CFLAGS_SHARED := endif ALL_LIBS := $(SHARED_LIBS) $(STATIC_LIBS) BUILT_INCLUDES := \ src/include/$(package)/sysdeps.h \ src/include/$(package)/uint16.h \ src/include/$(package)/uint32.h \ src/include/$(package)/uint64.h \ src/include/$(package)/types.h \ src/include/$(package)/ip46.h ALL_INCLUDES := $(sort $(BUILT_INCLUDES) $(wildcard src/include/$(package)/*.h)) ALL_SYSDEPS := $(wildcard $(sysdeps)/*) ALL_DATA := $(wildcard src/etc/*) all: $(ALL_LIBS) $(ALL_INCLUDES) $(ALL_SYSDEPS) $(ALL_DATA) clean: @exec rm -f $(ALL_LIBS) $(ALL_BINS) $(ALL_SOBJS) $(ALL_DOBJS) $(BUILT_INCLUDES) distclean: clean @exec rm -rf config.mak src/include/$(package)/config.h sysdeps.cfg tgz: distclean @. package/info && \ rm -rf /tmp/$$package-$$version && \ cp -a . /tmp/$$package-$$version && \ cd /tmp && \ tar -zpcv --owner=0 --group=0 --numeric-owner --exclude=.git* -f /tmp/$$package-$$version.tar.gz $$package-$$version && \ exec rm -rf /tmp/$$package-$$version strip: $(ALL_LIBS) ifneq ($(strip $(STATIC_LIBS)),) exec $(STRIP) -x -R .note -R .comment $(STATIC_LIBS) endif ifneq ($(strip $(SHARED_LIBS)),) exec $(STRIP) -R .note -R .comment $(SHARED_LIBS) endif install: install-sysconf install-sysdeps install-dynlib install-lib install-include install-sysconf: $(ALL_DATA:src/etc/%=$(DESTDIR)$(sysconfdir)/%) install-sysdeps: $(ALL_SYSDEPS:$(sysdeps)/%=$(DESTDIR)$(sysdepdir)/%) install-dynlib: $(SHARED_LIBS:lib%.so.xyzzy=$(DESTDIR)$(dynlibdir)/lib%.so) install-lib: $(STATIC_LIBS:lib%.a.xyzzy=$(DESTDIR)$(libdir)/lib%.a) install-include: $(ALL_INCLUDES:src/include/$(package)/%.h=$(DESTDIR)$(includedir)/$(package)/%.h) ifneq ($(exthome),) $(DESTDIR)$(exthome): $(DESTDIR)$(home) exec $(INSTALL) -l $(notdir $(home)) $(DESTDIR)$(exthome) update: $(DESTDIR)$(exthome) global-links: $(DESTDIR)$(exthome) $(SHARED_LIBS:lib%.so.xyzzy=$(DESTDIR)$(sproot)/library.so/lib%.so.$(version_M)) $(DESTDIR)$(sproot)/library.so/lib%.so.$(version_M): $(DESTDIR)$(dynlibdir)/lib%.so.$(version_M) exec $(INSTALL) -D -l ..$(subst $(sproot),,$(exthome))/library.so/$( $@ src/include/$(package)/uint16.h: $(sysdeps)/sysdeps src/headers/uint16-bswap src/headers/bits-header src/headers/bits-footer src/headers/bits-lendian src/headers/bits-bendian src/headers/bits-template src/headers/uint64-include src/include/$(package)/uint64.h exec tools/gen-bits.sh $(sysdeps)/sysdeps 16 6 7 5 17 > $@ src/include/$(package)/uint32.h: $(sysdeps)/sysdeps src/headers/uint32-bswap src/headers/bits-header src/headers/bits-footer src/headers/bits-lendian src/headers/bits-bendian src/headers/bits-template src/headers/uint64-include src/include/$(package)/uint64.h exec tools/gen-bits.sh $(sysdeps)/sysdeps 32 11 13 9 33 > $@ src/include/$(package)/uint64.h: $(sysdeps)/sysdeps src/headers/uint64-bswap src/headers/bits-header src/headers/bits-footer src/headers/bits-lendian src/headers/bits-bendian src/headers/bits-template src/headers/uint64-ulong64 src/headers/uint64-noulong64 src/headers/uint64-defs src/headers/uint64-macros exec tools/gen-bits.sh $(sysdeps)/sysdeps 64 21 25 17 65 > $@ src/include/$(package)/types.h: src/include/$(package)/uint16.h src/include/$(package)/uint32.h src/include/$(package)/uint64.h $(sysdeps)/sysdeps src/headers/types-header src/headers/types-footer src/headers/unsigned-template src/headers/signed-template exec tools/gen-types.sh $(sysdeps)/sysdeps $(TYPES) > $@ src/include/$(package)/ip46.h: src/include/$(package)/fmtscan.h src/include/$(package)/tai.h src/include/$(package)/socket.h $(sysdeps)/sysdeps src/headers/ip46-header src/headers/ip46-footer src/headers/ip46-with src/headers/ip46-without @{ \ cat src/headers/ip46-header ; \ if $(ipv6) && grep -qF 'ipv6: yes' $(sysdeps)/sysdeps ; then cat src/headers/ip46-with ; \ else cat src/headers/ip46-without ; \ fi ; \ exec cat src/headers/ip46-footer ; \ } > $@ skalibs-2.14.1.1/NEWS000066400000000000000000000212531455624754300141070ustar00rootroot00000000000000Changelog for skalibs. In 2.14.1.1 ----------- - Bugfixes. In 2.14.1.0 ----------- - Bugfixes. - Portability improvements. - New socket_sendnb46_g() and socket_recvnb46_g() macros. In 2.14.0.1 ----------- - Bugfixes. In 2.14.0.0 ----------- - Bugfixes. - New accessor function: selfpipe_fd(). - New functions: slurpn(), openslurpnclose(). - slurp() and openslurpclose() are now macros. - New strerr macros to warn with a "fatal" message. - New cdb functions: cdb_hashv(), cdbmake_addv(). - child_spawn() revamp. Prototype change (last arg is a size_t). - case_lowerb() and friends now use ctype.h functions. - case_str() removed, strcasestr() fallback implementation added. - cspawn(): finally unifying fork() and posix_spawn(). - Better support for nonstandard posix_spawn subfunctions. - Lots of new sysdeps. In 2.13.1.1 ----------- - Bugfixes. In 2.13.1.0 ----------- - New macro: SKALIBS_PATH_MAX, in posixishard.h. Defined to 4096 on systems that do not define PATH_MAX. - New function: sals(). In 2.13.0.0 ----------- - Bugfixes. - New functions: buffer_timed_put(), buffer_timed_puts(). - strerr.h revamped. strerr_die, strerr_warn, strerr_diesys, strerr_warnsys and all the previous strerr2 macros are now __VA_ARGS__ macros around strerr_diev() and friends. In 2.12.0.1 ----------- - Bugfixes. In 2.12.0.0 ----------- - librandom revamped (again). * random_init() and random_finish() removed. * random_char() removed. * random_string() renamed to random_buf(). * early versions added. - New djbunix functions: waitn_posix(), waitn_reap_posix(). - readnclose() made public, now doesn't touch errno on success. - openreadnclose_at() now returns a ssize_t. In 2.11.2.0 ----------- - Bugfixes. - User-provided CPPFLAGS, CFLAGS and LDFLAGS are now honored in sysdep autodetection. - envdir_internal() now supports a SKALIBS_ENVDIR_NOCLAMP option, for unlimited-size variable reading. In 2.11.1.0 ----------- - fd_close() doesn't retry if close() fails. (i.e. adapts to Linux's behaviour over HP-UX's.) - New function: opendir_at. In 2.11.0.0 ----------- - libbiguint removed. - Obsolete skalibs/environ.h and skalibs/getpeereid.h removed. - rc4 and md5 removed. - iobuffer removed. - fd_cat and fd_catn changed signatures. - All *_t types renamed to avoid treading on POSIX namespace. - subgetopt() renamed to lgetopt(). - signal functions reworked; skasigaction removed; sig_stack removed - Various functions removed: skaoffsetof(), selfpipe_untrap() - cdb_make renamed to cdbmake; ui changed to 1=success/0=failure. - cdb redesigned. cdb is now fixed, cdb_reader holds the state for cdb_find, which puts data pointer and len directly into a cdb_data. A cdb is always a map, pointers should always work. - cdb_successor removed (unsafe to use); cdb_nextkey changed to cdb_traverse_next, which puts key and data into two cdb_data's. - cdb does not touch errno anymore. - New posixplz function: munmap_void. In 2.10.0.3 ----------- - Bugfixes. In 2.10.0.2 ----------- - Bugfixes. In 2.10.0.1 ----------- - Bugfixes. In 2.10.0.0 ----------- - New openc_* functions. - New function: ipc_bind_reuse_lock(), taking a lock before unconditionally deleting the socket. - ipc_bind_reuse() rewritten to use ipc_bind_reuse_lock(), so it does the right thing instead of clobbering sockets. - Complete revamping of the pathexec functions, see exec.h. - Revamping of the locking functions. - Use of standard O_NONBLOCK and O_CLOEXEC instead of adhoc DJBUNIX_FLAG_NB and DJBUNIX_FLAG_COE. - Better header separation; webipc.h removed (stuff moved to socket.h) - New function: mkptemp2(), creating a fifo with a templated name (like mkptemp) but with options for O_NONBLOCK and O_CLOEXEC. - New sysdep to test for chroot(). In 2.9.3.0 ---------- - New stralloc_readyplus_tuned() function. - Bugfixes. In 2.9.2.1 ---------- - Bugfixes. In 2.9.2.0 ---------- - Bugfixes. - New bigkv_* set of functions in libdatastruct. In 2.9.1.0 ---------- - Bugfixes. - Better support for GNU Hurd. - Added path_canonicalize(). In 2.9.0.0 ---------- - Bugfixes. - Better support of out-of-path toolchains (among other things, that means better autotools emulation). - Build more friendly to recent glibc. - Refactoring and optimization of scanning and formatting functions. - Refactoring of stopwatch/wallclock functions. The --enable-clock and --enable-monotonic configure switches have been removed. tain_now() can now be set at run time to use a wall clock (default, or via tain_now_set_wallclock()) or a stopwatch (via tain_now_set_stopwatch()), instead of it being fixed at build time. - Easy cross-compilation: no need to provide a whole sysdeps directory anymore. Only a few sysdeps have to be provided manually, via a --with-sysdep-K=V option to configure. Currently, that means one: --with-sysdep-devurandom=yes|no In 2.8.1.0 ---------- - Added skalibs_regcomp(), accepting empty regexes on BSDs. In 2.8.0.1 ---------- - Bugfixes. - Better reporting in utc_from_tai() and localtm_from_*() In 2.8.0.0 ---------- - Bugfixes. - avltreeb removed. (It used VLAs inside of structures, which is GNU C, not C99.) The AVLTREEN_DECLARE_AND_INIT() macro should be used instead. - New functions: env_dump(), mk?temp(), autosurf(), autosurf_name() - mkdir_unique() removed. (Duplicate functionality with mkdtemp.) - ancilautoclose and nbwaitall sysdeps removed. - New header: skalibs/posixishard.h - Static libraries are now PIC by default. In 2.7.0.0 ---------- - Bugfixes. - New functions: ipc_timed_sendv(), unlink_void(), genset_deepfree(), gensetdyn_deepfree(), skagetln_loose(), skagetlnsep_loose() - dir_close() now returns void and leaves errno unchanged - absolutepath(), sarealpath_tmp(), avl*_deletnode(), mininetstring, prot functions removed - djbunix.h doesn't include env.h anymore In 2.6.4.0 ---------- - Bugfixes. - New functions: execvep_loose(), byte_zzero(), openb_read(), sig0_scan() - New function family: skalibs/genqdyn.h In 2.6.3.1 ---------- - Bugfixes. In 2.6.3.0 ---------- - New dir_fd function wrapping dirfd() (Solaris doesn't have dirfd()) - memmem implementation for platforms that don't provide it. - memmem wrappers: byte_search, siovec_search. - New functions: atomic_symlink, skagetlnmaxsep, child_spawn3 - New header: skalibs/posixplz.h, some header reorganization. - New family of functions: textmessage and textclient - skalibs/environ.h and skalibs/getpeereid.h are now obsolescent. - Bugfixes. In 2.6.2.0 ---------- - New functions: access_at() (MacOS and Solaris don't support faccessat), skaclient_timed_aflush(). - stralloc.h and tai.h are suitable for inclusion in C++ headers. - New sysdep: SKALIBS_HASODIRECTORY. (MacOS doesn't support O_DIRECTORY.) In 2.6.1.0 ---------- - New function: lock_unx(). In 2.6.0.2 ---------- - Bugfixes. - Optimized packing/unpacking routines. In 2.6.0.1 ---------- - Better CPPFLAGS/CFLAGS/LDFLAGS management. - openwritenclose() and openwritevnclose() now use mkstemp. In 2.6.0.0 ---------- - Bugfixes. - New unixmessage_receiver_hasmsginbuf() function to address an issue in unixmessage_handle(). - fd_close() now returns void. This mandates a major version bump. - new skalibs_setgroups(), setgroups_with_egid() and setgroups_and_gid() functions to work around supplementary group mismanagement in... can you guess what operating system? (You get 3 tries. One for each BSD.) In 2.5.1.1 ---------- - Bugfixes. In 2.5.1.0 ---------- - Bugfixes. - More workarounds for OpenBSD (who else). - More workarounds for sysdeps detection by broken toolchains. - Added the xpathexec_* family of functions (in djbunix.h). In 2.5.0.0 ---------- - Added this NEWS file. :) - Dropped support for old versions of OpenBSD (at least 4.9 isn't working anymore). Newer versions are still supported: 5.7 and up are working. - --enable-replace-libc flag dropped. All supported systems now have a compliant-enough libc for skalibs' purposes. - Major types overhaul to be more POSIXly correct. 64-bit operations are now supported on 64-bit archs where int is 32-bit. Use of POSIX types wherever important, e.g. where pointers are used: datastruct.h indices, for instance, are uint32_t. stralloc et al. lengths are size_t. - Related API changes: skalibs/ushort.h, skalibs/uint.h and skalibs/ulong.h have disappeared - replaced with skalibs/types.h that also includes basic fmtscan support for common POSIX types. The uint16, uint32 and uint64 integer types have disappeared - replaced with stdint.h types. uint64_t is defined by skalibs/uint64.h when stdint.h omits it. - Lots of minor bugfixes and cleanups related to the types system. - Better support for getrandom() and arc4random(). skalibs-2.14.1.1/README000066400000000000000000000012061455624754300142640ustar00rootroot00000000000000skalibs - a general-purpose low-level C library ----------------------------------------------- skalibs is a C library used by all the skarnet.org packages. It provides APIs more suited to secure and efficient system programming than the libc, especially where network programming and IPCs are concerned. See the enclosed doc/ subdirectory for the documentation, or https://skarnet.org/software/skalibs/ * Installation ------------ See the INSTALL file. * Contact information ------------------- Laurent Bercot Please use the mailing-list for questions about skalibs. skalibs-2.14.1.1/README.macos000066400000000000000000000002421455624754300153640ustar00rootroot00000000000000 This package will compile on Darwin (MacOS), but the building of shared libraries is not supported. Make sure you use the --disable-shared option to configure. skalibs-2.14.1.1/README.solaris000066400000000000000000000006531455624754300157440ustar00rootroot00000000000000 This package assumes the existence of a POSIX shell in /bin/sh. On Solaris, /bin/sh is not POSIX. Most versions of Solaris provide a POSIX shell in /usr/xpg4/bin/sh. To compile this package on Solaris, you will need to run ./patch-for-solaris before you run ./configure. This script will change the #! invocation of the configure script and various tools so that a POSIX shell is used for the compilation process. skalibs-2.14.1.1/configure000077500000000000000000000522721455624754300153240ustar00rootroot00000000000000#!/bin/sh cd `dirname "$0"` . package/info # Helper functions usage () { cat </dev/null 2>&1 && { echo "$1" ; return 0 ; } $1 EOF echo "$1" | sed -e "s/'/'\\\\''/g" -e "1s/^/'/" -e "\$s/\$/'/" -e "s#^'\([-[:alnum:]_,./:]*\)=\(.*\)\$#\1='\2#" -e "s|\*/|* /|g" } fail () { echo "$*" 1>&2 exit 1 } fnmatch () { eval "case \"\$2\" in $1) return 0 ;; *) return 1 ;; esac" } cmdexists () { type "$1" >/dev/null 2>&1 } trycc () { test -z "$CC_AUTO" && cmdexists "$1" && CC_AUTO="$*" } stripdir () { while eval "fnmatch '*/' \"\${$1}\"" ; do eval "$1=\${$1%/}" done } tryflag () { echo "Checking whether compiler accepts $2 ..." echo "typedef int x;" > "$tmpc" if $CC_AUTO $CPPFLAGS_POST $CFLAGS_POST "$2" -c -o "$tmpo" "$tmpc" >/dev/null 2>&1 ; then echo " ... yes" eval "$1=\"\${$1} \$2\"" eval "$1=\${$1# }" return 0 else echo " ... no" return 1 fi } tryldflag () { echo "Checking whether linker accepts $2 ..." echo "typedef int x;" > "$tmpc" if $CC_AUTO $CPPFLAGS_POST $CFLAGS_POST $LDFLAGS_POST -nostdlib "$2" -o "$tmpe" "$tmpc" >/dev/null 2>&1 ; then echo " ... yes" eval "$1=\"\${$1} \$2\"" eval "$1=\${$1# }" return 0 else echo " ... no" return 1 fi } # Sysdeps determination functions iscached () { if test -r "$tmps" && grep -q "^${1}: " "$tmps" ; then grep "^${1}: " "$tmps" | tail -n 1 | { IFS=' ' read -r k v ldlibs if test -n "$ldlibs" ; then echo " ... user-provided: $v with linker args: $ldlibs" echo "$ldlibs" >&3 else echo " ... user-provided: $v" fi echo "${1}: $v" >> "$sysdeps/sysdeps" return 0 ; } else return 1 ; fi } choose () { what="$1" name="$2" echo "Checking whether system has $3..." if iscached "$name" ; then return ; fi shift 3 libs="$*" r=true case "$what" in *c*) $CC_AUTO $CPPFLAGS_AUTO $CPPFLAGS $CPPFLAGS_POST $CFLAGS_AUTO $CFLAGS $CFLAGS_POST -o "$tmpo" -c src/sysdeps/try$name.c 2>/dev/null || r=false ;; esac if $r ; then case "$what" in *l*) $CC_AUTO $CFLAGS_AUTO $CFLAGS $CFLAGS_POST $LDFLAGS_AUTO $LDFLAGS $LDFLAGS_POST -o try$name "$tmpo" $libs 2>/dev/null || r=false ;; esac fi if $r ; then case "$what" in *r*) if test -n "$cross" ; then rm -f try$name fail "$0: sysdep $name cannot be autodetected when cross-compiling. Please manually provide a value with the --with-sysdep-${name}=yes|no|... option." fi ./try$name >/dev/null 2>&1 ; r=$? case "$r" in 111) fail "$0: test crashed, aborting." ;; 0) r=true ;; *) r=false ;; esac esac fi rm -f try$name if $r ; then echo "$name: yes" >> $sysdeps/sysdeps echo " ... yes" else echo "$name: no" >> $sysdeps/sysdeps echo " ... no" fi } trybasic () { $CC_AUTO $CPPFLAGS_AUTO $CPPFLAGS $CPPFLAGS_POST $CFLAGS_AUTO $CFLAGS $CFLAGS_POST -o "$tmpo" -c "$1" 2>/dev/null } tryendianness () { echo "Checking endianness..." if iscached endianness ; then return ; fi for i in endian.h sys/endian.h machine/endian.h sys/machine.h ; do cat > "$tmpc" < int a = LITTLE_ENDIAN ; int b = BIG_ENDIAN ; int c = BYTE_ORDER ; EOF trybasic "$tmpc" || continue for j in little big pdp ; do k=`echo $j | tr '[:lower:]' '[:upper:]'` cat > "$tmpc" < int a[BYTE_ORDER == ${k}_ENDIAN ? 1 : -1] ; EOF if trybasic "$tmpc" ; then echo "endianness: $j" >> "$sysdeps/sysdeps" echo " ... $j" rm -f "$tmpc" return fi done rm -f "$tmpc" fail "$0: error: unable to determine endianness according to $i" done for j in little big ; do k=`echo $j | tr '[:lower:]' '[:upper:]'` cat > "$tmpc" < int a = _${k}_ENDIAN +1 ; EOF if trybasic "$tmpc" ; then echo "endianness: $j" >> "$sysdeps/sysdeps" echo " ... $j" rm -f "$tmpc" return fi done rm -f "$tmpc" fail "$0: error: unable to determine endianness: no suitable endian.h found" } trysigned () { cat > "$tmpc" < int a[($1)-1 < 0 ? 1 : -1] ; EOF trybasic "$tmpc" r=$? rm -f "$tmpc" return $r } trysizes () { t="$1" ; shift for arg ; do cat > "$tmpc" < int a[sizeof($t) == $arg ? 1 : -1] ; EOF if trybasic "$tmpc" ; then rm -f "$tmpc" echo "$arg" return fi done rm -f "$tmpc" fail "$0: error: unable to determine the size of $t on the target" } trystdtype () { t="$1" ; shift iscached "sizeofu$t" || { echon "sizeofu${t}: " ; trysizes "$t" "$@" ; } >> "$sysdeps/sysdeps" } trytypes () { echo "Checking size and signedness of standard types..." trystdtype short 2 4 trystdtype int 4 8 2 trystdtype long 8 4 for t in size uid gid pid time dev ino ; do iscached "signed$t" || { echon "signed${t}: " ; if trysigned "${t}_t" ; then echo "yes" ; else echo "no" ; fi ; } >> "$sysdeps/sysdeps" iscached "sizeof$t" || { echon "sizeof${t}: " ; trysizes "${t}_t" 4 8 2 ; } >> "$sysdeps/sysdeps" done echo " ... done" } detectlibs () { args= name=$1 shift if $CC_AUTO $CPPFLAGS_AUTO $CPPFLAGS $CPPFLAGS_POST $CFLAGS_AUTO $CFLAGS $CFLAGS_POST -c -o try$name.o src/sysdeps/try$name.c 2>/dev/null ; then until $CC_AUTO $CFLAGS_AUTO $CFLAGS $CFLAGS_POST $LDFLAGS_AUTO $LDFLAGS $LDFLAGS_POST -o "$tmpe" try$name.o $args 2>/dev/null ; do if test -z "$*" ; then rm -f try$name.o return 1 fi args="$args $1" shift done echo ${args# } rm -f try$name.o return 0 else return 1 fi } trylibs () { name="$1" libvar="$2"_lib libfile="$2".lib echo "Checking whether system has $3..." shift 3 if { args=`iscached $name 3>&1 1>&4 4>&-` ; } 4>&1 ; then : elif args=`detectlibs "$name" "$@"` ; then echo "${name}: yes" >> "${sysdeps}/sysdeps" if test -z "$args" ; then echo " ... yes" else echo " ... yes, with linker args: $args" fi else echo "${name}: no" >> ${sysdeps}/sysdeps echo " ... no" fi eval "${libvar}=\"$args\"" echo "$args" > "${sysdeps}/$libfile" } # The script starts HERE. # Initialize variables CC_AUTO= CPPFLAGS_AUTO="-D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -Isrc/include" CPPFLAGS_POST="$CPPFLAGS" CPPFLAGS= CFLAGS_AUTO="-pipe -Wall" CFLAGS_POST="$CFLAGS" CFLAGS="-O2" LDFLAGS_AUTO= LDFLAGS_POST="$LDFLAGS" LDFLAGS= LDFLAGS_NOSHARED= LDFLAGS_SHARED=-shared prefix= dynlibdir='$prefix/lib' libdir='$prefix/lib/$package' includedir='$prefix/include' sysconfdir='$prefix/etc' sysdepdir='$prefix/lib/$package/sysdeps' sysdeplist= shared=true static=true allpic=true slashpackage=false ipv6=true select=false taiclock=false ddefaultpath=/usr/bin:/bin defaultpath=$ddefaultpath dpathorig=true sproot= home= exthome= addincpath='' addlibspath='' addlibdpath='' vpaths='' vpathd='' build= # Parse command line for arg ; do case "$arg" in --help) usage ;; --prefix=*) prefix=${arg#*=} ;; --dynlibdir=*) dynlibdir=${arg#*=} ;; --libdir=*) libdir=${arg#*=} ;; --includedir=*) includedir=${arg#*=} ;; --sysconfdir=*) sysconfdir=${arg#*=} ;; --sysdepdir=*) sysdepdir=${arg#*=} ;; --with-include=*) var=${arg#*=} ; stripdir var ; addincpath="$addincpath -I$var" ;; --with-lib=*) var=${arg#*=} ; stripdir var ; addlibspath="$addlibspath -L$var" ; vpaths="$vpaths $var" ;; --with-dynlib=*) var=${arg#*=} ; stripdir var ; addlibdpath="$addlibdpath -L$var" ; vpathd="$vpathd $var" ;; --enable-shared|--enable-shared=yes) shared=true ;; --disable-shared|--enable-shared=no) shared=false ;; --enable-static|--enable-static=yes) static=true ;; --disable-static|--enable-static=no) static=false ;; --enable-all-pic|--enable-all-pic=yes) allpic=true ;; --disable-all-pic|--enable-all-pic=no) allpic=false ;; --enable-slashpackage=*) sproot=${arg#*=} ; slashpackage=true ; ;; --enable-slashpackage) sproot= ; slashpackage=true ;; --disable-slashpackage) sproot= ; slashpackage=false ;; --enable-ipv6|--enable-ipv6=yes) ipv6=true ;; --disable-ipv6|--enable-ipv6=no) ipv6=false ;; --enable-iopause-select|--enable-iopause-select=yes) select=true ;; --disable-iopause-select|--enable-iopause-select=no) select=false ;; --enable-tai-clock|--enable-tai-clock=yes) taiclock=true ;; --disable-tai-clock|--enable-tai-clock=no) taiclock=false ;; --enable-monotonic|--enable-monotonic=yes) echo "$0: warning: --enable-monotonic is now obsolete" 1>&2 ;; --disable-monotonic|--enable-monotonic=no) ;; --with-default-path=*) defaultpath=${arg#*=} ; dpathorig=false ;; --without-default-path) defaultpath=$ddefaultpath ; dpathorig=true ;; --with-sysdep-*=*) sysdeplist="$sysdeplist ${arg#--with-sysdep-}" ;; --without-sysdep-*) sysdeplist="$sysdeplist ${arg#--without-sysdep-}=no" ;; --enable-*|--disable-*|--with-*|--without-*|--*dir=*) ;; --host=*|--target=*) target=${arg#*=} ;; --build=*) build=${arg#*=} ;; -* ) echo "$0: unknown option $arg" ;; *=*) eval "${arg%%=*}=\${arg#*=}" ;; *) target=$arg ;; esac done # Add /usr in the default default case if test -z "$prefix" ; then if test "$libdir" = '$prefix/lib/$package' ; then libdir=/usr/lib/$package fi if test "$includedir" = '$prefix/include' ; then includedir=/usr/include fi if test "$sysdepdir" = '$prefix/lib/$package/sysdeps' ; then sysdepdir=/usr/lib/$package/sysdeps fi fi # Expand installation directories stripdir prefix for i in exec_prefix dynlibdir libdir includedir sysconfdir sysdepdir sysdepspre sproot ; do eval tmp=\${$i} eval $i=$tmp stripdir $i done # Set slashpackage values if $slashpackage ; then home=${sproot}/package/${category}/${package}-${version} exthome=${sproot}/package/${category}/${package} sysdepdir=${home}/sysdeps binprefix=${home}/command extbinprefix=${exthome}/command dynlibdir=${home}/library.so libdir=${home}/library includedir=${home}/include if $dpathorig ; then if echo $defaultpath | tr : '\n' | grep -q '^/command$' ; then : ; else defaultpath="/command:$defaultpath" fi fi fi # Get usable temp filenames i=0 set -C while test "$i" -lt 50 ; do i=$(($i+1)) tmpc="./tmp-configure-$$-$PPID-$i.c" tmpo="./tmp-configure-$$-$PPID-$i.o" tmpe="./tmp-configure-$$-$PPID-$i.tmp" tmps="./tmp-configure-$$-$PPID-$i.sysdeps" 2>|/dev/null > "$tmpc" && break 2>|/dev/null > "$tmpo" && break 2>|/dev/null > "$tmpe" && break 2>|/dev/null > "$tmps" && break done if test "$i" -gt 50 ; then fail "$0: cannot create temporary files" fi set +C trap 'rm -f "$tmpc" "$tmpo" "$tmpe" "$tmps"' EXIT ABRT INT QUIT TERM HUP # Preprocess user-provided sysdeps rm -f "$tmps" if test -n "$sysdeplist" ; then :> "$tmps" for i in $sysdeplist ; do k=${i%%=*} echo ${i#*=} | sed 's/,/ /g' | { read v extras if test -z "$k" || test -z "$v" ; then fail "$0: invalid user-provided sysdep: $i" ; fi if test "$v" = "true" ; then v=yes elif test "$v" = "false" ; then v=no fi if grep -q -e "^${k}: " "$tmps" ; then grep -v -e "^${k}: " "$tmps" > "$tmpe" mv -f "$tmpe" "$tmps" fi if test -n "$extras" ; then echo "${k}: $v $extras" else echo "${k}: $v" fi >> "$tmps" } done fi # Find a C compiler to use if test -n "$target" && test x${build} != x${target} ; then cross=${target}- else cross= fi echo "Checking for C compiler..." trycc ${CC} if test -n "$CC_AUTO" ; then b=`basename "$CC"` adjust_cross=false if test "$b" != "$CC" ; then adjust_cross=true echo "$0: warning: compiler $CC is declared with its own path. If it's not accessible via PATH, you will need to pass AR, RANLIB and STRIP make variables to the make invocation." 1>&2 fi if test -n "$cross" ; then if test "$b" = "${b##$cross}" ; then echo "$0: warning: compiler $CC is declared as a cross-compiler for target $target but does not start with prefix ${cross}" 1>&2 elif $adjust_cross ; then cross=`dirname "$CC"`/"$cross" fi fi fi trycc ${cross}gcc trycc ${cross}clang trycc ${cross}cc test -n "$CC_AUTO" || fail "$0: cannot find a C compiler" echo " ... $CC_AUTO" echo "Checking whether C compiler works... " echo "typedef int x;" > "$tmpc" if $CC_AUTO $CPPFLAGS_AUTO $CPPFLAGS $CPPFLAGS_POST $CFLAGS_AUTO $CFLAGS $CFLAGS_POST -c -o "$tmpo" "$tmpc" 2>"$tmpe" ; then echo " ... yes" else echo " ... no. Compiler output follows:" cat < "$tmpe" exit 1 fi echo "Checking target system type..." if test -z "$target" ; then if test -n "$build" ; then target=$build ; else target=$($CC_AUTO -dumpmachine 2>/dev/null) || target=unknown fi fi echo " ... $target" # Produce automatic compilation flags if $allpic ; then tryflag CPPFLAGS_AUTO -fPIC fi tryflag CFLAGS_AUTO -std=c99 tryflag CFLAGS -fomit-frame-pointer tryflag CFLAGS_AUTO -fno-exceptions tryflag CFLAGS_AUTO -fno-unwind-tables tryflag CFLAGS_AUTO -fno-asynchronous-unwind-tables tryflag CPPFLAGS_AUTO -Werror=implicit-function-declaration tryflag CPPFLAGS_AUTO -Werror=implicit-int tryflag CPPFLAGS_AUTO -Werror=pointer-sign tryflag CPPFLAGS_AUTO -Werror=pointer-arith tryflag CPPFLAGS_AUTO -Wno-unused-value tryflag CPPFLAGS_AUTO -Wno-parentheses tryflag CFLAGS_AUTO -ffunction-sections tryflag CFLAGS_AUTO -fdata-sections tryldflag LDFLAGS_SHARED -nostartfiles tryldflag LDFLAGS_AUTO -Wl,--as-needed tryldflag LDFLAGS_AUTO -Wl,--sort-section=alignment tryldflag LDFLAGS_AUTO -Wl,--sort-common if $shared ; then tryldflag LDFLAGS -Wl,--hash-style=both fi # And now, determine a big fat batch of sysdeps. sysdeps=sysdeps.cfg mkdir -p $sysdeps echo "$target" > $sysdeps/target :> "$sysdeps/sysdeps" util_lib= echo > $sysdeps/util.lib echo 'Checking required linker flags for socket functions...' socket_lib=`detectlibs lsock -lsocket -lnsl` || fail "$0: unable to determine required linker flags for socket functions" if test -n "$socket_lib" ; then echo " ... $socket_lib" else echo " ... none" fi echo "$socket_lib" > $sysdeps/socket.lib trylibs clockrt sysclock 'clock_gettime()' -lrt choose cl clockmon CLOCK_MONOTONIC $sysclock_lib choose cl clockboot CLOCK_BOOTTIME $sysclock_lib trylibs posixspawn spawn 'posix_spawn()' -lrt trylibs timer timer 'timer_create()' -lrt trylibs pthread pthread 'pthread support' -lpthread -lrt tryendianness trytypes choose cl accept4 'accept4()' choose c cmsgcloexec 'MSG_CMSG_CLOEXEC' choose cl dirfd 'dirfd()' choose cl eventfd 'eventfd()' choose cl flock 'flock()' choose cl getpeereid 'getpeereid()' choose cl sopeercred 'SO_PEERCRED' choose cl getpeerucred 'getpeerucred()' choose cl ipv6 'IPv6 support' $socket_lib choose c msgdontwait 'MSG_DONTWAIT' choose c odirectory 'O_DIRECTORY' choose cl openat 'openat()' choose cl linkat 'linkat()' choose cl memmem 'memmem()' choose cl pipe2 'pipe2()' choose cl ppoll 'ppoll()' choose cl revoke 'revoke()' choose cl sendfile 'sendfile()' choose cl setgroups 'setgroups()' choose cl settimeofday 'settimeofday()' choose cl signalfd 'signalfd()' choose cl splice 'splice()' choose c statim 'st.st_atim' choose c statimespec 'st.st_atimespec' choose cl strcasestr 'strcasestr()' choose c strnlen 'strnlen()' choose c uint64t 'uint64_t' choose cl waitid 'waitid()' choose cl futimens 'futimens()' choose cl futimes 'futimes()' choose cl arc4random 'arc4random()' choose cl arc4random_addrandom 'arc4random_addrandom()' choose cl itimer 'setitimer()' choose cl namespaces 'namespaces' choose cl nsgetparent 'NS_GET_PARENT' choose cl explicit_bzero 'explicit_bzero()' choose cl getrandom 'getrandom()' choose cl grndinsecure 'GRND_INSECURE' choose cl chroot 'chroot()' choose cl posixspawnsetsid 'POSIX_SPAWN_SETSID' $spawn_lib choose cl posixspawnsetsidnp 'POSIX_SPAWN_SETSID_NP' $spawn_lib choose cl posixspawnchdir 'posix_spawn_file_actions_addchdir()' $spawn_lib choose cl posixspawnchdirnp 'posix_spawn_file_actions_addchdir_np()' $spawn_lib # Here are the evil irreducible run-time sysdeps. choose clr devurandom '/dev/urandom' choose clr posixspawnearlyreturn 'posix_spawn() return early' $spawn_lib # Finally, produce config.mak and config.h rm -f "$tmps" echo "Creating config.mak..." cmdline=$(quote "$0") for i ; do cmdline="$cmdline $(quote "$i")" ; done exec 3>&1 1>config.mak cat << EOF # This file was generated by: # $cmdline # Any changes made here will be lost if configure is re-run. target := $target package := $package prefix := $prefix sysconfdir := $sysconfdir sysdepdir := $sysdepdir dynlibdir := $dynlibdir libdir := $libdir includedir := $includedir sysdeps := $sysdeps version := $version sproot := $sproot home := $home exthome := ${exthome} ipv6 := ${ipv6} SPAWN_LIB := ${spawn_lib} SOCKET_LIB := ${socket_lib} SYSCLOCK_LIB := ${sysclock_lib} TIMER_LIB := ${timer_lib} UTIL_LIB := ${util_lib} CC := ${CC_AUTO} CPPFLAGS_AUTO := $CPPFLAGS_AUTO CPPFLAGS := $CPPFLAGS $CPPFLAGS_POST CFLAGS_AUTO := $CFLAGS_AUTO CFLAGS := $CFLAGS $CFLAGS_POST LDFLAGS_AUTO := $LDFLAGS_AUTO LDFLAGS := $LDFLAGS $LDFLAGS_POST LDFLAGS_NOSHARED := $LDFLAGS_NOSHARED LDFLAGS_SHARED := $LDFLAGS_SHARED CROSS_COMPILE := ${cross} EOF if test -n "$vpaths" ; then echo "vpath lib%a$vpaths" fi if test -n "$vpathd" ; then echo "vpath lib%.so$vpathd" fi if $static ; then echo "STATIC_LIBS := libskarnet.a.xyzzy" else echo "STATIC_LIBS :=" fi if $shared ; then echo "SHARED_LIBS := libskarnet.so.xyzzy" else echo "SHARED_LIBS :=" fi if $allpic ; then echo "STATIC_LIBS_ARE_PIC := 1" else echo "STATIC_LIBS_ARE_PIC :=" fi exec 1>&3 3>&- echo " ... done." echo "Creating src/include/${package}/config.h..." mkdir -p -m 0755 src/include/${package} exec 3>&1 1> src/include/${package}/config.h cat <&3 3>&- echo " ... done." skalibs-2.14.1.1/doc/000077500000000000000000000000001455624754300141525ustar00rootroot00000000000000skalibs-2.14.1.1/doc/crosscompile.html000066400000000000000000000073351455624754300175520ustar00rootroot00000000000000 How to cross-compile skalibs

skalibs
Software
skarnet.org

How to cross-compile skalibs

There are three issues in the world of cross-compilation:

  • support for parallel builds: the source directory must be read-only and each build process must have its own build tree.
  • support for compiler options: to specify the target architecture, the header and library files that should be used, etc.
  • build-time tests performed on the build architecture are invalid if the target architecture is different.

Support for parallel builds

skalibs does not support out-of-tree builds at the moment, but since the source code tree is small, it's not costly to duplicate it to perform parallel builds. If the source code tree grows significantly larger, out-of-tree build support will be considered.

Support for staging

The skalibs Makefile, as well as every other skarnet.org package's Makefile, supports the DESTDIR convention for staging. To install skalibs under a stage fake root:

  • Give the options you need to ./configure. The arguments to the --prefix, --libdir and similar options must be the valid paths for run-time.
  • To install the software, run make install DESTDIR=stage.

Support for build-time options and bypassing target execution tests

skalibs uses a standard ./configure && make && make install process, and cross-compiling build-time options can be given on the ./configure command line.

skalibs performs a certain number of build-time tests, to collect behaviour information on the target architecture. Most of these tests work when cross-compiling, because they only involve characteristics of the target that the cross-toolchain knows at build time; but some actually require code execution on the target, and so they cannot be performed when cross-compiling. For those, you have to manually give a special option to configure, to tell the build system what the behaviour of the target architecture is. The option is of the form --with-sysdep-key=value, where key is the name of the sysdep (i.e. the element of target behaviour that is being tested), and value the associated value, most of the time yes or no.

At all times, ./configure --help provides the list of sysdeps you need to provide a --with-sysdep-* option for. As of skalibs-2.14.0.1, there are two sysdeps in this case:

  • devurandom: yes if the target has a valid pseudorandom generation device in /dev/urandom, and no otherwise.
  • posixspawnearlyreturn: yes if the target has a broken posix_spawn() implementation that can return before the child has successfully exec'ed. That happens with old glibcs and some virtual platforms.
skalibs-2.14.1.1/doc/djblegacy.html000066400000000000000000000127551455624754300167760ustar00rootroot00000000000000 skalibs: the djb legacy

skalibs
Software
skarnet.org

The DJB legacy

Who is this DJB guy, and why is he so special anyway ?

Dan J. Bernstein is a cryptologist and a mathematician; he's also the author of a widely known and used MTA, qmail, as well as a few lesser known pieces of software.

For some time he was quite active in some Unix software-related Internet newsgroups and mailing-lists; he quickly became a controversial figure of the Unix programming community, mostly by being extremely vocal against well-known authors of "mainstream" Unix software and by suggesting designs so removed from traditional software design that a normal human reaction is to first view him as a complete nut.

I do not care for controversy. I am interested in the code. I was a sysadmin at the time, and still learning to program in C beyond what they teach you in school (i.e. not much). I had heard enough horror stories with sendmail; so I gave a shot at qmail, trying to understand its design principles and the way it was made. And then I fell down the rabbit hole.

Look, I don't care what you think of the guy, I don't know him anyway, and this is totally beside the point. The only thing that matters is that DJB's software is right in so many ways. This software works. DJB's design principles are sound and elegant; they are sound foundations to build reliable, secure, and low resource-consuming software. And the design, when you get used to it, feels so unix-ish: it's Unix the way it should have been from the start.

Studying DJB's software was the best course in C/Unix programming I ever had. Now I teach C/Unix; and I am really glad I learned from the best.

Building beyond DJB's works.

There's already a lot you can do with pristine DJB software and some brains.

However, I mostly see DJB as a pioneer. He showed it was possible to think Unix differently and build secure, reliable and efficient software without investing millions of dollars into it; now it is up to software architects and programmers to use the breakthrough and build upon it. There's a real demand for quality Unix software out there; it's time to supply. And I am not the only one thinking this way.

So, skalibs.

One of the "DJB philosophy" key points is to question the interfaces. You have a task to do; you have existing interfaces. What do you do?

  • Most people don't even think about it and use the existing interfaces, even if it amounts to cramming a square peg into a round hole. This is why buffer overflows exist. This is why people use abominations such as gets(), which is still in the Single Unix Specification as of version 4, in freaking June 2011. This is why the System V initialization scheme is still prevalent in Linux distributions, despite being one of the slowest and most unreliable of all initialization schemes. This is why people still use the atrocious "libresolv" DNS client library.
  • An alternative way of thinking is to ask yourself: "Is the interface I have adequate for the task at hand?"
    • If yes: perfect, use that interface.
    • If no: then do not use that interface, duh. Design a better one and use it: so the complexity will be split and the code will be easier to maintain.

Interfaces should be questioned right down to the libc. You cannot build strong software on flakey foundations. And from a system and network programmer's point of view, one thing is clear: most standard libc interfaces suck. There is no buffered asynchronous I/O. There is no timed I/O. There is no heap management helper. Even simple system calls are not always guaranteed to succeed!

That is where skalibs comes from. skalibs results from questioning the libc interfaces, and providing replacements or additions where the existing interfaces do not make it easy to write reliable, secure and efficient software. It is inspired by DJB's work. It is not a shrine or anything of the kind.

Conclusion

So, in short, DJB is not a guru, I'm not a mindless brainwashed fan, and the "DJB advocates" are not a cult. We just think DJB brought something to Unix and more generally to the software programming world; we learned from him, we write software following sound principles that he was one of the first to really apply, and we give credit where credit is due.

Use our software. You will never want to go back.

skalibs-2.14.1.1/doc/flags.html000066400000000000000000000204431455624754300161370ustar00rootroot00000000000000 skalibs: configuration flags

skalibs
Software
skarnet.org

skalibs configuration flags

The skalibs ./configure script comes with a few uncommon options; this page explains what they are for.

--enable-slashpackage[=sproot]

This flag tells configure that you want to install skalibs according to the slashpackage convention. If you enable it, and $v is the version of skalibs you're compiling, make install will install the skalibs header files in /package/prog/skalibs-$v/include, the static libraries in /package/prog/skalibs-$v/library, the dynamic libraries in /package/prog/skalibs-$v/library.so and the data files in /package/prog/skalibs-$v/etc, all prefixed by sproot if present.

It will also prepend the default path with /command, unless an explicit default path has been given via the --with-default-path option.

Additionally, it will add two more "make" targets:

  • make update will update the /package/prog/skalibs symbolic link to point to skalibs-$v
  • make -L global-links will make links from /library.so to the installed skalibs shared libraries.

If this option is not given, no slashpackage support will be provided.

--enable-tai-clock

To understand what this flag is about - and the next two flags too - you should start by reading this page about Unix time, which David Madore wrote after a long and fairly complete discussion we had on the subject. You can also read what DJB says about Unix time. Unfortunately, when he says "the POSIX rules are so outrageously dumb (...) that no self-respecting engineer would obey them", DJB is wrong: a lot of people follow the POSIX rules. Or maybe he's right... and there are very, very few self-respecting engineers.

Basically, when you configure a Unix system, there are essentially two ways to deal with your system clock.

  1. You can set your system clock to TAI-10, which is the "right", but uncommon, thing to do:
    • ↑ The main advantage of this setup is that it makes your system clock linear. In other words, gettimeofday() becomes suitable for both timestamping (which needs absolute time) and timeout computations (which need reliable interval measurements); if your clock is accurate enough, it can function as both a wall clock and a stopwatch. This simplifies keeping track of the current time considerably, and makes event loop handling (with functions such as iopause()) trivial.
    • ↑ skalibs uses TAI internally; setting your system clock to TAI-10 saves a lot of conversions and makes time computations with skalibs more efficient.
    • → skalibs-aware software will display GMT or local time properly in every case, but you have to use the right/ timezones, from Arthur David Olson's timezone library, to prevent your other software from being confused by a TAI-10 system clock. If you do not use right/ timezones, utilities such as date will not compute the proper time - they will have an offset of 24 seconds or so.
    • ↓ This setup is arguably not SUSv4 conformant (a strict interpretation of Single Unix requires the system clock to be set to UTC).
    • ↓ This setup is not compatible with ntpd. ntpd's design is flawed: it makes the mistake of setting the system clock itself - instead of simply making the computed time available to other programs, one of which could set the system clock - and it always sets it to UTC. (The s6-networking package provides alternate ways to synchronize your clock, though.)
  2. You can set your system clock to UTC, which is the common, strictly POSIX setup:
    • ↑ This is strictly SUSv4-compliant. Most Unix machines all over the world are set up like this.
    • ↑ This is compatible with ntpd.
    • → You should use posix/ time zones in that case, not right/ time zones.
    • ↓ skalibs time computations will take a bit more processing power.
    • ↓ Most importantly, you forsake all linearity - and even monotonicity - on your system clock, which can now only be used as a wall clock, not as a stopwatch. skalibs will try its best to do accurate time computations, but there's no way gettimeofday() can be relied on when a leap second is nearby; you have to use CLOCK_MONOTONIC as a stopwatch for accurate interval measurement.

Use --enable-tai-clock if your system clock is set to TAI-10. I generally recommend this setup for computers you have full control on, on which you install and tweak the software your way, like manually administered servers or embedded boxes. If you do not run ntpd and do not mind breaking POSIX, it is the sensible choice.

Do not use this option if your system clock is set to UTC, i.e. if you're in none of the above cases: you are a POSIX freak, or your Unix distribution is running ntpd for you, or other software is assuming you're on UTC. This is the default.

--disable-ipv6

If you set this option, then skalibs will be compiled without IPv6 support, even if your target architecture supports it. This can significantly reduce the size of your networking applications if they don't need IPv6 support.

If you don't set this option, then skalibs will include IPv6 support in the relevant networking functions if and only if the target architecture supports it. This is the default, and it is safe.

--with-default-path=path

The execvep() function uses the value of the PATH environment variable as its executable search path. Specifying this option to configure tells execvep() what executable search path to use when PATH is undefined (which should not happen often anyway). The default is /usr/bin:/bin, which is usually safe.

--with-sysdep-devurandom=yes

When compiling natively, skalibs probes the build system for sysdeps, i.e. system-specific behaviours that influence the way skalibs must implement certain interfaces. This autodetection can be overriden on the configure command line: for a sysdep named K, if you want to enforce the value V, you can use --with-sysdep-K=V as a configure option.

(This is similar to the ac_cv_foobar_K=V environment variable mechanism in autotools.)

When cross-compiling, there are a few sysdeps that cannot be autodetected and have to be provided manually on the command line. The devurandom sysdep, which encodes the existence of a functional /dev/urandom device on the target, is one of those. --with-sysdep-devurandom=yes tells skalibs to assume that there is such a device it can rely on for random number generation.

skalibs-2.14.1.1/doc/index.html000066400000000000000000000102701455624754300161470ustar00rootroot00000000000000 skalibs: a C library for system programming

Software
skarnet.org

skalibs

What is it ?

skalibs is a package centralizing the free software / open source C development files used for building all software at skarnet.org: it contains essentially general-purpose libraries. You will need to install skalibs if you plan to build skarnet.org software. The point is that you won't have to download and compile big libraries, and care about portability issues, everytime you need to build a package: do it only once.

skalibs can also be used as a sound basic start for C development. There are a lot of general-purpose libraries out there; but if your main goal is to produce small and secure C code with a focus on system programming, skalibs might be for you.


Installation

Requirements

Licensing

skalibs is free software. It is available under the ISC license.

Download

  • The current released version of skalibs is 2.14.1.1.
  • Alternatively, you can checkout a copy of the skalibs git repository:
     git clone git://git.skarnet.org/skalibs 
  • There's also a GitHub mirror of the skalibs git repository.

Compilation

  • See the enclosed INSTALL file for installation details.
  • skalibs sports a few uncommon options to its ./configure script. This page documents them in detail.

Upgrade notes

  • This page lists the differences to be aware of between the previous versions of skalibs and the current one.

Cross-compilation

Cross-compilation is tricky. skalibs provides system-agnostic interfaces, so all the other skarnet.org packages cross-compile easily; but some effort needs to be made to cross-compile skalibs, see this page.


Reference

Libraries


Similar work

Here are a few other libraries originating from the same place as skalibs, i.e. people start to reuse and package, or rewrite, code from Dan J. Bernstein, and then patch after patch, addition after addition, the code evolves into a project of its own:

Related resources

  • skalibs is discussed on the skaware mailing-list.
skalibs-2.14.1.1/doc/libdatastruct/000077500000000000000000000000001455624754300170175ustar00rootroot00000000000000skalibs-2.14.1.1/doc/libdatastruct/genqdyn.html000066400000000000000000000105021455624754300213500ustar00rootroot00000000000000 skalibs: the genqdyn library interface

libdatastruct
libskarnet
skalibs
Software
skarnet.org

The genqdyn library interface

The following functions are declared in the skalibs/genqdyn.h header, and implemented in the libskarnet.a or libskarnet.so library.

General information

genqdyn is a set of functions implementing simple queues on generic objects. The dyn prefix means the queues are dynamically allocated (and live in heap memory): it is possible to enqueue an arbitrary number of objects, up to the available memory.

Data structures

A genqdyn structure holds the information necessary to implement a queue. It can be declared anywhere (including in the stack). All genqdyn functions take a pointer to this structure as an argument.

Macros

genqdyn GENQDYN_INIT(type, num, den)
Returns an anonymous genqdyn structure suitable for holding objects of type type. The num and den arguments are integers, used to tune the amount of memory needed / management overhead balance. num/den must be a fractional value between 0 and 1. The closer to 0, the longer genqdyn will wait before performing a cleanup (and the more memory it can consume). At 0, genqdyn can only recycle memory when the queue becomes totally empty. The closer to 1, the more genqdyn optimizes its memory usage (and the more often it performs maintenance on its queue). At 1, it performs maintenance every time an object is popped. Anything between 1/4 and 3/4 is a reasonable value for num/den.

size_t genqdyn_n (genqdyn *g)
Returns the number of elements in the genqdyn *g, which must have been initialized.

void *genqdyn_peek (genqdyn *g)
Peeks at the next object in the queue, i.e. the object that has been pushed the earliest and that hasn't been popped yet. You can use the GENQDYN_PEEK(type, g) macro to get a type * pointer instead of a void * one.

Functions

void genqdyn_init (genqdyn *g, size_t esize, unsigned int num, unsigned int den)
Initializes the genqdyn *g to hold objects of size esize. g must be unused, or have been freed. The num and den arguments tune g's behaviour as described above in the GENQDYN_INIT description. This function is similar to the GENQDYN_INIT macro, except that it can be used dynamically and works on a pre-declared genqdyn, whereas the macro can only be used as a static initializer.

void genqdyn_free (genqdyn *g)
Frees the resources used by *g, which is then considered uninitialized.

int genqdyn_push (genqdyn *g, void const *p)
Pushes the object pointed to by p onto the queue. This object must have the same size that has been given to the genqdyn_init() invocation, or be of the same type that has been given to the GENQDYN_INIT() invocation. The function returns 1 if it succeeds and 0 (and sets errno) if it fails.

int genqdyn_unpush (genqdyn *g)
Undoes the last push. Returns 1, except if the queue is empty, in which case it returns 0 and sets errno to EINVAL.

int genqdyn_pop (genqdyn *g)
Pops an object from the queue, and possibly performs maintenance to reuse some memory. Returns 1, unless the queue is empty, in which case it returns 0 and sets errno to EINVAL.

skalibs-2.14.1.1/doc/libdatastruct/index.html000066400000000000000000000027721455624754300210240ustar00rootroot00000000000000 skalibs: the datastruct library interface

libskarnet
skalibs
Software
skarnet.org

The datastruct library interface

libdatastruct implements generic data structures like chained lists and AVL trees, in a memory-efficient and CPU-efficient way.

Compiling

  • Use #include <skalibs/datastruct.h>
  • You can also use the lower-level headers included by skalibs/datastruct.h instead.

Programming

skalibs/datastruct.h is a collection of several headers, each one defining a specific data structure and providing functions to work on it.

  • skalibs/genqdyn.h: dynamically allocated queues for generic objects
  • FIXME: To be completed
skalibs-2.14.1.1/doc/libposixplz/000077500000000000000000000000001455624754300165315ustar00rootroot00000000000000skalibs-2.14.1.1/doc/libposixplz/index.html000066400000000000000000000021601455624754300205250ustar00rootroot00000000000000 skalibs: the posixplz library interface

libskarnet
skalibs
Software
www.skarnet.org

The posixplz library interface

libposixplz is a thin layer of APIs addressing deficencies in POSIX itself.

Compiling

  • The libposixplz functions are available under the skalibs/posixplz.h header.

Programming

  • TODO: describe the functions.
skalibs-2.14.1.1/doc/librandom/000077500000000000000000000000001455624754300161215ustar00rootroot00000000000000skalibs-2.14.1.1/doc/librandom/index.html000066400000000000000000000075471455624754300201330ustar00rootroot00000000000000 skalibs: the random library interface

libskarnet
skalibs
Software
skarnet.org

The random library interface

librandom is a small library designed to provide an interface to some reasonable-quality pseudorandom number generation. librandom uses arc4random when available, or getrandom - else it defaults to /dev/urandom and a a SURF PRNG.

Compiling

  • Use #include <skalibs/random.h>

Programming

You should refer to the skalibs/random.h header for the exact function prototypes.

Basic functions

  unsigned char c ;
  uint32_t max ;
  uint32_t n ;
  size_t b ;
  char data[at least b] ;
  int r ;

  r = random_init() ;
  c = random_char() ;
  n = random_uint32(max) ;
  random_string(data, b) ;
  random_finish() ;

random_init() must be called before any other function in the random library. It returns 0 (and sets errno) on failure, and nonzero on success.

It is recommended that you let the library perform cleanups after you are done using it, by calling random_finish() - unless your process exits right away.

  • random_char() returns a random character.
  • random_uint32(max) returns a random integer between 0 and max-1.
  • random_string(data, b) fills b bytes in data (which must be preallocated) with random data.

Advanced functions

void random_unsort (char *s, unsigned int n, unsigned int chunksize)
Shuffles the array s (of size at least n*chunksize) by performing a random permutation of the n blocks of chunksize bytes. Bytes are not permuted inside chunks.

void random_name (char *s, size_t n)
Writes n random readable ASCII characters into s: letters, numbers, hyphens or underscores. Does not terminate with a null character.

int random_sauniquename (stralloc *sa, unsigned int n)
Appends a (non-null-terminated) unique, unpredictable ASCII name to the stralloc *sa. That name includes n randomly generated ASCII characters.

Notes

  • The random library is a thin wrapper around the best available random generator provided by the underlying system. By decreasing order of preference, it will use the following implementations if available:
  • The random_init() function tries to automatically add some reasonably random data to the underlying random generator's entropy pool. However, that pseudorandom data is not 100% unpredictable, so it will not replace proper seeding of the random generator at boot time.
skalibs-2.14.1.1/doc/libskarnet.html000066400000000000000000000112651455624754300172030ustar00rootroot00000000000000 skalibs: the skarnet library interface

skalibs
Software
skarnet.org

The skarnet library interface

libskarnet is the library exported by skalibs; both a static library and a shared library (if they are supported on your system) are available. Every skarnet.org binary needs this library.

Compiling

  • Make sure the place you installed the skalibs header files in is in your header directory list; the default is /usr/include, which is normally browsed by default by your C preprocessor.
  • Use #include <skalibs/foobar.h> where foobar.h is the header you need.
    • The skalibs/skalibs.h header is the general entry point that will declare the near-entirety of the functions, variables and constants in skalibs. Including this header in your source files whenever you need a skalibs function will work; however, it is rather heavy, and you might want to include lower-level headers instead to reduce compilation time.

Linking

  • For static linking: add /usr/lib/skalibs, or wherever you installed your .a files, to your library directory list.
  • For dynamic linking: make sure the place you installed the libskarnet.so shared library in is in your shared library directory list; the default is /lib, which is normally browsed by default by your build-time and run-time linker. If you are using another place than the default (for instance, if you are using the slashpackage convention), make sure to edit your ld.so.conf file so your linker can find this place, and to run ldconfig if needed.
  • Take note of the place where your sysdeps directory has been installed: by default, it's /usr/lib/skalibs/sysdeps. Let's call it $sysdeps.
  • Link with -lskarnet. If you are using socket functions, you will also need to link with `cat $sysdeps/socket.lib`. If you are using time functions such as tain_now(), you will also need to link with `cat $sysdeps/sysclock.lib`. Also `cat $sysdeps/spawn.lib`` for posix_spawn() functions, timer.lib for timer_create functions, and so on. This is, unfortunately, the only way to work with all the idiosyncrasies and whimsies of various libcs; only musl does the sensible thing and exports all its functions from libc.a and libc.so, without requiring any additional linker command line flags.

The skarnet library as a whole is big (945k for libskarnet.a and 179k for libskarnet.so.2.4.0.0 on x86_64-linux), but the utmost care has been given to separate functions so that linkers never pull in any more than they need. Linking against the static version of libskarnet actually produces very small executables, and if your libc is suited for that, since skalibs only uses very basic libc interfaces, it is very possible to produce small static binaries - in many cases, a static program written with skalibs APIs will be an order of magnitude smaller than the equivalent program written using libc's or other utility libraries' APIs.

Programming

The skalibs source code is divided into several subdirectories, each containing a logical unit of code implementing independent functions.

  • libposixplz: workarounds for some POSIX deficiencies and for systems that don't quite implement POSIX
  • libstddjb: basic C API for system programming
  • libdatastruct: efficient C implementation of basic data structures like sets or trees
  • libstdcrypto: a few crypto primitives
  • librandom: cryptographically secure random or pseudorandom number generation
  • libunixonacid: more advanced C/Unix APIs, mainly for safe asynchronous interprocess communication
skalibs-2.14.1.1/doc/libstdcrypto/000077500000000000000000000000001455624754300166745ustar00rootroot00000000000000skalibs-2.14.1.1/doc/libstdcrypto/index.html000066400000000000000000000077061455624754300207030ustar00rootroot00000000000000 skalibs: the stdcrypto library interface

libskarnet
skalibs
Software
skarnet.org

The stdcrypto library interface

stdcrypto is a small collection of standard, public-domain cryptographic primitives. Currently, the following operations are provided:

  • rc4
  • md5
  • sha1
  • sha256
  • sha512

Please bear in mind that rc4 and md5 are broken, and that sha1 is about to be. Do not use them in security-critical applications.

Compiling

  • Use #include <skalibs/stdcrypto.h>

Programming

You should refer to the skalibs/stdcrypto.h header and included headers for the exact function prototypes.

RC4

  RC4Schedule ctx ;
  unsigned char const *key ;
  size_t keylen ;
  unsigned char const *in ;
  unsigned char *out ;
  size_t len ;

  rc4_init(&ctx, key, keylen) ;
  rc4(&ctx, in, out, len) ;
  • rc4_init() initializes a RC4Schedule structure with a key key, of length keylen. It then computes and throws away the first RC4_THROWAWAY bytes, usually 100
  • rc4() encrypts len bytes of in with the RC4 flow, and stores the results into out

MD5

  MD5Schedule ctx ;
  char const *message ;
  size_t messagelen ;
  char digest[16] ;

  md5_init(&ctx) ;
  md5_update(&ctx, message, messagelen) ;
  md5_final(&ctx, digest) ;
  • md5_init() prepares a MD5Schedule structure for computation
  • md5_update() adds message to the message to be digested
  • md5_final() computes the digest

SHA1

  SHA1Schedule ctx ;
  char const *message ;
  size_t messagelen ;
  unsigned char digest[20] ;

  sha1_init(&ctx) ;
  sha1_update(&ctx, message, messagelen) ;
  sha1_final(&ctx, digest) ;
  • sha1_init() prepares a SHA1Schedule structure for computation
  • sha1_update() adds message to the message to be digested
  • sha1_final() computes the digest

SHA256

  SHA256Schedule ctx ;
  char const *message ;
  size_t messagelen ;
  char digest[32] ;

  sha256_init(&ctx) ;
  sha256_update(&ctx, message, messagelen) ;
  sha256_final(&ctx, digest) ;
  • sha256_init() prepares a SHA256Schedule structure for computation
  • sha256_update() adds message to the message to be digested
  • sha256_final() computes the digest

SHA512

  SHA512Schedule ctx ;
  char const *message ;
  size_t messagelen ;
  char digest[64] ;

  sha512_init(&ctx) ;
  sha512_update(&ctx, message, messagelen) ;
  sha512_final(&ctx, digest) ;
  • sha512_init() prepares a SHA512Schedule structure for computation
  • sha512_update() adds message to the message to be digested
  • sha512_final() computes the digest
skalibs-2.14.1.1/doc/libstddjb/000077500000000000000000000000001455624754300161135ustar00rootroot00000000000000skalibs-2.14.1.1/doc/libstddjb/alarm.html000066400000000000000000000066021455624754300201010ustar00rootroot00000000000000 skalibs: the alarm library interface

libstddjb
libskarnet
skalibs
Software
skarnet.org

The alarm library interface

The following functions are declared in the skalibs/alarm.h header, and implemented in the libskarnet.a or libskarnet.so library.

General information

alarm is a set of primitives to provide the same functionality as alarm(), but with sub-second precision.

Depending on the functionality the underlying system provides, the precision can be 1 nanosecond (implementation via timer_settime(), 1 microsecond (implementation via setitimer(), or 1 second (fallback implementation with alarm() when nothing better can be found).

Functions

int alarm_milliseconds (unsigned int n)
Sets a fuse that will raise a SIGALRM after n milliseconds. If n is 0, the SIGALRM will be raised instantly. Returns 1 on success and 0 (and sets errno) on failure.

int alarm_timeout (tain const *tto)
Sets a fuse that will raise a SIGALRM after some amount of time has passed. The amount of time is described in *tto, which is a relative tain, i.e. a structure containing a relative TAIN64 time. Returns 1 on success and 0 (and sets errno) on failure.

int alarm_deadline (tain const *deadline)
Sets a fuse that will raise a SIGALRM when the clock reaches *deadline, which is an absolute time expressed in TAI64N format. Returns 1 on success and 0 (and sets errno) on failure.

void alarm_disable (void)
Cancels a previously set fuse. No SIGALRM will be raised.

Notes

  • Asynchronous programming via signals is bad. The best way to handle situations where something happens after some time has elapsed is to use an asynchronous loop primitive such as iopause(). The problem is that some external libraries only provide synchronous functions (including functions talking to the network!) with no obvious way to set a timeout. The alarm_* set of functions is meant to work around that, with hopefully better granularity than the POSIX alarm() function.
skalibs-2.14.1.1/doc/libstddjb/alloc.html000066400000000000000000000074301455624754300200770ustar00rootroot00000000000000 skalibs: the alloc library interface

libstddjb
libskarnet
skalibs
Software
skarnet.org

The alloc library interface

The following functions are declared in the skalibs/alloc.h header, and implemented in the libskarnet.a or libskarnet.so library.

General information

alloc is the skalibs heap memory manager. It's actually a wrapper for the malloc() series of functions; it unifies a few system-dependent malloc behaviours. It's also the API to implement and preload if for some reason you need to plug in your own allocator: replacing alloc() is much easier than replacing malloc() safely.

As a general rule, you should not be using the alloc interface directly. Allocating and freeing individual cells in the heap is a recipe for heap fragmentation, as well as cell tracking nightmares leading to memory leaks. You should use the higher-level stralloc and genalloc interfaces to handle dynamic arrays of objects.

C's lack of automatic management of heap memory is not a drawback: it's a feature of the language. It allows for code that is one or two orders of magnitude faster than the equivalent in a higher-level language, and very low on resources consumption. However, it requires more attention from the programmer. Good APIs can significantly reduce the difficulty of keeping track of every heap-allocated cell, and every smart programmer should favor them over basic interfaces like malloc().

alloc is used internally by skalibs to implement stralloc, and nowhere else.

Functions

void *alloc (size_t len)
Allocates a block of len bytes in the heap and returns a pointer to the start of the block (or NULL if it failed). If len is 0, the function returns a unique pointer that cannot be written to, but that is not null. Note that this is different from the required C99 behaviour for malloc().

void alloc_free (void *p)
Frees the block of heap memory pointed to by p.

int alloc_realloc (char **p, size_t newlen)
Redimension the block of heap memory pointed to by *p to newlen bytes. The block may have to be moved, in which case *p will be modified. Normally returns 1; if an error occurred, returns 0 and sets errno, and neither *p nor its contents are modified. Note that p must be a pointer to a char *, because polymorphism isn't possible here (for reasons that have to do with pointer representation in C).

int alloc_re (char **p, size_t oldlen, size_t newlen)
Legacy interface for reallocation. It works like alloc_realloc, except that the original block length must be provided as the oldlen argument.

skalibs-2.14.1.1/doc/libstddjb/allreadwrite.html000066400000000000000000000165711455624754300214720ustar00rootroot00000000000000 skalibs: the allreadwrite library interface

libstddjb
libskarnet
skalibs
Software
skarnet.org

The allreadwrite library interface

The following functions are declared in the skalibs/allreadwrite.h header, and implemented in the libskarnet.a or libskarnet.so library.

General information

allreadwrite is a set of IO function helpers. It's the basis for safe reading and writing, either in blocking or in non-blocking mode. The buffer interface relies heavily on allreadwrite.

Unless the IO you need is very simple, you generally should not be using the allreadwrite functions directly; you should use higher-level APIs such as buffer and bufalloc.

Function types

typedef ssize_t io_func (int fd, char *buf, size_t len)
This is the simplified type of IO functions such as read() and write().

typedef ssize_t iov_func (int fd, struct iovec const *v, unsigned int vlen)
This is the simplified type of IO functions such as readv() and writev(), where the content to perform IO on is specified as a scatter/gather array of vlen elements instead of a single string.

typedef size_t allio_func (int fd, char *buf, size_t len)
This is the type of an IO operation that expects all of its len bytes to be sent or received, and that will loop around a lower-level IO function until either len bytes have been transmitted or an error has occurred. The return value is the actual number of transmitted bytes; if this value is lesser than len, it means that an error has occurred and errno is set.

Functions

ssize_t sanitize_read (ssize_t r)
Reading functions such as read() and fd_read return a positive number when they succeed, -1 when they fail, and 0 when they read an EOF. No data available on the descriptor when reading in non-blocking mode is treated as a failure: -1 EWOULDBLOCK. But sometimes (namely, in asynchronous IO loops) it's preferrable to handle EOF as an exception condition and EWOULDBLOCK as a normal condition. sanitize_read(), when applied to the result of a basic reading function, returns 0 if r is -1 and errno is EWOULDBLOCK (or EAGAIN). If r is zero, it returns -1 EPIPE. Else it returns r.

(No system reading function can ever set errno to EPIPE, and the semantics are appropriate, so EPIPE is a good candidate to signal EOF on reading.)

ssize_t unsanitize_read (ssize_t r)
Returns the inverse of sanitize_read.

size_t allreadwrite (io_func *f, int fd, char *s, size_t len)
*f must be a basic reading or writing function such as fd_read or fd_write. allreadwrite() performs *f on fd, s and len until len bytes have been read or written, or until an error occurs. It returns the total number of handled bytes, and sets errno if this number is not len. allreadwrite may block if fd is in blocking mode; if fd is in non-blocking mode, it might set errno to EWOULDBLOCK or EAGAIN.

size_t allreadwritev (iov_func *f, int fd, struct iovec const *v, unsigned int vlen)
Like allreadwrite but the content to perform IO on is specified as a scatter/gather array of vlen elements instead of a single string.

ssize_t fd_read (int fd, char *s, size_t len)
Safe wrapper around the read() function.

ssize_t fd_write (int fd, char const *s, size_t len)
Safe wrapper around the write() function.

ssize_t fd_readv (int fd, struct iovec const *v, unsigned int vlen)
Safe wrapper around the readv() function.

ssize_t fd_writev (int fd, struct iovec const *v, unsigned int vlen)
Safe wrapper around the writev() function.

ssize_t fd_recv (int fd, char *s, size_t len, unsigned int flags)
Safe wrapper around the recv() function.

ssize_t fd_send (int fd, char const *s, size_t len, unsigned int flags)
Safe wrapper around the send() function.

size_t allread (int fd, char *s, size_t len)
Equivalent to allreadwrite(&fd_read, fd, s, len) : attempts to read len bytes from fd into s, looping around fd_read() if necessary, until either len bytes are read or an error occurs.

size_t allwrite (int fd, char const *s, size_t len)
Equivalent to allreadwrite((io_func *)&fd_write, fd, s, len) : attempts to write len bytes from s to fd, looping around fd_write() if necessary, until either len bytes are written or an error occurs.

size_t allreadv (int fd, struct iovec *v, unsigned int vlen)
Like allread, but the bytes from fd are read into a scatter/gather array of vlen elements instead of a single string.

size_t allwritev (int fd, struct iovec const *v, unsigned int vlen)
Like allwrite, but the content to write is taken from a scatter/gather array of vlen elements instead of a single string.

skalibs-2.14.1.1/doc/libstddjb/bitarray.html000066400000000000000000000120311455624754300206130ustar00rootroot00000000000000 skalibs: the bitarray library interface

libstddjb
libskarnet
skalibs
Software
skarnet.org

The bitarray library interface

The following functions are declared in the skalibs/bitarray.h header, and implemented in the libskarnet.a or libskarnet.so library.

General information

bitarray is a set of primitives to operate efficiently on large bitfields.

A bitfield is represented by a pre-allocated block of unsigned char; bitarray does not care if that block has been BSS-, stack- or heap-allocated. Bitfields that can grow in size should be stored in a stralloc.

Bits in a bitfield of length n are numbered from 0 to n-1.

Functions

size_t bitarray_div8 (size_t n)
Returns the minimum number of bytes needed to store a field of n bits.

void bitarray_clearsetn (unsigned char *s, size_t start, size_t len, int h)
Sets (if h is nonzero) or clears (if h is zero) len bits in field s, starting at bit start.

void bitarray_clearn (unsigned char *s, size_t start, size_t len)
Clears len bits in field s, starting at bit start.

void bitarray_setn (unsigned char *s, size_t start, size_t len)
Sets len bits in field s, starting at bit start.

int bitarray_peek (unsigned char const *s, size_t n)
Returns the value of the nth bit in field s.

void bitarray_poke (unsigned char *s, size_t n, int h)
Sets (if h is nonzero) or clears (if h is zero) the nth bit in field s.

void bitarray_clear (unsigned char *s, size_t n)
Clears the nth bit in field s.

void bitarray_set (unsigned char *s, size_t n)
Sets the nth bit in field s.

int bitarray_testandpoke (unsigned char *s, size_t n, int h)
Sets (if h is nonzero) or clears (if h is zero) the nth bit in field s, and returns the previous value of that bit.

int bitarray_testandclear (unsigned char *s, size_t n)
Clear the nth bit in field s, and returns the previous value of that bit.

int bitarray_testandset (unsigned char *s, size_t n)
Sets the nth bit in field s, and returns the previous value of that bit.

size_t bitarray_first (unsigned char const *s, size_t len, int h)
Returns the number of the first set (if h is nonzero) or clear (if h is zero) bit in s, len being the total number of bits. If all bits in s are the negation of h, then len is returned.

size_t bitarray_firstclear (unsigned char const *s, size_t len)
Returns the number of the first clear bit in s, len being the total number of bits. If all bits in s are set, len is returned.

size_t bitarray_firstclear_skip (unsigned char const *s, size_t len, size_t skip)
Like bitarray_firstclear, but the first skip bits are ignored: the function cannot return less than skip. It is a programming error if skip > len.

size_t bitarray_firstset (unsigned char const *s, size_t len)
Returns the number of the first set bit in s, len being the total number of bits. If all bits in s are clear, len is returned.

size_t bitarray_firstset_skip (unsigned char const *s, size_t len, size_t skip)
Like bitarray_firstset, but the first skip bits are ignored: the function cannot return less than skip. It is a programming error if skip > len.

size_t bitarray_countones (unsigned char const *s, size_t len)
Returns the number of set bits in s, len being the total number of bits being tested.

skalibs-2.14.1.1/doc/libstddjb/bufalloc.html000066400000000000000000000015751455624754300206000ustar00rootroot00000000000000 skalibs: the bufalloc header

libstddjb
libskarnet
skalibs
Software
skarnet.org

The skalibs/bufalloc.h header

TODO: write this documentation page. (Sorry!)

skalibs-2.14.1.1/doc/libstddjb/buffer.html000066400000000000000000000015601455624754300202540ustar00rootroot00000000000000 skalibs: the buffer header

libstddjb
libskarnet
skalibs
Software
skarnet.org

The skalibs/buffer.h header

TODO: write this documentation page. (Sorry!)

skalibs-2.14.1.1/doc/libstddjb/bytestr.html000066400000000000000000000204121455624754300204740ustar00rootroot00000000000000 skalibs: the bytestr header

libstddjb
libskarnet
skalibs
Software
skarnet.org

The skalibs/bytestr.h header

The following functions are declared in the skalibs/bytestr.h header and implemented in the libskarnet.a or libskarnet.so library.

Purpose

These functions handle arrays of bytes (strings). They are similar to their counterparts from the standard string.h header, but they return indices instead of pointers.

byte_* functions and macros work with strings that are not necessarily null-terminated, but require sizes of the strings to be passed. On the contary, str_* family accepts null-terminated strings. case_* functions and macros are like their str_* counterparts, but are case-insensitive.

Functions

size_t byte_chr (char const *s, size_t n, int c)
Looks for the first occurrence of byte c in array s of size n. Returns its index, or n if there is no such byte in s.

size_t byte_rchr (char const *s, size_t n, int c)
Looks for the last occurrence of byte c in array s of size n. Returns its index, or n if there is no such byte in s.

size_t byte_in (char const *s, size_t n, char const *sep, size_t len)
Looks for the first occurrence of any byte from array sep of size len in array s of size n. Returns the index of such an occurrence, or n if there are no bytes from sep in s.

size_t byte_count (char const *s, size_t len, char b)
Returns the amount of occurrences of byte b in string s of size len.

size_t byte_search (char const *haystack, size_t hlen, char const *needle, size_t nlen)
Looks for the first occurrence of string needle of size nlen in string haystack of size hlen. Returns the index of the first byte of that occurrence, or hlen + 1 - nlen if needle cannot be found in haystack.

void byte_zzero (char *s, size_t n)
Zeroes n bytes of memory beginning with address s. Special measures are taken to prevent the compiler from optimizing out the call:

  • If the explicit_bzero function is present on the system, it is used. Calls to this function are guaranteed not to be removed by the compiler.
  • Otherwise, byte_zzero performs a normal memset followed by a special no-op function with a weak alias in order to trick the compiler.
This is useful for erasing sensitive data before returning from some function, typically in cryptography settings. Compilers usually remove memset calls since these have no observable effect for the rest of the code.

size_t str_chr (char const *s, int c)
Looks for the first occurrence of byte c in null-terminated string s. Returns the index of this occurrence, or the length of the string if there is no such byte in s.

size_t str_rchr (char const *s, int c)
Looks for the last occurrence of byte c in null-terminated string s. Returns the index of this occurrence, or the length of the string if there is no such byte in s.

int str_start (char const *s, char const *t)
Returns 1 if (null-terminated) string s begins with (null-terminated) string t, and 0 otherwise.

size_t str_strn (char const *haystack, size_t hlen, char const *needle, size_t nlen)
Looks for the first occurrence of string needle of size nlen in string haystack of size hlen. Returns the index of the first character in this occurrence, or hlen if needle is not present in haystack.

void case_lowers (char *s)
Turns all capital letters in null-terminated string s into lowercase letters. This function only works with ASCII symbols.

void case_lowerb (char *s, size_t len)
Turns all capital letters in string s of size len into lowercase letters. This function only works with ASCII symbols.

void case_uppers (char *s)
Turns all lowercase letters in null-terminated string s into capital letters. This function only works with ASCII symbols.

void case_upperb (char *s, size_t len)
Turns all lowercase letters in string s of size len into capital letters. This function only works with ASCII symbols.

int case_startb (char const *s, size_t slen, char const *t)
Returns 1 if string s of size slen begins with null-terminated string t, ignoring case, and 0 otherwise.

size_t case_str (char const *haystack, char const *needle)
Looks for the first occurrence of null-terminated string needle in null-terminated string haystack, ignoring case while comparing bytes. Returns the index of the first byte of this occurrence or the length of haystack if needle is not presented in haystack.

Macros

These macros are either wrappers around functions described above or C standard library functions. They only exist for compatibility purposes. Programmers are expected to use the standard functions directly: in the rare case where a standard function interface is good, it is best to use it.

byte_copy(to, n, from)
byte_copyr(to, n, from)
Same as memmove(to, from, n).

byte_diff(a, n, b)
Same as memcmp(a, b, n).

byte_zero(p, n)
Same as memset(p, 0 ,n). There is a caveat in zeroing memory range with memset — compiler may omit the call to memset if it is called in the end of function. If you need to destroy sensitive data, use byte_zzero instead.

str_len(s)
Same as strlen(s).

str_nlen(s)
Same as strnlen(s).

str_diff(s1, s2)
Same as strcmp(s1, s2).

str_diffn(s1, s2, n)
Same as strncmp(s1, s2, n).

str_copy(to, from)
Copies null-terminated string from, including null terminator, to buffer to. Returns the length of the string.

case_diffs(s1, s2)
Same as strcasecmp(s1, s2).

case_diffn(s1, s2, n)
Same as strcasecmp(s1, s2, n).

byte_equal(s, n, t)
Same as !memcmp(s, t, n).

str_diffb(a, n, b)
Same as strncmp(a, b, n).

str_equal(s, t)
Same as !strcmp(s, t).

case_diffb(a, n, b)
Same as strncasecmp(a, b, n).

case_equals(a, b)
Same as !strcasecmp(a, b).

case_equalb(a, n, b)
Same as !strncasecmp(a, b, n).

case_starts(s, t)
Same as case_startb(s, strlen(s), t).

skalibs-2.14.1.1/doc/libstddjb/cdb.html000066400000000000000000000125761455624754300175440ustar00rootroot00000000000000 skalibs: the cdb header

libstddjb
libskarnet
skalibs
Software
skarnet.org

The skalibs/cdb.h header

General information

A cdb, for constant database, is an immutable key-value store. In skalibs, a cdb is built once via the cdbmake primitives and stored on disk; the cdb primitives, documented here, are about accessing the information.

Data structures

  • A cdb is an opaque structure, that must be initialized to CDB_ZERO when declared.
  • A cdb_data is a structure that is passed by address to cdb-reading primitives, which fill it with record information. It contains (at least) two fields:
    • s, a char const *, which holds a pointer to the record; the const indicates that a cdb is read-only, you cannot write to the record even when you have a pointer to it.
    • len, a uint32_t, which holds the record length. It can be zero (records can be empty). A cdb must fit into 4 GB, so record lengths always fit in 32 bits.
    Pointers returned in a cdb_data are only valid while the cdb is mapped. Make sure to copy the information before calling cdb_free().
  • A cdb_find_state is an opaque structure, that should be initialized to CDB_FIND_STATE_ZERO when declared. It is passed by address to cdb_findnext, to maintain position state when looking for all the data records under one key.

Macros and functions

Starting and ending

int cdb_init (cdb *c, char const *file)
Maps the file named file to the cdb pointed to by c. *c must be CDB_ZERO before the call. The function returns a positive integer if it succeeds, and 0 (and sets errno) if it fails.

int cdb_init_at (cdb *c, int dfd, char const *file)
Like cdb_init, but file is interpreted relative to the file descriptor dfd, which must be open on a directory.

int cdb_init_fromfd (cdb *c, int fd)
Like cdb_init, but the database file is already open and readable via then file descriptor fd.

void cdb_free (cdb *c)
Frees the resources used by a cdb mapping. After the call, c is immediately reusable by another cdb_init function.

cdb lookup

Single record lookup

int cdb_find (cdb const *c, cdb_data *data, char const *key, uint32_t klen)
Looks up key key of length klen in the cdb *c. The function returns -1 if *c isn't a valid cdb; 0 if no record can be found for the key; and 1 on success, in which case the corresponding value is returned in *data: data→s points to the start of the value, and data→len contains the length of the value. Only the first record with the same key can be obtained this way.

Multiple record lookup

void cdb_findstart (cdb_find_state *state)
Initializes state so that the next invocation of cdb_findnext() finds the first record for a given key.

int cdb_findnext (cdb const *c, cdb_data *data, char const *key, uint32_t klen, cdb_find_state *state)
Like cdb_find, except that the extra argument state memorizes internal cdb lookup data, so the next cdb_findnext() invocation with the same key, klen and state will yield the next record for the key. cdb_findnext returns 0 when all the records for the key have been exhausted.

cdb enumeration

void cdb_traverse_init (uint32_t *pos)
Initializes *pos so that the next invocation of cdb_traverse_next finds the first entry in the cdb. *pos can also be initialized to the macro CDB_TRAVERSE_INIT() instead.

int cdb_traverse_next (cdb const *c, cdb_data *key, cdb_data *data, uint32_t *pos)
Gets the next entry in the cdb *c. On success, the key is stored in *key and the data is stored in *data. *pos* is an opaque integer storing internal state; it is automatically updated so that the next invocation of cdb_traverse_next() yields the next entry. The function returns -1 if *c is not a valid cdb or *pos is not valid state, 1 on success, and 0 if no entry can be found, i.e. the end of the cdb has been reached.

skalibs-2.14.1.1/doc/libstddjb/cdbmake.html000066400000000000000000000016161455624754300203730ustar00rootroot00000000000000 skalibs: the cdbmake header

libstddjb
libskarnet
skalibs
Software
skarnet.org

The skalibs/cdbmake.h header

TODO: write this documentation page. (Sorry!)

skalibs-2.14.1.1/doc/libstddjb/cspawn.html000066400000000000000000000152261455624754300203020ustar00rootroot00000000000000 skalibs: the cspawn library interface

libstddjb
libskarnet
skalibs
Software
skarnet.org

The cspawn library interface

The following functions are declared in the skalibs/cspawn.h header, and implemented in the libskarnet.a or libskarnet.so library.

General information

cspawn is a unifier API to spawn child processes with posix_spawn() as a backend if supported by the system, falling back on fork() + execve() otherwise.

Functions

Primitive

pid_t cspawn (char const *file, char const *const *argv, char const *const *envp, uint32_t flags, cspawn_fileaction const *fa, size_t n)
Forks and execs a child as with exec_ae(file, argv, envp). Returns 0 if it fails, and the pid of the child if it succeeds. Before execing, the following operations are performed in the child:

  • If flags contains (the or-able value) CSPAWN_FLAGS_SIGBLOCKNONE, the child's signal processing mask is reset - no signal will be blocked.
  • Alternatively, if flags contains (the or-able value) CSPAWN_FLAGS_SELFPIPE_FINISH, the child's signal state is reset to what it was before the invocation of selfpipe_init() in the parent.
  • The file actions described in the array fa, which must have at least n elements, are processed in order. For every i from 0 to n-1:
    • if fa[i].type is CSPAWN_FA_CLOSE, then file descriptor fa[i].x.fd is closed
    • else if fa[i].type is CSPAWN_FA_MOVE, then file descriptor fa[i].x.fd2[1] is moved to fa[i].x.fd2[0]
    • else if fa[i].type is CSPAWN_FA_COPY, then file descriptor fa[i].x.fd2[1] is copied to fa[i].x.fd2[0], as with dup2(fa[i].x.fd2[1], fa[i].x.fd2[0])
    • else if fa[i].type is CSPAWN_FA_OPEN, then file fa[i].x.openinfo.file is opened with flags fa[i].x.openinfo.oflag and mode fa[i].x.openinfo.mode, and file descriptor fa[i].x.openinfo.fd points to it.

Higher level interfaces

pid_t child_spawn1_pipe (char const *file, char const *const *argv, char const *const *envp, int *fd, int w)
Spawns file as with cspawn() with a flags value of CSPAWN_FLAGS_SIGBLOCKNONE; a pipe is created between the child's stdin (if w is 0) or stdout (if w is nonzero) and the parent. The parent's end of the pipe will be stored in *fd.

pid_t child_spawn1_socket (char const *file, char const *const *argv, char const *const *envp, int *fd)
Like child_spawn1, except that a socket, not a pipe is created between the parent and the child. Both the child's stdin and stdout point to the socket; the parent has its end of the socket available in *fd.

pid_t child_spawn2 (char const *file, char const *const *argv, char const *const *envp, int *fds)
Two pipes are created between the parent and the child. fds must point to an array of 2 ints: this array is read as well as written by child_spawn2(). On function call, the numbers in fds must describe what fds should be used in the child to contain the communication pipes (for instance, if the child will read from its parent on stdin and write to its parent on stdout, fds must contain 0 and 1). On function return, fds contains the descriptors for the pipes that read from / write to the child.

pid_t child_spawn3 (char const *file, char const *const *argv, char const *const *envp, int *fds)
Three pipes are created between the parent and the child. fds must point to an array of 3 ints: this array is read as well as written by child_spawn2(). On function call, the numbers in fds[0] and fds[1] must describe what fds should be used in the child to read from (resp. write to) the parent. On function return, fds contains the descriptors for the pipes that read from / write to the child. fds[2] is the reading end of a pipe; the writing end is present in the child, and its number is available as the value of the SKALIBS_CHILD_SPAWN_FDS environment variable.

pid_t child_spawn (char const *file, char const *const *argv, char const *const *envp, int *fds, unsigned int nfds)
More generic spawning function. fds must point to an array of at least nfds ints; file descriptors reading from or writing to the child will be stored there. The function returns 0 on failure or the pid of the child on success.

  • If nfds is 0, then the function behaves like cspawn with a flags value of CSPAWN_FLAGS_SIGBLOCKNONE.
  • If nfds is 1 or more, then fds will contain pipes between the child and the parent. The parent will read on even-numbered ones and write on odd-numbered ones. The child will read on fds[0], write on fds[1], then any additional fds are available to it in the SKALIBS_CHILD_SPAWN_FDS environment variable as a comma-separated list of integers.

pid_t gcspawn (char const *file, char const *const *argv, char const *const *envp, uint32_t flags, cspawn_fileaction const *fa, size_t n)
Like cspawn, but argv will be running as a grandchild of the current process. The function forks once, invokes cspawn from the child, and the child exits after passing the grandchild's pid to the parent.

skalibs-2.14.1.1/doc/libstddjb/direntry.html000066400000000000000000000016121455624754300206410ustar00rootroot00000000000000 skalibs: the direntry header

libstddjb
libskarnet
skalibs
Software
skarnet.org

The skalibs/direntry.h header

TODO: write this documentation page. (Sorry!)

skalibs-2.14.1.1/doc/libstddjb/djbtime.html000066400000000000000000000146531455624754300204300ustar00rootroot00000000000000 skalibs: the djbtime library interface

libstddjb
skalibs
skalibs
Software
skarnet.org

The djbtime library interface

The following functions are declared in the skalibs/djbtime.h header, and implemented in the libskarnet.a or libskarnet.so library.

General information

djbtime is a set of functions to convert tai and tain structures, and TAI time, from and to other time formats and user-friendly representations.

Data structures

  • TAI time with 1-second precision is represented as a tai.
  • TAI time with more precision is represented as a tain.
  • UTC time is represented as an unsigned 64-bit integer equal to 2^62 added to the number of seconds since the Epoch. It's a trivial extension of the standard 32-bit Unix time that will expire in 2038.
  • Broken-down GMT or local time with more than a 1-second precision is stored in a localtmn structure, containing a struct tm tm field and an unsigned long nano field.

Functions

UTC

int utc_from_tai (uint64_t *u, tai const *t)
Converts the absolute TAI64 time in *t to an UTC time, stored in *u as an unsigned 64-bit integer. *u is actually 2^62 plus the number of seconds since the Epoch. The function returns 1 if it succeeds, or 0 (and sets errno) if an error occurs. If *t happens to hit a leap second, the function returns 2 instead of 1.

int tai_from_utc (tai *t, uint64_t u)
Converts the UTC time in u, stored as an unsigned 64-bit integer (2^62 plus the number of seconds since the Epoch), to a TAI64 time in *t. The function returns 1 if it succeeds, or 0 (and sets errno) if an error occurs.

NTP

int ntp_from_tain (uint64_t *ntp, tain const *a)
Converts the absolute TAI64N time in *a to a 64-bit NTP timestamp, stored in *ntp. The higher 32 bits of *ntp represent a number of seconds ; the lower 32 bits are the fractional part of the timestamp. The function returns 1 if it succeeds, or 0 (and sets errno) if an error occurs (for instance: *a cannot be represented in the valid NTP range).

int tain_from_ntp (tain *a, uint64_t ntp)
Converts the NTP timestamp in ntp to a TAI64N time in *a. The function returns 1 if it succeeds, or 0 (and sets errno) if an error occurs.

Local time

The following functions convert time between an internal representation and a broken-down struct tm. Conversions are performed to get leap seconds handling right, depending on whether skalibs has been configured for a TAI-10 or a UTC system clock, and on whether the current timezone takes leap seconds into account or not.

int localtm_from_tai (struct tm *tm, tai const *t, int lo)
Converts the TAI time in *t to broken-down GMT (if lo is zero) or local (if lo is nonzero) time in *tm. The function returns 1 if it succeeds, or 0 (and sets errno) if an error occurs (for instance: *t cannot be validly represented in a struct tm). If *t happens to hit a leap second, the value of tm→tm_sec is 60.

int localtm_from_utc (struct tm *tm, uint64_t u, int lo)
Converts the UTC time in u to broken-down GMT (if lo is zero) or local (if lo is nonzero) time in *tm. The function returns 1 if it succeeds, or 0 (and sets errno) if an error occurs (for instance: u cannot be validly represented in a struct tm).

int localtm_from_sysclock (struct tm *tm, uint64_t u, int lo)
Converts the time in u to broken-down GMT (if lo is zero) or local (if lo is nonzero) time in *tm. u will be interpreted as a TAI-10 value (with --enable-tai-clock) or as a UTC value (without --enable-tai-clock). The function returns 1 if it succeeds, or 0 (and sets errno) if an error occurs (for instance: u cannot be validly represented in a struct tm).

int utc_from_localtm (uint64_t *u, struct tm const *tm)
Converts the broken-down local time in *tm to an UTC value in *u. The function returns 1 if it succeeds, or 0 (and sets errno) if an error occurs.

int tai_from_localtm (tai *t, struct tm const *tm)
Converts the broken-down local time in *tm to a TAI value in *t. The function returns 1 if it succeeds, or 0 (and sets errno) if an error occurs.

int sysclock_from_localtm (uint64_t *u, struct tm const *tm)
Converts the broken-down local time in *tm to a value in *u - either TAI-10 or UTC depending on your system clock. The function returns 1 if it succeeds, or 0 (and sets errno) if an error occurs.

The following functions use the localtmn type to hold both a broken-down time and a nanosecond count:

typedef struct localtmn_s localtmn, *localtmn_ref ;
struct localtmn_s
{
  struct tm tm ;
  uint32_t nano ;
} ;

The prototypes are self-explaining:

int localtmn_from_tain (localtmn *tmn, tain const *a, int lo) ;
int tain_from_localtmn (tain *a, localtmn const *tmn) ;
int localtmn_from_sysclock (localtmn *tmn, tain const *a, int lo) ;
int sysclock_from_localtmn (tain *a, localtmn const *tmn) ;

skalibs-2.14.1.1/doc/libstddjb/djbunix.html000066400000000000000000000643311455624754300204530ustar00rootroot00000000000000 skalibs: the djbunix library interface

libstddjb
libskarnet
skalibs
Software
skarnet.org

The djbunix library interface

The following functions are declared in the skalibs/djbunix.h header, and implemented in the libskarnet.a or libskarnet.so library.

General information

djbunix is an alternative API to management of basic Unix concepts: file descriptors, files, environment, and so on. It is a rather chaotic mix of safe wrappers around Unix system calls, better reimplementations of standard libc functionalities, and higher-level manipulations of Unix concepts.

Understanding djbunix is essential to understanding any piece of code depending on skalibs.

Functions

Basic fd operations

int coe (int fd)
Sets the close-on-exec flag on fd. Returns 0 if it succeeds, or -1 (and sets errno) if it fails.

int uncoe (int fd)
Clears the close-on-exec flag on fd. Returns 0 if it succeeds, or -1 (and sets errno) if it fails.

int ndelay_on (int fd)
Sets the O_NONBLOCK flag on fd: sets it to non-blocking mode. Returns 0 if it succeeds, or -1 (and sets errno) if it fails.

int ndelay_off (int fd)
Clears the O_NONBLOCK flag on fd: sets it to blocking mode. Returns 0 if it succeeds, or -1 (and sets errno) if it fails.

int pipenb (int *p)
Like pipe(), but both ends of the created pipe are in non-blocking mode.

int pipecoe (int *p)
Like pipe(), but both ends of the created pipe are close-on-exec.

int pipenbcoe (int *p)
Like pipe(), but both ends of the created pipe are in non-blocking mode and close-on-exec.

int fd_copy (int to, int from)
Copies the open fd from to number to. If to was already open, it is closed before the copy. Returns 0 if it succeeds, or -1 (and sets errno) if it fails.

int fd_copy2 (int to1, int from1, int to2, int from2)
Copies the open fd from1 to number to2. Also copies from2 to to2 at the same time. Returns 0 if it succeeds, or -1 (and sets errno) if it fails.

int fd_move (int to, int from)
Moves the open fd from to number to. If to was already open, it is closed before the move. Returns 0 if it succeeds, or -1 (and sets errno) if it fails.

int fd_move2 (int to1, int from1, int to2, int from2)
Moves the open fd from to number to. Also moves from2 to to2 at the same time. This is useful for instance when you want to swap two fds: fd_move2 will handle the situation correctly. Returns 0 if it succeeds, or -1 (and sets errno) if it fails.

void fd_close (int fd)
Closes fd. This is a safe wrapper around close().

int fd_chmod (int fd, unsigned int mode)
Safe wrapper around fchmod().

int fd_chown (int fd, uid_t uid, gid_t gid)
Safe wrapper around fchown(). This function requires root privileges.

int fd_sync (int fd)
Safe wrapper around fsync().

int fd_chdir (int fd)
Safe wrapper around fchdir().

off_t fd_cat (int from, int to)
Synchronously copies data from fd from to fd to, until it encounters EOF or an error. Returns -1 (and sets errno) if it fails; returns the number of transmitted bytes if it gets an EOF.

When the underlying OS allows it, zero-copy transmission is performed. Currently, the following zero-copy implementations are supported:

off_t fd_catn (int from, int to, off_t n)
Synchronously copies at most n bytes from fd from to fd to. Returns the total number of transmitted bytes; sets errno if this number is lesser than n. EOF is reported as EPIPE. See above for zero-copy transmission; zero-copy transmission is not attempted for less than 64k of data.

int fd_ensure_open (int fd, int w)
If fd is not open, opens it to /dev/null, for reading if w is zero, and for writing otherwise. Returns 1 if it succeeds and 0 if it fails.

int fd_sanitize (void)
Ensures stdin, stdout and stderr are open. If one of those file descriptors was closed, it now points to /dev/null. Returns 1 if it succeeds and 0 if it fails.

void fd_shutdown (int fd, int w)
Shuts down socket fd, for reading if w is zero, and for writing otherwise. Does not return an error code; does not modify errno. This is just a call to shutdown() with errno saved, used essentially to isolate application code from sys/socket.h which is a portability nightmare.

int fd_lock (int fd, int w, int nb)
Gets an advisory lock on fd: shared if w is zero, exclusive otherwise. fd must point to a regular file, open for writing or reading depending on whether you want an exclusive lock or not. If nb is zero, the function blocks until the lock can be obtained; otherwise it returns 0 immediately. On success, the function returns 1 ; it returns 0 if it cannot take the lock, or -1 (and sets errno) if an error occurs.

void fd_unlock (int fd)
Releases a previously held lock on fd.

int fd_islocked (int fd)
Returns 1 if a lock is currently held on fd, 0 otherwise. Returns -1 (and sets errno) if an error occurs.

int open2 (char const *file, unsigned int flags)
Safe wrapper around open() when it takes 2 arguments.

int open3 (char const *file, unsigned int flags, unsigned int mode)
Safe wrapper around open() when it takes 3 arguments.

int open_read (char const *file)
Opens file in read-only, non-blocking mode. Returns a valid fd number if it succeeds, or -1 (and sets errno) if it fails.

int openc_read (char const *file)
Opens file in read-only, non-blocking mode, close-on-exec. Returns a valid fd number if it succeeds, or -1 (and sets errno) if it fails.

int openb_read (char const *file)
Opens file in read-only, blocking mode. Returns a valid fd number if it succeeds, or -1 (and sets errno) if it fails.

int openbc_read (char const *file)
Opens file in read-only, blocking mode, close-on-exec. Returns a valid fd number if it succeeds, or -1 (and sets errno) if it fails.

int open_readb (char const *file)
Opens file in read-only, blocking mode. Returns a valid fd number if it succeeds, or -1 (and sets errno) if it fails. This call does not block. The open() system call is actually performed with the O_NONBLOCK option, and blocking mode is set afterwards; this behaviour allows for more transparent interactions with FIFOs.

int openc_readb (char const *file)
Same as above, but the file is opened close-on-exec.

int open_excl (char const *file)
Opens file in write-only, non-blocking mode, with the additional O_EXCL and O_CREAT flags. Returns a valid fd number if it succeeds, or -1 (and sets errno) if it fails.

int openc_excl (char const *file)
Opens file in write-only, non-blocking mode, close-on-exec, with the additional O_EXCL and O_CREAT flags. Returns a valid fd number if it succeeds, or -1 (and sets errno) if it fails.

int open_append (char const *file)
Opens file in write-only, non-blocking mode, with the additional O_APPEND and O_CREAT flags. Returns a valid fd number if it succeeds, or -1 (and sets errno) if it fails.

int openc_append (char const *file)
Opens file in write-only, non-blocking mode, close-on-exec, with the additional O_APPEND and O_CREAT flags. Returns a valid fd number if it succeeds, or -1 (and sets errno) if it fails.

int open_trunc (char const *file)
Opens file in write-only, non-blocking mode, with the additional O_TRUNC and O_CREAT flags. Returns a valid fd number if it succeeds, or -1 (and sets errno) if it fails.

int openc_trunc (char const *file)
Opens file in write-only, non-blocking mode, close-on-exec, with the additional O_TRUNC and O_CREAT flags. Returns a valid fd number if it succeeds, or -1 (and sets errno) if it fails.

int open_create (char const *file)
Opens file in write-only, non-blocking mode, with the additional O_CREAT flag. Returns a valid fd number if it succeeds, or -1 (and sets errno) if it fails.

int openc_create (char const *file)
Opens file in write-only, non-blocking mode, close-on-exec, with the additional O_CREAT flag. Returns a valid fd number if it succeeds, or -1 (and sets errno) if it fails.

int open_write (char const *file)
Opens file in write-only, non-blocking mode. Returns a valid fd number if it succeeds, or -1 (and sets errno) if it fails.

int openc_write (char const *file)
Opens file in write-only, non-blocking mode, close-on-exec. Returns a valid fd number if it succeeds, or -1 (and sets errno) if it fails.

Forking children

pid_t doublefork ()
Performs a double fork. Returns -1 if it fails (and sets errno, EINTR meaning that the intermediate process was killed by a signal), 0 if the current process is the grandchild, and the grandchild's PID if the current process is the parent.

The child_spawn family of functions has been moved to the skalibs/cspawn.h header.

Waiting for children

unsigned int wait_reap ()
Instantly reaps all the pending zombies, without blocking, without a look at the exit codes. Returns the number of reaped zombies.

int waitn (pid_t *pids, unsigned int n)
Waits until all processes whose PIDs are stored in the pids array, of size n, have died. Returns 1 if it succeeds, and 0 (and sets errno) if it fails. The pid array is not guaranteed to be unchanged.

int waitn_posix (pid_t *pids, unsigned int n, int *wstat)
Like waitn, but stores into *wstat the status of the last process in the pids array (i.e. pids[n-1]).

int waitn_reap (pid_t *pids, unsigned int n)
Instantly reaps all zombies whose PIDs are stored in the pids array, of size n. Returns -1 (and sets errno) if it fails, and the number of reaped zombies if it succeeds. The pid array is not guaranteed to be unchanged.

int waitn_reap_posix (pid_t *pids, unsigned int n, int *wstat)
Like waitn_reap, but stores into *wstat the status of the last process in the pids array (i.e. pids[n-1]), if applicable; otherwise *wstat is unchanged.

pid_t wait_nohang (int *wstat)
Instantly reaps one zombie, and stores the status information into *wstat. Returns the PID of the reaped zombie if it succeeds, 0 if there was nothing to reap (and the current process still has children), -1 ECHILD if there was nothing to reap (and the current process has no children), or -1 (and sets errno) if it fails.

pid_t waitpid_nointr (pid_t pid, int *wstat, int flags)
Safe wrapper around waitpid().

pid_t wait_pid_nohang (pid_t pid, int *wstat)
Instantly reaps an undetermined number of zombies until it finds pid. Stores the status information for dead pid into *wstat. Returns pid if it succeeds, 0 if there was nothing to reap (and the current process still has children), -1 ECHILD if there was nothing to reap (and the current process has no children), or -1 (and sets errno) if it fails.

int wait_pids_nohang (pid_t const *pids, unsigned int len, int *wstat)
Instantly reaps an undetermined number of zombies until it finds one whose PID is in the pids array, of size len. Stores the status information for that dead process into *wstat. Returns the index of the found PID in pids, starting at 1. Returns 0 if there was nothing to reap (and the current process still has children), -1 ECHILD if there was nothing to reap (and the current process has no children), or -1 (and sets errno) if it fails.

When asynchronously dealing with a child (resp. several children) and getting a SIGCHLD - which should be handled via a selfpipe - it is generally a good idea to use the wait_pid_nohang() (resp. wait_pids_nohang()) function over the basic Unix APIs. This allows a program to:

  • Automatically and silently take care of children it does not know it has. This situation can happen when a process forks and the parent execs. When the child dies, the new parent process has to drag the "zombie bastard" along, which is ugly; wait_pids_nohang() prevents this.
  • Still take appropriate care of its legitimate children, in any order.

Reading and writing whole files

int slurp (stralloc *sa, int fd)
Slurps the contents of open descriptor fd into the *sa stralloc. If you are doing this, you should either have full control over the slurped file, or run your process with suitable limits to the amount of heap memory it can get. The function returns 1 if it succeeds, or 0 (and sets errno) if it fails.

int slurpn (stralloc *sa, int fd, size_t max)
Same as slurp, but only grows the stralloc to a maximum of max bytes of total length. If there is still more to read on fd after sa→len has reached max, the function returns 0 with errno set to ENOBUFS.

int openslurpclose (stralloc *sa, char const *file)
Slurps the contents of file file into *sa. Returns 1 if it succeeds, and 0 (and sets errno) if it fails.

ssize_t openreadnclose (char const *file, char *s, size_t n)
Reads at most n bytes from file file into preallocated buffer s. Returns -1 (and sets errno) if it fails; else returns the number of read bytes.

ssize_t openreadnclose_nb (char const *file, char *s, size_t n)
Like openreadnclose, but can fail with EAGAIN if the file cannot be immediately read (for instance if it's a named pipe or other special file).

int openreadfileclose (char const *file, stralloc *sa, size_t n)
Reads at most n bytes from file file into the *sa stralloc, which is grown (if needed) to just accommodate the file size. Returns 1 if it succeeds and 0 (and sets errno) if it fails.

int openwritenclose_unsafe5 (char const *file, char const *s, size_t len, devino *devino, unsigned int options)
Writes the n bytes stored at s into file file. The previous contents of file are destroyed even if the function fails. If options has bit 0 set, the new contents of file are synced to disk before the function returns. If devino is not null, the device number of file is stored in devino→dev and its inode number in devino&arr;ino. The function returns 1 if it succeeds, or 0 (and sets errno) if it fails.

int openwritenclose_unsafe (char const *file, char const *s, size_t len)
int openwritenclose_unsafe_sync (char const *file, char const *s, size_t len)

Trivial shortcuts around openwritenclose_unsafe5(). The reader can easily figure out what they do.

int openwritenclose_suffix6 (char const *file, char const *s, size_t len, devino *devino, unsigned int options, char const *suffix)
Writes the n bytes stored at s into file file, by first writing into filesuffix and atomically renaming filesuffix to file. IOW, the old contents of file are preserved if the operation fails, and are atomically replaced with the new contents if the operation succeeds. If options has bit 0 set, the new contents of filesuffix are synced to disk before the atomic replace. If devino is not null, the device number of file is stored in devino→dev and its inode number in devino&arr;ino. The function returns 1 if it succeeds, or 0 (and sets errno) if it fails.

int openwritenclose_suffix (char const *file, char const *s, size_t len, char const *suffix)
int openwritenclose_suffix_sync (char const *file, char const *s, size_t len, char const *suffix)

Trivial shortcuts around openwritenclose_suffix_internal(). The reader can easily figure out what they do.

int openwritevnclose_unsafe5 (char const *file, struct iovec const *v, unsigned int vlen, devino *devino, int dosync)
Like openwritenclose_unsafe5, but the content to write is taken from a scatter/gather array of vlen elements instead of a single string.

int openwritevnclose_unsafe (char const *file, struct iovec const *v, unsigned int vlen)
int openwritevnclose_unsafe_sync (char const *file, struct iovec const *v, unsigned int vlen)

Trivial wrappers around openwritevnclose_unsafe5().

int openwritevnclose_suffix6 (char const *file, struct iovec const *v, unsigned int vlen, devino *devino, int dosync, char const *suffix)
Like openwritenclose_suffix6, but the content to write is taken from a scatter/gather array of vlen elements instead of a single string.

int openwritevnclose_suffix (char const *file, struct iovec const *v, unsigned int vlen, char const *suffix)
int openwritevnclose_suffix_sync (char const *file, struct iovec const *v, unsigned int vlen, char const *suffix)

Trivial wrappers around openwritevnclose_suffix6().

Filesystem deletion

The following operations are not atomic, so if they fail, the relevant subtree might end up partially deleted.

int rm_rf (char const *path)
Deletes the filesystem subtree at path. Returns 0 if it succeeds or -1 (and sets errno) if it fails.

int rm_rf_tmp (char const *path, stralloc *tmp)
Deletes the filesystem subtree at path, using *tmp as heap-allocated temporary space. Returns 0 if it succeeds or -1 (and sets errno) if it fails.

int rm_rf_in_tmp (stralloc *tmp, size_t n)
Deletes a filesystem subtree, using *tmp as heap-allocated temporary space. Returns 0 if it succeeds or -1 (and sets errno) if it fails. When the function is called, *tmp must contain the null-terminated name of the subtree to delete at offset n.

int rmstar (char const *dir)
Deletes all the filesystem subtrees in directory dir. Returns 0 if it succeeds or -1 (and sets errno) if it fails.

int rmstar_tmp (char const *dir, stralloc *tmp)
Deletes all the filesystem subtrees in directory dir, using *tmp as heap-allocated temporary space. Returns 0 if it succeeds or -1 (and sets errno) if it fails.

Filesystem copy

int hiercopy_tmp (char const *src, char const *dst, stralloc *tmp)
Recursively copies the filesystem hierarchy at src into dst, preserving modes, and also preserving the uids/gids if the process is running as the super-user. Uses *tmp as heap-allocated temporary space. Returns 1 if it succeeds or 0 (and sets errno) if it fails.

int hiercopy (char const *src, char const *dst)
Same as above, using the satmp global stralloc as heap-allocated temporary space.

Directory listing

int sals (char const *dir, stralloc *sa, size_t *maxlen)
Appends the base names of all the files (save . and ..) in dir to the stralloc *sa; each name is null-terminated. On error, returns -1 and sets errno. On success, returns the number of files it found, and writes to *maxlen the size of the largest file name it found (0 for an empty directory).

Variable length wrappers around Single Unix calls

int sarealpath (stralloc *sa, char const *path)
Resolves path into a symlink-free absolute path, appending the result to the *sa stralloc. Returns 0 if it succeeds and -1 (and sets errno) if it fails.

int sarealpath_tmp (stralloc *sa, char const *path, stralloc *tmp)
Resolves path into a symlink-free absolute path, appending the result to *sa. Uses *tmp as heap-allocated temporary space. Returns 0 if it succeeds and -1 (and sets errno) if it fails.

int sabasename (stralloc *sa, char const *s, size_t len)
Appends the basename of filename s (of length len) to *sa. Returns 1 if it succeeds and 0 (and sets errno) if it fails.

int sadirname (stralloc *sa, char const *s, size_t len)
Appends the dirname of filename s (of length len) to *sa. Returns 1 if it succeeds and 0 (and sets errno) if it fails.

int sagetcwd (stralloc *sa)
Appends the current working directory to *sa. Returns 0 if it succeeds and -1 (and sets errno) if it fails.

int sareadlink (stralloc *sa, char const *link)
Appends the contents of symbolic link link to *sa. Returns 0 if it succeeds and -1 (and sets errno) if it fails.

int sagethostname (stralloc *sa)
Appends the machine's hostname to *sa. Returns 0 if it succeeds and -1 (and sets errno) if it fails.

Temporization

void deepsleepuntil (tain const *deadline, tain *stamp)
Sleeps until the absolute time represented by the tain *deadline. *stamp must contain the current time. When the function returns, *stamp has been updated to reflect the new current time.

void deepsleep (unsigned int n)
Sleeps n seconds. Signals received during that time are handled, but do not interrupt the sleep.

void deepmillisleep (unsigned long n)
Sleeps n milliseconds. Signals received during that time are handled, but do not interrupt the sleep.

Miscellaneous functions

size_t path_canonicalize (char *out, char const *in, int check)
Writes into out the canonical form of the Unix path given in in. The out array must be preallocated with at least strlen(in)+2 bytes. Returns the length of the out path, without counting the terminating null byte. If check is nonzero, in is tested for every foobar/.. element, and the function returns 0, and sets errno appropriately, if foobar is not a valid directory; in that case, out contains the problematic path.

skalibs-2.14.1.1/doc/libstddjb/env.html000066400000000000000000000015571455624754300176010ustar00rootroot00000000000000 skalibs: the env header

libstddjb
libskarnet
skalibs
Software
skarnet.org

The skalibs/env.h header

TODO: write this documentation page. (Sorry!)

skalibs-2.14.1.1/doc/libstddjb/envalloc.html000066400000000000000000000016311455624754300206050ustar00rootroot00000000000000 skalibs: the envalloc header

libstddjb
libskarnet
skalibs
Software
skarnet.org

The skalibs/envalloc.h header

TODO: write this documentation page. (Sorry!)

skalibs-2.14.1.1/doc/libstddjb/exec.html000066400000000000000000000015531455624754300177310ustar00rootroot00000000000000 skalibs: the exec header

libstddjb
libskarnet
skalibs
Software
skarnet.org

The skalibs/exec.h header

TODO: write this documentation page. (Sorry!)

skalibs-2.14.1.1/doc/libstddjb/fmtscan.html000066400000000000000000000015751455624754300204440ustar00rootroot00000000000000 skalibs: the fmtscan header

libstddjb
libskarnet
skalibs
Software
skarnet.org

The skalibs/fmtscan.h header

TODO: write this documentation page. (Sorry!)

skalibs-2.14.1.1/doc/libstddjb/gccattributes.html000066400000000000000000000025721455624754300216520ustar00rootroot00000000000000 skalibs: the gccattributes header

libstddjb
libskarnet
skalibs
Software
skarnet.org

The skalibs/gccattributes.h header

skalibs/gccattributes.h is a set of wrappers around gcc attributes (duh). It defines macros that are always valid, and that have no effect if the compiler is not gcc or the used version of gcc does not support the wanted attribute.

For instance:

 extern size_t str_len (char const *) gccattr_pure ;

defines the str_len function as pure if it is supported.

The source code is self-explanatory.

skalibs-2.14.1.1/doc/libstddjb/genalloc.html000066400000000000000000000027271455624754300205750ustar00rootroot00000000000000 skalibs: the genalloc library interface

libstddjb
libskarnet
skalibs
Software
skarnet.org

The genalloc library interface

The following functions are declared in the skalibs/genalloc.h header, and implemented in the libskarnet.a or libskarnet.so library.

General information

genalloc is the skalibs way of handling dynamic arrays, i.e. dynamically growing arrays of fixed-size objects. Any array that needs to be stored in heap memory can be implemented via genalloc.

Most genalloc functions are just macro calls around stralloc functions.

The genalloc.h header is actually very simple and the prototypes there are self-explaining.

skalibs-2.14.1.1/doc/libstddjb/genwrite.html000066400000000000000000000066121455624754300206320ustar00rootroot00000000000000 skalibs: the genwrite library interface

libstddjb
libskarnet
skalibs
Software
skarnet.org

The genwrite library interface

The following functions are declared in the skalibs/genwrite.h header, and implemented in the libskarnet.a or libskarnet.so library.

General information

genwrite is syntactic sugar to help write functions that might want to write either to memory or to a file descriptor.

Writing to memory is achieved via appending to a stralloc; writing to a file descriptor is achieved via appending to a buffer or a bufalloc.

Usage

A genwrite_t structure contains a pointer to a function that writes stuff to the target without flushing it (which can be genwrite_put_stralloc, genwrite_put_buffer, genwrite_put_bufalloc or any compatible user-defined function) in .put, a pointer to a function that flushes the target (which can be genwrite_flush_stralloc, genwrite_flush_buffer, genwrite_flush_bufalloc or any compatible user-defined function) in .flush, and a pointer to the target writing structure in .target.

Users should define a genwrite_t first, using the provided functions, and give applications a pointer gp to this structure. To write len characters at position s to the target, the application should then call (*gp->put)(gp->target, s, len). When it is done writing, the application should call (*gp->flush)(gp->target) to flush the output.

genwrite_stdout and genwrite_stderr are predefined; they write to buffer_1 and buffer_2 respectively.

Macros

GENWRITE_STRALLOC_INIT(sa)
Declares a genwrite_t writing to the stralloc *sa.

GENWRITE_BUFFER_INIT(b)
Declares a genwrite_t writing to the buffer *b. Use of such a buffer might interact badly with nonblocking I/O.

GENWRITE_BUFALLOC_INIT(ba)
Declares a genwrite_t writing to the bufalloc *ba.

Note

Object-oriented programming in C is inefficient and cumbersome. It is usually possible to avoid it in Unix system programming, because Unix primitives are often generic enough. Unfortunately, it is not the case here: Unix does not provide an abstraction representing either a file or a memory buffer. So an object-oriented approach is unavoidable.

skalibs-2.14.1.1/doc/libstddjb/getpeereid.html000066400000000000000000000015601455624754300211200ustar00rootroot00000000000000 skalibs: the getpeereid header

libstddjb
libskarnet
skalibs
Software
skarnet.org

The skalibs/getpeereid.h header

TODO: write this documentation page. (Sorry!)

skalibs-2.14.1.1/doc/libstddjb/index.html000066400000000000000000000160601455624754300201130ustar00rootroot00000000000000 skalibs: the stddjb library interface

libskarnet
skalibs
Software
www.skarnet.org

The stddjb library interface

libstddjb is the base, and the most important part, of skalibs. It is a set of general-purpose C functions wrapping some system calls, hiding some Unix portability problems, providing some basic low-level buffering functions and string handling, and generally offering a nice API to Unix programming - in many ways nicer and safer than the "standard" Unix APIs like stdio.h.

It is mostly based on some excellent code written and placed into the public domain by D. J. Bernstein.

Compiling

  • The libstddjb functions are available under the skalibs/stddjb.h header, which includes a lot of lower-level headers. If you know what lower-level headers to use, you might speed up your compilation process by including them directly.

Programming

The following headers are automatically generated at compile-time, when the headers subsystem is made. The skalibs/stddjb.h file also includes them.

  • skalibs/uint16.h: operations with 16-bit unsigned integers
  • skalibs/uint32.h: operations with 32-bit unsigned integers
  • skalibs/uint64.h: operations with 64-bit unsigned integers
  • skalibs/types.h: portable helpers for common Unix types: size_t, uid_t, gid_t, pid_t, time_t, dev_t and ino_t.
  • skalibs/error.h: portable macros for errno management
  • skalibs/setgroups.h: stub for the setgroups() function, for systems that do not define it
  • skalibs/ip46.h: IPv4/IPv6 abstraction layer

Additionally, stddjb.h also includes the following headers, which are not associated with any code and are mostly self-explanatory:

  • skalibs/gccattributes.h: wrappers around a few GCC-specific optimizations
  • skalibs/diuint.h: for associative arrays of unsigned integers
  • skalibs/diuint32.h: for associative arrays of 32-bit unsigned integers
  • skalibs/disize.h: for associative arrays of size_t
  • skalibs/nsig.h: the number of system signals, for systems that do not define it
  • skalibs/nonposix.h: feature test macros for non-POSIX-compliant systems
skalibs-2.14.1.1/doc/libstddjb/iopause.html000066400000000000000000000213251455624754300204510ustar00rootroot00000000000000 skalibs: the iopause library interface

libstddjb
libskarnet
skalibs
Software
skarnet.org

The iopause library interface

The following functions are declared in the skalibs/iopause.h header, and implemented in the libskarnet.a or libskarnet.so library.

General information

iopause is the skalibs API for event loop selection. It's a wrapper around the system's ppoll() or poll() (if available) or select() (if neither ppoll() nor poll() is available) function. It works around some system-dependent quirks; also it works with absolute dates instead of timeouts. This is a good thing: see below.

iopause is a derived work from Dan J. Bernstein's iopause library, but the skalibs implementation is subtly different.

Data structures

An iopause_fd structure is similar to a struct pollfd structure, and must be filled the same way. Usually, the user declares an array of iopause_fd and fills it, one element per descriptor to select on. If x is an iopause_fd:

  • x.fd must be set to the fd number to select on.
  • x.events must be a disjunction of the following flags:
    • IOPAUSE_READ if the fd is to be selected for reading.
    • IOPAUSE_WRITE if the fd is to be selected for writing.
  • When the selection function returns, x.revents contains a disjunction of the following flags:
    • IOPAUSE_READ if the fd is readable (this includes reception of an EOF).
    • IOPAUSE_WRITE if the fd is writable.
    • IOPAUSE_EXCEPT if an exception (such as EOF or an error) occurred on the fd.

Unlike poll() or select(), which use a timeout argument, the iopause() function uses a deadline argument, i.e. an absolute time at which it must return 0 if no event has happened so far, as well as a stamp argument, i.e. an absolute time meaning now. Those arguments are stored in tains. Here is why:

The event loop pattern is mostly used to multiplex several asynchronous events that can happen independently, at the same time or not. Let's say you have 3 events, x, y and z. Each of those has a separate timeout: if x happens before x-timeout milliseconds, you call the x-event-handler function, but if x-timeout milliseconds elapse without x happening, you call x-timeout-handler function. And similarly with y and z.

But the selection function returning does not mean x has happened or that x has timed out. It might also mean that y has happened, that y has timed out, that z has happened, that z has timed out, or something else entirely. In the post-selection part of the loop, the proper handler is called for the event or timeout that has happened; then the loop is executed again, and in the pre-selection part of the loop, the array describing the events is filled, and the selection timeout is computed.

How are you going to compute that global selection timeout? Easy: it's the shortest of the three. But we just spent some amount of time waiting, so the individual timeouts must be recomputed! This means:

  • You need a way to know the time spent in a selection primitive, which basically means getting a timestamp before the selection and once again after the timestamp.
  • You need to recompute every individual timeout everytime you enter the loop.

That is really cumbersome. A much simpler way of doing things is:

  • Always keep a reasonably accurate estimation of the current time in a stamp variable. That means getting the current time at the start of the process, and updating it right after any action that takes a significant amount of time. When to update stamp can be difficult to estimate in CPU-bound processes; fortunately, most processes using an event loop are IO-bound, and the only actions that take a non-negligible amount of time in an IO-bound process are the blocking primitives. So, stamp must be updated right after a selection function returns, and if the program has been correctly written and cannot block anywhere else, it's the only place where it needs to be.
  • For every event, compute the deadline of that event: x-deadline is x-timeout added to the current stamp value when x enters the loop. This is done only once per event: you never have to recompute event deadlines - unlike timeouts, which diminish over time, deadlines do not change.
  • At every iteration, the selection deadline is the earliest of all the available event deadlines.
  • As an added bonus: after the selection function returns and stamp has been updated, it is easy to check which events have timed out and which have not: x has timed out iff x-deadline is earlier than stamp.

Maintaining a global timestamp and using absolute times instead of relative times really is the right way to work with event loops, and the iopause interface reflects that. Of course, you need a reliable, bug-free time library and a monotonic, constant system clock to handle absolute times correctly; that is why iopause relies on the tai library.

Functions

int iopause (iopause_fd *x, unsigned int len, tain const *deadline, tain const *stamp)
Blocks until one of the events described in the x array, of length len, happens, or until the absolute date *deadline is reached. deadline may be null, in which case the function blocks indefinitely until an event happens. If deadline is not null, then stamp must not be null, and must contain an accurate estimation of the current time. The function returns the number of events that have happened, 0 for a timeout, or -1 (and sets errno) for an error.

int iopause_stamp (iopause_fd *x, unsigned int len, tain const *deadline, tain *stamp)
Like iopause(), but if stamp is not null, it is updated right before the function returns. This helps the user always keep a reasonably accurate estimation of the current time in stamp; it is recommended to use this function instead of the lower-level iopause().

Underlying implementations

iopause is an alias to one of iopause_ppoll, iopause_poll or iopause_select. It is always aliased to iopause_ppoll if the ppoll() function is available on the system; else, it's aliased to iopause_poll by default, and users can alias it to iopause_select instead if they configure skalibs with the --enable-iopause-select option.

poll() has a more comfortable API than select(), but its maximum precision is 1 millisecond, which might not be enough for some applications; using select() instead incurs some CPU overhead for the API conversion, but has a 1 microsecond precision. ppoll() gets the best of both worlds with the same interface model as poll() and a 1 nanosecond precision, which is why skalibs always uses it when available.

skalibs-2.14.1.1/doc/libstddjb/ip46.html000066400000000000000000000154131455624754300175670ustar00rootroot00000000000000 skalibs: the ip46 library interface

libstddjb
libskarnet
skalibs
Software
skarnet.org

The ip46 library interface

The following functions and structures are declared in the skalibs/ip46.h header, and implemented in the libskarnet.a or libskarnet.so library.

General information

ip46 is a set of macros and functions to support both IPv4 and IPv6 network operations in an abstracted way.

If skalibs has been built with the --disable-ipv6 configure option, or it detects at build time than the target does not support IPv6, then ip46 structures and functions will be directly aliased to their IPv4 implementations with no overhead at all.

Data structures

An ip46full_t is a structure that contains either an IPv4 or an IPv6 address. If a is an ip46full_t, then:

  • ip46_is6(&a) is 1 if a is IPv6 and 0 otherwise.
  • a.ip points to 16 (if IPv6) or 4 (if IPv4) bytes containing the address, in network byte order.

If skalibs has been build with IPv6 support, an ip46_t is the same type as an ip46full_t. Otherwise, an ip46_t is a structure that just contains an IPv4 address.

Functions

int ip46_from_ip4 (ip46_t *a, char const *ip)
Stores the IPv4 pointed to by ip into *a. Returns 1.

int ip46_from_ip6 (ip46_t *a, char const *ip)
Stores the IPv6 pointed to by ip into *a. Returns 1, except if IPv6 is unavailable, in which case it returns 0 ENOSYS.

size_t ip46_fmt (char *s, ip46_t const *a)
Formats the address in *a into the string s, which must be preallocated. Returns the number of bytes written. The address will be accordingly formatted as IPv4 or IPv6.

size_t ip46_scan (char const *s, ip46_t *a)
Scans the string s for an IPv4 or IPv6 address. If it finds one, writes it into *a and returns the number of bytes read. If it cannot, returns 0.

size_t ip46_scanlist (ip46_t *list, size_t max, char const *s, size_t *n)
Scans the string s for a list of comma-, semicolon-, space-, tab- or newline-separated IPv4 or IPv6 addresses, up to a maximum of max. It stores them into the (preallocated) ip46_t array pointed to by list. It returns the number of bytes read (0 if s does not contain a valid IP list at all), and stores the number of found and scanned addresses into *n.

int socket_connect46 (int fd, ip46_t *a, uint16_t port)
Connects the socket fd to address *a and port port. Returns 0 in case of success, and -1 (and sets errno) in case of failure.

int socket_bind46 (int fd, ip46_t *a, uint16_t port)
Binds the socket fd to address *a and port port. Returns 0 in case of success, and -1 (and sets errno) in case of failure.

int socket_bind46_reuse (int fd, ip46_t *a, uint16_t port)
Same as the previous function, with the SO_REUSEADDR option.

int socket_deadlineconnstamp46 (int fd, ip46_t const *a, uint16_t port, tain const *deadline, tain *stamp)
Attempts to synchronously connect the socket fd to address aa and port port. Returns 1 if it succeeds and 0 (and sets errno) if it fails. stamp must contain an accurate enough timestamp, and is updated when the function returns. If the connection is still pending by deadline, then the attempt stops and the function returns 0 ETIMEDOUT.

ssize_t socket_recv46 (int fd, char *s, size_t len, ip46_t *a, uint16_t *port)
Reads a datagram from socket fd. The message is stored into buffer s of max length len, and stores the sender information into address *a and port *port. Returns the length of the read datagram, or -1 if it fails.

ssize_t socket_send46 (int fd, char const *s, size_t len, ip46_t const *a, uint16_t port)
Writes a datagram to socket fd. The message is read from buffer s of length len, and the recipient information is address *a and port port. Returns the number of written bytes, or -1 if it fails.

int socket_local46 (int fd, ip46_t *a, uint16_t *port)
Gets the local information about bound socket fd: the local IP address is stored into *a and the local port into *port. Returns 0 in case of success, and -1 (and sets errno) in case of failure.

int socket_remote46 (int fd, ip46_t *a, uint16_t *port)
Gets the peer information about connected socket fd: the remote IP address is stored into *a and the remote port into *port. Returns 0 in case of success, and -1 (and sets errno) in case of failure.

ssize_t socket_recvnb46 (int fd, char *s, size_t len, ip46_t *a, uint16_t *port, tain const *deadline, tain *stamp)
Like socket_recv46, except that the function blocks until a datagram is received. *stamp must be an accurate enough approximation of the current time, and is updated when the function returns. If no datagram has arrived by absolute date *deadline, the function returns -1 ETIMEOUT.

ssize_t socket_sendnb46 (int fd, char const *s, size_t len, ip46_t const *a, uint16_t port, tain const *deadline, tain *stamp)
Like socket_send46, except that the function blocks until a datagram has been effectively sent. *stamp must be an accurate enough approximation of the current time, and is updated when the function returns. If the message still has not been sent by absolute date *deadline, the function returns -1 ETIMEOUT.

skalibs-2.14.1.1/doc/libstddjb/lolstdio.html000066400000000000000000000065751455624754300206470ustar00rootroot00000000000000 skalibs: the lolstdio library interface

libstddjb
libskarnet
skalibs
Software
skarnet.org

The lolstdio library interface

The following functions are declared in the skalibs/lolstdio.h header, and implemented in the libskarnet.a or libskarnet.so library.

General information

lolstdio is a set of convenience functions providing printf-style formatting but interacting with buffers or bufallocs instead of stdio FILEs.

Like any printf-style functions, the lolstdio functions are rather complex and inefficient, and not recommended for general use; they are provided as a quick and dirty way to debug or test things. Programmers are advised to use type-specific formatting functions instead in production-quality code.

Be aware that functions writing into buffers interact badly with non-blocking fds (and asynchronism in general) - just as you cannot use FILEs with non-blocking output. Functions writing into bufallocs, however, are fine, because bufallocs are much more suited to asynchronous writing than fixed-size buffers or FILEs are.

The current lolstdio implementation relies on the libc's vsnprintf function.

Functions

int vbprintf (buffer *b, char const *format, va_list args)
Like vfprintf except that the result is written to the buffer b.

int bprintf (buffer *b, char const *format, ...)
Like fprintf except that the result is written to the buffer b.

int lolprintf (char const *format, ...)
Like printf except that the result is written to the buffer buffer_1.

int vbaprintf (bufalloc *ba, char const *format, va_list args)
Like vfprintf except that the result is written to the bufalloc ba.

int baprintf (bufalloc *ba, char const *format, ...)
Like fprintf except that the result is written to the bufalloc ba.

skalibs-2.14.1.1/doc/libstddjb/mininetstring.html000066400000000000000000000016001455624754300216700ustar00rootroot00000000000000 skalibs: the mininetstring header

libstddjb
libskarnet
skalibs
Software
skarnet.org

The skalibs/mininetstring.h header

TODO: write this documentation page. (Sorry!)

skalibs-2.14.1.1/doc/libstddjb/netstring.html000066400000000000000000000015541455624754300210230ustar00rootroot00000000000000 skalibs: the netstring header

libstddjb
libskarnet
skalibs
Software
skarnet.org

The skalibs/netstring.h header

TODO: write this documentation page. (Sorry!)

skalibs-2.14.1.1/doc/libstddjb/safewrappers.html000066400000000000000000000076431455624754300215150ustar00rootroot00000000000000 skalibs: safe wrappers

libstddjb
libskarnet
skalibs
Software
skarnet.org

Safe wrappers

Lots of functions in libstddjb, declared for instance in allreadwrite.h or djbunix.h, are just "safe wrappers" around corresponding system functions. For instance, fd_read() is a safe wrapper around the system read() function.

The problem

Quite a lot of system calls are defined by The Open Group Base Specifications as interruptible: when the process is in the middle of such a system call and receives a signal that it does not ignore, the system call immediately returns -1 EINTR (after the signal handler, if any, has been executed).

Most of the time, this is not an issue: unignored signals usually kill the process anyway. Or stop it - and when it resumes, system calls are simply restarted, not interrupted. EINTR can only happen when a signal handler has been installed, and a signal is actually caught by the signal handler during an interruptible system call. And to avoid EINTR, users can use the SA_RESTART flag when installing the signal handler with sigaction().

However, there is a common case where using SA_RESTART is a bad idea: when writing an asynchronous event loop.

An asynchronous event loop is organized around a select() or poll() system call that is the only blocking operation in the whole loop. That call takes a timeout as an argument. If a signal handler is installed with SA_RESTART and a signal arrives in the middle of the select/poll call - which happens often since it is blocking - then the select/poll is restarted with the same arguments, including the timeout. This is not good: time has elapsed, the timeout should be recomputed. Some versions of select update the values in the struct timeval even when select() is interrupted, but it is not portable, and not applicable to poll(). So it is necessary, in this case, to have select/poll return -1 EINTR when a signal is caught. And that means SA_RESTART should not be used.

Which also means that other system calls performed when the signal handler has been installed, for instance in the body of the loop, will not be protected, and can return -1 EINTR if a signal is caught at the wrong time.

The solution

So, in order to be perfectly reliable, when a program has caught a signal without SA_RESTART and makes an interruptible system call, it must check whether the return value is -1 EINTR, and restart the system call if it is the case. This is annoying to write; so, skalibs provides small wrappers around interruptible system calls, so that programmers can just call those safe wrappers and never bother with this again.

The performance loss from having a wrapper layer is totally negligible compared to the cost of using a system call in the first place.

skalibs-2.14.1.1/doc/libstddjb/segfault.html000066400000000000000000000016161455624754300206170ustar00rootroot00000000000000 skalibs: the segfault header

libstddjb
libskarnet
skalibs
Software
skarnet.org

The skalibs/segfault.h header

TODO: write this documentation page. (Sorry!)

skalibs-2.14.1.1/doc/libstddjb/selfpipe.html000066400000000000000000000211761455624754300206170ustar00rootroot00000000000000 skalibs: the selfpipe library interface

libstddjb
libskarnet
skalibs
Software
skarnet.org

The selfpipe library interface

The selfpipe functions are declared in the skalibs/selfpipe.h header and implemented in the libskarnet.a or libskarnet.so library.

What does it do ?

Signal handlers suck.

They do. I don't care how experienced you are with C/Unix programming, they do. You can be Ken Thompson, if you use signal handlers as a regular part of your C programming model, you are going to screw up, and write buggy code.

Unix is tricky enough with interruptions. Even when you have a single thread, signals can make the execution flow very non-intuitive. They mess up the logic of linear and structured code, they introduce non-determinism; you always have to think "and what if I get interrupted here and the flow goes into a handler...". This is annoying.

Moreover, signal handler code is very limited in what it can do. It can't use any non-reentrant function! If you call a non-reentrant function, and by chance you were precisely in that non-reentrant function code when you got interrupted by a signal... you lose. That means, no malloc(). No bufferized IO. No globals. The list goes on and on.
If you're going to catch signals, you'll want to handle them outside the signal handler. You actually want to spend the least possible time inside a signal handler - just enough to notify your main execution flow that there's a signal to take care of.

And, of course, signal handlers don't mix with event loops, which is a classic source of headaches for programmers and led to the birth of abominations such as pselect. So much for the "everything is a file" concept that Unix was built on.

A signal should be an event like any other. There should be a unified interface - receiving a signal should make some fd readable or something.

And that's exactly what the self-pipe trick, invented by DJB, does.

As long as you're in some kind of event loop, the self-pipe trick allows you to forget about signal handlers... forever. It works this way:

  1. Create a pipe p. Make both ends close-on-exec and nonblocking.
  2. Write a tiny signal handler ("top half") for all the signals you want to catch. This signal handler should just write one byte into p[1], and do nothing more; ideally, the written byte identifies the signal.
  3. In your event loop, add p[0] to the list of fds you're watching for readability.

When you get a signal, a byte will be written to the self-pipe, and your execution flow will resume. When you next go through the event loop, p[0] will be readable; you'll then be able to read a byte from it, identify the signal, and handle it - in your unrestricted main environment (the "bottom half" of the handler).

The selfpipe library does it all for you - you don't even have to write the top half yourself. You can forget their existence and recover some peace of mind.

Note that in an asynchronous event loop, you need to protect your system calls against EINTR by using safe wrappers.

How do I use it ?

Starting

int fd = selfpipe_init() ;

selfpipe_init() sets up a selfpipe. You must use that function first.
If fd is -1, then an error occurred. Else fd is a non-blocking descriptor that can be used in your event loop. It will be selected for readability when you've caught a signal.

Trapping signals

int r = selfpipe_trap(SIGTERM) ;

selfpipe_trap() catches a signal and sends it to the selfpipe. Uncaught signals won't trigger the selfpipe. r is 1 if the operation succeeded, and 0 if it failed. If it succeeded, you can forget about the trapped signal entirely.
In our example, if r is 1, then a SIGTERM will instantly trigger readability on fd.

int r ;
sigset_t set ;
sigemptyset(&set) ;
sigaddset(&set, SIGTERM) ;
sigaddset(&set, SIGHUP) ;
r = selfpipe_trapset(&set) ;

selfpipe_trap() handles signals one by one. Alternatively (and often preferrably), you can use selfpipe_trapset() to directly handle signal sets. When you call selfpipe_trapset(), signals that are present in set will be caught by the selfpipe, and signals that are absent from set will be uncaught. r is 1 if the operation succeeded and 0 if it failed.

Handling events

int c = selfpipe_read() ;

Call selfpipe_read() when your fd is readable. That's where you write your real signal handler: in the body of your event loop, in a "normal" context.
c is -1 if an error occurred - in which case chances are it's a serious one and your system has become very unstable. c is 0 if there are no more pending signals. If c is positive, it is the number of the signal that was caught.

Accessing the selfpipe

int fd = selfpipe_fd() ;

Sometimes you need to access the fd of the selfpipe in two very distinct translation units (typically to poll on it), and you rightly don't want to add a global variable to store it, especially since it's already stored in a global internal variable in skalibs. No need to bloat your binary anymore: selfpipe_fd() will now retrieve the value for you, wherever you are.

Finishing

selfpipe_finish() ;

Call selfpipe_finish() when you're done using the selfpipe. Signal handlers will be restored to SIG_DFL, i.e. signals will not be trapped anymore.

Any limitations ?

Some, as always.

  • The selfpipe library uses a global pipe; so, it's theoretically not safe for multithreading. However, as long as you dedicate one thread to signal handling and block signals in all the other threads (see pthread_sigmask()) then you should be able to use the selfpipe in the thread that handles signals without trouble. Since reading the selfpipe involves waiting for a file descriptor to become readable, it is recommended to do this in a thread that will already have a regular input/output loop (via poll() or iopause()) so you can just add the selfpipe to the list of fds you're reading on.
  • In rare cases, the self-pipe can theoretically be filled, if some application sends more than PIPE_BUF signals before you have time to selfpipe_read(). On most Unix systems, PIPE_BUF is 4096, so it's a very acceptable margin. Unless your code is waiting where it should not be, only malicious applications will fill the self-pipe - and malicious applications could just send you a SIGKILL and be done with you, so this is not a concern. Protect yourself from malicious applications with clever use of uids.

Hey, Linux has signalfd() for this !

Yes, the Linux team loves to gratuitously add new system calls to do things that could already be done before without much effort. This adds API complexity, which is not a sign of good engineering.

However, now that signalfd() exists, it is indeed marginally more efficient than a pipe, and it saves one fd: so the selfpipe library is implemented via signalfd() when this call is available.

skalibs-2.14.1.1/doc/libstddjb/sgetopt.html000066400000000000000000000015531455624754300204720ustar00rootroot00000000000000 skalibs: the sgetopt header

libstddjb
libskarnet
skalibs
Software
skarnet.org

The skalibs/sgetopt.h header

TODO: write this documentation page. (Sorry!)

skalibs-2.14.1.1/doc/libstddjb/sig.html000066400000000000000000000015451455624754300175700ustar00rootroot00000000000000 skalibs: the sig header

libstddjb
libskarnet
skalibs
Software
skarnet.org

The skalibs/sig.h header

TODO: write this documentation page. (Sorry!)

skalibs-2.14.1.1/doc/libstddjb/siovec.html000066400000000000000000000151161455624754300202750ustar00rootroot00000000000000 skalibs: the siovec header

libstddjb
libskarnet
skalibs
Software
skarnet.org

The skalibs/siovec.h header

The following functions are declared in the skalibs/siovec.h header and implemented in the libskarnet.a or libskarnet.so library.

Purpose

These functions manipulate arrays of struct iovec containing ranges of bytes, handling them as contiguous arrays. They're used, for instance, in the skalibs implementation of circular buffers.

Functions

size_t siovec_len (struct iovec const *v, unsigned int n)
Returns the sum of the first n iov_len fields of the v array - i.e. the total number of bytes contained in the array represented by v of length n.

size_t siovec_gather (struct iovec const *v, unsigned int n, char *s, size_t max)
Gathers all the data scattered in ranges described by v of length n into the space pointed to by s. Specifically: the first v[0].iov_len bytes pointed to by v[0].iov_base bytes are copied to s, then the first v[1].iov_len bytes pointed to by v[1].iov_base are appended to it, and so on, n times. The function copies no more than max bytes. It returns the total amount of bytes copied.

size_t siovec_scatter (struct iovec const *v, unsigned int n, char const *s, size_t len)
Scatters len bytes of data from s into the byte ranges represented by array v of length n. (This is the opposite of the siovec_gather() function.) The first v[0].iov_len bytes of s are copied to v[0].iov_base, then the following v[1].iov_len bytes of s are copied to v[1].iov_base, and so on up to len bytes or until if the scatter array is full, i.e. siovec_len(v, n) bytes have been copied. The function returns the total amount of bytes copied.

size_t siovec_deal (struct iovec const *vj, unsigned int nj, struct iovec const *vi, unsigned int ni)
Copies the data contained in the ranges represented by the array vi of length ni to the ranges represented by the array vj of length nj. The first vi[0].iov_len bytes pointed to by vi[0].iov_base are copied to vj[0].iov_base, up to vj[0].iov_len bytes, moving on to vj[1].iov_base if it overflows; then the bytes pointed to by vi[1].iov_base are copied to what space remains wherever the writing pointer is, and so on until all the bytes in the ranges described by vi have been copied or there is no more room left in the ranges described by vj. The function returns the total amount of bytes copied.

size_t siovec_seek (struct iovec *v, unsigned int n, size_t len)
Does the equivalent of p += len; if the byte ranges represented by array v of size n were a single byte array pointed by p. If v[0].iov_len is lesser than len, then v[0] is zeroed out (set to { .iov_base = 0, .iov_len = 0 }), v[0].iov_len bytes are deduced from len, and the same operation is repeated with v[1], and so on. If every iovec gets zeroed out, the operation stops; but if a v[i].iov_len is greater than the remaining amount of bytes to deduce, that amount is substracted from v[i].iov_len and added to v[i].iov_base. The function returns the total number of bytes that have been deduced.

unsigned int siovec_trunc (struct iovec *v, unsigned int n, size_t len)
Truncates the last fields of v of size n so that the byte ranges it represents have a total length of len or less. The iov_len field of v[n-1] is decreased by len; if it would be negative, then it's zeroed out and the remainder is taken from v[n-2] instead, and so on. The function returns the new size of array v with the tailing zeroed out members removed. It can only return 0 if len is 0, which means all of v has been zeroed out.

size_t siovec_bytechr (struct iovec const *v, unsigned int n, char c)
Looks for the first occurence of c among the byte ranges represented by the members of v. Returns its cumulative index, i.e. the position that c would have if the byte ranges pointed to by members of v were a single array. If there are no occurences of c, the function retunrs siovec_len(v, n).

size_t siovec_bytein (struct iovec const *v, unsigned int n, char const *sep, size_t seplen)
Looks for the first occurence of any byte from the sep array of size seplen among the byte ranges represented by the members of array v of size n, and returns the cumulative index of the first one it finds.

size_t siovec_search (struct iovec const *v, unsigned int n, char const *needle, size_t nlen)
Looks for the string (as in array of bytes: null characters are supported) needle of size nlen in the byte ranges represented by the members of array v of size n, and returns the cumulative index of the first occurrence it finds, or siovec_len(v, n) if it cannot find one. Split strings are supported: if needle starts at position v[i].iov_base + pos but is cut because it reaches v[i].iov_len midstring, and the rest of needle is available at v[i+1].iov_base, then the function will find it (and return pos plus the sum length of all the v members before i).

skalibs-2.14.1.1/doc/libstddjb/skamisc.html000066400000000000000000000015671455624754300204440ustar00rootroot00000000000000 skalibs: the skamisc header

libstddjb
libskarnet
skalibs
Software
skarnet.org

The skalibs/skamisc.h header

TODO: write this documentation page. (Sorry!)

skalibs-2.14.1.1/doc/libstddjb/socket.html000066400000000000000000000015701455624754300202740ustar00rootroot00000000000000 skalibs: the socket header

libstddjb
libskarnet
skalibs
Software
skarnet.org

The skalibs/socket.h header

TODO: write this documentation page. (Sorry!)

skalibs-2.14.1.1/doc/libstddjb/stralloc.html000066400000000000000000000113671455624754300206340ustar00rootroot00000000000000 skalibs: the stralloc library interface

libstddjb
libskarnet
skalibs
Software
skarnet.org

The stralloc library interface

The following functions are declared in the skalibs/stralloc.h header, and implemented in the libskarnet.a or libskarnet.so library.

General information

stralloc is the preferred skalibs way of storing objects into heap memory. It focuses on strings of char, which is the generic way to handle any object. For easy structure manipulation, the genalloc series of functions can be used; those functions are mostly macros wrapping calls to their stralloc counterparts.

A stralloc is a structure containing the following fields:

  • s: a pointer to a zone of heap memory. The stralloc functions internally manipulate those via the alloc series of functions. It is recommended to never modify that field manually.
  • len: the used length of the allocated zone. It is the only field that the user can modify directly.
  • a: the number of allocated bytes. The user should never have to access that field, because the memory allocation management should be entirely transparent. len cannot exceed a: if an operation needs a bigger len, it will automatically reallocate as needed.

The benefits of using stralloc are as follows:

  • Memory allocation is performed on-demand and automatically, with a suitable size. Heuristics are used to accommodate constantly growing strings while minimizing the amount of needed reallocations.
  • If every heap-allocated object is represented by a stralloc, then it is very easy to identify what pointer is in the heap. When you stop using a pointer p, should you free it ? Sometimes it's not easy to find out. When you stop using a stralloc sa, you know you must call stralloc_free(&sa). Store your strong references as strallocs and weak references as simple pointers, and never free simple pointers. This policy allows me to boast that no skarnet.org software has ever leaked memory.
  • Repeated for emphasis: the golden rule for programming with strallocs is every pointer to the heap must be owned by a stralloc. Every pointer you handle yourself either does not point to the heap, or is weak. That sometimes implies unusual programming practices, such as having storage separated from structure, but it's hands down the easiest way to keep control of your heap in complex situations.
  • The indirection layer makes weak references immune to reallocation troubles. The s field may change when a reallocation happens, but the stralloc structure's address never changes.

A stralloc can be declared anywhere: static/global data, stack or heap. (Of course, as a general rule, you should favor the stack whenever possible.) A stralloc should be initialized to STRALLOC_ZERO before its first use.

Functions

int stralloc_catb (stralloc *sa, char const *s, size_t len)
Appends the len bytes pointed to by s to the end of the memory zone handled by *sa, automatically allocating more memory if needed. Returns 1 if it succeeds, and 0 if it fails.

void stralloc_free (stralloc *sa)
Frees *sa, i.e. calls alloc_free on sa→s then zeroes the structure. *sa is then reusable. However, it is not good practice to call this function if you're going to reuse *sa soon: it takes time and causes memory fragmentation. Just setting sa→len to 0 allows you to instantly reuse the allocated block of memory.

The above are the most important and fundamental functions of skalibs/stralloc.h. Other functions can be found in this header and their prototypes are self-explaining.

skalibs-2.14.1.1/doc/libstddjb/strerr.html000066400000000000000000000015701455624754300203250ustar00rootroot00000000000000 skalibs: the strerr header

libstddjb
libskarnet
skalibs
Software
skarnet.org

The skalibs/strerr.h header

TODO: write this documentation page. (Sorry!)

skalibs-2.14.1.1/doc/libstddjb/tai.html000066400000000000000000000500551455624754300175630ustar00rootroot00000000000000 skalibs: the tai library interface

libstddjb
libskarnet
skalibs
Software
skarnet.org

The tai library interface

The following functions are declared in the skalibs/tai.h header, and implemented in the libskarnet.a or libskarnet.so library.

General information

tai is a set of data structures and primitives to represent and perform operations on time.

The point of tai is to handle time without ever having to deal with annoyances such as Y2K, Y2038, NTP limits, non-linear clocks, and the like. By using the tai interface, you ensure your program will behave properly no matter what.

What is the problem ?

The standard APIs for time management under Unix are broken in more or less subtle ways. The most obvious thing is that they do not pass year 2038. A less obvious problem is that they do not handle leap seconds correctly. Here are a few references you should read to understand what is going on:

The meat and potatoes of all this is that programmers cannot simply rely on standard Unix APIs such as gettimeofday() (which, by the way, is marked as obsolescent, but it's not going to disappear tomorrow) to measure time intervals or even to give precise absolute time, and in any case those APIs will become obsolete in 2038.

So what does tai do ?

tai implements - among other things - the TAI64 and TAI64N formats, which are used in all of skalibs. This gives a programmer access to precise linear absolute time, which is suitable for both timestamping (wallclock usage) and time interval measurements (stopwatch usage). Additionally, TAI64 passes Y2038 (it can represent dates exceeding the estimated lifespan of the universe).

tai has been inspired by Dan J. Bernstein's libtai library, but does not borrow any code from it.

Data structures

A tai structure holds an absolute date with a one-second precision. A tain structure holds an absolute date with a maximum of one-nanosecond precision, as permitted by the underlying system call. If flag-usert is clear, the system clock will be read via gettimeofday() system call, which has a one-microsecond precision; if it is set, the system clock will be read via the clock_gettime() system call, which has a one-nanosecond precision. In either case, a current tain will be unable to be more precise than the underlying implementation.

A tai, as well as a tain, can also hold a (possibly negative) relative time, i.e. a difference of absolute dates. It is up to the programmer to make sure that a relative time is never interpreted as an absolute TAI64 date, and vice-versa.

Functions

Wallclock operations

int tai_now (tai *t)
Writes the current time as a TAI value to *t, with a 1-second precision. The current time is based on the system clock. Make sure skalibs has been compiled with or without the --enable-tai-clock configure option according to your system clock synchronization method: skalibs supports a system clock set to TAI-10 or to UTC. The function returns 1 if it succeeds, or 0 (and sets errno) if it fails.

int sysclock_get (tain *a)
Reads the current value of the system clock (as in CLOCK_REALTIME) into *a. Returns 1 if it succeeds or 0 (and sets errno) if it fails. Note that despite being a tain, *a does not contain a TAI value - it only contains an internal, Y2038-safe representation of the value of the system clock, which should be either TAI-10 or UTC. You should not use this function directly unless you know exactly what you are doing.

int sysclock_set (tain const *a)
Sets the system clock to *a, provided *a has the correct internal representation. You should not use this function directly unless you know exactly what you are doing.

int tain_wallclock_read (tain *a)
Reads the current time into *a, as a TAI64N value. Returns 1 if it succeeds or 0 (and sets errno) if it fails. Here a contains a valid TAI64N stamp, no matter what the system clock is set to: arithmetic operations can be performed on it.

int tain_setnow (tain const *a)
Sets the current time to *a. Returns 1 if it succeeds or 0 (and sets errno) if it fails. a must contain a valid TAI64N stamp; proper operations will be automatically run to convert that stamp into the right format for the system clock.

int tain_now_set_wallclock (tain *a)
Tells skalibs that future invocations of tain_now() (see below) should use a wall clock, i.e. the system time as returned by clock_gettime(CLOCK_REALTIME) or gettimeofday(). Also reads the current time into *a. Returns 1 if it succeeds or 0 (and sets errno) if it fails. A wall clock is the default: it is not necessary to call this function before invoking tain_now() at the start of a program.

Stopwatch operations

The following two operations can only succeed if your system provides the clock_gettime() primitive with at least one of the CLOCK_MONOTONIC or CLOCK_BOOTTIME clocks. Otherwise, they will fail with errno set to ENOSYS.

int tain_stopwatch_init (tain *a, clock_t cl, tain *offset)
Initializes a stopwatch in *offset, using a clock named cl. Typically, cl is something like CLOCK_MONOTONIC, when it is defined by the system. The actual value of *offset is meaningless to the user; offset's only use is to be given as a second parameter to tain_stopwatch_read(). The function returns 1 if it succeeds or 0 (and sets errno) if it fails. On success, the current time, as given by the system clock (a wall clock), is returned in *a.

What tain_stopwatch_init() does is synchronize the "stopwatch clock" to the system clock. Right after tain_stopwatch_init() has been called, the absolute times given by tain_stopwatch_read() and tain_wallclock_read() are the same. Then, depending on the accuracy of the system clock, a drift may appear; calling tain_stopwatch_init() again resets that drift to zero.

int tain_stopwatch_read (tain *a, clock_t cl, tain const *offset)
Gives the absolute time, as a TAI64N value, in *a. This absolute time is computed as a linear increase (as measured with the cl clock, which should be a monotonic clock such as CLOCK_MONOTONIC) since the last time tain_stopwatch_init() was called with parameter offset. tain_stopwatch_read() guarantees precise time interval measurements; however, the time it gives can slightly differ from the result of tain_wallclock_read(). The function returns 1 if it succeeds or 0 (and sets errno) if it fails.

int tain_now_set_stopwatch (tain *a)
Tells skalibs that future invocations of tain_now() (see below) should use a stopwatch, i.e. the system time as returned by clock_gettime(CLOCK_MONOTONIC) or similar, if supported by the system. This is useful when it is more important for a program to compute unchanging time intervals no matter what the system clock does, than to display absolute time that is in sync with a human view of time (which is the cause and reason of most system clock jumps).
If no monotonic clock is supported by the system, this function does not change what tain_now() refers to (i.e. it will keep referring to the system clock).
Returns 1 on success and 0 (and sets errno) on failure. On success, the current time, as given by the system clock (a wall clock), is returned in *a.

All-purpose time reading

int tain_now (tain *a)
Writes the current time, as a TAI value, to *a. This is the function you should use by default. It returns 1 if it succeeds or 0 (and sets errno) if it fails.

tain_now() relies on the concept that there is One True Time Source for the process, and that is where it reads time from. By default, the One True Time Source is the system clock (a wall clock), and tain_now() is actually an alias to tain_wallclock_read(). At the start of a program, calling tain_now_set_stopwatch() will define a monotonic clock (if supported by the system) as the One True Time Source, which will make tain_now() resistant to system clock jumps, but will also make it unsuitable for timestamping.

In other words: the first time you need to read the clock, or at the start of your program, you should use tain_now_set_wallclock() or tain_now_set_stopwatch() depending on whether you want the One True Time Source to be the system clock (CLOCK_REALTIME or gettimeofday()) or a stopwatch (CLOCK_MONOTONIC, if supported). Afterwards, every time you need to read from that time source, use tain_now(). skalibs functions that may block, such as iopause_g, internally call tain_now() to update the timestamp they're using, so they will use the time source you have defined. (Functions ending in _g use the STAMP global variable to store the current timestamp.)

Converting to/from libc representations

The following functions only convert from a certain structure format to another; they do not make any assumption about the format of the time contained in those structures. For instance, for the tai_from_timeval function, if the struct timeval contains an absolute UTC time, then the tai will also contain the same UTC time. Despite being a tai, it may contain something else than TAI time.

If you need conversion from the native machine system clock format to TAI, see the next section.

int tai_from_time (tai *t, time_t u)
int tai_relative_from_time (tai *t, time_t u)

Those functions convert an absolute (resp. relative) time in a time_t to an absolute (resp. relative) time in a tai, with a 1-second precision. They return 1, unless the time_t value is invalid (in which case they return 0).

int time_from_tai (time_t *u, tai const *t)
int time_from_tai_relative (time_t *u, tai const *t)

The inverse functions of the previous ones. Be aware that time_t is 32 bits on some systems and cannot store all values of a tai (in which case the functions will return 0 EOVERFLOW).

int tain_from_timeval (tain *a, struct timeval const *tv)
int tain_relative_from_timeval (tain *a, struct timeval const *tv)
int tain_from_timespec (tain *a, struct timespec const *ts)
int tain_relative_from_timespec (tain *a, struct timespec const *ts)
int timeval_from_tain (struct timeval *tv, tain const *a)
int timeval_from_tain_relative (struct timeval *tv, tain const *a)
int timespec_from_tain (struct timespec *ts, tain const *a)
int timespec_from_tain_relative (struct timespec *ts, tain const *a)

Same conversion operations, between tain and a struct timeval or struct timespec. The 1-microsecond (for struct timeval) or 1-nanosecond (for struct timespec) precision is preserved.

Conversion between TAI and the system clock format

Unlike the previous functions, the functions listed here will always operate on valid absolute timestamps. Only TAI64 time is stored in tai structures, and only TAI64N time is stored in tain structures. These functions will convert to/from TAI, from/to the machine system clock format, i.e. TAI-10 or UTC depending on whether skalibs was compiled with the --enable-tai-clock configure option). This is useful to get valid TAI/TAI64N timestamps out of information exported by the system, for instance the time_t returned by time(), or in the st_atim, st_mtim or st_ctim fields of a struct stat.

The functions return 1 in case of success, or 0 if the conversion could not be performed; in which case errno is set to EINVAL if the input argument was not a valid timestamp, to EOVERFLOW if the output could not be represented in the chosen format (which may happen on systems with a 32 bit time_t), or other error codes.

int tai_from_time_sysclock (tai *a, time_t t)
int time_sysclock_from_tai (time_t *t, tai const *a)
int tain_from_timeval_sysclock (tain *a, struct timeval const *tv)
int timeval_sysclock_from_tain (struct timeval *tv, tain const *a)
int tain_from_timespec_sysclock (tain *a, struct timespec const *ts)
int timespec_sysclock_from_tain (struct timespec *ts, tain const *a)

Conversions to/from basic types

int tain_uint (tain *a, unsigned int c)
Stores a relative time of c seconds into a. Normally returns 1, but may return 0 EINVAL on pathological numbers.

int tain_from_millisecs (tain *a, int ms)
This function makes a tain representing a relative time of ms milliseconds. ms must be non-negative. The function returns 1, unless ms is negative, in which case it returns 0 EINVAL.

int taino_millisecs (tain const *a)
If *a contains a non-negative relative time that fits into a 31-bit integer number of milliseconds, the function returns that number. Else it returns -1 EINVAL.

Time computations

int tai_add (tai *t, tai const *t1, tai const *t2)
Stores *t1 + *t2 into t. Of course, *t1 and *t2 must not both represent absolute times. The function normally returns 1, but will return 0 on bad inputs.

int tai_sub (tai *t, tai const *t1, tai const *t2)
Stores *t1 - *t2 into t. *t1 cannot be relative if *t2 is absolute. If they are both relative or both absolute, then *t is relative, else it's absolute. The function normally returns 1, but will return 0 on bad inputs.

int tain_add (tain *a, tain const *a1, tain const *a2)
int tain_sub (tain *a, tain const *a1, tain const *a2)

Same thing with tain.

int tain_addsec (tain *a, tain const *a1, int c)
Adds c seconds to *a1 and stores the result into a. c may be negative.

void tain_half (tain *a, tain const *b)
Stores *b/2 into a. *b must be relative.

Comparing dates or durations

int tai_less (tai const *t1, tai const *t2)
int tain_less (tain const *t1, tain const *t2)

Those functions return nonzero iff *t1 is lesser than *t2. *t1 and *t2 must be both relative, or both absolute.

Packing and unpacking

void tai_pack (char *s, tai const *t)
Marshals *t into the buffer s points to, which must be preallocated with at least TAI_PACK (8) characters. Afterwards, the buffer contains the external TAI64 format representation of *t.

void tai_unpack (char const *s, tai *t)
Unmarshals the external TAI64 format label pointed to by s (at least TAI_PACK characters) and stores the result into t.

void tain_pack (char *s, tain const *a)
void tain_unpack (char const *s, tain *a)

Same thing with external TAI64N format, using TAIN_PACK (12) characters.

Formatting and scanning

unsigned int tain_fmt (char *s, tain const *a)
Writes into s an ASCII representation of *a in external TAI64N format. s must point to a preallocated buffer of at least TAIN_PACK*2 (24) characters. The function returns the number of bytes that have been written to s (24).

unsigned int tain_scan (char const *s, tain *a)
Reads 24 characters from s; if those characters are a valid ASCII representation of the external TAI64N format of some time value, this value is stored into a, and 24 is returned. Else 0 is returned.

Timestamping

A TAI64N timestamp is a string of 25 characters: a single '@' character followed by the ASCII representation of the TAI64N external format of an absolute date.

unsigned int timestamp_fmt (char *s, tain const *a)
Writes a TAI64N timestamp representing the absolute date *a into the 25 characters pointed to by s. Returns 25.

unsigned int timestamp_scan (char const *s, tain *a)
Reads 25 characters at s. If those characters are a valid TAI64N timestamp, stores the absolute date in a and returns 25. Else, returns 0.

int timestamp (char *s)
Writes the current time (read from the system clock) as a TAI64N timestamp into s. Returns 1 if it succeeds or 0 (and sets errno) if it fails.

TAI64N timestamps are an efficient, robust, and easy-to-use way of timestampping log lines. They're easy to recognize in automatic data parsers. Log files where every line starts with a TAI64N timestamp can be merged and alphanumerically sorted: the resulting file will be chronologically sorted.

The s6 package provides tools to convert TAI64N timestamps into human-readable dates. Please do not embed human-readable dates in your log files, thus making parsing tools unnecessarily hard to write; use TAI64N timestamps instead, design tools that can parse them, and translate them to human-readable form at human analysis time.

skalibs-2.14.1.1/doc/libunixonacid/000077500000000000000000000000001455624754300170025ustar00rootroot00000000000000skalibs-2.14.1.1/doc/libunixonacid/index.html000066400000000000000000000037351455624754300210070ustar00rootroot00000000000000 skalibs: the unixonacid library interface

libskarnet
skalibs
Software
skarnet.org

The unixonacid library interface

libunixonacid provides higher-level interfaces to Unix concepts such as the filesystem - for instance, it provides a way to access several files atomically, be it for reading or for writing - or interprocess communication.

Compiling

  • Use #include <skalibs/unixonacid.h>

Programming

The skalibs/unixonacid.h header is actually a concatenation of other headers, every one of each declaring related structures, macros and functions.

skalibs-2.14.1.1/doc/libunixonacid/kolbak.html000066400000000000000000000024331455624754300211350ustar00rootroot00000000000000 skalibs: the kolbak library interface

libunixonacid
libskarnet
skalibs
Software
skarnet.org

The kolbak library interface

The following functions are declared in the skalibs/kolbak.h header, and implemented in the libskarnet.a or libskarnet.so library.

General information

kolbak implements simple queuing of callback functions to use when sending a message to a peer and expecting an answer, which will be handled by the callback function. The queue is a circular buffer.

FIXME: To be completed.

skalibs-2.14.1.1/doc/libunixonacid/skaclient.html000066400000000000000000000050441455624754300216500ustar00rootroot00000000000000 skalibs: the skaclient library interface

libunixonacid
libskarnet
skalibs
Software
skarnet.org

The skaclient library interface

The following functions are declared in the skalibs/skaclient.h header, and implemented in the libskarnet.a or libskarnet.so library.

General information

skaclient is a client-server initiation protocol framework, allowing a process (the "client") to either connect to another process (the "server") via a Unix domain socket, or spawn such a "server" process itself. The client and the server then communicate via two sockets, one for synchronous data, the other for asynchronous data; they exchange unixmessages.

The skaclient framework is used in several places in skarnet.org software, whenever a server can send asynchronous data to its client. For instance:

  • Communication between notification subscribers such as s6-ftrig-wait and their own s6-ftrigrd daemon
  • Communication between clients of the s6lock library and a s6lockd server
  • Communication between a client such as s6-dnsip4-filter, in need of asynchronous DNS service, and its own skadnsd daemon
  • The skabus Unix bus infrastructure is entirely based on the skaclient framework to transmit unixmessages across processes.

Programming

FIXME: to be completed.

skalibs-2.14.1.1/doc/libunixonacid/unix-timed.html000066400000000000000000000021221455624754300217500ustar00rootroot00000000000000 skalibs: the unix-timed library interface

libunixonacid
libskarnet
skalibs
Software
skarnet.org

The unix-timed library interface

The following functions are declared in the skalibs/unix-timed.h header, and implemented in the libskarnet.a or libskarnet.so library.

General information

FIXME: to be completed.

skalibs-2.14.1.1/doc/libunixonacid/unix-transactional.html000066400000000000000000000021761455624754300235210ustar00rootroot00000000000000 skalibs: the unix-transactional library interface

libunixonacid
libskarnet
skalibs
Software
www.skarnet.org

The unix-transactional library interface

The following functions are declared in the skalibs/unix-transactional.h header, and implemented in the libskarnet.a or libskarnet.so library.

General information

FIXME: to be completed.

skalibs-2.14.1.1/doc/libunixonacid/unixmessage.html000066400000000000000000000024401455624754300222200ustar00rootroot00000000000000 skalibs: the unixmessage library interface

libunixonacid
libskarnet
skalibs
Software
skarnet.org

The unixmessage library interface

The following functions are declared in the skalibs/unixmessage.h header, and implemented in the libskarnet.a or libskarnet.so library.

General information

unixmessage implements message transmission over Unix domain sockets. Messages are made of standard untyped data (strings), but can also include file descriptors using fd-passing.

FIXME: To be completed.

skalibs-2.14.1.1/doc/license.html000066400000000000000000000056451455624754300164740ustar00rootroot00000000000000 skalibs: license

skalibs
Software
skarnet.org

skalibs license

Source code

The skalibs source code from skalibs is released under the ISC license, the text of which can be found in the COPYING file enclosed in the package.

The license has been chosen for its simplicity - it's short and to the point - and above all its permissivity. There is nothing legitimate you should not be able to do with the skalibs code. If the license somehow stands in the way, please let me know.

Documentation

However, the skalibs documentation, which you are currently reading, and which is available in the doc/ subdirectory of the official skalibs tarball, is not provided under the same license.

The license for the skalibs documentation is more restrictive than the license for the source code. Namely:

  • The exact same disclaimer applies.
  • You have the right to download, use and modify the documentation.
  • You have the right to distribute unmodified copies of the documentation.
  • You have the right to distribute modified copies of the documentation, provided that:
    • The contents and links (not necessarily the appearance) of this file, license.html, are left unmodified;
    • On your documentation's main page, you explicitly state that the documentation has been modified, and you set up a link to the original skalibs site, explicitly stating that the original software and documentation can be found there;
    • The parts of the documentation that you have modified are unarguably and undeniably distinguishable from the unmodified parts. You can, for instance, use a different text color, different background color, or different text font.

I am aware that the previous restrictions sound completely ridiculous while the official skalibs documentation is incomplete. As of 2.14.1.1, I'm not going to enforce those restrictions, but if you're going to provide documentation for skalibs, don't keep it to yourself, please send it to me instead. :-)

skalibs-2.14.1.1/doc/upgrade.html000066400000000000000000000413011455624754300164660ustar00rootroot00000000000000 skalibs: how to upgrade

skalibs
Software
skarnet.org

in 2.14.1.1

  • No functional changes.

in 2.14.1.0

  • New ip46.h macros: socket_sendnb46_g() and socket_recvnb46_g()

in 2.14.0.1

  • No functional changes.

in 2.14.0.0

  • New selfpipe accessor function: selfpipe_fd()
  • New djbunix functions: slurpn(), openslurpnclose()
  • slurp and openslurpclose are now macros
  • New cdb functions: cdb_hashv(), cdbmake_addv()
  • New cspawn function, for posix_spawn/fork unification
  • child_spawn functions are now declared in cspawn.h
  • New sysdeps for posix_spawn options and more
  • case_lowerb() and friends now use ctype.h functions, supporting locale if it is declared in the application.
  • case_str() removed, strcasestr() fallback implementation added

in 2.13.1.1

  • No functional changes.

in 2.13.1.0

  • New macro: SKALIBS_PATH_MAX

in 2.13.0.0

  • New functions: buffer_timed_put(), buffer_timed_puts().

in 2.12.0.1

  • No functional changes.

in 2.12.0.0

  • random_init() and random_finish() removed, as well as random_char().
  • random_string() renamed to random_buf().
  • random functions now have an early version, to use when randomness is required before the generator can be seeded (i.e. in programs running in the very early boot).
  • New djbunix functions: waitn_posix(), waitn_reap_posix()

in 2.11.2.0

  • User-provided CPPFLAGS, CFLAGS and LDFLAGS are now honored during sysdeps autodetection.
  • envdir_internal() now has a SKALIBS_ENVDIR_NOCLAMP option allowing reading of unlimited-size variables.

in 2.11.1.0

  • fd_close() now chooses to adapt to Linux's close() behaviour (closing the fd on EINTR) over the HP-UX one (not closing it). Destructors like close() being allowed to fail has always been a mistake in the specification and a programming nightmare, making it impossible to behave correctly on all systems, but apparently standardization efforts are on the way and the Linux behaviour seems to be the chosen one.
  • New unix-transactional.h function: opendir_at.

in 2.11.0.0

  • libbiguint removed.
  • Obsolete skalibs/environ.h and skalibs/getpeereid.h headers removed.
  • rc4 and md5 functions removed.
  • iobuffer removed. fd_cat() and fd_catn() changed signatures.
  • All *_t types renamed without the _t suffix, in order to preserve POSIX namespace.
  • subgetopt() renamed to lgetopt().
  • All signal functions entirely reworked; cruft removed.
  • skalibs/cdb_make.h renamed to skalibs/cdbmake.h; cdbmake functions now return 1 on success and 0 on failure.
  • skalibs/cdb.h redesigned to remove reader state from the cdb structure itself.
  • The unsafe cdb_successor() API has been removed.
  • New skalibs/posixplz.h function: munmap_void().

in 2.10.0.3

  • No functional changes.

in 2.10.0.2

  • No functional changes.

in 2.10.0.1

  • No functional changes.

in 2.10.0.0

  • New openc_* functions, which are O_CLOEXEC versions of the djbunix.h open_* functions.
  • New ipc_bind_reuse_lock() function, which takes a lock before deleting a Unix domain socket. The ipc_bind_reuse() function now uses it, so it won't unconditionally clobber sockets in the filesystem anymore.
  • Complete revamping of the pathexec functions, see exec.h.
  • Revamping of the locking functions, see instead of adhoc DJBUNIX_FLAG_NB and DJBUNIX_FLAG_COE.
  • Better header separation; webipc.h removed (stuff moved to socket.h).
  • New mkptemp2() function, creating a fifo with a templated name and an option field for O_NONBLOCK and O_CLOEXEC.
  • New sysdep: chroot, testing whether the system has the chroot() function.

in 2.9.3.0

  • New function: stralloc_readyplus_tuned()

in 2.9.2.1

  • No functional changes.

in 2.9.2.0

  • New functions: bigkv_*

in 2.9.1.0

  • skalibs now works on GNU Hurd without patches.
  • New function: path_canonicalize

in 2.9.0.0

  • Formatting and scanning functions and macros have been refactored.
  • The configure script now emulates autotools-created configure scripts more closely. In particular, it's now possible to declare an out-of-path compiler in CC.
  • tain_* functions dealing with wall clocks and stopwatches have been refactored. The --enable-clock and --enable-monotonic configure switches have been removed. tain_now() can now be told at run time to use a wall clock (default, or via tain_now_set_wallclock()) or a stopwatch (via tain_now_set_stopwatch()), instead of it being fixed at build time.
  • Cross-compilation has been made a lot easier, by removing the need to provide a whole sysdeps directory anymore. Only a few sysdeps - the ones that need code execution on the target to be autodetected - have to be provided manually, via a --with-sysdep-K=V option to configure. Currently, that means one: --with-sysdep-devurandom=yes or --with-sysdep-devurandom=no.

in 2.8.1.0

  • New functions:
    • skalibs_regcomp(), which accepts empty regexes even when regcomp() does not (e.g. the BSDs).

in 2.8.0.1

  • Changes to skalibs/djbtime.h functions that produce UTC time: when a leap second is hit, utc_from_tai() now returns 2, and functions writing a struct tm put 60 into the struct's tm_sec field.

in 2.8.0.0

  • The avltreeb macros have been removed. Instead, the AVLTREEN_DECLARE_AND_INIT() macro has been added.
  • The mkdir_unique() function has been removed. (It duplicated the functionality of the standard mkdtemp() function.)
  • New functions: env_dump(), mk?temp(), autosurf(), autosurf_name()
  • The ancilautoclose and nbwaitall sysdeps have been removed.
  • New header: skalibs/posixishard.h
  • libskarnet.a now builds as PIC by default no matter the toolchain's settings. Use the --disable-all-pic configure option to build static libraries as non-PIC.

in 2.7.0.0

  • New functions: ipc_timed_sendv(), unlink_void(), skagetln_loose(), skagetlnsep_loose(), genset_deepfree(), gensetdyn_deepfree()
  • The dir_close() function now returns void and leaves errno unchanged.
  • The absolutepath() and sarealpath_tmp() functions, as well as the avl*_deletenode(), skalibs/mininetstring.h and prot families of functions, have been removed.
  • skalibs/djbunix.h does not include skalibs/env.h anymore.

in 2.6.4.0

in 2.6.3.1

  • No functional changes.

in 2.6.3.0

  • New dir_fd function wrapping dirfd() (Solaris doesn't have dirfd()).
  • memmem implementation for platforms that don't provide it.
  • memmem wrappers: byte_search, siovec_search.
  • New functions: atomic_symlink, skagetlnmaxsep, child_spawn3
  • New header: skalibs/posixplz.h. Some header reorganization.
  • New family of functions: skalibs/textmessage.h, skalibs/textclient.h
  • skalibs/environ.h and skalibs/getpeereid.h are now obsolescent.

in 2.6.2.0

  • New functions: access_at(), skaclient_timed_aflush().

in 2.6.1.0

in 2.6.0.2

  • No functional changes.

in 2.6.0.1

  • openwritenclose() and openwritevnclose() now use mkstemp() instead of relying on an unpredictable name (which required a random generator to be fully initialized).

in 2.6.0.0

  • New functions: unixmessage_receiver_hasmsginbuf(), skalibs_setgroups(), setgroups_with_egid(), setgroups_and_gid(). The setgroups_and_gid() function is the one that should be used, if possible: it does the right thing even on the BSDs. (That's an achievement.)

in 2.5.1.1

  • No functional changes.

in 2.5.1.0

What has changed in skalibs

in 2.5.0.0

  • Support for old versions of OpenBSD dropped. At least OpenBSD 5.7 and newer are still supported.
  • --enable-replace-libc compilation flag dropped
  • skalibs/ushort.h, skalibs/uint.h and skalibs/ulong.h removed. skalibs/types.h is now a generic header for fmtscan primitives for various types.
  • uint16, uint32 and uint64 types replaced with POSIX uint16_t, uint32_t and uint64_t.
  • APIs changed across all skalibs functions to support more POSIXly correct types. Main benefit: correct 64-bit support on 64-bit archs with 32-bit int.

in 2.4.0.2

  • No functional changes.

in 2.4.0.1

  • No functional changes.

in 2.4.0.0

  • More support for advanced fd callbacks in unixmessage_sender and unixconnection.
  • ipc_timed_send(), ipc_timed_recv()
  • rt.lib sysdep removed; spawn.lib and timer.lib sysdeps added
  • Leap second for 2016-12-31 23:59:60 UTC added
  • Complete librandom rewrite
  • skalibs/alarm.h added

in 2.3.10.0

  • Support for advanced fd callbacks in unixmessage_sender.

in 2.3.9.0

  • New functions: bitarray_firstclear_skip and bitarray_firstset_skip.

in 2.3.8.3

  • No functional changes.

in 2.3.8.2

  • No functional changes.

in 2.3.8.1

  • No functional changes.

in 2.3.8.0

  • The /etc/leapsecs.dat file is no longer necessary.

in 2.3.7.1

  • No functional changes.

in 2.3.7.0

  • New functions: atomic_rm_rf(), atomic_rm_rf_tmp().

in 2.3.6.1

  • No functional changes.

in 2.3.6.0

  • New function: openreadnclose_nb.

in 2.3.5.2

  • No functional changes.

in 2.3.5.1

  • No functional changes.

in 2.3.5.0

  • New functions: bitarray_count(), openwritevnclose_at()

in 2.3.4.0

  • New function: stat_at()
  • The rest of the changes are bugfixes or QoL.

in 2.3.3.0

  • New sha512 functions, see skalibs/sha512.h

in 2.3.2.0

  • New macro: gid0_scan()

in 2.3.1.3

  • Bugfix release, no functional changes.

in 2.3.1.2

  • The child_spawn* family of functions now resets all signals to their default values when spawning a program on systems with posix_spawn(). This should not change anything - it's just paranoia.
  • Minor bugfixes.

in 2.3.1.1

  • Bugfix release, no functional changes.

in 2.3.1.0

  • wait_status() now returns 256 + signal number when WIFSIGNALED().
  • new macro wait_estatus() to get WIFSIGNALED information in an exit code.
  • new functions in djbunix.h: hiercopy(), hiercopy_tmp()

in 2.3.0.1

  • wait_status() now returns 256 (instead of 126) when WIFSIGNALED().

in 2.3.0.0

  • buffer_getvall and buffer_putvall have a different interface. (And now work.)
  • buffer_read and buffer_write are now deprecated.
  • various siovec additions, such as siovec_trunc

in 2.2.1.0

  • unixconnection added.
  • sig_name and sig_number added.

in 2.2.0.0

  • TAI64 and TAI64N conversion functions revisited. API slightly changed, made more consistent.

in 2.1.0.0

  • unixmessage_drop added, part of unixmessage/skaclient hardening against fd leakage
  • unixmessage_sender_flush return code aligned with the convention in the rest of skalibs
  • unixmessage_sender_flush now handles short writes
  • skaclient_start(_async) prototype changed: now takes an option argument

in 2.0.0.0

  • The packaging system has completely changed.
  • Programs should now link with -lskarnet followed by the appropriate sysdeps links.
  • No compatibility is ensured. Most APIs haven't changed, but no guarantee is offered.
  • The most important change is probably the disparition of struct tai and struct taia, replaced with the tai_t and tain_t types. Attosecond precision has been removed - processor speed is almost capped now, and it looks like nanosecond precision will be enough for the foreseeable future.
  • Buffer implementation has changed, and some interfaces too, mainly the buffer_flush and bufalloc_flush return code.
  • skaclient, skalibs' client-server communication suite, has been entirely reimplemented: it's now using the new "unixmessage" set of primitives for easier fd-passing.
skalibs-2.14.1.1/package/000077500000000000000000000000001455624754300150005ustar00rootroot00000000000000skalibs-2.14.1.1/package/deps.mak000066400000000000000000004046051455624754300164360ustar00rootroot00000000000000# # This file has been generated by tools/gen-deps.sh # src/include/skalibs/alarm.h: src/include/skalibs/tai.h src/include/skalibs/alloc.h: src/include/skalibs/gccattributes.h src/include/skalibs/allreadwrite.h: src/include/skalibs/functypes.h src/include/skalibs/avlnode.h: src/include/skalibs/functypes.h src/include/skalibs/gccattributes.h src/include/skalibs/avltree.h: src/include/skalibs/avlnode.h src/include/skalibs/functypes.h src/include/skalibs/gensetdyn.h src/include/skalibs/avltreen.h: src/include/skalibs/avlnode.h src/include/skalibs/functypes.h src/include/skalibs/genset.h src/include/skalibs/bigkv.h: src/include/skalibs/avltree.h src/include/skalibs/genalloc.h src/include/skalibs/stralloc.h src/include/skalibs/bitarray.h: src/include/skalibs/gccattributes.h src/include/skalibs/bufalloc.h: src/include/skalibs/functypes.h src/include/skalibs/gccattributes.h src/include/skalibs/stralloc.h src/include/skalibs/buffer.h: src/include/skalibs/allreadwrite.h src/include/skalibs/cbuffer.h src/include/skalibs/functypes.h src/include/skalibs/gccattributes.h src/include/skalibs/bytestr.h: src/include/skalibs/gccattributes.h src/include/skalibs/cbuffer.h: src/include/skalibs/gccattributes.h src/include/skalibs/cdb.h: src/include/skalibs/gccattributes.h src/include/skalibs/cdbmake.h: src/include/skalibs/buffer.h src/include/skalibs/genalloc.h src/include/skalibs/datastruct.h: src/include/skalibs/avlnode.h src/include/skalibs/avltree.h src/include/skalibs/avltreen.h src/include/skalibs/bigkv.h src/include/skalibs/genqdyn.h src/include/skalibs/genset.h src/include/skalibs/gensetdyn.h src/include/skalibs/djbtime.h: src/include/skalibs/tai.h src/include/skalibs/uint64.h src/include/skalibs/djbunix.h: src/include/skalibs/devino.h src/include/skalibs/gccattributes.h src/include/skalibs/stralloc.h src/include/skalibs/env.h: src/include/skalibs/gccattributes.h src/include/skalibs/stralloc.h src/include/skalibs/envalloc.h: src/include/skalibs/genalloc.h src/include/skalibs/error.h: src/include/skalibs/gccattributes.h src/include/skalibs/exec.h: src/include/skalibs/env.h src/include/skalibs/gccattributes.h src/include/skalibs/posixplz.h src/include/skalibs/fmtscan.h: src/include/skalibs/gccattributes.h src/include/skalibs/genalloc.h: src/include/skalibs/functypes.h src/include/skalibs/stralloc.h src/include/skalibs/genqdyn.h: src/include/skalibs/stralloc.h src/include/skalibs/genset.h: src/include/skalibs/functypes.h src/include/skalibs/gensetdyn.h: src/include/skalibs/functypes.h src/include/skalibs/genalloc.h src/include/skalibs/stralloc.h src/include/skalibs/iopause.h: src/include/skalibs/tai.h src/include/skalibs/kolbak.h: src/include/skalibs/unixmessage.h src/include/skalibs/lolstdio.h: src/include/skalibs/bufalloc.h src/include/skalibs/buffer.h src/include/skalibs/strerr.h src/include/skalibs/netstring.h: src/include/skalibs/buffer.h src/include/skalibs/stralloc.h src/include/skalibs/posixishard.h: src/include/skalibs/gccattributes.h src/include/skalibs/stat.h src/include/skalibs/posixplz.h: src/include/skalibs/functypes.h src/include/skalibs/gccattributes.h src/include/skalibs/random.h: src/include/skalibs/functypes.h src/include/skalibs/stralloc.h src/include/skalibs/setgroups.h: src/include/skalibs/sysdeps.h src/include/skalibs/sha512.h: src/include/skalibs/uint64.h src/include/skalibs/sig.h: src/include/skalibs/gccattributes.h src/include/skalibs/siovec.h: src/include/skalibs/gccattributes.h src/include/skalibs/skaclient.h: src/include/skalibs/kolbak.h src/include/skalibs/tai.h src/include/skalibs/unixmessage.h src/include/skalibs/skalibs.h: src/include/skalibs/datastruct.h src/include/skalibs/posixplz.h src/include/skalibs/random.h src/include/skalibs/stdcrypto.h src/include/skalibs/stddjb.h src/include/skalibs/strerr.h src/include/skalibs/unixonacid.h src/include/skalibs/skamisc.h: src/include/skalibs/buffer.h src/include/skalibs/stralloc.h src/include/skalibs/socket.h: src/include/skalibs/gccattributes.h src/include/skalibs/posixplz.h src/include/skalibs/tai.h src/include/skalibs/stat.h: src/include/skalibs/sysdeps.h src/include/skalibs/stdcrypto.h: src/include/skalibs/blake2s.h src/include/skalibs/sha1.h src/include/skalibs/sha256.h src/include/skalibs/sha512.h src/include/skalibs/stddjb.h: src/include/skalibs/alarm.h src/include/skalibs/alloc.h src/include/skalibs/allreadwrite.h src/include/skalibs/bitarray.h src/include/skalibs/bufalloc.h src/include/skalibs/buffer.h src/include/skalibs/bytestr.h src/include/skalibs/cbuffer.h src/include/skalibs/cdb.h src/include/skalibs/cdbmake.h src/include/skalibs/cspawn.h src/include/skalibs/devino.h src/include/skalibs/direntry.h src/include/skalibs/disize.h src/include/skalibs/diuint.h src/include/skalibs/diuint32.h src/include/skalibs/djbtime.h src/include/skalibs/djbunix.h src/include/skalibs/env.h src/include/skalibs/envalloc.h src/include/skalibs/error.h src/include/skalibs/exec.h src/include/skalibs/fmtscan.h src/include/skalibs/functypes.h src/include/skalibs/gccattributes.h src/include/skalibs/genalloc.h src/include/skalibs/genwrite.h src/include/skalibs/iopause.h src/include/skalibs/ip46.h src/include/skalibs/lolstdio.h src/include/skalibs/netstring.h src/include/skalibs/segfault.h src/include/skalibs/selfpipe.h src/include/skalibs/setgroups.h src/include/skalibs/sgetopt.h src/include/skalibs/sig.h src/include/skalibs/siovec.h src/include/skalibs/skamisc.h src/include/skalibs/socket.h src/include/skalibs/stralloc.h src/include/skalibs/tai.h src/include/skalibs/types.h src/include/skalibs/uint16.h src/include/skalibs/uint32.h src/include/skalibs/uint64.h src/include/skalibs/strerr.h: src/include/skalibs/gccattributes.h src/include/skalibs/strerr2.h: src/include/skalibs/strerr.h src/include/skalibs/tai.h: src/include/skalibs/gccattributes.h src/include/skalibs/uint64.h src/include/skalibs/textclient.h: src/include/skalibs/allreadwrite.h src/include/skalibs/tai.h src/include/skalibs/textmessage.h src/include/skalibs/textmessage.h: src/include/skalibs/allreadwrite.h src/include/skalibs/bufalloc.h src/include/skalibs/buffer.h src/include/skalibs/gccattributes.h src/include/skalibs/stralloc.h src/include/skalibs/tai.h src/include/skalibs/unix-timed.h: src/include/skalibs/bufalloc.h src/include/skalibs/buffer.h src/include/skalibs/functypes.h src/include/skalibs/stralloc.h src/include/skalibs/tai.h src/include/skalibs/unix-transactional.h: src/include/skalibs/direntry.h src/include/skalibs/stralloc.h src/include/skalibs/unixconnection.h: src/include/skalibs/unixmessage.h src/include/skalibs/unixmessage.h: src/include/skalibs/buffer.h src/include/skalibs/cbuffer.h src/include/skalibs/gccattributes.h src/include/skalibs/genalloc.h src/include/skalibs/stralloc.h src/include/skalibs/tai.h src/include/skalibs/unixonacid.h: src/include/skalibs/ancil.h src/include/skalibs/kolbak.h src/include/skalibs/skaclient.h src/include/skalibs/textclient.h src/include/skalibs/textmessage.h src/include/skalibs/unix-timed.h src/include/skalibs/unix-transactional.h src/include/skalibs/unixconnection.h src/include/skalibs/unixmessage.h src/libdatastruct/avlnode-internal.h: src/include/skalibs/avlnode.h src/libdatastruct/genqdyn-internal.h: src/include/skalibs/genqdyn.h src/libenvexec/envdir-internal.h: src/include/skalibs/stralloc.h src/libstdcrypto/blake2s-internal.h: src/include/skalibs/blake2s.h src/libstdcrypto/sha1-internal.h: src/include/skalibs/sha1.h src/libstdcrypto/sha256-internal.h: src/include/skalibs/sha256.h src/libstdcrypto/sha512-internal.h: src/include/skalibs/sha512.h src/libstddjb/cdb-internal.h: src/include/skalibs/cdb.h src/include/skalibs/gccattributes.h src/libstddjb/cdbmake-internal.h: src/include/skalibs/cdbmake.h src/libstddjb/djbtime-internal.h: src/include/skalibs/uint64.h src/libstddjb/fmtscan-internal.h: src/include/skalibs/fmtscan.h src/include/skalibs/uint64.h src/libunixonacid/skaclient-internal.h: src/include/skalibs/kolbak.h src/include/skalibs/skaclient.h src/include/skalibs/unixmessage.h src/libdatastruct/avlnode_delete.o src/libdatastruct/avlnode_delete.lo: src/libdatastruct/avlnode_delete.c src/libdatastruct/avlnode-internal.h src/include/skalibs/avlnode.h src/libdatastruct/avlnode_doublerotate.o src/libdatastruct/avlnode_doublerotate.lo: src/libdatastruct/avlnode_doublerotate.c src/libdatastruct/avlnode-internal.h src/include/skalibs/avlnode.h src/libdatastruct/avlnode_extreme.o src/libdatastruct/avlnode_extreme.lo: src/libdatastruct/avlnode_extreme.c src/include/skalibs/avlnode.h src/libdatastruct/avlnode_extremenode.o src/libdatastruct/avlnode_extremenode.lo: src/libdatastruct/avlnode_extremenode.c src/include/skalibs/avlnode.h src/libdatastruct/avlnode_height.o src/libdatastruct/avlnode_height.lo: src/libdatastruct/avlnode_height.c src/include/skalibs/avlnode.h src/libdatastruct/avlnode_insertnode.o src/libdatastruct/avlnode_insertnode.lo: src/libdatastruct/avlnode_insertnode.c src/libdatastruct/avlnode-internal.h src/include/skalibs/avlnode.h src/libdatastruct/avlnode_iter.o src/libdatastruct/avlnode_iter.lo: src/libdatastruct/avlnode_iter.c src/include/skalibs/avlnode.h src/libdatastruct/avlnode_iter_withcancel.o src/libdatastruct/avlnode_iter_withcancel.lo: src/libdatastruct/avlnode_iter_withcancel.c src/include/skalibs/avlnode.h src/libdatastruct/avlnode_rotate.o src/libdatastruct/avlnode_rotate.lo: src/libdatastruct/avlnode_rotate.c src/libdatastruct/avlnode-internal.h src/include/skalibs/avlnode.h src/libdatastruct/avlnode_search.o src/libdatastruct/avlnode_search.lo: src/libdatastruct/avlnode_search.c src/include/skalibs/avlnode.h src/libdatastruct/avlnode_searchnode.o src/libdatastruct/avlnode_searchnode.lo: src/libdatastruct/avlnode_searchnode.c src/libdatastruct/avlnode-internal.h src/include/skalibs/avlnode.h src/libdatastruct/avlnode_zero.o src/libdatastruct/avlnode_zero.lo: src/libdatastruct/avlnode_zero.c src/include/skalibs/avlnode.h src/libdatastruct/avltree_delete.o src/libdatastruct/avltree_delete.lo: src/libdatastruct/avltree_delete.c src/include/skalibs/avlnode.h src/include/skalibs/avltree.h src/include/skalibs/gensetdyn.h src/libdatastruct/avltree_free.o src/libdatastruct/avltree_free.lo: src/libdatastruct/avltree_free.c src/include/skalibs/avltree.h src/include/skalibs/gensetdyn.h src/libdatastruct/avltree_init.o src/libdatastruct/avltree_init.lo: src/libdatastruct/avltree_init.c src/include/skalibs/avlnode.h src/include/skalibs/avltree.h src/include/skalibs/gensetdyn.h src/libdatastruct/avltree_insert.o src/libdatastruct/avltree_insert.lo: src/libdatastruct/avltree_insert.c src/include/skalibs/avltree.h src/libdatastruct/avltree_newnode.o src/libdatastruct/avltree_newnode.lo: src/libdatastruct/avltree_newnode.c src/include/skalibs/avlnode.h src/include/skalibs/avltree.h src/include/skalibs/gensetdyn.h src/libdatastruct/avltree_zero.o src/libdatastruct/avltree_zero.lo: src/libdatastruct/avltree_zero.c src/include/skalibs/avltree.h src/libdatastruct/avltreen_delete.o src/libdatastruct/avltreen_delete.lo: src/libdatastruct/avltreen_delete.c src/include/skalibs/avlnode.h src/include/skalibs/avltreen.h src/include/skalibs/genset.h src/libdatastruct/avltreen_init.o src/libdatastruct/avltreen_init.lo: src/libdatastruct/avltreen_init.c src/include/skalibs/avlnode.h src/include/skalibs/avltreen.h src/include/skalibs/genset.h src/libdatastruct/avltreen_insert.o src/libdatastruct/avltreen_insert.lo: src/libdatastruct/avltreen_insert.c src/include/skalibs/avltreen.h src/libdatastruct/avltreen_newnode.o src/libdatastruct/avltreen_newnode.lo: src/libdatastruct/avltreen_newnode.c src/include/skalibs/avlnode.h src/include/skalibs/avltreen.h src/include/skalibs/genset.h src/libdatastruct/bigkv_fill.o src/libdatastruct/bigkv_fill.lo: src/libdatastruct/bigkv_fill.c src/include/skalibs/avltree.h src/include/skalibs/bigkv.h src/include/skalibs/bytestr.h src/include/skalibs/genalloc.h src/include/skalibs/stralloc.h src/libdatastruct/bigkv_free.o src/libdatastruct/bigkv_free.lo: src/libdatastruct/bigkv_free.c src/include/skalibs/avltree.h src/include/skalibs/bigkv.h src/include/skalibs/genalloc.h src/include/skalibs/stralloc.h src/libdatastruct/bigkv_search.o src/libdatastruct/bigkv_search.lo: src/libdatastruct/bigkv_search.c src/include/skalibs/avltree.h src/include/skalibs/bigkv.h src/include/skalibs/genalloc.h src/libdatastruct/bigkv_zero.o src/libdatastruct/bigkv_zero.lo: src/libdatastruct/bigkv_zero.c src/include/skalibs/bigkv.h src/libdatastruct/genqdyn_clean.o src/libdatastruct/genqdyn_clean.lo: src/libdatastruct/genqdyn_clean.c src/libdatastruct/genqdyn-internal.h src/libdatastruct/genqdyn_free.o src/libdatastruct/genqdyn_free.lo: src/libdatastruct/genqdyn_free.c src/include/skalibs/genqdyn.h src/include/skalibs/stralloc.h src/libdatastruct/genqdyn_init.o src/libdatastruct/genqdyn_init.lo: src/libdatastruct/genqdyn_init.c src/include/skalibs/genqdyn.h src/include/skalibs/stralloc.h src/libdatastruct/genqdyn_pop.o src/libdatastruct/genqdyn_pop.lo: src/libdatastruct/genqdyn_pop.c src/libdatastruct/genqdyn-internal.h src/include/skalibs/genqdyn.h src/libdatastruct/genqdyn_push.o src/libdatastruct/genqdyn_push.lo: src/libdatastruct/genqdyn_push.c src/include/skalibs/genqdyn.h src/include/skalibs/stralloc.h src/libdatastruct/genqdyn_unpush.o src/libdatastruct/genqdyn_unpush.lo: src/libdatastruct/genqdyn_unpush.c src/include/skalibs/genqdyn.h src/include/skalibs/stralloc.h src/libdatastruct/genqdyn_zero.o src/libdatastruct/genqdyn_zero.lo: src/libdatastruct/genqdyn_zero.c src/include/skalibs/genqdyn.h src/libdatastruct/genset.o src/libdatastruct/genset.lo: src/libdatastruct/genset.c src/include/skalibs/genset.h src/libdatastruct/genset_deepfree.o src/libdatastruct/genset_deepfree.lo: src/libdatastruct/genset_deepfree.c src/include/skalibs/functypes.h src/include/skalibs/genset.h src/libdatastruct/genset_iter_nocancel.o src/libdatastruct/genset_iter_nocancel.lo: src/libdatastruct/genset_iter_nocancel.c src/include/skalibs/bitarray.h src/include/skalibs/genset.h src/libdatastruct/genset_iter_withcancel.o src/libdatastruct/genset_iter_withcancel.lo: src/libdatastruct/genset_iter_withcancel.c src/include/skalibs/genset.h src/libdatastruct/gensetdyn_deepfree.o src/libdatastruct/gensetdyn_deepfree.lo: src/libdatastruct/gensetdyn_deepfree.c src/include/skalibs/functypes.h src/include/skalibs/gensetdyn.h src/libdatastruct/gensetdyn_delete.o src/libdatastruct/gensetdyn_delete.lo: src/libdatastruct/gensetdyn_delete.c src/include/skalibs/genalloc.h src/include/skalibs/gensetdyn.h src/libdatastruct/gensetdyn_free.o src/libdatastruct/gensetdyn_free.lo: src/libdatastruct/gensetdyn_free.c src/include/skalibs/genalloc.h src/include/skalibs/gensetdyn.h src/include/skalibs/stralloc.h src/libdatastruct/gensetdyn_init.o src/libdatastruct/gensetdyn_init.lo: src/libdatastruct/gensetdyn_init.c src/include/skalibs/genalloc.h src/include/skalibs/gensetdyn.h src/include/skalibs/stralloc.h src/libdatastruct/gensetdyn_iter_nocancel.o src/libdatastruct/gensetdyn_iter_nocancel.lo: src/libdatastruct/gensetdyn_iter_nocancel.c src/include/skalibs/bitarray.h src/include/skalibs/gensetdyn.h src/libdatastruct/gensetdyn_iter_withcancel.o src/libdatastruct/gensetdyn_iter_withcancel.lo: src/libdatastruct/gensetdyn_iter_withcancel.c src/include/skalibs/gensetdyn.h src/libdatastruct/gensetdyn_new.o src/libdatastruct/gensetdyn_new.lo: src/libdatastruct/gensetdyn_new.c src/include/skalibs/genalloc.h src/include/skalibs/gensetdyn.h src/libdatastruct/gensetdyn_ready.o src/libdatastruct/gensetdyn_ready.lo: src/libdatastruct/gensetdyn_ready.c src/include/skalibs/genalloc.h src/include/skalibs/gensetdyn.h src/include/skalibs/stralloc.h src/libdatastruct/gensetdyn_zero.o src/libdatastruct/gensetdyn_zero.lo: src/libdatastruct/gensetdyn_zero.c src/include/skalibs/gensetdyn.h src/libenvexec/env_addmodif.o src/libenvexec/env_addmodif.lo: src/libenvexec/env_addmodif.c src/include/skalibs/env.h src/include/skalibs/stralloc.h src/libenvexec/env_dump.o src/libenvexec/env_dump.lo: src/libenvexec/env_dump.c src/include/skalibs/bytestr.h src/include/skalibs/djbunix.h src/include/skalibs/env.h src/include/skalibs/nonposix.h src/include/skalibs/unix-transactional.h src/libenvexec/env_get.o src/libenvexec/env_get.lo: src/libenvexec/env_get.c src/include/skalibs/posixplz.h src/libenvexec/env_get2.o src/libenvexec/env_get2.lo: src/libenvexec/env_get2.c src/include/skalibs/bytestr.h src/include/skalibs/env.h src/libenvexec/env_len.o src/libenvexec/env_len.lo: src/libenvexec/env_len.c src/include/skalibs/env.h src/libenvexec/env_make.o src/libenvexec/env_make.lo: src/libenvexec/env_make.c src/include/skalibs/env.h src/libenvexec/env_merg.o src/libenvexec/env_merg.lo: src/libenvexec/env_merg.c src/include/skalibs/env.h src/libenvexec/env_merge.o src/libenvexec/env_merge.lo: src/libenvexec/env_merge.c src/include/skalibs/bytestr.h src/include/skalibs/env.h src/libenvexec/env_mergen.o src/libenvexec/env_mergen.lo: src/libenvexec/env_mergen.c src/include/skalibs/bytestr.h src/include/skalibs/env.h src/libenvexec/env_mergn.o src/libenvexec/env_mergn.lo: src/libenvexec/env_mergn.c src/include/skalibs/env.h src/libenvexec/env_string.o src/libenvexec/env_string.lo: src/libenvexec/env_string.c src/include/skalibs/env.h src/include/skalibs/stralloc.h src/libenvexec/envalloc_0.o src/libenvexec/envalloc_0.lo: src/libenvexec/envalloc_0.c src/include/skalibs/envalloc.h src/include/skalibs/genalloc.h src/libenvexec/envalloc_make.o src/libenvexec/envalloc_make.lo: src/libenvexec/envalloc_make.c src/include/skalibs/env.h src/include/skalibs/envalloc.h src/include/skalibs/genalloc.h src/libenvexec/envalloc_merge.o src/libenvexec/envalloc_merge.lo: src/libenvexec/envalloc_merge.c src/include/skalibs/bytestr.h src/include/skalibs/env.h src/include/skalibs/envalloc.h src/include/skalibs/genalloc.h src/libenvexec/envalloc_uniq.o src/libenvexec/envalloc_uniq.lo: src/libenvexec/envalloc_uniq.c src/include/skalibs/bytestr.h src/include/skalibs/envalloc.h src/include/skalibs/genalloc.h src/libenvexec/envdir.o src/libenvexec/envdir.lo: src/libenvexec/envdir.c src/include/skalibs/env.h src/libenvexec/envdir-internal.h src/libenvexec/envdir_clamp.o src/libenvexec/envdir_clamp.lo: src/libenvexec/envdir_clamp.c src/include/skalibs/bytestr.h src/include/skalibs/direntry.h src/include/skalibs/djbunix.h src/include/skalibs/env.h src/libenvexec/envdir-internal.h src/include/skalibs/stralloc.h src/libenvexec/envdir_noclamp.o src/libenvexec/envdir_noclamp.lo: src/libenvexec/envdir_noclamp.c src/include/skalibs/buffer.h src/include/skalibs/bytestr.h src/include/skalibs/direntry.h src/include/skalibs/djbunix.h src/include/skalibs/env.h src/libenvexec/envdir-internal.h src/include/skalibs/skamisc.h src/include/skalibs/stralloc.h src/libenvexec/exec0_ae.o src/libenvexec/exec0_ae.lo: src/libenvexec/exec0_ae.c src/include/skalibs/exec.h src/libenvexec/exec_ae.o src/libenvexec/exec_ae.lo: src/libenvexec/exec_ae.c src/include/skalibs/config.h src/include/skalibs/exec.h src/include/skalibs/posixplz.h src/libenvexec/mexec0_af.o src/libenvexec/mexec0_af.lo: src/libenvexec/mexec0_af.c src/include/skalibs/exec.h src/libenvexec/mexec0_afm.o src/libenvexec/mexec0_afm.lo: src/libenvexec/mexec0_afm.c src/include/skalibs/exec.h src/libenvexec/mexec0_afn.o src/libenvexec/mexec0_afn.lo: src/libenvexec/mexec0_afn.c src/include/skalibs/exec.h src/libenvexec/mexec_af.o src/libenvexec/mexec_af.lo: src/libenvexec/mexec_af.c src/include/skalibs/env.h src/include/skalibs/exec.h src/include/skalibs/stralloc.h src/libenvexec/mexec_afm.o src/libenvexec/mexec_afm.lo: src/libenvexec/mexec_afm.c src/include/skalibs/bytestr.h src/include/skalibs/exec.h src/libenvexec/mexec_afn.o src/libenvexec/mexec_afn.lo: src/libenvexec/mexec_afn.c src/include/skalibs/env.h src/include/skalibs/exec.h src/libenvexec/xexec0_ae.o src/libenvexec/xexec0_ae.lo: src/libenvexec/xexec0_ae.c src/include/skalibs/exec.h src/libenvexec/xexec_ae.o src/libenvexec/xexec_ae.lo: src/libenvexec/xexec_ae.c src/include/skalibs/exec.h src/include/skalibs/strerr.h src/libenvexec/xexecvep.o src/libenvexec/xexecvep.lo: src/libenvexec/xexecvep.c src/include/skalibs/exec.h src/include/skalibs/posixplz.h src/include/skalibs/strerr.h src/libenvexec/xexecvep_loose.o src/libenvexec/xexecvep_loose.lo: src/libenvexec/xexecvep_loose.c src/include/skalibs/exec.h src/include/skalibs/posixplz.h src/include/skalibs/strerr.h src/libenvexec/xmexec0_af.o src/libenvexec/xmexec0_af.lo: src/libenvexec/xmexec0_af.c src/include/skalibs/exec.h src/include/skalibs/strerr.h src/libenvexec/xmexec0_afm.o src/libenvexec/xmexec0_afm.lo: src/libenvexec/xmexec0_afm.c src/include/skalibs/exec.h src/include/skalibs/strerr.h src/libenvexec/xmexec0_afn.o src/libenvexec/xmexec0_afn.lo: src/libenvexec/xmexec0_afn.c src/include/skalibs/exec.h src/include/skalibs/strerr.h src/libenvexec/xmexec_af.o src/libenvexec/xmexec_af.lo: src/libenvexec/xmexec_af.c src/include/skalibs/exec.h src/include/skalibs/strerr.h src/libenvexec/xmexec_afm.o src/libenvexec/xmexec_afm.lo: src/libenvexec/xmexec_afm.c src/include/skalibs/exec.h src/include/skalibs/strerr.h src/libenvexec/xmexec_afn.o src/libenvexec/xmexec_afn.lo: src/libenvexec/xmexec_afn.c src/include/skalibs/exec.h src/include/skalibs/strerr.h src/libposixplz/doublefork.o src/libposixplz/doublefork.lo: src/libposixplz/doublefork.c src/include/skalibs/allreadwrite.h src/include/skalibs/djbunix.h src/include/skalibs/posixplz.h src/include/skalibs/uint64.h src/libposixplz/execvep.o src/libposixplz/execvep.lo: src/libposixplz/execvep.c src/libposixplz/posixplz-internal.h src/include/skalibs/posixplz.h src/libposixplz/execvep_internal.o src/libposixplz/execvep_internal.lo: src/libposixplz/execvep_internal.c src/include/skalibs/bytestr.h src/include/skalibs/posixplz.h src/libposixplz/execvep_loose.o src/libposixplz/execvep_loose.lo: src/libposixplz/execvep_loose.c src/libposixplz/posixplz-internal.h src/include/skalibs/posixplz.h src/libposixplz/getpeereid.o src/libposixplz/getpeereid.lo: src/libposixplz/getpeereid.c src/include/skalibs/nonposix.h src/include/skalibs/posixplz.h src/include/skalibs/sysdeps.h src/libposixplz/memmem.o src/libposixplz/memmem.lo: src/libposixplz/memmem.c src/include/skalibs/posixplz.h src/include/skalibs/sysdeps.h src/libposixplz/mkbtemp.o src/libposixplz/mkbtemp.lo: src/libposixplz/mkbtemp.c src/include/skalibs/djbunix.h src/include/skalibs/posixplz.h src/libposixplz/mkctemp.o src/libposixplz/mkctemp.lo: src/libposixplz/mkctemp.c src/include/skalibs/djbunix.h src/include/skalibs/posixplz.h src/libposixplz/mkfiletemp.o src/libposixplz/mkfiletemp.lo: src/libposixplz/mkfiletemp.c src/include/skalibs/posixplz.h src/include/skalibs/random.h src/libposixplz/mkhtemp.o src/libposixplz/mkhtemp.lo: src/libposixplz/mkhtemp.c src/include/skalibs/posixplz.h src/libposixplz/mklinktemp.o src/libposixplz/mklinktemp.lo: src/libposixplz/mklinktemp.c src/include/skalibs/djbunix.h src/libposixplz/posixplz-internal.h src/include/skalibs/posixplz.h src/libposixplz/mkltemp.o src/libposixplz/mkltemp.lo: src/libposixplz/mkltemp.c src/include/skalibs/posixplz.h src/libposixplz/mkptemp.o src/libposixplz/mkptemp.lo: src/libposixplz/mkptemp.c src/include/skalibs/posixplz.h src/libposixplz/mkptemp2.o src/libposixplz/mkptemp2.lo: src/libposixplz/mkptemp2.c src/include/skalibs/djbunix.h src/include/skalibs/posixplz.h src/libposixplz/munmap_void.o src/libposixplz/munmap_void.lo: src/libposixplz/munmap_void.c src/include/skalibs/posixplz.h src/libposixplz/setgroups.o src/libposixplz/setgroups.lo: src/libposixplz/setgroups.c src/include/skalibs/nonposix.h src/include/skalibs/posixishard.h src/include/skalibs/setgroups.h src/include/skalibs/sysdeps.h src/libposixplz/strcasestr.o src/libposixplz/strcasestr.lo: src/libposixplz/strcasestr.c src/include/skalibs/bytestr.h src/include/skalibs/sysdeps.h src/libposixplz/strnlen.o src/libposixplz/strnlen.lo: src/libposixplz/strnlen.c src/include/skalibs/bytestr.h src/include/skalibs/posixishard.h src/include/skalibs/sysdeps.h src/libposixplz/touch.o src/libposixplz/touch.lo: src/libposixplz/touch.c src/include/skalibs/djbunix.h src/include/skalibs/nonposix.h src/include/skalibs/posixplz.h src/include/skalibs/sysdeps.h src/libposixplz/unlink_void.o src/libposixplz/unlink_void.lo: src/libposixplz/unlink_void.c src/include/skalibs/posixplz.h src/librandom/autosurf.o src/librandom/autosurf.lo: src/librandom/autosurf.c src/include/skalibs/sha1.h src/include/skalibs/surf.h src/include/skalibs/tai.h src/include/skalibs/uint32.h src/librandom/autosurf_name.o src/librandom/autosurf_name.lo: src/librandom/autosurf_name.c src/include/skalibs/random.h src/include/skalibs/surf.h src/librandom/random_buf.o src/librandom/random_buf.lo: src/librandom/random_buf.c src/include/skalibs/nonposix.h src/include/skalibs/random.h src/include/skalibs/surf.h src/include/skalibs/sysdeps.h src/librandom/random_buf_early.o src/librandom/random_buf_early.lo: src/librandom/random_buf_early.c src/include/skalibs/nonposix.h src/include/skalibs/random.h src/include/skalibs/surf.h src/include/skalibs/sysdeps.h src/librandom/random_devurandom.o src/librandom/random_devurandom.lo: src/librandom/random_devurandom.c src/include/skalibs/allreadwrite.h src/include/skalibs/djbunix.h src/include/skalibs/random.h src/include/skalibs/strerr.h src/librandom/random_name_from.o src/librandom/random_name_from.lo: src/librandom/random_name_from.c src/include/skalibs/functypes.h src/include/skalibs/random.h src/librandom/random_sauniquename_from.o src/librandom/random_sauniquename_from.lo: src/librandom/random_sauniquename_from.c src/include/skalibs/random.h src/include/skalibs/skamisc.h src/include/skalibs/stralloc.h src/librandom/random_uint32_from.o src/librandom/random_uint32_from.lo: src/librandom/random_uint32_from.c src/include/skalibs/functypes.h src/include/skalibs/random.h src/include/skalibs/uint32.h src/librandom/random_unsort_from.o src/librandom/random_unsort_from.lo: src/librandom/random_unsort_from.c src/include/skalibs/random.h src/librandom/surf.o src/librandom/surf.lo: src/librandom/surf.c src/include/skalibs/surf.h src/include/skalibs/uint32.h src/librandom/surf_init.o src/librandom/surf_init.lo: src/librandom/surf_init.c src/include/skalibs/surf.h src/include/skalibs/uint32.h src/libstdcrypto/blake2s_final.o src/libstdcrypto/blake2s_final.lo: src/libstdcrypto/blake2s_final.c src/libstdcrypto/blake2s-internal.h src/include/skalibs/blake2s.h src/include/skalibs/uint32.h src/libstdcrypto/blake2s_init.o src/libstdcrypto/blake2s_init.lo: src/libstdcrypto/blake2s_init.c src/include/skalibs/blake2s.h src/libstdcrypto/blake2s_transform.o src/libstdcrypto/blake2s_transform.lo: src/libstdcrypto/blake2s_transform.c src/libstdcrypto/blake2s-internal.h src/include/skalibs/blake2s.h src/include/skalibs/uint32.h src/libstdcrypto/blake2s_update.o src/libstdcrypto/blake2s_update.lo: src/libstdcrypto/blake2s_update.c src/libstdcrypto/blake2s-internal.h src/include/skalibs/blake2s.h src/libstdcrypto/sha1_feed.o src/libstdcrypto/sha1_feed.lo: src/libstdcrypto/sha1_feed.c src/include/skalibs/bytestr.h src/libstdcrypto/sha1-internal.h src/include/skalibs/sha1.h src/libstdcrypto/sha1_final.o src/libstdcrypto/sha1_final.lo: src/libstdcrypto/sha1_final.c src/libstdcrypto/sha1-internal.h src/include/skalibs/sha1.h src/include/skalibs/uint32.h src/libstdcrypto/sha1_init.o src/libstdcrypto/sha1_init.lo: src/libstdcrypto/sha1_init.c src/include/skalibs/sha1.h src/libstdcrypto/sha1_transform.o src/libstdcrypto/sha1_transform.lo: src/libstdcrypto/sha1_transform.c src/libstdcrypto/sha1-internal.h src/libstdcrypto/sha1_update.o src/libstdcrypto/sha1_update.lo: src/libstdcrypto/sha1_update.c src/libstdcrypto/sha1-internal.h src/include/skalibs/sha1.h src/libstdcrypto/sha256_feed.o src/libstdcrypto/sha256_feed.lo: src/libstdcrypto/sha256_feed.c src/include/skalibs/bytestr.h src/libstdcrypto/sha256-internal.h src/include/skalibs/sha256.h src/libstdcrypto/sha256_final.o src/libstdcrypto/sha256_final.lo: src/libstdcrypto/sha256_final.c src/include/skalibs/bytestr.h src/libstdcrypto/sha256-internal.h src/include/skalibs/sha256.h src/libstdcrypto/sha256_init.o src/libstdcrypto/sha256_init.lo: src/libstdcrypto/sha256_init.c src/include/skalibs/sha256.h src/libstdcrypto/sha256_transform.o src/libstdcrypto/sha256_transform.lo: src/libstdcrypto/sha256_transform.c src/libstdcrypto/sha256-internal.h src/libstdcrypto/sha256_update.o src/libstdcrypto/sha256_update.lo: src/libstdcrypto/sha256_update.c src/libstdcrypto/sha256-internal.h src/include/skalibs/sha256.h src/libstdcrypto/sha512_final.o src/libstdcrypto/sha512_final.lo: src/libstdcrypto/sha512_final.c src/libstdcrypto/sha512-internal.h src/include/skalibs/sha512.h src/include/skalibs/uint64.h src/libstdcrypto/sha512_init.o src/libstdcrypto/sha512_init.lo: src/libstdcrypto/sha512_init.c src/include/skalibs/sha512.h src/libstdcrypto/sha512_transform.o src/libstdcrypto/sha512_transform.lo: src/libstdcrypto/sha512_transform.c src/libstdcrypto/sha512-internal.h src/include/skalibs/sha512.h src/include/skalibs/uint64.h src/libstdcrypto/sha512_update.o src/libstdcrypto/sha512_update.lo: src/libstdcrypto/sha512_update.c src/libstdcrypto/sha512-internal.h src/include/skalibs/sha512.h src/libstddjb/alarm_deadline.o src/libstddjb/alarm_deadline.lo: src/libstddjb/alarm_deadline.c src/libstddjb/alarm-internal.h src/include/skalibs/alarm.h src/include/skalibs/sysdeps.h src/include/skalibs/tai.h src/libstddjb/alarm_disable.o src/libstddjb/alarm_disable.lo: src/libstddjb/alarm_disable.c src/libstddjb/alarm-internal.h src/include/skalibs/alarm.h src/include/skalibs/sysdeps.h src/libstddjb/alarm_milliseconds.o src/libstddjb/alarm_milliseconds.lo: src/libstddjb/alarm_milliseconds.c src/libstddjb/alarm-internal.h src/include/skalibs/alarm.h src/include/skalibs/sysdeps.h src/libstddjb/alarm_timeout.o src/libstddjb/alarm_timeout.lo: src/libstddjb/alarm_timeout.c src/libstddjb/alarm-internal.h src/include/skalibs/alarm.h src/include/skalibs/sysdeps.h src/include/skalibs/tai.h src/libstddjb/alloc.o src/libstddjb/alloc.lo: src/libstddjb/alloc.c src/include/skalibs/alloc.h src/libstddjb/alloc_realloc.o src/libstddjb/alloc_realloc.lo: src/libstddjb/alloc_realloc.c src/include/skalibs/alloc.h src/libstddjb/allread.o src/libstddjb/allread.lo: src/libstddjb/allread.c src/include/skalibs/allreadwrite.h src/libstddjb/allreadv.o src/libstddjb/allreadv.lo: src/libstddjb/allreadv.c src/include/skalibs/allreadwrite.h src/libstddjb/allreadwrite.o src/libstddjb/allreadwrite.lo: src/libstddjb/allreadwrite.c src/include/skalibs/allreadwrite.h src/libstddjb/allreadwritev.o src/libstddjb/allreadwritev.lo: src/libstddjb/allreadwritev.c src/include/skalibs/allreadwrite.h src/include/skalibs/siovec.h src/libstddjb/allwrite.o src/libstddjb/allwrite.lo: src/libstddjb/allwrite.c src/include/skalibs/allreadwrite.h src/include/skalibs/functypes.h src/libstddjb/allwritev.o src/libstddjb/allwritev.lo: src/libstddjb/allwritev.c src/include/skalibs/allreadwrite.h src/libstddjb/baprintf.o src/libstddjb/baprintf.lo: src/libstddjb/baprintf.c src/include/skalibs/bufalloc.h src/include/skalibs/lolstdio.h src/libstddjb/bitarray_and.o src/libstddjb/bitarray_and.lo: src/libstddjb/bitarray_and.c src/include/skalibs/bitarray.h src/libstddjb/bitarray_clearsetn.o src/libstddjb/bitarray_clearsetn.lo: src/libstddjb/bitarray_clearsetn.c src/include/skalibs/bitarray.h src/libstddjb/bitarray_count.o src/libstddjb/bitarray_count.lo: src/libstddjb/bitarray_count.c src/include/skalibs/bitarray.h src/libstddjb/bitarray_firstclear.o src/libstddjb/bitarray_firstclear.lo: src/libstddjb/bitarray_firstclear.c src/include/skalibs/bitarray.h src/libstddjb/bitarray_firstclear_skip.o src/libstddjb/bitarray_firstclear_skip.lo: src/libstddjb/bitarray_firstclear_skip.c src/include/skalibs/bitarray.h src/libstddjb/bitarray_firstset.o src/libstddjb/bitarray_firstset.lo: src/libstddjb/bitarray_firstset.c src/include/skalibs/bitarray.h src/libstddjb/bitarray_firstset_skip.o src/libstddjb/bitarray_firstset_skip.lo: src/libstddjb/bitarray_firstset_skip.c src/include/skalibs/bitarray.h src/libstddjb/bitarray_not.o src/libstddjb/bitarray_not.lo: src/libstddjb/bitarray_not.c src/include/skalibs/bitarray.h src/libstddjb/bitarray_or.o src/libstddjb/bitarray_or.lo: src/libstddjb/bitarray_or.c src/include/skalibs/bitarray.h src/libstddjb/bitarray_testandpoke.o src/libstddjb/bitarray_testandpoke.lo: src/libstddjb/bitarray_testandpoke.c src/include/skalibs/bitarray.h src/libstddjb/bitarray_xor.o src/libstddjb/bitarray_xor.lo: src/libstddjb/bitarray_xor.c src/include/skalibs/bitarray.h src/libstddjb/bprintf.o src/libstddjb/bprintf.lo: src/libstddjb/bprintf.c src/include/skalibs/buffer.h src/include/skalibs/lolstdio.h src/libstddjb/bufalloc_1.o src/libstddjb/bufalloc_1.lo: src/libstddjb/bufalloc_1.c src/include/skalibs/allreadwrite.h src/include/skalibs/bufalloc.h src/libstddjb/bufalloc_2.o src/libstddjb/bufalloc_2.lo: src/libstddjb/bufalloc_2.c src/include/skalibs/allreadwrite.h src/include/skalibs/bufalloc.h src/libstddjb/bufalloc_clean.o src/libstddjb/bufalloc_clean.lo: src/libstddjb/bufalloc_clean.c src/include/skalibs/bufalloc.h src/libstddjb/bufalloc_flush.o src/libstddjb/bufalloc_flush.lo: src/libstddjb/bufalloc_flush.c src/include/skalibs/allreadwrite.h src/include/skalibs/bufalloc.h src/include/skalibs/functypes.h src/libstddjb/bufalloc_getfd.o src/libstddjb/bufalloc_getfd.lo: src/libstddjb/bufalloc_getfd.c src/include/skalibs/bufalloc.h src/libstddjb/bufalloc_getlen.o src/libstddjb/bufalloc_getlen.lo: src/libstddjb/bufalloc_getlen.c src/include/skalibs/bufalloc.h src/libstddjb/bufalloc_init.o src/libstddjb/bufalloc_init.lo: src/libstddjb/bufalloc_init.c src/include/skalibs/bufalloc.h src/include/skalibs/stralloc.h src/libstddjb/buffer_0.o src/libstddjb/buffer_0.lo: src/libstddjb/buffer_0.c src/include/skalibs/allreadwrite.h src/include/skalibs/buffer.h src/libstddjb/buffer_0f1.o src/libstddjb/buffer_0f1.lo: src/libstddjb/buffer_0f1.c src/include/skalibs/buffer.h src/libstddjb/buffer_0small.o src/libstddjb/buffer_0small.lo: src/libstddjb/buffer_0small.c src/include/skalibs/allreadwrite.h src/include/skalibs/buffer.h src/libstddjb/buffer_1.o src/libstddjb/buffer_1.lo: src/libstddjb/buffer_1.c src/include/skalibs/allreadwrite.h src/include/skalibs/buffer.h src/libstddjb/buffer_1small.o src/libstddjb/buffer_1small.lo: src/libstddjb/buffer_1small.c src/include/skalibs/allreadwrite.h src/include/skalibs/buffer.h src/libstddjb/buffer_2.o src/libstddjb/buffer_2.lo: src/libstddjb/buffer_2.c src/include/skalibs/allreadwrite.h src/include/skalibs/buffer.h src/libstddjb/buffer_fill.o src/libstddjb/buffer_fill.lo: src/libstddjb/buffer_fill.c src/include/skalibs/buffer.h src/libstddjb/buffer_flush.o src/libstddjb/buffer_flush.lo: src/libstddjb/buffer_flush.c src/include/skalibs/buffer.h src/include/skalibs/cbuffer.h src/libstddjb/buffer_flush1read.o src/libstddjb/buffer_flush1read.lo: src/libstddjb/buffer_flush1read.c src/include/skalibs/allreadwrite.h src/include/skalibs/buffer.h src/libstddjb/buffer_get.o src/libstddjb/buffer_get.lo: src/libstddjb/buffer_get.c src/include/skalibs/allreadwrite.h src/include/skalibs/buffer.h src/libstddjb/buffer_getall.o src/libstddjb/buffer_getall.lo: src/libstddjb/buffer_getall.c src/include/skalibs/allreadwrite.h src/include/skalibs/buffer.h src/libstddjb/buffer_getallnf.o src/libstddjb/buffer_getallnf.lo: src/libstddjb/buffer_getallnf.c src/include/skalibs/buffer.h src/libstddjb/buffer_getfd.o src/libstddjb/buffer_getfd.lo: src/libstddjb/buffer_getfd.c src/include/skalibs/buffer.h src/libstddjb/buffer_getlen.o src/libstddjb/buffer_getlen.lo: src/libstddjb/buffer_getlen.c src/include/skalibs/buffer.h src/libstddjb/buffer_getv.o src/libstddjb/buffer_getv.lo: src/libstddjb/buffer_getv.c src/include/skalibs/allreadwrite.h src/include/skalibs/buffer.h src/libstddjb/buffer_getvall.o src/libstddjb/buffer_getvall.lo: src/libstddjb/buffer_getvall.c src/include/skalibs/allreadwrite.h src/include/skalibs/buffer.h src/include/skalibs/siovec.h src/libstddjb/buffer_getvallnf.o src/libstddjb/buffer_getvallnf.lo: src/libstddjb/buffer_getvallnf.c src/include/skalibs/buffer.h src/include/skalibs/siovec.h src/libstddjb/buffer_init.o src/libstddjb/buffer_init.lo: src/libstddjb/buffer_init.c src/include/skalibs/buffer.h src/include/skalibs/cbuffer.h src/libstddjb/buffer_put.o src/libstddjb/buffer_put.lo: src/libstddjb/buffer_put.c src/include/skalibs/buffer.h src/libstddjb/buffer_putall.o src/libstddjb/buffer_putall.lo: src/libstddjb/buffer_putall.c src/include/skalibs/buffer.h src/libstddjb/buffer_putallnf.o src/libstddjb/buffer_putallnf.lo: src/libstddjb/buffer_putallnf.c src/include/skalibs/buffer.h src/libstddjb/buffer_putflush.o src/libstddjb/buffer_putflush.lo: src/libstddjb/buffer_putflush.c src/include/skalibs/buffer.h src/libstddjb/buffer_puts.o src/libstddjb/buffer_puts.lo: src/libstddjb/buffer_puts.c src/include/skalibs/buffer.h src/libstddjb/buffer_putsall.o src/libstddjb/buffer_putsall.lo: src/libstddjb/buffer_putsall.c src/include/skalibs/buffer.h src/libstddjb/buffer_putsallflush.o src/libstddjb/buffer_putsallflush.lo: src/libstddjb/buffer_putsallflush.c src/include/skalibs/buffer.h src/libstddjb/buffer_putsallnoflush.o src/libstddjb/buffer_putsallnoflush.lo: src/libstddjb/buffer_putsallnoflush.c src/include/skalibs/buffer.h src/libstddjb/buffer_putsflush.o src/libstddjb/buffer_putsflush.lo: src/libstddjb/buffer_putsflush.c src/include/skalibs/buffer.h src/libstddjb/buffer_putsnoflush.o src/libstddjb/buffer_putsnoflush.lo: src/libstddjb/buffer_putsnoflush.c src/include/skalibs/buffer.h src/libstddjb/buffer_putv.o src/libstddjb/buffer_putv.lo: src/libstddjb/buffer_putv.c src/include/skalibs/buffer.h src/libstddjb/buffer_putvall.o src/libstddjb/buffer_putvall.lo: src/libstddjb/buffer_putvall.c src/include/skalibs/buffer.h src/include/skalibs/siovec.h src/libstddjb/buffer_putvallnf.o src/libstddjb/buffer_putvallnf.lo: src/libstddjb/buffer_putvallnf.c src/include/skalibs/buffer.h src/include/skalibs/siovec.h src/libstddjb/buffer_putvflush.o src/libstddjb/buffer_putvflush.lo: src/libstddjb/buffer_putvflush.c src/include/skalibs/buffer.h src/libstddjb/byte_chr.o src/libstddjb/byte_chr.lo: src/libstddjb/byte_chr.c src/include/skalibs/bytestr.h src/libstddjb/byte_count.o src/libstddjb/byte_count.lo: src/libstddjb/byte_count.c src/include/skalibs/bytestr.h src/libstddjb/byte_in.o src/libstddjb/byte_in.lo: src/libstddjb/byte_in.c src/include/skalibs/bytestr.h src/libstddjb/byte_rchr.o src/libstddjb/byte_rchr.lo: src/libstddjb/byte_rchr.c src/include/skalibs/bytestr.h src/libstddjb/byte_search.o src/libstddjb/byte_search.lo: src/libstddjb/byte_search.c src/include/skalibs/bytestr.h src/include/skalibs/posixplz.h src/libstddjb/byte_zzero.o src/libstddjb/byte_zzero.lo: src/libstddjb/byte_zzero.c src/include/skalibs/bytestr.h src/include/skalibs/gccattributes.h src/include/skalibs/nonposix.h src/include/skalibs/sysdeps.h src/libstddjb/case_lowerb.o src/libstddjb/case_lowerb.lo: src/libstddjb/case_lowerb.c src/include/skalibs/bytestr.h src/libstddjb/case_lowers.o src/libstddjb/case_lowers.lo: src/libstddjb/case_lowers.c src/include/skalibs/bytestr.h src/libstddjb/case_startb.o src/libstddjb/case_startb.lo: src/libstddjb/case_startb.c src/include/skalibs/bytestr.h src/libstddjb/case_upperb.o src/libstddjb/case_upperb.lo: src/libstddjb/case_upperb.c src/include/skalibs/bytestr.h src/libstddjb/case_uppers.o src/libstddjb/case_uppers.lo: src/libstddjb/case_uppers.c src/include/skalibs/bytestr.h src/libstddjb/cbuffer_get.o src/libstddjb/cbuffer_get.lo: src/libstddjb/cbuffer_get.c src/include/skalibs/cbuffer.h src/include/skalibs/siovec.h src/libstddjb/cbuffer_getv.o src/libstddjb/cbuffer_getv.lo: src/libstddjb/cbuffer_getv.c src/include/skalibs/cbuffer.h src/include/skalibs/siovec.h src/libstddjb/cbuffer_init.o src/libstddjb/cbuffer_init.lo: src/libstddjb/cbuffer_init.c src/include/skalibs/cbuffer.h src/libstddjb/cbuffer_put.o src/libstddjb/cbuffer_put.lo: src/libstddjb/cbuffer_put.c src/include/skalibs/cbuffer.h src/include/skalibs/siovec.h src/libstddjb/cbuffer_putv.o src/libstddjb/cbuffer_putv.lo: src/libstddjb/cbuffer_putv.c src/include/skalibs/cbuffer.h src/include/skalibs/siovec.h src/libstddjb/cbuffer_rpeek.o src/libstddjb/cbuffer_rpeek.lo: src/libstddjb/cbuffer_rpeek.c src/include/skalibs/cbuffer.h src/libstddjb/cbuffer_rseek.o src/libstddjb/cbuffer_rseek.lo: src/libstddjb/cbuffer_rseek.c src/include/skalibs/cbuffer.h src/libstddjb/cbuffer_unget.o src/libstddjb/cbuffer_unget.lo: src/libstddjb/cbuffer_unget.c src/include/skalibs/cbuffer.h src/libstddjb/cbuffer_unput.o src/libstddjb/cbuffer_unput.lo: src/libstddjb/cbuffer_unput.c src/include/skalibs/cbuffer.h src/libstddjb/cbuffer_wpeek.o src/libstddjb/cbuffer_wpeek.lo: src/libstddjb/cbuffer_wpeek.c src/include/skalibs/cbuffer.h src/libstddjb/cbuffer_wseek.o src/libstddjb/cbuffer_wseek.lo: src/libstddjb/cbuffer_wseek.c src/include/skalibs/cbuffer.h src/libstddjb/cdb_find.o src/libstddjb/cdb_find.lo: src/libstddjb/cdb_find.c src/include/skalibs/cdb.h src/libstddjb/cdb_findnext.o src/libstddjb/cdb_findnext.lo: src/libstddjb/cdb_findnext.c src/libstddjb/cdb-internal.h src/include/skalibs/cdb.h src/include/skalibs/uint32.h src/libstddjb/cdb_free.o src/libstddjb/cdb_free.lo: src/libstddjb/cdb_free.c src/include/skalibs/cdb.h src/include/skalibs/posixplz.h src/libstddjb/cdb_hash.o src/libstddjb/cdb_hash.lo: src/libstddjb/cdb_hash.c src/libstddjb/cdb-internal.h src/libstddjb/cdb_hashadd.o src/libstddjb/cdb_hashadd.lo: src/libstddjb/cdb_hashadd.c src/libstddjb/cdb-internal.h src/libstddjb/cdb_hashv.o src/libstddjb/cdb_hashv.lo: src/libstddjb/cdb_hashv.c src/libstddjb/cdb-internal.h src/libstddjb/cdb_init.o src/libstddjb/cdb_init.lo: src/libstddjb/cdb_init.c src/include/skalibs/cdb.h src/include/skalibs/djbunix.h src/libstddjb/cdb_init_at.o src/libstddjb/cdb_init_at.lo: src/libstddjb/cdb_init_at.c src/include/skalibs/cdb.h src/include/skalibs/djbunix.h src/include/skalibs/unix-transactional.h src/libstddjb/cdb_init_fromfd.o src/libstddjb/cdb_init_fromfd.lo: src/libstddjb/cdb_init_fromfd.c src/include/skalibs/bsdsnowflake.h src/include/skalibs/cdb.h src/libstddjb/cdb_p.o src/libstddjb/cdb_p.lo: src/libstddjb/cdb_p.c src/libstddjb/cdb-internal.h src/include/skalibs/cdb.h src/libstddjb/cdb_traverse_next.o src/libstddjb/cdb_traverse_next.lo: src/libstddjb/cdb_traverse_next.c src/libstddjb/cdb-internal.h src/include/skalibs/cdb.h src/include/skalibs/uint32.h src/libstddjb/cdb_zero.o src/libstddjb/cdb_zero.lo: src/libstddjb/cdb_zero.c src/include/skalibs/cdb.h src/libstddjb/cdbmake_add.o src/libstddjb/cdbmake_add.lo: src/libstddjb/cdbmake_add.c src/include/skalibs/buffer.h src/libstddjb/cdb-internal.h src/libstddjb/cdbmake-internal.h src/include/skalibs/cdbmake.h src/include/skalibs/diuint32.h src/include/skalibs/genalloc.h src/include/skalibs/uint32.h src/libstddjb/cdbmake_addbeginend.o src/libstddjb/cdbmake_addbeginend.lo: src/libstddjb/cdbmake_addbeginend.c src/include/skalibs/buffer.h src/libstddjb/cdbmake-internal.h src/include/skalibs/diuint32.h src/include/skalibs/genalloc.h src/include/skalibs/uint32.h src/libstddjb/cdbmake_addv.o src/libstddjb/cdbmake_addv.lo: src/libstddjb/cdbmake_addv.c src/include/skalibs/buffer.h src/libstddjb/cdb-internal.h src/libstddjb/cdbmake-internal.h src/include/skalibs/cdbmake.h src/include/skalibs/diuint32.h src/include/skalibs/genalloc.h src/include/skalibs/siovec.h src/include/skalibs/uint32.h src/libstddjb/cdbmake_finish.o src/libstddjb/cdbmake_finish.lo: src/libstddjb/cdbmake_finish.c src/include/skalibs/buffer.h src/libstddjb/cdbmake-internal.h src/include/skalibs/cdbmake.h src/include/skalibs/diuint32.h src/include/skalibs/genalloc.h src/include/skalibs/uint32.h src/libstddjb/cdbmake_posplus.o src/libstddjb/cdbmake_posplus.lo: src/libstddjb/cdbmake_posplus.c src/libstddjb/cdbmake-internal.h src/libstddjb/cdbmake_start.o src/libstddjb/cdbmake_start.lo: src/libstddjb/cdbmake_start.c src/include/skalibs/buffer.h src/include/skalibs/cdbmake.h src/include/skalibs/genalloc.h src/libstddjb/child_spawn.o src/libstddjb/child_spawn.lo: src/libstddjb/child_spawn.c src/include/skalibs/cspawn.h src/include/skalibs/djbunix.h src/include/skalibs/env.h src/include/skalibs/types.h src/libstddjb/child_spawn0.o src/libstddjb/child_spawn0.lo: src/libstddjb/child_spawn0.c src/include/skalibs/cspawn.h src/libstddjb/child_spawn1_internal.o src/libstddjb/child_spawn1_internal.lo: src/libstddjb/child_spawn1_internal.c src/libstddjb/cspawn-internal.h src/include/skalibs/cspawn.h src/include/skalibs/djbunix.h src/libstddjb/child_spawn1_pipe.o src/libstddjb/child_spawn1_pipe.lo: src/libstddjb/child_spawn1_pipe.c src/libstddjb/cspawn-internal.h src/include/skalibs/cspawn.h src/libstddjb/child_spawn1_socket.o src/libstddjb/child_spawn1_socket.lo: src/libstddjb/child_spawn1_socket.c src/libstddjb/cspawn-internal.h src/include/skalibs/cspawn.h src/include/skalibs/socket.h src/libstddjb/child_spawn2.o src/libstddjb/child_spawn2.lo: src/libstddjb/child_spawn2.c src/include/skalibs/cspawn.h src/include/skalibs/djbunix.h src/libstddjb/child_spawn3.o src/libstddjb/child_spawn3.lo: src/libstddjb/child_spawn3.c src/include/skalibs/cspawn.h src/include/skalibs/djbunix.h src/include/skalibs/env.h src/include/skalibs/types.h src/libstddjb/coe.o src/libstddjb/coe.lo: src/libstddjb/coe.c src/include/skalibs/djbunix.h src/libstddjb/cspawn.o src/libstddjb/cspawn.lo: src/libstddjb/cspawn.c src/include/skalibs/allreadwrite.h src/include/skalibs/config.h src/include/skalibs/cspawn.h src/include/skalibs/djbunix.h src/include/skalibs/exec.h src/include/skalibs/nonposix.h src/include/skalibs/selfpipe.h src/include/skalibs/sig.h src/include/skalibs/sysdeps.h src/libstddjb/deepsleepuntil.o src/libstddjb/deepsleepuntil.lo: src/libstddjb/deepsleepuntil.c src/include/skalibs/iopause.h src/include/skalibs/tai.h src/libstddjb/devino_cmp.o src/libstddjb/devino_cmp.lo: src/libstddjb/devino_cmp.c src/include/skalibs/devino.h src/libstddjb/dir_close.o src/libstddjb/dir_close.lo: src/libstddjb/dir_close.c src/include/skalibs/direntry.h src/libstddjb/dir_fd.o src/libstddjb/dir_fd.lo: src/libstddjb/dir_fd.c src/include/skalibs/direntry.h src/include/skalibs/nonposix.h src/include/skalibs/sysdeps.h src/libstddjb/error_isalready.o src/libstddjb/error_isalready.lo: src/libstddjb/error_isalready.c src/include/skalibs/bsdsnowflake.h src/include/skalibs/error.h src/libstddjb/error_temp.o src/libstddjb/error_temp.lo: src/libstddjb/error_temp.c src/include/skalibs/error.h src/libstddjb/fd_cat.o src/libstddjb/fd_cat.lo: src/libstddjb/fd_cat.c src/include/skalibs/allreadwrite.h src/include/skalibs/djbunix.h src/libstddjb/fd_catn.o src/libstddjb/fd_catn.lo: src/libstddjb/fd_catn.c src/include/skalibs/allreadwrite.h src/include/skalibs/djbunix.h src/libstddjb/fd_chdir.o src/libstddjb/fd_chdir.lo: src/libstddjb/fd_chdir.c src/include/skalibs/djbunix.h src/libstddjb/fd_chmod.o src/libstddjb/fd_chmod.lo: src/libstddjb/fd_chmod.c src/include/skalibs/djbunix.h src/include/skalibs/nonposix.h src/libstddjb/fd_chown.o src/libstddjb/fd_chown.lo: src/libstddjb/fd_chown.c src/include/skalibs/djbunix.h src/libstddjb/fd_close.o src/libstddjb/fd_close.lo: src/libstddjb/fd_close.c src/include/skalibs/djbunix.h src/libstddjb/fd_copy.o src/libstddjb/fd_copy.lo: src/libstddjb/fd_copy.c src/include/skalibs/djbunix.h src/libstddjb/fd_copy2.o src/libstddjb/fd_copy2.lo: src/libstddjb/fd_copy2.c src/include/skalibs/djbunix.h src/libstddjb/fd_ensure_open.o src/libstddjb/fd_ensure_open.lo: src/libstddjb/fd_ensure_open.c src/include/skalibs/djbunix.h src/libstddjb/fd_islocked.o src/libstddjb/fd_islocked.lo: src/libstddjb/fd_islocked.c src/include/skalibs/djbunix.h src/libstddjb/fd_lock.o src/libstddjb/fd_lock.lo: src/libstddjb/fd_lock.c src/include/skalibs/djbunix.h src/include/skalibs/error.h src/libstddjb/fd_move.o src/libstddjb/fd_move.lo: src/libstddjb/fd_move.c src/include/skalibs/djbunix.h src/libstddjb/fd_move2.o src/libstddjb/fd_move2.lo: src/libstddjb/fd_move2.c src/include/skalibs/djbunix.h src/libstddjb/fd_read.o src/libstddjb/fd_read.lo: src/libstddjb/fd_read.c src/include/skalibs/allreadwrite.h src/libstddjb/fd_readv.o src/libstddjb/fd_readv.lo: src/libstddjb/fd_readv.c src/include/skalibs/allreadwrite.h src/libstddjb/fd_recv.o src/libstddjb/fd_recv.lo: src/libstddjb/fd_recv.c src/include/skalibs/allreadwrite.h src/libstddjb/fd_send.o src/libstddjb/fd_send.lo: src/libstddjb/fd_send.c src/include/skalibs/allreadwrite.h src/libstddjb/fd_shutdown.o src/libstddjb/fd_shutdown.lo: src/libstddjb/fd_shutdown.c src/include/skalibs/djbunix.h src/include/skalibs/nonposix.h src/libstddjb/fd_sync.o src/libstddjb/fd_sync.lo: src/libstddjb/fd_sync.c src/include/skalibs/djbunix.h src/libstddjb/fd_unlock.o src/libstddjb/fd_unlock.lo: src/libstddjb/fd_unlock.c src/include/skalibs/djbunix.h src/libstddjb/fd_write.o src/libstddjb/fd_write.lo: src/libstddjb/fd_write.c src/include/skalibs/allreadwrite.h src/libstddjb/fd_writev.o src/libstddjb/fd_writev.lo: src/libstddjb/fd_writev.c src/include/skalibs/allreadwrite.h src/libstddjb/filecopy_suffix.o src/libstddjb/filecopy_suffix.lo: src/libstddjb/filecopy_suffix.c src/include/skalibs/djbunix.h src/libstddjb/filecopy_unsafe.o src/libstddjb/filecopy_unsafe.lo: src/libstddjb/filecopy_unsafe.c src/include/skalibs/djbunix.h src/libstddjb/fmtscan_asc.o src/libstddjb/fmtscan_asc.lo: src/libstddjb/fmtscan_asc.c src/include/skalibs/fmtscan.h src/libstddjb/fmtscan_num.o src/libstddjb/fmtscan_num.lo: src/libstddjb/fmtscan_num.c src/include/skalibs/fmtscan.h src/libstddjb/gcspawn.o src/libstddjb/gcspawn.lo: src/libstddjb/gcspawn.c src/include/skalibs/allreadwrite.h src/include/skalibs/cspawn.h src/include/skalibs/djbunix.h src/include/skalibs/types.h src/libstddjb/genalloc_deepfree.o src/libstddjb/genalloc_deepfree.lo: src/libstddjb/genalloc_deepfree.c src/include/skalibs/genalloc.h src/include/skalibs/stralloc.h src/libstddjb/genwrite_flush_bufalloc.o src/libstddjb/genwrite_flush_bufalloc.lo: src/libstddjb/genwrite_flush_bufalloc.c src/include/skalibs/bufalloc.h src/include/skalibs/genwrite.h src/libstddjb/genwrite_flush_buffer.o src/libstddjb/genwrite_flush_buffer.lo: src/libstddjb/genwrite_flush_buffer.c src/include/skalibs/buffer.h src/include/skalibs/genwrite.h src/libstddjb/genwrite_flush_stralloc.o src/libstddjb/genwrite_flush_stralloc.lo: src/libstddjb/genwrite_flush_stralloc.c src/include/skalibs/genwrite.h src/libstddjb/genwrite_put_bufalloc.o src/libstddjb/genwrite_put_bufalloc.lo: src/libstddjb/genwrite_put_bufalloc.c src/include/skalibs/bufalloc.h src/include/skalibs/genwrite.h src/libstddjb/genwrite_put_buffer.o src/libstddjb/genwrite_put_buffer.lo: src/libstddjb/genwrite_put_buffer.c src/include/skalibs/buffer.h src/include/skalibs/genwrite.h src/libstddjb/genwrite_put_stralloc.o src/libstddjb/genwrite_put_stralloc.lo: src/libstddjb/genwrite_put_stralloc.c src/include/skalibs/genwrite.h src/include/skalibs/stralloc.h src/libstddjb/genwrite_stderr.o src/libstddjb/genwrite_stderr.lo: src/libstddjb/genwrite_stderr.c src/include/skalibs/buffer.h src/include/skalibs/genwrite.h src/libstddjb/genwrite_stdout.o src/libstddjb/genwrite_stdout.lo: src/libstddjb/genwrite_stdout.c src/include/skalibs/buffer.h src/include/skalibs/genwrite.h src/libstddjb/getlnmax.o src/libstddjb/getlnmax.lo: src/libstddjb/getlnmax.c src/include/skalibs/buffer.h src/include/skalibs/siovec.h src/include/skalibs/skamisc.h src/libstddjb/getlnmaxsep.o src/libstddjb/getlnmaxsep.lo: src/libstddjb/getlnmaxsep.c src/include/skalibs/buffer.h src/include/skalibs/siovec.h src/include/skalibs/skamisc.h src/libstddjb/hiercopy.o src/libstddjb/hiercopy.lo: src/libstddjb/hiercopy.c src/include/skalibs/djbunix.h src/include/skalibs/skamisc.h src/libstddjb/hiercopy_internal.o src/libstddjb/hiercopy_internal.lo: src/libstddjb/hiercopy_internal.c src/include/skalibs/direntry.h src/include/skalibs/djbunix.h src/include/skalibs/stralloc.h src/libstddjb/hiercopy_loose.o src/libstddjb/hiercopy_loose.lo: src/libstddjb/hiercopy_loose.c src/include/skalibs/djbunix.h src/include/skalibs/skamisc.h src/libstddjb/hiercopy_loose_tmp.o src/libstddjb/hiercopy_loose_tmp.lo: src/libstddjb/hiercopy_loose_tmp.c src/include/skalibs/djbunix.h src/libstddjb/hiercopy_tmp.o src/libstddjb/hiercopy_tmp.lo: src/libstddjb/hiercopy_tmp.c src/include/skalibs/djbunix.h src/libstddjb/int160_scan.o src/libstddjb/int160_scan.lo: src/libstddjb/int160_scan.c src/libstddjb/fmtscan-internal.h src/include/skalibs/uint16.h src/libstddjb/int16_fmtlist.o src/libstddjb/int16_fmtlist.lo: src/libstddjb/int16_fmtlist.c src/libstddjb/fmtscan-internal.h src/include/skalibs/uint16.h src/libstddjb/int16_scan.o src/libstddjb/int16_scan.lo: src/libstddjb/int16_scan.c src/libstddjb/fmtscan-internal.h src/include/skalibs/uint16.h src/include/skalibs/uint64.h src/libstddjb/int16_scanlist.o src/libstddjb/int16_scanlist.lo: src/libstddjb/int16_scanlist.c src/libstddjb/fmtscan-internal.h src/include/skalibs/uint16.h src/libstddjb/int320_scan.o src/libstddjb/int320_scan.lo: src/libstddjb/int320_scan.c src/libstddjb/fmtscan-internal.h src/include/skalibs/uint32.h src/libstddjb/int32_fmtlist.o src/libstddjb/int32_fmtlist.lo: src/libstddjb/int32_fmtlist.c src/libstddjb/fmtscan-internal.h src/include/skalibs/uint32.h src/libstddjb/int32_scan.o src/libstddjb/int32_scan.lo: src/libstddjb/int32_scan.c src/libstddjb/fmtscan-internal.h src/include/skalibs/uint32.h src/include/skalibs/uint64.h src/libstddjb/int32_scanlist.o src/libstddjb/int32_scanlist.lo: src/libstddjb/int32_scanlist.c src/libstddjb/fmtscan-internal.h src/include/skalibs/uint32.h src/libstddjb/int640_scan.o src/libstddjb/int640_scan.lo: src/libstddjb/int640_scan.c src/libstddjb/fmtscan-internal.h src/include/skalibs/uint64.h src/libstddjb/int64_fmt_generic.o src/libstddjb/int64_fmt_generic.lo: src/libstddjb/int64_fmt_generic.c src/include/skalibs/uint64.h src/libstddjb/int64_fmtlist.o src/libstddjb/int64_fmtlist.lo: src/libstddjb/int64_fmtlist.c src/libstddjb/fmtscan-internal.h src/include/skalibs/uint64.h src/libstddjb/int64_scan.o src/libstddjb/int64_scan.lo: src/libstddjb/int64_scan.c src/libstddjb/fmtscan-internal.h src/include/skalibs/uint64.h src/libstddjb/int64_scan_base_max.o src/libstddjb/int64_scan_base_max.lo: src/libstddjb/int64_scan_base_max.c src/libstddjb/fmtscan-internal.h src/include/skalibs/uint64.h src/libstddjb/int64_scanlist.o src/libstddjb/int64_scanlist.lo: src/libstddjb/int64_scanlist.c src/libstddjb/fmtscan-internal.h src/include/skalibs/uint64.h src/libstddjb/iopause.o src/libstddjb/iopause.lo: src/libstddjb/iopause.c src/include/skalibs/config.h src/include/skalibs/iopause.h src/include/skalibs/sysdeps.h src/libstddjb/iopause_poll.o src/libstddjb/iopause_poll.lo: src/libstddjb/iopause_poll.c src/include/skalibs/iopause.h src/include/skalibs/tai.h src/libstddjb/iopause_ppoll.o src/libstddjb/iopause_ppoll.lo: src/libstddjb/iopause_ppoll.c src/include/skalibs/iopause.h src/include/skalibs/nonposix.h src/include/skalibs/sysdeps.h src/include/skalibs/tai.h src/libstddjb/iopause_select.o src/libstddjb/iopause_select.lo: src/libstddjb/iopause_select.c src/include/skalibs/bsdsnowflake.h src/include/skalibs/iopause.h src/include/skalibs/tai.h src/libstddjb/iopause_stamp.o src/libstddjb/iopause_stamp.lo: src/libstddjb/iopause_stamp.c src/include/skalibs/iopause.h src/include/skalibs/tai.h src/libstddjb/ip46_scan.o src/libstddjb/ip46_scan.lo: src/libstddjb/ip46_scan.c src/include/skalibs/fmtscan.h src/include/skalibs/ip46.h src/libstddjb/ip46_scanlist.o src/libstddjb/ip46_scanlist.lo: src/libstddjb/ip46_scanlist.c src/include/skalibs/fmtscan.h src/include/skalibs/ip46.h src/libstddjb/ip4_fmt.o src/libstddjb/ip4_fmt.lo: src/libstddjb/ip4_fmt.c src/include/skalibs/fmtscan.h src/include/skalibs/uint32.h src/libstddjb/ip4_fmtu32.o src/libstddjb/ip4_fmtu32.lo: src/libstddjb/ip4_fmtu32.c src/include/skalibs/fmtscan.h src/include/skalibs/uint32.h src/libstddjb/ip4_scan.o src/libstddjb/ip4_scan.lo: src/libstddjb/ip4_scan.c src/include/skalibs/fmtscan.h src/include/skalibs/types.h src/libstddjb/ip4_scanlist.o src/libstddjb/ip4_scanlist.lo: src/libstddjb/ip4_scanlist.c src/include/skalibs/fmtscan.h src/libstddjb/ip4_scanlist_u32.o src/libstddjb/ip4_scanlist_u32.lo: src/libstddjb/ip4_scanlist_u32.c src/include/skalibs/fmtscan.h src/libstddjb/ip4_scanu32.o src/libstddjb/ip4_scanu32.lo: src/libstddjb/ip4_scanu32.c src/include/skalibs/fmtscan.h src/include/skalibs/uint32.h src/libstddjb/ip6_fmt.o src/libstddjb/ip6_fmt.lo: src/libstddjb/ip6_fmt.c src/include/skalibs/diuint.h src/include/skalibs/fmtscan.h src/libstddjb/ip6_scan.o src/libstddjb/ip6_scan.lo: src/libstddjb/ip6_scan.c src/include/skalibs/fmtscan.h src/include/skalibs/uint16.h src/libstddjb/ip6_scanlist.o src/libstddjb/ip6_scanlist.lo: src/libstddjb/ip6_scanlist.c src/include/skalibs/fmtscan.h src/libstddjb/ipc_accept.o src/libstddjb/ipc_accept.lo: src/libstddjb/ipc_accept.c src/include/skalibs/bytestr.h src/include/skalibs/djbunix.h src/include/skalibs/nonposix.h src/include/skalibs/socket.h src/include/skalibs/sysdeps.h src/libstddjb/ipc_bind.o src/libstddjb/ipc_bind.lo: src/libstddjb/ipc_bind.c src/include/skalibs/nonposix.h src/include/skalibs/posixishard.h src/include/skalibs/socket.h src/libstddjb/ipc_bind_reuse.o src/libstddjb/ipc_bind_reuse.lo: src/libstddjb/ipc_bind_reuse.c src/include/skalibs/socket.h src/libstddjb/ipc_bind_reuse_lock_perms.o src/libstddjb/ipc_bind_reuse_lock_perms.lo: src/libstddjb/ipc_bind_reuse_lock_perms.c src/include/skalibs/djbunix.h src/include/skalibs/nonposix.h src/include/skalibs/socket.h src/libstddjb/ipc_bind_reuse_perms.o src/libstddjb/ipc_bind_reuse_perms.lo: src/libstddjb/ipc_bind_reuse_perms.c src/include/skalibs/socket.h src/libstddjb/ipc_connect.o src/libstddjb/ipc_connect.lo: src/libstddjb/ipc_connect.c src/include/skalibs/nonposix.h src/include/skalibs/posixishard.h src/include/skalibs/socket.h src/libstddjb/ipc_connected.o src/libstddjb/ipc_connected.lo: src/libstddjb/ipc_connected.c src/include/skalibs/allreadwrite.h src/include/skalibs/nonposix.h src/include/skalibs/socket.h src/libstddjb/ipc_dgram.o src/libstddjb/ipc_dgram.lo: src/libstddjb/ipc_dgram.c src/include/skalibs/nonposix.h src/include/skalibs/socket.h src/libstddjb/ipc_listen.o src/libstddjb/ipc_listen.lo: src/libstddjb/ipc_listen.c src/include/skalibs/nonposix.h src/include/skalibs/socket.h src/libstddjb/ipc_local.o src/libstddjb/ipc_local.lo: src/libstddjb/ipc_local.c src/include/skalibs/bytestr.h src/include/skalibs/nonposix.h src/include/skalibs/socket.h src/libstddjb/ipc_pair.o src/libstddjb/ipc_pair.lo: src/libstddjb/ipc_pair.c src/include/skalibs/nonposix.h src/include/skalibs/socket.h src/libstddjb/ipc_recv.o src/libstddjb/ipc_recv.lo: src/libstddjb/ipc_recv.c src/include/skalibs/nonposix.h src/include/skalibs/posixishard.h src/include/skalibs/socket.h src/libstddjb/ipc_send.o src/libstddjb/ipc_send.lo: src/libstddjb/ipc_send.c src/include/skalibs/nonposix.h src/include/skalibs/posixishard.h src/include/skalibs/socket.h src/libstddjb/ipc_stream.o src/libstddjb/ipc_stream.lo: src/libstddjb/ipc_stream.c src/include/skalibs/nonposix.h src/include/skalibs/socket.h src/libstddjb/ipc_timed_connect.o src/libstddjb/ipc_timed_connect.lo: src/libstddjb/ipc_timed_connect.c src/include/skalibs/error.h src/include/skalibs/iopause.h src/include/skalibs/socket.h src/libstddjb/leapsecs_add.o src/libstddjb/leapsecs_add.lo: src/libstddjb/leapsecs_add.c src/libstddjb/djbtime-internal.h src/include/skalibs/uint64.h src/libstddjb/leapsecs_sub.o src/libstddjb/leapsecs_sub.lo: src/libstddjb/leapsecs_sub.c src/libstddjb/djbtime-internal.h src/include/skalibs/uint64.h src/libstddjb/leapsecs_table.o src/libstddjb/leapsecs_table.lo: src/libstddjb/leapsecs_table.c src/libstddjb/djbtime-internal.h src/include/skalibs/tai.h src/include/skalibs/uint64.h src/libstddjb/localtm_fmt.o src/libstddjb/localtm_fmt.lo: src/libstddjb/localtm_fmt.c src/include/skalibs/djbtime.h src/include/skalibs/types.h src/libstddjb/localtm_from_ltm64.o src/libstddjb/localtm_from_ltm64.lo: src/libstddjb/localtm_from_ltm64.c src/include/skalibs/bsdsnowflake.h src/include/skalibs/djbtime.h src/include/skalibs/sysdeps.h src/include/skalibs/tai.h src/include/skalibs/uint64.h src/libstddjb/localtm_from_sysclock.o src/libstddjb/localtm_from_sysclock.lo: src/libstddjb/localtm_from_sysclock.c src/include/skalibs/djbtime.h src/include/skalibs/uint64.h src/libstddjb/localtm_from_tai.o src/libstddjb/localtm_from_tai.lo: src/libstddjb/localtm_from_tai.c src/include/skalibs/djbtime.h src/include/skalibs/uint64.h src/libstddjb/localtm_from_utc.o src/libstddjb/localtm_from_utc.lo: src/libstddjb/localtm_from_utc.c src/include/skalibs/djbtime.h src/include/skalibs/uint64.h src/libstddjb/localtm_scan.o src/libstddjb/localtm_scan.lo: src/libstddjb/localtm_scan.c src/include/skalibs/djbtime.h src/include/skalibs/types.h src/libstddjb/localtmn_fmt.o src/libstddjb/localtmn_fmt.lo: src/libstddjb/localtmn_fmt.c src/include/skalibs/djbtime.h src/include/skalibs/uint32.h src/libstddjb/localtmn_from_sysclock.o src/libstddjb/localtmn_from_sysclock.lo: src/libstddjb/localtmn_from_sysclock.c src/include/skalibs/djbtime.h src/libstddjb/localtmn_from_tain.o src/libstddjb/localtmn_from_tain.lo: src/libstddjb/localtmn_from_tain.c src/include/skalibs/djbtime.h src/libstddjb/localtmn_scan.o src/libstddjb/localtmn_scan.lo: src/libstddjb/localtmn_scan.c src/include/skalibs/djbtime.h src/include/skalibs/uint32.h src/libstddjb/lolprintf.o src/libstddjb/lolprintf.lo: src/libstddjb/lolprintf.c src/include/skalibs/buffer.h src/include/skalibs/lolstdio.h src/libstddjb/ltm64_from_localtm.o src/libstddjb/ltm64_from_localtm.lo: src/libstddjb/ltm64_from_localtm.c src/include/skalibs/djbtime.h src/include/skalibs/tai.h src/libstddjb/ltm64_from_sysclock.o src/libstddjb/ltm64_from_sysclock.lo: src/libstddjb/ltm64_from_sysclock.c src/include/skalibs/config.h src/include/skalibs/djbtime.h src/include/skalibs/tai.h src/libstddjb/ltm64_from_tai.o src/libstddjb/ltm64_from_tai.lo: src/libstddjb/ltm64_from_tai.c src/libstddjb/djbtime-internal.h src/include/skalibs/djbtime.h src/libstddjb/ltm64_from_utc.o src/libstddjb/ltm64_from_utc.lo: src/libstddjb/ltm64_from_utc.c src/libstddjb/djbtime-internal.h src/include/skalibs/djbtime.h src/include/skalibs/uint64.h src/libstddjb/ndelay_off.o src/libstddjb/ndelay_off.lo: src/libstddjb/ndelay_off.c src/include/skalibs/djbunix.h src/libstddjb/ndelay_on.o src/libstddjb/ndelay_on.lo: src/libstddjb/ndelay_on.c src/include/skalibs/djbunix.h src/libstddjb/netstring_append.o src/libstddjb/netstring_append.lo: src/libstddjb/netstring_append.c src/include/skalibs/netstring.h src/include/skalibs/stralloc.h src/include/skalibs/uint64.h src/libstddjb/netstring_appendv.o src/libstddjb/netstring_appendv.lo: src/libstddjb/netstring_appendv.c src/include/skalibs/bytestr.h src/include/skalibs/netstring.h src/include/skalibs/siovec.h src/include/skalibs/stralloc.h src/include/skalibs/uint64.h src/libstddjb/netstring_decode.o src/libstddjb/netstring_decode.lo: src/libstddjb/netstring_decode.c src/include/skalibs/netstring.h src/include/skalibs/stralloc.h src/include/skalibs/uint64.h src/libstddjb/netstring_encode.o src/libstddjb/netstring_encode.lo: src/libstddjb/netstring_encode.c src/include/skalibs/netstring.h src/include/skalibs/stralloc.h src/include/skalibs/uint64.h src/libstddjb/netstring_get.o src/libstddjb/netstring_get.lo: src/libstddjb/netstring_get.c src/include/skalibs/allreadwrite.h src/include/skalibs/buffer.h src/include/skalibs/bytestr.h src/include/skalibs/netstring.h src/include/skalibs/posixishard.h src/include/skalibs/stralloc.h src/include/skalibs/types.h src/libstddjb/netstring_put.o src/libstddjb/netstring_put.lo: src/libstddjb/netstring_put.c src/include/skalibs/buffer.h src/include/skalibs/netstring.h src/include/skalibs/uint64.h src/libstddjb/ntp_from_tain.o src/libstddjb/ntp_from_tain.lo: src/libstddjb/ntp_from_tain.c src/include/skalibs/djbtime.h src/include/skalibs/tai.h src/include/skalibs/uint64.h src/libstddjb/open2.o src/libstddjb/open2.lo: src/libstddjb/open2.c src/include/skalibs/nonposix.h src/libstddjb/open3.o src/libstddjb/open3.lo: src/libstddjb/open3.c src/include/skalibs/nonposix.h src/libstddjb/open_append.o src/libstddjb/open_append.lo: src/libstddjb/open_append.c src/include/skalibs/djbunix.h src/include/skalibs/nonposix.h src/libstddjb/open_create.o src/libstddjb/open_create.lo: src/libstddjb/open_create.c src/include/skalibs/djbunix.h src/include/skalibs/nonposix.h src/libstddjb/open_excl.o src/libstddjb/open_excl.lo: src/libstddjb/open_excl.c src/include/skalibs/djbunix.h src/include/skalibs/nonposix.h src/libstddjb/open_read.o src/libstddjb/open_read.lo: src/libstddjb/open_read.c src/include/skalibs/djbunix.h src/include/skalibs/nonposix.h src/libstddjb/open_readb.o src/libstddjb/open_readb.lo: src/libstddjb/open_readb.c src/include/skalibs/djbunix.h src/libstddjb/open_trunc.o src/libstddjb/open_trunc.lo: src/libstddjb/open_trunc.c src/include/skalibs/djbunix.h src/include/skalibs/nonposix.h src/libstddjb/open_write.o src/libstddjb/open_write.lo: src/libstddjb/open_write.c src/include/skalibs/djbunix.h src/include/skalibs/nonposix.h src/libstddjb/openb_read.o src/libstddjb/openb_read.lo: src/libstddjb/openb_read.c src/include/skalibs/djbunix.h src/include/skalibs/nonposix.h src/libstddjb/openbc_read.o src/libstddjb/openbc_read.lo: src/libstddjb/openbc_read.c src/include/skalibs/djbunix.h src/include/skalibs/nonposix.h src/libstddjb/openc_append.o src/libstddjb/openc_append.lo: src/libstddjb/openc_append.c src/include/skalibs/djbunix.h src/include/skalibs/nonposix.h src/libstddjb/openc_create.o src/libstddjb/openc_create.lo: src/libstddjb/openc_create.c src/include/skalibs/djbunix.h src/include/skalibs/nonposix.h src/libstddjb/openc_excl.o src/libstddjb/openc_excl.lo: src/libstddjb/openc_excl.c src/include/skalibs/djbunix.h src/include/skalibs/nonposix.h src/libstddjb/openc_read.o src/libstddjb/openc_read.lo: src/libstddjb/openc_read.c src/include/skalibs/djbunix.h src/include/skalibs/nonposix.h src/libstddjb/openc_readb.o src/libstddjb/openc_readb.lo: src/libstddjb/openc_readb.c src/include/skalibs/djbunix.h src/libstddjb/openc_trunc.o src/libstddjb/openc_trunc.lo: src/libstddjb/openc_trunc.c src/include/skalibs/djbunix.h src/include/skalibs/nonposix.h src/libstddjb/openc_write.o src/libstddjb/openc_write.lo: src/libstddjb/openc_write.c src/include/skalibs/djbunix.h src/include/skalibs/nonposix.h src/libstddjb/openreadfileclose.o src/libstddjb/openreadfileclose.lo: src/libstddjb/openreadfileclose.c src/include/skalibs/allreadwrite.h src/include/skalibs/djbunix.h src/include/skalibs/stralloc.h src/libstddjb/openreadnclose.o src/libstddjb/openreadnclose.lo: src/libstddjb/openreadnclose.c src/include/skalibs/djbunix.h src/libstddjb/openreadnclose_nb.o src/libstddjb/openreadnclose_nb.lo: src/libstddjb/openreadnclose_nb.c src/include/skalibs/djbunix.h src/libstddjb/openslurpnclose.o src/libstddjb/openslurpnclose.lo: src/libstddjb/openslurpnclose.c src/include/skalibs/djbunix.h src/libstddjb/openwritenclose5.o src/libstddjb/openwritenclose5.lo: src/libstddjb/openwritenclose5.c src/include/skalibs/devino.h src/include/skalibs/djbunix.h src/include/skalibs/posixplz.h src/libstddjb/openwritenclose_suffix6.o src/libstddjb/openwritenclose_suffix6.lo: src/libstddjb/openwritenclose_suffix6.c src/include/skalibs/djbunix.h src/include/skalibs/posixplz.h src/libstddjb/openwritenclose_unsafe5.o src/libstddjb/openwritenclose_unsafe5.lo: src/libstddjb/openwritenclose_unsafe5.c src/include/skalibs/djbunix.h src/include/skalibs/posixplz.h src/libstddjb/openwritevnclose5.o src/libstddjb/openwritevnclose5.lo: src/libstddjb/openwritevnclose5.c src/include/skalibs/djbunix.h src/include/skalibs/posixplz.h src/libstddjb/openwritevnclose_suffix6.o src/libstddjb/openwritevnclose_suffix6.lo: src/libstddjb/openwritevnclose_suffix6.c src/include/skalibs/djbunix.h src/include/skalibs/posixplz.h src/libstddjb/openwritevnclose_unsafe5.o src/libstddjb/openwritevnclose_unsafe5.lo: src/libstddjb/openwritevnclose_unsafe5.c src/include/skalibs/djbunix.h src/include/skalibs/posixplz.h src/libstddjb/path_canonicalize.o src/libstddjb/path_canonicalize.lo: src/libstddjb/path_canonicalize.c src/include/skalibs/djbunix.h src/libstddjb/pipe_internal.o src/libstddjb/pipe_internal.lo: src/libstddjb/pipe_internal.c src/include/skalibs/djbunix.h src/include/skalibs/nonposix.h src/include/skalibs/sysdeps.h src/libstddjb/prog.o src/libstddjb/prog.lo: src/libstddjb/prog.c src/include/skalibs/strerr.h src/libstddjb/readnclose.o src/libstddjb/readnclose.lo: src/libstddjb/readnclose.c src/include/skalibs/allreadwrite.h src/include/skalibs/djbunix.h src/libstddjb/rm_rf.o src/libstddjb/rm_rf.lo: src/libstddjb/rm_rf.c src/include/skalibs/djbunix.h src/include/skalibs/skamisc.h src/libstddjb/rm_rf_in_tmp.o src/libstddjb/rm_rf_in_tmp.lo: src/libstddjb/rm_rf_in_tmp.c src/include/skalibs/djbunix.h src/include/skalibs/stralloc.h src/libstddjb/rm_rf_tmp.o src/libstddjb/rm_rf_tmp.lo: src/libstddjb/rm_rf_tmp.c src/include/skalibs/djbunix.h src/include/skalibs/stralloc.h src/libstddjb/rmstar.o src/libstddjb/rmstar.lo: src/libstddjb/rmstar.c src/include/skalibs/djbunix.h src/include/skalibs/skamisc.h src/libstddjb/sabasename.o src/libstddjb/sabasename.lo: src/libstddjb/sabasename.c src/include/skalibs/bytestr.h src/include/skalibs/djbunix.h src/include/skalibs/stralloc.h src/libstddjb/sadirname.o src/libstddjb/sadirname.lo: src/libstddjb/sadirname.c src/include/skalibs/bytestr.h src/include/skalibs/djbunix.h src/include/skalibs/stralloc.h src/libstddjb/sagetcwd.o src/libstddjb/sagetcwd.lo: src/libstddjb/sagetcwd.c src/include/skalibs/djbunix.h src/include/skalibs/stralloc.h src/libstddjb/sagethostname.o src/libstddjb/sagethostname.lo: src/libstddjb/sagethostname.c src/include/skalibs/djbunix.h src/include/skalibs/stralloc.h src/libstddjb/sals.o src/libstddjb/sals.lo: src/libstddjb/sals.c src/include/skalibs/direntry.h src/include/skalibs/djbunix.h src/include/skalibs/stralloc.h src/libstddjb/sanitize_read.o src/libstddjb/sanitize_read.lo: src/libstddjb/sanitize_read.c src/include/skalibs/allreadwrite.h src/include/skalibs/error.h src/libstddjb/sareadlink.o src/libstddjb/sareadlink.lo: src/libstddjb/sareadlink.c src/include/skalibs/djbunix.h src/include/skalibs/stralloc.h src/libstddjb/sarealpath.o src/libstddjb/sarealpath.lo: src/libstddjb/sarealpath.c src/include/skalibs/djbunix.h src/include/skalibs/stralloc.h src/libstddjb/satmp.o src/libstddjb/satmp.lo: src/libstddjb/satmp.c src/include/skalibs/skamisc.h src/include/skalibs/stralloc.h src/libstddjb/sauniquename.o src/libstddjb/sauniquename.lo: src/libstddjb/sauniquename.c src/include/skalibs/djbunix.h src/include/skalibs/skamisc.h src/include/skalibs/stralloc.h src/include/skalibs/tai.h src/include/skalibs/types.h src/libstddjb/selfpipe.o src/libstddjb/selfpipe.lo: src/libstddjb/selfpipe.c src/include/skalibs/allreadwrite.h src/include/skalibs/djbunix.h src/include/skalibs/nonposix.h src/include/skalibs/nsig.h src/include/skalibs/sig.h src/include/skalibs/sysdeps.h src/libstddjb/sgetopt.o src/libstddjb/sgetopt.lo: src/libstddjb/sgetopt.c src/include/skalibs/buffer.h src/include/skalibs/sgetopt.h src/libstddjb/sig0_scan.o src/libstddjb/sig0_scan.lo: src/libstddjb/sig0_scan.c src/include/skalibs/sig.h src/include/skalibs/types.h src/libstddjb/sig_altignore.o src/libstddjb/sig_altignore.lo: src/libstddjb/sig_altignore.c src/include/skalibs/sig.h src/libstddjb/sig_block.o src/libstddjb/sig_block.lo: src/libstddjb/sig_block.c src/include/skalibs/sig.h src/libstddjb/sig_blocknone.o src/libstddjb/sig_blocknone.lo: src/libstddjb/sig_blocknone.c src/include/skalibs/sig.h src/libstddjb/sig_catch.o src/libstddjb/sig_catch.lo: src/libstddjb/sig_catch.c src/include/skalibs/functypes.h src/include/skalibs/nonposix.h src/include/skalibs/nsig.h src/include/skalibs/sig.h src/libstddjb/sig_name.o src/libstddjb/sig_name.lo: src/libstddjb/sig_name.c src/libstddjb/sig-internal.h src/include/skalibs/sig.h src/libstddjb/sig_number.o src/libstddjb/sig_number.lo: src/libstddjb/sig_number.c src/libstddjb/sig-internal.h src/include/skalibs/sig.h src/libstddjb/sig_restoreto.o src/libstddjb/sig_restoreto.lo: src/libstddjb/sig_restoreto.c src/include/skalibs/sig.h src/libstddjb/sig_table.o src/libstddjb/sig_table.lo: src/libstddjb/sig_table.c src/include/skalibs/nonposix.h src/libstddjb/sig-internal.h src/libstddjb/sig_unblock.o src/libstddjb/sig_unblock.lo: src/libstddjb/sig_unblock.c src/include/skalibs/sig.h src/libstddjb/sigfpe.o src/libstddjb/sigfpe.lo: src/libstddjb/sigfpe.c src/include/skalibs/segfault.h src/libstddjb/sigsegv.o src/libstddjb/sigsegv.lo: src/libstddjb/sigsegv.c src/include/skalibs/segfault.h src/libstddjb/siovec_bytechr.o src/libstddjb/siovec_bytechr.lo: src/libstddjb/siovec_bytechr.c src/include/skalibs/bytestr.h src/include/skalibs/siovec.h src/libstddjb/siovec_bytein.o src/libstddjb/siovec_bytein.lo: src/libstddjb/siovec_bytein.c src/include/skalibs/bytestr.h src/include/skalibs/siovec.h src/libstddjb/siovec_deal.o src/libstddjb/siovec_deal.lo: src/libstddjb/siovec_deal.c src/include/skalibs/siovec.h src/libstddjb/siovec_gather.o src/libstddjb/siovec_gather.lo: src/libstddjb/siovec_gather.c src/include/skalibs/siovec.h src/libstddjb/siovec_len.o src/libstddjb/siovec_len.lo: src/libstddjb/siovec_len.c src/include/skalibs/siovec.h src/libstddjb/siovec_scatter.o src/libstddjb/siovec_scatter.lo: src/libstddjb/siovec_scatter.c src/include/skalibs/siovec.h src/libstddjb/siovec_search.o src/libstddjb/siovec_search.lo: src/libstddjb/siovec_search.c src/include/skalibs/posixplz.h src/include/skalibs/siovec.h src/libstddjb/siovec_seek.o src/libstddjb/siovec_seek.lo: src/libstddjb/siovec_seek.c src/include/skalibs/bytestr.h src/include/skalibs/siovec.h src/libstddjb/siovec_trunc.o src/libstddjb/siovec_trunc.lo: src/libstddjb/siovec_trunc.c src/include/skalibs/siovec.h src/libstddjb/skagetln.o src/libstddjb/skagetln.lo: src/libstddjb/skagetln.c src/include/skalibs/buffer.h src/include/skalibs/skamisc.h src/include/skalibs/stralloc.h src/libstddjb/skagetln_loose.o src/libstddjb/skagetln_loose.lo: src/libstddjb/skagetln_loose.c src/include/skalibs/skamisc.h src/include/skalibs/stralloc.h src/libstddjb/skagetln_nofill.o src/libstddjb/skagetln_nofill.lo: src/libstddjb/skagetln_nofill.c src/include/skalibs/buffer.h src/include/skalibs/siovec.h src/include/skalibs/skamisc.h src/include/skalibs/stralloc.h src/libstddjb/skagetlnmaxsep.o src/libstddjb/skagetlnmaxsep.lo: src/libstddjb/skagetlnmaxsep.c src/include/skalibs/buffer.h src/include/skalibs/siovec.h src/include/skalibs/skamisc.h src/include/skalibs/stralloc.h src/libstddjb/skagetlnsep.o src/libstddjb/skagetlnsep.lo: src/libstddjb/skagetlnsep.c src/include/skalibs/buffer.h src/include/skalibs/siovec.h src/include/skalibs/skamisc.h src/include/skalibs/stralloc.h src/libstddjb/skagetlnsep_loose.o src/libstddjb/skagetlnsep_loose.lo: src/libstddjb/skagetlnsep_loose.c src/include/skalibs/skamisc.h src/include/skalibs/stralloc.h src/libstddjb/skalibs_tzisright.o src/libstddjb/skalibs_tzisright.lo: src/libstddjb/skalibs_tzisright.c src/libstddjb/djbtime-internal.h src/libstddjb/slurpn.o src/libstddjb/slurpn.lo: src/libstddjb/slurpn.c src/include/skalibs/allreadwrite.h src/include/skalibs/djbunix.h src/include/skalibs/stralloc.h src/libstddjb/socket_accept4.o src/libstddjb/socket_accept4.lo: src/libstddjb/socket_accept4.c src/include/skalibs/djbunix.h src/include/skalibs/nonposix.h src/include/skalibs/socket.h src/include/skalibs/sysdeps.h src/include/skalibs/uint16.h src/libstddjb/socket_accept4_u32.o src/libstddjb/socket_accept4_u32.lo: src/libstddjb/socket_accept4_u32.c src/include/skalibs/socket.h src/include/skalibs/uint32.h src/libstddjb/socket_accept6.o src/libstddjb/socket_accept6.lo: src/libstddjb/socket_accept6.c src/include/skalibs/djbunix.h src/include/skalibs/ip46.h src/include/skalibs/nonposix.h src/include/skalibs/socket.h src/include/skalibs/sysdeps.h src/include/skalibs/uint16.h src/libstddjb/socket_bind4.o src/libstddjb/socket_bind4.lo: src/libstddjb/socket_bind4.c src/include/skalibs/nonposix.h src/include/skalibs/socket.h src/include/skalibs/uint16.h src/libstddjb/socket_bind4r.o src/libstddjb/socket_bind4r.lo: src/libstddjb/socket_bind4r.c src/include/skalibs/nonposix.h src/include/skalibs/socket.h src/libstddjb/socket_bind6.o src/libstddjb/socket_bind6.lo: src/libstddjb/socket_bind6.c src/include/skalibs/ip46.h src/include/skalibs/nonposix.h src/include/skalibs/socket.h src/include/skalibs/uint16.h src/libstddjb/socket_bind6r.o src/libstddjb/socket_bind6r.lo: src/libstddjb/socket_bind6r.c src/include/skalibs/nonposix.h src/include/skalibs/socket.h src/libstddjb/socket_connect4.o src/libstddjb/socket_connect4.lo: src/libstddjb/socket_connect4.c src/include/skalibs/nonposix.h src/include/skalibs/socket.h src/include/skalibs/uint16.h src/libstddjb/socket_connect4_u32.o src/libstddjb/socket_connect4_u32.lo: src/libstddjb/socket_connect4_u32.c src/include/skalibs/socket.h src/include/skalibs/uint32.h src/libstddjb/socket_connect6.o src/libstddjb/socket_connect6.lo: src/libstddjb/socket_connect6.c src/include/skalibs/ip46.h src/include/skalibs/nonposix.h src/include/skalibs/socket.h src/include/skalibs/uint16.h src/libstddjb/socket_connected.o src/libstddjb/socket_connected.lo: src/libstddjb/socket_connected.c src/include/skalibs/allreadwrite.h src/include/skalibs/nonposix.h src/include/skalibs/socket.h src/libstddjb/socket_deadlineconnstamp4.o src/libstddjb/socket_deadlineconnstamp4.lo: src/libstddjb/socket_deadlineconnstamp4.c src/include/skalibs/error.h src/include/skalibs/socket.h src/libstddjb/socket_deadlineconnstamp46.o src/libstddjb/socket_deadlineconnstamp46.lo: src/libstddjb/socket_deadlineconnstamp46.c src/include/skalibs/error.h src/include/skalibs/ip46.h src/include/skalibs/socket.h src/libstddjb/socket_deadlineconnstamp4_u32.o src/libstddjb/socket_deadlineconnstamp4_u32.lo: src/libstddjb/socket_deadlineconnstamp4_u32.c src/include/skalibs/socket.h src/include/skalibs/uint32.h src/libstddjb/socket_deadlineconnstamp6.o src/libstddjb/socket_deadlineconnstamp6.lo: src/libstddjb/socket_deadlineconnstamp6.c src/include/skalibs/error.h src/include/skalibs/socket.h src/libstddjb/socket_internal.o src/libstddjb/socket_internal.lo: src/libstddjb/socket_internal.c src/include/skalibs/djbunix.h src/include/skalibs/nonposix.h src/include/skalibs/socket.h src/include/skalibs/sysdeps.h src/libstddjb/socket_ioloop.o src/libstddjb/socket_ioloop.lo: src/libstddjb/socket_ioloop.c src/include/skalibs/error.h src/include/skalibs/iopause.h src/include/skalibs/socket.h src/libstddjb/socket_ioloop_send4.o src/libstddjb/socket_ioloop_send4.lo: src/libstddjb/socket_ioloop_send4.c src/include/skalibs/socket.h src/libstddjb/socket_ioloop_send6.o src/libstddjb/socket_ioloop_send6.lo: src/libstddjb/socket_ioloop_send6.c src/include/skalibs/socket.h src/libstddjb/socket_local4.o src/libstddjb/socket_local4.lo: src/libstddjb/socket_local4.c src/include/skalibs/nonposix.h src/include/skalibs/socket.h src/include/skalibs/uint16.h src/libstddjb/socket_local46.o src/libstddjb/socket_local46.lo: src/libstddjb/socket_local46.c src/include/skalibs/ip46.h src/include/skalibs/nonposix.h src/include/skalibs/uint16.h src/libstddjb/socket_local6.o src/libstddjb/socket_local6.lo: src/libstddjb/socket_local6.c src/include/skalibs/ip46.h src/include/skalibs/nonposix.h src/include/skalibs/socket.h src/include/skalibs/uint16.h src/libstddjb/socket_recv4.o src/libstddjb/socket_recv4.lo: src/libstddjb/socket_recv4.c src/include/skalibs/nonposix.h src/include/skalibs/socket.h src/include/skalibs/uint16.h src/libstddjb/socket_recv46.o src/libstddjb/socket_recv46.lo: src/libstddjb/socket_recv46.c src/include/skalibs/ip46.h src/include/skalibs/socket.h src/libstddjb/socket_recv6.o src/libstddjb/socket_recv6.lo: src/libstddjb/socket_recv6.c src/include/skalibs/ip46.h src/include/skalibs/nonposix.h src/include/skalibs/socket.h src/include/skalibs/uint16.h src/libstddjb/socket_recvnb46.o src/libstddjb/socket_recvnb46.lo: src/libstddjb/socket_recvnb46.c src/include/skalibs/ip46.h src/include/skalibs/socket.h src/libstddjb/socket_remote4.o src/libstddjb/socket_remote4.lo: src/libstddjb/socket_remote4.c src/include/skalibs/nonposix.h src/include/skalibs/socket.h src/include/skalibs/uint16.h src/libstddjb/socket_remote46.o src/libstddjb/socket_remote46.lo: src/libstddjb/socket_remote46.c src/include/skalibs/ip46.h src/include/skalibs/nonposix.h src/include/skalibs/uint16.h src/libstddjb/socket_remote6.o src/libstddjb/socket_remote6.lo: src/libstddjb/socket_remote6.c src/include/skalibs/ip46.h src/include/skalibs/nonposix.h src/include/skalibs/socket.h src/include/skalibs/uint16.h src/libstddjb/socket_send4.o src/libstddjb/socket_send4.lo: src/libstddjb/socket_send4.c src/include/skalibs/nonposix.h src/include/skalibs/socket.h src/include/skalibs/uint16.h src/libstddjb/socket_send6.o src/libstddjb/socket_send6.lo: src/libstddjb/socket_send6.c src/include/skalibs/ip46.h src/include/skalibs/nonposix.h src/include/skalibs/socket.h src/include/skalibs/uint16.h src/libstddjb/socket_tcp4.o src/libstddjb/socket_tcp4.lo: src/libstddjb/socket_tcp4.c src/include/skalibs/nonposix.h src/include/skalibs/socket.h src/libstddjb/socket_tcp6.o src/libstddjb/socket_tcp6.lo: src/libstddjb/socket_tcp6.c src/include/skalibs/djbunix.h src/include/skalibs/ip46.h src/include/skalibs/nonposix.h src/include/skalibs/socket.h src/libstddjb/socket_tcpnodelay.o src/libstddjb/socket_tcpnodelay.lo: src/libstddjb/socket_tcpnodelay.c src/include/skalibs/nonposix.h src/include/skalibs/socket.h src/libstddjb/socket_timeoutconn.o src/libstddjb/socket_timeoutconn.lo: src/libstddjb/socket_timeoutconn.c src/include/skalibs/socket.h src/include/skalibs/tai.h src/libstddjb/socket_tryreservein.o src/libstddjb/socket_tryreservein.lo: src/libstddjb/socket_tryreservein.c src/include/skalibs/nonposix.h src/include/skalibs/socket.h src/libstddjb/socket_udp4.o src/libstddjb/socket_udp4.lo: src/libstddjb/socket_udp4.c src/include/skalibs/nonposix.h src/include/skalibs/socket.h src/libstddjb/socket_udp6.o src/libstddjb/socket_udp6.lo: src/libstddjb/socket_udp6.c src/include/skalibs/djbunix.h src/include/skalibs/ip46.h src/include/skalibs/nonposix.h src/include/skalibs/socket.h src/libstddjb/socket_waitconn.o src/libstddjb/socket_waitconn.lo: src/libstddjb/socket_waitconn.c src/include/skalibs/allreadwrite.h src/include/skalibs/iopause.h src/include/skalibs/socket.h src/libstddjb/socketpair_internal.o src/libstddjb/socketpair_internal.lo: src/libstddjb/socketpair_internal.c src/include/skalibs/djbunix.h src/include/skalibs/nonposix.h src/include/skalibs/socket.h src/include/skalibs/sysdeps.h src/libstddjb/stamp.o src/libstddjb/stamp.lo: src/libstddjb/stamp.c src/include/skalibs/tai.h src/libstddjb/str_chr.o src/libstddjb/str_chr.lo: src/libstddjb/str_chr.c src/include/skalibs/bytestr.h src/libstddjb/str_fmt.o src/libstddjb/str_fmt.lo: src/libstddjb/str_fmt.c src/include/skalibs/fmtscan.h src/libstddjb/str_rchr.o src/libstddjb/str_rchr.lo: src/libstddjb/str_rchr.c src/include/skalibs/bytestr.h src/libstddjb/str_start.o src/libstddjb/str_start.lo: src/libstddjb/str_start.c src/include/skalibs/bytestr.h src/libstddjb/str_strn.o src/libstddjb/str_strn.lo: src/libstddjb/str_strn.c src/include/skalibs/bytestr.h src/libstddjb/stralloc_append.o src/libstddjb/stralloc_append.lo: src/libstddjb/stralloc_append.c src/include/skalibs/stralloc.h src/libstddjb/stralloc_catb.o src/libstddjb/stralloc_catb.lo: src/libstddjb/stralloc_catb.c src/include/skalibs/stralloc.h src/libstddjb/stralloc_catv.o src/libstddjb/stralloc_catv.lo: src/libstddjb/stralloc_catv.c src/include/skalibs/siovec.h src/include/skalibs/stralloc.h src/libstddjb/stralloc_copyb.o src/libstddjb/stralloc_copyb.lo: src/libstddjb/stralloc_copyb.c src/include/skalibs/stralloc.h src/libstddjb/stralloc_free.o src/libstddjb/stralloc_free.lo: src/libstddjb/stralloc_free.c src/include/skalibs/alloc.h src/include/skalibs/stralloc.h src/libstddjb/stralloc_insertb.o src/libstddjb/stralloc_insertb.lo: src/libstddjb/stralloc_insertb.c src/include/skalibs/stralloc.h src/libstddjb/stralloc_ready_tuned.o src/libstddjb/stralloc_ready_tuned.lo: src/libstddjb/stralloc_ready_tuned.c src/include/skalibs/alloc.h src/include/skalibs/stralloc.h src/libstddjb/stralloc_readyplus_tuned.o src/libstddjb/stralloc_readyplus_tuned.lo: src/libstddjb/stralloc_readyplus_tuned.c src/include/skalibs/stralloc.h src/libstddjb/stralloc_reverse.o src/libstddjb/stralloc_reverse.lo: src/libstddjb/stralloc_reverse.c src/include/skalibs/stralloc.h src/libstddjb/stralloc_reverse_blocks.o src/libstddjb/stralloc_reverse_blocks.lo: src/libstddjb/stralloc_reverse_blocks.c src/include/skalibs/stralloc.h src/libstddjb/stralloc_shrink.o src/libstddjb/stralloc_shrink.lo: src/libstddjb/stralloc_shrink.c src/include/skalibs/alloc.h src/include/skalibs/stralloc.h src/libstddjb/stralloc_zero.o src/libstddjb/stralloc_zero.lo: src/libstddjb/stralloc_zero.c src/include/skalibs/stralloc.h src/libstddjb/strerr_diev.o src/libstddjb/strerr_diev.lo: src/libstddjb/strerr_diev.c src/include/skalibs/strerr.h src/libstddjb/strerr_dievsys.o src/libstddjb/strerr_dievsys.lo: src/libstddjb/strerr_dievsys.c src/include/skalibs/strerr.h src/libstddjb/strerr_warnv.o src/libstddjb/strerr_warnv.lo: src/libstddjb/strerr_warnv.c src/include/skalibs/buffer.h src/include/skalibs/strerr.h src/libstddjb/strerr_warnvsys.o src/libstddjb/strerr_warnvsys.lo: src/libstddjb/strerr_warnvsys.c src/include/skalibs/buffer.h src/include/skalibs/strerr.h src/libstddjb/string_format.o src/libstddjb/string_format.lo: src/libstddjb/string_format.c src/include/skalibs/bytestr.h src/include/skalibs/stralloc.h src/libstddjb/string_quote.o src/libstddjb/string_quote.lo: src/libstddjb/string_quote.c src/include/skalibs/skamisc.h src/include/skalibs/stralloc.h src/libstddjb/string_quote_nodelim_mustquote.o src/libstddjb/string_quote_nodelim_mustquote.lo: src/libstddjb/string_quote_nodelim_mustquote.c src/include/skalibs/fmtscan.h src/include/skalibs/skamisc.h src/include/skalibs/stralloc.h src/libstddjb/string_unquote.o src/libstddjb/string_unquote.lo: src/libstddjb/string_unquote.c src/include/skalibs/skamisc.h src/libstddjb/string_unquote_nodelim.o src/libstddjb/string_unquote_nodelim.lo: src/libstddjb/string_unquote_nodelim.c src/include/skalibs/skamisc.h src/libstddjb/string_unquote_withdelim.o src/libstddjb/string_unquote_withdelim.lo: src/libstddjb/string_unquote_withdelim.c src/include/skalibs/bytestr.h src/include/skalibs/fmtscan.h src/include/skalibs/posixishard.h src/include/skalibs/skamisc.h src/libstddjb/strn_fmt.o src/libstddjb/strn_fmt.lo: src/libstddjb/strn_fmt.c src/include/skalibs/fmtscan.h src/include/skalibs/types.h src/libstddjb/subgetopt.o src/libstddjb/subgetopt.lo: src/libstddjb/subgetopt.c src/include/skalibs/sgetopt.h src/libstddjb/subgetopt_here.o src/libstddjb/subgetopt_here.lo: src/libstddjb/subgetopt_here.c src/include/skalibs/sgetopt.h src/libstddjb/sysclock_from_localtm.o src/libstddjb/sysclock_from_localtm.lo: src/libstddjb/sysclock_from_localtm.c src/include/skalibs/djbtime.h src/include/skalibs/uint64.h src/libstddjb/sysclock_from_localtmn.o src/libstddjb/sysclock_from_localtmn.lo: src/libstddjb/sysclock_from_localtmn.c src/include/skalibs/djbtime.h src/libstddjb/sysclock_from_ltm64.o src/libstddjb/sysclock_from_ltm64.lo: src/libstddjb/sysclock_from_ltm64.c src/include/skalibs/config.h src/include/skalibs/djbtime.h src/include/skalibs/uint64.h src/libstddjb/sysclock_from_tai.o src/libstddjb/sysclock_from_tai.lo: src/libstddjb/sysclock_from_tai.c src/include/skalibs/config.h src/include/skalibs/djbtime.h src/include/skalibs/tai.h src/libstddjb/sysclock_from_tain.o src/libstddjb/sysclock_from_tain.lo: src/libstddjb/sysclock_from_tain.c src/include/skalibs/tai.h src/libstddjb/sysclock_from_utc.o src/libstddjb/sysclock_from_utc.lo: src/libstddjb/sysclock_from_utc.c src/include/skalibs/config.h src/include/skalibs/djbtime.h src/include/skalibs/uint64.h src/libstddjb/sysclock_get.o src/libstddjb/sysclock_get.lo: src/libstddjb/sysclock_get.c src/include/skalibs/sysdeps.h src/include/skalibs/tai.h src/libstddjb/sysclock_set.o src/libstddjb/sysclock_set.lo: src/libstddjb/sysclock_set.c src/include/skalibs/nonposix.h src/include/skalibs/sysdeps.h src/include/skalibs/tai.h src/libstddjb/tai_add.o src/libstddjb/tai_add.lo: src/libstddjb/tai_add.c src/include/skalibs/tai.h src/libstddjb/tai_from_localtm.o src/libstddjb/tai_from_localtm.lo: src/libstddjb/tai_from_localtm.c src/include/skalibs/djbtime.h src/include/skalibs/uint64.h src/libstddjb/tai_from_ltm64.o src/libstddjb/tai_from_ltm64.lo: src/libstddjb/tai_from_ltm64.c src/libstddjb/djbtime-internal.h src/include/skalibs/djbtime.h src/libstddjb/tai_from_sysclock.o src/libstddjb/tai_from_sysclock.lo: src/libstddjb/tai_from_sysclock.c src/include/skalibs/config.h src/include/skalibs/djbtime.h src/include/skalibs/tai.h src/include/skalibs/uint64.h src/libstddjb/tai_from_utc.o src/libstddjb/tai_from_utc.lo: src/libstddjb/tai_from_utc.c src/libstddjb/djbtime-internal.h src/include/skalibs/djbtime.h src/include/skalibs/tai.h src/libstddjb/tai_now.o src/libstddjb/tai_now.lo: src/libstddjb/tai_now.c src/include/skalibs/tai.h src/libstddjb/tai_pack.o src/libstddjb/tai_pack.lo: src/libstddjb/tai_pack.c src/include/skalibs/tai.h src/include/skalibs/uint64.h src/libstddjb/tai_pack_little.o src/libstddjb/tai_pack_little.lo: src/libstddjb/tai_pack_little.c src/include/skalibs/tai.h src/include/skalibs/uint64.h src/libstddjb/tai_sub.o src/libstddjb/tai_sub.lo: src/libstddjb/tai_sub.c src/include/skalibs/tai.h src/libstddjb/tai_u64.o src/libstddjb/tai_u64.lo: src/libstddjb/tai_u64.c src/include/skalibs/bsdsnowflake.h src/include/skalibs/tai.h src/include/skalibs/uint64.h src/libstddjb/tai_unpack.o src/libstddjb/tai_unpack.lo: src/libstddjb/tai_unpack.c src/include/skalibs/tai.h src/include/skalibs/uint64.h src/libstddjb/tai_unpack_little.o src/libstddjb/tai_unpack_little.lo: src/libstddjb/tai_unpack_little.c src/include/skalibs/tai.h src/include/skalibs/uint64.h src/libstddjb/tain_add.o src/libstddjb/tain_add.lo: src/libstddjb/tain_add.c src/include/skalibs/tai.h src/libstddjb/tain_addsec.o src/libstddjb/tain_addsec.lo: src/libstddjb/tain_addsec.c src/include/skalibs/tai.h src/include/skalibs/uint64.h src/libstddjb/tain_approx.o src/libstddjb/tain_approx.lo: src/libstddjb/tain_approx.c src/include/skalibs/tai.h src/libstddjb/tain_earliest1.o src/libstddjb/tain_earliest1.lo: src/libstddjb/tain_earliest1.c src/include/skalibs/tai.h src/libstddjb/tain_earliestv.o src/libstddjb/tain_earliestv.lo: src/libstddjb/tain_earliestv.c src/include/skalibs/tai.h src/libstddjb/tain_fmt.o src/libstddjb/tain_fmt.lo: src/libstddjb/tain_fmt.c src/include/skalibs/fmtscan.h src/include/skalibs/tai.h src/libstddjb/tain_frac.o src/libstddjb/tain_frac.lo: src/libstddjb/tain_frac.c src/include/skalibs/tai.h src/libstddjb/tain_from_localtmn.o src/libstddjb/tain_from_localtmn.lo: src/libstddjb/tain_from_localtmn.c src/include/skalibs/djbtime.h src/libstddjb/tain_from_millisecs.o src/libstddjb/tain_from_millisecs.lo: src/libstddjb/tain_from_millisecs.c src/include/skalibs/tai.h src/libstddjb/tain_from_ntp.o src/libstddjb/tain_from_ntp.lo: src/libstddjb/tain_from_ntp.c src/include/skalibs/djbtime.h src/include/skalibs/tai.h src/include/skalibs/uint64.h src/libstddjb/tain_from_sysclock.o src/libstddjb/tain_from_sysclock.lo: src/libstddjb/tain_from_sysclock.c src/include/skalibs/tai.h src/libstddjb/tain_from_timespec.o src/libstddjb/tain_from_timespec.lo: src/libstddjb/tain_from_timespec.c src/include/skalibs/tai.h src/libstddjb/tain_from_timespec_sysclock.o src/libstddjb/tain_from_timespec_sysclock.lo: src/libstddjb/tain_from_timespec_sysclock.c src/include/skalibs/tai.h src/libstddjb/tain_from_timeval.o src/libstddjb/tain_from_timeval.lo: src/libstddjb/tain_from_timeval.c src/include/skalibs/tai.h src/libstddjb/tain_from_timeval_sysclock.o src/libstddjb/tain_from_timeval_sysclock.lo: src/libstddjb/tain_from_timeval_sysclock.c src/include/skalibs/tai.h src/libstddjb/tain_half.o src/libstddjb/tain_half.lo: src/libstddjb/tain_half.c src/include/skalibs/tai.h src/libstddjb/tain_infinite.o src/libstddjb/tain_infinite.lo: src/libstddjb/tain_infinite.c src/include/skalibs/tai.h src/libstddjb/tain_infinite_relative.o src/libstddjb/tain_infinite_relative.lo: src/libstddjb/tain_infinite_relative.c src/include/skalibs/tai.h src/libstddjb/tain_less.o src/libstddjb/tain_less.lo: src/libstddjb/tain_less.c src/include/skalibs/tai.h src/libstddjb/tain_nano500.o src/libstddjb/tain_nano500.lo: src/libstddjb/tain_nano500.c src/include/skalibs/tai.h src/libstddjb/tain_now.o src/libstddjb/tain_now.lo: src/libstddjb/tain_now.c src/include/skalibs/tai.h src/libstddjb/tain_now_set_stopwatch.o src/libstddjb/tain_now_set_stopwatch.lo: src/libstddjb/tain_now_set_stopwatch.c src/include/skalibs/sysdeps.h src/include/skalibs/tai.h src/libstddjb/tain_now_set_wallclock.o src/libstddjb/tain_now_set_wallclock.lo: src/libstddjb/tain_now_set_wallclock.c src/include/skalibs/tai.h src/libstddjb/tain_pack.o src/libstddjb/tain_pack.lo: src/libstddjb/tain_pack.c src/include/skalibs/tai.h src/include/skalibs/uint32.h src/libstddjb/tain_pack_little.o src/libstddjb/tain_pack_little.lo: src/libstddjb/tain_pack_little.c src/include/skalibs/tai.h src/include/skalibs/uint32.h src/libstddjb/tain_relative_from_timespec.o src/libstddjb/tain_relative_from_timespec.lo: src/libstddjb/tain_relative_from_timespec.c src/include/skalibs/tai.h src/libstddjb/tain_relative_from_timeval.o src/libstddjb/tain_relative_from_timeval.lo: src/libstddjb/tain_relative_from_timeval.c src/include/skalibs/tai.h src/libstddjb/tain_scan.o src/libstddjb/tain_scan.lo: src/libstddjb/tain_scan.c src/include/skalibs/fmtscan.h src/include/skalibs/tai.h src/libstddjb/tain_setnow.o src/libstddjb/tain_setnow.lo: src/libstddjb/tain_setnow.c src/include/skalibs/tai.h src/libstddjb/tain_stopwatch.o src/libstddjb/tain_stopwatch.lo: src/libstddjb/tain_stopwatch.c src/include/skalibs/sysdeps.h src/include/skalibs/tai.h src/libstddjb/tain_sub.o src/libstddjb/tain_sub.lo: src/libstddjb/tain_sub.c src/include/skalibs/tai.h src/libstddjb/tain_to_millisecs.o src/libstddjb/tain_to_millisecs.lo: src/libstddjb/tain_to_millisecs.c src/include/skalibs/tai.h src/include/skalibs/uint64.h src/libstddjb/tain_ulong.o src/libstddjb/tain_ulong.lo: src/libstddjb/tain_ulong.c src/include/skalibs/tai.h src/libstddjb/tain_unpack.o src/libstddjb/tain_unpack.lo: src/libstddjb/tain_unpack.c src/include/skalibs/tai.h src/include/skalibs/uint32.h src/libstddjb/tain_unpack_little.o src/libstddjb/tain_unpack_little.lo: src/libstddjb/tain_unpack_little.c src/include/skalibs/tai.h src/include/skalibs/uint32.h src/libstddjb/tain_wallclock_read.o src/libstddjb/tain_wallclock_read.lo: src/libstddjb/tain_wallclock_read.c src/include/skalibs/tai.h src/libstddjb/tain_zero.o src/libstddjb/tain_zero.lo: src/libstddjb/tain_zero.c src/include/skalibs/tai.h src/libstddjb/time_from_tai.o src/libstddjb/time_from_tai.lo: src/libstddjb/time_from_tai.c src/include/skalibs/bsdsnowflake.h src/include/skalibs/sysdeps.h src/include/skalibs/tai.h src/include/skalibs/uint64.h src/libstddjb/time_from_tai_relative.o src/libstddjb/time_from_tai_relative.lo: src/libstddjb/time_from_tai_relative.c src/include/skalibs/bsdsnowflake.h src/include/skalibs/sysdeps.h src/include/skalibs/tai.h src/libstddjb/time_sysclock_from_tai.o src/libstddjb/time_sysclock_from_tai.lo: src/libstddjb/time_sysclock_from_tai.c src/include/skalibs/bsdsnowflake.h src/include/skalibs/sysdeps.h src/include/skalibs/tai.h src/include/skalibs/uint64.h src/libstddjb/timespec_cmp.o src/libstddjb/timespec_cmp.lo: src/libstddjb/timespec_cmp.c src/include/skalibs/djbtime.h src/libstddjb/timespec_from_tain.o src/libstddjb/timespec_from_tain.lo: src/libstddjb/timespec_from_tain.c src/include/skalibs/tai.h src/libstddjb/timespec_from_tain_relative.o src/libstddjb/timespec_from_tain_relative.lo: src/libstddjb/timespec_from_tain_relative.c src/include/skalibs/tai.h src/libstddjb/timespec_sysclock_from_tain.o src/libstddjb/timespec_sysclock_from_tain.lo: src/libstddjb/timespec_sysclock_from_tain.c src/include/skalibs/tai.h src/libstddjb/timestamp.o src/libstddjb/timestamp.lo: src/libstddjb/timestamp.c src/include/skalibs/tai.h src/libstddjb/timestamp_fmt.o src/libstddjb/timestamp_fmt.lo: src/libstddjb/timestamp_fmt.c src/include/skalibs/tai.h src/libstddjb/timestamp_r.o src/libstddjb/timestamp_r.lo: src/libstddjb/timestamp_r.c src/include/skalibs/tai.h src/libstddjb/timestamp_scan.o src/libstddjb/timestamp_scan.lo: src/libstddjb/timestamp_scan.c src/include/skalibs/tai.h src/libstddjb/timeval_from_tain.o src/libstddjb/timeval_from_tain.lo: src/libstddjb/timeval_from_tain.c src/include/skalibs/tai.h src/libstddjb/timeval_from_tain_relative.o src/libstddjb/timeval_from_tain_relative.lo: src/libstddjb/timeval_from_tain_relative.c src/include/skalibs/tai.h src/libstddjb/timeval_sysclock_from_tain.o src/libstddjb/timeval_sysclock_from_tain.lo: src/libstddjb/timeval_sysclock_from_tain.c src/include/skalibs/tai.h src/libstddjb/ucharn_findlen.o src/libstddjb/ucharn_findlen.lo: src/libstddjb/ucharn_findlen.c src/include/skalibs/fmtscan.h src/libstddjb/ucharn_fmt.o src/libstddjb/ucharn_fmt.lo: src/libstddjb/ucharn_fmt.c src/include/skalibs/fmtscan.h src/libstddjb/ucharn_fmt_little.o src/libstddjb/ucharn_fmt_little.lo: src/libstddjb/ucharn_fmt_little.c src/include/skalibs/fmtscan.h src/libstddjb/ucharn_scan.o src/libstddjb/ucharn_scan.lo: src/libstddjb/ucharn_scan.c src/include/skalibs/fmtscan.h src/libstddjb/ucharn_scan_little.o src/libstddjb/ucharn_scan_little.lo: src/libstddjb/ucharn_scan_little.c src/include/skalibs/fmtscan.h src/libstddjb/ucspi_get.o src/libstddjb/ucspi_get.lo: src/libstddjb/ucspi_get.c src/include/skalibs/env.h src/libstddjb/uint160_scan.o src/libstddjb/uint160_scan.lo: src/libstddjb/uint160_scan.c src/libstddjb/fmtscan-internal.h src/include/skalibs/uint16.h src/libstddjb/uint16_bswap.o src/libstddjb/uint16_bswap.lo: src/libstddjb/uint16_bswap.c src/include/skalibs/uint16.h src/libstddjb/uint16_bswapn.o src/libstddjb/uint16_bswapn.lo: src/libstddjb/uint16_bswapn.c src/include/skalibs/uint16.h src/libstddjb/uint16_bswapp.o src/libstddjb/uint16_bswapp.lo: src/libstddjb/uint16_bswapp.c src/include/skalibs/uint16.h src/libstddjb/uint16_fmtlist.o src/libstddjb/uint16_fmtlist.lo: src/libstddjb/uint16_fmtlist.c src/libstddjb/fmtscan-internal.h src/include/skalibs/uint16.h src/libstddjb/uint16_pack.o src/libstddjb/uint16_pack.lo: src/libstddjb/uint16_pack.c src/include/skalibs/uint16.h src/libstddjb/uint16_pack_big.o src/libstddjb/uint16_pack_big.lo: src/libstddjb/uint16_pack_big.c src/include/skalibs/uint16.h src/libstddjb/uint16_scan.o src/libstddjb/uint16_scan.lo: src/libstddjb/uint16_scan.c src/libstddjb/fmtscan-internal.h src/include/skalibs/uint16.h src/include/skalibs/uint64.h src/libstddjb/uint16_scanlist.o src/libstddjb/uint16_scanlist.lo: src/libstddjb/uint16_scanlist.c src/libstddjb/fmtscan-internal.h src/include/skalibs/uint16.h src/libstddjb/uint16_unpack.o src/libstddjb/uint16_unpack.lo: src/libstddjb/uint16_unpack.c src/include/skalibs/uint16.h src/libstddjb/uint16_unpack_big.o src/libstddjb/uint16_unpack_big.lo: src/libstddjb/uint16_unpack_big.c src/include/skalibs/uint16.h src/libstddjb/uint320_scan.o src/libstddjb/uint320_scan.lo: src/libstddjb/uint320_scan.c src/libstddjb/fmtscan-internal.h src/include/skalibs/uint32.h src/libstddjb/uint32_bswap.o src/libstddjb/uint32_bswap.lo: src/libstddjb/uint32_bswap.c src/include/skalibs/uint32.h src/libstddjb/uint32_bswapn.o src/libstddjb/uint32_bswapn.lo: src/libstddjb/uint32_bswapn.c src/include/skalibs/uint32.h src/libstddjb/uint32_bswapp.o src/libstddjb/uint32_bswapp.lo: src/libstddjb/uint32_bswapp.c src/include/skalibs/uint32.h src/libstddjb/uint32_fmtlist.o src/libstddjb/uint32_fmtlist.lo: src/libstddjb/uint32_fmtlist.c src/libstddjb/fmtscan-internal.h src/include/skalibs/uint32.h src/libstddjb/uint32_pack.o src/libstddjb/uint32_pack.lo: src/libstddjb/uint32_pack.c src/include/skalibs/uint32.h src/libstddjb/uint32_pack_big.o src/libstddjb/uint32_pack_big.lo: src/libstddjb/uint32_pack_big.c src/include/skalibs/uint32.h src/libstddjb/uint32_scan.o src/libstddjb/uint32_scan.lo: src/libstddjb/uint32_scan.c src/libstddjb/fmtscan-internal.h src/include/skalibs/uint32.h src/include/skalibs/uint64.h src/libstddjb/uint32_scanlist.o src/libstddjb/uint32_scanlist.lo: src/libstddjb/uint32_scanlist.c src/libstddjb/fmtscan-internal.h src/include/skalibs/uint32.h src/libstddjb/uint32_unpack.o src/libstddjb/uint32_unpack.lo: src/libstddjb/uint32_unpack.c src/include/skalibs/uint32.h src/libstddjb/uint32_unpack_big.o src/libstddjb/uint32_unpack_big.lo: src/libstddjb/uint32_unpack_big.c src/include/skalibs/uint32.h src/libstddjb/uint640_fmt_generic.o src/libstddjb/uint640_fmt_generic.lo: src/libstddjb/uint640_fmt_generic.c src/include/skalibs/fmtscan.h src/include/skalibs/uint64.h src/libstddjb/uint640_scan.o src/libstddjb/uint640_scan.lo: src/libstddjb/uint640_scan.c src/libstddjb/fmtscan-internal.h src/include/skalibs/uint64.h src/libstddjb/uint640_scan_base_max.o src/libstddjb/uint640_scan_base_max.lo: src/libstddjb/uint640_scan_base_max.c src/include/skalibs/fmtscan.h src/include/skalibs/uint64.h src/libstddjb/uint64_bswap.o src/libstddjb/uint64_bswap.lo: src/libstddjb/uint64_bswap.c src/include/skalibs/uint64.h src/libstddjb/uint64_bswapn.o src/libstddjb/uint64_bswapn.lo: src/libstddjb/uint64_bswapn.c src/include/skalibs/uint64.h src/libstddjb/uint64_bswapp.o src/libstddjb/uint64_bswapp.lo: src/libstddjb/uint64_bswapp.c src/include/skalibs/uint64.h src/libstddjb/uint64_fmt_generic.o src/libstddjb/uint64_fmt_generic.lo: src/libstddjb/uint64_fmt_generic.c src/include/skalibs/fmtscan.h src/include/skalibs/uint64.h src/libstddjb/uint64_fmtlist.o src/libstddjb/uint64_fmtlist.lo: src/libstddjb/uint64_fmtlist.c src/libstddjb/fmtscan-internal.h src/include/skalibs/uint64.h src/libstddjb/uint64_fmtlist_generic.o src/libstddjb/uint64_fmtlist_generic.lo: src/libstddjb/uint64_fmtlist_generic.c src/include/skalibs/uint64.h src/libstddjb/uint64_pack.o src/libstddjb/uint64_pack.lo: src/libstddjb/uint64_pack.c src/include/skalibs/uint64.h src/libstddjb/uint64_pack_big.o src/libstddjb/uint64_pack_big.lo: src/libstddjb/uint64_pack_big.c src/include/skalibs/uint64.h src/libstddjb/uint64_scan.o src/libstddjb/uint64_scan.lo: src/libstddjb/uint64_scan.c src/libstddjb/fmtscan-internal.h src/include/skalibs/uint64.h src/libstddjb/uint64_scan_base_max.o src/libstddjb/uint64_scan_base_max.lo: src/libstddjb/uint64_scan_base_max.c src/include/skalibs/fmtscan.h src/include/skalibs/uint64.h src/libstddjb/uint64_scanlist.o src/libstddjb/uint64_scanlist.lo: src/libstddjb/uint64_scanlist.c src/libstddjb/fmtscan-internal.h src/include/skalibs/uint64.h src/libstddjb/uint64_unpack.o src/libstddjb/uint64_unpack.lo: src/libstddjb/uint64_unpack.c src/include/skalibs/uint64.h src/libstddjb/uint64_unpack_big.o src/libstddjb/uint64_unpack_big.lo: src/libstddjb/uint64_unpack_big.c src/include/skalibs/uint64.h src/libstddjb/uncoe.o src/libstddjb/uncoe.lo: src/libstddjb/uncoe.c src/include/skalibs/djbunix.h src/libstddjb/unsanitize_read.o src/libstddjb/unsanitize_read.lo: src/libstddjb/unsanitize_read.c src/include/skalibs/allreadwrite.h src/include/skalibs/error.h src/libstddjb/utc_from_localtm.o src/libstddjb/utc_from_localtm.lo: src/libstddjb/utc_from_localtm.c src/include/skalibs/djbtime.h src/include/skalibs/uint64.h src/libstddjb/utc_from_ltm64.o src/libstddjb/utc_from_ltm64.lo: src/libstddjb/utc_from_ltm64.c src/include/skalibs/config.h src/libstddjb/djbtime-internal.h src/include/skalibs/djbtime.h src/include/skalibs/uint64.h src/libstddjb/utc_from_sysclock.o src/libstddjb/utc_from_sysclock.lo: src/libstddjb/utc_from_sysclock.c src/include/skalibs/config.h src/include/skalibs/djbtime.h src/include/skalibs/tai.h src/include/skalibs/uint64.h src/libstddjb/utc_from_tai.o src/libstddjb/utc_from_tai.lo: src/libstddjb/utc_from_tai.c src/libstddjb/djbtime-internal.h src/include/skalibs/djbtime.h src/libstddjb/vbaprintf.o src/libstddjb/vbaprintf.lo: src/libstddjb/vbaprintf.c src/include/skalibs/bufalloc.h src/include/skalibs/lolstdio.h src/include/skalibs/stralloc.h src/libstddjb/vbprintf.o src/libstddjb/vbprintf.lo: src/libstddjb/vbprintf.c src/include/skalibs/buffer.h src/include/skalibs/lolstdio.h src/libstddjb/wait_nointr.o src/libstddjb/wait_nointr.lo: src/libstddjb/wait_nointr.c src/include/skalibs/djbunix.h src/libstddjb/wait_pid_nohang.o src/libstddjb/wait_pid_nohang.lo: src/libstddjb/wait_pid_nohang.c src/include/skalibs/djbunix.h src/libstddjb/wait_pids_nohang.o src/libstddjb/wait_pids_nohang.lo: src/libstddjb/wait_pids_nohang.c src/include/skalibs/djbunix.h src/libstddjb/wait_reap.o src/libstddjb/wait_reap.lo: src/libstddjb/wait_reap.c src/include/skalibs/djbunix.h src/libstddjb/waitn.o src/libstddjb/waitn.lo: src/libstddjb/waitn.c src/include/skalibs/djbunix.h src/libstddjb/waitn_posix.o src/libstddjb/waitn_posix.lo: src/libstddjb/waitn_posix.c src/include/skalibs/djbunix.h src/libstddjb/waitn_reap.o src/libstddjb/waitn_reap.lo: src/libstddjb/waitn_reap.c src/include/skalibs/djbunix.h src/libstddjb/waitn_reap_posix.o src/libstddjb/waitn_reap_posix.lo: src/libstddjb/waitn_reap_posix.c src/include/skalibs/djbunix.h src/libstddjb/waitpid_nointr.o src/libstddjb/waitpid_nointr.lo: src/libstddjb/waitpid_nointr.c src/include/skalibs/djbunix.h src/libstddjb/writenclose_unsafe5.o src/libstddjb/writenclose_unsafe5.lo: src/libstddjb/writenclose_unsafe5.c src/include/skalibs/allreadwrite.h src/include/skalibs/djbunix.h src/libstddjb/writevnclose_unsafe5.o src/libstddjb/writevnclose_unsafe5.lo: src/libstddjb/writevnclose_unsafe5.c src/include/skalibs/allreadwrite.h src/include/skalibs/djbunix.h src/include/skalibs/siovec.h src/libunixonacid/access_at.o src/libunixonacid/access_at.lo: src/libunixonacid/access_at.c src/include/skalibs/djbunix.h src/include/skalibs/nonposix.h src/include/skalibs/sysdeps.h src/include/skalibs/unix-transactional.h src/libunixonacid/ancil_recv_fd.o src/libunixonacid/ancil_recv_fd.lo: src/libunixonacid/ancil_recv_fd.c src/include/skalibs/allreadwrite.h src/include/skalibs/ancil.h src/include/skalibs/djbunix.h src/include/skalibs/nonposix.h src/include/skalibs/posixishard.h src/include/skalibs/sysdeps.h src/libunixonacid/ancil_send_fd.o src/libunixonacid/ancil_send_fd.lo: src/libunixonacid/ancil_send_fd.c src/include/skalibs/ancil.h src/include/skalibs/nonposix.h src/include/skalibs/posixishard.h src/libunixonacid/atomic_rm_rf.o src/libunixonacid/atomic_rm_rf.lo: src/libunixonacid/atomic_rm_rf.c src/include/skalibs/skamisc.h src/include/skalibs/unix-transactional.h src/libunixonacid/atomic_rm_rf_tmp.o src/libunixonacid/atomic_rm_rf_tmp.lo: src/libunixonacid/atomic_rm_rf_tmp.c src/include/skalibs/djbunix.h src/include/skalibs/random.h src/include/skalibs/stralloc.h src/include/skalibs/unix-transactional.h src/libunixonacid/atomic_symlink.o src/libunixonacid/atomic_symlink.lo: src/libunixonacid/atomic_symlink.c src/include/skalibs/posixplz.h src/include/skalibs/unix-transactional.h src/libunixonacid/bufalloc_timed_flush.o src/libunixonacid/bufalloc_timed_flush.lo: src/libunixonacid/bufalloc_timed_flush.c src/include/skalibs/bufalloc.h src/include/skalibs/functypes.h src/include/skalibs/unix-timed.h src/libunixonacid/buffer_timed_fill.o src/libunixonacid/buffer_timed_fill.lo: src/libunixonacid/buffer_timed_fill.c src/include/skalibs/allreadwrite.h src/include/skalibs/buffer.h src/include/skalibs/functypes.h src/include/skalibs/unix-timed.h src/libunixonacid/buffer_timed_flush.o src/libunixonacid/buffer_timed_flush.lo: src/libunixonacid/buffer_timed_flush.c src/include/skalibs/buffer.h src/include/skalibs/functypes.h src/include/skalibs/unix-timed.h src/libunixonacid/buffer_timed_get.o src/libunixonacid/buffer_timed_get.lo: src/libunixonacid/buffer_timed_get.c src/include/skalibs/buffer.h src/include/skalibs/functypes.h src/include/skalibs/unix-timed.h src/libunixonacid/buffer_timed_put.o src/libunixonacid/buffer_timed_put.lo: src/libunixonacid/buffer_timed_put.c src/include/skalibs/buffer.h src/include/skalibs/unix-timed.h src/libunixonacid/buffer_timed_puts.o src/libunixonacid/buffer_timed_puts.lo: src/libunixonacid/buffer_timed_puts.c src/include/skalibs/unix-timed.h src/libunixonacid/ipc_timed_recv.o src/libunixonacid/ipc_timed_recv.lo: src/libunixonacid/ipc_timed_recv.c src/include/skalibs/allreadwrite.h src/include/skalibs/functypes.h src/include/skalibs/socket.h src/include/skalibs/unix-timed.h src/libunixonacid/ipc_timed_send.o src/libunixonacid/ipc_timed_send.lo: src/libunixonacid/ipc_timed_send.c src/include/skalibs/error.h src/include/skalibs/iopause.h src/include/skalibs/nonposix.h src/include/skalibs/posixishard.h src/include/skalibs/unix-timed.h src/libunixonacid/ipc_timed_sendv.o src/libunixonacid/ipc_timed_sendv.lo: src/libunixonacid/ipc_timed_sendv.c src/include/skalibs/error.h src/include/skalibs/iopause.h src/include/skalibs/nonposix.h src/include/skalibs/posixishard.h src/include/skalibs/siovec.h src/include/skalibs/unix-timed.h src/libunixonacid/kolbak_call.o src/libunixonacid/kolbak_call.lo: src/libunixonacid/kolbak_call.c src/include/skalibs/kolbak.h src/include/skalibs/unixmessage.h src/libunixonacid/kolbak_enqueue.o src/libunixonacid/kolbak_enqueue.lo: src/libunixonacid/kolbak_enqueue.c src/include/skalibs/kolbak.h src/include/skalibs/unixmessage.h src/libunixonacid/kolbak_queue_init.o src/libunixonacid/kolbak_queue_init.lo: src/libunixonacid/kolbak_queue_init.c src/include/skalibs/kolbak.h src/libunixonacid/kolbak_unenqueue.o src/libunixonacid/kolbak_unenqueue.lo: src/libunixonacid/kolbak_unenqueue.c src/include/skalibs/kolbak.h src/libunixonacid/netstring_timed_get.o src/libunixonacid/netstring_timed_get.lo: src/libunixonacid/netstring_timed_get.c src/include/skalibs/buffer.h src/include/skalibs/iopause.h src/include/skalibs/netstring.h src/include/skalibs/unix-timed.h src/libunixonacid/open2_at.o src/libunixonacid/open2_at.lo: src/libunixonacid/open2_at.c src/include/skalibs/djbunix.h src/include/skalibs/nonposix.h src/include/skalibs/sysdeps.h src/include/skalibs/unix-transactional.h src/libunixonacid/open3_at.o src/libunixonacid/open3_at.lo: src/libunixonacid/open3_at.c src/include/skalibs/djbunix.h src/include/skalibs/nonposix.h src/include/skalibs/sysdeps.h src/include/skalibs/unix-transactional.h src/libunixonacid/open_appendat.o src/libunixonacid/open_appendat.lo: src/libunixonacid/open_appendat.c src/include/skalibs/unix-transactional.h src/libunixonacid/open_appendatb.o src/libunixonacid/open_appendatb.lo: src/libunixonacid/open_appendatb.c src/include/skalibs/djbunix.h src/include/skalibs/unix-transactional.h src/libunixonacid/open_readat.o src/libunixonacid/open_readat.lo: src/libunixonacid/open_readat.c src/include/skalibs/unix-transactional.h src/libunixonacid/open_readatb.o src/libunixonacid/open_readatb.lo: src/libunixonacid/open_readatb.c src/include/skalibs/djbunix.h src/include/skalibs/unix-transactional.h src/libunixonacid/open_truncat.o src/libunixonacid/open_truncat.lo: src/libunixonacid/open_truncat.c src/include/skalibs/unix-transactional.h src/libunixonacid/open_truncatb.o src/libunixonacid/open_truncatb.lo: src/libunixonacid/open_truncatb.c src/include/skalibs/djbunix.h src/include/skalibs/unix-transactional.h src/libunixonacid/open_writeat.o src/libunixonacid/open_writeat.lo: src/libunixonacid/open_writeat.c src/include/skalibs/unix-transactional.h src/libunixonacid/open_writeatb.o src/libunixonacid/open_writeatb.lo: src/libunixonacid/open_writeatb.c src/include/skalibs/djbunix.h src/include/skalibs/unix-transactional.h src/libunixonacid/openc_appendat.o src/libunixonacid/openc_appendat.lo: src/libunixonacid/openc_appendat.c src/include/skalibs/unix-transactional.h src/libunixonacid/openc_appendatb.o src/libunixonacid/openc_appendatb.lo: src/libunixonacid/openc_appendatb.c src/include/skalibs/djbunix.h src/include/skalibs/unix-transactional.h src/libunixonacid/openc_readat.o src/libunixonacid/openc_readat.lo: src/libunixonacid/openc_readat.c src/include/skalibs/unix-transactional.h src/libunixonacid/openc_readatb.o src/libunixonacid/openc_readatb.lo: src/libunixonacid/openc_readatb.c src/include/skalibs/djbunix.h src/include/skalibs/unix-transactional.h src/libunixonacid/openc_truncat.o src/libunixonacid/openc_truncat.lo: src/libunixonacid/openc_truncat.c src/include/skalibs/unix-transactional.h src/libunixonacid/openc_truncatb.o src/libunixonacid/openc_truncatb.lo: src/libunixonacid/openc_truncatb.c src/include/skalibs/djbunix.h src/include/skalibs/unix-transactional.h src/libunixonacid/openc_writeat.o src/libunixonacid/openc_writeat.lo: src/libunixonacid/openc_writeat.c src/include/skalibs/unix-transactional.h src/libunixonacid/openc_writeatb.o src/libunixonacid/openc_writeatb.lo: src/libunixonacid/openc_writeatb.c src/include/skalibs/djbunix.h src/include/skalibs/unix-transactional.h src/libunixonacid/opendir_at.o src/libunixonacid/opendir_at.lo: src/libunixonacid/opendir_at.c src/include/skalibs/direntry.h src/include/skalibs/djbunix.h src/include/skalibs/nonposix.h src/include/skalibs/unix-transactional.h src/libunixonacid/opengetlnclose.o src/libunixonacid/opengetlnclose.lo: src/libunixonacid/opengetlnclose.c src/include/skalibs/allreadwrite.h src/include/skalibs/buffer.h src/include/skalibs/djbunix.h src/include/skalibs/skamisc.h src/include/skalibs/unix-transactional.h src/libunixonacid/opengetlnclose_at.o src/libunixonacid/opengetlnclose_at.lo: src/libunixonacid/opengetlnclose_at.c src/include/skalibs/allreadwrite.h src/include/skalibs/buffer.h src/include/skalibs/djbunix.h src/include/skalibs/skamisc.h src/include/skalibs/unix-transactional.h src/libunixonacid/openreadnclose_at.o src/libunixonacid/openreadnclose_at.lo: src/libunixonacid/openreadnclose_at.c src/include/skalibs/djbunix.h src/include/skalibs/unix-transactional.h src/libunixonacid/openslurpclose_at.o src/libunixonacid/openslurpclose_at.lo: src/libunixonacid/openslurpclose_at.c src/include/skalibs/djbunix.h src/include/skalibs/unix-transactional.h src/libunixonacid/openwritenclose_at.o src/libunixonacid/openwritenclose_at.lo: src/libunixonacid/openwritenclose_at.c src/include/skalibs/allreadwrite.h src/include/skalibs/djbunix.h src/include/skalibs/unix-transactional.h src/libunixonacid/openwritevnclose_at.o src/libunixonacid/openwritevnclose_at.lo: src/libunixonacid/openwritevnclose_at.c src/include/skalibs/allreadwrite.h src/include/skalibs/djbunix.h src/include/skalibs/siovec.h src/include/skalibs/unix-transactional.h src/libunixonacid/skaclient_default_cb.o src/libunixonacid/skaclient_default_cb.lo: src/libunixonacid/skaclient_default_cb.c src/include/skalibs/posixishard.h src/include/skalibs/skaclient.h src/include/skalibs/unixmessage.h src/libunixonacid/skaclient_end.o src/libunixonacid/skaclient_end.lo: src/libunixonacid/skaclient_end.c src/include/skalibs/djbunix.h src/include/skalibs/skaclient.h src/include/skalibs/unixmessage.h src/libunixonacid/skaclient_init.o src/libunixonacid/skaclient_init.lo: src/libunixonacid/skaclient_init.c src/libunixonacid/skaclient-internal.h src/include/skalibs/skaclient.h src/include/skalibs/unixmessage.h src/libunixonacid/skaclient_put.o src/libunixonacid/skaclient_put.lo: src/libunixonacid/skaclient_put.c src/include/skalibs/skaclient.h src/include/skalibs/unixmessage.h src/libunixonacid/skaclient_putmsg.o src/libunixonacid/skaclient_putmsg.lo: src/libunixonacid/skaclient_putmsg.c src/include/skalibs/kolbak.h src/include/skalibs/skaclient.h src/include/skalibs/unixmessage.h src/libunixonacid/skaclient_putmsgv.o src/libunixonacid/skaclient_putmsgv.lo: src/libunixonacid/skaclient_putmsgv.c src/include/skalibs/kolbak.h src/include/skalibs/skaclient.h src/include/skalibs/unixmessage.h src/libunixonacid/skaclient_putv.o src/libunixonacid/skaclient_putv.lo: src/libunixonacid/skaclient_putv.c src/include/skalibs/skaclient.h src/include/skalibs/unixmessage.h src/libunixonacid/skaclient_send.o src/libunixonacid/skaclient_send.lo: src/libunixonacid/skaclient_send.c src/include/skalibs/skaclient.h src/include/skalibs/unixmessage.h src/libunixonacid/skaclient_sendmsg.o src/libunixonacid/skaclient_sendmsg.lo: src/libunixonacid/skaclient_sendmsg.c src/include/skalibs/skaclient.h src/libunixonacid/skaclient_sendmsgv.o src/libunixonacid/skaclient_sendmsgv.lo: src/libunixonacid/skaclient_sendmsgv.c src/include/skalibs/skaclient.h src/libunixonacid/skaclient_sendv.o src/libunixonacid/skaclient_sendv.lo: src/libunixonacid/skaclient_sendv.c src/include/skalibs/skaclient.h src/include/skalibs/unixmessage.h src/libunixonacid/skaclient_server_ack.o src/libunixonacid/skaclient_server_ack.lo: src/libunixonacid/skaclient_server_ack.c src/include/skalibs/djbunix.h src/include/skalibs/posixishard.h src/include/skalibs/skaclient.h src/include/skalibs/socket.h src/include/skalibs/unixmessage.h src/libunixonacid/skaclient_server_bidi_ack.o src/libunixonacid/skaclient_server_bidi_ack.lo: src/libunixonacid/skaclient_server_bidi_ack.c src/include/skalibs/skaclient.h src/include/skalibs/unixmessage.h src/libunixonacid/skaclient_server_init.o src/libunixonacid/skaclient_server_init.lo: src/libunixonacid/skaclient_server_init.c src/include/skalibs/allreadwrite.h src/include/skalibs/skaclient.h src/include/skalibs/unixmessage.h src/libunixonacid/skaclient_start.o src/libunixonacid/skaclient_start.lo: src/libunixonacid/skaclient_start.c src/include/skalibs/kolbak.h src/libunixonacid/skaclient-internal.h src/include/skalibs/skaclient.h src/libunixonacid/skaclient_start_async.o src/libunixonacid/skaclient_start_async.lo: src/libunixonacid/skaclient_start_async.c src/include/skalibs/djbunix.h src/include/skalibs/error.h src/include/skalibs/kolbak.h src/libunixonacid/skaclient-internal.h src/include/skalibs/skaclient.h src/include/skalibs/socket.h src/include/skalibs/unixmessage.h src/libunixonacid/skaclient_start_cb.o src/libunixonacid/skaclient_start_cb.lo: src/libunixonacid/skaclient_start_cb.c src/include/skalibs/posixishard.h src/libunixonacid/skaclient-internal.h src/include/skalibs/skaclient.h src/include/skalibs/unixmessage.h src/libunixonacid/skaclient_startf.o src/libunixonacid/skaclient_startf.lo: src/libunixonacid/skaclient_startf.c src/include/skalibs/kolbak.h src/libunixonacid/skaclient-internal.h src/include/skalibs/skaclient.h src/libunixonacid/skaclient_startf_async.o src/libunixonacid/skaclient_startf_async.lo: src/libunixonacid/skaclient_startf_async.c src/include/skalibs/cspawn.h src/include/skalibs/djbunix.h src/include/skalibs/kolbak.h src/libunixonacid/skaclient-internal.h src/include/skalibs/skaclient.h src/libunixonacid/skaclient_syncify.o src/libunixonacid/skaclient_syncify.lo: src/libunixonacid/skaclient_syncify.c src/include/skalibs/skaclient.h src/libunixonacid/skaclient_zero.o src/libunixonacid/skaclient_zero.lo: src/libunixonacid/skaclient_zero.c src/include/skalibs/skaclient.h src/libunixonacid/stat_at.o src/libunixonacid/stat_at.lo: src/libunixonacid/stat_at.c src/include/skalibs/djbunix.h src/include/skalibs/nonposix.h src/include/skalibs/sysdeps.h src/include/skalibs/unix-transactional.h src/libunixonacid/textclient_command.o src/libunixonacid/textclient_command.lo: src/libunixonacid/textclient_command.c src/include/skalibs/posixishard.h src/include/skalibs/textclient.h src/libunixonacid/textclient_commandv.o src/libunixonacid/textclient_commandv.lo: src/libunixonacid/textclient_commandv.c src/include/skalibs/posixishard.h src/include/skalibs/textclient.h src/libunixonacid/textclient_end.o src/libunixonacid/textclient_end.lo: src/libunixonacid/textclient_end.c src/include/skalibs/djbunix.h src/include/skalibs/textclient.h src/include/skalibs/textmessage.h src/libunixonacid/textclient_server_init.o src/libunixonacid/textclient_server_init.lo: src/libunixonacid/textclient_server_init.c src/include/skalibs/cspawn.h src/include/skalibs/textclient.h src/libunixonacid/textclient_server_init_frompipe.o src/libunixonacid/textclient_server_init_frompipe.lo: src/libunixonacid/textclient_server_init_frompipe.c src/include/skalibs/allreadwrite.h src/include/skalibs/cspawn.h src/include/skalibs/posixishard.h src/include/skalibs/textclient.h src/include/skalibs/textmessage.h src/include/skalibs/types.h src/libunixonacid/textclient_server_init_fromsocket.o src/libunixonacid/textclient_server_init_fromsocket.lo: src/libunixonacid/textclient_server_init_fromsocket.c src/include/skalibs/allreadwrite.h src/include/skalibs/posixishard.h src/include/skalibs/textclient.h src/include/skalibs/textmessage.h src/libunixonacid/textclient_start.o src/libunixonacid/textclient_start.lo: src/libunixonacid/textclient_start.c src/include/skalibs/djbunix.h src/include/skalibs/posixishard.h src/include/skalibs/socket.h src/include/skalibs/textclient.h src/include/skalibs/textmessage.h src/libunixonacid/textclient_startf.o src/libunixonacid/textclient_startf.lo: src/libunixonacid/textclient_startf.c src/include/skalibs/allreadwrite.h src/include/skalibs/cspawn.h src/include/skalibs/posixishard.h src/include/skalibs/textclient.h src/include/skalibs/textmessage.h src/libunixonacid/textclient_zero.o src/libunixonacid/textclient_zero.lo: src/libunixonacid/textclient_zero.c src/include/skalibs/textclient.h src/libunixonacid/textmessage_create_send_channel.o src/libunixonacid/textmessage_create_send_channel.lo: src/libunixonacid/textmessage_create_send_channel.c src/include/skalibs/ancil.h src/include/skalibs/djbunix.h src/include/skalibs/posixishard.h src/include/skalibs/textclient.h src/include/skalibs/textmessage.h src/include/skalibs/unix-timed.h src/libunixonacid/textmessage_handle.o src/libunixonacid/textmessage_handle.lo: src/libunixonacid/textmessage_handle.c src/include/skalibs/textmessage.h src/libunixonacid/textmessage_put.o src/libunixonacid/textmessage_put.lo: src/libunixonacid/textmessage_put.c src/include/skalibs/bufalloc.h src/include/skalibs/textmessage.h src/include/skalibs/uint32.h src/libunixonacid/textmessage_putv.o src/libunixonacid/textmessage_putv.lo: src/libunixonacid/textmessage_putv.c src/include/skalibs/bufalloc.h src/include/skalibs/siovec.h src/include/skalibs/textmessage.h src/include/skalibs/uint32.h src/libunixonacid/textmessage_receive.o src/libunixonacid/textmessage_receive.lo: src/libunixonacid/textmessage_receive.c src/include/skalibs/allreadwrite.h src/include/skalibs/buffer.h src/include/skalibs/stralloc.h src/include/skalibs/textmessage.h src/include/skalibs/uint32.h src/libunixonacid/textmessage_receiver_0.o src/libunixonacid/textmessage_receiver_0.lo: src/libunixonacid/textmessage_receiver_0.c src/include/skalibs/buffer.h src/include/skalibs/textmessage.h src/libunixonacid/textmessage_receiver_free.o src/libunixonacid/textmessage_receiver_free.lo: src/libunixonacid/textmessage_receiver_free.c src/include/skalibs/stralloc.h src/include/skalibs/textmessage.h src/libunixonacid/textmessage_receiver_hasmsginbuf.o src/libunixonacid/textmessage_receiver_hasmsginbuf.lo: src/libunixonacid/textmessage_receiver_hasmsginbuf.c src/include/skalibs/buffer.h src/include/skalibs/siovec.h src/include/skalibs/textmessage.h src/include/skalibs/uint32.h src/libunixonacid/textmessage_receiver_init.o src/libunixonacid/textmessage_receiver_init.lo: src/libunixonacid/textmessage_receiver_init.c src/include/skalibs/buffer.h src/include/skalibs/stralloc.h src/include/skalibs/textmessage.h src/libunixonacid/textmessage_receiver_zero.o src/libunixonacid/textmessage_receiver_zero.lo: src/libunixonacid/textmessage_receiver_zero.c src/include/skalibs/textmessage.h src/libunixonacid/textmessage_recv_channel.o src/libunixonacid/textmessage_recv_channel.lo: src/libunixonacid/textmessage_recv_channel.c src/include/skalibs/allreadwrite.h src/include/skalibs/ancil.h src/include/skalibs/djbunix.h src/include/skalibs/error.h src/include/skalibs/posixishard.h src/include/skalibs/textmessage.h src/include/skalibs/unix-timed.h src/libunixonacid/textmessage_sender_1.o src/libunixonacid/textmessage_sender_1.lo: src/libunixonacid/textmessage_sender_1.c src/include/skalibs/textmessage.h src/libunixonacid/textmessage_sender_flush.o src/libunixonacid/textmessage_sender_flush.lo: src/libunixonacid/textmessage_sender_flush.c src/include/skalibs/bufalloc.h src/include/skalibs/textmessage.h src/libunixonacid/textmessage_sender_getfd.o src/libunixonacid/textmessage_sender_getfd.lo: src/libunixonacid/textmessage_sender_getfd.c src/include/skalibs/bufalloc.h src/include/skalibs/textmessage.h src/libunixonacid/textmessage_sender_timed_flush.o src/libunixonacid/textmessage_sender_timed_flush.lo: src/libunixonacid/textmessage_sender_timed_flush.c src/include/skalibs/functypes.h src/include/skalibs/textmessage.h src/include/skalibs/unix-timed.h src/libunixonacid/textmessage_sender_x.o src/libunixonacid/textmessage_sender_x.lo: src/libunixonacid/textmessage_sender_x.c src/include/skalibs/textmessage.h src/libunixonacid/textmessage_sender_zero.o src/libunixonacid/textmessage_sender_zero.lo: src/libunixonacid/textmessage_sender_zero.c src/include/skalibs/textmessage.h src/libunixonacid/textmessage_timed_handle.o src/libunixonacid/textmessage_timed_handle.lo: src/libunixonacid/textmessage_timed_handle.c src/include/skalibs/functypes.h src/include/skalibs/textmessage.h src/include/skalibs/unix-timed.h src/libunixonacid/textmessage_timed_receive.o src/libunixonacid/textmessage_timed_receive.lo: src/libunixonacid/textmessage_timed_receive.c src/include/skalibs/functypes.h src/include/skalibs/textmessage.h src/include/skalibs/unix-timed.h src/libunixonacid/timed_flush.o src/libunixonacid/timed_flush.lo: src/libunixonacid/timed_flush.c src/include/skalibs/error.h src/include/skalibs/iopause.h src/include/skalibs/unix-timed.h src/libunixonacid/timed_get.o src/libunixonacid/timed_get.lo: src/libunixonacid/timed_get.c src/include/skalibs/allreadwrite.h src/include/skalibs/iopause.h src/include/skalibs/unix-timed.h src/libunixonacid/timed_getln.o src/libunixonacid/timed_getln.lo: src/libunixonacid/timed_getln.c src/include/skalibs/allreadwrite.h src/include/skalibs/buffer.h src/include/skalibs/functypes.h src/include/skalibs/skamisc.h src/include/skalibs/stralloc.h src/include/skalibs/unix-timed.h src/libunixonacid/timed_getlnmax.o src/libunixonacid/timed_getlnmax.lo: src/libunixonacid/timed_getlnmax.c src/include/skalibs/allreadwrite.h src/include/skalibs/buffer.h src/include/skalibs/functypes.h src/include/skalibs/skamisc.h src/include/skalibs/unix-timed.h src/libunixonacid/unixconnection_free.o src/libunixonacid/unixconnection_free.lo: src/libunixonacid/unixconnection_free.c src/include/skalibs/unixconnection.h src/include/skalibs/unixmessage.h src/libunixonacid/unixconnection_init.o src/libunixonacid/unixconnection_init.lo: src/libunixonacid/unixconnection_init.c src/include/skalibs/unixconnection.h src/include/skalibs/unixmessage.h src/libunixonacid/unixconnection_init_withclosecb.o src/libunixonacid/unixconnection_init_withclosecb.lo: src/libunixonacid/unixconnection_init_withclosecb.c src/include/skalibs/unixconnection.h src/include/skalibs/unixmessage.h src/libunixonacid/unixconnection_zero.o src/libunixonacid/unixconnection_zero.lo: src/libunixonacid/unixconnection_zero.c src/include/skalibs/unixconnection.h src/libunixonacid/unixmessage_bits_closeall.o src/libunixonacid/unixmessage_bits_closeall.lo: src/libunixonacid/unixmessage_bits_closeall.c src/include/skalibs/bitarray.h src/include/skalibs/unixmessage.h src/libunixonacid/unixmessage_bits_closenone.o src/libunixonacid/unixmessage_bits_closenone.lo: src/libunixonacid/unixmessage_bits_closenone.c src/include/skalibs/bitarray.h src/include/skalibs/unixmessage.h src/libunixonacid/unixmessage_drop.o src/libunixonacid/unixmessage_drop.lo: src/libunixonacid/unixmessage_drop.c src/include/skalibs/djbunix.h src/include/skalibs/unixmessage.h src/libunixonacid/unixmessage_handle.o src/libunixonacid/unixmessage_handle.lo: src/libunixonacid/unixmessage_handle.c src/include/skalibs/unixmessage.h src/libunixonacid/unixmessage_put.o src/libunixonacid/unixmessage_put.lo: src/libunixonacid/unixmessage_put.c src/include/skalibs/bitarray.h src/include/skalibs/disize.h src/include/skalibs/genalloc.h src/include/skalibs/posixishard.h src/include/skalibs/siovec.h src/include/skalibs/stralloc.h src/include/skalibs/unixmessage.h src/libunixonacid/unixmessage_receive.o src/libunixonacid/unixmessage_receive.lo: src/libunixonacid/unixmessage_receive.c src/include/skalibs/allreadwrite.h src/include/skalibs/cbuffer.h src/include/skalibs/djbunix.h src/include/skalibs/nonposix.h src/include/skalibs/posixishard.h src/include/skalibs/stralloc.h src/include/skalibs/sysdeps.h src/include/skalibs/uint16.h src/include/skalibs/uint32.h src/include/skalibs/unixmessage.h src/libunixonacid/unixmessage_receiver_0.o src/libunixonacid/unixmessage_receiver_0.lo: src/libunixonacid/unixmessage_receiver_0.c src/include/skalibs/unixmessage.h src/libunixonacid/unixmessage_receiver_free.o src/libunixonacid/unixmessage_receiver_free.lo: src/libunixonacid/unixmessage_receiver_free.c src/include/skalibs/cbuffer.h src/include/skalibs/djbunix.h src/include/skalibs/stralloc.h src/include/skalibs/unixmessage.h src/libunixonacid/unixmessage_receiver_hasmsginbuf.o src/libunixonacid/unixmessage_receiver_hasmsginbuf.lo: src/libunixonacid/unixmessage_receiver_hasmsginbuf.c src/include/skalibs/cbuffer.h src/include/skalibs/siovec.h src/include/skalibs/uint32.h src/include/skalibs/unixmessage.h src/libunixonacid/unixmessage_receiver_init.o src/libunixonacid/unixmessage_receiver_init.lo: src/libunixonacid/unixmessage_receiver_init.c src/include/skalibs/cbuffer.h src/include/skalibs/stralloc.h src/include/skalibs/unixmessage.h src/libunixonacid/unixmessage_sender_1.o src/libunixonacid/unixmessage_sender_1.lo: src/libunixonacid/unixmessage_sender_1.c src/include/skalibs/unixmessage.h src/libunixonacid/unixmessage_sender_closecb.o src/libunixonacid/unixmessage_sender_closecb.lo: src/libunixonacid/unixmessage_sender_closecb.c src/include/skalibs/djbunix.h src/include/skalibs/unixmessage.h src/libunixonacid/unixmessage_sender_flush.o src/libunixonacid/unixmessage_sender_flush.lo: src/libunixonacid/unixmessage_sender_flush.c src/include/skalibs/allreadwrite.h src/include/skalibs/disize.h src/include/skalibs/djbunix.h src/include/skalibs/genalloc.h src/include/skalibs/nonposix.h src/include/skalibs/posixishard.h src/include/skalibs/uint16.h src/include/skalibs/uint32.h src/include/skalibs/unixmessage.h src/libunixonacid/unixmessage_sender_free.o src/libunixonacid/unixmessage_sender_free.lo: src/libunixonacid/unixmessage_sender_free.c src/include/skalibs/disize.h src/include/skalibs/djbunix.h src/include/skalibs/genalloc.h src/include/skalibs/stralloc.h src/include/skalibs/unixmessage.h src/libunixonacid/unixmessage_sender_getfd.o src/libunixonacid/unixmessage_sender_getfd.lo: src/libunixonacid/unixmessage_sender_getfd.c src/include/skalibs/unixmessage.h src/libunixonacid/unixmessage_sender_init.o src/libunixonacid/unixmessage_sender_init.lo: src/libunixonacid/unixmessage_sender_init.c src/include/skalibs/unixmessage.h src/libunixonacid/unixmessage_sender_init_withclosecb.o src/libunixonacid/unixmessage_sender_init_withclosecb.lo: src/libunixonacid/unixmessage_sender_init_withclosecb.c src/include/skalibs/genalloc.h src/include/skalibs/stralloc.h src/include/skalibs/unixmessage.h src/libunixonacid/unixmessage_sender_timed_flush.o src/libunixonacid/unixmessage_sender_timed_flush.lo: src/libunixonacid/unixmessage_sender_timed_flush.c src/include/skalibs/functypes.h src/include/skalibs/unix-timed.h src/include/skalibs/unixmessage.h src/libunixonacid/unixmessage_sender_x.o src/libunixonacid/unixmessage_sender_x.lo: src/libunixonacid/unixmessage_sender_x.c src/include/skalibs/unixmessage.h src/libunixonacid/unixmessage_sender_zero.o src/libunixonacid/unixmessage_sender_zero.lo: src/libunixonacid/unixmessage_sender_zero.c src/include/skalibs/unixmessage.h src/libunixonacid/unixmessage_timed_handle.o src/libunixonacid/unixmessage_timed_handle.lo: src/libunixonacid/unixmessage_timed_handle.c src/include/skalibs/functypes.h src/include/skalibs/unix-timed.h src/include/skalibs/unixmessage.h src/libunixonacid/unixmessage_timed_receive.o src/libunixonacid/unixmessage_timed_receive.lo: src/libunixonacid/unixmessage_timed_receive.c src/include/skalibs/functypes.h src/include/skalibs/unix-timed.h src/include/skalibs/unixmessage.h src/libunixonacid/unixmessage_unput.o src/libunixonacid/unixmessage_unput.lo: src/libunixonacid/unixmessage_unput.c src/include/skalibs/disize.h src/include/skalibs/djbunix.h src/include/skalibs/genalloc.h src/include/skalibs/unixmessage.h src/libunixonacid/unixmessage_zero.o src/libunixonacid/unixmessage_zero.lo: src/libunixonacid/unixmessage_zero.c src/include/skalibs/unixmessage.h src/libunixonacid/unixmessagev_zero.o src/libunixonacid/unixmessagev_zero.lo: src/libunixonacid/unixmessagev_zero.c src/include/skalibs/unixmessage.h skalibs-2.14.1.1/package/info000066400000000000000000000001121455624754300156500ustar00rootroot00000000000000package=skalibs version=2.14.1.1 category=prog package_macro_name=SKALIBS skalibs-2.14.1.1/patch-for-solaris000077500000000000000000000013131455624754300166660ustar00rootroot00000000000000#!/usr/xpg4/bin/sh patchit () { if head -n 1 $1 | grep -qF -- -e ; then echo '#!/usr/xpg4/bin/sh -e' > $1.tmp else echo '#!/usr/xpg4/bin/sh' > $1.tmp fi tail -n +2 $1 >> $1.tmp mv -f $1.tmp $1 chmod 0755 $1 } # Solaris doesn't understand POSIX.1-2008 either. sed -e 's/XOPEN_SOURCE=700/XOPEN_SOURCE=600/' < configure > configure.tmp mv -f configure.tmp configure patchit ./configure patchit ./tools/install.sh patchit ./tools/gen-deps.sh patchit ./tools/gen-types.sh patchit ./tools/gen-types-internal.sh patchit ./tools/gen-bits.sh patchit ./tools/gen-sysdepsh.sh echo 'SHELL := /usr/xpg4/bin/sh' > Makefile.tmp echo >> Makefile.tmp cat Makefile >> Makefile.tmp mv -f Makefile.tmp Makefile skalibs-2.14.1.1/src/000077500000000000000000000000001455624754300141745ustar00rootroot00000000000000skalibs-2.14.1.1/src/headers/000077500000000000000000000000001455624754300156075ustar00rootroot00000000000000skalibs-2.14.1.1/src/headers/bits-bendian000066400000000000000000000005231455624754300200710ustar00rootroot00000000000000 #define UINT@BITS@_LITTLE(u) UINT@BITS@_BSWAP(u) #define UINT@BITS@_BIG(u) (u) #define uint@BITS@_little(u) uint@BITS@_bswap(u) #define uint@BITS@_big(u) (u) #define uint@BITS@_littlep(u) uint@BITS@_bswapp(u) #define uint@BITS@_bigp(u) #define uint@BITS@_littlen(array, n) uint@BITS@_bswapn(array, n) #define uint@BITS@_bign(array, n) skalibs-2.14.1.1/src/headers/bits-footer000066400000000000000000000000101455624754300177560ustar00rootroot00000000000000 #endif skalibs-2.14.1.1/src/headers/bits-header000066400000000000000000000001671455624754300177250ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_UINT@BITS@_H #define SKALIBS_UINT@BITS@_H #include #include skalibs-2.14.1.1/src/headers/bits-lendian000066400000000000000000000005231455624754300201030ustar00rootroot00000000000000 #define UINT@BITS@_LITTLE(u) (u) #define UINT@BITS@_BIG(u) UINT@BITS@_BSWAP(u) #define uint@BITS@_little(u) (u) #define uint@BITS@_big(u) uint@BITS@_bswap(u) #define uint@BITS@_littlep(u) #define uint@BITS@_bigp(u) uint@BITS@_bswapp(u) #define uint@BITS@_littlen(array, n) #define uint@BITS@_bign(array, n) uint@BITS@_bswapn(array, n) skalibs-2.14.1.1/src/headers/bits-template000066400000000000000000000057731455624754300203200ustar00rootroot00000000000000 extern void uint@BITS@_pack (char *, uint@BITS@_t) ; extern void uint@BITS@_pack_big (char *, uint@BITS@_t) ; extern void uint@BITS@_unpack (char const *, uint@BITS@_t *) ; extern void uint@BITS@_unpack_big (char const *, uint@BITS@_t *) ; extern uint@BITS@_t uint@BITS@_bswap (uint@BITS@_t) ; extern void uint@BITS@_bswapp (uint@BITS@_t *) ; extern void uint@BITS@_bswapn (uint@BITS@_t *, size_t) ; #define UINT@BITS@_FMT @DFMT@ #define UINT@BITS@_OFMT @OFMT@ #define UINT@BITS@_XFMT @XFMT@ #define UINT@BITS@_BFMT @BFMT@ #define uint@BITS@_fmt_base uint64_fmt_generic #define uint@BITS@0_fmt_base uint640_fmt_generic #define uint@BITS@_fmt(s, u) uint@BITS@_fmt_base(s, (u), 10) #define uint@BITS@0_fmt(s, u, n) uint@BITS@0_fmt_base(s, u, (n), 10) #define uint@BITS@_ofmt(s, o) uint@BITS@_fmt_base(s, (o), 8) #define uint@BITS@0_ofmt(s, o, n) uint@BITS@0_fmt_base(s, o, (n), 8) #define uint@BITS@_xfmt(s, x) uint@BITS@_fmt_base(s, (x), 16) #define uint@BITS@0_xfmt(s, x, n) uint@BITS@0_fmt_base(s, x, (n), 16) #define uint@BITS@_bfmt(s, b) uint@BITS@_fmt_base(s, (b), 2) #define uint@BITS@0_bfmt(s, b, n) uint@BITS@0_fmt_base(s, b, (n), 2) extern size_t uint@BITS@_fmtlist (char *, uint@BITS@_t const *, size_t) ; extern size_t uint@BITS@_scan_base (char const *, uint@BITS@_t *, uint8_t) ; extern size_t uint@BITS@0_scan_base (char const *, uint@BITS@_t *, uint8_t) ; #define uint@BITS@_scan(s, u) uint@BITS@_scan_base(s, (u), 10) #define uint@BITS@0_scan(s, u) uint@BITS@0_scan_base(s, (u), 10) #define uint@BITS@_oscan(s, u) uint@BITS@_scan_base(s, (u), 8) #define uint@BITS@0_oscan(s, u) uint@BITS@0_scan_base(s, (u), 8) #define uint@BITS@_xscan(s, u) uint@BITS@_scan_base(s, (u), 16) #define uint@BITS@0_xscan(s, u) uint@BITS@0_scan_base(s, (u), 16) #define uint@BITS@_bscan(s, u) uint@BITS@_scan_base(s, (u), 2) #define uint@BITS@0_bscan(s, u) uint@BITS@0_scan_base(s, (u), 2) extern size_t uint@BITS@_scanlist (uint@BITS@_t *, size_t, char const *, size_t *) ; #define int@BITS@_fmt_base int64_fmt_generic #define int@BITS@_fmt(s, u) int@BITS@_fmt_base(s, (u), 10) #define int@BITS@_ofmt(s, o) int@BITS@_fmt_base(s, (o), 8) #define int@BITS@_xfmt(s, x) int@BITS@_fmt_base(s, (x), 16) #define int@BITS@_bfmt(s, b) int@BITS@_fmt_base(s, (b), 2) extern size_t int@BITS@_fmtlist (char *, int@BITS@_t const *, size_t) ; extern size_t int@BITS@_scan_base (char const *, int@BITS@_t *, uint8_t) ; extern size_t int@BITS@0_scan_base (char const *, int@BITS@_t *, uint8_t) ; #define int@BITS@_scan(s, u) int@BITS@_scan_base(s, (u), 10) #define int@BITS@0_scan(s, u) int@BITS@0_scan_base(s, (u), 10) #define int@BITS@_oscan(s, u) int@BITS@_scan_base(s, (u), 8) #define int@BITS@0_oscan(s, u) int@BITS@0_scan_base(s, (u), 8) #define int@BITS@_xscan(s, u) int@BITS@_scan_base(s, (u), 16) #define int@BITS@0_xscan(s, u) int@BITS@0_scan_base(s, (u), 16) #define int@BITS@_bscan(s, u) int@BITS@_scan_base(s, (u), 2) #define int@BITS@0_bscan(s, u) int@BITS@0_scan_base(s, (u), 2) extern size_t int@BITS@_scanlist (int@BITS@_t *, size_t, char const *, size_t *) ; skalibs-2.14.1.1/src/headers/ip46-footer000066400000000000000000000013301455624754300176050ustar00rootroot00000000000000 #define ip46_from_ip(i, s, h) ((h) ? ip46_from_ip6(i, s) : ip46_from_ip4(i, s)) extern ssize_t socket_recv46 (int, char *, size_t, ip46 *, uint16_t *, int) ; extern ssize_t socket_recvnb46 (int, char *, size_t, ip46 *, uint16_t *, int, tain const *, tain *) ; #define socket_recvnb46_g(fd, buf, len, i, port, h, deadline) socket_recvnb46(fd, buf, len, i, port, h, (deadline), &STAMP) #define socket_sendnb46_g(fd, buf, len, i, port, deadline) socket_sendnb46(fd, buf, len, i, port, (deadline), &STAMP) extern int socket_deadlineconnstamp46 (int, ip46 const *, uint16_t, tain const *, tain *) ; #define socket_deadlineconnstamp46_g(fd, ip, port, deadline) socket_deadlineconnstamp46(fd, ip, port, (deadline), &STAMP) #endif skalibs-2.14.1.1/src/headers/ip46-header000066400000000000000000000017441455624754300175500ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_IP46_H #define SKALIBS_IP46_H #include #include #include #include #include #include #define IP46_FMT IP6_FMT #define IP4_ANY "\0\0\0" #define IP6_ANY "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" #define IP4_LOCAL "\177\0\0\1" #define IP6_LOCAL "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1" typedef struct ip46full_s ip46full, *ip46full_ref ; struct ip46full_s { char ip[16] ; unsigned int is6: 1 ; } ; #define IP46FULL_ZERO { .ip = IP6_ANY, .is6 = 0 } #define ip46full_is6(i) ((i)->is6) #define ip46full_fmt(s, i) ((i)->is6 ? ip6_fmt(s, (i)->ip) : ip4_fmt(s, (i)->ip)) extern size_t ip46full_scan (char const *, ip46full *) ; extern size_t ip46full_scanlist (ip46full *, size_t, char const *, size_t *) ; #define ip46full_from_ip4(i, ip4) (memcpy((i)->ip, ip4, 4), memset((i)->ip + 4, 0, 12), (i)->is6 = 0) #define ip46full_from_ip6(i, ip6) (memcpy((i)->ip, ip6, 16), (i)->is6 = 1) skalibs-2.14.1.1/src/headers/ip46-with000066400000000000000000000042031455624754300172640ustar00rootroot00000000000000typedef ip46full ip46, *ip46_ref ; #define IP46_ZERO IP46FULL_ZERO #define SKALIBS_IPV6_ENABLED #define SKALIBS_IP_SIZE 16 #define ip46_is6(i) ip46full_is6(i) #define ip46_fmt(s, i) ip46full_fmt(s, i) #define ip46_scan(s, i) ip46full_scan(s, i) #define ip46_scanlist(out, max, s, num) ip46full_scanlist(out, max, s, num) #define ip46_from_ip4(i, ip4) (ip46full_from_ip4(i, ip4), 1) #define ip46_from_ip6(i, ip6) (ip46full_from_ip6(i, ip6), 1) #define socket_connect46(s, i, port) ((i)->is6 ? socket_connect6(s, (i)->ip, port) : socket_connect4(s, (i)->ip, port)) #define socket_bind46(s, i, port) ((i)->is6 ? socket_bind6(s, (i)->ip, port) : socket_bind4(s, (i)->ip, port)) #define socket_bind46_reuse(s, i, port) ((i)->is6 ? socket_bind6_reuse(s, (i)->ip, port) : socket_bind4_reuse(s, (i)->ip, port)) #define socket_tcp46(h) ((h) ? socket_tcp6() : socket_tcp4()) #define socket_tcp46_b(h) ((h) ? socket_tcp6_b() : socket_tcp4_b()) #define socket_tcp46_nb(h) ((h) ? socket_tcp6_nb() : socket_tcp4_nb()) #define socket_tcp46_coe(h) ((h) ? socket_tcp6_coe() : socket_tcp4_coe()) #define socket_tcp46_nbcoe(h) ((h) ? socket_tcp6_nbcoe() : socket_tcp4_nbcoe()) #define socket_tcp46_internal(h, flags) ((h) ? socket_tcp6_internal(flags) : socket_tcp4_internal(flags)) #define socket_udp46(h) ((h) ? socket_udp6() : socket_udp4()) #define socket_udp46_b(h) ((h) ? socket_udp6_b() : socket_udp4_b()) #define socket_udp46_nb(h) ((h) ? socket_udp6_nb() : socket_udp4_nb()) #define socket_udp46_coe(h) ((h) ? socket_udp6_coe() : socket_udp4_coe()) #define socket_udp46_nbcoe(h) ((h) ? socket_udp6_nbcoe() : socket_udp4_nbcoe()) #define socket_udp46_internal(h, flags) ((h) ? socket_udp6_internal(flags) : socket_udp4_internal(flags)) #define socket_send46(fd, s, len, i, port) ((i)->is6 ? socket_send6(fd, s, len, (i)->ip, port) : socket_send4(fd, s, len, (i)->ip, port)) extern int socket_local46 (int, ip46 *, uint16_t *) ; extern int socket_remote46 (int, ip46 *, uint16_t *) ; #define socket_sendnb46(fd, buf, len, i, port, deadline, stamp) ((i)->is6 ? socket_sendnb6(fd, buf, len, (i)->ip, port, deadline, stamp) : socket_sendnb4(fd, buf, len, (i)->ip, port, deadline, stamp)) skalibs-2.14.1.1/src/headers/ip46-without000066400000000000000000000031111455624754300200110ustar00rootroot00000000000000typedef struct ip46_s ip46, *ip46_ref ; struct ip46_s { char ip[4] ; } ; #define IP46_ZERO { .ip = "\0\0\0" } #undef SKALIBS_IPV6_ENABLED #define SKALIBS_IP_SIZE 4 #define ip46_is6(ip) 0 #define ip46_fmt(s, i) ip4_fmt(s, (i)->ip) #define ip46_scan(s, i) ip4_scan(s, (i)->ip) #define ip46_scanlist(out, max, s, num) ip4_scanlist((out)->ip, max, s, num) #define ip46_from_ip4(i, ip4) (memmove((i)->ip, (ip4), 4), 1) #define ip46_from_ip6(i, ip6) (errno = ENOSYS, 0) #define socket_connect46(s, i, port) socket_connect4(s, (i)->ip, port) #define socket_bind46(s, i, port) socket_bind4(s, (i)->ip, port) #define socket_bind46_reuse(s, i, port) socket_bind4_reuse(s, (i)->ip, port) #define socket_tcp46(h) socket_tcp4() #define socket_tcp46_b(h) socket_tcp4_b() #define socket_tcp46_nb(h) socket_tcp4_nb() #define socket_tcp46_coe(h) socket_tcp4_coe() #define socket_tcp46_nbcoe(h) socket_tcp4_nbcoe() #define socket_tcp46_internal(h, flags) socket_tcp4_internal(flags) #define socket_udp46(h) socket_udp4() #define socket_udp46_b(h) socket_udp4_b() #define socket_udp46_nb(h) socket_udp4_nb() #define socket_udp46_coe(h) socket_udp4_coe() #define socket_udp46_nbcoe(h) socket_udp4_nbcoe() #define socket_udp46_internal(h, flags) socket_udp4_internal(flags) #define socket_send46(fd, s, len, i, port) socket_send4(fd, s, len, (i)->ip, port) #define socket_local46(fd, i, port) socket_local4(fd, (i)->ip, port) #define socket_remote46(fd, i, port) socket_remote4(fd, (i)->ip, port) #define socket_sendnb46(fd, buf, len, i, port, deadline, stamp) socket_sendnb4(fd, buf, len, (i)->ip, port, deadline, stamp) skalibs-2.14.1.1/src/headers/signed-template000066400000000000000000000007621455624754300206210ustar00rootroot00000000000000#define @TYPE@_PACK @BYTES@ #define @type@_pack uint@BITS@_pack #define @type@_pack_big uint@BITS@_pack_big #define @type@_unpack(pack, p) uint@BITS@_unpack(pack, (uint@BITS@_t *)(p)) #define @type@_unpack_big(pack, p) uint@BITS@_unpack_big(pack, (uint@BITS@_t *)(p)) #define @TYPE@_FMT (1+UINT@BITS@_FMT) #define @type@_fmt int@BITS@_fmt #define @type@_fmtlist int@BITS@_fmtlist #define @type@_scan int@BITS@_scan #define @type@0_scan int@BITS@0_scan #define @type@_scanlist int@BITS@_scanlist skalibs-2.14.1.1/src/headers/types-footer000066400000000000000000000000101455624754300201610ustar00rootroot00000000000000 #endif skalibs-2.14.1.1/src/headers/types-header000066400000000000000000000003071455624754300201240ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_TYPES_H #define SKALIBS_TYPES_H #include #include #include #include #include skalibs-2.14.1.1/src/headers/uint16-bswap000066400000000000000000000001071455624754300177700ustar00rootroot00000000000000 #define UINT16_BSWAP(a) (((a) & 0x00ffu) << 8 | ((a) & 0xff00u) >> 8) skalibs-2.14.1.1/src/headers/uint32-bswap000066400000000000000000000002071455624754300177670ustar00rootroot00000000000000 #define UINT32_BSWAP(a) (((a) & 0x000000ffu) << 24 | ((a) & 0x0000ff00u) << 8 | ((a) & 0x00ff0000u) >> 8 | ((a) & 0xff000000u) >> 24) skalibs-2.14.1.1/src/headers/uint64-bswap000066400000000000000000000005071455624754300177770ustar00rootroot00000000000000 #define UINT64_BSWAP(a) (((a) & 0x00000000000000ffull) << 56 | ((a) & 0x000000000000ff00ull) << 40 | ((a) & 0x0000000000ff0000ull) << 24 | ((a) & 0x00000000ff000000ull) << 8 | ((a) & 0x000000ff00000000ull) >> 8 | ((a) & 0x0000ff0000000000ull) >> 24 | ((a) & 0x00ff000000000000ull) >> 40 | ((a) & 0xff00000000000000ull) >> 56) skalibs-2.14.1.1/src/headers/uint64-defs000066400000000000000000000007361455624754300176100ustar00rootroot00000000000000 extern size_t uint64_fmt_generic (char *, uint64_t, uint8_t) ; extern size_t uint640_fmt_generic (char *, uint64_t, size_t, uint8_t) ; extern size_t int64_fmt_generic (char *, int64_t, uint8_t) ; extern size_t uint64_fmtlist_generic (char *, void const *, size_t, uint8_t, uint64_t (*)(void const *, size_t)) ; extern size_t uint64_scan_base_max (char const *, uint64_t *, uint8_t, uint64_t) ; extern size_t int64_scan_base_max (char const *, int64_t *, uint8_t, uint64_t) ; skalibs-2.14.1.1/src/headers/uint64-include000066400000000000000000000000351455624754300203020ustar00rootroot00000000000000 #include skalibs-2.14.1.1/src/headers/uint64-macros000066400000000000000000000006251455624754300201500ustar00rootroot00000000000000 #ifndef INT_LEAST64_MIN # define INT_LEAST64_MIN INT64_MIN #endif #ifndef INT_FAST64_MIN # define INT_FAST64_MIN INT64_MIN #endif #ifndef INT_LEAST64_MAX # define INT_LEAST64_MAX INT64_MAX #endif #ifndef INT_FAST64_MAX # define INT_FAST64_MAX INT64_MAX #endif #ifndef UINT_LEAST64_MAX # define UINT_LEAST64_MAX UINT64_MAX #endif #ifndef UINT_FAST64_MAX # define UINT_FAST64_MAX UINT64_MAX #endif skalibs-2.14.1.1/src/headers/uint64-noulong64000066400000000000000000000004311455624754300205120ustar00rootroot00000000000000 typedef unsigned long long uint64_t ; typedef signed long long int64_t ; #ifndef INT64_MIN # define INT64_MIN (-1-0x7fffffffffffffffll) #endif #ifndef INT64_MAX # define INT64_MAX 0x7fffffffffffffffll #endif #ifndef UINT64_MAX # define UINT64_MAX 0xffffffffffffffffull #endif skalibs-2.14.1.1/src/headers/uint64-ulong64000066400000000000000000000004051455624754300201560ustar00rootroot00000000000000 typedef unsigned long uint64_t ; typedef long int64_t ; #ifndef INT64_MIN # define INT64_MIN (-1-0x7fffffffffffffffl) #endif #ifndef INT64_MAX # define INT64_MAX 0x7fffffffffffffffl #endif #ifndef UINT64_MAX # define UINT64_MAX 0xfffffffffffffffful #endif skalibs-2.14.1.1/src/headers/unsigned-template000066400000000000000000000030631455624754300211610ustar00rootroot00000000000000#define @TYPE@_PACK @BYTES@ #define @type@_pack uint@BITS@_pack #define @type@_pack_big uint@BITS@_pack_big #define @type@_unpack uint@BITS@_unpack #define @type@_unpack_big uint@BITS@_unpack_big #define @type@_little uint@BITS@_little #define @type@_big uint@BITS@_big #define @type@_littlep uint@BITS@_littlep #define @type@_bigp uint@BITS@_bigp #define @type@_littlen uint@BITS@_littlen #define @type@_bign uint@BITS@_bign #define @TYPE@_FMT UINT@BITS@_FMT #define @TYPE@_OFMT UINT@BITS@_OFMT #define @TYPE@_XFMT UINT@BITS@_XFMT #define @TYPE@_BFMT UINT@BITS@_BFMT #define @type@_fmt_base uint@BITS@_fmt_base #define @type@0_fmt_base uint@BITS@0_fmt_base #define @type@_fmt uint@BITS@_fmt #define @type@0_fmt uint@BITS@0_fmt #define @type@_ofmt uint@BITS@_ofmt #define @type@0_ofmt uint@BITS@0_ofmt #define @type@_xfmt uint@BITS@_xfmt #define @type@0_xfmt uint@BITS@0_xfmt #define @type@_bfmt uint@BITS@_bfmt #define @type@0_bfmt uint@BITS@0_bfmt #define @type@_fmtlist uint@BITS@_fmtlist #define @type@_scan_base uint@BITS@_scan_base #define @type@0_scan_base uint@BITS@0_scan_base #define @type@_scanlist uint@BITS@_scanlist #define @type@_scan(s, u) @type@_scan_base(s, (u), 10) #define @type@0_scan(s, u) @type@0_scan_base(s, (u), 10) #define @type@_oscan(s, u) @type@_scan_base(s, (u), 8) #define @type@0_oscan(s, u) @type@0_scan_base(s, (u), 8) #define @type@_xscan(s, u) @type@_scan_base(s, (u), 16) #define @type@0_xscan(s, u) @type@0_scan_base(s, (u), 16) #define @type@_bscan(s, u) @type@_scan_base(s, (u), 2) #define @type@0_bscan(s, u) @type@0_scan_base(s, (u), 2) skalibs-2.14.1.1/src/include/000077500000000000000000000000001455624754300156175ustar00rootroot00000000000000skalibs-2.14.1.1/src/include/skalibs/000077500000000000000000000000001455624754300172475ustar00rootroot00000000000000skalibs-2.14.1.1/src/include/skalibs/alarm.h000066400000000000000000000004161455624754300205150ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_ALARM_H #define SKALIBS_ALARM_H #include extern int alarm_milliseconds (unsigned int) ; extern int alarm_timeout (tain const *) ; extern int alarm_deadline (tain const *) ; extern void alarm_disable (void) ; #endif skalibs-2.14.1.1/src/include/skalibs/alloc.h000066400000000000000000000004441455624754300205140ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_ALLOC_H #define SKALIBS_ALLOC_H #include #include extern void *alloc (size_t) ; #define alloc_free(p) free(p) #define alloc_re(p, old, new) alloc_realloc(p, new) extern int alloc_realloc (char **, size_t) ; #endif skalibs-2.14.1.1/src/include/skalibs/allreadwrite.h000066400000000000000000000017271455624754300221060ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_ALLREADWRITE_H #define SKALIBS_ALLREADWRITE_H #include #include extern ssize_t sanitize_read (ssize_t) ; extern ssize_t unsanitize_read (ssize_t) ; extern size_t allreadwrite (io_func_ref, int, char *, size_t) ; extern size_t allreadwritev (iov_func_ref, int, struct iovec const *, unsigned int) ; extern ssize_t fd_read (int, char *, size_t) ; extern ssize_t fd_write (int, char const *, size_t) ; extern ssize_t fd_readv (int, struct iovec const *, unsigned int) ; extern ssize_t fd_writev (int, struct iovec const *, unsigned int) ; extern ssize_t fd_recv (int, char *, size_t, unsigned int) ; extern ssize_t fd_send (int, char const *, size_t, unsigned int) ; extern size_t allread (int, char *, size_t) ; extern size_t allwrite (int, char const *, size_t) ; extern size_t allreadv (int, struct iovec const *, unsigned int) ; extern size_t allwritev (int, struct iovec const *, unsigned int) ; #endif skalibs-2.14.1.1/src/include/skalibs/ancil.h000066400000000000000000000002401455624754300205020ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_ANCIL_H #define SKALIBS_ANCIL_H extern int ancil_recv_fd (int, char) ; extern int ancil_send_fd (int, int, char) ; #endif skalibs-2.14.1.1/src/include/skalibs/avlnode.h000066400000000000000000000037151455624754300210560ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_AVLNODE_H #define SKALIBS_AVLNODE_H #include #include #include #define AVLNODE_MAXDEPTH 49 /* enough for 2^32 nodes in the worst case */ typedef int avliter_func (uint32_t, unsigned int, void *) ; typedef avliter_func *avliter_func_ref ; typedef struct avlnode_s avlnode, *avlnode_ref ; struct avlnode_s { uint32_t data ; uint32_t child[2] ; signed char balance : 2 ; } ; #define AVLNODE_ZERO { .data = 0, .child = { UINT32_MAX, UINT32_MAX }, .balance = 0 } extern avlnode const avlnode_zero ; extern uint32_t avlnode_searchnode (avlnode const *, uint32_t, uint32_t, void const *, dtok_func_ref, cmp_func_ref, void *) ; extern int avlnode_search (avlnode const *, uint32_t, uint32_t, void const *, uint32_t *, dtok_func_ref, cmp_func_ref, void *) ; extern unsigned int avlnode_height (avlnode const *, uint32_t, uint32_t) gccattr_pure ; extern uint32_t avlnode_extremenode (avlnode const *, uint32_t, uint32_t, int) gccattr_pure ; #define avlnode_minnode(s, max, r) avlnode_extremenode(s, max, (r), 0) #define avlnode_maxnode(s, max, r) avlnode_extremenode(s, max, (r), 1) extern int avlnode_extreme (avlnode const *, uint32_t, uint32_t, int, uint32_t *) ; #define avlnode_min(s, max, r, data) avlnode_extreme(s, max, (r), 0, data) #define avlnode_max(s, max, r, data) avlnode_extreme(s, max, (r), 1, data) extern uint32_t avlnode_insertnode (avlnode *, uint32_t, uint32_t, uint32_t, dtok_func_ref, cmp_func_ref, void *) ; extern uint32_t avlnode_delete (avlnode *, uint32_t, uint32_t *, void const *, dtok_func_ref, cmp_func_ref, void *) ; extern uint32_t avlnode_iter_nocancel (avlnode *, uint32_t, uint32_t, uint32_t, avliter_func_ref, void *) ; #define avlnode_iter(tree, max, root, f, stuff) (avlnode_iter_nocancel(tree, max, max, root, f, stuff) == (max)) extern int avlnode_iter_withcancel (avlnode *, uint32_t, uint32_t, avliter_func_ref, avliter_func_ref, void *) ; #endif skalibs-2.14.1.1/src/include/skalibs/avltree.h000066400000000000000000000052241455624754300210650ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_AVLTREE_H #define SKALIBS_AVLTREE_H #include #include #include #include typedef struct avltree_s avltree, *avltree_ref ; struct avltree_s { gensetdyn x ; uint32_t root ; dtok_func_ref dtok ; cmp_func_ref kcmp ; void *external ; } ; #define AVLTREE_ZERO { .x = GENSETDYN_ZERO, .root = UINT32_MAX, .dtok = 0, .kcmp = 0, .external = 0 } extern avltree const avltree_zero ; #define avltree_len(t) gensetdyn_n(&(t)->x) #define avltree_totalsize(t) ((uint32_t)(t)->x.storage.len) #define avltree_nodes(t) ((avlnode *)(t)->x.storage.s) #define avltree_data(t, i) ((uint32_t)avltree_nodes(t)[i].data) #define avltree_root(t) ((t)->root) #define avltree_setroot(t, r) ((t)->root = (r)) extern void avltree_free (avltree *) ; extern void avltree_init (avltree *, uint32_t, uint32_t, uint32_t, dtok_func_ref, cmp_func_ref, void *) ; #define AVLTREE_INIT(b, num, den, dtk, f, p) { .x = GENSETDYN_INIT(avlnode, (b), num, den), .root = UINT32_MAX, .dtok = (dtk), .kcmp = (f), .external = (p) } #define avltree_searchnode(t, k) avlnode_searchnode(avltree_nodes(t), avltree_totalsize(t), avltree_root(t), k, (t)->dtok, (t)->kcmp, (t)->external) #define avltree_search(t, k, data) avlnode_search(avltree_nodes(t), avltree_totalsize(t), avltree_root(t), k, (data), (t)->dtok, (t)->kcmp, (t)->external) #define avltree_height(t) avlnode_height(avltree_nodes(t), avltree_totalsize(t), avltree_root(t)) #define avltree_extremenode(t, h) avlnode_extremenode(avltree_nodes(t), avltree_totalsize(t), avltree_root(t), h) #define avltree_minnode(t) avltree_extremenode((t), 0) #define avltree_maxnode(t) avltree_extremenode((t), 1) #define avltree_extreme(t, h, data) avlnode_extreme(avltree_nodes(t), avltree_totalsize(t), avltree_root(t), (h), data) #define avltree_min(t, data) avltree_extreme((t), 0, data) #define avltree_max(t, data) avltree_extreme((t), 1, data) extern int avltree_newnode (avltree *, uint32_t, uint32_t *) ; #define avltree_insertnode(t, i) avltree_setroot(t, avlnode_insertnode(avltree_nodes(t), avltree_totalsize(t), avltree_root(t), i, (t)->dtok, (t)->kcmp, (t)->external)) extern int avltree_insert (avltree *, uint32_t) ; extern int avltree_delete (avltree *, void const *) ; #define avltree_iter_nocancel(t, cut, f, p) avlnode_iter_nocancel(avltree_nodes(t), avltree_totalsize(t), cut, avltree_root(t), f, p) #define avltree_iter(t, f, p) avlnode_iter(avltree_nodes(t), avltree_totalsize(t), avltree_root(t), f, p) #define avltree_iter_withcancel(t, f, cancelf, p) avlnode_iter_withcancel(avltree_nodes(t), avltree_totalsize(t), avltree_root(t), f, cancelf, p) #endif skalibs-2.14.1.1/src/include/skalibs/avltreen.h000066400000000000000000000056551455624754300212530ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_AVLTREEN_H #define SKALIBS_AVLTREEN_H #include #include #include #include /* avltreen is the structure managing the AVL tree. It needs pre-declared arrays: "storage", an array of avlnode, and "freelist", an array of uint32_t, given as arguments to avltreen_init(). Pointers to those arrays are then stored in the genset. */ typedef struct avltreen_s avltreen, *avltreen_ref ; struct avltreen_s { genset x ; uint32_t root ; dtok_func_ref dtok ; cmp_func_ref kcmp ; void *external ; } ; #define AVLTREEN_ZERO { .x = GENSET_ZERO, .root = UINT32_MAX, .dtok = 0, .kcmp = 0, .external = 0 } #define avltreen_totalsize(t) ((t)->x.max) #define avltreen_len(t) genset_n(&(t)->x) #define avltreen_nodes(t) ((avlnode *)(t)->x.storage) #define avltreen_data(t, i) (avltreen_nodes(t)[i].data) #define avltreen_root(t) ((t)->root) #define avltreen_setroot(t, r) ((t)->root = (r)) extern void avltreen_init (avltreen *, avlnode *, uint32_t *, uint32_t, dtok_func_ref, cmp_func_ref, void *) ; #define AVLTREEN_DECLARE_AND_INIT(name, size, dtk, cmp, p) \ avlnode name##_storage[size] ; \ uint32_t name##_freelist[size] ; \ avltreen name ; \ avltreen_init(&name, name##_storage, name##_freelist, size, dtk, cmp, p) #define avltreen_searchnode(t, k) avlnode_searchnode(avltreen_nodes(t), avltreen_totalsize(t), avltreen_root(t), (k), (t)->dtok, (t)->kcmp, (t)->external) #define avltreen_search(t, k, data) avlnode_search(avltreen_nodes(t), avltreen_totalsize(t), avltreen_root(t), k, (data), (t)->dtok, (t)->kcmp, (t)->external) #define avltreen_height(t) avlnode_height(avltreen_nodes(t), avltreen_totalsize(t), avltreen_root(t)) #define avltreen_extremenode(t, h) avlnode_extremenode(avltreen_nodes(t), avltreen_totalsize(t), avltreen_root(t), h) #define avltreen_minnode(t) avltreen_extremenode((t), 0) #define avltreen_maxnode(t) avltreen_extremenode((t), 1) #define avltreen_extreme(t, h, data) avlnode_extreme(avltreen_nodes(t), avltreen_totalsize(t), avltreen_root(t), (h), data) #define avltreen_min(t, data) avltreen_extreme((t), 0, data) #define avltreen_max(t, data) avltreen_extreme((t), 1, data) extern uint32_t avltreen_newnode (avltreen *, uint32_t) ; #define avltreen_insertnode(t, i) avltreen_setroot(t, avlnode_insertnode(avltreen_nodes(t), avltreen_totalsize(t), avltreen_root(t), i, (t)->dtok, (t)->kcmp, (t)->external)) extern int avltreen_insert (avltreen *, uint32_t) ; extern int avltreen_delete (avltreen *, void const *) ; #define avltreen_iter(t, f, p) avlnode_iter(avltreen_nodes(t), avltreen_totalsize(t), avltreen_root(t), f, p) #define avltreen_iter_nocancel(t, cut, f, p) avlnode_iter_nocancel(avltreen_nodes(t), avltreen_totalsize(t), cut, avltreen_root(t), f, p) #define avltreen_iter_withcancel(t, f, cancelf, p) avlnode_iter_withcancel(avltreen_nodes(t), avltreen_totalsize(t), avltreen_root(t), f, cancelf, p) #endif skalibs-2.14.1.1/src/include/skalibs/bigkv.h000066400000000000000000000021071455624754300205220ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_BIGKV_H #define SKALIBS_BIGKV_H #include #include #include #include #include typedef struct bigkv_node_s bigkv_node, *bigkv_node_ref ; struct bigkv_node_s { size_t k ; size_t v ; } ; #define BIGKV_NODE_ZERO { .k = 0, .v = 0 } typedef struct bigkv_s bigkv, *bigkv_ref ; struct bigkv_s { stralloc storage ; genalloc nodes ; /* bigkv_node */ avltree map ; } ; #define BIGKV_ZERO { .storage = STRALLOC_ZERO, .nodes = GENALLOC_ZERO, .map = AVLTREE_ZERO } extern bigkv const bigkv_zero ; #define BIGKV_OPTIONS_NODUP 0x00000001u #define bigkv_len(b) avltree_len(&(b)->map) #define bigkv_init(b) (*(b) = bigkv_zero) extern int bigkv_fill (bigkv *, char const *const *, char, char const *, char const *, uint32_t) ; #define bigkv_fill_argv(b, argv) bigkv_fill(b, (argv), '=', "--", "--", 0) #define bigkv_fill_envp(b, envp) bigkv_fill(b, (envp), '=', 0, 0, 0) extern char const *bigkv_search (bigkv const *, char const *) ; extern void bigkv_free (bigkv *) ; #endif skalibs-2.14.1.1/src/include/skalibs/bitarray.h000066400000000000000000000036321455624754300212410ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_BITARRAY_H #define SKALIBS_BITARRAY_H #include #include #define bitarray_div8(n) ((n) ? 1U + (((n) - 1) >> 3) : 0U) extern void bitarray_clearsetn (unsigned char *, size_t, size_t, int) ; #define bitarray_clearn(s, start, len) bitarray_clearsetn(s, start, (len), 0) #define bitarray_setn(s, start, len) bitarray_clearsetn(s, start, (len), 1) #define bitarray_peek(s, n) (((s)[(n)>>3] & (1U<<((n)&7))) ? 1 : 0) #define bitarray_isset(b, n) bitarray_peek(b, n) #define bitarray_clear(s, n) ((s)[(n)>>3] &= ~(1U << ((n) & 7))) #define bitarray_set(s, n) ((s)[(n)>>3] |= 1U << ((n) & 7)) #define bitarray_poke(s, n, h) ((h) ? bitarray_set(s, n) : bitarray_clear(s, n)) extern int bitarray_testandpoke (unsigned char *, size_t, int) ; #define bitarray_testandclear(b, n) bitarray_testandpoke(b, n, 0) #define bitarray_testandset(b, n) bitarray_testandpoke(b, n, 1) extern size_t bitarray_firstclear (unsigned char const *, size_t) gccattr_pure ; extern size_t bitarray_firstset (unsigned char const *, size_t) gccattr_pure ; #define bitarray_first(s, n, h) ((h) ? bitarray_firstset(s, n) : bitarray_firstclear(s, n)) extern size_t bitarray_firstclear_skip (unsigned char const *, size_t, size_t) gccattr_pure ; extern size_t bitarray_firstset_skip (unsigned char const *, size_t, size_t) gccattr_pure ; #define bitarray_first_skip(s, n, k, h) ((h) ? bitarray_firstset_skip(s, n, k) : bitarray_firstclear_skip(s, n, k)) extern size_t bitarray_countones (unsigned char const *, size_t) gccattr_pure ; extern void bitarray_not (unsigned char *, size_t, size_t) ; extern void bitarray_and (unsigned char *, unsigned char const *, unsigned char const *, size_t) ; extern void bitarray_or (unsigned char *, unsigned char const *, unsigned char const *, size_t) ; extern void bitarray_xor (unsigned char *, unsigned char const *, unsigned char const *, size_t) ; #endif skalibs-2.14.1.1/src/include/skalibs/blake2s.h000066400000000000000000000014341455624754300207450ustar00rootroot00000000000000 /* ISC license. */ #ifndef SKALIBS_BLAKE2S_H #define SKALIBS_BLAKE2S_H #include #include typedef struct blake2s_ctx_s blake2s_ctx, *blake2s_ctx_ref ; struct blake2s_ctx_s { size_t buflen ; size_t outlen ; uint32_t h[8] ; uint32_t t[2] ; uint32_t f[2] ; char buf[64] ; } ; #define BLAKE2S_INIT(len) { \ .buflen = 0, \ .outlen = len, \ .h = { 0x6A09E667UL ^ (0x01010000 | len), 0xBB67AE85UL, 0x3C6EF372UL, 0xA54FF53AUL, 0x510E527FUL, 0x9B05688CUL, 0x1F83D9ABUL, 0x5BE0CD19UL }, \ .t = { 0, 0 }, \ .f = { 0, 0 }, \ .buf = { 0 } } extern void blake2s_init (blake2s_ctx *, size_t) ; /* outlen <= 32 */ extern void blake2s_update (blake2s_ctx *, char const *, size_t) ; extern void blake2s_final (blake2s_ctx *, char *) ; /* outlen chars */ #endif skalibs-2.14.1.1/src/include/skalibs/bsdsnowflake.h000066400000000000000000000023741455624754300221100ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_BSDSNOWFLAKE_H #define SKALIBS_BSDSNOWFLAKE_H /* Like skalibs/nonposix.h, this header is supposed to be included *before* system headers. Unlike skalibs/nonposix.h, though, it does not define ftms that enable non-portable behaviour; it just attempts to work around blatant brokenness, things that actually ARE defined by POSIX but where OSes just ignore the spec. The BSDs are experts at this, hence the name. */ #if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__bsdi__) || defined(__DragonFly__) /* BSDs: the eponym. Sometimes you just need to recognize who they are and what they do. */ #ifndef SKALIBS_BSD_SUCKS #define SKALIBS_BSD_SUCKS #endif /* Other times you just need to say you're a BSD so they deign to define symbols like EOVERFLOW. Give me my POSIX symbols, pretty please? */ #ifndef _BSD_SOURCE #define _BSD_SOURCE #endif #endif #if defined(__APPLE__) && defined(__MACH__) /* MacOS: needs this for full SUSv3 conformance. That's how you can tell it's really a BSD inside. With additional layers of crap. */ #ifndef _DARWIN_C_SOURCE #define _DARWIN_C_SOURCE #endif #endif /* __APPLE__ && __MACH__ */ #endif /* SKALIBS_BSDSNOWFLAKE_H */ skalibs-2.14.1.1/src/include/skalibs/bufalloc.h000066400000000000000000000024451455624754300212140ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_BUFALLOC_H #define SKALIBS_BUFALLOC_H #include #include #include #include typedef struct bufalloc_s bufalloc, *bufalloc_ref ; struct bufalloc_s { stralloc x ; size_t p ; int fd ; iow_func_ref op ; } ; #define BUFALLOC_ZERO { STRALLOC_ZERO, 0, -1, 0 } #define BUFALLOC_INIT(f, d) { STRALLOC_ZERO, 0, (d), (f) } extern void bufalloc_init (bufalloc *, iow_func_ref, int) ; #define bufalloc_shrink(ba) stralloc_shrink(&(ba)->x) #define bufalloc_free(ba) stralloc_free(&(ba)->x) #define bufalloc_put(ba, s, n) stralloc_catb(&(ba)->x, s, n) #define bufalloc_puts(ba, s) stralloc_cats(&(ba)->x, s) #define bufalloc_putv(ba, v, n) stralloc_catv(&(ba)->x, v, n) #define bufalloc_unput(ba, n) ((ba)->x.len -= (n)) #define bufalloc_fd(ba) ((ba)->fd) extern int bufalloc_getfd (bufalloc const *) gccattr_pure ; extern int bufalloc_flush (bufalloc *) ; extern void bufalloc_clean (bufalloc *) ; #define bufalloc_len(ba) ((ba)->x.len - (ba)->p) extern size_t bufalloc_getlen (bufalloc const *) gccattr_pure ; #define bufalloc_isempty(ba) ((ba)->x.len == (ba)->p) extern bufalloc bufalloc_1_ ; #define bufalloc_1 (&bufalloc_1_) extern bufalloc bufalloc_2_ ; #define bufalloc_2 (&bufalloc_2_) #endif skalibs-2.14.1.1/src/include/skalibs/buffer.h000066400000000000000000000077051455624754300207020ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_BUFFER_H #define SKALIBS_BUFFER_H #include #include #include #include #include typedef struct buffer_s buffer, *buffer_ref ; struct buffer_s { iov_func_ref op ; int fd ; cbuffer c ; } ; #define BUFFER_ZERO { 0, -1, CBUFFER_ZERO } /* Circular buffers need to be 1 char bigger than the storage space, so that the head == tail case is nonambiguous (empty, not full). */ #define BUFFER_INSIZE 8192 #define BUFFER_OUTSIZE 8192 #define BUFFER_ERRSIZE 1024 #define BUFFER_INSIZE_SMALL 512 #define BUFFER_OUTSIZE_SMALL 512 #define BUFFER_INIT(f, d, buf, len) { (f), (d), CBUFFER_INIT(buf, len) } extern int buffer_init (buffer *, iov_func_ref, int, char *, size_t) ; /* Writing */ extern int buffer_flush (buffer *) ; #define buffer_putnoflush(b, s, len) cbuffer_put(&(b)->c, s, len) #define buffer_putvnoflush(b, v, n) cbuffer_putv(&(b)->c, v, n) extern size_t buffer_putsnoflush (buffer *, char const *) ; extern int buffer_putallnoflush (buffer *, char const *, size_t) ; extern int buffer_putvallnoflush (buffer *, struct iovec const *, unsigned int) ; extern int buffer_putsallnoflush (buffer *, char const *) ; extern int buffer_putall (buffer *, char const *, size_t, size_t *) ; extern int buffer_putvall (buffer *, struct iovec const *, unsigned int, size_t *) ; extern int buffer_putsall (buffer *, char const *, size_t *) ; #define buffer_putallflush(b, s, len, w) (buffer_putall(b, s, len, w) && buffer_flush(b)) #define buffer_putvallflush(b, v, n, w) (buffer_putvall(b, v, n, w) && buffer_flush(b)) extern int buffer_putsallflush (buffer *, char const *, size_t *) ; extern ssize_t buffer_put (buffer *, char const *, size_t) ; extern ssize_t buffer_putv (buffer *, struct iovec const *, unsigned int) ; extern ssize_t buffer_puts (buffer *, char const *) ; extern ssize_t buffer_putflush (buffer *, char const *, size_t) ; extern ssize_t buffer_putvflush (buffer *, struct iovec const *, unsigned int) ; extern ssize_t buffer_putsflush (buffer *, char const *) ; #define buffer_unput(b, n) cbuffer_unput(&(b)->c, n) #define buffer_wpeek(b, v) cbuffer_wpeek(&(b)->c, v) #define buffer_wseek(b, n) cbuffer_wseek(&(b)->c, n) /* Reading */ extern ssize_t buffer_fill (buffer *) ; #define buffer_getnofill(b, s, len) cbuffer_get(&(b)->c, s, len) #define buffer_getvnofill(b, v, n) cbuffer_getv(&(b)->c, v, n) extern int buffer_getallnofill (buffer *, char *, size_t) ; extern int buffer_getvallnofill (buffer *, struct iovec const *, unsigned int) ; extern int buffer_getall (buffer *, char *, size_t, size_t *) ; extern int buffer_getvall (buffer *, struct iovec const *, unsigned int, size_t *) ; extern ssize_t buffer_get (buffer *, char *, size_t) ; extern ssize_t buffer_getv (buffer *, struct iovec const *, unsigned int) ; #define buffer_unget(b, n) cbuffer_unget(&(b)->c, n) #define buffer_rpeek(b, v) cbuffer_rpeek(&(b)->c, v) #define buffer_rseek(b, n) cbuffer_rseek(&(b)->c, n) /* Utility */ #define buffer_len(b) cbuffer_len(&(b)->c) extern size_t buffer_getlen (buffer const *) gccattr_pure ; #define buffer_available(b) cbuffer_available(&(b)->c) #define buffer_isempty(b) cbuffer_isempty(&(b)->c) #define buffer_isfull(b) cbuffer_isfull(&(b)->c) #define buffer_fd(b) ((b)->fd) extern int buffer_getfd (buffer const *) gccattr_pure ; #define buffer_isreadable(b) (!buffer_isfull(b)) #define buffer_iswritable(b) (!buffer_isempty(b)) /* Globals */ #define buffer_read fd_readv #define buffer_write fd_writev extern iov_func buffer_flush1read ; extern buffer buffer_0_ ; #define buffer_0 (&buffer_0_) extern buffer buffer_0small_ ; #define buffer_0small (&buffer_0small_) extern buffer buffer_0f1_ ; #define buffer_0f1 (&buffer_0f1_) extern buffer buffer_1_ ; #define buffer_1 (&buffer_1_) extern buffer buffer_1small_ ; #define buffer_1small (&buffer_1small_) extern buffer buffer_2_ ; #define buffer_2 (&buffer_2_) #endif skalibs-2.14.1.1/src/include/skalibs/bytestr.h000066400000000000000000000035361455624754300211230ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_BYTESTR_H #define SKALIBS_BYTESTR_H /* for Alphas and other archs where char != 8bit */ #define T8(x) ((x) & 0xffU) #include #include #include #define byte_copy(to, n, from) memmove(to, (from), n) #define byte_copyr(to, n, from) memmove(to, (from), n) #define byte_diff(a, n, b) memcmp(a, (b), n) #define byte_zero(p, n) memset(p, 0, n) #define str_len strlen #define str_nlen strnlen #define str_diff strcmp #define str_diffn strncmp #define str_copy(to, from) strlen(strcpy(to, from)) #define case_diffs strcasecmp #define case_diffn strncasecmp extern size_t byte_chr (char const *, size_t, int) gccattr_pure ; extern size_t byte_rchr (char const *, size_t, int) gccattr_pure ; extern size_t byte_in (char const *, size_t, char const *, size_t) gccattr_pure ; #define byte_equal(s, n, t) (!memcmp(s, (t), n)) extern size_t byte_count (char const *, size_t, char) gccattr_pure ; extern size_t byte_search (char const *, size_t, char const *, size_t) ; extern void byte_zzero (char *, size_t) ; #define str_diffb(a, n, b) strncmp(a, (b), n) extern size_t str_chr (char const *, int) gccattr_pure ; extern size_t str_rchr (char const *, int) gccattr_pure ; extern int str_start (char const *, char const *) gccattr_pure ; #define str_equal(s, t) (!strcmp(s, t)) extern size_t str_strn (char const *, size_t, char const *, size_t) gccattr_pure ; extern void case_lowers (char *) ; extern void case_lowerb (char *, size_t) ; extern void case_uppers (char *) ; extern void case_upperb (char *, size_t) ; #define case_diffb(a, n, b) case_diffn(a, (b), n) #define case_equals(a, b) (!strcasecmp(a, b)) #define case_equalb(a, n, b) (!strncasecmp(a, (b), n)) #define case_starts(s, t) case_startb(s, strlen(s), t) extern int case_startb (char const *, size_t, char const *) gccattr_pure ; #endif skalibs-2.14.1.1/src/include/skalibs/cbuffer.h000066400000000000000000000034651455624754300210440ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_CBUFFER_H #define SKALIBS_CBUFFER_H #include #include #include typedef struct cbuffer_s cbuffer, *cbuffer_ref ; struct cbuffer_s { char *x ; size_t a ; /* total length */ size_t p ; /* head */ size_t n ; /* tail */ } ; #define CBUFFER_ZERO { 0, 0, 0, 0 } /* Circular buffers need to be 1 char bigger than the storage space, so that the head == tail case is nonambiguous (empty). */ #define CBUFFER_INIT(buf, len) { (buf), (len), 0, 0 } extern int cbuffer_init (cbuffer *, char *, size_t) ; /* Writing */ extern size_t cbuffer_put (cbuffer *, char const *, size_t) ; extern size_t cbuffer_putv (cbuffer *, struct iovec const *, unsigned int) ; #define cbuffer_puts(b, s) cbuffer_put(b, (s), strlen(s)) #define cbuffer_UNPUT(b, w) ((b)->n = ((b)->a + (b)->n - w) % (b)->a, w) ; extern size_t cbuffer_unput (cbuffer *, size_t) ; extern void cbuffer_wpeek (cbuffer const *, struct iovec *) ; #define cbuffer_WSEEK(b, w) ((b)->n = ((b)->n + (w)) % (b)->a, w) extern size_t cbuffer_wseek (cbuffer *, size_t) ; /* Reading */ extern size_t cbuffer_get (cbuffer *, char *, size_t) ; extern size_t cbuffer_getv (cbuffer *, struct iovec const *, unsigned int) ; #define cbuffer_UNGET(b, n) ((b)->p = ((b)->a + (b)->p - n) % (b)->a, n) ; extern size_t cbuffer_unget (cbuffer *, size_t) ; extern void cbuffer_rpeek (cbuffer const *, struct iovec *) ; #define cbuffer_RSEEK(b, n) ((b)->p = ((b)->p + (n)) % (b)->a, n) extern size_t cbuffer_rseek (cbuffer *, size_t) ; /* Utility */ #define cbuffer_len(b) ((size_t)(((b)->a - (b)->p + (b)->n) % (b)->a)) #define cbuffer_available(b) ((size_t)(((b)->a - (b)->n + (b)->p - 1) % (b)->a)) #define cbuffer_isempty(b) (!cbuffer_len(b)) #define cbuffer_isfull(b) (!cbuffer_available(b)) #endif skalibs-2.14.1.1/src/include/skalibs/cdb.h000066400000000000000000000023141455624754300201500ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_CDB_H #define SKALIBS_CDB_H #include #include typedef struct cdb_s cdb, *cdb_ref ; struct cdb_s { char const *map ; uint32_t size ; } ; #define CDB_ZERO { .map = 0, .size = 0 } extern cdb const cdb_zero ; typedef struct cdb_find_state_s cdb_find_state, *cdb_find_state_ref ; struct cdb_find_state_s { uint32_t loop ; uint32_t khash ; uint32_t kpos ; uint32_t hpos ; uint32_t hslots ; } ; #define CDB_FIND_STATE_ZERO { .loop = 0, .khash = 0, .kpos = 0, .hpos = 0, .hslots = 0 } typedef struct cdb_data_s cdb_data, *cdb_data_ref ; struct cdb_data_s { char const *s ; uint32_t len ; } ; extern void cdb_free (cdb *) ; extern int cdb_init (cdb *, char const *) ; extern int cdb_init_at (cdb *, int, char const *) ; extern int cdb_init_fromfd (cdb *, int) ; #define cdb_findstart(d) ((d)->loop = 0) extern int cdb_findnext (cdb const *, cdb_data *, char const *, uint32_t, cdb_find_state *) ; extern int cdb_find (cdb const *, cdb_data *, char const *, uint32_t) ; #define CDB_TRAVERSE_INIT() 2048 #define cdb_traverse_init(pos) (*(pos) = 2048) extern int cdb_traverse_next (cdb const *, cdb_data *, cdb_data *, uint32_t *) ; #endif skalibs-2.14.1.1/src/include/skalibs/cdbmake.h000066400000000000000000000013441455624754300210100ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_CDBMAKE_H #define SKALIBS_CDBMAKE_H #include #include #include #include typedef struct cdbmaker_s cdbmaker, *cdbmaker_ref ; struct cdbmaker_s { genalloc hplist ; /* array of diuint32 */ uint32_t pos ; buffer b ; char buf[BUFFER_OUTSIZE] ; } ; #define CDBMAKER_ZERO { .hplist = GENALLOC_ZERO, .pos = 2048, .b = BUFFER_ZERO, .buf = { 0 } } extern int cdbmake_start (cdbmaker *, int) ; extern int cdbmake_add (cdbmaker *, char const *, uint32_t, char const *, uint32_t) ; extern int cdbmake_addv (cdbmaker *, struct iovec const *, unsigned int, struct iovec const *, unsigned int) ; extern int cdbmake_finish (cdbmaker *) ; #endif skalibs-2.14.1.1/src/include/skalibs/cspawn.h000066400000000000000000000050101455624754300207070ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_CSPAWN_H #define SKALIBS_CSPAWN_H #include #include #define CSPAWN_FLAGS_SELFPIPE_FINISH 0x0001U #define CSPAWN_FLAGS_SIGBLOCKNONE 0x0002U #define CSPAWN_FLAGS_SETSID 0x0004U enum cspawn_fileaction_type_e { CSPAWN_FA_CLOSE, CSPAWN_FA_COPY, CSPAWN_FA_MOVE, CSPAWN_FA_OPEN, CSPAWN_FA_CHDIR, CSPAWN_FA_FCHDIR } ; struct cspawn_fa_openinfo_s { int fd ; char const *file ; int oflag ; mode_t mode ; } ; union cspawn_fileaction_u { int fd ; int fd2[2] ; char const *path ; struct cspawn_fa_openinfo_s openinfo ; } ; typedef struct cspawn_fileaction_s cspawn_fileaction, *cspawn_fileaction_ref ; struct cspawn_fileaction_s { enum cspawn_fileaction_type_e type ; union cspawn_fileaction_u x ; } ; /* Generic interface for posix_spawn() with a fork()+execve() fallback */ extern pid_t cspawn (char const *, char const *const *, char const *const *, uint16_t, cspawn_fileaction const *, size_t) ; /* Simple spawn functions with 0 or 1 communicating fds. */ extern pid_t child_spawn0 (char const *, char const *const *, char const *const *) ; extern pid_t child_spawn1_pipe (char const *, char const *const *, char const *const *, int *, int) ; extern pid_t child_spawn1_socket (char const *, char const *const *, char const *const *, int *) ; /* Spawn function with 2 communicating pipes. The int * points to 2 fds. Input: fds[0] and fds[1] are the fds to move the pipes to in the child. Output: fds[0] and fds[1] contain the pipes to the child. */ extern pid_t child_spawn2 (char const *, char const *const *, char const *const *, int *) ; /* Same, with an additional pipe from the child to the parent. The int * points to 3 fds. The additional fd# is available to the child in the defined env variable. */ #define SKALIBS_CHILD_SPAWN_FDS_ENVVAR "SKALIBS_CHILD_SPAWN_FDS" extern pid_t child_spawn3 (char const *, char const *const *, char const *const *, int *) ; /* Generalization of the previous functions. * requests n (the last arg) communication fds between parent and child. Uses pipes. * if n=1, equivalent to child_spawn1_pipe; child writes, parent reads. * if n>=2, parent reads on even and writes on odd. */ extern pid_t child_spawn (char const *, char const *const *, char const *const *, int *, size_t) ; /* cspawn, but running as a grandchild. Uses one fork(). */ extern pid_t gcspawn (char const *, char const *const *, char const *const *, uint16_t, cspawn_fileaction const *, size_t) ; #endif skalibs-2.14.1.1/src/include/skalibs/datastruct.h000066400000000000000000000004421455624754300215760ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_DATASTRUCT_H #define SKALIBS_DATASTRUCT_H #include #include #include #include #include #include #include #endif skalibs-2.14.1.1/src/include/skalibs/devino.h000066400000000000000000000004501455624754300207030ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_DEVINO_H #define SKALIBS_DEVINO_H #include typedef struct devino_s devino, *devino_ref ; struct devino_s { dev_t dev ; ino_t ino ; } ; #define DEVINO_ZERO { .dev = 0, .ino = 0 } extern int devino_cmp (void const *, void const *) ; #endif skalibs-2.14.1.1/src/include/skalibs/direntry.h000066400000000000000000000003711455624754300212610ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_DIRENTRY_H #define SKALIBS_DIRENTRY_H #include typedef struct dirent direntry, *direntry_ref ; extern void dir_close (DIR *) ; extern int dir_fd (DIR *) ; /* Solaris doesn't have dirfd() */ #endif skalibs-2.14.1.1/src/include/skalibs/disize.h000066400000000000000000000003701455624754300207070ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_DISIZE_H #define SKALIBS_DISIZE_H #include typedef struct disize_s disize, *disize_ref ; struct disize_s { size_t left ; size_t right ; } ; #define DISIZE_ZERO { .left = 0, .right = 0 } #endif skalibs-2.14.1.1/src/include/skalibs/diuint.h000066400000000000000000000003531455624754300207150ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_DIUINT_H #define SKALIBS_DIUINT_H typedef struct diuint diuint, *diuint_ref ; struct diuint { unsigned int left ; unsigned int right ; } ; #define DIUINT_ZERO { .left = 0, .right = 0 } #endif skalibs-2.14.1.1/src/include/skalibs/diuint32.h000066400000000000000000000004121455624754300210560ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_DIUINT32_H #define SKALIBS_DIUINT32_H #include typedef struct diuint32_s diuint32, *diuint32_ref ; struct diuint32_s { uint32_t left ; uint32_t right ; } ; #define DIUINT32_ZERO { .left = 0, .right = 0 } #endif skalibs-2.14.1.1/src/include/skalibs/djbtime.h000066400000000000000000000046411455624754300210430ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_DJBTIME_H #define SKALIBS_DJBTIME_H #include #include #include #include extern int timespec_cmp (struct timespec const *, struct timespec const *) ; /* UTC <--> TAI conversions */ /* sysclock can be either TAI-10 or UTC */ extern int utc_from_tai (uint64_t *, tai const *) ; extern int tai_from_utc (tai *, uint64_t) ; extern int utc_from_sysclock (uint64_t *) ; extern int sysclock_from_utc (uint64_t *) ; /* NTP internal format */ #define NTP_OFFSET 2208988800UL extern int ntp_from_tain (uint64_t *, tain const *) ; #define ntp_from_tain_g(u) ntp_from_tain((u), &STAMP) extern int tain_from_ntp (tain *, uint64_t) ; /* localtime handling - replaces caltimedate functions */ /* ltm64 can be either TAI-10 or UTC depending on the current timezone */ /* normally ltm64 is the same as sysclock, but we allow it to be different */ /* for instance for musl TAI-10 systems */ typedef struct localtmn_s localtmn, *localtmn_ref ; struct localtmn_s { struct tm tm ; uint32_t nano ; } ; extern int ltm64_from_tai (uint64_t *, tai const *) ; extern int tai_from_ltm64 (tai *, uint64_t) ; extern int ltm64_from_utc (uint64_t *) ; extern int utc_from_ltm64 (uint64_t *) ; extern int ltm64_from_sysclock (uint64_t *) ; extern int sysclock_from_ltm64 (uint64_t *) ; extern int localtm_from_ltm64 (struct tm *, uint64_t, int) ; extern int ltm64_from_localtm (uint64_t *, struct tm const *) ; extern int localtm_from_sysclock (struct tm *, uint64_t, int) ; extern int sysclock_from_localtm (uint64_t *, struct tm const *) ; extern int localtm_from_utc (struct tm *, uint64_t, int) ; extern int utc_from_localtm (uint64_t *, struct tm const *) ; extern int localtm_from_tai (struct tm *, tai const *, int) ; extern int tai_from_localtm (tai *, struct tm const *) ; extern int localtmn_from_tain (localtmn *, tain const *, int) ; #define localtmn_from_tain_g(l, h) localtmn_from_tain(l, &STAMP, h) extern int tain_from_localtmn (tain *, localtmn const *) ; extern int localtmn_from_sysclock (localtmn *, tain const *, int) ; extern int sysclock_from_localtmn (tain *, localtmn const *) ; #define LOCALTM_FMT 21 extern size_t localtm_fmt (char *, struct tm const *) ; extern size_t localtm_scan (char const *, struct tm *) ; #define LOCALTMN_FMT 31 extern size_t localtmn_fmt (char *, localtmn const *) ; extern size_t localtmn_scan (char const *, localtmn *) ; #endif skalibs-2.14.1.1/src/include/skalibs/djbunix.h000066400000000000000000000145231455624754300210700ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_DJBUNIX_H #define SKALIBS_DJBUNIX_H #include #include #include #include #include #include #include extern int coe (int) ; extern int uncoe (int) ; extern int ndelay_on (int) ; extern int ndelay_off (int) ; extern int pipe_internal (int *, unsigned int) ; #define pipenb(p) pipe_internal(p, O_NONBLOCK) #define pipecoe(p) pipe_internal(p, O_CLOEXEC) #define pipenbcoe(p) pipe_internal(p, O_NONBLOCK|O_CLOEXEC) extern int fd_copy (int, int) ; extern int fd_copy2 (int, int, int, int) ; extern int fd_move (int, int) ; extern int fd_move2 (int, int, int, int) ; extern void fd_close (int) ; extern int fd_chmod (int, unsigned int) ; extern int fd_chown (int, uid_t, gid_t) ; extern int fd_sync (int) ; extern off_t fd_cat (int, int) ; extern off_t fd_catn (int, int, off_t) ; extern int fd_ensure_open (int, int) ; #define fd_sanitize() (fd_ensure_open(0, 0) && fd_ensure_open(1, 1) && fd_ensure_open(2, 1)) extern void fd_shutdown (int, int) ; extern int fd_lock (int, int, int) ; extern void fd_unlock (int) ; extern int fd_islocked (int) ; extern int open2 (char const *, unsigned int) ; extern int open3 (char const *, unsigned int, unsigned int) ; extern int open_read (char const *) ; extern int openc_read (char const *) ; extern int openb_read (char const *) ; extern int openbc_read (char const *) ; extern int open_readb (char const *) ; extern int openc_readb (char const *) ; extern int open_excl (char const *) ; extern int openc_excl (char const *) ; extern int open_append (char const *) ; extern int openc_append (char const *) ; extern int open_create (char const *) ; extern int openc_create (char const *) ; extern int open_trunc (char const *) ; extern int openc_trunc (char const *) ; extern int open_write (char const *) ; extern int openc_write (char const *) ; extern size_t path_canonicalize (char *, char const *, int) ; extern pid_t wait_nointr (int *) ; extern pid_t waitpid_nointr (pid_t, int *, int) ; #define wait_pid(pid, wstat) waitpid_nointr(pid, (wstat), 0) #define wait_nohang(wstat) waitpid_nointr(-1, (wstat), WNOHANG) extern pid_t wait_pid_nohang (pid_t, int *) ; extern int wait_pids_nohang (pid_t const *, unsigned int, int *) ; #define wait_status(w) (WIFSIGNALED(w) ? 256 + WTERMSIG(w) : WEXITSTATUS(w)) #define wait_estatus(w) (WIFSIGNALED(w) ? 128 + WTERMSIG(w) : WEXITSTATUS(w) >= 128 ? 128 : WEXITSTATUS(w)) extern unsigned int wait_reap (void) ; extern int waitn (pid_t *, unsigned int) ; extern int waitn_posix (pid_t *, unsigned int, int *) ; extern int waitn_reap (pid_t *, unsigned int) ; extern int waitn_reap_posix (pid_t *, unsigned int, int *) ; extern int fd_chdir (int) ; extern int sarealpath (stralloc *, char const *) ; extern int sabasename (stralloc *, char const *, size_t) ; extern int sadirname (stralloc *, char const *, size_t) ; extern int sagetcwd (stralloc *) ; extern int sareadlink (stralloc *, char const *) ; extern int sagethostname (stralloc *) ; #define slurp(sa, fd) slurpn((fd), (sa), 0) #define openslurpclose(sa, fn) openslurpnclose((fn), (sa), 0) extern int slurpn (int, stralloc *, size_t) ; extern int openslurpnclose (char const *, stralloc *, size_t) ; extern ssize_t readnclose (int fd, char *, size_t) ; /* closes fd */ extern ssize_t openreadnclose (char const *, char *, size_t) ; extern ssize_t openreadnclose_nb (char const *, char *, size_t) ; extern int openreadfileclose (char const *, stralloc *, size_t) ; #define writenclose_unsafe(fd, s, n) writenclose_unsafe5(fd, s, (n), 0, 0) #define writenclose_unsafe_sync(fd, s, n) writenclose_unsafe5(fd, s, (n), 0, 1) extern int writenclose_unsafe5 (int, char const *, size_t, devino *, unsigned int) ; #define openwritenclose_unsafe(f, s, n) openwritenclose_unsafe5(f, s, (n), 0, 0) #define openwritenclose_unsafe_sync(f, s, n) openwritenclose_unsafe5(f, s, (n), 0, 1) extern int openwritenclose_unsafe5 (char const *, char const *, size_t, devino *, unsigned int) ; #define openwritenclose_suffix(f, s, n, t) openwritenclose_suffix6(f, s, n, 0, 0, t) #define openwritenclose_suffix_sync(f, s, n, t) openwritenclose_suffix6(f, s, n, 0, 1, t) extern int openwritenclose_suffix6 (char const *, char const *, size_t, devino *, unsigned int, char const *) ; #define openwritenclose(f, s, n) openwritenclose5(f, s, (n), 0, 0) #define openwritenclose_sync(f, s, n) openwritenclose5(f, s, (n), 0, 1) extern int openwritenclose5 (char const *, char const *, size_t, devino *, unsigned int) ; #define writenvclose_unsafe(fd, v, n) writevnclose_unsafe5(fd, v, (n), 0, 0) #define writevnclose_unsafe_sync(fd, v, n) writevnclose_unsafe5(fd, v, (n), 0, 1) extern int writevnclose_unsafe5 (int, struct iovec const *, unsigned int, devino *, unsigned int) ; #define openwritevnclose_unsafe(f, v, n) openwritevnclose_unsafe5(f, v, (n), 0, 0) #define openwritevnclose_unsafe_sync(f, v, n) openwritevnclose_unsafe5(f, v, (n), 0, 1) extern int openwritevnclose_unsafe5 (char const *, struct iovec const *, unsigned int, devino *, unsigned int) ; #define openwritevnclose_suffix(f, v, n, t) openwritevnclose_suffix6(f, v, n, 0, 0, t) #define openwritevnclose_suffix_sync(f, v, n, t) openwritevnclose_suffix6(f, v, n, 0, 1, t) extern int openwritevnclose_suffix6 (char const *, struct iovec const *, unsigned int, devino *, unsigned int, char const *) ; #define openwritevnclose(f, v, n) openwritevnclose5(f, v, (n), 0, 0) #define openwritevnclose_sync(f, v, n) openwritevnclose5(f, v, (n), 0, 1) extern int openwritevnclose5 (char const *, struct iovec const *, unsigned int, devino *, unsigned int) ; extern int rm_rf (char const *) ; extern int rm_rf_tmp (char const *, stralloc *) ; extern int rm_rf_in_tmp (stralloc *, size_t) ; /* caution ! */ extern int rmstar (char const *) ; extern int rmstar_tmp (char const *, stralloc *) ; extern int filecopy_unsafe (char const *, char const *, unsigned int) ; extern int filecopy_suffix (char const *, char const *, unsigned int, char const *) ; extern int sals (char const *, stralloc *, size_t *) ; extern int hiercopy (char const *, char const *) ; extern int hiercopy_tmp (char const *, char const *, stralloc *) ; extern int hiercopy_loose (char const *, char const *) ; extern int hiercopy_loose_tmp (char const *, char const *, stralloc *) ; extern int hiercopy_internal (char const *, char const *, stralloc *, unsigned int) ; #endif skalibs-2.14.1.1/src/include/skalibs/env.h000066400000000000000000000031611455624754300202110ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_ENV_H #define SKALIBS_ENV_H #include #include #include extern size_t env_len (char const *const *) gccattr_pure ; extern char const *env_get (char const *) gccattr_deprecated ; extern char const *env_get2 (char const *const *, char const *) gccattr_pure ; extern char const *ucspi_get (char const *) gccattr_pure ; extern int env_addmodif (stralloc *, char const *, char const *) ; extern int env_make (char const **, size_t, char const *, size_t) ; extern int env_string (stralloc *, char const *const *, size_t) ; extern size_t env_mergen (char const **, size_t, char const *const *, size_t, char const *, size_t, size_t) ; extern size_t env_merge (char const **, size_t, char const *const *, size_t, char const *, size_t) ; extern size_t env_mergn (char const **, size_t, char const *const *, char const *, size_t, size_t) ; extern size_t env_merg (char const **, size_t, char const *const *, char const *, size_t) ; #define SKALIBS_ENVDIR_VERBATIM 0x01 #define SKALIBS_ENVDIR_NOCHOMP 0x02 #define SKALIBS_ENVDIR_NOCLAMP 0x04 extern int envdir_internal (char const *, stralloc *, unsigned int, char) ; #define envdir(path, sa) envdir_internal(path, (sa), 0, '\n') #define envdir_chomp(path, sa) envdir_internal(path, (sa), SKALIBS_ENVDIR_NOCHOMP, '\n') #define envdir_verbatim_chomp(path, sa) envdir_internal(path, (sa), SKALIBS_ENVDIR_VERBATIM, '\n') #define envdir_verbatim(path, sa) envdir_internal(path, (sa), SKALIBS_ENVDIR_VERBATIM|SKALIBS_ENVDIR_NOCHOMP, '\n') extern int env_dump (char const *, mode_t, char const *const *) ; #endif skalibs-2.14.1.1/src/include/skalibs/envalloc.h000066400000000000000000000006441455624754300212270ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_ENVALLOC_H #define SKALIBS_ENVALLOC_H #include #include #define ENVALLOC_ZERO GENALLOC_ZERO extern int envalloc_make (genalloc *, size_t, char const *, size_t) ; extern int envalloc_uniq (genalloc *, char) ; extern int envalloc_merge (genalloc *, char const *const *, size_t, char const *, size_t) ; extern int envalloc_0 (genalloc *) ; #endif skalibs-2.14.1.1/src/include/skalibs/error.h000066400000000000000000000004211455624754300205460ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_ERROR_H #define SKALIBS_ERROR_H #include extern int error_temp (int) gccattr_const ; extern int error_isalready (int) gccattr_const ; #define error_isagain(e) (((e) == EAGAIN) || ((e) == EWOULDBLOCK)) #endif skalibs-2.14.1.1/src/include/skalibs/exec.h000066400000000000000000000230171455624754300203470ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_EXEC_H #define SKALIBS_EXEC_H #include #include #include #include extern void xexecvep (char const *, char const *const *, char const *const *, char const *) gccattr_noreturn ; extern void xexecvep_loose (char const *, char const *const *, char const *const *, char const *) gccattr_noreturn ; /* Direct execution with PATH (calls execvep). (was called pathexec_run in earlier skalibs versions) a for provided file name (default: argv[0]) e for provided envp (default: environ) foo0 exits 0 if argv[0] is NULL xfoo dies if the exec fails */ extern void exec_ae (char const *, char const *const *, char const *const *) ; #define exec_a(file, argv) exec_ae(file, (argv), (char const *const *)environ) #define exec_e(argv, envp) exec_ae((argv)[0], (argv), envp) #define exec(argv) exec_a((argv)[0], (argv)) extern void xexec_ae (char const *, char const *const *, char const *const *) gccattr_noreturn ; #define xexec_a(file, argv) xexec_ae(file, (argv), (char const *const *)environ) #define xexec_e(argv, envp) xexec_ae((argv)[0], (argv), envp) #define xexec(argv) xexec_a((argv)[0], (argv)) extern void exec0_ae (char const *, char const *const *, char const *const *) ; #define exec0_a(file, argv) exec0_ae(file, (argv), (char const *const *)environ) #define exec0_e(argv, envp) exec0_ae((argv)[0], (argv), envp) #define exec0(argv) exec0_a((argv)[0], (argv)) extern void xexec0_ae (char const *, char const *const *, char const *const *) gccattr_noreturn ; #define xexec0_a(file, argv) xexec0_ae(file, (argv), (char const *const *)environ) #define xexec0_e(argv, envp) xexec0_ae((argv)[0], (argv), envp) #define xexec0(argv) xexec0_a((argv)[0], (argv)) /* Execution with environment modifications : env_merge and exec. (was called pathexec in earlier skalibs versions) a for provided file name (default: argv[0]) e for provided envp (default: environ) f for provided envp *and* length of the envp m for provided modif string plus its length (the length is always needed because the modifs are null-terminated) n for provided modif string, length *and* number of modifs */ extern int env_mexec (char const *, char const *) ; extern void mexec_afn (char const *, char const *const *, char const *const *, size_t, char const *, size_t, size_t) ; extern void mexec_afm (char const *, char const *const *, char const *const *, size_t, char const *, size_t) ; extern void mexec_af (char const *, char const *const *, char const *const *, size_t) ; #define mexec_aen(file, argv, envp, modif, modiflen, modifn) mexec_afn(file, argv, envp, env_len(envp), modif, modiflen, modifn) #define mexec_aem(file, argv, envp, modif, modiflen) mexec_afm(file, argv, envp, env_len(envp), modif, modiflen) #define mexec_ae(file, argv, envp) mexec_af(file, argv, (envp), env_len(envp)) #define mexec_an(file, argv, modif, modiflen, modifn) mexec_aen(file, argv, (char const *const *)environ, modif, modiflen, modifn) #define mexec_am(file, argv, modif, modiflen) mexec_aem(file, argv, (char const *const *)environ, modif, modiflen) #define mexec_a(file, argv) mexec_ae(file, (argv), (char const *const *)environ) #define mexec_fn(argv, envp, envlen, modif, modiflen, modifn) mexec_afn((argv)[0], (argv), envp, envlen, modif, modiflen, modifn) #define mexec_fm(argv, envp, envlen, modif, modiflen) mexec_afm((argv)[0], (argv), envp, envlen, modif, modiflen) #define mexec_f(argv, envp, envlen) mexec_af((argv)[0], (argv), envp, envlen) #define mexec_en(argv, envp, modif, modiflen, modifn) mexec_aen((argv)[0], (argv), envp, modif, modiflen, modifn) #define mexec_em(argv, envp, modif, modiflen) mexec_aem((argv)[0], (argv), envp, modif, modiflen) #define mexec_e(argv, envp) mexec_ae((argv)[0], (argv), envp) #define mexec_n(argv, modif, modiflen, modifn) mexec_an((argv)[0], (argv), modif, modiflen, modifn) #define mexec_m(argv, modif, modiflen) mexec_am((argv)[0], (argv), modif, modiflen) #define mexec(argv) mexec_a((argv)[0], (argv)) extern void mexec0_afn (char const *, char const *const *, char const *const *, size_t, char const *, size_t, size_t) ; extern void mexec0_afm (char const *, char const *const *, char const *const *, size_t, char const *, size_t) ; extern void mexec0_af (char const *, char const *const *, char const *const *, size_t) ; #define mexec0_aen(file, argv, envp, modif, modiflen, modifn) mexec0_afn(file, argv, envp, env_len(envp), modif, modiflen, modifn) #define mexec0_aem(file, argv, envp, modif, modiflen) mexec0_afm(file, argv, envp, env_len(envp), modif, modiflen) #define mexec0_ae(file, argv, envp) mexec0_af(file, argv, (envp), env_len(envp)) #define mexec0_an(file, argv, modif, modiflen, modifn) mexec0_aen(file, argv, (char const *const *)environ, modif, modiflen, modifn) #define mexec0_am(file, argv, modif, modiflen) mexec0_aem(file, argv, (char const *const *)environ, modif, modiflen) #define mexec0_a(file, argv) mexec0_ae(file, (argv), (char const *const *)environ) #define mexec0_fn(argv, envp, envlen, modif, modiflen, modifn) mexec0_afn((argv)[0], (argv), envp, envlen, modif, modiflen, modifn) #define mexec0_fm(argv, envp, envlen, modif, modiflen) mexec0_afm((argv)[0], (argv), envp, envlen, modif, modiflen) #define mexec0_f(argv, envp, envlen) mexec0_af((argv)[0], (argv), envp, envlen) #define mexec0_en(argv, envp, modif, modiflen, modifn) mexec0_aen((argv)[0], (argv), envp, modif, modiflen, modifn) #define mexec0_em(argv, envp, modif, modiflen) mexec0_aem((argv)[0], (argv), envp, modif, modiflen) #define mexec0_e(argv, envp) mexec0_ae((argv)[0], (argv), envp) #define mexec0_n(argv, modif, modiflen, modifn) mexec0_an((argv)[0], (argv), modif, modiflen, modifn) #define mexec0_m(argv, modif, modiflen) mexec0_am((argv)[0], (argv), modif, modiflen) #define mexec0(argv) mexec0_a((argv)[0], (argv)) extern void xmexec_afn (char const *, char const *const *, char const *const *, size_t, char const *, size_t, size_t) gccattr_noreturn ; extern void xmexec_afm (char const *, char const *const *, char const *const *, size_t, char const *, size_t) gccattr_noreturn ; extern void xmexec_af (char const *, char const *const *, char const *const *, size_t) gccattr_noreturn ; #define xmexec_aen(file, argv, envp, modif, modiflen, modifn) xmexec_afn(file, argv, envp, env_len(envp), modif, modiflen, modifn) #define xmexec_aem(file, argv, envp, modif, modiflen) xmexec_afm(file, argv, envp, env_len(envp), modif, modiflen) #define xmexec_ae(file, argv, envp) xmexec_af(file, argv, (envp), env_len(envp)) #define xmexec_an(file, argv, modif, modiflen, modifn) xmexec_aen(file, argv, (char const *const *)environ, modif, modiflen, modifn) #define xmexec_am(file, argv, modif, modiflen) xmexec_aem(file, argv, (char const *const *)environ, modif, modiflen) #define xmexec_a(file, argv) xmexec_ae(file, (argv), (char const *const *)environ) #define xmexec_fn(argv, envp, envlen, modif, modiflen, modifn) xmexec_afn((argv)[0], (argv), envp, envlen, modif, modiflen, modifn) #define xmexec_fm(argv, envp, envlen, modif, modiflen) xmexec_afm((argv)[0], (argv), envp, envlen, modif, modiflen) #define xmexec_f(argv, envp, envlen) xmexec_af((argv)[0], (argv), envp, envlen) #define xmexec_en(argv, envp, modif, modiflen, modifn) xmexec_aen((argv)[0], (argv), envp, modif, modiflen, modifn) #define xmexec_em(argv, envp, modif, modiflen) xmexec_aem((argv)[0], (argv), envp, modif, modiflen) #define xmexec_e(argv, envp) xmexec_ae((argv)[0], (argv), envp) #define xmexec_n(argv, modif, modiflen, modifn) xmexec_an((argv)[0], (argv), modif, modiflen, modifn) #define xmexec_m(argv, modif, modiflen) xmexec_am((argv)[0], (argv), modif, modiflen) #define xmexec(argv) xmexec_a((argv)[0], (argv)) extern void xmexec0_afn (char const *, char const *const *, char const *const *, size_t, char const *, size_t, size_t) gccattr_noreturn ; extern void xmexec0_afm (char const *, char const *const *, char const *const *, size_t, char const *, size_t) gccattr_noreturn ; extern void xmexec0_af (char const *, char const *const *, char const *const *, size_t) gccattr_noreturn ; #define xmexec0_aen(file, argv, envp, modif, modiflen, modifn) xmexec0_afn(file, argv, envp, env_len(envp), modif, modiflen, modifn) #define xmexec0_aem(file, argv, envp, modif, modiflen) xmexec0_afm(file, argv, envp, env_len(envp), modif, modiflen) #define xmexec0_ae(file, argv, envp) xmexec0_af(file, argv, (envp), env_len(envp)) #define xmexec0_an(file, argv, modif, modiflen, modifn) xmexec0_aen(file, argv, (char const *const *)environ, modif, modiflen, modifn) #define xmexec0_am(file, argv, modif, modiflen) xmexec0_aem(file, argv, (char const *const *)environ, modif, modiflen) #define xmexec0_a(file, argv) xmexec0_ae(file, (argv), (char const *const *)environ) #define xmexec0_fn(argv, envp, envlen, modif, modiflen, modifn) xmexec0_afn((argv)[0], (argv), envp, envlen, modif, modiflen, modifn) #define xmexec0_fm(argv, envp, envlen, modif, modiflen) xmexec0_afm((argv)[0], (argv), envp, envlen, modif, modiflen) #define xmexec0_f(argv, envp, envlen) xmexec0_af((argv)[0], (argv), envp, envlen) #define xmexec0_en(argv, envp, modif, modiflen, modifn) xmexec0_aen((argv)[0], (argv), envp, modif, modiflen, modifn) #define xmexec0_em(argv, envp, modif, modiflen) xmexec0_aem((argv)[0], (argv), envp, modif, modiflen) #define xmexec0_e(argv, envp) xmexec0_ae((argv)[0], (argv), envp) #define xmexec0_n(argv, modif, modiflen, modifn) xmexec0_an((argv)[0], (argv), modif, modiflen, modifn) #define xmexec0_m(argv, modif, modiflen) xmexec0_am((argv)[0], (argv), modif, modiflen) #define xmexec0(argv) xmexec0_a((argv)[0], (argv)) #endif skalibs-2.14.1.1/src/include/skalibs/fmtscan.h000066400000000000000000000024221455624754300210530ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_FMTSCAN_H #define SKALIBS_FMTSCAN_H #include #include #include /* fmt */ extern size_t str_fmt (char *, char const *) ; extern size_t strn_fmt (char *, char const *, size_t) ; extern unsigned char fmtscan_asc (unsigned char) gccattr_const ; #define IP4_FMT 20 extern size_t ip4_fmt (char *, char const *) ; extern size_t ip4_fmtu32 (char *, uint32_t) ; extern size_t ucharn_fmt (char *, char const *, size_t) ; extern size_t ucharn_fmt_little (char *, char const *, size_t) ; #define IP6_FMT 40 extern size_t ip6_fmt (char *, char const *) ; /* scan */ extern unsigned char fmtscan_num (unsigned char, unsigned char) gccattr_const ; extern size_t ip4_scan (char const *, char *) ; extern size_t ip4_scanu32 (char const *, uint32_t *) ; extern size_t ip4_scanlist_u32 (uint32_t *, size_t, char const *, size_t *) ; extern size_t ip4_scanlist (char *, size_t, char const *, size_t *) ; extern size_t ip6_scan (char const *, char *) ; extern size_t ip6_scanlist (char *, size_t, char const *, size_t *) ; extern size_t ucharn_scan (char const *, char *, size_t) ; extern size_t ucharn_scan_little (char const *, char *, size_t) ; extern size_t ucharn_findlen (char const *) gccattr_pure ; #endif skalibs-2.14.1.1/src/include/skalibs/functypes.h000066400000000000000000000032721455624754300214440ustar00rootroot00000000000000/* ISC license. */ #ifndef FUNCTYPES_H #define FUNCTYPES_H #include #include #include typedef int uintcmp_func (unsigned int, unsigned int, void *) ; typedef uintcmp_func *uintcmp_func_ref ; typedef int uint32cmp_func (uint32_t, uint32_t, void *) ; typedef uint32cmp_func *uint32cmp_func_ref ; typedef int cmp_func (void const *, void const *, void *) ; typedef cmp_func *cmp_func_ref ; typedef void *dtok_func (uint32_t, void *) ; typedef dtok_func *dtok_func_ref ; typedef int iter_func (void *, void *) ; typedef iter_func *iter_func_ref ; typedef void free_func (void *) ; typedef free_func *free_func_ref ; typedef int init_func (void *) ; typedef init_func *init_func_ref ; typedef ssize_t get_func (void *) ; typedef get_func *get_func_ref ; typedef size_t uget_func (void *) ; typedef uget_func *uget_func_ref ; typedef ssize_t io_func (int, char *, size_t) ; typedef io_func *io_func_ref ; typedef ssize_t iow_func (int, char const *, size_t) ; typedef iow_func *iow_func_ref ; typedef ssize_t iov_func (int, struct iovec const *, unsigned int) ; typedef iov_func *iov_func_ref ; typedef size_t allio_func (int, char *, size_t) ; typedef allio_func *allio_func_ref ; typedef size_t alliow_func (int, char const *, size_t) ; typedef alliow_func *alliow_func_ref ; typedef size_t alliov_func (int, struct iovec const *, unsigned int) ; typedef alliov_func *alliov_func_ref ; typedef int create_func (char const *, mode_t, void *) ; typedef create_func *create_func_ref ; typedef int link_func (char const *, char const *) ; typedef link_func *link_func_ref ; typedef void randomgen_func (char *, size_t) ; typedef randomgen_func *randomgen_func_ref ; #endif skalibs-2.14.1.1/src/include/skalibs/gccattributes.h000066400000000000000000000024171455624754300222670ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_GCCATTRIBUTES_H #define SKALIBS_GCCATTRIBUTES_H #ifdef __GNUC__ #define gccattr_noreturn __attribute__((noreturn)) #define gccattr_returns_twice __attribute__((returns_twice)) #define gccattr_noinline __attribute__((noinline)) #define gccattr_inline __attribute__((always_inline)) #define gccattr_const __attribute__((const)) #define gccattr_unused __attribute__((unused)) #define gccattr_used __attribute__((used)) #define gccattr_weak __attribute__((weak)) #define gccattr_aligned __attribute__((aligned (__BIGGEST_ALIGNMENT__))) #define gccattr_nonstring __attribute__((nonstring)) # if (__GNUC__ >= 3) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 96)) #define gccattr_malloc __attribute__((malloc)) #define gccattr_pure __attribute__((pure)) # else #define gccattr_malloc #define gccattr_pure # endif # if (__GNUC__ >= 3) #define gccattr_deprecated __attribute__((deprecated)) # else #define gccattr_deprecated # endif #else #define gccattr_noreturn #define gccattr_returns_twice #define gccattr_noinline #define gccattr_inline #define gccattr_const #define gccattr_unused #define gccattr_used #define gccattr_weak #define gccattr_aligned #define gccattr_nonstring #define gccattr_malloc #define gccattr_pure #define gccattr_deprecated #endif #endif skalibs-2.14.1.1/src/include/skalibs/genalloc.h000066400000000000000000000032271455624754300212100ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_GENALLOC_H #define SKALIBS_GENALLOC_H #include #include typedef stralloc genalloc, *genalloc_ref ; #define GENALLOC_ZERO STRALLOC_ZERO #define genalloc_zero stralloc_zero #define genalloc_s(type, g) ((type *)((g)->s)) #define genalloc_len(type, g) ((g)->len/sizeof(type)) #define genalloc_setlen(type, g, n) ((g)->len = (n)*sizeof(type)) #define genalloc_ready(type, g, n) stralloc_ready((g), (n)*sizeof(type)) #define genalloc_ready_tuned(type, g, n, base, fracnum, fracden) stralloc_ready_tuned((g), (n)*sizeof(type), base, fracnum, fracden) #define genalloc_readyplus(type, g, n) stralloc_readyplus((g), (n)*sizeof(type)) #define genalloc_free(type, g) stralloc_free(g) #define genalloc_shrink(type, g) stralloc_shrink(g) #define genalloc_catb(type, g, s, n) stralloc_catb((g), (char const *)(s), (n)*sizeof(type)) #define genalloc_copyb(type, g, s, n) stralloc_copyb((g), (char const *)(s), (n)*sizeof(type)) #define genalloc_copy(type, g1, g2) stralloc_copy((g1), g2) #define genalloc_cat(type, g1, g2) stralloc_cat((g1), g2) #define genalloc_append(type, g, p) stralloc_catb((g), (char const *)(p), sizeof(type)) #define genalloc_reverse(type, g) stralloc_reverse_blocks((g), sizeof(type)) #define genalloc_insertb(type, g, offset, s, n) stralloc_insertb((g), (offset)*sizeof(type), (char const *)(s), (n)*sizeof(type)) #define genalloc_insert(type, g1, offset, g2) stralloc_insert((g1), (offset)*sizeof(type), (g2)) #define genalloc_deepfree(type, g, f) genalloc_deepfree_size(g, (free_func_ref)(f), sizeof(type)) extern void genalloc_deepfree_size (genalloc *, free_func_ref, size_t) ; #endif skalibs-2.14.1.1/src/include/skalibs/genqdyn.h000066400000000000000000000017121455624754300210660ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_GENQDYN_H #define SKALIBS_GENQDYN_H #include #include typedef struct genqdyn_s genqdyn, *genqdyn_ref ; struct genqdyn_s { stralloc queue ; size_t esize ; size_t head ; unsigned int num ; unsigned int den ; } ; #define GENQDYN_ZERO { .queue = STRALLOC_ZERO, .esize = 1, .head = 0, .num = 0, .den = 1 } extern genqdyn const genqdyn_zero ; #define GENQDYN_INIT(type, n, d) { .queue = STRALLOC_ZERO, .esize = sizeof(type), .head = 0, .num = n, .den = d } extern void genqdyn_init (genqdyn *, size_t, unsigned int, unsigned int) ; #define genqdyn_n(g) (((g)->queue.len - (g)->head) / (g)->esize) extern void genqdyn_free (genqdyn *) ; extern int genqdyn_push (genqdyn *, void const *) ; extern int genqdyn_unpush (genqdyn *) ; #define GENQDYN_PEEK(type, g) ((type *)((g)->queue.s + (g)->head)) #define genqdyn_peek(g) GENQDYN_PEEK(void, (g)) extern int genqdyn_pop (genqdyn *) ; #endif skalibs-2.14.1.1/src/include/skalibs/genset.h000066400000000000000000000030651455624754300207110ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_GENSET_H #define SKALIBS_GENSET_H #include #include typedef struct genset_s genset, *genset_ref ; struct genset_s { char *storage ; uint32_t *freelist ; uint32_t esize ; uint32_t max ; uint32_t sp ; } ; #define GENSET_ZERO { .storage = 0, .freelist = 0, .esize = 1, .max = 0, .sp = 0 } extern void genset_init (genset *, void *, uint32_t *, uint32_t, uint32_t) ; #define GENSET_init(g, type, storage, fl, size) genset_init(g, storage, fl, sizeof(type), size) #define genset_p(type, g, i) ((type *)((g)->storage + (i) * (g)->esize)) extern uint32_t genset_new (genset *) ; extern int genset_delete (genset *, uint32_t) ; #define genset_n(g) ((g)->max - (g)->sp) extern uint32_t genset_iter_nocancel (genset *, uint32_t, iter_func_ref, void *) ; #define genset_iter(g, f, stuff) genset_iter_nocancel(g, (g)->max, f, stuff) extern int genset_iter_withcancel (genset *, iter_func_ref, iter_func_ref, void *) ; extern void genset_deepfree (genset *, free_func_ref) ; #define GENSETB_TYPE(type, size) struct { type storage[size] ; uint32_t freelist[size] ; genset info ; } #define GENSETB_init(type, g, size) GENSET_init(&(g)->info, type, (g)->storage, (g)->freelist, size) #define gensetb_p(type, g, i) genset_p(type, &(g)->info, i) #define gensetb_new(g) genset_new(&(g)->info) #define gensetb_delete(g, i) genset_delete(&(g)->info, i) #define gensetb_n(g) genset_n(&(g)->info) #define gensetb_iter(g, f, p) genset_iter(&(g)->info, f, p) #define gensetb_deepfree(g, f) genset_deepfree(&(g)->info, f) #endif skalibs-2.14.1.1/src/include/skalibs/gensetdyn.h000066400000000000000000000032171455624754300214230ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_GENSETDYN_H #define SKALIBS_GENSETDYN_H #include #include #include #include typedef struct gensetdyn_s gensetdyn, *gensetdyn_ref ; struct gensetdyn_s { stralloc storage ; genalloc freelist ; /* array of uint32_t */ uint32_t esize ; uint32_t base ; uint32_t fracnum ; uint32_t fracden ; } ; #define GENSETDYN_ZERO { .storage = STRALLOC_ZERO, .freelist = GENALLOC_ZERO, .esize = 1, .base = 0, .fracnum = 0, .fracden = 1 } extern gensetdyn const gensetdyn_zero ; #define GENSETDYN_INIT(type, b, num, den) { .storage = STRALLOC_ZERO, .freelist = GENALLOC_ZERO, .esize = sizeof(type), .base = (b), .fracnum = (num), .fracden = (den) } extern void gensetdyn_init (gensetdyn *, uint32_t, uint32_t, uint32_t, uint32_t) ; #define gensetdyn_n(g) ((uint32_t)((g)->storage.len - genalloc_len(uint32_t, &(g)->freelist))) extern int gensetdyn_ready (gensetdyn *, uint32_t) ; #define gensetdyn_readyplus(x, n) gensetdyn_ready(x, gensetdyn_n(x) + (n)) extern void gensetdyn_free (gensetdyn *) ; extern void gensetdyn_deepfree (gensetdyn *, free_func_ref) ; extern int gensetdyn_new (gensetdyn *, uint32_t *) ; extern int gensetdyn_delete (gensetdyn *, uint32_t) ; #define gensetdyn_p(g, i) ((g)->storage.s + (i) * (g)->esize) #define GENSETDYN_P(type, g, i) ((type *)gensetdyn_p(g, i)) extern uint32_t gensetdyn_iter_nocancel (gensetdyn *, uint32_t, iter_func_ref, void *) ; #define gensetdyn_iter(g, f, stuff) gensetdyn_iter_nocancel(g, gensetdyn_n(g), f, stuff) extern int gensetdyn_iter_withcancel (gensetdyn *, iter_func_ref, iter_func_ref, void *) ; #endif skalibs-2.14.1.1/src/include/skalibs/genwrite.h000066400000000000000000000023631455624754300212500ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_GENWRITE_H #define SKALIBS_GENWRITE_H #include typedef ssize_t genwrite_put_func (void *, char const *, size_t) ; typedef genwrite_put_func *genwrite_put_func_ref ; typedef int genwrite_flush_func (void *) ; typedef genwrite_flush_func *genwrite_flush_func_ref ; typedef struct genwrite_s genwrite, *genwrite_ref ; struct genwrite_s { genwrite_put_func_ref put ; genwrite_flush_func_ref flush ; void *target ; } ; #define GENWRITE_ZERO { .put = 0, .flush = 0, .target = 0 } extern genwrite_put_func genwrite_put_stralloc ; extern genwrite_flush_func genwrite_flush_stralloc ; extern genwrite_put_func genwrite_put_buffer ; extern genwrite_flush_func genwrite_flush_buffer ; extern genwrite_put_func genwrite_put_bufalloc ; extern genwrite_flush_func genwrite_flush_bufalloc ; #define GENWRITE_STRALLOC_INIT(sa) { .put = &genwrite_put_stralloc, .flush = &genwrite_flush_stralloc, .target = (sa) } #define GENWRITE_BUFFER_INIT(b) { .put = &genwrite_put_buffer, .flush = &genwrite_flush_buffer, .target = (b) } #define GENWRITE_BUFALLOC_INIT(ba) { .put = &genwrite_put_bufalloc, .flush = &genwrite_flush_bufalloc, .target = (ba) } extern genwrite genwrite_stdout ; extern genwrite genwrite_stderr ; #endif skalibs-2.14.1.1/src/include/skalibs/iopause.h000066400000000000000000000015561455624754300210740ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_IOPAUSE_H #define SKALIBS_IOPAUSE_H #include #include typedef struct pollfd iopause_fd, *iopause_fd_ref ; #define IOPAUSE_READ (POLLIN|POLLHUP) #define IOPAUSE_WRITE POLLOUT #define IOPAUSE_EXCEPT (POLLERR|POLLHUP|POLLNVAL) typedef int iopause_func (iopause_fd *, unsigned int, tain const *, tain const *) ; typedef iopause_func *iopause_func_ref ; extern iopause_func iopause_select ; extern iopause_func iopause_poll ; extern iopause_func iopause_ppoll ; extern iopause_func_ref const iopause_ ; #define iopause (*iopause_) extern int iopause_stamp (iopause_fd *, unsigned int, tain const *, tain *) ; #define iopause_g(x, n, deadline) iopause_stamp(x, n, (deadline), &STAMP) extern void deepsleepuntil (tain const *, tain *) ; #define deepsleepuntil_g(deadline) deepsleepuntil((deadline), &STAMP) #endif skalibs-2.14.1.1/src/include/skalibs/kolbak.h000066400000000000000000000016221455624754300206640ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_KOLBAK_H #define SKALIBS_KOLBAK_H #include #include typedef struct kolbak_closure_s kolbak_closure, *kolbak_closure_ref ; struct kolbak_closure_s { unixmessage_handler_func_ref f ; void *data ; } ; #define KOLBAK_CLOSURE_ZERO { .f = 0, .data = 0 } typedef struct kolbak_queue_s kolbak_queue, *kolbak_queue_ref ; struct kolbak_queue_s { kolbak_closure *x ; size_t n ; size_t head ; size_t tail ; } ; #define KOLBAK_QUEUE_ZERO { .x = 0, .n = 0, .head = 0, .tail = 0 } #define KOLBAK_QUEUE_INIT(s, len) { .x = (s), .n = (len), .head = 0, .tail = 0 } extern int kolbak_queue_init (kolbak_queue *, kolbak_closure *, size_t) ; extern int kolbak_enqueue (kolbak_queue *, unixmessage_handler_func_ref, void *) ; extern int kolbak_unenqueue (kolbak_queue *) ; extern int kolbak_call (unixmessage const *, kolbak_queue *) ; #endif skalibs-2.14.1.1/src/include/skalibs/lolstdio.h000066400000000000000000000013121455624754300212460ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_LOLSTDIO_H #define SKALIBS_LOLSTDIO_H #include #include #include #include #ifdef DEBUG # define LOLDEBUG(...) do \ { \ buffer_puts(buffer_2, PROG) ; \ buffer_puts(buffer_2, ": debug: ") ; \ bprintf(buffer_2, __VA_ARGS__) ; \ buffer_putflush(buffer_2, "\n", 1) ; \ } while (0) #else # define LOLDEBUG(...) #endif extern int vbprintf (buffer *, char const *, va_list) ; extern int bprintf (buffer *, char const *, ...) ; extern int lolprintf (char const *, ...) ; extern int vbaprintf (bufalloc *, char const *, va_list) ; extern int baprintf (bufalloc *, char const *, ...) ; #endif skalibs-2.14.1.1/src/include/skalibs/netstring.h000066400000000000000000000016531455624754300214420ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_NETSTRING_H #define SKALIBS_NETSTRING_H #include #include #include #include extern int netstring_appendb (stralloc *, char const *, size_t) ; #define netstring_appends(sa, s) netstring_appendb((sa), (s), strlen(s)) #define netstring_append(to, from) netstring_appendb((to), (from)->s, (from)->len) extern int netstring_appendv (stralloc *, struct iovec const *, unsigned int) ; extern int netstring_encode (stralloc *, char const *, size_t) ; extern ssize_t netstring_decode (stralloc *, char const *, size_t) ; extern int netstring_okeof (buffer *, size_t) ; extern int netstring_get (buffer *, stralloc *, size_t *) ; extern int netstring_put (buffer *, char const *, size_t, size_t *) ; #define netstring_putba(ba, s, n) netstring_appendb(&(ba)->x, s, n) #define netstring_putbav(ba, v, n) netstring_appendv(&(ba)->x, v, n) #endif skalibs-2.14.1.1/src/include/skalibs/nonposix.h000066400000000000000000000032521455624754300212770ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_NONPOSIX_H #define SKALIBS_NONPOSIX_H /* Drop all pretense of standardness: some libc headers are *more* broken when you define standard feature test macros than when you don't (I'm looking at you, FreeBSD). */ #undef _POSIX_C_SOURCE #undef _XOPEN_SOURCE #if defined(sun) || defined(__sun) /* Solaris: the socket API is not POSIX unless you enable this */ #ifndef _XPG4_2 #define _XPG4_2 #endif #ifndef _XPG6 #define _XPG6 #endif /* Solaris: for settimeofday() and similar. Notice how you have to define by hand a macro with double underscores. */ #ifndef __EXTENSIONS__ #define __EXTENSIONS__ #endif #endif /* sun || __sun */ #if defined(__linux__) || defined(__GNU__) /* GNU (Linux or Hurd): most extensions are unavailable unless you enable _GNU_SOURCE. Some Linux interfaces are also unavailable without it. */ #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif #else /* __linux__ || __GNU__ */ /* Various BSDs and others: _BSD_SOURCE opens up a lot of extensions. We guard this under not-GNU because recent glibcs scream their heads off if you define _BSD_SOURCE. Stay classy, GNU. */ #ifndef _BSD_SOURCE #define _BSD_SOURCE #endif #endif /* __linux__ || __GNU__ */ #ifdef __NetBSD__ /* NetBSD: of course they had to have their own macros too. */ #ifndef _NETBSD_SOURCE #define _NETBSD_SOURCE #endif #ifndef _INCOMPLETE_XOPEN_C063 #define _INCOMPLETE_XOPEN_C063 #endif #endif /* __NetBSD__ */ /* old versions of BSD and some broken GNU toolchains: system headers are not self-contained, starting with sys/types.h normally always works. */ #include #endif /* SKALIBS_NONPOSIX_H */ skalibs-2.14.1.1/src/include/skalibs/nsig.h000066400000000000000000000013721455624754300203630ustar00rootroot00000000000000/* ISC license. */ /* This header MUST be paired with skalibs/nonposix.h, which must be included before system headers. */ #ifndef SKALIBS_NSIG_H #define SKALIBS_NSIG_H #include #ifndef NSIG # ifdef _NSIG # define NSIG _NSIG # elif defined(SIGMAX) # define NSIG (SIGMAX + 1) # elif defined(_SIGMAX) # define NSIG(_SIGMAX + 1) # else # define NSIG 65 # endif #endif /* Some systems (FreeBSD, Darwin) incorrectly define NSIG as 32 (their highest signal number) when it should be 33 (highest plus one). OpenBSD gets this right so we can't use SKALIBS_BSD_SUCKS. The heuristic we use is: if NSIG is a power of two, it's wrong. */ #if NSIG & (NSIG - 1) # define SKALIBS_NSIG NSIG #else # define SKALIBS_NSIG (NSIG+1) #endif #endif skalibs-2.14.1.1/src/include/skalibs/posixishard.h000066400000000000000000000017731455624754300217650ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_POSIXISHARD_H #define SKALIBS_POSIXISHARD_H #include #include #include #include #include #include /* This header must be used with some broken OSes who have serious trouble implementing even easy parts of POSIX. It's supposed to be included *after* system headers, so it won't catch behaviour such as "this macro must be defined prior to including system headers in order to define that symbol". If that's what you need, include skalibs/nonposix.h instead, which must happen *before* system headers. */ extern size_t strnlen (char const *, size_t) gccattr_pure ; #ifndef EPROTO #define EPROTO EPROTOTYPE #endif #ifndef MSG_NOSIGNAL #define MSG_NOSIGNAL 0 #endif #ifdef PATH_MAX #define SKALIBS_PATH_MAX PATH_MAX #else #define SKALIBS_PATH_MAX 4096 #endif #ifdef NAME_MAX #define SKALIBS_NAME_MAX NAME_MAX #else #define SKALIBS_NAME_MAX 255 #endif #endif skalibs-2.14.1.1/src/include/skalibs/posixplz.h000066400000000000000000000031141455624754300213070ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_POSIXPLZ_H #define SKALIBS_POSIXPLZ_H #include #include #include #include #include /* Stuff that doesn't have its own POSIX header for some reason. */ extern char **environ ; /* Non-POSIX functions that some OSes provide and others don't. setgroups() isn't included because it's its own kind of broken. */ extern void *memmem (void const *, size_t, void const *, size_t) gccattr_pure ; extern char *strcasestr (char const *, char const *) gccattr_pure ; extern int getpeereid (int, uid_t *, gid_t *) ; /* Functions that aren't standard at all, but honestly could be. :P */ extern void execvep (char const *, char const *const *, char const *const *, char const *) ; extern void execvep_loose (char const *, char const *const *, char const *const *, char const *) ; extern void unlink_void (char const *) ; extern void munmap_void (void *, size_t) ; extern pid_t doublefork (void) ; extern int touch (char const *) ; extern int mkfiletemp (char *, create_func_ref, mode_t, void *) ; extern int mklinktemp (char const *, char *, link_func_ref) ; extern int mkptemp (char *) ; extern int mkptemp2 (char *, unsigned int) ; extern int mkltemp (char const *, char *) ; extern int mkhtemp (char const *, char *) ; extern int mkctemp (char *, mode_t, dev_t) ; extern int mkbtemp (char *, mode_t, dev_t) ; /* Wrappers around functions that should be specified better. */ #define skalibs_regcomp(re, s, flags) regcomp(re, (s)[0] ? (s) : ".*", flags) #endif skalibs-2.14.1.1/src/include/skalibs/random.h000066400000000000000000000023171455624754300207030ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_RANDOM_H #define SKALIBS_RANDOM_H #include #include #include #include extern void random_devurandom (char *, size_t) ; extern void random_buf (char *, size_t) ; extern void random_buf_early (char *, size_t) ; extern uint32_t random_uint32_from (uint32_t, randomgen_func_ref) ; #define random_uint32(n) random_uint32_from((n), &random_buf) #define random_uint32_early(n) random_uint32_from((n), &random_buf_early) extern void random_name_from (char *, size_t, randomgen_func_ref) ; #define random_name(s, n) random_name_from(s, (n), &random_buf) #define random_name_early(s, n) random_name_from(s, (n), &random_buf_early) extern void random_unsort_from (char *, size_t, size_t, randomgen_func_ref) ; #define random_unsort(s, n, c) random_unsort_from(s, n, (c), &random_buf) #define random_unsort_early(s, n, c) random_unsort_from(s, n, (c), &random_buf_early) extern int random_sauniquename_from (stralloc *, size_t, randomgen_func_ref) ; #define random_sauniquename(sa, n) random_sauniquename_from(sa, (n), &random_buf) #define random_sauniquename_early(sa, n) random_sauniquename_from(sa, (n), &random_buf_early) #endif skalibs-2.14.1.1/src/include/skalibs/segfault.h000066400000000000000000000002501455624754300212270ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_SEGFAULT_H #define SKALIBS_SEGFAULT_H extern int sigsegv (void) ; extern int sigfpe (void) ; #define segfault() sigsegv() #endif skalibs-2.14.1.1/src/include/skalibs/selfpipe.h000066400000000000000000000005031455624754300212250ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_SELFPIPE_H #define SKALIBS_SELFPIPE_H #include extern int selfpipe_init (void) ; extern int selfpipe_trap (int) ; extern int selfpipe_trapset (sigset_t const *) ; extern int selfpipe_fd (void) ; extern int selfpipe_read (void) ; extern void selfpipe_finish (void) ; #endif skalibs-2.14.1.1/src/include/skalibs/setgroups.h000066400000000000000000000014731455624754300214600ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_SETGROUPS_H #define SKALIBS_SETGROUPS_H #include #ifdef SKALIBS_HASSETGROUPS /* setgroups() is defined by a lot of OSes. However, they don't agree on what it should do: some change the primary gid, others don't, etc. It's a mess. Never use setgroups(). Use the functions below instead. */ #include extern int setgroups_and_gid (gid_t, size_t, gid_t const *) ; extern int setgroups_with_egid (size_t, gid_t const *) ; extern int skalibs_setgroups (size_t, gid_t const *) ; #else /* No setgroups() at all? not much we can do. */ #include #define setgroups_and_gid(g, n, tab) (errno = ENOSYS, -1) #define setgroups_with_egid(n, tab) (errno = ENOSYS, -1) #define skalibs_setgroups(n, tab) (errno = ENOSYS, -1) #endif #endif skalibs-2.14.1.1/src/include/skalibs/sgetopt.h000066400000000000000000000021241455624754300211040ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_SGETOPT_H #define SKALIBS_SGETOPT_H /* reentrant */ typedef struct subgetopt_s subgetopt, *subgetopt_ref ; struct subgetopt_s { int ind ; int err ; int problem ; char const *arg ; unsigned int pos ; char const *prog ; } ; #define SUBGETOPT_ZERO { .ind = 1, .err = 1, .problem = 0, .arg = 0, .pos = 0, .prog = 0 } extern int subgetopt_r (int, char const *const *, char const *, subgetopt *) ; /* non-reentrant */ extern int sgetopt_r (int, char const *const *, char const *, subgetopt *) ; extern subgetopt subgetopt_here ; #define lgetopt(argc, argv, opts) subgetopt_r((argc), (argv), (opts), &subgetopt_here) #define sgetopt(argc, argv, opts) sgetopt_r((argc), (argv), (opts), &subgetopt_here) #define sgetopt_prog() (subgetopt_here.prog = PROG) /* define SUBGETOPT_SHORT if you don't mind potential name conflicts */ #ifdef SUBGETOPT_SHORT # define getopt sgetopt # define optarg subgetopt_here.arg # define optind subgetopt_here.ind # define opterr subgetopt_here.err # define optopt subgetopt_here.problem # define opteof (-1) #endif #endif skalibs-2.14.1.1/src/include/skalibs/sha1.h000066400000000000000000000012021455624754300202470ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_SHA1_H #define SKALIBS_SHA1_H #include #include typedef struct SHA1Schedule SHA1Schedule, *SHA1Schedule_ref ; struct SHA1Schedule { uint32_t buf[5] ; uint32_t bits[2] ; uint32_t in[16] ; unsigned int b ; } ; #define SHA1_INIT() { .buf = { 0x67452301U, 0xefcdab89U, 0x98badcfeU, 0x10325476U, 0xc3d2e1f0U }, .bits = { 0, 0 }, .in = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, .b = 0 } extern void sha1_init (SHA1Schedule *) ; extern void sha1_update (SHA1Schedule *, char const *, size_t) ; extern void sha1_final (SHA1Schedule *, char * /* 20 chars */) ; #endif skalibs-2.14.1.1/src/include/skalibs/sha256.h000066400000000000000000000012721455624754300204320ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_SHA256_H #define SKALIBS_SHA256_H #include #include typedef struct SHA256Schedule_s SHA256Schedule, *SHA256Schedule_ref ; struct SHA256Schedule_s { uint32_t buf[8] ; uint32_t bits[2] ; uint32_t in[16] ; uint32_t b ; } ; #define SHA256_INIT() { .buf = { 0x6a09e667U, 0xbb67ae85U, 0x3c6ef372U, 0xa54ff53aU, 0x510e527fU, 0x9b05688cU, 0x1f83d9abU, 0x5be0cd19U }, .bits = { 0, 0 }, .in = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, .b = 0 } extern void sha256_init (SHA256Schedule *) ; extern void sha256_update (SHA256Schedule *, char const *, size_t) ; extern void sha256_final (SHA256Schedule *, char *digest) ; #endif skalibs-2.14.1.1/src/include/skalibs/sha512.h000066400000000000000000000012711455624754300204240ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_SHA512_H #define SKALIBS_SHA512_H #include #include typedef struct SHA512Schedule_s SHA512Schedule, *SHA512Schedule_ref ; struct SHA512Schedule_s { uint64_t len ; uint64_t h[8] ; unsigned char buf[128] ; } ; #define SHA512_INIT() { .len = 0, .h = { 0x6a09e667f3bcc908ULL, 0xbb67ae8584caa73bULL, 0x3c6ef372fe94f82bULL, 0xa54ff53a5f1d36f1ULL, 0x510e527fade682d1ULL, 0x9b05688c2b3e6c1fULL, 0x1f83d9abfb41bd6bULL, 0x5be0cd19137e2179ULL } } extern void sha512_init (SHA512Schedule *) ; extern void sha512_update (SHA512Schedule *, char const *, size_t) ; extern void sha512_final (SHA512Schedule *, char *digest) ; #endif skalibs-2.14.1.1/src/include/skalibs/sig.h000066400000000000000000000012461455624754300202050ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_SIG_H #define SKALIBS_SIG_H #include #include #include typedef void sig_func (int) ; typedef sig_func *sig_func_ref ; extern int sig_catch (int, sig_func_ref) ; #define sig_restore(sig) sig_catch((sig), SIG_DFL) #define sig_ignore(sig) sig_catch((sig), SIG_IGN) extern int sig_altignore (int) ; extern void sig_restoreto (sigset_t const *, unsigned int) ; extern void sig_block (int) ; extern void sig_unblock (int) ; extern void sig_blocknone (void) ; extern char const *sig_name (int) ; extern int sig_number (char const *) ; extern size_t sig0_scan (char const *, int *) ; #endif skalibs-2.14.1.1/src/include/skalibs/siovec.h000066400000000000000000000015621455624754300207140ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_SIOVEC_H #define SKALIBS_SIOVEC_H #include #include extern size_t siovec_len (struct iovec const *, unsigned int) gccattr_pure ; extern size_t siovec_gather (struct iovec const *, unsigned int, char *, size_t) ; extern size_t siovec_scatter (struct iovec const *, unsigned int, char const *, size_t) ; extern size_t siovec_deal (struct iovec const *, unsigned int, struct iovec const *, unsigned int) ; extern size_t siovec_seek (struct iovec *, unsigned int, size_t) ; extern unsigned int siovec_trunc (struct iovec *, unsigned int, size_t) ; extern size_t siovec_bytechr (struct iovec const *, unsigned int, char) ; extern size_t siovec_bytein (struct iovec const *, unsigned int, char const *, size_t) ; extern size_t siovec_search (struct iovec const *, unsigned int, char const *, size_t) ; #endif skalibs-2.14.1.1/src/include/skalibs/skaclient.h000066400000000000000000000247341455624754300214070ustar00rootroot00000000000000/* ISC license. */ #ifndef SKACLIENT_H #define SKACLIENT_H #include #include #include #include #include #include /* Server part */ extern int skaclient_server_ack (unixmessage const *, unixmessage_sender *, unixmessage_sender *, char const *, size_t, char const *, size_t) ; extern int skaclient_server_bidi_ack (unixmessage const *, unixmessage_sender *, unixmessage_sender *, unixmessage_receiver *, char *, size_t, char *, size_t, char const *, size_t, char const *, size_t) ; extern int skaclient_server_init (unixmessage_receiver *, unixmessage_sender *, unixmessage_sender *, char const *, size_t, char const *, size_t, tain const *, tain *) ; #define skaclient_server_init_g(in, out, asyncout, before, beforelen, after, afterlen, deadline) skaclient_server_init(in, out, asyncout, before, beforelen, after, afterlen, (deadline), &STAMP) #define skaclient_server_01x_init(before, beforelen, after, afterlen, deadline, stamp) skaclient_server_init(unixmessage_receiver_0, unixmessage_sender_1, unixmessage_sender_x, before, beforelen, after, afterlen, deadline, stamp) #define skaclient_server_01x_init_g(before, beforelen, after, afterlen, deadline) skaclient_server_01x_init(before, beforelen, after, afterlen, (deadline), &STAMP) /* Client part: the rest of this file */ #define SKACLIENT_KOLBAK_SIZE 64 #define SKACLIENT_OPTION_WAITPID 0x00000001U #define SKACLIENT_OPTION_ASYNC_ACCEPT_FDS 0x00000002U #define SKACLIENT_OPTION_SYNC_ACCEPT_FDS 0x00000004U #define skaclient_buffer_type(bufsn, auxbufsn, bufan, auxbufan, qlen) struct { char bufs[bufsn] ; char auxbufs[auxbufsn] ; char bufa[bufan] ; char auxbufa[auxbufan] ; kolbak_closure q[qlen] ; } typedef skaclient_buffer_type(UNIXMESSAGE_BUFSIZE, UNIXMESSAGE_AUXBUFSIZE, UNIXMESSAGE_BUFSIZE, UNIXMESSAGE_AUXBUFSIZE, SKACLIENT_KOLBAK_SIZE) skaclient_buffer, *skaclient_buffer_ref ; /* User structure */ typedef struct skaclient_s skaclient, *skaclient_ref ; struct skaclient_s { unixmessage_receiver syncin ; unixmessage_sender syncout ; kolbak_queue kq ; unixmessage_receiver asyncin ; unixmessage_sender asyncout ; pid_t pid ; uint32_t options ; } ; #define SKACLIENT_ZERO { .syncin = UNIXMESSAGE_RECEIVER_ZERO, .syncout = UNIXMESSAGE_SENDER_ZERO, .kq = KOLBAK_QUEUE_ZERO, .asyncin = UNIXMESSAGE_RECEIVER_ZERO, .asyncout = UNIXMESSAGE_SENDER_ZERO, .pid = 0, .options = 0 } extern skaclient const skaclient_zero ; /* Callback data for init */ typedef struct skaclient_cbdata_s skaclient_cbdata, *skaclient_cbdata_ref ; struct skaclient_cbdata_s { skaclient *a ; char const *after ; size_t afterlen ; } ; /* Starting and ending */ extern void skaclient_end (skaclient *) ; extern int skaclient_start_async (skaclient *, char *, size_t, char *, size_t, char *, size_t, char *, size_t, kolbak_closure *, size_t, char const *, uint32_t, char const *, size_t, char const *, size_t, skaclient_cbdata *) ; #define skaclient_start_async_b(a, sb, path, options, before, beforelen, after, afterlen, blah) skaclient_start_async(a, (sb)->bufs, sizeof((sb)->bufs), (sb)->auxbufs, sizeof((sb)->auxbufs), (sb)->bufa, sizeof((sb)->bufa), (sb)->auxbufa, sizeof((sb)->auxbufa), (sb)->q, sizeof((sb)->q), path, options, before, beforelen, after, afterlen, blah) extern int skaclient_startf_async (skaclient *, char *, size_t, char *, size_t, char *, size_t, char *, size_t, kolbak_closure *, size_t, char const *, char const *const *, char const *const *, uint32_t, char const *, size_t, char const *, size_t, skaclient_cbdata *) ; #define skaclient_startf_async_b(a, sb, prog, argv, envp, options, before, beforelen, after, afterlen, blah) skaclient_startf_async(a, (sb)->bufs, sizeof((sb)->bufs), (sb)->auxbufs, sizeof((sb)->auxbufs), (sb)->bufa, sizeof((sb)->bufa), (sb)->auxbufa, sizeof((sb)->auxbufa), (sb)->q, sizeof((sb)->q) / sizeof(kolbak_closure), prog, argv, envp, options, before, beforelen, after, afterlen, blah) extern int skaclient_start (skaclient *, char *, size_t, char *, size_t, char *, size_t, char *, size_t, kolbak_closure *, size_t, char const *, uint32_t, char const *, size_t, char const *, size_t, tain const *, tain *) ; #define skaclient_start_b(a, sb, path, options, before, beforelen, after, afterlen, deadline, stamp) skaclient_start(a, (sb)->bufs, sizeof((sb)->bufs), (sb)->auxbufs, sizeof((sb)->auxbufs), (sb)->bufa, sizeof((sb)->bufa), (sb)->auxbufa, sizeof((sb)->auxbufa), (sb)->q, sizeof((sb)->q) / sizeof(kolbak_closure), path, options, before, beforelen, after, afterlen, deadline, stamp) #define skaclient_start_g(a, bufs, bufsn, auxbufs, auxbufsn, bufa, bufan, auxbufa, auxbufan, q, qlen, path, options, before, beforelen, after, afterlen, deadline) skaclient_start(a, bufs, bufsn, auxbufs, auxbufsn, bufa, bufan, auxbufa, auxbufan, q, qlen, path, options, before, beforelen, after, afterlen, (deadline), &STAMP) #define skaclient_start_b_g(a, sb, path, options, before, beforelen, after, afterlen, deadline) skaclient_start_b(a, sb, path, options, before, beforelen, after, afterlen, (deadline), &STAMP) extern int skaclient_startf (skaclient *, char *, size_t, char *, size_t, char *, size_t, char *, size_t, kolbak_closure *, size_t, char const *, char const *const *, char const *const *, uint32_t, char const *, size_t, char const *, size_t, tain const *, tain *) ; #define skaclient_startf_b(a, sb, prog, argv, envp, options, before, beforelen, after, afterlen, deadline, stamp) skaclient_startf(a, (sb)->bufs, sizeof((sb)->bufs), (sb)->auxbufs, sizeof((sb)->auxbufs), (sb)->bufa, sizeof((sb)->bufa), (sb)->auxbufa, sizeof((sb)->auxbufa), (sb)->q, sizeof((sb)->q) / sizeof(kolbak_closure), prog, argv, envp, options, before, beforelen, after, afterlen, deadline, stamp) #define skaclient_startf_g(a, bufs, bufsn, auxbufs, auxbufsn, bufa, bufan, auxbufa, auxbufan, q, qlen, prog, argv, envp, options, before, beforelen, after, afterlen, deadline) skaclient_startf(a, bufs, bufsn, auxbufs, auxbufsn, bufa, bufan, auxbufa, auxbufan, q, qlen, prog, argv, envp, options, before, beforelen, after, afterlen, (deadline), &STAMP) #define skaclient_startf_b_g(a, sb, prog, argv, envp, options, before, beforelen, after, afterlen, deadline) skaclient_startf_b(a, sb, prog, argv, envp, options, before, beforelen, after, afterlen, (deadline), &STAMP) /* Writing */ extern int skaclient_putmsg_and_close (skaclient *, unixmessage const *, unsigned char const *, unixmessage_handler_func_ref, void *) ; #define skaclient_putmsg(a, m, cb, result) skaclient_putmsg_and_close(a, m, unixmessage_bits_closenone, cb, result) extern int skaclient_putmsgv_and_close (skaclient *, unixmessagev const *, unsigned char const *, unixmessage_handler_func_ref, void *) ; #define skaclient_putmsgv(a, m, cb, result) skaclient_putmsgv_and_close(a, m, unixmessage_bits_closenone, cb, result) extern int skaclient_put (skaclient *, char const *, size_t, unixmessage_handler_func_ref, void *) ; extern int skaclient_putv (skaclient *, struct iovec const *, unsigned int, unixmessage_handler_func_ref, void *) ; /* Writing and flushing */ extern int skaclient_sendmsg_and_close (skaclient *, unixmessage const *, unsigned char const *, unixmessage_handler_func_ref, void *, tain const *, tain *) ; #define skaclient_sendmsg_and_close_g(a, m, bits, cb, result, deadline) skaclient_sendmsg_and_close(a, m, bits, cb, result, (deadline), &STAMP) #define skaclient_sendmsg(a, m, cb, result, deadline, stamp) skaclient_sendmsg_and_close(a, m, unixmessage_bits_closenone, cb, result, deadline, stamp) #define skaclient_sendmsg_g(a, m, cb, result, deadline) skaclient_sendmsg(a, m, cb, result, (deadline), &STAMP) extern int skaclient_sendmsgv_and_close (skaclient *, unixmessagev const *, unsigned char const *, unixmessage_handler_func_ref, void *, tain const *, tain *) ; #define skaclient_sendmsgv_and_close_g(a, m, bits, cb, result, deadline) skaclient_sendmsgv_and_close(a, m, bits, cb, result, (deadline), &STAMP) #define skaclient_sendmsgv(a, m, cb, result, deadline, stamp) skaclient_sendmsgv_and_close(a, m, unixmessage_bits_closenone, cb, result, deadline, stamp) #define skaclient_sendmsgv_g(a, m, cb, result, deadline) skaclient_sendmsgv(a, m, cb, result, (deadline), &STAMP) extern int skaclient_send (skaclient *, char const *, size_t, unixmessage_handler_func_ref, void *, tain const *, tain *) ; #define skaclient_send_g(a, s, len, cb, result, deadline) skaclient_send(a, s, len, cb, result, (deadline), &STAMP) extern int skaclient_sendv (skaclient *, struct iovec const *, unsigned int, unixmessage_handler_func_ref, void *, tain const *, tain *) ; #define skaclient_sendv_g(a, v, vlen, cb, result, deadline) skaclient_sendv(a, v, vlen, cb, result, (deadline), &STAMP) /* Helpers for full async */ #define skaclient_sfd(a) unixmessage_receiver_fd(&(a)->syncin) #define skaclient_siswritable(a) (!unixmessage_sender_isempty(&(a)->syncout)) #define skaclient_flush(a) unixmessage_sender_flush(&(a)->syncout) #define skaclient_timed_flush(a, deadline, stamp) unixmessage_sender_timed_flush(&(a)->syncout, deadline, stamp) #define skaclient_timed_flush_g(a, deadline) skaclient_timed_flush(a, (deadline), &STAMP) #define skaclient_supdate(a) unixmessage_handle(&(a)->syncin, (unixmessage_handler_func_ref)&kolbak_call, &(a)->kq) #define skaclient_timed_supdate(a, deadline, stamp) unixmessage_timed_handle(&(a)->syncin, (unixmessage_handler_func_ref)&kolbak_call, &(a)->kq, deadline, stamp) #define skaclient_timed_supdate_g(a, deadline) skaclient_timed_supdate(a, (deadline), &STAMP) extern int skaclient_syncify (skaclient *, tain const *, tain *) ; #define skaclient_fd(a) skaclient_afd(a) #define skaclient_afd(a) unixmessage_receiver_fd(&(a)->asyncin) #define skaclient_update(a, f, p) skaclient_aupdate(a, f, p) #define skaclient_aupdate(a, f, p) unixmessage_handle(&(a)->asyncin, f, p) extern unixmessage_handler_func skaclient_default_cb ; /* When asyncout is actually used (skabus...) */ #define skaclient_aiswritable(a) (!unixmessage_sender_isempty(&(a)->asyncout)) #define skaclient_aput_and_close(a, m, bits) unixmessage_put_and_close(&(a)->asyncout, m, bits) #define skaclient_aputv_and_close(a, m, bits) unixmessage_putv_and_close(&(a)->asyncout, m, bits) #define skaclient_aput(a, m) unixmessage_put(&(a)->asyncout, m) #define skaclient_aputv(a, m) unixmessage_putv(&(a)->asyncout, m) #define skaclient_aflush(a) unixmessage_sender_flush(&(a)->asyncout) #define skaclient_timed_aflush(a, deadline, stamp) unixmessage_sender_timed_flush(&(a)->asyncout, deadline, stamp) #define skaclient_timed_aflush_g(a, deadline) skaclient_timed_aflush(a, (deadline), &STAMP) #endif skalibs-2.14.1.1/src/include/skalibs/skalibs.h000066400000000000000000000013611455624754300210510ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_H #define SKALIBS_H /* This header is heavy! It includes everything in skalibs except: - skalibs/config.h: package configuration - skalibs/sysdeps.h: system-dependent feature test macros - skalibs/nonposix.h: pre-system headers definitions for POSIX extensions - skalibs/bsdsnowflake.h: pre-system headers BSD-specific workarounds - skalibs/nsig.h: SKALIBS_NSIG definition, requires nonposix - skalibs/posixishard.h: post-system headers workarounds for conformance failures */ #include #include #include #include #include #include #include #endif skalibs-2.14.1.1/src/include/skalibs/skamisc.h000066400000000000000000000037541455624754300210630ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_SKAMISC_H #define SKALIBS_SKAMISC_H #include #include #include extern stralloc satmp ; extern int skagetln (buffer *, stralloc *, char) ; extern int skagetln_loose (buffer *, stralloc *, char) ; extern int skagetln_nofill (buffer *, stralloc *, char) ; extern int skagetlnsep (buffer *, stralloc *, char const *, size_t) ; extern int skagetlnsep_loose (buffer *, stralloc *, char const *, size_t) ; extern int skagetlnmaxsep (buffer *, stralloc *, size_t, char const *, size_t) ; extern int getlnmax (buffer *, char *, size_t, size_t *, char) ; extern int getlnmaxsep (buffer *, char *, size_t, size_t *, char const *, size_t) ; extern int sauniquename (stralloc *) ; extern int string_quote_options (stralloc *, char const *, size_t, uint32_t) ; #define string_quote(sa, s, len) string_quote_options(sa, s, (len), 0) #define string_quote_nospace(sa, s, len) string_quote_options(sa, s, (len), 1) #define string_quotes(sa, s) string_quote(sa, (s), strlen(s)) extern int string_quote_nodelim_mustquote_options (stralloc *, char const *, size_t, char const *, size_t, uint32_t) ; #define string_quote_nodelim_mustquote(sa, s, len, delim, delimlen) string_quote_nodelim_mustquote_options(sa, s, len, delim, (delimlen), 0) #define string_quote_nodelim_mustquote_nospace(sa, s, len, delim, delimlen) string_quote_nodelim_mustquote_options(sa, s, len, delim, (delimlen), 1) #define string_quote_nodelim(sa, s, len) string_quote_nodelim_mustquote(sa, s, (len), "\"", 1) #define string_quote_nodelim_nospace(sa, s, len) string_quote_nodelim_mustquote_nospace(sa, s, (len), "\"", 1) extern int string_unquote (char *, size_t *, char const *, size_t, size_t *) ; extern ssize_t string_unquote_nodelim (char *, char const *, size_t) ; extern int string_unquote_withdelim (char *, size_t *, char const *, size_t, size_t *, char const *, size_t) ; extern int string_format (stralloc *, char const *, char const *, char const *const *) ; #endif skalibs-2.14.1.1/src/include/skalibs/socket.h000066400000000000000000000212531455624754300207130ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_SOCKET_H #define SKALIBS_SOCKET_H #include #include #include #include #include #include typedef ssize_t socket_io_func (int, char *, size_t, char *, uint16_t *) ; typedef socket_io_func *socket_io_func_ref ; typedef ssize_t socket_iow_func (int, char const *, size_t, char const *, uint16_t) ; typedef socket_iow_func *socket_iow_func_ref ; extern int socket_internal (int, int, int, unsigned int) ; extern int socketpair_internal (int, int, int, unsigned int, int *) ; /* UNIX domain sockets */ #define IPCPATH_MAX 107 #define ipc_stream() ipc_stream_nb() #define ipc_stream_b() ipc_stream_internal(0) #define ipc_stream_nb() ipc_stream_internal(O_NONBLOCK) #define ipc_stream_coe() ipc_stream_internal(O_CLOEXEC) #define ipc_stream_nbcoe() ipc_stream_internal(O_NONBLOCK|O_CLOEXEC) extern int ipc_stream_internal (unsigned int) ; #define ipc_datagram() ipc_datagram_nb() #define ipc_datagram_b() ipc_datagram_internal(0) #define ipc_datagram_nb() ipc_datagram_internal(O_NONBLOCK) #define ipc_datagram_coe() ipc_datagram_internal(O_CLOEXEC) #define ipc_datagram_nbcoe() ipc_datagram_internal(O_NONBLOCK|O_CLOEXEC) extern int ipc_datagram_internal (unsigned int) ; #define ipc_pair(sv) ipc_pair_nb(sv) #define ipc_pair_b(sv) ipc_pair_internal((sv), 0) #define ipc_pair_nb(sv) ipc_pair_internal((sv), O_NONBLOCK) #define ipc_pair_coe(sv) ipc_pair_internal((sv), O_CLOEXEC) #define ipc_pair_nbcoe(sv) ipc_pair_internal((sv), O_NONBLOCK|O_CLOEXEC) extern int ipc_pair_internal (int *, unsigned int) ; extern int ipc_bind (int, char const *) ; extern int ipc_bind_reuse (int, char const *) ; #define ipc_bind_reuse_lock(fd, path, fdlock) ipc_bind_reuse_lock_perms(fd, path, (fdlock), 0) extern int ipc_bind_reuse_perms (int, char const *, unsigned int) ; extern int ipc_bind_reuse_lock_perms (int, char const *, int *, unsigned int) ; extern int ipc_listen (int, int) ; #define ipc_accept(s, path, len, trunc) ipc_accept_internal(s, path, len, (trunc), 0) #define ipc_accept_nb(s, path, len, trunc) ipc_accept_internal(s, path, len, (trunc), O_NONBLOCK) #define ipc_accept_coe(s, path, len, trunc) ipc_accept_internal(s, path, len, (trunc), O_CLOEXEC) #define ipc_accept_nbcoe(s, path, len, trunc) ipc_accept_internal(s, path, len, (trunc), O_NONBLOCK|O_CLOEXEC) extern int ipc_accept_internal (int, char *, size_t, int *, unsigned int) ; extern int ipc_local (int, char *, size_t, int *) ; extern int ipc_connect (int, char const *) ; extern int ipc_connected (int) ; extern int ipc_timed_connect (int, char const *, tain const *, tain *) ; #define ipc_timed_connect_g(fd, path, deadline) ipc_timed_connect(fd, path, (deadline), &STAMP) extern ssize_t ipc_send (int, char const *, size_t, char const *) ; extern ssize_t ipc_recv (int, char *, size_t, char *) ; /* INET and INET6 domain sockets */ #define socket_tcp() socket_tcp4() #define socket_tcp_b() socket_tcp4_b() #define socket_tcp_nb() socket_tcp4_nb() #define socket_tcp_coe() socket_tcp4_coe() #define socket_tcp_nbcoe() socket_tcp4_nbcoe() #define socket_tcp4() socket_tcp4_nb() #define socket_tcp4_b() socket_tcp4_internal(0) #define socket_tcp4_nb() socket_tcp4_internal(O_NONBLOCK) #define socket_tcp4_coe() socket_tcp4_internal(O_CLOEXEC) #define socket_tcp4_nbcoe() socket_tcp4_internal(O_NONBLOCK|O_CLOEXEC) extern int socket_tcp4_internal (unsigned int) ; #define socket_tcp6() socket_tcp6_nb() #define socket_tcp6_b() socket_tcp6_internal(0) #define socket_tcp6_nb() socket_tcp6_internal(O_NONBLOCK) #define socket_tcp6_coe() socket_tcp6_internal(O_CLOEXEC) #define socket_tcp6_nbcoe() socket_tcp6_internal(O_NONBLOCK|O_CLOEXEC) extern int socket_tcp6_internal (unsigned int) ; #define socket_udp() socket_udp4() #define socket_udp_b() socket_udp4_b() #define socket_udp_nb() socket_udp4_nb() #define socket_udp_coe() socket_udp4_coe() #define socket_udp_nbcoe() socket_udp4_nbcoe() #define socket_udp4() socket_udp4_nb() #define socket_udp4_b() socket_udp4_internal(0) #define socket_udp4_nb() socket_udp4_internal(O_NONBLOCK) #define socket_udp4_coe() socket_udp4_internal(O_CLOEXEC) #define socket_udp4_nbcoe() socket_udp4_internal(O_NONBLOCK|O_CLOEXEC) extern int socket_udp4_internal (unsigned int) ; #define socket_udp6() socket_udp6_nb() #define socket_udp6_b() socket_udp6_internal(0) #define socket_udp6_nb() socket_udp6_internal(O_NONBLOCK) #define socket_udp6_coe() socket_udp6_internal(O_CLOEXEC) #define socket_udp6_nbcoe() socket_udp6_internal(O_NONBLOCK|O_CLOEXEC) extern int socket_udp6_internal (unsigned int) ; extern int socket_waitconn (int, tain const *, tain *) ; #define socket_waitconn_g(fd, deadline) socket_waitconn(fd, (deadline), &STAMP) extern int socket_deadlineconnstamp4 (int, char const *, uint16_t, tain const *, tain *) ; #define socket_deadlineconnstamp(s, ip, port, deadline, stamp) socket_deadlineconnstamp4(s, ip, port, deadline, stamp) #define socket_deadlineconnstamp4_g(fd, ip, port, deadline) socket_deadlineconnstamp4(fd, ip, port, (deadline), &STAMP) extern int socket_deadlineconnstamp4_u32 (int, uint32_t, uint16_t, tain const *, tain *) ; #define socket_deadlineconnstamp4_u32_g(fd, ip, port, deadline) socket_deadlineconnstamp4_u32(fd, ip, port, (deadline), &STAMP) extern int socket_timeoutconn (int, char const *, uint16_t, unsigned int) ; extern int socket_connect4 (int, char const *, uint16_t) ; extern int socket_connect4_u32 (int, uint32_t, uint16_t) ; extern int socket_connected (int) gccattr_const ; extern int socket_bind4 (int, char const *, uint16_t) ; extern int socket_bind4_reuse (int, char const *, uint16_t) ; #define socket_listen(fd, b) ipc_listen(fd, b) extern int socket_connect6 (int, char const *, uint16_t) ; extern int socket_deadlineconnstamp6 (int, char const *, uint16_t, tain const *, tain *) ; #define socket_deadlineconnstamp6_g(fd, ip6, port, deadline) socket_deadlineconnstamp6(fd, ip6, port, (deadline), &STAMP) extern int socket_bind6 (int, char const *, uint16_t) ; extern int socket_bind6_reuse (int, char const *, uint16_t) ; #define socket_accept4(s, ip, port) socket_accept4_internal(s, ip, (port), 0) #define socket_accept4_nb(s, ip, port) socket_accept4_internal(s, ip, (port), O_NONBLOCK) #define socket_accept4_coe(s, ip, port) socket_accept4_internal(s, ip, (port), O_CLOEXEC) #define socket_accept4_nbcoe(s, ip, port) socket_accept4_internal(s, ip, (port), O_NONBLOCK|O_CLOEXEC) extern int socket_accept4_internal (int, char *, uint16_t *, unsigned int) ; extern socket_io_func socket_recv4 ; extern socket_iow_func socket_send4 ; extern int socket_local4 (int, char *, uint16_t *) ; extern int socket_remote4 (int, char *, uint16_t *) ; #define socket_accept6(s, ip6, port) socket_accept6_internal(s, ip6, (port), 0) #define socket_accept6_nb(s, ip6, port) socket_accept6_internal(s, ip6, (port), O_NONBLOCK) #define socket_accept6_coe(s, ip6, port) socket_accept6_internal(s, ip6, (port), O_CLOEXEC) #define socket_accept6_nbcoe(s, ip6, port) socket_accept6_internal(s, ip6, (port), O_NONBLOCK|O_CLOEXEC) extern int socket_accept6_internal (int, char *, uint16_t *, unsigned int) ; extern socket_io_func socket_recv6 ; extern socket_iow_func socket_send6 ; extern int socket_local6 (int, char *, uint16_t *) ; extern int socket_remote6 (int, char *, uint16_t *) ; extern int socket_ipoptionskill (int) ; extern int socket_tcpnodelay (int) ; extern void socket_tryreservein (int, unsigned int) ; /* Timed send and recv operations (for dgram sockets) */ extern ssize_t socket_ioloop (int, char *, size_t, char *, uint16_t *, socket_io_func_ref, int, tain const *, tain *) ; extern socket_io_func socket_ioloop_send4 ; extern socket_io_func socket_ioloop_send6 ; #define socket_sendnb4(fd, buf, len, ip4, port, deadline, stamp) socket_ioloop(fd, buf, len, (char *)ip4, &(port), &socket_ioloop_send4, 1, deadline, stamp) #define socket_sendnb4_g(fd, buf, len, ip4, port, deadline) socket_sendnb4(fd, buf, len, ip4, port, (deadline), &STAMP) #define socket_recvnb4(fd, buf, len, ip4, port, deadline, stamp) socket_ioloop(fd, buf, len, ip4, port, &socket_recv4, 0, deadline, stamp) #define socket_recvnb4_g(fd, buf, len, ip4, port, deadline) socket_recvnb4(fd, buf, len, ip4, port, (deadline), &STAMP) #define socket_sendnb6(fd, buf, len, ip6, port, deadline, stamp) socket_ioloop(fd, buf, len, (char *)ip6, &(port), &socket_ioloop_send6, 1, deadline, stamp) #define socket_sendnb6_g(fd, buf, len, ip6, port, deadline) socket_sendnb6(fd, buf, len, ip6, port, (deadline), &STAMP) #define socket_recvnb6(fd, buf, len, ip6, port, deadline, stamp) socket_ioloop(fd, buf, len, ip6, port, &socket_recv6, 0, deadline, stamp) #define socket_recvnb6_g(fd, buf, len, ip6, port, deadline) socket_recvnb6(fd, buf, len, ip6, port, (deadline), &STAMP) #endif skalibs-2.14.1.1/src/include/skalibs/stat.h000066400000000000000000000007521455624754300203770ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_STAT_H #define SKALIBS_STAT_H /* This header must always be paired with skalibs/bsdsnowflake.h (which must always come first). If you #include before bsdsnowflake, the workaround will not work. */ #include #include #if !defined(SKALIBS_HASSTATIM) && defined(SKALIBS_HASSTATIMESPEC) #define st_atim st_atimespec #define st_mtim st_mtimespec #define st_ctim st_ctimespec #endif #endif skalibs-2.14.1.1/src/include/skalibs/stdcrypto.h000066400000000000000000000003041455624754300214500ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_STDCRYPTO_H #define SKALIBS_STDCRYPTO_H #include #include #include #include #endif skalibs-2.14.1.1/src/include/skalibs/stddjb.h000066400000000000000000000025151455624754300206750ustar00rootroot00000000000000/* ISC license. */ #ifndef STDDJB_H #define STDDJB_H #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #endif skalibs-2.14.1.1/src/include/skalibs/stralloc.h000066400000000000000000000031401455624754300212410ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_STRALLOC_H #define SKALIBS_STRALLOC_H #include #include typedef struct stralloc_s stralloc, *stralloc_ref ; struct stralloc_s { char *s ; size_t len ; size_t a ; } ; #define STRALLOC_ZERO { 0, 0, 0 } extern stralloc const stralloc_zero ; extern int stralloc_ready_tuned (stralloc *, size_t, size_t, size_t, size_t) ; extern int stralloc_readyplus_tuned (stralloc *, size_t, size_t, size_t, size_t) ; #define stralloc_ready(sa, n) stralloc_ready_tuned(sa, (n), 8, 1, 8) #define stralloc_readyplus(sa, n) stralloc_readyplus_tuned(sa, (n), 8, 1, 8) extern void stralloc_free (stralloc *) ; extern int stralloc_shrink (stralloc *) ; extern int stralloc_copyb (stralloc *, char const *, size_t) ; extern int stralloc_catb (stralloc *, char const *, size_t) ; extern int stralloc_catv (stralloc *, struct iovec const *, unsigned int) ; #define stralloc_copys(sa, s) stralloc_copyb(sa, (s), strlen(s)) #define stralloc_cats(sa, s) stralloc_catb(sa, (s), strlen(s)) #define stralloc_copy(sa1, sa2) stralloc_copyb(sa1, (sa2)->s, (sa2)->len) #define stralloc_cat(sa1, sa2) stralloc_catb(sa1, (sa2)->s, (sa2)->len) extern int stralloc_append (stralloc *, char) ; extern void stralloc_reverse (stralloc *) ; extern void stralloc_reverse_blocks (stralloc *, size_t) ; #define stralloc_0(sa) stralloc_catb(sa, "", 1) extern int stralloc_insertb (stralloc *, size_t, char const *, size_t) ; #define stralloc_inserts(sa, offset, s) stralloc_insertb(sa, offset, (s), strlen(s)) #define stralloc_insert(sa1, offset, sa2) stralloc_insertb(sa1, offset, (sa2)->s, (sa2)->len) #endif skalibs-2.14.1.1/src/include/skalibs/strerr.h000066400000000000000000000541541455624754300207520ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_STRERR_H #define SKALIBS_STRERR_H #include extern void strerr_warnv (char const *const *, unsigned int) ; extern void strerr_warnvsys (char const *const *, unsigned int) ; extern void strerr_diev (int, char const *const *, unsigned int) gccattr_noreturn ; extern void strerr_dievsys(int, char const *const *, unsigned int) gccattr_noreturn ; #define strerr_array(...) ((char const *const[]){__VA_ARGS__}) #define strerr_warnn(n, ...) strerr_warnv(strerr_array(__VA_ARGS__), (n)) #define strerr_warnnsys(n, ...) strerr_warnvsys(strerr_array(__VA_ARGS__), (n)) #define strerr_dien(e, n, ...) strerr_diev(e, strerr_array(__VA_ARGS__), (n)) #define strerr_diensys(e, n, ...) strerr_dievsys(e, strerr_array(__VA_ARGS__), (n)) #define strerr_warn(...) strerr_warnn(sizeof(strerr_array(__VA_ARGS__))/sizeof(char const *), __VA_ARGS__) #define strerr_warnsys(...) strerr_warnnsys(sizeof(strerr_array(__VA_ARGS__))/sizeof(char const *), __VA_ARGS__) #define strerr_die(e, ...) strerr_dien(e, sizeof(strerr_array(__VA_ARGS__))/sizeof(char const *), __VA_ARGS__) #define strerr_diesys(e, ...) strerr_diensys(e, sizeof(strerr_array(__VA_ARGS__))/sizeof(char const *), __VA_ARGS__) extern char const *PROG ; #define strerr_warnwn(n, ...) strerr_warnn((n)+2, PROG, ": warning: ", __VA_ARGS__) #define strerr_warnwnsys(n, ...) strerr_warnnsys((n)+2, PROG, ": warning: ", __VA_ARGS__) #define strerr_warnfn(n, ...) strerr_warnn((n)+2, PROG, ": fatal: ", __VA_ARGS__) #define strerr_warnfnsys(n, ...) strerr_warnnsys((n)+2, PROG, ": fatal: ", __VA_ARGS__) #define strerr_diewn(e, n, ...) strerr_dien(e, (n)+2, PROG, ": warning: ", __VA_ARGS__) #define strerr_diewnsys(e, n, ...) strerr_diensys(e, (n)+2, PROG, ": warning: ", __VA_ARGS__) #define strerr_diefn(e, n, ...) strerr_dien(e, (n)+2, PROG, ": fatal: ", __VA_ARGS__) #define strerr_diefnsys(e, n, ...) strerr_diensys(e, (n)+2, PROG, ": fatal: ", __VA_ARGS__) #define strerr_warnw(...) strerr_warn(PROG, ": warning: ", __VA_ARGS__) #define strerr_warnwsys(...) strerr_warnsys(PROG, ": warning: ", __VA_ARGS__) #define strerr_warnf(...) strerr_warn(PROG, ": fatal: ", __VA_ARGS__) #define strerr_warnfsys(...) strerr_warnsys(PROG, ": fatal: ", __VA_ARGS__) #define strerr_diew(e, ...) strerr_die(e, PROG, ": warning: ", __VA_ARGS__) #define strerr_diewsys(e, ...) strerr_diesys(e, PROG, ": warning: ", __VA_ARGS__) #define strerr_dief(e, ...) strerr_die(e, PROG, ": fatal: ", __VA_ARGS__) #define strerr_diefsys(e, ...) strerr_diesys(e, PROG, ": fatal: ", __VA_ARGS__) #define strerr_warnwun(n, ...) strerr_warnwn((n)+1, "unable to ", __VA_ARGS__) #define strerr_warnwunsys(n, ...) strerr_warnwnsys((n)+1, "unable to ", __VA_ARGS__) #define strerr_warnfun(n, ...) strerr_warnfn((n)+1, "unable to ", __VA_ARGS__) #define strerr_warnfunsys(n, ...) strerr_warnfnsys((n)+1, "unable to ", __VA_ARGS__) #define strerr_diewun(e, n, ...) strerr_diewn(e, (n)+1, "unable to ", __VA_ARGS__) #define strerr_diewunsys(e, n, ...) strerr_diewnsys(e, (n)+1, "unable to ", __VA_ARGS__) #define strerr_diefun(e, n, ...) strerr_diefn(e, (n)+1, "unable to ", __VA_ARGS__) #define strerr_diefunsys(e, n, ...) strerr_diefnsys(e, (n)+1, "unable to ", __VA_ARGS__) #define strerr_warnwu(...) strerr_warnw("unable to ", __VA_ARGS__) #define strerr_warnwusys(...) strerr_warnwsys("unable to ", __VA_ARGS__) #define strerr_warnfu(...) strerr_warnf("unable to ", __VA_ARGS__) #define strerr_warnfusys(...) strerr_warnfsys("unable to ", __VA_ARGS__) #define strerr_diewu(e, ...) strerr_diew(e, "unable to ", __VA_ARGS__) #define strerr_diewusys(e, ...) strerr_diewsys(e, "unable to ", __VA_ARGS__) #define strerr_diefu(e, ...) strerr_dief(e, "unable to ", __VA_ARGS__) #define strerr_diefusys(e, ...) strerr_diefsys(e, "unable to ", __VA_ARGS__) #define strerr_warnin(n, ...) strerr_warnn((n)+2, PROG, ": info: ", __VA_ARGS__) #define strerr_warninsys(n, ...) strerr_warnnsys((n)+2, PROG, ": info: ", __VA_ARGS__) #define strerr_warntn(n, ...) strerr_warnn((n)+2, PROG, ": tracing: ", __VA_ARGS__) #define strerr_warntnsys(n, ...) strerr_warnnsys((n)+2, PROG, ": tracing: ", __VA_ARGS__) #define strerr_warni(...) strerr_warn(PROG, ": info: ", __VA_ARGS__) #define strerr_warnisys(...) strerr_warnsys(PROG, ": info: ", __VA_ARGS__) #define strerr_warnt(...) strerr_warn(PROG, ": tracing: ", __VA_ARGS__) #define strerr_warntsys(...) strerr_warnsys(PROG, ": tracing: ", __VA_ARGS__) #define strerr_dieusage(e, u) strerr_dien(e, 3, PROG, ": usage: ", u) #define strerr_dienotset(e, x) strerr_diefn(e, 2, (x), " not set") #define strerr_dieinvalid(e, x) strerr_diefn(e, 2, "invalid $", x) #define strerr_dieexec(e, x) strerr_diefunsys(e, 2, "exec ", x) /* compat */ #define strerr_warnw1x(x1) strerr_warnwn(1, x1) #define strerr_warnw2x(x1, x2) strerr_warnwn(2, x1, x2) #define strerr_warnw3x(x1, x2, x3) strerr_warnwn(3, x1, x2, x3) #define strerr_warnw4x(x1, x2, x3, x4) strerr_warnwn(4, x1, x2, x3, x4) #define strerr_warnw5x(x1, x2, x3, x4, x5) strerr_warnwn(5, x1, x2, x3, x4, x5) #define strerr_warnw6x(x1, x2, x3, x4, x5, x6) strerr_warnwn(6, x1, x2, x3, x4, x5, x6) #define strerr_warnw7x(x1, x2, x3, x4, x5, x6, x7) strerr_warnwn(7, x1, x2, x3, x4, x5, x6, x7) #define strerr_warnw8x(x1, x2, x3, x4, x5, x6, x7, x8) strerr_warnwn(8, x1, x2, x3, x4, x5, x6, x7, x8) #define strerr_warnw9x(x1, x2, x3, x4, x5, x6, x7, x8, x9) strerr_warnwn(9, x1, x2, x3, x4, x5, x6, x7, x8, x9) #define strerr_warnw10x(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) strerr_warnwn(10, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) #define strerr_warnw1sys(x1) strerr_warnwnsys(1, x1) #define strerr_warnw2sys(x1, x2) strerr_warnwnsys(2, x1, x2) #define strerr_warnw3sys(x1, x2, x3) strerr_warnwnsys(3, x1, x2, x3) #define strerr_warnw4sys(x1, x2, x3, x4) strerr_warnwnsys(4, x1, x2, x3, x4) #define strerr_warnw5sys(x1, x2, x3, x4, x5) strerr_warnwnsys(5, x1, x2, x3, x4, x5) #define strerr_warnw6sys(x1, x2, x3, x4, x5, x6) strerr_warnwnsys(6, x1, x2, x3, x4, x5, x6) #define strerr_warnw7sys(x1, x2, x3, x4, x5, x6, x7) strerr_warnwnsys(7, x1, x2, x3, x4, x5, x6, x7) #define strerr_warnw8sys(x1, x2, x3, x4, x5, x6, x7, x8) strerr_warnwnsys(8, x1, x2, x3, x4, x5, x6, x7, x8) #define strerr_warnw9sys(x1, x2, x3, x4, x5, x6, x7, x8, x9) strerr_warnwnsys(9, x1, x2, x3, x4, x5, x6, x7, x8, x9) #define strerr_warnw10sys(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) strerr_warnwnsys(10, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) #define strerr_warnf1x(x1) strerr_warnfn(1, x1) #define strerr_warnf2x(x1, x2) strerr_warnfn(2, x1, x2) #define strerr_warnf3x(x1, x2, x3) strerr_warnfn(3, x1, x2, x3) #define strerr_warnf4x(x1, x2, x3, x4) strerr_warnfn(4, x1, x2, x3, x4) #define strerr_warnf5x(x1, x2, x3, x4, x5) strerr_warnfn(5, x1, x2, x3, x4, x5) #define strerr_warnf6x(x1, x2, x3, x4, x5, x6) strerr_warnfn(6, x1, x2, x3, x4, x5, x6) #define strerr_warnf7x(x1, x2, x3, x4, x5, x6, x7) strerr_warnfn(7, x1, x2, x3, x4, x5, x6, x7) #define strerr_warnf8x(x1, x2, x3, x4, x5, x6, x7, x8) strerr_warnfn(8, x1, x2, x3, x4, x5, x6, x7, x8) #define strerr_warnf9x(x1, x2, x3, x4, x5, x6, x7, x8, x9) strerr_warnfn(9, x1, x2, x3, x4, x5, x6, x7, x8, x9) #define strerr_warnf10x(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) strerr_warnfn(10, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) #define strerr_warnf1sys(x1) strerr_warnfnsys(1, x1) #define strerr_warnf2sys(x1, x2) strerr_warnfnsys(2, x1, x2) #define strerr_warnf3sys(x1, x2, x3) strerr_warnfnsys(3, x1, x2, x3) #define strerr_warnf4sys(x1, x2, x3, x4) strerr_warnfnsys(4, x1, x2, x3, x4) #define strerr_warnf5sys(x1, x2, x3, x4, x5) strerr_warnfnsys(5, x1, x2, x3, x4, x5) #define strerr_warnf6sys(x1, x2, x3, x4, x5, x6) strerr_warnfnsys(6, x1, x2, x3, x4, x5, x6) #define strerr_warnf7sys(x1, x2, x3, x4, x5, x6, x7) strerr_warnfnsys(7, x1, x2, x3, x4, x5, x6, x7) #define strerr_warnf8sys(x1, x2, x3, x4, x5, x6, x7, x8) strerr_warnfnsys(8, x1, x2, x3, x4, x5, x6, x7, x8) #define strerr_warnf9sys(x1, x2, x3, x4, x5, x6, x7, x8, x9) strerr_warnfnsys(9, x1, x2, x3, x4, x5, x6, x7, x8, x9) #define strerr_warnf10sys(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) strerr_warnfnsys(10, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) #define strerr_diew1x(e, x1) strerr_diewn(e, 1, x1) #define strerr_diew2x(e, x1, x2) strerr_diewn(e, 2, x1, x2) #define strerr_diew3x(e, x1, x2, x3) strerr_diewn(e, 3, x1, x2, x3) #define strerr_diew4x(e, x1, x2, x3, x4) strerr_diewn(e, 4, x1, x2, x3, x4) #define strerr_diew5x(e, x1, x2, x3, x4, x5) strerr_diewn(e, 5, x1, x2, x3, x4, x5) #define strerr_diew6x(e, x1, x2, x3, x4, x5, x6) strerr_diewn(e, 6, x1, x2, x3, x4, x5, x6) #define strerr_diew7x(e, x1, x2, x3, x4, x5, x6, x7) strerr_diewn(e, 7, x1, x2, x3, x4, x5, x6, x7) #define strerr_diew8x(e, x1, x2, x3, x4, x5, x6, x7, x8) strerr_diewn(e, 8, x1, x2, x3, x4, x5, x6, x7, x8) #define strerr_diew9x(e, x1, x2, x3, x4, x5, x6, x7, x8, x9) strerr_diewn(e, 9, x1, x2, x3, x4, x5, x6, x7, x8, x9) #define strerr_diew10x(e, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) strerr_diewn(e, 10, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) #define strerr_diew1sys(e, x1) strerr_diewnsys(e, 1, x1) #define strerr_diew2sys(e, x1, x2) strerr_diewnsys(e, 2, x1, x2) #define strerr_diew3sys(e, x1, x2, x3) strerr_diewnsys(e, 3, x1, x2, x3) #define strerr_diew4sys(e, x1, x2, x3, x4) strerr_diewnsys(e, 4, x1, x2, x3, x4) #define strerr_diew5sys(e, x1, x2, x3, x4, x5) strerr_diewnsys(e, 5, x1, x2, x3, x4, x5) #define strerr_diew6sys(e, x1, x2, x3, x4, x5, x6) strerr_diewnsys(e, 6, x1, x2, x3, x4, x5, x6) #define strerr_diew7sys(e, x1, x2, x3, x4, x5, x6, x7) strerr_diewnsys(e, 7, x1, x2, x3, x4, x5, x6, x7) #define strerr_diew8sys(e, x1, x2, x3, x4, x5, x6, x7, x8) strerr_diewnsys(e, 8, x1, x2, x3, x4, x5, x6, x7, x8) #define strerr_diew9sys(e, x1, x2, x3, x4, x5, x6, x7, x8, x9) strerr_diewnsys(e, 9, x1, x2, x3, x4, x5, x6, x7, x8, x9) #define strerr_diew10sys(e, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) strerr_diewnsys(e, 10, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) #define strerr_dief1x(e, x1) strerr_diefn(e, 1, x1) #define strerr_dief2x(e, x1, x2) strerr_diefn(e, 2, x1, x2) #define strerr_dief3x(e, x1, x2, x3) strerr_diefn(e, 3, x1, x2, x3) #define strerr_dief4x(e, x1, x2, x3, x4) strerr_diefn(e, 4, x1, x2, x3, x4) #define strerr_dief5x(e, x1, x2, x3, x4, x5) strerr_diefn(e, 5, x1, x2, x3, x4, x5) #define strerr_dief6x(e, x1, x2, x3, x4, x5, x6) strerr_diefn(e, 6, x1, x2, x3, x4, x5, x6) #define strerr_dief7x(e, x1, x2, x3, x4, x5, x6, x7) strerr_diefn(e, 7, x1, x2, x3, x4, x5, x6, x7) #define strerr_dief8x(e, x1, x2, x3, x4, x5, x6, x7, x8) strerr_diefn(e, 8, x1, x2, x3, x4, x5, x6, x7, x8) #define strerr_dief9x(e, x1, x2, x3, x4, x5, x6, x7, x8, x9) strerr_diefn(e, 9, x1, x2, x3, x4, x5, x6, x7, x8, x9) #define strerr_dief10x(e, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) strerr_diefn(e, 10, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) #define strerr_dief1sys(e, x1) strerr_diefnsys(e, 1, x1) #define strerr_dief2sys(e, x1, x2) strerr_diefnsys(e, 2, x1, x2) #define strerr_dief3sys(e, x1, x2, x3) strerr_diefnsys(e, 3, x1, x2, x3) #define strerr_dief4sys(e, x1, x2, x3, x4) strerr_diefnsys(e, 4, x1, x2, x3, x4) #define strerr_dief5sys(e, x1, x2, x3, x4, x5) strerr_diefnsys(e, 5, x1, x2, x3, x4, x5) #define strerr_dief6sys(e, x1, x2, x3, x4, x5, x6) strerr_diefnsys(e, 6, x1, x2, x3, x4, x5, x6) #define strerr_dief7sys(e, x1, x2, x3, x4, x5, x6, x7) strerr_diefnsys(e, 7, x1, x2, x3, x4, x5, x6, x7) #define strerr_dief8sys(e, x1, x2, x3, x4, x5, x6, x7, x8) strerr_diefnsys(e, 8, x1, x2, x3, x4, x5, x6, x7, x8) #define strerr_dief9sys(e, x1, x2, x3, x4, x5, x6, x7, x8, x9) strerr_diefnsys(e, 9, x1, x2, x3, x4, x5, x6, x7, x8, x9) #define strerr_dief10sys(e, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) strerr_diefnsys(e, 10, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) #define strerr_warnwu1x(x1) strerr_warnwun(1, x1) #define strerr_warnwu2x(x1, x2) strerr_warnwun(2, x1, x2) #define strerr_warnwu3x(x1, x2, x3) strerr_warnwun(3, x1, x2, x3) #define strerr_warnwu4x(x1, x2, x3, x4) strerr_warnwun(4, x1, x2, x3, x4) #define strerr_warnwu5x(x1, x2, x3, x4, x5) strerr_warnwun(5, x1, x2, x3, x4, x5) #define strerr_warnwu6x(x1, x2, x3, x4, x5, x6) strerr_warnwun(6, x1, x2, x3, x4, x5, x6) #define strerr_warnwu7x(x1, x2, x3, x4, x5, x6, x7) strerr_warnwun(7, x1, x2, x3, x4, x5, x6, x7) #define strerr_warnwu8x(x1, x2, x3, x4, x5, x6, x7, x8) strerr_warnwun(8, x1, x2, x3, x4, x5, x6, x7, x8) #define strerr_warnwu9x(x1, x2, x3, x4, x5, x6, x7, x8, x9) strerr_warnwun(9, x1, x2, x3, x4, x5, x6, x7, x8, x9) #define strerr_warnwu10x(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) strerr_warnwun(10, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) #define strerr_warnwu1sys(x1) strerr_warnwunsys(1, x1) #define strerr_warnwu2sys(x1, x2) strerr_warnwunsys(2, x1, x2) #define strerr_warnwu3sys(x1, x2, x3) strerr_warnwunsys(3, x1, x2, x3) #define strerr_warnwu4sys(x1, x2, x3, x4) strerr_warnwunsys(4, x1, x2, x3, x4) #define strerr_warnwu5sys(x1, x2, x3, x4, x5) strerr_warnwunsys(5, x1, x2, x3, x4, x5) #define strerr_warnwu6sys(x1, x2, x3, x4, x5, x6) strerr_warnwunsys(6, x1, x2, x3, x4, x5, x6) #define strerr_warnwu7sys(x1, x2, x3, x4, x5, x6, x7) strerr_warnwunsys(7, x1, x2, x3, x4, x5, x6, x7) #define strerr_warnwu8sys(x1, x2, x3, x4, x5, x6, x7, x8) strerr_warnwunsys(8, x1, x2, x3, x4, x5, x6, x7, x8) #define strerr_warnwu9sys(x1, x2, x3, x4, x5, x6, x7, x8, x9) strerr_warnwunsys(9, x1, x2, x3, x4, x5, x6, x7, x8, x9) #define strerr_warnwu10sys(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) strerr_warnwunsys(10, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) #define strerr_warnfu1x(x1) strerr_warnfun(1, x1) #define strerr_warnfu2x(x1, x2) strerr_warnfun(2, x1, x2) #define strerr_warnfu3x(x1, x2, x3) strerr_warnfun(3, x1, x2, x3) #define strerr_warnfu4x(x1, x2, x3, x4) strerr_warnfun(4, x1, x2, x3, x4) #define strerr_warnfu5x(x1, x2, x3, x4, x5) strerr_warnfun(5, x1, x2, x3, x4, x5) #define strerr_warnfu6x(x1, x2, x3, x4, x5, x6) strerr_warnfun(6, x1, x2, x3, x4, x5, x6) #define strerr_warnfu7x(x1, x2, x3, x4, x5, x6, x7) strerr_warnfun(7, x1, x2, x3, x4, x5, x6, x7) #define strerr_warnfu8x(x1, x2, x3, x4, x5, x6, x7, x8) strerr_warnfun(8, x1, x2, x3, x4, x5, x6, x7, x8) #define strerr_warnfu9x(x1, x2, x3, x4, x5, x6, x7, x8, x9) strerr_warnfun(9, x1, x2, x3, x4, x5, x6, x7, x8, x9) #define strerr_warnfu10x(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) strerr_warnfun(10, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) #define strerr_warnfu1sys(x1) strerr_warnfunsys(1, x1) #define strerr_warnfu2sys(x1, x2) strerr_warnfunsys(2, x1, x2) #define strerr_warnfu3sys(x1, x2, x3) strerr_warnfunsys(3, x1, x2, x3) #define strerr_warnfu4sys(x1, x2, x3, x4) strerr_warnfunsys(4, x1, x2, x3, x4) #define strerr_warnfu5sys(x1, x2, x3, x4, x5) strerr_warnfunsys(5, x1, x2, x3, x4, x5) #define strerr_warnfu6sys(x1, x2, x3, x4, x5, x6) strerr_warnfunsys(6, x1, x2, x3, x4, x5, x6) #define strerr_warnfu7sys(x1, x2, x3, x4, x5, x6, x7) strerr_warnfunsys(7, x1, x2, x3, x4, x5, x6, x7) #define strerr_warnfu8sys(x1, x2, x3, x4, x5, x6, x7, x8) strerr_warnfunsys(8, x1, x2, x3, x4, x5, x6, x7, x8) #define strerr_warnfu9sys(x1, x2, x3, x4, x5, x6, x7, x8, x9) strerr_warnfunsys(9, x1, x2, x3, x4, x5, x6, x7, x8, x9) #define strerr_warnfu10sys(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) strerr_warnfunsys(10, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) #define strerr_diewu1x(e, x1) strerr_diewun(e, 1, x1) #define strerr_diewu2x(e, x1, x2) strerr_diewun(e, 2, x1, x2) #define strerr_diewu3x(e, x1, x2, x3) strerr_diewun(e, 3, x1, x2, x3) #define strerr_diewu4x(e, x1, x2, x3, x4) strerr_diewun(e, 4, x1, x2, x3, x4) #define strerr_diewu5x(e, x1, x2, x3, x4, x5) strerr_diewun(e, 5, x1, x2, x3, x4, x5) #define strerr_diewu6x(e, x1, x2, x3, x4, x5, x6) strerr_diewun(e, 6, x1, x2, x3, x4, x5, x6) #define strerr_diewu7x(e, x1, x2, x3, x4, x5, x6, x7) strerr_diewun(e, 7, x1, x2, x3, x4, x5, x6, x7) #define strerr_diewu8x(e, x1, x2, x3, x4, x5, x6, x7, x8) strerr_diewun(e, 8, x1, x2, x3, x4, x5, x6, x7, x8) #define strerr_diewu9x(e, x1, x2, x3, x4, x5, x6, x7, x8, x9) strerr_diewun(e, 9, x1, x2, x3, x4, x5, x6, x7, x8, x9) #define strerr_diewu10x(e, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) strerr_diewun(e, 10, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) #define strerr_diewu1sys(e, x1) strerr_diewunsys(e, 1, x1) #define strerr_diewu2sys(e, x1, x2) strerr_diewunsys(e, 2, x1, x2) #define strerr_diewu3sys(e, x1, x2, x3) strerr_diewunsys(e, 3, x1, x2, x3) #define strerr_diewu4sys(e, x1, x2, x3, x4) strerr_diewunsys(e, 4, x1, x2, x3, x4) #define strerr_diewu5sys(e, x1, x2, x3, x4, x5) strerr_diewunsys(e, 5, x1, x2, x3, x4, x5) #define strerr_diewu6sys(e, x1, x2, x3, x4, x5, x6) strerr_diewunsys(e, 6, x1, x2, x3, x4, x5, x6) #define strerr_diewu7sys(e, x1, x2, x3, x4, x5, x6, x7) strerr_diewunsys(e, 7, x1, x2, x3, x4, x5, x6, x7) #define strerr_diewu8sys(e, x1, x2, x3, x4, x5, x6, x7, x8) strerr_diewunsys(e, 8, x1, x2, x3, x4, x5, x6, x7, x8) #define strerr_diewu9sys(e, x1, x2, x3, x4, x5, x6, x7, x8, x9) strerr_diewunsys(e, 9, x1, x2, x3, x4, x5, x6, x7, x8, x9) #define strerr_diewu10sys(e, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) strerr_diewunsys(e, 10, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) #define strerr_diefu1x(e, x1) strerr_diefun(e, 1, x1) #define strerr_diefu2x(e, x1, x2) strerr_diefun(e, 2, x1, x2) #define strerr_diefu3x(e, x1, x2, x3) strerr_diefun(e, 3, x1, x2, x3) #define strerr_diefu4x(e, x1, x2, x3, x4) strerr_diefun(e, 4, x1, x2, x3, x4) #define strerr_diefu5x(e, x1, x2, x3, x4, x5) strerr_diefun(e, 5, x1, x2, x3, x4, x5) #define strerr_diefu6x(e, x1, x2, x3, x4, x5, x6) strerr_diefun(e, 6, x1, x2, x3, x4, x5, x6) #define strerr_diefu7x(e, x1, x2, x3, x4, x5, x6, x7) strerr_diefun(e, 7, x1, x2, x3, x4, x5, x6, x7) #define strerr_diefu8x(e, x1, x2, x3, x4, x5, x6, x7, x8) strerr_diefun(e, 8, x1, x2, x3, x4, x5, x6, x7, x8) #define strerr_diefu9x(e, x1, x2, x3, x4, x5, x6, x7, x8, x9) strerr_diefun(e, 9, x1, x2, x3, x4, x5, x6, x7, x8, x9) #define strerr_diefu10x(e, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) strerr_diefun(e, 10, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) #define strerr_diefu1sys(e, x1) strerr_diefunsys(e, 1, x1) #define strerr_diefu2sys(e, x1, x2) strerr_diefunsys(e, 2, x1, x2) #define strerr_diefu3sys(e, x1, x2, x3) strerr_diefunsys(e, 3, x1, x2, x3) #define strerr_diefu4sys(e, x1, x2, x3, x4) strerr_diefunsys(e, 4, x1, x2, x3, x4) #define strerr_diefu5sys(e, x1, x2, x3, x4, x5) strerr_diefunsys(e, 5, x1, x2, x3, x4, x5) #define strerr_diefu6sys(e, x1, x2, x3, x4, x5, x6) strerr_diefunsys(e, 6, x1, x2, x3, x4, x5, x6) #define strerr_diefu7sys(e, x1, x2, x3, x4, x5, x6, x7) strerr_diefunsys(e, 7, x1, x2, x3, x4, x5, x6, x7) #define strerr_diefu8sys(e, x1, x2, x3, x4, x5, x6, x7, x8) strerr_diefunsys(e, 8, x1, x2, x3, x4, x5, x6, x7, x8) #define strerr_diefu9sys(e, x1, x2, x3, x4, x5, x6, x7, x8, x9) strerr_diefunsys(e, 9, x1, x2, x3, x4, x5, x6, x7, x8, x9) #define strerr_diefu10sys(e, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) strerr_diefunsys(e, 10, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) #define strerr_warni1x(x1) strerr_warnin(1, x1) #define strerr_warni2x(x1, x2) strerr_warnin(2, x1, x2) #define strerr_warni3x(x1, x2, x3) strerr_warnin(3, x1, x2, x3) #define strerr_warni4x(x1, x2, x3, x4) strerr_warnin(4, x1, x2, x3, x4) #define strerr_warni5x(x1, x2, x3, x4, x5) strerr_warnin(5, x1, x2, x3, x4, x5) #define strerr_warni6x(x1, x2, x3, x4, x5, x6) strerr_warnin(6, x1, x2, x3, x4, x5, x6) #define strerr_warni7x(x1, x2, x3, x4, x5, x6, x7) strerr_warnin(7, x1, x2, x3, x4, x5, x6, x7) #define strerr_warni8x(x1, x2, x3, x4, x5, x6, x7, x8) strerr_warnin(8, x1, x2, x3, x4, x5, x6, x7, x8) #define strerr_warni9x(x1, x2, x3, x4, x5, x6, x7, x8, x9) strerr_warnin(9, x1, x2, x3, x4, x5, x6, x7, x8, x9) #define strerr_warni10x(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) strerr_warnin(10, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) #define strerr_warni1sys(x1) strerr_warninsys(1, x1) #define strerr_warni2sys(x1, x2) strerr_warninsys(2, x1, x2) #define strerr_warni3sys(x1, x2, x3) strerr_warninsys(3, x1, x2, x3) #define strerr_warni4sys(x1, x2, x3, x4) strerr_warninsys(4, x1, x2, x3, x4) #define strerr_warni5sys(x1, x2, x3, x4, x5) strerr_warninsys(5, x1, x2, x3, x4, x5) #define strerr_warni6sys(x1, x2, x3, x4, x5, x6) strerr_warninsys(6, x1, x2, x3, x4, x5, x6) #define strerr_warni7sys(x1, x2, x3, x4, x5, x6, x7) strerr_warninsys(7, x1, x2, x3, x4, x5, x6, x7) #define strerr_warni8sys(x1, x2, x3, x4, x5, x6, x7, x8) strerr_warninsys(8, x1, x2, x3, x4, x5, x6, x7, x8) #define strerr_warni9sys(x1, x2, x3, x4, x5, x6, x7, x8, x9) strerr_warninsys(9, x1, x2, x3, x4, x5, x6, x7, x8, x9) #define strerr_warni10sys(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) strerr_warninsys(10, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) #define strerr_warnt1x(x1) strerr_warntn(1, x1) #define strerr_warnt2x(x1, x2) strerr_warntn(2, x1, x2) #define strerr_warnt3x(x1, x2, x3) strerr_warntn(3, x1, x2, x3) #define strerr_warnt4x(x1, x2, x3, x4) strerr_warntn(4, x1, x2, x3, x4) #define strerr_warnt5x(x1, x2, x3, x4, x5) strerr_warntn(5, x1, x2, x3, x4, x5) #define strerr_warnt6x(x1, x2, x3, x4, x5, x6) strerr_warntn(6, x1, x2, x3, x4, x5, x6) #define strerr_warnt7x(x1, x2, x3, x4, x5, x6, x7) strerr_warntn(7, x1, x2, x3, x4, x5, x6, x7) #define strerr_warnt8x(x1, x2, x3, x4, x5, x6, x7, x8) strerr_warntn(8, x1, x2, x3, x4, x5, x6, x7, x8) #define strerr_warnt9x(x1, x2, x3, x4, x5, x6, x7, x8, x9) strerr_warntn(9, x1, x2, x3, x4, x5, x6, x7, x8, x9) #define strerr_warnt10x(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) strerr_warntn(10, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) #define strerr_warnt1sys(x1) strerr_warntnsys(1, x1) #define strerr_warnt2sys(x1, x2) strerr_warntnsys(2, x1, x2) #define strerr_warnt3sys(x1, x2, x3) strerr_warntnsys(3, x1, x2, x3) #define strerr_warnt4sys(x1, x2, x3, x4) strerr_warntnsys(4, x1, x2, x3, x4) #define strerr_warnt5sys(x1, x2, x3, x4, x5) strerr_warntnsys(5, x1, x2, x3, x4, x5) #define strerr_warnt6sys(x1, x2, x3, x4, x5, x6) strerr_warntnsys(6, x1, x2, x3, x4, x5, x6) #define strerr_warnt7sys(x1, x2, x3, x4, x5, x6, x7) strerr_warntnsys(7, x1, x2, x3, x4, x5, x6, x7) #define strerr_warnt8sys(x1, x2, x3, x4, x5, x6, x7, x8) strerr_warntnsys(8, x1, x2, x3, x4, x5, x6, x7, x8) #define strerr_warnt9sys(x1, x2, x3, x4, x5, x6, x7, x8, x9) strerr_warntnsys(9, x1, x2, x3, x4, x5, x6, x7, x8, x9) #define strerr_warnt10sys(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) strerr_warntnsys(10, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) #endif skalibs-2.14.1.1/src/include/skalibs/strerr2.h000066400000000000000000000002751455624754300210270ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_STRERR2_H #define SKALIBS_STRERR2_H #include #warning strerr2.h is now deprecated, use #include instead. #endif skalibs-2.14.1.1/src/include/skalibs/surf.h000066400000000000000000000013701455624754300204000ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_SURF_H #define SKALIBS_SURF_H #include #include typedef struct SURFSchedule SURFSchedule, *SURFSchedule_ref ; struct SURFSchedule { uint32_t seed[32] ; uint32_t in[12] ; uint32_t pos ; char out[32] ; } ; #define SURFSCHEDULE_ZERO { .seed = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, .in = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, .pos = 32, .out = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" } extern void surf_init (SURFSchedule *, char const *) ; /* 160 chars */ extern void surf (SURFSchedule *, char *, size_t) ; extern void autosurf (char *, size_t) ; extern void autosurf_name (char *, size_t) ; #endif skalibs-2.14.1.1/src/include/skalibs/tai.h000066400000000000000000000134571455624754300202070ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_TAI_H #define SKALIBS_TAI_H #include #include #include #include #include typedef struct tai_s tai, *tai_ref ; struct tai_s { uint64_t x ; } ; #define TAI_ZERO { 0 } #define TAI_MAGIC ((uint64_t)4611686018427387904ULL) #define TAI_EPOCH { TAI_MAGIC + 10UL } #define TAI_INFINITE_RELATIVE { (uint64_t)1 << 61 } #define TAI_INFINITE { TAI_MAGIC + ((uint64_t)1 << 61) } #define tai_sec(t) ((t)->x) extern int tai_u64 (tai *, uint64_t) ; #define tai_unix(t, u) tai_u64(t, (TAI_MAGIC + (u))) #define tai_uint(t, u) tai_u64(t, (uint64_t)(u)) extern int tai_now (tai *) ; #define tai_relative_from_time(t, u) ((t)->x = (uint64_t)(u), 1) #define tai_from_time(t, u) tai_unix(t, u) #define tai_from_time_sysclock(t, u) tai_from_sysclock(t, (uint64_t)(u) + TAI_MAGIC) extern int time_from_tai_relative (time_t *, tai const *) ; extern int time_from_tai (time_t *, tai const *) ; extern int time_sysclock_from_tai(time_t *, tai const *) ; extern int tai_from_sysclock (tai *, uint64_t) ; extern int sysclock_from_tai (uint64_t *, tai const *) ; #define tai_approx(t) ((double)(tai_sec(t))) extern int tai_add (tai *, tai const *, tai const *) ; extern int tai_sub (tai *, tai const *, tai const *) ; #define tai_less(t,u) (tai_sec(t) < tai_sec(u)) #define TAI_PACK 8 extern void tai_pack (char *, tai const *) ; extern void tai_unpack (char const *, tai *) ; extern void tai_pack_little (char *, tai const *) ; extern void tai_unpack_little (char const *, tai *) ; typedef struct tain_s tain, *tain_ref ; struct tain_s { tai sec ; uint32_t nano ; /* 0..999999999U */ } ; #define TAIN_ZERO { TAI_ZERO, 0 } #define TAIN_EPOCH { TAI_EPOCH, 0 } #define TAIN_INFINITE { TAI_INFINITE, 0 } #define TAIN_INFINITE_RELATIVE { TAI_INFINITE_RELATIVE, 0 } #define TAIN_NANO500 { TAI_ZERO, 500 } extern tain STAMP ; /* the global process wallclock */ extern tain const tain_zero ; extern tain const tain_infinite_relative ; extern tain const tain_infinite ; extern tain const tain_nano500 ; #define tain_sec(a) ((a)->sec) #define tain_secp(a) (&(a)->sec) #define tain_nano(a) ((a)->nano) extern int tain_relative_from_timeval (tain *, struct timeval const *) ; extern int tain_from_timeval (tain *, struct timeval const *) ; extern int tain_from_timeval_sysclock (tain *, struct timeval const *) ; extern int timeval_from_tain_relative (struct timeval *, tain const *) ; extern int timeval_from_tain (struct timeval *, tain const *) ; extern int timeval_sysclock_from_tain (struct timeval *, tain const *) ; extern int tain_relative_from_timespec (tain *, struct timespec const *) ; extern int tain_from_timespec (tain *, struct timespec const *) ; extern int tain_from_timespec_sysclock (tain *, struct timespec const *) ; extern int timespec_from_tain_relative (struct timespec *, tain const *) ; extern int timespec_from_tain (struct timespec *, tain const *) ; extern int timespec_sysclock_from_tain (struct timespec *, tain const *) ; typedef int tain_clockread_func (tain *) ; typedef tain_clockread_func *tain_clockread_func_ref ; extern int tain_from_sysclock (tain *, tain const *) ; extern int sysclock_from_tain (tain *, tain const *) ; extern tain_clockread_func sysclock_get ; extern tain_clockread_func tain_wallclock_read ; #define tain_wallclock_read_g() tain_wallclock_read(&STAMP) extern int tain_stopwatch_init (tain *, clock_t, tain *) ; extern int tain_stopwatch_read (tain *, clock_t, tain const *) ; #define tain_stopwatch_read_g(cl, offset) tain_stopwatch_read(&STAMP, (cl), offset) extern tain_clockread_func_ref tain_now ; #define tain_now_g() (*tain_now)(&STAMP) #define tain_copynow(t) (*(t) = STAMP) extern tain_clockread_func tain_now_set_wallclock ; #define tain_now_set_wallclock_g() tain_now_set_wallclock(&STAMP) extern tain_clockread_func tain_now_set_stopwatch ; #define tain_now_set_stopwatch_g() tain_now_set_stopwatch(&STAMP) extern int sysclock_set (tain const *) ; extern int tain_setnow (tain const *) ; extern double tain_approx (tain const *) gccattr_pure ; extern double tain_frac (tain const *) gccattr_pure ; extern int tain_from_millisecs (tain *, int) ; extern int tain_to_millisecs (tain const *) gccattr_pure ; extern int tain_add (tain *, tain const *, tain const *) ; #define tain_add_g(deadline, tto) tain_add(deadline, &STAMP, tto) extern int tain_addsec (tain *, tain const *, int) ; #define tain_addsec_g(deadline, n) tain_addsec(deadline, &STAMP, n) extern int tain_sub (tain *, tain const *, tain const *) ; extern int tain_less (tain const *, tain const *) gccattr_pure ; #define tain_future(deadline) tain_less(&STAMP, (deadline)) extern void tain_earliest1 (tain *, tain const *) ; extern void tain_earliestv (tain *, tain const *const *, unsigned int) ; #define tain_array(...) ((tain const *const[]){__VA_ARGS__}) #define tain_earliestn(t, n, ...) tain_earliestv(t, tain_array(__VA_ARGS__), (n)) #define tain_earliest(t, ...) tain_earliestn(t, sizeof(tain_array(__VA_ARGS__))/sizeof(tain const *), __VA_ARGS__) #define TAIN_PACK 12 extern void tain_pack (char *, tain const *) ; extern void tain_unpack (char const *, tain *) ; extern void tain_pack_little (char *, tain const *) ; extern void tain_unpack_little (char const *, tain *) ; #define TAIN_FMT 25 extern size_t tain_fmt (char *, tain const *) ; extern size_t tain_scan (char const *, tain *) ; #define TAIN_FMTFRAC 19 extern size_t tain_fmtfrac (char *, tain const *) ; #define tain_uint(a, u) tain_ulong(a, u) extern int tain_ulong (tain *, unsigned long) ; extern void tain_half (tain *, tain const *) ; #define TIMESTAMP (1 + (TAIN_PACK << 1)) extern size_t timestamp_fmt (char *, tain const *) ; extern size_t timestamp_scan (char const *, tain *) ; extern int timestamp_r (char *, tain *) ; extern int timestamp (char *) ; #define timestamp_g(s) timestamp_fmt((s), &STAMP) #endif skalibs-2.14.1.1/src/include/skalibs/textclient.h000066400000000000000000000155741455624754300216170ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_TEXTCLIENT_H #define SKALIBS_TEXTCLIENT_H #include #include #include #include #include #include /* This is a simpler, smaller version of skaclient for basic cases: - no fd-passing - no asyncout - no kolbak: client calls are always synchronous - fixed-size buffers included in the client structure */ #define TEXTCLIENT_BUFSIZE 4096 #define TEXTCLIENT_OPTION_WAITPID 0x00000001U /* Server-side functions */ extern int textclient_server_init (textmessage_receiver *, textmessage_sender *, textmessage_sender *, char const *, size_t, char const *, size_t, tain const *, tain *) ; extern int textclient_server_init_frompipe (textmessage_receiver *, textmessage_sender *, textmessage_sender *, char const *, size_t, char const *, size_t, tain const *, tain *) ; extern int textclient_server_init_fromsocket (textmessage_receiver *, textmessage_sender *, textmessage_sender *, char const *, size_t, char const *, size_t, tain const *, tain *) ; #define textclient_server_init_g(in, syncout, asyncout, before, beforelen, after, afterlen, deadline) textclient_server_init(in, syncout, asyncout, before, beforelen, after, afterlen, (deadline), &STAMP) #define textclient_server_init_frompipe_g(in, syncout, asyncout, before, beforelen, after, afterlen, deadline) textclient_server_init_frompipe(in, syncout, asyncout, before, beforelen, after, afterlen, (deadline), &STAMP) #define textclient_server_init_fromsocket_g(in, syncout, asyncout, before, beforelen, after, afterlen, deadline) textclient_server_init_fromsocket(in, syncout, asyncout, before, beforelen, after, afterlen, (deadline), &STAMP) #define textclient_server_01x_init(before, beforelen, after, afterlen, deadline, stamp) textclient_server_init(textmessage_receiver_0, textmessage_sender_1, textmessage_sender_x, before, beforelen, after, afterlen, deadline, stamp) #define textclient_server_01x_init_frompipe(before, beforelen, after, afterlen, deadline, stamp) textclient_server_init_frompipe(textmessage_receiver_0, textmessage_sender_1, textmessage_sender_x, before, beforelen, after, afterlen, deadline, stamp) #define textclient_server_01x_init_fromsocket(before, beforelen, after, afterlen, deadline, stamp) textclient_server_init_fromsocket(textmessage_receiver_0, textmessage_sender_1, textmessage_sender_x, before, beforelen, after, afterlen, deadline, stamp) #define textclient_server_01x_init_g(before, beforelen, after, afterlen, deadline) textclient_server_01x_init(before, beforelen, after, afterlen, (deadline), &STAMP) #define textclient_server_01x_init_frompipe_g(before, beforelen, after, afterlen, deadline) textclient_server_01x_init_frompipe(before, beforelen, after, afterlen, (deadline), &STAMP) #define textclient_server_01x_init_fromsocket_g(before, beforelen, after, afterlen, deadline) textclient_server_01x_init_fromsocket(before, beforelen, after, afterlen, (deadline), &STAMP) /* User structure */ typedef struct textclient_s textclient, *textclient_ref ; struct textclient_s { textmessage_sender syncout ; textmessage_receiver syncin ; textmessage_receiver asyncin ; pid_t pid ; uint32_t options ; char syncbuf[TEXTCLIENT_BUFSIZE] ; char asyncbuf[TEXTCLIENT_BUFSIZE] ; } ; #define TEXTCLIENT_ZERO { .syncout = TEXTMESSAGE_SENDER_ZERO, .syncin = TEXTMESSAGE_RECEIVER_ZERO, .asyncin = TEXTMESSAGE_RECEIVER_ZERO, .pid = 0, .options = 0 } extern textclient const textclient_zero ; /* Starting and ending */ extern void textclient_end (textclient *) ; extern int textclient_start (textclient *, char const *, uint32_t, char const *, size_t, char const *, size_t, tain const *, tain *) ; extern int textclient_startf (textclient *, char const *const *, char const *const *, uint32_t, char const *, size_t, char const *, size_t, tain const *, tain *) ; #define textclient_start_g(a, path, options, before, beforelen, after, afterlen, deadline) textclient_start(a, path, options, before, beforelen, after, afterlen, (deadline), &STAMP) #define textclient_startf_g(a, argv, envp, options, before, beforelen, after, afterlen, deadline) textclient_startf_b(a, argv, envp, options, before, beforelen, after, afterlen, (deadline), &STAMP) /* Writing */ #define textclient_put(a, s, len) textmessage_sender_put(&(a)->syncout, s, len) #define textclient_putv(a, v, n) textmessage_sender_putv(&(a)->syncout, v, n) #define textclient_flush(a) textmessage_sender_flush(&(a)->syncout) #define textclient_timed_flush(a, deadline, stamp) textmessage_sender_timed_flush(&(a)->syncout, deadline, stamp) #define textclient_timed_flush_g(a, deadline) textclient_timed_flush(a, (deadline), &STAMP) #define textclient_send(a, s, len) textmessage_send(&(a)->syncout, s, len) #define textclient_sendv(a, v, n) textmessage_sendv(&(a)->syncout, v, n) #define textclient_timed_send(a, s, len, deadline, stamp) textmessage_timed_send(&(a)->syncout, s, len, deadline, stamp) #define textclient_timed_sendv(a, v, n, deadline, stamp) textmessage_timed_sendv(&(a)->syncout, v, n, deadline, stamp) #define textclient_timed_send_g(a, s, len, deadline) textclient_timed_send(a, s, len, (deadline), &STAMP) #define textclient_timed_sendv_g(a, v, n, deadline) textclient_timed_sendv(a, v, n, (deadline), &STAMP) /* Sync reading */ #define textclient_get(a, v) textmessage_receive(&(a)->syncin, v) #define textclient_timed_get(a, v, deadline, stamp) (sanitize_read(textmessage_timed_receive(&(a)->syncin, v, deadline, stamp)) > 0) #define textclient_timed_get_g(a, v, deadline) textclient_timed_get(a, v, (deadline), &STAMP) /* Sync writing+reading */ #define textclient_exchange(a, s, len, ans, deadline, stamp) (textclient_timed_send(a, s, len, deadline, stamp) && textclient_timed_get(a, ans, deadline, stamp)) #define textclient_exchangev(a, v, n, ans, deadline, stamp) (textclient_timed_sendv(a, v, n, deadline, stamp) && textclient_timed_get(a, ans, deadline, stamp)) #define textclient_exchange_g(a, s, len, ans, deadline) textclient_exchange(a, s, len, ans, (deadline), &STAMP) #define textclient_exchangev_g(a, v, n, ans, deadline) textclient_exchangev(a, v, n, ans, (deadline), &STAMP) extern int textclient_command (textclient *, char const *, size_t, tain const *, tain *) ; extern int textclient_commandv (textclient *, struct iovec const *, unsigned int, tain const *, tain *) ; #define textclient_command_g(a, s, len, deadline) textclient_command(a, s, len, (deadline), &STAMP) #define textclient_commandv_g(a, v, n, deadline) textclient_commandv(a, v, n, (deadline), &STAMP) /* Async reading */ #define textclient_fd(a) textmessage_receiver_fd(&(a)->asyncin) #define textclient_update(a, f, p) textmessage_handle(&(a)->asyncin, f, p) #define textclient_timed_update(a, f, p, deadline, stamp) textmessage_timed_handle(&(a)->asyncin, f, p, deadline, stamp) #define textclient_timed_update_g(a, f, p, deadline) textclient_timed_update(a, f, p, (deadline), &STAMP) #endif skalibs-2.14.1.1/src/include/skalibs/textmessage.h000066400000000000000000000106311455624754300217520ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_TEXTMESSAGE_H #define SKALIBS_TEXTMESSAGE_H #include #include #include #include #include #include #include #include #define TEXTMESSAGE_MAXREADS 128 #define TEXTMESSAGE_MAXLEN 0x01000000U /* Sender */ typedef struct textmessage_sender_s textmessage_sender, *textmessage_sender_ref ; struct textmessage_sender_s { bufalloc out ; } ; #define TEXTMESSAGE_SENDER_ZERO { BUFALLOC_ZERO } extern textmessage_sender const textmessage_sender_zero ; #define TEXTMESSAGE_SENDER_INIT(fd) { BUFALLOC_INIT(&fd_write, (fd)) } #define textmessage_sender_init(ts, fd) bufalloc_init(&(ts)->out, &fd_write, fd) #define textmessage_sender_free(ts) bufalloc_free(&(ts)->out) #define textmessage_sender_fd(ts) bufalloc_fd(&(ts)->out) extern int textmessage_sender_getfd (textmessage_sender const *) gccattr_pure ; #define textmessage_sender_isempty(ts) bufalloc_isempty(&(ts)->out) extern int textmessage_put (textmessage_sender *, char const *, size_t) ; extern int textmessage_putv (textmessage_sender *, struct iovec const *, unsigned int) ; extern int textmessage_sender_flush (textmessage_sender *) ; extern int textmessage_sender_timed_flush (textmessage_sender *, tain const *, tain *) ; #define textmessage_sender_timed_flush_g(ts, deadline) textmessage_sender_timed_flush(ts, (deadline), &STAMP) #define textmessage_send(ts, s, len) (textmessage_put(ts, s, len) && textmessage_sender_flush(ts)) #define textmessage_sendv(ts, v, n) (textmessage_putv(ts, v, n) && textmessage_sender_flush(ts)) #define textmessage_timed_send(ts, s, len, deadline, stamp) (textmessage_put(ts, s, len) && textmessage_sender_timed_flush(ts, deadline, stamp)) #define textmessage_timed_sendv(ts, v, n, deadline, stamp) (textmessage_putv(ts, v, n) && textmessage_sender_timed_flush(ts, deadline, stamp)) #define textmessage_timed_send_g(ts, s, len, deadline) textmessage_timed_send(ts, s, len, (deadline), &STAMP) #define textmessage_timed_sendv_g(ts, v, n, deadline) textmessage_timed_sendv(ts, v, n, (deadline), &STAMP) /* Receiver */ typedef struct textmessage_receiver_s textmessage_receiver, *textmessage_receiver_ref ; struct textmessage_receiver_s { buffer in ; stralloc indata ; uint32_t wanted ; uint32_t max ; } ; #define TEXTMESSAGE_RECEIVER_ZERO { BUFFER_ZERO, STRALLOC_ZERO, 0, 0 } extern textmessage_receiver const textmessage_receiver_zero ; #define TEXTMESSAGE_RECEIVER_INIT(fd, buf, len, n) { BUFFER_INIT(&buffer_read, (fd), buf, len), STRALLOC_ZERO, 0, n } extern int textmessage_receiver_init (textmessage_receiver *, int, char *, size_t, uint32_t) ; extern void textmessage_receiver_free (textmessage_receiver *) ; #define textmessage_receiver_fd(tr) buffer_fd(&(tr)->in) #define textmessage_receiver_isempty(tr) buffer_isempty(&(tr)->in) #define textmessage_receiver_isfull(tr) buffer_isfull(&(tr)->in) extern int textmessage_receiver_hasmsginbuf (textmessage_receiver const *) gccattr_pure ; extern int textmessage_receive (textmessage_receiver *, struct iovec *) ; extern int textmessage_timed_receive (textmessage_receiver *, struct iovec *, tain const *, tain *) ; #define textmessage_timed_receive_g(tr, v, deadline) textmessage_timed_receive(tr, v, (deadline), &STAMP) typedef int textmessage_handler_func (struct iovec const *, void *) ; typedef textmessage_handler_func *textmessage_handler_func_ref ; extern int textmessage_handle (textmessage_receiver *, textmessage_handler_func_ref, void *) ; extern int textmessage_timed_handle (textmessage_receiver *, textmessage_handler_func_ref, void *, tain const *, tain *) ; #define textmessage_timed_handle_g(tr, f, p, deadline) textmessage_timed_handle(tr, f, p, (deadline), &STAMP) /* Creating new textmessage channels via fd-passing over a socket */ extern int textmessage_create_send_channel (int, textmessage_sender *, char const *, size_t, tain const *, tain *) ; extern int textmessage_recv_channel (int, textmessage_receiver *, char *, size_t, char const *, size_t, tain const *, tain *) ; /* Globals */ extern textmessage_receiver textmessage_receiver_0_ ; #define textmessage_receiver_0 (&textmessage_receiver_0_) extern textmessage_sender textmessage_sender_1_ ; #define textmessage_sender_1 (&textmessage_sender_1_) extern textmessage_sender textmessage_sender_x_ ; #define textmessage_sender_x (&textmessage_sender_x_) #endif skalibs-2.14.1.1/src/include/skalibs/unix-timed.h000066400000000000000000000054471455624754300215150ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_UNIX_TIMED_H #define SKALIBS_UNIX_TIMED_H #include #include #include #include #include #include #include /* Timed "blocking" operations (the fd must still be non-blocking) */ extern int timed_flush (void *, init_func_ref, init_func_ref, init_func_ref, tain const *, tain *) ; #define timed_flush_g(b, getfd, isnonempty, flush, deadline) timed_flush(b, getfd, isnonempty, flush, (deadline), &STAMP) extern ssize_t timed_get (void *, init_func_ref, get_func_ref, tain const *, tain *) ; #define timed_get_g (b, getfd, get, deadline) timed_get(b, getfd, get, (deadline), &STAMP) extern ssize_t buffer_timed_fill (buffer *, tain const *, tain *) ; #define buffer_timed_fill_g(b, deadline) buffer_timed_fill(b, (deadline), &STAMP) extern int bufalloc_timed_flush (bufalloc *, tain const *, tain *) ; #define bufalloc_timed_flush_g(ba, deadline) bufalloc_timed_flush(ba, (deadline), &STAMP) extern int buffer_timed_flush (buffer *, tain const *, tain *) ; #define buffer_timed_flush_g(b, deadline) buffer_timed_flush(b, (deadline), &STAMP) extern size_t buffer_timed_get (buffer *, char *, size_t, tain const *, tain *) ; #define buffer_timed_get_g(b, buf, buflen, deadline) buffer_timed_get(b, buf, buflen, (deadline), &STAMP) extern size_t buffer_timed_put (buffer *, char const *, size_t, tain const *, tain *) ; #define buffer_timed_put_g(b, s, len, deadline) buffer_timed_put(b, s, len, (deadline), &STAMP) extern size_t buffer_timed_puts (buffer *, char const *, tain const *, tain *) ; #define buffer_timed_puts_g(b, s, deadline) buffer_timed_puts(b, s, (deadline), &STAMP) extern int timed_getln (buffer *, stralloc *, char, tain const *, tain *) ; #define timed_getln_g(b, sa, sep, deadline) timed_getln(b, sa, sep, (deadline), &STAMP) extern ssize_t timed_getlnmax (buffer *, char *, size_t, size_t *, char, tain const *, tain *) ; #define timed_getlnmax_g(b, max, maxlen, len, sep, deadline) timed_getlnmax(b, max, maxlen, len, sep, (deadline), &STAMP) extern int netstring_timed_get (buffer *, stralloc *, tain const *, tain *) ; #define netstring_timed_get_g(b, sa, deadline) netstring_timed_get(b, sa, (deadline), &STAMP) extern int ipc_timed_send (int, char const *, size_t, tain const *, tain *) ; #define ipc_timed_send_g(fd, s, len, deadline) ipc_timed_send(fd, s, len, (deadline), &STAMP) extern int ipc_timed_sendv (int, struct iovec const *, unsigned int, tain const *, tain *) ; #define ipc_timed_sendv_g(fd, v, n, deadline) ipc_timed_sendv(fd, v, n, (deadline), &STAMP) extern ssize_t ipc_timed_recv (int, char *, size_t, char *, tain const *, tain *) ; #define ipc_timed_recv_g(fd, s, len, path, deadline) ipc_timed_recv(fd, s, len, path, (deadline), &STAMP) #endif skalibs-2.14.1.1/src/include/skalibs/unix-transactional.h000066400000000000000000000036561455624754300232550ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_UNIX_TRANSACTIONAL_H #define SKALIBS_UNIX_TRANSACTIONAL_H #include #include #include #include #include /* Transactional/reliable filesystem operations */ extern int opengetlnclose (char const *, stralloc *, int) ; extern int open2_at (int, char const *, int) ; extern int open3_at (int, char const *, int, unsigned int) ; extern int access_at (int, char const *, int, unsigned int) ; extern DIR *opendir_at (int, char const *) ; extern int stat_at (int, char const *, struct stat *) ; extern int lstat_at (int, char const *, struct stat *) ; extern int open_readat (int, char const *) ; extern int open_readatb (int, char const *) ; extern int open_writeat (int, char const *) ; extern int open_writeatb (int, char const *) ; extern int open_truncat (int, char const *) ; extern int open_truncatb (int, char const *) ; extern int open_appendat (int, char const *) ; extern int open_appendatb (int, char const *) ; extern int openc_readat (int, char const *) ; extern int openc_readatb (int, char const *) ; extern int openc_writeat (int, char const *) ; extern int openc_writeatb (int, char const *) ; extern int openc_truncat (int, char const *) ; extern int openc_truncatb (int, char const *) ; extern int openc_appendat (int, char const *) ; extern int openc_appendatb (int, char const *) ; extern ssize_t openreadnclose_at (int, char const *, char *, size_t) ; extern int openslurpclose_at (int, char const *, stralloc *) ; extern int opengetlnclose_at (int, char const *, stralloc *, int) ; extern size_t openwritenclose_at (int, char const *, char const *, size_t) ; extern size_t openwritevnclose_at (int, char const *, struct iovec const *, unsigned int) ; extern int atomic_rm_rf (char const *) ; extern int atomic_rm_rf_tmp (char const *, stralloc *) ; extern int atomic_symlink (char const *, char const *, char const *) ; #endif skalibs-2.14.1.1/src/include/skalibs/unixconnection.h000066400000000000000000000015711455624754300224670ustar00rootroot00000000000000 /* ISC license. */ #ifndef SKALIBS_UNIXCONNECTION_H #define SKALIBS_UNIXCONNECTION_H #include typedef struct unixconnection_s unixconnection, *unixconnection_ref ; struct unixconnection_s { unixmessage_sender out ; unixmessage_receiver in ; char mainbuf[UNIXMESSAGE_BUFSIZE] ; char auxbuf[UNIXMESSAGE_AUXBUFSIZE] ; } ; #define UNIXCONNECTION_ZERO { .out = UNIXMESSAGE_SENDER_ZERO, .in = UNIXMESSAGE_RECEIVER_ZERO } extern unixconnection const unixconnection_zero ; extern void unixconnection_init (unixconnection *, int, int) ; extern void unixconnection_init_withclosecb (unixconnection *, int, int, unixmessage_sender_closecb_func_ref, void *) ; extern void unixconnection_free (unixconnection *) ; #define unixconnection_flush(io) unixmessage_sender_flush(&(io)->out) #define unixconnection_receive(io, m) unixmessage_receive(&(io)->in, m) #endif skalibs-2.14.1.1/src/include/skalibs/unixmessage.h000066400000000000000000000137241455624754300217570ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_UNIXMESSAGE_H #define SKALIBS_UNIXMESSAGE_H #include #include #include #include #include #include #include #include /* Message */ typedef struct unixmessage_s unixmessage, *unixmessage_ref ; struct unixmessage_s { char *s ; size_t len ; int *fds ; unsigned int nfds ; } ; #define UNIXMESSAGE_ZERO { .s = 0, .len = 0, .fds = 0, .nfds = 0 } extern unixmessage const unixmessage_zero ; extern void unixmessage_drop (unixmessage const *) ; typedef struct unixmessagev_s unixmessagev, *unixmessagev_ref ; struct unixmessagev_s { struct iovec *v ; unsigned int vlen ; int *fds ; unsigned int nfds ; } ; #define UNIXMESSAGEV_ZERO { .v = 0, .vlen = 0, .fds = 0, .nfds = 0 } extern unixmessagev const unixmessagev_zero ; #define UNIXMESSAGE_MAXSIZE (1U << 28) #define UNIXMESSAGE_MAXFDS 255 #define UNIXMESSAGE_BUFSIZE 2048 #define UNIXMESSAGE_AUXBUFSIZE (sizeof(int) * UNIXMESSAGE_MAXFDS + 1) #define UNIXMESSAGE_MAXREADS 128 /* Sender */ typedef void unixmessage_sender_closecb_func (int, void *) ; typedef unixmessage_sender_closecb_func *unixmessage_sender_closecb_func_ref ; typedef struct unixmessage_sender_s unixmessage_sender, *unixmessage_sender_ref ; struct unixmessage_sender_s { int fd ; stralloc data ; genalloc fds ; /* int */ genalloc offsets ; /* disize */ size_t head ; size_t shorty ; unixmessage_sender_closecb_func_ref closecb ; void *closecbdata ; } ; #define UNIXMESSAGE_SENDER_ZERO UNIXMESSAGE_SENDER_INIT(-1) #define UNIXMESSAGE_SENDER_INIT(s) UNIXMESSAGE_SENDER_INIT_WITHCLOSECB((s), &unixmessage_sender_closecb, 0) #define UNIXMESSAGE_SENDER_INIT_WITHCLOSECB(s, f, p) { .fd = (s), .data = STRALLOC_ZERO, .fds = GENALLOC_ZERO, .offsets = GENALLOC_ZERO, .head = 0, .shorty = 0, .closecb = (f), .closecbdata = (p) } extern unixmessage_sender const unixmessage_sender_zero ; extern unixmessage_sender_closecb_func unixmessage_sender_closecb ; extern void unixmessage_sender_init (unixmessage_sender *, int) ; extern void unixmessage_sender_init_withclosecb (unixmessage_sender *, int, unixmessage_sender_closecb_func_ref, void *) ; extern void unixmessage_sender_free (unixmessage_sender *) ; #define unixmessage_sender_fd(b) ((b)->fd) extern int unixmessage_sender_getfd (unixmessage_sender const *) gccattr_pure ; #define unixmessage_sender_isempty(b) (!genalloc_len(unsigned int, &(b)->offsets)) extern int unixmessage_put_and_close (unixmessage_sender *, unixmessage const *, unsigned char const *) ; #define unixmessage_put(b, m) unixmessage_put_and_close(b, m, unixmessage_bits_closenone) extern int unixmessage_putv_and_close (unixmessage_sender *, unixmessagev const *, unsigned char const *) ; #define unixmessage_putv(b, m) unixmessage_putv_and_close(b, m, unixmessage_bits_closenone) extern int unixmessage_unput_and_maybe_drop (unixmessage_sender *, int) ; #define unixmessage_unput(b) unixmessage_unput_and_maybe_drop((b), 0) #define unixmessage_unput_and_drop(b) unixmessage_unput_and_maybe_drop((b), 1) extern unsigned char const *const unixmessage_bits_closenone ; extern unsigned char const *const unixmessage_bits_closeall ; extern int unixmessage_sender_flush (unixmessage_sender *) ; extern int unixmessage_sender_timed_flush (unixmessage_sender *, tain const *, tain *) ; #define unixmessage_sender_timed_flush_g(sender, deadline) unixmessage_sender_timed_flush(sender, (deadline), &STAMP) /* Receiver */ typedef struct unixmessage_receiver_s unixmessage_receiver, *unixmessage_receiver_ref ; struct unixmessage_receiver_s { int fd ; cbuffer mainb ; cbuffer auxb ; stralloc maindata ; stralloc auxdata ; uint32_t mainlen ; uint16_t auxlen ; unsigned int fds_ok : 2 ; } ; #define UNIXMESSAGE_RECEIVER_ZERO { .fd = -1, .mainb = CBUFFER_ZERO, .auxb = CBUFFER_ZERO, .maindata = STRALLOC_ZERO, .auxdata = STRALLOC_ZERO, .mainlen = 0, .auxlen = 0, .fds_ok = 3 } #define UNIXMESSAGE_RECEIVER_INIT(d, mains, mainn, auxs, auxn) \ { \ .fd = d, \ .mainb = CBUFFER_INIT(mains, mainn), \ .auxb = CBUFFER_INIT(auxs, auxn), \ .maindata = STRALLOC_ZERO, \ .auxdata = STRALLOC_ZERO, \ .mainlen = 0, \ .auxlen = 0, \ .fds_ok = 3 \ } extern int unixmessage_receiver_init (unixmessage_receiver *, int, char *, size_t, char *, size_t) ; extern void unixmessage_receiver_free (unixmessage_receiver *) ; #define unixmessage_receiver_fd(b) ((b)->fd) #define unixmessage_receiver_isempty(b) (cbuffer_isempty(&(b)->mainb) && cbuffer_isempty(&(b)->auxb)) #define unixmessage_receiver_isfull(b) (cbuffer_isfull(&(b)->mainb) || cbuffer_isfull(&(b)->auxb)) extern int unixmessage_receiver_hasmsginbuf (unixmessage_receiver const *) ; extern int unixmessage_receive (unixmessage_receiver *, unixmessage *) ; extern int unixmessage_timed_receive (unixmessage_receiver *, unixmessage *, tain const *, tain *) ; #define unixmessage_timed_receive_g(receiver, msg, deadline) unixmessage_timed_receive(receiver, msg, (deadline), &STAMP) #define unixmessage_receiver_accept_fds(b) ((b)->fds_ok = 3) #define unixmessage_receiver_refuse_fds(b) ((b)->fds_ok = 1) #define unixmessage_receiver_ignore_fds(b) ((b)->fds_ok = 0) typedef int unixmessage_handler_func (unixmessage const *, void *) ; typedef unixmessage_handler_func *unixmessage_handler_func_ref ; extern int unixmessage_handle (unixmessage_receiver *, unixmessage_handler_func_ref, void *) ; extern int unixmessage_timed_handle (unixmessage_receiver *, unixmessage_handler_func_ref, void *, tain const *, tain *) ; #define unixmessage_timed_handle_g(b, f, p, deadline) unixmessage_timed_handle(b, f, p, (deadline), &STAMP) /* Globals */ extern unixmessage_receiver unixmessage_receiver_0_ ; #define unixmessage_receiver_0 (&unixmessage_receiver_0_) extern unixmessage_sender unixmessage_sender_1_ ; #define unixmessage_sender_1 (&unixmessage_sender_1_) extern unixmessage_sender unixmessage_sender_x_ ; #define unixmessage_sender_x (&unixmessage_sender_x_) #endif skalibs-2.14.1.1/src/include/skalibs/unixonacid.h000066400000000000000000000005731455624754300215660ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_UNIXONACID_H #define SKALIBS_UNIXONACID_H #include #include #include #include #include #include #include #include #include #endif skalibs-2.14.1.1/src/libdatastruct/000077500000000000000000000000001455624754300170415ustar00rootroot00000000000000skalibs-2.14.1.1/src/libdatastruct/avlnode-internal.h000066400000000000000000000007571455624754300224650ustar00rootroot00000000000000/* ISC license. */ #ifndef AVLNODE_INTERNAL_H #define AVLNODE_INTERNAL_H #include #include #define avlnode_ufroms(c) ((c) > 0) #define avlnode_sfromu(h) ((h) ? 1 : -1) extern uint32_t avlnode_rotate (avlnode *, uint32_t, uint32_t, int) ; extern uint32_t avlnode_doublerotate (avlnode *, uint32_t, uint32_t, int) ; #define avlnode_rotate_maydouble(s, max, r, h, isdouble) ((isdouble) ? avlnode_doublerotate(s, max, r, h) : avlnode_rotate(s, max, r, h)) #endif skalibs-2.14.1.1/src/libdatastruct/avlnode_delete.c000066400000000000000000000033601455624754300221610ustar00rootroot00000000000000/* ISC license. */ #include #include #include "avlnode-internal.h" uint32_t avlnode_delete (avlnode *s, uint32_t max, uint32_t *root, void const *k, dtok_func_ref dtok, cmp_func_ref f, void *p) { uint32_t r = *root ; uint32_t itodel ; uint32_t stack[AVLNODE_MAXDEPTH] ; uint8_t spin[AVLNODE_MAXDEPTH] ; uint8_t sp = 0 ; for (; r < max ; sp++) { int c = (*f)(k, (*dtok)(s[r].data, p), p) ; if (!c) break ; spin[sp] = avlnode_ufroms(c) ; stack[sp] = r ; r = s[r].child[spin[sp]] ; } if (r >= max) return max ; itodel = r ; if ((s[r].child[0] < max) || (s[r].child[1] < max)) { uint8_t subspin = s[r].child[1] < max ; stack[sp] = r ; spin[sp++] = subspin ; r = s[r].child[subspin] ; for (; r < max ; sp++) { stack[sp] = r ; spin[sp] = !subspin ; r = s[r].child[!subspin] ; } r = stack[--sp] ; s[itodel].data = s[r].data ; itodel = s[r].child[subspin] ; if (itodel < max) { s[r].data = s[itodel].data ; stack[sp] = r ; spin[sp++] = subspin ; } else itodel = r ; } r = max ; while (sp--) { s[stack[sp]].child[spin[sp]] = r ; r = stack[sp] ; if (!s[r].balance) goto easyfix ; else if (spin[sp] == avlnode_ufroms(s[r].balance)) s[r].balance = 0 ; else if (!s[s[r].child[!spin[sp]]].balance) goto hardfix ; else r = avlnode_rotate_maydouble(s, max, r, spin[sp], spin[sp] == avlnode_ufroms(s[s[r].child[!spin[sp]]].balance)) ; } *root = r ; return itodel ; easyfix: s[r].balance = -avlnode_sfromu(spin[sp]) ; return itodel ; hardfix: r = avlnode_rotate(s, max, r, spin[sp]) ; if (!sp--) *root = r ; else s[stack[sp]].child[spin[sp]] = r ; return itodel ; } skalibs-2.14.1.1/src/libdatastruct/avlnode_doublerotate.c000066400000000000000000000007421455624754300234110ustar00rootroot00000000000000/* ISC license. */ #include #include "avlnode-internal.h" uint32_t avlnode_doublerotate (avlnode_ref s, uint32_t max, uint32_t i, int h) { uint32_t j = s[i].child[!h] ; uint32_t k = s[j].child[h] ; s[i].child[!h] = s[k].child[h] ; s[j].child[h] = s[k].child[!h] ; s[k].child[!h] = j ; s[k].child[h] = i ; s[h ? i : j].balance = (s[k].balance < 0) ; s[h ? j : i].balance = -(s[k].balance > 0) ; s[k].balance = 0 ; (void)max ; return k ; } skalibs-2.14.1.1/src/libdatastruct/avlnode_extreme.c000066400000000000000000000004351455624754300223700ustar00rootroot00000000000000/* ISC license. */ #include #include int avlnode_extreme (avlnode const *s, uint32_t max, uint32_t r, int h, uint32_t *k) { uint32_t i = avlnode_extremenode(s, max, r, h) ; if (i >= max) return (errno = ESRCH, 0) ; *k = s[i].data ; return 1 ; } skalibs-2.14.1.1/src/libdatastruct/avlnode_extremenode.c000066400000000000000000000003371455624754300232370ustar00rootroot00000000000000/* ISC license. */ #include uint32_t avlnode_extremenode (avlnode const *s, uint32_t max, uint32_t r, int h) { uint32_t oldr = r ; for (; r < max ; oldr = r, r = s[r].child[h]) ; return oldr ; } skalibs-2.14.1.1/src/libdatastruct/avlnode_height.c000066400000000000000000000006471455624754300221740ustar00rootroot00000000000000/* ISC license. */ #include unsigned int avlnode_height (avlnode const *s, uint32_t max, uint32_t r) { if (r >= max) return 0 ; else if (s[r].balance) return 1 + avlnode_height(s, max, s[r].child[s[r].balance > 0]) ; else { unsigned int h1 = avlnode_height(s, max, s[r].child[0]) ; unsigned int h2 = avlnode_height(s, max, s[r].child[1]) ; return 1 + ((h1 > h2) ? h1 : h2) ; } } skalibs-2.14.1.1/src/libdatastruct/avlnode_insertnode.c000066400000000000000000000017461455624754300230770ustar00rootroot00000000000000/* ISC license. */ #include #include #include "avlnode-internal.h" uint32_t avlnode_insertnode (avlnode *s, uint32_t max, uint32_t r, uint32_t i, dtok_func_ref dtok, cmp_func_ref f, void *p) { uint32_t stack[AVLNODE_MAXDEPTH] ; uint8_t spin[AVLNODE_MAXDEPTH] ; uint8_t sp = 0 ; { void const *k = (*dtok)(s[i].data, p) ; for (; r < max ; sp++) { spin[sp] = avlnode_ufroms((*f)(k, (*dtok)(s[r].data, p), p)) ; stack[sp] = r ; r = s[r].child[spin[sp]] ; } } r = i ; while (sp--) { s[stack[sp]].child[spin[sp]] = r ; r = stack[sp] ; if (s[r].balance) goto lastfix ; s[r].balance = avlnode_sfromu(spin[sp]) ; } return r ; lastfix: if (avlnode_ufroms(s[r].balance) != spin[sp]) { s[r].balance = 0 ; return stack[0] ; } r = avlnode_rotate_maydouble(s, max, r, !spin[sp], spin[sp] != spin[sp+1]) ; if (!sp--) return r ; s[stack[sp]].child[spin[sp]] = r ; return stack[0] ; } skalibs-2.14.1.1/src/libdatastruct/avlnode_iter.c000066400000000000000000000015231455624754300216610ustar00rootroot00000000000000/* ISC license. */ #include #include struct avlnode_iter_s { avlnode const *s ; uint32_t max ; uint32_t cut ; avliter_func_ref f ; void *p ; } ; static uint32_t avlnode_iter_rec (struct avlnode_iter_s const *blah, uint32_t r, unsigned int h) { if (r >= blah->max) return blah->max ; { uint32_t res = avlnode_iter_rec(blah, blah->s[r].child[0], h+1) ; if (res != blah->max) return res ; } if (r == blah->cut) return blah->max ; if (!(*blah->f)(blah->s[r].data, h, blah->p)) return r ; return avlnode_iter_rec(blah, blah->s[r].child[1], h+1) ; } uint32_t avlnode_iter_nocancel (avlnode *s, uint32_t max, uint32_t cut, uint32_t r, avliter_func_ref f, void *p) { struct avlnode_iter_s blah = { .s = s, .max = max, .cut = cut, .f = f, .p = p } ; return avlnode_iter_rec(&blah, r, 0) ; } skalibs-2.14.1.1/src/libdatastruct/avlnode_iter_withcancel.c000066400000000000000000000006621455624754300240650ustar00rootroot00000000000000/* ISC license. */ #include #include int avlnode_iter_withcancel (avlnode *tree, uint32_t max, uint32_t root, avliter_func_ref f, avliter_func_ref cancelf, void *stuff) { uint32_t cut = avlnode_iter_nocancel(tree, max, max, root, f, stuff) ; if (cut != max) { int e = errno ; avlnode_iter_nocancel(tree, max, cut, root, cancelf, stuff) ; errno = e ; return 0 ; } return 1 ; } skalibs-2.14.1.1/src/libdatastruct/avlnode_rotate.c000066400000000000000000000006061455624754300222150ustar00rootroot00000000000000/* ISC license. */ #include #include "avlnode-internal.h" uint32_t avlnode_rotate (avlnode *s, uint32_t max, uint32_t i, int h) { uint32_t j = s[i].child[!h] ; s[i].child[!h] = s[j].child[h] ; s[j].child[h] = i ; if (s[j].balance * avlnode_sfromu(h) < 0) s[i].balance = s[j].balance = 0 ; else s[j].balance = avlnode_sfromu(h) ; (void)max ; return j ; } skalibs-2.14.1.1/src/libdatastruct/avlnode_search.c000066400000000000000000000005421455624754300221630ustar00rootroot00000000000000/* ISC license. */ #include #include int avlnode_search (avlnode const *s, uint32_t max, uint32_t r, void const *k, uint32_t *data, dtok_func_ref dtok, cmp_func_ref f, void *p) { uint32_t i = avlnode_searchnode(s, max, r, k, dtok, f, p) ; if (i >= max) return (errno = ESRCH, 0) ; *data = s[i].data ; return 1 ; } skalibs-2.14.1.1/src/libdatastruct/avlnode_searchnode.c000066400000000000000000000005541455624754300230340ustar00rootroot00000000000000/* ISC license. */ #include #include "avlnode-internal.h" uint32_t avlnode_searchnode (avlnode const *s, uint32_t max, uint32_t r, void const *k, dtok_func_ref dtok, cmp_func_ref f, void *p) { while (r < max) { int h = (*f)(k, (*dtok)(s[r].data, p), p) ; if (!h) break ; r = s[r].child[avlnode_ufroms(h)] ; } return r ; } skalibs-2.14.1.1/src/libdatastruct/avlnode_zero.c000066400000000000000000000001361455624754300216740ustar00rootroot00000000000000/* ISC license. */ #include avlnode const avlnode_zero = AVLNODE_ZERO ; skalibs-2.14.1.1/src/libdatastruct/avltree_delete.c000066400000000000000000000007511455624754300221740ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include int avltree_delete (avltree *t, void const *k) { uint32_t r = avltree_root(t) ; uint32_t i = avlnode_delete(avltree_nodes(t), avltree_totalsize(t), &r, k, t->dtok, t->kcmp, t->external) ; if (i >= avltree_totalsize(t)) return (errno = ESRCH, 0) ; avltree_setroot(t, r) ; if (!gensetdyn_delete(&t->x, i)) return 0 ; return 1 ; } skalibs-2.14.1.1/src/libdatastruct/avltree_free.c000066400000000000000000000002441455624754300216500ustar00rootroot00000000000000/* ISC license. */ #include #include void avltree_free (avltree *t) { gensetdyn_free(&t->x) ; *t = avltree_zero ; } skalibs-2.14.1.1/src/libdatastruct/avltree_init.c000066400000000000000000000006531455624754300216760ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include void avltree_init (avltree *t, uint32_t base, uint32_t fracnum, uint32_t fracden, dtok_func_ref dtok, cmp_func_ref f, void *p) { gensetdyn_init(&t->x, sizeof(avlnode), base, fracnum, fracden) ; t->root = UINT32_MAX ; t->dtok = dtok ; t->kcmp = f ; t->external = p ; } skalibs-2.14.1.1/src/libdatastruct/avltree_insert.c000066400000000000000000000003101455624754300222250ustar00rootroot00000000000000/* ISC license. */ #include int avltree_insert (avltree *t, uint32_t d) { uint32_t i ; if (!avltree_newnode(t, d, &i)) return 0 ; avltree_insertnode(t, i) ; return 1 ; } skalibs-2.14.1.1/src/libdatastruct/avltree_newnode.c000066400000000000000000000006111455624754300223640ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include int avltree_newnode (avltree *t, uint32_t data, uint32_t *i) { if (!gensetdyn_new(&t->x, i)) return 0 ; { avlnode *s = avltree_nodes(t) ; s[*i].data = data ; s[*i].child[0] = s[*i].child[1] = UINT32_MAX ; s[*i].balance = 0 ; } return 1 ; } skalibs-2.14.1.1/src/libdatastruct/avltree_zero.c000066400000000000000000000001361455624754300217060ustar00rootroot00000000000000/* ISC license. */ #include avltree const avltree_zero = AVLTREE_ZERO ; skalibs-2.14.1.1/src/libdatastruct/avltreen_delete.c000066400000000000000000000007531455624754300223540ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include int avltreen_delete (avltreen *t, void const *k) { uint32_t r = avltreen_root(t) ; uint32_t i = avlnode_delete(avltreen_nodes(t), avltreen_totalsize(t), &r, k, t->dtok, t->kcmp, t->external) ; if (i >= avltreen_totalsize(t)) return (errno = ESRCH, 0) ; avltreen_setroot(t, r) ; if (!genset_delete(&t->x, i)) return 0 ; return 1 ; } skalibs-2.14.1.1/src/libdatastruct/avltreen_init.c000066400000000000000000000005661455624754300220570ustar00rootroot00000000000000/* ISC license. */ #include #include #include void avltreen_init (avltreen *t, avlnode *storage, uint32_t *freelist, uint32_t size, dtok_func_ref dtok, cmp_func_ref f, void *p) { GENSET_init(&t->x, avlnode, storage, freelist, size) ; t->root = size ; t->dtok = dtok ; t->kcmp = f ; t->external = p ; } skalibs-2.14.1.1/src/libdatastruct/avltreen_insert.c000066400000000000000000000003451455624754300224130ustar00rootroot00000000000000/* ISC license. */ #include int avltreen_insert (avltreen *t, uint32_t d) { uint32_t i = avltreen_newnode(t, d) ; if (i >= avltreen_totalsize(t)) return 0 ; avltreen_insertnode(t, i) ; return 1 ; } skalibs-2.14.1.1/src/libdatastruct/avltreen_newnode.c000066400000000000000000000006111455624754300225420ustar00rootroot00000000000000/* ISC license. */ #include #include #include uint32_t avltreen_newnode (avltreen *t, uint32_t d) { uint32_t i = genset_new(&t->x) ; if (i < avltreen_totalsize(t)) { avlnode *s = avltreen_nodes(t) ; s[i].data = d ; s[i].child[0] = s[i].child[1] = avltreen_totalsize(t) ; s[i].balance = 0 ; } return i ; } skalibs-2.14.1.1/src/libdatastruct/bigkv_fill.c000066400000000000000000000035451455624754300213240ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #include #include static void *bigkv_dtok (uint32_t d, void *p) { bigkv *b = p ; return b->storage.s + genalloc_s(bigkv_node, &b->nodes)[d].k ; } static int bigkv_cmp (void const *a, void const *b, void *p) { (void)p ; return strcmp((char const *)a, (char const *)b) ; } int bigkv_fill (bigkv *b, char const *const *argv, char delim, char const *prefix, char const *stop, uint32_t options) { int i = 0 ; size_t prefixlen = prefix ? strlen(prefix) : 0 ; avltree_init(&b->map, 3, 3, 8, &bigkv_dtok, &bigkv_cmp, b) ; for (; argv[i] && !(stop && !strcmp(argv[i], stop)) ; i++) { bigkv_node node = { .k = b->storage.len } ; char const *s = argv[i] ; size_t len = strlen(s) ; size_t pos ; int isdup ; uint32_t d ; if (prefixlen) { if (!strncmp(s, prefix, prefixlen)) return i+1 ; s += prefixlen ; len -= prefixlen ; } pos = byte_chr(s, len, delim) ; if (!stralloc_catb(&b->storage, s, pos+1)) goto err ; b->storage.s[pos] = 0 ; isdup = avltree_search(&b->map, s, &d) ; if (isdup) { if (options & BIGKV_OPTIONS_NODUP) goto invalid ; b->storage.len = node.k ; } if (pos < len) { node.v = b->storage.len ; if (!stralloc_catb(&b->storage, s + pos + 1, len - pos)) goto err ; } else node.v = b->storage.len - 1 ; if (isdup) genalloc_s(bigkv_node, &b->nodes)[d].v = node.v ; else { d = genalloc_len(bigkv_node, &b->nodes) ; if (!genalloc_append(bigkv_node, &b->nodes, &node)) goto err ; if (!avltree_insert(&b->map, d)) goto err ; } } return i ; invalid: errno = EINVAL ; err: bigkv_free(b) ; return -1 ; } skalibs-2.14.1.1/src/libdatastruct/bigkv_free.c000066400000000000000000000004361455624754300213130ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include void bigkv_free (bigkv *b) { avltree_free(&b->map) ; genalloc_free(bigkv_node, &b->nodes) ; stralloc_free(&b->storage) ; *b = bigkv_zero ; } skalibs-2.14.1.1/src/libdatastruct/bigkv_search.c000066400000000000000000000004521455624754300216350ustar00rootroot00000000000000/* ISC license. */ #include #include #include char const *bigkv_search (bigkv const *b, char const *k) { uint32_t i ; if (!avltree_search(&b->map, k, &i)) return 0 ; return b->storage.s + genalloc_s(bigkv_node, &b->nodes)[i].v ; } skalibs-2.14.1.1/src/libdatastruct/bigkv_zero.c000066400000000000000000000001261455624754300213450ustar00rootroot00000000000000/* ISC license. */ #include bigkv const bigkv_zero = BIGKV_ZERO ; skalibs-2.14.1.1/src/libdatastruct/genqdyn-internal.h000066400000000000000000000002511455624754300224670ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_GENQDYN_INTERNAL_H #define SKALIBS_GENQDYN_INTERNAL_H #include extern void genqdyn_clean (genqdyn *) ; #endif skalibs-2.14.1.1/src/libdatastruct/genqdyn_clean.c000066400000000000000000000003351455624754300220150ustar00rootroot00000000000000/* ISC license. */ #include #include "genqdyn-internal.h" void genqdyn_clean (genqdyn *g) { memmove(g->queue.s, g->queue.s + g->head, g->queue.len - g->head) ; g->queue.len -= g->head ; g->head = 0 ; } skalibs-2.14.1.1/src/libdatastruct/genqdyn_free.c000066400000000000000000000002461455624754300216550ustar00rootroot00000000000000/* ISC license. */ #include #include void genqdyn_free (genqdyn *g) { stralloc_free(&g->queue) ; *g = genqdyn_zero ; } skalibs-2.14.1.1/src/libdatastruct/genqdyn_init.c000066400000000000000000000004111455624754300216710ustar00rootroot00000000000000/* ISC license. */ #include #include void genqdyn_init (genqdyn *g, size_t esize, unsigned int num, unsigned int den) { g->queue = stralloc_zero ; g->esize = esize ; g->head = 0 ; g->num = num ; g->den = den ; } skalibs-2.14.1.1/src/libdatastruct/genqdyn_pop.c000066400000000000000000000004721455624754300215330ustar00rootroot00000000000000/* ISC license. */ #include #include #include "genqdyn-internal.h" int genqdyn_pop (genqdyn *g) { if (g->head >= g->queue.len) return (errno = EINVAL, 0) ; g->head += g->esize ; if (g->den * (g->queue.len - g->head) <= g->num * g->queue.len) genqdyn_clean(g) ; return 1 ; } skalibs-2.14.1.1/src/libdatastruct/genqdyn_push.c000066400000000000000000000003001455624754300217020ustar00rootroot00000000000000/* ISC license. */ #include #include int genqdyn_push (genqdyn *g, void const *p) { return stralloc_catb(&g->queue, (char const *)p, g->esize) ; } skalibs-2.14.1.1/src/libdatastruct/genqdyn_unpush.c000066400000000000000000000003551455624754300222570ustar00rootroot00000000000000/* ISC license. */ #include #include #include int genqdyn_unpush (genqdyn *g) { if (g->queue.len < g->esize) return (errno = EINVAL, 0) ; g->queue.len -= g->esize ; return 1 ; } skalibs-2.14.1.1/src/libdatastruct/genqdyn_zero.c000066400000000000000000000001361455624754300217110ustar00rootroot00000000000000/* ISC license. */ #include genqdyn const genqdyn_zero = GENQDYN_ZERO ; skalibs-2.14.1.1/src/libdatastruct/genset.c000066400000000000000000000011371455624754300204740ustar00rootroot00000000000000/* ISC license. */ #include #include void genset_init (genset *x, void *storage, uint32_t *freelist, uint32_t esize, uint32_t max) { uint32_t i = max ; x->storage = (char *)storage ; x->freelist = freelist ; x->esize = esize ; x->max = max ; x->sp = max ; while (i--) freelist[i] = max - 1 - i ; } uint32_t genset_new (genset *x) { return x->sp ? x->freelist[--x->sp] : (errno = ENOSPC, x->max) ; } int genset_delete (genset *x, uint32_t i) { if ((i >= x->max) || (x->sp >= x->max)) return (errno = EINVAL, 0) ; x->freelist[x->sp++] = i ; return 1 ; } skalibs-2.14.1.1/src/libdatastruct/genset_deepfree.c000066400000000000000000000004101455624754300223240ustar00rootroot00000000000000/* ISC license. */ #include #include static int freeiter (void *s, void *aux) { free_func_ref f = aux ; (*f)(s) ; return 1 ; } void genset_deepfree (genset *g, free_func_ref f) { genset_iter(g, &freeiter, f) ; } skalibs-2.14.1.1/src/libdatastruct/genset_iter_nocancel.c000066400000000000000000000010441455624754300233560ustar00rootroot00000000000000/* ISC license. */ #include #include #include uint32_t genset_iter_nocancel (genset *g, uint32_t n, iter_func_ref f, void *stuff) { unsigned char bits[bitarray_div8(n)] ; uint32_t i = 0, j = 0, m = genset_n(g) ; bitarray_setn(bits, 0, n) ; for (; i < g->sp ; i++) if (g->freelist[i] < n) bitarray_clear(bits, g->freelist[i]) ; for (i = 0 ; (i < n) && (j < m) ; i++) if (bitarray_peek(bits, i)) { j++ ; if (!(*f)(g->storage + i * g->esize, stuff)) break ; } return i ; } skalibs-2.14.1.1/src/libdatastruct/genset_iter_withcancel.c000066400000000000000000000005561455624754300237240ustar00rootroot00000000000000/* ISC license. */ #include #include #include int genset_iter_withcancel (genset *g, iter_func_ref f, iter_func_ref cancelf, void *stuff) { uint32_t n = genset_iter(g, f, stuff) ; if (n < g->max) { int e = errno ; genset_iter_nocancel(g, n, cancelf, stuff) ; errno = e ; return 0 ; } return 1 ; } skalibs-2.14.1.1/src/libdatastruct/gensetdyn_deepfree.c000066400000000000000000000004521455624754300230450ustar00rootroot00000000000000/* ISC license. */ #include #include static int freeiter (void *s, void *aux) { free_func_ref f = aux ; (*f)(s) ; return 1 ; } void gensetdyn_deepfree (gensetdyn *g, free_func_ref f) { gensetdyn_iter(g, &freeiter, f) ; gensetdyn_free(g) ; } skalibs-2.14.1.1/src/libdatastruct/gensetdyn_delete.c000066400000000000000000000004031455624754300225240ustar00rootroot00000000000000/* ISC license. */ #include #include #include int gensetdyn_delete (gensetdyn *g, uint32_t i) { return (i >= g->storage.len) ? (errno = EINVAL, 0) : genalloc_catb(uint32_t, &g->freelist, &i, 1) ; } skalibs-2.14.1.1/src/libdatastruct/gensetdyn_free.c000066400000000000000000000004141455624754300222050ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include void gensetdyn_free (gensetdyn *g) { stralloc_free(&g->storage) ; genalloc_free(uint32_t, &g->freelist) ; *g = gensetdyn_zero ; } skalibs-2.14.1.1/src/libdatastruct/gensetdyn_init.c000066400000000000000000000005631455624754300222340ustar00rootroot00000000000000/* ISC license. */ #include #include #include void gensetdyn_init (gensetdyn *g, uint32_t esize, uint32_t base, uint32_t fracnum, uint32_t fracden) { g->storage = stralloc_zero ; g->freelist = genalloc_zero ; g->esize = esize ; g->base = base ; g->fracnum = fracnum ; g->fracden = fracden ; } skalibs-2.14.1.1/src/libdatastruct/gensetdyn_iter_nocancel.c000066400000000000000000000015471455624754300241010ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include uint32_t gensetdyn_iter_nocancel (gensetdyn *g, uint32_t n, iter_func_ref f, void *stuff) { /* XXX: we may be called by a freeing function, so we cannot alloc - XXX: so pray that the bitarray fits in the stack. */ unsigned char bits[bitarray_div8(g->storage.len) ? bitarray_div8(g->storage.len) : 1] ; size_t i = 0 ; uint32_t j = 0 ; uint32_t *fl = genalloc_s(uint32_t, &g->freelist) ; size_t sp = genalloc_len(uint32_t, &g->freelist) ; bitarray_setn(bits, 0, g->storage.len) ; for (; i < sp ; i++) if (fl[i] < g->storage.len) bitarray_clear(bits, fl[i]) ; for (i = 0 ; (i < g->storage.len) && (j < n) ; i++) if (bitarray_peek(bits, i)) { j++ ; if (!(*f)(gensetdyn_p(g, i), stuff)) break ; } return j ; } skalibs-2.14.1.1/src/libdatastruct/gensetdyn_iter_withcancel.c000066400000000000000000000006361455624754300244360ustar00rootroot00000000000000/* ISC license. */ #include #include #include int gensetdyn_iter_withcancel (gensetdyn *g, iter_func_ref f, iter_func_ref cancelf, void *stuff) { uint32_t n = gensetdyn_iter_nocancel(g, gensetdyn_n(g), f, stuff) ; if (n < gensetdyn_n(g)) { int e = errno ; gensetdyn_iter_nocancel(g, n, cancelf, stuff) ; errno = e ; return 0 ; } return 1 ; } skalibs-2.14.1.1/src/libdatastruct/gensetdyn_new.c000066400000000000000000000006321455624754300220570ustar00rootroot00000000000000/* ISC license. */ #include #include #include int gensetdyn_new (gensetdyn *g, uint32_t *i) { size_t n ; if (!genalloc_len(uint32_t, &g->freelist) && !gensetdyn_readyplus(g, 1)) return 0 ; n = genalloc_len(uint32_t, &g->freelist) ; *i = genalloc_s(uint32_t, &g->freelist)[n-1] ; genalloc_setlen(uint32_t, &g->freelist, n-1) ; return 1 ; } skalibs-2.14.1.1/src/libdatastruct/gensetdyn_ready.c000066400000000000000000000012221455624754300223660ustar00rootroot00000000000000/* ISC license. */ #include #include #include int gensetdyn_ready (gensetdyn *g, uint32_t n) { int wasnull = !g->storage.s ; uint32_t i = g->storage.len ; if (n < i) return 1 ; n += g->base + (n * g->fracnum) / g->fracden ; if (!stralloc_ready_tuned(&g->storage, n * g->esize, 0, 0, 1)) return 0 ; if (!genalloc_ready(uint32_t, &g->freelist, n)) { if (wasnull) stralloc_free(&g->storage) ; return 0 ; } for (; i < n ; i++) { uint32_t j = n - 1 - i + g->storage.len ; genalloc_catb(uint32_t, &g->freelist, &j, 1) ; } g->storage.len = n ; return 1 ; } skalibs-2.14.1.1/src/libdatastruct/gensetdyn_zero.c000066400000000000000000000001461455624754300222450ustar00rootroot00000000000000/* ISC license. */ #include gensetdyn const gensetdyn_zero = GENSETDYN_ZERO ; skalibs-2.14.1.1/src/libenvexec/000077500000000000000000000000001455624754300163205ustar00rootroot00000000000000skalibs-2.14.1.1/src/libenvexec/env_addmodif.c000066400000000000000000000006231455624754300211040ustar00rootroot00000000000000/* ISC license. */ #include #include #include int env_addmodif (stralloc *sa, char const *s, char const *t) { size_t oldlen = sa->len ; if (!s) return 1 ; if (!stralloc_cats(sa, s)) return 0 ; if ((t && (!stralloc_catb(sa, "=", 1) || !stralloc_cats(sa, t))) || !stralloc_0(sa)) { sa->len = oldlen ; return 0 ; } return 1 ; } skalibs-2.14.1.1/src/libenvexec/env_dump.c000066400000000000000000000023441455624754300203040ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #include #include #include #include /* XXX: breaks layering, but really openat() should be supported everywhere */ #include #define SUFFIX ":envdump:XXXXXX" int env_dump (char const *dir, mode_t mode, char const *const *envp) { int fd ; size_t dirlen = strlen(dir) ; char tmpdir[dirlen + sizeof(SUFFIX)] ; memcpy(tmpdir, dir, dirlen) ; memcpy(tmpdir + dirlen, SUFFIX, sizeof(SUFFIX)) ; if (!mkdtemp(tmpdir)) return 0 ; fd = open_read(tmpdir) ; if (fd == -1) goto err ; for (; *envp ; envp++) { size_t len = str_chr(*envp, '=') ; size_t vallen = strlen(*envp + len + 1) ; char fn[len + 1] ; memcpy(fn, *envp, len) ; fn[len] = 0 ; len = openwritenclose_at(fd, fn, *envp + len + 1, vallen) ; if (len < vallen) goto cerr ; } fd_close(fd) ; if (chmod(tmpdir, mode) == -1) goto err ; if (rename(tmpdir, dir) == -1) goto err ; return 1 ; cerr: fd_close(fd) ; err: { int e = errno ; rm_rf(tmpdir) ; errno = e ; } return 0 ; } skalibs-2.14.1.1/src/libenvexec/env_get.c000066400000000000000000000002041455624754300201070ustar00rootroot00000000000000/* ISC license. */ #include #include char const *env_get (char const *s) { return getenv(s) ; } skalibs-2.14.1.1/src/libenvexec/env_get2.c000066400000000000000000000005451455624754300202010ustar00rootroot00000000000000/* ISC license. */ #include #include #include char const *env_get2 (char const *const *envp, char const *s) { size_t len, i ; if (!s) return 0 ; len = strlen(s) ; for (i = 0 ; envp[i] ; ++i) if (str_start(envp[i], s) && (envp[i][len] == '=')) return envp[i] + len + 1 ; return 0 ; } skalibs-2.14.1.1/src/libenvexec/env_len.c000066400000000000000000000002131455624754300201060ustar00rootroot00000000000000/* ISC license. */ #include size_t env_len (char const *const *e) { size_t i = 0 ; while (*e++) i++ ; return i ; } skalibs-2.14.1.1/src/libenvexec/env_make.c000066400000000000000000000004651455624754300202560ustar00rootroot00000000000000/* ISC license. */ #include #include #include int env_make (char const **v, size_t argc, char const *s, size_t len) { while (argc--) { size_t n = strlen(s) + 1 ; if (n > len) return (errno = EINVAL, 0) ; *v++ = s ; s += n ; len -= n ; } return 1 ; } skalibs-2.14.1.1/src/libenvexec/env_merg.c000066400000000000000000000003431455624754300202660ustar00rootroot00000000000000/* ISC license. */ #include size_t env_merg (char const **v, size_t vmax, char const *const *envp, char const *modifs, size_t modiflen) { return env_merge(v, vmax, envp, env_len(envp), modifs, modiflen) ; } skalibs-2.14.1.1/src/libenvexec/env_merge.c000066400000000000000000000004561455624754300204400ustar00rootroot00000000000000/* ISC license. */ #include #include size_t env_merge (char const **v, size_t vmax, char const *const *envp, size_t envlen, char const *modifs, size_t modiflen) { return env_mergen(v, vmax, envp, envlen, modifs, modiflen, byte_count(modifs, modiflen, '\0')) ; } skalibs-2.14.1.1/src/libenvexec/env_mergen.c000066400000000000000000000014601455624754300206120ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include size_t env_mergen (char const **v, size_t vmax, char const *const *envp, size_t envlen, char const *modifs, size_t modiflen, size_t n) { size_t vlen = envlen ; size_t i = 0 ; if (envlen >= vmax) return 0 ; for (; i < envlen ; i++) v[i] = envp[i] ; for (i = 0 ; i < modiflen ; i += strlen(modifs + i) + 1) { size_t split = str_chr(modifs + i, '=') ; size_t j = 0 ; for (; j < vlen ; j++) if (!strncmp(modifs + i, v[j], split) && (v[j][split] == '=')) break ; if (j < vlen) v[j] = v[--vlen] ; if (modifs[i + split]) { if (vlen >= vmax) return 0 ; v[vlen++] = modifs + i ; } } if (vlen >= vmax) return 0 ; v[vlen++] = 0 ; return vlen ; } skalibs-2.14.1.1/src/libenvexec/env_mergn.c000066400000000000000000000003741455624754300204500ustar00rootroot00000000000000/* ISC license. */ #include size_t env_mergn (char const **v, size_t vmax, char const *const *envp, char const *modifs, size_t modiflen, size_t modifn) { return env_mergen(v, vmax, envp, env_len(envp), modifs, modiflen, modifn) ; } skalibs-2.14.1.1/src/libenvexec/env_string.c000066400000000000000000000005371455624754300206470ustar00rootroot00000000000000/* ISC license. */ #include #include int env_string (stralloc *sa, char const *const *envp, size_t envlen) { size_t salen = sa->len ; size_t i = 0 ; for (; i < envlen ; i++) { if (!stralloc_cats(sa, envp[i]) || !stralloc_0(sa)) { sa->len = salen ; return 0 ; } } return 1 ; } skalibs-2.14.1.1/src/libenvexec/envalloc_0.c000066400000000000000000000002701455624754300205050ustar00rootroot00000000000000/* ISC license. */ #include #include int envalloc_0 (genalloc *v) { char const *z = 0 ; return genalloc_append(char const *, v, &z) ; } skalibs-2.14.1.1/src/libenvexec/envalloc_make.c000066400000000000000000000010121455624754300212560ustar00rootroot00000000000000/* ISC license. */ #include #include #include int envalloc_make (genalloc *v, size_t argc, char const *s, size_t len) { int wasnull = !v->s ; if (!genalloc_readyplus(char const *, v, argc+1)) return 0 ; if (!env_make(genalloc_s(char const *, v) + genalloc_len(char const *, v), argc, s, len)) { if (wasnull) genalloc_free(char const *, v) ; return 0 ; } genalloc_setlen(char const *, v, genalloc_len(char const *, v) + argc) ; return 1 ; } skalibs-2.14.1.1/src/libenvexec/envalloc_merge.c000066400000000000000000000011351455624754300214460ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include int envalloc_merge (genalloc *v, char const *const *envp, size_t envlen, char const *modifs, size_t modiflen) { size_t modifn = byte_count(modifs, modiflen, '\0') ; size_t n = envlen + 1 + modifn ; if (!genalloc_readyplus(char const *, v, n)) return 0 ; n = env_mergen(genalloc_s(char const *, v) + genalloc_len(char const *, v), n, envp, envlen, modifs, modiflen, modifn) ; genalloc_setlen(char const *, v, genalloc_len(char const *, v) + n) ; return 1 ; } skalibs-2.14.1.1/src/libenvexec/envalloc_uniq.c000066400000000000000000000014131455624754300213220ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include int envalloc_uniq (genalloc *v, char delim) { unsigned int m = 0 ; size_t i = 0 ; for (; i < genalloc_len(char const *, v) ; i++) { size_t j = i+1 ; char const *s = genalloc_s(char const *, v)[i] ; size_t n = str_chr(s, delim) ; if (delim && !s[n]) return (errno = EINVAL, -1) ; for (; j < genalloc_len(char const *, v) ; j++) { char const **p = genalloc_s(char const *, v) ; if (!strncmp(s, p[j], n)) { size_t len = genalloc_len(char const *, v) - 1 ; genalloc_setlen(char const *, v, len) ; p[j] = p[len] ; m++ ; } } } return m ; } skalibs-2.14.1.1/src/libenvexec/envdir-internal.h000066400000000000000000000004261455624754300215740ustar00rootroot00000000000000/* ISC license. */ #ifndef ENVDIR_INTERNAL_H #define ENVDIR_INTERNAL_H #include extern int envdir_internal_clamp (char const *, stralloc *, unsigned int, char) ; extern int envdir_internal_noclamp (char const *, stralloc *, unsigned int, char) ; #endif skalibs-2.14.1.1/src/libenvexec/envdir.c000066400000000000000000000006351455624754300177570ustar00rootroot00000000000000/* ISC license. */ #include #include #include "envdir-internal.h" int envdir_internal (char const *path, stralloc *modifs, unsigned int options, char nullis) { return nullis ? options & SKALIBS_ENVDIR_NOCLAMP ? envdir_internal_noclamp(path, modifs, options & ~SKALIBS_ENVDIR_NOCLAMP, nullis) : envdir_internal_clamp(path, modifs, options, nullis) : (errno = EINVAL, -1) ; } skalibs-2.14.1.1/src/libenvexec/envdir_clamp.c000066400000000000000000000036561455624754300211410ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #include #include #include "envdir-internal.h" #define MAXVARSIZE 4095 int envdir_internal_clamp (char const *path, stralloc *modifs, unsigned int options, char nullis) { char buf[MAXVARSIZE + 1] ; unsigned int n = 0 ; size_t pathlen = strlen(path) ; size_t modifbase = modifs->len ; int wasnull = !modifs->s ; DIR *dir = opendir(path) ; if (!dir) return -1 ; for (;;) { direntry *d ; size_t len ; ssize_t r ; errno = 0 ; d = readdir(dir) ; if (!d) break ; if (d->d_name[0] == '.') continue ; len = strlen(d->d_name) ; if (str_chr(d->d_name, '=') < len) continue ; { char tmp[pathlen + len + 2] ; memcpy(tmp, path, pathlen) ; tmp[pathlen] = '/' ; memcpy(tmp + pathlen + 1, d->d_name, len + 1) ; r = openreadnclose(tmp, buf, MAXVARSIZE) ; } if (r < 0) { if (errno == ENOENT) errno = EIDRM ; goto err ; } else if (r > 0) { if (options & SKALIBS_ENVDIR_VERBATIM) { if (!(options & SKALIBS_ENVDIR_NOCHOMP) && (buf[r-1] == '\n')) r-- ; } else { r = byte_chr(buf, r, '\n') ; if (!(options & SKALIBS_ENVDIR_NOCHOMP)) { while (r--) if ((buf[r] != ' ') && (buf[r] != '\t') && (buf[r] != '\r')) break ; r++ ; } } { size_t i = 0 ; for (; i < (size_t)r ; i++) if (!buf[i]) buf[i] = nullis ; } buf[r++] = 0 ; if (!env_addmodif(modifs, d->d_name, buf)) goto err ; } else if (!env_addmodif(modifs, d->d_name, 0)) goto err ; n++ ; } if (errno) goto err ; dir_close(dir) ; return n ; err: dir_close(dir) ; if (wasnull) stralloc_free(modifs) ; else modifs->len = modifbase ; return -1 ; } skalibs-2.14.1.1/src/libenvexec/envdir_noclamp.c000066400000000000000000000047441455624754300214750ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #include #include #include #include #include "envdir-internal.h" #define N 4096 int envdir_internal_noclamp (char const *path, stralloc *modifs, unsigned int options, char nullis) { unsigned int n = 0 ; size_t pathlen = strlen(path) ; size_t modifbase = modifs->len ; int wasnull = !modifs->s ; int fd ; DIR *dir = opendir(path) ; if (!dir) return -1 ; for (;;) { direntry *d ; size_t len, pos ; errno = 0 ; d = readdir(dir) ; if (!d) break ; if (d->d_name[0] == '.') continue ; len = strlen(d->d_name) ; if (str_chr(d->d_name, '=') < len) continue ; { char tmp[pathlen + len + 2] ; memcpy(tmp, path, pathlen) ; tmp[pathlen] = '/' ; memcpy(tmp + pathlen + 1, d->d_name, len + 1) ; fd = openc_readb(tmp) ; } if (fd < 0) { if (errno == ENOENT) errno = EIDRM ; goto err ; } if (!stralloc_catb(modifs, d->d_name, len) || !stralloc_catb(modifs, "=", 1)) goto errfd ; pos = modifs->len ; if (options & SKALIBS_ENVDIR_VERBATIM) { if (!slurp(modifs, fd)) goto errfd ; if (modifs->len == pos) modifs->len = pos - 1 ; if (!(options & SKALIBS_ENVDIR_NOCHOMP) && (modifs->s[modifs->len - 1] == '\n')) modifs->len-- ; } else { int r ; char buf[N] ; buffer b = BUFFER_INIT(&buffer_read, fd, buf, N) ; r = skagetln(&b, modifs, '\n') ; if (r == -1) { if (errno != EPIPE) goto errfd ; if (!(options & SKALIBS_ENVDIR_NOCHOMP)) modifs->len = pos ; modifs->len++ ; } if (!r) modifs->len = pos - 1 ; else { modifs->len-- ; if (!(options & SKALIBS_ENVDIR_NOCHOMP)) { while (modifs->len-- > pos) { char c = modifs->s[modifs->len] ; if ((c != ' ') && (c != '\t') && (c != '\r')) break ; } modifs->len++ ; } } } fd_close(fd) ; for (; pos < modifs->len ; pos++) if (!modifs->s[pos]) modifs->s[pos] = nullis ; if (!stralloc_0(modifs)) goto err ; n++ ; } if (errno) goto err ; dir_close(dir) ; return n ; errfd: fd_close(fd) ; err: dir_close(dir) ; if (wasnull) stralloc_free(modifs) ; else modifs->len = modifbase ; return -1 ; } skalibs-2.14.1.1/src/libenvexec/exec0_ae.c000066400000000000000000000003241455624754300201340ustar00rootroot00000000000000/* ISC license. */ #include #include void exec0_ae (char const *file, char const *const *argv, char const *const *envp) { if (!argv[0]) _exit(0) ; exec_ae(file, argv, envp) ; } skalibs-2.14.1.1/src/libenvexec/exec_ae.c000066400000000000000000000005101455624754300200510ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include void exec_ae (char const *file, char const *const *argv, char const *const *envp) { char const *path = getenv("PATH") ; if (!path) path = SKALIBS_DEFAULTPATH ; execvep(file, argv, envp, path) ; } skalibs-2.14.1.1/src/libenvexec/mexec0_af.c000066400000000000000000000003551455624754300203160ustar00rootroot00000000000000/* ISC license. */ #include #include void mexec0_af (char const *file, char const *const *argv, char const *const *envp, size_t envlen) { if (!argv[0]) _exit(0) ; mexec_af(file, argv, envp, envlen) ; } skalibs-2.14.1.1/src/libenvexec/mexec0_afm.c000066400000000000000000000004441455624754300204720ustar00rootroot00000000000000/* ISC license. */ #include #include void mexec0_afm (char const *file, char const *const *argv, char const *const *envp, size_t envlen, char const *modif, size_t modiflen) { if (!argv[0]) _exit(0) ; mexec_afm(file, argv, envp, envlen, modif, modiflen) ; } skalibs-2.14.1.1/src/libenvexec/mexec0_afn.c000066400000000000000000000004731455624754300204750ustar00rootroot00000000000000/* ISC license. */ #include #include void mexec0_afn (char const *file, char const *const *argv, char const *const *envp, size_t envlen, char const *modif, size_t modiflen, size_t modifn) { if (!argv[0]) _exit(0) ; mexec_afn(file, argv, envp, envlen, modif, modiflen, modifn) ; } skalibs-2.14.1.1/src/libenvexec/mexec_af.c000066400000000000000000000006351455624754300202370ustar00rootroot00000000000000/* ISC license. */ #include #include #include static stralloc modifsa = STRALLOC_ZERO ; int env_mexec (char const *key, char const *value) { return env_addmodif(&modifsa, key, value) ; } void mexec_af (char const *file, char const *const *argv, char const *const *envp, size_t envlen) { mexec_afm(file, argv, envp, envlen, modifsa.s, modifsa.len) ; } skalibs-2.14.1.1/src/libenvexec/mexec_afm.c000066400000000000000000000004631455624754300204130ustar00rootroot00000000000000/* ISC license. */ #include #include void mexec_afm (char const *file, char const *const *argv, char const *const *envp, size_t envlen, char const *modif, size_t modiflen) { mexec_afn(file, argv, envp, envlen, modif, modiflen, byte_count(modif, modiflen, '\0')) ; } skalibs-2.14.1.1/src/libenvexec/mexec_afn.c000066400000000000000000000006041455624754300204110ustar00rootroot00000000000000/* ISC license. */ #include #include void mexec_afn (char const *file, char const *const *argv, char const *const *envp, size_t envlen, char const *modif, size_t modiflen, size_t modifn) { char const *newenvp[envlen + modifn + 1] ; env_mergen(newenvp, envlen + modifn + 1, envp, envlen, modif, modiflen, modifn) ; exec_ae(file, argv, newenvp) ; } skalibs-2.14.1.1/src/libenvexec/xexec0_ae.c000066400000000000000000000003261455624754300203260ustar00rootroot00000000000000/* ISC license. */ #include #include void xexec0_ae (char const *file, char const *const *argv, char const *const *envp) { if (!argv[0]) _exit(0) ; xexec_ae(file, argv, envp) ; } skalibs-2.14.1.1/src/libenvexec/xexec_ae.c000066400000000000000000000004121455624754300202420ustar00rootroot00000000000000/* ISC license. */ #include #include #include void xexec_ae (char const *file, char const *const *argv, char const *const *envp) { exec_ae(file, argv, envp) ; strerr_dieexec(errno == ENOENT ? 127 : 126, file) ; } skalibs-2.14.1.1/src/libenvexec/xexecvep.c000066400000000000000000000005001455624754300203060ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include void xexecvep (char const *file, char const *const *argv, char const *const *envp, char const *path) { execvep(file, argv, envp, path) ; strerr_dieexec(errno == ENOENT ? 127 : 126, file) ; } skalibs-2.14.1.1/src/libenvexec/xexecvep_loose.c000066400000000000000000000005141455624754300215140ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include void xexecvep_loose (char const *file, char const *const *argv, char const *const *envp, char const *path) { execvep_loose(file, argv, envp, path) ; strerr_dieexec(errno == ENOENT ? 127 : 126, file) ; } skalibs-2.14.1.1/src/libenvexec/xmexec0_af.c000066400000000000000000000004451455624754300205060ustar00rootroot00000000000000/* ISC license. */ #include #include #include void xmexec0_af (char const *file, char const *const *argv, char const *const *envp, size_t envlen) { mexec0_af(file, argv, envp, envlen) ; strerr_dieexec(errno == ENOENT ? 127 : 126, file) ; } skalibs-2.14.1.1/src/libenvexec/xmexec0_afm.c000066400000000000000000000005341455624754300206620ustar00rootroot00000000000000/* ISC license. */ #include #include #include void xmexec0_afm (char const *file, char const *const *argv, char const *const *envp, size_t envlen, char const *modif, size_t modiflen) { mexec0_afm(file, argv, envp, envlen, modif, modiflen) ; strerr_dieexec(errno == ENOENT ? 127 : 126, file) ; } skalibs-2.14.1.1/src/libenvexec/xmexec0_afn.c000066400000000000000000000005631455624754300206650ustar00rootroot00000000000000/* ISC license. */ #include #include #include void xmexec0_afn (char const *file, char const *const *argv, char const *const *envp, size_t envlen, char const *modif, size_t modiflen, size_t modifn) { mexec0_afn(file, argv, envp, envlen, modif, modiflen, modifn) ; strerr_dieexec(errno == ENOENT ? 127 : 126, file) ; } skalibs-2.14.1.1/src/libenvexec/xmexec_af.c000066400000000000000000000004431455624754300204240ustar00rootroot00000000000000/* ISC license. */ #include #include #include void xmexec_af (char const *file, char const *const *argv, char const *const *envp, size_t envlen) { mexec_af(file, argv, envp, envlen) ; strerr_dieexec(errno == ENOENT ? 127 : 126, file) ; } skalibs-2.14.1.1/src/libenvexec/xmexec_afm.c000066400000000000000000000005321455624754300206000ustar00rootroot00000000000000/* ISC license. */ #include #include #include void xmexec_afm (char const *file, char const *const *argv, char const *const *envp, size_t envlen, char const *modif, size_t modiflen) { mexec_afm(file, argv, envp, envlen, modif, modiflen) ; strerr_dieexec(errno == ENOENT ? 127 : 126, file) ; } skalibs-2.14.1.1/src/libenvexec/xmexec_afn.c000066400000000000000000000005611455624754300206030ustar00rootroot00000000000000/* ISC license. */ #include #include #include void xmexec_afn (char const *file, char const *const *argv, char const *const *envp, size_t envlen, char const *modif, size_t modiflen, size_t modifn) { mexec_afn(file, argv, envp, envlen, modif, modiflen, modifn) ; strerr_dieexec(errno == ENOENT ? 127 : 126, file) ; } skalibs-2.14.1.1/src/libposixplz/000077500000000000000000000000001455624754300165535ustar00rootroot00000000000000skalibs-2.14.1.1/src/libposixplz/doublefork.c000066400000000000000000000020711455624754300210530ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #include pid_t doublefork () { char pack[8] ; int fd[2] ; pid_t child ; if (pipe(fd) == -1) return -1 ; child = fork() ; switch (child) { case -1: { fd_close(fd[1]) ; fd_close(fd[0]) ; return -1 ; } case 0: { pid_t pid ; fd_close(fd[0]) ; pid = fork() ; switch (pid) { case -1: _exit(errno) ; case 0: fd_close(fd[1]) ; return 0 ; } uint64_pack_big(pack, pid) ; _exit((allwrite(fd[1], pack, 8) < 8) ? errno : 0) ; } } fd_close(fd[1]) ; { uint64_t grandchild = 0 ; int wstat ; if (allread(fd[0], pack, 8) < 8) grandchild = 1 ; fd_close(fd[0]) ; wait_pid(child, &wstat) ; if (grandchild) return (errno = WIFSIGNALED(wstat) ? EINTR : WEXITSTATUS(wstat), -1) ; uint64_unpack_big(pack, &grandchild) ; return (pid_t)grandchild ; } } skalibs-2.14.1.1/src/libposixplz/execvep.c000066400000000000000000000005561455624754300203640ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include "posixplz-internal.h" void execvep (char const *file, char const *const *argv, char const *const *envp, char const *path) { if (strchr(file, '/')) execve(file, (char *const *)argv, (char *const *)envp) ; else execvep_internal(file, argv, envp, path) ; } skalibs-2.14.1.1/src/libposixplz/execvep_internal.c000066400000000000000000000017601455624754300222560ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include void execvep_internal (char const *file, char const *const *argv, char const *const *envp, char const *path) { if (!path) errno = EINVAL ; else { size_t pathlen = strlen(path) + 1 ; size_t filelen = strlen(file) ; int savederrno = 0 ; while (pathlen) { size_t split = byte_chr(path, pathlen - 1, ':') ; if (split) { char tmp[split + 2 + filelen] ; memcpy(tmp, path, split) ; tmp[split] = '/' ; memcpy(tmp + split + 1, file, filelen + 1) ; execve(tmp, (char *const *)argv, (char *const *)envp) ; if (errno != ENOENT) { savederrno = errno ; if ((errno != EACCES) && (errno != EPERM) && (errno != EISDIR) && (errno != ENOTDIR)) break ; } } path += split+1 ; pathlen -= split+1 ; } if (savederrno) errno = savederrno ; } } skalibs-2.14.1.1/src/libposixplz/execvep_loose.c000066400000000000000000000005351455624754300215620ustar00rootroot00000000000000/* ISC license. */ #include #include #include "posixplz-internal.h" void execvep_loose (char const *file, char const *const *argv, char const *const *envp, char const *path) { if (file[0] == '/') execve(file, (char *const *)argv, (char *const *)envp) ; else execvep_internal(file, argv, envp, path) ; } skalibs-2.14.1.1/src/libposixplz/getpeereid.c000066400000000000000000000021731455624754300210370ustar00rootroot00000000000000/* ISC license. */ #include #ifdef SKALIBS_HASGETPEEREID /* syscall exists - do nothing */ #else #ifdef SKALIBS_HASSOPEERCRED /* implementation with SO_PEERCRED */ #include #include #include #include int getpeereid (int s, uid_t *u, gid_t *g) { struct ucred blah ; socklen_t len = sizeof(blah) ; if (getsockopt(s, SOL_SOCKET, SO_PEERCRED, &blah, &len) == -1) return -1 ; *u = blah.uid ; *g = blah.gid ; return 0 ; } #else #ifdef SKALIBS_HASGETPEERUCRED /* implementation with getpeerucred() */ #include #include #include int getpeereid (int s, uid_t *u, gid_t *g) { ucred_t *cred = 0 ; if (getpeerucred(s, &cred) == -1) return -1 ; *u = ucred_geteuid(cred) ; *g = ucred_getegid(cred) ; ucred_free(cred) ; return 0 ; } #else /* can't find a real implementation, make a stub */ #include #include int getpeereid (int s, uid_t *uid, gid_t *gid) { (void)s ; *uid = *gid = -1 ; errno = ENOSYS ; return -1 ; } #endif #endif #endif skalibs-2.14.1.1/src/libposixplz/memmem.c000066400000000000000000000144551455624754300202050ustar00rootroot00000000000000/* MIT license. See below. */ #include #ifndef SKALIBS_HASMEMMEM /* If the underlying platform does not provide memmem(), then the following implementation is used. It comes from the musl libc, which is MIT-licensed: ---------------------------------------------------------------------- Copyright © 2005-2017 Rich Felker, Szabolcs Nagy, Timo Teräs, Alexander Monakov Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ---------------------------------------------------------------------- */ #include #include #include static char *twobyte_memmem(const unsigned char *h, size_t k, const unsigned char *n) { uint16_t nw = n[0]<<8 | n[1], hw = h[0]<<8 | h[1]; for (h+=2, k-=2; k; k--, hw = hw<<8 | *h++) if (hw == nw) return (char *)h-2; return hw == nw ? (char *)h-2 : 0; } static char *threebyte_memmem(const unsigned char *h, size_t k, const unsigned char *n) { uint32_t nw = n[0]<<24 | n[1]<<16 | n[2]<<8; uint32_t hw = h[0]<<24 | h[1]<<16 | h[2]<<8; for (h+=3, k-=3; k; k--, hw = (hw|*h++)<<8) if (hw == nw) return (char *)h-3; return hw == nw ? (char *)h-3 : 0; } static char *fourbyte_memmem(const unsigned char *h, size_t k, const unsigned char *n) { uint32_t nw = n[0]<<24 | n[1]<<16 | n[2]<<8 | n[3]; uint32_t hw = h[0]<<24 | h[1]<<16 | h[2]<<8 | h[3]; for (h+=4, k-=4; k; k--, hw = hw<<8 | *h++) if (hw == nw) return (char *)h-4; return hw == nw ? (char *)h-4 : 0; } #define MAX(a,b) ((a)>(b)?(a):(b)) #define MIN(a,b) ((a)<(b)?(a):(b)) #define BITOP(a,b,op) \ ((a)[(size_t)(b)/(8*sizeof *(a))] op (size_t)1<<((size_t)(b)%(8*sizeof *(a)))) static char *twoway_memmem(const unsigned char *h, const unsigned char *z, const unsigned char *n, size_t l) { size_t i, ip, jp, k, p, ms, p0, mem, mem0; size_t byteset[32 / sizeof(size_t)] = { 0 }; size_t shift[256]; /* Computing length of needle and fill shift table */ for (i=0; i n[jp+k]) { jp += k; k = 1; p = jp - ip; } else { ip = jp++; k = p = 1; } } ms = ip; p0 = p; /* And with the opposite comparison */ ip = -1; jp = 0; k = p = 1; while (jp+k ms+1) ms = ip; else p = p0; /* Periodic needle? */ if (memcmp(n, n+p, ms+1)) { mem0 = 0; p = MAX(ms, l-ms-1) + 1; } else mem0 = l-p; mem = 0; /* Search loop */ for (;;) { /* If remainder of haystack is shorter than needle, done */ if (z-h < l) return 0; /* Check last byte first; advance by shift on mismatch */ if (BITOP(byteset, h[l-1], &)) { k = l-shift[h[l-1]]; if (k) { if (mem0 && mem && k < p) k = l-p; h += k; mem = 0; continue; } } else { h += l; mem = 0; continue; } /* Compare right half */ for (k=MAX(ms+1,mem); kmem && n[k-1] == h[k-1]; k--); if (k <= mem) return (char *)h; h += p; mem = mem0; } } void *memmem(const void *h0, size_t k, const void *n0, size_t l) { const unsigned char *h = h0, *n = n0; /* Return immediately on empty needle */ if (!l) return (void *)h; /* Return immediately when needle is longer than haystack */ if (k #include #include static int f (char const *fn, mode_t mode, void *data) { dev_t *devp = data ; mode_t m = umask(0) ; int r = mknod(fn, (mode & 00777) | S_IFBLK, *devp) ; umask(m) ; if (r == -1) return -1 ; r = open_readb(fn) ; if (r == -1) unlink_void(fn) ; return r ; } int mkbtemp (char *s, mode_t mode, dev_t dev) { return mkfiletemp(s, &f, mode, &dev) ; } skalibs-2.14.1.1/src/libposixplz/mkctemp.c000066400000000000000000000007211455624754300203570ustar00rootroot00000000000000/* ISC license. */ #include #include #include static int f (char const *fn, mode_t mode, void *data) { dev_t *devp = data ; mode_t m = umask(0) ; int r = mknod(fn, (mode & 00777) | S_IFCHR, *devp) ; umask(m) ; if (r == -1) return -1 ; r = open_readb(fn) ; if (r == -1) unlink_void(fn) ; return r ; } int mkctemp (char *s, mode_t mode, dev_t dev) { return mkfiletemp(s, &f, mode, &dev) ; } skalibs-2.14.1.1/src/libposixplz/mkfiletemp.c000066400000000000000000000007661455624754300210650ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include int mkfiletemp (char *s, create_func_ref f, mode_t mode, void *data) { size_t len = strlen(s) ; size_t xlen = 0 ; int r ; for (; xlen < len ; xlen++) if (s[len - 1 - xlen] != 'X') break ; if (xlen < 6) return (errno = EINVAL, -1) ; do { random_name_early(s + len - xlen, xlen) ; r = (*f)(s, mode, data) ; } while (r == -1 && errno == EEXIST) ; return r ; } skalibs-2.14.1.1/src/libposixplz/mkhtemp.c000066400000000000000000000002341455624754300203630ustar00rootroot00000000000000/* ISC license. */ #include #include int mkhtemp (char const *src, char *dst) { return mklinktemp(src, dst, &link) ; } skalibs-2.14.1.1/src/libposixplz/mklinktemp.c000066400000000000000000000006411455624754300210730ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include "posixplz-internal.h" static int f (char const *dst, mode_t mode, void *data) { linkarg *la = data ; (void)mode ; return (*la->lf)(la->src, dst) ; } int mklinktemp (char const *src, char *dst, link_func_ref lf) { linkarg la = { .lf = lf, .src = src } ; return mkfiletemp(dst, &f, 0600, &la) ; } skalibs-2.14.1.1/src/libposixplz/mkltemp.c000066400000000000000000000002371455624754300203720ustar00rootroot00000000000000/* ISC license. */ #include #include int mkltemp (char const *src, char *dst) { return mklinktemp(src, dst, &symlink) ; } skalibs-2.14.1.1/src/libposixplz/mkptemp.c000066400000000000000000000001471455624754300203760ustar00rootroot00000000000000/* ISC license. */ #include int mkptemp (char *s) { return mkptemp2(s, 0) ; } skalibs-2.14.1.1/src/libposixplz/mkptemp2.c000066400000000000000000000011211455624754300204510ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include static int f (char const *fn, mode_t mode, void *data) { unsigned int flags = *(unsigned int *)data ; mode_t m = umask(0) ; int r = mkfifo(fn, mode) ; umask(m) ; if (r == -1) return -1 ; r = flags & O_NONBLOCK ? flags & O_CLOEXEC ? openc_read(fn) : open_read(fn) : flags & O_CLOEXEC ? openc_readb(fn) : open_readb(fn) ; if (r == -1) unlink_void(fn) ; return r ; } int mkptemp2 (char *s, unsigned int flags) { return mkfiletemp(s, &f, 0600, &flags) ; } skalibs-2.14.1.1/src/libposixplz/munmap_void.c000066400000000000000000000003011455624754300212270ustar00rootroot00000000000000/* ISC license. */ #include #include #include void munmap_void (void *addr, size_t len) { int e = errno ; munmap(addr, len) ; errno = e ; } skalibs-2.14.1.1/src/libposixplz/posixplz-internal.h000066400000000000000000000004751455624754300224340ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_POSIXPLZ_INTERNAL_H #define SKALIBS_POSIXPLZ_INTERNAL_H typedef struct linkarg_s linkarg, *linkarg_ref ; struct linkarg_s { link_func_ref lf ; char const *src ; } ; extern void execvep_internal (char const *, char const *const *, char const *const *, char const *) ; #endif skalibs-2.14.1.1/src/libposixplz/setgroups.c000066400000000000000000000020701455624754300207510ustar00rootroot00000000000000/* ISC license. */ #include #ifdef SKALIBS_HASSETGROUPS #include #include #include #include #include #include int setgroups_and_gid (gid_t g, size_t n, gid_t const *tab) { size_t i = 1 ; if (!n) return setgroups(1, &g) ; if (tab[0] == g) return setgroups(n, tab) ; for (; i < n ; i++) if (tab[i] == g) break ; if (i < n) { gid_t newtab[n] ; newtab[0] = g ; memcpy(newtab + 1, tab, i * sizeof(gid_t)) ; memcpy(newtab + i + 1, tab + i + 1, (n - i - 1) * sizeof(gid_t)) ; return setgroups(n, newtab) ; } else { gid_t newtab[n+1] ; newtab[0] = g ; memcpy(newtab + 1, tab, n * sizeof(gid_t)) ; return setgroups(n+1, newtab) ; } } int setgroups_with_egid (size_t n, gid_t const *tab) { return setgroups_and_gid(getegid(), n, tab) ; } int skalibs_setgroups (size_t n, gid_t const *tab) { #ifdef SKALIBS_BSD_SUCKS return setgroups_with_egid(n, tab) ; #else return setgroups(n, tab) ; #endif } #endif skalibs-2.14.1.1/src/libposixplz/strcasestr.c000066400000000000000000000011711455624754300211140ustar00rootroot00000000000000/* ISC license. */ #include #ifndef SKALIBS_HASSTRCASESTR #include #include /* XXX: copies strings on the stack, careful with long strings */ char *strcasestr (char const *haystack, char const *needle) { size_t nlen = strlen(needle) ; size_t hlen = strlen(haystack) ; char *p ; char lneedle[nlen + 1] ; char lhaystack[hlen + 1] ; memcpy(lneedle, needle, nlen + 1) ; memcpy(lhaystack, haystack, hlen + 1) ; case_lowerb(lneedle, nlen) ; case_lowerb(lhaystack, hlen) ; p = strstr(lhaystack, lneedle) ; return p ? haystack + (p - lhaystack) : 0 ; } #endif skalibs-2.14.1.1/src/libposixplz/strnlen.c000066400000000000000000000003671455624754300204120ustar00rootroot00000000000000/* ISC license. */ #include #ifndef SKALIBS_HASSTRNLEN #include #include #include size_t strnlen (char const *s, size_t max) { return byte_chr(s, max, 0) ; } #endif skalibs-2.14.1.1/src/libposixplz/touch.c000066400000000000000000000016201455624754300200400ustar00rootroot00000000000000/* ISC license. */ #include #ifdef SKALIBS_HASFUTIMENS #include #include #include #include #include int touch (char const *file) { int r ; int fd = open_create(file) ; if (fd < 0) return 0 ; r = futimens(fd, 0) >= 0 ; fd_close(fd) ; return r ; } #else #ifdef SKALIBS_HASFUTIMES #include #include #include #include int touch (char const *file) { int r ; int fd = open_create(file) ; if (fd < 0) return 0 ; r = futimes(fd, 0) >= 0 ; fd_close(fd) ; return r ; } #else #include #include #include int touch (char const *file) { int fd = open_create(file) ; if (fd < 0) return 0 ; fd_close(fd) ; return utimes(file, 0) >= 0 ; } #endif #endif skalibs-2.14.1.1/src/libposixplz/unlink_void.c000066400000000000000000000002631455624754300212410ustar00rootroot00000000000000/* ISC license. */ #include #include #include void unlink_void (char const *file) { int e = errno ; unlink(file) ; errno = e ; } skalibs-2.14.1.1/src/librandom/000077500000000000000000000000001455624754300161435ustar00rootroot00000000000000skalibs-2.14.1.1/src/librandom/autosurf.c000066400000000000000000000023531455624754300201620ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include /* Writes 160 bytes of crap into s. Certainly not cryptographically secure or 100% unpredictable, but we're only using this to seed a fallback internal PRNG. */ static void makeseed (char *s) { SHA1Schedule bak = SHA1_INIT() ; { tain now ; char tmp[256] ; uint32_t x = getpid() ; uint32_pack(tmp, x) ; /* if valgrind sends you here, tell it to stfu */ x = getppid() ; uint32_pack(tmp + 4, x) ; tain_now(&now) ; tain_pack(tmp + 8, &now) ; sha1_update(&bak, tmp, 8 + TAIN_PACK) ; gethostname(tmp, 256) ; sha1_update(&bak, tmp, 256) ; sha1_final(&bak, tmp) ; sha1_init(&bak) ; sha1_update(&bak, tmp, 20) ; } { char i = 0 ; for (; i < 8 ; i++) { SHA1Schedule ctx = bak ; sha1_update(&ctx, &i, 1) ; sha1_final(&ctx, s + 20*i) ; } } } void autosurf (char *s, size_t n) { static SURFSchedule ctx = SURFSCHEDULE_ZERO ; static int need4seed = 1 ; if (need4seed) { char seed[160] ; makeseed(seed) ; surf_init(&ctx, seed) ; need4seed = 0 ; } surf(&ctx, s, n) ; } skalibs-2.14.1.1/src/librandom/autosurf_name.c000066400000000000000000000002341455624754300211560ustar00rootroot00000000000000/* ISC license. */ #include #include void autosurf_name (char *s, size_t n) { random_name_from(s, n, &autosurf) ; } skalibs-2.14.1.1/src/librandom/random_buf.c000066400000000000000000000013501455624754300204220ustar00rootroot00000000000000/* ISC license. */ #include #if defined(SKALIBS_HASARC4RANDOM) #include #include #include void random_buf (char *s, size_t n) { arc4random_buf(s, n) ; } #elif defined(SKALIBS_HASGETRANDOM) #include #include void random_buf (char *s, size_t n) { while (n) { ssize_t r = getrandom(s, n, 0) ; if (r >= 0) { s += r ; n -= r ; } } } #elif defined(SKALIBS_HASDEVURANDOM) #include void random_buf (char *s, size_t n) { random_devurandom(s, n) ; } #else #include #include void random_buf (char *s, size_t n) { autosurf(s, n) ; } #endif skalibs-2.14.1.1/src/librandom/random_buf_early.c000066400000000000000000000020201455624754300216110ustar00rootroot00000000000000/* ISC license. */ #include #if defined(SKALIBS_HASARC4RANDOM) && !defined(__linux__) #include #include #include void random_buf_early (char *s, size_t n) { arc4random_buf(s, n) ; } #elif defined(SKALIBS_HASGETRANDOM) && defined(SKALIBS_HASGRNDINSECURE) #include #include #include void random_buf_early (char *s, size_t n) { static int broken = 0 ; if (broken) goto bleh ; while (n) { ssize_t r = getrandom(s, n, GRND_INSECURE) ; if (r == -1) { if (errno != EINTR) goto breakit ; else continue ; } s += r ; n -= r ; } return ; breakit: broken = 1 ; bleh: random_devurandom(s, n) ; } #elif defined(SKALIBS_HASDEVURANDOM) #include void random_buf_early (char *s, size_t n) { random_devurandom(s, n) ; } #else #include #include void random_buf_early (char *s, size_t n) { autosurf(s, n) ; } #endif skalibs-2.14.1.1/src/librandom/random_devurandom.c000066400000000000000000000010751455624754300220160ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include void random_devurandom (char *s, size_t n) { static int random_fd = -1 ; size_t r ; int e = errno ; if (random_fd < 0) { random_fd = openbc_read("/dev/urandom") ; if (random_fd < 0) strerr_diefu2sys(111, "open ", "/dev/urandom") ; } errno = EPIPE ; r = allread(random_fd, s, n) ; if (r < n) strerr_diefu2sys(111, "read from ", "/dev/urandom") ; errno = e ; } skalibs-2.14.1.1/src/librandom/random_name_from.c000066400000000000000000000005001455624754300216050ustar00rootroot00000000000000/* ISC license. */ #include #include void random_name_from (char *s, size_t n, randomgen_func_ref f) { static char const random_oklist[64] = "ABCDEFGHIJKLMNOPQRSTUVWXYZghijklmnopqrstuvwxyz-_0123456789abcdef" ; (*f)(s, n) ; while (n--) s[n] = random_oklist[s[n] & 63] ; } skalibs-2.14.1.1/src/librandom/random_sauniquename_from.c000066400000000000000000000007661455624754300233760ustar00rootroot00000000000000/* ISC license. */ #include #include #include int random_sauniquename_from (stralloc *sa, size_t n, randomgen_func_ref f) { size_t base = sa->len ; int wasnull = !sa->s ; if (!sauniquename(sa)) return 0 ; if (!stralloc_readyplus(sa, n+1)) goto err ; stralloc_catb(sa, ":", 1) ; random_name_from(sa->s + sa->len, n, f) ; sa->len += n ; return 1 ; err: if (wasnull) stralloc_free(sa) ; else sa->len = base ; return 0 ; } skalibs-2.14.1.1/src/librandom/random_uint32_from.c000066400000000000000000000005601455624754300220170ustar00rootroot00000000000000/* ISC license. */ #include #include #include uint32_t random_uint32_from (uint32_t n, randomgen_func_ref f) { uint32_t min, x ; if (n < 2) return 0 ; min = -n % n ; for (;;) { char tmp[4] ; (*f)(tmp, 4) ; uint32_unpack_big(tmp, &x) ; if (x >= min) break ; } return x % n ; } skalibs-2.14.1.1/src/librandom/random_unsort_from.c000066400000000000000000000006541455624754300222310ustar00rootroot00000000000000/* ISC license. */ #include #include #include void random_unsort_from (char *s, size_t n, size_t chunksize, randomgen_func_ref f) { char tmp[chunksize] ; while (n--) { uint32_t i = random_uint32_from(n+1, f) ; memcpy(tmp, s + i * chunksize, chunksize) ; memcpy(s + i * chunksize, s + n * chunksize, chunksize) ; memcpy(s + n * chunksize, tmp, chunksize) ; } } skalibs-2.14.1.1/src/librandom/surf.c000066400000000000000000000025261455624754300172730ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #define ROTATE(x, b) (((x) << (b)) | ((x) >> (32 - (b)))) #define MUSH(i, b) x = t[i] += (((x ^ ctx->seed[i]) + sum) ^ ROTATE(x, b)) static void surfit (SURFSchedule *ctx) { uint32_t t[12] ; uint32_t z[8] ; uint32_t x ; uint32_t sum = 0 ; uint32_t i = 0, loop = 0 ; ; if (!++ctx->in[0] && !++ctx->in[1] && !++ctx->in[2]) ++ctx->in[3] ; for (; i < 12 ; i++) t[i] = ctx->in[i] ^ ctx->seed[12+i] ; for (i = 0 ; i < 8 ; i++) z[i] = ctx->seed[24+i] ; x = t[11] ; for (; loop < 2 ; loop++) { for (i = 0 ; i < 16 ; i++) { sum += 0x9e3779b9 ; MUSH(0, 5) ; MUSH(1, 7) ; MUSH(2, 9) ; MUSH(3, 13) ; MUSH(4, 5) ; MUSH(5, 7) ; MUSH(6, 9) ; MUSH(7, 13) ; MUSH(8, 5) ; MUSH(9, 7) ; MUSH(10, 9) ; MUSH(11, 13) ; } for (i = 0 ; i < 8 ; i++) z[i] ^= t[i+4] ; } for (i = 0 ; i < 8 ; i++) uint32_pack(ctx->out + (i<<2), z[i]) ; } void surf (SURFSchedule *ctx, char *s, size_t n) { { size_t i = 32 - ctx->pos ; if (n < i) i = n ; memcpy(s, ctx->out + ctx->pos, i) ; s += i ; n -= i ; ctx->pos += i ; } while (n > 32) { surfit(ctx) ; memcpy(s, ctx->out, 32) ; s += 32 ; n -= 32 ; } if (!n) return ; surfit(ctx) ; memcpy(s, ctx->out, n) ; ctx->pos = n ; } skalibs-2.14.1.1/src/librandom/surf_init.c000066400000000000000000000005561455624754300203170ustar00rootroot00000000000000/* ISC license. */ #include #include #include void surf_init (SURFSchedule *ctx, char const *s) { SURFSchedule z = SURFSCHEDULE_ZERO ; for (uint32_t i = 4 ; i < 12 ; i++) uint32_unpack(s + (i<<2) - 16, z.in + i) ; for (uint32_t i = 0 ; i < 32 ; i++) uint32_unpack(s + 32 + (i<<2), z.seed + i) ; *ctx = z ; } skalibs-2.14.1.1/src/libstdcrypto/000077500000000000000000000000001455624754300167165ustar00rootroot00000000000000skalibs-2.14.1.1/src/libstdcrypto/blake2s-internal.h000066400000000000000000000003731455624754300222270ustar00rootroot00000000000000 /* ISC license. */ #ifndef SKALIBS_BLAKE2S_INTERNAL_H #define SKALIBS_BLAKE2S_INTERNAL_H #include #include #include extern void blake2s_transform (blake2s_ctx *, char const *, size_t, uint32_t) ; #endif skalibs-2.14.1.1/src/libstdcrypto/blake2s_final.c000066400000000000000000000005721455624754300215620ustar00rootroot00000000000000 /* ISC license. */ #include #include #include #include "blake2s-internal.h" void blake2s_final (blake2s_ctx *ctx, char *out) { ctx->f[0] = -1 ; memset(ctx->buf + ctx->buflen, 0, 64 - ctx->buflen) ; blake2s_transform(ctx, ctx->buf, 1, ctx->buflen) ; uint32_littlen(ctx->h, 8) ; memcpy(out, ctx->h, ctx->outlen) ; } skalibs-2.14.1.1/src/libstdcrypto/blake2s_init.c000066400000000000000000000002411455624754300214250ustar00rootroot00000000000000 /* ISC license. */ #include void blake2s_init (blake2s_ctx *ctx, size_t outlen) { blake2s_ctx c = BLAKE2S_INIT(outlen) ; *ctx = c ; } skalibs-2.14.1.1/src/libstdcrypto/blake2s_transform.c000066400000000000000000000045631455624754300225100ustar00rootroot00000000000000 /* ISC license. */ #include #include #include #include "blake2s-internal.h" static uint32_t const blake2s_iv[8] = { 0x6A09E667UL, 0xBB67AE85UL, 0x3C6EF372UL, 0xA54FF53AUL, 0x510E527FUL, 0x9B05688CUL, 0x1F83D9ABUL, 0x5BE0CD19UL }; static uint8_t const blake2s_sigma[10][16] = { { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }, { 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 }, { 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 }, { 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 }, { 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13 }, { 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9 }, { 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11 }, { 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10 }, { 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5 }, { 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0 } } ; static uint32_t ror32 (uint32_t word, unsigned int shift) { return (word >> (shift & 31)) | (word << ((-shift) & 31)) ; } #define G(r, i, a, b, c, d) do \ { \ a += b + m[blake2s_sigma[r][i<<1]] ; \ d = ror32(d ^ a, 16) ; \ c += d ; \ b = ror32(b ^ c, 12) ; \ a += b + m[blake2s_sigma[r][(i<<1)+1]] ; \ d = ror32(d ^ a, 8) ; \ c += d ; \ b = ror32(b ^ c, 7) ; \ } while (0) void blake2s_transform (blake2s_ctx *ctx, char const *block, size_t n, uint32_t inc) { uint32_t m[16] ; uint32_t v[16] ; while (n--) { unsigned int i = 0 ; ctx->t[0] += inc ; ctx->t[1] += (ctx->t[0] < inc) ; for (; i < 16 ; i++) uint32_unpack(block + (i << 2), m + i) ; for (i = 0 ; i < 8 ; i++) v[i] = ctx->h[i] ; v[8] = blake2s_iv[0] ; v[9] = blake2s_iv[1] ; v[10] = blake2s_iv[2] ; v[11] = blake2s_iv[3] ; v[12] = blake2s_iv[4] ^ ctx->t[0] ; v[13] = blake2s_iv[5] ^ ctx->t[1] ; v[14] = blake2s_iv[6] ^ ctx->f[0] ; v[15] = blake2s_iv[7] ^ ctx->f[1] ; for (i = 0 ; i < 10 ; i++) { G(i, 0, v[0], v[ 4], v[ 8], v[12]) ; G(i, 1, v[1], v[ 5], v[ 9], v[13]) ; G(i, 2, v[2], v[ 6], v[10], v[14]) ; G(i, 3, v[3], v[ 7], v[11], v[15]) ; G(i, 4, v[0], v[ 5], v[10], v[15]) ; G(i, 5, v[1], v[ 6], v[11], v[12]) ; G(i, 6, v[2], v[ 7], v[ 8], v[13]) ; G(i, 7, v[3], v[ 4], v[ 9], v[14]) ; } for (i = 0 ; i < 8 ; i++) ctx->h[i] ^= v[i] ^ v[i+8] ; block += 64 ; } } skalibs-2.14.1.1/src/libstdcrypto/blake2s_update.c000066400000000000000000000011031455624754300217420ustar00rootroot00000000000000 /* ISC license. */ #include #include #include "blake2s-internal.h" void blake2s_update (blake2s_ctx *ctx, char const *s, size_t len) { size_t w = 64 - ctx->buflen ; if (!len) return ; if (len > w) { memcpy(ctx->buf + ctx->buflen, s, w) ; blake2s_transform(ctx, ctx->buf, 1, 64) ; ctx->buflen = 0 ; s += w ; len -= w ; } if (len > 64) { size_t n = (len+63)/64 - 1 ; blake2s_transform(ctx, s, n, 64) ; n <<= 6 ; s += n ; len -= n ; } memcpy(ctx->buf + ctx->buflen, s, len) ; ctx->buflen += len ; } skalibs-2.14.1.1/src/libstdcrypto/sha1-internal.h000066400000000000000000000004211455624754300215320ustar00rootroot00000000000000/* ISC license. */ #ifndef SHA1_INTERNAL_H #define SHA1_INTERNAL_H #include #include extern void sha1_feed (SHA1Schedule *, unsigned char) ; extern void sha1_transform (uint32_t * /* 5 uint32s */, uint32_t const * /* 16 uint32s */) ; #endif skalibs-2.14.1.1/src/libstdcrypto/sha1_feed.c000066400000000000000000000007551455624754300207100ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include "sha1-internal.h" void sha1_feed (SHA1Schedule *ctx, unsigned char inb) { uint32_t tmp ; ctx->in[ctx->b>>2] <<= 8 ; ctx->in[ctx->b>>2] |= T8(inb) ; if (++ctx->b >= 64) { sha1_transform(ctx->buf, ctx->in) ; ctx->b = 0 ; for (uint32_t i = 0 ; i < 16 ; i++) ctx->in[i] = 0 ; } tmp = ctx->bits[0] ; ctx->bits[0] += 8 ; if (tmp > ctx->bits[0]) ctx->bits[1]++ ; } skalibs-2.14.1.1/src/libstdcrypto/sha1_final.c000066400000000000000000000006761455624754300211000ustar00rootroot00000000000000/* ISC license. */ #include #include #include "sha1-internal.h" void sha1_final (SHA1Schedule *ctx, char *digest) { char pack[8] ; uint32_pack_big(pack, ctx->bits[1]) ; uint32_pack_big(pack+4, ctx->bits[0]) ; sha1_feed(ctx, 0x80) ; while (ctx->b != 56) sha1_feed(ctx, 0) ; sha1_update(ctx, pack, 8) ; for (unsigned int i = 0 ; i < 5 ; i++) uint32_pack_big(digest + (i<<2), ctx->buf[i]) ; } skalibs-2.14.1.1/src/libstdcrypto/sha1_init.c000066400000000000000000000005321455624754300207410ustar00rootroot00000000000000/* ISC license. */ #include void sha1_init (SHA1Schedule *ctx) { ctx->buf[0] = 0x67452301U ; ctx->buf[1] = 0xefcdab89U ; ctx->buf[2] = 0x98badcfeU ; ctx->buf[3] = 0x10325476U ; ctx->buf[4] = 0xc3d2e1f0U ; ctx->bits[0] = ctx->bits[1] = 0 ; for (unsigned int i = 0 ; i < 16 ; i++) ctx->in[i] = 0 ; ctx->b = 0 ; } skalibs-2.14.1.1/src/libstdcrypto/sha1_transform.c000066400000000000000000000020411455624754300220060ustar00rootroot00000000000000/* ISC license. */ #include #include "sha1-internal.h" #define F1(x, y, z) ((x & y) | ((~x) & z)) #define F2(x, y, z) (x ^ y ^ z) #define F3(x, y, z) ((x & y) | (x & z) | (y & z)) #define F4(x, y, z) (x ^ y ^ z) #define SHA1STEP(f, data) \ { \ uint32_t tmp = e + f(b, c, d) + data + ((a<<5) | (a>>27)); \ e = d ; \ d = c ; \ c = (b<<30) | (b>>2) ; \ b = a ; \ a = tmp ; \ } void sha1_transform (uint32_t *buf, uint32_t const *in) { uint32_t a = buf[0], b = buf[1], c = buf[2], d = buf[3], e = buf[4] ; uint32_t w[80] ; unsigned int i = 0 ; for (; i < 16 ; i++) w[i] = in[i] ; for (; i < 80 ; i++) { w[i] = w[i-3] ^ w[i-8] ^ w[i-14] ^ w[i-16] ; w[i] = (w[i]<<1) | (w[i]>>31) ; } for (i = 0 ; i < 20 ; i++) SHA1STEP(F1, w[i] + 0x5a827999U) ; for (; i < 40 ; i++) SHA1STEP(F2, w[i] + 0x6ed9eba1U) ; for (; i < 60 ; i++) SHA1STEP(F3, w[i] + 0x8f1bbcdcU) ; for (; i < 80 ; i++) SHA1STEP(F4, w[i] + 0xca62c1d6U) ; buf[0] += a ; buf[1] += b ; buf[2] += c ; buf[3] += d ; buf[4] += e ; } skalibs-2.14.1.1/src/libstdcrypto/sha1_update.c000066400000000000000000000003411455624754300212560ustar00rootroot00000000000000/* ISC license. */ #include #include "sha1-internal.h" void sha1_update (SHA1Schedule *ctx, char const *buf, size_t len) { size_t i = 0 ; for (; i < len ; i++) sha1_feed(ctx, (unsigned char)buf[i]) ; } skalibs-2.14.1.1/src/libstdcrypto/sha256-internal.h000066400000000000000000000003741455624754300217150ustar00rootroot00000000000000/* ISC license. */ #ifndef SHA256_INTERNAL_H #define SHA256_INTERNAL_H #include #include extern void sha256_feed (SHA256Schedule *, unsigned char) ; extern void sha256_transform (uint32_t *, uint32_t const *) ; #endif skalibs-2.14.1.1/src/libstdcrypto/sha256_feed.c000066400000000000000000000007671455624754300210670ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include "sha256-internal.h" void sha256_feed (SHA256Schedule *ctx, unsigned char inb) { uint32_t tmp ; ctx->in[ctx->b>>2] <<= 8 ; ctx->in[ctx->b>>2] |= T8(inb) ; if (++ctx->b >= 64) { sha256_transform(ctx->buf, ctx->in) ; ctx->b = 0 ; for (uint32_t i = 0; i < 16 ; i++) ctx->in[i] = 0 ; } tmp = ctx->bits[0] ; ctx->bits[0] += 8 ; if (tmp > ctx->bits[0]) ctx->bits[1]++ ; } skalibs-2.14.1.1/src/libstdcrypto/sha256_final.c000066400000000000000000000014721455624754300212470ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include "sha256-internal.h" void sha256_final (SHA256Schedule *ctx, char *digest) { unsigned char *p = (unsigned char *)digest ; uint32_t bits[2] = { ctx->bits[0], ctx->bits[1] } ; sha256_feed(ctx, 0x80) ; while (ctx->b != 56) sha256_feed(ctx, 0) ; sha256_feed(ctx, T8(bits[1]>>24)) ; sha256_feed(ctx, T8(bits[1]>>16)) ; sha256_feed(ctx, T8(bits[1]>>8)) ; sha256_feed(ctx, T8(bits[1])) ; sha256_feed(ctx, T8(bits[0]>>24)) ; sha256_feed(ctx, T8(bits[0]>>16)) ; sha256_feed(ctx, T8(bits[0]>>8)) ; sha256_feed(ctx, T8(bits[0])) ; for (uint32_t i = 0 ; i < 8 ; i++) { *p++ = T8(ctx->buf[i]>>24) ; *p++ = T8(ctx->buf[i]>>16) ; *p++ = T8(ctx->buf[i]>>8) ; *p++ = T8(ctx->buf[i]) ; } } skalibs-2.14.1.1/src/libstdcrypto/sha256_init.c000066400000000000000000000002261455624754300211150ustar00rootroot00000000000000/* ISC license. */ #include void sha256_init (SHA256Schedule *ctx) { SHA256Schedule empty = SHA256_INIT() ; *ctx = empty ; } skalibs-2.14.1.1/src/libstdcrypto/sha256_transform.c000066400000000000000000000040321455624754300221640ustar00rootroot00000000000000/* ISC license. */ #include "sha256-internal.h" #define F1(x, y, z) ((x & y) | ((~x) & z)) #define F2(x, y, z) ((x & y) | (x & z) | (y & z)) #define ROTR(x,n) (((x)>>(n)) | ((x)<<(32-(n)))) #define CAPITALSIGMA0(x) (ROTR(x,2)^ROTR(x,13)^ROTR(x,22)) #define CAPITALSIGMA1(x) (ROTR(x,6)^ROTR(x,11)^ROTR(x,25)) #define SMALLSIGMA0(x) (ROTR(x,7)^ROTR(x,18)^((x)>>3)) #define SMALLSIGMA1(x) (ROTR(x,17)^ROTR(x,19)^((x)>>10)) static uint32_t const sha256_constants[64] = { 0x428a2f98U, 0x71374491U, 0xb5c0fbcfU, 0xe9b5dba5U, 0x3956c25bU, 0x59f111f1U, 0x923f82a4U, 0xab1c5ed5U, 0xd807aa98U, 0x12835b01U, 0x243185beU, 0x550c7dc3U, 0x72be5d74U, 0x80deb1feU, 0x9bdc06a7U, 0xc19bf174U, 0xe49b69c1U, 0xefbe4786U, 0x0fc19dc6U, 0x240ca1ccU, 0x2de92c6fU, 0x4a7484aaU, 0x5cb0a9dcU, 0x76f988daU, 0x983e5152U, 0xa831c66dU, 0xb00327c8U, 0xbf597fc7U, 0xc6e00bf3U, 0xd5a79147U, 0x06ca6351U, 0x14292967U, 0x27b70a85U, 0x2e1b2138U, 0x4d2c6dfcU, 0x53380d13U, 0x650a7354U, 0x766a0abbU, 0x81c2c92eU, 0x92722c85U, 0xa2bfe8a1U, 0xa81a664bU, 0xc24b8b70U, 0xc76c51a3U, 0xd192e819U, 0xd6990624U, 0xf40e3585U, 0x106aa070U, 0x19a4c116U, 0x1e376c08U, 0x2748774cU, 0x34b0bcb5U, 0x391c0cb3U, 0x4ed8aa4aU, 0x5b9cca4fU, 0x682e6ff3U, 0x748f82eeU, 0x78a5636fU, 0x84c87814U, 0x8cc70208U, 0x90befffaU, 0xa4506cebU, 0xbef9a3f7U, 0xc67178f2U } ; void sha256_transform (uint32_t *buf, uint32_t const *in) { uint32_t w[64] ; unsigned int i = 0 ; uint32_t a = buf[0], b = buf[1], c = buf[2], d = buf[3], e = buf[4], f = buf[5], g = buf[6], h = buf[7] ; for (; i < 16 ; i++) w[i] = in[i] ; for (; i < 64 ; i++) w[i] = SMALLSIGMA1(w[i-2]) + w[i-7] + SMALLSIGMA0(w[i-15]) + w[i-16] ; for (i = 0 ; i < 64 ; i++) { uint32_t temp1 = h + CAPITALSIGMA1(e) + F1(e, f, g) + sha256_constants[i] + w[i] ; uint32_t temp2 = CAPITALSIGMA0(a) + F2(a, b, c) ; h = g ; g = f ; f = e ; e = d + temp1 ; d = c ; c = b ; b = a ; a = temp1 + temp2 ; } buf[0] += a ; buf[1] += b ; buf[2] += c ; buf[3] += d ; buf[4] += e ; buf[5] += f ; buf[6] += g ; buf[7] += h ; } skalibs-2.14.1.1/src/libstdcrypto/sha256_update.c000066400000000000000000000003471455624754300214400ustar00rootroot00000000000000/* ISC license. */ #include #include "sha256-internal.h" void sha256_update (SHA256Schedule *ctx, char const *buf, size_t len) { for (size_t i = 0 ; i < len ; i++) sha256_feed(ctx, (unsigned char)buf[i]) ; } skalibs-2.14.1.1/src/libstdcrypto/sha512-internal.h000066400000000000000000000002671455624754300217110ustar00rootroot00000000000000/* ISC license. */ #ifndef SHA512_INTERNAL_H #define SHA512_INTERNAL_H #include extern void sha512_transform (SHA512Schedule *, unsigned char const *) ; #endif skalibs-2.14.1.1/src/libstdcrypto/sha512_final.c000066400000000000000000000011271455624754300212370ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include "sha512-internal.h" void sha512_final (SHA512Schedule *ctx, char *digest) { unsigned int pad = ctx->len & 0x7fU ; ctx->buf[pad++] = 0x80 ; if (pad > 112) { memset(ctx->buf + pad, 0, 128 - pad) ; sha512_transform(ctx, ctx->buf) ; pad = 0 ; } memset(ctx->buf + pad, 0, 120 - pad) ; uint64_pack_big((char *)ctx->buf + 120, ctx->len << 3) ; sha512_transform(ctx, ctx->buf) ; for (unsigned int i = 0 ; i < 8 ; i++) uint64_pack_big(digest + (i << 3), ctx->h[i]) ; } skalibs-2.14.1.1/src/libstdcrypto/sha512_init.c000066400000000000000000000002261455624754300211100ustar00rootroot00000000000000/* ISC license. */ #include void sha512_init (SHA512Schedule *ctx) { SHA512Schedule empty = SHA512_INIT() ; *ctx = empty ; } skalibs-2.14.1.1/src/libstdcrypto/sha512_transform.c000066400000000000000000000064551455624754300221720ustar00rootroot00000000000000/* ISC license. */ #include #include #include "sha512-internal.h" static uint64_t ror (uint64_t n, unsigned int k) { return (n >> k) | (n << (64 - k)) ; } #undef Ch #undef Maj #undef S0 #undef S1 #undef R0 #undef R1 #define Ch(x, y, z) ((z) ^ ((x) & ((y) ^ (z)))) #define Maj(x, y, z) (((x) & (y)) | ((z) & ((x) | (y)))) #define S0(x) (ror((x), 28) ^ ror((x), 34) ^ ror((x), 39)) #define S1(x) (ror((x), 14) ^ ror((x), 18) ^ ror((x), 41)) #define R0(x) (ror((x), 1) ^ ror((x), 8) ^ ((x) >> 7)) #define R1(x) (ror((x), 19) ^ ror((x), 61) ^ ((x) >> 6)) void sha512_transform (SHA512Schedule *ctx, unsigned char const *block) { static uint64_t const K[80] = { 0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL, 0xb5c0fbcfec4d3b2fULL, 0xe9b5dba58189dbbcULL, 0x3956c25bf348b538ULL, 0x59f111f1b605d019ULL, 0x923f82a4af194f9bULL, 0xab1c5ed5da6d8118ULL, 0xd807aa98a3030242ULL, 0x12835b0145706fbeULL, 0x243185be4ee4b28cULL, 0x550c7dc3d5ffb4e2ULL, 0x72be5d74f27b896fULL, 0x80deb1fe3b1696b1ULL, 0x9bdc06a725c71235ULL, 0xc19bf174cf692694ULL, 0xe49b69c19ef14ad2ULL, 0xefbe4786384f25e3ULL, 0x0fc19dc68b8cd5b5ULL, 0x240ca1cc77ac9c65ULL, 0x2de92c6f592b0275ULL, 0x4a7484aa6ea6e483ULL, 0x5cb0a9dcbd41fbd4ULL, 0x76f988da831153b5ULL, 0x983e5152ee66dfabULL, 0xa831c66d2db43210ULL, 0xb00327c898fb213fULL, 0xbf597fc7beef0ee4ULL, 0xc6e00bf33da88fc2ULL, 0xd5a79147930aa725ULL, 0x06ca6351e003826fULL, 0x142929670a0e6e70ULL, 0x27b70a8546d22ffcULL, 0x2e1b21385c26c926ULL, 0x4d2c6dfc5ac42aedULL, 0x53380d139d95b3dfULL, 0x650a73548baf63deULL, 0x766a0abb3c77b2a8ULL, 0x81c2c92e47edaee6ULL, 0x92722c851482353bULL, 0xa2bfe8a14cf10364ULL, 0xa81a664bbc423001ULL, 0xc24b8b70d0f89791ULL, 0xc76c51a30654be30ULL, 0xd192e819d6ef5218ULL, 0xd69906245565a910ULL, 0xf40e35855771202aULL, 0x106aa07032bbd1b8ULL, 0x19a4c116b8d2d0c8ULL, 0x1e376c085141ab53ULL, 0x2748774cdf8eeb99ULL, 0x34b0bcb5e19b48a8ULL, 0x391c0cb3c5c95a63ULL, 0x4ed8aa4ae3418acbULL, 0x5b9cca4f7763e373ULL, 0x682e6ff3d6b2b8a3ULL, 0x748f82ee5defb2fcULL, 0x78a5636f43172f60ULL, 0x84c87814a1f0ab72ULL, 0x8cc702081a6439ecULL, 0x90befffa23631e28ULL, 0xa4506cebde82bde9ULL, 0xbef9a3f7b2c67915ULL, 0xc67178f2e372532bULL, 0xca273eceea26619cULL, 0xd186b8c721c0c207ULL, 0xeada7dd6cde0eb1eULL, 0xf57d4f7fee6ed178ULL, 0x06f067aa72176fbaULL, 0x0a637dc5a2c898a6ULL, 0x113f9804bef90daeULL, 0x1b710b35131c471bULL, 0x28db77f523047d84ULL, 0x32caab7b40c72493ULL, 0x3c9ebe0a15c9bebcULL, 0x431d67c49c100d4cULL, 0x4cc5d4becb3e42b6ULL, 0x597f299cfc657e2aULL, 0x5fcb6fab3ad6faecULL, 0x6c44198c4a475817ULL } ; uint64_t w[80] ; uint64_t h[8] ; uint64_t t[2] ; unsigned int i = 0 ; for (; i < 16 ; i++) uint64_unpack_big((char const *)block + (i << 3), w + i) ; for (; i < 80 ; i++) w[i] = R1(w[i-2]) + w[i-7] + R0(w[i-15]) + w[i-16] ; for (i = 0 ; i < 8 ; i++) h[i] = ctx->h[i] ; for (i = 0 ; i < 80 ; i++) { t[0] = h[7] + S1(h[4]) + Ch(h[4], h[5], h[6]) + K[i] + w[i] ; t[1] = S0(h[0]) + Maj(h[0], h[1], h[2]) ; h[7] = h[6] ; h[6] = h[5] ; h[5] = h[4] ; h[4] = h[3] + t[0] ; h[3] = h[2] ; h[2] = h[1] ; h[1] = h[0] ; h[0] = t[0] + t[1] ; } for (i = 0 ; i < 8 ; i++) ctx->h[i] += h[i] ; } skalibs-2.14.1.1/src/libstdcrypto/sha512_update.c000066400000000000000000000011001455624754300214170ustar00rootroot00000000000000/* ISC license. */ #include #include #include "sha512-internal.h" void sha512_update (SHA512Schedule *ctx, char const *buf, size_t len) { unsigned int pad = ctx->len & 0x7fU ; ctx->len += len ; if (pad && len >= 128 - pad) { memcpy((char *)ctx->buf + pad, buf, 128 - pad) ; buf += 128 - pad ; len -= 128 - pad ; pad = 0 ; sha512_transform(ctx, ctx->buf) ; } while (len >= 128) { sha512_transform(ctx, (unsigned char const *)buf) ; buf += 128 ; len -= 128 ; } memcpy((char *)ctx->buf + pad, buf, len) ; } skalibs-2.14.1.1/src/libstddjb/000077500000000000000000000000001455624754300161355ustar00rootroot00000000000000skalibs-2.14.1.1/src/libstddjb/alarm-internal.h000066400000000000000000000002371455624754300212160ustar00rootroot00000000000000/* ISC license. */ #ifndef ALARM_INTERNAL_H #define ALARM_INTERNAL_H #ifdef SKALIBS_HASTIMER #include extern timer_t timer_here ; #endif #endif skalibs-2.14.1.1/src/libstddjb/alarm_deadline.c000066400000000000000000000020661455624754300212260ustar00rootroot00000000000000/* ISC license. */ #include #include #include #ifdef SKALIBS_HASTIMER #include #include #include #include "alarm-internal.h" #undef MYCLOCK #ifdef SKALIBS_HASCLOCKMON # define MYCLOCK CLOCK_MONOTONIC #else # define MYCLOCK CLOCK_REALTIME #endif int alarm_deadline (tain const *deadline) { struct itimerspec it = { .it_interval = { .tv_sec = 0, .tv_nsec = 0 } } ; struct sigevent se = { .sigev_notify = SIGEV_SIGNAL, .sigev_signo = SIGALRM, .sigev_value = { .sival_int = 0 }, .sigev_notify_function = 0, .sigev_notify_attributes = 0 } ; if (!timespec_from_tain(&it.it_value, deadline)) return 0 ; if (timer_create(MYCLOCK, &se, &timer_here) < 0) return 0 ; if (timer_settime(timer_here, TIMER_ABSTIME, &it, 0) < 0) { int e = errno ; timer_delete(timer_here) ; errno = e ; return 0 ; } return 1 ; } #else int alarm_deadline (tain const *deadline) { tain tto ; tain_now(&tto) ; tain_sub(&tto, deadline, &tto) ; return alarm_timeout(&tto) ; } #endif skalibs-2.14.1.1/src/libstddjb/alarm_disable.c000066400000000000000000000013201455624754300210540ustar00rootroot00000000000000/* ISC license. */ #include #include #ifdef SKALIBS_HASTIMER #include #include "alarm-internal.h" timer_t timer_here ; void alarm_disable () { struct itimerspec stopit = { .it_value = { .tv_sec = 0, .tv_nsec = 0 }, .it_interval = { .tv_sec = 0, .tv_nsec = 0 } } ; timer_settime(timer_here, 0, &stopit, 0) ; timer_delete(timer_here) ; } #else #ifdef SKALIBS_HASITIMER #include void alarm_disable () { struct itimerval stopit = { .it_value = { .tv_sec = 0, .tv_usec = 0 }, .it_interval = { .tv_sec = 0, .tv_usec = 0 } } ; setitimer(ITIMER_REAL, &stopit, 0) ; } #else #include void alarm_disable () { alarm(0) ; } #endif #endif skalibs-2.14.1.1/src/libstddjb/alarm_milliseconds.c000066400000000000000000000025551455624754300221510ustar00rootroot00000000000000/* ISC license. */ #include #include #ifdef SKALIBS_HASTIMER #include #include #include #include "alarm-internal.h" #undef MYCLOCK #ifdef SKALIBS_HASCLOCKMON # define MYCLOCK CLOCK_MONOTONIC #else # define MYCLOCK CLOCK_REALTIME #endif int alarm_milliseconds (unsigned int t) { struct itimerspec it = { .it_interval = { .tv_sec = 0, .tv_nsec = 0 }, .it_value = { .tv_sec = t / 1000, .tv_nsec = 1000000 * (t % 1000) } } ; struct sigevent se = { .sigev_notify = SIGEV_SIGNAL, .sigev_signo = SIGALRM, .sigev_value = { .sival_int = 0 }, .sigev_notify_function = 0, .sigev_notify_attributes = 0 } ; if (timer_create(MYCLOCK, &se, &timer_here) < 0) return 0 ; if (timer_settime(timer_here, 0, &it, 0) < 0) { int e = errno ; timer_delete(timer_here) ; errno = e ; return 0 ; } return 1 ; } #else #ifdef SKALIBS_HASITIMER #include int alarm_milliseconds (unsigned int t) { struct itimerval it = { .it_interval = { .tv_sec = 0, .tv_usec = 0 }, .it_value = { .tv_sec = t / 1000, .tv_usec = 1000 * (t % 1000) } } ; if (setitimer(ITIMER_REAL, &it, 0) < 0) return 0 ; return 1 ; } #else #include #include int alarm_milliseconds (unsigned int t) { if (t > UINT_MAX - 999) return 0 ; t = (t + 999) / 1000 ; alarm(t) ; return 1 ; } #endif #endif skalibs-2.14.1.1/src/libstddjb/alarm_timeout.c000066400000000000000000000026411455624754300211460ustar00rootroot00000000000000/* ISC license. */ #include #include #include #ifdef SKALIBS_HASTIMER #include #include #include #include "alarm-internal.h" #undef MYCLOCK #ifdef SKALIBS_HASCLOCKMON # define MYCLOCK CLOCK_MONOTONIC #else # define MYCLOCK CLOCK_REALTIME #endif int alarm_timeout (tain const *tto) { struct itimerspec it = { .it_interval = { .tv_sec = 0, .tv_nsec = 0 } } ; struct sigevent se = { .sigev_notify = SIGEV_SIGNAL, .sigev_signo = SIGALRM, .sigev_value = { .sival_int = 0 }, .sigev_notify_function = 0, .sigev_notify_attributes = 0 } ; if (!timespec_from_tain_relative(&it.it_value, tto)) return 0 ; if (timer_create(MYCLOCK, &se, &timer_here) < 0) return 0 ; if (timer_settime(timer_here, 0, &it, 0) < 0) { int e = errno ; timer_delete(timer_here) ; errno = e ; return 0 ; } return 1 ; } #else #ifdef SKALIBS_HASITIMER #include int alarm_timeout (tain const *tto) { struct itimerval it = { .it_interval = { .tv_sec = 0, .tv_usec = 0 } } ; if (!timeval_from_tain_relative(&it.it_value, tto)) return 0 ; if (setitimer(ITIMER_REAL, &it, 0) < 0) return 0 ; return 1 ; } #else #include #include int alarm_timeout (tain const *tto) { int t = tain_to_millisecs(tto) ; if (t < 0 || t > INT_MAX - 999) return 0 ; t = (t + 999) / 1000 ; alarm(t) ; return 1 ; } #endif #endif skalibs-2.14.1.1/src/libstddjb/alloc.c000066400000000000000000000001741455624754300173750ustar00rootroot00000000000000/* ISC license. */ #include #include void *alloc (size_t n) { return malloc(n ? n : 1) ; } skalibs-2.14.1.1/src/libstddjb/alloc_realloc.c000066400000000000000000000003351455624754300210750ustar00rootroot00000000000000/* ISC license. */ #include #include int alloc_realloc (char **x, size_t n) { char *y = n ? realloc(*x, n) : alloc(0) ; if (!y) return 0 ; if (!n) free(*x) ; *x = y ; return 1 ; } skalibs-2.14.1.1/src/libstddjb/allread.c000066400000000000000000000002321455624754300177020ustar00rootroot00000000000000/* ISC license. */ #include size_t allread (int fd, char *buf, size_t len) { return allreadwrite(&fd_read, fd, buf, len) ; } skalibs-2.14.1.1/src/libstddjb/allreadv.c000066400000000000000000000003041455624754300200700ustar00rootroot00000000000000/* ISC license. */ #include #include size_t allreadv (int fd, struct iovec const *v, unsigned int vlen) { return allreadwritev(&fd_readv, fd, v, vlen) ; } skalibs-2.14.1.1/src/libstddjb/allreadwrite.c000066400000000000000000000004561455624754300207650ustar00rootroot00000000000000/* ISC license. */ #include size_t allreadwrite (io_func_ref op, int fd, char *buf, size_t len) { size_t written = 0 ; while (len) { ssize_t w = (*op)(fd, buf, len) ; if (w <= 0) break ; written += w ; buf += w ; len -= w ; } return written ; } skalibs-2.14.1.1/src/libstddjb/allreadwritev.c000066400000000000000000000007461455624754300211550ustar00rootroot00000000000000/* ISC license. */ #include #include #include size_t allreadwritev (iov_func_ref op, int fd, struct iovec const *v, unsigned int vlen) { size_t written = 0 ; struct iovec vv[vlen ? vlen : 1] ; unsigned int i = vlen ; while (i--) vv[i] = v[i] ; while (siovec_len(vv, vlen)) { ssize_t w = (*op)(fd, vv, vlen) ; if (w <= 0) break ; w = siovec_seek(vv, vlen, w) ; written += w ; } return written ; } skalibs-2.14.1.1/src/libstddjb/allwrite.c000066400000000000000000000003261455624754300201250ustar00rootroot00000000000000/* ISC license. */ #include #include size_t allwrite (int fd, char const *buf, size_t len) { return allreadwrite((io_func_ref)&fd_write, fd, (char *)buf, len) ; } skalibs-2.14.1.1/src/libstddjb/allwritev.c000066400000000000000000000003061455624754300203110ustar00rootroot00000000000000/* ISC license. */ #include #include size_t allwritev (int fd, struct iovec const *v, unsigned int vlen) { return allreadwritev(&fd_writev, fd, v, vlen) ; } skalibs-2.14.1.1/src/libstddjb/baprintf.c000066400000000000000000000004261455624754300201100ustar00rootroot00000000000000/* ISC license. */ #include #include #include int baprintf (bufalloc *ba, char const *format, ...) { va_list args ; int r ; va_start(args, format) ; r = vbaprintf(ba, format, args) ; va_end(args) ; return r ; } skalibs-2.14.1.1/src/libstddjb/bitarray_and.c000066400000000000000000000003311455624754300207350ustar00rootroot00000000000000/* ISC license. */ #include void bitarray_and (unsigned char *c, unsigned char const *a, unsigned char const *b, size_t n) { size_t i = bitarray_div8(n) ; while (i--) c[i] = a[i] & b[i] ; } skalibs-2.14.1.1/src/libstddjb/bitarray_clearsetn.c000066400000000000000000000012161455624754300221560ustar00rootroot00000000000000/* ISC license. */ #include void bitarray_clearsetn (unsigned char *s, size_t a, size_t b, int h) { if (!b) return ; b += a ; if ((a >> 3) == ((b-1) >> 3)) { unsigned char mask = (1 << (a & 7)) - 1 ^ (1 << (1 + (b-1 & 7))) - 1 ; if (h) s[a>>3] |= mask ; else s[a>>3] &= ~mask ; } else { unsigned char mask = ~((1 << (a & 7)) - 1) ; size_t i = (a>>3) + 1 ; if (h) s[a>>3] |= mask ; else s[a>>3] &= ~mask ; mask = h ? 0xff : 0x00 ; for (; i < b>>3 ; i++) s[i] = mask ; if (b & 7) { mask = (1 << (b & 7)) - 1 ; if (h) s[b>>3] |= mask ; else s[b>>3] &= ~mask ; } } } skalibs-2.14.1.1/src/libstddjb/bitarray_count.c000066400000000000000000000010571455624754300213310ustar00rootroot00000000000000/* ISC license. */ #include #define B0(n) n, n+1, n+1, n+2 #define B1(n) B0(n), B0(n+1), B0(n+1), B0(n+2) #define B2(n) B1(n), B1(n+1), B1(n+1), B1(n+2) #define B3(n) B2(n), B2(n+1), B2(n+1), B2(n+2) size_t bitarray_countones (unsigned char const *c, size_t n) { static unsigned char const table[256] = { B3(0) } ; size_t len = bitarray_div8(n) ; size_t total = 0 ; size_t i = 0 ; if (n & 7) len-- ; for (; i < len ; i++) total += table[c[i]] ; if (n & 7) total += table[c[i] & ((1 << (n & 7)) - 1)] ; return total ; } skalibs-2.14.1.1/src/libstddjb/bitarray_firstclear.c000066400000000000000000000005001455624754300223270ustar00rootroot00000000000000/* ISC license. */ #include size_t bitarray_firstclear (unsigned char const *s, size_t max) { size_t n = bitarray_div8(max) ; size_t i = 0 ; for (; i < n ; i++) if (s[i] != 0xffU) break ; if (i == n) return max ; i <<= 3 ; while ((i < max) && bitarray_peek(s, i)) i++ ; return i ; } skalibs-2.14.1.1/src/libstddjb/bitarray_firstclear_skip.c000066400000000000000000000006101455624754300233570ustar00rootroot00000000000000/* ISC license. */ #include size_t bitarray_firstclear_skip (unsigned char const *s, size_t max, size_t skip) { size_t i = bitarray_div8(skip) ; size_t j = i << 3 > max ? max : i << 3 ; if (i && s[i-1] != 0xffU) { while ((skip < j) && bitarray_peek(s, skip)) skip++ ; if (skip < j) return skip ; } return j + bitarray_firstclear(s + i, max - j) ; } skalibs-2.14.1.1/src/libstddjb/bitarray_firstset.c000066400000000000000000000004661455624754300220470ustar00rootroot00000000000000/* ISC license. */ #include size_t bitarray_firstset (unsigned char const *s, size_t max) { size_t n = bitarray_div8(max) ; size_t i = 0 ; for (; i < n ; i++) if (s[i]) break ; if (i == n) return max ; i <<= 3 ; while ((i < max) && !bitarray_peek(s, i)) i++ ; return i ; } skalibs-2.14.1.1/src/libstddjb/bitarray_firstset_skip.c000066400000000000000000000005741455624754300230750ustar00rootroot00000000000000/* ISC license. */ #include size_t bitarray_firstset_skip (unsigned char const *s, size_t max, size_t skip) { size_t i = bitarray_div8(skip) ; size_t j = i << 3 > max ? max : i << 3 ; if (i && s[i-1]) { while ((skip < j) && !bitarray_peek(s, skip)) skip++ ; if (skip < j) return skip ; } return j + bitarray_firstset(s + i, max - j) ; } skalibs-2.14.1.1/src/libstddjb/bitarray_not.c000066400000000000000000000006251455624754300210010ustar00rootroot00000000000000/* ISC license. */ #include void bitarray_not (unsigned char *s, size_t a, size_t b) { if (!b) return ; b += a ; if ((a >> 3) == ((b-1) >> 3)) s[a>>3] ^= ((1 << (a & 7)) - 1) ^ ((1 << (1 + (b-1 & 7))) - 1) ; else { size_t i = (a>>3) + 1 ; s[a>>3] ^= ~((1 << (a & 7)) - 1) ; for (; i < (b>>3) ; i++) s[i] = ~s[i] ; s[b>>3] ^= (1 << (b & 7)) - 1 ; } } skalibs-2.14.1.1/src/libstddjb/bitarray_or.c000066400000000000000000000003301455624754300206120ustar00rootroot00000000000000/* ISC license. */ #include void bitarray_or (unsigned char *c, unsigned char const *a, unsigned char const *b, size_t n) { size_t i = bitarray_div8(n) ; while (i--) c[i] = a[i] | b[i] ; } skalibs-2.14.1.1/src/libstddjb/bitarray_testandpoke.c000066400000000000000000000003751455624754300225240ustar00rootroot00000000000000/* ISC license. */ #include int bitarray_testandpoke (unsigned char *s, size_t n, int h) { unsigned char mask = 1 << (n & 7) ; unsigned char c = s[n>>3] ; s[n>>3] = h ? c | mask : c & ~mask ; return (c & mask) ? 1 : 0 ; } skalibs-2.14.1.1/src/libstddjb/bitarray_xor.c000066400000000000000000000003311455624754300210030ustar00rootroot00000000000000/* ISC license. */ #include void bitarray_xor (unsigned char *c, unsigned char const *a, unsigned char const *b, size_t n) { size_t i = bitarray_div8(n) ; while (i--) c[i] = a[i] ^ b[i] ; } skalibs-2.14.1.1/src/libstddjb/bprintf.c000066400000000000000000000004161455624754300177460ustar00rootroot00000000000000/* ISC license. */ #include #include #include int bprintf (buffer *b, char const *format, ...) { va_list args ; int r ; va_start(args, format) ; r = vbprintf(b, format, args) ; va_end(args) ; return r ; } skalibs-2.14.1.1/src/libstddjb/bufalloc_1.c000066400000000000000000000002331455624754300203060ustar00rootroot00000000000000/* ISC license. */ /* MT-unsafe */ #include #include bufalloc bufalloc_1_ = BUFALLOC_INIT(&fd_write, 1) ; skalibs-2.14.1.1/src/libstddjb/bufalloc_2.c000066400000000000000000000002331455624754300203070ustar00rootroot00000000000000/* ISC license. */ /* MT-unsafe */ #include #include bufalloc bufalloc_2_ = BUFALLOC_INIT(&fd_write, 2) ; skalibs-2.14.1.1/src/libstddjb/bufalloc_clean.c000066400000000000000000000003471455624754300212360ustar00rootroot00000000000000/* ISC license. */ #include #include void bufalloc_clean (bufalloc *ba) { if (ba->p) { memmove(ba->x.s, ba->x.s + ba->p, ba->x.len - ba->p) ; ba->x.len -= ba->p ; ba->p = 0 ; } } skalibs-2.14.1.1/src/libstddjb/bufalloc_flush.c000066400000000000000000000004421455624754300212710ustar00rootroot00000000000000/* ISC license. */ #include #include #include int bufalloc_flush (bufalloc *ba) { ba->p += allreadwrite((io_func_ref)ba->op, ba->fd, ba->x.s + ba->p, ba->x.len - ba->p) ; bufalloc_clean(ba) ; return !ba->x.len ; } skalibs-2.14.1.1/src/libstddjb/bufalloc_getfd.c000066400000000000000000000001721455624754300212410ustar00rootroot00000000000000/* ISC license. */ #include int bufalloc_getfd (bufalloc const *ba) { return bufalloc_fd(ba) ; } skalibs-2.14.1.1/src/libstddjb/bufalloc_getlen.c000066400000000000000000000001771455624754300214330ustar00rootroot00000000000000/* ISC license. */ #include size_t bufalloc_getlen (bufalloc const *ba) { return bufalloc_len(ba) ; } skalibs-2.14.1.1/src/libstddjb/bufalloc_init.c000066400000000000000000000003611455624754300211130ustar00rootroot00000000000000/* ISC license. */ #include #include void bufalloc_init (bufalloc *ba, ssize_t (*op)(int, char const *, size_t), int fd) { ba->x = stralloc_zero ; ba->op = op ; ba->fd = fd ; ba->p = 0 ; } skalibs-2.14.1.1/src/libstddjb/buffer_0.c000066400000000000000000000003101455624754300177630ustar00rootroot00000000000000/* ISC license. */ /* MT-unsafe */ #include #include static char buf[BUFFER_INSIZE] ; buffer buffer_0_ = BUFFER_INIT(&fd_readv, 0, buf, BUFFER_INSIZE) ; skalibs-2.14.1.1/src/libstddjb/buffer_0f1.c000066400000000000000000000002611455624754300202170ustar00rootroot00000000000000/* ISC license. */ /* MT-unsafe */ #include static char buf[BUFFER_INSIZE] ; buffer buffer_0f1_ = BUFFER_INIT(&buffer_flush1read, 0, buf, BUFFER_INSIZE) ; skalibs-2.14.1.1/src/libstddjb/buffer_0small.c000066400000000000000000000003311455624754300210170ustar00rootroot00000000000000/* ISC license. */ /* MT-unsafe */ #include #include static char buf[BUFFER_INSIZE_SMALL] ; buffer buffer_0small_ = BUFFER_INIT(&fd_readv, 0, buf, BUFFER_INSIZE_SMALL) ; skalibs-2.14.1.1/src/libstddjb/buffer_1.c000066400000000000000000000003131455624754300177670ustar00rootroot00000000000000/* ISC license. */ /* MT-unsafe */ #include #include static char buf[BUFFER_OUTSIZE] ; buffer buffer_1_ = BUFFER_INIT(&fd_writev, 1, buf, BUFFER_OUTSIZE) ; skalibs-2.14.1.1/src/libstddjb/buffer_1small.c000066400000000000000000000003341455624754300210230ustar00rootroot00000000000000/* ISC license. */ /* MT-unsafe */ #include #include static char buf[BUFFER_OUTSIZE_SMALL] ; buffer buffer_1small_ = BUFFER_INIT(&fd_writev, 1, buf, BUFFER_OUTSIZE_SMALL) ; skalibs-2.14.1.1/src/libstddjb/buffer_2.c000066400000000000000000000003131455624754300177700ustar00rootroot00000000000000/* ISC license. */ /* MT-unsafe */ #include #include static char buf[BUFFER_ERRSIZE] ; buffer buffer_2_ = BUFFER_INIT(&fd_writev, 2, buf, BUFFER_ERRSIZE) ; skalibs-2.14.1.1/src/libstddjb/buffer_fill.c000066400000000000000000000005121455624754300205560ustar00rootroot00000000000000/* ISC license. */ #include #include #include ssize_t buffer_fill (buffer *b) { struct iovec v[2] ; ssize_t r ; if (buffer_isfull(b)) return (errno = ENOBUFS, -1) ; buffer_wpeek(b, v) ; r = (*b->op)(b->fd, v, 2) ; if (r <= 0) return r ; buffer_wseek(b, r) ; return r ; } skalibs-2.14.1.1/src/libstddjb/buffer_flush.c000066400000000000000000000005561455624754300207610ustar00rootroot00000000000000/* ISC license. */ #include #include #include int buffer_flush (buffer *b) { for (;;) { struct iovec v[2] ; ssize_t r ; buffer_rpeek(b, v) ; if (!v[0].iov_len && !v[1].iov_len) break ; r = (*b->op)(b->fd, v, 2) ; if (r <= 0) return 0 ; cbuffer_RSEEK(&b->c, r) ; } return 1 ; } skalibs-2.14.1.1/src/libstddjb/buffer_flush1read.c000066400000000000000000000003771455624754300216770ustar00rootroot00000000000000/* ISC license. */ #include #include #include ssize_t buffer_flush1read (int fd, struct iovec const *v, unsigned int n) { if (!buffer_flush(buffer_1)) return -1 ; return fd_readv(fd, v, n) ; } skalibs-2.14.1.1/src/libstddjb/buffer_get.c000066400000000000000000000004101455624754300204040ustar00rootroot00000000000000/* ISC license. */ #include #include #include ssize_t buffer_get (buffer *b, char *s, size_t len) { size_t w = 0 ; ssize_t r = unsanitize_read(buffer_getall(b, s, len, &w)) ; return r < 0 ? r : w ; } skalibs-2.14.1.1/src/libstddjb/buffer_getall.c000066400000000000000000000006321455624754300211030ustar00rootroot00000000000000/* ISC license. */ #include #include #include int buffer_getall (buffer *b, char *buf, size_t len, size_t *w) { if (*w > len) return (errno = EINVAL, -1) ; for (;;) { ssize_t r ; *w += buffer_getnofill(b, buf + *w, len - *w) ; if (*w >= len) break ; r = sanitize_read(buffer_fill(b)) ; if (r <= 0) return r ; } return 1 ; } skalibs-2.14.1.1/src/libstddjb/buffer_getallnf.c000066400000000000000000000004131455624754300214240ustar00rootroot00000000000000/* ISC license. */ #include #include int buffer_getallnofill (buffer *b, char *s, size_t len) { size_t r = buffer_getnofill(b, s, len) ; if (r < len) { buffer_unget(b, r) ; return (errno = ENOBUFS, 0) ; } return 1 ; } skalibs-2.14.1.1/src/libstddjb/buffer_getfd.c000066400000000000000000000001601455624754300207200ustar00rootroot00000000000000/* ISC license. */ #include int buffer_getfd (buffer const *b) { return buffer_fd(b) ; } skalibs-2.14.1.1/src/libstddjb/buffer_getlen.c000066400000000000000000000001651455624754300211120ustar00rootroot00000000000000/* ISC license. */ #include size_t buffer_getlen (buffer const *b) { return buffer_len(b) ; } skalibs-2.14.1.1/src/libstddjb/buffer_getv.c000066400000000000000000000004321455624754300205760ustar00rootroot00000000000000/* ISC license. */ #include #include #include ssize_t buffer_getv (buffer *b, struct iovec const *v, unsigned int n) { size_t w = 0 ; ssize_t r = unsanitize_read(buffer_getvall(b, v, n, &w)) ; return r < 0 ? r : w ; } skalibs-2.14.1.1/src/libstddjb/buffer_getvall.c000066400000000000000000000012711455624754300212710ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include int buffer_getvall (buffer *b, struct iovec const *v, unsigned int n, size_t *written) { size_t len = siovec_len(v, n) ; struct iovec vv[n ? n : 1] ; if (*written > len) return (errno = EINVAL, -1) ; { unsigned int i = n ; while (i--) vv[i] = v[i] ; } siovec_seek(vv, n, *written) ; for (;;) { ssize_t r ; size_t w = buffer_getvnofill(b, vv, n) ; *written += w ; if (*written >= len) break ; siovec_seek(vv, n, w) ; r = sanitize_read(buffer_fill(b)) ; if (r <= 0) return r ; } return 1 ; } skalibs-2.14.1.1/src/libstddjb/buffer_getvallnf.c000066400000000000000000000005331455624754300216150ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include int buffer_getvallnofill (buffer *b, struct iovec const *v, unsigned int n) { size_t r = buffer_getvnofill(b, v, n) ; if (r < siovec_len(v, n)) { buffer_unget(b, r) ; return (errno = ENOBUFS, 0) ; } return 1 ; } skalibs-2.14.1.1/src/libstddjb/buffer_init.c000066400000000000000000000004111455624754300205710ustar00rootroot00000000000000/* ISC license. */ #include #include #include int buffer_init (buffer *b, iov_func_ref op, int fd, char *s, size_t len) { if (!cbuffer_init(&b->c, s, len)) return 0 ; b->fd = fd ; b->op = op ; return 1 ; } skalibs-2.14.1.1/src/libstddjb/buffer_put.c000066400000000000000000000002761455624754300204470ustar00rootroot00000000000000/* ISC license. */ #include ssize_t buffer_put (buffer *b, char const *s, size_t len) { size_t w = 0 ; if (!buffer_putall(b, s, len, &w)) return -1 ; return w ; } skalibs-2.14.1.1/src/libstddjb/buffer_putall.c000066400000000000000000000005741455624754300211410ustar00rootroot00000000000000/* ISC license. */ #include #include int buffer_putall (buffer *b, char const *s, size_t len, size_t *written) { if (*written > len) return (errno = EINVAL, 0) ; for (;;) { *written += buffer_putnoflush(b, s + *written, len - *written) ; if (*written >= len) return 1 ; buffer_flush(b) ; if (buffer_isfull(b)) return 0 ; } } skalibs-2.14.1.1/src/libstddjb/buffer_putallnf.c000066400000000000000000000004241455624754300214570ustar00rootroot00000000000000/* ISC license. */ #include #include int buffer_putallnoflush (buffer *b, char const *s, size_t len) { ssize_t r = buffer_putnoflush(b, s, len) ; if (r < len) { buffer_unput(b, r) ; return (errno = ENOBUFS, 0) ; } return 1 ; } skalibs-2.14.1.1/src/libstddjb/buffer_putflush.c000066400000000000000000000003441455624754300215050ustar00rootroot00000000000000/* ISC license. */ #include ssize_t buffer_putflush (buffer *b, char const *s, size_t len) { ssize_t r = buffer_put(b, s, len) ; if (r < 0) return -1 ; if (!buffer_flush(b)) return -1 ; return r ; } skalibs-2.14.1.1/src/libstddjb/buffer_puts.c000066400000000000000000000002371455624754300206270ustar00rootroot00000000000000/* ISC license. */ #include #include ssize_t buffer_puts (buffer *b, char const *s) { return buffer_put(b, s, strlen(s)) ; } skalibs-2.14.1.1/src/libstddjb/buffer_putsall.c000066400000000000000000000002571455624754300213220ustar00rootroot00000000000000/* ISC license. */ #include #include int buffer_putsall (buffer *b, char const *s, size_t *w) { return buffer_putall(b, s, strlen(s), w) ; } skalibs-2.14.1.1/src/libstddjb/buffer_putsallflush.c000066400000000000000000000002711455624754300223600ustar00rootroot00000000000000/* ISC license. */ #include #include int buffer_putsallflush (buffer *b, char const *s, size_t *w) { return buffer_putallflush(b, s, strlen(s), w) ; } skalibs-2.14.1.1/src/libstddjb/buffer_putsallnoflush.c000066400000000000000000000002571455624754300227210ustar00rootroot00000000000000/* ISC license. */ #include #include int buffer_putsallnoflush (buffer *b, char const *s) { return buffer_putallnoflush(b, s, strlen(s)) ; } skalibs-2.14.1.1/src/libstddjb/buffer_putsflush.c000066400000000000000000000002511455624754300216650ustar00rootroot00000000000000/* ISC license. */ #include #include ssize_t buffer_putsflush (buffer *b, char const *s) { return buffer_putflush(b, s, strlen(s)) ; } skalibs-2.14.1.1/src/libstddjb/buffer_putsnoflush.c000066400000000000000000000002541455624754300222250ustar00rootroot00000000000000/* ISC license. */ #include #include size_t buffer_putsnoflush (buffer *b, char const *s) { return buffer_putnoflush(b, s, strlen(s)) ; } skalibs-2.14.1.1/src/libstddjb/buffer_putv.c000066400000000000000000000003331455624754300206270ustar00rootroot00000000000000/* ISC license. */ #include #include ssize_t buffer_putv (buffer *b, struct iovec const *v, unsigned int n) { size_t w = 0 ; return buffer_putvall(b, v, n, &w) ? (ssize_t)w : -1 ; } skalibs-2.14.1.1/src/libstddjb/buffer_putvall.c000066400000000000000000000011141455624754300213160ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include int buffer_putvall (buffer *b, struct iovec const *v, unsigned int n, size_t *written) { size_t len = siovec_len(v, n) ; size_t w = n ; struct iovec vv[n ? n : 1] ; if (*written > len) return (errno = EINVAL, 0) ; while (w--) vv[w] = v[w] ; w = *written ; for (;;) { siovec_seek(vv, n, w) ; w = buffer_putvnoflush(b, vv, n) ; *written += w ; if (*written >= len) return 1 ; buffer_flush(b) ; if (buffer_isfull(b)) return 0 ; } } skalibs-2.14.1.1/src/libstddjb/buffer_putvallnf.c000066400000000000000000000005351455624754300216500ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include int buffer_putvallnoflush (buffer *b, struct iovec const *v, unsigned int n) { size_t r = buffer_putvnoflush(b, v, n) ; if (r < siovec_len(v, n)) { buffer_unput(b, r) ; return (errno = ENOBUFS, 0) ; } return 1 ; } skalibs-2.14.1.1/src/libstddjb/buffer_putvflush.c000066400000000000000000000004051455624754300216710ustar00rootroot00000000000000/* ISC license. */ #include #include ssize_t buffer_putvflush (buffer *b, struct iovec const *v, unsigned int n) { ssize_t r = buffer_putv(b, v, n) ; if (r < 0) return -1 ; if (!buffer_flush(b)) return -1 ; return r ; } skalibs-2.14.1.1/src/libstddjb/byte_chr.c000066400000000000000000000003251455624754300201000ustar00rootroot00000000000000/* ISC license. */ #include #include size_t byte_chr (char const *s, size_t n, int c) { void *p ; if (!n) return 0 ; p = memchr(s, c, n) ; return p ? (char *)p - s : n ; } skalibs-2.14.1.1/src/libstddjb/byte_count.c000066400000000000000000000002571455624754300204600ustar00rootroot00000000000000/* ISC license. */ #include size_t byte_count (char const *s, size_t len, char b) { size_t n = 0 ; while (len--) if (*s++ == b) n++ ; return n ; } skalibs-2.14.1.1/src/libstddjb/byte_in.c000066400000000000000000000003751455624754300177370ustar00rootroot00000000000000/* ISC license. */ #include #include size_t byte_in (char const *s, size_t n, char const *sep, size_t len) { char const *t = s ; while (n--) { if (memchr(sep, *t, len)) break ; ++t ; } return t - s ; } skalibs-2.14.1.1/src/libstddjb/byte_rchr.c000066400000000000000000000003121455624754300202560ustar00rootroot00000000000000/* ISC license. */ #include size_t byte_rchr (char const *s, size_t n, int c) { size_t i = n ; char ch = c ; s += n ; while (i--) if (*--s == ch) return i ; return n ; } skalibs-2.14.1.1/src/libstddjb/byte_search.c000066400000000000000000000004411455624754300205700ustar00rootroot00000000000000/* ISC license. */ #include #include #include size_t byte_search (char const *haystack, size_t hlen, char const *needle, size_t nlen) { char *p = memmem(haystack, hlen, needle, nlen) ; return p ? p - haystack : hlen + 1 - nlen ; } skalibs-2.14.1.1/src/libstddjb/byte_zzero.c000066400000000000000000000010511455624754300204720ustar00rootroot00000000000000/* ISC license. */ #include #ifdef SKALIBS_HASEXPLICIT_BZERO #include #include #include #include void byte_zzero (char *s, size_t n) { explicit_bzero(s, n) ; } #else #include #include #include void _byte_zzero_hook (char *, size_t) gccattr_weak ; gccattr_weak void _byte_zzero_hook (char *s, size_t n) { } void byte_zzero (char *s, size_t n) { memset(s, 0, n) ; _byte_zzero_hook(s, n) ; } #endif skalibs-2.14.1.1/src/libstddjb/case_lowerb.c000066400000000000000000000003011455624754300205600ustar00rootroot00000000000000/* ISC license. */ #include #include void case_lowerb (char *s, size_t len) { while (len--) { int c = tolower(*s) ; *s++ = (unsigned char)c ; } } skalibs-2.14.1.1/src/libstddjb/case_lowers.c000066400000000000000000000002621455624754300206070ustar00rootroot00000000000000/* ISC license. */ #include #include void case_lowers (char *s) { while (*s) { int c = tolower(*s) ; *s++ = (unsigned char)c ; } } skalibs-2.14.1.1/src/libstddjb/case_startb.c000066400000000000000000000003561455624754300205770ustar00rootroot00000000000000/* ISC license. */ #include #include #include int case_startb (char const *s, size_t slen, char const *t) { size_t tlen = strlen(t) ; return slen < tlen ? 0 : !strncasecmp(s, t, tlen) ; } skalibs-2.14.1.1/src/libstddjb/case_upperb.c000066400000000000000000000003011455624754300205630ustar00rootroot00000000000000/* ISC license. */ #include #include void case_upperb (char *s, size_t len) { while (len--) { int c = toupper(*s) ; *s++ = (unsigned char)c ; } } skalibs-2.14.1.1/src/libstddjb/case_uppers.c000066400000000000000000000002621455624754300206120ustar00rootroot00000000000000/* ISC license. */ #include #include void case_uppers (char *s) { while (*s) { int c = toupper(*s) ; *s++ = (unsigned char)c ; } } skalibs-2.14.1.1/src/libstddjb/cbuffer_get.c000066400000000000000000000004321455624754300205530ustar00rootroot00000000000000/* ISC license. */ #include #include #include size_t cbuffer_get (cbuffer *b, char *s, size_t len) { struct iovec v[2] ; size_t w ; cbuffer_rpeek(b, v) ; w = siovec_gather(v, 2, s, len) ; return cbuffer_RSEEK(b, w) ; } skalibs-2.14.1.1/src/libstddjb/cbuffer_getv.c000066400000000000000000000004621455624754300207440ustar00rootroot00000000000000/* ISC license. */ #include #include #include size_t cbuffer_getv (cbuffer *b, struct iovec const *v, unsigned int n) { struct iovec vsrc[2] ; size_t w ; cbuffer_rpeek(b, vsrc) ; w = siovec_deal(v, n, vsrc, 2) ; return cbuffer_RSEEK(b, w) ; } skalibs-2.14.1.1/src/libstddjb/cbuffer_init.c000066400000000000000000000003451455624754300207420ustar00rootroot00000000000000/* ISC license. */ #include #include int cbuffer_init (cbuffer *b, char *s, size_t len) { if (len < 2) return (errno = EINVAL, 0) ; b->x = s ; b->a = len ; b->p = b->n = 0 ; return 1 ; } skalibs-2.14.1.1/src/libstddjb/cbuffer_put.c000066400000000000000000000004411455624754300206040ustar00rootroot00000000000000/* ISC license. */ #include #include #include size_t cbuffer_put (cbuffer *b, char const *s, size_t len) { struct iovec v[2] ; size_t w ; cbuffer_wpeek(b, v) ; w = siovec_scatter(v, 2, s, len) ; return cbuffer_WSEEK(b, w) ; } skalibs-2.14.1.1/src/libstddjb/cbuffer_putv.c000066400000000000000000000004651455624754300210000ustar00rootroot00000000000000/* ISC license. */ #include #include #include size_t cbuffer_putv (cbuffer *b, struct iovec const *v, unsigned int n) { struct iovec vdest[2] ; size_t w ; cbuffer_wpeek(b, vdest) ; w = siovec_deal(vdest, 2, v, n) ; return cbuffer_WSEEK(b, w) ; } skalibs-2.14.1.1/src/libstddjb/cbuffer_rpeek.c000066400000000000000000000005631455624754300211070ustar00rootroot00000000000000/* ISC license. */ #include #include void cbuffer_rpeek (cbuffer const *b, struct iovec *v) { v[0].iov_base = b->x + b->p ; if (b->n >= b->p) { v[0].iov_len = b->n - b->p ; v[1].iov_base = 0 ; v[1].iov_len = 0 ; } else { v[0].iov_len = b->a - b->p ; v[1].iov_base = b->x ; v[1].iov_len = b->n ; } } skalibs-2.14.1.1/src/libstddjb/cbuffer_rseek.c000066400000000000000000000003021455624754300211010ustar00rootroot00000000000000/* ISC license. */ #include size_t cbuffer_rseek (cbuffer *b, size_t len) { size_t max = cbuffer_len(b) ; if (len > max) len = max ; return cbuffer_RSEEK(b, len) ; } skalibs-2.14.1.1/src/libstddjb/cbuffer_unget.c000066400000000000000000000003101455624754300211110ustar00rootroot00000000000000/* ISC license. */ #include size_t cbuffer_unget (cbuffer *b, size_t len) { size_t max = cbuffer_available(b) ; if (len > max) len = max ; return cbuffer_UNGET(b, len) ; } skalibs-2.14.1.1/src/libstddjb/cbuffer_unput.c000066400000000000000000000003021455624754300211430ustar00rootroot00000000000000/* ISC license. */ #include size_t cbuffer_unput (cbuffer *b, size_t len) { size_t max = cbuffer_len(b) ; if (len > max) len = max ; return cbuffer_UNPUT(b, len) ; } skalibs-2.14.1.1/src/libstddjb/cbuffer_wpeek.c000066400000000000000000000006361455624754300211150ustar00rootroot00000000000000/* ISC license. */ #include #include void cbuffer_wpeek (cbuffer const *b, struct iovec *v) { size_t last = (b->a - 1 + b->p) % b->a ; v[0].iov_base = b->x + b->n ; if (last >= b->n) { v[0].iov_len = last - b->n ; v[1].iov_base = 0 ; v[1].iov_len = 0 ; } else { v[0].iov_len = b->a - b->n ; v[1].iov_base = b->x ; v[1].iov_len = last ; } } skalibs-2.14.1.1/src/libstddjb/cbuffer_wseek.c000066400000000000000000000003111455624754300211060ustar00rootroot00000000000000/* ISC license. */ #include size_t cbuffer_wseek (cbuffer *b, size_t len) { size_t max = cbuffer_available(b) ; if (len > max) len = max ; return cbuffer_WSEEK(b, len) ; } skalibs-2.14.1.1/src/libstddjb/cdb-internal.h000066400000000000000000000007511455624754300206530ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_CDB_INTERNAL_H #define SKALIBS_CDB_INTERNAL_H #include #include #include #include #define CDB_HASHSTART 5381 extern uint32_t cdb_hashadd (uint32_t, uint8_t) ; extern uint32_t cdb_hash (char const *, uint32_t) gccattr_pure ; extern uint32_t cdb_hashv (struct iovec const *, unsigned int) gccattr_pure ; extern char const *cdb_p (cdb const *, uint32_t, uint32_t) gccattr_pure ; #endif skalibs-2.14.1.1/src/libstddjb/cdb_find.c000066400000000000000000000003311455624754300200260ustar00rootroot00000000000000/* ISC license. */ #include int cdb_find (cdb const *c, cdb_data *out, char const *key, uint32_t len) { cdb_find_state cfs = CDB_FIND_STATE_ZERO ; return cdb_findnext(c, out, key, len, &cfs) ; } skalibs-2.14.1.1/src/libstddjb/cdb_findnext.c000066400000000000000000000024251455624754300207330ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include "cdb-internal.h" int cdb_findnext (cdb const *c, cdb_data *out, char const *key, uint32_t len, cdb_find_state *d) { if (!d->loop) { uint32_t u = cdb_hash(key, len) ; char const *p = cdb_p(c, 8, (u << 3) & 2047) ; if (!p) return -1 ; uint32_unpack(p + 4, &d->hslots) ; if (!d->hslots) return 0 ; uint32_unpack(p, &d->hpos) ; d->khash = u ; u >>= 8 ; u %= d->hslots ; u <<= 3 ; d->kpos = d->hpos + u ; } while (d->loop < d->hslots) { uint32_t pos, u ; char const *p = cdb_p(c, 8, d->kpos) ; if (!p) return -1 ; uint32_unpack(p + 4, &pos) ; if (!pos) return 0 ; d->loop++ ; d->kpos += 8 ; if (d->kpos == d->hpos + (d->hslots << 3)) d->kpos = d->hpos ; uint32_unpack(p, &u) ; if (u == d->khash) { p = cdb_p(c, 8, pos) ; if (!p) return -1 ; uint32_unpack(p, &u) ; if (u == len) { char const *k = cdb_p(c, len, pos + 8) ; if (!k) return -1 ; if (!memcmp(key, k, len)) { uint32_unpack(p + 4, &out->len) ; out->s = c->map + pos + 8 + len ; return 1 ; } } } } return 0 ; } skalibs-2.14.1.1/src/libstddjb/cdb_free.c000066400000000000000000000003001455624754300200230ustar00rootroot00000000000000/* ISC license. */ #include #include extern void cdb_free (cdb *c) { if (c->map) { munmap_void((void *)c->map, c->size) ; c->map = 0 ; } } skalibs-2.14.1.1/src/libstddjb/cdb_hash.c000066400000000000000000000003231455624754300200320ustar00rootroot00000000000000/* ISC license. */ #include #include "cdb-internal.h" uint32_t cdb_hash (char const *buf, uint32_t len) { uint32_t h = CDB_HASHSTART ; while (len--) h = cdb_hashadd(h, *buf++) ; return h ; } skalibs-2.14.1.1/src/libstddjb/cdb_hashadd.c000066400000000000000000000002031455624754300205000ustar00rootroot00000000000000/* ISC license. */ #include "cdb-internal.h" uint32_t cdb_hashadd (uint32_t h, uint8_t c) { h += (h << 5) ; return h ^ c ; } skalibs-2.14.1.1/src/libstddjb/cdb_hashv.c000066400000000000000000000005101455624754300202160ustar00rootroot00000000000000/* ISC license. */ #include #include "cdb-internal.h" uint32_t cdb_hashv (struct iovec const *v, unsigned int n) { uint32_t h = CDB_HASHSTART ; for (unsigned int i = 0 ; i < n ; i++) for (size_t j = 0 ; j < v[i].iov_len ; j++) h = cdb_hashadd(h, ((uint8_t const *)v[i].iov_base)[j]) ; return h ; } skalibs-2.14.1.1/src/libstddjb/cdb_init.c000066400000000000000000000004251455624754300200550ustar00rootroot00000000000000/* ISC license. */ #include #include int cdb_init (cdb *c, char const *file) { int fd = openc_read(file) ; if (fd < 0) return 0 ; if (!cdb_init_fromfd(c, fd)) { fd_close(fd) ; return 0 ; } fd_close(fd) ; return 1 ; } skalibs-2.14.1.1/src/libstddjb/cdb_init_at.c000066400000000000000000000005171455624754300205430ustar00rootroot00000000000000/* ISC license. */ #include #include #include int cdb_init_at (cdb *c, int dfd, char const *file) { int fd = open_readat(dfd, file) ; if (fd < 0) return 0 ; if (!cdb_init_fromfd(c, fd)) { fd_close(fd) ; return 0 ; } fd_close(fd) ; return 1 ; } skalibs-2.14.1.1/src/libstddjb/cdb_init_fromfd.c000066400000000000000000000007521455624754300214150ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include int cdb_init_fromfd (cdb *c, int fd) { char *map ; struct stat st ; if (fstat(fd, &st) < 0) return 0 ; if (st.st_size > UINT32_MAX) return (errno = EOVERFLOW, 0) ; map = mmap(0, st.st_size, PROT_READ, MAP_SHARED, fd, 0) ; if (map == MAP_FAILED) return 0 ; c->map = map ; c->size = st.st_size ; return 1 ; } skalibs-2.14.1.1/src/libstddjb/cdb_p.c000066400000000000000000000003161455624754300173500ustar00rootroot00000000000000/* ISC license. */ #include #include "cdb-internal.h" char const *cdb_p (cdb const *c, uint32_t len, uint32_t pos) { return pos <= c->size && len <= c->size - pos ? c->map + pos : 0 ; } skalibs-2.14.1.1/src/libstddjb/cdb_traverse_next.c000066400000000000000000000011521455624754300220010ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include "cdb-internal.h" int cdb_traverse_next (cdb const *c, cdb_data *key, cdb_data *data, uint32_t *pos) { uint32_t eod ; char const *p = cdb_p(c, 4, 0) ; if (!p) return -1 ; uint32_unpack(p, &eod) ; if (eod < 8 || eod - 8 < *pos) return 0 ; if (*pos + 8 < *pos) return -1 ; p = cdb_p(c, 8, *pos) ; if (!p) return -1 ; uint32_unpack(p, &key->len) ; uint32_unpack(p + 4, &data->len) ; key->s = c->map + *pos + 8 ; data->s = key->s + key->len ; *pos += 8 + key->len + data->len ; return 1 ; } skalibs-2.14.1.1/src/libstddjb/cdb_zero.c000066400000000000000000000001161455624754300200660ustar00rootroot00000000000000/* ISC license. */ #include cdb const cdb_zero = CDB_ZERO ; skalibs-2.14.1.1/src/libstddjb/cdbmake-internal.h000066400000000000000000000005201455624754300215030ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_CDBMAKE_INTERNAL_H #define SKALIBS_CDBMAKE_INTERNAL_H #include #include extern int cdbmake_posplus (cdbmaker *, uint32_t) ; extern int cdbmake_addend (cdbmaker *, uint32_t, uint32_t, uint32_t) ; extern int cdbmake_addbegin (cdbmaker *, uint32_t, uint32_t) ; #endif skalibs-2.14.1.1/src/libstddjb/cdbmake_add.c000066400000000000000000000011411455624754300204740ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include "cdb-internal.h" #include "cdbmake-internal.h" int cdbmake_add (cdbmaker *c, char const *key, uint32_t keylen, char const *data, uint32_t datalen) { if (!cdbmake_addbegin(c, keylen, datalen) || buffer_put(&c->b, key, keylen) < keylen || buffer_put(&c->b, data, datalen) < datalen || !cdbmake_addend(c, keylen, datalen, cdb_hash(key, keylen))) { genalloc_free(diuint32, &c->hplist) ; return 0 ; } return 1 ; } skalibs-2.14.1.1/src/libstddjb/cdbmake_addbeginend.c000066400000000000000000000012501455624754300221710ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #include "cdbmake-internal.h" int cdbmake_addend (cdbmaker *c, uint32_t keylen, uint32_t datalen, uint32_t h) { diuint32 blah = { .left = h, .right = c->pos } ; return genalloc_append(diuint32, &c->hplist, &blah) && cdbmake_posplus(c, 8) && cdbmake_posplus(c, keylen) && cdbmake_posplus(c, datalen) ; } int cdbmake_addbegin (cdbmaker *c, uint32_t keylen, uint32_t datalen) { char buf[8] ; uint32_pack(buf, keylen) ; uint32_pack(buf + 4, datalen) ; return buffer_put(&c->b, buf, 8) == 8 ; } skalibs-2.14.1.1/src/libstddjb/cdbmake_addv.c000066400000000000000000000015101455624754300206620ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #include #include #include "cdb-internal.h" #include "cdbmake-internal.h" int cdbmake_addv (cdbmaker *c, struct iovec const *kv, unsigned int kn, struct iovec const *dv, unsigned int dn) { size_t keylen = siovec_len(kv, kn) ; size_t datalen = siovec_len(dv, dn) ; if (keylen > UINT32_MAX || datalen > UINT32_MAX) return (errno = EOVERFLOW, 0) ; if (!cdbmake_addbegin(c, keylen, datalen) || buffer_putv(&c->b, kv, kn) < keylen || buffer_putv(&c->b, dv, dn) < datalen || !cdbmake_addend(c, keylen, datalen, cdb_hashv(kv, kn))) { genalloc_free(diuint32, &c->hplist) ; return 0 ; } return 1 ; } skalibs-2.14.1.1/src/libstddjb/cdbmake_finish.c000066400000000000000000000040521455624754300212300ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #include #include #include "cdbmake-internal.h" int cdbmake_finish (cdbmaker *c) { uint32_t count[256] ; uint32_t start[256] ; char final[2048] ; unsigned int size = 1 ; unsigned int n = genalloc_len(diuint32, &c->hplist) ; unsigned int i = 0 ; diuint32 *hp = genalloc_s(diuint32, &c->hplist) ; for (; i < 256 ; i++) count[i] = 0 ; for (i = 0 ; i < n ; i++) ++count[hp[i].left & 255] ; { uint32_t u = 0 ; for (i = 0 ; i < 256 ; i++) start[i] = u += count[i] ; /* bounded by n */ for (i = 0 ; i < 256 ; i++) { u = count[i] << 1 ; if (u > size) size = u ; } size += n ; /* no overflow possible up to now */ u = 0xffffffffUL ; u /= sizeof(diuint32) ; if (size > u) return (errno = ENOMEM, 0) ; } i = n ; { diuint32 split[size] ; while (i--) split[--start[hp[i].left & 255]] = hp[i] ; genalloc_free(diuint32, &c->hplist) ; hp = split + n ; for (i = 0 ; i < 256 ; ++i) { char buf[8] ; uint32_t k = count[i] ; uint32_t len = k << 1 ; /* no overflow possible */ diuint32 *p = split + start[i] ; uint32_pack(final + (i << 3), c->pos) ; uint32_pack(final + (i << 3) + 4, len) ; for (uint32_t j = 0 ; j < len ; j++) hp[j].left = hp[j].right = 0 ; for (uint32_t j = 0 ; j < k ; j++) { uint32_t where = (p->left >> 8) % len ; while (hp[where].right) if (++where == len) where = 0 ; hp[where] = *p++ ; } for (uint32_t j = 0 ; j < len ; j++) { uint32_pack(buf, hp[j].left) ; uint32_pack(buf + 4, hp[j].right) ; if (buffer_put(&c->b, buf, 8) < 0) return 0 ; if (!cdbmake_posplus(c, 8)) return 0 ; } } } if (!buffer_flush(&c->b) || lseek(buffer_fd(&c->b), 0, SEEK_SET) == -1 || buffer_putflush(&c->b, final, 2048) < 2048) return 0 ; return 1 ; } skalibs-2.14.1.1/src/libstddjb/cdbmake_posplus.c000066400000000000000000000004041455624754300214520ustar00rootroot00000000000000/* ISC license. */ #include #include #include "cdbmake-internal.h" int cdbmake_posplus (cdbmaker *c, uint32_t len) { uint32_t newpos = c->pos + len ; if (newpos < len) return (errno = ENOMEM, 0) ; c->pos = newpos ; return 1 ; } skalibs-2.14.1.1/src/libstddjb/cdbmake_start.c000066400000000000000000000005131455624754300211030ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include int cdbmake_start (cdbmaker *c, int fd) { c->hplist = genalloc_zero ; c->pos = 2048 ; buffer_init(&c->b, &buffer_write, fd, c->buf, BUFFER_OUTSIZE) ; return lseek(fd, c->pos, SEEK_SET) >= 0 ; } skalibs-2.14.1.1/src/libstddjb/child_spawn.c000066400000000000000000000027651455624754300206060ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include pid_t child_spawn (char const *prog, char const *const *argv, char const *const *envp, int *fds, size_t n) { pid_t pid ; cspawn_fileaction fa[2] = { [0] = { .type = CSPAWN_FA_MOVE, .x = { .fd2 = { [0] = 1 } } }, [1] = { .type = CSPAWN_FA_MOVE, .x = { .fd2 = { [0] = 0 } } } } ; size_t m = sizeof(SKALIBS_CHILD_SPAWN_FDS_ENVVAR) ; size_t envlen = env_len(envp) ; size_t i = 0 ; int p[n ? n : 1][2] ; char const *newenv[envlen + 2] ; char modifs[m + 1 + n * UINT_FMT] ; for (; i < n ; i++) { if (pipe(p[i]) == -1) goto errpi ; if ((ndelay_on(p[i][i & 1]) == -1) || (coe(p[i][i & 1]) == -1)) goto errpip ; } memcpy(modifs, SKALIBS_CHILD_SPAWN_FDS_ENVVAR "=", sizeof(SKALIBS_CHILD_SPAWN_FDS_ENVVAR)) ; for (i = 2 ; i < n ; i++) { m += uint_fmt(modifs + m, p[i][!(i & 1)]) ; if (i+1 < n) modifs[m++] = ',' ; } modifs[m++] = 0 ; env_mergen(newenv, envlen + 2, envp, envlen, modifs, m, 1) ; if (n) fa[0].x.fd2[1] = p[0][1] ; if (n >= 2) fa[1].x.fd2[1] = p[1][0] ; pid = cspawn(prog, argv, newenv, CSPAWN_FLAGS_SIGBLOCKNONE, fa, n < 2 ? n : 2) ; if (!pid) goto errpi ; for (i = 0 ; i < n ; i++) { fd_close(p[i][!(i & 1)]) ; fds[i] = p[i][i & 1] ; } return pid ; errpip: i++ ; errpi: while (i--) { fd_close(p[i][1]) ; fd_close(p[i][0]) ; } return 0 ; } skalibs-2.14.1.1/src/libstddjb/child_spawn0.c000066400000000000000000000003221455624754300206510ustar00rootroot00000000000000/* ISC license. */ #include pid_t child_spawn0 (char const *prog, char const *const *argv, char const *const *envp) { return cspawn(prog, argv, envp, CSPAWN_FLAGS_SIGBLOCKNONE, 0, 0) ; } skalibs-2.14.1.1/src/libstddjb/child_spawn1_internal.c000066400000000000000000000013241455624754300225510ustar00rootroot00000000000000/* ISC license. */ #include #include #include "cspawn-internal.h" pid_t child_spawn1_internal (char const *prog, char const *const *argv, char const *const *envp, int *p, int to) { pid_t pid ; cspawn_fileaction fa[3] = { [0] = { .type = CSPAWN_FA_CLOSE, .x = { .fd = p[!(to & 1)]} }, [1] = { .type = CSPAWN_FA_MOVE, .x = { .fd2 = { [0] = to & 1, [1] = p[to & 1] } } }, [2] = { .type = CSPAWN_FA_COPY, .x = { .fd2 = { [0] = !(to & 1), [1] = to & 1 } } } } ; pid = cspawn(prog, argv, envp, CSPAWN_FLAGS_SIGBLOCKNONE, fa, 2 + !!(to & 2)) ; if (!pid) goto err ; fd_close(p[to & 1]) ; return pid ; err: fd_close(p[1]) ; fd_close(p[0]) ; return 0 ; } skalibs-2.14.1.1/src/libstddjb/child_spawn1_pipe.c000066400000000000000000000006001455624754300216660ustar00rootroot00000000000000/* ISC license. */ #include #include #include "cspawn-internal.h" pid_t child_spawn1_pipe (char const *prog, char const *const *argv, char const *const *envp, int *fd, int to) { pid_t pid ; int p[2] ; if (pipe(p) < 0) return 0 ; pid = child_spawn1_internal(prog, argv, envp, p, !!to) ; if (!pid) return 0 ; *fd = p[!to] ; return pid ; } skalibs-2.14.1.1/src/libstddjb/child_spawn1_socket.c000066400000000000000000000006021455624754300222230ustar00rootroot00000000000000/* ISC license. */ #include #include #include "cspawn-internal.h" pid_t child_spawn1_socket (char const *prog, char const *const *argv, char const *const *envp, int *fd) { pid_t pid ; int p[2] ; if (ipc_pair_b(p) < 0) return 0 ; pid = child_spawn1_internal(prog, argv, envp, p, 3) ; if (!pid) return 0 ; *fd = p[0] ; return pid ; } skalibs-2.14.1.1/src/libstddjb/child_spawn2.c000066400000000000000000000017001455624754300206540ustar00rootroot00000000000000/* ISC license. */ #include #include #include pid_t child_spawn2 (char const *prog, char const *const *argv, char const *const *envp, int *fds) { pid_t pid ; int p[2][2] ; if (pipe(p[0]) == -1) return 0 ; if (ndelay_on(p[0][0]) == -1 || coe(p[0][0]) == -1 || pipe(p[1]) == -1) goto errp ; if (ndelay_on(p[1][1]) == -1 || coe(p[1][1]) == -1) goto err ; { cspawn_fileaction fa[2] = { [0] = { .type = CSPAWN_FA_MOVE, .x = { .fd2 = { [0] = fds[0], [1] = p[1][0] } } }, [1] = { .type = CSPAWN_FA_MOVE, .x = { .fd2 = { [0] = fds[1], [1] = p[0][1] } } } } ; pid = cspawn(prog, argv, envp, CSPAWN_FLAGS_SIGBLOCKNONE, fa, 2) ; if (!pid) goto err ; } fd_close(p[0][1]) ; fd_close(p[1][0]) ; fds[0] = p[0][0] ; fds[1] = p[1][1] ; return pid ; err: fd_close(p[1][1]) ; fd_close(p[1][0]) ; errp: fd_close(p[0][1]) ; fd_close(p[0][0]) ; return 0 ; } skalibs-2.14.1.1/src/libstddjb/child_spawn3.c000066400000000000000000000030771455624754300206660ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include pid_t child_spawn3 (char const *prog, char const *const *argv, char const *const *envp, int *fds) { pid_t pid ; int p[3][2] ; if (pipe(p[0]) == -1) return 0 ; if (ndelay_on(p[0][0]) == -1 || coe(p[0][0]) == -1 || pipe(p[1]) == -1) goto errp0 ; if (ndelay_on(p[1][1]) == -1 || coe(p[1][1]) == -1 || pipe(p[2]) == -1) goto errp1 ; if (ndelay_on(p[2][0]) == -1 || coe(p[2][0]) == -1) goto err ; { cspawn_fileaction fa[2] = { [0] = { .type = CSPAWN_FA_MOVE, .x = { .fd2 = { [0] = fds[0], [1] = p[1][0] } } }, [1] = { .type = CSPAWN_FA_MOVE, .x = { .fd2 = { [0] = fds[1], [1] = p[0][1] } } } } ; size_t envlen = env_len(envp) ; size_t m = sizeof(SKALIBS_CHILD_SPAWN_FDS_ENVVAR) ; char modifs[sizeof(SKALIBS_CHILD_SPAWN_FDS_ENVVAR) + UINT_FMT] = SKALIBS_CHILD_SPAWN_FDS_ENVVAR "=" ; char const *newenv[envlen + 2] ; m += uint_fmt(modifs + sizeof(SKALIBS_CHILD_SPAWN_FDS_ENVVAR), p[2][1]) ; modifs[m++] = 0 ; env_mergen(newenv, envlen + 2, envp, envlen, modifs, m, 1) ; pid = cspawn(prog, argv, newenv, CSPAWN_FLAGS_SIGBLOCKNONE, fa, 2) ; if (!pid) goto err ; } fd_close(p[2][1]) ; fd_close(p[1][0]) ; fd_close(p[0][1]) ; fds[0] = p[0][0] ; fds[1] = p[1][1] ; fds[2] = p[2][0] ; return pid ; err: fd_close(p[2][1]) ; fd_close(p[2][0]) ; errp1: fd_close(p[1][1]) ; fd_close(p[1][0]) ; errp0: fd_close(p[0][1]) ; fd_close(p[0][0]) ; return 0 ; } skalibs-2.14.1.1/src/libstddjb/coe.c000066400000000000000000000003371455624754300170520ustar00rootroot00000000000000/* ISC license. */ #include #include int coe (int fd) { int flags = fcntl(fd, F_GETFD, 0) ; return flags < 0 ? flags : flags & FD_CLOEXEC ? 0 : fcntl(fd, F_SETFD, flags | FD_CLOEXEC) ; } skalibs-2.14.1.1/src/libstddjb/cspawn-internal.h000066400000000000000000000003231455624754300214110ustar00rootroot00000000000000/* ISC license. */ #ifndef CSPAWN_INTERNAL_H #define CSPAWN_INTERNAL_H #include extern pid_t child_spawn1_internal (char const *, char const *const *, char const *const *, int *, int) ; #endif skalibs-2.14.1.1/src/libstddjb/cspawn.c000066400000000000000000000205501455624754300175760ustar00rootroot00000000000000/* ISC license. */ #include #ifdef SKALIBS_HASPOSIXSPAWN #include #endif #include #include #include #include #include #include #include #include static inline void cspawn_child_exec (char const *prog, char const *const *argv, char const *const *envp, uint16_t flags, cspawn_fileaction const *fa, size_t n) { for (size_t i = 0 ; i < n ; i++) { switch (fa[i].type) { case CSPAWN_FA_CLOSE : fd_close(fa[i].x.fd) ; break ; case CSPAWN_FA_COPY : if (fd_copy(fa[i].x.fd2[0], fa[i].x.fd2[1]) == -1) return ; break ; case CSPAWN_FA_MOVE : if (fd_move(fa[i].x.fd2[0], fa[i].x.fd2[1]) == -1) return ; if (fa[i].x.fd2[0] == fa[i].x.fd2[1] && uncoe(fa[i].x.fd2[0]) == -1) return ; break ; case CSPAWN_FA_OPEN : { int fd = open3(fa[i].x.openinfo.file, fa[i].x.openinfo.oflag, fa[i].x.openinfo.mode) ; if (fd == -1) return ; if (fd_move(fa[i].x.openinfo.fd, fd) == -1) return ; break ; } case CSPAWN_FA_CHDIR : if (chdir(fa[i].x.path) == -1) return ; break ; case CSPAWN_FA_FCHDIR : if (fchdir(fa[i].x.fd) == -1) return ; break ; default : errno = EINVAL ; return ; } } if (flags & CSPAWN_FLAGS_SELFPIPE_FINISH) selfpipe_finish() ; if (flags & CSPAWN_FLAGS_SIGBLOCKNONE) sig_blocknone() ; if (flags & CSPAWN_FLAGS_SETSID) setsid() ; exec_ae(prog, argv, envp) ; } static inline pid_t cspawn_fork (char const *prog, char const *const *argv, char const *const *envp, uint16_t flags, cspawn_fileaction const *fa, size_t n) { pid_t pid ; int p[2] ; char c ; if (pipecoe(p) == -1) return 0 ; pid = fork() ; if (pid == -1) { fd_close(p[1]) ; fd_close(p[0]) ; return 0 ; } if (!pid) { cspawn_child_exec(prog, argv, envp, flags, fa, n) ; c = errno ; fd_write(p[1], &c, 1) ; _exit(127) ; } fd_close(p[1]) ; p[1] = fd_read(p[0], &c, 1) ; if (p[1] < 0) { fd_close(p[0]) ; return 0 ; } fd_close(p[0]) ; if (p[1]) { wait_pid(pid, &p[0]) ; errno = (unsigned char)c ; return 0 ; } return pid ; } /* guess who has a buggy posix_spawn() *and* doesn't have waitid() to work around it? if you guessed OpenBSD, you're right! */ #if defined(SKALIBS_HASPOSIXSPAWN) && (!defined(SKALIBS_HASPOSIXSPAWNEARLYRETURN) || defined(SKALIBS_HASWAITID)) #include #include #include #include #include #ifdef SKALIBS_HASPOSIXSPAWNEARLYRETURN #include static inline pid_t cspawn_workaround (pid_t pid, int const *p) { siginfo_t si ; int e ; ssize_t r ; char c ; fd_close(p[1]) ; r = fd_read(p[0], &c, 1) ; fd_close(p[0]) ; if (r == -1) return 0 ; if (r) return (errno = EILSEQ, 0) ; /* child wrote, wtf */ do e = waitid(P_PID, pid, &si, WEXITED | WNOHANG | WNOWAIT) ; while (e == -1 && errno == EINTR) ; if (e == -1) return pid ; /* we're in trouble, but don't leak a child */ if (!si.si_pid) return pid ; /* child is running */ if (si.si_code != CLD_EXITED || si.si_status != 127) return pid ; /* child died after execve(), let caller handle it */ /* child exited 127, so either execve() failed, which is what we want to catch, or it raced like a mofo, execve()d and then exited 127 on its own, in which case, tough luck, it never existed. */ wait_pid(pid, 0) ; return (errno = 0, 0) ; } #endif static inline pid_t cspawn_pspawn (char const *prog, char const *const *argv, char const *const *envp, uint16_t flags, cspawn_fileaction const *fa, size_t n) { pid_t pid ; posix_spawnattr_t attr ; posix_spawn_file_actions_t actions ; int e ; int nopath = !getenv("PATH") ; #ifdef SKALIBS_HASPOSIXSPAWNEARLYRETURN int p[2] ; if (pipecoe(p) == -1) return 0 ; #endif if (flags) { short pfff = 0 ; e = posix_spawnattr_init(&attr) ; if (e) goto err ; if (flags & (CSPAWN_FLAGS_SIGBLOCKNONE | CSPAWN_FLAGS_SELFPIPE_FINISH)) { sigset_t set ; sigemptyset(&set) ; e = posix_spawnattr_setsigmask(&attr, &set) ; if (e) goto errattr ; pfff |= POSIX_SPAWN_SETSIGMASK ; } #ifdef SKALIBS_HASPOSIXSPAWNSETSID if (flags & CSPAWN_FLAGS_SETSID) pfff |= POSIX_SPAWN_SETSID ; #else #ifdef SKALIBS_HASPOSIXSPAWNSETSIDNP if (flags & CSPAWN_FLAGS_SETSID) pfff |= POSIX_SPAWN_SETSID_NP ; #endif #endif e = posix_spawnattr_setflags(&attr, pfff) ; if (e) goto errattr ; } if (n) { e = posix_spawn_file_actions_init(&actions) ; if (e) goto errattr ; for (size_t i = 0 ; i < n ; i++) { switch (fa[i].type) { case CSPAWN_FA_CLOSE : e = posix_spawn_file_actions_addclose(&actions, fa[i].x.fd) ; if (e) goto erractions ; break ; case CSPAWN_FA_COPY : e = posix_spawn_file_actions_adddup2(&actions, fa[i].x.fd2[1], fa[i].x.fd2[0]) ; if (e) goto erractions ; break ; case CSPAWN_FA_MOVE : e = posix_spawn_file_actions_adddup2(&actions, fa[i].x.fd2[1], fa[i].x.fd2[0]) ; if (e) goto erractions ; if (fa[i].x.fd2[0] != fa[i].x.fd2[1]) { e = posix_spawn_file_actions_addclose(&actions, fa[i].x.fd2[1]) ; if (e) goto erractions ; } break ; case CSPAWN_FA_OPEN : e = posix_spawn_file_actions_addopen(&actions, fa[i].x.openinfo.fd, fa[i].x.openinfo.file, fa[i].x.openinfo.oflag, fa[i].x.openinfo.mode) ; if (e) goto erractions ; break ; #ifdef SKALIBS_HASPOSIXSPAWNCHDIR case CSPAWN_FA_CHDIR : e = posix_spawn_file_actions_addchdir(&actions, fa[i].x.path) ; if (e) goto erractions ; break ; case CSPAWN_FA_FCHDIR : e = posix_spawn_file_actions_addfchdir(&actions, fa[i].x.fd) ; if (e) goto erractions ; break ; #else #ifdef SKALIBS_HASPOSIXSPAWNCHDIRNP case CSPAWN_FA_CHDIR : e = posix_spawn_file_actions_addchdir_np(&actions, fa[i].x.path) ; if (e) goto erractions ; break ; case CSPAWN_FA_FCHDIR : e = posix_spawn_file_actions_addfchdir_np(&actions, fa[i].x.fd) ; if (e) goto erractions ; break ; #endif #endif default : e = EINVAL ; goto erractions ; } } } if (nopath && (setenv("PATH", SKALIBS_DEFAULTPATH, 0) == -1)) { e = errno ; goto erractions ; } e = posix_spawnp(&pid, prog, n ? &actions : 0, flags ? &attr : 0, (char *const *)argv, (char *const *)envp) ; if (nopath) unsetenv("PATH") ; if (e) goto erractions ; if (n) posix_spawn_file_actions_destroy(&actions) ; if (flags) posix_spawnattr_destroy(&attr) ; #ifdef SKALIBS_HASPOSIXSPAWNEARLYRETURN return cspawn_workaround(pid, p) ; #else return pid ; #endif erractions: if (n) posix_spawn_file_actions_destroy(&actions) ; errattr: if (flags) posix_spawnattr_destroy(&attr) ; err: #ifdef SKALIBS_HASPOSIXSPAWNEARLYRETURN fd_close(p[1]) ; fd_close(p[0]) ; #endif errno = e ; return 0 ; } #if (defined(SKALIBS_HASPOSIXSPAWNSETSID) || defined(SKALIBS_HASPOSIXSPAWNSETSIDNP)) && (defined(SKALIBS_HASPOSIXSPAWNCHDIR) || defined(SKALIBS_HASPOSIXSPAWNCHDIRNP)) pid_t cspawn (char const *prog, char const *const *argv, char const *const *envp, uint16_t flags, cspawn_fileaction const *fa, size_t n) { return cspawn_pspawn(prog, argv, envp, flags, fa, n) ; } #else pid_t cspawn (char const *prog, char const *const *argv, char const *const *envp, uint16_t flags, cspawn_fileaction const *fa, size_t n) { #if !defined(SKALIBS_HASPOSIXSPAWNSETSID) && !defined(SKALIBS_HASPOSIXSPAWNSETSIDNP) if (flags & CSPAWN_FLAGS_SETSID) goto dofork ; #endif #if !defined(SKALIBS_HASPOSIXSPAWNCHDIR) && !defined(SKALIBS_HASPOSIXSPAWNCHDIRNP) for (size_t i = 0 ; i < n ; i++) if (fa[i].type == CSPAWN_FA_CHDIR || fa[i].type == CSPAWN_FA_FCHDIR) goto dofork ; #endif return cspawn_pspawn(prog, argv, envp, flags, fa, n) ; dofork: return cspawn_fork(prog, argv, envp, flags, fa, n) ; } #endif #else pid_t cspawn (char const *prog, char const *const *argv, char const *const *envp, uint16_t flags, cspawn_fileaction const *fa, size_t n) { return cspawn_fork(prog, argv, envp, flags, fa, n) ; } #endif skalibs-2.14.1.1/src/libstddjb/deepsleepuntil.c000066400000000000000000000003451455624754300213250ustar00rootroot00000000000000/* ISC license. */ #include #include void deepsleepuntil (tain const *deadline, tain *stamp) { iopause_fd x ; while (tain_less(stamp, deadline)) iopause_stamp(&x, 0, deadline, stamp) ; } skalibs-2.14.1.1/src/libstddjb/devino_cmp.c000066400000000000000000000004101455624754300204170ustar00rootroot00000000000000/* ISC license. */ #include int devino_cmp (void const *a, void const *b) { devino const *aa = a ; devino const *bb = b ; return aa->dev < bb->dev ? -1 : aa->dev > bb->dev ? 1 : aa->ino < bb->ino ? -1 : aa->ino > bb->ino ; } skalibs-2.14.1.1/src/libstddjb/dir_close.c000066400000000000000000000003331455624754300202430ustar00rootroot00000000000000/* ISC license. */ #include #include void dir_close (DIR *dir) { int e = errno ; for (;;) { if (closedir(dir) == 0) break ; if (errno != EINTR) break ; } errno = e ; } skalibs-2.14.1.1/src/libstddjb/dir_fd.c000066400000000000000000000004561455624754300175350ustar00rootroot00000000000000/* ISC license. */ #include #include #include #ifdef SKALIBS_HASDIRFD int dir_fd (DIR *dir) { return dirfd(dir) ; } #else /* Pokes at the internals of DIR - no choice here */ int dir_fd (DIR *dir) { return dir->dd_fd ; } #endif skalibs-2.14.1.1/src/libstddjb/djbtime-internal.h000066400000000000000000000005101455624754300215320ustar00rootroot00000000000000/* ISC license. */ #ifndef DJBTIME_INTERNAL_H #define DJBTIME_INTERNAL_H #include extern unsigned int const leapsecs_table_len ; extern uint64_t const *const leapsecs_table ; extern void leapsecs_add (uint64_t *, int) ; extern int leapsecs_sub (uint64_t *) ; extern int skalibs_tzisright (void) ; #endif skalibs-2.14.1.1/src/libstddjb/error_isalready.c000066400000000000000000000003521455624754300214670ustar00rootroot00000000000000/* ISC license. */ #include #include #include int error_isalready (int e) { return e == EALREADY || e == EINPROGRESS #ifdef SKALIBS_BSD_SUCKS || e == EADDRINUSE #endif ; } skalibs-2.14.1.1/src/libstddjb/error_temp.c000066400000000000000000000021631455624754300204610ustar00rootroot00000000000000/* ISC license. */ #include #include int error_temp (int e) { if (error_isagain(e)) return 1 ; switch (e) { case 0 : case EINTR : case ENOMEM : case ETXTBSY : case EIO : case ETIMEDOUT : case ENOBUFS : #ifdef EDEADLK case EDEADLK : #endif #ifdef EBUSY case EBUSY : #endif #ifdef ENFILE case ENFILE : #endif #ifdef EFBIG case EFBIG : #endif #ifdef ENOSPC case ENOSPC : #endif #ifdef ENETDOWN case ENETDOWN : #endif #ifdef ENETUNREACH case ENETUNREACH : #endif #ifdef ENETRESET case ENETRESET : #endif #ifdef ECONNABORTED case ECONNABORTED : #endif #ifdef ECONNRESET case ECONNRESET : #endif #ifdef ETOOMANYREFS case ETOOMANYREFS : #endif #ifdef ECONNREFUSED case ECONNREFUSED : #endif #ifdef EHOSTDOWN case EHOSTDOWN : #endif #ifdef EHOSTUNREACH case EHOSTUNREACH : #endif #ifdef EPROCLIM case EPROCLIM : #endif #ifdef EUSERS case EUSERS : #endif #ifdef EDQUOT case EDQUOT : #endif #ifdef ESTALE case ESTALE : #endif #ifdef ENOLCK case ENOLCK : #endif return 1 ; default : return 0 ; } } skalibs-2.14.1.1/src/libstddjb/fd_cat.c000066400000000000000000000005761455624754300175310ustar00rootroot00000000000000/* ISC license. */ #include #include #include #define BSIZE 65536 off_t fd_cat (int from, int to) { off_t n = 0 ; char buf[BSIZE] ; for (;;) { ssize_t r = fd_read(from, buf, BSIZE) ; if (r == -1) return -1 ; if (!r) break ; if (allwrite(to, buf, r) < r) return -1 ; n += r ; } return n ; } skalibs-2.14.1.1/src/libstddjb/fd_catn.c000066400000000000000000000011361455624754300177000ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #define BSIZE 65536 off_t fd_catn (int from, int to, off_t n) { off_t w = 0 ; char buf[BSIZE] ; while (n >= BSIZE) { size_t v ; ssize_t r = fd_read(from, buf, BSIZE) ; if (r == -1) return w ; if (!r) return (errno = EPIPE, w) ; v = allwrite(to, buf, r) ; if (v < r) return w + v ; n -= r ; w += r ; } if (n) { size_t r = allread(from, buf, n) ; size_t v = 0 ; if (r) v = allwrite(to, buf, r) ; w += v ; } return w ; } skalibs-2.14.1.1/src/libstddjb/fd_chdir.c000066400000000000000000000003141455624754300200410ustar00rootroot00000000000000/* ISC license. */ #include #include #include int fd_chdir (int d) { int r ; do r = fchdir(d) ; while ((r == -1) && (errno == EINTR)) ; return r ; } skalibs-2.14.1.1/src/libstddjb/fd_chmod.c000066400000000000000000000005051455624754300200440ustar00rootroot00000000000000/* ISC license. */ /* OpenBSD manages to bork the fchmod declaration */ #include #include #include #include int fd_chmod (int fd, unsigned int mode) { int r ; do r = fchmod(fd, (mode_t)mode) ; while ((r == -1) && (errno == EINTR)) ; return r ; } skalibs-2.14.1.1/src/libstddjb/fd_chown.c000066400000000000000000000003561455624754300200740ustar00rootroot00000000000000/* ISC license. */ #include #include #include int fd_chown (int fd, uid_t uid, gid_t gid) { int r ; do r = fchown(fd, uid, gid) ; while ((r == -1) && (errno == EINTR)) ; return r ; } skalibs-2.14.1.1/src/libstddjb/fd_close.c000066400000000000000000000002421455624754300200550ustar00rootroot00000000000000/* ISC license. */ #include #include #include void fd_close (int fd) { int e = errno ; close(fd) ; errno = e ; } skalibs-2.14.1.1/src/libstddjb/fd_copy.c000066400000000000000000000004131455624754300177220ustar00rootroot00000000000000/* ISC license. */ #include #include #include int fd_copy (int to, int from) { int r ; if (to == from) return (errno = EINVAL, -1) ; do r = dup2(from, to) ; while ((r == -1) && (errno == EINTR)) ; return r ; } skalibs-2.14.1.1/src/libstddjb/fd_copy2.c000066400000000000000000000005361455624754300200120ustar00rootroot00000000000000/* ISC license. */ #include #include int fd_copy2 (int to1, int from1, int to2, int from2) { if ((to1 == from2) || (to2 == from1)) return (errno = EINVAL, -1) ; if (fd_copy(to1, from1) == -1) return -1 ; if (fd_copy(to2, from2) == -1) { if (to1 != from1) fd_close(to1) ; return -1 ; } return 0 ; } skalibs-2.14.1.1/src/libstddjb/fd_ensure_open.c000066400000000000000000000006571455624754300213040ustar00rootroot00000000000000/* ISC license. */ #include #include #include int fd_ensure_open (int fd, int w) { int dummy ; if (fcntl(fd, F_GETFD, &dummy) == -1) { int newfd ; if (errno != EBADF) return 0 ; newfd = open2("/dev/null", w ? O_WRONLY : O_RDONLY) ; if (newfd == -1) return 0 ; if (fd_move(fd, newfd) == -1) { fd_close(newfd) ; return 0 ; } } return 1 ; } skalibs-2.14.1.1/src/libstddjb/fd_islocked.c000066400000000000000000000004541455624754300205520ustar00rootroot00000000000000/* ISC license. */ #include #include #include int fd_islocked (int fd) { struct flock fl = { .l_type = F_RDLCK, .l_whence = SEEK_SET, .l_start = 0, .l_len = 0 } ; return fcntl(fd, F_GETLK, &fl) == -1 ? -1 : fl.l_type != F_UNLCK ; } skalibs-2.14.1.1/src/libstddjb/fd_lock.c000066400000000000000000000010021455624754300176730ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include int fd_lock (int fd, int w, int nb) { struct flock fl = { .l_type = w ? F_WRLCK : F_RDLCK, .l_whence = SEEK_SET, .l_start = 0, .l_len = 0 } ; int e = errno ; int r ; do r = fcntl(fd, nb ? F_SETLK : F_SETLKW, &fl) ; while (r == -1 && errno == EINTR) ; return r != -1 ? 1 : errno == EACCES || error_isagain(errno) ? (errno = e, 0) : -1 ; } skalibs-2.14.1.1/src/libstddjb/fd_move.c000066400000000000000000000004431455624754300177210ustar00rootroot00000000000000/* ISC license. */ #include #include #include int fd_move (int to, int from) { int r ; if (to == from) return 0 ; do r = dup2(from, to) ; while ((r == -1) && (errno == EINTR)) ; if (r < 0) return r ; fd_close(from) ; return 0 ; } skalibs-2.14.1.1/src/libstddjb/fd_move2.c000066400000000000000000000014431455624754300200040ustar00rootroot00000000000000/* ISC license. */ #include #include #include int fd_move2 (int to1, int from1, int to2, int from2) { int tmp = from2 ; if (to1 == from1) return fd_move(to2, from2) ; if (to2 == from2) return fd_move(to1, from1) ; if (from1 == from2) return (to1 == to2) ? fd_move(to1, from1) : (errno = EINVAL, -1) ; if (to1 == to2) return (errno = EINVAL, -1) ; if (from2 == to1) { tmp = dup(from2) ; if (tmp == -1) return -1 ; } if (fd_copy(to1, from1) == -1) { if (from2 != tmp) fd_close(tmp) ; return -1 ; } if (fd_copy(to2, tmp) == -1) { int e = errno ; fd_close(to1) ; if (from2 != tmp) fd_move(from2, tmp) ; errno = e ; return -1 ; } if (from1 != to2) fd_close(from1) ; fd_close(tmp) ; return 0 ; } skalibs-2.14.1.1/src/libstddjb/fd_read.c000066400000000000000000000003651455624754300176710ustar00rootroot00000000000000/* ISC license. */ #include #include #include ssize_t fd_read (int fd, char *buf, size_t len) { ssize_t r ; do r = read(fd, buf, len) ; while ((r == -1) && (errno == EINTR)) ; return r ; } skalibs-2.14.1.1/src/libstddjb/fd_readv.c000066400000000000000000000004121455624754300200500ustar00rootroot00000000000000/* ISC license. */ #include #include #include ssize_t fd_readv (int fd, struct iovec const *v, unsigned int vlen) { ssize_t r ; do r = readv(fd, v, vlen) ; while ((r == -1) && (errno == EINTR)) ; return r ; } skalibs-2.14.1.1/src/libstddjb/fd_recv.c000066400000000000000000000004241455624754300177110ustar00rootroot00000000000000/* ISC license. */ #include #include #include ssize_t fd_recv (int fd, char *buf, size_t len, unsigned int flags) { ssize_t r ; do r = recv(fd, buf, len, flags) ; while ((r == -1) && (errno == EINTR)) ; return r ; } skalibs-2.14.1.1/src/libstddjb/fd_send.c000066400000000000000000000004321455624754300177020ustar00rootroot00000000000000/* ISC license. */ #include #include #include ssize_t fd_send (int fd, char const *buf, size_t len, unsigned int flags) { ssize_t r ; do r = send(fd, buf, len, flags) ; while ((r == -1) && (errno == EINTR)) ; return r ; } skalibs-2.14.1.1/src/libstddjb/fd_shutdown.c000066400000000000000000000003511455624754300206240ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include void fd_shutdown (int fd, int h) { int e = errno ; shutdown(fd, h ? SHUT_WR : SHUT_RD) ; errno = e ; } skalibs-2.14.1.1/src/libstddjb/fd_sync.c000066400000000000000000000003141455624754300177240ustar00rootroot00000000000000/* ISC license. */ #include #include #include int fd_sync (int fd) { int r ; do r = fsync(fd) ; while ((r == -1) && (errno == EINTR)) ; return r ; } skalibs-2.14.1.1/src/libstddjb/fd_unlock.c000066400000000000000000000004651455624754300202520ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include void fd_unlock (int fd) { struct flock fl = { .l_type = F_UNLCK, .l_whence = SEEK_SET, .l_start = 0, .l_len = 0 } ; int e = errno ; fcntl(fd, F_SETLK, &fl) ; errno = e ; } skalibs-2.14.1.1/src/libstddjb/fd_write.c000066400000000000000000000003751455624754300201110ustar00rootroot00000000000000/* ISC license. */ #include #include #include ssize_t fd_write (int fd, char const *buf, size_t len) { ssize_t r ; do r = write(fd, buf, len) ; while ((r == -1) && (errno == EINTR)) ; return r ; } skalibs-2.14.1.1/src/libstddjb/fd_writev.c000066400000000000000000000004141455624754300202710ustar00rootroot00000000000000/* ISC license. */ #include #include #include ssize_t fd_writev (int fd, struct iovec const *v, unsigned int vlen) { ssize_t r ; do r = writev(fd, v, vlen) ; while ((r == -1) && (errno == EINTR)) ; return r ; } skalibs-2.14.1.1/src/libstddjb/filecopy_suffix.c000066400000000000000000000011041455624754300214730ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include int filecopy_suffix (char const *src, char const *dst, unsigned int mode, char const *suffix) { size_t dstlen = strlen(dst) ; size_t suffixlen = strlen(suffix) ; char tmp[dstlen + suffixlen + 1] ; memcpy(tmp, dst, dstlen) ; memcpy(tmp + dstlen, suffix, suffixlen + 1) ; if (!filecopy_unsafe(src, tmp, mode)) return 0 ; if (rename(tmp, dst) < 0) { int e = errno ; unlink(tmp) ; errno = e ; return 0 ; } return 1 ; } skalibs-2.14.1.1/src/libstddjb/filecopy_unsafe.c000066400000000000000000000006611455624754300214570ustar00rootroot00000000000000/* ISC license. */ #include #include int filecopy_unsafe (char const *src, char const *dst, unsigned int mode) { int d ; int s = open2(src, O_RDONLY) ; if (s < 0) return 0 ; d = open3(dst, O_WRONLY | O_CREAT | O_TRUNC, mode) ; if (d < 0) goto errs ; if (fd_cat(s, d) < 0) goto errd ; fd_close(d) ; fd_close(s) ; return 1 ; errd: fd_close(d) ; errs: fd_close(s) ; return 0 ; } skalibs-2.14.1.1/src/libstddjb/fmtscan-internal.h000066400000000000000000000042331455624754300215550ustar00rootroot00000000000000/* ISC license. */ #ifndef FMTSCAN_INTERNAL_H #define FMTSCAN_INTERNAL_H #include #include #include #include #include #include #define SCANB0(bits) \ size_t uint##bits##0_scan_base (char const *s, uint##bits##_t *u, uint8_t base) \ { \ size_t pos = uint##bits##_scan_base(s, u, base) ; \ if (!pos) return (errno = EINVAL, 0) ; \ if (!s[pos]) return pos ; \ errno = fmtscan_num(s[pos], base) < base ? ERANGE : EINVAL ; \ return 0 ; \ } \ #define SCANS0(bits) \ size_t int##bits##0_scan_base (char const *s, int##bits##_t *d, uint8_t base) \ { \ size_t pos = int##bits##_scan(s, d) ; \ if (!pos) return (errno = EINVAL, 0) ; \ if (!s[pos]) return pos ; \ errno = (fmtscan_num(s[pos], base) < base) ? ERANGE : EINVAL ; \ return 0 ; \ } \ #define SCANL(bits) \ size_t uint##bits##_scanlist (uint##bits##_t *tab, size_t max, char const *s, size_t *num) \ { \ size_t i = 0, len = 0 ; \ for (; s[len] && (i < max) ; i++) \ { \ size_t w = uint##bits##_scan(s + len, tab + i) ; \ if (!w) break ; \ len += w ; \ while (memchr(",:; \t\r\n", s[len], 7)) len++ ; \ } \ *num = i ; \ return len ; \ } \ #define SCANSL(bits) \ size_t int##bits##_scanlist (int##bits##_t *tab, size_t max, char const *s, size_t *num) \ { \ size_t i = 0, len = 0 ; \ for (; s[len] && (i < max) ; i++) \ { \ size_t w = int##bits##_scan(s + len, tab + i) ; \ if (!w) break ; \ len += w ; \ while (memchr(",:; \t\r\n", s[len], 7)) len++ ; \ } \ *num = i ; \ return len ; \ } \ #define FMTL(bits) \ static uint64_t get (void const *tab, size_t i) \ { \ return ((uint##bits##_t const *)tab)[i] ; \ } \ size_t uint##bits##_fmtlist (char *s, uint##bits##_t const *tab, size_t n) \ { \ return uint64_fmtlist_generic(s, tab, n, 10, &get) ; \ } \ #define FMTSL(bits) \ size_t int##bits##_fmtlist (char *s, int##bits##_t const *tab, size_t n) \ { \ size_t i = 0, len = 0 ; \ for (; i < n ; i++) \ { \ size_t w = int##bits##_fmt(s, tab[i]) ; \ len += w ; \ if (s) s += w ; \ if (i < n-1) { len++ ; if (s) *s++ = ',' ; } \ } \ return len ; \ } \ #endif skalibs-2.14.1.1/src/libstddjb/fmtscan_asc.c000066400000000000000000000003101455624754300205540ustar00rootroot00000000000000/* ISC license. */ #include unsigned char fmtscan_asc (unsigned char c) { static char const *tab = "0123456789abcdefghijklmnopqrstuvwxyz" ; return (c >= 36) ? 0 : tab[c] ; } skalibs-2.14.1.1/src/libstddjb/fmtscan_num.c000066400000000000000000000005541455624754300206170ustar00rootroot00000000000000/* ISC license. */ #include unsigned char fmtscan_num (unsigned char c, unsigned char n) { return ((c < '0') || (n > 36)) ? n : (n <= 10) ? (c - '0' <= n) ? c - '0' : n : (c - '0' <= 9) ? c - '0' : (c < 'A') ? n : (c - 'A' < n - 10) ? c - 'A' + 10 : (c < 'a') ? n : (c - 'a' < n - 10) ? c - 'a' + 10 : n ; } skalibs-2.14.1.1/src/libstddjb/gcspawn.c000066400000000000000000000021141455624754300177410ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #include pid_t gcspawn (char const *prog, char const *const *argv, char const *const *envp, uint16_t flags, cspawn_fileaction const *fa, size_t n) { pid_t pid = 0 ; int wstat ; int p[2] ; char pack[PID_PACK] ; if (pipecoe(p) == -1) return 0 ; pid = fork() ; switch (pid) { case -1: { fd_close(p[1]) ; fd_close(p[0]) ; return 0 ; } case 0: { fd_close(p[0]) ; pid = cspawn(prog, argv, envp, flags, fa, n) ; if (!pid) _exit(errno) ; pid_pack_big(pack, pid) ; _exit(fd_write(p[1], pack, PID_PACK) < PID_PACK ? errno : 0) ; } } fd_close(p[1]) ; if (fd_read(p[0], pack, PID_PACK) < PID_PACK) goto err ; fd_close(p[0]) ; wait_pid(pid, &wstat) ; pid_unpack_big(pack, &pid) ; return pid ; err: fd_close(p[0]) ; wait_pid(pid, &wstat) ; return (errno = WIFSIGNALED(wstat) ? EINTR : WEXITSTATUS(wstat), 0) ; } skalibs-2.14.1.1/src/libstddjb/genalloc_deepfree.c000066400000000000000000000004221455624754300217220ustar00rootroot00000000000000/* ISC license. */ #include #include void genalloc_deepfree_size (genalloc *g, free_func_ref f, size_t size) { size_t len = g->len / size ; size_t i = 0 ; for (; i < len ; i++) (*f)(g->s + i * size) ; stralloc_free(g) ; } skalibs-2.14.1.1/src/libstddjb/genwrite_flush_bufalloc.c000066400000000000000000000002561455624754300232000ustar00rootroot00000000000000/* ISC license. */ #include #include int genwrite_flush_bufalloc (void *target) { return bufalloc_flush((bufalloc *)target) ; } skalibs-2.14.1.1/src/libstddjb/genwrite_flush_buffer.c000066400000000000000000000002461455624754300226610ustar00rootroot00000000000000/* ISC license. */ #include #include int genwrite_flush_buffer (void *target) { return buffer_flush((buffer *)target) ; } skalibs-2.14.1.1/src/libstddjb/genwrite_flush_stralloc.c000066400000000000000000000002001455624754300232210ustar00rootroot00000000000000/* ISC license. */ #include int genwrite_flush_stralloc (void *target) { (void)target ; return 1 ; } skalibs-2.14.1.1/src/libstddjb/genwrite_put_bufalloc.c000066400000000000000000000003741455624754300226700ustar00rootroot00000000000000/* ISC license. */ #include #include #include ssize_t genwrite_put_bufalloc (void *target, char const *s, size_t len) { return bufalloc_put((bufalloc *)target, s, len) ? (ssize_t)len : -1 ; } skalibs-2.14.1.1/src/libstddjb/genwrite_put_buffer.c000066400000000000000000000003111455624754300223410ustar00rootroot00000000000000/* ISC license. */ #include #include ssize_t genwrite_put_buffer (void *target, char const *s, size_t len) { return buffer_put((buffer *)target, s, len) ; } skalibs-2.14.1.1/src/libstddjb/genwrite_put_stralloc.c000066400000000000000000000003351455624754300227210ustar00rootroot00000000000000/* ISC license. */ #include #include ssize_t genwrite_put_stralloc (void *target, char const *s, size_t len) { return stralloc_catb((stralloc *)target, s, len) ? len : -1 ; } skalibs-2.14.1.1/src/libstddjb/genwrite_stderr.c000066400000000000000000000002131455624754300215040ustar00rootroot00000000000000/* ISC license. */ #include #include genwrite genwrite_stderr = GENWRITE_BUFFER_INIT(buffer_2) ; skalibs-2.14.1.1/src/libstddjb/genwrite_stdout.c000066400000000000000000000002131455624754300215230ustar00rootroot00000000000000/* ISC license. */ #include #include genwrite genwrite_stdout = GENWRITE_BUFFER_INIT(buffer_1) ; skalibs-2.14.1.1/src/libstddjb/getlnmax.c000066400000000000000000000013111455624754300201140ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include int getlnmax (buffer *b, char *d, size_t max, size_t *w, char sep) { if (*w > max) return (errno = EINVAL, -1) ; for (;;) { size_t len = buffer_len(b) ; struct iovec v[2] ; size_t pos ; ssize_t r ; buffer_rpeek(b, v) ; if (len > max - *w) len = max - *w ; pos = siovec_bytechr(v, 2, sep) ; if (pos > len) pos = len ; r = pos < len ; pos += r ; buffer_getnofill(b, d + *w, pos) ; *w += pos ; if (r) return 1 ; if (*w >= max) return (errno = ERANGE, -1) ; r = buffer_fill(b) ; if (r <= 0) return r ; } } skalibs-2.14.1.1/src/libstddjb/getlnmaxsep.c000066400000000000000000000013501455624754300206270ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include int getlnmaxsep (buffer *b, char *d, size_t max, size_t *w, char const *sep, size_t seplen) { if (max < *w) return (errno = EINVAL, -1) ; for (;;) { struct iovec v[2] ; size_t len = buffer_len(b) ; size_t pos ; ssize_t r ; buffer_rpeek(b, v) ; if (len > max - *w) len = max - *w ; pos = siovec_bytein(v, 2, sep, seplen) ; if (pos > len) pos = len ; r = pos < len ; pos += r ; buffer_getnofill(b, d + *w, pos) ; *w += pos ; if (*w >= max) return (errno = ERANGE, -1) ; if (r) return 1 ; r = buffer_fill(b) ; if (r <= 0) return r ; } } skalibs-2.14.1.1/src/libstddjb/hiercopy.c000066400000000000000000000002651455624754300201260ustar00rootroot00000000000000/* ISC license. */ #include #include int hiercopy (char const *src, char const *dst) { return hiercopy_internal(src, dst, &satmp, 0) ; } skalibs-2.14.1.1/src/libstddjb/hiercopy_internal.c000066400000000000000000000043641455624754300220260ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #include #include static int dircopy (char const *src, char const *dst, mode_t mode, stralloc *tmp, unsigned int options) { size_t tmpbase = tmp->len ; size_t maxlen = 0 ; if (sals(src, tmp, &maxlen) == -1) return 0 ; if (mkdir(dst, S_IRWXU) < 0) { struct stat st ; if (errno != EEXIST) goto err ; if (stat(dst, &st) < 0) goto err ; if (!S_ISDIR(st.st_mode)) { errno = ENOTDIR ; goto err ; } } { size_t srclen = strlen(src) ; size_t dstlen = strlen(dst) ; size_t i = tmpbase ; char srcbuf[srclen + maxlen + 2] ; char dstbuf[dstlen + maxlen + 2] ; memcpy(srcbuf, src, srclen) ; memcpy(dstbuf, dst, dstlen) ; srcbuf[srclen] = '/' ; dstbuf[dstlen] = '/' ; while (i < tmp->len) { size_t n = strlen(tmp->s + i) + 1 ; memcpy(srcbuf + srclen + 1, tmp->s + i, n) ; memcpy(dstbuf + dstlen + 1, tmp->s + i, n) ; i += n ; hiercopy_internal(srcbuf, dstbuf, tmp, 0) ; } } if (chmod(dst, mode) < 0 && !(options & 1)) goto err ; tmp->len = tmpbase ; return 1 ; err: tmp->len = tmpbase ; return 0 ; } int hiercopy_internal (char const *src, char const *dst, stralloc *tmp, unsigned int options) { struct stat st ; if (lstat(src, &st) < 0) return 0 ; if (S_ISREG(st.st_mode)) { if (!filecopy_unsafe(src, dst, st.st_mode)) return 0 ; } else if (S_ISDIR(st.st_mode)) { if (!dircopy(src, dst, st.st_mode, tmp, options)) return 0 ; } else if (S_ISFIFO(st.st_mode)) { if (mkfifo(dst, st.st_mode) < 0) return 0 ; } else if (S_ISLNK(st.st_mode)) { size_t tmpbase = tmp->len ; if (sareadlink(tmp, src) < 0) return 0 ; if (!stralloc_0(tmp) || symlink(tmp->s + tmpbase, dst) < 0) { tmp->len = tmpbase ; return 0 ; } tmp->len = tmpbase ; } else if (S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode) || S_ISSOCK(st.st_mode)) { if (mknod(dst, st.st_mode, st.st_rdev) < 0) return 0 ; } else return (errno = ENOTSUP, 0) ; lchown(dst, st.st_uid, st.st_gid) ; if (!S_ISLNK(st.st_mode)) chmod(dst, st.st_mode) ; return 1 ; } skalibs-2.14.1.1/src/libstddjb/hiercopy_loose.c000066400000000000000000000002731455624754300213260ustar00rootroot00000000000000/* ISC license. */ #include #include int hiercopy_loose (char const *src, char const *dst) { return hiercopy_internal(src, dst, &satmp, 1) ; } skalibs-2.14.1.1/src/libstddjb/hiercopy_loose_tmp.c000066400000000000000000000002561455624754300222070ustar00rootroot00000000000000/* ISC license. */ #include int hiercopy_loose_tmp (char const *src, char const *dst, stralloc *tmp) { return hiercopy_internal(src, dst, tmp, 1) ; } skalibs-2.14.1.1/src/libstddjb/hiercopy_tmp.c000066400000000000000000000002501455624754300210000ustar00rootroot00000000000000/* ISC license. */ #include int hiercopy_tmp (char const *src, char const *dst, stralloc *tmp) { return hiercopy_internal(src, dst, tmp, 0) ; } skalibs-2.14.1.1/src/libstddjb/int160_scan.c000066400000000000000000000001321455624754300203220ustar00rootroot00000000000000/* ISC license. */ #include #include "fmtscan-internal.h" SCANS0(16) skalibs-2.14.1.1/src/libstddjb/int16_fmtlist.c000066400000000000000000000001311455624754300207770ustar00rootroot00000000000000/* ISC license. */ #include "fmtscan-internal.h" #include FMTSL(16) skalibs-2.14.1.1/src/libstddjb/int16_scan.c000066400000000000000000000004541455624754300202510ustar00rootroot00000000000000/* ISC license. */ #include #include #include "fmtscan-internal.h" size_t int16_scan_base (char const *s, int16_t *d, uint8_t base) { int64_t dd ; size_t pos = int64_scan_base_max(s, &dd, base, UINT16_MAX) ; if (pos) *d = (uint16_t)dd ; return pos ; } skalibs-2.14.1.1/src/libstddjb/int16_scanlist.c000066400000000000000000000001321455624754300211360ustar00rootroot00000000000000/* ISC license. */ #include "fmtscan-internal.h" #include SCANSL(16) skalibs-2.14.1.1/src/libstddjb/int320_scan.c000066400000000000000000000001321455624754300203200ustar00rootroot00000000000000/* ISC license. */ #include #include "fmtscan-internal.h" SCANS0(32) skalibs-2.14.1.1/src/libstddjb/int32_fmtlist.c000066400000000000000000000001311455624754300207750ustar00rootroot00000000000000/* ISC license. */ #include "fmtscan-internal.h" #include FMTSL(32) skalibs-2.14.1.1/src/libstddjb/int32_scan.c000066400000000000000000000004531455624754300202460ustar00rootroot00000000000000/* ISC license. */ #include #include #include "fmtscan-internal.h" size_t int32_scan_base (char const *s, int32_t *d, uint8_t base) { int64_t dd ; size_t pos = int64_scan_base_max(s, &dd, base, UINT32_MAX) ; if (pos) *d = (int32_t)dd ; return pos ; } skalibs-2.14.1.1/src/libstddjb/int32_scanlist.c000066400000000000000000000001321455624754300211340ustar00rootroot00000000000000/* ISC license. */ #include "fmtscan-internal.h" #include SCANSL(32) skalibs-2.14.1.1/src/libstddjb/int640_scan.c000066400000000000000000000001321455624754300203250ustar00rootroot00000000000000/* ISC license. */ #include #include "fmtscan-internal.h" SCANS0(64) skalibs-2.14.1.1/src/libstddjb/int64_fmt_generic.c000066400000000000000000000004121455624754300216040ustar00rootroot00000000000000/* ISC license. */ #include size_t int64_fmt_generic (char *fmt, int64_t d, uint8_t base) { if (d >= 0) return uint64_fmt_generic(fmt, (uint64_t)d, base) ; if (fmt) *fmt++ = '-' ; return 1 + uint64_fmt_generic(fmt, -(uint64_t)d, base) ; } skalibs-2.14.1.1/src/libstddjb/int64_fmtlist.c000066400000000000000000000001311455624754300210020ustar00rootroot00000000000000/* ISC license. */ #include "fmtscan-internal.h" #include FMTSL(64) skalibs-2.14.1.1/src/libstddjb/int64_scan.c000066400000000000000000000003121455624754300202450ustar00rootroot00000000000000/* ISC license. */ #include #include "fmtscan-internal.h" size_t int64_scan_base (char const *s, int64_t *d, uint8_t base) { return int64_scan_base_max(s, d, base, INT64_MAX) ; } skalibs-2.14.1.1/src/libstddjb/int64_scan_base_max.c000066400000000000000000000010021455624754300221010ustar00rootroot00000000000000/* ISC license. */ #include #include "fmtscan-internal.h" size_t int64_scan_base_max (char const *s, int64_t *d, uint8_t base, uint64_t max) { if (s[0] == '-') { uint64_t u ; size_t pos = uint64_scan_base_max(s+1, &u, base, max+1) ; return pos ? (*d = -u, 1 + pos) : 0 ; } else if (s[0] == '+') { size_t pos = uint64_scan_base_max(s+1, (uint64_t *)d, base, max) ; return pos ? 1 + pos : 0 ; } else return uint64_scan_base_max(s, (uint64_t *)d, base, max) ; } skalibs-2.14.1.1/src/libstddjb/int64_scanlist.c000066400000000000000000000001321455624754300211410ustar00rootroot00000000000000/* ISC license. */ #include "fmtscan-internal.h" #include SCANSL(64) skalibs-2.14.1.1/src/libstddjb/iopause.c000066400000000000000000000005401455624754300177450ustar00rootroot00000000000000/* ISC license. */ #include #include #ifdef SKALIBS_HASPPOLL iopause_func_ref const iopause_ = &iopause_ppoll ; #else #include #ifdef SKALIBS_FLAG_PREFERSELECT iopause_func_ref const iopause_ = &iopause_select ; #else iopause_func_ref const iopause_ = &iopause_poll ; #endif #endif skalibs-2.14.1.1/src/libstddjb/iopause_poll.c000066400000000000000000000006641455624754300210020ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include int iopause_poll (iopause_fd *x, unsigned int len, tain const *deadline, tain const *stamp) { int millisecs = 0 ; if (!deadline) millisecs = -1 ; else if (tain_less(stamp, deadline)) { tain t ; tain_sub(&t, deadline, stamp) ; millisecs = tain_to_millisecs(&t) ; } return poll(x, len, millisecs) ; } skalibs-2.14.1.1/src/libstddjb/iopause_ppoll.c000066400000000000000000000016201455624754300211530ustar00rootroot00000000000000/* ISC license. */ #include #ifdef SKALIBS_HASPPOLL #include #include #include #include #include #include int iopause_ppoll (iopause_fd *x, unsigned int len, tain const *deadline, tain const *stamp) { struct timespec ts = { .tv_sec = 0, .tv_nsec = 0 } ; if (deadline && tain_less(stamp, deadline)) { tain delta ; tain_sub(&delta, deadline, stamp) ; if (!timespec_from_tain_relative(&ts, &delta)) { if (errno != EOVERFLOW) return -1 ; else deadline = 0 ; } } return ppoll(x, len, deadline ? &ts : 0, 0) ; } #else #include #include int iopause_ppoll (iopause_fd *x, unsigned int len, tain const *deadline, tain const *stamp) { (void)x ; (void)len ; (void)deadline ; (void)stamp ; return (errno = ENOSYS, -1) ; } #endif skalibs-2.14.1.1/src/libstddjb/iopause_select.c000066400000000000000000000031671455624754300213140ustar00rootroot00000000000000/* ISC license. */ #include #include /* Solaris... */ #include #include #include #include int iopause_select (iopause_fd *x, unsigned int len, tain const *deadline, tain const *stamp) { struct timeval tv = { .tv_sec = 0, .tv_usec = 0 } ; int nfds = 0 ; fd_set rfds, wfds, xfds ; int r ; FD_ZERO(&rfds) ; FD_ZERO(&wfds) ; FD_ZERO(&xfds) ; if (deadline && tain_less(stamp, deadline)) { tain delta ; tain_sub(&delta, deadline, stamp) ; if (!timeval_from_tain_relative(&tv, &delta)) { if (errno != EOVERFLOW) return -1 ; else deadline = 0 ; } } { unsigned int i = 0 ; for (; i < len ; i++) { x[i].revents = 0 ; if (x[i].fd >= 0) { if (x[i].fd >= FD_SETSIZE) return (errno = EMFILE, -1) ; if (x[i].fd >= nfds) nfds = x[i].fd + 1 ; if (x[i].events & IOPAUSE_READ) FD_SET(x[i].fd, &rfds) ; if (x[i].events & IOPAUSE_WRITE) FD_SET(x[i].fd, &wfds) ; if (x[i].events & IOPAUSE_EXCEPT) FD_SET(x[i].fd, &xfds) ; } } } r = select(nfds, &rfds, &wfds, &xfds, deadline ? &tv : 0) ; if (r > 0) { unsigned int i = 0 ; for (; i < len ; i++) if (x[i].fd >= 0) { if ((x[i].events & IOPAUSE_READ) && FD_ISSET(x[i].fd, &rfds)) x[i].revents |= IOPAUSE_READ ; if ((x[i].events & IOPAUSE_WRITE) && FD_ISSET(x[i].fd, &wfds)) x[i].revents |= IOPAUSE_WRITE ; if ((x[i].events & IOPAUSE_EXCEPT) && FD_ISSET(x[i].fd, &xfds)) x[i].revents |= IOPAUSE_EXCEPT ; } } return r ; } skalibs-2.14.1.1/src/libstddjb/iopause_stamp.c000066400000000000000000000006071455624754300211550ustar00rootroot00000000000000/* ISC license. */ #include #include #include int iopause_stamp (iopause_fd *x, unsigned int n, tain const *deadline, tain *stamp) { int r ; do { r = iopause(x, n, deadline, stamp) ; if (stamp) { int e = errno ; tain_now(stamp) ; errno = e ; } } while ((r < 0) && (errno == EINTR)) ; return r ; } skalibs-2.14.1.1/src/libstddjb/ip46_scan.c000066400000000000000000000004571455624754300200750ustar00rootroot00000000000000/* ISC license. */ #include #include #include size_t ip46full_scan (char const *s, ip46full *ip) { size_t len = ip6_scan(s, ip->ip) ; if (len) ip->is6 = 1 ; else { len = ip4_scan(s, ip->ip) ; if (len) ip->is6 = 0 ; } return len ; } skalibs-2.14.1.1/src/libstddjb/ip46_scanlist.c000066400000000000000000000010151455624754300207600ustar00rootroot00000000000000/* ISC license. */ #include #include #include size_t ip46full_scanlist (ip46full *out, size_t max, char const *s, size_t *num) { size_t n = 0, w = 0 ; for (; s[w] && (n < max) ; n++) { ip46full z ; size_t i = ip6_scan(s + w, z.ip) ; if (i) z.is6 = 1 ; else { i = ip4_scan(s + w, z.ip) ; if (!i) break ; z.is6 = 0 ; } out[n] = z ; w += i ; while (memchr(",; \t\r\n", s[w], 6)) w++ ; } *num = n ; return w ; } skalibs-2.14.1.1/src/libstddjb/ip4_fmt.c000066400000000000000000000005461455624754300176500ustar00rootroot00000000000000/* ISC license. */ #include #include size_t ip4_fmt (char *s, char const *ip) { size_t len = 0 ; unsigned int j = 0 ; for (; j < 4 ; j++) { size_t i = uint32_fmt(s, (unsigned char)ip[j]) ; len += i ; if (s) s += i ; if (j == 3) break ; if (s) *s++ = '.' ; ++len ; } return len ; } skalibs-2.14.1.1/src/libstddjb/ip4_fmtu32.c000066400000000000000000000003061455624754300201740ustar00rootroot00000000000000/* ISC license. */ #include #include size_t ip4_fmtu32 (char *s, uint32_t ip) { char pack[4] ; uint32_pack_big(pack, ip) ; return ip4_fmt(s, pack) ; } skalibs-2.14.1.1/src/libstddjb/ip4_scan.c000066400000000000000000000006361455624754300200060ustar00rootroot00000000000000/* ISC license. */ #include #include size_t ip4_scan (char const *s, char *ip) { size_t len = 0 ; unsigned int j = 0 ; for (; j < 4 ; j++) { unsigned int u ; size_t i = uint_scan(s, &u) ; if (!i) return 0 ; ip[j] = (char)u ; s += i ; len += i ; if (j == 3) break ; if (*s != '.') return 0 ; ++s ; ++len ; } return len ; } skalibs-2.14.1.1/src/libstddjb/ip4_scanlist.c000066400000000000000000000005601455624754300206760ustar00rootroot00000000000000/* ISC license. */ #include #include size_t ip4_scanlist (char *out, size_t max, char const *s, size_t *num) { size_t n = 0, w = 0 ; for (; s[w] && (n < max) ; n++) { size_t i = ip4_scan(s + w, out + (n << 2)) ; if (!i) break ; w += i ; while (memchr(",:; \t\r\n", s[w], 7)) w++ ; } *num = n ; return w ; } skalibs-2.14.1.1/src/libstddjb/ip4_scanlist_u32.c000066400000000000000000000005641455624754300213730ustar00rootroot00000000000000/* ISC license. */ #include #include size_t ip4_scanlist_u32 (uint32_t *out, size_t max, char const *s, size_t *num) { size_t n = 0, w = 0 ; for (; s[w] && (n < max) ; n++) { size_t i = ip4_scanu32(s + w, out + n) ; if (!i) break ; w += i ; while (memchr(",:; \t\r\n", s[w], 7)) w++ ; } *num = n ; return w ; } skalibs-2.14.1.1/src/libstddjb/ip4_scanu32.c000066400000000000000000000003511455624754300203320ustar00rootroot00000000000000/* ISC license. */ #include #include size_t ip4_scanu32 (char const *s, uint32_t *ip) { char pack[4] ; size_t r = ip4_scan(s, pack) ; if (r) uint32_unpack_big(pack, ip) ; return r ; } skalibs-2.14.1.1/src/libstddjb/ip6_fmt.c000066400000000000000000000031101455624754300176400ustar00rootroot00000000000000/* ISC license. */ #include #include #define px(c) ((j || (c)) ? (*s++ = fmtscan_asc(c), 1) : 0) static inline size_t xfmt16 (char *s, char const *key) { size_t j = 0 ; j += px((unsigned char)key[0] >> 4) ; j += px((unsigned char)key[0] & 15) ; j += px((unsigned char)key[1] >> 4) ; j += px((unsigned char)key[1] & 15) ; return j ? j : (*s = '0', 1) ; } static inline unsigned int find_colcol (char const *key, unsigned int *pos) { diuint z[4] = { DIUINT_ZERO, DIUINT_ZERO, DIUINT_ZERO, DIUINT_ZERO } ; unsigned int j = 0 ; unsigned int max = 0 ; int iszero = 0 ; unsigned int i = 0 ; for ( ; i < 8 ; i++) { if (key[i<<1] || key[(i<<1)+1]) { if (iszero) { iszero = 0 ; z[j].right = i - z[j].left ; if (z[j].right > max) max = z[j].right ; j++ ; } } else { if (!iszero) { iszero = 1 ; z[j].left = i ; } } } if (iszero) { z[j].right = 8 - z[j].left ; if (z[j].right > max) max = z[j].right ; j++ ; } if (max >= 2) for (i = 0 ; i < j ; i++) if (z[i].right == max) return (*pos = z[i].left, max) ; return 0 ; } size_t ip6_fmt (char *s, char const *ip6) { size_t w = 0 ; unsigned int pos = 8 ; unsigned int len = find_colcol(ip6, &pos) ; unsigned int i = 0 ; for (; i < 8 ; i++) { if (i == pos) { if (!i) s[w++] = ':' ; s[w++] = ':' ; i += len-1 ; } else { w += xfmt16(s + w, ip6 + (i<<1)) ; if (i < 7) s[w++] = ':' ; } } return w ; } skalibs-2.14.1.1/src/libstddjb/ip6_scan.c000066400000000000000000000044401455624754300200050ustar00rootroot00000000000000/* ISC license. */ #include #include #include /* IPv6 scanner class | 0 1 2 3 st\ev | other hex : . START | m 00 | X LIMB COLON1 X COLON1 | p 01 | X X NEW X NEW | m 02 | END LIMB X X LIMB | h h 03 | END LIMB COLON V4 COLON | m p 04 | X LIMB NEW X END = 05 V4 = 06 X = 07 0x10 m mark 0x20 p set doublecolon pos 0x40 h scan hex, next limb */ size_t ip6_scan (char const *s, char *ip6) { static unsigned char const class[256] = "0000000000000000000000000000000000000000000000301111111111200000011111100000000000000000000000000111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" ; static uint8_t const table[5][4] = { { 0x07, 0x13, 0x01, 0x07 }, { 0x07, 0x07, 0x22, 0x07 }, { 0x05, 0x13, 0x07, 0x07 }, { 0x45, 0x03, 0x44, 0x06 }, { 0x07, 0x13, 0x22, 0x07 } } ; size_t i = 0, mark = 0 ; uint16_t limb[8] = { 0, 0, 0, 0, 0, 0, 0, 0 } ; uint8_t pos = 8, j = 0, state = 0 ; for (; state < 0x05 ; i++) { uint8_t c = table[state][class[(unsigned char)s[i]] - '0'] ; state = c & 0x07 ; if (c & 0x10) mark = i ; if (c & 0x20) { if (pos < 8) state = 0x07 ; else pos = j ; } if (c & 0x40) if (j >= 8 || uint16_xscan(s + mark, limb + j++) != i - mark) state = 0x07 ; } switch (state) { case 0x05: if (pos == 8 && j < 8 || (pos < 8 && j > 6)) return 0 ; i-- ; break ; case 0x06: { uint32_t ip4 ; if (pos == 8 && j != 6 || (pos < 8 && j > 4)) return 0 ; i = ip4_scanu32(s + mark, &ip4) ; if (!i) return 0 ; limb[j++] = ip4 >> 16 ; limb[j++] = ip4 & 0xffff ; i += mark ; break ; } default : return 0 ; } for (state = j ; state > pos ; state--) limb[state - j + 7] = limb[state - 1] ; for (; state < pos + 8 - j ; state++) limb[state] = 0 ; for (j = 0 ; j < 8 ; j++) uint16_pack_big(ip6 + (j<<1), limb[j]) ; return i ; } skalibs-2.14.1.1/src/libstddjb/ip6_scanlist.c000066400000000000000000000006321455624754300207000ustar00rootroot00000000000000/* ISC license. */ #include #include size_t ip6_scanlist (char *out, size_t max, char const *s, size_t *num) { size_t n = 0, w = 0 ; for (; s[w] && (n < max) ; n++) { char ip[16] ; size_t i = ip6_scan(s + w, ip) ; if (!i) break ; memcpy(out + (n << 4), ip, 16) ; w += i ; while (memchr(",; \t\r\n", s[w], 6)) w++ ; } *num = n ; return w ; } skalibs-2.14.1.1/src/libstddjb/ipc_accept.c000066400000000000000000000022711455624754300203750ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #include #include #include #include int ipc_accept_internal (int s, char *p, size_t l, int *trunc, unsigned int options) { struct sockaddr_un sa ; socklen_t dummy = sizeof sa ; int fd ; memset(&sa, 0, dummy) ; do #ifdef SKALIBS_HASACCEPT4 fd = accept4(s, (struct sockaddr *)&sa, &dummy, ((options & O_NONBLOCK) ? SOCK_NONBLOCK : 0) | ((options & O_CLOEXEC) ? SOCK_CLOEXEC : 0)) ; #else fd = accept(s, (struct sockaddr *)&sa, &dummy) ; #endif while ((fd == -1) && (errno == EINTR)) ; if (fd == -1) return -1 ; #ifndef SKALIBS_HASACCEPT4 if ((((options & O_NONBLOCK) ? ndelay_on(fd) : ndelay_off(fd)) < 0) || (((options & O_CLOEXEC) ? coe(fd) : uncoe(fd)) < 0)) { fd_close(fd) ; return -1 ; } #endif if (p) { dummy = byte_chr(sa.sun_path, dummy, 0) ; *trunc = 1 ; if (!l) return fd ; if (l < (dummy + 1)) dummy = l - 1 ; else *trunc = 0 ; memcpy(p, sa.sun_path, dummy) ; p[dummy] = 0 ; } return fd ; } skalibs-2.14.1.1/src/libstddjb/ipc_bind.c000066400000000000000000000007441455624754300200550ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #include int ipc_bind (int s, char const *p) { struct sockaddr_un sa ; size_t l = strlen(p) ; if (l > IPCPATH_MAX) return (errno = EPROTO, -1) ; memset(&sa, 0, sizeof sa) ; sa.sun_family = AF_UNIX ; memcpy(sa.sun_path, p, l+1) ; return bind(s, (struct sockaddr *)&sa, sizeof sa) ; } skalibs-2.14.1.1/src/libstddjb/ipc_bind_reuse.c000066400000000000000000000002341455624754300212520ustar00rootroot00000000000000/* ISC license. */ #include int ipc_bind_reuse (int s, char const *p) { int fdlock ; return ipc_bind_reuse_lock(s, p, &fdlock) ; } skalibs-2.14.1.1/src/libstddjb/ipc_bind_reuse_lock_perms.c000066400000000000000000000017201455624754300234710ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #include #include #include int ipc_bind_reuse_lock_perms (int s, char const *p, int *fdlock, unsigned int perms) { unsigned int opt = 1 ; size_t len = strlen(p) ; int fd ; int r ; mode_t m ; char lockname[len + 6] ; memcpy(lockname, p, len) ; memcpy(lockname + len, ".lock", 6) ; fd = open3(lockname, O_WRONLY | O_NONBLOCK | O_CREAT | O_CLOEXEC, 0600) ; if (fd < 0) return -1 ; r = fd_lock(fd, 1, 1) ; if (r < 0) return -1 ; if (!r) return (errno = EBUSY, -1) ; r = errno ; setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof opt) ; errno = r ; unlink_void(p) ; if (perms) m = umask(~perms & 0777) ; if (ipc_bind(s, p) < 0) { if (perms) umask(m) ; return -1 ; } if (perms) umask(m) ; *fdlock = fd ; return 0 ; } skalibs-2.14.1.1/src/libstddjb/ipc_bind_reuse_perms.c000066400000000000000000000003031455624754300224550ustar00rootroot00000000000000/* ISC license. */ #include int ipc_bind_reuse_perms (int s, char const *p, unsigned int perms) { int fdlock ; return ipc_bind_reuse_lock_perms(s, p, &fdlock, perms) ; } skalibs-2.14.1.1/src/libstddjb/ipc_connect.c000066400000000000000000000010751455624754300205700ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #include int ipc_connect (int s, char const *p) { struct sockaddr_un sa ; size_t l = strlen(p) ; if (l > IPCPATH_MAX) return (errno = EPROTO, 0) ; memset(&sa, 0, sizeof sa) ; sa.sun_family = AF_UNIX ; memcpy(sa.sun_path, p, l+1) ; if (connect(s, (struct sockaddr *)&sa, sizeof sa) == -1) { if (errno == EINTR) errno = EINPROGRESS ; return 0 ; } return 1 ; } skalibs-2.14.1.1/src/libstddjb/ipc_connected.c000066400000000000000000000005751455624754300211050ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include int ipc_connected (int s) { struct sockaddr_un sa ; socklen_t dummy = sizeof sa ; if (getpeername(s, (struct sockaddr *)&sa, &dummy) == -1) { char ch ; fd_read(s, &ch, 1) ; return 0 ; } return 1 ; } skalibs-2.14.1.1/src/libstddjb/ipc_dgram.c000066400000000000000000000003241455624754300202250ustar00rootroot00000000000000/* ISC license. */ #include #include #include int ipc_datagram_internal (unsigned int flags) { return socket_internal(AF_UNIX, SOCK_DGRAM, 0, flags) ; } skalibs-2.14.1.1/src/libstddjb/ipc_listen.c000066400000000000000000000002561455624754300204350ustar00rootroot00000000000000/* ISC license. */ #include #include #include int ipc_listen (int s, int backlog) { return listen(s, backlog) ; } skalibs-2.14.1.1/src/libstddjb/ipc_local.c000066400000000000000000000011211455624754300202210ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include int ipc_local (int s, char *p, size_t l, int *trunc) { struct sockaddr_un sa ; socklen_t dummy = sizeof sa ; memset(&sa, 0, sizeof sa) ; if (getsockname(s, (struct sockaddr *)&sa, &dummy) == -1) return -1 ; dummy = byte_chr(sa.sun_path, dummy, 0) ; *trunc = 1 ; if (!l) return 0 ; if (l < (dummy + 1)) dummy = l - 1 ; else *trunc = 0 ; memcpy(p, sa.sun_path, dummy) ; p[dummy] = 0 ; return 0 ; } skalibs-2.14.1.1/src/libstddjb/ipc_pair.c000066400000000000000000000003421455624754300200660ustar00rootroot00000000000000/* ISC license. */ #include #include #include int ipc_pair_internal (int *sv, unsigned int flags) { return socketpair_internal(AF_UNIX, SOCK_STREAM, 0, flags, sv) ; } skalibs-2.14.1.1/src/libstddjb/ipc_recv.c000066400000000000000000000015051455624754300200740ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #include ssize_t ipc_recv (int fd, char *s, size_t len, char *path) { struct sockaddr_un sa = { .sun_family = AF_UNIX } ; socklen_t total = sizeof sa ; char tmp[len] ; ssize_t r ; do r = recvfrom(fd, tmp, len, 0, (struct sockaddr *)&sa, &total) ; while ((r == -1) && (errno == EINTR)) ; if (r < 0) return r ; if (sa.sun_family != AF_UNIX) return (errno = EPROTO, -1) ; if (path) { if (total == sizeof(sa_family_t)) path[0] = 0 ; else { size_t l = strlen(sa.sun_path) ; if (l > IPCPATH_MAX) return (errno = EPROTO, -1) ; memcpy(path, sa.sun_path, l+1) ; } } memcpy(s, tmp, r) ; return r ; } skalibs-2.14.1.1/src/libstddjb/ipc_send.c000066400000000000000000000010331455624754300200620ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #include ssize_t ipc_send (int fd, char const *s, size_t len, char const *path) { struct sockaddr_un sa ; size_t l = strlen(path) ; if (l > IPCPATH_MAX) return (errno = EPROTO, -1) ; memset(&sa, 0, sizeof sa) ; sa.sun_family = AF_UNIX ; memcpy(sa.sun_path, path, l+1) ; return sendto(fd, s, len, 0, (struct sockaddr *)&sa, sizeof sa) ; } skalibs-2.14.1.1/src/libstddjb/ipc_stream.c000066400000000000000000000003231455624754300204250ustar00rootroot00000000000000/* ISC license. */ #include #include #include int ipc_stream_internal (unsigned int flags) { return socket_internal(AF_UNIX, SOCK_STREAM, 0, flags) ; } skalibs-2.14.1.1/src/libstddjb/ipc_timed_connect.c000066400000000000000000000012441455624754300217500ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include int ipc_timed_connect (int s, char const *path, tain const *deadline, tain *stamp) { if (!ipc_connect(s, path)) { iopause_fd x = { s, IOPAUSE_WRITE, 0 } ; if (!error_isagain(errno) && !error_isalready(errno)) return 0 ; for (;;) { int r = iopause_stamp(&x, 1, deadline, stamp) ; if (r < 0) return 0 ; else if (!r) return (errno = ETIMEDOUT, 0) ; else if (x.revents & IOPAUSE_EXCEPT) return 0 ; else if (x.revents & IOPAUSE_WRITE) break ; } if (!ipc_connected(s)) return 0 ; } return 1 ; } skalibs-2.14.1.1/src/libstddjb/leapsecs_add.c000066400000000000000000000004771455624754300207200ustar00rootroot00000000000000/* ISC license. */ #include #include "djbtime-internal.h" void leapsecs_add (uint64_t *t, int hit) { uint64_t u = *t - !!hit ; unsigned int i = 0 ; for (; i < leapsecs_table_len ; i++) { if (u < leapsecs_table[i]) break ; if (!hit || (leapsecs_table[i] < u)) ++u ; } *t = u ; } skalibs-2.14.1.1/src/libstddjb/leapsecs_sub.c000066400000000000000000000005551455624754300207560ustar00rootroot00000000000000/* ISC license. */ #include #include "djbtime-internal.h" int leapsecs_sub (uint64_t *t) { uint64_t u = *t ; uint64_t d = 0 ; unsigned int i = 0 ; int hit = 0 ; for (; i < leapsecs_table_len ; i++) { if (u < leapsecs_table[i]) break ; if (u == leapsecs_table[i]) hit = 1 ; else d++ ; } *t = u - d ; return hit ; } skalibs-2.14.1.1/src/libstddjb/leapsecs_table.c000066400000000000000000000017501455624754300212520ustar00rootroot00000000000000/* ISC license. */ /* This file has been generated by ./tools/make-leapsecs_table */ #include #include #include "djbtime-internal.h" unsigned int const leapsecs_table_len = 27 ; static uint64_t const leapsecs_table_[27] = { TAI_MAGIC + 78796800, TAI_MAGIC + 94694401, TAI_MAGIC + 126230402, TAI_MAGIC + 157766403, TAI_MAGIC + 189302404, TAI_MAGIC + 220924805, TAI_MAGIC + 252460806, TAI_MAGIC + 283996807, TAI_MAGIC + 315532808, TAI_MAGIC + 362793609, TAI_MAGIC + 394329610, TAI_MAGIC + 425865611, TAI_MAGIC + 489024012, TAI_MAGIC + 567993613, TAI_MAGIC + 631152014, TAI_MAGIC + 662688015, TAI_MAGIC + 709948816, TAI_MAGIC + 741484817, TAI_MAGIC + 773020818, TAI_MAGIC + 820454419, TAI_MAGIC + 867715220, TAI_MAGIC + 915148821, TAI_MAGIC + 1136073622, TAI_MAGIC + 1230768023, TAI_MAGIC + 1341100824, TAI_MAGIC + 1435708825, TAI_MAGIC + 1483228826 } ; uint64_t const *const leapsecs_table = leapsecs_table_ ; skalibs-2.14.1.1/src/libstddjb/localtm_fmt.c000066400000000000000000000007541455624754300206100ustar00rootroot00000000000000/* ISC license. */ #include #include #include size_t localtm_fmt (char *s, struct tm const *l) { char *p = s ; p += uint_fmt(p, 1900 + l->tm_year) ; *p++ = '-' ; uint0_fmt(p, 1 + l->tm_mon, 2) ; p += 2 ; *p++ = '-' ; uint0_fmt(p, l->tm_mday, 2) ; p += 2 ; *p++ = ' ' ; uint0_fmt(p, l->tm_hour, 2) ; p += 2 ; *p++ = ':' ; uint0_fmt(p, l->tm_min, 2) ; p += 2 ; *p++ = ':' ; uint0_fmt(p, l->tm_sec, 2) ; p += 2 ; return p - s ; } skalibs-2.14.1.1/src/libstddjb/localtm_from_ltm64.c000066400000000000000000000011111455624754300217770ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #include int localtm_from_ltm64 (struct tm *l, uint64_t uu, int tzh) { time_t u ; if (uu < TAI_MAGIC) return (errno = EINVAL, 0) ; uu -= TAI_MAGIC ; #if SKALIBS_SIZEOFTIME != 8 if (uu > 0xFFFFFFFFUL) return (errno = EOVERFLOW, 0) ; #endif u = (time_t)uu - !!(tzh & 2) ; if (tzh & 1 ? !localtime_r(&u, l) : !gmtime_r(&u, l)) return 0 ; if (tzh & 2) l->tm_sec++ ; return 1 ; } skalibs-2.14.1.1/src/libstddjb/localtm_from_sysclock.c000066400000000000000000000003661455624754300226760ustar00rootroot00000000000000/* ISC license. */ #include #include #include int localtm_from_sysclock (struct tm *l, uint64_t u, int tz) { if (!ltm64_from_sysclock(&u)) return 0 ; return localtm_from_ltm64(l, u, !!tz) ; } skalibs-2.14.1.1/src/libstddjb/localtm_from_tai.c000066400000000000000000000004131455624754300216120ustar00rootroot00000000000000/* ISC license. */ #include #include #include int localtm_from_tai (struct tm *l, tai const *t, int tz) { uint64_t u ; int h = ltm64_from_tai(&u, t) ; return h ? localtm_from_ltm64(l, u, !!tz | (h & 2)) : 0 ; } skalibs-2.14.1.1/src/libstddjb/localtm_from_utc.c000066400000000000000000000003541455624754300216340ustar00rootroot00000000000000/* ISC license. */ #include #include #include int localtm_from_utc (struct tm *l, uint64_t u, int tz) { if (!ltm64_from_utc(&u)) return 0 ; return localtm_from_ltm64(l, u, !!tz) ; } skalibs-2.14.1.1/src/libstddjb/localtm_scan.c000066400000000000000000000022721455624754300207430ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include size_t localtm_scan (char const *s, struct tm *l) { struct tm ll = { .tm_isdst = -1 } ; size_t n = 0 ; unsigned int u ; size_t i = uint_scan(s+n, &u) ; if (!i) goto fail ; n += i ; if (u < 1900) goto fail ; u -= 1900 ; ll.tm_year = u ; if (s[n++] != '-') goto fail ; i = uint_scan(s+n, &u) ; if (!i) goto fail ; n += i ; if (!u || (u > 12)) goto fail ; u-- ; ll.tm_mon = u ; if (s[n++] != '-') goto fail ; i = uint_scan(s+n, &u) ; if (!i) goto fail ; n += i ; if (!u || (u > 31)) goto fail ; ll.tm_mday = u ; if ((s[n] != ' ') && (s[n] != 'T')) goto fail ; n++ ; i = uint_scan(s+n, &u) ; if (!i) goto fail ; n += i ; if (u > 23) goto fail ; ll.tm_hour = u ; if (s[n++] != ':') goto fail ; i = uint_scan(s+n, &u) ; if (!i) goto fail ; n += i ; if (u > 59) goto fail ; ll.tm_min = u ; if (s[n++] != ':') goto fail ; i = uint_scan(s+n, &u) ; if (!i) goto fail ; n += i ; if (u > 60) goto fail ; ll.tm_sec = u ; if (mktime(&ll) == (time_t)-1) goto fail ; *l = ll ; return n ; fail: return (errno = EINVAL, 0) ; } skalibs-2.14.1.1/src/libstddjb/localtmn_fmt.c000066400000000000000000000003711455624754300207610ustar00rootroot00000000000000/* ISC license. */ #include #include size_t localtmn_fmt (char *s, localtmn const *l) { char *p = s ; p += localtm_fmt(p, &l->tm) ; *p++ = '.' ; uint320_fmt(p, l->nano, 9) ; p += 9 ; return p - s ; } skalibs-2.14.1.1/src/libstddjb/localtmn_from_sysclock.c000066400000000000000000000004051455624754300230460ustar00rootroot00000000000000/* ISC license. */ #include #include int localtmn_from_sysclock (localtmn *l, tain const *a, int tz) { struct tm t ; if (!localtm_from_sysclock(&t, a->sec.x, tz)) return 0 ; l->tm = t ; l->nano = a->nano ; return 1 ; } skalibs-2.14.1.1/src/libstddjb/localtmn_from_tain.c000066400000000000000000000003771455624754300221570ustar00rootroot00000000000000/* ISC license. */ #include #include int localtmn_from_tain (localtmn *l, tain const *a, int tz) { struct tm t ; if (!localtm_from_tai(&t, tain_secp(a), tz)) return 0 ; l->tm = t ; l->nano = a->nano ; return 1 ; } skalibs-2.14.1.1/src/libstddjb/localtmn_scan.c000066400000000000000000000005551455624754300211230ustar00rootroot00000000000000/* ISC license. */ #include #include size_t localtmn_scan (char const *s, localtmn *l) { localtmn m ; size_t n = localtm_scan(s, &m.tm) ; if (!n) return 0 ; s += n ; if (*s++ != '.') m.nano = 0 ; else { size_t b = uint32_scan(s, &m.nano) ; if (!b) return 0 ; n += b ; } *l = m ; return n ; } skalibs-2.14.1.1/src/libstddjb/lolprintf.c000066400000000000000000000004141455624754300203110ustar00rootroot00000000000000/* ISC license. */ #include #include #include int lolprintf (char const *format, ...) { va_list args ; int r ; va_start(args, format) ; r = vbprintf(buffer_1, format, args) ; va_end(args) ; return r ; } skalibs-2.14.1.1/src/libstddjb/ltm64_from_localtm.c000066400000000000000000000004701455624754300220060ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include int ltm64_from_localtm (uint64_t *uu, struct tm const *l) { struct tm ll = *l ; time_t u = mktime(&ll) ; if (u == (time_t)-1) return (errno = EINVAL, 0) ; *uu = TAI_MAGIC + u ; return 1 ; } skalibs-2.14.1.1/src/libstddjb/ltm64_from_sysclock.c000066400000000000000000000005101455624754300222000ustar00rootroot00000000000000/* ISC license. */ #include #include #ifdef SKALIBS_FLAG_CLOCKISTAI #include int ltm64_from_sysclock (uint64_t *u) { tai t = { .x = *u + 10U } ; return ltm64_from_tai(u, &t) ; } #else int ltm64_from_sysclock (uint64_t *u) { return ltm64_from_utc(u) ; } #endif skalibs-2.14.1.1/src/libstddjb/ltm64_from_tai.c000066400000000000000000000004261455624754300211310ustar00rootroot00000000000000/* ISC license. */ #include #include "djbtime-internal.h" int ltm64_from_tai (uint64_t *u, tai const *t) { switch (skalibs_tzisright()) { case 1 : *u = t->x - 10U ; return 1 ; case 0 : return utc_from_tai(u, t) ; default : return 0 ; } } skalibs-2.14.1.1/src/libstddjb/ltm64_from_utc.c000066400000000000000000000004131455624754300211430ustar00rootroot00000000000000/* ISC license. */ #include #include #include "djbtime-internal.h" int ltm64_from_utc (uint64_t *u) { switch (skalibs_tzisright()) { case 1 : leapsecs_add(u, 0) ; case 0 : return 1 ; default : return 0 ; } } skalibs-2.14.1.1/src/libstddjb/ndelay_off.c000066400000000000000000000003321455624754300204050ustar00rootroot00000000000000/* ISC license. */ #include #include int ndelay_off (int fd) { int got = fcntl(fd, F_GETFL) ; return got < 0 ? got : got & O_NONBLOCK ? fcntl(fd, F_SETFL, got & ~O_NONBLOCK) : 0 ; } skalibs-2.14.1.1/src/libstddjb/ndelay_on.c000066400000000000000000000003301455624754300202450ustar00rootroot00000000000000/* ISC license. */ #include #include int ndelay_on (int fd) { int got = fcntl(fd, F_GETFL) ; return got < 0 ? got : got & O_NONBLOCK ? 0 : fcntl(fd, F_SETFL, got | O_NONBLOCK) ; } skalibs-2.14.1.1/src/libstddjb/netstring_append.c000066400000000000000000000007501455624754300216470ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include int netstring_appendb (stralloc *sa, char const *s, size_t len) { char fmt[UINT64_FMT] ; size_t n = uint64_fmt(fmt, len) ; if (!stralloc_readyplus(sa, len + n + 2)) return 0 ; fmt[n] = ':' ; memcpy(sa->s + sa->len, fmt, n+1) ; memcpy(sa->s + sa->len + n+1, s, len) ; sa->s[sa->len + n+1 + len] = ',' ; sa->len += n + 2 + len ; return 1 ; } skalibs-2.14.1.1/src/libstddjb/netstring_appendv.c000066400000000000000000000013141455624754300220320ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include int netstring_appendv (stralloc *sa, struct iovec const *v, unsigned int n) { char fmt[UINT64_FMT] ; size_t len = 0, pos ; unsigned int i = 0 ; for (; i < n ; i++) len += v[i].iov_len ; pos = uint64_fmt(fmt, len) ; if (!stralloc_readyplus(sa, len + pos + 2)) return 0 ; fmt[pos] = ':' ; memcpy(sa->s + sa->len, fmt, pos+1) ; sa->len += pos+1 ; for (i = 0 ; i < n ; i++) { memcpy(sa->s + sa->len, v[i].iov_base, v[i].iov_len) ; sa->len += v[i].iov_len ; } sa->s[sa->len++] = ',' ; return 1 ; } skalibs-2.14.1.1/src/libstddjb/netstring_decode.c000066400000000000000000000011171455624754300216210ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include ssize_t netstring_decode (stralloc *sa, char const *s, size_t len) { uint64_t nlen ; size_t pos ; if (!len) return 0 ; pos = uint64_scan(s, &nlen) ; if (pos >= len) return (errno = EINVAL, -1) ; if (s[pos] != ':') return (errno = EINVAL, -1) ; s += pos+1 ; len -= pos+1 ; if (len <= nlen) return (errno = EINVAL, -1) ; if (s[nlen] != ',') return (errno = EINVAL, -1) ; if (!stralloc_catb(sa, s, nlen)) return -1 ; return pos + nlen + 2 ; } skalibs-2.14.1.1/src/libstddjb/netstring_encode.c000066400000000000000000000007041455624754300216340ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include int netstring_encode (stralloc *sa, char const *s, size_t len) { char fmt[UINT64_FMT] ; size_t pos = uint64_fmt(fmt, len) ; if (!stralloc_readyplus(sa, pos + len + 2)) return 0 ; stralloc_catb(sa, fmt, pos) ; stralloc_catb(sa, ":", 1) ; stralloc_catb(sa, s, len) ; stralloc_catb(sa, ",", 1) ; return 1 ; } skalibs-2.14.1.1/src/libstddjb/netstring_get.c000066400000000000000000000025511455624754300211600ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #include #include int netstring_okeof (buffer *b, size_t w) { return (errno == EPIPE) && !w && buffer_isempty(b) ? (errno = 0, 1) : 0 ; } int netstring_get (buffer *b, stralloc *sa, size_t *state) { if (!*state) { size_t n ; size_t len ; char buf[SIZE_FMT] ; if (b->c.a < SIZE_FMT+1) return (errno = EINVAL, -1) ; for (;;) { ssize_t r ; len = buffer_getnofill(b, buf, SIZE_FMT) ; n = byte_chr(buf, len, ':') ; /* XXX: accepts :, as a valid netstring */ if (n >= SIZE_FMT) { buffer_unget(b, len) ; return (errno = EPROTO, -1) ; } if (n < len) break ; buffer_unget(b, len) ; r = sanitize_read(buffer_fill(b)) ; if (r <= 0) return r ; } buffer_unget(b, len - n - 1) ; if (!n || n != size_scan(buf, &len)) return (errno = EPROTO, -1) ; if (!stralloc_readyplus(sa, len + 1)) return -1 ; *state = len + 1 ; } { size_t w = 0 ; int r = buffer_getall(b, sa->s + sa->len, *state, &w) ; sa->len += w ; *state -= w ; if (r <= 0) return r ; } return (sa->s[--sa->len] == ',') ? 1 : (errno = EPROTO, -1) ; } skalibs-2.14.1.1/src/libstddjb/netstring_put.c000066400000000000000000000015211455624754300212050ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include int netstring_put (buffer *b, char const *s, size_t len, size_t *written) { char fmt[UINT64_FMT] ; size_t n = uint64_fmt(fmt, len) ; if (*written > len + n + 2) return (errno = EINVAL, 0) ; fmt[n] = ':' ; if (*written < n + 1) { size_t w = *written ; int r = buffer_putall(b, fmt, n+1, &w) ; if (r < 0) return (*written = w, 0) ; *written = n+1 ; } if (*written < n+1 + len) { size_t w = *written - (n+1) ; int r = buffer_putall(b, s, len, &w) ; *written = w + (n+1) ; if (r < 0) return (*written = n+1 + w, 0) ; *written = n+1 + len ; } { size_t w = 0 ; int r = buffer_putall(b, ",", 1, &w) ; if (r < 0) return 0 ; } *written = 0 ; return 1 ; } skalibs-2.14.1.1/src/libstddjb/ntp_from_tain.c000066400000000000000000000011301455624754300211330ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include int ntp_from_tain (uint64_t *u, tain const *a) { uint64_t secs, frac ; if (!utc_from_tai(&secs, tain_secp(a))) return 0 ; secs += NTP_OFFSET ; if (secs < TAI_MAGIC + 2147483648UL) goto ifail ; secs -= TAI_MAGIC ; if (secs >= ((uint64_t)3 << 31)) goto ifail ; secs &= (secs < ((uint64_t)1 << 32)) ? 0xFFFFFFFFUL : 0x7FFFFFFFUL ; frac = ((uint64_t)a->nano << 32) / 1000000000UL ; *u = (secs << 32) + frac ; return 1 ; ifail: errno = EINVAL ; return 0 ; } skalibs-2.14.1.1/src/libstddjb/open2.c000066400000000000000000000003741455624754300173300ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include int open2 (char const *s, unsigned int flags) { int r ; do r = open(s, flags) ; while ((r == -1) && (errno == EINTR)) ; return r ; } skalibs-2.14.1.1/src/libstddjb/open3.c000066400000000000000000000004251455624754300173260ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include int open3 (char const *s, unsigned int flags, unsigned int mode) { int r ; do r = open(s, flags, mode) ; while ((r == -1) && (errno == EINTR)) ; return r ; } skalibs-2.14.1.1/src/libstddjb/open_append.c000066400000000000000000000003171455624754300205720ustar00rootroot00000000000000/* ISC license. */ #include #include #include int open_append (char const *fn) { return open3(fn, O_WRONLY | O_NONBLOCK | O_APPEND | O_CREAT, 0666) ; } skalibs-2.14.1.1/src/libstddjb/open_create.c000066400000000000000000000003041455624754300205620ustar00rootroot00000000000000/* ISC license. */ #include #include #include int open_create (char const *fn) { return open3(fn, O_WRONLY | O_NONBLOCK | O_CREAT, 0666) ; } skalibs-2.14.1.1/src/libstddjb/open_excl.c000066400000000000000000000003131455624754300202520ustar00rootroot00000000000000/* ISC license. */ #include #include #include int open_excl (char const *fn) { return open3(fn, O_WRONLY | O_CREAT | O_EXCL | O_NONBLOCK, 0666) ; } skalibs-2.14.1.1/src/libstddjb/open_read.c000066400000000000000000000002621455624754300202350ustar00rootroot00000000000000/* ISC license. */ #include #include #include int open_read (char const *fn) { return open2(fn, O_RDONLY | O_NONBLOCK) ; } skalibs-2.14.1.1/src/libstddjb/open_readb.c000066400000000000000000000003361455624754300204010ustar00rootroot00000000000000/* ISC license. */ #include int open_readb (char const *fn) { int fd = open_read(fn) ; if (fd < 0) return -1 ; if (ndelay_off(fd) < 0) { fd_close(fd) ; return -1 ; } return fd ; } skalibs-2.14.1.1/src/libstddjb/open_trunc.c000066400000000000000000000003151455624754300204540ustar00rootroot00000000000000/* ISC license. */ #include #include #include int open_trunc (char const *fn) { return open3(fn, O_WRONLY | O_NONBLOCK | O_TRUNC | O_CREAT, 0666) ; } skalibs-2.14.1.1/src/libstddjb/open_write.c000066400000000000000000000002631455624754300204550ustar00rootroot00000000000000/* ISC license. */ #include #include #include int open_write (char const *fn) { return open2(fn, O_WRONLY | O_NONBLOCK) ; } skalibs-2.14.1.1/src/libstddjb/openb_read.c000066400000000000000000000002461455624754300204010ustar00rootroot00000000000000/* ISC license. */ #include #include #include int openb_read (char const *fn) { return open2(fn, O_RDONLY) ; } skalibs-2.14.1.1/src/libstddjb/openbc_read.c000066400000000000000000000002631455624754300205430ustar00rootroot00000000000000/* ISC license. */ #include #include #include int openbc_read (char const *fn) { return open2(fn, O_RDONLY | O_CLOEXEC) ; } skalibs-2.14.1.1/src/libstddjb/openc_append.c000066400000000000000000000003341455624754300207340ustar00rootroot00000000000000/* ISC license. */ #include #include #include int openc_append (char const *fn) { return open3(fn, O_WRONLY | O_NONBLOCK | O_APPEND | O_CREAT | O_CLOEXEC, 0666) ; } skalibs-2.14.1.1/src/libstddjb/openc_create.c000066400000000000000000000003211455624754300207240ustar00rootroot00000000000000/* ISC license. */ #include #include #include int openc_create (char const *fn) { return open3(fn, O_WRONLY | O_NONBLOCK | O_CREAT | O_CLOEXEC, 0666) ; } skalibs-2.14.1.1/src/libstddjb/openc_excl.c000066400000000000000000000003301455624754300204140ustar00rootroot00000000000000/* ISC license. */ #include #include #include int openc_excl (char const *fn) { return open3(fn, O_WRONLY | O_CREAT | O_EXCL | O_NONBLOCK | O_CLOEXEC, 0666) ; } skalibs-2.14.1.1/src/libstddjb/openc_read.c000066400000000000000000000002771455624754300204060ustar00rootroot00000000000000/* ISC license. */ #include #include #include int openc_read (char const *fn) { return open2(fn, O_RDONLY | O_NONBLOCK | O_CLOEXEC) ; } skalibs-2.14.1.1/src/libstddjb/openc_readb.c000066400000000000000000000003401455624754300205370ustar00rootroot00000000000000/* ISC license. */ #include int openc_readb (char const *fn) { int fd = openc_read(fn) ; if (fd < 0) return -1 ; if (ndelay_off(fd) < 0) { fd_close(fd) ; return -1 ; } return fd ; } skalibs-2.14.1.1/src/libstddjb/openc_trunc.c000066400000000000000000000003321455624754300206160ustar00rootroot00000000000000/* ISC license. */ #include #include #include int openc_trunc (char const *fn) { return open3(fn, O_WRONLY | O_NONBLOCK | O_TRUNC | O_CREAT | O_CLOEXEC, 0666) ; } skalibs-2.14.1.1/src/libstddjb/openc_write.c000066400000000000000000000003001455624754300206100ustar00rootroot00000000000000/* ISC license. */ #include #include #include int openc_write (char const *fn) { return open2(fn, O_WRONLY | O_NONBLOCK | O_CLOEXEC) ; } skalibs-2.14.1.1/src/libstddjb/openreadfileclose.c000066400000000000000000000013211455624754300217610ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include int openreadfileclose (char const *file, stralloc *sa, size_t limit) { size_t n ; int e = errno ; int fd = openbc_read(file) ; if (fd < 0) return 0 ; { struct stat st ; if (fstat(fd, &st) < 0) goto err ; n = st.st_size ; } if (limit && (limit < n)) n = limit ; if (!stralloc_ready_tuned(sa, sa->len + n, 0, 0, 1)) goto err ; { size_t r ; errno = EPIPE ; r = allread(fd, sa->s + sa->len, n) ; sa->len += r ; if (r < n) goto err ; } fd_close(fd) ; errno = e ; return 1 ; err: fd_close(fd) ; return 0 ; } skalibs-2.14.1.1/src/libstddjb/openreadnclose.c000066400000000000000000000003021455624754300212750ustar00rootroot00000000000000/* ISC license. */ #include ssize_t openreadnclose (char const *file, char *s, size_t n) { int fd = openbc_read(file) ; return fd == -1 ? fd : readnclose(fd, s, n) ; } skalibs-2.14.1.1/src/libstddjb/openreadnclose_nb.c000066400000000000000000000003041455624754300217560ustar00rootroot00000000000000/* ISC license. */ #include ssize_t openreadnclose_nb (char const *file, char *s, size_t n) { int fd = openc_read(file) ; return fd == -1 ? fd : readnclose(fd, s, n) ; } skalibs-2.14.1.1/src/libstddjb/openslurpnclose.c000066400000000000000000000003611455624754300215340ustar00rootroot00000000000000/* ISC license. */ #include int openslurpnclose (char const *fn, stralloc *sa, size_t max) { int r ; int fd = openbc_read(fn) ; if (fd == -1) return 0 ; r = slurpn(fd, sa, max) ; fd_close(fd) ; return r ; } skalibs-2.14.1.1/src/libstddjb/openwritenclose5.c000066400000000000000000000013161455624754300216070ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #define SUFFIX ":skalibs-openwritenclose:XXXXXX" int openwritenclose5 (char const *fn, char const *s, size_t n, devino *devino, unsigned int options) { int fd ; size_t fnlen = strlen(fn) ; char tmp[fnlen + sizeof(SUFFIX)] ; memcpy(tmp, fn, fnlen) ; memcpy(tmp + fnlen, SUFFIX, sizeof(SUFFIX)) ; fd = mkstemp(tmp) ; if (fd < 0) return 0 ; if (!writenclose_unsafe5(fd, s, n, devino, options)) goto failclose ; if (rename(tmp, fn) < 0) goto fail ; return 1 ; failclose: fd_close(fd) ; fail: unlink_void(tmp) ; return 0 ; } skalibs-2.14.1.1/src/libstddjb/openwritenclose_suffix6.c000066400000000000000000000011041455624754300231670ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include int openwritenclose_suffix6 (char const *fn, char const *s, size_t n, devino *devino, unsigned int options, char const *suffix) { size_t len = strlen(fn) ; size_t suffixlen = strlen(suffix) ; char tmp[len + suffixlen + 1] ; memcpy(tmp, fn, len) ; memcpy(tmp + len, suffix, suffixlen + 1) ; if (!openwritenclose_unsafe5(tmp, s, n, devino, options)) return 0 ; if (rename(tmp, fn) < 0) { unlink_void(tmp) ; return 0 ; } return 1 ; } skalibs-2.14.1.1/src/libstddjb/openwritenclose_unsafe5.c000066400000000000000000000006461455624754300231550ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include int openwritenclose_unsafe5 (char const *fn, char const *s, size_t len, devino *devino, unsigned int options) { int fd = openc_trunc(fn) ; if (fd < 0) return 0 ; if (!writenclose_unsafe5(fd, s, len, devino, options)) { fd_close(fd) ; unlink_void(fn) ; return 0 ; } return 1 ; } skalibs-2.14.1.1/src/libstddjb/openwritevnclose5.c000066400000000000000000000013111455624754300217700ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #define SUFFIX ":skalibs-openwritevnclose:XXXXXX" int openwritevnclose5 (char const *fn, struct iovec const *v, unsigned int vlen, devino *devino, unsigned int options) { int fd ; size_t fnlen = strlen(fn) ; char tmp[fnlen + sizeof(SUFFIX)] ; memcpy(tmp, fn, fnlen) ; memcpy(tmp + fnlen, SUFFIX, sizeof(SUFFIX)) ; fd = mkstemp(tmp) ; if (fd < 0) return 0 ; if (!writevnclose_unsafe5(fd, v, vlen, devino, options)) goto failclose ; if (rename(tmp, fn) < 0) goto fail ; return 1 ; failclose: fd_close(fd) ; fail: unlink_void(tmp) ; return 0 ; } skalibs-2.14.1.1/src/libstddjb/openwritevnclose_suffix6.c000066400000000000000000000011241455624754300233570ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include int openwritevnclose_suffix6 (char const *fn, struct iovec const *v, unsigned int n, devino *devino, unsigned int options, char const *suffix) { size_t len = strlen(fn) ; size_t suffixlen = strlen(suffix) ; char tmp[len + suffixlen + 1] ; memcpy(tmp, fn, len) ; memcpy(tmp + len, suffix, suffixlen + 1) ; if (!openwritevnclose_unsafe5(tmp, v, n, devino, options)) return 0 ; if (rename(tmp, fn) < 0) { unlink_void(tmp) ; return 0 ; } return 1 ; } skalibs-2.14.1.1/src/libstddjb/openwritevnclose_unsafe5.c000066400000000000000000000006201455624754300233330ustar00rootroot00000000000000/* ISC license. */ #include #include int openwritevnclose_unsafe5 (char const *fn, struct iovec const *v, unsigned int vlen, devino *devino, unsigned int options) { int fd = openc_trunc(fn) ; if (fd < 0) return 0 ; if (!writevnclose_unsafe5(fd, v, vlen, devino, options)) { fd_close(fd) ; unlink_void(fn) ; return 0 ; } return 1 ; } skalibs-2.14.1.1/src/libstddjb/path_canonicalize.c000066400000000000000000000026761455624754300217670ustar00rootroot00000000000000/* ISC license. */ #include #include #include static unsigned char cclass (char c) { switch (c) { case 0 : return 0 ; case '/' : return 1 ; case '.' : return 2 ; default : return 3 ; } } /* out must be at least strlen(in) + 2 bytes */ size_t path_canonicalize (char *out, char const *in, int check) { static unsigned char const table[4][4] = { { 0x04, 0x00, 0x12, 0x11 }, { 0x04, 0x50, 0x11, 0x11 }, { 0x24, 0x20, 0x13, 0x11 }, { 0xa4, 0xa0, 0x11, 0x11 } } ; int isabsolute = in[0] == '/' ; size_t j = 0 ; unsigned int depth = 0 ; unsigned char state = 0 ; if (isabsolute) *out++ = *in++ ; while (state < 4) { char c = *in++ ; unsigned char what = table[state][cclass(c)] ; state = what & 0x07 ; if (what & 0x80) { if (depth) { depth-- ; j -= 3 ; if (check) { struct stat st ; out[j] = 0 ; if (stat(out - isabsolute, &st) < 0) return 0 ; if (!S_ISDIR(st.st_mode)) return (errno = ENOTDIR, 0) ; } } else if (!isabsolute) { out[j++] = '/' ; out[j++] = '.' ; } } if (what & 0x40) depth++ ; if (what & 0x20) while (j && out[j-1] != '/') j-- ; if (what & 0x10) out[j++] = c ; } if (j && out[j-1] == '/') j-- ; if (!j && !isabsolute) out[j++] = '.' ; out[j] = 0 ; return j + isabsolute ; } skalibs-2.14.1.1/src/libstddjb/pipe_internal.c000066400000000000000000000013071455624754300211330ustar00rootroot00000000000000/* ISC license. */ #include #ifdef SKALIBS_HASPIPE2 #include #include #include int pipe_internal (int *p, unsigned int flags) { return pipe2(p, flags) ; } #else #include #include #include int pipe_internal (int *p, unsigned int flags) { int pi[2] ; if (pipe(pi) < 0) return -1 ; if (flags & O_CLOEXEC) if ((coe(pi[0]) < 0) || (coe(pi[1]) < 0)) goto err ; if (flags & O_NONBLOCK) if ((ndelay_on(pi[0]) < 0) || (ndelay_on(pi[1]) < 0)) goto err ; p[0] = pi[0] ; p[1] = pi[1] ; return 0 ; err: { fd_close(pi[1]) ; fd_close(pi[0]) ; } return -1 ; } #endif skalibs-2.14.1.1/src/libstddjb/prog.c000066400000000000000000000001401455624754300172430ustar00rootroot00000000000000/* ISC license. */ /* MT-unsafe */ #include char const *PROG = "(none)" ; skalibs-2.14.1.1/src/libstddjb/readnclose.c000066400000000000000000000004471455624754300204250ustar00rootroot00000000000000/* ISC license. */ #include #include #include ssize_t readnclose (int fd, char *s, size_t n) { int e = errno ; size_t r ; errno = 0 ; r = allread(fd, s, n) ; fd_close(fd) ; if (errno) return -1 ; errno = e ; return r ; } skalibs-2.14.1.1/src/libstddjb/rm_rf.c000066400000000000000000000002541455624754300174070ustar00rootroot00000000000000/* ISC license. */ /* MT-unsafe */ #include #include int rm_rf (char const *filename) { return rm_rf_tmp(filename, &satmp) ; } skalibs-2.14.1.1/src/libstddjb/rm_rf_in_tmp.c000066400000000000000000000027421455624754300207610ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include static int rmstar_in_tmp (stralloc *tmp, size_t ipos) { size_t tmpbase = tmp->len, tmpstop ; size_t fnbase = strlen(tmp->s + ipos) ; size_t i ; if (sals(tmp->s + ipos, tmp, &i) == -1) return -1 ; tmpstop = tmp->len ; if (!stralloc_readyplus(tmp, fnbase + 2 + i)) goto err ; stralloc_catb(tmp, tmp->s + ipos, fnbase) ; stralloc_catb(tmp, "/", 1) ; fnbase = tmp->len ; for (i = tmpbase ; i < tmpstop ; i += tmp->len - fnbase) { size_t n = strlen(tmp->s + i) ; tmp->len = fnbase ; stralloc_catb(tmp, tmp->s + i, n+1) ; if (rm_rf_in_tmp(tmp, tmpstop) == -1) goto err ; } tmp->len = tmpbase ; return 0 ; err: tmp->len = tmpbase ; return -1 ; } int rm_rf_in_tmp (stralloc *tmp, size_t ipos) { int isadir ; if (unlink(tmp->s + ipos) == 0) return 0 ; if (errno == ENOENT) return 0 ; if ((errno != EISDIR) && (errno != EPERM)) return -1 ; isadir = errno == EPERM ; if (rmstar_in_tmp(tmp, ipos) == -1) { if (isadir && errno == ENOTDIR) errno = EPERM ; return -1 ; } return rmdir(tmp->s + ipos) ; } int rmstar_tmp (char const *dirname, stralloc *tmp) { size_t tmpbase = tmp->len ; if (!stralloc_cats(tmp, dirname)) return -1 ; if (!stralloc_0(tmp)) goto err ; if (rmstar_in_tmp(tmp, tmpbase) == -1) goto err ; tmp->len = tmpbase ; return 0 ; err: tmp->len = tmpbase ; return -1 ; } skalibs-2.14.1.1/src/libstddjb/rm_rf_tmp.c000066400000000000000000000005741455624754300202740ustar00rootroot00000000000000/* ISC license. */ #include #include int rm_rf_tmp (char const *filename, stralloc *tmp) { size_t tmpbase = tmp->len ; if (!stralloc_cats(tmp, filename)) return -1 ; if (!stralloc_0(tmp)) goto err ; if (rm_rf_in_tmp(tmp, tmpbase) == -1) goto err ; tmp->len = tmpbase ; return 0 ; err: tmp->len = tmpbase ; return -1 ; } skalibs-2.14.1.1/src/libstddjb/rmstar.c000066400000000000000000000002541455624754300176120ustar00rootroot00000000000000/* ISC license. */ /* MT-unsafe */ #include #include int rmstar (char const *dirname) { return rmstar_tmp(dirname, &satmp) ; } skalibs-2.14.1.1/src/libstddjb/sabasename.c000066400000000000000000000007051455624754300204020ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include int sabasename (stralloc *sa, char const *s, size_t len) { if (!len) return stralloc_catb(sa, ".", 1) ; while (len && (s[len-1] == '/')) len-- ; if (!len) return stralloc_catb(sa, "/", 1) ; { size_t i = byte_rchr(s, len, '/') ; i = (i == len) ? 0 : i+1 ; return stralloc_catb(sa, s + i, len - i) ; } } skalibs-2.14.1.1/src/libstddjb/sadirname.c000066400000000000000000000010201455624754300202350ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include int sadirname (stralloc *sa, char const *s, size_t len) { if (!len) return stralloc_catb(sa, ".", 1) ; while (len && (s[len-1] == '/')) len-- ; if (!len) return stralloc_catb(sa, "/", 1) ; { size_t i = byte_rchr(s, len, '/') ; return (i == len) ? stralloc_catb(sa, ".", 1) : (i == 0) ? stralloc_catb(sa, "/", 1) : stralloc_catb(sa, s, i) ; } } skalibs-2.14.1.1/src/libstddjb/sagetcwd.c000066400000000000000000000007441455624754300201070ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include int sagetcwd (stralloc *sa) { size_t n = 128 ; int wasnull = !sa->s ; for (;;) { if (!stralloc_readyplus(sa, n)) goto err ; if (getcwd(sa->s + sa->len, n)) break ; if (errno != ERANGE) goto err ; n += 128 ; } sa->len += strlen(sa->s + sa->len) ; return 0 ; err: if (wasnull) stralloc_free(sa) ; return -1 ; } skalibs-2.14.1.1/src/libstddjb/sagethostname.c000066400000000000000000000011731455624754300211450ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include int sagethostname (stralloc *sa) { size_t n = 32 ; int e = errno ; int wasnull = !sa->s ; for (;;) { if (!stralloc_readyplus(sa, n)) goto err ; sa->s[sa->len + n - 2] = 0 ; errno = 0 ; if (gethostname(sa->s + sa->len, n) < 0) { if (errno != ENAMETOOLONG) goto err ; } else if (!sa->s[sa->len + n - 2]) break ; n += 32 ; } sa->len += strlen(sa->s + sa->len) ; errno = e ; return 0 ; err: if (wasnull) stralloc_free(sa) ; return -1 ; } skalibs-2.14.1.1/src/libstddjb/sals.c000066400000000000000000000015751455624754300172530ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include int sals (char const *fn, stralloc *sa, size_t *x) { int n = 0 ; size_t sabase = sa->len ; size_t maxlen = 0 ; DIR *dir = opendir(fn) ; if (dir) { for (;;) { direntry *d ; size_t len ; errno = 0 ; d = readdir(dir) ; if (!d) break ; if (d->d_name[0] == '.') if (((d->d_name[1] == '.') && !d->d_name[2]) || !d->d_name[1]) continue ; len = strlen(d->d_name) ; if (len > maxlen) maxlen = len ; if (!stralloc_catb(sa, d->d_name, len+1)) goto err ; n++ ; } if (errno) goto err ; dir_close(dir) ; } else if (errno != ENOENT) return -1 ; if (x) *x = maxlen ; return n ; err: dir_close(dir) ; sa->len = sabase ; return -1 ; } skalibs-2.14.1.1/src/libstddjb/sanitize_read.c000066400000000000000000000003631455624754300211240ustar00rootroot00000000000000/* ISC license. */ #include #include #include ssize_t sanitize_read (ssize_t r) { return r == -1 ? error_isagain(errno) ? (errno = 0, 0) : -1 : !r ? (errno = EPIPE, -1) : r ; } skalibs-2.14.1.1/src/libstddjb/sareadlink.c000066400000000000000000000007371455624754300204250ustar00rootroot00000000000000/* ISC license. */ #include #include #include int sareadlink (stralloc *sa, char const *path) { size_t n = 128 ; int wasnull = !sa->s ; ssize_t r ; for (;;) { if (!stralloc_readyplus(sa, n)) goto err ; r = readlink(path, sa->s + sa->len, n) ; if (r < 0) goto err ; if ((size_t)r < n) break ; n += 128 ; } sa->len += r ; return 0 ; err: if (wasnull) stralloc_free(sa) ; return -1 ; } skalibs-2.14.1.1/src/libstddjb/sarealpath.c000066400000000000000000000013751455624754300204330ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include int sarealpath (stralloc *sa, char const *path) { if (sa->s) { #ifdef PATH_MAX if (!stralloc_readyplus(sa, PATH_MAX)) return -1 ; if (!realpath(path, sa->s + sa->len)) return -1 ; sa->len += strlen(sa->s + sa->len) ; #else char *p = realpath(path, 0) ; if (!p) return -1 ; if (!stralloc_cats(sa, p) || !stralloc_0(sa)) { free(p) ; return -1 ; } free(p) ; #endif } else { char *p = realpath(path, 0) ; if (!p) return -1 ; sa->s = p ; /* XXX: incompatible with alloc() interposition */ sa->len = strlen(p) ; sa->a = sa->len + 1 ; } return 0 ; } skalibs-2.14.1.1/src/libstddjb/satmp.c000066400000000000000000000001611455624754300174230ustar00rootroot00000000000000/* ISC license. */ #include #include stralloc satmp = STRALLOC_ZERO ; skalibs-2.14.1.1/src/libstddjb/sauniquename.c000066400000000000000000000012371455624754300207770ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include int sauniquename (stralloc *sa) { size_t base = sa->len ; int wasnull = !sa->s ; if (!stralloc_readyplus(sa, TIMESTAMP + PID_FMT + 131)) return 0 ; sa->s[base] = ':' ; timestamp(sa->s + base + 1) ; sa->s[base + 1 + TIMESTAMP] = ':' ; sa->len = base + 2 + TIMESTAMP ; sa->len += pid_fmt(sa->s + sa->len, getpid()) ; sa->s[sa->len++] = ':' ; if (sagethostname(sa) < 0) goto err ; return 1 ; err: if (wasnull) stralloc_free(sa) ; else sa->len = base ; return 0 ; } skalibs-2.14.1.1/src/libstddjb/selfpipe.c000066400000000000000000000066401455624754300201160ustar00rootroot00000000000000/* ISC license. */ /* MT-unsafe */ #include #ifdef SKALIBS_HASSIGNALFD #include #include #include #include #include #include struct selfpipe_s { sigset_t caught ; int fd ; } ; static struct selfpipe_s sp = { .fd = -1 } ; int selfpipe_fd () { return sp.fd ; } int selfpipe_read () { struct signalfd_siginfo buf ; ssize_t r = sanitize_read(fd_read(sp.fd, (char *)&buf, sizeof(struct signalfd_siginfo))) ; return (r <= 0) ? r : buf.ssi_signo ; } int selfpipe_trap (int sig) { sigset_t set = sp.caught ; sigset_t old ; if (sp.fd == -1) return (errno = EBADF, 0) ; if (sigaddset(&set, sig) == -1 || sigprocmask(SIG_BLOCK, &set, &old) == -1) return 0 ; if (signalfd(sp.fd, &set, SFD_NONBLOCK | SFD_CLOEXEC) == -1) { int e = errno ; sigprocmask(SIG_SETMASK, &old, 0) ; errno = e ; return 0 ; } sp.caught = set ; return 1 ; } int selfpipe_trapset (sigset_t const *set) { sigset_t old ; if (sp.fd == -1) return (errno = EBADF, 0) ; if (sigprocmask(SIG_SETMASK, set, &old) == -1) return 0 ; if (signalfd(sp.fd, set, SFD_NONBLOCK | SFD_CLOEXEC) == -1) { int e = errno ; sigprocmask(SIG_SETMASK, &old, 0) ; errno = e ; return 0 ; } sp.caught = *set ; return 1 ; } void selfpipe_finish () { int e = errno ; fd_close(sp.fd) ; sp.fd = -1 ; sigprocmask(SIG_UNBLOCK, &sp.caught, 0) ; sigemptyset(&sp.caught) ; errno = e ; } int selfpipe_init () { sigemptyset(&sp.caught) ; sig_blocknone() ; sp.fd = signalfd(sp.fd, &sp.caught, SFD_NONBLOCK | SFD_CLOEXEC) ; return sp.fd ; } #else #include #include #include #include #include #include #include #include struct selfpipe_s { sigset_t caught ; int fd[2] ; } ; static struct selfpipe_s sp = { .fd = { -1, -1 } } ; static void selfpipe_tophalf (int s) { int e = errno ; unsigned char c = (unsigned char)s ; write(sp.fd[1], (char *)&c, 1) ; errno = e ; } int selfpipe_fd () { return sp.fd[0] ; } int selfpipe_read () { char c ; ssize_t r = sanitize_read((fd_read(sp.fd[0], &c, 1))) ; return (r <= 0) ? r : c ; } int selfpipe_trap (int sig) { if (sp.fd[0] == -1) return (errno = EBADF, 0) ; if (!sig_catch(sig, &selfpipe_tophalf)) return 0 ; sigaddset(&sp.caught, sig) ; sig_unblock(sig) ; return 1 ; } int selfpipe_trapset (sigset_t const *set) { unsigned int i = 1 ; if (sp.fd[0] == -1) return (errno = EBADF, 0) ; for (; i < SKALIBS_NSIG ; i++) { int h = sigismember(set, i) ; if (h < 0) continue ; if (h) { if (!sig_catch(i, &selfpipe_tophalf)) goto err ; } else if (sigismember(&sp.caught, i)) { if (!sig_restore(i)) goto err ; } } sig_blocknone() ; sp.caught = *set ; return 1 ; err: sig_restoreto(set, i) ; return 0 ; } void selfpipe_finish () { int e = errno ; sigprocmask(SIG_BLOCK, &sp.caught, 0) ; sig_restoreto(&sp.caught, SKALIBS_NSIG) ; fd_close(sp.fd[1]) ; fd_close(sp.fd[0]) ; sigprocmask(SIG_UNBLOCK, &sp.caught, 0) ; sigemptyset(&sp.caught) ; sp.fd[0] = sp.fd[1] = -1 ; errno = e ; } int selfpipe_init () { if (sp.fd[0] >= 0) selfpipe_finish() ; else sigemptyset(&sp.caught) ; sig_blocknone() ; return pipenbcoe(sp.fd) < 0 ? -1 : sp.fd[0] ; } #endif skalibs-2.14.1.1/src/libstddjb/sgetopt.c000066400000000000000000000011061455624754300177640ustar00rootroot00000000000000/* ISC license. */ /* MT-unsafe */ #undef SUBGETOPT_SHORT #include #include int sgetopt_r (int argc, char const *const *argv, char const *opts, subgetopt *o) { int c = subgetopt_r(argc, argv, opts, o) ; if (o->err && ((c == '?') || (c == ':'))) { buffer_puts(buffer_2, o->prog ? o->prog : argv[0]) ; buffer_put(buffer_2, ": ", 2) ; buffer_puts(buffer_2, ((c == '?') && argv[o->ind] && (o->ind < argc)) ? "illegal option" : "option requires an argument") ; buffer_putflush(buffer_2, "\n", 1) ; } return c ; } skalibs-2.14.1.1/src/libstddjb/sig-internal.h000066400000000000000000000003671455624754300207100ustar00rootroot00000000000000/* ISC license. */ #ifndef SKALIBS_SIG_INTERNAL_H #define SKALIBS_SIG_INTERNAL_H typedef struct sigtable_s sigtable, *sigtable_ref ; struct sigtable_s { int number ; char const *name ; } ; extern sigtable const skalibs_sigtable[] ; #endif skalibs-2.14.1.1/src/libstddjb/sig0_scan.c000066400000000000000000000011241455624754300201450ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include static size_t sig0_scan_norec (char const *s, int *sig) { int r = sig_number(s) ; if (r) { *sig = r ; return strlen(s) ; } { unsigned int u ; size_t len = uint0_scan(s, &u) ; if (len) *sig = u ; return len ; } } size_t sig0_scan (char const *s, int *sig) { size_t len = sig0_scan_norec(s, sig) ; if (len) return len ; if (!strncasecmp(s, "SIG", 3)) { len = sig0_scan_norec(s+3, sig) ; if (len) return 3+len ; } return 0 ; } skalibs-2.14.1.1/src/libstddjb/sig_altignore.c000066400000000000000000000002641455624754300211310ustar00rootroot00000000000000/* ISC license. */ /* MT-unsafe */ #include static void sig_nop (int sig) { (void)sig ; } int sig_altignore (int sig) { return sig_catch(sig, &sig_nop) ; } skalibs-2.14.1.1/src/libstddjb/sig_block.c000066400000000000000000000003001455624754300202260ustar00rootroot00000000000000/* ISC license. */ #include #include void sig_block (int sig) { sigset_t ss ; sigemptyset(&ss) ; sigaddset(&ss, sig) ; sigprocmask(SIG_BLOCK, &ss, 0) ; } skalibs-2.14.1.1/src/libstddjb/sig_blocknone.c000066400000000000000000000003361455624754300211170ustar00rootroot00000000000000/* ISC license. */ #include #include #include void sig_blocknone (void) { int e = errno ; sigset_t ss ; sigemptyset(&ss) ; sigprocmask(SIG_SETMASK, &ss, 0) ; errno = e ; } skalibs-2.14.1.1/src/libstddjb/sig_catch.c000066400000000000000000000010421455624754300202220ustar00rootroot00000000000000/* ISC license. */ /* MT-unsafe */ #include #include #include #include #include #include /* We don't want to fail on non-catchable signals, even if sigaction() does. */ int sig_catch (int sig, sig_func_ref f) { struct sigaction action = { .sa_handler = f, .sa_flags = SA_RESTART | SA_NOCLDSTOP } ; sigfillset(&action.sa_mask) ; return sigaction(sig, &action, 0) >= 0 || (errno == EINVAL && sig >= 1 && sig < SKALIBS_NSIG) ; } skalibs-2.14.1.1/src/libstddjb/sig_name.c000066400000000000000000000003631455624754300200650ustar00rootroot00000000000000/* ISC license. */ #include #include "sig-internal.h" char const *sig_name (int sig) { sigtable const *p = skalibs_sigtable ; for (; p->number ; p++) if (sig == p->number) break ; return p->number ? p->name : "???" ; } skalibs-2.14.1.1/src/libstddjb/sig_number.c000066400000000000000000000004021455624754300204270ustar00rootroot00000000000000/* ISC license. */ #include #include #include "sig-internal.h" int sig_number (char const *name) { sigtable const *p = skalibs_sigtable ; for (; p->name ; p++) if (!strcasecmp(name, p->name)) break ; return p->number ; } skalibs-2.14.1.1/src/libstddjb/sig_restoreto.c000066400000000000000000000005211455624754300211670ustar00rootroot00000000000000/* ISC license. */ /* MT-unsafe */ #include #include #include void sig_restoreto (sigset_t const *set, unsigned int n) { int e = errno ; unsigned int i = 1 ; for (; i < n ; i++) { int h = sigismember(set, i) ; if (h < 0) continue ; if (h) sig_restore(i) ; } errno = e ; } skalibs-2.14.1.1/src/libstddjb/sig_table.c000066400000000000000000000026031455624754300202330ustar00rootroot00000000000000 /* ISC license. */ #include #include #include "sig-internal.h" sigtable const skalibs_sigtable[] = { { SIGABRT, "ABRT" }, { SIGALRM, "ALRM" }, { SIGBUS, "BUS" }, { SIGCHLD, "CHLD" }, { SIGCONT, "CONT" }, { SIGFPE, "FPE" }, { SIGHUP, "HUP" }, { SIGILL, "ILL" }, { SIGINT, "INT" }, { SIGKILL, "KILL" }, { SIGPIPE, "PIPE" }, { SIGQUIT, "QUIT" }, { SIGSEGV, "SEGV" }, { SIGSTOP, "STOP" }, { SIGTERM, "TERM" }, { SIGTSTP, "TSTP" }, { SIGTTIN, "TTIN" }, { SIGTTOU, "TTOU" }, { SIGUSR1, "USR1" }, { SIGUSR2, "USR2" }, #ifdef SIGPOLL { SIGPOLL, "POLL" }, #endif #ifdef SIGPROF { SIGPROF, "PROF" }, #endif #ifdef SIGSYS { SIGSYS, "SYS" }, #endif #ifdef SIGTRAP { SIGTRAP, "TRAP" }, #endif #ifdef SIGURG { SIGURG, "URG" }, #endif #ifdef SIGVTALRM { SIGVTALRM, "VTALRM" }, #endif #ifdef SIGXCPU { SIGXCPU, "XCPU" }, #endif #ifdef SIGXFSZ { SIGXFSZ, "XFSZ" }, #endif #ifdef SIGIOT { SIGIOT, "IOT" }, #endif #ifdef SIGEMT { SIGEMT, "EMT" }, #endif #ifdef SIGSTKFLT { SIGSTKFLT, "STKFLT" }, #endif #ifdef SIGCLD { SIGCLD, "CLD" }, #endif #ifdef SIGWINCH { SIGWINCH, "WINCH" }, #endif #ifdef SIGIO { SIGIO, "IO" }, #endif #ifdef SIGINFO { SIGINFO, "INFO" }, #endif #ifdef SIGLOST { SIGLOST, "LOST" }, #endif #ifdef SIGPWR { SIGPWR, "PWR" }, #endif #ifdef SIGUNUSED { SIGUNUSED, "UNUSED" }, #endif { 0, 0 } } ; skalibs-2.14.1.1/src/libstddjb/sig_unblock.c000066400000000000000000000003041455624754300205750ustar00rootroot00000000000000/* ISC license. */ #include #include void sig_unblock (int sig) { sigset_t ss ; sigemptyset(&ss) ; sigaddset(&ss, sig) ; sigprocmask(SIG_UNBLOCK, &ss, 0) ; } skalibs-2.14.1.1/src/libstddjb/sigfpe.c000066400000000000000000000001731455624754300175570ustar00rootroot00000000000000/* ISC license. */ #include #include int sigfpe (void) { return raise(SIGFPE) == 0 ; } skalibs-2.14.1.1/src/libstddjb/sigsegv.c000066400000000000000000000001751455624754300177530ustar00rootroot00000000000000/* ISC license. */ #include #include int sigsegv (void) { return raise(SIGSEGV) == 0 ; } skalibs-2.14.1.1/src/libstddjb/siovec_bytechr.c000066400000000000000000000005751455624754300213200ustar00rootroot00000000000000/* ISC license. */ #include #include #include size_t siovec_bytechr (struct iovec const *v, unsigned int n, char c) { size_t w = 0 ; unsigned int i = 0 ; for (; i < n ; i++) { size_t pos = byte_chr((char const *)v[i].iov_base, v[i].iov_len, c) ; w += pos ; if (pos < v[i].iov_len) break ; } return w ; } skalibs-2.14.1.1/src/libstddjb/siovec_bytein.c000066400000000000000000000006351455624754300211470ustar00rootroot00000000000000/* ISC license. */ #include #include #include size_t siovec_bytein (struct iovec const *v, unsigned int n, char const *sep, size_t seplen) { size_t w = 0 ; unsigned int i = 0 ; for (; i < n ; i++) { size_t pos = byte_in((char const *)v[i].iov_base, v[i].iov_len, sep, seplen) ; w += pos ; if (pos < v[i].iov_len) break ; } return w ; } skalibs-2.14.1.1/src/libstddjb/siovec_deal.c000066400000000000000000000012461455624754300205610ustar00rootroot00000000000000/* ISC license. */ #include #include #include size_t siovec_deal (struct iovec const *vj, unsigned int nj, struct iovec const *vi, unsigned int ni) { size_t w = 0 ; size_t wi = 0 ; size_t wj = 0 ; unsigned int i = 0 ; unsigned int j = 0 ; while (i < ni && j < nj) { size_t tor = vi[i].iov_len - wi ; size_t tow = vj[j].iov_len - wj ; size_t len = tor < tow ? tor : tow ; memmove((char *)vj[j].iov_base + wj, (char const *)vi[i].iov_base + wi, len) ; wi += len ; wj += len ; w += len ; if (wi >= vi[i].iov_len) { wi = 0 ; i++ ; } if (wj >= vj[j].iov_len) { wj = 0 ; j++ ; } } return w ; } skalibs-2.14.1.1/src/libstddjb/siovec_gather.c000066400000000000000000000006261455624754300211270ustar00rootroot00000000000000/* ISC license. */ #include #include #include size_t siovec_gather (struct iovec const *v, unsigned int n, char *s, size_t max) { size_t w = 0 ; unsigned int i = 0 ; for (; i < n && w < max ; i++) { size_t len = v[i].iov_len ; if (len > max - w) len = max - w ; if (len) memmove(s + w, v[i].iov_base, len) ; w += len ; } return w ; } skalibs-2.14.1.1/src/libstddjb/siovec_len.c000066400000000000000000000003041455624754300204240ustar00rootroot00000000000000/* ISC license. */ #include #include size_t siovec_len (struct iovec const *v, unsigned int n) { size_t w = 0 ; while (n--) w += v[n].iov_len ; return w ; } skalibs-2.14.1.1/src/libstddjb/siovec_scatter.c000066400000000000000000000006551455624754300213240ustar00rootroot00000000000000/* ISC license. */ #include #include #include size_t siovec_scatter (struct iovec const *v, unsigned int n, char const *s, size_t len) { size_t w = 0 ; unsigned int i = 0 ; for (; i < n && w < len ; i++) { size_t chunklen = v[i].iov_len ; if (w + chunklen > len) chunklen = len - w ; memmove(v[i].iov_base, s + w, chunklen) ; w += chunklen ; } return w ; } skalibs-2.14.1.1/src/libstddjb/siovec_search.c000066400000000000000000000017631455624754300211250ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include size_t siovec_search (struct iovec const *v, unsigned int n, char const *needle, size_t nlen) { size_t vlen = siovec_len(v, n) ; size_t w = 0 ; unsigned int i = 0 ; for (; i < n ; i++) { char *p = memmem(v[i].iov_base, v[i].iov_len, needle, nlen) ; if (p) return w + (p - (char *)v[i].iov_base) ; if (i < n-1 && nlen > 1 && v[i].iov_len) { size_t prelen = v[i].iov_len < nlen ? v[i].iov_len : nlen ; size_t postlen = vlen - w - v[i].iov_len < nlen ? vlen - w - v[i].iov_len : nlen ; char buf[prelen + postlen - 2] ; memcpy(buf, (char *)v[i].iov_base + v[i].iov_len - prelen + 1, prelen - 1) ; siovec_gather(v + i + 1, n - 1 - i, buf + prelen - 1, postlen - 1) ; p = memmem(buf, prelen + postlen - 2, needle, nlen) ; if (p) return w + v[i].iov_len - prelen + 1 + (p - buf) ; } w += v[i].iov_len ; } return w ; } skalibs-2.14.1.1/src/libstddjb/siovec_seek.c000066400000000000000000000007601455624754300206030ustar00rootroot00000000000000/* ISC license. */ #include #include #include size_t siovec_seek (struct iovec *v, unsigned int n, size_t len) { size_t w = 0 ; unsigned int i = 0 ; for (; i < n ; i++) { if (len < v[i].iov_len) break ; w += v[i].iov_len ; len -= v[i].iov_len ; v[i].iov_base = 0 ; v[i].iov_len = 0 ; } if (i < n) { v[i].iov_base = (char *)v[i].iov_base + len ; v[i].iov_len -= len ; w += len ; } return w ; } skalibs-2.14.1.1/src/libstddjb/siovec_trunc.c000066400000000000000000000006001455624754300210000ustar00rootroot00000000000000/* ISC license. */ #include #include unsigned int siovec_trunc (struct iovec *v, unsigned int n, size_t len) { size_t w = siovec_len(v, n) ; if (w < len) return n ; len = w - len ; while (n && len) { w = len > v[n-1].iov_len ? v[n-1].iov_len : len ; v[n-1].iov_len -= w ; len -= w ; if (!v[n-1].iov_len) n-- ; } return n ; } skalibs-2.14.1.1/src/libstddjb/skagetln.c000066400000000000000000000006451455624754300201160ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include int skagetln (buffer *b, stralloc *sa, char sep) { size_t start = sa->len ; for (;;) { ssize_t r = skagetln_nofill(b, sa, sep) ; if (r) return r ; r = buffer_fill(b) ; if (r < 0) return r ; if (!r) return (sa->s && (sa->len > start)) ? (errno = EPIPE, -1) : 0 ; } } skalibs-2.14.1.1/src/libstddjb/skagetln_loose.c000066400000000000000000000005111455624754300213070ustar00rootroot00000000000000/* ISC license. */ #include #include #include int skagetln_loose (buffer *b, stralloc *sa, char sep) { int e = errno ; int r = skagetln(b, sa, sep) ; if (r >= 0) return r ; if (errno != EPIPE) return -1 ; if (!stralloc_0(sa)) return -1 ; return (errno = e, 3) ; } skalibs-2.14.1.1/src/libstddjb/skagetln_nofill.c000066400000000000000000000007461455624754300214630ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include int skagetln_nofill (buffer *b, stralloc *sa, char sep) { struct iovec v[2] ; size_t pos ; int r ; buffer_rpeek(b, v) ; pos = siovec_bytechr(v, 2, sep) ; r = pos < buffer_len(b) ; pos += r ; if (!stralloc_readyplus(sa, pos)) return -1 ; buffer_getnofill(b, sa->s + sa->len, pos) ; sa->len += pos ; return r ; } skalibs-2.14.1.1/src/libstddjb/skagetlnmaxsep.c000066400000000000000000000014471455624754300213350ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include int skagetlnmaxsep (buffer *b, stralloc *sa, size_t max, char const *sep, size_t seplen) { size_t start = sa->len ; for (;;) { struct iovec v[2] ; size_t pos ; int r ; buffer_rpeek(b, v) ; pos = siovec_bytein(v, 2, sep, seplen) ; r = pos < buffer_len(b) ; pos += r ; if (!stralloc_readyplus(sa, pos)) return -1 ; buffer_getnofill(b, sa->s + sa->len, pos) ; sa->len += pos ; if (r) return 1 ; if (sa->len - start >= max) return (errno = EMSGSIZE, -1) ; r = buffer_fill(b) ; if (r < 0) return r ; if (!r) return (sa->s && (sa->len > start)) ? (errno = EPIPE, -1) : 0 ; } } skalibs-2.14.1.1/src/libstddjb/skagetlnsep.c000066400000000000000000000013301455624754300206160ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include int skagetlnsep (buffer *b, stralloc *sa, char const *sep, size_t seplen) { size_t start = sa->len ; for (;;) { struct iovec v[2] ; size_t pos ; int r ; buffer_rpeek(b, v) ; pos = siovec_bytein(v, 2, sep, seplen) ; r = pos < buffer_len(b) ; pos += r ; if (!stralloc_readyplus(sa, pos)) return -1 ; buffer_getnofill(b, sa->s + sa->len, pos) ; sa->len += pos ; if (r) return 1 ; r = buffer_fill(b) ; if (r < 0) return r ; if (!r) return (sa->s && (sa->len > start)) ? (errno = EPIPE, -1) : 0 ; } } skalibs-2.14.1.1/src/libstddjb/skagetlnsep_loose.c000066400000000000000000000005551455624754300220270ustar00rootroot00000000000000/* ISC license. */ #include #include #include int skagetlnsep_loose (buffer *b, stralloc *sa, char const *sep, size_t seplen) { int e = errno ; int r = skagetlnsep(b, sa, sep, seplen) ; if (r >= 0) return r ; if (errno != EPIPE) return -1 ; if (!stralloc_0(sa)) return -1 ; return (errno = e, 3) ; } skalibs-2.14.1.1/src/libstddjb/skalibs_tzisright.c000066400000000000000000000004331455624754300220400ustar00rootroot00000000000000/* ISC license. */ #include #include "djbtime-internal.h" int skalibs_tzisright () { static int tzisright = -1 ; if (tzisright < 0) { struct tm tm ; time_t t = 78796800 ; if (localtime_r(&t, &tm)) tzisright = tm.tm_sec == 60 ; } return tzisright ; } skalibs-2.14.1.1/src/libstddjb/slurpn.c000066400000000000000000000010621455624754300176230ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #define N 4096 int slurpn (int fd, stralloc *sa, size_t max) { for (;;) { ssize_t r ; size_t n = max && sa->len + N > max ? max - sa->len : N ; if (!n) return (errno = ENOBUFS, 0) ; if (!stralloc_readyplus(sa, n)) return 0 ; r = fd_read(fd, sa->s + sa->len, n) ; switch (r) { case -1 : return 0 ; case 0 : return 1 ; default : sa->len += r ; } } } skalibs-2.14.1.1/src/libstddjb/socket_accept4.c000066400000000000000000000020121455624754300211670ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #include #include #include #include int socket_accept4_internal (int s, char *ip, uint16_t *port, unsigned int options) { int fd ; struct sockaddr_in sa ; socklen_t dummy = sizeof sa ; do #ifdef SKALIBS_HASACCEPT4 fd = accept4(s, (struct sockaddr *)&sa, &dummy, ((options & O_NONBLOCK) ? SOCK_NONBLOCK : 0) | ((options & O_CLOEXEC) ? SOCK_CLOEXEC : 0)) ; #else fd = accept(s, (struct sockaddr *)&sa, &dummy) ; #endif while ((fd < 0) && (errno == EINTR)) ; if (fd < 0) return -1 ; #ifndef SKALIBS_HASACCEPT4 if ((((options & O_NONBLOCK) ? ndelay_on(fd) : ndelay_off(fd)) < 0) || (((options & O_CLOEXEC) ? coe(fd) : uncoe(fd)) < 0)) { fd_close(fd) ; return -1 ; } #endif memcpy(ip, &sa.sin_addr.s_addr, 4) ; *port = uint16_big(sa.sin_port) ; return fd ; } skalibs-2.14.1.1/src/libstddjb/socket_accept4_u32.c000066400000000000000000000004661455624754300216730ustar00rootroot00000000000000/* ISC license. */ #include #include int socket_accept4_internal_u32 (int s, uint32_t *ip, uint16_t *port, unsigned int options) { char pack[4] ; int fd = socket_accept4_internal(s, pack, port, options) ; if (fd >= 0) uint32_unpack_big(pack, ip) ; return fd ; } skalibs-2.14.1.1/src/libstddjb/socket_accept6.c000066400000000000000000000024131455624754300211760ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #include #include #include #include #include #ifdef SKALIBS_IPV6_ENABLED int socket_accept6_internal (int s, char *ip6, uint16_t *port, unsigned int options) { int fd ; struct sockaddr_in6 sa ; socklen_t dummy = sizeof sa ; do #ifdef SKALIBS_HASACCEPT4 fd = accept4(s, (struct sockaddr *)&sa, &dummy, ((options & O_NONBLOCK) ? SOCK_NONBLOCK : 0) | ((options & O_CLOEXEC) ? SOCK_CLOEXEC : 0)) ; #else fd = accept(s, (struct sockaddr *)&sa, &dummy) ; #endif while ((fd < 0) && (errno == EINTR)) ; if (fd < 0) return -1 ; #ifndef SKALIBS_HASACCEPT4 if ((((options & O_NONBLOCK) ? ndelay_on(fd) : ndelay_off(fd)) < 0) || (((options & O_CLOEXEC) ? coe(fd) : uncoe(fd)) < 0)) { fd_close(fd) ; return -1 ; } #endif memcpy(ip6, sa.sin6_addr.s6_addr, 16) ; *port = uint16_big(sa.sin6_port) ; return fd ; } #else int socket_accept6_internal (int s, char *ip6, uint16_t *port, unsigned int options) { (void)s ; (void)ip6 ; (void)port ; (void)options ; return (errno = ENOSYS, -1) ; } #endif skalibs-2.14.1.1/src/libstddjb/socket_bind4.c000066400000000000000000000007011455624754300206470ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include int socket_bind4 (int s, char const *ip, uint16_t port) { struct sockaddr_in sa ; memset(&sa, 0, sizeof sa) ; sa.sin_family = AF_INET ; sa.sin_port = uint16_big(port) ; memcpy(&sa.sin_addr.s_addr, ip, 4) ; return bind(s, (struct sockaddr *)&sa, sizeof sa) ; } skalibs-2.14.1.1/src/libstddjb/socket_bind4r.c000066400000000000000000000004641455624754300210370ustar00rootroot00000000000000/* ISC license. */ #include #include #include int socket_bind4_reuse (int s, char const *ip, uint16_t port) { static unsigned int const opt = 1 ; setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof opt) ; return socket_bind4(s, ip, port) ; } skalibs-2.14.1.1/src/libstddjb/socket_bind6.c000066400000000000000000000012511455624754300206520ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #include #include #ifdef SKALIBS_IPV6_ENABLED int socket_bind6 (int s, char const *ip6, uint16_t port) { struct sockaddr_in6 sa ; memset(&sa, 0, sizeof sa) ; sa.sin6_family = AF_INET6 ; sa.sin6_port = uint16_big(port) ; memcpy(sa.sin6_addr.s6_addr, ip6, 16) ; return bind(s, (struct sockaddr *)&sa, sizeof sa) ; } #else int socket_bind6 (int s, char const *ip6, uint16_t port) { (void)s ; (void)ip6 ; (void)port ; return (errno = ENOSYS, -1) ; } #endif skalibs-2.14.1.1/src/libstddjb/socket_bind6r.c000066400000000000000000000004661455624754300210430ustar00rootroot00000000000000/* ISC license. */ #include #include #include int socket_bind6_reuse (int s, char const *ip6, uint16_t port) { static unsigned int const opt = 1 ; setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof opt) ; return socket_bind6(s, ip6, port) ; } skalibs-2.14.1.1/src/libstddjb/socket_connect4.c000066400000000000000000000011311455624754300213620ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #include int socket_connect4 (int s, char const *ip, uint16_t port) { int r ; struct sockaddr_in sa ; memset(&sa, 0, sizeof sa) ; sa.sin_family = AF_INET ; sa.sin_port = uint16_big(port) ; memcpy(&sa.sin_addr.s_addr, ip, 4) ; do r = connect(s, (struct sockaddr *)&sa, sizeof sa) ; while ((r == -1) && (errno == EINTR)) ; if ((r == -1) && (errno == EALREADY)) errno = EINPROGRESS ; return r ; } skalibs-2.14.1.1/src/libstddjb/socket_connect4_u32.c000066400000000000000000000003461455624754300220620ustar00rootroot00000000000000/* ISC license. */ #include #include int socket_connect4_u32 (int s, uint32_t ip, uint16_t port) { char pack[4] ; uint32_pack_big(pack, ip) ; return socket_connect4(s, pack, port) ; } skalibs-2.14.1.1/src/libstddjb/socket_connect6.c000066400000000000000000000014611455624754300213720ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #include #include #ifdef SKALIBS_IPV6_ENABLED int socket_connect6 (int s, char const *ip6, uint16_t port) { struct sockaddr_in6 sa ; int r ; memset(&sa, 0, sizeof sa) ; sa.sin6_family = AF_INET6 ; sa.sin6_port = uint16_big(port) ; memcpy(sa.sin6_addr.s6_addr, ip6, 16) ; do r = connect(s, (struct sockaddr *)&sa, sizeof sa) ; while ((r == -1) && (errno == EINTR)) ; if ((r == -1) && (errno == EALREADY)) errno = EINPROGRESS ; return r ; } #else int socket_connect6 (int s, char const *ip6, uint16_t port) { (void)s ; (void)ip6 ; (void)port ; return (errno = ENOSYS, -1) ; } #endif skalibs-2.14.1.1/src/libstddjb/socket_connected.c000066400000000000000000000006051455624754300216140ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include int socket_connected (int s) { struct sockaddr_in sa ; socklen_t dummy = sizeof sa ; if (getpeername(s, (struct sockaddr *)&sa, &dummy) == -1) { char ch ; fd_read(s, &ch, 1) ; return 0 ; } return 1 ; } skalibs-2.14.1.1/src/libstddjb/socket_deadlineconnstamp4.c000066400000000000000000000006201455624754300234230ustar00rootroot00000000000000/* ISC license. */ #include #include #include int socket_deadlineconnstamp (int s, char const *ip, uint16_t port, tain const *deadline, tain *stamp) { int e = errno ; if (socket_connect4(s, ip, port) >= 0) return 1 ; if (!error_isagain(errno) && !error_isalready(errno)) return 0 ; errno = e ; return socket_waitconn(s, deadline, stamp) ; } skalibs-2.14.1.1/src/libstddjb/socket_deadlineconnstamp46.c000066400000000000000000000006541455624754300235200ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include int socket_deadlineconnstamp46 (int s, ip46 const *i, uint16_t port, tain const *deadline, tain *stamp) { int e = errno ; if (socket_connect46(s, i, port) >= 0) return 1 ; if (!error_isagain(errno) && !error_isalready(errno)) return 0 ; errno = e ; return socket_waitconn(s, deadline, stamp) ; } skalibs-2.14.1.1/src/libstddjb/socket_deadlineconnstamp4_u32.c000066400000000000000000000004561455624754300241230ustar00rootroot00000000000000/* ISC license. */ #include #include int socket_deadlineconnstamp4_u32 (int s, uint32_t ip, uint16_t port, tain const *deadline, tain *stamp) { char pack[4] ; uint32_pack_big(pack, ip) ; return socket_deadlineconnstamp4(s, pack, port, deadline, stamp) ; } skalibs-2.14.1.1/src/libstddjb/socket_deadlineconnstamp6.c000066400000000000000000000006211455624754300234260ustar00rootroot00000000000000/* ISC license. */ #include #include #include int socket_deadlineconnstamp6 (int s, char const *ip, uint16_t port, tain const *deadline, tain *stamp) { int e = errno ; if (socket_connect6(s, ip, port) >= 0) return 1 ; if (!error_isagain(errno) && !error_isalready(errno)) return 0 ; errno = e ; return socket_waitconn(s, deadline, stamp) ; } skalibs-2.14.1.1/src/libstddjb/socket_internal.c000066400000000000000000000013731455624754300214710ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #ifdef SKALIBS_HASACCEPT4 int socket_internal (int domain, int type, int protocol, unsigned int flags) { return socket(domain, type | ((flags & O_NONBLOCK) ? SOCK_NONBLOCK : 0) | ((flags & O_CLOEXEC) ? SOCK_CLOEXEC : 0), protocol) ; } #else int socket_internal (int domain, int type, int protocol, unsigned int flags) { int s = socket(domain, type, protocol) ; if (s == -1) return -1 ; if ((((flags & O_NONBLOCK) ? ndelay_on(s) : ndelay_off(s)) < 0) || (((flags & O_CLOEXEC) ? coe(s) : uncoe(s)) < 0)) { fd_close(s) ; return -1 ; } return s ; } #endif skalibs-2.14.1.1/src/libstddjb/socket_ioloop.c000066400000000000000000000013641455624754300211560ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include ssize_t socket_ioloop (int s, char *buf, size_t len, char *ip, uint16_t *port, socket_io_func_ref f, int w, tain const *deadline, tain *stamp) { iopause_fd x = { .fd = s, .events = w ? IOPAUSE_WRITE : IOPAUSE_READ, .revents = 0 } ; for (;;) { ssize_t r = iopause_stamp(&x, 1, deadline, stamp) ; if (r < 0) return -1 ; if (!r) return (errno = ETIMEDOUT, -1) ; if (x.revents & IOPAUSE_EXCEPT) return (errno = EIO, -1) ; if (x.revents & x.events) { r = (*f)(s, buf, len, ip, port) ; if (r < 0) { if (!error_isagain(errno)) return -1 ; } else return r ; } } } skalibs-2.14.1.1/src/libstddjb/socket_ioloop_send4.c000066400000000000000000000002701455624754300222460ustar00rootroot00000000000000/* ISC license. */ #include ssize_t socket_ioloop_send4 (int fd, char *s, size_t len, char *ip, uint16_t *port) { return socket_send4(fd, s, len, ip, *port) ; } skalibs-2.14.1.1/src/libstddjb/socket_ioloop_send6.c000066400000000000000000000002701455624754300222500ustar00rootroot00000000000000/* ISC license. */ #include ssize_t socket_ioloop_send6 (int fd, char *s, size_t len, char *ip, uint16_t *port) { return socket_send6(fd, s, len, ip, *port) ; } skalibs-2.14.1.1/src/libstddjb/socket_local4.c000066400000000000000000000007031455624754300210270ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include int socket_local4 (int s, char *ip, uint16_t *port) { struct sockaddr_in sa ; socklen_t dummy = sizeof sa ; if (getsockname(s, (struct sockaddr *)&sa, &dummy) == -1) return -1 ; memcpy(ip, &sa.sin_addr.s_addr, 4) ; *port = uint16_big(sa.sin_port) ; return 0 ; } skalibs-2.14.1.1/src/libstddjb/socket_local46.c000066400000000000000000000015741455624754300211240ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #include #ifdef SKALIBS_IPV6_ENABLED int socket_local46 (int s, ip46 *ip, uint16_t *port) { struct sockaddr_storage sa ; socklen_t dummy = sizeof sa ; if (getsockname(s, (struct sockaddr *)&sa, &dummy) < 0) return -1 ; if (sa.ss_family == AF_INET6) { struct sockaddr_in6 *sa6 = (struct sockaddr_in6 *)&sa ; memcpy(ip->ip, sa6->sin6_addr.s6_addr, 16) ; *port = uint16_big(sa6->sin6_port) ; ip->is6 = 1 ; } else if (sa.ss_family == AF_INET) { struct sockaddr_in *sa4 = (struct sockaddr_in *)&sa ; memcpy(ip->ip, &sa4->sin_addr.s_addr, 4) ; *port = uint16_big(sa4->sin_port) ; ip->is6 = 0 ; } else return (errno = EAFNOSUPPORT, -1) ; return 0 ; } #endif skalibs-2.14.1.1/src/libstddjb/socket_local6.c000066400000000000000000000012421455624754300210300ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #include #ifdef SKALIBS_IPV6_ENABLED int socket_local6 (int s, char *ip, uint16_t *port) { struct sockaddr_in6 sa ; socklen_t dummy = sizeof sa ; if (getsockname(s, (struct sockaddr *)&sa, &dummy) == -1) return -1 ; memcpy(ip, sa.sin6_addr.s6_addr, 16) ; *port = uint16_big(sa.sin6_port) ; return 0 ; } #else #include int socket_local6 (int s, char *ip, uint16_t *port) { (void)s ; (void)ip ; (void)port ; return (errno = ENOSYS, -1) ; } #endif skalibs-2.14.1.1/src/libstddjb/socket_recv4.c000066400000000000000000000010701455624754300206720ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #include ssize_t socket_recv4 (int s, char *buf, size_t len, char *ip, uint16_t *port) { ssize_t r ; struct sockaddr_in sa ; socklen_t dummy = sizeof sa ; do r = recvfrom(s, buf, len, 0, (struct sockaddr *)&sa, &dummy) ; while ((r == -1) && (errno == EINTR)) ; if (r == -1) return -1 ; memcpy(ip, &sa.sin_addr, 4) ; *port = uint16_big(sa.sin_port) ; return r ; } skalibs-2.14.1.1/src/libstddjb/socket_recv46.c000066400000000000000000000010131455624754300207550ustar00rootroot00000000000000/* ISC license. */ #include #include #ifdef SKALIBS_IPV6_ENABLED ssize_t socket_recv46 (int s, char *buf, size_t len, ip46 *ip, uint16_t *port, int h) { ssize_t r = h ? socket_recv6(s, buf, len, ip->ip, port) : socket_recv4(s, buf, len, ip->ip, port) ; if (r == -1) return -1 ; ip->is6 = !!h ; return r ; } #else ssize_t socket_recv46 (int s, char *buf, size_t len, ip46 *ip, uint16_t *port, int h) { (void)h ; return socket_recv4(s, buf, len, ip->ip, port) ; } #endif skalibs-2.14.1.1/src/libstddjb/socket_recv6.c000066400000000000000000000015041455624754300206760ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #include #include #ifdef SKALIBS_IPV6_ENABLED ssize_t socket_recv6 (int s, char *buf, size_t len, char *ip6, uint16_t *port) { struct sockaddr_in6 sa ; socklen_t dummy = sizeof sa ; ssize_t r ; do r = recvfrom(s, buf, len, 0, (struct sockaddr *)&sa, &dummy) ; while ((r == -1) && (errno == EINTR)) ; if (r == -1) return -1 ; memcpy(ip6, sa.sin6_addr.s6_addr, 16) ; *port = uint16_big(sa.sin6_port) ; return r ; } #else ssize_t socket_recv6 (int s, char *buf, size_t len, char *ip6, uint16_t *port) { (void)s ; (void)buf ; (void)len ; (void)ip6 ; (void)port ; return (errno = ENOSYS, -1) ; } #endif skalibs-2.14.1.1/src/libstddjb/socket_recvnb46.c000066400000000000000000000012161455624754300213020ustar00rootroot00000000000000/* ISC license. */ #include #include #ifdef SKALIBS_IPV6_ENABLED ssize_t socket_recvnb46 (int s, char *buf, size_t len, ip46 *ip, uint16_t *port, int h, tain const *deadline, tain *stamp) { ssize_t r = h ? socket_recvnb6(s, buf, len, ip->ip, port, deadline, stamp) : socket_recvnb4(s, buf, len, ip->ip, port, deadline, stamp) ; if (r == -1) return -1 ; ip->is6 = !!h ; return r ; } #else ssize_t socket_recvnb46 (int s, char *buf, size_t len, ip46 *ip, uint16_t *port, int h, tain const *deadline, tain *stamp) { (void)h ; return socket_recvnb4(s, buf, len, ip->ip, port, deadline, stamp) ; } #endif skalibs-2.14.1.1/src/libstddjb/socket_remote4.c000066400000000000000000000007041455624754300212310ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include int socket_remote4 (int s, char *ip, uint16_t *port) { struct sockaddr_in sa ; socklen_t dummy = sizeof sa ; if (getpeername(s, (struct sockaddr *)&sa, &dummy) == -1) return -1 ; memcpy(ip, &sa.sin_addr.s_addr, 4) ; *port = uint16_big(sa.sin_port) ; return 0 ; } skalibs-2.14.1.1/src/libstddjb/socket_remote46.c000066400000000000000000000015751455624754300213260ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #include #ifdef SKALIBS_IPV6_ENABLED int socket_remote46 (int s, ip46 *ip, uint16_t *port) { struct sockaddr_storage sa ; socklen_t dummy = sizeof sa ; if (getpeername(s, (struct sockaddr *)&sa, &dummy) < 0) return -1 ; if (sa.ss_family == AF_INET6) { struct sockaddr_in6 *sa6 = (struct sockaddr_in6 *)&sa ; memcpy(ip->ip, sa6->sin6_addr.s6_addr, 16) ; *port = uint16_big(sa6->sin6_port) ; ip->is6 = 1 ; } else if (sa.ss_family == AF_INET) { struct sockaddr_in *sa4 = (struct sockaddr_in *)&sa ; memcpy(ip->ip, &sa4->sin_addr.s_addr, 4) ; *port = uint16_big(sa4->sin_port) ; ip->is6 = 0 ; } else return (errno = EAFNOSUPPORT, -1) ; return 0 ; } #endif skalibs-2.14.1.1/src/libstddjb/socket_remote6.c000066400000000000000000000012431455624754300212320ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #include #include #ifdef SKALIBS_IPV6_ENABLED int socket_remote6 (int s, char *ip, uint16_t *port) { struct sockaddr_in6 sa ; socklen_t dummy = sizeof sa ; if (getpeername(s, (struct sockaddr *)&sa, &dummy) == -1) return -1 ; memcpy(ip, sa.sin6_addr.s6_addr, 16) ; *port = uint16_big(sa.sin6_port) ; return 0 ; } #else int socket_remote6 (int s, char *ip, uint16_t *port) { (void)s ; (void)ip ; (void)port ; return (errno = ENOSYS, -1) ; } #endif skalibs-2.14.1.1/src/libstddjb/socket_send4.c000066400000000000000000000011021455624754300206600ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #include ssize_t socket_send4 (int s, char const *buf, size_t len, char const *ip, uint16_t port) { ssize_t r ; struct sockaddr_in sa ; memset(&sa, 0, sizeof sa) ; sa.sin_family = AF_INET ; sa.sin_port = uint16_big(port) ; memcpy(&sa.sin_addr, ip, 4) ; do r = sendto(s, buf, len, 0, (struct sockaddr *)&sa, sizeof sa) ; while ((r == -1) && (errno == EINTR)) ; return r ; } skalibs-2.14.1.1/src/libstddjb/socket_send6.c000066400000000000000000000015331455624754300206720ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #include #include #ifdef SKALIBS_IPV6_ENABLED ssize_t socket_send6 (int s, char const *buf, size_t len, char const *ip6, uint16_t port) { ssize_t r ; struct sockaddr_in6 sa ; memset(&sa, 0, sizeof sa) ; sa.sin6_family = AF_INET6 ; sa.sin6_port = uint16_big(port) ; memcpy(sa.sin6_addr.s6_addr, ip6, 16) ; do r = sendto(s, buf, len, 0, (struct sockaddr *)&sa, sizeof sa) ; while ((r == -1) && (errno == EINTR)) ; return r ; } #else ssize_t socket_send6 (int s, char const *buf, size_t len, char const *ip6, uint16_t port) { (void)s ; (void)buf ; (void)len ; (void)ip6 ; (void)port ; return (errno = ENOSYS, -1) ; } #endif skalibs-2.14.1.1/src/libstddjb/socket_tcp4.c000066400000000000000000000003551455624754300205260ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include int socket_tcp4_internal (unsigned int flags) { return socket_internal(AF_INET, SOCK_STREAM, 0, flags) ; } skalibs-2.14.1.1/src/libstddjb/socket_tcp6.c000066400000000000000000000012201455624754300205200ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #include #ifdef SKALIBS_IPV6_ENABLED int socket_tcp6_internal (unsigned int flags) { int fd = socket_internal(AF_INET6, SOCK_STREAM, 0, flags) ; if (fd < 0) return fd ; { int option = 1 ; if (setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &option, sizeof(option)) < 0) { fd_close(fd) ; return -1 ; } } return fd ; } #else int socket_tcp6_internal (unsigned int flags) { (void)flags ; return (errno = ENOSYS, -1) ; } #endif skalibs-2.14.1.1/src/libstddjb/socket_tcpnodelay.c000066400000000000000000000004371455624754300220170ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include int socket_tcpnodelay (int s) { static int const opt = TCP_NODELAY ; return setsockopt(s, IPPROTO_TCP, 1, &opt, sizeof(int)) ; } skalibs-2.14.1.1/src/libstddjb/socket_timeoutconn.c000066400000000000000000000005011455624754300222110ustar00rootroot00000000000000/* ISC license. */ #include #include int socket_timeoutconn (int s, char const *ip, uint16_t port, unsigned int timeout) { tain stamp, deadline ; tain_now(&stamp) ; tain_addsec(&deadline, &stamp, timeout) ; return socket_deadlineconnstamp4(s, ip, port, &deadline, &stamp) ; } skalibs-2.14.1.1/src/libstddjb/socket_tryreservein.c000066400000000000000000000004441455624754300224140ustar00rootroot00000000000000/* ISC license. */ #include #include #include void socket_tryreservein (int s, unsigned int size) { while (size >= 1024) { if (!setsockopt(s, SOL_SOCKET, SO_RCVBUF, &size, sizeof size)) return ; size -= (size >> 5) ; } } skalibs-2.14.1.1/src/libstddjb/socket_udp4.c000066400000000000000000000003531455624754300205260ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include int socket_udp4_internal (unsigned int flags) { return socket_internal(AF_INET, SOCK_DGRAM, 0, flags) ; } skalibs-2.14.1.1/src/libstddjb/socket_udp6.c000066400000000000000000000012171455624754300205300ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #include #ifdef SKALIBS_IPV6_ENABLED int socket_udp6_internal (unsigned int flags) { int fd = socket_internal(AF_INET6, SOCK_DGRAM, 0, flags) ; if (fd < 0) return fd ; { int option = 1 ; if (setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &option, sizeof(option)) < 0) { fd_close(fd) ; return -1 ; } } return fd ; } #else int socket_udp6_internal (unsigned int flags) { (void)flags ; return (errno = ENOSYS, -1) ; } #endif skalibs-2.14.1.1/src/libstddjb/socket_waitconn.c000066400000000000000000000010661455624754300214760ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include int socket_waitconn (int s, tain const *deadline, tain *stamp) { iopause_fd x = { s, IOPAUSE_WRITE, 0 } ; for (;;) { int r = iopause_stamp(&x, 1, deadline, stamp) ; if (r < 0) return 0 ; if (!r) return (errno = ETIMEDOUT, 0) ; if (x.revents & IOPAUSE_WRITE) break ; if (x.revents & IOPAUSE_EXCEPT) { fd_write(s, "", 1) ; /* sets errno */ return 0 ; } } return socket_connected(s) ; } skalibs-2.14.1.1/src/libstddjb/socketpair_internal.c000066400000000000000000000022121455624754300223360ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #include #ifdef SKALIBS_HASACCEPT4 int socketpair_internal (int domain, int type, int protocol, unsigned int flags, int *sv) { return socketpair(domain, type | ((flags & O_NONBLOCK) ? SOCK_NONBLOCK : 0) | ((flags & O_CLOEXEC) ? SOCK_CLOEXEC : 0), protocol, sv) ; } #else int socketpair_internal (int domain, int type, int protocol, unsigned int flags, int *sv) { int fd[2] ; if (socketpair(domain, type, protocol, fd) < 0) return -1 ; if (flags & O_NONBLOCK) { if (ndelay_on(fd[0]) < 0) goto err ; if (ndelay_on(fd[1]) < 0) goto err ; } else { if (ndelay_off(fd[0]) < 0) goto err ; if (ndelay_off(fd[1]) < 0) goto err ; } if (flags & O_CLOEXEC) { if (coe(fd[0]) < 0) goto err ; if (coe(fd[1]) < 0) goto err ; } else { if (uncoe(fd[0]) < 0) goto err ; if (uncoe(fd[1]) < 0) goto err ; } sv[0] = fd[0] ; sv[1] = fd[1] ; return 0 ; err: fd_close(fd[1]) ; fd_close(fd[0]) ; return -1 ; } #endif skalibs-2.14.1.1/src/libstddjb/stamp.c000066400000000000000000000001311455624754300174200ustar00rootroot00000000000000/* ISC license. */ /* MT-unsafe */ #include tain STAMP = TAIN_EPOCH ; skalibs-2.14.1.1/src/libstddjb/str_chr.c000066400000000000000000000002541455624754300177460ustar00rootroot00000000000000/* ISC license. */ #include #include size_t str_chr (char const *s, int c) { char *p = strchr(s, c) ; return p ? p - s : strlen(s) ; } skalibs-2.14.1.1/src/libstddjb/str_fmt.c000066400000000000000000000002271455624754300177600ustar00rootroot00000000000000/* ISC license. */ #include #include size_t str_fmt (char *d, char const *s) { return strn_fmt(d, s, strlen(s)) ; } skalibs-2.14.1.1/src/libstddjb/str_rchr.c000066400000000000000000000002571455624754300201330ustar00rootroot00000000000000/* ISC license. */ #include #include size_t str_rchr (char const *s, int c) { char *p = strrchr(s, c) ; return p ? p - s : strlen(s) ; } skalibs-2.14.1.1/src/libstddjb/str_start.c000066400000000000000000000002341455624754300203250ustar00rootroot00000000000000/* ISC license. */ #include #include int str_start (char const *s, char const *t) { return !strncmp(s, t, strlen(t)) ; } skalibs-2.14.1.1/src/libstddjb/str_strn.c000066400000000000000000000006301455624754300201560ustar00rootroot00000000000000/* ISC license. */ #include #include size_t str_strn (char const *haystack, size_t hlen, char const *needle, size_t nlen) { char haystack2[hlen+1] ; char needle2[nlen+1] ; char *p ; memcpy(haystack2, haystack, hlen) ; haystack2[hlen] = 0 ; memcpy(needle2, needle, nlen) ; needle2[nlen] = 0 ; p = strstr(haystack2, needle2) ; return p ? p - haystack2 : hlen ; } skalibs-2.14.1.1/src/libstddjb/stralloc_append.c000066400000000000000000000002061455624754300214510ustar00rootroot00000000000000/* ISC license. */ #include int stralloc_append (stralloc *sa, char c) { return stralloc_catb(sa, &c, 1) ; } skalibs-2.14.1.1/src/libstddjb/stralloc_catb.c000066400000000000000000000003631455624754300211170ustar00rootroot00000000000000/* ISC license. */ #include #include int stralloc_catb (stralloc *sa, char const *s, size_t n) { if (!stralloc_readyplus(sa, n)) return 0 ; memmove(sa->s + sa->len, s, n) ; sa->len += n ; return 1 ; } skalibs-2.14.1.1/src/libstddjb/stralloc_catv.c000066400000000000000000000006351455624754300211450ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include int stralloc_catv (stralloc *sa, struct iovec const *v, unsigned int n) { unsigned int i = 0 ; if (!stralloc_readyplus(sa, siovec_len(v, n))) return 0 ; for ( ; i < n ; i++) { memmove(sa->s + sa->len, v[i].iov_base, v[i].iov_len) ; sa->len += v[i].iov_len ; } return 1 ; } skalibs-2.14.1.1/src/libstddjb/stralloc_copyb.c000066400000000000000000000003721455624754300213220ustar00rootroot00000000000000/* ISC license. */ #include #include int stralloc_copyb (stralloc *sa, char const *s, size_t n) { if (!n) return 1 ; if (!stralloc_ready(sa, n)) return 0 ; memmove(sa->s, s, n) ; sa->len = n ; return 1 ; } skalibs-2.14.1.1/src/libstddjb/stralloc_free.c000066400000000000000000000002421455624754300211230ustar00rootroot00000000000000/* ISC license. */ #include #include void stralloc_free (stralloc *sa) { alloc_free(sa->s) ; *sa = stralloc_zero ; } skalibs-2.14.1.1/src/libstddjb/stralloc_insertb.c000066400000000000000000000006161455624754300216550ustar00rootroot00000000000000/* ISC license. */ #include #include #include int stralloc_insertb (stralloc *sa, size_t offset, char const *s, size_t n) { if (offset > sa->len) return (errno = EINVAL, 0) ; if (!stralloc_readyplus(sa, n)) return 0 ; memmove(sa->s + offset + n, sa->s + offset, sa->len - offset) ; sa->len += n ; memmove(sa->s + offset, s, n) ; return 1 ; } skalibs-2.14.1.1/src/libstddjb/stralloc_ready_tuned.c000066400000000000000000000010121455624754300225010ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include int stralloc_ready_tuned (stralloc *sa, size_t n, size_t base, size_t a, size_t b) { size_t t ; if (!b) return (errno = EINVAL, 0) ; t = n + base + a * n / b ; if (t < n) return (errno = ERANGE, 0) ; if (!sa->s) { sa->s = alloc(t) ; if (!sa->s) return 0 ; sa->a = t ; } else if (n > sa->a) { if (!alloc_re(&sa->s, sa->a, t)) return 0 ; sa->a = t ; } return 1 ; } skalibs-2.14.1.1/src/libstddjb/stralloc_readyplus_tuned.c000066400000000000000000000004521455624754300234140ustar00rootroot00000000000000/* ISC license. */ #include #include int stralloc_readyplus_tuned (stralloc *sa, size_t n, size_t base, size_t a, size_t b) { size_t newlen = sa->len + n ; return newlen < sa->len ? (errno = ERANGE, 0) : stralloc_ready_tuned(sa, newlen, base, a, b) ; } skalibs-2.14.1.1/src/libstddjb/stralloc_reverse.c000066400000000000000000000004171455624754300216610ustar00rootroot00000000000000/* ISC license. */ #include #include void stralloc_reverse (stralloc *sa) { size_t i = 0 ; for (; i < sa->len >> 1 ; i++) { char tmp = sa->s[i] ; sa->s[i] = sa->s[sa->len - 1 - i] ; sa->s[sa->len - 1 - i] = tmp ; } } skalibs-2.14.1.1/src/libstddjb/stralloc_reverse_blocks.c000066400000000000000000000006221455624754300232140ustar00rootroot00000000000000/* ISC license. */ #include #include void stralloc_reverse_blocks (stralloc *sa, size_t size) { size_t n = sa->len / (size << 1) ; size_t i = 0 ; char tmp[size] ; for (; i < n ; i++) { size_t k = sa->len - (i + 1) * size ; memcpy(tmp, sa->s + i * size, size) ; memcpy(sa->s + i * size, sa->s + k, size) ; memcpy(sa->s + k, tmp, size) ; } } skalibs-2.14.1.1/src/libstddjb/stralloc_shrink.c000066400000000000000000000003551455624754300215050ustar00rootroot00000000000000/* ISC license. */ #include #include int stralloc_shrink (stralloc *sa) { if (sa->a > sa->len) { if (!alloc_re(&sa->s, sa->a, sa->len)) return 0 ; sa->a = sa->len ; } return 1 ; } skalibs-2.14.1.1/src/libstddjb/stralloc_zero.c000066400000000000000000000001421455624754300211600ustar00rootroot00000000000000/* ISC license. */ #include stralloc const stralloc_zero = STRALLOC_ZERO ; skalibs-2.14.1.1/src/libstddjb/strerr_diev.c000066400000000000000000000002761455624754300206360ustar00rootroot00000000000000/* ISC license. */ /* MT-unsafe */ #include #include void strerr_diev (int e, char const *const *v, unsigned int n) { strerr_warnv(v, n) ; _exit(e) ; } skalibs-2.14.1.1/src/libstddjb/strerr_dievsys.c000066400000000000000000000003041455624754300213650ustar00rootroot00000000000000/* ISC license. */ /* MT-unsafe */ #include #include void strerr_dievsys (int e, char const *const *v, unsigned int n) { strerr_warnvsys(v, n) ; _exit(e) ; } skalibs-2.14.1.1/src/libstddjb/strerr_warnv.c000066400000000000000000000005131455624754300210360ustar00rootroot00000000000000/* ISC license. */ /* MT-unsafe */ #include #include #include void strerr_warnv (char const *const *v, unsigned int n) { int e = errno ; for (unsigned int i = 0 ; i < n ; i++) if (v[i]) buffer_puts(buffer_2, v[i]) ; buffer_putflush(buffer_2, "\n", 1) ; errno = e ; } skalibs-2.14.1.1/src/libstddjb/strerr_warnvsys.c000066400000000000000000000006531455624754300216020ustar00rootroot00000000000000/* ISC license. */ /* MT-unsafe */ #include #include #include #include void strerr_warnvsys (char const *const *v, unsigned int n) { int e = errno ; for (unsigned int i = 0 ; i < n ; i++) if (v[i]) buffer_puts(buffer_2, v[i]) ; buffer_put(buffer_2, ": ", 2) ; buffer_puts(buffer_2, strerror(e)) ; buffer_putflush(buffer_2, "\n", 1) ; errno = e ; } skalibs-2.14.1.1/src/libstddjb/string_format.c000066400000000000000000000023511455624754300211600ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include int string_format (stralloc *sa, char const *vars, char const *format, char const *const *args) { static unsigned char const tab[2][4] = { "1442", "4833" } ; char class[256] = "3222222222222222222222222222222222222022222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222" ; size_t varlen = strlen(vars) ; size_t base = sa->len ; size_t state = 0 ; int wasnull = !sa->s ; for (; state < varlen ; state++) if (class[(unsigned char)vars[state]] == '2') class[(unsigned char)vars[state]] = '1' ; else return (errno = EINVAL, 0) ; for (state = 0 ; state < 2 ; format++) { unsigned char c = tab[state][class[(unsigned char)(*format)] - '0'] ; state = c & 3 ; if (c & 4) if (!stralloc_catb(sa, format, 1)) goto err ; if (c & 8) if (!stralloc_cats(sa, args[byte_chr(vars, varlen, *format)])) goto err ; } if (state == 2) return 1 ; errno = EINVAL ; err: if (wasnull) stralloc_free(sa) ; else sa->len = base ; return 0 ; } skalibs-2.14.1.1/src/libstddjb/string_quote.c000066400000000000000000000007251455624754300210300ustar00rootroot00000000000000/* ISC license. */ #include #include int string_quote_options (stralloc *sa, char const *s, size_t len, uint32_t options) { size_t base = sa->len ; int wasnull = !sa->s ; if (!stralloc_catb(sa, "\"", 1)) return 0 ; if (!string_quote_nodelim_mustquote_options(sa, s, len, "\"", 1, options) || !stralloc_catb(sa, "\"", 1)) { if (wasnull) stralloc_free(sa) ; else sa->len = base ; return 0 ; } return 1 ; } skalibs-2.14.1.1/src/libstddjb/string_quote_nodelim_mustquote.c000066400000000000000000000034631455624754300246670ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include int string_quote_nodelim_mustquote_options (stralloc *sa, char const *s, size_t len, char const *delim, size_t delimlen, uint32_t options) { char class[256] = "dddddddaaaaaaaddddddddddddddddddcccccccccccccccceeeeeeeeeeccccccccccccccccccccccccccccccccccbcccceeeeeecccccccecccececececcccccddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd" ; size_t base = sa->len ; size_t i = 0 ; int wasnull = !sa->s ; if (options & 1) class[' '] = 'f' ; for (; i < delimlen ; i++) if (class[(uint8_t)delim[i]] == 'c' || class[(uint8_t)delim[i]] == 'b') class[(uint8_t)delim[i]] = 'b' ; else return (errno = EINVAL, 0) ; for (i = 0 ; i < len ; i++) { switch (class[(unsigned char)s[i]]) { case 'a' : { static char const tab[7] = "abtnvfr" ; char fmt[2] = "\\" ; fmt[1] = tab[s[i] - 7] ; if (!stralloc_catb(sa, fmt, 2)) goto err ; break ; } case 'b' : { char fmt[2] = "\\" ; fmt[1] = s[i] ; if (!stralloc_catb(sa, fmt, 2)) goto err ; break ; } case 'c' : case 'e' : if (!stralloc_catb(sa, s+i, 1)) goto err ; break ; case 'd' : { char fmt[5] = "\\0x" ; ucharn_fmt(fmt+3, s+i, 1) ; if (!stralloc_catb(sa, fmt, 5)) goto err ; break ; } case 'f' : if (!stralloc_catb(sa, "\\s", 2)) goto err ; break ; default : errno = EFAULT ; goto err ; /* can't happen */ } } return 1 ; err: if (wasnull) stralloc_free(sa) ; else sa->len = base ; return 0 ; } skalibs-2.14.1.1/src/libstddjb/string_unquote.c000066400000000000000000000007441455624754300213740ustar00rootroot00000000000000/* ISC license. */ #include #include #include int string_unquote (char *d, size_t *w, char const *s, size_t len, size_t *r) { if (!len-- || (*s++ != '"')) return (errno = EINVAL, 0) ; { size_t rr, ww ; char tmp[len ? len : 1] ; if (!string_unquote_withdelim(tmp, &ww, s, len, &rr, "\"", 1)) return 0 ; if (rr == len) return (errno = EPIPE, 0) ; memcpy(d, tmp, ww) ; *w = ww ; *r = rr + 2 ; } return 1 ; } skalibs-2.14.1.1/src/libstddjb/string_unquote_nodelim.c000066400000000000000000000003761455624754300231040ustar00rootroot00000000000000/* ISC license. */ #include #include ssize_t string_unquote_nodelim (char *d, char const *s, size_t len) { size_t rr, ww ; if (!string_unquote_withdelim(d, &ww, s, len, &rr, 0, 0)) return -1 ; return (ssize_t)ww ; } skalibs-2.14.1.1/src/libstddjb/string_unquote_withdelim.c000066400000000000000000000043771455624754300234500ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #define PUSH0 0x40 #define PUSH 0x20 #define PUSHSPEC 0x10 #define STORE 0x08 #define CALC 0x04 #define SYNTAXERROR 0x02 #define BROKENPIPE 0x01 int string_unquote_withdelim (char *d, size_t *w, char const *s, size_t len, size_t *r, char const *delim, size_t delimlen) { static unsigned char const actions[5][9] = { { 0, 0, PUSH, PUSH, PUSH, PUSH, PUSH, PUSH, 0 }, { PUSH, PUSH, 0, PUSH, PUSHSPEC, PUSH, PUSHSPEC, PUSH, BROKENPIPE }, { PUSH0, PUSH0, PUSH0|PUSH, 0, PUSH0|PUSH, PUSH0|PUSH, PUSH0|PUSH, PUSH0|PUSH, PUSH0 }, { SYNTAXERROR, SYNTAXERROR, STORE, SYNTAXERROR, STORE, STORE, SYNTAXERROR, SYNTAXERROR, BROKENPIPE }, { SYNTAXERROR, SYNTAXERROR, CALC, SYNTAXERROR, CALC, CALC, SYNTAXERROR, SYNTAXERROR, BROKENPIPE } } ; static unsigned char const states[5][9] = { { 1, 5, 0, 0, 0, 0, 0, 0, 5 }, { 0, 0, 2, 0, 0, 0, 0, 0, 6 }, { 1, 5, 0, 3, 0, 0, 0, 0, 5 }, { 6, 6, 4, 6, 4, 4, 6, 6, 6 }, { 6, 6, 0, 6, 0, 0, 6, 6, 6 } } ; unsigned char class[256] = "7777777777777777777777777777777777777777777777772555555555777777777777777777777777777777777707777445554777777767776667673777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777" ; size_t i = 0 ; unsigned char store = 0 ; unsigned char state = 0 ; for (; i < delimlen ; i++) if (class[(unsigned char)delim[i]] == '7') class[(unsigned char)delim[i]] = '1' ; else return (errno = EINVAL, 0) ; *w = 0 ; for (i = 0 ; state < 5 ; i++) { unsigned char c = i < len ? class[(unsigned char)s[i]] - '0' : 8 ; unsigned char action = actions[state][c] ; state = states[state][c] ; if (action & PUSH0) d[(*w)++] = 0 ; if (action & PUSH) d[(*w)++] = s[i] ; if (action & PUSHSPEC) d[(*w)++] = s[i] == 's' ? ' ' : 7 + byte_chr("abtnvfr", 7, s[i]) ; if (action & STORE) store = fmtscan_num(s[i], 16) << 4 ; if (action & CALC) d[(*w)++] = store | fmtscan_num(s[i], 16) ; if (action & SYNTAXERROR) errno = EPROTO ; if (action & BROKENPIPE) errno = EPIPE ; } *r = i - 1 ; return (state == 5) ; } skalibs-2.14.1.1/src/libstddjb/strn_fmt.c000066400000000000000000000007151455624754300201400ustar00rootroot00000000000000/* ISC license. */ #include #include size_t strn_fmt (char *blah, char const *s, size_t len) { char *d = blah ; size_t i ; for (i = 0 ; i < len ; i++) if ((s[i] >= 32) && ((unsigned char)s[i] < 127)) *d++ = s[i] ; else { *d++ = '\\' ; *d++ = '0' ; *d++ = 'x' ; if ((unsigned char)s[i] < 16) *d++ = '0' ; d += uint_xfmt(d, (unsigned char)s[i]) ; } return d - blah ; } skalibs-2.14.1.1/src/libstddjb/subgetopt.c000066400000000000000000000024201455624754300203130ustar00rootroot00000000000000/* ISC license. */ #undef SUBGETOPT_SHORT #include int subgetopt_r (int argc, char const *const *argv, char const *opts, subgetopt *o) { o->arg = 0 ; if ((o->ind >= argc) || !argv[o->ind]) return -1 ; if (o->pos && !argv[o->ind][o->pos]) { o->ind++ ; o->pos = 0 ; if ((o->ind >= argc) || !argv[o->ind]) return -1 ; } if (!o->pos) { char c ; if (argv[o->ind][0] != '-') return -1 ; o->pos++ ; c = argv[o->ind][1] ; if (c == '-') { if (argv[o->ind][2]) return o->problem = '-', '?' ; o->ind++ ; o->pos = 0 ; return -1 ; } if (!c || c == '-') return o->pos = 0, -1 ; } { char c = argv[o->ind][o->pos++] ; char const *s = opts ; char retnoarg = (*s == ':') ? (s++, ':') : '?' ; while (*s) { if (c == *s) { if (s[1] == ':') { o->arg = argv[o->ind++] + o->pos ; o->pos = 0 ; if (!*o->arg) { o->arg = argv[o->ind] ; if ((o->ind >= argc) || !o->arg) { o->problem = c ; return retnoarg ; } o->ind++ ; } } return c ; } if (*++s == ':') s++ ; } o->problem = c ; } return '?' ; } skalibs-2.14.1.1/src/libstddjb/subgetopt_here.c000066400000000000000000000001571455624754300213230ustar00rootroot00000000000000/* ISC license. */ /* MT-unsafe */ #include subgetopt subgetopt_here = SUBGETOPT_ZERO ; skalibs-2.14.1.1/src/libstddjb/sysclock_from_localtm.c000066400000000000000000000004411455624754300226700ustar00rootroot00000000000000/* ISC license. */ #include #include #include int sysclock_from_localtm (uint64_t *uu, struct tm const *l) { uint64_t u ; if (!ltm64_from_localtm(&u, l)) return 0 ; if (!sysclock_from_ltm64(&u)) return 0 ; *uu = u ; return 1 ; } skalibs-2.14.1.1/src/libstddjb/sysclock_from_localtmn.c000066400000000000000000000003151455624754300230460ustar00rootroot00000000000000/* ISC license. */ #include int sysclock_from_localtmn (tain *a, localtmn const *l) { if (!sysclock_from_localtm(&a->sec.x, &l->tm)) return 0 ; a->nano = l->nano ; return 1 ; } skalibs-2.14.1.1/src/libstddjb/sysclock_from_ltm64.c000066400000000000000000000005421455624754300222050ustar00rootroot00000000000000/* ISC license. */ #include #include #include #ifdef SKALIBS_FLAG_CLOCKISTAI int sysclock_from_ltm64 (uint64_t *u) { tai t ; if (!tai_from_ltm64(&t, *u)) return 0 ; *u = t.x - 10U ; return 1 ; } #else int sysclock_from_ltm64 (uint64_t *u) { return utc_from_sysclock(u) ; } #endif skalibs-2.14.1.1/src/libstddjb/sysclock_from_tai.c000066400000000000000000000006051455624754300220140ustar00rootroot00000000000000/* ISC license. */ #include #include #include #ifdef SKALIBS_FLAG_CLOCKISTAI int sysclock_from_tai (uint64_t *u, tai const *t) { if (t->x < 10U) return (errno = EINVAL, 0) ; *u = t->x - 10U ; return 1 ; } #else #include int sysclock_from_tai (uint64_t *u, tai const *t) { return utc_from_tai(u, t) ; } #endif skalibs-2.14.1.1/src/libstddjb/sysclock_from_tain.c000066400000000000000000000002771455624754300221770ustar00rootroot00000000000000 /* ISC license. */ #include int sysclock_from_tain (tain *u, tain const *t) { if (!sysclock_from_tai(&u->sec.x, &t->sec)) return 0 ; u->nano = t->nano ; return 1 ; } skalibs-2.14.1.1/src/libstddjb/sysclock_from_utc.c000066400000000000000000000006241455624754300220330ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #ifdef SKALIBS_FLAG_CLOCKISTAI int sysclock_from_utc (uint64_t *u) { tai t ; if (!tai_from_utc(&t, *u)) return 0 ; if (t.x < 10) return (errno = EINVAL, 0) ; *u = t.x - 10 ; return 1 ; } #else int sysclock_from_utc (uint64_t *u) { (void)u ; return 1 ; } #endif skalibs-2.14.1.1/src/libstddjb/sysclock_get.c000066400000000000000000000011161455624754300207710ustar00rootroot00000000000000/* ISC license. */ #include #include #ifdef SKALIBS_HASCLOCKRT #include int sysclock_get (tain *a) { tain aa ; struct timespec now ; if (clock_gettime(CLOCK_REALTIME, &now) < 0) return 0 ; if (!tain_from_timespec(&aa, &now)) return 0 ; tain_add(a, &aa, &tain_nano500) ; return 1 ; } #else #include int sysclock_get (tain *a) { tain aa ; struct timeval now ; if (gettimeofday(&now, 0) < 0) return 0 ; if (!tain_from_timeval(&aa, &now)) return 0 ; tain_add(a, &aa, &tain_nano500) ; return 1 ; } #endif skalibs-2.14.1.1/src/libstddjb/sysclock_set.c000066400000000000000000000014621455624754300210110ustar00rootroot00000000000000/* ISC license. */ /* MT-unsafe */ #include #ifdef SKALIBS_HASCLOCKRT #include #include int sysclock_set (tain const *a) { struct timespec now ; tain aa ; tain_add(&aa, a, &tain_nano500) ; if (!timespec_from_tain(&now, &aa)) return 0 ; if (clock_settime(CLOCK_REALTIME, &now) < 0) return 0 ; return 1 ; } #else #ifdef SKALIBS_HASSETTIMEOFDAY #include #include #include int sysclock_set (tain const *a) { struct timeval now ; tain aa ; tain_add(&aa, a, &tain_nano500) ; if (!timeval_from_tain(&now, &aa)) return 0 ; if (settimeofday(&now, 0) < 0) return 0 ; return 1 ; } #else #error "neither clockrt nor settimeofday sysdeps are present. How do your set your system clock?" #endif #endif skalibs-2.14.1.1/src/libstddjb/tai_add.c000066400000000000000000000002071455624754300176650ustar00rootroot00000000000000/* ISC license. */ #include int tai_add (tai *t, tai const *u, tai const *v) { t->x = u->x + v->x ; return 1 ; } skalibs-2.14.1.1/src/libstddjb/tai_from_localtm.c000066400000000000000000000003621455624754300216150ustar00rootroot00000000000000/* ISC license. */ #include #include #include int tai_from_localtm (tai *t, struct tm const *l) { uint64_t u ; if (!ltm64_from_localtm(&u, l)) return 0 ; return tai_from_ltm64(t, u) ; } skalibs-2.14.1.1/src/libstddjb/tai_from_ltm64.c000066400000000000000000000004171455624754300211310ustar00rootroot00000000000000/* ISC license. */ #include #include "djbtime-internal.h" int tai_from_ltm64 (tai *t, uint64_t u) { switch (skalibs_tzisright()) { case 1 : return tai_u64(t, u + 10U) ; case 0 : return tai_from_utc(t, u) ; default : return 0 ; } } skalibs-2.14.1.1/src/libstddjb/tai_from_sysclock.c000066400000000000000000000005171455624754300220160ustar00rootroot00000000000000/* ISC license. */ #include #include #include #ifdef SKALIBS_FLAG_CLOCKISTAI int tai_from_sysclock (tai *t, uint64_t u) { return tai_u64(t, u + 10U) ; } #else #include int tai_from_sysclock (tai *t, uint64_t u) { return tai_from_utc(t, u) ; } #endif skalibs-2.14.1.1/src/libstddjb/tai_from_utc.c000066400000000000000000000003111455624754300207470ustar00rootroot00000000000000/* ISC license. */ #include #include #include "djbtime-internal.h" int tai_from_utc (tai *t, uint64_t u) { leapsecs_add(&u, 0) ; return tai_u64(t, u + 10) ; } skalibs-2.14.1.1/src/libstddjb/tai_now.c000066400000000000000000000003131455624754300177360ustar00rootroot00000000000000/* ISC license. */ /* MT-unsafe */ #include #include int tai_now (tai *t) { time_t u = time(0) ; if (u == (time_t)-1) return 0 ; return tai_from_time_sysclock(t, u) ; } skalibs-2.14.1.1/src/libstddjb/tai_pack.c000066400000000000000000000002271455624754300200550ustar00rootroot00000000000000/* ISC license. */ #include #include void tai_pack (char *s, tai const *t) { uint64_pack_big(s, tai_sec(t)) ; } skalibs-2.14.1.1/src/libstddjb/tai_pack_little.c000066400000000000000000000002321455624754300214260ustar00rootroot00000000000000/* ISC license. */ #include #include void tai_pack_little (char *s, tai const *t) { uint64_pack(s, tai_sec(t)) ; } skalibs-2.14.1.1/src/libstddjb/tai_sub.c000066400000000000000000000002071455624754300177260ustar00rootroot00000000000000/* ISC license. */ #include int tai_sub (tai *t, tai const *u, tai const *v) { t->x = u->x - v->x ; return 1 ; } skalibs-2.14.1.1/src/libstddjb/tai_u64.c000066400000000000000000000003751455624754300175610ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include int tai_u64 (tai *t, uint64_t u) { if (u & ((uint64_t)1 << 63)) return (errno = EOVERFLOW, 0) ; t->x = u ; return 1 ; } skalibs-2.14.1.1/src/libstddjb/tai_unpack.c000066400000000000000000000002261455624754300204170ustar00rootroot00000000000000/* ISC license. */ #include #include void tai_unpack (char const *s, tai *t) { uint64_unpack_big(s, &t->x) ; } skalibs-2.14.1.1/src/libstddjb/tai_unpack_little.c000066400000000000000000000002311455624754300217700ustar00rootroot00000000000000/* ISC license. */ #include #include void tai_unpack_little (char const *s, tai *t) { uint64_unpack(s, &t->x) ; } skalibs-2.14.1.1/src/libstddjb/tain_add.c000066400000000000000000000004111455624754300200400ustar00rootroot00000000000000/* ISC license. */ #include int tain_add (tain *t, tain const *u, tain const *v) { t->sec.x = u->sec.x + v->sec.x ; t->nano = u->nano + v->nano ; if (t->nano > 999999999U) { t->sec.x++ ; t->nano -= 1000000000U ; } return 1 ; } skalibs-2.14.1.1/src/libstddjb/tain_addsec.c000066400000000000000000000005251455624754300205410ustar00rootroot00000000000000/* ISC license. */ #include #include int tain_addsec (tain *b, tain const *a, int c) { if (c >= 0) { tai t = { .x = (uint64_t)c } ; tai_add(&b->sec, &a->sec, &t) ; } else { tai t = { .x = (uint64_t)-c } ; tai_sub(&b->sec, &a->sec, &t) ; } b->nano = a->nano ; return 1 ; } skalibs-2.14.1.1/src/libstddjb/tain_approx.c000066400000000000000000000002031455624754300206200ustar00rootroot00000000000000/* ISC license. */ #include double tain_approx (tain const *t) { return tai_approx(&t->sec) + tain_frac(t) ; } skalibs-2.14.1.1/src/libstddjb/tain_earliest1.c000066400000000000000000000002001455624754300211750ustar00rootroot00000000000000/* ISC license. */ #include void tain_earliest1 (tain *t, tain const *u) { if (tain_less(u, t)) *t = *u ; } skalibs-2.14.1.1/src/libstddjb/tain_earliestv.c000066400000000000000000000003101455624754300213040ustar00rootroot00000000000000/* ISC license. */ #include void tain_earliestv (tain *t, tain const *const *v, unsigned int n) { for (unsigned int i = 0 ; i < n ; i++) if (tain_less(v[i], t)) *t = *v[i] ; } skalibs-2.14.1.1/src/libstddjb/tain_fmt.c000066400000000000000000000003221455624754300200770ustar00rootroot00000000000000/* ISC license. */ #include #include size_t tain_fmt (char *s, tain const *a) { char pack[TAIN_PACK] ; tain_pack(pack, a) ; return ucharn_fmt(s, pack, TAIN_PACK) ; } skalibs-2.14.1.1/src/libstddjb/tain_frac.c000066400000000000000000000001641455624754300202300ustar00rootroot00000000000000/* ISC license. */ #include double tain_frac (tain const *t) { return t->nano * 0.000000001 ; } skalibs-2.14.1.1/src/libstddjb/tain_from_localtmn.c000066400000000000000000000003261455624754300221510ustar00rootroot00000000000000/* ISC license. */ #include int tain_from_localtmn (tain *a, localtmn const *l) { tai t ; if (!tai_from_localtm(&t, &l->tm)) return 0 ; a->sec = t ; a->nano = l->nano ; return 1 ; } skalibs-2.14.1.1/src/libstddjb/tain_from_millisecs.c000066400000000000000000000004011455624754300223160ustar00rootroot00000000000000/* ISC license. */ #include #include int tain_from_millisecs (tain *a, int millisecs) { if (millisecs < 0) return (errno = EINVAL, 0) ; a->sec.x = millisecs / 1000 ; a->nano = (millisecs % 1000) * 1000000U ; return 1 ; } skalibs-2.14.1.1/src/libstddjb/tain_from_ntp.c000066400000000000000000000006461455624754300211460ustar00rootroot00000000000000/* ISC license. */ #include #include #include int tain_from_ntp (tain *a, uint64_t u) { tai secs = { .x = u >> 32 } ; if (secs.x <= 0x7FFFFFFFUL) secs.x |= ((uint64_t)1 << 32) ; secs.x += TAI_MAGIC ; secs.x -= NTP_OFFSET ; if (!tai_from_utc(&secs, secs.x)) return 0 ; a->sec = secs ; a->nano = ((u & 0xFFFFFFFFUL) * 1000000000) >> 32 ; return 1 ; } skalibs-2.14.1.1/src/libstddjb/tain_from_sysclock.c000066400000000000000000000002751455624754300221750ustar00rootroot00000000000000/* ISC license. */ #include int tain_from_sysclock (tain *a, tain const *u) { if (!tai_from_sysclock(&a->sec, u->sec.x)) return 0 ; a->nano = u->nano ; return 1 ; } skalibs-2.14.1.1/src/libstddjb/tain_from_timespec.c000066400000000000000000000003351455624754300221510ustar00rootroot00000000000000/* ISC license. */ #include #include int tain_from_timespec (tain *t, struct timespec const *ts) { if (!tai_from_time(&t->sec, ts->tv_sec)) return 0 ; t->nano = ts->tv_nsec ; return 1 ; } skalibs-2.14.1.1/src/libstddjb/tain_from_timespec_sysclock.c000066400000000000000000000003571455624754300240670ustar00rootroot00000000000000/* ISC license. */ #include #include int tain_from_timespec_sysclock (tain *t, struct timespec const *ts) { if (!tai_from_time_sysclock(&t->sec, ts->tv_sec)) return 0 ; t->nano = ts->tv_nsec ; return 1 ; } skalibs-2.14.1.1/src/libstddjb/tain_from_timeval.c000066400000000000000000000003461455624754300220030ustar00rootroot00000000000000/* ISC license. */ #include #include int tain_from_timeval (tain *t, struct timeval const *tv) { if (!tai_from_time(&t->sec, tv->tv_sec)) return 0 ; t->nano = 1000 * tv->tv_usec ; return 1 ; } skalibs-2.14.1.1/src/libstddjb/tain_from_timeval_sysclock.c000066400000000000000000000003701455624754300237120ustar00rootroot00000000000000/* ISC license. */ #include #include int tain_from_timeval_sysclock (tain *t, struct timeval const *tv) { if (!tai_from_time_sysclock(&t->sec, tv->tv_sec)) return 0 ; t->nano = 1000 * tv->tv_usec ; return 1 ; } skalibs-2.14.1.1/src/libstddjb/tain_half.c000066400000000000000000000002761455624754300202330ustar00rootroot00000000000000/* ISC license. */ #include void tain_half (tain *t, tain const *u) { t->nano = u->nano >> 1 ; if (u->sec.x & 1) t->nano += 500000000U ; t->sec.x = u->sec.x >> 1 ; } skalibs-2.14.1.1/src/libstddjb/tain_infinite.c000066400000000000000000000001311455624754300211140ustar00rootroot00000000000000/* ISC license. */ #include tain const tain_infinite = TAIN_INFINITE ; skalibs-2.14.1.1/src/libstddjb/tain_infinite_relative.c000066400000000000000000000001531455624754300230130ustar00rootroot00000000000000/* ISC license. */ #include tain const tain_infinite_relative = TAIN_INFINITE_RELATIVE ; skalibs-2.14.1.1/src/libstddjb/tain_less.c000066400000000000000000000003501455624754300202600ustar00rootroot00000000000000/* ISC license. */ #include int tain_less (tain const *t, tain const *u) { if (tai_sec(&t->sec) < tai_sec(&u->sec)) return 1 ; if (tai_sec(&t->sec) > tai_sec(&u->sec)) return 0 ; return t->nano < u->nano ; } skalibs-2.14.1.1/src/libstddjb/tain_nano500.c000066400000000000000000000001271455624754300204740ustar00rootroot00000000000000/* ISC license. */ #include tain const tain_nano500 = TAIN_NANO500 ; skalibs-2.14.1.1/src/libstddjb/tain_now.c000066400000000000000000000001711455624754300201160ustar00rootroot00000000000000/* ISC license. */ /* MT-unsafe */ #include tain_clockread_func_ref tain_now = &tain_wallclock_read ; skalibs-2.14.1.1/src/libstddjb/tain_now_set_stopwatch.c000066400000000000000000000013711455624754300230700ustar00rootroot00000000000000/* ISC license. */ /* MT-unsafe */ #include #include #if defined(SKALIBS_HASCLOCKRT) && (defined(SKALIBS_HASCLOCKMON) || defined(SKALIBS_HASCLOCKBOOT)) #include #ifdef SKALIBS_HASCLOCKMON # define SKALIBS_STOPWATCH CLOCK_MONOTONIC #else # define SKALIBS_STOPWATCH CLOCK_BOOTTIME #endif static tain offset ; static int tain_now_stopwatch (tain *now) { return tain_stopwatch_read(now, SKALIBS_STOPWATCH, &offset) ; } int tain_now_set_stopwatch (tain *now) { if (!tain_stopwatch_init(now, SKALIBS_STOPWATCH, &offset)) return tain_now_set_wallclock(now) ; tain_now = &tain_now_stopwatch ; return 1 ; } #else int tain_now_set_stopwatch (tain *now) { return tain_now_set_wallclock(now) ; } #endif skalibs-2.14.1.1/src/libstddjb/tain_now_set_wallclock.c000066400000000000000000000002621455624754300230250ustar00rootroot00000000000000/* ISC license. */ /* MT-unsafe */ #include int tain_now_set_wallclock (tain *now) { tain_now = &tain_wallclock_read ; return tain_wallclock_read(now) ; } skalibs-2.14.1.1/src/libstddjb/tain_pack.c000066400000000000000000000002611455624754300202310ustar00rootroot00000000000000/* ISC license. */ #include #include void tain_pack (char *s, tain const *t) { tai_pack(s, &t->sec) ; uint32_pack_big(s+8, t->nano) ; } skalibs-2.14.1.1/src/libstddjb/tain_pack_little.c000066400000000000000000000002731455624754300216110ustar00rootroot00000000000000/* ISC license. */ #include #include void tain_pack_little (char *s, tain const *t) { uint32_pack(s, t->nano) ; tai_pack_little(s+4, &t->sec) ; } skalibs-2.14.1.1/src/libstddjb/tain_relative_from_timespec.c000066400000000000000000000003401455624754300240400ustar00rootroot00000000000000/* ISC license. */ #include #include int tain_relative_from_timespec (tain *a, struct timespec const *ts) { tai_relative_from_time(&a->sec, ts->tv_sec) ; a->nano = ts->tv_nsec ; return 1 ; } skalibs-2.14.1.1/src/libstddjb/tain_relative_from_timeval.c000066400000000000000000000003511455624754300236720ustar00rootroot00000000000000/* ISC license. */ #include #include int tain_relative_from_timeval (tain *a, struct timeval const *tv) { tai_relative_from_time(&a->sec, tv->tv_sec) ; a->nano = 1000 * tv->tv_usec ; return 1 ; } skalibs-2.14.1.1/src/libstddjb/tain_scan.c000066400000000000000000000003561455624754300202440ustar00rootroot00000000000000/* ISC license. */ #include #include size_t tain_scan (char const *s, tain *a) { char pack[TAIN_PACK] ; size_t r = ucharn_scan(s, pack, TAIN_PACK) ; if (r) tain_unpack(pack, a) ; return r ; } skalibs-2.14.1.1/src/libstddjb/tain_setnow.c000066400000000000000000000003331455624754300206320ustar00rootroot00000000000000/* ISC license. */ /* MT-unsafe */ #include int tain_setnow (tain const *a) { tain aa ; if (!sysclock_from_tai(&aa.sec.x, &a->sec)) return 0 ; aa.nano = a->nano ; return sysclock_set(&aa) ; } skalibs-2.14.1.1/src/libstddjb/tain_stopwatch.c000066400000000000000000000020251455624754300213270ustar00rootroot00000000000000/* ISC license. */ #include #include #if defined(SKALIBS_HASCLOCKRT) && (defined(SKALIBS_HASCLOCKMON) || defined(SKALIBS_HASCLOCKBOOT)) #include int tain_stopwatch_init (tain *now, clock_t cl, tain *offset) { tain a, b ; struct timespec ts ; if (clock_gettime(cl, &ts) < 0) return 0 ; if (!tain_from_timespec(&b, &ts)) return 0 ; if (!tain_wallclock_read(&a)) return 0 ; tain_sub(offset, &a, &b) ; *now = a ; return 1 ; } int tain_stopwatch_read (tain *now, clock_t cl, tain const *offset) { struct timespec ts ; if (clock_gettime(cl, &ts) < 0) return 0 ; if (!tain_from_timespec(now, &ts)) return 0 ; tain_add(now, now, offset) ; return 1 ; } #else #include int tain_stopwatch_init (tain *now, clock_t cl, tain *offset) { (void)now ; (void)cl ; (void)offset ; return (errno = ENOSYS, 0) ; } int tain_stopwatch_read (tain *now, clock_t cl, tain const *offset) { (void)now ; (void)cl ; (void)offset ; return (errno = ENOSYS, 0) ; } #endif skalibs-2.14.1.1/src/libstddjb/tain_sub.c000066400000000000000000000004361455624754300201100ustar00rootroot00000000000000/* ISC license. */ #include int tain_sub (tain *t, tain const *u, tain const *v) { tain tt ; tt.sec.x = u->sec.x - v->sec.x ; tt.nano = u->nano - v->nano ; if (tt.nano > u->nano) { tt.sec.x-- ; tt.nano += 1000000000U ; } *t = tt ; return 1 ; } skalibs-2.14.1.1/src/libstddjb/tain_to_millisecs.c000066400000000000000000000004541455624754300220050ustar00rootroot00000000000000/* ISC license. */ #include #include int tain_to_millisecs (tain const *a) { if (a->sec.x > (uint64_t)2147483) return -1 ; if ((a->sec.x == (uint64_t)2147483) && (a->nano > 646000000U)) return -1 ; return a->sec.x * 1000 + (a->nano + 999999) / 1000000U ; } skalibs-2.14.1.1/src/libstddjb/tain_ulong.c000066400000000000000000000002401455624754300204340ustar00rootroot00000000000000/* ISC license. */ #include int tain_ulong (tain *t, unsigned long s) { if (!tai_u64(&t->sec, s)) return 0 ; t->nano = 0 ; return 1 ; } skalibs-2.14.1.1/src/libstddjb/tain_unpack.c000066400000000000000000000002701455624754300205740ustar00rootroot00000000000000/* ISC license. */ #include #include void tain_unpack (char const *s, tain *t) { tai_unpack(s, &t->sec) ; uint32_unpack_big(s+8, &t->nano) ; } skalibs-2.14.1.1/src/libstddjb/tain_unpack_little.c000066400000000000000000000003021455624754300221450ustar00rootroot00000000000000/* ISC license. */ #include #include void tain_unpack_little (char const *s, tain *t) { uint32_unpack(s, &t->nano) ; tai_unpack_little(s+4, &t->sec) ; } skalibs-2.14.1.1/src/libstddjb/tain_wallclock_read.c000066400000000000000000000002531455624754300222620ustar00rootroot00000000000000/* ISC license. */ #include int tain_wallclock_read (tain *a) { tain aa ; if (!sysclock_get(&aa)) return 0 ; return tain_from_sysclock(a, &aa) ; } skalibs-2.14.1.1/src/libstddjb/tain_zero.c000066400000000000000000000001211455624754300202650ustar00rootroot00000000000000/* ISC license. */ #include tain const tain_zero = TAIN_ZERO ; skalibs-2.14.1.1/src/libstddjb/time_from_tai.c000066400000000000000000000006311455624754300211170ustar00rootroot00000000000000 /* ISC license. */ #include #include #include #include #include #include int time_from_tai (time_t *u, tai const *t) { uint64_t uu = t->x - TAI_MAGIC ; #if SKALIBS_SIZEOFTIME < 8 if ((uu >> 32) && (uu >> 32) != 0xffffffffUL) return (errno = EOVERFLOW, 0) ; #endif *u = (time_t)uu ; return 1 ; } skalibs-2.14.1.1/src/libstddjb/time_from_tai_relative.c000066400000000000000000000005511455624754300230130ustar00rootroot00000000000000 /* ISC license. */ #include #include #include #include #include int time_from_tai_relative (time_t *u, tai const *t) { #if SKALIBS_SIZEOFTIME < 8 if ((t->x >> 32) && (t->x >> 32) != 0xffffffffUL) return (errno = EOVERFLOW, 0) ; #endif *u = (time_t)t->x ; return 1 ; } skalibs-2.14.1.1/src/libstddjb/time_sysclock_from_tai.c000066400000000000000000000007171455624754300230360ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include int time_sysclock_from_tai (time_t *u, tai const *t) { uint64_t uu ; if (!sysclock_from_tai(&uu, t)) return 0 ; uu -= TAI_MAGIC ; #if SKALIBS_SIZEOFTIME < 8 if ((uu >> 32) && (uu >> 32) != 0xffffffffUL) return (errno = EOVERFLOW, 0) ; #endif *u = (time_t)uu ; return 1 ; } skalibs-2.14.1.1/src/libstddjb/timespec_cmp.c000066400000000000000000000004561455624754300207560ustar00rootroot00000000000000/* ISC license. */ #include #include int timespec_cmp (struct timespec const *a, struct timespec const *b) { if (a->tv_sec < b->tv_sec) return -1 ; if (a->tv_sec > b->tv_sec) return 1 ; if (a->tv_nsec < b->tv_nsec) return -1 ; return a->tv_nsec > b->tv_nsec ; } skalibs-2.14.1.1/src/libstddjb/timespec_from_tain.c000066400000000000000000000003361455624754300221520ustar00rootroot00000000000000/* ISC license. */ #include #include int timespec_from_tain (struct timespec *ts, tain const *t) { if (!time_from_tai(&ts->tv_sec, &t->sec)) return 0 ; ts->tv_nsec = t->nano ; return 1 ; } skalibs-2.14.1.1/src/libstddjb/timespec_from_tain_relative.c000066400000000000000000000003601455624754300240420ustar00rootroot00000000000000/* ISC license. */ #include #include int timespec_from_tain_relative (struct timespec *ts, tain const *t) { if (!time_from_tai_relative(&ts->tv_sec, &t->sec)) return 0 ; ts->tv_nsec = t->nano ; return 1 ; } skalibs-2.14.1.1/src/libstddjb/timespec_sysclock_from_tain.c000066400000000000000000000003601455624754300240610ustar00rootroot00000000000000/* ISC license. */ #include #include int timespec_sysclock_from_tain (struct timespec *ts, tain const *t) { if (!time_sysclock_from_tai(&ts->tv_sec, &t->sec)) return 0 ; ts->tv_nsec = t->nano ; return 1 ; } skalibs-2.14.1.1/src/libstddjb/timestamp.c000066400000000000000000000001671455624754300203100ustar00rootroot00000000000000/* ISC license. */ #include int timestamp (char *s) { tain now ; return timestamp_r(s, &now) ; } skalibs-2.14.1.1/src/libstddjb/timestamp_fmt.c000066400000000000000000000002151455624754300211500ustar00rootroot00000000000000/* ISC license. */ #include size_t timestamp_fmt (char *s, tain const *a) { *s = '@' ; return 1 + tain_fmt(s+1, a) ; } skalibs-2.14.1.1/src/libstddjb/timestamp_r.c000066400000000000000000000002601455624754300206230ustar00rootroot00000000000000/* ISC license. */ #include int timestamp_r (char *s, tain *stamp) { if (!tain_wallclock_read(stamp)) return 0 ; timestamp_fmt(s, stamp) ; return 1 ; } skalibs-2.14.1.1/src/libstddjb/timestamp_scan.c000066400000000000000000000002731455624754300213120ustar00rootroot00000000000000/* ISC license. */ #include size_t timestamp_scan (char const *s, tain *a) { size_t r ; if (*s != '@') return 0 ; r = tain_scan(s+1, a) ; return r ? r+1 : 0 ; } skalibs-2.14.1.1/src/libstddjb/timeval_from_tain.c000066400000000000000000000003571455624754300220050ustar00rootroot00000000000000/* ISC license. */ #include #include int timeval_from_tain (struct timeval *tv, tain const *t) { if (!time_from_tai(&tv->tv_sec, &t->sec)) return 0 ; tv->tv_usec = (t->nano + 500) / 1000 ; return 1 ; } skalibs-2.14.1.1/src/libstddjb/timeval_from_tain_relative.c000066400000000000000000000004011455624754300236660ustar00rootroot00000000000000/* ISC license. */ #include #include int timeval_from_tain_relative (struct timeval *tv, tain const *t) { if (!time_from_tai_relative(&tv->tv_sec, &t->sec)) return 0 ; tv->tv_usec = (t->nano + 500) / 1000 ; return 1 ; } skalibs-2.14.1.1/src/libstddjb/timeval_sysclock_from_tain.c000066400000000000000000000004011455624754300237050ustar00rootroot00000000000000/* ISC license. */ #include #include int timeval_sysclock_from_tain (struct timeval *tv, tain const *t) { if (!time_sysclock_from_tai(&tv->tv_sec, &t->sec)) return 0 ; tv->tv_usec = (t->nano + 500) / 1000 ; return 1 ; } skalibs-2.14.1.1/src/libstddjb/ucharn_findlen.c000066400000000000000000000002471455624754300212630ustar00rootroot00000000000000/* ISC license. */ #include size_t ucharn_findlen (char const *s) { size_t i = 0 ; while (fmtscan_num(s[i], 16) <= 0xF) i++ ; return i ; } skalibs-2.14.1.1/src/libstddjb/ucharn_fmt.c000066400000000000000000000004431455624754300204300ustar00rootroot00000000000000/* ISC license. */ #include size_t ucharn_fmt (char *s, char const *key, size_t n) { size_t i = 0 ; for (; i < n ; i++) { s[i<<1] = fmtscan_asc((unsigned char)key[i] >> 4) ; s[(i<<1)+1] = fmtscan_asc((unsigned char)key[i] & 0xF) ; } return n << 1 ; } skalibs-2.14.1.1/src/libstddjb/ucharn_fmt_little.c000066400000000000000000000004521455624754300220050ustar00rootroot00000000000000/* ISC license. */ #include size_t ucharn_fmt_little (char *s, char const *key, size_t n) { size_t i = 0 ; for (; i < n ; i++) { s[i<<1] = fmtscan_asc((unsigned char)key[i] & 0xF) ; s[(i<<1)+1] = fmtscan_asc((unsigned char)key[i] >> 4) ; } return n << 1 ; } skalibs-2.14.1.1/src/libstddjb/ucharn_scan.c000066400000000000000000000005431455624754300205670ustar00rootroot00000000000000/* ISC license. */ #include size_t ucharn_scan (char const *s, char *key, size_t n) { size_t i = 0 ; for (; i < n ; i++) { unsigned char c = fmtscan_num(s[2*i], 16) ; if (c > 0xF) return 0 ; key[i] = c << 4 ; c = fmtscan_num(s[2*i+1], 16) ; if (c > 0xF) return 0 ; key[i] += c ; } return n << 1 ; } skalibs-2.14.1.1/src/libstddjb/ucharn_scan_little.c000066400000000000000000000005561455624754300221500ustar00rootroot00000000000000/* ISC license. */ #include size_t ucharn_scan_little (char const *s, char *key, size_t n) { size_t i = 0 ; for (; i < n ; i++) { unsigned char c = fmtscan_num(s[(i<<1)+1], 16) ; if (c > 0xF) return 0 ; key[i] = c << 4 ; c = fmtscan_num(s[i<<1], 16) ; if (c > 0xF) return 0 ; key[i] += c ; } return n << 1 ; } skalibs-2.14.1.1/src/libstddjb/ucspi_get.c000066400000000000000000000006721455624754300202700ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include char const *ucspi_get (char const *s) { char const *x = getenv("PROTO") ; if (x) { size_t len = strlen(s) ; size_t xlen = strlen(x) ; char tmp[len + xlen + 1] ; memcpy(tmp, x, xlen) ; memcpy(tmp + xlen, s, len + 1) ; x = getenv(tmp) ; if (!x) errno = ENOENT ; } else errno = EINVAL ; return x ; } skalibs-2.14.1.1/src/libstddjb/uint160_scan.c000066400000000000000000000001321455624754300205070ustar00rootroot00000000000000/* ISC license. */ #include #include "fmtscan-internal.h" SCANB0(16) skalibs-2.14.1.1/src/libstddjb/uint16_bswap.c000066400000000000000000000001631455624754300206230ustar00rootroot00000000000000/* ISC license. */ #include uint16_t uint16_bswap (uint16_t a) { return UINT16_BSWAP(a) ; } skalibs-2.14.1.1/src/libstddjb/uint16_bswapn.c000066400000000000000000000002301455624754300207740ustar00rootroot00000000000000/* ISC license. */ #include #include void uint16_bswapn (uint16_t *x, size_t n) { while (n--) uint16_bswapp(x++) ; } skalibs-2.14.1.1/src/libstddjb/uint16_bswapp.c000066400000000000000000000001601455624754300210000ustar00rootroot00000000000000/* ISC license. */ #include void uint16_bswapp (uint16_t *x) { *x = uint16_bswap(*x) ; } skalibs-2.14.1.1/src/libstddjb/uint16_fmtlist.c000066400000000000000000000001301455624754300211630ustar00rootroot00000000000000/* ISC license. */ #include #include "fmtscan-internal.h" FMTL(16) skalibs-2.14.1.1/src/libstddjb/uint16_pack.c000066400000000000000000000003001455624754300204160ustar00rootroot00000000000000/* ISC license. */ #include #include #include void uint16_pack (char *s, uint16_t u) { uint16_littlep(&u) ; memcpy(s, &u, sizeof(uint16_t)) ; } skalibs-2.14.1.1/src/libstddjb/uint16_pack_big.c000066400000000000000000000003011455624754300212400ustar00rootroot00000000000000/* ISC license. */ #include #include #include void uint16_pack_big (char *s, uint16_t u) { uint16_bigp(&u) ; memcpy(s, &u, sizeof(uint16_t)) ; } skalibs-2.14.1.1/src/libstddjb/uint16_scan.c000066400000000000000000000004601455624754300204330ustar00rootroot00000000000000/* ISC license. */ #include #include #include "fmtscan-internal.h" size_t uint16_scan_base (char const *s, uint16_t *u, uint8_t base) { uint64_t uu ; size_t pos = uint64_scan_base_max(s, &uu, base, UINT16_MAX) ; if (pos) *u = (uint16_t)uu ; return pos ; } skalibs-2.14.1.1/src/libstddjb/uint16_scanlist.c000066400000000000000000000001311455624754300213220ustar00rootroot00000000000000/* ISC license. */ #include "fmtscan-internal.h" #include SCANL(16) skalibs-2.14.1.1/src/libstddjb/uint16_unpack.c000066400000000000000000000003331455624754300207670ustar00rootroot00000000000000/* ISC license. */ #include #include #include void uint16_unpack (char const *s, uint16_t *u) { uint16_t x ; memcpy(&x, s, sizeof(uint16_t)) ; *u = uint16_little(x) ; } skalibs-2.14.1.1/src/libstddjb/uint16_unpack_big.c000066400000000000000000000003341455624754300216110ustar00rootroot00000000000000/* ISC license. */ #include #include #include void uint16_unpack_big (char const *s, uint16_t *u) { uint16_t x ; memcpy(&x, s, sizeof(uint16_t)) ; *u = uint16_big(x) ; } skalibs-2.14.1.1/src/libstddjb/uint320_scan.c000066400000000000000000000001321455624754300205050ustar00rootroot00000000000000/* ISC license. */ #include #include "fmtscan-internal.h" SCANB0(32) skalibs-2.14.1.1/src/libstddjb/uint32_bswap.c000066400000000000000000000001631455624754300206210ustar00rootroot00000000000000/* ISC license. */ #include uint32_t uint32_bswap (uint32_t a) { return UINT32_BSWAP(a) ; } skalibs-2.14.1.1/src/libstddjb/uint32_bswapn.c000066400000000000000000000002301455624754300207720ustar00rootroot00000000000000/* ISC license. */ #include #include void uint32_bswapn (uint32_t *x, size_t n) { while (n--) uint32_bswapp(x++) ; } skalibs-2.14.1.1/src/libstddjb/uint32_bswapp.c000066400000000000000000000001601455624754300207760ustar00rootroot00000000000000/* ISC license. */ #include void uint32_bswapp (uint32_t *x) { *x = uint32_bswap(*x) ; } skalibs-2.14.1.1/src/libstddjb/uint32_fmtlist.c000066400000000000000000000001301455624754300211610ustar00rootroot00000000000000/* ISC license. */ #include #include "fmtscan-internal.h" FMTL(32) skalibs-2.14.1.1/src/libstddjb/uint32_pack.c000066400000000000000000000003001455624754300204140ustar00rootroot00000000000000/* ISC license. */ #include #include #include void uint32_pack (char *s, uint32_t u) { uint32_littlep(&u) ; memcpy(s, &u, sizeof(uint32_t)) ; } skalibs-2.14.1.1/src/libstddjb/uint32_pack_big.c000066400000000000000000000003011455624754300212360ustar00rootroot00000000000000/* ISC license. */ #include #include #include void uint32_pack_big (char *s, uint32_t u) { uint32_bigp(&u) ; memcpy(s, &u, sizeof(uint32_t)) ; } skalibs-2.14.1.1/src/libstddjb/uint32_scan.c000066400000000000000000000004601455624754300204310ustar00rootroot00000000000000/* ISC license. */ #include #include #include "fmtscan-internal.h" size_t uint32_scan_base (char const *s, uint32_t *u, uint8_t base) { uint64_t uu ; size_t pos = uint64_scan_base_max(s, &uu, base, UINT32_MAX) ; if (pos) *u = (uint32_t)uu ; return pos ; } skalibs-2.14.1.1/src/libstddjb/uint32_scanlist.c000066400000000000000000000001311455624754300213200ustar00rootroot00000000000000/* ISC license. */ #include "fmtscan-internal.h" #include SCANL(32) skalibs-2.14.1.1/src/libstddjb/uint32_unpack.c000066400000000000000000000003331455624754300207650ustar00rootroot00000000000000/* ISC license. */ #include #include #include void uint32_unpack (char const *s, uint32_t *u) { uint32_t x ; memcpy(&x, s, sizeof(uint32_t)) ; *u = uint32_little(x) ; } skalibs-2.14.1.1/src/libstddjb/uint32_unpack_big.c000066400000000000000000000003341455624754300216070ustar00rootroot00000000000000/* ISC license. */ #include #include #include void uint32_unpack_big (char const *s, uint32_t *u) { uint32_t x ; memcpy(&x, s, sizeof(uint32_t)) ; *u = uint32_big(x) ; } skalibs-2.14.1.1/src/libstddjb/uint640_fmt_generic.c000066400000000000000000000006051455624754300220550ustar00rootroot00000000000000/* ISC license. */ #include #include #include size_t uint640_fmt_generic (char *s, uint64_t x, size_t n, uint8_t base) { size_t len = uint64_fmt_generic(0, x, base) ; if (s) { if (len < n) { memset(s, '0', n - len) ; s += n - len ; } uint64_fmt_generic(s, x, base) ; } return len > n ? len : n ; } skalibs-2.14.1.1/src/libstddjb/uint640_scan.c000066400000000000000000000001321455624754300205120ustar00rootroot00000000000000/* ISC license. */ #include #include "fmtscan-internal.h" SCANB0(64) skalibs-2.14.1.1/src/libstddjb/uint640_scan_base_max.c000066400000000000000000000006041455624754300223550ustar00rootroot00000000000000/* ISC license. */ #include #include #include size_t uint640_scan_base_max (char const *s, uint64_t *u, uint8_t base, uint64_t max) { size_t pos = uint64_scan_base_max(s, u, base, max) ; if (!pos) return (errno = EINVAL, 0) ; if (!s[pos]) return pos ; errno = fmtscan_num(s[pos], base) < base ? ERANGE : EINVAL ; return 0 ; } skalibs-2.14.1.1/src/libstddjb/uint64_bswap.c000066400000000000000000000001631455624754300206260ustar00rootroot00000000000000/* ISC license. */ #include uint64_t uint64_bswap (uint64_t a) { return UINT64_BSWAP(a) ; } skalibs-2.14.1.1/src/libstddjb/uint64_bswapn.c000066400000000000000000000002301455624754300207770ustar00rootroot00000000000000/* ISC license. */ #include #include void uint64_bswapn (uint64_t *x, size_t n) { while (n--) uint64_bswapp(x++) ; } skalibs-2.14.1.1/src/libstddjb/uint64_bswapp.c000066400000000000000000000001601455624754300210030ustar00rootroot00000000000000/* ISC license. */ #include void uint64_bswapp (uint64_t *x) { *x = uint64_bswap(*x) ; } skalibs-2.14.1.1/src/libstddjb/uint64_fmt_generic.c000066400000000000000000000005231455624754300217740ustar00rootroot00000000000000/* ISC license. */ #include #include size_t uint64_fmt_generic (char *s, uint64_t x, uint8_t base) { size_t len = 1 ; uint64_t q = x ; while (q >= base) { len++ ; q /= base ; } if (s) { s += len ; do { *--s = fmtscan_asc(x % base) ; x /= base ; } while (x) ; } return len ; } skalibs-2.14.1.1/src/libstddjb/uint64_fmtlist.c000066400000000000000000000001301455624754300211660ustar00rootroot00000000000000/* ISC license. */ #include #include "fmtscan-internal.h" FMTL(64) skalibs-2.14.1.1/src/libstddjb/uint64_fmtlist_generic.c000066400000000000000000000006051455624754300226710ustar00rootroot00000000000000/* ISC license. */ #include size_t uint64_fmtlist_generic (char *s, void const *tab, size_t n, uint8_t base, uint64_t (*get)(void const *, size_t)) { size_t i = 0, len = 0 ; for (; i < n ; i++) { size_t w = uint64_fmt_generic(s, (*get)(tab, i), base) ; len += w ; if (s) s += w ; if (i < n-1) { len++ ; if (s) *s++ = ',' ; } } return len ; } skalibs-2.14.1.1/src/libstddjb/uint64_pack.c000066400000000000000000000002541455624754300204310ustar00rootroot00000000000000/* ISC license. */ #include #include void uint64_pack (char *s, uint64_t u) { uint64_littlep(&u) ; memcpy(s, &u, sizeof(uint64_t)) ; } skalibs-2.14.1.1/src/libstddjb/uint64_pack_big.c000066400000000000000000000002551455624754300212530ustar00rootroot00000000000000/* ISC license. */ #include #include void uint64_pack_big (char *s, uint64_t u) { uint64_bigp(&u) ; memcpy(s, &u, sizeof(uint64_t)) ; } skalibs-2.14.1.1/src/libstddjb/uint64_scan.c000066400000000000000000000003161455624754300204360ustar00rootroot00000000000000/* ISC license. */ #include #include "fmtscan-internal.h" size_t uint64_scan_base (char const *s, uint64_t *u, uint8_t base) { return uint64_scan_base_max(s, u, base, UINT64_MAX) ; } skalibs-2.14.1.1/src/libstddjb/uint64_scan_base_max.c000066400000000000000000000006321455624754300222760ustar00rootroot00000000000000/* ISC license. */ #include #include size_t uint64_scan_base_max (char const *s, uint64_t *u, uint8_t base, uint64_t max) { uint64_t result = 0 ; size_t pos = 0 ; for (;; pos++) { uint8_t c = fmtscan_num(s[pos], base) ; if (c >= base || result > ((max - c) / base)) break ; result = result * base + c ; } if (pos) *u = result ; return pos ; } skalibs-2.14.1.1/src/libstddjb/uint64_scanlist.c000066400000000000000000000001311455624754300213250ustar00rootroot00000000000000/* ISC license. */ #include "fmtscan-internal.h" #include SCANL(64) skalibs-2.14.1.1/src/libstddjb/uint64_unpack.c000066400000000000000000000003071455624754300207730ustar00rootroot00000000000000/* ISC license. */ #include #include void uint64_unpack (char const *s, uint64_t *u) { uint64_t x ; memcpy(&x, s, sizeof(uint64_t)) ; *u = uint64_little(x) ; } skalibs-2.14.1.1/src/libstddjb/uint64_unpack_big.c000066400000000000000000000003101455624754300216060ustar00rootroot00000000000000/* ISC license. */ #include #include void uint64_unpack_big (char const *s, uint64_t *u) { uint64_t x ; memcpy(&x, s, sizeof(uint64_t)) ; *u = uint64_big(x) ; } skalibs-2.14.1.1/src/libstddjb/uncoe.c000066400000000000000000000003421455624754300174110ustar00rootroot00000000000000/* ISC license. */ #include #include int uncoe (int fd) { int flags = fcntl(fd, F_GETFD, 0) ; return flags < 0 ? flags : flags & FD_CLOEXEC ? fcntl(fd, F_SETFD, flags & ~FD_CLOEXEC) : 0 ; } skalibs-2.14.1.1/src/libstddjb/unsanitize_read.c000066400000000000000000000003651455624754300214710ustar00rootroot00000000000000/* ISC license. */ #include #include #include ssize_t unsanitize_read (ssize_t r) { return r == -1 ? errno == EPIPE ? (errno = 0, 0) : -1 : !r ? (errno = EWOULDBLOCK, -1) : r ; } skalibs-2.14.1.1/src/libstddjb/utc_from_localtm.c000066400000000000000000000003551455624754300216350ustar00rootroot00000000000000/* ISC license. */ #include #include #include int utc_from_localtm (uint64_t *uu, struct tm const *l) { if (!ltm64_from_localtm(uu, l)) return 0 ; utc_from_ltm64(uu) ; return 1 ; } skalibs-2.14.1.1/src/libstddjb/utc_from_ltm64.c000066400000000000000000000003641455624754300211500ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include "djbtime-internal.h" int utc_from_ltm64 (uint64_t *u) { #ifdef SKALIBS_FLAG_CLOCKISTAI leapsecs_sub(u) ; #endif return 1 ; } skalibs-2.14.1.1/src/libstddjb/utc_from_sysclock.c000066400000000000000000000005321455624754300220310ustar00rootroot00000000000000/* ISC license. */ #include #include #include #ifdef SKALIBS_FLAG_CLOCKISTAI #include int utc_from_sysclock (uint64_t *u) { tai t = { .x = *u + 10U } ; return utc_from_tai(u, &t) ; } #else int utc_from_sysclock (uint64_t *u) { (void)u ; return 1 ; } #endif skalibs-2.14.1.1/src/libstddjb/utc_from_tai.c000066400000000000000000000004411455624754300207530ustar00rootroot00000000000000/* ISC license. */ #include #include #include "djbtime-internal.h" int utc_from_tai (uint64_t *u, tai const *t) { int r = 1 ; uint64_t tt = t->x - 10 ; if (t->x < 10U) return (errno = EINVAL, 0) ; r += leapsecs_sub(&tt) ; *u = tt ; return r ; } skalibs-2.14.1.1/src/libstddjb/vbaprintf.c000066400000000000000000000010101455624754300202640ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include int vbaprintf (bufalloc *ba, char const *format, va_list args) { int r ; { va_list ugly ; va_copy(ugly, args) ; r = vsnprintf(0, 0, format, ugly) ; va_end(ugly) ; } if (r < 0) return r ; if (!stralloc_readyplus(&ba->x, r + 1)) return -1 ; r = vsnprintf(ba->x.s + ba->x.len, r + 1, format, args) ; if (r > 0) ba->x.len += r ; return r ; } skalibs-2.14.1.1/src/libstddjb/vbprintf.c000066400000000000000000000007471455624754300201430ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include int vbprintf (buffer *b, char const *format, va_list args) { int r ; { va_list ugly ; va_copy(ugly, args) ; r = vsnprintf(0, 0, format, ugly) ; va_end(ugly) ; } if (r < 0) return r ; { char buf[r+1] ; r = vsnprintf(buf, r + 1, format, args) ; if (r < 0) return r ; if (buffer_put(b, buf, r) < r) return -1 ; } return r ; } skalibs-2.14.1.1/src/libstddjb/wait_nointr.c000066400000000000000000000003431455624754300206360ustar00rootroot00000000000000/* ISC license. */ #include #include #include pid_t wait_nointr (int *wstat) { pid_t r ; do r = wait(wstat) ; while ((r == (pid_t)-1) && (errno == EINTR)) ; return r ; } skalibs-2.14.1.1/src/libstddjb/wait_pid_nohang.c000066400000000000000000000004241455624754300214330ustar00rootroot00000000000000/* ISC license. */ #include #include pid_t wait_pid_nohang (pid_t pid, int *wstat) { int w = 0 ; pid_t r = 0 ; while (r != pid) { r = wait_nohang(&w) ; if (!r || (r == (pid_t)-1)) return r ; } *wstat = w ; return r ; } skalibs-2.14.1.1/src/libstddjb/wait_pids_nohang.c000066400000000000000000000006541455624754300216230ustar00rootroot00000000000000/* ISC license. */ #include #include int wait_pids_nohang (pid_t const *pids, unsigned int len, int *wstat) { for (;;) { int w ; pid_t r = wait_nohang(&w) ; if (!r || (r == (pid_t)-1)) return (int)r ; { unsigned int i = 0 ; for (; i < len ; i++) if (r == pids[i]) break ; if (i < len) { *wstat = w ; return 1+i ; } } } } skalibs-2.14.1.1/src/libstddjb/wait_reap.c000066400000000000000000000002521455624754300202530ustar00rootroot00000000000000/* ISC license. */ #include unsigned int wait_reap () { unsigned int n = 0 ; int wstat ; while (wait_nohang(&wstat) > 0) n++ ; return n ; } skalibs-2.14.1.1/src/libstddjb/waitn.c000066400000000000000000000002531455624754300174230ustar00rootroot00000000000000/* ISC license. */ #include #include int waitn (pid_t *pids, unsigned int n) { int dummy ; return waitn_posix(pids, n, &dummy) ; } skalibs-2.14.1.1/src/libstddjb/waitn_posix.c000066400000000000000000000006611455624754300206500ustar00rootroot00000000000000/* ISC license. */ #include #include int waitn_posix (pid_t *pids, unsigned int n, int *w) { pid_t wanted = n ? pids[n-1] : 0 ; while (n) { int wstat ; unsigned int i = 0 ; pid_t pid = wait_nointr(&wstat) ; if (pid < 0) return 0 ; for (; i < n ; i++) if (pid == pids[i]) break ; if (i < n) pids[i] = pids[--n] ; if (pid == wanted) *w = wstat ; } return 1 ; } skalibs-2.14.1.1/src/libstddjb/waitn_reap.c000066400000000000000000000002711455624754300204320ustar00rootroot00000000000000/* ISC license. */ #include #include int waitn_reap (pid_t *pids, unsigned int len) { int dummy ; return waitn_reap_posix(pids, len, &dummy) ; } skalibs-2.14.1.1/src/libstddjb/waitn_reap_posix.c000066400000000000000000000006641455624754300216620ustar00rootroot00000000000000/* ISC license. */ #include #include int waitn_reap_posix (pid_t *pids, unsigned int len, int *w) { pid_t wanted = len ? pids[len-1] : 0 ; unsigned int n = 0 ; while (len) { int wstat ; int r = wait_pids_nohang(pids, len, &wstat) ; if (r < 0) return r ; else if (!r) break ; if (pids[r-1] == wanted) *w = wstat ; pids[r-1] = pids[--len] ; n++ ; } return n ; } skalibs-2.14.1.1/src/libstddjb/waitpid_nointr.c000066400000000000000000000004071455624754300213340ustar00rootroot00000000000000/* ISC license. */ #include #include #include pid_t waitpid_nointr (pid_t pid, int *wstat, int flags) { pid_t r ; do r = waitpid(pid, wstat, flags) ; while ((r == (pid_t)-1) && (errno == EINTR)) ; return r ; } skalibs-2.14.1.1/src/libstddjb/writenclose_unsafe5.c000066400000000000000000000010051455624754300222610ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include int writenclose_unsafe5 (int fd, char const *s, size_t len, devino *devino, unsigned int options) { if (allwrite(fd, s, len) < len) return 0 ; if (options & 1 && fd_sync(fd) == -1 && errno != EINVAL) return 0 ; if (devino) { struct stat st ; if (fstat(fd, &st) == -1) return 0 ; devino->dev = st.st_dev ; devino->ino = st.st_ino ; } fd_close(fd) ; return 1 ; } skalibs-2.14.1.1/src/libstddjb/writevnclose_unsafe5.c000066400000000000000000000011031455624754300224460ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include int writevnclose_unsafe5 (int fd, struct iovec const *v, unsigned int vlen, devino *devino, unsigned int options) { if (allwritev(fd, v, vlen) < siovec_len(v, vlen)) return 0 ; if (options & 1 && fd_sync(fd) == -1 && errno != EINVAL) return 0 ; if (devino) { struct stat st ; if (fstat(fd, &st) == -1) return 0 ; devino->dev = st.st_dev ; devino->ino = st.st_ino ; } fd_close(fd) ; return 1 ; } skalibs-2.14.1.1/src/libunixonacid/000077500000000000000000000000001455624754300170245ustar00rootroot00000000000000skalibs-2.14.1.1/src/libunixonacid/access_at.c000066400000000000000000000020041455624754300211110ustar00rootroot00000000000000/* ISC license. */ #include #ifdef SKALIBS_HASLINKAT #ifndef _ATFILE_SOURCE #define _ATFILE_SOURCE #endif #include #include #include #include int access_at (int dirfd, char const *file, int amode, unsigned int flag) { return faccessat(dirfd, file, amode, flag ? AT_EACCESS : 0) ; } #else #include #include #include #include int access_at (int dirfd, char const *file, int amode, unsigned int flag) { int fdhere ; if (getuid() != geteuid() || getgid() != getegid()) return (errno = ENOSYS, -1) ; (void)flag ; fdhere = openc_read(".") ; if (fdhere < 0) return -1 ; if (fd_chdir(dirfd) < 0) { fd_close(fdhere) ; return -1 ; } if (access(file, amode) < 0) { int e = errno ; fd_chdir(fdhere) ; fd_close(fdhere) ; return (errno = e, -1) ; } fd_chdir(fdhere) ; fd_close(fdhere) ; return 0 ; } #endif skalibs-2.14.1.1/src/libunixonacid/ancil_recv_fd.c000066400000000000000000000030101455624754300217400ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #include #include #include #include union aligner_u { struct cmsghdr cmsghdr ; int i ; } ; int ancil_recv_fd (int sock, char expected_ch) { static int const awesomeflags = #ifdef SKALIBS_HASMSGDONTWAIT MSG_DONTWAIT #else 0 #endif | #ifdef SKALIBS_HASCMSGCLOEXEC MSG_CMSG_CLOEXEC #else 0 #endif ; int fd ; struct cmsghdr *c ; ssize_t r ; char ch ; struct iovec v = { .iov_base = &ch, .iov_len = 1 } ; union aligner_u ancilbuf[1 + (CMSG_SPACE(sizeof(int)) - 1) / sizeof(union aligner_u)] ; struct msghdr msghdr = { .msg_name = 0, .msg_namelen = 0, .msg_iov = &v, .msg_iovlen = 1, .msg_flags = 0, .msg_control = ancilbuf, .msg_controllen = CMSG_SPACE(sizeof(int)) } ; do r = recvmsg(sock, &msghdr, awesomeflags) ; while (r < 0 && errno == EINTR) ; if (r < 0) return r ; if (!r) return (errno = EPIPE, -1) ; c = CMSG_FIRSTHDR(&msghdr) ; if (ch != expected_ch || !c || c->cmsg_level != SOL_SOCKET || c->cmsg_type != SCM_RIGHTS || (size_t)(c->cmsg_len - (CMSG_DATA(c) - (unsigned char *)c)) != sizeof(int)) return (errno = EPROTO, -1) ; memcpy(&fd, CMSG_DATA(c), sizeof(int)) ; #ifndef SKALIBS_HASCMSGCLOEXEC if (coe(fd) < 0) { fd_close(fd) ; return -1 ; } #endif return fd ; } skalibs-2.14.1.1/src/libunixonacid/ancil_send_fd.c000066400000000000000000000017641455624754300217500ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #include union aligner_u { struct cmsghdr cmsghdr ; int i ; } ; int ancil_send_fd (int sock, int fd, char ch) { ssize_t r ; struct iovec v = { .iov_base = &ch, .iov_len = 1 } ; union aligner_u ancilbuf[1 + (CMSG_SPACE(sizeof(int)) - 1) / sizeof(union aligner_u)] ; struct msghdr hdr = { .msg_name = 0, .msg_namelen = 0, .msg_iov = &v, .msg_iovlen = 1, .msg_control = ancilbuf, .msg_controllen = CMSG_SPACE(sizeof(int)) } ; struct cmsghdr *c = CMSG_FIRSTHDR(&hdr) ; memset(hdr.msg_control, 0, hdr.msg_controllen) ; c->cmsg_level = SOL_SOCKET ; c->cmsg_type = SCM_RIGHTS ; c->cmsg_len = CMSG_LEN(sizeof(int)) ; memcpy(CMSG_DATA(c), &fd, sizeof(int)) ; do r = sendmsg(sock, &hdr, MSG_NOSIGNAL) ; while (r < 0 && errno == EINTR) ; if (r <= 0) return 0 ; return 1 ; } skalibs-2.14.1.1/src/libunixonacid/atomic_rm_rf.c000066400000000000000000000002641455624754300216330ustar00rootroot00000000000000/* ISC license. */ #include #include int atomic_rm_rf (char const *filename) { return atomic_rm_rf_tmp(filename, &satmp) ; } skalibs-2.14.1.1/src/libunixonacid/atomic_rm_rf_tmp.c000066400000000000000000000014411455624754300225110ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #include int atomic_rm_rf_tmp (char const *filename, stralloc *tmp) { size_t tmpbase = tmp->len ; size_t start ; if (!stralloc_cats(tmp, ".skalibs-rmrf-") || !stralloc_cats(tmp, filename)) return -1 ; start = tmp->len ; for (;;) { if (!random_sauniquename(tmp, 64)) goto err ; if (!stralloc_0(tmp)) goto err ; if (!rename(filename, tmp->s + tmpbase)) break ; if (errno != EEXIST && errno != ENOTEMPTY) goto err ; tmp->len = start ; } if (rm_rf_in_tmp(tmp, tmpbase) < 0) goto err ; tmp->len = tmpbase ; return 0 ; err: tmp->len = tmpbase ; return -1 ; } skalibs-2.14.1.1/src/libunixonacid/atomic_symlink.c000066400000000000000000000016071455624754300222160ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include int atomic_symlink (char const *target, char const *name, char const *suffix) { { int e = errno ; if (symlink(target, name) == 0) return 1 ; if (errno != EEXIST) return 0 ; errno = e ; } { size_t namelen = strlen(name) ; size_t suffixlen = suffix ? strlen(suffix) + 1 : 0 ; char tmp[namelen + suffixlen + 8] ; memcpy(tmp, name, namelen) ; if (suffix) { tmp[namelen] = ':' ; memcpy(tmp + namelen + 1, suffix, suffixlen - 1) ; } memcpy(tmp + namelen + suffixlen, ":XXXXXX", 7) ; tmp[namelen + suffixlen + 7] = 0 ; if (mkltemp(target, tmp) == -1) return 0 ; if (rename(tmp, name) < 0) { unlink_void(tmp) ; return 0 ; } } return 1 ; } skalibs-2.14.1.1/src/libunixonacid/bufalloc_timed_flush.c000066400000000000000000000006431455624754300233450ustar00rootroot00000000000000/* ISC license. */ #include #include #include static int bufalloc_isnonempty (bufalloc *ba) { return !!bufalloc_len(ba) ; } int bufalloc_timed_flush (bufalloc *ba, tain const *deadline, tain *stamp) { return timed_flush(ba, (init_func_ref)&bufalloc_getfd, (init_func_ref)&bufalloc_isnonempty, (init_func_ref)&bufalloc_flush, deadline, stamp) ; } skalibs-2.14.1.1/src/libunixonacid/buffer_timed_fill.c000066400000000000000000000006071455624754300226340ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include static ssize_t get (buffer *b) { return sanitize_read(buffer_fill(b)) ; } ssize_t buffer_timed_fill (buffer *b, tain const *deadline, tain *stamp) { return timed_get(b, (init_func_ref)&buffer_getfd, (get_func_ref)&get, deadline, stamp) ; } skalibs-2.14.1.1/src/libunixonacid/buffer_timed_flush.c000066400000000000000000000006201455624754300230220ustar00rootroot00000000000000/* ISC license. */ #include #include #include static int buffer_isnonempty (buffer *b) { return !buffer_isempty(b) ; } int buffer_timed_flush (buffer *b, tain const *deadline, tain *stamp) { return timed_flush(b, (init_func_ref)&buffer_getfd, (init_func_ref)&buffer_isnonempty, (init_func_ref)&buffer_flush, deadline, stamp) ; } skalibs-2.14.1.1/src/libunixonacid/buffer_timed_get.c000066400000000000000000000011661455624754300224660ustar00rootroot00000000000000/* ISC license. */ #include #include #include struct blah_s { buffer *b ; char *s ; size_t len ; size_t w ; } ; static int getfd (struct blah_s *blah) { return buffer_fd(blah->b) ; } static ssize_t get (struct blah_s *blah) { return buffer_getall(blah->b, blah->s, blah->len, &blah->w) ; } size_t buffer_timed_get (buffer *b, char *s, size_t len, tain const *deadline, tain *stamp) { struct blah_s blah = { .b = b, .s = s, .len = len, .w = 0 } ; timed_get(&blah, (init_func_ref)&getfd, (get_func_ref)&get, deadline, stamp) ; return blah.w ; } skalibs-2.14.1.1/src/libunixonacid/buffer_timed_put.c000066400000000000000000000005621455624754300225160ustar00rootroot00000000000000/* ISC license. */ #include #include #include size_t buffer_timed_put (buffer *b, char const *s, size_t len, tain const *deadline, tain *stamp) { size_t w = 0 ; for (;;) { w += buffer_putnoflush(b, s + w, len - w) ; if (w >= len || !buffer_timed_flush(b, deadline, stamp)) break ; } return w ; } skalibs-2.14.1.1/src/libunixonacid/buffer_timed_puts.c000066400000000000000000000003431455624754300226760ustar00rootroot00000000000000/* ISC license. */ #include #include size_t buffer_timed_puts (buffer *b, char const *s, tain const *deadline, tain *stamp) { return buffer_timed_put(b, s, strlen(s), deadline, stamp) ; } skalibs-2.14.1.1/src/libunixonacid/ipc_timed_recv.c000066400000000000000000000012371455624754300221470ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include struct blah_s { int fd ; char *s ; size_t len ; char *path ; } ; static int getfd (struct blah_s *blah) { return blah->fd ; } static ssize_t get (struct blah_s *blah) { return sanitize_read(ipc_recv(blah->fd, blah->s, blah->len, blah->path)) ; } ssize_t ipc_timed_recv (int fd, char *s, size_t len, char *path, tain const *deadline, tain *stamp) { struct blah_s blah = { .fd = fd, .s = s, .len = len, .path = path } ; return timed_get(&blah, (init_func_ref)&getfd, (get_func_ref)&get, deadline, stamp) ; } skalibs-2.14.1.1/src/libunixonacid/ipc_timed_send.c000066400000000000000000000014421455624754300221370ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #include int ipc_timed_send (int fd, char const *s, size_t len, tain const *deadline, tain *stamp) { iopause_fd x = { .fd = fd, .events = IOPAUSE_WRITE, .revents = 0 } ; for (;;) { int r = iopause_stamp(&x, 1, deadline, stamp) ; if (r < 0) return 0 ; else if (!r) return (errno = ETIMEDOUT, 0) ; else if (x.revents & IOPAUSE_WRITE) { if (send(fd, s, len, MSG_NOSIGNAL) == (ssize_t)len) break ; if (!error_isagain(errno)) return 0 ; } else if (x.revents & IOPAUSE_EXCEPT) return (send(fd, s, len, MSG_NOSIGNAL) == (ssize_t)len) ; } return 1 ; } skalibs-2.14.1.1/src/libunixonacid/ipc_timed_sendv.c000066400000000000000000000020611455624754300223230ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #include #include int ipc_timed_sendv (int fd, struct iovec const *v, unsigned int n, tain const *deadline, tain *stamp) { struct msghdr hdr = { .msg_name = 0, .msg_namelen = 0, .msg_iov = (struct iovec *)v, .msg_iovlen = n, .msg_control = 0, .msg_controllen = 0, .msg_flags = 0 } ; size_t len = siovec_len(v, n) ; iopause_fd x = { .fd = fd, .events = IOPAUSE_WRITE, .revents = 0 } ; for (;;) { int r = iopause_stamp(&x, 1, deadline, stamp) ; if (r < 0) return 0 ; else if (!r) return (errno = ETIMEDOUT, 0) ; else if (x.revents & IOPAUSE_WRITE) { if (sendmsg(fd, &hdr, MSG_NOSIGNAL) == (ssize_t)len) break ; if (!error_isagain(errno)) return 0 ; } else if (x.revents & IOPAUSE_EXCEPT) return (sendmsg(fd, &hdr, MSG_NOSIGNAL) == (ssize_t)len) ; } return 1 ; } skalibs-2.14.1.1/src/libunixonacid/kolbak_call.c000066400000000000000000000005061455624754300214270ustar00rootroot00000000000000/* ISC license. */ #include #include #include int kolbak_call (unixmessage const *m, kolbak_queue *q) { if (q->head == q->tail) return (errno = EILSEQ, 0) ; if (!(*q->x[q->head].f)(m, q->x[q->head].data)) return 0 ; q->head = (q->head + 1) % q->n ; return 1 ; } skalibs-2.14.1.1/src/libunixonacid/kolbak_enqueue.c000066400000000000000000000006151455624754300221640ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include int kolbak_enqueue (kolbak_queue *q, unixmessage_handler_func_ref f, void *data) { size_t newtail = (q->tail + 1) % q->n ; if (newtail == q->head) return (errno = ENOBUFS, 0) ; q->x[q->tail].f = f ; q->x[q->tail].data = data ; q->tail = newtail ; return 1 ; } skalibs-2.14.1.1/src/libunixonacid/kolbak_queue_init.c000066400000000000000000000004051455624754300226610ustar00rootroot00000000000000/* ISC license. */ #include #include int kolbak_queue_init (kolbak_queue *q, kolbak_closure *s, size_t len) { if (len < 2) return (errno = EINVAL, 0) ; q->x = s ; q->n = len ; q->head = 0 ; q->tail = 0 ; return 1 ; } skalibs-2.14.1.1/src/libunixonacid/kolbak_unenqueue.c000066400000000000000000000003361455624754300225270ustar00rootroot00000000000000/* ISC license. */ #include #include int kolbak_unenqueue (kolbak_queue *q) { if (q->head == q->tail) return (errno = EINVAL, 0) ; q->tail = (q->tail + q->n - 1) % q->n ; return 1 ; } skalibs-2.14.1.1/src/libunixonacid/netstring_timed_get.c000066400000000000000000000010651455624754300232300ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include int netstring_timed_get (buffer *b, stralloc *sa, tain const *deadline, tain *stamp) { iopause_fd x = { .fd = buffer_fd(b), .events = IOPAUSE_READ } ; size_t w = 0 ; for (;;) { int r = netstring_get(b, sa, &w) ; if (r > 0) return r ; if (r < 0) return 0 ; r = iopause_stamp(&x, 1, deadline, stamp) ; if (r < 0) return 0 ; else if (!r) return (errno = ETIMEDOUT, 0) ; } } skalibs-2.14.1.1/src/libunixonacid/open2_at.c000066400000000000000000000017601455624754300207030ustar00rootroot00000000000000/* ISC license. */ #include #ifdef SKALIBS_HASOPENAT #ifndef _ATFILE_SOURCE #define _ATFILE_SOURCE #endif #include #include #include #include int open2_at (int dirfd, char const *file, int flags) { int fd ; do fd = openat(dirfd, file, flags) ; while (fd == -1 && errno == EINTR) ; return fd ; } #else #include #include #include #include #include int open2_at (int dirfd, char const *file, int flags) { int fd ; int fdhere = open_read(".") ; if (fdhere < 0) return -1 ; if (fd_chdir(dirfd) < 0) goto errclose ; fd = open2(file, flags) ; if (fd < 0) { int e = errno ; fd_chdir(fdhere) ; errno = e ; goto errclose ; } if (fd_chdir(fdhere) < 0) { fd_close(fd) ; goto errclose ; } fd_close(fdhere) ; return fd ; errclose: fd_close(fdhere) ; return -1 ; } #endif skalibs-2.14.1.1/src/libunixonacid/open3_at.c000066400000000000000000000020421455624754300206760ustar00rootroot00000000000000/* ISC license. */ #include #ifdef SKALIBS_HASOPENAT #ifndef _ATFILE_SOURCE #define _ATFILE_SOURCE #endif #include #include #include #include int open3_at (int dirfd, char const *file, int flags, unsigned int mode) { int fd ; do fd = openat(dirfd, file, flags, mode) ; while (fd == -1 && errno == EINTR) ; return fd ; } #else #include #include #include #include #include int open3_at (int dirfd, char const *file, int flags, unsigned int mode) { int fd ; int fdhere = open_read(".") ; if (fdhere < 0) return -1 ; if (fd_chdir(dirfd) < 0) goto errclose ; fd = open3(file, flags, mode) ; if (fd < 0) { int e = errno ; fd_chdir(fdhere) ; errno = e ; goto errclose ; } if (fd_chdir(fdhere) < 0) { fd_close(fd) ; goto errclose ; } fd_close(fdhere) ; return fd ; errclose: fd_close(fdhere) ; return -1 ; } #endif skalibs-2.14.1.1/src/libunixonacid/open_appendat.c000066400000000000000000000003471455624754300220110ustar00rootroot00000000000000/* ISC license. */ #include #include #include int open_appendat (int fd, char const *name) { return open3_at(fd, name, O_WRONLY | O_NONBLOCK | O_APPEND | O_CREAT, 0666) ; } skalibs-2.14.1.1/src/libunixonacid/open_appendatb.c000066400000000000000000000004501455624754300221460ustar00rootroot00000000000000/* ISC license. */ #include #include int open_appendatb (int dirfd, char const *name) { int fd = open_appendat(dirfd, name) ; if (fd == -1) return -1 ; if (ndelay_off(fd) == -1) { fd_close(fd) ; return -1 ; } return fd ; } skalibs-2.14.1.1/src/libunixonacid/open_readat.c000066400000000000000000000002641455624754300214530ustar00rootroot00000000000000/* ISC license. */ #include #include int open_readat (int fd, char const *name) { return open2_at(fd, name, O_RDONLY | O_NONBLOCK) ; } skalibs-2.14.1.1/src/libunixonacid/open_readatb.c000066400000000000000000000004441455624754300216150ustar00rootroot00000000000000/* ISC license. */ #include #include int open_readatb (int dirfd, char const *name) { int fd = open_readat(dirfd, name) ; if (fd == -1) return -1 ; if (ndelay_off(fd) == -1) { fd_close(fd) ; return -1 ; } return fd ; } skalibs-2.14.1.1/src/libunixonacid/open_truncat.c000066400000000000000000000003171455624754300216720ustar00rootroot00000000000000/* ISC license. */ #include #include int open_truncat (int fd, char const *name) { return open3_at(fd, name, O_WRONLY | O_NONBLOCK | O_TRUNC | O_CREAT, 0666) ; } skalibs-2.14.1.1/src/libunixonacid/open_truncatb.c000066400000000000000000000004461455624754300220370ustar00rootroot00000000000000/* ISC license. */ #include #include int open_truncatb (int dirfd, char const *name) { int fd = open_truncat(dirfd, name) ; if (fd == -1) return -1 ; if (ndelay_off(fd) == -1) { fd_close(fd) ; return -1 ; } return fd ; } skalibs-2.14.1.1/src/libunixonacid/open_writeat.c000066400000000000000000000002651455624754300216730ustar00rootroot00000000000000/* ISC license. */ #include #include int open_writeat (int fd, char const *name) { return open2_at(fd, name, O_WRONLY | O_NONBLOCK) ; } skalibs-2.14.1.1/src/libunixonacid/open_writeatb.c000066400000000000000000000004461455624754300220360ustar00rootroot00000000000000/* ISC license. */ #include #include int open_writeatb (int dirfd, char const *name) { int fd = open_writeat(dirfd, name) ; if (fd == -1) return -1 ; if (ndelay_off(fd) == -1) { fd_close(fd) ; return -1 ; } return fd ; } skalibs-2.14.1.1/src/libunixonacid/openc_appendat.c000066400000000000000000000003651455624754300221540ustar00rootroot00000000000000/* ISC license. */ #include #include #include int openc_appendat (int fd, char const *name) { return open3_at(fd, name, O_WRONLY | O_NONBLOCK | O_APPEND | O_CREAT | O_CLOEXEC, 0666) ; } skalibs-2.14.1.1/src/libunixonacid/openc_appendatb.c000066400000000000000000000004521455624754300223130ustar00rootroot00000000000000/* ISC license. */ #include #include int openc_appendatb (int dirfd, char const *name) { int fd = openc_appendat(dirfd, name) ; if (fd == -1) return -1 ; if (ndelay_off(fd) == -1) { fd_close(fd) ; return -1 ; } return fd ; } skalibs-2.14.1.1/src/libunixonacid/openc_readat.c000066400000000000000000000003021455624754300216070ustar00rootroot00000000000000/* ISC license. */ #include #include int openc_readat (int fd, char const *name) { return open2_at(fd, name, O_RDONLY | O_NONBLOCK | O_CLOEXEC) ; } skalibs-2.14.1.1/src/libunixonacid/openc_readatb.c000066400000000000000000000004461455624754300217620ustar00rootroot00000000000000/* ISC license. */ #include #include int openc_readatb (int dirfd, char const *name) { int fd = openc_readat(dirfd, name) ; if (fd == -1) return -1 ; if (ndelay_off(fd) == -1) { fd_close(fd) ; return -1 ; } return fd ; } skalibs-2.14.1.1/src/libunixonacid/openc_truncat.c000066400000000000000000000003351455624754300220350ustar00rootroot00000000000000/* ISC license. */ #include #include int openc_truncat (int fd, char const *name) { return open3_at(fd, name, O_WRONLY | O_NONBLOCK | O_TRUNC | O_CREAT | O_CLOEXEC, 0666) ; } skalibs-2.14.1.1/src/libunixonacid/openc_truncatb.c000066400000000000000000000004501455624754300221750ustar00rootroot00000000000000/* ISC license. */ #include #include int openc_truncatb (int dirfd, char const *name) { int fd = openc_truncat(dirfd, name) ; if (fd == -1) return -1 ; if (ndelay_off(fd) == -1) { fd_close(fd) ; return -1 ; } return fd ; } skalibs-2.14.1.1/src/libunixonacid/openc_writeat.c000066400000000000000000000003031455624754300220270ustar00rootroot00000000000000/* ISC license. */ #include #include int openc_writeat (int fd, char const *name) { return open2_at(fd, name, O_WRONLY | O_NONBLOCK | O_CLOEXEC) ; } skalibs-2.14.1.1/src/libunixonacid/openc_writeatb.c000066400000000000000000000004501455624754300221740ustar00rootroot00000000000000/* ISC license. */ #include #include int openc_writeatb (int dirfd, char const *name) { int fd = openc_writeat(dirfd, name) ; if (fd == -1) return -1 ; if (ndelay_off(fd) == -1) { fd_close(fd) ; return -1 ; } return fd ; } skalibs-2.14.1.1/src/libunixonacid/opendir_at.c000066400000000000000000000006731455624754300213220ustar00rootroot00000000000000/* ISC license. */ /* Should not be necessary but old NetBSD/OpenBSD fail to properly expose fdopendir() otherwise */ #include #include #include #include DIR *opendir_at (int dfd, char const *name) { DIR *dir ; int fd = openc_readatb(dfd, name) ; if (fd < 0) return 0 ; dir = fdopendir(fd) ; if (!dir) fd_close(fd) ; return dir ; } skalibs-2.14.1.1/src/libunixonacid/opengetlnclose.c000066400000000000000000000007211455624754300222110ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include int opengetlnclose (char const *fn, stralloc *sa, int sep) { char buf[BUFFER_INSIZE] ; buffer b ; int r ; int fd = openc_readb(fn) ; if (fd < 0) return -1 ; buffer_init(&b, &fd_readv, fd, buf, BUFFER_INSIZE) ; r = skagetln(&b, sa, sep) ; fd_close(fd) ; return r ; } skalibs-2.14.1.1/src/libunixonacid/opengetlnclose_at.c000066400000000000000000000007531455624754300227020ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include int opengetlnclose_at (int dirfd, char const *fn, stralloc *sa, int sep) { char buf[BUFFER_INSIZE] ; buffer b ; int r ; int fd = openc_readatb(dirfd, fn) ; if (fd < 0) return -1 ; buffer_init(&b, &buffer_read, fd, buf, BUFFER_INSIZE) ; r = skagetln(&b, sa, sep) ; fd_close(fd) ; return r ; } skalibs-2.14.1.1/src/libunixonacid/openreadnclose_at.c000066400000000000000000000004011455624754300226500ustar00rootroot00000000000000/* ISC license. */ #include #include ssize_t openreadnclose_at (int dirfd, char const *file, char *s, size_t n) { int fd = openc_readatb(dirfd, file) ; return fd == -1 ? -1 : readnclose(fd, s, n) ; } skalibs-2.14.1.1/src/libunixonacid/openslurpclose_at.c000066400000000000000000000004731455624754300227350ustar00rootroot00000000000000/* ISC license. */ #include #include int openslurpclose_at (int dirfd, char const *fn, stralloc *sa) { int fd = openc_readatb(dirfd, fn) ; if (fd < 0) return 0 ; if (!slurp(sa, fd)) { fd_close(fd) ; return 0 ; } fd_close(fd) ; return 1 ; } skalibs-2.14.1.1/src/libunixonacid/openwritenclose_at.c000066400000000000000000000006101455624754300230710ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include size_t openwritenclose_at (int dirfd, char const *file, char const *s, size_t n) { size_t r ; int fd = openc_truncatb(dirfd, file) ; if (fd < 0) return 0 ; r = allwrite(fd, s, n) ; if (r >= n) fsync(fd) ; fd_close(fd) ; return r ; } skalibs-2.14.1.1/src/libunixonacid/openwritevnclose_at.c000066400000000000000000000007301455624754300232620ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include size_t openwritevnclose_at (int dirfd, char const *file, struct iovec const *v, unsigned int n) { size_t r ; int fd = openc_truncatb(dirfd, file) ; if (fd < 0) return 0 ; r = allwritev(fd, v, n) ; if (r >= siovec_len(v, n)) fsync(fd) ; fd_close(fd) ; return r ; } skalibs-2.14.1.1/src/libunixonacid/skaclient-internal.h000066400000000000000000000006651455624754300227730ustar00rootroot00000000000000/* ISC license. */ #ifndef SKACLIENT_INTERNAL_H #define SKACLIENT_INTERNAL_H #include #include #include #include extern int skaclient_init (skaclient *, int, char *, size_t, char *, size_t, char *, size_t, char *, size_t, kolbak_closure *, size_t, char const *, size_t) ; extern int skaclient_start_cb (unixmessage const *, skaclient_cbdata *) ; #endif skalibs-2.14.1.1/src/libunixonacid/skaclient_default_cb.c000066400000000000000000000004751455624754300233230ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include int skaclient_default_cb (unixmessage const *m, void *p) { unsigned char *err = p ; if (m->len != 1 || m->nfds) return (errno = EPROTO, 0) ; *err = m->s[0] ; return 1 ; } skalibs-2.14.1.1/src/libunixonacid/skaclient_end.c000066400000000000000000000010771455624754300220000ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include void skaclient_end (skaclient *a) { fd_close(a->syncout.fd) ; fd_close(a->asyncout.fd) ; unixmessage_sender_free(&a->syncout) ; unixmessage_sender_free(&a->asyncout) ; unixmessage_receiver_free(&a->syncin) ; unixmessage_receiver_free(&a->asyncin) ; if (a->pid && a->options & SKACLIENT_OPTION_WAITPID) { int e = errno ; int wstat ; waitpid_nointr(a->pid, &wstat, 0) ; errno = e ; } *a = skaclient_zero ; } skalibs-2.14.1.1/src/libunixonacid/skaclient_init.c000066400000000000000000000015161455624754300221730ustar00rootroot00000000000000/* ISC license. */ #include #include #include "skaclient-internal.h" int skaclient_init ( skaclient *a, int fd, char *bufss, size_t bufsn, char *auxbufss, size_t auxbufsn, char *bufas, size_t bufan, char *auxbufas, size_t auxbufan, kolbak_closure *q, size_t qlen, char const *before, size_t beforelen) { unixmessage msg = { .s = (char *)before, .len = beforelen, .fds = 0, .nfds = 0 } ; if (!unixmessage_receiver_init(&a->syncin, fd, bufss, bufsn, auxbufss, auxbufsn) || !unixmessage_receiver_init(&a->asyncin, -1, bufas, bufan, auxbufas, auxbufan) || !kolbak_queue_init(&a->kq, q, qlen)) return 0 ; unixmessage_sender_init(&a->syncout, fd) ; unixmessage_sender_init(&a->asyncout, -1) ; if (!unixmessage_put(&a->syncout, &msg)) return 0 ; return 1 ; } skalibs-2.14.1.1/src/libunixonacid/skaclient_put.c000066400000000000000000000004701455624754300220360ustar00rootroot00000000000000/* ISC license. */ #include #include int skaclient_put (skaclient *a, char const *s, size_t len, unixmessage_handler_func *cb, void *result) { unixmessage m = { .s = (char *)s, .len = len, .fds = 0, .nfds = 0 } ; return skaclient_putmsg(a, &m, cb, result) ; } skalibs-2.14.1.1/src/libunixonacid/skaclient_putmsg.c000066400000000000000000000006641455624754300225520ustar00rootroot00000000000000/* ISC license. */ #include #include #include int skaclient_putmsg_and_close (skaclient *a, unixmessage const *m, unsigned char const *bits, unixmessage_handler_func_ref cb, void *result) { if (!kolbak_enqueue(&a->kq, cb, result)) return 0 ; if (!unixmessage_put_and_close(&a->syncout, m, bits)) { kolbak_unenqueue(&a->kq) ; return 0 ; } return 1 ; } skalibs-2.14.1.1/src/libunixonacid/skaclient_putmsgv.c000066400000000000000000000006671455624754300227430ustar00rootroot00000000000000/* ISC license. */ #include #include #include int skaclient_putmsgv_and_close (skaclient *a, unixmessagev const *m, unsigned char const *bits, unixmessage_handler_func_ref cb, void *result) { if (!kolbak_enqueue(&a->kq, cb, result)) return 0 ; if (!unixmessage_putv_and_close(&a->syncout, m, bits)) { kolbak_unenqueue(&a->kq) ; return 0 ; } return 1 ; } skalibs-2.14.1.1/src/libunixonacid/skaclient_putv.c000066400000000000000000000005511455624754300222240ustar00rootroot00000000000000/* ISC license. */ #include #include #include int skaclient_putv (skaclient *a, struct iovec const *v, unsigned int vlen, unixmessage_handler_func *cb, void *result) { unixmessagev m = { .v = (struct iovec *)v, .vlen = vlen, .fds = 0, .nfds = 0 } ; return skaclient_putmsgv(a, &m, cb, result) ; } skalibs-2.14.1.1/src/libunixonacid/skaclient_send.c000066400000000000000000000005561455624754300221640ustar00rootroot00000000000000/* ISC license. */ #include #include int skaclient_send (skaclient *a, char const *s, size_t len, unixmessage_handler_func *cb, void *result, tain const *deadline, tain *stamp) { unixmessage m = { .s = (char *)s, .len = len, .fds = 0, .nfds = 0 } ; return skaclient_sendmsg(a, &m, cb, result, deadline, stamp) ; } skalibs-2.14.1.1/src/libunixonacid/skaclient_sendmsg.c000066400000000000000000000005241455624754300226660ustar00rootroot00000000000000/* ISC license. */ #include int skaclient_sendmsg_and_close (skaclient *a, unixmessage const *m, unsigned char const *bits, unixmessage_handler_func_ref cb, void *result, tain const *deadline, tain *stamp) { return skaclient_putmsg_and_close(a, m, bits, cb, result) && skaclient_syncify(a, deadline, stamp) ; } skalibs-2.14.1.1/src/libunixonacid/skaclient_sendmsgv.c000066400000000000000000000005301455624754300230510ustar00rootroot00000000000000/* ISC license. */ #include int skaclient_sendmsgv_and_close (skaclient *a, unixmessagev const *m, unsigned char const *bits, unixmessage_handler_func_ref cb, void *result, tain const *deadline, tain *stamp) { return skaclient_putmsgv_and_close(a, m, bits, cb, result) && skaclient_syncify(a, deadline, stamp) ; } skalibs-2.14.1.1/src/libunixonacid/skaclient_sendv.c000066400000000000000000000006121455624754300223430ustar00rootroot00000000000000/* ISC license. */ #include #include int skaclient_sendv (skaclient *a, struct iovec const *v, unsigned int vlen, unixmessage_handler_func *cb, void *result, tain const *deadline, tain *stamp) { unixmessagev m = { .v = (struct iovec *)v, .vlen = vlen, .fds = 0, .nfds = 0 } ; return skaclient_sendmsgv(a, &m, cb, result, deadline, stamp) ; } skalibs-2.14.1.1/src/libunixonacid/skaclient_server_ack.c000066400000000000000000000015731455624754300233570ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #include int skaclient_server_ack (unixmessage const *clientmsg, unixmessage_sender *out, unixmessage_sender *asyncout, char const *before, size_t beforelen, char const *after, size_t afterlen) { int fd[2] ; unixmessage m = { .s = (char *)after, .len = afterlen, .fds = fd, .nfds = 1 } ; static unsigned char const bits = 0xff ; if (clientmsg->nfds || clientmsg->len != beforelen || memcmp(clientmsg->s, before, beforelen)) return (errno = EPROTO, 0) ; if (ipc_pair_nbcoe(fd) < 0) return 0 ; unixmessage_sender_init(asyncout, fd[1]) ; if (!unixmessage_put_and_close(out, &m, &bits)) { fd_close(fd[1]) ; fd_close(fd[0]) ; return 0 ; } return 1 ; } skalibs-2.14.1.1/src/libunixonacid/skaclient_server_bidi_ack.c000066400000000000000000000011631455624754300243410ustar00rootroot00000000000000/* ISC license. */ #include #include int skaclient_server_bidi_ack (unixmessage const *clientmsg, unixmessage_sender *out, unixmessage_sender *asyncout, unixmessage_receiver *asyncin, char *mainbuf, size_t mainlen, char *auxbuf, size_t auxlen, char const *before, size_t beforelen, char const *after, size_t afterlen) { if (!unixmessage_receiver_init(asyncin, -1, mainbuf, mainlen, auxbuf, auxlen)) return 0 ; if (!skaclient_server_ack(clientmsg, out, asyncout, before, beforelen, after, afterlen)) return 0 ; asyncin->fd = unixmessage_sender_fd(asyncout) ; return 1 ; } skalibs-2.14.1.1/src/libunixonacid/skaclient_server_init.c000066400000000000000000000011071455624754300235550ustar00rootroot00000000000000/* ISC license. */ #include #include #include int skaclient_server_init (unixmessage_receiver *in, unixmessage_sender *out, unixmessage_sender *asyncout, char const *before, size_t beforelen, char const *after, size_t afterlen, tain const *deadline, tain *stamp) { unixmessage m ; return (sanitize_read(unixmessage_timed_receive(in, &m, deadline, stamp)) >= 0) && skaclient_server_ack(&m, out, asyncout, before, beforelen, after, afterlen) && unixmessage_sender_timed_flush(out, deadline, stamp) ; } skalibs-2.14.1.1/src/libunixonacid/skaclient_start.c000066400000000000000000000021051455624754300223600ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include "skaclient-internal.h" int skaclient_start ( skaclient *a, char *bufss, size_t bufsn, char *auxbufss, size_t auxbufsn, char *bufas, size_t bufan, char *auxbufas, size_t auxbufan, kolbak_closure *q, size_t qlen, char const *path, uint32_t options, char const *before, size_t beforelen, char const *after, size_t afterlen, tain const *deadline, tain *stamp) { skaclient_cbdata blah ; unixmessage m ; int r ; if (!skaclient_start_async(a, bufss, bufsn, auxbufss, auxbufsn, bufas, bufan, auxbufas, auxbufan, q, qlen, path, options, before, beforelen, after, afterlen, &blah)) return 0 ; if (!skaclient_timed_flush(a, deadline, stamp)) { int e = errno ; skaclient_end(a) ; errno = e ; return 0 ; } r = unixmessage_timed_receive(&a->syncin, &m, deadline, stamp) ; if (r < 1) { int e = errno ; if (!r) e = EPIPE ; skaclient_end(a) ; errno = e ; return 0 ; } return kolbak_call(&m, &a->kq) ; } skalibs-2.14.1.1/src/libunixonacid/skaclient_start_async.c000066400000000000000000000022411455624754300235560ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #include #include "skaclient-internal.h" int skaclient_start_async ( skaclient *a, char *bufss, size_t bufsn, char *auxbufss, size_t auxbufsn, char *bufas, size_t bufan, char *auxbufas, size_t auxbufan, kolbak_closure *q, size_t qlen, char const *path, uint32_t options, char const *before, size_t beforelen, char const *after, size_t afterlen, skaclient_cbdata *blah) { int fd = ipc_stream_nbcoe() ; if (fd < 0) return 0 ; if ((!ipc_connect(fd, path) && !error_isalready(errno)) || !skaclient_init(a, fd, bufss, bufsn, auxbufss, auxbufsn, bufas, bufan, auxbufas, auxbufan, q, qlen, before, beforelen)) { fd_close(fd) ; return 0 ; } a->pid = 0 ; a->options = options & ~SKACLIENT_OPTION_WAITPID ; if (!kolbak_enqueue(&a->kq, (unixmessage_handler_func_ref)&skaclient_start_cb, blah)) { skaclient_end(a) ; return 0 ; } blah->a = a ; blah->after = after ; blah->afterlen = afterlen ; return 1 ; } skalibs-2.14.1.1/src/libunixonacid/skaclient_start_cb.c000066400000000000000000000013521455624754300230270ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include "skaclient-internal.h" int skaclient_start_cb (unixmessage const *m, skaclient_cbdata *blah) { if (m->len != blah->afterlen || memcmp(m->s, blah->after, m->len) || m->nfds != 1) { unixmessage_drop(m) ; return (errno = EPROTO, 0) ; } blah->a->asyncin.fd = m->fds[0] ; blah->a->asyncout.fd = m->fds[0] ; if (!(blah->a->options & SKACLIENT_OPTION_ASYNC_ACCEPT_FDS)) unixmessage_receiver_refuse_fds(&blah->a->asyncin) ; if (!(blah->a->options & SKACLIENT_OPTION_SYNC_ACCEPT_FDS)) unixmessage_receiver_refuse_fds(&blah->a->syncin) ; return 1 ; } skalibs-2.14.1.1/src/libunixonacid/skaclient_startf.c000066400000000000000000000022111455624754300225240ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include "skaclient-internal.h" int skaclient_startf ( skaclient *a, char *bufss, size_t bufsn, char *auxbufss, size_t auxbufsn, char *bufas, size_t bufan, char *auxbufas, size_t auxbufan, kolbak_closure *q, size_t qlen, char const *prog, char const *const *argv, char const *const *envp, uint32_t options, char const *before, size_t beforelen, char const *after, size_t afterlen, tain const *deadline, tain *stamp) { skaclient_cbdata blah ; unixmessage m ; int r ; if (!skaclient_startf_async(a, bufss, bufsn, auxbufss, auxbufsn, bufas, bufan, auxbufas, auxbufan, q, qlen, prog, argv, envp, options, before, beforelen, after, afterlen, &blah)) return 0 ; if (!skaclient_timed_flush(a, deadline, stamp)) { int e = errno ; skaclient_end(a) ; errno = e ; return 0 ; } r = unixmessage_timed_receive(&a->syncin, &m, deadline, stamp) ; if (r < 1) { int e = errno ; if (!r) e = EPIPE ; skaclient_end(a) ; errno = e ; return 0 ; } return kolbak_call(&m, &a->kq) ; } skalibs-2.14.1.1/src/libunixonacid/skaclient_startf_async.c000066400000000000000000000025061455624754300237300ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #include "skaclient-internal.h" int skaclient_startf_async ( skaclient *a, char *bufss, size_t bufsn, char *auxbufss, size_t auxbufsn, char *bufas, size_t bufan, char *auxbufas, size_t auxbufan, kolbak_closure *q, size_t qlen, char const *prog, char const *const *argv, char const *const *envp, uint32_t options, char const *before, size_t beforelen, char const *after, size_t afterlen, skaclient_cbdata *blah) { int fd ; pid_t pid = child_spawn1_socket(prog, argv, envp, &fd) ; if (!pid) return 0 ; if (ndelay_on(fd) < 0 || coe(fd) < 0 || !skaclient_init(a, fd, bufss, bufsn, auxbufss, auxbufsn, bufas, bufan, auxbufas, auxbufan, q, qlen, before, beforelen)) { fd_close(fd) ; if (options & SKACLIENT_OPTION_WAITPID) { int e = errno ; int wstat ; waitpid_nointr(a->pid, &wstat, 0) ; errno = e ; } return 0 ; } a->pid = pid ; a->options = options ; if (!kolbak_enqueue(&a->kq, (unixmessage_handler_func_ref)&skaclient_start_cb, blah)) { skaclient_end(a) ; return 0 ; } blah->a = a ; blah->after = after ; blah->afterlen = afterlen ; return 1 ; } skalibs-2.14.1.1/src/libunixonacid/skaclient_syncify.c000066400000000000000000000005021455624754300227060ustar00rootroot00000000000000/* ISC license. */ #include #include int skaclient_syncify (skaclient *a, tain const *deadline, tain *stamp) { int r ; if (!skaclient_timed_flush(a, deadline, stamp)) return 0 ; r = skaclient_timed_supdate(a, deadline, stamp) ; return r < 0 ? 0 : !r ? (errno = EPIPE, 0) : 1 ; } skalibs-2.14.1.1/src/libunixonacid/skaclient_zero.c000066400000000000000000000001461455624754300222050ustar00rootroot00000000000000/* ISC license. */ #include skaclient const skaclient_zero = SKACLIENT_ZERO ; skalibs-2.14.1.1/src/libunixonacid/stat_at.c000066400000000000000000000026071455624754300206340ustar00rootroot00000000000000/* ISC license. */ #include #ifdef SKALIBS_HASOPENAT #ifndef _ATFILE_SOURCE #define _ATFILE_SOURCE #endif #include #include #include #include int stat_at (int dirfd, char const *file, struct stat *st) { return fstatat(dirfd, file, st, 0) ; } int lstat_at (int dirfd, char const *file, struct stat *st) { return fstatat(dirfd, file, st, AT_SYMLINK_NOFOLLOW) ; } #else /* OpenBSD plz. lstat() is POSIX. */ #include #include #include #include #include #include static int fstat_at (int dirfd, char const *file, struct stat *st, int (*dostat)(char const *, struct stat *)) { int r ; int fdhere = open_read(".") ; if (fdhere < 0) return -1 ; if (fd_chdir(dirfd) < 0) { fd_close(fdhere) ; return -1 ; } r = (*dostat)(file, st) ; if (r < 0) { int e = errno ; fd_chdir(fdhere) ; fd_close(fdhere) ; errno = e ; return -1 ; } if (fd_chdir(fdhere) < 0) { fd_close(fdhere) ; return -1 ; } fd_close(fdhere) ; return r ; } int stat_at (int dirfd, char const *file, struct stat *st) { return fstat_at(dirfd, file, st, &stat) ; } int lstat_at (int dirfd, char const *file, struct stat *st) { return fstat_at(dirfd, file, st, &lstat) ; } #endif skalibs-2.14.1.1/src/libunixonacid/textclient_command.c000066400000000000000000000007431455624754300230550ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include int textclient_command (textclient *a, char const *s, size_t len, tain const *deadline, tain *stamp) { struct iovec ans ; if (!textclient_exchange(a, s, len, &ans, deadline, stamp)) return 0 ; if (ans.iov_len != 1) return (errno = EPROTO, 0) ; if (*(unsigned char *)ans.iov_base) return (errno = *(unsigned char *)ans.iov_base, 0) ; return 1 ; } skalibs-2.14.1.1/src/libunixonacid/textclient_commandv.c000066400000000000000000000007571455624754300232500ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include int textclient_commandv (textclient *a, struct iovec const *v, unsigned int n, tain const *deadline, tain *stamp) { struct iovec ans ; if (!textclient_exchangev(a, v, n, &ans, deadline, stamp)) return 0 ; if (ans.iov_len != 1) return (errno = EPROTO, 0) ; if (*(unsigned char *)ans.iov_base) return (errno = *(unsigned char *)ans.iov_base, 0) ; return 1 ; } skalibs-2.14.1.1/src/libunixonacid/textclient_end.c000066400000000000000000000013131455624754300221770ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include void textclient_end (textclient *a) { fd_close(textmessage_sender_fd(&a->syncout)) ; if (textmessage_receiver_fd(&a->syncin) != textmessage_sender_fd(&a->syncout)) fd_close(textmessage_receiver_fd(&a->syncin)) ; fd_close(textmessage_receiver_fd(&a->asyncin)) ; textmessage_sender_free(&a->syncout) ; textmessage_receiver_free(&a->syncin) ; textmessage_receiver_free(&a->asyncin) ; if (a->pid && a->options & TEXTCLIENT_OPTION_WAITPID) { int e = errno ; int wstat ; waitpid_nointr(a->pid, &wstat, 0) ; errno = e ; } *a = textclient_zero ; } skalibs-2.14.1.1/src/libunixonacid/textclient_server_init.c000066400000000000000000000011401455624754300237600ustar00rootroot00000000000000/* ISC license. */ #include #include #include int textclient_server_init (textmessage_receiver *in, textmessage_sender *syncout, textmessage_sender *asyncout, char const *before, size_t beforelen, char const *after, size_t afterlen, tain const *deadline, tain *stamp) { return getenv(SKALIBS_CHILD_SPAWN_FDS_ENVVAR) ? textclient_server_init_frompipe(in, syncout, asyncout, before, beforelen, after, afterlen, deadline, stamp) : textclient_server_init_fromsocket(in, syncout, asyncout, before, beforelen, after, afterlen, deadline, stamp) ; } skalibs-2.14.1.1/src/libunixonacid/textclient_server_init_frompipe.c000066400000000000000000000023411455624754300256650ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #include #include #include #include int textclient_server_init_frompipe (textmessage_receiver *in, textmessage_sender *syncout, textmessage_sender *asyncout, char const *before, size_t beforelen, char const *after, size_t afterlen, tain const *deadline, tain *stamp) { struct iovec v ; unsigned int asyncfd ; char *x = getenv(SKALIBS_CHILD_SPAWN_FDS_ENVVAR) ; if (!x || !uint0_scan(x, &asyncfd) || asyncfd == textmessage_sender_fd(syncout) || asyncfd == textmessage_receiver_fd(in)) return (errno = EPROTO, 0) ; if (sanitize_read(textmessage_timed_receive(in, &v, deadline, stamp)) <= 0) return 0 ; if (v.iov_len != beforelen || memcmp(v.iov_base, before, beforelen)) return (errno = EPROTO, 0) ; if (fcntl(asyncfd, F_GETFD) < 0) return 0 ; textmessage_sender_init(asyncout, asyncfd) ; if (!textmessage_timed_send(asyncout, after, afterlen, deadline, stamp)) return 0 ; if (!textmessage_timed_send(syncout, after, afterlen, deadline, stamp)) return 0 ; return 1 ; } skalibs-2.14.1.1/src/libunixonacid/textclient_server_init_fromsocket.c000066400000000000000000000015641455624754300262260ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #include int textclient_server_init_fromsocket (textmessage_receiver *in, textmessage_sender *syncout, textmessage_sender *asyncout, char const *before, size_t beforelen, char const *after, size_t afterlen, tain const *deadline, tain *stamp) { struct iovec v ; if (sanitize_read(textmessage_timed_receive(in, &v, deadline, stamp)) <= 0) return 0 ; if (v.iov_len != beforelen || memcmp(v.iov_base, before, beforelen)) return (errno = EPROTO, 0) ; if (!textmessage_create_send_channel(textmessage_sender_fd(syncout), asyncout, after, afterlen, deadline, stamp)) return 0 ; if (!textmessage_timed_send(syncout, after, afterlen, deadline, stamp)) return 0 ; return 1 ; } skalibs-2.14.1.1/src/libunixonacid/textclient_start.c000066400000000000000000000025151455624754300225730ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #include #include int textclient_start (textclient *a, char const *path, uint32_t options, char const *before, size_t beforelen, char const *after, size_t afterlen, tain const *deadline, tain *stamp) { struct iovec v ; int fd = ipc_stream_nbcoe() ; if (fd < 0) return 0 ; if (!ipc_timed_connect(fd, path, deadline, stamp)) goto err ; textmessage_sender_init(&a->syncout, fd) ; if (!textmessage_timed_send(&a->syncout, before, beforelen, deadline, stamp)) goto ferr ; if (!textmessage_recv_channel(fd, &a->asyncin, a->asyncbuf, TEXTCLIENT_BUFSIZE, after, afterlen, deadline, stamp)) goto ferr ; textmessage_receiver_init(&a->syncin, fd, a->syncbuf, TEXTCLIENT_BUFSIZE, TEXTMESSAGE_MAXLEN) ; if (!textclient_timed_get(a, &v, deadline, stamp)) goto aerr ; if (v.iov_len != afterlen || memcmp(v.iov_base, after, afterlen)) goto berr ; a->pid = 0 ; a->options = options & ~TEXTCLIENT_OPTION_WAITPID ; return 1 ; berr: errno = EPROTO ; aerr: textmessage_receiver_free(&a->syncin) ; textmessage_receiver_free(&a->asyncin) ; ferr: textmessage_sender_free(&a->syncout) ; err: fd_close(fd) ; return 0 ; } skalibs-2.14.1.1/src/libunixonacid/textclient_startf.c000066400000000000000000000025331455624754300227410ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #include #include int textclient_startf (textclient *a, char const *const *argv, char const *const *envp, uint32_t options, char const *before, size_t beforelen, char const *after, size_t afterlen, tain const *deadline, tain *stamp) { struct iovec v ; int fd[3] = { 0, 1 } ; pid_t pid = child_spawn3(argv[0], argv, envp, fd) ; if (!pid) return 0 ; textmessage_receiver_init(&a->syncin, fd[0], a->syncbuf, TEXTCLIENT_BUFSIZE, TEXTMESSAGE_MAXLEN) ; textmessage_receiver_init(&a->asyncin, fd[2], a->asyncbuf, TEXTCLIENT_BUFSIZE, TEXTMESSAGE_MAXLEN) ; textmessage_sender_init(&a->syncout, fd[1]) ; a->pid = pid ; a->options = options ; if (!textclient_timed_send(a, before, beforelen, deadline, stamp)) goto err ; if (sanitize_read(textmessage_timed_receive(&a->asyncin, &v, deadline, stamp)) <= 0) goto err ; if (v.iov_len != afterlen || memcmp(v.iov_base, after, afterlen)) goto errproto ; if (!textclient_timed_get(a, &v, deadline, stamp)) goto err ; if (v.iov_len != afterlen || memcmp(v.iov_base, after, afterlen)) goto errproto ; return 1 ; errproto: errno = EPROTO ; err: textclient_end(a) ; return 0 ; } skalibs-2.14.1.1/src/libunixonacid/textclient_zero.c000066400000000000000000000001521455624754300224100ustar00rootroot00000000000000/* ISC license. */ #include textclient const textclient_zero = TEXTCLIENT_ZERO ; skalibs-2.14.1.1/src/libunixonacid/textmessage_create_send_channel.c000066400000000000000000000017641455624754300255550ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #include #include static int getfd (void *p) { return ((int *)p)[0] ; } static int one (void *p) { (void)p ; return 1 ; } static int sendit (void *p) { int *fd = p ; return ancil_send_fd(fd[0], fd[1], '|') ; } int textmessage_create_send_channel (int sock, textmessage_sender *asyncout, char const *after, size_t afterlen, tain const *deadline, tain *stamp) { int fd[3] = { sock } ; int r ; if (pipenbcoe(fd+1) < 0) return 0 ; r = timed_flush(fd, &getfd, &one, &sendit, deadline, stamp) ; fd_close(fd[1]) ; if (!r) goto err ; textmessage_sender_init(asyncout, fd[2]) ; if (!textmessage_timed_send(asyncout, after, afterlen, deadline, stamp)) goto ferr ; return 1 ; ferr: textmessage_sender_free(asyncout) ; err: fd_close(fd[2]) ; return 0 ; } skalibs-2.14.1.1/src/libunixonacid/textmessage_handle.c000066400000000000000000000007411455624754300230360ustar00rootroot00000000000000/* ISC license. */ #include #include int textmessage_handle (textmessage_receiver *tr, textmessage_handler_func_ref f, void *p) { unsigned int count = 0 ; while (count < TEXTMESSAGE_MAXREADS || textmessage_receiver_hasmsginbuf(tr)) { struct iovec v ; int r = textmessage_receive(tr, &v) ; if (r < 0) return -1 ; if (!r) break ; r = (*f)(&v, p) ; if (r <= 0) return r-2 ; count++ ; } return (int)count ; } skalibs-2.14.1.1/src/libunixonacid/textmessage_put.c000066400000000000000000000010161455624754300224070ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include int textmessage_put (textmessage_sender *ts, char const *s, size_t len) { char pack[4] ; struct iovec v[2] = { { .iov_base = pack, .iov_len = 4 }, { .iov_base = (char *)s, .iov_len = len } } ; if (len > TEXTMESSAGE_MAXLEN) return (errno = EINVAL, 0) ; uint32_pack_big(pack, (uint32_t)len) ; return bufalloc_putv(&ts->out, v, 2) ; } skalibs-2.14.1.1/src/libunixonacid/textmessage_putv.c000066400000000000000000000011511455624754300225750ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #include int textmessage_putv (textmessage_sender *ts, struct iovec const *v, unsigned int n) { size_t len = siovec_len(v, n) ; char pack[4] ; struct iovec vv[n+1] ; if (len > TEXTMESSAGE_MAXLEN) return (errno = EINVAL, 0) ; vv[0].iov_base = pack ; vv[0].iov_len = 4 ; for (unsigned int i = 0 ; i < n ; i++) vv[i+1] = v[i] ; uint32_pack_big(pack, (uint32_t)len) ; return bufalloc_putv(&ts->out, vv, n+1) ; } skalibs-2.14.1.1/src/libunixonacid/textmessage_receive.c000066400000000000000000000017551455624754300232330ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #include #include int textmessage_receive (textmessage_receiver *tr, struct iovec *v) { if (tr->indata.len == tr->wanted) { uint32_t u ; char pack[4] ; if (buffer_len(&tr->in) < 4) { ssize_t r = sanitize_read(buffer_fill(&tr->in)) ; if (r <= 0) return r ; if (buffer_len(&tr->in) < 4) return (errno = EWOULDBLOCK, 0) ; } buffer_getnofill(&tr->in, pack, 4) ; uint32_unpack_big(pack, &u) ; if (u > tr->max) return (errno = EMSGSIZE, -1) ; if (!stralloc_ready(&tr->indata, u)) return -1 ; tr->wanted = u ; tr->indata.len = 0 ; } { int r = buffer_getall(&tr->in, tr->indata.s, tr->wanted, &tr->indata.len) ; if (r <= 0) return r ; } v->iov_base = tr->indata.s ; v->iov_len = tr->indata.len ; return 1 ; } skalibs-2.14.1.1/src/libunixonacid/textmessage_receiver_0.c000066400000000000000000000003721455624754300236260ustar00rootroot00000000000000/* ISC license. */ /* MT-unsafe */ #include #include static char buf[BUFFER_INSIZE] ; textmessage_receiver textmessage_receiver_0_ = TEXTMESSAGE_RECEIVER_INIT(0, buf, BUFFER_INSIZE, TEXTMESSAGE_MAXLEN) ; skalibs-2.14.1.1/src/libunixonacid/textmessage_receiver_free.c000066400000000000000000000003251455624754300244060ustar00rootroot00000000000000/* ISC license. */ #include #include void textmessage_receiver_free (textmessage_receiver *ts) { stralloc_free(&ts->indata) ; *ts = textmessage_receiver_zero ; } skalibs-2.14.1.1/src/libunixonacid/textmessage_receiver_hasmsginbuf.c000066400000000000000000000007501455624754300257750ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include int textmessage_receiver_hasmsginbuf (textmessage_receiver const *tr) { size_t len = buffer_len(&tr->in) ; uint32_t n ; char pack[4] ; struct iovec v[2] ; if (len < 4) return 0 ; buffer_rpeek(&tr->in, v) ; siovec_gather(v, 2, pack, 4) ; uint32_unpack_big(pack, &n) ; return len - 4 >= n ; } skalibs-2.14.1.1/src/libunixonacid/textmessage_receiver_init.c000066400000000000000000000005651455624754300244360ustar00rootroot00000000000000/* ISC license. */ #include #include #include int textmessage_receiver_init (textmessage_receiver *tr, int fd, char *buf, size_t buflen, uint32_t max) { if (!buffer_init(&tr->in, &buffer_read, fd, buf, buflen)) return 0 ; tr->indata = stralloc_zero ; tr->wanted = 0 ; tr->max = max ; return 1 ; } skalibs-2.14.1.1/src/libunixonacid/textmessage_receiver_zero.c000066400000000000000000000002111455624754300244360ustar00rootroot00000000000000/* ISC license. */ #include textmessage_receiver const textmessage_receiver_zero = TEXTMESSAGE_RECEIVER_ZERO ; skalibs-2.14.1.1/src/libunixonacid/textmessage_recv_channel.c000066400000000000000000000023561455624754300242360ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #include #include #include #include static int getfd (void *p) { return ((int *)p)[0] ; } static ssize_t get (void *p) { int *fd = p ; int r = ancil_recv_fd(fd[0], '|') ; if (r < 0) return error_isagain(errno) ? (errno = 0, 0) : r ; fd[1] = r ; return 1 ; } int textmessage_recv_channel (int sock, textmessage_receiver *asyncin, char *asyncbuf, size_t asyncbufsize, char const *after, size_t afterlen, tain const *deadline, tain *stamp) { struct iovec v ; int fd[2] = { sock, -1 } ; ssize_t r = timed_get(fd, &getfd, &get, deadline, stamp) ; if (!r) errno = EPIPE ; if (r <= 0) return 0 ; textmessage_receiver_init(asyncin, fd[1], asyncbuf, asyncbufsize, TEXTMESSAGE_MAXLEN) ; if (sanitize_read(textmessage_timed_receive(asyncin, &v, deadline, stamp)) <= 0) goto serr ; if (v.iov_len != afterlen || memcmp(v.iov_base, after, afterlen)) goto berr ; return 1 ; berr: errno = EPROTO ; serr: textmessage_receiver_free(asyncin) ; fd_close(fd[1]) ; return 0 ; } skalibs-2.14.1.1/src/libunixonacid/textmessage_sender_1.c000066400000000000000000000002171455624754300233010ustar00rootroot00000000000000/* ISC license. */ /* MT-unsafe */ #include textmessage_sender textmessage_sender_1_ = TEXTMESSAGE_SENDER_INIT(1) ; skalibs-2.14.1.1/src/libunixonacid/textmessage_sender_flush.c000066400000000000000000000002621455624754300242620ustar00rootroot00000000000000/* ISC license. */ #include #include int textmessage_sender_flush (textmessage_sender *ts) { return bufalloc_flush(&ts->out) ; } skalibs-2.14.1.1/src/libunixonacid/textmessage_sender_getfd.c000066400000000000000000000002651455624754300242350ustar00rootroot00000000000000/* ISC license. */ #include #include int textmessage_sender_getfd (textmessage_sender const *ts) { return bufalloc_fd(&ts->out) ; } skalibs-2.14.1.1/src/libunixonacid/textmessage_sender_timed_flush.c000066400000000000000000000007711455624754300254510ustar00rootroot00000000000000/* ISC license. */ #include #include #include static int textmessage_sender_isnonempty (textmessage_sender *ts) { return !textmessage_sender_isempty(ts) ; } int textmessage_sender_timed_flush (textmessage_sender *ts, tain const *deadline, tain *stamp) { return timed_flush(ts, (init_func_ref)&textmessage_sender_getfd, (init_func_ref)&textmessage_sender_isnonempty, (init_func_ref)&textmessage_sender_flush, deadline, stamp) ; } skalibs-2.14.1.1/src/libunixonacid/textmessage_sender_x.c000066400000000000000000000002141455624754300234050ustar00rootroot00000000000000/* ISC license. */ /* MT-unsafe */ #include textmessage_sender textmessage_sender_x_ = TEXTMESSAGE_SENDER_ZERO ; skalibs-2.14.1.1/src/libunixonacid/textmessage_sender_zero.c000066400000000000000000000002031455624754300241130ustar00rootroot00000000000000/* ISC license. */ #include textmessage_sender const textmessage_sender_zero = TEXTMESSAGE_SENDER_ZERO ; skalibs-2.14.1.1/src/libunixonacid/textmessage_timed_handle.c000066400000000000000000000015061455624754300242200ustar00rootroot00000000000000/* ISC license. */ #include #include #include typedef struct textmessage_handler_blah_s textmessage_handler_blah, *textmessage_handler_blah_ref ; struct textmessage_handler_blah_s { textmessage_receiver *tr ; textmessage_handler_func_ref f ; void *p ; } ; static int getfd (textmessage_handler_blah *blah) { return textmessage_receiver_fd(blah->tr) ; } static ssize_t get (textmessage_handler_blah *blah) { return textmessage_handle(blah->tr, blah->f, blah->p) ; } int textmessage_timed_handle (textmessage_receiver *tr, textmessage_handler_func_ref f, void *p, tain const *deadline, tain *stamp) { textmessage_handler_blah blah = { .tr = tr, .f = f, .p = p } ; return timed_get(&blah, (init_func_ref)&getfd, (get_func_ref)&get, deadline, stamp) ; } skalibs-2.14.1.1/src/libunixonacid/textmessage_timed_receive.c000066400000000000000000000013331455624754300244050ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include typedef struct textmessage_getter_s textmessage_getter, *textmessage_getter_ref ; struct textmessage_getter_s { textmessage_receiver *tr ; struct iovec *v ; } ; static int getfd (textmessage_getter *g) { return textmessage_receiver_fd(g->tr) ; } static ssize_t get (textmessage_getter *g) { return textmessage_receive(g->tr, g->v) ; } int textmessage_timed_receive (textmessage_receiver *tr, struct iovec *v, tain const *deadline, tain *stamp) { textmessage_getter g = { .tr = tr, .v = v } ; return timed_get(&g, (init_func_ref)&getfd, (get_func_ref)&get, deadline, stamp) ; } skalibs-2.14.1.1/src/libunixonacid/timed_flush.c000066400000000000000000000012641455624754300214760ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include int timed_flush (void *b, init_func_ref getfd, init_func_ref isnonempty, init_func_ref flush, tain const *deadline, tain *stamp) { iopause_fd x = { .fd = (*getfd)(b), .events = IOPAUSE_WRITE, .revents = 0 } ; while ((*isnonempty)(b)) { int r = iopause_stamp(&x, 1, deadline, stamp) ; if (r < 0) return 0 ; else if (!r) return (errno = ETIMEDOUT, 0) ; else if (x.revents & IOPAUSE_WRITE) { if (!((*flush)(b)) && !error_isagain(errno)) return 0 ; } else if (x.revents & IOPAUSE_EXCEPT) return (*flush)(b) ; } return 1 ; } skalibs-2.14.1.1/src/libunixonacid/timed_get.c000066400000000000000000000010751455624754300211340ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include ssize_t timed_get (void *b, init_func_ref getfd, get_func_ref get, tain const *deadline, tain *stamp) { iopause_fd x = { .fd = (*getfd)(b), .events = IOPAUSE_READ, .revents = 0 } ; ssize_t r = (*get)(b) ; while (!r) { r = iopause_stamp(&x, 1, deadline, stamp) ; if (!r) return (errno = ETIMEDOUT, -1) ; else if (r > 0 && x.revents & (IOPAUSE_READ | IOPAUSE_EXCEPT)) r = (*get)(b) ; } return unsanitize_read(r) ; } skalibs-2.14.1.1/src/libunixonacid/timed_getln.c000066400000000000000000000013131455624754300214610ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #include struct blah_s { buffer *b ; stralloc *sa ; char sep ; } ; static int getfd (struct blah_s *blah) { return buffer_fd(blah->b) ; } static ssize_t get (struct blah_s *blah) { return sanitize_read(skagetln(blah->b, blah->sa, blah->sep)) ; } int timed_getln (buffer *b, stralloc *sa, char sep, tain const *deadline, tain *stamp) { struct blah_s blah = { .b = b, .sa = sa, .sep = sep } ; return timed_get(&blah, (init_func_ref)&getfd, (get_func_ref)&get, deadline, stamp) ; } skalibs-2.14.1.1/src/libunixonacid/timed_getlnmax.c000066400000000000000000000014461455624754300221760ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include struct blah_s { buffer *b ; char *d ; size_t max ; size_t w ; char sep ; } ; static int getfd (struct blah_s *blah) { return buffer_fd(blah->b) ; } static ssize_t get (struct blah_s *blah) { return sanitize_read(getlnmax(blah->b, blah->d, blah->max, &blah->w, blah->sep)) ; } ssize_t timed_getlnmax (buffer *b, char *d, size_t max, size_t *w, char sep, tain const *deadline, tain *stamp) { struct blah_s blah = { .b = b, .d = d, .max = max, .w = *w, .sep = sep } ; ssize_t r = timed_get(&blah, (init_func_ref)&getfd, (get_func_ref)&get, deadline, stamp) ; *w = blah.w ; return r ; } skalibs-2.14.1.1/src/libunixonacid/unixconnection_free.c000066400000000000000000000003701455624754300232340ustar00rootroot00000000000000 /* ISC license. */ #include #include void unixconnection_free (unixconnection *io) { unixmessage_sender_free(&io->out) ; unixmessage_receiver_free(&io->in) ; *io = unixconnection_zero ; } skalibs-2.14.1.1/src/libunixonacid/unixconnection_init.c000066400000000000000000000003671455624754300232640ustar00rootroot00000000000000 /* ISC license. */ #include #include void unixconnection_init (unixconnection *io, int fdin, int fdout) { unixconnection_init_withclosecb(io, fdin, fdout, &unixmessage_sender_closecb, 0) ; } skalibs-2.14.1.1/src/libunixonacid/unixconnection_init_withclosecb.c000066400000000000000000000006201455624754300256420ustar00rootroot00000000000000 /* ISC license. */ #include #include void unixconnection_init_withclosecb (unixconnection *io, int fdin, int fdout, unixmessage_sender_closecb_func_ref f, void *p) { unixmessage_receiver_init(&io->in, fdin, io->mainbuf, UNIXMESSAGE_BUFSIZE, io->auxbuf, UNIXMESSAGE_AUXBUFSIZE) ; unixmessage_sender_init_withclosecb(&io->out, fdout, f, p) ; } skalibs-2.14.1.1/src/libunixonacid/unixconnection_zero.c000066400000000000000000000001731455624754300232730ustar00rootroot00000000000000 /* ISC license. */ #include unixconnection const unixconnection_zero = UNIXCONNECTION_ZERO ; skalibs-2.14.1.1/src/libunixonacid/unixmessage_bits_closeall.c000066400000000000000000000006101455624754300244140ustar00rootroot00000000000000/* ISC license. */ #include #include static unsigned char const unixmessage_bits_closeall_[bitarray_div8(UNIXMESSAGE_MAXFDS)] = "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" ; unsigned char const *const unixmessage_bits_closeall = unixmessage_bits_closeall_ ; skalibs-2.14.1.1/src/libunixonacid/unixmessage_bits_closenone.c000066400000000000000000000005111455624754300246030ustar00rootroot00000000000000/* ISC license. */ #include #include static unsigned char const unixmessage_bits_closenone_[bitarray_div8(UNIXMESSAGE_MAXFDS)] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" ; unsigned char const *const unixmessage_bits_closenone = unixmessage_bits_closenone_ ; skalibs-2.14.1.1/src/libunixonacid/unixmessage_drop.c000066400000000000000000000003051455624754300225420ustar00rootroot00000000000000/* ISC license. */ #include #include void unixmessage_drop (unixmessage const *m) { unsigned int i = m->nfds ; while (i--) fd_close(m->fds[i]) ; } skalibs-2.14.1.1/src/libunixonacid/unixmessage_handle.c000066400000000000000000000007101455624754300230310ustar00rootroot00000000000000/* ISC license. */ #include int unixmessage_handle (unixmessage_receiver *b, unixmessage_handler_func_ref f, void *p) { unsigned int count = 0 ; while (count < UNIXMESSAGE_MAXREADS || unixmessage_receiver_hasmsginbuf(b)) { unixmessage m ; int r = unixmessage_receive(b, &m) ; if (r < 0) return -1 ; if (!r) break ; r = (*f)(&m, p) ; if (r <= 0) return r-2 ; count++ ; } return (int)count ; } skalibs-2.14.1.1/src/libunixonacid/unixmessage_put.c000066400000000000000000000036061455624754300224150ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #include #include #include static inline int copyfds (char *s, int const *fds, unsigned int n, unsigned char const *bits, unixmessage_sender_closecb_func_ref closecb, void *closecbdata) { unsigned int i = 0 ; for (; i < n ; i++) { int fd = fds[i] ; if (fd < 0) return (errno = EINVAL, -1) ; if (bitarray_peek(bits, i)) fd = - fd - 1 ; memcpy(s, (char const *)&fd, sizeof(int)) ; s += sizeof(int) ; } return 1 ; } static int reserve_and_copy (unixmessage_sender *b, size_t len, int const *fds, unsigned int nfds, unsigned char const *bits) { disize cur = { .left = b->data.len, .right = genalloc_len(int, &b->fds) } ; if (len > UNIXMESSAGE_MAXSIZE || nfds > UNIXMESSAGE_MAXFDS) return (errno = EPROTO, 0) ; if (!genalloc_readyplus(disize, &b->offsets, 1) || !genalloc_readyplus(int, &b->fds, nfds) || !stralloc_readyplus(&b->data, len)) return 0 ; if (!copyfds(b->fds.s + b->fds.len, fds, nfds, bits, b->closecb, b->closecbdata)) return 0 ; genalloc_setlen(int, &b->fds, cur.right + nfds) ; return genalloc_append(disize, &b->offsets, &cur) ; } int unixmessage_put_and_close (unixmessage_sender *b, unixmessage const *m, unsigned char const *bits) { if (!reserve_and_copy(b, m->len, m->fds, m->nfds, bits)) return 0 ; memmove(b->data.s + b->data.len, m->s, m->len) ; b->data.len += m->len ; return 1 ; } int unixmessage_putv_and_close (unixmessage_sender *b, unixmessagev const *m, unsigned char const *bits) { size_t len = siovec_len(m->v, m->vlen) ; if (!reserve_and_copy(b, len, m->fds, m->nfds, bits)) return 0 ; b->data.len += siovec_gather(m->v, m->vlen, b->data.s + b->data.len, len) ; return 1 ; } skalibs-2.14.1.1/src/libunixonacid/unixmessage_receive.c000066400000000000000000000077521455624754300232350ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #include #include #include #include #include #include #include union aligner_u { struct cmsghdr cmsghdr ; int i ; } ; static int const awesomeflags = #ifdef SKALIBS_HASMSGDONTWAIT MSG_DONTWAIT #else 0 #endif | #ifdef SKALIBS_HASCMSGCLOEXEC MSG_CMSG_CLOEXEC #else 0 #endif ; static int unixmessage_receiver_fill (unixmessage_receiver *b) { union aligner_u ancilbuf[1 + CMSG_SPACE(b->auxb.a - 1) / sizeof(union aligner_u)] ; struct iovec iov[2] ; struct msghdr msghdr = { .msg_name = 0, .msg_namelen = 0, .msg_iov = iov, .msg_iovlen = 2, .msg_flags = 0, .msg_control = b->fds_ok & 1 ? ancilbuf : 0, .msg_controllen = b->fds_ok & 1 ? CMSG_SPACE(b->auxb.a - 1) : 0 } ; ssize_t r = -1 ; if (cbuffer_isfull(&b->mainb) || ((b->fds_ok & 1) && cbuffer_isfull(&b->auxb))) return (errno = ENOBUFS, -1) ; cbuffer_wpeek(&b->mainb, iov) ; while (r < 0) { r = recvmsg(b->fd, &msghdr, awesomeflags) ; if (!r || (r < 0 && errno != EINTR)) return r ; } if (b->fds_ok & 1) { struct cmsghdr *c = CMSG_FIRSTHDR(&msghdr) ; if (c) { size_t auxlen ; if (c->cmsg_level != SOL_SOCKET || c->cmsg_type != SCM_RIGHTS) return (errno = EPROTO, -1) ; auxlen = (size_t)(c->cmsg_len - (CMSG_DATA(c) - (unsigned char *)c)) ; if (auxlen && !(b->fds_ok & 2)) { size_t i = auxlen / sizeof(int) ; while (i--) fd_close(((int *)CMSG_DATA(c))[i]) ; return (errno = EPROTO, -1) ; } #ifndef SKALIBS_HASCMSGCLOEXEC { size_t i = 0 ; for (; i < auxlen / sizeof(int) ; i++) if (coe(((int *)CMSG_DATA(c))[i]) < 0) { i++ ; while (i--) fd_close(((int *)CMSG_DATA(c))[i]) ; return -1 ; } } #endif if ((msghdr.msg_flags & MSG_CTRUNC) || cbuffer_put(&b->auxb, (char *)CMSG_DATA(c), auxlen) < auxlen) { size_t i = auxlen/sizeof(int) ; while (i--) fd_close(((int *)CMSG_DATA(c))[i]) ; return (errno = ENOBUFS, -1) ; } } } cbuffer_WSEEK(&b->mainb, r) ; return 1 ; } int unixmessage_receive (unixmessage_receiver *b, unixmessage *m) { if (b->maindata.len == b->mainlen && b->auxdata.len == b->auxlen) { char pack[6] ; if (cbuffer_len(&b->mainb) < 6) { ssize_t r = sanitize_read(unixmessage_receiver_fill(b)) ; if (r <= 0) return r ; if (cbuffer_len(&b->mainb) < 6) return (errno = EWOULDBLOCK, 0) ; } cbuffer_get(&b->mainb, pack, 6) ; uint32_unpack_big(pack, &b->mainlen) ; if (b->fds_ok & 1) uint16_unpack_big(pack + 4, &b->auxlen) ; else b->auxlen = 0 ; b->auxlen *= sizeof(int) ; if (b->mainlen > UNIXMESSAGE_MAXSIZE || b->auxlen > ((b->fds_ok & 2) ? UNIXMESSAGE_MAXFDS * sizeof(int) : 0)) return (errno = EPROTO, -1) ; if (!stralloc_ready(&b->maindata, b->mainlen) || !stralloc_ready(&b->auxdata, b->auxlen)) return -1 ; b->maindata.len = 0 ; b->auxdata.len = 0 ; } for (;;) { ssize_t r ; size_t n = cbuffer_len(&b->mainb) ; if (n > b->mainlen - b->maindata.len) n = b->mainlen - b->maindata.len ; b->maindata.len += cbuffer_get(&b->mainb, b->maindata.s + b->maindata.len, n) ; n = cbuffer_len(&b->auxb) ; if (n > b->auxlen - b->auxdata.len) n = b->auxlen - b->auxdata.len ; b->auxdata.len += cbuffer_get(&b->auxb, b->auxdata.s + b->auxdata.len, n) ; if (b->maindata.len == b->mainlen && b->auxdata.len == b->auxlen) break ; r = sanitize_read(unixmessage_receiver_fill(b)) ; if (r <= 0) return r ; } m->s = b->maindata.s ; m->len = b->maindata.len ; m->fds = (int *)b->auxdata.s ; m->nfds = b->auxdata.len / sizeof(int) ; return 1 ; } skalibs-2.14.1.1/src/libunixonacid/unixmessage_receiver_0.c000066400000000000000000000004541455624754300236260ustar00rootroot00000000000000/* ISC license. */ /* MT-unsafe */ #include static char mainbuf[UNIXMESSAGE_BUFSIZE] ; static char auxbuf[UNIXMESSAGE_AUXBUFSIZE] ; unixmessage_receiver unixmessage_receiver_0_ = UNIXMESSAGE_RECEIVER_INIT(0, mainbuf, UNIXMESSAGE_BUFSIZE, auxbuf, UNIXMESSAGE_AUXBUFSIZE) ; skalibs-2.14.1.1/src/libunixonacid/unixmessage_receiver_free.c000066400000000000000000000014021455624754300244020ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include void unixmessage_receiver_free (unixmessage_receiver *b) { size_t maindatalen = b->maindata.len ; int h ; b->fd = -1 ; stralloc_free(&b->maindata) ; h = maindatalen != b->mainlen || b->auxdata.len != b->auxlen || cbuffer_len(&b->auxb) ; if (h) { size_t n = b->auxdata.len / sizeof(int) ; while (n--) fd_close(((int *)b->auxdata.s)[n]) ; } stralloc_free(&b->auxdata) ; if (h) { size_t n = cbuffer_len(&b->auxb) / sizeof(int) ; if (n) { int fds[n] ; cbuffer_get(&b->auxb, (char *)fds, n * sizeof(int)) ; while (n--) fd_close(fds[n]) ; } } } skalibs-2.14.1.1/src/libunixonacid/unixmessage_receiver_hasmsginbuf.c000066400000000000000000000010001455624754300257610ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include int unixmessage_receiver_hasmsginbuf (unixmessage_receiver const *b) { size_t len = cbuffer_len(&b->mainb) ; uint32_t mainlen ; char pack[4] ; struct iovec v[2] ; if (len < 6) return 0 ; cbuffer_rpeek(&b->mainb, v) ; siovec_gather(v, 2, pack, 4) ; uint32_unpack_big(pack, &mainlen) ; return len - 6 >= mainlen ; } skalibs-2.14.1.1/src/libunixonacid/unixmessage_receiver_init.c000066400000000000000000000007501455624754300244310ustar00rootroot00000000000000/* ISC license. */ #include #include #include int unixmessage_receiver_init (unixmessage_receiver *b, int fd, char *mainbuf, size_t mainlen, char *auxbuf, size_t auxlen) { if (!cbuffer_init(&b->mainb, mainbuf, mainlen) || !cbuffer_init(&b->auxb, auxbuf, auxlen)) return 0 ; b->fd = fd ; b->mainlen = b->auxlen = 0 ; b->maindata = stralloc_zero ; b->auxdata = stralloc_zero ; b->fds_ok = 3 ; return 1 ; } skalibs-2.14.1.1/src/libunixonacid/unixmessage_sender_1.c000066400000000000000000000002171455624754300233000ustar00rootroot00000000000000/* ISC license. */ /* MT-unsafe */ #include unixmessage_sender unixmessage_sender_1_ = UNIXMESSAGE_SENDER_INIT(1) ; skalibs-2.14.1.1/src/libunixonacid/unixmessage_sender_closecb.c000066400000000000000000000002461455624754300245540ustar00rootroot00000000000000/* ISC license. */ #include #include void unixmessage_sender_closecb (int fd, void *p) { fd_close(fd) ; (void)p ; } skalibs-2.14.1.1/src/libunixonacid/unixmessage_sender_flush.c000066400000000000000000000067441455624754300242740ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include union aligner_u { struct cmsghdr cmsghdr ; int i ; } ; /* XXX: sendmsg/recvmsg is badly, badly specified. XXX: We assume ancillary data is attached to the first byte. */ int unixmessage_sender_flush (unixmessage_sender *b) { disize last = { .left = b->data.len, .right = genalloc_len(int, &b->fds) } ; disize *offsets = genalloc_s(disize, &b->offsets) ; size_t n = genalloc_len(disize, &b->offsets) ; ssize_t r ; if (b->shorty) /* we had a short write, gotta send the remainder first */ { disize *next = b->head+1 < n ? offsets + b->head+1 : &last ; size_t len = next->left - offsets[b->head].left ; if (b->shorty <= len) r = fd_write(b->fd, b->data.s + offsets[b->head].left + (len - b->shorty), b->shorty) ; else { size_t nfds = next->right - offsets[b->head].right ; char pack[6] ; struct iovec v[2] = { { .iov_base = pack + 6 - (b->shorty - len), .iov_len = b->shorty - len }, { .iov_base = b->data.s + offsets[b->head].left, .iov_len = len } } ; uint32_pack_big(pack, (uint32_t)len) ; uint16_pack_big(pack + 4, (uint16_t)nfds) ; r = fd_writev(b->fd, v, 2) ; } if (r <= 0) return 0 ; b->shorty -= r ; if (b->shorty) return (errno = EWOULDBLOCK, 0) ; } for (; b->head < n ; b->head++) { disize *next = b->head+1 < n ? offsets + b->head+1 : &last ; size_t len = next->left - offsets[b->head].left ; size_t nfds = next->right - offsets[b->head].right ; char pack[6] ; struct iovec v[2] = { { .iov_base = pack, .iov_len = 6 }, { .iov_base = b->data.s + offsets[b->head].left, .iov_len = len } } ; union aligner_u ancilbuf[1 + CMSG_SPACE(nfds * sizeof(int)) / sizeof(union aligner_u)] ; struct msghdr hdr = { .msg_name = 0, .msg_namelen = 0, .msg_iov = v, .msg_iovlen = 2, .msg_control = nfds ? ancilbuf : 0, .msg_controllen = nfds ? CMSG_SPACE(nfds * sizeof(int)) : 0 } ; uint32_pack_big(pack, (uint32_t)len) ; uint16_pack_big(pack + 4, (uint16_t)nfds) ; if (nfds) { struct cmsghdr *cp = CMSG_FIRSTHDR(&hdr) ; size_t i = 0 ; memset(hdr.msg_control, 0, hdr.msg_controllen) ; cp->cmsg_level = SOL_SOCKET ; cp->cmsg_type = SCM_RIGHTS ; cp->cmsg_len = CMSG_LEN(nfds * sizeof(int)) ; for (; i < nfds ; i++) { int fd = genalloc_s(int, &b->fds)[offsets[b->head].right + i] ; ((int *)CMSG_DATA(cp))[i] = fd < 0 ? -(fd+1) : fd ; } } do r = sendmsg(b->fd, &hdr, MSG_NOSIGNAL) ; while (r < 0 && errno == EINTR) ; if (r <= 0) return 0 ; if (nfds) { size_t i = 0 ; for (; i < nfds ; i++) { int fd = genalloc_s(int, &b->fds)[offsets[b->head].right + i] ; if (fd < 0) (*b->closecb)(-(fd+1), b->closecbdata) ; } } if ((size_t)r < 6 + len) { b->shorty = 6 + len - r ; return (errno = EWOULDBLOCK, 0) ; } } b->data.len = 0 ; genalloc_setlen(int, &b->fds, 0) ; genalloc_setlen(disize, &b->offsets, 0) ; b->head = 0 ; return 1 ; } skalibs-2.14.1.1/src/libunixonacid/unixmessage_sender_free.c000066400000000000000000000012061455624754300240600ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include void unixmessage_sender_free (unixmessage_sender *b) { size_t n = genalloc_len(int, &b->fds) ; if (n) { size_t i = genalloc_s(disize, &b->offsets)[b->head].right ; for (; i < n ; i++) { int fd = genalloc_s(int, &b->fds)[i] ; if (fd < 0) (*b->closecb)(-(fd+1), b->closecbdata) ; } } genalloc_free(disize, &b->offsets) ; genalloc_free(int, &b->fds) ; stralloc_free(&b->data) ; *b = unixmessage_sender_zero ; } skalibs-2.14.1.1/src/libunixonacid/unixmessage_sender_getfd.c000066400000000000000000000002061455624754300242270ustar00rootroot00000000000000/* ISC license. */ #include int unixmessage_sender_getfd (unixmessage_sender const *b) { return b->fd ; } skalibs-2.14.1.1/src/libunixonacid/unixmessage_sender_init.c000066400000000000000000000003061455624754300241020ustar00rootroot00000000000000/* ISC license. */ #include void unixmessage_sender_init (unixmessage_sender *b, int fd) { unixmessage_sender_init_withclosecb(b, fd, &unixmessage_sender_closecb, 0) ; } skalibs-2.14.1.1/src/libunixonacid/unixmessage_sender_init_withclosecb.c000066400000000000000000000006401455624754300264710ustar00rootroot00000000000000/* ISC license. */ #include #include #include void unixmessage_sender_init_withclosecb (unixmessage_sender *b, int fd, unixmessage_sender_closecb_func_ref f, void *p) { b->fd = fd ; b->data = stralloc_zero ; b->fds = genalloc_zero ; b->offsets = genalloc_zero ; b->head = 0 ; b->shorty = 0 ; b->closecb = f ; b->closecbdata = p ; } skalibs-2.14.1.1/src/libunixonacid/unixmessage_sender_timed_flush.c000066400000000000000000000007651455624754300254530ustar00rootroot00000000000000/* ISC license. */ #include #include #include static int unixmessage_sender_isnonempty (unixmessage_sender *b) { return !unixmessage_sender_isempty(b) ; } int unixmessage_sender_timed_flush (unixmessage_sender *b, tain const *deadline, tain *stamp) { return timed_flush(b, (init_func_ref)&unixmessage_sender_getfd, (init_func_ref)&unixmessage_sender_isnonempty, (init_func_ref)&unixmessage_sender_flush, deadline, stamp) ; } skalibs-2.14.1.1/src/libunixonacid/unixmessage_sender_x.c000066400000000000000000000002141455624754300234040ustar00rootroot00000000000000/* ISC license. */ /* MT-unsafe */ #include unixmessage_sender unixmessage_sender_x_ = UNIXMESSAGE_SENDER_ZERO ; skalibs-2.14.1.1/src/libunixonacid/unixmessage_sender_zero.c000066400000000000000000000002031455624754300241120ustar00rootroot00000000000000/* ISC license. */ #include unixmessage_sender const unixmessage_sender_zero = UNIXMESSAGE_SENDER_ZERO ; skalibs-2.14.1.1/src/libunixonacid/unixmessage_timed_handle.c000066400000000000000000000015001455624754300242110ustar00rootroot00000000000000/* ISC license. */ #include #include #include typedef struct unixmessage_handler_blah_s unixmessage_handler_blah, *unixmessage_handler_blah_ref ; struct unixmessage_handler_blah_s { unixmessage_receiver *b ; unixmessage_handler_func_ref f ; void *p ; } ; static int getfd (unixmessage_handler_blah *blah) { return unixmessage_receiver_fd(blah->b) ; } static ssize_t get (unixmessage_handler_blah *blah) { return unixmessage_handle(blah->b, blah->f, blah->p) ; } int unixmessage_timed_handle (unixmessage_receiver *b, unixmessage_handler_func_ref f, void *p, tain const *deadline, tain *stamp) { unixmessage_handler_blah blah = { .b = b, .f = f, .p = p } ; return timed_get(&blah, (init_func_ref)&getfd, (get_func_ref)&get, deadline, stamp) ; } skalibs-2.14.1.1/src/libunixonacid/unixmessage_timed_receive.c000066400000000000000000000013251455624754300244050ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include typedef struct unixmessage_getter_s unixmessage_getter, *unixmessage_getter_ref ; struct unixmessage_getter_s { unixmessage_receiver *b ; unixmessage *m ; } ; static int getfd (unixmessage_getter *g) { return unixmessage_receiver_fd(g->b) ; } static ssize_t get (unixmessage_getter *g) { return unixmessage_receive(g->b, g->m) ; } int unixmessage_timed_receive (unixmessage_receiver *b, unixmessage *m, tain const *deadline, tain *stamp) { unixmessage_getter g = { .b = b, .m = m } ; return timed_get(&g, (init_func_ref)&getfd, (get_func_ref)&get, deadline, stamp) ; } skalibs-2.14.1.1/src/libunixonacid/unixmessage_unput.c000066400000000000000000000013411455624754300227520ustar00rootroot00000000000000 /* ISC license. */ #include #include #include #include int unixmessage_unput_and_maybe_drop (unixmessage_sender *b, int drop) { disize *start ; size_t n = genalloc_len(disize, &b->offsets) ; size_t i ; int *fds ; if (!n) return 0 ; start = genalloc_s(disize, &b->offsets) + n - 1 ; fds = genalloc_s(int, &b->fds) + start->right ; i = genalloc_len(int, &b->fds) - start->right ; while (i--) if (fds[i] < 0) (*b->closecb)(-(fds[i]+1), b->closecbdata) ; else if (drop) fd_close(fds[i]) ; b->data.len = start->left ; genalloc_setlen(int, &b->fds, start->right) ; genalloc_setlen(disize, &b->offsets, n-1) ; return 1 ; } skalibs-2.14.1.1/src/libunixonacid/unixmessage_zero.c000066400000000000000000000001561455624754300225610ustar00rootroot00000000000000/* ISC license. */ #include unixmessage const unixmessage_zero = UNIXMESSAGE_ZERO ; skalibs-2.14.1.1/src/libunixonacid/unixmessagev_zero.c000066400000000000000000000001611455624754300227430ustar00rootroot00000000000000/* ISC license. */ #include unixmessagev const unixmessagev_zero = UNIXMESSAGEV_ZERO ; skalibs-2.14.1.1/src/sysdeps/000077500000000000000000000000001455624754300156665ustar00rootroot00000000000000skalibs-2.14.1.1/src/sysdeps/tryaccept4.c000066400000000000000000000010611455624754300201120ustar00rootroot00000000000000/* ISC license. */ #undef _POSIX_C_SOURCE #undef _XOPEN_SOURCE #ifndef _XPG4_2 #define _XPG4_2 #endif #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif #ifndef _DEFAULT_SOURCE #define _DEFAULT_SOURCE #endif #include #include #include #include int main (void) { struct sockaddr blah ; socklen_t blahlen = sizeof(blah) ; int fd = open("/dev/null", O_RDONLY | O_NONBLOCK) ; if (fd < 0) return 111 ; if ((accept4(fd, &blah, &blahlen, SOCK_NONBLOCK) < 0) && (errno != ENOTSOCK)) return 1 ; return 0 ; } skalibs-2.14.1.1/src/sysdeps/tryarc4random.c000066400000000000000000000006311455624754300206230ustar00rootroot00000000000000/* ISC license. */ #undef _POSIX_C_SOURCE #undef _XOPEN_SOURCE #ifndef __EXTENSIONS__ #define __EXTENSIONS__ #endif #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif #ifndef _BSD_SOURCE #define _BSD_SOURCE #endif #ifndef _NETBSD_SOURCE #define _NETBSD_SOURCE #endif #ifndef _INCOMPLETE_XOPEN_C063 #define _INCOMPLETE_XOPEN_C063 #endif #include int main (void) { return arc4random_uniform(1) ; } skalibs-2.14.1.1/src/sysdeps/tryarc4random_addrandom.c000066400000000000000000000007251455624754300226400ustar00rootroot00000000000000/* ISC license. */ #undef _POSIX_C_SOURCE #undef _XOPEN_SOURCE #ifndef __EXTENSIONS__ #define __EXTENSIONS__ #endif #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif #ifndef _BSD_SOURCE #define _BSD_SOURCE #endif #ifndef _NETBSD_SOURCE #define _NETBSD_SOURCE #endif #ifndef _INCOMPLETE_XOPEN_C063 #define _INCOMPLETE_XOPEN_C063 #endif #include int main (void) { unsigned char *blah = (unsigned char *)"" ; arc4random_addrandom(blah, 1) ; return 0 ; } skalibs-2.14.1.1/src/sysdeps/trychroot.c000066400000000000000000000004011455624754300200620ustar00rootroot00000000000000/* ISC license. */ #undef _POSIX_C_SOURCE #undef _XOPEN_SOURCE #ifndef _BSD_SOURCE #define _BSD_SOURCE #endif #ifndef _DEFAULT_SOURCE #define _DEFAULT_SOURCE #endif #include int main (void) { if (chroot("/") < 0) return 1 ; return 0 ; } skalibs-2.14.1.1/src/sysdeps/tryclockboot.c000066400000000000000000000002321455624754300205450ustar00rootroot00000000000000/* ISC license. */ #include int main (void) { struct timespec ts ; if (clock_gettime(CLOCK_BOOTTIME, &ts) < 0) return 111 ; return 0 ; } skalibs-2.14.1.1/src/sysdeps/tryclockmon.c000066400000000000000000000002331455624754300203740ustar00rootroot00000000000000/* ISC license. */ #include int main (void) { struct timespec ts ; if (clock_gettime(CLOCK_MONOTONIC, &ts) < 0) return 111 ; return 0 ; } skalibs-2.14.1.1/src/sysdeps/tryclockrt.c000066400000000000000000000002321455624754300202270ustar00rootroot00000000000000/* ISC license. */ #include int main (void) { struct timespec ts ; if (clock_gettime(CLOCK_REALTIME, &ts) < 0) return 111 ; return 0 ; } skalibs-2.14.1.1/src/sysdeps/trycmsgcloexec.c000066400000000000000000000004331455624754300210650ustar00rootroot00000000000000/* ISC license. */ #undef _POSIX_C_SOURCE #undef _XOPEN_SOURCE #ifndef _XPG4_2 # define _XPG4_2 #endif #ifndef _XPG_6 # define _XPG6 #endif #ifndef _GNU_SOURCE # define _GNU_SOURCE #endif #include int main (void) { int flag = MSG_CMSG_CLOEXEC ; return 0 ; } skalibs-2.14.1.1/src/sysdeps/trydevurandom.c000066400000000000000000000006441455624754300207410ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include int main (void) { char a[64] ; char b[64] ; int fd ; fd = open("/dev/urandom", O_RDONLY) ; if ((fd == -1) || (read(fd, a, 64) < 64) ) return 111 ; close(fd) ; fd = open("/dev/urandom", O_RDONLY) ; if ((fd == -1) || (read(fd, b, 64) < 64) ) return 111 ; close(fd) ; return (!memcmp(a, b, 64)) ; } skalibs-2.14.1.1/src/sysdeps/trydirfd.c000066400000000000000000000004661455624754300176670ustar00rootroot00000000000000/* ISC license. */ #undef _POSIX_C_SOURCE #undef _XOPEN_SOURCE #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif #ifndef _NETBSD_SOURCE #define _NETBSD_SOURCE #endif #ifndef __EXTENSIONS__ #define __EXTENSIONS__ #endif #include int main (void) { DIR *dir = opendir(".") ; return dirfd(dir) ; } skalibs-2.14.1.1/src/sysdeps/tryeventfd.c000066400000000000000000000002161455624754300202230ustar00rootroot00000000000000/* ISC license. */ #include int main (void) { int fd = eventfd(0, EFD_NONBLOCK) ; if (fd < 0) return 1 ; return 0 ; } skalibs-2.14.1.1/src/sysdeps/tryexplicit_bzero.c000066400000000000000000000007071455624754300216170ustar00rootroot00000000000000/* ISC license. */ #undef _POSIX_C_SOURCE #undef _XOPEN_SOURCE #ifndef __EXTENSIONS__ #define __EXTENSIONS__ #endif #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif #ifndef _BSD_SOURCE #define _BSD_SOURCE #endif #ifndef _NETBSD_SOURCE #define _NETBSD_SOURCE #endif #ifndef _INCOMPLETE_XOPEN_C063 #define _INCOMPLETE_XOPEN_C063 #endif #include #include int main (void) { char blah[4] ; explicit_bzero(blah, 4) ; return 0 ; } skalibs-2.14.1.1/src/sysdeps/tryflock.c000066400000000000000000000002601455624754300176650ustar00rootroot00000000000000/* ISC license. */ #undef _POSIX_C_SOURCE #undef _XOPEN_SOURCE #include #include int main (void) { return flock(0, LOCK_EX | LOCK_UN | LOCK_NB) ; } skalibs-2.14.1.1/src/sysdeps/tryfutimens.c000066400000000000000000000005201455624754300204200ustar00rootroot00000000000000/* ISC license. */ #undef _POSIX_C_SOURCE #undef _XOPEN_SOURCE #ifndef __EXTENSIONS__ #define __EXTENSIONS__ #endif #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif #include int main (void) { struct timespec foo[2] = { { .tv_sec = 0, .tv_nsec = 0 }, { .tv_sec = 0, .tv_nsec = 0 } } ; futimens(0, foo) ; return 0 ; } skalibs-2.14.1.1/src/sysdeps/tryfutimes.c000066400000000000000000000004311455624754300202430ustar00rootroot00000000000000/* ISC license. */ #undef _POSIX_C_SOURCE #undef _XOPEN_SOURCE #ifndef _BSD_SOURCE #define _BSD_SOURCE #endif #include int main (void) { struct timeval foo[2] = { { .tv_sec = 0, .tv_usec = 0 }, { .tv_sec = 0, .tv_usec = 0 } } ; futimes(0, foo) ; return 0 ; } skalibs-2.14.1.1/src/sysdeps/trygetpeereid.c000066400000000000000000000007401455624754300207070ustar00rootroot00000000000000/* ISC license. */ #undef _POSIX_C_SOURCE #undef _XOPEN_SOURCE #ifndef __EXTENSIONS__ #define __EXTENSIONS__ #endif #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif #ifndef _BSD_SOURCE #define _BSD_SOURCE #endif #ifndef _NETBSD_SOURCE #define _NETBSD_SOURCE #endif #ifndef _INCOMPLETE_XOPEN_C063 #define _INCOMPLETE_XOPEN_C063 #endif #include #include int main (void) { uid_t uid ; gid_t gid ; int fd = 0 ; return getpeereid(fd, &uid, &gid) ; } skalibs-2.14.1.1/src/sysdeps/trygetpeerucred.c000066400000000000000000000004651455624754300212540ustar00rootroot00000000000000/* ISC license. */ #undef _POSIX_C_SOURCE #undef _XOPEN_SOURCE #include #include int main (void) { ucred_t *cred ; uid_t uid ; gid_t gid ; int s = 0 ; getpeerucred(s, &cred) ; uid = ucred_geteuid(cred) ; gid = ucred_getegid(cred) ; ucred_free(cred) ; return 0 ; } skalibs-2.14.1.1/src/sysdeps/trygetrandom.c000066400000000000000000000004171455624754300205530ustar00rootroot00000000000000/* ISC license. */ #include #ifdef __stub_getrandom #error getrandom() appears to be a stub function, we won't use it. #endif #include int main (void) { char buf[4] ; if (getrandom(buf, 4, GRND_NONBLOCK) < 0) return 1 ; return 0 ; } skalibs-2.14.1.1/src/sysdeps/trygrndinsecure.c000066400000000000000000000004171455624754300212630ustar00rootroot00000000000000/* ISC license. */ #include #ifdef __stub_getrandom #error getrandom() appears to be a stub function, we won't use it. #endif #include int main (void) { char buf[4] ; if (getrandom(buf, 4, GRND_INSECURE) < 0) return 1 ; return 0 ; } skalibs-2.14.1.1/src/sysdeps/tryipv6.c000066400000000000000000000011421455624754300174530ustar00rootroot00000000000000/* ISC license. */ #undef _POSIX_C_SOURCE #undef _XOPEN_SOURCE #define _XPG4_2 #define _XPG6 #include #include #include #include int main (void) { int s, r ; struct in6_addr foo ; struct sockaddr_in6 bar ; memset(&foo, 0, sizeof(struct sockaddr_in6)) ; bar.sin6_addr = foo ; bar.sin6_port = 1026 ; s = socket(AF_INET6, SOCK_STREAM, 0) ; if (s < 0) return 111 ; do r = connect(s, (struct sockaddr *)&bar, sizeof bar) ; while ((r == -1) && (errno == EINTR)) ; if ((r == -1) && (errno == EALREADY)) errno = EINPROGRESS ; return 0 ; } skalibs-2.14.1.1/src/sysdeps/tryitimer.c000066400000000000000000000002341455624754300200610ustar00rootroot00000000000000/* ISC license. */ #include int main (void) { struct itimerval blah ; if (getitimer(ITIMER_REAL, &blah) < 0) return 111 ; return 0 ; } skalibs-2.14.1.1/src/sysdeps/trylinkat.c000066400000000000000000000006731455624754300200610ustar00rootroot00000000000000/* ISC license. */ #undef _POSIX_C_SOURCE #undef _XOPEN_SOURCE #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif #ifndef _ATFILE_SOURCE #define _ATFILE_SOURCE #endif #ifndef _INCOMPLETE_XOPEN_C063 #define _INCOMPLETE_XOPEN_C063 #endif #ifndef __EXTENSIONS__ #define __EXTENSIONS__ #endif #include #include int main (void) { int r = linkat(AT_FDCWD, "/foo", AT_FDCWD, "foo", AT_SYMLINK_FOLLOW) ; return (r < 0) ; } skalibs-2.14.1.1/src/sysdeps/trylsock.c000066400000000000000000000003461455624754300177070ustar00rootroot00000000000000/* ISC license. */ #undef _POSIX_C_SOURCE #undef _XOPEN_SOURCE #ifndef _XPG4_2 #define _XPG4_2 #endif #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif #include int main (void) { shutdown(0, 0) ; return 0 ; } skalibs-2.14.1.1/src/sysdeps/trymalloc0.c000066400000000000000000000001221455624754300201130ustar00rootroot00000000000000/* ISC license */ #include int main (void) { return !malloc(0) ; } skalibs-2.14.1.1/src/sysdeps/trymemmem.c000066400000000000000000000006441455624754300200520ustar00rootroot00000000000000/* ISC license. */ #undef _POSIX_C_SOURCE #undef _XOPEN_SOURCE #ifndef __EXTENSIONS__ #define __EXTENSIONS__ #endif #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif #ifndef _BSD_SOURCE #define _BSD_SOURCE #endif #ifndef _NETBSD_SOURCE #define _NETBSD_SOURCE #endif #ifndef _INCOMPLETE_XOPEN_C063 #define _INCOMPLETE_XOPEN_C063 #endif #include int main (void) { memmem("blah", 4, "la", 2) ; return 0 ; } skalibs-2.14.1.1/src/sysdeps/trymsgdontwait.c000066400000000000000000000003161455624754300211310ustar00rootroot00000000000000/* ISC license. */ #undef _POSIX_C_SOURCE #undef _XOPEN_SOURCE #ifndef _XPG4_2 # define _XPG4_2 #endif #ifndef _BSD_SOURCE #define _BSD_SOURCE #endif #include int value = MSG_DONTWAIT ; skalibs-2.14.1.1/src/sysdeps/trynamespaces.c000066400000000000000000000006151455624754300207120ustar00rootroot00000000000000/* ISC license. */ #undef _POSIX_C_SOURCE #undef _XOPEN_SOURCE #ifndef __EXTENSIONS__ #define __EXTENSIONS__ #endif #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif #ifndef _BSD_SOURCE #define _BSD_SOURCE #endif #ifndef _NETBSD_SOURCE #define _NETBSD_SOURCE #endif #ifndef _INCOMPLETE_XOPEN_C063 #define _INCOMPLETE_XOPEN_C063 #endif #include int main (void) { return unshare(0) ; } skalibs-2.14.1.1/src/sysdeps/trynsgetparent.c000066400000000000000000000002501455624754300211200ustar00rootroot00000000000000/* ISC license. */ #undef _POSIX_C_SOURCE #undef _XOPEN_SOURCE #include #include int main (void) { return ioctl(0, NS_GET_PARENT) ; } skalibs-2.14.1.1/src/sysdeps/tryodirectory.c000066400000000000000000000001021455624754300207450ustar00rootroot00000000000000/* ISC license. */ #include int dummy = O_DIRECTORY ; skalibs-2.14.1.1/src/sysdeps/tryopenat.c000066400000000000000000000006331455624754300200610ustar00rootroot00000000000000/* ISC license. */ #undef _POSIX_C_SOURCE #undef _XOPEN_SOURCE #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif #ifndef _ATFILE_SOURCE #define _ATFILE_SOURCE #endif #ifndef _INCOMPLETE_XOPEN_C063 #define _INCOMPLETE_XOPEN_C063 #endif #ifndef __EXTENSIONS__ #define __EXTENSIONS__ #endif #include #include int main (void) { int fd = openat(0, "/", O_RDONLY) ; return (fd < 0) ; } skalibs-2.14.1.1/src/sysdeps/trypipe2.c000066400000000000000000000007551455624754300176170ustar00rootroot00000000000000/* ISC license. */ #undef _POSIX_C_SOURCE #undef _XOPEN_SOURCE #ifndef __EXTENSIONS__ #define __EXTENSIONS__ #endif #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif #ifndef _BSD_SOURCE #define _BSD_SOURCE #endif #ifndef _DEFAULT_SOURCE #define _DEFAULT_SOURCE #endif #ifndef _NETBSD_SOURCE #define _NETBSD_SOURCE #endif #ifndef _INCOMPLETE_XOPEN_C063 #define _INCOMPLETE_XOPEN_C063 #endif #include int main (void) { int p[2] ; if (pipe2(p, 0) < 0) return 111 ; return 0 ; } skalibs-2.14.1.1/src/sysdeps/tryposixspawn.c000066400000000000000000000005441455624754300210070ustar00rootroot00000000000000/* ISC license. */ #include int main (void) { pid_t pid ; posix_spawn_file_actions_t actions ; posix_spawnattr_t attr ; char *const argv[2] = { "/bin/true", 0 } ; char *const envp[1] = { 0 } ; posix_spawnattr_setflags(&attr, 0) ; posix_spawn_file_actions_init(&actions) ; return posix_spawn(&pid, argv[0], 0, 0, argv, envp) ; } skalibs-2.14.1.1/src/sysdeps/tryposixspawnchdir.c000066400000000000000000000011441455624754300220160ustar00rootroot00000000000000/* ISC license. */ #undef _POSIX_C_SOURCE #undef _XOPEN_SOURCE #ifndef _XPG4_2 #define _XPG4_2 #endif #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif #ifndef _DEFAULT_SOURCE #define _DEFAULT_SOURCE #endif #include int main (void) { pid_t pid ; posix_spawn_file_actions_t actions ; posix_spawnattr_t attr ; char *const argv[2] = { "/bin/true", 0 } ; char *const envp[1] = { 0 } ; posix_spawn_file_actions_init(&actions) ; posix_spawn_file_actions_addchdir(&actions, "/") ; posix_spawn_file_actions_addfchdir(&actions, -1) ; return posix_spawn(&pid, argv[0], 0, 0, argv, envp) ; } skalibs-2.14.1.1/src/sysdeps/tryposixspawnchdirnp.c000066400000000000000000000011521455624754300223530ustar00rootroot00000000000000/* ISC license. */ #undef _POSIX_C_SOURCE #undef _XOPEN_SOURCE #ifndef _XPG4_2 #define _XPG4_2 #endif #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif #ifndef _DEFAULT_SOURCE #define _DEFAULT_SOURCE #endif #include int main (void) { pid_t pid ; posix_spawn_file_actions_t actions ; posix_spawnattr_t attr ; char *const argv[2] = { "/bin/true", 0 } ; char *const envp[1] = { 0 } ; posix_spawn_file_actions_init(&actions) ; posix_spawn_file_actions_addchdir_np(&actions, "/") ; posix_spawn_file_actions_addfchdir_np(&actions, -1) ; return posix_spawn(&pid, argv[0], 0, 0, argv, envp) ; } skalibs-2.14.1.1/src/sysdeps/tryposixspawnearlyreturn.c000066400000000000000000000011241455624754300232770ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include int main (void) { posix_spawnattr_t attr ; int e ; char tmp[40] = "./tryposixspawnearlyreturn child:XXXXXX" ; char *argv[2] = { tmp, 0 } ; char *env = 0 ; int fd = mkstemp(tmp) ; if (fd == -1) return 111 ; e = posix_spawnattr_init(&attr) ; if (e) return 111 ; e = posix_spawnattr_setflags(&attr, 0) ; if (e) return 111 ; if (close(fd) == -1 || unlink(tmp) == -1) return 111 ; e = posix_spawn(0, argv[0], 0, &attr, argv, &env) ; return e ? e == ENOENT ? 1 : 111 : 0 ; } skalibs-2.14.1.1/src/sysdeps/tryposixspawnsetsid.c000066400000000000000000000010621455624754300222170ustar00rootroot00000000000000/* ISC license. */ #undef _POSIX_C_SOURCE #undef _XOPEN_SOURCE #ifndef _XPG4_2 #define _XPG4_2 #endif #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif #ifndef _DEFAULT_SOURCE #define _DEFAULT_SOURCE #endif #include int main (void) { pid_t pid ; posix_spawn_file_actions_t actions ; posix_spawnattr_t attr ; char *const argv[2] = { "/bin/true", 0 } ; char *const envp[1] = { 0 } ; posix_spawnattr_setflags(&attr, POSIX_SPAWN_SETSID) ; posix_spawn_file_actions_init(&actions) ; return posix_spawn(&pid, argv[0], 0, 0, argv, envp) ; } skalibs-2.14.1.1/src/sysdeps/tryposixspawnsetsidnp.c000066400000000000000000000010651455624754300225600ustar00rootroot00000000000000/* ISC license. */ #undef _POSIX_C_SOURCE #undef _XOPEN_SOURCE #ifndef _XPG4_2 #define _XPG4_2 #endif #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif #ifndef _DEFAULT_SOURCE #define _DEFAULT_SOURCE #endif #include int main (void) { pid_t pid ; posix_spawn_file_actions_t actions ; posix_spawnattr_t attr ; char *const argv[2] = { "/bin/true", 0 } ; char *const envp[1] = { 0 } ; posix_spawnattr_setflags(&attr, POSIX_SPAWN_SETSID_NP) ; posix_spawn_file_actions_init(&actions) ; return posix_spawn(&pid, argv[0], 0, 0, argv, envp) ; } skalibs-2.14.1.1/src/sysdeps/tryppoll.c000066400000000000000000000011141455624754300177140ustar00rootroot00000000000000/* ISC license. */ #undef _POSIX_C_SOURCE #undef _XOPEN_SOURCE #ifndef _BSD_SOURCE #define _BSD_SOURCE #endif #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif #ifndef _DEFAULT_SOURCE #define _DEFAULT_SOURCE #endif #include #include #include #include int main (void) { struct pollfd x = { .events = POLLIN } ; struct timespec ts = { .tv_sec = 0, .tv_nsec = 10 } ; x.fd = open("src/sysdeps/tryppoll.c", O_RDONLY); if (x.fd < 0) return 111 ; if (ppoll(&x, 1, &ts, 0) < 0) return 1 ; if (x.revents != POLLIN) return 1 ; return 0 ; } skalibs-2.14.1.1/src/sysdeps/trypthread.c000066400000000000000000000010171455624754300202170ustar00rootroot00000000000000/* ISC license. */ #include #include void *pstart (void *arg) { (void)arg ; return 0 ; } int main (void) { pthread_t th ; pthread_attr_t attr ; pthread_cond_t cond = PTHREAD_COND_INITIALIZER ; pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER ; struct timespec ts = { .tv_sec = 1, .tv_nsec = 0 } ; void *p ; int e = pthread_attr_init(&attr) ; e = pthread_create(&th, &attr, &pstart, 0) ; e = pthread_cond_timedwait(&cond, &mutex, &ts) ; e = pthread_join(th, &p) ; return 0 ; } skalibs-2.14.1.1/src/sysdeps/tryrevoke.c000066400000000000000000000002011455624754300200550ustar00rootroot00000000000000/* ISC license. */ #undef _POSIX_C_SOURCE #undef _XOPEN_SOURCE #include int main (void) { return revoke("/") ; } skalibs-2.14.1.1/src/sysdeps/trysendfile.c000066400000000000000000000001541455624754300203620ustar00rootroot00000000000000/* ISC license. */ #include int main (void) { sendfile(1, 0, 0, 4096) ; return 0 ; } skalibs-2.14.1.1/src/sysdeps/trysetgroups.c000066400000000000000000000007101455624754300206220ustar00rootroot00000000000000/* ISC license. */ #undef _POSIX_C_SOURCE #undef _XOPEN_SOURCE #ifndef _BSD_SOURCE #define _BSD_SOURCE #endif #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif #ifndef _DEFAULT_SOURCE #define _DEFAULT_SOURCE #endif #ifndef _NETBSD_SOURCE #define _NETBSD_SOURCE #endif #ifndef __EXTENSIONS__ #define __EXTENSIONS__ #endif #include #include #include int main (void) { gid_t g = 0 ; setgroups(1, &g) ; return 0 ; } skalibs-2.14.1.1/src/sysdeps/trysettimeofday.c000066400000000000000000000005351455624754300212710ustar00rootroot00000000000000/* ISC license. */ #undef _POSIX_C_SOURCE #undef _XOPEN_SOURCE #ifndef _BSD_SOURCE #define _BSD_SOURCE #endif #ifndef _NETBSD_SOURCE #define _NETBSD_SOURCE #endif #ifndef __EXTENSIONS__ #define __EXTENSIONS__ #endif #include int main (void) { struct timeval tv ; gettimeofday(&tv, 0) ; settimeofday(&tv, 0) ; return 0 ; } skalibs-2.14.1.1/src/sysdeps/trysignalfd.c000066400000000000000000000003021455624754300203530ustar00rootroot00000000000000/* ISC license. */ #include #include int main (void) { sigset_t foo ; sigemptyset(&foo) ; if (signalfd(-1, &foo, SFD_NONBLOCK) < 0) return 1 ; return 0 ; } skalibs-2.14.1.1/src/sysdeps/trysopeercred.c000066400000000000000000000005441455624754300207270ustar00rootroot00000000000000/* ISC license. */ #undef _POSIX_C_SOURCE #undef _XOPEN_SOURCE #ifndef _XPG4_2 #define _XPG4_2 #endif #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif #include #include int main (void) { int s ; struct ucred dummy ; socklen_t len = sizeof(struct ucred) ; return getsockopt(s, SOL_SOCKET, SO_PEERCRED, &dummy, &len) ; } skalibs-2.14.1.1/src/sysdeps/trysplice.c000066400000000000000000000007071455624754300200540ustar00rootroot00000000000000/* ISC license. */ #undef _POSIX_C_SOURCE #undef _XOPEN_SOURCE #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif #include #include int main (void) { char s[2][2] ; struct iovec v[2] = { { .iov_base = s[0], .iov_len = 2 }, { .iov_base = s[1], .iov_len = 2 } } ; loff_t in, out ; ssize_t r = splice(0, &in, 1, &out, 4096, SPLICE_F_MOVE) ; r = tee(0, 1, 4096, SPLICE_F_NONBLOCK) ; r = vmsplice(0, v, 2, 0) ; return 0 ; } skalibs-2.14.1.1/src/sysdeps/trystatim.c000066400000000000000000000002751455624754300200760ustar00rootroot00000000000000/* ISC license. */ #include #include struct stat st ; struct timespec *tsa = &st.st_atim ; struct timespec *tsm = &st.st_mtim ; struct timespec *tsc = &st.st_ctim ; skalibs-2.14.1.1/src/sysdeps/trystatimespec.c000066400000000000000000000003711455624754300211130ustar00rootroot00000000000000/* ISC license. */ #undef _POSIX_C_SOURCE #undef _XOPEN_SOURCE #include #include struct stat st ; struct timespec *tsa = &st.st_atimespec ; struct timespec *tsm = &st.st_mtimespec ; struct timespec *tsc = &st.st_ctimespec ; skalibs-2.14.1.1/src/sysdeps/trystrcasestr.c000066400000000000000000000006401455624754300207660ustar00rootroot00000000000000/* ISC license. */ #undef _POSIX_C_SOURCE #undef _XOPEN_SOURCE #ifndef __EXTENSIONS__ #define __EXTENSIONS__ #endif #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif #ifndef _BSD_SOURCE #define _BSD_SOURCE #endif #ifndef _NETBSD_SOURCE #define _NETBSD_SOURCE #endif #ifndef _INCOMPLETE_XOPEN_C063 #define _INCOMPLETE_XOPEN_C063 #endif #include int main (void) { return !strcasestr("foobar", "bar") ; } skalibs-2.14.1.1/src/sysdeps/trystrnlen.c000066400000000000000000000001301455624754300202500ustar00rootroot00000000000000/* ISC license. */ #include int main (void) { return strnlen("/", 1) ; } skalibs-2.14.1.1/src/sysdeps/trytimer.c000066400000000000000000000010271455624754300177110ustar00rootroot00000000000000/* ISC license. */ #include #include int main (void) { timer_t blah ; struct itimerspec it = { .it_interval = { .tv_sec = 0, .tv_nsec = 0 }, .it_value = { .tv_sec = 1, .tv_nsec = 0 } } ; struct sigevent se = { .sigev_notify = SIGEV_SIGNAL, .sigev_signo = SIGALRM, .sigev_value = { .sival_int = 0 }, .sigev_notify_function = 0, .sigev_notify_attributes = 0 } ; if (timer_create(CLOCK_REALTIME, &se, &blah) < 0) return 111 ; if (timer_settime(blah, TIMER_ABSTIME, &it, 0) < 0) return 111 ; return 0 ; } skalibs-2.14.1.1/src/sysdeps/tryuint64t.c000066400000000000000000000000761455624754300201110ustar00rootroot00000000000000/* ISC license. */ #include uint64_t dummy = 0 ; skalibs-2.14.1.1/src/sysdeps/trywaitid.c000066400000000000000000000002571455624754300200560ustar00rootroot00000000000000/* ISC license. */ #include #include #include int main (void) { siginfo_t info ; waitid(P_PID, 0, &info, WEXITED) ; return 0 ; } skalibs-2.14.1.1/tools/000077500000000000000000000000001455624754300145455ustar00rootroot00000000000000skalibs-2.14.1.1/tools/convert-leapsecs.c000066400000000000000000000025761455624754300202000ustar00rootroot00000000000000/* ISC license. */ #include #include #include #include #include #include #include #include static genalloc table = GENALLOC_ZERO ; /* uint64_t */ static void add_leapsecs (uint64_t *t) { uint64_t *tab = genalloc_s(uint64_t, &table) ; size_t n = genalloc_len(uint64_t, &table) ; size_t i = 0 ; for (; i < n ; i++) if (*t >= tab[i]) (*t)++ ; } int main (int argc, char const *const *argv) { stralloc sa = STRALLOC_ZERO ; for (;;) { struct tm tm ; uint64_t tt ; time_t t ; int r ; char fmt[UINT64_FMT] ; sa.len = 0 ; r = skagetln(buffer_0, &sa, '\n') ; if (r < 0) strerr_diefu1sys(111, "read from stdin") ; if (!r) break ; sa.s[sa.len-1] = 0 ; if (!strptime(sa.s, "+%Y-%m-%d", &tm)) continue ; tm.tm_sec = 59 ; tm.tm_min = 59 ; tm.tm_hour = 23 ; t = mktime(&tm) ; if (t < 0) strerr_diefu1sys(111, "mktime") ; tt = t + 1 ; add_leapsecs(&tt) ; if (!genalloc_append(uint64_t, &table, &tt)) strerr_diefu1sys(111, "genalloc_append") ; fmt[uint64_fmt(fmt, tt)] = 0 ; buffer_puts(buffer_1, " TAI_MAGIC + ") ; buffer_puts(buffer_1, fmt) ; buffer_puts(buffer_1, ",\n") ; } buffer_unput(buffer_1, 2) ; buffer_putsflush(buffer_1, "\n") ; return 0 ; } skalibs-2.14.1.1/tools/gen-bits.sh000077500000000000000000000020071455624754300166130ustar00rootroot00000000000000#!/bin/sh -e sysdeps="$1" bits="$2" dfmt="$3" ofmt="$4" xfmt="$5" bfmt="$6" gen_bits() { sed -e "s/@BITS@/$1/g; s/@DFMT@/$2/g; s/@OFMT@/$3/g; s/@XFMT@/$4/g; s/@BFMT@/$5/g;" < src/headers/bits-template } tools/gen-types-internal.sh "" "" "$bits" < src/headers/bits-header if test "$bits" = 64 ; then cat src/headers/uint64-defs if grep -qF 'uint64t: no' "$sysdeps" ; then if grep -qF 'sizeofulong: 8' "$sysdeps" ; then cat src/headers/uint64-ulong64 else cat src/headers/uint64-noulong64 fi cat src/headers/uint64-macros fi else cat src/headers/uint64-include fi if grep -qF 'endianness: little' < "$sysdeps" ; then endian=l elif grep -qF 'endianness: big' < "$sysdeps" ; then endian=b else echo 'Error ! Unsupported endianness' 1>&2 ./crash fi cat "src/headers/uint${bits}-bswap" tools/gen-types-internal.sh "" "" "$bits" < src/headers/bits-${endian}endian gen_bits "$bits" "$dfmt" "$ofmt" "$xfmt" "$bfmt" exec tools/gen-types-internal.sh "" "" "$bits" < src/headers/bits-footer skalibs-2.14.1.1/tools/gen-deps.sh000077500000000000000000000024771455624754300166200ustar00rootroot00000000000000#!/bin/sh -e . package/info echo '#' echo '# This file has been generated by tools/gen-deps.sh' echo '#' echo for dir in src/include/${package} src/lib* ; do for file in $(ls -1 $dir | grep -- \\.h$) ; do { grep -F "#include <${package}/" < ${dir}/$file | cut -d/ -f2- | cut -d'>' -f1 ; grep -- '#include ".*-internal\.h"' < ${dir}/$file | cut -d'"' -f2 } | sort -u | { deps= while read dep ; do if echo $dep | grep -q -- -internal\\.h$ ; then deps="$deps ${dir}/$dep" else deps="$deps src/include/${package}/$dep" fi done if test -n "$deps" ; then echo "${dir}/${file}:${deps}" fi } done done for dir in src/lib* ; do for file in $(ls -1 $dir | grep -- \\.c$) ; do { grep -F "#include <${package}/" < ${dir}/$file | cut -d/ -f2- | cut -d'>' -f1 ; grep -- '#include ".*-internal\.h"' < ${dir}/$file | cut -d'"' -f2 } | sort -u | { deps=" ${dir}/$file" while read dep ; do if echo $dep | grep -q -- -internal\\.h$ ; then deps="$deps ${dir}/$dep" else deps="$deps src/include/${package}/$dep" fi done o=$(echo $file | sed s/\\.c$/.o/) lo=$(echo $file | sed s/\\.c$/.lo/) echo "${dir}/${o} ${dir}/${lo}:${deps}" } done done skalibs-2.14.1.1/tools/gen-sysdepsh.sh000077500000000000000000000014231455624754300175150ustar00rootroot00000000000000#!/bin/sh cat <&2 exit 1 } mkdirp=false symlink=false mode=0755 og= while getopts Dlm:O: name ; do case "$name" in D) mkdirp=true ;; l) symlink=true ;; m) mode=$OPTARG ;; O) og=$OPTARG ;; ?) usage ;; esac done shift $(($OPTIND - 1)) test "$#" -eq 2 || usage src=$1 dst=$2 tmp="$dst.tmp.$$" case "$dst" in */) echo "$0: $dst ends in /" 1>&2 ; exit 1 ;; esac set -C set -e if $mkdirp ; then umask 022 case "$2" in */*) mkdir -p "${dst%/*}" ;; esac fi trap 'rm -f "$tmp"' EXIT INT QUIT TERM HUP umask 077 if $symlink ; then ln -s "$src" "$tmp" else cat < "$1" > "$tmp" if test -n "$og" ; then chown -- "$og" "$tmp" fi chmod -- "$mode" "$tmp" fi mv -f "$tmp" "$dst" if test -d "$dst" ; then rm -f "$dst/$(basename $tmp)" if $symlink ; then mkdir "$tmp" ln -s "$src" "$tmp/$(basename $dst)" mv -f "$tmp/$(basename $dst)" "${dst%/*}" rmdir "$tmp" else echo "$0: $dst is a directory" 1>&2 exit 1 fi fi skalibs-2.14.1.1/tools/leapsecs.txt000066400000000000000000000006001455624754300171010ustar00rootroot00000000000000# # 1972-01-01 00:00:00 UTC was 1972-01-01 00:00:10 TAI. # +1972-06-30 +1972-12-31 +1973-12-31 +1974-12-31 +1975-12-31 +1976-12-31 +1977-12-31 +1978-12-31 +1979-12-31 +1981-06-30 +1982-06-30 +1983-06-30 +1985-06-30 +1987-12-31 +1989-12-31 +1990-12-31 +1992-06-30 +1993-06-30 +1994-06-30 +1995-12-31 +1997-06-30 +1998-12-31 +2005-12-31 +2008-12-31 +2012-06-30 +2015-06-30 +2016-12-31 skalibs-2.14.1.1/tools/make-leapsecs_table000077500000000000000000000012751455624754300203610ustar00rootroot00000000000000#!/command/execlineb -P # Compile convert-leapsecs.c, then use this to create # src/libstddjb/leapsecs_table.c define PREFIX ./tools backtick -n N { pipeline { redirfd -r 0 ${PREFIX}/leapsecs.txt ${PREFIX}/convert-leapsecs } wc -l } import -u N if { s6-echo "/* ISC license. */ /* This file has been generated by ./tools/make-leapsecs_table */ #include #include #include \"djbtime-internal.h\" unsigned int const leapsecs_table_len = ${N} ; static uint64_t const leapsecs_table_[${N}] =\n{" } if { redirfd -r 0 ${PREFIX}/leapsecs.txt ${PREFIX}/convert-leapsecs } s6-echo "} ;\nuint64_t const *const leapsecs_table = leapsecs_table_ ;"