]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
Add new ply_string_has_prefix function
authorRay Strode <rstrode@redhat.com>
Tue, 11 Nov 2008 14:48:26 +0000 (09:48 -0500)
committerRay Strode <rstrode@redhat.com>
Tue, 11 Nov 2008 14:48:26 +0000 (09:48 -0500)
New api to help with kernel command line parsing.

src/libply/ply-utils.c
src/libply/ply-utils.h

index 3ef8c718b06f5fc24e98f04a884230e3ef9f94a8..08c3bbb10338826f1c380744e71cda7e3b18534e 100644 (file)
@@ -480,6 +480,22 @@ ply_free_string_array (char **array)
   free (array);
 }
 
+bool
+ply_string_has_prefix (const char *string,
+                       const char *prefix)
+{
+  if (string == NULL)
+    return false;
+
+  if (prefix == NULL)
+    return false;
+
+  if (strlen (prefix) > strlen (string))
+    return false;
+
+  return strncmp (string, prefix, strlen (prefix)) == 0;
+}
+
 static int
 ply_get_max_open_fds (void)
 {
index 96fded8f6a069ea3dbf0aba3d0781dba00e08087..493fdad5dea662dc356a4254d76f115bd2b39299 100644 (file)
@@ -67,6 +67,8 @@ bool ply_fd_can_take_data (int fd);
 bool ply_fd_may_block (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 *string,
+                            const char *prefix);
 void ply_close_all_fds (void);
 double ply_get_timestamp (void);