Internal function to run a command line with pipe usage. @param[in] CmdLine The pointer to the command line. @param[in] StdIn The pointer to the Standard input. @param[in] StdOut The pointer to the Standard output. @retval EFI_SUCCESS The split command is executed successfully. @retval other Some error occurs when executing the split com
| 1759 | @retval other Some error occurs when executing the split command. |
| 1760 | **/ |
| 1761 | EFI_STATUS |
| 1762 | RunSplitCommand( |
| 1763 | IN CONST CHAR16 *CmdLine, |
| 1764 | IN SHELL_FILE_HANDLE *StdIn, |
| 1765 | IN SHELL_FILE_HANDLE *StdOut |
| 1766 | ) |
| 1767 | { |
| 1768 | EFI_STATUS Status; |
| 1769 | CHAR16 *NextCommandLine; |
| 1770 | CHAR16 *OurCommandLine; |
| 1771 | UINTN Size1; |
| 1772 | UINTN Size2; |
| 1773 | SPLIT_LIST *Split; |
| 1774 | SHELL_FILE_HANDLE *TempFileHandle; |
| 1775 | BOOLEAN Unicode; |
| 1776 | |
| 1777 | // ASSERT(StdOut == NULL); |
| 1778 | |
| 1779 | // ASSERT(StrStr(CmdLine, L"|") != NULL); |
| 1780 | if (!StrStr(CmdLine, L"|")) { |
| 1781 | return EFI_INVALID_PARAMETER; |
| 1782 | } |
| 1783 | |
| 1784 | // ASSERT(StrStr(CmdLine, L"|") != NULL); |
| 1785 | |
| 1786 | Status = EFI_SUCCESS; |
| 1787 | NextCommandLine = NULL; |
| 1788 | OurCommandLine = NULL; |
| 1789 | Size1 = 0; |
| 1790 | Size2 = 0; |
| 1791 | |
| 1792 | NextCommandLine = StrnCatGrow(&NextCommandLine, &Size1, StrStr(CmdLine, L"|")+1, 0); |
| 1793 | OurCommandLine = StrnCatGrow(&OurCommandLine , &Size2, CmdLine , StrStr(CmdLine, L"|") - CmdLine); |
| 1794 | |
| 1795 | if (NextCommandLine == NULL || OurCommandLine == NULL) { |
| 1796 | SHELL_FREE_NON_NULL(OurCommandLine); |
| 1797 | SHELL_FREE_NON_NULL(NextCommandLine); |
| 1798 | return (EFI_OUT_OF_RESOURCES); |
| 1799 | } else if (StrStr(OurCommandLine, L"|") != NULL || Size1 == 0 || Size2 == 0) { |
| 1800 | SHELL_FREE_NON_NULL(OurCommandLine); |
| 1801 | SHELL_FREE_NON_NULL(NextCommandLine); |
| 1802 | return (EFI_INVALID_PARAMETER); |
| 1803 | } else if (NextCommandLine[0] == L'a' && |
| 1804 | (NextCommandLine[1] == L' ' || NextCommandLine[1] == CHAR_NULL) |
| 1805 | ){ |
| 1806 | CopyMem(NextCommandLine, NextCommandLine+1, StrSize(NextCommandLine) - sizeof(NextCommandLine[0])); |
| 1807 | while (NextCommandLine[0] == L' ') { |
| 1808 | CopyMem(NextCommandLine, NextCommandLine+1, StrSize(NextCommandLine) - sizeof(NextCommandLine[0])); |
| 1809 | } |
| 1810 | if (NextCommandLine[0] == CHAR_NULL) { |
| 1811 | SHELL_FREE_NON_NULL(OurCommandLine); |
| 1812 | SHELL_FREE_NON_NULL(NextCommandLine); |
| 1813 | return (EFI_INVALID_PARAMETER); |
| 1814 | } |
| 1815 | Unicode = FALSE; |
| 1816 | } else { |
| 1817 | Unicode = TRUE; |
| 1818 | } |
no test coverage detected