not contain a '.', otherwise it points at the last dot in 'n'.
*/
static int ms_fnmatch_core(const char *p, const char *n,
- struct max_n *max_n, const char *ldot)
+ struct max_n *max_n, const char *ldot,
+ bool is_case_sensitive)
{
codepoint_t c, c2;
int i;
}
for (i=0; n[i]; i += size_n) {
next_codepoint(n+i, &size_n);
- if (ms_fnmatch_core(p, n+i, max_n+1, ldot) == 0) {
+ if (ms_fnmatch_core(p, n+i, max_n+1, ldot, is_case_sensitive) == 0) {
return 0;
}
}
}
for (i=0; n[i]; i += size_n) {
next_codepoint(n+i, &size_n);
- if (ms_fnmatch_core(p, n+i, max_n+1, ldot) == 0) return 0;
+ if (ms_fnmatch_core(p, n+i, max_n+1, ldot, is_case_sensitive) == 0) return 0;
if (n+i == ldot) {
- if (ms_fnmatch_core(p, n+i+size_n, max_n+1, ldot) == 0) return 0;
+ if (ms_fnmatch_core(p, n+i+size_n, max_n+1, ldot, is_case_sensitive) == 0) return 0;
if (!max_n->postdot || max_n->postdot > n) max_n->postdot = n;
return -1;
}
default:
c2 = next_codepoint(n, &size_n);
- if (c != c2 && codepoint_cmpi(c, c2) != 0) {
- return -1;
+ if (c != c2) {
+ if (is_case_sensitive) {
+ return -1;
+ }
+ if (codepoint_cmpi(c, c2) != 0) {
+ return -1;
+ }
}
n += size_n;
break;
return -1;
}
-int ms_fnmatch_protocol(const char *pattern, const char *string, int protocol)
+int ms_fnmatch_protocol(const char *pattern, const char *string, int protocol,
+ bool is_case_sensitive)
{
int ret, count, i;
struct max_n *max_n = NULL;
p[i] = '<';
}
}
- ret = ms_fnmatch_protocol(p, string, PROTOCOL_NT1);
+ ret = ms_fnmatch_protocol(p, string, PROTOCOL_NT1,
+ is_case_sensitive);
talloc_free(p);
return ret;
}
return -1;
}
- ret = ms_fnmatch_core(pattern, string, max_n, strrchr(string, '.'));
+ ret = ms_fnmatch_core(pattern, string, max_n, strrchr(string, '.'),
+ is_case_sensitive);
talloc_free(max_n);
/** a generic fnmatch function - uses for non-CIFS pattern matching */
int gen_fnmatch(const char *pattern, const char *string)
{
- return ms_fnmatch_protocol(pattern, string, PROTOCOL_NT1);
+ return ms_fnmatch_protocol(pattern, string, PROTOCOL_NT1, false);
}
* @brief MS-style Filename matching
*/
-int ms_fnmatch_protocol(const char *pattern, const char *string, int protocol);
+int ms_fnmatch_protocol(const char *pattern, const char *string, int protocol,
+ bool is_case_sensitive);
/** a generic fnmatch function - uses for non-CIFS pattern matching */
int gen_fnmatch(const char *pattern, const char *string);
return false;
if (is_case_sensitive)
- return ms_fnmatch_protocol(pattern, string,
- c->transport->negotiate.protocol) == 0;
+ return ms_fnmatch_protocol(
+ pattern, string, c->transport->negotiate.protocol,
+ true) == 0;
p2 = strlower_talloc(NULL, pattern);
s2 = strlower_talloc(NULL, string);
- ret = ms_fnmatch_protocol(p2, s2, c->transport->negotiate.protocol) == 0;
+ ret = ms_fnmatch_protocol(p2, s2, c->transport->negotiate.protocol,
+ true) == 0;
talloc_free(p2);
talloc_free(s2);
if (!low_name) { continue; }
/* check it matches the wildcard pattern */
- if (ms_fnmatch_protocol(low_mask, low_name, PROTOCOL_NT1) != 0) {
+ if (ms_fnmatch_protocol(low_mask, low_name, PROTOCOL_NT1,
+ true) != 0) {
continue;
}
if (*ofs == DIR_OFFSET_DOT) {
(*ofs) = DIR_OFFSET_DOTDOT;
dir->offset = *ofs;
- if (ms_fnmatch_protocol(dir->pattern, ".", protocol) == 0) {
+ if (ms_fnmatch_protocol(dir->pattern, ".", protocol,
+ true) == 0) {
dcache_add(dir, ".");
return ".";
}
if (*ofs == DIR_OFFSET_DOTDOT) {
(*ofs) = DIR_OFFSET_BASE;
dir->offset = *ofs;
- if (ms_fnmatch_protocol(dir->pattern, "..", protocol) == 0) {
+ if (ms_fnmatch_protocol(dir->pattern, "..", protocol,
+ true) == 0) {
dcache_add(dir, "..");
return "..";
}
continue;
}
- if (ms_fnmatch_protocol(dir->pattern, dname, protocol) != 0) {
+ if (ms_fnmatch_protocol(dir->pattern, dname, protocol,
+ true) != 0) {
char *short_name = pvfs_short_name_component(dir->pvfs, dname);
if (short_name == NULL ||
- ms_fnmatch_protocol(dir->pattern, short_name, protocol) != 0) {
+ ms_fnmatch_protocol(dir->pattern, short_name,
+ protocol, true) != 0) {
talloc_free(short_name);
continue;
}
if (!low_name) { continue; }
/* check it matches the wildcard pattern */
- if (ms_fnmatch_protocol(low_mask, low_name, PROTOCOL_NT1) != 0) {
+ if (ms_fnmatch_protocol(low_mask, low_name, PROTOCOL_NT1,
+ true) != 0) {
continue;
}
if (ISDOTDOT(file)) file = ".";
- return ms_fnmatch_protocol(pattern, file, cli->transport->negotiate.protocol)==0;
+ return ms_fnmatch_protocol(
+ pattern, file, cli->transport->negotiate.protocol, true)==0;
}
static char *reg_test(struct smbcli_state *cli, TALLOC_CTX *mem_ctx, const char *pattern, const char *long_name, const char *short_name)