- for (struct command *cc = head; cc; cc = cc->next) {
- if (strcmp(cc->name, name) == 0)
- return cc;
- }
- return NULL;
-}
-
-struct command *command_find_in_context(struct command_context *cmd_ctx,
- const char *name)
-{
- return command_find(cmd_ctx->commands, name);
-}
-struct command *command_find_in_parent(struct command *parent,
- const char *name)
-{
- return command_find(parent->children, name);
-}
-
-/**
- * Add the command into the linked list, sorted by name.
- * @param head Address to head of command list pointer, which may be
- * updated if @c c gets inserted at the beginning of the list.
- * @param c The command to add to the list pointed to by @c head.
- */
-static void command_add_child(struct command **head, struct command *c)
-{
- assert(head);
- if (NULL == *head) {
- *head = c;
- return;
- }
-
- while ((*head)->next && (strcmp(c->name, (*head)->name) > 0))
- head = &(*head)->next;
-
- if (strcmp(c->name, (*head)->name) > 0) {
- c->next = (*head)->next;
- (*head)->next = c;
- } else {
- c->next = *head;
- *head = c;
- }
-}
-
-static struct command **command_list_for_parent(
- struct command_context *cmd_ctx, struct command *parent)
-{
- return parent ? &parent->children : &cmd_ctx->commands;
-}
-
-static void command_free(struct command *c)
-{
- /** @todo if command has a handler, unregister its jim command! */