summaryrefslogtreecommitdiffstats
path: root/util.h
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2021-03-06 14:06:01 -0500
committerTavian Barnes <tavianator@tavianator.com>2021-03-06 14:10:24 -0500
commitfeb349458e8ae17ede636716ccfa9d97e63f30b1 (patch)
treeb9dd312a3f6ce3e9f7adaa52ced64f124da1b0c3 /util.h
parent863b70d198f62f28581162473a521208dd67879e (diff)
downloadbfs-feb349458e8ae17ede636716ccfa9d97e63f30b1.tar.xz
Support -flags on all the BSDs
Diffstat (limited to 'util.h')
-rw-r--r--util.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/util.h b/util.h
index ed47aa2..ca90494 100644
--- a/util.h
+++ b/util.h
@@ -74,6 +74,10 @@
# define BFS_HAS_SYS_XATTR BFS_HAS_INCLUDE(<sys/xattr.h>, __linux__)
#endif
+#ifndef BFS_HAS_UTIL
+# define BFS_HAS_UTIL BFS_HAS_INCLUDE(<util.h>, __NetBSD__)
+#endif
+
#if !defined(FNM_CASEFOLD) && defined(FNM_IGNORECASE)
# define FNM_CASEFOLD FNM_IGNORECASE
#endif
@@ -180,6 +184,21 @@ const char *xbasename(const char *path);
int xfaccessat(int fd, const char *path, int amode);
/**
+ * Portability wrapper for strtofflags().
+ *
+ * @param str
+ * The string to parse. The pointee will be advanced to the first
+ * invalid position on error.
+ * @param set
+ * The flags that are set in the string.
+ * @param clear
+ * The flags that are cleared in the string.
+ * @return
+ * 0 on success, -1 on failure.
+ */
+int xstrtofflags(const char **str, unsigned long long *set, unsigned long long *clear);
+
+/**
* Return whether an error code is due to a path not existing.
*/
bool is_nonexistence_error(int error);