From: Lucas De Marchi Date: Wed, 7 Dec 2011 12:59:17 +0000 (-0200) Subject: Add helper strchr_replace() X-Git-Tag: v1~79 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=afca78015b57825fa9ae38d02e2fed57ab42c2b2;p=thirdparty%2Fkmod.git Add helper strchr_replace() --- diff --git a/libkmod/libkmod-private.h b/libkmod/libkmod-private.h index f1e03500..df7e82a8 100644 --- a/libkmod/libkmod-private.h +++ b/libkmod/libkmod-private.h @@ -112,6 +112,7 @@ void *memdup(const void *p, size_t n) __attribute__((nonnull(1))); ssize_t read_str_safe(int fd, char *buf, size_t buflen) __must_check __attribute__((nonnull(2))); int read_str_long(int fd, long *value, int base) __must_check __attribute__((nonnull(2))); int read_str_ulong(int fd, unsigned long *value, int base) __must_check __attribute__((nonnull(2))); +char *strchr_replace(char *s, int c, char r); #endif diff --git a/libkmod/libkmod-util.c b/libkmod/libkmod-util.c index e506b52c..58ba1d3a 100644 --- a/libkmod/libkmod-util.c +++ b/libkmod/libkmod-util.c @@ -204,3 +204,13 @@ int read_str_ulong(int fd, unsigned long *value, int base) { *value = v; return 0; } + +char *strchr_replace(char *s, int c, char r) +{ + char *p; + + for (p = s; p != NULL; p = strchr(p, c)) + *p = r; + + return s; +}