summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/components/utilities/utclib.c87
-rw-r--r--source/include/acclib.h10
2 files changed, 97 insertions, 0 deletions
diff --git a/source/components/utilities/utclib.c b/source/components/utilities/utclib.c
index d2f73642f..31241a992 100644
--- a/source/components/utilities/utclib.c
+++ b/source/components/utilities/utclib.c
@@ -358,6 +358,93 @@ strlen (
/*******************************************************************************
*
+ * FUNCTION: strpbrk
+ *
+ * PARAMETERS: String - Null terminated string
+ * Delimiters - Delimiters to match
+ *
+ * RETURN: The first occurance in the string of any of the bytes in the
+ * delimiters
+ *
+ * DESCRIPTION: Search a string for any of a set of the delimiters
+ *
+ ******************************************************************************/
+
+char *
+strpbrk (
+ const char *String,
+ const char *Delimiters)
+{
+ const char *Delimiter;
+
+
+ for ( ; *String != '\0'; ++String)
+ {
+ for (Delimiter = Delimiters; *Delimiter != '\0'; Delimiter++)
+ {
+ if (*String == *Delimiter)
+ {
+ return (ACPI_CAST_PTR (char, String));
+ }
+ }
+ }
+
+ return (NULL);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: strtok
+ *
+ * PARAMETERS: String - Null terminated string
+ * Delimiters - Delimiters to match
+ *
+ * RETURN: Pointer to the next token
+ *
+ * DESCRIPTION: Split string into tokens
+ *
+ ******************************************************************************/
+
+char*
+strtok (
+ char *String,
+ const char *Delimiters)
+{
+ char *Begin = String;
+ static char *SavedPtr;
+
+
+ if (Begin == NULL)
+ {
+ if (SavedPtr == NULL)
+ {
+ return (NULL);
+ }
+ Begin = SavedPtr;
+ }
+
+ SavedPtr = strpbrk (Begin, Delimiters);
+ while (SavedPtr == Begin)
+ {
+ *Begin++ = '\0';
+ SavedPtr = strpbrk (Begin, Delimiters);
+ }
+
+ if (SavedPtr)
+ {
+ *SavedPtr++ = '\0';
+ return (Begin);
+ }
+ else
+ {
+ return (NULL);
+ }
+}
+
+
+/*******************************************************************************
+ *
* FUNCTION: strcpy
*
* PARAMETERS: DstString - Target of the copy
diff --git a/source/include/acclib.h b/source/include/acclib.h
index 10667216a..bd7b564e0 100644
--- a/source/include/acclib.h
+++ b/source/include/acclib.h
@@ -176,6 +176,16 @@ strchr (
int ch);
char *
+strpbrk (
+ const char *String,
+ const char *Delimiters);
+
+char *
+strtok (
+ char *String,
+ const char *Delimiters);
+
+char *
strcpy (
char *DstString,
const char *SrcString);