mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
LinuxKPI: add strreplace() to string.h
Add strreplace() needed by a driver. MFC after: 3 days Reviewed by: hselasky Differential Revision: https://reviews.freebsd.org/D32597
This commit is contained in:
parent
b382b78503
commit
a5e2a27dca
1 changed files with 13 additions and 0 deletions
|
|
@ -167,6 +167,19 @@ str_has_prefix(const char *str, const char *prefix)
|
|||
return (strncmp(str, prefix, len) == 0 ? len : 0);
|
||||
}
|
||||
|
||||
static inline char *
|
||||
strreplace(char *str, char old, char new)
|
||||
{
|
||||
char *p;
|
||||
|
||||
p = strchrnul(str, old);
|
||||
while (p != NULL && *p != '\0') {
|
||||
*p = new;
|
||||
p = strchrnul(str, old);
|
||||
}
|
||||
return (p);
|
||||
}
|
||||
|
||||
static inline ssize_t
|
||||
strscpy(char* dst, const char* src, size_t len)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue