X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=common-src%2Ffile.c;h=62cf171bab4da3dc2c53ce53c4a3dece1ddabc62;hb=34197d9f46a5f4e944378cbb65fca32ee0eec7b9;hp=a03197e2793cae42613368103f79bf9485a98cfa;hpb=71325c297e0436e9930a3e129a26696e78c27f62;p=debian%2Famanda diff --git a/common-src/file.c b/common-src/file.c index a03197e..62cf171 100644 --- a/common-src/file.c +++ b/common-src/file.c @@ -23,7 +23,7 @@ * Author: AMANDA core development group. */ /* - * $Id: file.c,v 1.40 2006/07/19 17:41:15 martinea Exp $ + * $Id: file.c,v 1.40.2.1 2006/11/24 18:05:05 martinea Exp $ * * file and directory bashing routines */ @@ -400,6 +400,35 @@ sanitise_filename( return buf; } +/* duplicate '_' */ +char * +old_sanitise_filename( + char * inp) +{ + char *buf; + size_t buf_size; + char *s, *d; + int ch; + + buf_size = 2*strlen(inp) + 1; /* worst case */ + buf = alloc(buf_size); + d = buf; + s = inp; + while((ch = *s++) != '\0') { + if(ch == '_') { + *d++ = (char)ch; + } + if(ch == '/') { + ch = '_'; /* convert "bad" to "_" */ + } + *d++ = (char)ch; + } + assert(d < buf + buf_size); + *d = '\0'; + + return buf; +} + /* *===================================================================== * Get the next line of input from a stdio file.