1996-05-04 11:50:46 +04:00
/*
2002-01-30 09:08:46 +03:00
Unix SMB / CIFS implementation .
2001-11-04 21:26:53 +03:00
Name mangling with persistent tdb
Copyright ( C ) Simo Sorce 2001
1996-05-04 11:50:46 +04:00
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation ; either version 2 of the License , or
( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program ; if not , write to the Free Software
Foundation , Inc . , 675 Mass Ave , Cambridge , MA 0213 9 , USA .
*/
2001-11-04 21:26:53 +03:00
/****************************************************************************
Rewritten from scrach in 2001 by Simo Sorce < idra @ samba . org >
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
Changes include:
proto.h: The unusual. ;)
reply.c: I changes some function names, and updated reply.c to match.
See mangle.c below for more.
server.c: Changed function names and parameters in file mangle.c, so
changed server.c calls to match. See mangle.c below for more.
mangle.c:
I replaced the caching mechanism used for caching reverse mangled name
maps. The old method was a large array of 256-byte strings. Movement
in the stack (including push and pop) was done by memcpy()ing whole
chunks of memory around.
The new system uses the ubi_Cache module which, in turn, uses a splay
tree. Entries are dynamically allocated using a minimum amount of
memory. Searches are non-linear, which should speed things up a bit,
too. Overall, this should save memory and be faster.
Other changes: I streamlined the is_mangled() test and made other
speed enhancements including replacing some static functions with
macros. Added comments, etc.
Note: Per an E'mail conversation with Andrew, the 'mangled stack'
parameter in smb.conf doesn't do anything anymore. The cache is
now set for 16K bytes maximum memory usage. The mangle stack
parameter is silently ignored. This can easily be changed, but
I'd rather introduce a 'mangled cache memory' parameter and
remove 'mangled stack'.
Remaining problems:
While testing the module, I noticed that something is calling
name_map_mangle() twice. The result is that names which contain
illegal characters are getting mangled twice.
Also, the entire module works by overwriting the input string.
This has a variety of nasty side effects.
Summary:
There's a lot still to be done, but the changes I have in place *should*
work in exactly the same way (except for the mangle stack parameter).
The rest of the bugs and other issues are separate.
Chris -)-----
(This used to be commit 8759bec11ba483b2292b0e513b85c98ed5e3e2d4)
1998-04-14 02:45:52 +04:00
1996-05-04 11:50:46 +04:00
# include "includes.h"
Changes include:
proto.h: The unusual. ;)
reply.c: I changes some function names, and updated reply.c to match.
See mangle.c below for more.
server.c: Changed function names and parameters in file mangle.c, so
changed server.c calls to match. See mangle.c below for more.
mangle.c:
I replaced the caching mechanism used for caching reverse mangled name
maps. The old method was a large array of 256-byte strings. Movement
in the stack (including push and pop) was done by memcpy()ing whole
chunks of memory around.
The new system uses the ubi_Cache module which, in turn, uses a splay
tree. Entries are dynamically allocated using a minimum amount of
memory. Searches are non-linear, which should speed things up a bit,
too. Overall, this should save memory and be faster.
Other changes: I streamlined the is_mangled() test and made other
speed enhancements including replacing some static functions with
macros. Added comments, etc.
Note: Per an E'mail conversation with Andrew, the 'mangled stack'
parameter in smb.conf doesn't do anything anymore. The cache is
now set for 16K bytes maximum memory usage. The mangle stack
parameter is silently ignored. This can easily be changed, but
I'd rather introduce a 'mangled cache memory' parameter and
remove 'mangled stack'.
Remaining problems:
While testing the module, I noticed that something is calling
name_map_mangle() twice. The result is that names which contain
illegal characters are getting mangled twice.
Also, the entire module works by overwriting the input string.
This has a variety of nasty side effects.
Summary:
There's a lot still to be done, but the changes I have in place *should*
work in exactly the same way (except for the mangle stack parameter).
The rest of the bugs and other issues are separate.
Chris -)-----
(This used to be commit 8759bec11ba483b2292b0e513b85c98ed5e3e2d4)
1998-04-14 02:45:52 +04:00
/* -------------------------------------------------------------------------- **
* External Variables . . .
*/
extern int case_default ; /* Are conforming 8.3 names all upper or lower? */
extern BOOL case_mangle ; /* If true, all chars in 8.3 should be same case. */
char magic_char = ' ~ ' ;
2001-10-08 15:58:25 +04:00
/* -------------------------------------------------------------------- */
2001-10-13 16:47:59 +04:00
2001-09-29 20:16:38 +04:00
# define MANGLE_TDB_VERSION "20010927"
2001-09-25 13:57:06 +04:00
# define MANGLE_TDB_FILE_NAME "mangle.tdb"
# define MANGLED_PREFIX "MANGLED_"
# define LONG_PREFIX "LONG_"
2001-09-29 20:16:38 +04:00
# define COUNTER_PREFIX "COUNTER_"
# define MANGLE_COUNTER_MAX 99
2001-11-04 21:26:53 +03:00
# define MANGLE_SUFFIX_SIZE 3 /* "~XX" */
2001-09-29 20:16:38 +04:00
2001-09-25 13:57:06 +04:00
2001-10-04 12:32:29 +04:00
static TDB_CONTEXT * mangle_tdb ;
2001-09-25 13:57:06 +04:00
2001-10-04 12:32:29 +04:00
BOOL init_mangle_tdb ( void )
2001-09-25 13:57:06 +04:00
{
2001-09-27 16:41:38 +04:00
char * tdbfile ;
2001-09-25 13:57:06 +04:00
2001-10-04 12:32:29 +04:00
tdbfile = lock_path ( MANGLE_TDB_FILE_NAME ) ; /* this return a static pstring do not try to free it */
2001-09-25 13:57:06 +04:00
2001-10-04 12:32:29 +04:00
/* Open tdb */
if ( ! ( mangle_tdb = tdb_open_log ( tdbfile , 0 , TDB_DEFAULT , O_RDWR | O_CREAT , 0600 ) ) )
{
DEBUG ( 0 , ( " Unable to open Mangle TDB \n " ) ) ;
return False ;
2001-09-25 13:57:06 +04:00
}
return True ;
}
2001-10-07 18:53:40 +04:00
/* trasform a unicode string into a dos charset string */
static int ucs2_to_dos ( char * dest , const smb_ucs2_t * src , int dest_len )
2001-09-25 13:57:06 +04:00
{
2001-10-07 18:53:40 +04:00
int src_len , ret ;
2001-09-25 13:57:06 +04:00
if ( dest_len = = - 1 ) {
dest_len = sizeof ( pstring ) ;
}
2001-10-28 22:19:57 +03:00
src_len = strlen_w ( src ) * sizeof ( smb_ucs2_t ) ;
2001-09-25 13:57:06 +04:00
ret = convert_string ( CH_UCS2 , CH_DOS , src , src_len , dest , dest_len ) ;
if ( dest_len ) dest [ MIN ( ret , dest_len - 1 ) ] = 0 ;
2001-10-07 18:53:40 +04:00
return ret ;
}
2002-01-24 16:31:34 +03:00
/* trasform in a string that contain only valid chars for win filenames,
not including a ' . ' */
2001-11-04 21:26:53 +03:00
static void strvalid ( smb_ucs2_t * src )
2001-10-07 18:53:40 +04:00
{
2001-11-04 21:26:53 +03:00
if ( ! src | | ! * src ) return ;
2001-10-07 18:53:40 +04:00
2001-11-04 21:26:53 +03:00
while ( * src ) {
2002-01-24 16:31:34 +03:00
if ( ! isvalid83_w ( * src ) | | * src = = UCS2_CHAR ( ' . ' ) ) * src = UCS2_CHAR ( ' _ ' ) ;
2001-11-04 21:26:53 +03:00
src + + ;
2001-10-07 18:53:40 +04:00
}
2001-09-25 13:57:06 +04:00
}
2001-10-07 18:53:40 +04:00
2001-09-27 16:41:38 +04:00
/* return False if something fail and
* return 2 alloced unicode strings that contain prefix and extension
*/
2001-11-04 21:26:53 +03:00
static NTSTATUS mangle_get_prefix ( const smb_ucs2_t * ucs2_string , smb_ucs2_t * * prefix , smb_ucs2_t * * extension )
2001-09-25 13:57:06 +04:00
{
2001-11-04 21:26:53 +03:00
size_t ext_len ;
2001-09-27 16:41:38 +04:00
smb_ucs2_t * p ;
2001-09-25 13:57:06 +04:00
2001-09-27 16:41:38 +04:00
* extension = 0 ;
* prefix = strdup_w ( ucs2_string ) ;
if ( ! * prefix )
2001-09-25 13:57:06 +04:00
{
2001-09-27 16:41:38 +04:00
DEBUG ( 0 , ( " mangle_get_prefix: out of memory! \n " ) ) ;
2001-11-04 21:26:53 +03:00
return NT_STATUS_NO_MEMORY ;
2001-09-25 13:57:06 +04:00
}
2001-11-04 21:26:53 +03:00
if ( ( p = strrchr_w ( * prefix , UCS2_CHAR ( ' . ' ) ) ) )
2001-09-25 13:57:06 +04:00
{
2002-01-24 16:31:34 +03:00
ext_len = strlen_w ( p + 1 ) ;
if ( ( ext_len > 0 ) & & ( ext_len < 4 ) & & ( p ! = * prefix ) & &
( NT_STATUS_IS_OK ( has_valid_chars ( p + 1 ) ) ) ) /* check extension */
2001-09-27 16:41:38 +04:00
{
2002-01-24 16:31:34 +03:00
* p = 0 ;
* extension = strdup_w ( p + 1 ) ;
2001-09-27 16:41:38 +04:00
if ( ! * extension )
{
DEBUG ( 0 , ( " mangle_get_prefix: out of memory! \n " ) ) ;
SAFE_FREE ( * prefix ) ;
2001-11-04 21:26:53 +03:00
return NT_STATUS_NO_MEMORY ;
2001-09-27 16:41:38 +04:00
}
}
2001-09-25 13:57:06 +04:00
}
2001-11-04 21:26:53 +03:00
return NT_STATUS_OK ;
2001-09-25 13:57:06 +04:00
}
2001-09-27 16:41:38 +04:00
2001-09-25 13:57:06 +04:00
/* mangled must contain only the file name, not a path.
and MUST be ZERO terminated */
smb_ucs2_t * unmangle ( const smb_ucs2_t * mangled )
{
TDB_DATA data , key ;
fstring keystr ;
fstring mufname ;
2001-09-27 16:41:38 +04:00
smb_ucs2_t * pref , * ext , * retstr ;
2001-10-07 18:53:40 +04:00
size_t long_len , ext_len , muf_len ;
2001-09-25 13:57:06 +04:00
if ( strlen_w ( mangled ) > 12 ) return NULL ;
2001-11-04 21:26:53 +03:00
if ( ! strchr_w ( mangled , UCS2_CHAR ( ' ~ ' ) ) ) return NULL ;
/* if it is a path refuse to proceed */
if ( strchr_w ( mangled , UCS2_CHAR ( ' / ' ) ) ) {
DEBUG ( 10 , ( " unmangle: cannot unmangle a path \n " ) ) ;
return NULL ;
}
if ( NT_STATUS_IS_ERR ( mangle_get_prefix ( mangled , & pref , & ext ) ) )
return NULL ;
/* mangled names are stored lowercase only */
2001-09-27 16:41:38 +04:00
strlower_w ( pref ) ;
2001-09-25 13:57:06 +04:00
/* set search key */
2001-10-07 18:53:40 +04:00
muf_len = ucs2_to_dos ( mufname , pref , sizeof ( mufname ) ) ;
2001-09-27 16:41:38 +04:00
SAFE_FREE ( pref ) ;
2001-10-07 18:53:40 +04:00
if ( ! muf_len ) return NULL ;
2001-09-27 16:41:38 +04:00
slprintf ( keystr , sizeof ( keystr ) - 1 , " %s%s " , MANGLED_PREFIX , mufname ) ;
2001-09-25 13:57:06 +04:00
key . dptr = keystr ;
key . dsize = strlen ( keystr ) + 1 ;
/* get the record */
2001-10-04 12:32:29 +04:00
data = tdb_fetch ( mangle_tdb , key ) ;
2001-09-25 13:57:06 +04:00
if ( ! data . dptr ) /* not found */
{
2001-10-04 12:32:29 +04:00
DEBUG ( 5 , ( " unmangle: failed retrieve from db %s \n " , tdb_errorstr ( mangle_tdb ) ) ) ;
2001-09-27 16:41:38 +04:00
retstr = NULL ;
goto done ;
2001-09-25 13:57:06 +04:00
}
2001-09-27 16:41:38 +04:00
if ( ext )
{
2001-10-07 18:53:40 +04:00
long_len = ( data . dsize / 2 ) - 1 ;
2001-09-27 16:41:38 +04:00
ext_len = strlen_w ( ext ) ;
2001-10-07 18:53:40 +04:00
retstr = ( smb_ucs2_t * ) malloc ( ( long_len + ext_len + 2 ) * sizeof ( smb_ucs2_t ) ) ;
2001-09-27 16:41:38 +04:00
if ( ! retstr )
{
DEBUG ( 0 , ( " unamngle: out of memory! \n " ) ) ;
goto done ;
}
strncpy_w ( retstr , ( smb_ucs2_t * ) data . dptr , long_len ) ;
retstr [ long_len ] = UCS2_CHAR ( ' . ' ) ;
retstr [ long_len + 1 ] = 0 ;
strncat_w ( retstr , ext , ext_len ) ;
}
else
2001-09-25 13:57:06 +04:00
{
2001-09-27 16:41:38 +04:00
retstr = strdup_w ( ( smb_ucs2_t * ) data . dptr ) ;
if ( ! retstr )
{
DEBUG ( 0 , ( " unamngle: out of memory! \n " ) ) ;
goto done ;
}
2001-09-25 13:57:06 +04:00
}
2001-09-27 16:41:38 +04:00
done :
2001-09-25 13:57:06 +04:00
SAFE_FREE ( data . dptr ) ;
2001-09-27 16:41:38 +04:00
SAFE_FREE ( pref ) ;
SAFE_FREE ( ext ) ;
2001-09-25 13:57:06 +04:00
return retstr ;
}
/* unmangled must contain only the file name, not a path.
2001-11-04 21:26:53 +03:00
and MUST be ZERO terminated .
return a new allocated string if the name is yet valid 8.3
or is mangled successfully .
return null on error .
*/
2001-10-29 14:37:42 +03:00
smb_ucs2_t * mangle ( const smb_ucs2_t * unmangled )
2001-09-25 13:57:06 +04:00
{
2001-09-29 20:16:38 +04:00
TDB_DATA data , key , klock ;
2001-09-25 13:57:06 +04:00
pstring keystr ;
pstring longname ;
2001-09-29 20:16:38 +04:00
fstring keylock ;
2001-09-25 13:57:06 +04:00
fstring mufname ;
2001-09-29 20:16:38 +04:00
fstring prefix ;
BOOL tclock = False ;
2001-10-04 12:32:29 +04:00
char suffix [ 7 ] ;
2001-09-27 16:41:38 +04:00
smb_ucs2_t * mangled = NULL ;
2001-11-04 21:26:53 +03:00
smb_ucs2_t * umpref , * ext , * p = NULL ;
2001-10-07 18:53:40 +04:00
size_t pref_len , ext_len , ud83_len ;
2001-09-29 20:16:38 +04:00
2001-11-04 21:26:53 +03:00
/* if it is a path refuse to proceed */
if ( strchr_w ( unmangled , UCS2_CHAR ( ' / ' ) ) ) {
DEBUG ( 10 , ( " mangle: cannot mangle a path \n " ) ) ;
return NULL ;
}
/* if it is a valid 8_3 do not mangle again */
if ( NT_STATUS_IS_OK ( is_8_3_w ( unmangled ) ) )
2001-11-10 18:21:54 +03:00
return NULL ;
2001-11-04 21:26:53 +03:00
if ( NT_STATUS_IS_ERR ( mangle_get_prefix ( unmangled , & umpref , & ext ) ) )
return NULL ;
2001-09-25 13:57:06 +04:00
/* test if the same is yet mangled */
/* set search key */
2001-11-04 21:26:53 +03:00
pull_ucs2 ( NULL , longname , umpref , sizeof ( longname ) , 0 , STR_TERMINATE ) ;
2001-09-25 13:57:06 +04:00
slprintf ( keystr , sizeof ( keystr ) - 1 , " %s%s " , LONG_PREFIX , longname ) ;
key . dptr = keystr ;
2001-09-29 20:16:38 +04:00
key . dsize = strlen ( keystr ) + 1 ;
2001-09-25 13:57:06 +04:00
/* get the record */
2001-10-04 12:32:29 +04:00
data = tdb_fetch ( mangle_tdb , key ) ;
2001-09-25 13:57:06 +04:00
if ( ! data . dptr ) /* not found */
{
2001-11-04 21:26:53 +03:00
smb_ucs2_t temp [ 9 ] ;
2001-11-05 03:42:33 +03:00
size_t c , pos ;
2001-11-04 21:26:53 +03:00
2001-10-04 12:32:29 +04:00
if ( tdb_error ( mangle_tdb ) ! = TDB_ERR_NOEXIST )
2001-09-25 13:57:06 +04:00
{
DEBUG ( 0 , ( " mangle: database retrieval error: %s \n " ,
2001-10-04 12:32:29 +04:00
tdb_errorstr ( mangle_tdb ) ) ) ;
2001-09-27 16:41:38 +04:00
goto done ;
2001-09-25 13:57:06 +04:00
}
2001-09-29 20:16:38 +04:00
2001-09-25 13:57:06 +04:00
/* if not find the first free possibile mangled name */
2001-09-29 20:16:38 +04:00
2001-11-04 21:26:53 +03:00
pos = strlen_w ( umpref ) ;
if ( ( 8 - MANGLE_SUFFIX_SIZE ) < pos )
pos = 8 - MANGLE_SUFFIX_SIZE ;
pos + + ;
2001-09-29 20:16:38 +04:00
do
2001-09-25 13:57:06 +04:00
{
2001-11-04 21:26:53 +03:00
pos - - ;
2001-09-27 16:41:38 +04:00
if ( pos = = 0 )
{
DEBUG ( 0 , ( " mangle: unable to mangle file name! \n " ) ) ;
goto done ;
}
2001-11-04 21:26:53 +03:00
strncpy_w ( temp , umpref , pos ) ;
2001-10-04 12:32:29 +04:00
temp [ pos ] = 0 ;
2001-09-27 16:41:38 +04:00
strlower_w ( temp ) ;
2001-09-25 13:57:06 +04:00
2001-11-04 21:26:53 +03:00
/* convert any invalid char into '_' */
strvalid ( temp ) ;
ud83_len = ucs2_to_dos ( prefix , temp , sizeof ( prefix ) ) ;
2001-10-07 18:53:40 +04:00
if ( ! ud83_len ) goto done ;
2001-09-29 20:16:38 +04:00
}
2001-11-04 21:26:53 +03:00
while ( ud83_len > 8 - MANGLE_SUFFIX_SIZE ) ;
2001-09-29 20:16:38 +04:00
slprintf ( keylock , sizeof ( keylock ) - 1 , " %s%s " , COUNTER_PREFIX , prefix ) ;
klock . dptr = keylock ;
klock . dsize = strlen ( keylock ) + 1 ;
c = 0 ;
data . dptr = ( char * ) & c ;
data . dsize = sizeof ( uint32 ) ;
/* try to insert a new counter prefix, if it exist the call will
fail ( correct ) otherwise it will create a new entry with counter set
to 0
*/
2001-10-04 12:32:29 +04:00
if ( tdb_store ( mangle_tdb , klock , data , TDB_INSERT ) ! = TDB_SUCCESS )
{
if ( tdb_error ( mangle_tdb ) ! = TDB_ERR_EXISTS )
{
DEBUG ( 0 , ( " mangle: database store error: %s \n " ,
tdb_errorstr ( mangle_tdb ) ) ) ;
goto done ;
}
}
2001-09-29 20:16:38 +04:00
/* lock the mangle counter for this prefix */
2001-10-04 12:32:29 +04:00
if ( tdb_chainlock ( mangle_tdb , klock ) )
2001-09-29 20:16:38 +04:00
{
DEBUG ( 0 , ( " mangle: failed to lock database \n ! " ) ) ;
goto done ;
}
tclock = True ;
2001-10-04 12:32:29 +04:00
data = tdb_fetch ( mangle_tdb , klock ) ;
2001-09-29 20:16:38 +04:00
if ( ! data . dptr )
{
DEBUG ( 0 , ( " mangle: database retrieval error: %s \n " ,
2001-10-04 12:32:29 +04:00
tdb_errorstr ( mangle_tdb ) ) ) ;
2001-09-29 20:16:38 +04:00
goto done ;
}
c = * ( ( uint32 * ) data . dptr ) ;
c + + ;
2001-10-04 12:32:29 +04:00
if ( c > MANGLE_COUNTER_MAX )
{
DEBUG ( 0 , ( " mangle: error, counter overflow! \n " ) ) ;
goto done ;
}
2001-09-29 20:16:38 +04:00
temp [ pos ] = UCS2_CHAR ( ' ~ ' ) ;
temp [ pos + 1 ] = 0 ;
2001-10-04 12:32:29 +04:00
snprintf ( suffix , 7 , " %.6d " , c ) ;
2001-11-04 21:26:53 +03:00
strncat_wa ( temp , & suffix [ 7 - MANGLE_SUFFIX_SIZE ] , MANGLE_SUFFIX_SIZE ) ;
2001-09-29 20:16:38 +04:00
2001-10-07 18:53:40 +04:00
ud83_len = ucs2_to_dos ( mufname , temp , sizeof ( mufname ) ) ;
if ( ! ud83_len ) goto done ;
if ( ud83_len > 8 )
2001-09-29 20:16:38 +04:00
{
DEBUG ( 0 , ( " mangle: darn, logic error aborting! \n " ) ) ;
goto done ;
}
2001-09-27 16:41:38 +04:00
2001-09-29 20:16:38 +04:00
/* store the long entry with mangled key */
slprintf ( keystr , sizeof ( keystr ) - 1 , " %s%s " , MANGLED_PREFIX , mufname ) ;
key . dptr = keystr ;
key . dsize = strlen ( keystr ) + 1 ;
2001-11-04 21:26:53 +03:00
data . dsize = ( strlen_w ( umpref ) + 1 ) * sizeof ( smb_ucs2_t ) ;
data . dptr = ( void * ) umpref ;
2001-09-29 20:16:38 +04:00
2001-10-04 12:32:29 +04:00
if ( tdb_store ( mangle_tdb , key , data , TDB_INSERT ) ! = TDB_SUCCESS )
2001-09-29 20:16:38 +04:00
{
DEBUG ( 0 , ( " mangle: database store error: %s \n " ,
2001-10-04 12:32:29 +04:00
tdb_errorstr ( mangle_tdb ) ) ) ;
2001-09-29 20:16:38 +04:00
goto done ;
}
/* store the mangled entry with long key*/
2001-11-04 21:26:53 +03:00
pull_ucs2 ( NULL , longname , umpref , sizeof ( longname ) , 0 , STR_TERMINATE ) ;
2001-09-29 20:16:38 +04:00
slprintf ( keystr , sizeof ( keystr ) - 1 , " %s%s " , LONG_PREFIX , longname ) ;
key . dptr = keystr ;
key . dsize = strlen ( keystr ) + 1 ;
2001-10-07 18:53:40 +04:00
data . dsize = strlen ( mufname ) + 1 ;
2001-09-29 20:16:38 +04:00
data . dptr = mufname ;
2001-10-04 12:32:29 +04:00
if ( tdb_store ( mangle_tdb , key , data , TDB_INSERT ) ! = TDB_SUCCESS )
2001-09-29 20:16:38 +04:00
{
2001-10-04 12:32:29 +04:00
DEBUG ( 0 , ( " mangle: database store failed: %s \n " ,
tdb_errorstr ( mangle_tdb ) ) ) ;
2001-09-29 20:16:38 +04:00
/* try to delete the mangled key entry to avoid later inconsistency */
2001-09-25 13:57:06 +04:00
slprintf ( keystr , sizeof ( keystr ) - 1 , " %s%s " , MANGLED_PREFIX , mufname ) ;
key . dptr = keystr ;
key . dsize = strlen ( keystr ) + 1 ;
2001-10-04 12:32:29 +04:00
if ( ! tdb_delete ( mangle_tdb , key ) )
2001-09-29 20:16:38 +04:00
{
DEBUG ( 0 , ( " mangle: severe error, mangled tdb may be inconsistent! \n " ) ) ;
}
goto done ;
}
2001-09-25 13:57:06 +04:00
2001-09-29 20:16:38 +04:00
p = strdup_w ( temp ) ;
if ( ! p )
{
DEBUG ( 0 , ( " mangle: out of memory! \n " ) ) ;
goto done ;
}
data . dptr = ( char * ) & c ;
data . dsize = sizeof ( uint32 ) ;
2001-10-04 12:32:29 +04:00
/* store the counter */
if ( tdb_store ( mangle_tdb , klock , data , TDB_REPLACE ) ! = TDB_SUCCESS )
2001-09-29 20:16:38 +04:00
{
2001-10-04 12:32:29 +04:00
DEBUG ( 0 , ( " mangle: database store failed: %s \n " ,
tdb_errorstr ( mangle_tdb ) ) ) ;
2001-09-29 20:16:38 +04:00
/* try to delete the mangled and long key entry to avoid later inconsistency */
slprintf ( keystr , sizeof ( keystr ) - 1 , " %s%s " , MANGLED_PREFIX , mufname ) ;
key . dptr = keystr ;
key . dsize = strlen ( keystr ) + 1 ;
2001-10-04 12:32:29 +04:00
if ( ! tdb_delete ( mangle_tdb , key ) )
2001-09-25 13:57:06 +04:00
{
2001-09-29 20:16:38 +04:00
DEBUG ( 0 , ( " mangle: severe error, mangled tdb may be inconsistent! \n " ) ) ;
2001-09-25 13:57:06 +04:00
}
2001-09-29 20:16:38 +04:00
slprintf ( keystr , sizeof ( keystr ) - 1 , " %s%s " , LONG_PREFIX , longname ) ;
key . dptr = keystr ;
key . dsize = strlen ( keystr ) + 1 ;
2001-10-04 12:32:29 +04:00
if ( ! tdb_delete ( mangle_tdb , key ) )
2001-09-25 13:57:06 +04:00
{
2001-09-29 20:16:38 +04:00
DEBUG ( 0 , ( " mangle: severe error, mangled tdb may be inconsistent! \n " ) ) ;
2001-09-25 13:57:06 +04:00
}
2001-09-29 20:16:38 +04:00
goto done ;
2001-09-25 13:57:06 +04:00
}
2001-09-29 20:16:38 +04:00
tclock = False ;
2001-10-04 12:32:29 +04:00
tdb_chainunlock ( mangle_tdb , klock ) ;
2001-09-25 13:57:06 +04:00
}
else /* FOUND */
{
2001-11-12 03:53:34 +03:00
p = acnv_dosu2 ( data . dptr ) ;
2001-09-27 16:41:38 +04:00
if ( ! p )
2001-09-25 13:57:06 +04:00
{
2002-02-04 03:59:23 +03:00
DEBUG ( 0 , ( " mangle: internal error acnv_dosu2() failed! \n " ) ) ;
2001-09-27 16:41:38 +04:00
goto done ;
2001-09-25 13:57:06 +04:00
}
}
2001-09-27 16:41:38 +04:00
if ( ext )
{
2001-10-07 18:53:40 +04:00
pref_len = strlen_w ( p ) ;
2001-09-27 16:41:38 +04:00
ext_len = strlen_w ( ext ) ;
2001-10-07 18:53:40 +04:00
mangled = ( smb_ucs2_t * ) malloc ( ( pref_len + ext_len + 2 ) * sizeof ( smb_ucs2_t ) ) ;
2001-09-27 16:41:38 +04:00
if ( ! mangled )
{
DEBUG ( 0 , ( " mangle: out of memory! \n " ) ) ;
goto done ;
}
strncpy_w ( mangled , p , pref_len ) ;
mangled [ pref_len ] = UCS2_CHAR ( ' . ' ) ;
mangled [ pref_len + 1 ] = 0 ;
strncat_w ( mangled , ext , ext_len ) ;
}
else
{
mangled = strdup_w ( p ) ;
if ( ! mangled )
{
DEBUG ( 0 , ( " mangle: out of memory! \n " ) ) ;
goto done ;
}
}
2001-09-25 13:57:06 +04:00
2001-11-04 21:26:53 +03:00
/* mangled name are returned in upper or lower case depending on
case_default value */
strnorm_w ( mangled ) ;
2001-09-27 16:41:38 +04:00
done :
2001-10-04 12:32:29 +04:00
if ( tclock ) tdb_chainunlock ( mangle_tdb , klock ) ;
2001-09-25 13:57:06 +04:00
SAFE_FREE ( p ) ;
2001-11-04 21:26:53 +03:00
SAFE_FREE ( umpref ) ;
2001-09-27 16:41:38 +04:00
SAFE_FREE ( ext ) ;
2001-09-25 13:57:06 +04:00
return mangled ;
}
2001-10-13 16:47:59 +04:00
2001-10-29 14:37:42 +03:00
/* non unicode compatibility functions */
2001-11-04 21:26:53 +03:00
char * dos_mangle ( const char * dos_unmangled )
2001-10-29 14:37:42 +03:00
{
smb_ucs2_t * in , * out ;
char * dos_mangled ;
if ( ! dos_unmangled | | ! * dos_unmangled ) return NULL ;
2001-11-12 03:53:34 +03:00
in = acnv_dosu2 ( dos_unmangled ) ;
2001-10-29 14:37:42 +03:00
if ( ! in )
{
2002-02-04 03:59:23 +03:00
DEBUG ( 0 , ( " dos_mangle: internal error acnv_dosu2() failed! \n " ) ) ;
2001-10-29 14:37:42 +03:00
return NULL ;
}
out = mangle ( in ) ;
if ( ! out )
{
SAFE_FREE ( in ) ;
return NULL ;
}
2001-11-12 03:53:34 +03:00
dos_mangled = acnv_u2dos ( out ) ;
2001-10-29 14:37:42 +03:00
if ( ! dos_mangled )
{
2002-02-04 03:59:23 +03:00
DEBUG ( 0 , ( " dos_mangle: internal error acnv_u2dos() failed! \n " ) ) ;
2001-10-29 14:37:42 +03:00
goto done ;
}
done :
SAFE_FREE ( in ) ;
SAFE_FREE ( out ) ;
return dos_mangled ;
}
2001-11-04 21:26:53 +03:00
char * dos_unmangle ( const char * dos_mangled )
2001-10-29 14:37:42 +03:00
{
smb_ucs2_t * in , * out ;
char * dos_unmangled ;
if ( ! dos_mangled | | ! * dos_mangled ) return NULL ;
2001-11-12 03:53:34 +03:00
in = acnv_dosu2 ( dos_mangled ) ;
2001-10-29 14:37:42 +03:00
if ( ! in )
{
2002-02-04 03:59:23 +03:00
DEBUG ( 0 , ( " dos_unmangle: internal error acnv_dosu2() failed! \n " ) ) ;
2001-10-29 14:37:42 +03:00
return NULL ;
}
2002-02-19 09:13:16 +03:00
out = unmangle ( in ) ;
2001-10-29 14:37:42 +03:00
if ( ! out )
{
SAFE_FREE ( in ) ;
return NULL ;
}
2001-11-12 03:53:34 +03:00
dos_unmangled = acnv_u2dos ( out ) ;
2001-10-29 14:37:42 +03:00
if ( ! dos_unmangled )
{
2002-02-04 03:59:23 +03:00
DEBUG ( 0 , ( " dos_unmangle: internal error acnv_u2dos failed! \n " ) ) ;
2001-10-29 14:37:42 +03:00
goto done ;
}
done :
SAFE_FREE ( in ) ;
SAFE_FREE ( out ) ;
return dos_unmangled ;
}
2001-10-13 16:47:59 +04:00
2001-11-04 21:26:53 +03:00
BOOL is_8_3 ( const char * fname , BOOL check_case )
{
2002-01-25 13:38:00 +03:00
const char * f ;
2001-11-04 21:26:53 +03:00
smb_ucs2_t * ucs2name ;
NTSTATUS ret = NT_STATUS_UNSUCCESSFUL ;
2001-10-13 16:47:59 +04:00
2001-11-04 21:26:53 +03:00
if ( ! fname | | ! * fname ) return False ;
2002-01-25 03:35:14 +03:00
if ( ( f = strrchr ( fname , ' / ' ) ) = = NULL ) f = fname ;
2002-01-25 12:55:29 +03:00
else f + + ;
2001-11-04 21:26:53 +03:00
2002-01-25 03:35:14 +03:00
DEBUG ( 10 , ( " is_8_3: testing [%s] \n " , f ) ) ;
2001-11-04 21:26:53 +03:00
2002-01-25 03:35:14 +03:00
if ( strlen ( f ) > 12 ) return False ;
2001-11-04 21:26:53 +03:00
2002-01-25 03:35:14 +03:00
ucs2name = acnv_uxu2 ( f ) ;
2001-11-04 21:26:53 +03:00
if ( ! ucs2name )
{
2002-02-04 03:59:23 +03:00
DEBUG ( 0 , ( " is_8_3: internal error acnv_uxu2() failed! \n " ) ) ;
2001-11-04 21:26:53 +03:00
goto done ;
}
ret = is_8_3_w ( ucs2name ) ;
done :
SAFE_FREE ( ucs2name ) ;
DEBUG ( 10 , ( " is_8_3: returning -> %s \n " , NT_STATUS_IS_OK ( ret ) ? " True " : " False " ) ) ;
if ( NT_STATUS_IS_ERR ( ret ) ) return False ;
else return True ;
}
2001-10-13 16:47:59 +04:00
2001-11-04 21:26:53 +03:00
NTSTATUS is_8_3_w ( const smb_ucs2_t * fname )
{
2001-11-05 03:42:33 +03:00
smb_ucs2_t * pref = 0 , * ext = 0 ;
2001-11-04 21:26:53 +03:00
size_t plen ;
NTSTATUS ret = NT_STATUS_UNSUCCESSFUL ;
if ( ! fname | | ! * fname ) return NT_STATUS_INVALID_PARAMETER ;
DEBUG ( 10 , ( " is_8_3_w: testing \n " ) ) ; /* [%s]\n", fname)); */
if ( strlen_w ( fname ) > 12 ) return NT_STATUS_UNSUCCESSFUL ;
if ( strcmp_wa ( fname , " . " ) = = 0 | | strcmp_wa ( fname , " .. " ) = = 0 )
return NT_STATUS_OK ;
if ( NT_STATUS_IS_ERR ( is_valid_name ( fname ) ) ) goto done ;
if ( NT_STATUS_IS_ERR ( mangle_get_prefix ( fname , & pref , & ext ) ) ) goto done ;
plen = strlen_w ( pref ) ;
2002-01-24 16:31:34 +03:00
if ( strchr_wa ( pref , ' . ' ) ) goto done ;
2001-11-04 21:26:53 +03:00
if ( plen < 1 | | plen > 8 ) goto done ;
if ( ext ) if ( strlen_w ( ext ) > 3 ) goto done ;
ret = NT_STATUS_OK ;
done :
SAFE_FREE ( pref ) ;
SAFE_FREE ( ext ) ;
return ret ;
}
NTSTATUS has_valid_chars ( const smb_ucs2_t * s )
{
NTSTATUS ret = NT_STATUS_OK ;
if ( ! s | | ! * s ) return NT_STATUS_INVALID_PARAMETER ;
DEBUG ( 10 , ( " has_valid_chars: testing \n " ) ) ; /* [%s]\n", s)); */
/* CHECK: this should not be necessary if the ms wild chars
are not valid in valid . dat - - - simo */
if ( ms_has_wild_w ( s ) ) return NT_STATUS_UNSUCCESSFUL ;
while ( * s ) {
if ( ! isvalid83_w ( * s ) ) return NT_STATUS_UNSUCCESSFUL ;
s + + ;
}
return ret ;
}
NTSTATUS is_valid_name ( const smb_ucs2_t * fname )
{
smb_ucs2_t * str , * p ;
NTSTATUS ret = NT_STATUS_OK ;
if ( ! fname | | ! * fname ) return NT_STATUS_INVALID_PARAMETER ;
2001-11-12 03:53:34 +03:00
DEBUG ( 10 , ( " is_valid_name: testing \n " ) ) ; /* [%s]\n", s)); */
2002-01-24 16:31:34 +03:00
if ( * fname = = UCS2_CHAR ( ' . ' ) ) return NT_STATUS_UNSUCCESSFUL ;
2001-11-04 21:26:53 +03:00
ret = has_valid_chars ( fname ) ;
if ( NT_STATUS_IS_ERR ( ret ) ) return ret ;
str = strdup_w ( fname ) ;
p = strchr_w ( str , UCS2_CHAR ( ' . ' ) ) ;
if ( p ) * p = 0 ;
strupper_w ( str ) ;
p = & ( str [ 1 ] ) ;
switch ( str [ 0 ] )
{
case UCS2_CHAR ( ' A ' ) :
if ( strcmp_wa ( p , " UX " ) = = 0 )
ret = NT_STATUS_UNSUCCESSFUL ;
break ;
case UCS2_CHAR ( ' C ' ) :
if ( ( strcmp_wa ( p , " LOCK$ " ) = = 0 )
| | ( strcmp_wa ( p , " ON " ) = = 0 )
| | ( strcmp_wa ( p , " OM1 " ) = = 0 )
| | ( strcmp_wa ( p , " OM2 " ) = = 0 )
| | ( strcmp_wa ( p , " OM3 " ) = = 0 )
| | ( strcmp_wa ( p , " OM4 " ) = = 0 )
)
ret = NT_STATUS_UNSUCCESSFUL ;
break ;
case UCS2_CHAR ( ' L ' ) :
if ( ( strcmp_wa ( p , " PT1 " ) = = 0 )
| | ( strcmp_wa ( p , " PT2 " ) = = 0 )
| | ( strcmp_wa ( p , " PT3 " ) = = 0 )
)
ret = NT_STATUS_UNSUCCESSFUL ;
break ;
case UCS2_CHAR ( ' N ' ) :
if ( strcmp_wa ( p , " UL " ) = = 0 )
ret = NT_STATUS_UNSUCCESSFUL ;
break ;
case UCS2_CHAR ( ' P ' ) :
if ( strcmp_wa ( p , " RN " ) = = 0 )
ret = NT_STATUS_UNSUCCESSFUL ;
break ;
default :
break ;
}
SAFE_FREE ( str ) ;
return ret ;
}
BOOL is_mangled ( const char * s )
2001-10-13 16:47:59 +04:00
{
smb_ucs2_t * u2 , * res ;
BOOL ret = False ;
2001-11-04 21:26:53 +03:00
DEBUG ( 10 , ( " is_mangled: testing [%s] \n " , s ) ) ;
2001-10-22 10:53:28 +04:00
if ( ! s | | ! * s ) return False ;
2001-11-04 21:26:53 +03:00
if ( ( strlen ( s ) > 12 ) | | ( ! strchr ( s , ' ~ ' ) ) ) return False ;
2001-10-22 10:53:28 +04:00
2001-11-12 03:53:34 +03:00
u2 = acnv_dosu2 ( s ) ;
2001-10-13 16:47:59 +04:00
if ( ! u2 )
{
2002-02-04 03:59:23 +03:00
DEBUG ( 0 , ( " is_mangled: internal error acnv_dosu2() failed!! \n " ) ) ;
2001-10-13 16:47:59 +04:00
return ret ;
}
2001-10-22 10:53:28 +04:00
2001-10-13 16:47:59 +04:00
res = unmangle ( u2 ) ;
if ( res ) ret = True ;
SAFE_FREE ( res ) ;
SAFE_FREE ( u2 ) ;
2001-11-04 21:26:53 +03:00
DEBUG ( 10 , ( " is_mangled: returning [%s] \n " , ret ? " True " : " False " ) ) ;
2001-10-13 16:47:59 +04:00
return ret ;
}
2001-11-04 21:26:53 +03:00
NTSTATUS is_mangled_w ( const smb_ucs2_t * s )
2001-10-13 16:47:59 +04:00
{
2001-11-04 21:26:53 +03:00
smb_ucs2_t * res ;
NTSTATUS ret = NT_STATUS_UNSUCCESSFUL ;
2001-10-22 10:53:28 +04:00
2001-11-04 21:26:53 +03:00
res = unmangle ( s ) ;
if ( res ) ret = NT_STATUS_OK ;
SAFE_FREE ( res ) ;
return ret ;
}
2001-10-22 10:53:28 +04:00
2001-11-04 21:26:53 +03:00
NTSTATUS path_has_mangled ( const smb_ucs2_t * s )
{
smb_ucs2_t * p , * f , * b ;
NTSTATUS ret = NT_STATUS_UNSUCCESSFUL ;
if ( ! s | | ! * s ) return NT_STATUS_INVALID_PARAMETER ;
p = strdup_w ( s ) ;
if ( ! p ) return NT_STATUS_NO_MEMORY ;
trim_string_wa ( p , " / " , " / " ) ;
f = b = p ;
while ( b ) {
b = strchr_w ( f , UCS2_CHAR ( ' / ' ) ) ;
if ( b ) * b = 0 ;
if ( NT_STATUS_IS_OK ( is_mangled_w ( f ) ) ) {
ret = NT_STATUS_OK ;
goto done ;
}
f = b + 1 ;
2001-10-13 16:47:59 +04:00
}
done :
2001-11-04 21:26:53 +03:00
SAFE_FREE ( p ) ;
return ret ;
2001-10-13 16:47:59 +04:00
}
2001-11-04 21:26:53 +03:00
/* backward compatibility functions */
2001-10-13 16:47:59 +04:00
void reset_mangled_cache ( void )
{
DEBUG ( 10 , ( " reset_mangled_cache: compatibility function, remove me! \n " ) ) ;
}
BOOL check_mangled_cache ( char * s )
{
smb_ucs2_t * u2 , * res ;
BOOL ret = False ;
2001-10-23 03:25:11 +04:00
2001-10-13 16:47:59 +04:00
DEBUG ( 10 , ( " check_mangled_cache: I'm so ugly, please remove me! \n " ) ) ;
2001-10-22 10:53:28 +04:00
DEBUG ( 10 , ( " check_mangled_cache: testing -> [%s] \n " , s ) ) ;
if ( ! s | | ! * s ) return False ;
2001-10-13 16:47:59 +04:00
2001-11-12 03:53:34 +03:00
u2 = acnv_dosu2 ( s ) ;
2001-10-13 16:47:59 +04:00
if ( ! u2 )
{
DEBUG ( 0 , ( " check_mangled_cache: out of memory! \n " ) ) ;
return ret ;
}
2001-10-23 03:25:11 +04:00
2001-10-13 16:47:59 +04:00
res = unmangle ( u2 ) ;
if ( res )
{
2001-10-28 22:19:57 +03:00
2001-10-29 14:37:42 +03:00
ucs2_to_dos ( s , res , PSTRING_LEN ) ;
2001-10-28 22:19:57 +03:00
/* We MUST change this brainded interface,
we do not know how many chars will be used
in dos so i guess they will be no more than
double the size of the unicode string
- - - simo */
2001-10-22 10:53:28 +04:00
DEBUG ( 10 , ( " check_mangled_cache: returning -> [%s] \n " , s ) ) ;
2001-10-13 16:47:59 +04:00
ret = True ;
}
SAFE_FREE ( res ) ;
SAFE_FREE ( u2 ) ;
2001-10-22 10:53:28 +04:00
DEBUG ( 10 , ( " check_mangled_cache: returning -> %s \n " , ret ? " True " : " False " ) ) ;
2001-10-13 16:47:59 +04:00
return ret ;
}
void mangle_name_83 ( char * s )
{
smb_ucs2_t * u2 , * res ;
2001-10-23 03:25:11 +04:00
2001-10-13 16:47:59 +04:00
DEBUG ( 10 , ( " mangle_name_83: I'm so ugly, please remove me! \n " ) ) ;
2001-10-22 10:53:28 +04:00
DEBUG ( 10 , ( " mangle_name_83: testing -> [%s] \n " , s ) ) ;
2001-10-13 16:47:59 +04:00
2001-10-22 10:53:28 +04:00
if ( ! s | | ! * s ) return ;
2001-11-12 03:53:34 +03:00
u2 = acnv_dosu2 ( s ) ;
2001-10-13 16:47:59 +04:00
if ( ! u2 )
{
2002-02-04 03:59:23 +03:00
DEBUG ( 0 , ( " mangle_name_83: internal error acnv_dosu2() failed! \n " ) ) ;
2001-10-13 16:47:59 +04:00
return ;
}
2001-10-23 03:25:11 +04:00
2001-10-29 14:37:42 +03:00
res = mangle ( u2 ) ;
2001-10-22 10:53:28 +04:00
if ( res ) ucs2_to_dos ( s , res , 13 ) ; /* ugly, but must be done this way */
2001-10-28 22:19:57 +03:00
DEBUG ( 10 , ( " mangle_name_83: returning -> [%s] \n " , s ) ) ;
2001-10-13 16:47:59 +04:00
SAFE_FREE ( res ) ;
SAFE_FREE ( u2 ) ;
}
BOOL name_map_mangle ( char * OutName , BOOL need83 , BOOL cache83 , int snum )
{
DEBUG ( 10 , ( " name_map_mangle: I'm so ugly, please remove me! \n " ) ) ;
2001-10-23 03:25:11 +04:00
if ( ! need83 ) return True ;
/* if (is_8_3(OutName, True)) return True; */
2001-10-22 10:53:28 +04:00
/* Warning: we should check for invalid chars in file name and mangle
if invalid chars found - - simo */
2001-10-23 03:25:11 +04:00
2001-10-13 16:47:59 +04:00
mangle_name_83 ( OutName ) ;
return True ;
}
2001-11-04 21:26:53 +03:00
2001-09-29 20:16:38 +04:00
2001-10-13 16:47:59 +04:00
#if 0 /* TEST_MANGLE_CODE */
2001-09-29 20:16:38 +04:00
# define LONG "this_is_a_long_file_name"
# define LONGM "this_~01"
# define SHORT "short"
# define SHORTM "short~01"
# define EXT1 "ex1"
# define EXT2 "e2"
# define EXT3 "3"
# define EXTFAIL "longext"
2001-10-07 18:53:40 +04:00
# define EXTNULL ""
2001-09-29 20:16:38 +04:00
static void unmangle_test ( char * name , char * ext )
{
smb_ucs2_t ucs2_name [ 2048 ] ;
smb_ucs2_t * retstr ;
pstring unix_name ;
push_ucs2 ( NULL , ucs2_name , name , sizeof ( ucs2_name ) , STR_TERMINATE ) ;
if ( ext )
{
strncat_wa ( ucs2_name , " . " , 1 ) ;
2001-10-04 12:32:29 +04:00
strncat_wa ( ucs2_name , ext , strlen ( ext ) + 1 ) ;
2001-09-29 20:16:38 +04:00
}
retstr = unmangle ( ucs2_name ) ;
if ( retstr ) pull_ucs2 ( NULL , unix_name , retstr , sizeof ( unix_name ) , 0 , STR_TERMINATE ) ;
else unix_name [ 0 ] = 0 ;
if ( ext ) printf ( " [%s.%s] ---> [%s] \n " , name , ext , unix_name ) ;
else printf ( " [%s] ---> [%s] \n " , name , unix_name ) ;
SAFE_FREE ( retstr ) ;
}
static void mangle_test ( char * name , char * ext )
{
smb_ucs2_t ucs2_name [ 2048 ] ;
smb_ucs2_t * retstr ;
pstring unix_name ;
push_ucs2 ( NULL , ucs2_name , name , sizeof ( ucs2_name ) , STR_TERMINATE ) ;
if ( ext )
{
strncat_wa ( ucs2_name , " . " , 1 ) ;
2001-10-04 12:32:29 +04:00
strncat_wa ( ucs2_name , ext , strlen ( ext ) + 1 ) ;
2001-09-29 20:16:38 +04:00
}
2001-10-29 14:37:42 +03:00
retstr = mangle ( ucs2_name ) ;
2001-09-29 20:16:38 +04:00
if ( retstr ) pull_ucs2 ( NULL , unix_name , retstr , sizeof ( unix_name ) , 0 , STR_TERMINATE ) ;
else unix_name [ 0 ] = 0 ;
if ( ext ) printf ( " [%s.%s] ---> [%s] \n " , name , ext , unix_name ) ;
else printf ( " [%s] ---> [%s] \n " , name , unix_name ) ;
SAFE_FREE ( retstr ) ;
}
void mangle_test_code ( void )
{
2001-10-04 12:32:29 +04:00
init_mangle_tdb ( ) ;
2001-09-29 20:16:38 +04:00
/* unmangle every */
2001-10-07 18:53:40 +04:00
printf ( " Unmangle test 1: \n " ) ;
2001-10-23 03:25:11 +04:00
2001-09-29 20:16:38 +04:00
unmangle_test ( LONG , NULL ) ;
unmangle_test ( LONG , EXT1 ) ;
unmangle_test ( LONG , EXT2 ) ;
unmangle_test ( LONG , EXT3 ) ;
unmangle_test ( LONG , EXTFAIL ) ;
2001-10-07 18:53:40 +04:00
unmangle_test ( LONG , EXTNULL ) ;
2001-09-29 20:16:38 +04:00
unmangle_test ( LONGM , NULL ) ;
unmangle_test ( LONGM , EXT1 ) ;
unmangle_test ( LONGM , EXT2 ) ;
unmangle_test ( LONGM , EXT3 ) ;
unmangle_test ( LONGM , EXTFAIL ) ;
2001-10-07 18:53:40 +04:00
unmangle_test ( LONGM , EXTNULL ) ;
2001-09-29 20:16:38 +04:00
unmangle_test ( SHORT , NULL ) ;
unmangle_test ( SHORT , EXT1 ) ;
unmangle_test ( SHORT , EXT2 ) ;
unmangle_test ( SHORT , EXT3 ) ;
unmangle_test ( SHORT , EXTFAIL ) ;
2001-10-07 18:53:40 +04:00
unmangle_test ( SHORT , EXTNULL ) ;
2001-09-29 20:16:38 +04:00
unmangle_test ( SHORTM , NULL ) ;
unmangle_test ( SHORTM , EXT1 ) ;
unmangle_test ( SHORTM , EXT2 ) ;
unmangle_test ( SHORTM , EXT3 ) ;
unmangle_test ( SHORTM , EXTFAIL ) ;
2001-10-07 18:53:40 +04:00
unmangle_test ( SHORTM , EXTNULL ) ;
2001-09-29 20:16:38 +04:00
/* mangle every */
2001-10-07 18:53:40 +04:00
printf ( " Mangle test \n " ) ;
2001-10-23 03:25:11 +04:00
2001-09-29 20:16:38 +04:00
mangle_test ( LONG , NULL ) ;
mangle_test ( LONG , EXT1 ) ;
mangle_test ( LONG , EXT2 ) ;
mangle_test ( LONG , EXT3 ) ;
mangle_test ( LONG , EXTFAIL ) ;
2001-10-07 18:53:40 +04:00
mangle_test ( LONG , EXTNULL ) ;
2001-09-29 20:16:38 +04:00
mangle_test ( LONGM , NULL ) ;
mangle_test ( LONGM , EXT1 ) ;
mangle_test ( LONGM , EXT2 ) ;
mangle_test ( LONGM , EXT3 ) ;
mangle_test ( LONGM , EXTFAIL ) ;
2001-10-07 18:53:40 +04:00
mangle_test ( LONGM , EXTNULL ) ;
2001-09-29 20:16:38 +04:00
mangle_test ( SHORT , NULL ) ;
mangle_test ( SHORT , EXT1 ) ;
mangle_test ( SHORT , EXT2 ) ;
mangle_test ( SHORT , EXT3 ) ;
mangle_test ( SHORT , EXTFAIL ) ;
2001-10-07 18:53:40 +04:00
mangle_test ( SHORT , EXTNULL ) ;
2001-09-29 20:16:38 +04:00
mangle_test ( SHORTM , NULL ) ;
mangle_test ( SHORTM , EXT1 ) ;
mangle_test ( SHORTM , EXT2 ) ;
mangle_test ( SHORTM , EXT3 ) ;
mangle_test ( SHORTM , EXTFAIL ) ;
2001-10-07 18:53:40 +04:00
mangle_test ( SHORTM , EXTNULL ) ;
2001-09-29 20:16:38 +04:00
/* unmangle again every */
2001-10-07 18:53:40 +04:00
printf ( " Unmangle test 2: \n " ) ;
2001-10-23 03:25:11 +04:00
2001-09-29 20:16:38 +04:00
unmangle_test ( LONG , NULL ) ;
unmangle_test ( LONG , EXT1 ) ;
unmangle_test ( LONG , EXT2 ) ;
unmangle_test ( LONG , EXT3 ) ;
unmangle_test ( LONG , EXTFAIL ) ;
2001-10-07 18:53:40 +04:00
unmangle_test ( LONG , EXTNULL ) ;
2001-09-29 20:16:38 +04:00
unmangle_test ( LONGM , NULL ) ;
unmangle_test ( LONGM , EXT1 ) ;
unmangle_test ( LONGM , EXT2 ) ;
unmangle_test ( LONGM , EXT3 ) ;
unmangle_test ( LONGM , EXTFAIL ) ;
2001-10-07 18:53:40 +04:00
unmangle_test ( LONGM , EXTNULL ) ;
2001-09-29 20:16:38 +04:00
unmangle_test ( SHORT , NULL ) ;
unmangle_test ( SHORT , EXT1 ) ;
unmangle_test ( SHORT , EXT2 ) ;
unmangle_test ( SHORT , EXT3 ) ;
unmangle_test ( SHORT , EXTFAIL ) ;
2001-10-07 18:53:40 +04:00
unmangle_test ( SHORT , EXTNULL ) ;
2001-09-29 20:16:38 +04:00
unmangle_test ( SHORTM , NULL ) ;
unmangle_test ( SHORTM , EXT1 ) ;
unmangle_test ( SHORTM , EXT2 ) ;
unmangle_test ( SHORTM , EXT3 ) ;
unmangle_test ( SHORTM , EXTFAIL ) ;
2001-10-07 18:53:40 +04:00
unmangle_test ( SHORTM , EXTNULL ) ;
2001-09-29 20:16:38 +04:00
}
# endif /* TEST_MANGLE_CODE */