From 486eaa69b6b2efe5f75e81808dd268ea65773d1b Mon Sep 17 00:00:00 2001 From: Hallvard Furuseth Date: Fri, 13 Dec 2002 19:15:20 +0000 Subject: [PATCH] Rename "lang(uage)" to "tag(s)". (Cleanup after attribute options patch.) --- servers/slapd/ad.c | 172 ++++++++++++++++---------------- servers/slapd/back-bdb/index.c | 18 ++-- servers/slapd/back-ldbm/index.c | 18 ++-- servers/slapd/index.c | 5 +- servers/slapd/modify.c | 4 +- servers/slapd/proto-slap.h | 4 +- servers/slapd/slap.h | 18 ++-- 7 files changed, 118 insertions(+), 121 deletions(-) diff --git a/servers/slapd/ad.c b/servers/slapd/ad.c index 70052708fb..6451a23c0b 100644 --- a/servers/slapd/ad.c +++ b/servers/slapd/ad.c @@ -58,18 +58,18 @@ void ad_destroy( AttributeDescription *ad ) } } -/* Is there an AttributeDescription for this type that uses this language? */ -AttributeDescription * ad_find_lang( +/* Is there an AttributeDescription for this type that uses these tags? */ +AttributeDescription * ad_find_tags( AttributeType *type, - struct berval *lang ) + struct berval *tags ) { AttributeDescription *ad; ldap_pvt_thread_mutex_lock( &type->sat_ad_mutex ); for (ad = type->sat_ad; ad; ad=ad->ad_next) { - if (ad->ad_lang.bv_len == lang->bv_len && - !strcasecmp(ad->ad_lang.bv_val, lang->bv_val)) + if (ad->ad_tags.bv_len == tags->bv_len && + !strcasecmp(ad->ad_tags.bv_val, tags->bv_val)) break; } ldap_pvt_thread_mutex_unlock( &type->sat_ad_mutex ); @@ -115,14 +115,14 @@ int slap_bv2ad( AttributeDescription desc, *d2; char *name, *options; char *opt, *next; - int nlang; - int langlen; + int ntags; + int tagslen; /* hardcoded limits for speed */ -#define MAX_LANG_OPTIONS 128 - struct berval langs[MAX_LANG_OPTIONS+1]; -#define MAX_LANG_LEN 1024 - char langbuf[MAX_LANG_LEN]; +#define MAX_TAGGING_OPTIONS 128 + struct berval tags[MAX_TAGGING_OPTIONS+1]; +#define MAX_TAGS_LEN 1024 + char tagbuf[MAX_TAGS_LEN]; assert( ad != NULL ); assert( *ad == NULL ); /* temporary */ @@ -160,9 +160,9 @@ int slap_bv2ad( /* * parse options in place */ - nlang = 0; - memset( langs, 0, sizeof( langs )); - langlen = 0; + ntags = 0; + memset( tags, 0, sizeof( tags )); + tagslen = 0; for( opt=options; opt != NULL; opt=next ) { int optlen; @@ -196,10 +196,10 @@ int slap_bv2ad( int i; if( opt[optlen-1] == '-' ) { - desc.ad_flags |= SLAP_DESC_LANG_RANGE; + desc.ad_flags |= SLAP_DESC_TAG_RANGE; } - if( nlang >= MAX_LANG_OPTIONS ) { + if( ntags >= MAX_TAGGING_OPTIONS ) { *text = "too many tagging options"; return rtn; } @@ -208,38 +208,38 @@ int slap_bv2ad( * tags should be presented in sorted order, * so run the array in reverse. */ - for( i=nlang-1; i>=0; i-- ) { + for( i=ntags-1; i>=0; i-- ) { int rc; - rc = strncasecmp( opt, langs[i].bv_val, - (unsigned) optlen < langs[i].bv_len - ? optlen : langs[i].bv_len ); + rc = strncasecmp( opt, tags[i].bv_val, + (unsigned) optlen < tags[i].bv_len + ? optlen : tags[i].bv_len ); - if( rc == 0 && (unsigned)optlen == langs[i].bv_len ) { + if( rc == 0 && (unsigned)optlen == tags[i].bv_len ) { /* duplicate (ignore) */ goto done; } else if ( rc > 0 || - ( rc == 0 && (unsigned)optlen > langs[i].bv_len )) + ( rc == 0 && (unsigned)optlen > tags[i].bv_len )) { - AC_MEMCPY( &langs[i+1], &langs[i], - (nlang-i)*sizeof(struct berval) ); - langs[i].bv_val = opt; - langs[i].bv_len = optlen; + AC_MEMCPY( &tags[i+1], &tags[i], + (ntags-i)*sizeof(struct berval) ); + tags[i].bv_val = opt; + tags[i].bv_len = optlen; goto done; } } - if( nlang ) { - AC_MEMCPY( &langs[1], &langs[0], - nlang*sizeof(struct berval) ); + if( ntags ) { + AC_MEMCPY( &tags[1], &tags[0], + ntags*sizeof(struct berval) ); } - langs[0].bv_val = opt; - langs[0].bv_len = optlen; + tags[0].bv_val = opt; + tags[0].bv_len = optlen; done:; - langlen += optlen + 1; - nlang++; + tagslen += optlen + 1; + ntags++; } else { *text = "unrecognized option"; @@ -247,27 +247,27 @@ done:; } } - if( nlang > 0 ) { + if( ntags > 0 ) { int i; - if( langlen > MAX_LANG_LEN ) { + if( tagslen > MAX_TAGS_LEN ) { *text = "tagging options too long"; return rtn; } - desc.ad_lang.bv_val = langbuf; - langlen = 0; + desc.ad_tags.bv_val = tagbuf; + tagslen = 0; - for( i=0; iad_flags != desc.ad_flags ) { continue; } - if( d2->ad_lang.bv_len != desc.ad_lang.bv_len ) { + if( d2->ad_tags.bv_len != desc.ad_tags.bv_len ) { continue; } - if( d2->ad_lang.bv_len == 0 ) { + if( d2->ad_tags.bv_len == 0 ) { break; } - if( strncasecmp( d2->ad_lang.bv_val, desc.ad_lang.bv_val, - desc.ad_lang.bv_len ) == 0 ) + if( strncasecmp( d2->ad_tags.bv_val, desc.ad_tags.bv_val, + desc.ad_tags.bv_len ) == 0 ) { break; } @@ -296,12 +296,12 @@ done:; for (d2 = desc.ad_type->sat_ad; d2; d2=d2->ad_next) { if (d2->ad_flags != desc.ad_flags) continue; - if (d2->ad_lang.bv_len != desc.ad_lang.bv_len) + if (d2->ad_tags.bv_len != desc.ad_tags.bv_len) continue; - if (d2->ad_lang.bv_len == 0) + if (d2->ad_tags.bv_len == 0) break; - if (strncasecmp(d2->ad_lang.bv_val, desc.ad_lang.bv_val, - desc.ad_lang.bv_len) == 0) + if (strncasecmp(d2->ad_tags.bv_val, desc.ad_tags.bv_val, + desc.ad_tags.bv_len) == 0) break; } if (d2) { @@ -312,15 +312,15 @@ done:; /* Allocate a single contiguous block. If there are no * options, we just need space for the AttrDesc structure. * Otherwise, we need to tack on the full name length + - * options length, + maybe language options length again. + * options length, + maybe tagging options length again. */ - if (desc.ad_lang.bv_len || desc.ad_flags != SLAP_DESC_NONE) { + if (desc.ad_tags.bv_len || desc.ad_flags != SLAP_DESC_NONE) { dlen = desc.ad_type->sat_cname.bv_len + 1; - if (desc.ad_lang.bv_len) { - dlen += 1+desc.ad_lang.bv_len; + if (desc.ad_tags.bv_len) { + dlen += 1+desc.ad_tags.bv_len; } if( slap_ad_is_binary( &desc ) ) { - dlen += sizeof(";binary")+desc.ad_lang.bv_len; + dlen += sizeof(";binary")+desc.ad_tags.bv_len; } } @@ -328,11 +328,11 @@ done:; d2->ad_type = desc.ad_type; d2->ad_flags = desc.ad_flags; d2->ad_cname.bv_len = desc.ad_type->sat_cname.bv_len; - d2->ad_lang.bv_len = desc.ad_lang.bv_len; + d2->ad_tags.bv_len = desc.ad_tags.bv_len; if (dlen == 0) { d2->ad_cname.bv_val = d2->ad_type->sat_cname.bv_val; - d2->ad_lang.bv_val = NULL; + d2->ad_tags.bv_val = NULL; } else { char *cp, *op, *lp; int j; @@ -342,17 +342,17 @@ done:; if( slap_ad_is_binary( &desc ) ) { op = cp; lp = NULL; - if( desc.ad_lang.bv_len ) { - lp = desc.ad_lang.bv_val; + if( desc.ad_tags.bv_len ) { + lp = desc.ad_tags.bv_val; while( strncasecmp(lp, "binary", sizeof("binary")-1) < 0 && (lp = strchr( lp, ';' )) != NULL ) ++lp; - if( lp != desc.ad_lang.bv_val ) { + if( lp != desc.ad_tags.bv_val ) { *cp++ = ';'; j = (lp - ? lp - desc.ad_lang.bv_val - 1 - : strlen( desc.ad_lang.bv_val )); - strncpy(cp, desc.ad_lang.bv_val, j); + ? lp - desc.ad_tags.bv_val - 1 + : strlen( desc.ad_tags.bv_val )); + strncpy(cp, desc.ad_tags.bv_val, j); cp += j; } } @@ -364,21 +364,21 @@ done:; cp += strlen( cp ); } d2->ad_cname.bv_len = cp - d2->ad_cname.bv_val; - if( desc.ad_lang.bv_len ) + if( desc.ad_tags.bv_len ) ldap_pvt_str2lower(op); j = 1; } else { j = 0; } - if( desc.ad_lang.bv_len ) { + if( desc.ad_tags.bv_len ) { lp = d2->ad_cname.bv_val + d2->ad_cname.bv_len + j; if ( j == 0 ) *lp++ = ';'; - d2->ad_lang.bv_val = lp; - strcpy(lp, desc.ad_lang.bv_val); + d2->ad_tags.bv_val = lp; + strcpy(lp, desc.ad_tags.bv_val); ldap_pvt_str2lower(lp); if( j == 0 ) - d2->ad_cname.bv_len += 1 + desc.ad_lang.bv_len; + d2->ad_cname.bv_len += 1 + desc.ad_tags.bv_len; } } /* Add new desc to list. We always want the bare Desc with @@ -404,25 +404,25 @@ done:; return LDAP_SUCCESS; } -static int is_ad_sublang( - struct berval *sublangbv, - struct berval *suplangbv ) +static int is_ad_subtags( + struct berval *subtagsbv, + struct berval *suptagsbv ) { - const char *suplang, *supp, *supdelimp; - const char *sublang, *subp, *subdelimp; + const char *suptags, *supp, *supdelimp; + const char *subtags, *subp, *subdelimp; int suplen, sublen; - if( suplangbv->bv_len == 0 ) return 1; - if( sublangbv->bv_len == 0 ) return 0; + if( suptagsbv->bv_len == 0 ) return 1; + if( subtagsbv->bv_len == 0 ) return 0; - sublang =sublangbv->bv_val; - suplang =suplangbv->bv_val; + subtags =subtagsbv->bv_val; + suptags =suptagsbv->bv_val; - for( supp=suplang ; supp; supp=supdelimp ) { + for( supp=suptags ; supp; supp=supdelimp ) { supdelimp = strchrlen( supp, ';', &suplen ); if( supdelimp ) supdelimp++; - for( subp=sublang ; subp; subp=subdelimp ) { + for( subp=subtags ; subp; subp=subdelimp ) { subdelimp = strchrlen( subp, ';', &sublen ); if( subdelimp ) subdelimp++; @@ -454,13 +454,13 @@ int is_ad_subtype( } /* ensure sub does support all flags of super */ - lr = sub->ad_lang.bv_len ? SLAP_DESC_LANG_RANGE : 0; + lr = sub->ad_tags.bv_len ? SLAP_DESC_TAG_RANGE : 0; if(( super->ad_flags & ( sub->ad_flags | lr )) != super->ad_flags ) { return 0; } - /* check for language tags */ - if ( !is_ad_sublang( &sub->ad_lang, &super->ad_lang )) { + /* check for tagging options */ + if ( !is_ad_subtags( &sub->ad_tags, &super->ad_tags )) { return 0; } @@ -603,8 +603,8 @@ int slap_bv2undef_ad( bv->bv_len); desc->ad_flags = SLAP_DESC_NONE; - desc->ad_lang.bv_val = NULL; - desc->ad_lang.bv_len = 0; + desc->ad_tags.bv_val = NULL; + desc->ad_tags.bv_len = 0; desc->ad_cname.bv_len = bv->bv_len; desc->ad_cname.bv_val = (char *)(desc+1); diff --git a/servers/slapd/back-bdb/index.c b/servers/slapd/back-bdb/index.c index 5a7b2a49b0..f6e3c10361 100644 --- a/servers/slapd/back-bdb/index.c +++ b/servers/slapd/back-bdb/index.c @@ -36,14 +36,14 @@ static slap_mask_t index_mask( return mask; } - /* If there is a language tag, did we ever index the base + /* If there is a tagging option, did we ever index the base * type? If so, check for mask, otherwise it's not there. */ - if( slap_ad_is_lang( desc ) && desc != desc->ad_type->sat_ad ) { - /* has language tag */ + if( slap_ad_is_tagged( desc ) && desc != desc->ad_type->sat_ad ) { + /* has tagging option */ bdb_attr_mask( be->be_private, desc->ad_type->sat_ad, &mask ); - if ( mask && ( mask ^ SLAP_INDEX_NOLANG ) ) { + if ( mask && ( mask ^ SLAP_INDEX_NOTAGS ) ) { *atname = desc->ad_type->sat_cname; *dbname = desc->ad_type->sat_cname.bv_val; return mask; @@ -262,7 +262,7 @@ static int index_at_values( Backend *be, DB_TXN *txn, AttributeType *type, - struct berval *lang, + struct berval *tags, BerVarray vals, ID id, int op ) @@ -273,7 +273,7 @@ static int index_at_values( if( type->sat_sup ) { /* recurse */ rc = index_at_values( be, txn, - type->sat_sup, lang, + type->sat_sup, tags, vals, id, op ); if( rc ) return rc; @@ -293,12 +293,12 @@ static int index_at_values( if( rc ) return rc; } - if( lang->bv_len ) { + if( tags->bv_len ) { AttributeDescription *desc; mask = 0; - desc = ad_find_lang( type, lang ); + desc = ad_find_tags( type, tags ); if( desc ) { bdb_attr_mask( be->be_private, desc, &mask ); } @@ -329,7 +329,7 @@ int bdb_index_values( int rc; rc = index_at_values( be, txn, - desc->ad_type, &desc->ad_lang, + desc->ad_type, &desc->ad_tags, vals, id, op ); return rc; diff --git a/servers/slapd/back-ldbm/index.c b/servers/slapd/back-ldbm/index.c index f5078c0051..97ac8fc494 100644 --- a/servers/slapd/back-ldbm/index.c +++ b/servers/slapd/back-ldbm/index.c @@ -32,14 +32,14 @@ static slap_mask_t index_mask( return mask; } - /* If there is a language tag, did we ever index the base + /* If there is a tagging option, did we ever index the base * type? If so, check for mask, otherwise it's not there. */ - if( slap_ad_is_lang( desc ) && desc != desc->ad_type->sat_ad ) { - /* has language tag */ + if( slap_ad_is_tagged( desc ) && desc != desc->ad_type->sat_ad ) { + /* has tagging option */ attr_mask( be->be_private, desc->ad_type->sat_ad, &mask ); - if( mask && ( mask ^ SLAP_INDEX_NOLANG ) ) { + if( mask && ( mask ^ SLAP_INDEX_NOTAGS ) ) { *atname = desc->ad_type->sat_cname; *dbname = desc->ad_type->sat_cname.bv_val; return mask; @@ -230,7 +230,7 @@ static int indexer( static int index_at_values( Backend *be, AttributeType *type, - struct berval *lang, + struct berval *tags, BerVarray vals, ID id, int op ) @@ -240,7 +240,7 @@ static int index_at_values( if( type->sat_sup ) { /* recurse */ (void) index_at_values( be, - type->sat_sup, lang, + type->sat_sup, tags, vals, id, op ); } @@ -256,12 +256,12 @@ static int index_at_values( mask ); } - if( lang->bv_len ) { + if( tags->bv_len ) { AttributeDescription *desc; mask = 0; - desc = ad_find_lang(type, lang); + desc = ad_find_tags(type, tags); if( desc ) { attr_mask( be->be_private, desc, &mask ); } @@ -284,7 +284,7 @@ int index_values( int op ) { (void) index_at_values( be, - desc->ad_type, &desc->ad_lang, + desc->ad_type, &desc->ad_tags, vals, id, op ); return LDAP_SUCCESS; diff --git a/servers/slapd/index.c b/servers/slapd/index.c index a3b1032f5c..3b9ebe9033 100644 --- a/servers/slapd/index.c +++ b/servers/slapd/index.c @@ -29,8 +29,9 @@ int slap_str2index( const char *str, slap_mask_t *idx ) strcasecmp( str, "sub" ) == 0 ) { *idx = SLAP_INDEX_SUBSTR_DEFAULT; - } else if ( strcasecmp( str, "nolang" ) == 0 ) { - *idx = SLAP_INDEX_NOLANG; + } else if ( strcasecmp( str, "nolang" ) == 0 || /* backwards compat */ + strcasecmp( str, "notags" ) == 0 ) { + *idx = SLAP_INDEX_NOTAGS; } else if ( strcasecmp( str, "nosubtypes" ) == 0 ) { *idx = SLAP_INDEX_NOSUBTYPES; } else { diff --git a/servers/slapd/modify.c b/servers/slapd/modify.c index e9c7bd72b7..49c657d5f8 100644 --- a/servers/slapd/modify.c +++ b/servers/slapd/modify.c @@ -482,10 +482,10 @@ int slap_mods_check( return LDAP_UNDEFINED_TYPE; } - if( slap_ad_is_lang_range( ad )) { + if( slap_ad_is_tag_range( ad )) { /* attribute requires binary transfer */ snprintf( textbuf, textlen, - "%s: inappropriate use of language range option", + "%s: inappropriate use of tag range option", ml->sml_type.bv_val ); *text = textbuf; return LDAP_UNDEFINED_TYPE; diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index b58a61a57a..7a423335b2 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -78,9 +78,9 @@ LDAP_SLAPD_F (int) slap_bv2undef_ad LDAP_P(( AttributeDescription **ad, const char **text )); -LDAP_SLAPD_F (AttributeDescription *) ad_find_lang LDAP_P(( +LDAP_SLAPD_F (AttributeDescription *) ad_find_tags LDAP_P(( AttributeType *type, - struct berval *lang )); + struct berval *tags )); LDAP_SLAPD_F (AttributeName *) str2anlist LDAP_P(( AttributeName *an, char *str, const char *brkstr )); diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index 96040ed185..f441e585bc 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -206,7 +206,7 @@ typedef struct slap_ssf_set { #define SLAP_INDEX_FLAGS 0xF000UL #define SLAP_INDEX_NOSUBTYPES 0x1000UL /* don't use index w/ subtypes */ -#define SLAP_INDEX_NOLANG 0x2000UL /* don't use index w/ lang */ +#define SLAP_INDEX_NOTAGS 0x2000UL /* don't use index w/ tags */ /* * there is a single index for each attribute. these prefixes ensure @@ -627,20 +627,16 @@ typedef struct slap_content_rule { struct slap_content_rule *scr_next; } ContentRule; -/* - * Represents a recognized attribute description ( type + options ). - * Note: Tagging options/ranges are mislabeled "language options", - * because language options ("lang-") were implemented first. - */ +/* Represents a recognized attribute description ( type + options ). */ typedef struct slap_attr_desc { struct slap_attr_desc *ad_next; AttributeType *ad_type; /* attribute type, must be specified */ struct berval ad_cname; /* canonical name, must be specified */ - struct berval ad_lang; /* empty if no language tags */ + struct berval ad_tags; /* empty if no tagging options */ unsigned ad_flags; #define SLAP_DESC_NONE 0x00U #define SLAP_DESC_BINARY 0x01U -#define SLAP_DESC_LANG_RANGE 0x80U +#define SLAP_DESC_TAG_RANGE 0x80U } AttributeDescription; typedef struct slap_attr_name { @@ -649,9 +645,9 @@ typedef struct slap_attr_name { ObjectClass *an_oc; } AttributeName; -#define slap_ad_is_lang(ad) ( (ad)->ad_lang.bv_len != 0 ) -#define slap_ad_is_lang_range(ad) \ - ( ((ad)->ad_flags & SLAP_DESC_LANG_RANGE) ? 1 : 0 ) +#define slap_ad_is_tagged(ad) ( (ad)->ad_tags.bv_len != 0 ) +#define slap_ad_is_tag_range(ad) \ + ( ((ad)->ad_flags & SLAP_DESC_TAG_RANGE) ? 1 : 0 ) #define slap_ad_is_binary(ad) \ ( ((ad)->ad_flags & SLAP_DESC_BINARY) ? 1 : 0 ) -- 2.39.5