mirror of
https://gitlab.freedesktop.org/plymouth/plymouth.git
synced 2026-05-05 00:38:10 +02:00
ply-utils: Add ply_kernel_command_line_get_key_value helper
ply_kernel_command_line_get_string_after_prefix returns the rest of the commandline after the passed in prefix. When parsing key=value parts of the commandline, we really only want the value part and stop at the whitespace separating it from other kernel commandline arguments. This commit adds a new helper which returns a strdup-ed string containing just the value; instead of the entire rest of the kernel commandline. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
This commit is contained in:
parent
6bacbbb8ad
commit
11f2017ab7
2 changed files with 13 additions and 0 deletions
|
|
@ -995,6 +995,18 @@ ply_kernel_command_line_has_argument (const char *argument)
|
|||
return true;
|
||||
}
|
||||
|
||||
char *
|
||||
ply_kernel_command_line_get_key_value (const char *key)
|
||||
{
|
||||
const char *value;
|
||||
|
||||
value = ply_kernel_command_line_get_string_after_prefix (key);
|
||||
if (value == NULL || value[0] == '\0')
|
||||
return NULL;
|
||||
|
||||
return strndup(value, strcspn (value, " \n"));
|
||||
}
|
||||
|
||||
void
|
||||
ply_kernel_command_line_override (const char *command_line)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -128,6 +128,7 @@ int ply_get_device_scale (uint32_t width,
|
|||
const char *ply_kernel_command_line_get_string_after_prefix (const char *prefix);
|
||||
bool ply_kernel_command_line_has_argument (const char *argument);
|
||||
void ply_kernel_command_line_override (const char *command_line);
|
||||
char *ply_kernel_command_line_get_key_value (const char *key);
|
||||
|
||||
double ply_strtod(const char *str);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue