]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
ply-utils: Reintroduce ply_string_has_prefix helper
authorHans de Goede <hdegoede@redhat.com>
Mon, 7 Mar 2022 11:25:56 +0000 (12:25 +0100)
committerHans de Goede <hdegoede@redhat.com>
Mon, 7 Mar 2022 11:28:29 +0000 (12:28 +0100)
ply_string_has_prefix was dropped in commit c7965ea19abf ("ply-utils:
Drop unused ply_string_has_prefix helper"). We have a need for this
helper again, so reintroduce it.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
src/libply/ply-utils.c
src/libply/ply-utils.h

index f90ac40a1ac9c660a58331699b786a5089fc9880..f457579c4d18f957977e4d47c765d82e33cef4d3 100644 (file)
@@ -459,6 +459,15 @@ ply_free_string_array (char **array)
         free (array);
 }
 
+bool
+ply_string_has_prefix (const char *str, const char *prefix)
+{
+        if (str == NULL || prefix == NULL)
+                return false;
+
+        return strncmp (str, prefix, strlen (prefix)) == 0;
+}
+
 double
 ply_get_timestamp (void)
 {
index 47bb3f247b0cf36c6778db6b214f076e4b375940..7572cca21aa9b8b380a0a806497fc49b1753483a 100644 (file)
@@ -85,6 +85,7 @@ bool ply_fd_has_data (int fd);
 bool ply_set_fd_as_blocking (int fd);
 char **ply_copy_string_array (const char *const *array);
 void ply_free_string_array (char **array);
+bool ply_string_has_prefix (const char *str, const char *prefix);
 double ply_get_timestamp (void);
 
 void ply_save_errno (void);