ShellPkg/DP: Add more check for input parameters
[mirror_edk2.git] / ShellPkg / DynamicCommand / TftpDynamicCommand / TftpApp.c
1 /** @file
2 Entrypoint of "tftp" shell standalone application.
3
4 Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved. <BR>
5 Copyright (c) 2015, ARM Ltd. All rights reserved.<BR>
6
7 This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
11
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14
15 **/
16 #include "Tftp.h"
17
18 //
19 // String token ID of help message text.
20 // Shell supports to find help message in the resource section of an application image if
21 // .MAN file is not found. This global variable is added to make build tool recognizes
22 // that the help string is consumed by user and then build tool will add the string into
23 // the resource section. Thus the application can use '-?' option to show help message in
24 // Shell.
25 //
26 GLOBAL_REMOVE_IF_UNREFERENCED EFI_STRING_ID mStringHelpTokenId = STRING_TOKEN (STR_GET_HELP_TFTP);
27
28 /**
29 Entry point of Tftp standalone application.
30
31 @param ImageHandle The image handle of the process.
32 @param SystemTable The EFI System Table pointer.
33
34 @retval EFI_SUCCESS Tftp command is executed sucessfully.
35 @retval EFI_ABORTED HII package was failed to initialize.
36 @retval others Other errors when executing tftp command.
37 **/
38 EFI_STATUS
39 EFIAPI
40 TftpAppInitialize (
41 IN EFI_HANDLE ImageHandle,
42 IN EFI_SYSTEM_TABLE *SystemTable
43 )
44 {
45 EFI_STATUS Status;
46 mTftpHiiHandle = InitializeHiiPackage (ImageHandle);
47 if (mTftpHiiHandle == NULL) {
48 return EFI_ABORTED;
49 }
50
51 Status = (EFI_STATUS)RunTftp (ImageHandle, SystemTable);
52 HiiRemovePackages (mTftpHiiHandle);
53 return Status;
54 }