2 Unix SMB/Netbios implementation.
4 Name mangling with persistent tdb
5 Copyright (C) Simo Sorce 2001
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 Rewritten from scrach in 2001 by Simo Sorce <idra@samba.org>
24 ****************************************************************************/
29 /* -------------------------------------------------------------------------- **
30 * External Variables...
33 extern int case_default
; /* Are conforming 8.3 names all upper or lower? */
34 extern BOOL case_mangle
; /* If true, all chars in 8.3 should be same case. */
36 char magic_char
= '~';
38 /* -------------------------------------------------------------------- */
40 #define MANGLE_TDB_VERSION "20010927"
41 #define MANGLE_TDB_FILE_NAME "mangle.tdb"
42 #define MANGLED_PREFIX "MANGLED_"
43 #define LONG_PREFIX "LONG_"
44 #define COUNTER_PREFIX "COUNTER_"
45 #define MANGLE_COUNTER_MAX 99
46 #define MANGLE_SUFFIX_SIZE 3 /* "~XX" */
49 static TDB_CONTEXT
*mangle_tdb
;
51 BOOL
init_mangle_tdb(void)
55 tdbfile
= lock_path(MANGLE_TDB_FILE_NAME
); /* this return a static pstring do not try to free it */
58 if (!(mangle_tdb
= tdb_open_log(tdbfile
, 0, TDB_DEFAULT
, O_RDWR
| O_CREAT
, 0600)))
60 DEBUG(0, ("Unable to open Mangle TDB\n"));
67 /* trasform a unicode string into a dos charset string */
68 static int ucs2_to_dos(char *dest
, const smb_ucs2_t
*src
, int dest_len
)
73 dest_len
= sizeof(pstring
);
76 src_len
= strlen_w(src
)* sizeof(smb_ucs2_t
);
78 ret
= convert_string(CH_UCS2
, CH_DOS
, src
, src_len
, dest
, dest_len
);
79 if (dest_len
) dest
[MIN(ret
, dest_len
-1)] = 0;
84 /* trasform in a string that contain only valid chars for win filenames,
85 not including a '.' */
86 static void strvalid(smb_ucs2_t
*src
)
88 if (!src
|| !*src
) return;
91 if (!isvalid83_w(*src
) || *src
== UCS2_CHAR('.')) *src
= UCS2_CHAR('_');
97 /* return False if something fail and
98 * return 2 alloced unicode strings that contain prefix and extension
100 static NTSTATUS
mangle_get_prefix(const smb_ucs2_t
*ucs2_string
, smb_ucs2_t
**prefix
, smb_ucs2_t
**extension
)
106 *prefix
= strdup_w(ucs2_string
);
109 DEBUG(0,("mangle_get_prefix: out of memory!\n"));
110 return NT_STATUS_NO_MEMORY
;
112 if ((p
= strrchr_w(*prefix
, UCS2_CHAR('.'))))
114 ext_len
= strlen_w(p
+1);
115 if ((ext_len
> 0) && (ext_len
< 4) && (p
!= *prefix
) &&
116 (NT_STATUS_IS_OK(has_valid_chars(p
+1)))) /* check extension */
119 *extension
= strdup_w(p
+1);
122 DEBUG(0,("mangle_get_prefix: out of memory!\n"));
124 return NT_STATUS_NO_MEMORY
;
132 /* mangled must contain only the file name, not a path.
133 and MUST be ZERO terminated */
134 smb_ucs2_t
*unmangle(const smb_ucs2_t
*mangled
)
139 smb_ucs2_t
*pref
, *ext
, *retstr
;
140 size_t long_len
, ext_len
, muf_len
;
142 if (strlen_w(mangled
) > 12) return NULL
;
143 if (!strchr_w(mangled
, UCS2_CHAR('~'))) return NULL
;
145 /* if it is a path refuse to proceed */
146 if (strchr_w(mangled
, UCS2_CHAR('/'))) {
147 DEBUG(10, ("unmangle: cannot unmangle a path\n"));
151 if (NT_STATUS_IS_ERR(mangle_get_prefix(mangled
, &pref
, &ext
)))
154 /* mangled names are stored lowercase only */
157 muf_len
= ucs2_to_dos(mufname
, pref
, sizeof(mufname
));
159 if (!muf_len
) return NULL
;
161 slprintf(keystr
, sizeof(keystr
) - 1, "%s%s", MANGLED_PREFIX
, mufname
);
163 key
.dsize
= strlen (keystr
) + 1;
166 data
= tdb_fetch(mangle_tdb
, key
);
168 if (!data
.dptr
) /* not found */
170 DEBUG(5,("unmangle: failed retrieve from db %s\n", tdb_errorstr(mangle_tdb
)));
177 long_len
= (data
.dsize
/ 2) - 1;
178 ext_len
= strlen_w(ext
);
179 retstr
= (smb_ucs2_t
*)malloc((long_len
+ ext_len
+ 2)*sizeof(smb_ucs2_t
));
182 DEBUG(0, ("unamngle: out of memory!\n"));
185 strncpy_w(retstr
, (smb_ucs2_t
*)data
.dptr
, long_len
);
186 retstr
[long_len
] = UCS2_CHAR('.');
187 retstr
[long_len
+ 1] = 0;
188 strncat_w(retstr
, ext
, ext_len
);
192 retstr
= strdup_w((smb_ucs2_t
*)data
.dptr
);
195 DEBUG(0, ("unamngle: out of memory!\n"));
202 SAFE_FREE(data
.dptr
);
209 /* unmangled must contain only the file name, not a path.
210 and MUST be ZERO terminated.
211 return a new allocated string if the name is yet valid 8.3
212 or is mangled successfully.
213 return null on error.
216 smb_ucs2_t
*mangle(const smb_ucs2_t
*unmangled
)
218 TDB_DATA data
, key
, klock
;
226 smb_ucs2_t
*mangled
= NULL
;
227 smb_ucs2_t
*umpref
, *ext
, *p
= NULL
;
228 size_t pref_len
, ext_len
, ud83_len
;
230 /* if it is a path refuse to proceed */
231 if (strchr_w(unmangled
, UCS2_CHAR('/'))) {
232 DEBUG(10, ("mangle: cannot mangle a path\n"));
236 /* if it is a valid 8_3 do not mangle again */
237 if (NT_STATUS_IS_OK(is_8_3_w(unmangled
)))
240 if (NT_STATUS_IS_ERR(mangle_get_prefix(unmangled
, &umpref
, &ext
)))
243 /* test if the same is yet mangled */
246 pull_ucs2(NULL
, longname
, umpref
, sizeof(longname
), 0, STR_TERMINATE
);
247 slprintf(keystr
, sizeof(keystr
)-1, "%s%s", LONG_PREFIX
, longname
);
249 key
.dsize
= strlen(keystr
) + 1;
252 data
= tdb_fetch (mangle_tdb
, key
);
253 if (!data
.dptr
) /* not found */
258 if (tdb_error(mangle_tdb
) != TDB_ERR_NOEXIST
)
260 DEBUG(0, ("mangle: database retrieval error: %s\n",
261 tdb_errorstr(mangle_tdb
)));
265 /* if not find the first free possibile mangled name */
267 pos
= strlen_w(umpref
);
268 if ((8 - MANGLE_SUFFIX_SIZE
) < pos
)
269 pos
= 8 - MANGLE_SUFFIX_SIZE
;
276 DEBUG(0, ("mangle: unable to mangle file name!\n"));
279 strncpy_w(temp
, umpref
, pos
);
283 /* convert any invalid char into '_' */
285 ud83_len
= ucs2_to_dos(prefix
, temp
, sizeof(prefix
));
286 if (!ud83_len
) goto done
;
288 while (ud83_len
> 8 - MANGLE_SUFFIX_SIZE
);
290 slprintf(keylock
, sizeof(keylock
)-1, "%s%s", COUNTER_PREFIX
, prefix
);
291 klock
.dptr
= keylock
;
292 klock
.dsize
= strlen(keylock
) + 1;
295 data
.dptr
= (char *)&c
;
296 data
.dsize
= sizeof(uint32
);
297 /* try to insert a new counter prefix, if it exist the call will
298 fail (correct) otherwise it will create a new entry with counter set
301 if(tdb_store(mangle_tdb
, klock
, data
, TDB_INSERT
) != TDB_SUCCESS
)
303 if (tdb_error(mangle_tdb
) != TDB_ERR_EXISTS
)
305 DEBUG(0, ("mangle: database store error: %s\n",
306 tdb_errorstr(mangle_tdb
)));
311 /* lock the mangle counter for this prefix */
312 if (tdb_chainlock(mangle_tdb
, klock
))
314 DEBUG(0,("mangle: failed to lock database\n!"));
319 data
= tdb_fetch(mangle_tdb
, klock
);
322 DEBUG(0, ("mangle: database retrieval error: %s\n",
323 tdb_errorstr(mangle_tdb
)));
326 c
= *((uint32
*)data
.dptr
);
329 if (c
> MANGLE_COUNTER_MAX
)
331 DEBUG(0, ("mangle: error, counter overflow!\n"));
335 temp
[pos
] = UCS2_CHAR('~');
337 snprintf(suffix
, 7, "%.6d", c
);
338 strncat_wa(temp
, &suffix
[7 - MANGLE_SUFFIX_SIZE
], MANGLE_SUFFIX_SIZE
);
340 ud83_len
= ucs2_to_dos(mufname
, temp
, sizeof(mufname
));
341 if (!ud83_len
) goto done
;
344 DEBUG(0, ("mangle: darn, logic error aborting!\n"));
348 /* store the long entry with mangled key */
349 slprintf(keystr
, sizeof(keystr
)-1, "%s%s", MANGLED_PREFIX
, mufname
);
351 key
.dsize
= strlen (keystr
) + 1;
352 data
.dsize
= (strlen_w(umpref
) + 1) * sizeof (smb_ucs2_t
);
353 data
.dptr
= (void *)umpref
;
355 if (tdb_store(mangle_tdb
, key
, data
, TDB_INSERT
) != TDB_SUCCESS
)
357 DEBUG(0, ("mangle: database store error: %s\n",
358 tdb_errorstr(mangle_tdb
)));
362 /* store the mangled entry with long key*/
363 pull_ucs2(NULL
, longname
, umpref
, sizeof(longname
), 0, STR_TERMINATE
);
364 slprintf(keystr
, sizeof(keystr
)-1, "%s%s", LONG_PREFIX
, longname
);
366 key
.dsize
= strlen (keystr
) + 1;
367 data
.dsize
= strlen(mufname
) + 1;
369 if (tdb_store(mangle_tdb
, key
, data
, TDB_INSERT
) != TDB_SUCCESS
)
371 DEBUG(0, ("mangle: database store failed: %s\n",
372 tdb_errorstr(mangle_tdb
)));
374 /* try to delete the mangled key entry to avoid later inconsistency */
375 slprintf(keystr
, sizeof(keystr
)-1, "%s%s", MANGLED_PREFIX
, mufname
);
377 key
.dsize
= strlen (keystr
) + 1;
378 if (!tdb_delete(mangle_tdb
, key
))
380 DEBUG(0, ("mangle: severe error, mangled tdb may be inconsistent!\n"));
388 DEBUG(0,("mangle: out of memory!\n"));
392 data
.dptr
= (char *)&c
;
393 data
.dsize
= sizeof(uint32
);
394 /* store the counter */
395 if(tdb_store(mangle_tdb
, klock
, data
, TDB_REPLACE
) != TDB_SUCCESS
)
397 DEBUG(0, ("mangle: database store failed: %s\n",
398 tdb_errorstr(mangle_tdb
)));
399 /* try to delete the mangled and long key entry to avoid later inconsistency */
400 slprintf(keystr
, sizeof(keystr
)-1, "%s%s", MANGLED_PREFIX
, mufname
);
402 key
.dsize
= strlen (keystr
) + 1;
403 if (!tdb_delete(mangle_tdb
, key
))
405 DEBUG(0, ("mangle: severe error, mangled tdb may be inconsistent!\n"));
407 slprintf(keystr
, sizeof(keystr
)-1, "%s%s", LONG_PREFIX
, longname
);
409 key
.dsize
= strlen (keystr
) + 1;
410 if (!tdb_delete(mangle_tdb
, key
))
412 DEBUG(0, ("mangle: severe error, mangled tdb may be inconsistent!\n"));
418 tdb_chainunlock(mangle_tdb
, klock
);
422 p
= acnv_dosu2(data
.dptr
);
425 DEBUG(0,("mangle: out of memory!\n"));
432 pref_len
= strlen_w(p
);
433 ext_len
= strlen_w(ext
);
434 mangled
= (smb_ucs2_t
*)malloc((pref_len
+ ext_len
+ 2)*sizeof(smb_ucs2_t
));
437 DEBUG(0,("mangle: out of memory!\n"));
440 strncpy_w (mangled
, p
, pref_len
);
441 mangled
[pref_len
] = UCS2_CHAR('.');
442 mangled
[pref_len
+ 1] = 0;
443 strncat_w (mangled
, ext
, ext_len
);
447 mangled
= strdup_w(p
);
450 DEBUG(0,("mangle: out of memory!\n"));
455 /* mangled name are returned in upper or lower case depending on
456 case_default value */
460 if (tclock
) tdb_chainunlock(mangle_tdb
, klock
);
469 /* non unicode compatibility functions */
471 char *dos_mangle(const char *dos_unmangled
)
473 smb_ucs2_t
*in
, *out
;
476 if (!dos_unmangled
|| !*dos_unmangled
) return NULL
;
478 in
= acnv_dosu2(dos_unmangled
);
481 DEBUG(0,("dos_mangle: out of memory!\n"));
492 dos_mangled
= acnv_u2dos(out
);
495 DEBUG(0,("dos_mangle: out of memory!\n"));
505 char *dos_unmangle(const char *dos_mangled
)
507 smb_ucs2_t
*in
, *out
;
510 if (!dos_mangled
|| !*dos_mangled
) return NULL
;
512 in
= acnv_dosu2(dos_mangled
);
515 DEBUG(0,("dos_unmangle: out of memory!\n"));
526 dos_unmangled
= acnv_u2dos(out
);
529 DEBUG(0,("dos_unmangle: out of memory!\n"));
536 return dos_unmangled
;
539 BOOL
is_8_3(const char *fname
, BOOL check_case
)
542 smb_ucs2_t
*ucs2name
;
543 NTSTATUS ret
= NT_STATUS_UNSUCCESSFUL
;
545 if (!fname
|| !*fname
) return False
;
546 if ((f
= strrchr(fname
, '/')) == NULL
) f
= fname
;
549 DEBUG(10,("is_8_3: testing [%s]\n", f
));
551 if (strlen(f
) > 12) return False
;
553 ucs2name
= acnv_uxu2(f
);
556 DEBUG(0,("is_8_3: out of memory!\n"));
560 ret
= is_8_3_w(ucs2name
);
565 DEBUG(10,("is_8_3: returning -> %s\n", NT_STATUS_IS_OK(ret
)?"True":"False"));
567 if (NT_STATUS_IS_ERR(ret
)) return False
;
571 NTSTATUS
is_8_3_w(const smb_ucs2_t
*fname
)
573 smb_ucs2_t
*pref
= 0, *ext
= 0;
575 NTSTATUS ret
= NT_STATUS_UNSUCCESSFUL
;
577 if (!fname
|| !*fname
) return NT_STATUS_INVALID_PARAMETER
;
579 DEBUG(10,("is_8_3_w: testing\n")); /* [%s]\n", fname)); */
581 if (strlen_w(fname
) > 12) return NT_STATUS_UNSUCCESSFUL
;
583 if (strcmp_wa(fname
, ".") == 0 || strcmp_wa(fname
, "..") == 0)
586 if (NT_STATUS_IS_ERR(is_valid_name(fname
))) goto done
;
588 if (NT_STATUS_IS_ERR(mangle_get_prefix(fname
, &pref
, &ext
))) goto done
;
589 plen
= strlen_w(pref
);
591 if (strchr_wa(pref
, '.')) goto done
;
592 if (plen
< 1 || plen
> 8) goto done
;
593 if (ext
) if (strlen_w(ext
) > 3) goto done
;
603 NTSTATUS
has_valid_chars(const smb_ucs2_t
*s
)
605 NTSTATUS ret
= NT_STATUS_OK
;
607 if (!s
|| !*s
) return NT_STATUS_INVALID_PARAMETER
;
609 DEBUG(10,("has_valid_chars: testing\n")); /* [%s]\n", s)); */
611 /* CHECK: this should not be necessary if the ms wild chars
612 are not valid in valid.dat --- simo */
613 if (ms_has_wild_w(s
)) return NT_STATUS_UNSUCCESSFUL
;
616 if(!isvalid83_w(*s
)) return NT_STATUS_UNSUCCESSFUL
;
623 NTSTATUS
is_valid_name(const smb_ucs2_t
*fname
)
626 NTSTATUS ret
= NT_STATUS_OK
;
628 if (!fname
|| !*fname
) return NT_STATUS_INVALID_PARAMETER
;
630 DEBUG(10,("is_valid_name: testing\n")); /* [%s]\n", s)); */
632 if (*fname
== UCS2_CHAR('.')) return NT_STATUS_UNSUCCESSFUL
;
634 ret
= has_valid_chars(fname
);
635 if (NT_STATUS_IS_ERR(ret
)) return ret
;
637 str
= strdup_w(fname
);
638 p
= strchr_w(str
, UCS2_CHAR('.'));
646 if(strcmp_wa(p
, "UX") == 0)
647 ret
= NT_STATUS_UNSUCCESSFUL
;
650 if((strcmp_wa(p
, "LOCK$") == 0)
651 || (strcmp_wa(p
, "ON") == 0)
652 || (strcmp_wa(p
, "OM1") == 0)
653 || (strcmp_wa(p
, "OM2") == 0)
654 || (strcmp_wa(p
, "OM3") == 0)
655 || (strcmp_wa(p
, "OM4") == 0)
657 ret
= NT_STATUS_UNSUCCESSFUL
;
660 if((strcmp_wa(p
, "PT1") == 0)
661 || (strcmp_wa(p
, "PT2") == 0)
662 || (strcmp_wa(p
, "PT3") == 0)
664 ret
= NT_STATUS_UNSUCCESSFUL
;
667 if(strcmp_wa(p
, "UL") == 0)
668 ret
= NT_STATUS_UNSUCCESSFUL
;
671 if(strcmp_wa(p
, "RN") == 0)
672 ret
= NT_STATUS_UNSUCCESSFUL
;
682 BOOL
is_mangled(const char *s
)
684 smb_ucs2_t
*u2
, *res
;
687 DEBUG(10,("is_mangled: testing [%s]\n", s
));
689 if (!s
|| !*s
) return False
;
690 if ((strlen(s
) > 12) || (!strchr(s
, '~'))) return False
;
695 DEBUG(0,("is_mangled: out of memory!\n"));
703 DEBUG(10,("is_mangled: returning [%s]\n", ret
?"True":"False"));
707 NTSTATUS
is_mangled_w(const smb_ucs2_t
*s
)
710 NTSTATUS ret
= NT_STATUS_UNSUCCESSFUL
;
713 if (res
) ret
= NT_STATUS_OK
;
718 NTSTATUS
path_has_mangled(const smb_ucs2_t
*s
)
720 smb_ucs2_t
*p
, *f
, *b
;
721 NTSTATUS ret
= NT_STATUS_UNSUCCESSFUL
;
723 if (!s
|| !*s
) return NT_STATUS_INVALID_PARAMETER
;
726 if (!p
) return NT_STATUS_NO_MEMORY
;
727 trim_string_wa(p
, "/", "/");
730 b
= strchr_w(f
, UCS2_CHAR('/'));
732 if (NT_STATUS_IS_OK(is_mangled_w(f
))) {
743 /* backward compatibility functions */
745 void reset_mangled_cache(void)
747 DEBUG(10,("reset_mangled_cache: compatibility function, remove me!\n"));
750 BOOL
check_mangled_cache(char *s
)
752 smb_ucs2_t
*u2
, *res
;
755 DEBUG(10,("check_mangled_cache: I'm so ugly, please remove me!\n"));
756 DEBUG(10,("check_mangled_cache: testing -> [%s]\n", s
));
758 if (!s
|| !*s
) return False
;
763 DEBUG(0,("check_mangled_cache: out of memory!\n"));
771 ucs2_to_dos (s
, res
, PSTRING_LEN
);
772 /* We MUST change this brainded interface,
773 we do not know how many chars will be used
774 in dos so i guess they will be no more than
775 double the size of the unicode string
777 DEBUG(10,("check_mangled_cache: returning -> [%s]\n", s
));
782 DEBUG(10,("check_mangled_cache: returning -> %s\n", ret
?"True":"False"));
786 void mangle_name_83(char *s
)
788 smb_ucs2_t
*u2
, *res
;
790 DEBUG(10,("mangle_name_83: I'm so ugly, please remove me!\n"));
791 DEBUG(10,("mangle_name_83: testing -> [%s]\n", s
));
793 if (!s
|| !*s
) return;
798 DEBUG(0,("mangle_name_83: out of memory!\n"));
803 if (res
) ucs2_to_dos (s
, res
, 13); /* ugly, but must be done this way */
804 DEBUG(10,("mangle_name_83: returning -> [%s]\n", s
));
809 BOOL
name_map_mangle(char *OutName
, BOOL need83
, BOOL cache83
, int snum
)
811 DEBUG(10,("name_map_mangle: I'm so ugly, please remove me!\n"));
813 if (!need83
) return True
;
814 /* if (is_8_3(OutName, True)) return True; */
815 /* Warning: we should check for invalid chars in file name and mangle
816 if invalid chars found --simo*/
818 mangle_name_83(OutName
);
824 #if 0 /* TEST_MANGLE_CODE */
826 #define LONG "this_is_a_long_file_name"
827 #define LONGM "this_~01"
828 #define SHORT "short"
829 #define SHORTM "short~01"
833 #define EXTFAIL "longext"
836 static void unmangle_test (char *name
, char *ext
)
838 smb_ucs2_t ucs2_name
[2048];
842 push_ucs2(NULL
, ucs2_name
, name
, sizeof(ucs2_name
), STR_TERMINATE
);
845 strncat_wa(ucs2_name
, ".", 1);
846 strncat_wa(ucs2_name
, ext
, strlen(ext
) + 1);
848 retstr
= unmangle(ucs2_name
);
849 if(retstr
) pull_ucs2(NULL
, unix_name
, retstr
, sizeof(unix_name
), 0, STR_TERMINATE
);
850 else unix_name
[0] = 0;
851 if (ext
) printf ("[%s.%s] ---> [%s]\n", name
, ext
, unix_name
);
852 else printf ("[%s] ---> [%s]\n", name
, unix_name
);
856 static void mangle_test (char *name
, char *ext
)
858 smb_ucs2_t ucs2_name
[2048];
862 push_ucs2(NULL
, ucs2_name
, name
, sizeof(ucs2_name
), STR_TERMINATE
);
865 strncat_wa(ucs2_name
, ".", 1);
866 strncat_wa(ucs2_name
, ext
, strlen(ext
) + 1);
868 retstr
= mangle(ucs2_name
);
869 if(retstr
) pull_ucs2(NULL
, unix_name
, retstr
, sizeof(unix_name
), 0, STR_TERMINATE
);
870 else unix_name
[0] = 0;
871 if (ext
) printf ("[%s.%s] ---> [%s]\n", name
, ext
, unix_name
);
872 else printf ("[%s] ---> [%s]\n", name
, unix_name
);
876 void mangle_test_code(void)
881 printf("Unmangle test 1:\n");
883 unmangle_test (LONG
, NULL
);
884 unmangle_test (LONG
, EXT1
);
885 unmangle_test (LONG
, EXT2
);
886 unmangle_test (LONG
, EXT3
);
887 unmangle_test (LONG
, EXTFAIL
);
888 unmangle_test (LONG
, EXTNULL
);
890 unmangle_test (LONGM
, NULL
);
891 unmangle_test (LONGM
, EXT1
);
892 unmangle_test (LONGM
, EXT2
);
893 unmangle_test (LONGM
, EXT3
);
894 unmangle_test (LONGM
, EXTFAIL
);
895 unmangle_test (LONGM
, EXTNULL
);
897 unmangle_test (SHORT
, NULL
);
898 unmangle_test (SHORT
, EXT1
);
899 unmangle_test (SHORT
, EXT2
);
900 unmangle_test (SHORT
, EXT3
);
901 unmangle_test (SHORT
, EXTFAIL
);
902 unmangle_test (SHORT
, EXTNULL
);
904 unmangle_test (SHORTM
, NULL
);
905 unmangle_test (SHORTM
, EXT1
);
906 unmangle_test (SHORTM
, EXT2
);
907 unmangle_test (SHORTM
, EXT3
);
908 unmangle_test (SHORTM
, EXTFAIL
);
909 unmangle_test (SHORTM
, EXTNULL
);
912 printf("Mangle test\n");
914 mangle_test (LONG
, NULL
);
915 mangle_test (LONG
, EXT1
);
916 mangle_test (LONG
, EXT2
);
917 mangle_test (LONG
, EXT3
);
918 mangle_test (LONG
, EXTFAIL
);
919 mangle_test (LONG
, EXTNULL
);
921 mangle_test (LONGM
, NULL
);
922 mangle_test (LONGM
, EXT1
);
923 mangle_test (LONGM
, EXT2
);
924 mangle_test (LONGM
, EXT3
);
925 mangle_test (LONGM
, EXTFAIL
);
926 mangle_test (LONGM
, EXTNULL
);
928 mangle_test (SHORT
, NULL
);
929 mangle_test (SHORT
, EXT1
);
930 mangle_test (SHORT
, EXT2
);
931 mangle_test (SHORT
, EXT3
);
932 mangle_test (SHORT
, EXTFAIL
);
933 mangle_test (SHORT
, EXTNULL
);
935 mangle_test (SHORTM
, NULL
);
936 mangle_test (SHORTM
, EXT1
);
937 mangle_test (SHORTM
, EXT2
);
938 mangle_test (SHORTM
, EXT3
);
939 mangle_test (SHORTM
, EXTFAIL
);
940 mangle_test (SHORTM
, EXTNULL
);
942 /* unmangle again every */
943 printf("Unmangle test 2:\n");
945 unmangle_test (LONG
, NULL
);
946 unmangle_test (LONG
, EXT1
);
947 unmangle_test (LONG
, EXT2
);
948 unmangle_test (LONG
, EXT3
);
949 unmangle_test (LONG
, EXTFAIL
);
950 unmangle_test (LONG
, EXTNULL
);
952 unmangle_test (LONGM
, NULL
);
953 unmangle_test (LONGM
, EXT1
);
954 unmangle_test (LONGM
, EXT2
);
955 unmangle_test (LONGM
, EXT3
);
956 unmangle_test (LONGM
, EXTFAIL
);
957 unmangle_test (LONGM
, EXTNULL
);
959 unmangle_test (SHORT
, NULL
);
960 unmangle_test (SHORT
, EXT1
);
961 unmangle_test (SHORT
, EXT2
);
962 unmangle_test (SHORT
, EXT3
);
963 unmangle_test (SHORT
, EXTFAIL
);
964 unmangle_test (SHORT
, EXTNULL
);
966 unmangle_test (SHORTM
, NULL
);
967 unmangle_test (SHORTM
, EXT1
);
968 unmangle_test (SHORTM
, EXT2
);
969 unmangle_test (SHORTM
, EXT3
);
970 unmangle_test (SHORTM
, EXTFAIL
);
971 unmangle_test (SHORTM
, EXTNULL
);
974 #endif /* TEST_MANGLE_CODE */