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.
(cherry picked from commit a5e2a27dca)
This commit is contained in:
parent
4459c16279
commit
9d2d8a27d0
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