summaryrefslogtreecommitdiff
path: root/source3/smbd/mangle.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2007-09-07 20:57:01 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:30:32 -0500
commit132ee3990af5d31573978f5a3abf43db2303880b (patch)
tree2ce69566fb9a4ecb0f8ce19261c60e4ad3d8593a /source3/smbd/mangle.c
parentc5d8fd3772706a469484df8a16abf10547d1c7a4 (diff)
downloadsamba-132ee3990af5d31573978f5a3abf43db2303880b.tar.gz
samba-132ee3990af5d31573978f5a3abf43db2303880b.tar.bz2
samba-132ee3990af5d31573978f5a3abf43db2303880b.zip
r25009: Large patch discussed with Volker. Move unix_convert to a talloc-based
interface. More development will come on top of this. Remove the "mangled map" parameter. Jeremy. (This used to be commit dee8beba7a92b8a3f68bbcc59fd0a827f68c7736)
Diffstat (limited to 'source3/smbd/mangle.c')
-rw-r--r--source3/smbd/mangle.c65
1 files changed, 33 insertions, 32 deletions
diff --git a/source3/smbd/mangle.c b/source3/smbd/mangle.c
index fce86903f2..61490c444e 100644
--- a/source3/smbd/mangle.c
+++ b/source3/smbd/mangle.c
@@ -1,18 +1,18 @@
-/*
+/*
Unix SMB/CIFS implementation.
Name mangling interface
Copyright (C) Andrew Tridgell 2002
-
+
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 3 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, see <http://www.gnu.org/licenses/>.
*/
@@ -100,50 +100,51 @@ BOOL mangle_is_8_3_wildcards(const char *fname, BOOL check_case,
return mangle_fns->is_8_3(fname, check_case, True, p);
}
+BOOL mangle_must_mangle(const char *fname,
+ const struct share_params *p)
+{
+ if (!lp_manglednames(p)) {
+ return False;
+ }
+ return mangle_fns->must_mangle(fname, p);
+}
+
/*
- try to reverse map a 8.3 name to the original filename. This doesn't have to
+ try to reverse map a 8.3 name to the original filename. This doesn't have to
always succeed, as the directory handling code in smbd will scan the directory
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_lookup_name_from_8_3(TALLOC_CTX *ctx,
+ const char *in,
+ char **out, /* talloced on the given context. */
const struct share_params *p)
{
- return mangle_fns->check_cache(s, maxlen, p);
-}
-
-BOOL mangle_check_cache_alloc(const char *name, char **presult,
- const struct share_params *p)
-{
- pstring tmp;
- char *result;
- pstrcpy(tmp, name);
-
- if (!mangle_check_cache(tmp, sizeof(pstring)-1, p)
- || !(result = SMB_STRDUP(tmp))) {
- return False;
- }
- *presult = result;
- return True;
+ return mangle_fns->lookup_name_from_8_3(ctx, in, out, p);
}
-/*
- map a long filename to a 8.3 name.
+/*
+ mangle a long filename to a 8.3 name.
+ Return True if we did mangle the name (ie. out is filled in).
+ False on error.
+ JRA.
*/
-void mangle_map(pstring OutName, BOOL need83, BOOL cache83,
+BOOL name_to_8_3(const char *in,
+ char out[13],
+ BOOL cache83,
const struct share_params *p)
{
/* name mangling can be disabled for speed, in which case
we just truncate the string */
if (!lp_manglednames(p)) {
- if (need83) {
- string_truncate(OutName, 12);
- }
- return;
+ safe_strcpy(out,in,12);
+ return True;
}
- /* invoke the inane "mangled map" code */
- mangle_map_filename(OutName, p);
- mangle_fns->name_map(OutName, need83, cache83, lp_defaultcase(p->service), p);
+ return mangle_fns->name_to_8_3(in,
+ out,
+ cache83,
+ lp_defaultcase(p->service),
+ p);
}