~ubuntu-branches/ubuntu/maverick/openldap/maverick-proposed

« back to all changes in this revision

Viewing changes to servers/slapd/dn.c

  • Committer: Bazaar Package Importer
  • Author(s): Mathias Gug
  • Date: 2009-09-07 13:41:10 UTC
  • mto: This revision was merged to the branch mainline in revision 19.
  • Revision ID: james.westby@ubuntu.com-20090907134110-jsdrvn0atu1fex4m
Tags: upstream-2.4.18
ImportĀ upstreamĀ versionĀ 2.4.18

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* dn.c - routines for dealing with distinguished names */
2
 
/* $OpenLDAP: pkg/ldap/servers/slapd/dn.c,v 1.182.2.12 2009/04/28 00:52:05 quanah Exp $ */
 
2
/* $OpenLDAP: pkg/ldap/servers/slapd/dn.c,v 1.182.2.13 2009/08/12 23:38:56 quanah Exp $ */
3
3
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4
4
 *
5
5
 * Copyright 1998-2009 The OpenLDAP Foundation.
1197
1197
        return( strcmp( dn->bv_val + d, suffix->bv_val ) == 0 );
1198
1198
}
1199
1199
 
 
1200
/*
 
1201
 * In place; assumes:
 
1202
 * - ndn is normalized
 
1203
 * - nbase is normalized
 
1204
 * - dnIsSuffix( ndn, nbase ) == TRUE
 
1205
 * - LDAP_SCOPE_DEFAULT == LDAP_SCOPE_SUBTREE
 
1206
 */
 
1207
int
 
1208
dnIsWithinScope( struct berval *ndn, struct berval *nbase, int scope )
 
1209
{
 
1210
        assert( ndn != NULL );
 
1211
        assert( nbase != NULL );
 
1212
        assert( !BER_BVISNULL( ndn ) );
 
1213
        assert( !BER_BVISNULL( nbase ) );
 
1214
 
 
1215
        switch ( scope ) {
 
1216
        case LDAP_SCOPE_DEFAULT:
 
1217
        case LDAP_SCOPE_SUBTREE:
 
1218
                break;
 
1219
 
 
1220
        case LDAP_SCOPE_BASE:
 
1221
                if ( ndn->bv_len != nbase->bv_len ) {
 
1222
                        return 0;
 
1223
                }
 
1224
                break;
 
1225
 
 
1226
        case LDAP_SCOPE_ONELEVEL: {
 
1227
                struct berval pndn;
 
1228
                dnParent( ndn, &pndn );
 
1229
                if ( pndn.bv_len != nbase->bv_len ) {
 
1230
                        return 0;
 
1231
                }
 
1232
                } break;
 
1233
 
 
1234
        case LDAP_SCOPE_SUBORDINATE:
 
1235
                if ( ndn->bv_len == nbase->bv_len ) {
 
1236
                        return 0;
 
1237
                }
 
1238
                break;
 
1239
 
 
1240
        /* unknown scope */
 
1241
        default:
 
1242
                return -1;
 
1243
        }
 
1244
 
 
1245
        return 1;
 
1246
}
 
1247
 
 
1248
/*
 
1249
 * In place; assumes:
 
1250
 * - ndn is normalized
 
1251
 * - nbase is normalized
 
1252
 * - LDAP_SCOPE_DEFAULT == LDAP_SCOPE_SUBTREE
 
1253
 */
 
1254
int
 
1255
dnIsSuffixScope( struct berval *ndn, struct berval *nbase, int scope )
 
1256
{
 
1257
        if ( !dnIsSuffix( ndn, nbase ) ) {
 
1258
                return 0;
 
1259
        }
 
1260
 
 
1261
        return dnIsWithinScope( ndn, nbase, scope );
 
1262
}
 
1263
 
1200
1264
int
1201
1265
dnIsOneLevelRDN( struct berval *rdn )
1202
1266
{