/** function to add each command name from the linked list to the string list. the resultant list is a double NULL terminated list of NULL terminated strings. @param[in,out] DestList double pointer to the list. may be NULL. @param[in,out] DestSize pointer to the size of list. may be 0, if DestList is NULL. @param[in] SourceList the double linked list of commands. @retval EFI_SUCCESS the operation was successful. **/ EFI_STATUS CopyListOfCommandNames( IN OUT CHAR16 **DestList, IN OUT UINTN *DestSize, IN CONST COMMAND_LIST *SourceList ) { CONST COMMAND_LIST *Node; for ( Node = (COMMAND_LIST*)GetFirstNode(&SourceList->Link) ; SourceList != NULL && !IsListEmpty(&SourceList->Link) && !IsNull(&SourceList->Link, &Node->Link) ; Node = (COMMAND_LIST*)GetNextNode(&SourceList->Link, &Node->Link) ) { LexicalInsertIntoList(DestList, DestSize, Node->CommandString); } return (EFI_SUCCESS); }
/** function to add each dynamic command name to the string list. the resultant list is a double NULL terminated list of NULL terminated strings. @param[in,out] DestList double pointer to the list. may be NULL. @param[in,out] DestSize pointer to the size of list. may be 0, if DestList is NULL. @retval EFI_SUCCESS the operation was successful. @return an error from HandleProtocol **/ STATIC EFI_STATUS EFIAPI CopyListOfCommandNamesWithDynamic( IN OUT CHAR16** DestList, IN OUT UINTN *DestSize ) { EFI_HANDLE *CommandHandleList; CONST EFI_HANDLE *NextCommand; EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *DynamicCommand; EFI_STATUS Status; CommandHandleList = GetHandleListByProtocol(&gEfiShellDynamicCommandProtocolGuid); // // If there are none, then just return with success // if (CommandHandleList == NULL) { return (EFI_SUCCESS); } Status = EFI_SUCCESS; // // Append those to the list. // for (NextCommand = CommandHandleList ; *NextCommand != NULL && !EFI_ERROR(Status) ; NextCommand++) { Status = gBS->HandleProtocol( *NextCommand, &gEfiShellDynamicCommandProtocolGuid, (VOID **)&DynamicCommand ); if (EFI_ERROR(Status)) { continue; } Status = LexicalInsertIntoList(DestList, DestSize, DynamicCommand->CommandName); } SHELL_FREE_NON_NULL(CommandHandleList); return (Status); }