2 Unix SMB/Netbios implementation.
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 /* -------------------------------------------------------------------------- **
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()
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 /* -------------------------------------------------------------------------- **
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.
45 * -------------------------------------------------------------------------- **
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. */
59 /* -------------------------------------------------------------------------- **
62 * magic_char - This is the magic char used for mangling. It's
63 * global. There is a call to lp_magicchar() in server.c
64 * that is used to override the initial value.
66 * MANGLE_BASE - This is the number of characters we use for name mangling.
68 * basechars - The set characters used for name mangling. This
69 * is static (scope is this file only).
71 * mangle() - Macro used to select a character from basechars (i.e.,
72 * mangle(n) will return the nth digit, modulo MANGLE_BASE).
74 * chartest - array 0..255. The index range is the set of all possible
75 * values of a byte. For each byte value, the content is a
76 * two nibble pair. See BASECHAR_MASK and ILLEGAL_MASK,
79 * ct_initialized - False until the chartest array has been initialized via
80 * a call to init_chartest().
82 * BASECHAR_MASK - Masks the upper nibble of a one-byte value.
84 * ILLEGAL_MASK - Masks the lower nibble of a one-byte value.
86 * isbasecahr() - Given a character, check the chartest array to see
87 * if that character is in the basechars set. This is
88 * faster than using strchr_m().
90 * isillegal() - Given a character, check the chartest array to see
91 * if that character is in the illegal characters set.
92 * This is faster than using strchr_m().
94 * mangled_cache - Cache header used for storing mangled -> original
97 * mc_initialized - False until the mangled_cache structure has been
98 * initialized via a call to reset_mangled_cache().
100 * MANGLED_CACHE_MAX_ENTRIES - Default maximum number of entries for the
101 * cache. A value of 0 indicates "infinite".
103 * MANGLED_CACHE_MAX_MEMORY - Default maximum amount of memory for the
104 * cache. When the cache was kept as an array of 256
105 * byte strings, the default cache size was 50 entries.
106 * This required a fixed 12.5Kbytes of memory. The
107 * mangled stack parameter is no longer used (though
108 * this might change). We're now using a fixed 16Kbyte
109 * maximum cache size. This will probably be much more
113 char magic_char
= '~';
122 static char basechars
[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_-!@#$%";
123 #define MANGLE_BASE ( (sizeof(basechars)/sizeof(char)) - 1 )
125 static unsigned char chartest
[256] = { 0 };
126 static BOOL ct_initialized
= False
;
128 #define mangle(V) ((char)(basechars[(V) % MANGLE_BASE]))
129 #define BASECHAR_MASK 0xf0
130 #define ILLEGAL_MASK 0x0f
131 #define isbasechar(C) ( (chartest[ ((C) & 0xff) ]) & BASECHAR_MASK )
132 #define isillegal(C) ( (chartest[ ((C) & 0xff) ]) & ILLEGAL_MASK )
134 static ubi_cacheRoot mangled_cache
[1] = {{ { 0, 0, 0, 0 }, 0, 0, 0, 0, 0, 0 }};
135 static BOOL mc_initialized
= False
;
136 #define MANGLED_CACHE_MAX_ENTRIES 0
137 #define MANGLED_CACHE_MAX_MEMORY 16384
140 /* -------------------------------------------------------------------------- **
144 /* ************************************************************************** **
145 * Initialize the static character test array.
151 * Notes: This function changes (loads) the contents of the <chartest>
152 * array. The scope of <chartest> is this file.
154 * ************************************************************************** **
156 static void init_chartest( void )
158 char *illegalchars
= "*\\/?<>|\":";
161 memset( (char *)chartest
, '\0', 256 );
163 for( s
= (unsigned char *)illegalchars
; *s
; s
++ )
164 chartest
[*s
] = ILLEGAL_MASK
;
166 for( s
= (unsigned char *)basechars
; *s
; s
++ )
167 chartest
[*s
] |= BASECHAR_MASK
;
169 ct_initialized
= True
;
170 } /* init_chartest */
172 /* ************************************************************************** **
173 * Return True if a name is a special msdos reserved name.
175 * Input: fname - String containing the name to be tested.
177 * Output: True, if the name matches one of the list of reserved names.
179 * Notes: This is a static function called by is_8_3(), below.
181 * ************************************************************************** **
183 static BOOL
is_reserved_msdos( char *fname
)
188 StrnCpy (upperFname
, fname
, 12);
190 /* lpt1.txt and con.txt etc are also illegal */
191 p
= strchr_m(upperFname
,'.');
195 strupper( upperFname
);
197 switch( upperFname
[0] )
200 if( 0 == strcmp( p
, "UX" ) )
204 if( (0 == strcmp( p
, "LOCK$" ))
205 || (0 == strcmp( p
, "ON" ))
206 || (0 == strcmp( p
, "OM1" ))
207 || (0 == strcmp( p
, "OM2" ))
208 || (0 == strcmp( p
, "OM3" ))
209 || (0 == strcmp( p
, "OM4" ))
214 if( (0 == strcmp( p
, "PT1" ))
215 || (0 == strcmp( p
, "PT2" ))
216 || (0 == strcmp( p
, "PT3" ))
221 if( 0 == strcmp( p
, "UL" ) )
225 if( 0 == strcmp( p
, "RN" ) )
231 } /* is_reserved_msdos */
233 /* ************************************************************************** **
234 * Determine whether or not a given name contains illegal characters, even
237 * Input: name - The name to be tested.
239 * Output: True if an illegal character was found in <name>, else False.
241 * Notes: This is used to test a name on the host system, long or short,
242 * for characters that would be illegal on most client systems,
243 * particularly DOS and Windows systems. Unix and AmigaOS, for
244 * example, allow a filenames which contain such oddities as
245 * quotes ("). If a name is found which does contain an illegal
246 * character, it is mangled even if it conforms to the 8.3
249 * ************************************************************************** **
251 static BOOL
is_illegal_name( char *name
)
258 if( !ct_initialized
)
261 s
= (unsigned char *)name
;
264 if( *s
>0x7F && isillegal( *s
) )
271 } /* is_illegal_name */
273 /* ************************************************************************** **
274 * Return True if the name *could be* a mangled name.
276 * Input: s - A path name - in UNIX pathname format.
278 * Output: True if the name matches the pattern described below in the
281 * Notes: The input name is *not* tested for 8.3 compliance. This must be
282 * done separately. This function returns true if the name contains
283 * a magic character followed by excactly two characters from the
284 * basechars list (above), which in turn are followed either by the
285 * nul (end of string) byte or a dot (extension) or by a '/' (end of
288 * ************************************************************************** **
290 BOOL
is_mangled( char *s
)
294 if( !ct_initialized
)
297 magic
= strchr_m( s
, magic_char
);
298 while( magic
&& magic
[1] && magic
[2] ) /* 3 chars, 1st is magic. */
300 if( ('.' == magic
[3] || '/' == magic
[3] || !(magic
[3])) /* Ends with '.' or nul or '/' ? */
301 && isbasechar( toupper(magic
[1]) ) /* is 2nd char basechar? */
302 && isbasechar( toupper(magic
[2]) ) ) /* is 3rd char basechar? */
303 return( True
); /* If all above, then true, */
304 magic
= strchr_m( magic
+1, magic_char
); /* else seek next magic. */
309 /* ************************************************************************** **
310 * Return True if the name is a valid DOS name in 8.3 DOS format.
312 * Input: fname - File name to be checked.
313 * check_case - If True, and if case_mangle is True, then the
314 * name will be checked to see if all characters
315 * are the correct case. See case_mangle and
316 * case_default above.
318 * Output: True if the name is a valid DOS name, else FALSE.
320 * ************************************************************************** **
322 BOOL
is_8_3( char *fname
, BOOL check_case
)
328 char *slash_pos
= strrchr_m( fname
, '/' );
330 /* If there is a directory path, skip it. */
332 fname
= slash_pos
+ 1;
333 len
= strlen( fname
);
335 DEBUG( 5, ( "Checking %s for 8.3\n", fname
) );
337 /* Can't be 0 chars or longer than 12 chars */
338 if( (len
== 0) || (len
> 12) )
341 /* Mustn't be an MS-DOS Special file such as lpt1 or even lpt1.txt */
342 if( is_reserved_msdos( fname
) )
345 /* Check that all characters are the correct case, if asked to do so. */
346 if( check_case
&& case_mangle
)
348 switch( case_default
)
351 if( strhasupper( fname
) )
355 if( strhaslower( fname
) )
361 /* Can't contain invalid dos chars */
362 /* Windows use the ANSI charset.
363 But filenames are translated in the PC charset.
364 This Translation may be more or less relaxed depending
365 the Windows application. */
367 /* %%% A nice improvment to name mangling would be to translate
368 filename to ANSI charset on the smb server host */
374 if( *p
== '.' && !dot_pos
)
377 if( !isdoschar( *p ) )
382 /* no dot and less than 9 means OK */
386 l
= PTR_DIFF( dot_pos
, fname
);
388 /* base must be at least 1 char except special cases . and .. */
390 return( 0 == strcmp( fname
, "." ) || 0 == strcmp( fname
, ".." ) );
392 /* base can't be greater than 8 */
396 /* see smb.conf(5) for a description of the 'strip dot' parameter. */
399 && !strchr_m( dot_pos
+ 1, '.' ) )
405 /* extension must be between 1 and 3 */
406 if( (len
- l
< 2 ) || (len
- l
> 4) )
409 /* extensions may not have a dot */
410 if( strchr_m( dot_pos
+1, '.' ) )
413 /* must be in 8.3 format */
418 /* ************************************************************************** **
419 * Compare two cache keys and return a value indicating their ordinal
422 * Input: ItemPtr - Pointer to a comparison key. In this case, this will
423 * be a mangled name string.
424 * NodePtr - Pointer to a node in the cache. The node structure
425 * will be followed in memory by a mangled name string.
427 * Output: A signed integer, as follows:
428 * (x < 0) <==> Key1 less than Key2
429 * (x == 0) <==> Key1 equals Key2
430 * (x > 0) <==> Key1 greater than Key2
432 * Notes: This is a ubiqx-style comparison routine. See ubi_BinTree for
435 * ************************************************************************** **
437 static signed int cache_compare( ubi_btItemPtr ItemPtr
, ubi_btNodePtr NodePtr
)
439 char *Key1
= (char *)ItemPtr
;
440 char *Key2
= (char *)(((ubi_cacheEntryPtr
)NodePtr
) + 1);
442 return( StrCaseCmp( Key1
, Key2
) );
443 } /* cache_compare */
445 /* ************************************************************************** **
446 * Free a cache entry.
448 * Input: WarrenZevon - Pointer to the entry that is to be returned to
452 * Notes: This function gets around the possibility that the standard
453 * free() function may be implemented as a macro, or other evil
454 * subversions (oh, so much fun).
456 * ************************************************************************** **
458 static void cache_free_entry( ubi_trNodePtr WarrenZevon
)
460 ZERO_STRUCTP(WarrenZevon
);
461 SAFE_FREE( WarrenZevon
);
462 } /* cache_free_entry */
464 /* ************************************************************************** **
465 * Initializes or clears the mangled cache.
470 * Notes: There is a section below that is commented out. It shows how
471 * one might use lp_ calls to set the maximum memory and entry size
472 * of the cache. You might also want to remove the constants used
473 * in ubi_cacheInit() and replace them with lp_ calls. If so, then
474 * the calls to ubi_cacheSetMax*() would be moved into the else
475 * clause. Another option would be to pass in the max_entries and
476 * max_memory values as parameters. crh 09-Apr-1998.
478 * ************************************************************************** **
480 void reset_mangled_cache( void )
482 if( !mc_initialized
)
484 (void)ubi_cacheInit( mangled_cache
,
487 MANGLED_CACHE_MAX_ENTRIES
,
488 MANGLED_CACHE_MAX_MEMORY
);
489 mc_initialized
= True
;
493 (void)ubi_cacheClear( mangled_cache
);
497 (void)ubi_cacheSetMaxEntries( mangled_cache, lp_mangled_cache_entries() );
498 (void)ubi_cacheSetMaxMemory( mangled_cache, lp_mangled_cache_memory() );
500 } /* reset_mangled_cache */
503 /* ************************************************************************** **
504 * Add a mangled name into the cache.
506 * Notes: If the mangled cache has not been initialized, then the
507 * function will simply fail. It could initialize the cache,
508 * but that's not the way it was done before I changed the
509 * cache mechanism, so I'm sticking with the old method.
511 * If the extension of the raw name maps directly to the
512 * extension of the mangled name, then we'll store both names
513 * *without* extensions. That way, we can provide consistent
514 * reverse mangling for all names that match. The test here is
515 * a bit more careful than the one done in earlier versions of
518 * - the extension must exist on the raw name,
519 * - it must be all lower case
520 * - it must match the mangled extension (to prove that no
521 * mangling occurred).
525 * ************************************************************************** **
527 static void cache_mangled_name( char *mangled_name
, char *raw_name
)
529 ubi_cacheEntryPtr new_entry
;
536 /* If the cache isn't initialized, give up. */
537 if( !mc_initialized
)
540 /* Init the string lengths. */
541 mangled_len
= strlen( mangled_name
);
542 raw_len
= strlen( raw_name
);
544 /* See if the extensions are unmangled. If so, store the entry
545 * without the extension, thus creating a "group" reverse map.
547 s1
= strrchr_m( mangled_name
, '.' );
548 if( s1
&& (s2
= strrchr_m( raw_name
, '.' )) )
551 while( s1
[i
] && (tolower( s1
[1] ) == s2
[i
]) )
553 if( !s1
[i
] && !s2
[i
] )
560 /* Allocate a new cache entry. If the allocation fails, just return. */
561 i
= sizeof( ubi_cacheEntry
) + mangled_len
+ raw_len
+ 2;
562 new_entry
= malloc( i
);
566 /* Fill the new cache entry, and add it to the cache. */
567 s1
= (char *)(new_entry
+ 1);
568 s2
= (char *)&(s1
[mangled_len
+ 1]);
569 (void)StrnCpy( s1
, mangled_name
, mangled_len
);
570 (void)StrnCpy( s2
, raw_name
, raw_len
);
571 ubi_cachePut( mangled_cache
, i
, new_entry
, s1
);
572 } /* cache_mangled_name */
574 /* ************************************************************************** **
575 * Check for a name on the mangled name stack
577 * Input: s - Input *and* output string buffer.
579 * Output: True if the name was found in the cache, else False.
581 * Notes: If a reverse map is found, the function will overwrite the string
582 * space indicated by the input pointer <s>. This is frightening.
583 * It should be rewritten to return NULL if the long name was not
584 * found, and a pointer to the long name if it was found.
586 * ************************************************************************** **
589 BOOL
check_mangled_cache( char *s
)
591 ubi_cacheEntryPtr FoundPtr
;
592 char *ext_start
= NULL
;
594 char *saved_ext
= NULL
;
596 /* If the cache isn't initialized, give up. */
597 if( !mc_initialized
)
600 FoundPtr
= ubi_cacheGet( mangled_cache
, (ubi_trItemPtr
)s
);
602 /* If we didn't find the name *with* the extension, try without. */
605 ext_start
= strrchr_m( s
, '.' );
608 if((saved_ext
= strdup(ext_start
)) == NULL
)
612 FoundPtr
= ubi_cacheGet( mangled_cache
, (ubi_trItemPtr
)s
);
614 * At this point s is the name without the
615 * extension. We re-add the extension if saved_ext
616 * is not null, before freeing saved_ext.
621 /* Okay, if we haven't found it we're done. */
626 /* Replace the saved_ext as it was truncated. */
627 (void)pstrcat( s
, saved_ext
);
628 SAFE_FREE(saved_ext
);
633 /* If we *did* find it, we need to copy it into the string buffer. */
634 found_name
= (char *)(FoundPtr
+ 1);
635 found_name
+= (strlen( found_name
) + 1);
637 DEBUG( 3, ("Found %s on mangled stack ", s
) );
639 (void)pstrcpy( s
, found_name
);
642 /* Replace the saved_ext as it was truncated. */
643 (void)pstrcat( s
, saved_ext
);
644 SAFE_FREE(saved_ext
);
647 DEBUG( 3, ("as %s\n", s
) );
650 } /* check_mangled_cache */
653 /* ************************************************************************** **
654 * Used only in do_fwd_mangled_map(), below.
655 * ************************************************************************** **
657 static char *map_filename( char *s
, /* This is null terminated */
658 char *pattern
, /* This isn't. */
659 int len
) /* This is the length of pattern. */
661 static pstring matching_bit
; /* The bit of the string which matches */
662 /* a * in pattern if indeed there is a * */
663 char *sp
; /* Pointer into s. */
664 char *pp
; /* Pointer into p. */
665 char *match_start
; /* Where the matching bit starts. */
668 StrnCpy( pat
, pattern
, len
); /* Get pattern into a proper string! */
669 pstrcpy( matching_bit
, "" ); /* Match but no star gets this. */
670 pp
= pat
; /* Initialize the pointers. */
673 if( strequal(s
, ".") || strequal(s
, ".."))
675 return NULL
; /* Do not map '.' and '..' */
678 if( (len
== 1) && (*pattern
== '*') )
680 return NULL
; /* Impossible, too ambiguous for */
683 while( (*sp
) /* Not the end of the string. */
684 && (*pp
) /* Not the end of the pattern. */
685 && (*sp
== *pp
) /* The two match. */
686 && (*pp
!= '*') ) /* No wildcard. */
688 sp
++; /* Keep looking. */
692 if( !*sp
&& !*pp
) /* End of pattern. */
693 return( matching_bit
); /* Simple match. Return empty string. */
697 pp
++; /* Always interrested in the chacter */
699 if( !*pp
) /* It is at the end of the pattern. */
701 StrnCpy( matching_bit
, s
, sp
-s
);
702 return( matching_bit
);
706 /* The next character in pattern must match a character further */
707 /* along s than sp so look for that character. */
709 while( (*sp
) /* Not the end of s. */
710 && (*sp
!= *pp
) ) /* Not the same */
711 sp
++; /* Keep looking. */
712 if( !*sp
) /* Got to the end without a match. */
715 } /* Still hope for a match. */
718 /* Now sp should point to a matching character. */
719 StrnCpy(matching_bit
, match_start
, sp
-match_start
);
720 /* Back to needing a stright match again. */
721 while( (*sp
) /* Not the end of the string. */
722 && (*pp
) /* Not the end of the pattern. */
723 && (*sp
== *pp
) ) /* The two match. */
725 sp
++; /* Keep looking. */
728 if( !*sp
&& !*pp
) /* Both at end so it matched */
729 return( matching_bit
);
735 return( NULL
); /* No match. */
739 /* ************************************************************************** **
740 * MangledMap is a series of name pairs in () separated by spaces.
741 * If s matches the first of the pair then the name given is the
742 * second of the pair. A * means any number of any character and if
743 * present in the second of the pair as well as the first the
744 * matching part of the first string takes the place of the * in the
747 * I wanted this so that we could have RCS files which can be used
748 * by UNIX and DOS programs. My mapping string is (RCS rcs) which
749 * converts the UNIX RCS file subdirectory to lowercase thus
750 * preventing mangling.
752 * (I think Andrew wrote the above, but I'm not sure. -- CRH)
754 * See 'mangled map' in smb.conf(5).
756 * ************************************************************************** **
758 static void do_fwd_mangled_map(char *s
, char *MangledMap
)
760 char *start
=MangledMap
; /* Use this to search for mappings. */
761 char *end
; /* Used to find the end of strings. */
763 pstring new_string
; /* Make up the result here. */
764 char *np
; /* Points into new_string. */
766 DEBUG( 5, ("Mangled Mapping '%s' map '%s'\n", s
, MangledMap
) );
769 while( (*start
) && (*start
!= '(') )
772 continue; /* Always check for the end. */
773 start
++; /* Skip the ( */
774 end
= start
; /* Search for the ' ' or a ')' */
775 DEBUG( 5, ("Start of first in pair '%s'\n", start
) );
776 while( (*end
) && !((*end
== ' ') || (*end
== ')')) )
781 continue; /* Always check for the end. */
783 DEBUG( 5, ("End of first in pair '%s'\n", end
) );
784 if( (match_string
= map_filename( s
, start
, end
-start
)) )
786 DEBUG( 5, ("Found a match\n") );
788 start
= end
+ 1; /* Point to start of what it is to become. */
789 DEBUG( 5, ("Start of second in pair '%s'\n", start
) );
792 while( (*end
) /* Not the end of string. */
793 && (*end
!= ')') /* Not the end of the pattern. */
794 && (*end
!= '*') ) /* Not a wildcard. */
799 continue; /* Always check for the end. */
803 pstrcpy( np
, match_string
);
804 np
+= strlen( match_string
);
805 end
++; /* Skip the '*' */
806 while( (*end
) /* Not the end of string. */
807 && (*end
!= ')') /* Not the end of the pattern. */
808 && (*end
!= '*') ) /* Not a wildcard. */
814 continue; /* Always check for the end. */
816 *np
++ = '\0'; /* NULL terminate it. */
817 DEBUG(5,("End of second in pair '%s'\n", end
));
818 pstrcpy( s
, new_string
); /* Substitute with the new name. */
819 DEBUG( 5, ("s is now '%s'\n", s
) );
821 start
= end
; /* Skip a bit which cannot be wanted anymore. */
824 } /* do_fwd_mangled_map */
826 /*****************************************************************************
827 * do the actual mangling to 8.3 format
828 * the buffer must be able to hold 13 characters (including the null)
829 *****************************************************************************
831 void mangle_name_83( char *s
)
843 p
= strrchr_m(s
,'.');
844 if( p
&& (strlen(p
+1) < (size_t)4) )
846 BOOL all_normal
= ( strisnormal(p
+1) ); /* XXXXXXXXX */
848 if( all_normal
&& p
[1] != 0 )
851 csum
= str_checksum( s
);
855 csum
= str_checksum(s
);
858 csum
= str_checksum(s
);
862 DEBUG( 5, ("Mangling name %s to ",s
) );
867 safe_strcpy( extension
, "___", 3 );
871 while( *p
&& extlen
< 3 )
873 if( /*isdoschar (*p) &&*/ *p
!= '.' )
874 extension
[extlen
++] = p
[0];
877 extension
[extlen
] = 0;
883 while( *p
&& baselen
< 5 )
885 if( /*isdoschar( *p ) &&*/ *p
!= '.' )
886 base
[baselen
++] = p
[0];
891 csum
= csum
% (MANGLE_BASE
*MANGLE_BASE
);
893 (void)slprintf(s
, 12, "%s%c%c%c",
894 base
, magic_char
, mangle( csum
/MANGLE_BASE
), mangle( csum
) );
898 (void)pstrcat( s
, "." );
899 (void)pstrcat( s
, extension
);
902 DEBUG( 5, ( "%s\n", s
) );
904 } /* mangle_name_83 */
906 /*****************************************************************************
907 * Convert a filename to DOS format. Return True if successful.
909 * Input: OutName - Source *and* destination buffer.
911 * NOTE that OutName must point to a memory space that
912 * is at least 13 bytes in size!
914 * need83 - If False, name mangling will be skipped unless the
915 * name contains illegal characters. Mapping will still
916 * be done, if appropriate. This is probably used to
917 * signal that a client does not require name mangling,
918 * thus skipping the name mangling even on shares which
919 * have name-mangling turned on.
920 * cache83 - If False, the mangled name cache will not be updated.
921 * This is usually used to prevent that we overwrite
922 * a conflicting cache entry prematurely, i.e. before
923 * we know whether the client is really interested in the
924 * current name. (See PR#13758). UKD.
925 * snum - Share number. This identifies the share in which the
928 * Output: Returns False only if the name wanted mangling but the share does
929 * not have name mangling turned on.
931 * ****************************************************************************
933 BOOL
name_map_mangle(char *OutName
, BOOL need83
, BOOL cache83
, int snum
)
936 DEBUG(5,("name_map_mangle( %s, need83 = %s, cache83 = %s, %d )\n", OutName
,
937 need83
? "TRUE" : "FALSE", cache83
? "TRUE" : "FALSE", snum
));
939 #ifdef MANGLE_LONG_FILENAMES
940 if( !need83
&& is_illegal_name(OutName
) )
944 /* apply any name mappings */
945 map
= lp_mangled_map(snum
);
948 do_fwd_mangled_map( OutName
, map
);
951 /* check if it's already in 8.3 format */
952 if (need83
&& !is_8_3(OutName
, True
)) {
955 if (!lp_manglednames(snum
)) {
959 /* mangle it into 8.3 */
961 tmp
= strdup(OutName
);
963 mangle_name_83(OutName
);
966 cache_mangled_name(OutName
, tmp
);
971 DEBUG(5,("name_map_mangle() ==> [%s]\n", OutName
));
973 } /* name_map_mangle */
980 /* -------------------------------------------------------------------- */
982 Unix SMB/Netbios implementation.
984 Name mangling with persistent tdb
985 Copyright (C) Simo Sorce <idra@samba.org> 2001
987 This program is free software; you can redistribute it and/or modify
988 it under the terms of the GNU General Public License as published by
989 the Free Software Foundation; either version 2 of the License, or
990 (at your option) any later version.
992 This program is distributed in the hope that it will be useful,
993 but WITHOUT ANY WARRANTY; without even the implied warranty of
994 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
995 GNU General Public License for more details.
997 You should have received a copy of the GNU General Public License
998 along with this program; if not, write to the Free Software
999 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
1004 #define MANGLE_TDB_VERSION "20010927"
1005 #define MANGLE_TDB_FILE_NAME "mangle.tdb"
1006 #define MANGLED_PREFIX "MANGLED_"
1007 #define LONG_PREFIX "LONG_"
1008 #define COUNTER_PREFIX "COUNTER_"
1009 #define MANGLE_COUNTER_MAX 99
1010 #define MANGLE_SUFFIX_SIZE 2
1013 static TDB_CONTEXT
*mangle_tdb
;
1015 BOOL
init_mangle_tdb(void)
1019 tdbfile
= lock_path(MANGLE_TDB_FILE_NAME
); /* this return a static pstring do not try to free it */
1022 if (!(mangle_tdb
= tdb_open_log(tdbfile
, 0, TDB_DEFAULT
, O_RDWR
| O_CREAT
, 0600)))
1024 DEBUG(0, ("Unable to open Mangle TDB\n"));
1031 /* trasform a dos charset string in a terminated unicode string */
1032 static int dos_to_ucs2(void *dest
, const char *src
, int dest_len
)
1035 int src_len
= strlen(src
) + 1;
1037 /* treat a pstring as "unlimited" length */
1038 if (dest_len
== -1) {
1039 dest_len
= sizeof(pstring
);
1042 /* ucs2 is always a multiple of 2 bytes */
1045 len
= convert_string(CH_DOS
, CH_UCS2
, src
, src_len
, dest
, dest_len
);
1049 /* trasform a unicode string into a dos charset string */
1050 static int ucs2_to_dos(char *dest
, const smb_ucs2_t
*src
, int dest_len
)
1054 if (dest_len
== -1) {
1055 dest_len
= sizeof(pstring
);
1058 src_len
= strlen_w(src
) * sizeof(smb_ucs2_t
);
1060 ret
= convert_string(CH_UCS2
, CH_DOS
, src
, src_len
, dest
, dest_len
);
1061 if (dest_len
) dest
[MIN(ret
, dest_len
-1)] = 0;
1066 /* trasform a ucs2 string in a dos charset string that contain only valid chars for 8.3 filenames */
1067 static int ucs2_to_dos83(char *dest
, const smb_ucs2_t
*src
, int dest_len
)
1072 u2s
= (smb_ucs2_t
*)malloc((strlen_w(src
) + 1) * sizeof(smb_ucs2_t
));
1074 DEBUG(0, ("ucs2_to_dos83: out of memory!\n"));
1078 src_len
= strlen_w(src
);
1086 if (isvalid83_w(c
)) u2s
[src_len
] = c
;
1087 else u2s
[src_len
] = UCS2_CHAR('_');
1090 ret
= ucs2_to_dos(dest
, u2s
, dest_len
);
1098 /* return False if something fail and
1099 * return 2 alloced unicode strings that contain prefix and extension
1101 static BOOL
mangle_get_prefix(const smb_ucs2_t
*ucs2_string
, smb_ucs2_t
**prefix
, smb_ucs2_t
**extension
)
1108 *prefix
= strdup_w(ucs2_string
);
1111 DEBUG(0,("mangle_get_prefix: out of memory!\n"));
1114 if ((p
= strrchr_wa(*prefix
, '.')))
1117 str_len
= ucs2_to_dos83(ext
, p
, sizeof(ext
));
1118 if (str_len
> 0 && str_len
< 4) /* check extension */
1121 *extension
= strdup_w(p
);
1124 DEBUG(0,("mangle_get_prefix: out of memory!\n"));
1135 /* mangled must contain only the file name, not a path.
1136 and MUST be ZERO terminated */
1137 smb_ucs2_t
*unmangle(const smb_ucs2_t
*mangled
)
1142 smb_ucs2_t
*pref
, *ext
, *retstr
;
1143 size_t long_len
, ext_len
, muf_len
;
1146 if (strlen_w(mangled
) > 12) return NULL
;
1147 if (!strchr_wa(mangled
, '~')) return NULL
;
1149 ret
= mangle_get_prefix(mangled
, &pref
, &ext
);
1150 if (!ret
) return NULL
;
1152 /* TODO: get out extension */
1154 /* set search key */
1155 muf_len
= ucs2_to_dos(mufname
, pref
, sizeof(mufname
));
1157 if (!muf_len
) return NULL
;
1159 slprintf(keystr
, sizeof(keystr
) - 1, "%s%s", MANGLED_PREFIX
, mufname
);
1161 key
.dsize
= strlen (keystr
) + 1;
1163 /* get the record */
1164 data
= tdb_fetch(mangle_tdb
, key
);
1166 if (!data
.dptr
) /* not found */
1168 DEBUG(5,("unmangle: failed retrieve from db %s\n", tdb_errorstr(mangle_tdb
)));
1175 long_len
= (data
.dsize
/ 2) - 1;
1176 ext_len
= strlen_w(ext
);
1177 retstr
= (smb_ucs2_t
*)malloc((long_len
+ ext_len
+ 2)*sizeof(smb_ucs2_t
));
1180 DEBUG(0, ("unamngle: out of memory!\n"));
1183 strncpy_w(retstr
, (smb_ucs2_t
*)data
.dptr
, long_len
);
1184 retstr
[long_len
] = UCS2_CHAR('.');
1185 retstr
[long_len
+ 1] = 0;
1186 strncat_w(retstr
, ext
, ext_len
);
1190 retstr
= strdup_w((smb_ucs2_t
*)data
.dptr
);
1193 DEBUG(0, ("unamngle: out of memory!\n"));
1200 SAFE_FREE(data
.dptr
);
1207 /* unmangled must contain only the file name, not a path.
1208 and MUST be ZERO terminated */
1209 smb_ucs2_t
*_mangle(const smb_ucs2_t
*unmangled
)
1211 TDB_DATA data
, key
, klock
;
1217 BOOL tclock
= False
;
1219 smb_ucs2_t
*mangled
= NULL
;
1220 smb_ucs2_t
*um
, *ext
, *p
= NULL
;
1222 size_t pref_len
, ext_len
, ud83_len
;
1225 /* TODO: if it is a path return a failure ?? */
1226 if (!mangle_get_prefix(unmangled
, &um
, &ext
)) return NULL
;
1228 /* test if the same is yet mangled */
1230 /* set search key */
1231 pull_ucs2(NULL
, longname
, um
, sizeof(longname
), 0, STR_TERMINATE
);
1232 slprintf(keystr
, sizeof(keystr
)-1, "%s%s", LONG_PREFIX
, longname
);
1234 key
.dsize
= strlen(keystr
) + 1;
1236 /* get the record */
1237 data
= tdb_fetch (mangle_tdb
, key
);
1238 if (!data
.dptr
) /* not found */
1240 if (tdb_error(mangle_tdb
) != TDB_ERR_NOEXIST
)
1242 DEBUG(0, ("mangle: database retrieval error: %s\n",
1243 tdb_errorstr(mangle_tdb
)));
1247 /* if not find the first free possibile mangled name */
1253 pos
= 8 - n
- MANGLE_SUFFIX_SIZE
;
1256 DEBUG(0, ("mangle: unable to mangle file name!\n"));
1259 strncpy_w(temp
, um
, pos
);
1263 ud83_len
= ucs2_to_dos83(prefix
, temp
, sizeof(prefix
));
1264 if (!ud83_len
) goto done
;
1266 while (ud83_len
> 8 - (MANGLE_SUFFIX_SIZE
+ 1));
1268 slprintf(keylock
, sizeof(keylock
)-1, "%s%s", COUNTER_PREFIX
, prefix
);
1269 klock
.dptr
= keylock
;
1270 klock
.dsize
= strlen(keylock
) + 1;
1273 data
.dptr
= (char *)&c
;
1274 data
.dsize
= sizeof(uint32
);
1275 /* try to insert a new counter prefix, if it exist the call will
1276 fail (correct) otherwise it will create a new entry with counter set
1279 if(tdb_store(mangle_tdb
, klock
, data
, TDB_INSERT
) != TDB_SUCCESS
)
1281 if (tdb_error(mangle_tdb
) != TDB_ERR_EXISTS
)
1283 DEBUG(0, ("mangle: database store error: %s\n",
1284 tdb_errorstr(mangle_tdb
)));
1289 /* lock the mangle counter for this prefix */
1290 if (tdb_chainlock(mangle_tdb
, klock
))
1292 DEBUG(0,("mangle: failed to lock database\n!"));
1297 data
= tdb_fetch(mangle_tdb
, klock
);
1300 DEBUG(0, ("mangle: database retrieval error: %s\n",
1301 tdb_errorstr(mangle_tdb
)));
1304 c
= *((uint32
*)data
.dptr
);
1307 if (c
> MANGLE_COUNTER_MAX
)
1309 DEBUG(0, ("mangle: error, counter overflow!\n"));
1313 temp
[pos
] = UCS2_CHAR('~');
1315 snprintf(suffix
, 7, "%.6d", c
);
1316 strncat_wa(temp
, &suffix
[6 - MANGLE_SUFFIX_SIZE
], MANGLE_SUFFIX_SIZE
+ 1);
1318 ud83_len
= ucs2_to_dos(mufname
, temp
, sizeof(mufname
));
1319 if (!ud83_len
) goto done
;
1322 DEBUG(0, ("mangle: darn, logic error aborting!\n"));
1326 /* store the long entry with mangled key */
1327 slprintf(keystr
, sizeof(keystr
)-1, "%s%s", MANGLED_PREFIX
, mufname
);
1329 key
.dsize
= strlen (keystr
) + 1;
1330 data
.dsize
= (strlen_w(um
) + 1) * sizeof (smb_ucs2_t
);
1331 data
.dptr
= (void *)um
;
1333 if (tdb_store(mangle_tdb
, key
, data
, TDB_INSERT
) != TDB_SUCCESS
)
1335 DEBUG(0, ("mangle: database store error: %s\n",
1336 tdb_errorstr(mangle_tdb
)));
1340 /* store the mangled entry with long key*/
1341 pull_ucs2(NULL
, longname
, um
, sizeof(longname
), 0, STR_TERMINATE
);
1342 slprintf(keystr
, sizeof(keystr
)-1, "%s%s", LONG_PREFIX
, longname
);
1344 key
.dsize
= strlen (keystr
) + 1;
1345 data
.dsize
= strlen(mufname
) + 1;
1346 data
.dptr
= mufname
;
1347 if (tdb_store(mangle_tdb
, key
, data
, TDB_INSERT
) != TDB_SUCCESS
)
1349 DEBUG(0, ("mangle: database store failed: %s\n",
1350 tdb_errorstr(mangle_tdb
)));
1352 /* try to delete the mangled key entry to avoid later inconsistency */
1353 slprintf(keystr
, sizeof(keystr
)-1, "%s%s", MANGLED_PREFIX
, mufname
);
1355 key
.dsize
= strlen (keystr
) + 1;
1356 if (!tdb_delete(mangle_tdb
, key
))
1358 DEBUG(0, ("mangle: severe error, mangled tdb may be inconsistent!\n"));
1366 DEBUG(0,("mangle: out of memory!\n"));
1370 data
.dptr
= (char *)&c
;
1371 data
.dsize
= sizeof(uint32
);
1372 /* store the counter */
1373 if(tdb_store(mangle_tdb
, klock
, data
, TDB_REPLACE
) != TDB_SUCCESS
)
1375 DEBUG(0, ("mangle: database store failed: %s\n",
1376 tdb_errorstr(mangle_tdb
)));
1377 /* try to delete the mangled and long key entry to avoid later inconsistency */
1378 slprintf(keystr
, sizeof(keystr
)-1, "%s%s", MANGLED_PREFIX
, mufname
);
1380 key
.dsize
= strlen (keystr
) + 1;
1381 if (!tdb_delete(mangle_tdb
, key
))
1383 DEBUG(0, ("mangle: severe error, mangled tdb may be inconsistent!\n"));
1385 slprintf(keystr
, sizeof(keystr
)-1, "%s%s", LONG_PREFIX
, longname
);
1387 key
.dsize
= strlen (keystr
) + 1;
1388 if (!tdb_delete(mangle_tdb
, key
))
1390 DEBUG(0, ("mangle: severe error, mangled tdb may be inconsistent!\n"));
1396 tdb_chainunlock(mangle_tdb
, klock
);
1400 p
= (smb_ucs2_t
*)malloc(data
.dsize
*sizeof(smb_ucs2_t
));
1403 DEBUG(0,("mangle: out of memory!\n"));
1406 dos_to_ucs2(p
, data
.dptr
, data
.dsize
*sizeof(smb_ucs2_t
));
1411 pref_len
= strlen_w(p
);
1412 ext_len
= strlen_w(ext
);
1413 mangled
= (smb_ucs2_t
*)malloc((pref_len
+ ext_len
+ 2)*sizeof(smb_ucs2_t
));
1416 DEBUG(0,("mangle: out of memory!\n"));
1419 strncpy_w (mangled
, p
, pref_len
);
1420 mangled
[pref_len
] = UCS2_CHAR('.');
1421 mangled
[pref_len
+ 1] = 0;
1422 strncat_w (mangled
, ext
, ext_len
);
1426 mangled
= strdup_w(p
);
1429 DEBUG(0,("mangle: out of memory!\n"));
1435 if (tclock
) tdb_chainunlock(mangle_tdb
, klock
);
1446 /* backward compatibility functions */
1448 BOOL
is_mangled(char *s
)
1450 smb_ucs2_t
*u2
, *res
;
1454 DEBUG(10,("is_mangled: testing -> [%s]\n", s
));
1456 if (!s
|| !*s
) return False
;
1458 u2len
= (strlen(s
) + 1) * sizeof(smb_ucs2_t
);
1459 u2
= (smb_ucs2_t
*)malloc(u2len
);
1462 DEBUG(0,("is_mangled: out of memory!\n"));
1465 dos_to_ucs2(u2
, s
, u2len
);
1468 if (res
) ret
= True
;
1471 DEBUG(10,("is_mangled: returning -> %s\n", ret
?"True":"False"));
1475 BOOL
is_8_3(char *fname
, BOOL check_case
)
1477 smb_ucs2_t
*u2
, *pref
= 0, *ext
= 0;
1482 DEBUG(10,("is_8_3: testing -> [%s]\n", fname
));
1484 if (!fname
|| !*fname
) return False
;
1486 if (strcmp(fname
, ".") == 0 || strcmp(fname
, "..") == 0) return True
;
1488 u2len
= (strlen(fname
) + 1) * sizeof(smb_ucs2_t
);
1489 u2
= (smb_ucs2_t
*)malloc(u2len
);
1492 DEBUG(0,("is_8_3: out of memory!\n"));
1495 s1
= (char *) malloc(u2len
* 2);
1498 DEBUG(0,("is_8_3: out of memory!\n"));
1502 dos_to_ucs2(u2
, fname
, u2len
);
1504 if (!mangle_get_prefix(u2
, &pref
, &ext
)) goto done
;
1505 plen
= strlen_w(pref
);
1506 if (plen
< 1 || plen
> 8) goto done
;
1508 if (strlen_w(ext
) > 3) goto done
;
1510 DEBUG(10,("pref len = %d, ext len = %d\n", pref
?strlen_w(pref
):0, ext
?strlen_w(ext
):0));
1512 ucs2_to_dos(s1
, u2
, u2len
);
1513 ucs2_to_dos83(s2
, u2
, u2len
);
1515 if (strncmp(s1
, s2
, u2len
)) goto done
;
1524 DEBUG(10,("is_8_3: returning -> %s\n", ret
?"True":"False"));
1528 void reset_mangled_cache(void)
1530 DEBUG(10,("reset_mangled_cache: compatibility function, remove me!\n"));
1533 BOOL
check_mangled_cache(char *s
)
1535 smb_ucs2_t
*u2
, *res
;
1539 DEBUG(10,("check_mangled_cache: I'm so ugly, please remove me!\n"));
1540 DEBUG(10,("check_mangled_cache: testing -> [%s]\n", s
));
1542 if (!s
|| !*s
) return False
;
1545 u2len
= (slen
+ 1) * sizeof(smb_ucs2_t
);
1546 u2
= (smb_ucs2_t
*)malloc(u2len
);
1549 DEBUG(0,("check_mangled_cache: out of memory!\n"));
1552 dos_to_ucs2(u2
, s
, u2len
);
1557 ucs2_to_dos (s
, res
, 13); /* ugly, but must be done this way */
1558 DEBUG(10,("check_mangled_cache: returning -> [%s]\n", s
));
1563 DEBUG(10,("check_mangled_cache: returning -> %s\n", ret
?"True":"False"));
1567 void mangle_name_83(char *s
)
1569 smb_ucs2_t
*u2
, *res
;
1572 DEBUG(10,("mangle_name_83: I'm so ugly, please remove me!\n"));
1573 DEBUG(10,("mangle_name_83: testing -> [%s]\n", s
));
1575 if (!s
|| !*s
) return;
1578 u2len
= (slen
+ 1) * sizeof(smb_ucs2_t
);
1579 u2
= (smb_ucs2_t
*)malloc(u2len
);
1582 DEBUG(0,("mangle_name_83: out of memory!\n"));
1585 dos_to_ucs2(u2
, s
, u2len
);
1588 if (res
) ucs2_to_dos (s
, res
, 13); /* ugly, but must be done this way */
1589 DEBUG(10,("mangle_name_83: returning -> [%s]\n", res
));
1594 BOOL
name_map_mangle(char *OutName
, BOOL need83
, BOOL cache83
, int snum
)
1596 DEBUG(10,("name_map_mangle: I'm so ugly, please remove me!\n"));
1598 if (!need83
) return True
;
1599 /* if (is_8_3(OutName, True)) return True; */
1600 /* Warning: we should check for invalid chars in file name and mangle
1601 if invalid chars found --simo*/
1603 mangle_name_83(OutName
);
1609 #if 0 /* TEST_MANGLE_CODE */
1611 #define LONG "this_is_a_long_file_name"
1612 #define LONGM "this_~01"
1613 #define SHORT "short"
1614 #define SHORTM "short~01"
1618 #define EXTFAIL "longext"
1621 static void unmangle_test (char *name
, char *ext
)
1623 smb_ucs2_t ucs2_name
[2048];
1627 push_ucs2(NULL
, ucs2_name
, name
, sizeof(ucs2_name
), STR_TERMINATE
);
1630 strncat_wa(ucs2_name
, ".", 1);
1631 strncat_wa(ucs2_name
, ext
, strlen(ext
) + 1);
1633 retstr
= unmangle(ucs2_name
);
1634 if(retstr
) pull_ucs2(NULL
, unix_name
, retstr
, sizeof(unix_name
), 0, STR_TERMINATE
);
1635 else unix_name
[0] = 0;
1636 if (ext
) printf ("[%s.%s] ---> [%s]\n", name
, ext
, unix_name
);
1637 else printf ("[%s] ---> [%s]\n", name
, unix_name
);
1641 static void mangle_test (char *name
, char *ext
)
1643 smb_ucs2_t ucs2_name
[2048];
1647 push_ucs2(NULL
, ucs2_name
, name
, sizeof(ucs2_name
), STR_TERMINATE
);
1650 strncat_wa(ucs2_name
, ".", 1);
1651 strncat_wa(ucs2_name
, ext
, strlen(ext
) + 1);
1653 retstr
= _mangle(ucs2_name
);
1654 if(retstr
) pull_ucs2(NULL
, unix_name
, retstr
, sizeof(unix_name
), 0, STR_TERMINATE
);
1655 else unix_name
[0] = 0;
1656 if (ext
) printf ("[%s.%s] ---> [%s]\n", name
, ext
, unix_name
);
1657 else printf ("[%s] ---> [%s]\n", name
, unix_name
);
1661 void mangle_test_code(void)
1665 /* unmangle every */
1666 printf("Unmangle test 1:\n");
1668 unmangle_test (LONG
, NULL
);
1669 unmangle_test (LONG
, EXT1
);
1670 unmangle_test (LONG
, EXT2
);
1671 unmangle_test (LONG
, EXT3
);
1672 unmangle_test (LONG
, EXTFAIL
);
1673 unmangle_test (LONG
, EXTNULL
);
1675 unmangle_test (LONGM
, NULL
);
1676 unmangle_test (LONGM
, EXT1
);
1677 unmangle_test (LONGM
, EXT2
);
1678 unmangle_test (LONGM
, EXT3
);
1679 unmangle_test (LONGM
, EXTFAIL
);
1680 unmangle_test (LONGM
, EXTNULL
);
1682 unmangle_test (SHORT
, NULL
);
1683 unmangle_test (SHORT
, EXT1
);
1684 unmangle_test (SHORT
, EXT2
);
1685 unmangle_test (SHORT
, EXT3
);
1686 unmangle_test (SHORT
, EXTFAIL
);
1687 unmangle_test (SHORT
, EXTNULL
);
1689 unmangle_test (SHORTM
, NULL
);
1690 unmangle_test (SHORTM
, EXT1
);
1691 unmangle_test (SHORTM
, EXT2
);
1692 unmangle_test (SHORTM
, EXT3
);
1693 unmangle_test (SHORTM
, EXTFAIL
);
1694 unmangle_test (SHORTM
, EXTNULL
);
1697 printf("Mangle test\n");
1699 mangle_test (LONG
, NULL
);
1700 mangle_test (LONG
, EXT1
);
1701 mangle_test (LONG
, EXT2
);
1702 mangle_test (LONG
, EXT3
);
1703 mangle_test (LONG
, EXTFAIL
);
1704 mangle_test (LONG
, EXTNULL
);
1706 mangle_test (LONGM
, NULL
);
1707 mangle_test (LONGM
, EXT1
);
1708 mangle_test (LONGM
, EXT2
);
1709 mangle_test (LONGM
, EXT3
);
1710 mangle_test (LONGM
, EXTFAIL
);
1711 mangle_test (LONGM
, EXTNULL
);
1713 mangle_test (SHORT
, NULL
);
1714 mangle_test (SHORT
, EXT1
);
1715 mangle_test (SHORT
, EXT2
);
1716 mangle_test (SHORT
, EXT3
);
1717 mangle_test (SHORT
, EXTFAIL
);
1718 mangle_test (SHORT
, EXTNULL
);
1720 mangle_test (SHORTM
, NULL
);
1721 mangle_test (SHORTM
, EXT1
);
1722 mangle_test (SHORTM
, EXT2
);
1723 mangle_test (SHORTM
, EXT3
);
1724 mangle_test (SHORTM
, EXTFAIL
);
1725 mangle_test (SHORTM
, EXTNULL
);
1727 /* unmangle again every */
1728 printf("Unmangle test 2:\n");
1730 unmangle_test (LONG
, NULL
);
1731 unmangle_test (LONG
, EXT1
);
1732 unmangle_test (LONG
, EXT2
);
1733 unmangle_test (LONG
, EXT3
);
1734 unmangle_test (LONG
, EXTFAIL
);
1735 unmangle_test (LONG
, EXTNULL
);
1737 unmangle_test (LONGM
, NULL
);
1738 unmangle_test (LONGM
, EXT1
);
1739 unmangle_test (LONGM
, EXT2
);
1740 unmangle_test (LONGM
, EXT3
);
1741 unmangle_test (LONGM
, EXTFAIL
);
1742 unmangle_test (LONGM
, EXTNULL
);
1744 unmangle_test (SHORT
, NULL
);
1745 unmangle_test (SHORT
, EXT1
);
1746 unmangle_test (SHORT
, EXT2
);
1747 unmangle_test (SHORT
, EXT3
);
1748 unmangle_test (SHORT
, EXTFAIL
);
1749 unmangle_test (SHORT
, EXTNULL
);
1751 unmangle_test (SHORTM
, NULL
);
1752 unmangle_test (SHORTM
, EXT1
);
1753 unmangle_test (SHORTM
, EXT2
);
1754 unmangle_test (SHORTM
, EXT3
);
1755 unmangle_test (SHORTM
, EXTFAIL
);
1756 unmangle_test (SHORTM
, EXTNULL
);
1759 #endif /* TEST_MANGLE_CODE */