summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Jones <pjones@redhat.com>2021-02-09 13:39:48 -0500
committerJavier Martinez Canillas <javierm@redhat.com>2021-02-13 00:04:13 +0100
commit186595864c4c7c47fe3a9795e4867b8a72205e38 (patch)
treecb924fcdcb46644d300e6a38a3921d21b5e8f63f
parent4a4d73f73a488d4df0418f0a45f5864f8dda739e (diff)
downloadefi-boot-shim-186595864c4c7c47fe3a9795e4867b8a72205e38.tar.gz
efi-boot-shim-186595864c4c7c47fe3a9795e4867b8a72205e38.zip
includes: add strchra() and strchrnula() impls
Unfortunately GNU-EFI doesn't currently implement ascii versions of strchr() or strchrnul(), and we kind of need them, so add an implementation here for now. Signed-off-by: Peter Jones <pjones@redhat.com>
-rw-r--r--include/str.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/include/str.h b/include/str.h
index f73c6212..ea03ee3f 100644
--- a/include/str.h
+++ b/include/str.h
@@ -64,4 +64,30 @@ translate_slashes(CHAR8 *out, const char *str)
return out;
}
+static inline UNUSED CHAR8 *
+strchrnula(const CHAR8 *s, int c)
+{
+ unsigned int i;
+
+ if (s == NULL)
+ return NULL;
+
+ for (i = 0; s[i] != '\000' && s[i] != c; i++)
+ ;
+
+ return (CHAR8 *)&s[i];
+}
+
+static inline UNUSED CHAR8 *
+strchra(const CHAR8 *s, int c)
+{
+ const CHAR8 *s1;
+
+ s1 = strchrnula(s, c);
+ if (!s1 || s1[0] == '\000')
+ return NULL;
+
+ return (CHAR8 *)s1;
+}
+
#endif /* SHIM_STR_H */