if we are adding a new sambaAccount, make sure that we add a
[Samba.git] / source / smbd / mangle_hash.c
blob7fef891f63346617813f94bf56348ce61d051722
1 /*
2 Unix SMB/Netbios implementation.
3 Version 1.9.
4 Name mangling
5 Copyright (C) Andrew Tridgell 1992-1998
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 /* -------------------------------------------------------------------------- **
23 * Notable problems...
25 * March/April 1998 CRH
26 * - Many of the functions in this module overwrite string buffers passed to
27 * them. This causes a variety of problems and is, generally speaking,
28 * dangerous and scarry. See the kludge notes in name_map_mangle()
29 * below.
30 * - It seems that something is calling name_map_mangle() twice. The
31 * first call is probably some sort of test. Names which contain
32 * illegal characters are being doubly mangled. I'm not sure, but
33 * I'm guessing the problem is in server.c.
35 * -------------------------------------------------------------------------- **
38 /* -------------------------------------------------------------------------- **
39 * History...
41 * March/April 1998 CRH
42 * Updated a bit. Rewrote is_mangled() to be a bit more selective.
43 * Rewrote the mangled name cache. Added comments here and there.
44 * &c.
45 * -------------------------------------------------------------------------- **
48 #include "includes.h"
51 /* -------------------------------------------------------------------------- **
52 * External Variables...
55 extern int case_default; /* Are conforming 8.3 names all upper or lower? */
56 extern BOOL case_mangle; /* If true, all chars in 8.3 should be same case. */
58 /* -------------------------------------------------------------------------- **
59 * Other stuff...
61 * magic_char - This is the magic char used for mangling. It's
62 * global. There is a call to lp_magicchar() in server.c
63 * that is used to override the initial value.
65 * MANGLE_BASE - This is the number of characters we use for name mangling.
67 * basechars - The set characters used for name mangling. This
68 * is static (scope is this file only).
70 * mangle() - Macro used to select a character from basechars (i.e.,
71 * mangle(n) will return the nth digit, modulo MANGLE_BASE).
73 * chartest - array 0..255. The index range is the set of all possible
74 * values of a byte. For each byte value, the content is a
75 * two nibble pair. See BASECHAR_MASK and ILLEGAL_MASK,
76 * below.
78 * ct_initialized - False until the chartest array has been initialized via
79 * a call to init_chartest().
81 * BASECHAR_MASK - Masks the upper nibble of a one-byte value.
83 * ILLEGAL_MASK - Masks the lower nibble of a one-byte value.
85 * isbasecahr() - Given a character, check the chartest array to see
86 * if that character is in the basechars set. This is
87 * faster than using strchr().
89 * isillegal() - Given a character, check the chartest array to see
90 * if that character is in the illegal characters set.
91 * This is faster than using strchr().
93 * mangled_cache - Cache header used for storing mangled -> original
94 * reverse maps.
96 * mc_initialized - False until the mangled_cache structure has been
97 * initialized via a call to reset_mangled_cache().
99 * MANGLED_CACHE_MAX_ENTRIES - Default maximum number of entries for the
100 * cache. A value of 0 indicates "infinite".
102 * MANGLED_CACHE_MAX_MEMORY - Default maximum amount of memory for the
103 * cache. When the cache was kept as an array of 256
104 * byte strings, the default cache size was 50 entries.
105 * This required a fixed 12.5Kbytes of memory. The
106 * mangled stack parameter is no longer used (though
107 * this might change). We're now using a fixed 16Kbyte
108 * maximum cache size. This will probably be much more
109 * than 50 entries.
112 char magic_char = '~';
114 static char basechars[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_-!@#$%";
115 #define MANGLE_BASE (sizeof(basechars)/sizeof(char)-1)
117 static unsigned char chartest[256] = { 0 };
118 static BOOL ct_initialized = False;
120 #define mangle(V) ((char)(basechars[(V) % MANGLE_BASE]))
121 #define BASECHAR_MASK 0xf0
122 #define ILLEGAL_MASK 0x0f
123 #define isbasechar(C) ( (chartest[ ((C) & 0xff) ]) & BASECHAR_MASK )
124 #define isillegal(C) ( (chartest[ ((C) & 0xff) ]) & ILLEGAL_MASK )
126 static ubi_cacheRoot mangled_cache[1] = { { { 0, 0, 0, 0 }, 0, 0, 0, 0, 0, 0 } };
127 static BOOL mc_initialized = False;
128 #define MANGLED_CACHE_MAX_ENTRIES 1024
129 #define MANGLED_CACHE_MAX_MEMORY 0
132 /* -------------------------------------------------------------------------- **
133 * Functions...
136 /* ************************************************************************** **
137 * Initialize the static character test array.
139 * Input: none
141 * Output: none
143 * Notes: This function changes (loads) the contents of the <chartest>
144 * array. The scope of <chartest> is this file.
146 * ************************************************************************** **
148 static void init_chartest( void )
150 char *illegalchars = "*\\/?<>|\":";
151 unsigned char *s;
153 memset( (char *)chartest, '\0', 256 );
155 for( s = (unsigned char *)illegalchars; *s; s++ )
156 chartest[*s] = ILLEGAL_MASK;
158 for( s = (unsigned char *)basechars; *s; s++ )
159 chartest[*s] |= BASECHAR_MASK;
161 ct_initialized = True;
162 } /* init_chartest */
164 /* ************************************************************************** **
165 * Return True if a name is a special msdos reserved name.
167 * Input: fname - String containing the name to be tested.
169 * Output: True, if the name matches one of the list of reserved names.
171 * Notes: This is a static function called by is_8_3(), below.
173 * ************************************************************************** **
175 static BOOL is_reserved_msdos( char *fname )
177 char upperFname[13];
178 char *p;
180 StrnCpy (upperFname, fname, 12);
182 /* lpt1.txt and con.txt etc are also illegal */
183 p = strchr(upperFname,'.');
184 if( p )
185 *p = '\0';
187 strupper( upperFname );
188 p = upperFname + 1;
189 switch( upperFname[0] )
191 case 'A':
192 if( 0 == strcmp( p, "UX" ) )
193 return( True );
194 break;
195 case 'C':
196 if( (0 == strcmp( p, "LOCK$" ))
197 || (0 == strcmp( p, "ON" ))
198 || (0 == strcmp( p, "OM1" ))
199 || (0 == strcmp( p, "OM2" ))
200 || (0 == strcmp( p, "OM3" ))
201 || (0 == strcmp( p, "OM4" ))
203 return( True );
204 break;
205 case 'L':
206 if( (0 == strcmp( p, "PT1" ))
207 || (0 == strcmp( p, "PT2" ))
208 || (0 == strcmp( p, "PT3" ))
210 return( True );
211 break;
212 case 'N':
213 if( 0 == strcmp( p, "UL" ) )
214 return( True );
215 break;
216 case 'P':
217 if( 0 == strcmp( p, "RN" ) )
218 return( True );
219 break;
222 return( False );
223 } /* is_reserved_msdos */
225 /* ************************************************************************** **
226 * Determine whether or not a given name contains illegal characters, even
227 * long names.
229 * Input: name - The name to be tested.
231 * Output: True if an illegal character was found in <name>, else False.
233 * Notes: This is used to test a name on the host system, long or short,
234 * for characters that would be illegal on most client systems,
235 * particularly DOS and Windows systems. Unix and AmigaOS, for
236 * example, allow a filenames which contain such oddities as
237 * quotes ("). If a name is found which does contain an illegal
238 * character, it is mangled even if it conforms to the 8.3
239 * format.
241 * ************************************************************************** **
243 static BOOL is_illegal_name( char *name )
245 unsigned char *s;
246 int skip;
247 int namelen;
249 if( !name )
250 return( True );
252 if( !ct_initialized )
253 init_chartest();
255 namelen = strlen(name);
256 if (namelen &&
257 name[namelen-1] == '.' &&
258 !strequal(name, ".") &&
259 !strequal(name, ".."))
260 return True;
262 s = (unsigned char *)name;
263 while( *s )
265 skip = get_character_len( *s );
266 if( skip != 0 )
268 s += skip;
270 else
272 if( isillegal( *s ) )
273 return( True );
274 else
275 s++;
279 return( False );
280 } /* is_illegal_name */
282 /* ************************************************************************** **
283 * Return True if the name *could be* a mangled name.
285 * Input: s - A path name - in UNIX pathname format.
287 * Output: True if the name matches the pattern described below in the
288 * notes, else False.
290 * Notes: The input name is *not* tested for 8.3 compliance. This must be
291 * done separately. This function returns true if the name contains
292 * a magic character followed by excactly two characters from the
293 * basechars list (above), which in turn are followed either by the
294 * nul (end of string) byte or a dot (extension) or by a '/' (end of
295 * a directory name).
297 * ************************************************************************** **
299 static BOOL is_mangled( const char *s )
301 char *magic;
302 BOOL ret = False;
304 if( !ct_initialized )
305 init_chartest();
307 magic = strchr( s, magic_char );
308 while( magic && magic[1] && magic[2] ) {
309 /* 3 chars, 1st is magic. */
310 if( ('.' == magic[3] || '/' == magic[3] || !(magic[3])) /* Ends with '.' or nul or '/' ? */
311 && isbasechar( toupper(magic[1]) ) /* is 2nd char basechar? */
312 && isbasechar( toupper(magic[2]) ) ) /* is 3rd char basechar? */
313 ret = ( True ); /* If all above, then true, */
314 magic = strchr( magic+1, magic_char ); /* else seek next magic. */
317 DEBUG(10,("is_mangled: %s : %s\n", s, ret ? "True" : "False"));
319 return ret;
320 } /* is_mangled */
322 static BOOL is_ms_wildchar(const char c)
324 switch(c) {
325 case '*':
326 case '?':
327 case '<':
328 case '>':
329 case '"':
330 return True;
331 default:
332 return False;
336 /* ************************************************************************** **
337 * Return True if the name is a valid DOS name in 8.3 DOS format.
339 * Input: fname - File name to be checked.
340 * check_case - If True, and if case_mangle is True, then the
341 * name will be checked to see if all characters
342 * are the correct case. See case_mangle and
343 * case_default above.
344 * allow_wildcards - If True dos wildcard characters *?<>" are allowed as 8.3.
346 * Output: True if the name is a valid DOS name, else False.
348 * ************************************************************************** **
351 static BOOL is_8_3( const char *cfname, BOOL check_case, BOOL allow_wildcards )
353 int len;
354 int l;
355 int skip;
356 char *p;
357 char *dot_pos;
358 char *slash_pos;
359 char *fname = (char *)cfname;
361 slash_pos = strrchr( fname, '/' );
363 /* If there is a directory path, skip it. */
364 if( slash_pos )
365 fname = slash_pos + 1;
366 len = strlen( fname );
368 DEBUG( 5, ( "Checking %s for 8.3\n", fname ) );
370 /* Can't be 0 chars or longer than 12 chars */
371 if( (len == 0) || (len > 12) )
372 return( False );
374 /* Mustn't be an MS-DOS Special file such as lpt1 or even lpt1.txt */
375 if( is_reserved_msdos( fname ) )
376 return( False );
378 /* Check that all characters are the correct case, if asked to do so. */
379 if( check_case && case_mangle ) {
380 switch( case_default ) {
381 case CASE_LOWER:
382 if( strhasupper( fname ) )
383 return(False);
384 break;
385 case CASE_UPPER:
386 if( strhaslower( fname ) )
387 return(False);
388 break;
392 /* Can't contain invalid dos chars */
393 /* Windows use the ANSI charset.
394 But filenames are translated in the PC charset.
395 This Translation may be more or less relaxed depending
396 the Windows application. */
398 /* %%% A nice improvment to name mangling would be to translate
399 filename to ANSI charset on the smb server host */
401 p = fname;
402 dot_pos = NULL;
403 while( *p ) {
404 if( (skip = get_character_len( *p )) != 0 )
405 p += skip;
406 else {
407 if( *p == '.' && !dot_pos )
408 dot_pos = (char *)p;
409 else {
410 if( !isdoschar( *p )) {
411 if (!allow_wildcards)
412 return False;
413 if (!is_ms_wildchar(*p))
414 return False;
417 p++;
421 /* no dot and less than 9 means OK */
422 if( !dot_pos )
423 return( len <= 8 );
425 l = PTR_DIFF( dot_pos, fname );
427 /* base must be at least 1 char except special cases . and .. */
428 if( l == 0 )
429 return( 0 == strcmp( fname, "." ) || 0 == strcmp( fname, ".." ) );
431 /* base can't be greater than 8 */
432 if( l > 8 )
433 return( False );
435 /* extension must be between 1 and 3 */
436 if( (len - l < 2 ) || (len - l > 4) )
437 return( False );
439 /* extensions may not have a dot */
440 if( strchr( dot_pos+1, '.' ) )
441 return( False );
443 /* must be in 8.3 format */
444 return( True );
447 /* ************************************************************************** **
448 * Compare two cache keys and return a value indicating their ordinal
449 * relationship.
451 * Input: ItemPtr - Pointer to a comparison key. In this case, this will
452 * be a mangled name string.
453 * NodePtr - Pointer to a node in the cache. The node structure
454 * will be followed in memory by a mangled name string.
456 * Output: A signed integer, as follows:
457 * (x < 0) <==> Key1 less than Key2
458 * (x == 0) <==> Key1 equals Key2
459 * (x > 0) <==> Key1 greater than Key2
461 * Notes: This is a ubiqx-style comparison routine. See ubi_BinTree for
462 * more info.
464 * ************************************************************************** **
467 static signed int cache_compare( ubi_btItemPtr ItemPtr, ubi_btNodePtr NodePtr )
469 char *Key1 = (char *)ItemPtr;
470 char *Key2 = (char *)(((ubi_cacheEntryPtr)NodePtr) + 1);
472 DEBUG(100,("cache_compare: %s %s\n", Key1, Key2));
474 return( StrCaseCmp( Key1, Key2 ) );
477 /* ************************************************************************** **
478 * Free a cache entry.
480 * Input: WarrenZevon - Pointer to the entry that is to be returned to
481 * Nirvana.
482 * Output: none.
484 * Notes: This function gets around the possibility that the standard
485 * free() function may be implemented as a macro, or other evil
486 * subversions (oh, so much fun).
488 * ************************************************************************** **
491 static void cache_free_entry( ubi_trNodePtr WarrenZevon )
493 ZERO_STRUCTP(WarrenZevon);
494 SAFE_FREE( WarrenZevon );
497 /* ************************************************************************** **
498 * Initializes or clears the mangled cache.
500 * Input: none.
501 * Output: none.
503 * Notes: There is a section below that is commented out. It shows how
504 * one might use lp_ calls to set the maximum memory and entry size
505 * of the cache. You might also want to remove the constants used
506 * in ubi_cacheInit() and replace them with lp_ calls. If so, then
507 * the calls to ubi_cacheSetMax*() would be moved into the else
508 * clause. Another option would be to pass in the max_entries and
509 * max_memory values as parameters. crh 09-Apr-1998.
511 * ************************************************************************** **
514 static void reset_mangled_cache( void )
516 if( !mc_initialized ) {
517 (void)ubi_cacheInit( mangled_cache,
518 cache_compare,
519 cache_free_entry,
520 MANGLED_CACHE_MAX_ENTRIES,
521 MANGLED_CACHE_MAX_MEMORY );
522 mc_initialized = True;
523 } else {
524 (void)ubi_cacheClear( mangled_cache );
528 (void)ubi_cacheSetMaxEntries( mangled_cache, lp_mangled_cache_entries() );
529 (void)ubi_cacheSetMaxMemory( mangled_cache, lp_mangled_cache_memory() );
533 /* ************************************************************************** **
534 * Add a mangled name into the cache.
536 * Notes: If the mangled cache has not been initialized, then the
537 * function will simply fail. It could initialize the cache,
538 * but that's not the way it was done before I changed the
539 * cache mechanism, so I'm sticking with the old method.
541 * If the extension of the raw name maps directly to the
542 * extension of the mangled name, then we'll store both names
543 * *without* extensions. That way, we can provide consistent
544 * reverse mangling for all names that match. The test here is
545 * a bit more careful than the one done in earlier versions of
546 * mangle.c:
548 * - the extension must exist on the raw name,
549 * - it must be all lower case
550 * - it must match the mangled extension (to prove that no
551 * mangling occurred).
553 * crh 07-Apr-1998
555 * ************************************************************************** **
557 static void cache_mangled_name( char *mangled_name, char *raw_name )
559 ubi_cacheEntryPtr new_entry;
560 char *s1;
561 char *s2;
562 size_t mangled_len;
563 size_t raw_len;
564 size_t i;
566 /* If the cache isn't initialized, give up. */
567 if( !mc_initialized )
568 return;
570 /* Init the string lengths. */
571 mangled_len = strlen( mangled_name );
572 raw_len = strlen( raw_name );
574 /* See if the extensions are unmangled. If so, store the entry
575 * without the extension, thus creating a "group" reverse map.
577 s1 = strrchr( mangled_name, '.' );
578 if( s1 && (s2 = strrchr( raw_name, '.' )) )
580 i = 1;
581 while( s1[i] && (tolower( s1[i] ) == s2[i]) )
582 i++;
583 if( !s1[i] && !s2[i] )
585 mangled_len -= i;
586 raw_len -= i;
590 /* Allocate a new cache entry. If the allocation fails, just return. */
591 i = sizeof( ubi_cacheEntry ) + mangled_len + raw_len + 2;
592 new_entry = malloc( i );
593 if( !new_entry )
594 return;
596 /* Fill the new cache entry, and add it to the cache. */
597 s1 = (char *)(new_entry + 1);
598 s2 = (char *)&(s1[mangled_len + 1]);
599 (void)StrnCpy( s1, mangled_name, mangled_len );
600 (void)StrnCpy( s2, raw_name, raw_len );
601 ubi_cachePut( mangled_cache, i, new_entry, s1 );
604 /* ************************************************************************** **
605 * Check for a name on the mangled name stack
607 * Input: s - Input *and* output string buffer.
609 * Output: True if the name was found in the cache, else False.
611 * Notes: If a reverse map is found, the function will overwrite the string
612 * space indicated by the input pointer <s>. This is frightening.
613 * It should be rewritten to return NULL if the long name was not
614 * found, and a pointer to the long name if it was found.
616 * ************************************************************************** **
619 static BOOL check_mangled_cache( char *s )
621 ubi_cacheEntryPtr FoundPtr;
622 char *ext_start = NULL;
623 char *found_name;
624 char *saved_ext = NULL;
626 /* If the cache isn't initialized, give up. */
627 if( !mc_initialized )
628 return( False );
630 FoundPtr = ubi_cacheGet( mangled_cache, (ubi_trItemPtr)s );
632 /* If we didn't find the name *with* the extension, try without. */
633 if( !FoundPtr )
635 ext_start = strrchr( s, '.' );
636 if( ext_start )
638 if((saved_ext = strdup(ext_start)) == NULL)
639 return False;
641 *ext_start = '\0';
642 FoundPtr = ubi_cacheGet( mangled_cache, (ubi_trItemPtr)s );
644 * At this point s is the name without the
645 * extension. We re-add the extension if saved_ext
646 * is not null, before freeing saved_ext.
651 /* Okay, if we haven't found it we're done. */
652 if( !FoundPtr )
654 if(saved_ext)
656 /* Replace the saved_ext as it was truncated. */
657 (void)pstrcat( s, saved_ext );
658 SAFE_FREE(saved_ext);
660 return( False );
663 /* If we *did* find it, we need to copy it into the string buffer. */
664 found_name = (char *)(FoundPtr + 1);
665 found_name += (strlen( found_name ) + 1);
667 DEBUG( 3, ("Found %s on mangled stack ", s) );
669 (void)pstrcpy( s, found_name );
670 if( saved_ext )
672 /* Replace the saved_ext as it was truncated. */
673 (void)pstrcat( s, saved_ext );
674 SAFE_FREE(saved_ext);
677 DEBUG( 3, ("as %s\n", s) );
679 return( True );
682 /*****************************************************************************
683 * do the actual mangling to 8.3 format
684 * the buffer must be able to hold 13 characters (including the null)
685 *****************************************************************************
687 static void mangle_name_83( char *s)
689 int csum;
690 char *p;
691 char extension[4];
692 char base[9];
693 int baselen = 0;
694 int extlen = 0;
695 int skip;
697 extension[0] = 0;
698 base[0] = 0;
700 p = strrchr(s,'.');
701 if( p && (strlen(p+1) < (size_t)4) )
703 BOOL all_normal = ( strisnormal(p+1) ); /* XXXXXXXXX */
705 if( all_normal && p[1] != 0 )
707 *p = 0;
708 csum = str_checksum( s );
709 *p = '.';
711 else
712 csum = str_checksum(s);
714 else
715 csum = str_checksum(s);
717 strupper( s );
719 DEBUG( 5, ("Mangling name %s to ",s) );
721 if( p )
723 if( p == s )
724 safe_strcpy( extension, "___", 3 );
725 else
727 *p++ = 0;
728 while( *p && extlen < 3 )
730 skip = get_character_len( *p );
731 switch( skip )
733 case 2:
734 if( extlen < 2 )
736 extension[extlen++] = p[0];
737 extension[extlen++] = p[1];
739 else
741 extension[extlen++] = mangle( (unsigned char)*p );
743 p += 2;
744 break;
745 case 1:
746 extension[extlen++] = p[0];
747 p++;
748 break;
749 default:
750 if( isdoschar (*p) && *p != '.' )
751 extension[extlen++] = p[0];
752 p++;
753 break;
756 extension[extlen] = 0;
760 p = s;
762 while( *p && baselen < 5 )
764 skip = get_character_len(*p);
765 switch( skip )
767 case 2:
768 if( baselen < 4 )
770 base[baselen++] = p[0];
771 base[baselen++] = p[1];
773 else
775 base[baselen++] = mangle( (unsigned char)*p );
777 p += 2;
778 break;
779 case 1:
780 base[baselen++] = p[0];
781 p++;
782 break;
783 default:
784 if( isdoschar( *p ) && *p != '.' )
785 base[baselen++] = p[0];
786 p++;
787 break;
790 base[baselen] = 0;
792 csum = csum % (MANGLE_BASE*MANGLE_BASE);
794 (void)slprintf(s, 12, "%s%c%c%c",
795 base, magic_char, mangle( csum/MANGLE_BASE ), mangle( csum ) );
797 if( *extension )
799 (void)pstrcat( s, "." );
800 (void)pstrcat( s, extension );
803 DEBUG( 5, ( "%s\n", s ) );
807 /*****************************************************************************
808 * Convert a filename to DOS format. Return True if successful.
810 * Input: OutName - Source *and* destination buffer.
812 * NOTE that OutName must point to a memory space that
813 * is at least 13 bytes in size!
815 * need83 - If False, name mangling will be skipped unless the
816 * name contains illegal characters. Mapping will still
817 * be done, if appropriate. This is probably used to
818 * signal that a client does not require name mangling,
819 * thus skipping the name mangling even on shares which
820 * have name-mangling turned on.
821 * cache83 - If False, the mangled name cache will not be updated.
822 * This is usually used to prevent that we overwrite
823 * a conflicting cache entry prematurely, i.e. before
824 * we know whether the client is really interested in the
825 * current name. (See PR#13758). UKD.
826 * snum - Share number. This identifies the share in which the
827 * name exists.
829 * Output: Returns False only if the name wanted mangling but the share does
830 * not have name mangling turned on.
832 * ****************************************************************************
834 static void name_map_mangle(char *OutName, BOOL need83, BOOL cache83)
836 DEBUG(5,("name_map_mangle( %s, need83 = %s, cache83 = %s )\n", OutName,
837 need83 ? "True" : "False", cache83 ? "True" : "False" ));
839 #ifdef MANGLE_LONG_FILENAMES
840 if( !need83 && is_illegal_name(OutName) )
841 need83 = True;
842 #endif
844 /* check if it's already in 8.3 format */
845 if (need83 && !is_8_3(OutName, True, False)) {
846 char *tmp = NULL;
848 /* mangle it into 8.3 */
849 if (cache83)
850 tmp = strdup(OutName);
852 mangle_name_83(OutName);
854 if(tmp != NULL) {
855 cache_mangled_name(OutName, tmp);
856 SAFE_FREE(tmp);
860 DEBUG(5,("name_map_mangle() ==> [%s]\n", OutName));
864 * the following provides the abstraction layer to make it easier
865 * to drop in an alternative mangling implementation
866 * */
867 static struct mangle_fns mangle_fns = {
868 is_mangled,
869 is_8_3,
870 reset_mangled_cache,
871 check_mangled_cache,
872 name_map_mangle
875 /* return the methods for this mangling implementation */
876 struct mangle_fns *mangle_hash_init(void)
878 reset_mangled_cache();
879 return &mangle_fns;