changeset 432:38cf60f5a1c4

util: cleanup hierarchy
author David Demelier <markand@malikania.fr>
date Sat, 15 Oct 2022 20:28:59 +0200
parents 8f59201dc76b
children 862b15c3a3ae
files GNUmakefile libmlk-core/mlk/core/sys.c libmlk-core/mlk/core/sys_p.h libmlk-core/mlk/core/util.c libmlk-util/mlk/util/fmemopen.c libmlk-util/mlk/util/openbsd/basename.c libmlk-util/mlk/util/openbsd/dirname.c libmlk-util/mlk/util/openbsd/getopt.c libmlk-util/mlk/util/openbsd/strlcat.c libmlk-util/mlk/util/openbsd/strlcpy.c libmlk-util/mlk/util/util.h src/libmlk-rpg/rpg/map-file.c src/libmlk-rpg/rpg/save.c src/libmlk-rpg/rpg/tileset-file.c src/libmlk-util/util/fmemopen.c src/libmlk-util/util/openbsd/basename.c src/libmlk-util/util/openbsd/dirname.c src/libmlk-util/util/openbsd/getopt.c src/libmlk-util/util/openbsd/strlcat.c src/libmlk-util/util/openbsd/strlcpy.c src/libmlk-util/util/util.h src/tools/map/mlk-map.c
diffstat 22 files changed, 538 insertions(+), 538 deletions(-) [+]
line wrap: on
line diff
--- a/GNUmakefile	Sat Oct 15 20:23:14 2022 +0200
+++ b/GNUmakefile	Sat Oct 15 20:28:59 2022 +0200
@@ -41,7 +41,7 @@
 # Global INCS, OPTS and DEFS for every targets.
 INCS :=                 -Iextern/libdt \
                         -Iextern/libsqlite \
-                        -Isrc/libmlk-util \
+                        -Ilibmlk-util \
                         -Ilibmlk-core \
                         -Isrc/libmlk-ui \
                         -Isrc/libmlk-rpg \
@@ -100,12 +100,12 @@
 # {{{ libmlk-util
 
 LIBMLK_UTIL :=          libmlk-util.a
-LIBMLK_UTIL_SRCS :=     src/libmlk-util/util/fmemopen.c \
-                        src/libmlk-util/util/openbsd/basename.c \
-                        src/libmlk-util/util/openbsd/dirname.c \
-                        src/libmlk-util/util/openbsd/getopt.c \
-                        src/libmlk-util/util/openbsd/strlcat.c \
-                        src/libmlk-util/util/openbsd/strlcpy.c
+LIBMLK_UTIL_SRCS :=     libmlk-util/mlk/util/fmemopen.c \
+                        libmlk-util/mlk/util/openbsd/basename.c \
+                        libmlk-util/mlk/util/openbsd/dirname.c \
+                        libmlk-util/mlk/util/openbsd/getopt.c \
+                        libmlk-util/mlk/util/openbsd/strlcat.c \
+                        libmlk-util/mlk/util/openbsd/strlcpy.c
 LIBMLK_UTIL_OBJS :=     $(LIBMLK_UTIL_SRCS:.c=.o)
 LIBMLK_UTIL_DEPS :=     $(LIBMLK_UTIL_SRCS:.c=.d)
 
@@ -144,7 +144,7 @@
 
 MLK_MAP :=              src/tools/map/mlk-map
 
-$(MLK_MAP): INCS := -Isrc/libmlk-util $(JANSSON_INCS)
+$(MLK_MAP): INCS := -Ilibmlk-util $(JANSSON_INCS)
 $(MLK_MAP): LIBS := $(LIBMLK_UTIL) $(JANSSON_LIBS)
 $(MLK_MAP): $(LIBMLK_UTIL)
 
--- a/libmlk-core/mlk/core/sys.c	Sat Oct 15 20:23:14 2022 +0200
+++ b/libmlk-core/mlk/core/sys.c	Sat Oct 15 20:28:59 2022 +0200
@@ -38,7 +38,7 @@
 
 #include <sndfile.h>
 
-#include <util/util.h>
+#include <mlk/util/util.h>
 
 #include "alloc.h"
 #include "error.h"
--- a/libmlk-core/mlk/core/sys_p.h	Sat Oct 15 20:23:14 2022 +0200
+++ b/libmlk-core/mlk/core/sys_p.h	Sat Oct 15 20:28:59 2022 +0200
@@ -19,7 +19,7 @@
 #ifndef MLK_CORE_SYS_P_H
 #define MLK_CORE_SYS_P_H
 
-#include <util/util.h>
+#include <mlk/util/util.h>
 
 #include <stddef.h>
 
--- a/libmlk-core/mlk/core/util.c	Sat Oct 15 20:23:14 2022 +0200
+++ b/libmlk-core/mlk/core/util.c	Sat Oct 15 20:28:59 2022 +0200
@@ -22,7 +22,7 @@
 
 #include <SDL.h>
 
-#include <util/util.h>
+#include <mlk/util/util.h>
 
 #include "util.h"
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libmlk-util/mlk/util/fmemopen.c	Sat Oct 15 20:28:59 2022 +0200
@@ -0,0 +1,75 @@
+/*
+ * fmemopen.h -- fmemopen polyfill
+ *
+ * Copyright (c) 2020-2022 David Demelier <markand@malikania.fr>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include "util.h"
+
+#if !defined(MLK_HAS_FMEMOPEN)
+
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <io.h>
+#include <share.h>
+#include <stdio.h>
+#include <string.h>
+#include <windows.h>
+
+FILE *
+util_fmemopen(void *buf, size_t size, const char *mode)
+{
+	char temppath[MAX_PATH + 1], filename[MAX_PATH + 1];
+	FILE *fp;
+	int fd, flags;
+
+	flags = _O_CREAT        |
+	        _O_SHORT_LIVED  |
+	        _O_TEMPORARY    |
+	        _O_RDWR         |
+	        _O_NOINHERIT;
+
+	if (strchr(mode, 'b'))
+		flags |= _O_BINARY;
+
+	if (!GetTempPath(sizeof (temppath), temppath))
+		return NULL;
+	if (!GetTempFileName(temppath, "MLK", 0, filename))
+		return NULL;
+	if ((fd = _sopen(temppath, flags, _SH_DENYRW, _S_IREAD | _S_IWRITE)) < 0)
+		return NULL;
+	if (!(fp = _fdopen(fd, mode))) {
+		_close(fd);
+		return NULL;
+	}
+
+	fwrite(buf, size, 1, fp);
+	rewind(fp);
+
+	return fp;
+}
+
+#else /* !MLK_HAS_FMEMOPEN */
+
+#include <stdio.h>
+
+FILE *
+util_fmemopen(void *buf, size_t len, const char *type)
+{
+	return fmemopen(buf, len, type);
+}
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libmlk-util/mlk/util/openbsd/basename.c	Sat Oct 15 20:28:59 2022 +0200
@@ -0,0 +1,68 @@
+/*	$OpenBSD: basename.c,v 1.17 2020/10/20 19:30:14 naddy Exp $	*/
+
+/*
+ * Copyright (c) 1997, 2004 Todd C. Miller <millert@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <errno.h>
+#include <limits.h>
+#include <string.h>
+
+#ifndef PATH_MAX
+#       define PATH_MAX 2048
+#endif
+
+char *
+util_basename(char *path)
+{
+	static char bname[PATH_MAX];
+	size_t len;
+	const char *endp, *startp;
+
+	/* Empty or NULL string gets treated as "." */
+	if (path == NULL || *path == '\0') {
+		bname[0] = '.';
+		bname[1] = '\0';
+		return (bname);
+	}
+
+	/* Strip any trailing slashes */
+	endp = path + strlen(path) - 1;
+	while (endp > path && *endp == '/')
+		endp--;
+
+	/* All slashes becomes "/" */
+	if (endp == path && *endp == '/') {
+		bname[0] = '/';
+		bname[1] = '\0';
+		return (bname);
+	}
+
+	/* Find the start of the base */
+	startp = endp;
+	while (startp > path && *(startp - 1) != '/')
+		startp--;
+
+	len = endp - startp + 1;
+	if (len >= sizeof(bname)) {
+#if defined(ENAMETOOLONG)
+		errno = ENAMETOOLONG;
+#endif
+		return (NULL);
+	}
+	memcpy(bname, startp, len);
+	bname[len] = '\0';
+	return (bname);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libmlk-util/mlk/util/openbsd/dirname.c	Sat Oct 15 20:28:59 2022 +0200
@@ -0,0 +1,72 @@
+/*	$OpenBSD: dirname.c,v 1.17 2020/10/20 19:30:14 naddy Exp $	*/
+
+/*
+ * Copyright (c) 1997, 2004 Todd C. Miller <millert@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <errno.h>
+#include <limits.h>
+#include <string.h>
+
+#ifndef PATH_MAX
+#       define PATH_MAX 2048
+#endif
+
+char *
+util_dirname(char *path)
+{
+	static char dname[PATH_MAX];
+	size_t len;
+	const char *endp;
+
+	/* Empty or NULL string gets treated as "." */
+	if (path == NULL || *path == '\0') {
+		dname[0] = '.';
+		dname[1] = '\0';
+		return (dname);
+	}
+
+	/* Strip any trailing slashes */
+	endp = path + strlen(path) - 1;
+	while (endp > path && *endp == '/')
+		endp--;
+
+	/* Find the start of the dir */
+	while (endp > path && *endp != '/')
+		endp--;
+
+	/* Either the dir is "/" or there are no slashes */
+	if (endp == path) {
+		dname[0] = *endp == '/' ? '/' : '.';
+		dname[1] = '\0';
+		return (dname);
+	} else {
+		/* Move forward past the separating slashes */
+		do {
+			endp--;
+		} while (endp > path && *endp == '/');
+	}
+
+	len = endp - path + 1;
+	if (len >= sizeof(dname)) {
+#if defined(ENAMETOOLONG)
+		errno = ENAMETOOLONG;
+#endif
+		return (NULL);
+	}
+	memcpy(dname, path, len);
+	dname[len] = '\0';
+	return (dname);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libmlk-util/mlk/util/openbsd/getopt.c	Sat Oct 15 20:28:59 2022 +0200
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 1987, 1993, 1994
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int	util_opterr = 1,		/* if error message should be printed */
+	util_optind = 1,		/* index into parent argv vector */
+	util_optopt,			/* character checked for validity */
+	util_optreset;		/* reset getopt */
+char	*util_optarg;		/* argument associated with option */
+
+#define	BADCH	(int)'?'
+#define	BADARG	(int)':'
+#define	EMSG	""
+
+/*
+ * getopt --
+ *	Parse argc/argv argument vector.
+ */
+int
+util_getopt(int nargc, char * const *nargv, const char *ostr)
+{
+	static char *place = EMSG;		/* option letter processing */
+	char *oli;				/* option letter list index */
+
+	if (ostr == NULL)
+		return (-1);
+
+	if (util_optreset || !*place) {		/* update scanning pointer */
+		util_optreset = 0;
+		if (util_optind >= nargc || *(place = nargv[util_optind]) != '-') {
+			place = EMSG;
+			return (-1);
+		}
+		if (place[1] && *++place == '-') {	/* found "--" */
+			++util_optind;
+			place = EMSG;
+			return (-1);
+		}
+	}					/* option letter okay? */
+	if ((util_optopt = (int)*place++) == (int)':' ||
+	    !(oli = strchr(ostr, util_optopt))) {
+		/*
+		 * if the user didn't specify '-' as an option,
+		 * assume it means -1.
+		 */
+		if (util_optopt == (int)'-')
+			return (-1);
+		if (!*place)
+			++util_optind;
+		if (util_opterr && *ostr != ':')
+			(void)fprintf(stderr,
+			    "illegal option -- %c\n", util_optopt);
+		return (BADCH);
+	}
+	if (*++oli != ':') {			/* don't need argument */
+		util_optarg = NULL;
+		if (!*place)
+			++util_optind;
+	}
+	else {					/* need an argument */
+		if (*place)			/* no white space */
+			util_optarg = place;
+		else if (nargc <= ++util_optind) {	/* no arg */
+			place = EMSG;
+			if (*ostr == ':')
+				return (BADARG);
+			if (util_opterr)
+				(void)fprintf(stderr,
+				    "option requires an argument -- %c\n",
+				    util_optopt);
+			return (BADCH);
+		}
+		else				/* white space */
+			util_optarg = nargv[util_optind];
+		place = EMSG;
+		++util_optind;
+	}
+	return (util_optopt);			/* dump back option letter */
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libmlk-util/mlk/util/openbsd/strlcat.c	Sat Oct 15 20:28:59 2022 +0200
@@ -0,0 +1,55 @@
+/*	$OpenBSD: strlcat.c,v 1.19 2019/01/25 00:19:25 millert Exp $	*/
+
+/*
+ * Copyright (c) 1998, 2015 Todd C. Miller <millert@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <stddef.h>
+#include <string.h>
+
+/*
+ * Appends src to string dst of size dsize (unlike strncat, dsize is the
+ * full size of dst, not space left).  At most dsize-1 characters
+ * will be copied.  Always NUL terminates (unless dsize <= strlen(dst)).
+ * Returns strlen(src) + MIN(dsize, strlen(initial dst)).
+ * If retval >= dsize, truncation occurred.
+ */
+size_t
+util_strlcat(char *dst, const char *src, size_t dsize)
+{
+	const char *odst = dst;
+	const char *osrc = src;
+	size_t n = dsize;
+	size_t dlen;
+
+	/* Find the end of dst and adjust bytes left but don't go past end. */
+	while (n-- != 0 && *dst != '\0')
+		dst++;
+	dlen = dst - odst;
+	n = dsize - dlen;
+
+	if (n-- == 0)
+		return(dlen + strlen(src));
+	while (*src != '\0') {
+		if (n != 0) {
+			*dst++ = *src;
+			n--;
+		}
+		src++;
+	}
+	*dst = '\0';
+
+	return(dlen + (src - osrc));	/* count does not include NUL */
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libmlk-util/mlk/util/openbsd/strlcpy.c	Sat Oct 15 20:28:59 2022 +0200
@@ -0,0 +1,49 @@
+/*	$OpenBSD: strlcpy.c,v 1.16 2019/01/25 00:19:25 millert Exp $	*/
+
+/*
+ * Copyright (c) 1998, 2015 Todd C. Miller <millert@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <stddef.h>
+
+/*
+ * Copy string src to buffer dst of size dsize.  At most dsize-1
+ * chars will be copied.  Always NUL terminates (unless dsize == 0).
+ * Returns strlen(src); if retval >= dsize, truncation occurred.
+ */
+size_t
+util_strlcpy(char *dst, const char *src, size_t dsize)
+{
+	const char *osrc = src;
+	size_t nleft = dsize;
+
+	/* Copy as many bytes as will fit. */
+	if (nleft != 0) {
+		while (--nleft != 0) {
+			if ((*dst++ = *src++) == '\0')
+				break;
+		}
+	}
+
+	/* Not enough room in dst, add NUL and traverse rest of src. */
+	if (nleft == 0) {
+		if (dsize != 0)
+			*dst = '\0';		/* NUL-terminate dst */
+		while (*src++)
+			;
+	}
+
+	return(src - osrc - 1);	/* count does not include NUL */
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libmlk-util/mlk/util/util.h	Sat Oct 15 20:28:59 2022 +0200
@@ -0,0 +1,96 @@
+/*
+ * util.h -- miscellaneous utilities
+ *
+ * Copyright (c) 2020-2022 David Demelier <markand@malikania.fr>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef MLK_PORT_H
+#define MLK_PORT_H
+
+#include <limits.h>
+#include <stdio.h>
+
+/*
+ * This file helps finding what are the available features accross the various
+ * operating system in the landscape.
+ *
+ * The following macros are automatically set depending on the operating
+ * system:
+ *
+ * - MLK_OS_WINDOWS: running on any Windows machine
+ * - MLK_OS_POSIX: every mostly POSIX systems
+ *
+ * The following macro will be automatically defined unless the user override
+ * them:
+ *
+ * - MLK_HAS_FMEMOPEN: defined if fmemopen function is available.
+ * - MLK_HAS_SSIZE_T: defined if ssize_t typedef is available.
+ */
+
+#if defined(_WIN32)
+#       define MLK_OS_WINDOWS
+#elif defined(__FreeBSD__)
+#       define MLK_OS_POSIX
+#elif defined(__OpenBSD__)
+#       define MLK_OS_POSIX
+#elif defined(__NetBSD__)
+#       define MLK_OS_POSIX
+#elif defined(__linux__)
+#       define MLK_OS_POSIX
+#elif defined(__APPLE__)
+#       define MLK_OS_POSIX
+#       define MLK_OS_APPLE
+#endif
+
+#if !defined(PATH_MAX)
+#       define PATH_MAX 2048
+#endif
+
+#if defined(MLK_OS_POSIX) && !defined(MLK_HAS_SSIZE_T)
+#       define MLK_HAS_SSIZE_T
+#endif
+
+#if !defined(MLK_HAS_SSIZE_T)
+typedef long long int ssize_t;
+#endif
+
+#if defined(MLK_OS_POSIX) && !defined(MLK_HAS_FMEMOPEN)
+#       define MLK_HAS_FMEMOPEN
+#endif
+
+size_t
+util_strlcpy(char *, const char *, size_t);
+
+size_t
+util_strlcat(char *, const char *, size_t);
+
+FILE *
+util_fmemopen(void *, size_t, const char *);
+
+char *
+util_basename(char *);
+
+char *
+util_dirname(char *);
+
+extern int util_opterr;
+extern int util_optind;
+extern int util_optopt;
+extern char *util_optarg;
+
+int
+util_getopt(int, char **, const char *);
+
+#endif /* !MLK_PORT_H */
--- a/src/libmlk-rpg/rpg/map-file.c	Sat Oct 15 20:23:14 2022 +0200
+++ b/src/libmlk-rpg/rpg/map-file.c	Sat Oct 15 20:28:59 2022 +0200
@@ -24,7 +24,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include <util/util.h>
+#include <mlk/util/util.h>
 
 #include <mlk/core/alloc.h>
 #include <mlk/core/error.h>
--- a/src/libmlk-rpg/rpg/save.c	Sat Oct 15 20:23:14 2022 +0200
+++ b/src/libmlk-rpg/rpg/save.c	Sat Oct 15 20:28:59 2022 +0200
@@ -23,7 +23,7 @@
 
 #include <sqlite3.h>
 
-#include <util/util.h>
+#include <mlk/util/util.h>
 
 #include <mlk/core/error.h>
 #include <mlk/core/sys.h>
--- a/src/libmlk-rpg/rpg/tileset-file.c	Sat Oct 15 20:23:14 2022 +0200
+++ b/src/libmlk-rpg/rpg/tileset-file.c	Sat Oct 15 20:28:59 2022 +0200
@@ -24,7 +24,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include <util/util.h>
+#include <mlk/util/util.h>
 
 #include <mlk/core/alloc.h>
 #include <mlk/core/animation.h>
--- a/src/libmlk-util/util/fmemopen.c	Sat Oct 15 20:23:14 2022 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,75 +0,0 @@
-/*
- * fmemopen.h -- fmemopen polyfill
- *
- * Copyright (c) 2020-2022 David Demelier <markand@malikania.fr>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include "util.h"
-
-#if !defined(MLK_HAS_FMEMOPEN)
-
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#include <io.h>
-#include <share.h>
-#include <stdio.h>
-#include <string.h>
-#include <windows.h>
-
-FILE *
-util_fmemopen(void *buf, size_t size, const char *mode)
-{
-	char temppath[MAX_PATH + 1], filename[MAX_PATH + 1];
-	FILE *fp;
-	int fd, flags;
-
-	flags = _O_CREAT        |
-	        _O_SHORT_LIVED  |
-	        _O_TEMPORARY    |
-	        _O_RDWR         |
-	        _O_NOINHERIT;
-
-	if (strchr(mode, 'b'))
-		flags |= _O_BINARY;
-
-	if (!GetTempPath(sizeof (temppath), temppath))
-		return NULL;
-	if (!GetTempFileName(temppath, "MLK", 0, filename))
-		return NULL;
-	if ((fd = _sopen(temppath, flags, _SH_DENYRW, _S_IREAD | _S_IWRITE)) < 0)
-		return NULL;
-	if (!(fp = _fdopen(fd, mode))) {
-		_close(fd);
-		return NULL;
-	}
-
-	fwrite(buf, size, 1, fp);
-	rewind(fp);
-
-	return fp;
-}
-
-#else /* !MLK_HAS_FMEMOPEN */
-
-#include <stdio.h>
-
-FILE *
-util_fmemopen(void *buf, size_t len, const char *type)
-{
-	return fmemopen(buf, len, type);
-}
-
-#endif
--- a/src/libmlk-util/util/openbsd/basename.c	Sat Oct 15 20:23:14 2022 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*	$OpenBSD: basename.c,v 1.17 2020/10/20 19:30:14 naddy Exp $	*/
-
-/*
- * Copyright (c) 1997, 2004 Todd C. Miller <millert@openbsd.org>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <errno.h>
-#include <limits.h>
-#include <string.h>
-
-#ifndef PATH_MAX
-#       define PATH_MAX 2048
-#endif
-
-char *
-util_basename(char *path)
-{
-	static char bname[PATH_MAX];
-	size_t len;
-	const char *endp, *startp;
-
-	/* Empty or NULL string gets treated as "." */
-	if (path == NULL || *path == '\0') {
-		bname[0] = '.';
-		bname[1] = '\0';
-		return (bname);
-	}
-
-	/* Strip any trailing slashes */
-	endp = path + strlen(path) - 1;
-	while (endp > path && *endp == '/')
-		endp--;
-
-	/* All slashes becomes "/" */
-	if (endp == path && *endp == '/') {
-		bname[0] = '/';
-		bname[1] = '\0';
-		return (bname);
-	}
-
-	/* Find the start of the base */
-	startp = endp;
-	while (startp > path && *(startp - 1) != '/')
-		startp--;
-
-	len = endp - startp + 1;
-	if (len >= sizeof(bname)) {
-#if defined(ENAMETOOLONG)
-		errno = ENAMETOOLONG;
-#endif
-		return (NULL);
-	}
-	memcpy(bname, startp, len);
-	bname[len] = '\0';
-	return (bname);
-}
--- a/src/libmlk-util/util/openbsd/dirname.c	Sat Oct 15 20:23:14 2022 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,72 +0,0 @@
-/*	$OpenBSD: dirname.c,v 1.17 2020/10/20 19:30:14 naddy Exp $	*/
-
-/*
- * Copyright (c) 1997, 2004 Todd C. Miller <millert@openbsd.org>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <errno.h>
-#include <limits.h>
-#include <string.h>
-
-#ifndef PATH_MAX
-#       define PATH_MAX 2048
-#endif
-
-char *
-util_dirname(char *path)
-{
-	static char dname[PATH_MAX];
-	size_t len;
-	const char *endp;
-
-	/* Empty or NULL string gets treated as "." */
-	if (path == NULL || *path == '\0') {
-		dname[0] = '.';
-		dname[1] = '\0';
-		return (dname);
-	}
-
-	/* Strip any trailing slashes */
-	endp = path + strlen(path) - 1;
-	while (endp > path && *endp == '/')
-		endp--;
-
-	/* Find the start of the dir */
-	while (endp > path && *endp != '/')
-		endp--;
-
-	/* Either the dir is "/" or there are no slashes */
-	if (endp == path) {
-		dname[0] = *endp == '/' ? '/' : '.';
-		dname[1] = '\0';
-		return (dname);
-	} else {
-		/* Move forward past the separating slashes */
-		do {
-			endp--;
-		} while (endp > path && *endp == '/');
-	}
-
-	len = endp - path + 1;
-	if (len >= sizeof(dname)) {
-#if defined(ENAMETOOLONG)
-		errno = ENAMETOOLONG;
-#endif
-		return (NULL);
-	}
-	memcpy(dname, path, len);
-	dname[len] = '\0';
-	return (dname);
-}
--- a/src/libmlk-util/util/openbsd/getopt.c	Sat Oct 15 20:23:14 2022 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,108 +0,0 @@
-/*
- * Copyright (c) 1987, 1993, 1994
- *	The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-int	util_opterr = 1,		/* if error message should be printed */
-	util_optind = 1,		/* index into parent argv vector */
-	util_optopt,			/* character checked for validity */
-	util_optreset;		/* reset getopt */
-char	*util_optarg;		/* argument associated with option */
-
-#define	BADCH	(int)'?'
-#define	BADARG	(int)':'
-#define	EMSG	""
-
-/*
- * getopt --
- *	Parse argc/argv argument vector.
- */
-int
-util_getopt(int nargc, char * const *nargv, const char *ostr)
-{
-	static char *place = EMSG;		/* option letter processing */
-	char *oli;				/* option letter list index */
-
-	if (ostr == NULL)
-		return (-1);
-
-	if (util_optreset || !*place) {		/* update scanning pointer */
-		util_optreset = 0;
-		if (util_optind >= nargc || *(place = nargv[util_optind]) != '-') {
-			place = EMSG;
-			return (-1);
-		}
-		if (place[1] && *++place == '-') {	/* found "--" */
-			++util_optind;
-			place = EMSG;
-			return (-1);
-		}
-	}					/* option letter okay? */
-	if ((util_optopt = (int)*place++) == (int)':' ||
-	    !(oli = strchr(ostr, util_optopt))) {
-		/*
-		 * if the user didn't specify '-' as an option,
-		 * assume it means -1.
-		 */
-		if (util_optopt == (int)'-')
-			return (-1);
-		if (!*place)
-			++util_optind;
-		if (util_opterr && *ostr != ':')
-			(void)fprintf(stderr,
-			    "illegal option -- %c\n", util_optopt);
-		return (BADCH);
-	}
-	if (*++oli != ':') {			/* don't need argument */
-		util_optarg = NULL;
-		if (!*place)
-			++util_optind;
-	}
-	else {					/* need an argument */
-		if (*place)			/* no white space */
-			util_optarg = place;
-		else if (nargc <= ++util_optind) {	/* no arg */
-			place = EMSG;
-			if (*ostr == ':')
-				return (BADARG);
-			if (util_opterr)
-				(void)fprintf(stderr,
-				    "option requires an argument -- %c\n",
-				    util_optopt);
-			return (BADCH);
-		}
-		else				/* white space */
-			util_optarg = nargv[util_optind];
-		place = EMSG;
-		++util_optind;
-	}
-	return (util_optopt);			/* dump back option letter */
-}
--- a/src/libmlk-util/util/openbsd/strlcat.c	Sat Oct 15 20:23:14 2022 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-/*	$OpenBSD: strlcat.c,v 1.19 2019/01/25 00:19:25 millert Exp $	*/
-
-/*
- * Copyright (c) 1998, 2015 Todd C. Miller <millert@openbsd.org>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <stddef.h>
-#include <string.h>
-
-/*
- * Appends src to string dst of size dsize (unlike strncat, dsize is the
- * full size of dst, not space left).  At most dsize-1 characters
- * will be copied.  Always NUL terminates (unless dsize <= strlen(dst)).
- * Returns strlen(src) + MIN(dsize, strlen(initial dst)).
- * If retval >= dsize, truncation occurred.
- */
-size_t
-util_strlcat(char *dst, const char *src, size_t dsize)
-{
-	const char *odst = dst;
-	const char *osrc = src;
-	size_t n = dsize;
-	size_t dlen;
-
-	/* Find the end of dst and adjust bytes left but don't go past end. */
-	while (n-- != 0 && *dst != '\0')
-		dst++;
-	dlen = dst - odst;
-	n = dsize - dlen;
-
-	if (n-- == 0)
-		return(dlen + strlen(src));
-	while (*src != '\0') {
-		if (n != 0) {
-			*dst++ = *src;
-			n--;
-		}
-		src++;
-	}
-	*dst = '\0';
-
-	return(dlen + (src - osrc));	/* count does not include NUL */
-}
--- a/src/libmlk-util/util/openbsd/strlcpy.c	Sat Oct 15 20:23:14 2022 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-/*	$OpenBSD: strlcpy.c,v 1.16 2019/01/25 00:19:25 millert Exp $	*/
-
-/*
- * Copyright (c) 1998, 2015 Todd C. Miller <millert@openbsd.org>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <stddef.h>
-
-/*
- * Copy string src to buffer dst of size dsize.  At most dsize-1
- * chars will be copied.  Always NUL terminates (unless dsize == 0).
- * Returns strlen(src); if retval >= dsize, truncation occurred.
- */
-size_t
-util_strlcpy(char *dst, const char *src, size_t dsize)
-{
-	const char *osrc = src;
-	size_t nleft = dsize;
-
-	/* Copy as many bytes as will fit. */
-	if (nleft != 0) {
-		while (--nleft != 0) {
-			if ((*dst++ = *src++) == '\0')
-				break;
-		}
-	}
-
-	/* Not enough room in dst, add NUL and traverse rest of src. */
-	if (nleft == 0) {
-		if (dsize != 0)
-			*dst = '\0';		/* NUL-terminate dst */
-		while (*src++)
-			;
-	}
-
-	return(src - osrc - 1);	/* count does not include NUL */
-}
--- a/src/libmlk-util/util/util.h	Sat Oct 15 20:23:14 2022 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,96 +0,0 @@
-/*
- * util.h -- miscellaneous utilities
- *
- * Copyright (c) 2020-2022 David Demelier <markand@malikania.fr>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifndef MLK_PORT_H
-#define MLK_PORT_H
-
-#include <limits.h>
-#include <stdio.h>
-
-/*
- * This file helps finding what are the available features accross the various
- * operating system in the landscape.
- *
- * The following macros are automatically set depending on the operating
- * system:
- *
- * - MLK_OS_WINDOWS: running on any Windows machine
- * - MLK_OS_POSIX: every mostly POSIX systems
- *
- * The following macro will be automatically defined unless the user override
- * them:
- *
- * - MLK_HAS_FMEMOPEN: defined if fmemopen function is available.
- * - MLK_HAS_SSIZE_T: defined if ssize_t typedef is available.
- */
-
-#if defined(_WIN32)
-#       define MLK_OS_WINDOWS
-#elif defined(__FreeBSD__)
-#       define MLK_OS_POSIX
-#elif defined(__OpenBSD__)
-#       define MLK_OS_POSIX
-#elif defined(__NetBSD__)
-#       define MLK_OS_POSIX
-#elif defined(__linux__)
-#       define MLK_OS_POSIX
-#elif defined(__APPLE__)
-#       define MLK_OS_POSIX
-#       define MLK_OS_APPLE
-#endif
-
-#if !defined(PATH_MAX)
-#       define PATH_MAX 2048
-#endif
-
-#if defined(MLK_OS_POSIX) && !defined(MLK_HAS_SSIZE_T)
-#       define MLK_HAS_SSIZE_T
-#endif
-
-#if !defined(MLK_HAS_SSIZE_T)
-typedef long long int ssize_t;
-#endif
-
-#if defined(MLK_OS_POSIX) && !defined(MLK_HAS_FMEMOPEN)
-#       define MLK_HAS_FMEMOPEN
-#endif
-
-size_t
-util_strlcpy(char *, const char *, size_t);
-
-size_t
-util_strlcat(char *, const char *, size_t);
-
-FILE *
-util_fmemopen(void *, size_t, const char *);
-
-char *
-util_basename(char *);
-
-char *
-util_dirname(char *);
-
-extern int util_opterr;
-extern int util_optind;
-extern int util_optopt;
-extern char *util_optarg;
-
-int
-util_getopt(int, char **, const char *);
-
-#endif /* !MLK_PORT_H */
--- a/src/tools/map/mlk-map.c	Sat Oct 15 20:23:14 2022 +0200
+++ b/src/tools/map/mlk-map.c	Sat Oct 15 20:28:59 2022 +0200
@@ -26,7 +26,7 @@
 
 #include <jansson.h>
 
-#include <util/util.h>
+#include <mlk/util/util.h>
 
 static void
 die(const char *fmt, ...)