From e9a910b33c7837b4b868e3abda18eb4810df7f02 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Sat, 4 Oct 2025 09:14:33 +0100 Subject: config/git: import suckless sbase i currently use the output of sha512sum in several places of xbmk, which is a bit unreliable in case output changes. other cases where i use util outputs in variables are probably reliable, because i'm using mostly posix utilities in those. to mitigate this, i now import suckless sbase, which has a reasonable sha512sum implementation. *every* binary it builds is being placed in build.list, because i'll probably start using more of them. for example, i may start modifying the "date" implementation, adding the GNU-specific options that i need as mentioned on init.sh i'm importing it in util/ because the sha512sum util is needed for verifying project sources, so if sbase itself is a "project source", that means we can into a chicken and egg bootstrapping problem. this is sbase at revision: 055cc1ae1b3a13c3d8f25af0a4a3316590efcd48 Signed-off-by: Leah Rowe --- util/sbase/util.h | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 util/sbase/util.h (limited to 'util/sbase/util.h') diff --git a/util/sbase/util.h b/util/sbase/util.h new file mode 100644 index 00000000..6b6a084b --- /dev/null +++ b/util/sbase/util.h @@ -0,0 +1,97 @@ +/* See LICENSE file for copyright and license details. */ +#include + +#include +#include +#include +#include + +#include "arg.h" +#include "compat.h" + +#define UTF8_POINT(c) (((c) & 0xc0) != 0x80) + +#undef MIN +#define MIN(x,y) ((x) < (y) ? (x) : (y)) +#undef MAX +#define MAX(x,y) ((x) > (y) ? (x) : (y)) +#undef LIMIT +#define LIMIT(x, a, b) (x) = (x) < (a) ? (a) : (x) > (b) ? (b) : (x) + +#define LEN(x) (sizeof (x) / sizeof *(x)) + +extern char *argv0; + +void *ecalloc(size_t, size_t); +void *emalloc(size_t); +void *erealloc(void *, size_t); +#undef reallocarray +void *reallocarray(void *, size_t, size_t); +void *ereallocarray(void *, size_t, size_t); +char *estrdup(const char *); +char *estrndup(const char *, size_t); +void *encalloc(int, size_t, size_t); +void *enmalloc(int, size_t); +void *enrealloc(int, void *, size_t); +void *enreallocarray(int, void *, size_t, size_t); +char *enstrdup(int, const char *); +char *enstrndup(int, const char *, size_t); + +void enfshut(int, FILE *, const char *); +void efshut(FILE *, const char *); +int fshut(FILE *, const char *); + +void enprintf(int, const char *, ...); +void eprintf(const char *, ...); +void weprintf(const char *, ...); +void xvprintf(const char *, va_list); + +int confirm(const char*, ...); + +double estrtod(const char *); + +#undef strcasestr +#define strcasestr xstrcasestr +char *strcasestr(const char *, const char *); + +#undef strlcat +#define strlcat xstrlcat +size_t strlcat(char *, const char *, size_t); +size_t estrlcat(char *, const char *, size_t); +#undef strlcpy +#define strlcpy xstrlcpy +size_t strlcpy(char *, const char *, size_t); +size_t estrlcpy(char *, const char *, size_t); + +#undef strsep +#define strsep xstrsep +char *strsep(char **, const char *); + +void strnsubst(char **, const char *, const char *, size_t); + +/* regex */ +int enregcomp(int, regex_t *, const char *, int); +int eregcomp(regex_t *, const char *, int); + +/* io */ +ssize_t writeall(int, const void *, size_t); +int concat(int, const char *, int, const char *); + +/* misc */ +void enmasse(int, char **, int (*)(const char *, const char *, int)); +void fnck(const char *, const char *, int (*)(const char *, const char *, int), int); +mode_t getumask(void); +char *humansize(off_t); +mode_t parsemode(const char *, mode_t, mode_t); +off_t parseoffset(const char *); +void putword(FILE *, const char *); +#undef strtonum +#define strtonum xstrtonum +long long strtonum(const char *, long long, long long, const char **); +long long enstrtonum(int, const char *, long long, long long); +long long estrtonum(const char *, long long, long long); +size_t unescape(char *); +int mkdirp(const char *, mode_t, mode_t); +#undef memmem +#define memmem xmemmem +void *memmem(const void *, size_t, const void *, size_t); -- cgit v1.2.1