lib/util: add spdk_strlwr()
Add function to convert string to lowercase in place. Originally based on code imported from istgt. Change-Id: Ica9fe2208e6ee09b22c9a652a33c5affe5be23cc Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
parent
87d3dd870a
commit
c5611b26b3
@ -47,6 +47,13 @@ extern "C" {
|
|||||||
*/
|
*/
|
||||||
char *spdk_sprintf_alloc(const char *format, ...) __attribute__((format(printf, 1, 2)));
|
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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
/*-
|
/*-
|
||||||
* BSD LICENSE
|
* BSD LICENSE
|
||||||
*
|
*
|
||||||
|
* Copyright (C) 2008-2012 Daisuke Aoyama <aoyama@peach.ne.jp>.
|
||||||
* Copyright (c) Intel Corporation.
|
* Copyright (c) Intel Corporation.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@ -34,6 +35,7 @@
|
|||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "spdk/string.h"
|
#include "spdk/string.h"
|
||||||
|
|
||||||
@ -80,3 +82,21 @@ spdk_sprintf_alloc(const char *format, ...)
|
|||||||
|
|
||||||
return NULL;
|
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;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user