summaryrefslogtreecommitdiffstats
path: root/include/vsprintf.h
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2015-06-23 15:39:08 -0600
committerSimon Glass <sjg@chromium.org>2015-07-21 17:39:28 -0600
commitc4af6732c4021ffe8b3d0c82bdcf1eebb263bfc3 (patch)
treeb34c0808db76437623e8c1f887ea24d36df91d59 /include/vsprintf.h
parent1acab96d974a1b9f35cbc901f68ef00653d18738 (diff)
downloadtalos-obmc-uboot-c4af6732c4021ffe8b3d0c82bdcf1eebb263bfc3.tar.gz
talos-obmc-uboot-c4af6732c4021ffe8b3d0c82bdcf1eebb263bfc3.zip
lib: Add function to extract a number from the end of a string
Split out the code in fdtdec which finds a number at the end of a string. It can be useful in other situations. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include/vsprintf.h')
-rw-r--r--include/vsprintf.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/include/vsprintf.h b/include/vsprintf.h
index d2fcca3f5a..b5bc9c1d95 100644
--- a/include/vsprintf.h
+++ b/include/vsprintf.h
@@ -41,6 +41,32 @@ unsigned long long simple_strtoull(const char *cp, char **endp,
long simple_strtol(const char *cp, char **endp, unsigned int base);
/**
+ * trailing_strtol() - extract a trailing integer from a string
+ *
+ * Given a string this finds a trailing number on the string and returns it.
+ * For example, "abc123" would return 123.
+ *
+ * @str: String to exxamine
+ * @return training number if found, else -1
+ */
+long trailing_strtol(const char *str);
+
+/**
+ * trailing_strtoln() - extract a 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 exxamine
+ * @end: Pointer to end of string to examine, or NULL to use the
+ * whole string
+ * @return training number if found, else -1
+ */
+long trailing_strtoln(const char *str, const char *end);
+
+/**
* panic() - Print a message and reset/hang
*
* Prints a message on the console(s) and then resets. If CONFIG_PANIC_HANG is
OpenPOWER on IntegriCloud