1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

r6625: Remove another global variable left over from a long time ago (magic char).

Jeremy.
This commit is contained in:
Jeremy Allison 2005-05-06 08:07:39 +00:00 committed by Gerald (Jerry) Carter
parent 94e5347266
commit b1bfa9cb37
9 changed files with 49 additions and 47 deletions

View File

@ -5,10 +5,10 @@
*/
struct mangle_fns {
BOOL (*is_mangled)(const char *s);
BOOL (*is_8_3)(const char *fname, BOOL check_case, BOOL allow_wildcards);
void (*reset)(void);
BOOL (*check_cache)(char *s, size_t maxlen);
void (*name_map)(char *OutName, BOOL need83, BOOL cache83, int default_case);
BOOL (*is_mangled)(const char *s, int snum);
BOOL (*is_8_3)(const char *fname, BOOL check_case, BOOL allow_wildcards, int snum);
BOOL (*check_cache)(char *s, size_t maxlen, int snum);
void (*name_map)(char *OutName, BOOL need83, BOOL cache83, int default_case, int snum);
};
#endif /* _MANGLE_H_ */

View File

@ -784,7 +784,7 @@ BOOL get_dir_entry(connection_struct *conn,char *mask,int dirtype, pstring fname
mask_match_search(filename,mask,False) ||
mangle_mask_match(conn,filename,mask)) {
if (!mangle_is_8_3(filename, False))
if (!mangle_is_8_3(filename, False, SNUM(conn)))
mangle_map(filename,True,False,SNUM(conn));
pstrcpy(fname,filename);

View File

@ -150,7 +150,7 @@ BOOL unix_convert(pstring name,connection_struct *conn,char *saved_last_componen
pstrcpy(saved_last_component, name);
}
if (!conn->case_preserve || (mangle_is_8_3(name, False) && !conn->short_case_preserve))
if (!conn->case_preserve || (mangle_is_8_3(name, False, SNUM(conn)) && !conn->short_case_preserve))
strnorm(name, lp_defaultcase(SNUM(conn)));
start = name;
@ -179,7 +179,7 @@ BOOL unix_convert(pstring name,connection_struct *conn,char *saved_last_componen
* sensitive then searching won't help.
*/
if (conn->case_sensitive && !mangle_is_mangled(name) && !*lp_mangled_map(SNUM(conn)))
if (conn->case_sensitive && !mangle_is_mangled(name, SNUM(conn)) && !*lp_mangled_map(SNUM(conn)))
return(False);
name_has_wildcard = ms_has_wild(start);
@ -189,7 +189,7 @@ BOOL unix_convert(pstring name,connection_struct *conn,char *saved_last_componen
* just a component. JRA.
*/
if (mangle_is_mangled(start))
if (mangle_is_mangled(start, SNUM(conn)))
component_was_mangled = True;
/*
@ -317,7 +317,7 @@ BOOL unix_convert(pstring name,connection_struct *conn,char *saved_last_componen
* base of the filename.
*/
if (mangle_is_mangled(start)) {
if (mangle_is_mangled(start, SNUM(conn))) {
mangle_check_cache( start, sizeof(pstring) - 1 - (start - name) );
}
@ -433,7 +433,7 @@ static BOOL scan_directory(connection_struct *conn, const char *path, char *name
BOOL mangled;
long curpos;
mangled = mangle_is_mangled(name);
mangled = mangle_is_mangled(name, SNUM(conn));
/* handle null paths */
if (*path == 0)

View File

@ -67,29 +67,28 @@ static void mangle_init(void)
void mangle_reset_cache(void)
{
mangle_init();
mangle_fns->reset();
}
/*
see if a filename has come out of our mangling code
*/
BOOL mangle_is_mangled(const char *s)
BOOL mangle_is_mangled(const char *s, int snum)
{
return mangle_fns->is_mangled(s);
return mangle_fns->is_mangled(s, snum);
}
/*
see if a filename matches the rules of a 8.3 filename
*/
BOOL mangle_is_8_3(const char *fname, BOOL check_case)
BOOL mangle_is_8_3(const char *fname, BOOL check_case, int snum)
{
return mangle_fns->is_8_3(fname, check_case, False);
return mangle_fns->is_8_3(fname, check_case, False, snum);
}
BOOL mangle_is_8_3_wildcards(const char *fname, BOOL check_case)
BOOL mangle_is_8_3_wildcards(const char *fname, BOOL check_case, int snum)
{
return mangle_fns->is_8_3(fname, check_case, True);
return mangle_fns->is_8_3(fname, check_case, True, snum);
}
/*
@ -98,9 +97,9 @@ BOOL mangle_is_8_3_wildcards(const char *fname, BOOL check_case)
looking for a matching name if it doesn't. It should succeed most of the time
or there will be a huge performance penalty
*/
BOOL mangle_check_cache(char *s, size_t maxlen)
BOOL mangle_check_cache(char *s, size_t maxlen, int snum)
{
return mangle_fns->check_cache(s, maxlen);
return mangle_fns->check_cache(s, maxlen, snum);
}
/*
@ -120,5 +119,5 @@ void mangle_map(pstring OutName, BOOL need83, BOOL cache83, int snum)
/* invoke the inane "mangled map" code */
mangle_map_filename(OutName, snum);
mangle_fns->name_map(OutName, need83, cache83, lp_defaultcase(snum));
mangle_fns->name_map(OutName, need83, cache83, lp_defaultcase(snum), snum);
}

View File

@ -276,13 +276,15 @@ done:
return ret;
}
static BOOL is_8_3(const char *fname, BOOL check_case, BOOL allow_wildcards)
static BOOL is_8_3(const char *fname, BOOL check_case, BOOL allow_wildcards, int snum)
{
const char *f;
smb_ucs2_t *ucs2name;
NTSTATUS ret = NT_STATUS_UNSUCCESSFUL;
size_t size;
magic_char = lp_magicchar(snum);
if (!fname || !*fname)
return False;
if ((f = strrchr(fname, '/')) == NULL)
@ -362,10 +364,12 @@ static void init_chartest( void )
*
* ************************************************************************** **
*/
static BOOL is_mangled(const char *s)
static BOOL is_mangled(const char *s, int snum)
{
char *magic;
magic_char = lp_magicchar(snum);
if( !ct_initialized )
init_chartest();
@ -460,12 +464,14 @@ static void cache_mangled_name( const char mangled_name[13], char *raw_name )
* ************************************************************************** **
*/
static BOOL check_cache( char *s, size_t maxlen )
static BOOL check_cache( char *s, size_t maxlen, int snum )
{
TDB_DATA data_val;
char *ext_start = NULL;
char *saved_ext = NULL;
magic_char = lp_magicchar(snum);
/* If the cache isn't initialized, give up. */
if( !tdb_mangled_cache )
return( False );
@ -604,9 +610,11 @@ static void to_8_3(char *s, int default_case)
* ****************************************************************************
*/
static void name_map(char *OutName, BOOL need83, BOOL cache83, int default_case)
static void name_map(char *OutName, BOOL need83, BOOL cache83, int default_case, int snum)
{
smb_ucs2_t *OutName_ucs2;
magic_char = lp_magicchar(snum);
DEBUG(5,("name_map( %s, need83 = %s, cache83 = %s)\n", OutName,
need83 ? "True" : "False", cache83 ? "True" : "False"));
@ -643,9 +651,9 @@ static void name_map(char *OutName, BOOL need83, BOOL cache83, int default_case)
to drop in an alternative mangling implementation
*/
static struct mangle_fns mangle_fns = {
mangle_reset,
is_mangled,
is_8_3,
mangle_reset,
check_cache,
name_map
};

View File

@ -268,7 +268,7 @@ static BOOL is_mangled_component(const char *name, size_t len)
directory separators. It should return true if any component is
mangled
*/
static BOOL is_mangled(const char *name)
static BOOL is_mangled(const char *name, int snum)
{
const char *p;
const char *s;
@ -293,7 +293,7 @@ static BOOL is_mangled(const char *name)
simplifies things greatly (it means that we know the string won't
get larger when converted from UNIX to DOS formats)
*/
static BOOL is_8_3(const char *name, BOOL check_case, BOOL allow_wildcards)
static BOOL is_8_3(const char *name, BOOL check_case, BOOL allow_wildcards, int snum)
{
int len, i;
char *dot_p;
@ -370,7 +370,7 @@ static void mangle_reset(void)
try to find a 8.3 name in the cache, and if found then
replace the string with the original long name.
*/
static BOOL check_cache(char *name, size_t maxlen)
static BOOL check_cache(char *name, size_t maxlen, int snum)
{
u32 hash, multiplier;
unsigned int i;
@ -378,7 +378,7 @@ static BOOL check_cache(char *name, size_t maxlen)
char extension[4];
/* make sure that this is a mangled name from this cache */
if (!is_mangled(name)) {
if (!is_mangled(name, snum)) {
M_DEBUG(10,("check_cache: %s -> not mangled\n", name));
return False;
}
@ -506,7 +506,7 @@ static BOOL is_legal_name(const char *name)
the name parameter must be able to hold 13 bytes
*/
static void name_map(fstring name, BOOL need83, BOOL cache83, int default_case)
static void name_map(fstring name, BOOL need83, BOOL cache83, int default_case, int snum)
{
char *dot_p;
char lead_chars[7];
@ -520,7 +520,7 @@ static void name_map(fstring name, BOOL need83, BOOL cache83, int default_case)
if (!is_reserved_name(name)) {
/* if the name is already a valid 8.3 name then we don't need to
do anything */
if (is_8_3(name, False, False)) {
if (is_8_3(name, False, False, snum)) {
return;
}
@ -679,14 +679,13 @@ static void init_tables(void)
}
}
/*
the following provides the abstraction layer to make it easier
to drop in an alternative mangling implementation */
static struct mangle_fns mangle_fns = {
mangle_reset,
is_mangled,
is_8_3,
mangle_reset,
check_cache,
name_map
};

View File

@ -30,7 +30,6 @@
extern enum protocol_types Protocol;
extern int max_send;
extern int max_recv;
extern char magic_char;
extern int global_oplock_break;
unsigned int smb_echo_count = 0;
extern uint32 global_client_caps;
@ -1753,7 +1752,7 @@ NTSTATUS unlink_internals(connection_struct *conn, int dirtype, char *name)
* Tine Smukavec <valentin.smukavec@hermes.si>.
*/
if (!rc && mangle_is_mangled(mask))
if (!rc && mangle_is_mangled(mask,SNUM(conn)))
mangle_check_cache( mask, sizeof(pstring)-1 );
if (!has_wild) {
@ -4055,7 +4054,7 @@ NTSTATUS rename_internals(connection_struct *conn, char *name, char *newname, ui
* Tine Smukavec <valentin.smukavec@hermes.si>.
*/
if (!rc && mangle_is_mangled(mask))
if (!rc && mangle_is_mangled(mask,SNUM(conn)))
mangle_check_cache( mask, sizeof(pstring)-1 );
has_wild = ms_has_wild(mask);
@ -4064,7 +4063,7 @@ NTSTATUS rename_internals(connection_struct *conn, char *name, char *newname, ui
/*
* No wildcards - just process the one file.
*/
BOOL is_short_name = mangle_is_8_3(name, True);
BOOL is_short_name = mangle_is_8_3(name, True, SNUM(conn));
/* Add a terminating '/' to the directory name. */
pstrcat(directory,"/");
@ -4536,7 +4535,7 @@ int reply_copy(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
* Tine Smukavec <valentin.smukavec@hermes.si>.
*/
if (!rc && mangle_is_mangled(mask))
if (!rc && mangle_is_mangled(mask, SNUM(conn)))
mangle_check_cache( mask, sizeof(pstring)-1 );
has_wild = ms_has_wild(mask);

View File

@ -20,11 +20,9 @@
#include "includes.h"
extern char magic_char;
extern struct timeval smb_last_time;
extern userdom_struct current_user_info;
/****************************************************************************
Load parameters specific to a connection/service.
****************************************************************************/
@ -80,7 +78,6 @@ BOOL set_current_service(connection_struct *conn, uint16 flags, BOOL do_chdir)
conn->case_sensitive = False;
break;
}
magic_char = lp_magicchar(snum);
return(True);
}

View File

@ -1064,7 +1064,7 @@ static BOOL get_lanman2_dir_entry(connection_struct *conn,
if(!(got_match = *got_exact_match = exact_match(fname, mask, conn->case_sensitive)))
got_match = mask_match(fname, mask, conn->case_sensitive);
if(!got_match && check_mangled_names && !mangle_is_8_3(fname, False)) {
if(!got_match && check_mangled_names && !mangle_is_8_3(fname, False, SNUM(conn))) {
/*
* It turns out that NT matches wildcards against
@ -1286,7 +1286,7 @@ static BOOL get_lanman2_dir_entry(connection_struct *conn,
case SMB_FIND_FILE_BOTH_DIRECTORY_INFO:
DEBUG(10,("get_lanman2_dir_entry: SMB_FIND_FILE_BOTH_DIRECTORY_INFO\n"));
was_8_3 = mangle_is_8_3(fname, True);
was_8_3 = mangle_is_8_3(fname, True, SNUM(conn));
p += 4;
SIVAL(p,0,reskey); p += 4;
put_long_date(p,cdate); p += 8;
@ -1422,7 +1422,7 @@ static BOOL get_lanman2_dir_entry(connection_struct *conn,
case SMB_FIND_ID_BOTH_DIRECTORY_INFO:
DEBUG(10,("get_lanman2_dir_entry: SMB_FIND_ID_BOTH_DIRECTORY_INFO\n"));
was_8_3 = mangle_is_8_3(fname, True);
was_8_3 = mangle_is_8_3(fname, True, SNUM(conn));
p += 4;
SIVAL(p,0,reskey); p += 4;
put_long_date(p,cdate); p += 8;
@ -1813,7 +1813,7 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
* (see PR#13758). JRA.
*/
if(!mangle_is_8_3_wildcards( mask, False))
if(!mangle_is_8_3_wildcards( mask, False, SNUM(conn)))
mangle_map(mask, True, True, SNUM(conn));
return(-1);
@ -2007,7 +2007,7 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
* could be mangled. Ensure we check the unmangled name.
*/
if (mangle_is_mangled(resume_name)) {
if (mangle_is_mangled(resume_name, SNUM(conn))) {
mangle_check_cache(resume_name, sizeof(resume_name)-1);
}
@ -3044,7 +3044,7 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
DEBUG(10,("call_trans2qfilepathinfo: SMB_FILE_ALTERNATE_NAME_INFORMATION\n"));
pstrcpy(short_name,base_name);
/* Mangle if not already 8.3 */
if(!mangle_is_8_3(short_name, True)) {
if(!mangle_is_8_3(short_name, True, SNUM(conn))) {
mangle_map(short_name,True,True,SNUM(conn));
}
len = srvstr_push(outbuf, pdata+4, short_name, -1, STR_UNICODE);