Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
OpenLDAP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
James Lowden
OpenLDAP
Commits
46d6f994
Commit
46d6f994
authored
12 years ago
by
Howard Chu
Committed by
Quanah Gibson-Mount
12 years ago
Browse files
Options
Downloads
Patches
Plain Diff
ITS#7473 Add mdb_dn2id_walk() to walk subtree
Non-recursive tree walker.
parent
5d61e28b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
servers/slapd/back-mdb/dn2id.c
+88
-0
88 additions, 0 deletions
servers/slapd/back-mdb/dn2id.c
servers/slapd/back-mdb/proto-mdb.h
+4
-0
4 additions, 0 deletions
servers/slapd/back-mdb/proto-mdb.h
with
92 additions
and
0 deletions
servers/slapd/back-mdb/dn2id.c
+
88
−
0
View file @
46d6f994
...
...
@@ -756,3 +756,91 @@ mdb_idscopes(
}
return
MDB_SUCCESS
;
}
int
mdb_dn2id_walk
(
Operation
*
op
,
IdScopes
*
isc
)
{
MDB_val
key
,
data
;
diskNode
*
d
;
char
*
ptr
;
int
rc
,
n
;
ID
nsubs
;
if
(
!
isc
->
numrdns
)
{
key
.
mv_data
=
&
isc
->
id
;
key
.
mv_size
=
sizeof
(
ID
);
rc
=
mdb_cursor_get
(
isc
->
mc
,
&
key
,
&
data
,
MDB_SET
);
isc
->
scopes
[
0
].
mid
=
isc
->
id
;
isc
->
numrdns
++
;
isc
->
nscope
=
0
;
/* skip base if not a subtree walk */
if
(
op
->
ors_scope
==
LDAP_SCOPE_SUBTREE
||
op
->
ors_scope
==
LDAP_SCOPE_BASE
)
return
rc
;
}
if
(
op
->
ors_scope
==
LDAP_SCOPE_BASE
)
return
MDB_NOTFOUND
;
for
(;;)
{
/* Get next sibling */
rc
=
mdb_cursor_get
(
isc
->
mc
,
&
key
,
&
data
,
MDB_NEXT_DUP
);
if
(
!
rc
)
{
ptr
=
data
.
mv_data
+
data
.
mv_size
-
2
*
sizeof
(
ID
);
d
=
data
.
mv_data
;
memcpy
(
&
isc
->
id
,
ptr
,
sizeof
(
ID
));
/* If we're pushing down, see if there's any children to find */
if
(
isc
->
nscope
)
{
ptr
+=
sizeof
(
ID
);
memcpy
(
&
nsubs
,
ptr
,
sizeof
(
ID
));
/* No children, go to next sibling */
if
(
nsubs
<
2
)
continue
;
}
n
=
isc
->
numrdns
;
isc
->
scopes
[
n
].
mid
=
isc
->
id
;
n
--
;
isc
->
nrdns
[
n
].
bv_len
=
((
d
->
nrdnlen
[
0
]
&
0x7f
)
<<
8
)
|
d
->
nrdnlen
[
1
];
isc
->
nrdns
[
n
].
bv_val
=
d
->
nrdn
;
isc
->
rdns
[
n
].
bv_val
=
d
->
nrdn
+
isc
->
nrdns
[
n
].
bv_len
+
1
;
isc
->
rdns
[
n
].
bv_len
=
data
.
mv_size
-
sizeof
(
diskNode
)
-
isc
->
nrdns
[
n
].
bv_len
-
sizeof
(
ID
);
/* return this ID to caller */
if
(
!
isc
->
nscope
)
break
;
/* push down to child */
key
.
mv_data
=
&
isc
->
id
;
mdb_cursor_get
(
isc
->
mc
,
&
key
,
&
data
,
MDB_SET
);
isc
->
nscope
=
0
;
isc
->
numrdns
++
;
continue
;
}
else
if
(
rc
==
MDB_NOTFOUND
)
{
if
(
!
isc
->
nscope
&&
op
->
ors_scope
!=
LDAP_SCOPE_ONELEVEL
)
{
/* reset to first dup */
mdb_cursor_get
(
isc
->
mc
,
&
key
,
NULL
,
MDB_GET_CURRENT
);
mdb_cursor_get
(
isc
->
mc
,
&
key
,
&
data
,
MDB_SET
);
isc
->
nscope
=
1
;
continue
;
}
else
{
isc
->
numrdns
--
;
/* stack is empty? */
if
(
!
isc
->
numrdns
)
break
;
/* pop up to prev node */
n
=
isc
->
numrdns
-
1
;
key
.
mv_data
=
&
isc
->
scopes
[
n
].
mid
;
key
.
mv_size
=
sizeof
(
ID
);
data
.
mv_data
=
isc
->
nrdns
[
n
].
bv_val
-
2
;
mdb_cursor_get
(
isc
->
mc
,
&
key
,
&
data
,
MDB_GET_BOTH
);
continue
;
}
}
else
{
break
;
}
}
return
rc
;
}
This diff is collapsed.
Click to expand it.
servers/slapd/back-mdb/proto-mdb.h
+
4
−
0
View file @
46d6f994
...
...
@@ -137,6 +137,10 @@ int mdb_idscopes(
Operation
*
op
,
struct
IdScopes
*
isc
);
int
mdb_dn2id_walk
(
Operation
*
op
,
struct
IdScopes
*
isc
);
MDB_cmp_func
mdb_dup_compare
;
/*
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment