+void btr_splice_out_node(struct btr_node *btrn)
+{
+ struct btr_node *ch, *tmp;
+
+ assert(btrn);
+ PARA_NOTICE_LOG("splicing out %s\n", btrn->name);
+ btr_pushdown(btrn);
+ if (btrn->parent)
+ list_del(&btrn->node);
+ FOR_EACH_CHILD_SAFE(ch, tmp, btrn) {
+ PARA_INFO_LOG("parent(%s): %s\n", ch->name,
+ btrn->parent? btrn->parent->name : "NULL");
+ ch->parent = btrn->parent;
+ if (btrn->parent)
+ list_move(&ch->node, &btrn->parent->children);
+ }
+ assert(list_empty(&btrn->children));
+ free(btrn->name);
+ free(btrn);
+}
+
+/**
+ * Return the size of the largest input queue.
+ *
+ * Iterates over all children of the given node.
+ */
+size_t btr_bytes_pending(struct btr_node *btrn)
+{
+ size_t max_size = 0;
+ struct btr_node *ch;
+
+ FOR_EACH_CHILD(ch, btrn) {
+ size_t size = btr_get_input_queue_size(ch);
+ max_size = PARA_MAX(max_size, size);
+ }
+ return max_size;
+}
+
+int btr_exec(struct btr_node *btrn, const char *command, char **value_result)
+{
+ if (!btrn)
+ return -ERRNO_TO_PARA_ERROR(EINVAL);
+ if (!btrn->execute)
+ return -ERRNO_TO_PARA_ERROR(ENOTSUP);
+ return btrn->execute(btrn, command, value_result);
+}
+
+int btr_exec_up(struct btr_node *btrn, const char *command, char **value_result)
+{
+ int ret;
+
+ for (; btrn; btrn = btrn->parent) {
+ struct btr_node *parent = btrn->parent;
+ if (!parent)
+ return -ERRNO_TO_PARA_ERROR(ENOTSUP);
+ if (!parent->execute)
+ continue;
+ PARA_INFO_LOG("parent: %s, cmd: %s\n", parent->name, command);
+ ret = parent->execute(parent, command, value_result);
+ if (ret == -ERRNO_TO_PARA_ERROR(ENOTSUP))
+ continue;
+ if (ret < 0)
+ return ret;
+ if (value_result && *value_result)
+ PARA_NOTICE_LOG("%s(%s): %s\n", command, parent->name,
+ *value_result);
+ return 1;
+ }
+ return -ERRNO_TO_PARA_ERROR(ENOTSUP);
+}
+
+void *btr_context(struct btr_node *btrn)