diff --git a/include/spdk/string.h b/include/spdk/string.h index f6261dc47..172a3dcb2 100644 --- a/include/spdk/string.h +++ b/include/spdk/string.h @@ -47,6 +47,13 @@ extern "C" { */ char *spdk_sprintf_alloc(const char *format, ...) __attribute__((format(printf, 1, 2))); +/** + * Convert string to lowercase in place. + * + * \param s String to convert to lowercase. + */ +char *spdk_strlwr(char *s); + #ifdef __cplusplus } #endif diff --git a/lib/util/string.c b/lib/util/string.c index de76048ed..56e124aa1 100644 --- a/lib/util/string.c +++ b/lib/util/string.c @@ -1,6 +1,7 @@ /*- * BSD LICENSE * + * Copyright (C) 2008-2012 Daisuke Aoyama . * Copyright (c) Intel Corporation. * All rights reserved. * @@ -34,6 +35,7 @@ #include #include #include +#include #include "spdk/string.h" @@ -80,3 +82,21 @@ spdk_sprintf_alloc(const char *format, ...) return NULL; } + +char * +spdk_strlwr(char *s) +{ + char *p; + + if (s == NULL) { + return NULL; + } + + p = s; + while (*p != '\0') { + *p = tolower(*p); + p++; + } + + return s; +}