changeset 446:4607eea0eabc

util: prefix with mlk_
author David Demelier <markand@malikania.fr>
date Sat, 18 Feb 2023 12:15:14 +0100
parents 773a082f0b91
children e1fa1b867281
files libmlk-core/mlk/core/sys.c libmlk-rpg/mlk/rpg/map-file.c libmlk-rpg/mlk/rpg/save.c libmlk-rpg/mlk/rpg/tileset-file.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 mlk-map/mlk-map.c
diffstat 12 files changed, 50 insertions(+), 50 deletions(-) [+]
line wrap: on
line diff
--- a/libmlk-core/mlk/core/sys.c	Wed Feb 01 13:08:54 2023 +0100
+++ b/libmlk-core/mlk/core/sys.c	Sat Feb 18 12:15:14 2023 +0100
@@ -85,10 +85,10 @@
 	char *pref;
 
 	if ((pref = SDL_GetPrefPath(info.organization, info.name))) {
-		util_strlcpy(path, pref, sizeof (path));
+		mlk_util_strlcpy(path, pref, sizeof (path));
 		SDL_free(pref);
 	} else
-		util_strlcpy(path, "./", sizeof (path));
+		mlk_util_strlcpy(path, "./", sizeof (path));
 
 	return path;
 }
@@ -220,7 +220,7 @@
 	char path[PATH_MAX], *p;
 
 	/* Copy the directory to normalize and iterate over '/'. */
-	util_strlcpy(path, directory, sizeof (path));
+	mlk_util_strlcpy(path, directory, sizeof (path));
 	normalize(path);
 
 #if defined(_WIN32)
--- a/libmlk-rpg/mlk/rpg/map-file.c	Wed Feb 01 13:08:54 2023 +0100
+++ b/libmlk-rpg/mlk/rpg/map-file.c	Sat Feb 18 12:15:14 2023 +0100
@@ -224,8 +224,8 @@
 	char line[1024];
 	char basedir[PATH_MAX];
 
-	util_strlcpy(basedir, path, sizeof (basedir));
-	util_strlcpy(ctx->basedir, util_dirname(basedir), sizeof (ctx->basedir));
+	mlk_util_strlcpy(basedir, path, sizeof (basedir));
+	mlk_util_strlcpy(ctx->basedir, mlk_util_dirname(basedir), sizeof (ctx->basedir));
 
 	while (fgets(line, sizeof (line), ctx->fp)) {
 		/* Remove \n if any */
--- a/libmlk-rpg/mlk/rpg/save.c	Wed Feb 01 13:08:54 2023 +0100
+++ b/libmlk-rpg/mlk/rpg/save.c	Sat Feb 18 12:15:14 2023 +0100
@@ -139,7 +139,7 @@
 			char *str = va_arg(ap, char *);
 			size_t max = va_arg(ap, size_t);
 
-			util_strlcpy(str, (const char *)sqlite3_column_text(stmt->handle, c++), max);
+			mlk_util_strlcpy(str, (const char *)sqlite3_column_text(stmt->handle, c++), max);
 			break;
 		}
 		case 't':
--- a/libmlk-rpg/mlk/rpg/tileset-file.c	Wed Feb 01 13:08:54 2023 +0100
+++ b/libmlk-rpg/mlk/rpg/tileset-file.c	Sat Feb 18 12:15:14 2023 +0100
@@ -273,8 +273,8 @@
 	char line[1024];
 	char basedir[PATH_MAX];
 
-	util_strlcpy(basedir, path, sizeof (basedir));
-	util_strlcpy(ctx->basedir, util_dirname(basedir), sizeof (ctx->basedir));
+	mlk_util_strlcpy(basedir, path, sizeof (basedir));
+	mlk_util_strlcpy(ctx->basedir, mlk_util_dirname(basedir), sizeof (ctx->basedir));
 
 	while (fgets(line, sizeof (line), ctx->fp)) {
 		/* Remove \n if any */
--- a/libmlk-util/mlk/util/fmemopen.c	Wed Feb 01 13:08:54 2023 +0100
+++ b/libmlk-util/mlk/util/fmemopen.c	Sat Feb 18 12:15:14 2023 +0100
@@ -30,7 +30,7 @@
 #include <windows.h>
 
 FILE *
-util_fmemopen(void *buf, size_t size, const char *mode)
+mlk_util_fmemopen(void *buf, size_t size, const char *mode)
 {
 	char temppath[MAX_PATH + 1], filename[MAX_PATH + 1];
 	FILE *fp;
@@ -67,7 +67,7 @@
 #include <stdio.h>
 
 FILE *
-util_fmemopen(void *buf, size_t len, const char *type)
+mlk_util_fmemopen(void *buf, size_t len, const char *type)
 {
 	return fmemopen(buf, len, type);
 }
--- a/libmlk-util/mlk/util/openbsd/basename.c	Wed Feb 01 13:08:54 2023 +0100
+++ b/libmlk-util/mlk/util/openbsd/basename.c	Sat Feb 18 12:15:14 2023 +0100
@@ -25,7 +25,7 @@
 #endif
 
 char *
-util_basename(char *path)
+mlk_util_basename(char *path)
 {
 	static char bname[PATH_MAX];
 	size_t len;
--- a/libmlk-util/mlk/util/openbsd/dirname.c	Wed Feb 01 13:08:54 2023 +0100
+++ b/libmlk-util/mlk/util/openbsd/dirname.c	Sat Feb 18 12:15:14 2023 +0100
@@ -25,7 +25,7 @@
 #endif
 
 char *
-util_dirname(char *path)
+mlk_util_dirname(char *path)
 {
 	static char dname[PATH_MAX];
 	size_t len;
--- a/libmlk-util/mlk/util/openbsd/getopt.c	Wed Feb 01 13:08:54 2023 +0100
+++ b/libmlk-util/mlk/util/openbsd/getopt.c	Sat Feb 18 12:15:14 2023 +0100
@@ -31,11 +31,11 @@
 #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 */
+int	mlk_util_opterr = 1,		/* if error message should be printed */
+	mlk_util_optind = 1,		/* index into parent argv vector */
+	mlk_util_optopt,		/* character checked for validity */
+	mlk_util_optreset;		/* reset getopt */
+char	*mlk_util_optarg;		/* argument associated with option */
 
 #define	BADCH	(int)'?'
 #define	BADARG	(int)':'
@@ -46,7 +46,7 @@
  *	Parse argc/argv argument vector.
  */
 int
-util_getopt(int nargc, char * const *nargv, const char *ostr)
+mlk_util_getopt(int nargc, char * const *nargv, const char *ostr)
 {
 	static char *place = EMSG;		/* option letter processing */
 	char *oli;				/* option letter list index */
@@ -54,55 +54,55 @@
 	if (ostr == NULL)
 		return (-1);
 
-	if (util_optreset || !*place) {		/* update scanning pointer */
-		util_optreset = 0;
-		if (util_optind >= nargc || *(place = nargv[util_optind]) != '-') {
+	if (mlk_util_optreset || !*place) {		/* update scanning pointer */
+		mlk_util_optreset = 0;
+		if (mlk_util_optind >= nargc || *(place = nargv[mlk_util_optind]) != '-') {
 			place = EMSG;
 			return (-1);
 		}
 		if (place[1] && *++place == '-') {	/* found "--" */
-			++util_optind;
+			++mlk_util_optind;
 			place = EMSG;
 			return (-1);
 		}
 	}					/* option letter okay? */
-	if ((util_optopt = (int)*place++) == (int)':' ||
-	    !(oli = strchr(ostr, util_optopt))) {
+	if ((mlk_util_optopt = (int)*place++) == (int)':' ||
+	    !(oli = strchr(ostr, mlk_util_optopt))) {
 		/*
 		 * if the user didn't specify '-' as an option,
 		 * assume it means -1.
 		 */
-		if (util_optopt == (int)'-')
+		if (mlk_util_optopt == (int)'-')
 			return (-1);
 		if (!*place)
-			++util_optind;
-		if (util_opterr && *ostr != ':')
+			++mlk_util_optind;
+		if (mlk_util_opterr && *ostr != ':')
 			(void)fprintf(stderr,
-			    "illegal option -- %c\n", util_optopt);
+			    "illegal option -- %c\n", mlk_util_optopt);
 		return (BADCH);
 	}
 	if (*++oli != ':') {			/* don't need argument */
-		util_optarg = NULL;
+		mlk_util_optarg = NULL;
 		if (!*place)
-			++util_optind;
+			++mlk_util_optind;
 	}
 	else {					/* need an argument */
 		if (*place)			/* no white space */
-			util_optarg = place;
-		else if (nargc <= ++util_optind) {	/* no arg */
+			mlk_util_optarg = place;
+		else if (nargc <= ++mlk_util_optind) {	/* no arg */
 			place = EMSG;
 			if (*ostr == ':')
 				return (BADARG);
-			if (util_opterr)
+			if (mlk_util_opterr)
 				(void)fprintf(stderr,
 				    "option requires an argument -- %c\n",
-				    util_optopt);
+				    mlk_util_optopt);
 			return (BADCH);
 		}
 		else				/* white space */
-			util_optarg = nargv[util_optind];
+			mlk_util_optarg = nargv[mlk_util_optind];
 		place = EMSG;
-		++util_optind;
+		++mlk_util_optind;
 	}
-	return (util_optopt);			/* dump back option letter */
+	return (mlk_util_optopt);			/* dump back option letter */
 }
--- a/libmlk-util/mlk/util/openbsd/strlcat.c	Wed Feb 01 13:08:54 2023 +0100
+++ b/libmlk-util/mlk/util/openbsd/strlcat.c	Sat Feb 18 12:15:14 2023 +0100
@@ -27,7 +27,7 @@
  * If retval >= dsize, truncation occurred.
  */
 size_t
-util_strlcat(char *dst, const char *src, size_t dsize)
+mlk_util_strlcat(char *dst, const char *src, size_t dsize)
 {
 	const char *odst = dst;
 	const char *osrc = src;
--- a/libmlk-util/mlk/util/openbsd/strlcpy.c	Wed Feb 01 13:08:54 2023 +0100
+++ b/libmlk-util/mlk/util/openbsd/strlcpy.c	Sat Feb 18 12:15:14 2023 +0100
@@ -24,7 +24,7 @@
  * Returns strlen(src); if retval >= dsize, truncation occurred.
  */
 size_t
-util_strlcpy(char *dst, const char *src, size_t dsize)
+mlk_util_strlcpy(char *dst, const char *src, size_t dsize)
 {
 	const char *osrc = src;
 	size_t nleft = dsize;
--- a/libmlk-util/mlk/util/util.h	Wed Feb 01 13:08:54 2023 +0100
+++ b/libmlk-util/mlk/util/util.h	Sat Feb 18 12:15:14 2023 +0100
@@ -73,26 +73,26 @@
 #endif
 
 size_t
-util_strlcpy(char *, const char *, size_t);
+mlk_util_strlcpy(char *, const char *, size_t);
 
 size_t
-util_strlcat(char *, const char *, size_t);
+mlk_util_strlcat(char *, const char *, size_t);
 
 FILE *
-util_fmemopen(void *, size_t, const char *);
+mlk_util_fmemopen(void *, size_t, const char *);
 
 char *
-util_basename(char *);
+mlk_util_basename(char *);
 
 char *
-util_dirname(char *);
+mlk_util_dirname(char *);
 
-extern int util_opterr;
-extern int util_optind;
-extern int util_optopt;
-extern char *util_optarg;
+extern int mlk_util_opterr;
+extern int mlk_util_optind;
+extern int mlk_util_optopt;
+extern char *mlk_util_optarg;
 
 int
-util_getopt(int, char **, const char *);
+mlk_util_getopt(int, char **, const char *);
 
 #endif /* !MLK_PORT_H */
--- a/mlk-map/mlk-map.c	Wed Feb 01 13:08:54 2023 +0100
+++ b/mlk-map/mlk-map.c	Sat Feb 18 12:15:14 2023 +0100
@@ -227,7 +227,7 @@
 
 	/* We need to replace the .json extension to .tileset. */
 	snprintf(path, sizeof (path), "%s", json_string_value(source));
-	snprintf(filename, sizeof (filename), "%s", util_basename(path));
+	snprintf(filename, sizeof (filename), "%s", mlk_util_basename(path));
 
 	if (!(ext = strstr(filename, ".json")))
 		die("could not determine tileset extension");