aboutsummaryrefslogtreecommitdiff
path: root/include/vsprintf.h
diff options
context:
space:
mode:
authorSimon Glass2022-04-24 23:30:58 -0600
committerTom Rini2022-04-25 10:00:03 -0400
commit8565efd509236dc7d4e766de39edae2cefb10057 (patch)
tree75c6a767cbdac256ad2b4433b5f08a0c97f45ff7 /include/vsprintf.h
parentd667a0d8f413d7278f912aa4e671bc56d28b25f2 (diff)
lib: Add a way to find the postiion of a trailing number
At present it is not possible to find out which part of the string is the number part and which is before it. Add a new variant which provides this feature, so we can separate the two in the caller. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include/vsprintf.h')
-rw-r--r--include/vsprintf.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/include/vsprintf.h b/include/vsprintf.h
index 5172ceedec1..e006af200fd 100644
--- a/include/vsprintf.h
+++ b/include/vsprintf.h
@@ -122,6 +122,24 @@ long trailing_strtol(const char *str);
long trailing_strtoln(const char *str, const char *end);
/**
+ * trailing_strtoln_end() - extract trailing integer from a fixed-length string
+ *
+ * Given a fixed-length string this finds a trailing number on the string
+ * and returns it. For example, "abc123" would return 123. Only the
+ * characters between @str and @end - 1 are examined. If @end is NULL, it is
+ * set to str + strlen(str).
+ *
+ * @str: String to examine
+ * @end: Pointer to end of string to examine, or NULL to use the
+ * whole string
+ * @endp: If non-NULL, this is set to point to the character where the
+ * number starts, e.g. for "mmc0" this would be point to the '0'; if no
+ * trailing number is found, it is set to the end of the string
+ * Return: training number if found, else -1
+ */
+long trailing_strtoln_end(const char *str, const char *end, char const **endp);
+
+/**
* panic() - Print a message and reset/hang
*
* Prints a message on the console(s) and then resets. If CONFIG_PANIC_HANG is