r2395: Patch from "Stefan (metze) Metzmacher" <metze@samba.org> to fix
[ira/wip.git] / source3 / smbd / mangle.c
index 6bf60f0543cb64f78a7e7644eb5d778c6e74524f..43becff69db99abb9bf27e0e9fe001d49e89e996 100644 (file)
 static struct mangle_fns *mangle_fns;
 
 /* this allows us to add more mangling backends */
-static struct {
-       char *name;
+static const struct {
+       const char *name;
        struct mangle_fns *(*init_fn)(void);
 } mangle_backends[] = {
        { "hash", mangle_hash_init },
        { "hash2", mangle_hash2_init },
+       /*{ "tdb", mangle_tdb_init }, */
        { NULL, NULL }
 };
 
@@ -40,11 +41,12 @@ static void mangle_init(void)
        int i;
        char *method;
 
-       if (mangle_fns) return;
+       if (mangle_fns)
+               return;
 
        method = lp_mangling_method();
 
-       /* find the first mangling method that manages to initialise and 
+       /* find the first mangling method that manages to initialise and
           matches the "mangling method" parameter */
        for (i=0; mangle_backends[i].name && !mangle_fns; i++) {
                if (!method || !*method || strcmp(method, mangle_backends[i].name) == 0) {
@@ -66,7 +68,7 @@ void mangle_reset_cache(void)
 {
        mangle_init();
 
-       return mangle_fns->reset();
+       mangle_fns->reset();
 }
 
 /*
@@ -82,7 +84,12 @@ BOOL mangle_is_mangled(const char *s)
 */
 BOOL mangle_is_8_3(const char *fname, BOOL check_case)
 {
-       return mangle_fns->is_8_3(fname, check_case);
+       return mangle_fns->is_8_3(fname, check_case, False);
+}
+
+BOOL mangle_is_8_3_wildcards(const char *fname, BOOL check_case)
+{
+       return mangle_fns->is_8_3(fname, check_case, True);
 }
 
 /*
@@ -91,15 +98,16 @@ BOOL mangle_is_8_3(const char *fname, BOOL check_case)
   looking for a matching name if it doesn't. It should succeed most of the time
   or there will be a huge performance penalty
 */
-BOOL mangle_check_cache(char *s)
+BOOL mangle_check_cache(char *s, size_t maxlen)
 {
-       return mangle_fns->check_cache(s);
+       return mangle_fns->check_cache(s, maxlen);
 }
 
 /* 
    map a long filename to a 8.3 name. 
  */
-BOOL mangle_map(char *OutName, BOOL need83, BOOL cache83, int snum)
+
+void mangle_map(pstring OutName, BOOL need83, BOOL cache83, int snum)
 {
        /* name mangling can be disabled for speed, in which case
           we just truncate the string */
@@ -107,11 +115,10 @@ BOOL mangle_map(char *OutName, BOOL need83, BOOL cache83, int snum)
                if (need83) {
                        string_truncate(OutName, 12);
                }
-               return True;
+               return;
        }
 
        /* invoke the inane "mangled map" code */
        mangle_map_filename(OutName, snum);
-
-       return mangle_fns->name_map(OutName, need83, cache83);
+       mangle_fns->name_map(OutName, need83, cache83, lp_defaultcase(snum));
 }