summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorPeter Jones <pjones@redhat.com>2021-02-22 13:21:43 -0500
committerPeter Jones <pjones@redhat.com>2021-02-25 10:15:14 -0500
commit1a6f9b807d2fad469035b25156cac94afda28751 (patch)
treea920ee576aaf79fa21a9e833f810f88c88ba4e23 /include
parent82ce86a4bdd17581bcb42dd78245b5d961bf99bb (diff)
downloadefi-boot-shim-1a6f9b807d2fad469035b25156cac94afda28751.tar.gz
efi-boot-shim-1a6f9b807d2fad469035b25156cac94afda28751.zip
Move is_utf8_bom() to str.h
This moves is_utf8_bom() to str.h, and also adds two #defines, UTF8_BOM and UTF8_BOM_SIZE. Signed-off-by: Peter Jones <pjones@redhat.com>
Diffstat (limited to 'include')
-rw-r--r--include/str.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/include/str.h b/include/str.h
index 0c34256d..72f87b75 100644
--- a/include/str.h
+++ b/include/str.h
@@ -214,4 +214,15 @@ strntoken(char *str, size_t max, const char *delims, char **token, char *state)
return state_is_delim;
}
+#define UTF8_BOM { 0xef, 0xbb, 0xbf }
+#define UTF8_BOM_SIZE 3
+
+static inline UNUSED NONNULL(1) BOOLEAN
+is_utf8_bom(CHAR8 *buf, size_t bufsize)
+{
+ unsigned char bom[] = UTF8_BOM;
+
+ return CompareMem(buf, bom, MIN(UTF8_BOM_SIZE, bufsize)) == 0;
+}
+
#endif /* SHIM_STR_H */