summaryrefslogtreecommitdiff
path: root/source3/libsmb/libsmb_xattr.c
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2011-05-13 20:23:36 +0200
committerAndrew Bartlett <abartlet@samba.org>2011-05-18 16:12:08 +0200
commitda662b82b87cdbe07762974b1f9e825ef15951bd (patch)
treef29813bc62f28b9bb73f835828c7f6d3ecbcc872 /source3/libsmb/libsmb_xattr.c
parentc615ebed6e3d273a682806b952d543e834e5630d (diff)
downloadsamba-da662b82b87cdbe07762974b1f9e825ef15951bd.tar.gz
samba-da662b82b87cdbe07762974b1f9e825ef15951bd.tar.bz2
samba-da662b82b87cdbe07762974b1f9e825ef15951bd.zip
s3-lib Replace StrnCaseCmp() with strncasecmp_m()
strncasecmp_m() never needs to call to talloc, and via next_codepoint() still has an ASCII fast-path bypassing iconv() calls. Andrew Bartlett
Diffstat (limited to 'source3/libsmb/libsmb_xattr.c')
-rw-r--r--source3/libsmb/libsmb_xattr.c74
1 files changed, 37 insertions, 37 deletions
diff --git a/source3/libsmb/libsmb_xattr.c b/source3/libsmb/libsmb_xattr.c
index 22d71571c6..56fe06435c 100644
--- a/source3/libsmb/libsmb_xattr.c
+++ b/source3/libsmb/libsmb_xattr.c
@@ -321,9 +321,9 @@ parse_ace(struct cli_state *ipc_cli,
return false;
}
- if (StrnCaseCmp(tok, "ALLOWED", strlen("ALLOWED")) == 0) {
+ if (strncasecmp_m(tok, "ALLOWED", strlen("ALLOWED")) == 0) {
atype = SEC_ACE_TYPE_ACCESS_ALLOWED;
- } else if (StrnCaseCmp(tok, "DENIED", strlen("DENIED")) == 0) {
+ } else if (strncasecmp_m(tok, "DENIED", strlen("DENIED")) == 0) {
atype = SEC_ACE_TYPE_ACCESS_DENIED;
} else {
TALLOC_FREE(frame);
@@ -436,12 +436,12 @@ sec_desc_parse(TALLOC_CTX *ctx,
while (next_token_talloc(ctx, &p, &tok, "\t,\r\n")) {
- if (StrnCaseCmp(tok,"REVISION:", 9) == 0) {
+ if (strncasecmp_m(tok,"REVISION:", 9) == 0) {
revision = strtol(tok+9, NULL, 16);
continue;
}
- if (StrnCaseCmp(tok,"OWNER:", 6) == 0) {
+ if (strncasecmp_m(tok,"OWNER:", 6) == 0) {
if (owner_sid) {
DEBUG(5,("OWNER specified more than once!\n"));
goto done;
@@ -457,7 +457,7 @@ sec_desc_parse(TALLOC_CTX *ctx,
continue;
}
- if (StrnCaseCmp(tok,"OWNER+:", 7) == 0) {
+ if (strncasecmp_m(tok,"OWNER+:", 7) == 0) {
if (owner_sid) {
DEBUG(5,("OWNER specified more than once!\n"));
goto done;
@@ -473,7 +473,7 @@ sec_desc_parse(TALLOC_CTX *ctx,
continue;
}
- if (StrnCaseCmp(tok,"GROUP:", 6) == 0) {
+ if (strncasecmp_m(tok,"GROUP:", 6) == 0) {
if (group_sid) {
DEBUG(5,("GROUP specified more than once!\n"));
goto done;
@@ -489,7 +489,7 @@ sec_desc_parse(TALLOC_CTX *ctx,
continue;
}
- if (StrnCaseCmp(tok,"GROUP+:", 7) == 0) {
+ if (strncasecmp_m(tok,"GROUP+:", 7) == 0) {
if (group_sid) {
DEBUG(5,("GROUP specified more than once!\n"));
goto done;
@@ -505,7 +505,7 @@ sec_desc_parse(TALLOC_CTX *ctx,
continue;
}
- if (StrnCaseCmp(tok,"ACL:", 4) == 0) {
+ if (strncasecmp_m(tok,"ACL:", 4) == 0) {
struct security_ace ace;
if (!parse_ace(ipc_cli, pol, &ace, numeric, tok+4)) {
DEBUG(5, ("Failed to parse ACL %s\n", tok));
@@ -518,7 +518,7 @@ sec_desc_parse(TALLOC_CTX *ctx,
continue;
}
- if (StrnCaseCmp(tok,"ACL+:", 5) == 0) {
+ if (strncasecmp_m(tok,"ACL+:", 5) == 0) {
struct security_ace ace;
if (!parse_ace(ipc_cli, pol, &ace, False, tok+5)) {
DEBUG(5, ("Failed to parse ACL %s\n", tok));
@@ -637,7 +637,7 @@ dos_attr_parse(SMBCCTX *context,
frame = talloc_stackframe();
while (next_token_talloc(frame, &p, &tok, "\t,\r\n")) {
- if (StrnCaseCmp(tok, "MODE:", 5) == 0) {
+ if (strncasecmp_m(tok, "MODE:", 5) == 0) {
long request = strtol(tok+5, NULL, 16);
if (request == 0) {
dad->mode = (request |
@@ -650,32 +650,32 @@ dos_attr_parse(SMBCCTX *context,
continue;
}
- if (StrnCaseCmp(tok, "SIZE:", 5) == 0) {
+ if (strncasecmp_m(tok, "SIZE:", 5) == 0) {
dad->size = (SMB_OFF_T)atof(tok+5);
continue;
}
n = strlen(attr_strings.access_time_attr);
- if (StrnCaseCmp(tok, attr_strings.access_time_attr, n) == 0) {
+ if (strncasecmp_m(tok, attr_strings.access_time_attr, n) == 0) {
dad->access_time = (time_t)strtol(tok+n+1, NULL, 10);
continue;
}
n = strlen(attr_strings.change_time_attr);
- if (StrnCaseCmp(tok, attr_strings.change_time_attr, n) == 0) {
+ if (strncasecmp_m(tok, attr_strings.change_time_attr, n) == 0) {
dad->change_time = (time_t)strtol(tok+n+1, NULL, 10);
continue;
}
n = strlen(attr_strings.write_time_attr);
- if (StrnCaseCmp(tok, attr_strings.write_time_attr, n) == 0) {
+ if (strncasecmp_m(tok, attr_strings.write_time_attr, n) == 0) {
dad->write_time = (time_t)strtol(tok+n+1, NULL, 10);
continue;
}
if (attr_strings.create_time_attr != NULL) {
n = strlen(attr_strings.create_time_attr);
- if (StrnCaseCmp(tok, attr_strings.create_time_attr,
+ if (strncasecmp_m(tok, attr_strings.create_time_attr,
n) == 0) {
dad->create_time = (time_t)strtol(tok+n+1,
NULL, 10);
@@ -683,7 +683,7 @@ dos_attr_parse(SMBCCTX *context,
}
}
- if (StrnCaseCmp(tok, "INODE:", 6) == 0) {
+ if (strncasecmp_m(tok, "INODE:", 6) == 0) {
dad->inode = (SMB_INO_T)atof(tok+6);
continue;
}
@@ -800,12 +800,12 @@ cacl_get(SMBCCTX *context,
*pExclude++ = '\0';
}
- all = (StrnCaseCmp(name, "system.*", 8) == 0);
- all_nt = (StrnCaseCmp(name, "system.nt_sec_desc.*", 20) == 0);
- all_nt_acls = (StrnCaseCmp(name, "system.nt_sec_desc.acl.*", 24) == 0);
- all_dos = (StrnCaseCmp(name, "system.dos_attr.*", 17) == 0);
- some_nt = (StrnCaseCmp(name, "system.nt_sec_desc.", 19) == 0);
- some_dos = (StrnCaseCmp(name, "system.dos_attr.", 16) == 0);
+ all = (strncasecmp_m(name, "system.*", 8) == 0);
+ all_nt = (strncasecmp_m(name, "system.nt_sec_desc.*", 20) == 0);
+ all_nt_acls = (strncasecmp_m(name, "system.nt_sec_desc.acl.*", 24) == 0);
+ all_dos = (strncasecmp_m(name, "system.dos_attr.*", 17) == 0);
+ some_nt = (strncasecmp_m(name, "system.nt_sec_desc.", 19) == 0);
+ some_dos = (strncasecmp_m(name, "system.dos_attr.", 16) == 0);
numeric = (* (name + strlen(name) - 1) != '+');
/* Look for exclusions from "all" requests */
@@ -982,7 +982,7 @@ cacl_get(SMBCCTX *context,
n = snprintf(buf, bufsize,
",OWNER:%s", sidstr);
}
- } else if (StrnCaseCmp(name, "owner", 5) == 0) {
+ } else if (strncasecmp_m(name, "owner", 5) == 0) {
if (determine_size) {
p = talloc_asprintf(ctx, "%s", sidstr);
if (!p) {
@@ -1028,7 +1028,7 @@ cacl_get(SMBCCTX *context,
n = snprintf(buf, bufsize,
",GROUP:%s", sidstr);
}
- } else if (StrnCaseCmp(name, "group", 5) == 0) {
+ } else if (strncasecmp_m(name, "group", 5) == 0) {
if (determine_size) {
p = talloc_asprintf(ctx, "%s", sidstr);
if (!p) {
@@ -1085,9 +1085,9 @@ cacl_get(SMBCCTX *context,
ace->flags,
ace->access_mask);
}
- } else if ((StrnCaseCmp(name, "acl", 3) == 0 &&
+ } else if ((strncasecmp_m(name, "acl", 3) == 0 &&
strcasecmp_m(name+3, sidstr) == 0) ||
- (StrnCaseCmp(name, "acl+", 4) == 0 &&
+ (strncasecmp_m(name, "acl+", 4) == 0 &&
strcasecmp_m(name+4, sidstr) == 0)) {
if (determine_size) {
p = talloc_asprintf(
@@ -1838,8 +1838,8 @@ SMBC_setxattr_ctx(SMBCCTX *context,
if (strcasecmp_m(name, "system.nt_sec_desc.*") == 0 ||
strcasecmp_m(name, "system.nt_sec_desc.*+") == 0 ||
strcasecmp_m(name, "system.nt_sec_desc.revision") == 0 ||
- StrnCaseCmp(name, "system.nt_sec_desc.acl", 22) == 0 ||
- StrnCaseCmp(name, "system.nt_sec_desc.acl+", 23) == 0) {
+ strncasecmp_m(name, "system.nt_sec_desc.acl", 22) == 0 ||
+ strncasecmp_m(name, "system.nt_sec_desc.acl+", 23) == 0) {
/* Yup. */
char *namevalue =
@@ -2082,22 +2082,22 @@ SMBC_getxattr_ctx(SMBCCTX *context,
/* Are they requesting a supported attribute? */
if (strcasecmp_m(name, "system.*") == 0 ||
- StrnCaseCmp(name, "system.*!", 9) == 0 ||
+ strncasecmp_m(name, "system.*!", 9) == 0 ||
strcasecmp_m(name, "system.*+") == 0 ||
- StrnCaseCmp(name, "system.*+!", 10) == 0 ||
+ strncasecmp_m(name, "system.*+!", 10) == 0 ||
strcasecmp_m(name, "system.nt_sec_desc.*") == 0 ||
- StrnCaseCmp(name, "system.nt_sec_desc.*!", 21) == 0 ||
+ strncasecmp_m(name, "system.nt_sec_desc.*!", 21) == 0 ||
strcasecmp_m(name, "system.nt_sec_desc.*+") == 0 ||
- StrnCaseCmp(name, "system.nt_sec_desc.*+!", 22) == 0 ||
+ strncasecmp_m(name, "system.nt_sec_desc.*+!", 22) == 0 ||
strcasecmp_m(name, "system.nt_sec_desc.revision") == 0 ||
strcasecmp_m(name, "system.nt_sec_desc.owner") == 0 ||
strcasecmp_m(name, "system.nt_sec_desc.owner+") == 0 ||
strcasecmp_m(name, "system.nt_sec_desc.group") == 0 ||
strcasecmp_m(name, "system.nt_sec_desc.group+") == 0 ||
- StrnCaseCmp(name, "system.nt_sec_desc.acl", 22) == 0 ||
- StrnCaseCmp(name, "system.nt_sec_desc.acl+", 23) == 0 ||
+ strncasecmp_m(name, "system.nt_sec_desc.acl", 22) == 0 ||
+ strncasecmp_m(name, "system.nt_sec_desc.acl+", 23) == 0 ||
strcasecmp_m(name, "system.dos_attr.*") == 0 ||
- StrnCaseCmp(name, "system.dos_attr.*!", 18) == 0 ||
+ strncasecmp_m(name, "system.dos_attr.*!", 18) == 0 ||
strcasecmp_m(name, "system.dos_attr.mode") == 0 ||
strcasecmp_m(name, "system.dos_attr.size") == 0 ||
(attr_strings.create_time_attr != NULL &&
@@ -2226,8 +2226,8 @@ SMBC_removexattr_ctx(SMBCCTX *context,
strcasecmp_m(name, "system.nt_sec_desc.owner+") == 0 ||
strcasecmp_m(name, "system.nt_sec_desc.group") == 0 ||
strcasecmp_m(name, "system.nt_sec_desc.group+") == 0 ||
- StrnCaseCmp(name, "system.nt_sec_desc.acl", 22) == 0 ||
- StrnCaseCmp(name, "system.nt_sec_desc.acl+", 23) == 0) {
+ strncasecmp_m(name, "system.nt_sec_desc.acl", 22) == 0 ||
+ strncasecmp_m(name, "system.nt_sec_desc.acl+", 23) == 0) {
/* Yup. */
ret = cacl_set(context, talloc_tos(), srv->cli,