]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
Add helper strchr_replace()
authorLucas De Marchi <lucas.demarchi@profusion.mobi>
Wed, 7 Dec 2011 12:59:17 +0000 (10:59 -0200)
committerLucas De Marchi <lucas.demarchi@profusion.mobi>
Wed, 7 Dec 2011 12:59:44 +0000 (10:59 -0200)
libkmod/libkmod-private.h
libkmod/libkmod-util.c

index f1e035000f0c38ff4dea5cb4e96c552c9a500f48..df7e82a82ebaec34dec6952296ecc7d916469f44 100644 (file)
@@ -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
index e506b52cdb6df6f755de78949444f5ef387259a8..58ba1d3a498d31f08ba667edd91a81003e07b4dd 100644 (file)
@@ -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;
+}