]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellLevel2CommandsLib/TimeDate.c
ShellPkg: Clean up source files
[mirror_edk2.git] / ShellPkg / Library / UefiShellLevel2CommandsLib / TimeDate.c
index 25dc6ffb640f889a87b9b5d4a13e4134ee01ebff..0e948e3b0a966d6eab0ac0e9314ce676e3fc7334 100644 (file)
@@ -1,8 +1,8 @@
 /** @file\r
   Main file for time, timezone, and date shell level 2 and shell level 3 functions.\r
 \r
-  (C) Copyright 2012-2014, Hewlett-Packard Development Company, L.P.\r
-  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
+  (C) Copyright 2012-2015 Hewlett-Packard Development Company, L.P.<BR>\r
+  Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -28,7 +28,6 @@
   @retval FALSE   String is invalid.\r
 **/\r
 BOOLEAN\r
-EFIAPI\r
 InternalIsTimeLikeString (\r
   IN CONST CHAR16   *String,\r
   IN CONST CHAR16   Char,\r
@@ -77,7 +76,7 @@ InternalIsTimeLikeString (
 }\r
 \r
 /**\r
-  Verify that the DateString is valid and if so set that as the current \r
+  Verify that the DateString is valid and if so set that as the current\r
   date.\r
 \r
   @param[in] DateString     The pointer to a string representation of the date.\r
@@ -87,7 +86,6 @@ InternalIsTimeLikeString (
   @retval SHELL_SUCCESS             The operation was successful.\r
 **/\r
 SHELL_STATUS\r
-EFIAPI\r
 CheckAndSetDate (\r
   IN CONST CHAR16 *DateString\r
   )\r
@@ -104,7 +102,7 @@ CheckAndSetDate (
 \r
   Status = gRT->GetTime(&TheTime, NULL);\r
   if (EFI_ERROR(Status)) {\r
-    ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), gShellLevel2HiiHandle, L"gRT->GetTime", Status);\r
+    ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), gShellLevel2HiiHandle, L"date", L"gRT->GetTime", Status);\r
     return (SHELL_DEVICE_ERROR);\r
   }\r
 \r
@@ -197,7 +195,7 @@ ShellCommandRunDate (
   Status = ShellCommandLineParse (SfoParamList, &Package, &ProblemParam, TRUE);\r
   if (EFI_ERROR(Status)) {\r
     if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {\r
-      ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, ProblemParam);\r
+      ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"date", ProblemParam);\r
       FreePool(ProblemParam);\r
       ShellStatus = SHELL_INVALID_PARAMETER;\r
     } else {\r
@@ -210,7 +208,7 @@ ShellCommandRunDate (
     if (ShellCommandLineGetFlag(Package, L"-?")) {\r
       ASSERT(FALSE);\r
     } else if (ShellCommandLineGetRawValue(Package, 2) != NULL) {\r
-      ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle);\r
+      ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"date");\r
       ShellStatus = SHELL_INVALID_PARAMETER;\r
     } else {\r
       //\r
@@ -223,7 +221,7 @@ ShellCommandRunDate (
         //\r
         Status = gRT->GetTime(&TheTime, NULL);\r
         if (EFI_ERROR(Status)) {\r
-          ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), gShellLevel2HiiHandle, L"gRT->GetTime", Status);\r
+          ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), gShellLevel2HiiHandle, L"date", L"gRT->GetTime", Status);\r
           return (SHELL_DEVICE_ERROR);\r
         }\r
 \r
@@ -243,7 +241,7 @@ ShellCommandRunDate (
         }\r
       } else {\r
         if (PcdGet8(PcdShellSupportLevel) == 2) {\r
-          ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle);\r
+          ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"date");\r
           ShellStatus = SHELL_INVALID_PARAMETER;\r
         } else {\r
           //\r
@@ -256,7 +254,7 @@ ShellCommandRunDate (
             ShellStatus = CheckAndSetDate(Param1);\r
           }\r
           if (ShellStatus != SHELL_SUCCESS) {\r
-            ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, Param1);\r
+            ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"date", Param1);\r
             ShellStatus = SHELL_INVALID_PARAMETER;\r
           }\r
         }\r
@@ -289,7 +287,7 @@ STATIC CONST SHELL_PARAM_ITEM TimeParamList3[] = {
   };\r
 \r
 /**\r
-  Verify that the TimeString is valid and if so set that as the current \r
+  Verify that the TimeString is valid and if so set that as the current\r
   time.\r
 \r
   @param[in] TimeString     The pointer to a string representation of the time.\r
@@ -301,7 +299,6 @@ STATIC CONST SHELL_PARAM_ITEM TimeParamList3[] = {
   @retval SHELL_SUCCESS             The operation was successful.\r
 **/\r
 SHELL_STATUS\r
-EFIAPI\r
 CheckAndSetTime (\r
   IN CONST CHAR16 *TimeString,\r
   IN CONST INT16  Tz,\r
@@ -323,7 +320,7 @@ CheckAndSetTime (
 \r
   Status = gRT->GetTime(&TheTime, NULL);\r
   if (EFI_ERROR(Status)) {\r
-    ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), gShellLevel2HiiHandle, L"gRT->GetTime", Status);\r
+    ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), gShellLevel2HiiHandle, L"time", L"gRT->GetTime", Status);\r
     return (SHELL_DEVICE_ERROR);\r
   }\r
 \r
@@ -436,7 +433,7 @@ ShellCommandRunTime (
   }\r
   if (EFI_ERROR(Status)) {\r
     if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {\r
-      ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, ProblemParam);\r
+      ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"time", ProblemParam);\r
       FreePool(ProblemParam);\r
       ShellStatus = SHELL_INVALID_PARAMETER;\r
     } else {\r
@@ -448,14 +445,14 @@ ShellCommandRunTime (
     //\r
     Status = gRT->GetTime(&TheTime, NULL);\r
     if (EFI_ERROR(Status)) {\r
-      ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), gShellLevel2HiiHandle, L"gRT->GetTime", Status);\r
+      ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), gShellLevel2HiiHandle, L"time", L"gRT->GetTime", Status);\r
       return (SHELL_DEVICE_ERROR);\r
     }\r
 \r
     if (ShellCommandLineGetFlag(Package, L"-?")) {\r
       ASSERT(FALSE);\r
     } else if (ShellCommandLineGetRawValue(Package, 2) != NULL) {\r
-      ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle);\r
+      ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"time");\r
       ShellStatus = SHELL_INVALID_PARAMETER;\r
     } else {\r
       //\r
@@ -542,18 +539,18 @@ ShellCommandRunTime (
               ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_TIME_DST3), gShellLevel2HiiHandle);\r
               break;\r
             default:\r
-              ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_ERROR), gShellLevel2HiiHandle, L"gRT->GetTime", L"TheTime.Daylight", TheTime.Daylight);\r
+              ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_ERROR), gShellLevel2HiiHandle, L"time", L"gRT->GetTime", L"TheTime.Daylight", TheTime.Daylight);\r
           }\r
       } else {\r
         if (PcdGet8(PcdShellSupportLevel) == 2) {\r
-          ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle);\r
+          ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"time");\r
           ShellStatus = SHELL_INVALID_PARAMETER;\r
         } else {\r
           //\r
           // perform level 3 operation here.\r
           //\r
           if ((TempLocation = ShellCommandLineGetValue(Package, L"-tz")) != NULL) {\r
-            if (StrniCmp (TempLocation, L"_local", StrLen (TempLocation)) == NULL) {\r
+            if (gUnicodeCollation->StriColl(gUnicodeCollation, (CHAR16 *)TempLocation, L"_local") == 0) {\r
               Tz = EFI_UNSPECIFIED_TIMEZONE;\r
             } else if (TempLocation[0] == L'-') {\r
 \r
@@ -581,7 +578,7 @@ ShellCommandRunTime (
               }\r
             }\r
             if (!(Tz >= -1440 && Tz <= 1440) && Tz != EFI_UNSPECIFIED_TIMEZONE) {\r
-              ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_VAL), gShellLevel2HiiHandle, L"-tz");\r
+              ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_VAL), gShellLevel2HiiHandle, L"time", TempLocation, L"-tz");\r
               ShellStatus = SHELL_INVALID_PARAMETER;\r
             }\r
           } else {\r
@@ -602,7 +599,7 @@ ShellCommandRunTime (
               Daylight = 0xff; //make it invalid = will not use\r
             }\r
             if (Daylight != 0 && Daylight != 1 && Daylight != 3) {\r
-              ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_VAL), gShellLevel2HiiHandle, L"-d");\r
+              ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_VAL), gShellLevel2HiiHandle, L"time", TempLocation, L"-d");\r
               ShellStatus = SHELL_INVALID_PARAMETER;\r
             }\r
           } else {\r
@@ -614,7 +611,7 @@ ShellCommandRunTime (
           if (ShellStatus == SHELL_SUCCESS) {\r
             ShellStatus = CheckAndSetTime(ShellCommandLineGetRawValue(Package, 1), Tz, Daylight);\r
             if (ShellStatus != SHELL_SUCCESS) {\r
-              ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, ShellCommandLineGetRawValue(Package, 1));\r
+              ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"time", ShellCommandLineGetRawValue(Package, 1));\r
               ShellStatus = SHELL_INVALID_PARAMETER;\r
             }\r
           }\r
@@ -691,7 +688,7 @@ STATIC CONST SHELL_PARAM_ITEM TimeZoneParamList3[] = {
 };\r
 \r
 /**\r
-  Verify that the TimeZoneString is valid and if so set that as the current \r
+  Verify that the TimeZoneString is valid and if so set that as the current\r
   timezone.\r
 \r
   @param[in] TimeZoneString     The pointer to a string representation of the timezone.\r
@@ -701,7 +698,6 @@ STATIC CONST SHELL_PARAM_ITEM TimeZoneParamList3[] = {
   @retval SHELL_SUCCESS             The operation was successful.\r
 **/\r
 SHELL_STATUS\r
-EFIAPI\r
 CheckAndSetTimeZone (\r
   IN CONST CHAR16 *TimeZoneString\r
   )\r
@@ -717,7 +713,7 @@ CheckAndSetTimeZone (
     return (SHELL_INVALID_PARAMETER);\r
   }\r
 \r
-  if (StrniCmp (TimeZoneString, L"_local", StrLen (TimeZoneString)) == NULL) {\r
+  if (gUnicodeCollation->StriColl(gUnicodeCollation, (CHAR16 *)TimeZoneString, L"_local") == 0) {\r
     Status = gRT->GetTime (&TheTime, NULL);\r
     if (EFI_ERROR (Status)) {\r
       ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), gShellLevel2HiiHandle, L"gRT->GetTime", Status);\r
@@ -737,7 +733,7 @@ CheckAndSetTimeZone (
 \r
   Status = gRT->GetTime(&TheTime, NULL);\r
   if (EFI_ERROR(Status)) {\r
-    ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), gShellLevel2HiiHandle, L"gRT->GetTime", Status);\r
+    ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), gShellLevel2HiiHandle, L"timezone", L"gRT->GetTime", Status);\r
     return (SHELL_DEVICE_ERROR);\r
   }\r
 \r
@@ -833,7 +829,7 @@ ShellCommandRunTimeZone (
   }\r
   if (EFI_ERROR(Status)) {\r
     if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {\r
-      ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, ProblemParam);\r
+      ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"timezone", ProblemParam);\r
       FreePool(ProblemParam);\r
       ShellStatus = SHELL_INVALID_PARAMETER;\r
     } else {\r
@@ -844,18 +840,18 @@ ShellCommandRunTimeZone (
     // check for "-?"\r
     //\r
     if (ShellCommandLineGetCount(Package) > 1) {\r
-      ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle);\r
+      ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"timezone");\r
       ShellStatus = SHELL_INVALID_PARAMETER;\r
     } else if (ShellCommandLineGetFlag(Package, L"-?")) {\r
       ASSERT(FALSE);\r
     } else if (ShellCommandLineGetFlag(Package, L"-s")) {\r
       if ((ShellCommandLineGetFlag(Package, L"-l")) || (ShellCommandLineGetFlag(Package, L"-f"))) {\r
-        ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"-l or -f");\r
+        ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"timezone", L"-l or -f");\r
         ShellStatus = SHELL_INVALID_PARAMETER;\r
       } else {\r
         ASSERT(PcdGet8(PcdShellSupportLevel) == 3);\r
         if (ShellCommandLineGetValue(Package, L"-s") == NULL) {\r
-          ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellLevel2HiiHandle, L"-s");\r
+          ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellLevel2HiiHandle, L"timezone", L"-s");\r
           ShellStatus = SHELL_INVALID_PARAMETER;\r
         } else {\r
           //\r
@@ -863,7 +859,7 @@ ShellCommandRunTimeZone (
           //\r
           ShellStatus = CheckAndSetTimeZone(ShellCommandLineGetValue(Package, L"-s"));\r
           if (ShellStatus != SHELL_SUCCESS) {\r
-            ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, ShellCommandLineGetValue(Package, L"-s"));\r
+            ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"timezone", ShellCommandLineGetValue(Package, L"-s"));\r
             ShellStatus = SHELL_INVALID_PARAMETER;\r
           }\r
         }\r
@@ -884,7 +880,7 @@ ShellCommandRunTimeZone (
       //\r
       Status = gRT->GetTime(&TheTime, NULL);\r
       if (EFI_ERROR(Status)) {\r
-        ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), gShellLevel2HiiHandle, L"gRT->GetTime", Status);\r
+        ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), gShellLevel2HiiHandle, L"timezone", L"gRT->GetTime", Status);\r
         return (SHELL_DEVICE_ERROR);\r
       }\r
 \r
@@ -946,7 +942,7 @@ ShellCommandRunTimeZone (
         //\r
         if (ShellCommandLineGetFlag (Package, L"-f")) {\r
           for ( LoopVar = 0\r
-              ; LoopVar < sizeof (TimeZoneList) / sizeof (TimeZoneList[0])\r
+              ; LoopVar < ARRAY_SIZE (TimeZoneList)\r
               ; LoopVar++\r
              ){\r
             if (TheTime.TimeZone == TimeZoneList[LoopVar].TimeZone) {\r
@@ -955,7 +951,7 @@ ShellCommandRunTimeZone (
               //\r
               ShellPrintHiiEx (-1, -1, NULL, TimeZoneList[LoopVar].StringId, gShellLevel2HiiHandle);\r
               break;\r
-            } \r
+            }\r
           }\r
         } else {\r
           //\r