X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=libcitadel%2Flib%2Ftools.c;h=5662133be92854609a719e33d314a85281ad3646;hb=95ce924064310c1cb86dfcd649f54dfdb081c0d3;hp=7d933de1195b9e2d308a40f3e3304ed1ce2f972e;hpb=a473a214c4c3b00b716e6fc5c71200472e109c68;p=citadel.git diff --git a/libcitadel/lib/tools.c b/libcitadel/lib/tools.c index 7d933de11..5662133be 100644 --- a/libcitadel/lib/tools.c +++ b/libcitadel/lib/tools.c @@ -456,6 +456,35 @@ char *rfc2047encode(char *line, long length) return result; } +/* + * removes double slashes from pathnames + * allows / disallows trailing slashes + */ +void StripSlashes(char *Dir, int TrailingSlash) +{ + char *a, *b; + + a = b = Dir; + + while (!IsEmptyStr(a)) { + if (*a == '/') { + while (*a == '/') + a++; + *b = '/'; + b++; + } + else { + *b = *a; + b++; a++; + } + } + if ((TrailingSlash) && (*(b - 1) != '/')){ + *b = '/'; + b++; + } + *b = '\0'; + +} /* * Strip leading and trailing spaces from a string