s3-lib Replace StrnCaseCmp() with strncasecmp_m()
authorAndrew Bartlett <abartlet@samba.org>
Fri, 13 May 2011 18:23:36 +0000 (20:23 +0200)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 18 May 2011 14:12:08 +0000 (16:12 +0200)
strncasecmp_m() never needs to call to talloc, and via next_codepoint()
still has an ASCII fast-path bypassing iconv() calls.

Andrew Bartlett

15 files changed:
source3/include/proto.h
source3/lib/substitute.c
source3/lib/tldap.c
source3/lib/util_str.c
source3/libsmb/libsmb_xattr.c
source3/passdb/pdb_smbpasswd.c
source3/registry/reg_api.c
source3/smbd/trans2.c
source3/utils/net_ads.c
source3/utils/net_groupmap.c
source3/utils/net_rpc.c
source3/utils/net_rpc_samsync.c
source3/utils/ntlm_auth.c
source3/winbindd/idmap_adex/cell_util.c
source3/winbindd/idmap_adex/provider_unified.c

index e886c1f8bae4d99941394c9f010dac044aeed7d6..76d9b64e013c74eddb3d66225b8462484d14c905 100644 (file)
@@ -871,7 +871,6 @@ ssize_t tstream_read_packet_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
 /* The following definitions come from lib/util_str.c  */
 
 bool next_token(const char **ptr, char *buff, const char *sep, size_t bufsize);
-int StrnCaseCmp(const char *s, const char *t, size_t len);
 bool strnequal(const char *s1,const char *s2,size_t n);
 bool strcsequal(const char *s1,const char *s2);
 void strnorm(char *s, int case_default);
index e72a8c3b6160ec0eeefca06d0925de0ef12b2419..b246a17132fcfed74a58664f050e174b12ccbdb1 100644 (file)
@@ -632,7 +632,7 @@ static char *alloc_sub_basic(const char *smb_name, const char *domain_name,
                                sub_sockaddr[0] ? sub_sockaddr : "0.0.0.0");
                        break;
                case 'L' : 
-                       if ( StrnCaseCmp(p, "%LOGONSERVER%", strlen("%LOGONSERVER%")) == 0 ) {
+                       if ( strncasecmp_m(p, "%LOGONSERVER%", strlen("%LOGONSERVER%")) == 0 ) {
                                break;
                        }
                        if (local_machine_name && *local_machine_name) {
index 3afdaea41942f43d3ea4d51aac0a89fa093c5d05..c2f5b2ced7143497dab9ad9eabe5375767ee8802 100644 (file)
@@ -1375,7 +1375,7 @@ static bool tldap_push_filter_basic(struct tldap_context *ld,
                                return false;
                        }
 
-                       if (StrnCaseCmp(dn, "dn:", 3) != 0) {
+                       if (strncasecmp_m(dn, "dn:", 3) != 0) {
                                if (rule == e) {
                                        rule = dn;
                                        dn = NULL;
index ee36930fd1ec94a95bd1e11e1ffae3b8e2066f78..bb8482ca0be17cfcade51fde54e7c1a8313371f6 100644 (file)
@@ -35,66 +35,6 @@ const char toupper_ascii_fast_table[128] = {
        0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f
 };
 
-/**
- Case insensitive string compararison, length limited.
-**/
-int StrnCaseCmp(const char *s, const char *t, size_t len)
-{
-       size_t n = 0;
-       const char *ps, *pt;
-       size_t size;
-       smb_ucs2_t *buffer_s, *buffer_t;
-       int ret;
-
-       for (ps = s, pt = t; n < len ; ps++, pt++, n++) {
-               char us, ut;
-
-               if (!*ps && !*pt)
-                       return 0; /* both ended */
-               else if (!*ps)
-                       return -1; /* s is a prefix */
-               else if (!*pt)
-                       return +1; /* t is a prefix */
-               else if ((*ps & 0x80) || (*pt & 0x80))
-                       /* not ascii anymore, do it the
-                        * hard way from here on in */
-                       break;
-
-               us = toupper_ascii_fast(*ps);
-               ut = toupper_ascii_fast(*pt);
-               if (us == ut)
-                       continue;
-               else if (us < ut)
-                       return -1;
-               else if (us > ut)
-                       return +1;
-       }
-
-       if (n == len) {
-               return 0;
-       }
-
-       if (!push_ucs2_talloc(talloc_tos(), &buffer_s, ps, &size)) {
-               return strncmp(ps, pt, len-n);
-               /* Not quite the right answer, but finding the right one
-                  under this failure case is expensive,
-                  and it's pretty close */
-       }
-
-       if (!push_ucs2_talloc(talloc_tos(), &buffer_t, pt, &size)) {
-               TALLOC_FREE(buffer_s);
-               return strncmp(ps, pt, len-n);
-               /* Not quite the right answer, but finding the right one
-                  under this failure case is expensive,
-                  and it's pretty close */
-       }
-
-       ret = strncasecmp_w(buffer_s, buffer_t, len-n);
-       TALLOC_FREE(buffer_s);
-       TALLOC_FREE(buffer_t);
-       return ret;
-}
-
 /**
  * Compare 2 strings up to and including the nth char.
  *
@@ -107,7 +47,7 @@ bool strnequal(const char *s1,const char *s2,size_t n)
        if (!s1 || !s2 || !n)
                return(false);
 
-       return(StrnCaseCmp(s1,s2,n)==0);
+       return(strncasecmp_m(s1,s2,n)==0);
 }
 
 /**
index 22d71571c6ae1c66c45062d1eaefe91943e5aa0a..56fe06435ccd0491657a87792c10ff5aed46f7f9 100644 (file)
@@ -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,
index 43d6eaf66457e0dc27f07466b5b9bc9dd5ece10c..73dc0a5c6b1b97037d4256325d3aff5b9e4c194d 100644 (file)
@@ -549,7 +549,7 @@ static struct smb_passwd *getsmbfilepwent(struct smbpasswd_privates *smbpasswd_s
                        }
                        if(*p == ':') {
                                p++;
-                               if(*p && (StrnCaseCmp((char *)p, "LCT-", 4)==0)) {
+                               if(*p && (strncasecmp_m((char *)p, "LCT-", 4)==0)) {
                                        int i;
                                        p += 4;
                                        for(i = 0; i < 8; i++) {
@@ -975,7 +975,7 @@ This is no longer supported.!\n", pwd->smb_name));
                        p++;
 
                        /* We should be pointing at the LCT entry. */
-                       if((linebuf_len > (PTR_DIFF(p, linebuf) + 13)) && (StrnCaseCmp((char *)p, "LCT-", 4) == 0)) {
+                       if((linebuf_len > (PTR_DIFF(p, linebuf) + 13)) && (strncasecmp_m((char *)p, "LCT-", 4) == 0)) {
                                p += 4;
                                for(i = 0; i < 8; i++) {
                                        if(p[i] == '\0' || !isxdigit(p[i])) {
@@ -990,7 +990,7 @@ This is no longer supported.!\n", pwd->smb_name));
                                         */
                                        got_pass_last_set_time = True;
                                } /* i == 8 */
-                       } /* *p && StrnCaseCmp() */
+                       } /* *p && strncasecmp_m() */
                } /* p == ':' */
        } /* p == '[' */
 
index 935d2441afa5fdf1e282dd16d631abf4e4b859e1..150a3ab02d40789d61b98180e15cd22749b37b63 100644 (file)
@@ -188,7 +188,7 @@ static WERROR regkey_open_onelevel(TALLOC_CTX *mem_ctx,
 
        /* Tag this as a Performance Counter Key */
 
-       if( StrnCaseCmp(key->name, KEY_HKPD, strlen(KEY_HKPD)) == 0 )
+       if( strncasecmp_m(key->name, KEY_HKPD, strlen(KEY_HKPD)) == 0 )
                key->type = REG_KEY_HKPD;
 
        /* Look up the table of registry I/O operations */
index 6eae9a5764268be638093986cc3c2852d7d7af5d..f5b87c77d3025022a74bcf63c66d4d94a1bc3223 100644 (file)
@@ -107,7 +107,7 @@ static bool samba_private_attr_name(const char *unix_ea_name)
                if (strequal( prohibited_ea_names[i], unix_ea_name))
                        return true;
        }
-       if (StrnCaseCmp(unix_ea_name, SAMBA_XATTR_DOSSTREAM_PREFIX,
+       if (strncasecmp_m(unix_ea_name, SAMBA_XATTR_DOSSTREAM_PREFIX,
                        strlen(SAMBA_XATTR_DOSSTREAM_PREFIX)) == 0) {
                return true;
        }
index e279c9d2bbf594a5466cba9dd98e9ff076529827..f712ddf2204e0343818c7bb423f4c007202c647f 100644 (file)
@@ -1349,25 +1349,25 @@ int net_ads_join(struct net_context *c, int argc, const char **argv)
        /* process additional command line args */
 
        for ( i=0; i<argc; i++ ) {
-               if ( !StrnCaseCmp(argv[i], "createupn", strlen("createupn")) ) {
+               if ( !strncasecmp_m(argv[i], "createupn", strlen("createupn")) ) {
                        createupn = true;
                        machineupn = get_string_param(argv[i]);
                }
-               else if ( !StrnCaseCmp(argv[i], "createcomputer", strlen("createcomputer")) ) {
+               else if ( !strncasecmp_m(argv[i], "createcomputer", strlen("createcomputer")) ) {
                        if ( (create_in_ou = get_string_param(argv[i])) == NULL ) {
                                d_fprintf(stderr, _("Please supply a valid OU path.\n"));
                                werr = WERR_INVALID_PARAM;
                                goto fail;
                        }
                }
-               else if ( !StrnCaseCmp(argv[i], "osName", strlen("osName")) ) {
+               else if ( !strncasecmp_m(argv[i], "osName", strlen("osName")) ) {
                        if ( (os_name = get_string_param(argv[i])) == NULL ) {
                                d_fprintf(stderr, _("Please supply a operating system name.\n"));
                                werr = WERR_INVALID_PARAM;
                                goto fail;
                        }
                }
-               else if ( !StrnCaseCmp(argv[i], "osVer", strlen("osVer")) ) {
+               else if ( !strncasecmp_m(argv[i], "osVer", strlen("osVer")) ) {
                        if ( (os_version = get_string_param(argv[i])) == NULL ) {
                                d_fprintf(stderr, _("Please supply a valid operating system version.\n"));
                                werr = WERR_INVALID_PARAM;
index ca4c60716630762185970b381a531a9681ea8d21..09f4bfd33a50cf6aa73883fedf1d467a504e7d30 100644 (file)
@@ -35,7 +35,7 @@ static bool get_sid_from_input(struct dom_sid *sid, char *input)
 {
        GROUP_MAP map;
 
-       if (StrnCaseCmp( input, "S-", 2)) {
+       if (strncasecmp_m( input, "S-", 2)) {
                /* Perhaps its the NT group name? */
                if (!pdb_getgrnam(&map, input)) {
                        printf(_("NT Group %s doesn't exist in mapping DB\n"),
@@ -103,14 +103,14 @@ static int net_groupmap_list(struct net_context *c, int argc, const char **argv)
                if ( !strcasecmp_m(argv[i], "verbose")) {
                        long_list = true;
                }
-               else if ( !StrnCaseCmp(argv[i], "ntgroup", strlen("ntgroup")) ) {
+               else if ( !strncasecmp_m(argv[i], "ntgroup", strlen("ntgroup")) ) {
                        fstrcpy( ntgroup, get_string_param( argv[i] ) );
                        if ( !ntgroup[0] ) {
                                d_fprintf(stderr, _("must supply a name\n"));
                                return -1;
                        }
                }
-               else if ( !StrnCaseCmp(argv[i], "sid", strlen("sid")) ) {
+               else if ( !strncasecmp_m(argv[i], "sid", strlen("sid")) ) {
                        fstrcpy( sid_string, get_string_param( argv[i] ) );
                        if ( !sid_string[0] ) {
                                d_fprintf(stderr, _("must supply a SID\n"));
@@ -201,7 +201,7 @@ static int net_groupmap_add(struct net_context *c, int argc, const char **argv)
 
        /* get the options */
        for ( i=0; i<argc; i++ ) {
-               if ( !StrnCaseCmp(argv[i], "rid", strlen("rid")) ) {
+               if ( !strncasecmp_m(argv[i], "rid", strlen("rid")) ) {
                        rid = get_int_param(argv[i]);
                        if ( rid < DOMAIN_RID_ADMINS ) {
                                d_fprintf(stderr,
@@ -210,28 +210,28 @@ static int net_groupmap_add(struct net_context *c, int argc, const char **argv)
                                return -1;
                        }
                }
-               else if ( !StrnCaseCmp(argv[i], "unixgroup", strlen("unixgroup")) ) {
+               else if ( !strncasecmp_m(argv[i], "unixgroup", strlen("unixgroup")) ) {
                        fstrcpy( unixgrp, get_string_param( argv[i] ) );
                        if ( !unixgrp[0] ) {
                                d_fprintf(stderr,_( "must supply a name\n"));
                                return -1;
                        }
                }
-               else if ( !StrnCaseCmp(argv[i], "ntgroup", strlen("ntgroup")) ) {
+               else if ( !strncasecmp_m(argv[i], "ntgroup", strlen("ntgroup")) ) {
                        fstrcpy( ntgroup, get_string_param( argv[i] ) );
                        if ( !ntgroup[0] ) {
                                d_fprintf(stderr, _("must supply a name\n"));
                                return -1;
                        }
                }
-               else if ( !StrnCaseCmp(argv[i], "sid", strlen("sid")) ) {
+               else if ( !strncasecmp_m(argv[i], "sid", strlen("sid")) ) {
                        fstrcpy( string_sid, get_string_param( argv[i] ) );
                        if ( !string_sid[0] ) {
                                d_fprintf(stderr, _("must supply a SID\n"));
                                return -1;
                        }
                }
-               else if ( !StrnCaseCmp(argv[i], "comment", strlen("comment")) ) {
+               else if ( !strncasecmp_m(argv[i], "comment", strlen("comment")) ) {
                        fstrcpy( ntcomment, get_string_param( argv[i] ) );
                        if ( !ntcomment[0] ) {
                                d_fprintf(stderr,
@@ -239,7 +239,7 @@ static int net_groupmap_add(struct net_context *c, int argc, const char **argv)
                                return -1;
                        }
                }
-               else if ( !StrnCaseCmp(argv[i], "type", strlen("type")) )  {
+               else if ( !strncasecmp_m(argv[i], "type", strlen("type")) )  {
                        fstrcpy( type, get_string_param( argv[i] ) );
                        switch ( type[0] ) {
                                case 'b':
@@ -361,21 +361,21 @@ static int net_groupmap_modify(struct net_context *c, int argc, const char **arg
 
        /* get the options */
        for ( i=0; i<argc; i++ ) {
-               if ( !StrnCaseCmp(argv[i], "ntgroup", strlen("ntgroup")) ) {
+               if ( !strncasecmp_m(argv[i], "ntgroup", strlen("ntgroup")) ) {
                        fstrcpy( ntgroup, get_string_param( argv[i] ) );
                        if ( !ntgroup[0] ) {
                                d_fprintf(stderr, _("must supply a name\n"));
                                return -1;
                        }
                }
-               else if ( !StrnCaseCmp(argv[i], "sid", strlen("sid")) ) {
+               else if ( !strncasecmp_m(argv[i], "sid", strlen("sid")) ) {
                        fstrcpy( sid_string, get_string_param( argv[i] ) );
                        if ( !sid_string[0] ) {
                                d_fprintf(stderr, _("must supply a name\n"));
                                return -1;
                        }
                }
-               else if ( !StrnCaseCmp(argv[i], "comment", strlen("comment")) ) {
+               else if ( !strncasecmp_m(argv[i], "comment", strlen("comment")) ) {
                        fstrcpy( ntcomment, get_string_param( argv[i] ) );
                        if ( !ntcomment[0] ) {
                                d_fprintf(stderr,
@@ -383,7 +383,7 @@ static int net_groupmap_modify(struct net_context *c, int argc, const char **arg
                                return -1;
                        }
                }
-               else if ( !StrnCaseCmp(argv[i], "unixgroup", strlen("unixgroup")) ) {
+               else if ( !strncasecmp_m(argv[i], "unixgroup", strlen("unixgroup")) ) {
                        fstrcpy( unixgrp, get_string_param( argv[i] ) );
                        if ( !unixgrp[0] ) {
                                d_fprintf(stderr,
@@ -391,7 +391,7 @@ static int net_groupmap_modify(struct net_context *c, int argc, const char **arg
                                return -1;
                        }
                }
-               else if ( !StrnCaseCmp(argv[i], "type", strlen("type")) )  {
+               else if ( !strncasecmp_m(argv[i], "type", strlen("type")) )  {
                        fstrcpy( type, get_string_param( argv[i] ) );
                        switch ( type[0] ) {
                                case 'd':
@@ -500,14 +500,14 @@ static int net_groupmap_delete(struct net_context *c, int argc, const char **arg
 
        /* get the options */
        for ( i=0; i<argc; i++ ) {
-               if ( !StrnCaseCmp(argv[i], "ntgroup", strlen("ntgroup")) ) {
+               if ( !strncasecmp_m(argv[i], "ntgroup", strlen("ntgroup")) ) {
                        fstrcpy( ntgroup, get_string_param( argv[i] ) );
                        if ( !ntgroup[0] ) {
                                d_fprintf(stderr, _("must supply a name\n"));
                                return -1;
                        }
                }
-               else if ( !StrnCaseCmp(argv[i], "sid", strlen("sid")) ) {
+               else if ( !strncasecmp_m(argv[i], "sid", strlen("sid")) ) {
                        fstrcpy( sid_string, get_string_param( argv[i] ) );
                        if ( !sid_string[0] ) {
                                d_fprintf(stderr, _("must supply a SID\n"));
index 2c35ae974b3fcca7b4f11995ae73bd6922cd9f22..b705f6af97db2b9ed3b8718e3dd50c09ab912a9b 100644 (file)
@@ -1977,7 +1977,7 @@ static NTSTATUS get_sid_from_name(struct cli_state *cli,
                TALLOC_FREE(pipe_hnd);
        }
 
-       if (!NT_STATUS_IS_OK(status) && (StrnCaseCmp(name, "S-", 2) == 0)) {
+       if (!NT_STATUS_IS_OK(status) && (strncasecmp_m(name, "S-", 2) == 0)) {
 
                /* Try as S-1-5-whatever */
 
index 861f429559fea7499d4822a76600a7aadda6768b..04aefbb13f2dd194c3e1f25e9cd997358efaa55c 100644 (file)
@@ -51,50 +51,50 @@ static void parse_samsync_partial_replication_objects(TALLOC_CTX *mem_ctx,
 
                ZERO_STRUCT(o);
 
-               if (!StrnCaseCmp(argv[i], "user_rid=", strlen("user_rid="))) {
+               if (!strncasecmp_m(argv[i], "user_rid=", strlen("user_rid="))) {
                        o.object_identifier.rid         = get_int_param(argv[i]);
                        o.object_type                   = NETR_DELTA_USER;
                        o.database_id                   = SAM_DATABASE_DOMAIN;
                }
-               if (!StrnCaseCmp(argv[i], "group_rid=", strlen("group_rid="))) {
+               if (!strncasecmp_m(argv[i], "group_rid=", strlen("group_rid="))) {
                        o.object_identifier.rid         = get_int_param(argv[i]);
                        o.object_type                   = NETR_DELTA_GROUP;
                        o.database_id                   = SAM_DATABASE_DOMAIN;
                }
-               if (!StrnCaseCmp(argv[i], "group_member_rid=", strlen("group_member_rid="))) {
+               if (!strncasecmp_m(argv[i], "group_member_rid=", strlen("group_member_rid="))) {
                        o.object_identifier.rid         = get_int_param(argv[i]);
                        o.object_type                   = NETR_DELTA_GROUP_MEMBER;
                        o.database_id                   = SAM_DATABASE_DOMAIN;
                }
-               if (!StrnCaseCmp(argv[i], "alias_rid=", strlen("alias_rid="))) {
+               if (!strncasecmp_m(argv[i], "alias_rid=", strlen("alias_rid="))) {
                        o.object_identifier.rid         = get_int_param(argv[i]);
                        o.object_type                   = NETR_DELTA_ALIAS;
                        o.database_id                   = SAM_DATABASE_BUILTIN;
                }
-               if (!StrnCaseCmp(argv[i], "alias_member_rid=", strlen("alias_member_rid="))) {
+               if (!strncasecmp_m(argv[i], "alias_member_rid=", strlen("alias_member_rid="))) {
                        o.object_identifier.rid         = get_int_param(argv[i]);
                        o.object_type                   = NETR_DELTA_ALIAS_MEMBER;
                        o.database_id                   = SAM_DATABASE_BUILTIN;
                }
-               if (!StrnCaseCmp(argv[i], "account_sid=", strlen("account_sid="))) {
+               if (!strncasecmp_m(argv[i], "account_sid=", strlen("account_sid="))) {
                        const char *sid_str = get_string_param(argv[i]);
                        string_to_sid(&o.object_identifier.sid, sid_str);
                        o.object_type                   = NETR_DELTA_ACCOUNT;
                        o.database_id                   = SAM_DATABASE_PRIVS;
                }
-               if (!StrnCaseCmp(argv[i], "policy_sid=", strlen("policy_sid="))) {
+               if (!strncasecmp_m(argv[i], "policy_sid=", strlen("policy_sid="))) {
                        const char *sid_str = get_string_param(argv[i]);
                        string_to_sid(&o.object_identifier.sid, sid_str);
                        o.object_type                   = NETR_DELTA_POLICY;
                        o.database_id                   = SAM_DATABASE_PRIVS;
                }
-               if (!StrnCaseCmp(argv[i], "trustdom_sid=", strlen("trustdom_sid="))) {
+               if (!strncasecmp_m(argv[i], "trustdom_sid=", strlen("trustdom_sid="))) {
                        const char *sid_str = get_string_param(argv[i]);
                        string_to_sid(&o.object_identifier.sid, sid_str);
                        o.object_type                   = NETR_DELTA_TRUSTED_DOMAIN;
                        o.database_id                   = SAM_DATABASE_PRIVS;
                }
-               if (!StrnCaseCmp(argv[i], "secret_name=", strlen("secret_name="))) {
+               if (!strncasecmp_m(argv[i], "secret_name=", strlen("secret_name="))) {
                        o.object_identifier.name        = get_string_param(argv[i]);
                        o.object_type                   = NETR_DELTA_SECRET;
                        o.database_id                   = SAM_DATABASE_PRIVS;
index 72d4c053e0bc80f2287addb260ecc5dc77c928ad..3a5ba223da496b1cc68ebc982b31dd6942b82ee0 100644 (file)
@@ -2680,7 +2680,7 @@ enum {
                        break;
 
                 case OPT_REQUIRE_MEMBERSHIP:
-                       if (StrnCaseCmp("S-", require_membership_of, 2) == 0) {
+                       if (strncasecmp_m("S-", require_membership_of, 2) == 0) {
                                require_membership_of_sid = require_membership_of;
                        }
                        break;
index c82407c0f4808eda6202df9963608dcbd782bcf8..9c50f73c4126f67a298beb2ae386bfab6b6dabb8 100644 (file)
@@ -38,7 +38,7 @@
        for (i = 0; i < num_lines; i++) {
                /* make sure to avoid substring matches like uid
                   and uidNumber */
-               if ((StrnCaseCmp(list[i], substr, cmplen) == 0) &&
+               if ((strncasecmp_m(list[i], substr, cmplen) == 0) &&
                    (list[i][cmplen] == '=')) {
                        /* Don't return an empty string */
                        if (list[i][cmplen + 1] != '\0')
@@ -230,7 +230,7 @@ done:
        while (next_token_talloc(frame, &tmp_dn, &buffer, ",")) {
 
                /* skip everything up the where DC=... begins */
-               if (StrnCaseCmp(buffer, "DC=", 3) != 0)
+               if (strncasecmp_m(buffer, "DC=", 3) != 0)
                        continue;
 
                if (!domain) {
index 03f9d33ba329a4669005bb68938a99ad17372654..9e271a0db9ecdfca0078f2c7cf6eca034584382b 100644 (file)
@@ -310,7 +310,7 @@ static bool check_forest_scope(const char *dn)
        }
 
        q++;
-       if (StrnCaseCmp(q, "dc=", 3) != 0) {
+       if (strncasecmp_m(q, "dc=", 3) != 0) {
                nt_status = NT_STATUS_OBJECT_PATH_NOT_FOUND;
                BAIL_ON_NTSTATUS_ERROR(nt_status);
        }