]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg: add API for determining operation type
authorJaben Carsey <jaben.carsey@intel.com>
Fri, 13 Dec 2013 00:13:59 +0000 (00:13 +0000)
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 13 Dec 2013 00:13:59 +0000 (00:13 +0000)
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

ShellPkg/Application/Shell/Shell.c
ShellPkg/Application/Shell/Shell.h

index 4e791af84c471ea7e3d8a45a79ef87c4c59fb94e..ef757dec0fa724f87b490cd45fde513fed3a16d1 100644 (file)
@@ -1527,6 +1527,67 @@ ShellSubstituteAliases(
   return (EFI_SUCCESS);\r
 }\r
 \r
+/**\r
+  Takes the Argv[0] part of the command line and determine the meaning of it.\r
+**/\r
+SHELL_OPERATION_TYPES\r
+EFIAPI\r
+GetOperationType(\r
+  IN CONST CHAR16 *CmdName\r
+  )\r
+{\r
+        CHAR16* FileWithPath;\r
+  CONST CHAR16* TempLocation;\r
+  CONST CHAR16* TempLocation2;\r
+\r
+  FileWithPath = NULL;\r
+  //\r
+  // test for an internal command.\r
+  //\r
+  if (ShellCommandIsCommandOnList(CmdName)) {\r
+    return (INTERNAL_COMMAND);\r
+  }\r
+\r
+  //\r
+  // Test for file system change request.  anything ending with : and cant have spaces.\r
+  //\r
+  if (CmdName[(StrLen(CmdName)-1)] == L':') {\r
+    if (StrStr(CmdName, L" ") != NULL) {\r
+      return (UNKNOWN_INVALID);\r
+    }\r
+    return (FILE_SYS_CHANGE);\r
+  }\r
+\r
+  //\r
+  // Test for a file\r
+  //\r
+  if ((FileWithPath = ShellFindFilePathEx(CmdName, mExecutableExtensions)) != NULL) {\r
+    //\r
+    // See if that file has a script file extension\r
+    //\r
+    if (StrLen(FileWithPath) > 4) {\r
+      TempLocation = FileWithPath+StrLen(FileWithPath)-4;\r
+      TempLocation2 = mScriptExtension;\r
+      if (StringNoCaseCompare((VOID*)(&TempLocation), (VOID*)(&TempLocation2)) == 0) {\r
+        SHELL_FREE_NON_NULL(FileWithPath);\r
+        return (SCRIPT_FILE_NAME);\r
+      }\r
+    }\r
+\r
+    //\r
+    // Was a file, but not a script.  we treat this as an application.\r
+    //\r
+    SHELL_FREE_NON_NULL(FileWithPath);\r
+    return (EFI_APPLICATION);\r
+  }\r
+  \r
+  SHELL_FREE_NON_NULL(FileWithPath);\r
+  //\r
+  // No clue what this is... return invalid flag...\r
+  //\r
+  return (UNKNOWN_INVALID);\r
+}\r
+\r
 /**\r
   Function will process and run a command line.\r
 \r
index 2ed05b8a1c566f23a9793dc9071259c5d2562ac1..4943fd19cbcb2b90fea35feb028cf2f60702ed33 100644 (file)
@@ -124,6 +124,14 @@ typedef struct {
 \r
 extern SHELL_INFO ShellInfoObject;\r
 \r
+typedef enum {\r
+  INTERNAL_COMMAND,\r
+  SCRIPT_FILE_NAME,\r
+  EFI_APPLICATION,\r
+  FILE_SYS_CHANGE,\r
+  UNKNOWN_INVALID\r
+} SHELL_OPERATION_TYPES;\r
+\r
 /**\r
   Sets all the alias' that were registered with the ShellCommandLib library.\r
 \r