diff options
author | Jaben Carsey <jaben.carsey@intel.com> | 2013-12-13 00:13:59 +0000 |
---|---|---|
committer | jcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524> | 2013-12-13 00:13:59 +0000 |
commit | 6ba2921da3c0b7db303b6db44810158a1fefd737 (patch) | |
tree | 30be05a0f68494a21c9e8fb3d6eb009f42b03fee /ShellPkg | |
parent | 1ef61d039062f551d47ce009c4b5df9f5324f3ea (diff) | |
download | edk2-platforms-6ba2921da3c0b7db303b6db44810158a1fefd737.tar.xz |
ShellPkg: add API for determining operation type
There are no callers for this new API yet. They will be added in the next commits.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Erik Bjorge <erik.c.bjorge@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14975 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ShellPkg')
-rw-r--r-- | ShellPkg/Application/Shell/Shell.c | 61 | ||||
-rw-r--r-- | ShellPkg/Application/Shell/Shell.h | 8 |
2 files changed, 69 insertions, 0 deletions
diff --git a/ShellPkg/Application/Shell/Shell.c b/ShellPkg/Application/Shell/Shell.c index 4e791af84c..ef757dec0f 100644 --- a/ShellPkg/Application/Shell/Shell.c +++ b/ShellPkg/Application/Shell/Shell.c @@ -1528,6 +1528,67 @@ ShellSubstituteAliases( }
/**
+ Takes the Argv[0] part of the command line and determine the meaning of it.
+**/
+SHELL_OPERATION_TYPES
+EFIAPI
+GetOperationType(
+ IN CONST CHAR16 *CmdName
+ )
+{
+ CHAR16* FileWithPath;
+ CONST CHAR16* TempLocation;
+ CONST CHAR16* TempLocation2;
+
+ FileWithPath = NULL;
+ //
+ // test for an internal command.
+ //
+ if (ShellCommandIsCommandOnList(CmdName)) {
+ return (INTERNAL_COMMAND);
+ }
+
+ //
+ // Test for file system change request. anything ending with : and cant have spaces.
+ //
+ if (CmdName[(StrLen(CmdName)-1)] == L':') {
+ if (StrStr(CmdName, L" ") != NULL) {
+ return (UNKNOWN_INVALID);
+ }
+ return (FILE_SYS_CHANGE);
+ }
+
+ //
+ // Test for a file
+ //
+ if ((FileWithPath = ShellFindFilePathEx(CmdName, mExecutableExtensions)) != NULL) {
+ //
+ // See if that file has a script file extension
+ //
+ if (StrLen(FileWithPath) > 4) {
+ TempLocation = FileWithPath+StrLen(FileWithPath)-4;
+ TempLocation2 = mScriptExtension;
+ if (StringNoCaseCompare((VOID*)(&TempLocation), (VOID*)(&TempLocation2)) == 0) {
+ SHELL_FREE_NON_NULL(FileWithPath);
+ return (SCRIPT_FILE_NAME);
+ }
+ }
+
+ //
+ // Was a file, but not a script. we treat this as an application.
+ //
+ SHELL_FREE_NON_NULL(FileWithPath);
+ return (EFI_APPLICATION);
+ }
+
+ SHELL_FREE_NON_NULL(FileWithPath);
+ //
+ // No clue what this is... return invalid flag...
+ //
+ return (UNKNOWN_INVALID);
+}
+
+/**
Function will process and run a command line.
This will determine if the command line represents an internal shell
diff --git a/ShellPkg/Application/Shell/Shell.h b/ShellPkg/Application/Shell/Shell.h index 2ed05b8a1c..4943fd19cb 100644 --- a/ShellPkg/Application/Shell/Shell.h +++ b/ShellPkg/Application/Shell/Shell.h @@ -124,6 +124,14 @@ typedef struct { extern SHELL_INFO ShellInfoObject;
+typedef enum {
+ INTERNAL_COMMAND,
+ SCRIPT_FILE_NAME,
+ EFI_APPLICATION,
+ FILE_SYS_CHANGE,
+ UNKNOWN_INVALID
+} SHELL_OPERATION_TYPES;
+
/**
Sets all the alias' that were registered with the ShellCommandLib library.
|