00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "includes.h"
00022
00023 static struct mangle_fns *mangle_fns;
00024
00025
00026 static const struct {
00027 const char *name;
00028 struct mangle_fns *(*init_fn)(void);
00029 } mangle_backends[] = {
00030 { "hash", mangle_hash_init },
00031 { "hash2", mangle_hash2_init },
00032 { "posix", posix_mangle_init },
00033
00034 { NULL, NULL }
00035 };
00036
00037
00038
00039
00040 static void mangle_init(void)
00041 {
00042 int i;
00043 const char *method;
00044
00045 if (mangle_fns)
00046 return;
00047
00048 method = lp_mangling_method();
00049
00050
00051
00052 for (i=0; mangle_backends[i].name && !mangle_fns; i++) {
00053 if (!method || !*method || strcmp(method, mangle_backends[i].name) == 0) {
00054 mangle_fns = mangle_backends[i].init_fn();
00055 }
00056 }
00057
00058 if (!mangle_fns) {
00059 DEBUG(0,("Failed to initialise mangling system '%s'\n", method));
00060 exit_server("mangling init failed");
00061 }
00062 }
00063
00064
00065
00066
00067
00068 void mangle_reset_cache(void)
00069 {
00070 mangle_init();
00071 mangle_fns->reset();
00072 }
00073
00074 void mangle_change_to_posix(void)
00075 {
00076 mangle_fns = NULL;
00077 lp_set_mangling_method("posix");
00078 mangle_reset_cache();
00079 }
00080
00081
00082
00083
00084 BOOL mangle_is_mangled(const char *s, const struct share_params *p)
00085 {
00086 return mangle_fns->is_mangled(s, p);
00087 }
00088
00089
00090
00091
00092 BOOL mangle_is_8_3(const char *fname, BOOL check_case,
00093 const struct share_params *p)
00094 {
00095 return mangle_fns->is_8_3(fname, check_case, False, p);
00096 }
00097
00098 BOOL mangle_is_8_3_wildcards(const char *fname, BOOL check_case,
00099 const struct share_params *p)
00100 {
00101 return mangle_fns->is_8_3(fname, check_case, True, p);
00102 }
00103
00104
00105
00106
00107
00108
00109
00110 BOOL mangle_check_cache(char *s, size_t maxlen,
00111 const struct share_params *p)
00112 {
00113 return mangle_fns->check_cache(s, maxlen, p);
00114 }
00115
00116
00117
00118
00119
00120 void mangle_map(pstring OutName, BOOL need83, BOOL cache83,
00121 const struct share_params *p)
00122 {
00123
00124
00125 if (!lp_manglednames(p)) {
00126 if (need83) {
00127 string_truncate(OutName, 12);
00128 }
00129 return;
00130 }
00131
00132
00133 mangle_map_filename(OutName, p);
00134 mangle_fns->name_map(OutName, need83, cache83, lp_defaultcase(p->service), p);
00135 }