MCPcopy Create free account
hub / github.com/CloverHackyColor/CloverBootloader / DoHelpUpdate

Function DoHelpUpdate

ShellPkg/Application/Shell/Shell.c:2237–2283  ·  view source on GitHub ↗

Reprocess the command line to direct all -? to the help command. if found, will add "help" as argv[0], and move the rest later. @param[in,out] CmdLine pointer to the command line to update **/

Source from the content-addressed store, hash-verified

2235 @param[in,out] CmdLine pointer to the command line to update
2236**/
2237EFI_STATUS
2238DoHelpUpdate(
2239 IN OUT CHAR16 **CmdLine
2240 )
2241{
2242 CHAR16 *CurrentParameter;
2243 CHAR16 *Walker;
2244 CHAR16 *NewCommandLine;
2245 EFI_STATUS Status;
2246 UINTN NewCmdLineSize;
2247
2248 Status = EFI_SUCCESS;
2249
2250 CurrentParameter = AllocateZeroPool(StrSize(*CmdLine));
2251 if (CurrentParameter == NULL) {
2252 return (EFI_OUT_OF_RESOURCES);
2253 }
2254
2255 Walker = *CmdLine;
2256 while(Walker != NULL && *Walker != CHAR_NULL) {
2257 if (!EFI_ERROR(GetNextParameter(&Walker, &CurrentParameter, StrSize(*CmdLine), TRUE))) {
2258 if (StrStr(CurrentParameter, L"-?") == CurrentParameter) {
2259 CurrentParameter[0] = L' ';
2260 CurrentParameter[1] = L' ';
2261 NewCmdLineSize = StrSize(L"help ") + StrSize(*CmdLine);
2262 NewCommandLine = AllocateZeroPool(NewCmdLineSize);
2263 if (NewCommandLine == NULL) {
2264 Status = EFI_OUT_OF_RESOURCES;
2265 break;
2266 }
2267
2268 //
2269 // We know the space is sufficient since we just calculated it.
2270 //
2271 StrnCpyS(NewCommandLine, NewCmdLineSize/sizeof(CHAR16), L"help ", 5);
2272 StrnCatS(NewCommandLine, NewCmdLineSize/sizeof(CHAR16), *CmdLine, StrLen(*CmdLine));
2273 SHELL_FREE_NON_NULL(*CmdLine);
2274 *CmdLine = NewCommandLine;
2275 break;
2276 }
2277 }
2278 }
2279
2280 SHELL_FREE_NON_NULL(CurrentParameter);
2281
2282 return (Status);
2283}
2284
2285/**
2286 Function to update the shell variable "lasterror".

Callers 1

Calls 7

GetNextParameterFunction · 0.85
StrStrFunction · 0.85
StrnCpySFunction · 0.85
StrnCatSFunction · 0.85
AllocateZeroPoolFunction · 0.50
StrSizeFunction · 0.50
StrLenFunction · 0.50

Tested by

no test coverage detected