Extract node lookup given mib input
This commit is contained in:
parent
3a627b9674
commit
6ab181d2b7
43
src/ctl.c
43
src/ctl.c
@ -1468,21 +1468,13 @@ label_return:
|
|||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static int
|
||||||
ctl_bymib(tsd_t *tsd, const size_t *mib, size_t miblen, void *oldp,
|
ctl_lookupbymib(tsdn_t *tsdn, const ctl_named_node_t **ending_nodep,
|
||||||
size_t *oldlenp, void *newp, size_t newlen) {
|
const size_t *mib, size_t miblen) {
|
||||||
int ret;
|
int ret;
|
||||||
const ctl_named_node_t *node;
|
|
||||||
size_t i;
|
|
||||||
|
|
||||||
if (!ctl_initialized && ctl_init(tsd)) {
|
const ctl_named_node_t *node = super_root_node;
|
||||||
ret = EAGAIN;
|
for (size_t i = 0; i < miblen; i++) {
|
||||||
goto label_return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Iterate down the tree. */
|
|
||||||
node = super_root_node;
|
|
||||||
for (i = 0; i < miblen; i++) {
|
|
||||||
assert(node);
|
assert(node);
|
||||||
assert(node->nchildren > 0);
|
assert(node->nchildren > 0);
|
||||||
if (ctl_named_node(node->children) != NULL) {
|
if (ctl_named_node(node->children) != NULL) {
|
||||||
@ -1497,13 +1489,36 @@ ctl_bymib(tsd_t *tsd, const size_t *mib, size_t miblen, void *oldp,
|
|||||||
|
|
||||||
/* Indexed element. */
|
/* Indexed element. */
|
||||||
inode = ctl_indexed_node(node->children);
|
inode = ctl_indexed_node(node->children);
|
||||||
node = inode->index(tsd_tsdn(tsd), mib, miblen, mib[i]);
|
node = inode->index(tsdn, mib, miblen, mib[i]);
|
||||||
if (node == NULL) {
|
if (node == NULL) {
|
||||||
ret = ENOENT;
|
ret = ENOENT;
|
||||||
goto label_return;
|
goto label_return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
assert(ending_nodep != NULL);
|
||||||
|
*ending_nodep = node;
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
|
label_return:
|
||||||
|
return(ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
ctl_bymib(tsd_t *tsd, const size_t *mib, size_t miblen, void *oldp,
|
||||||
|
size_t *oldlenp, void *newp, size_t newlen) {
|
||||||
|
int ret;
|
||||||
|
const ctl_named_node_t *node;
|
||||||
|
|
||||||
|
if (!ctl_initialized && ctl_init(tsd)) {
|
||||||
|
ret = EAGAIN;
|
||||||
|
goto label_return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = ctl_lookupbymib(tsd_tsdn(tsd), &node, mib, miblen);
|
||||||
|
if (ret != 0) {
|
||||||
|
goto label_return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Call the ctl function. */
|
/* Call the ctl function. */
|
||||||
if (node && node->ctl) {
|
if (node && node->ctl) {
|
||||||
|
Loading…
Reference in New Issue
Block a user