Imported Upstream version 2.5.1p3
[debian/amanda] / common-src / file.c
index a03197e2793cae42613368103f79bf9485a98cfa..62cf171bab4da3dc2c53ce53c4a3dece1ddabc62 100644 (file)
@@ -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.