add str_cmp()
This commit is contained in:
parent
4580fb1011
commit
210be97be3
2 changed files with 19 additions and 0 deletions
|
@ -105,6 +105,7 @@ uint8_t ch_hex(char ch);
|
|||
int str_hex(uint8_t *hex, size_t len, const char *str);
|
||||
void str_ncpy(char *dst, const char *src, size_t n);
|
||||
int str_dup(char **dst, const char *src);
|
||||
int str_cmp(const char *s1, const char *s2);
|
||||
int str_casecmp(const char *s1, const char *s2);
|
||||
size_t str_len(const char *s);
|
||||
const char *str_error(int errnum, char *buf, size_t sz);
|
||||
|
|
|
@ -94,6 +94,24 @@ int str_dup(char **dst, const char *src)
|
|||
* @return an integer less than, equal to, or greater than zero if s1 is found
|
||||
* respectively, to be less than, to match, or be greater than s2
|
||||
*/
|
||||
int str_cmp(const char *s1, const char *s2)
|
||||
{
|
||||
if (!s1 || !s2)
|
||||
return 1;
|
||||
|
||||
return strcmp(s1, s2);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Compare two 0-terminated strings, ignoring case
|
||||
*
|
||||
* @param s1 First string
|
||||
* @param s2 Second string
|
||||
*
|
||||
* @return an integer less than, equal to, or greater than zero if s1 is found
|
||||
* respectively, to be less than, to match, or be greater than s2
|
||||
*/
|
||||
int str_casecmp(const char *s1, const char *s2)
|
||||
{
|
||||
/* Same strings -> equal */
|
||||
|
|
Loading…
Add table
Reference in a new issue