summaryrefslogtreecommitdiff
path: root/src/common/util.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2004-10-06 13:26:37 +0000
committerNick Mathewson <nickm@torproject.org>2004-10-06 13:26:37 +0000
commitb56bb39ed6119edc6088987ba40d0604ac4ffba1 (patch)
tree62063e9a52966da52fd8e08cc352ddd26fecc54d /src/common/util.c
parent8cca36d26ac77c2ae2ac80fce57103aab9684e99 (diff)
downloadtor-b56bb39ed6119edc6088987ba40d0604ac4ffba1.tar.gz
tor-b56bb39ed6119edc6088987ba40d0604ac4ffba1.zip
Add a function to remove a set of characters from a string
svn:r2420
Diffstat (limited to 'src/common/util.c')
-rw-r--r--src/common/util.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/common/util.c b/src/common/util.c
index 6dd06c7ce6..dde5c7c914 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -200,6 +200,21 @@ char *tor_strndup(const char *s, size_t n) {
return dup;
}
+/** Remove from the string <b>s</b> every character which appears in
+ * <b>strip</b>. Return the number of characters removed. */
+int tor_strstrip(char *s, const char *strip)
+{
+ char *read = s;
+ while (*read) {
+ if (strchr(strip, *read)) {
+ ++read;
+ } else {
+ *s++ = *read++;
+ }
+ }
+ *s = '\0';
+ return read-s;
+}
#ifndef UNALIGNED_INT_ACCESS_OK
/**