/** @file
Main file for time, timezone, and date shell level 2 and shell level 3 functions.
Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "UefiShellLevel2CommandsLib.h"
/**
Determine if String is a valid representation for a time or date.
@param[in] String The pointer to the string to test.
@param[in] Char The delimeter character.
@param[in] Min The minimum value allowed.
@param[in] Max The maximum value allowed.
@param[in] MinusOk Whether negative numbers are permitted.
@retval TRUE String is a valid representation.
@retval FALSE String is invalid.
**/
)
{
Count = 0;
if (MinusOk) {
//
// A single minus is ok.
//
if (*String == L'-') {
String++;
}
}
//
// the first char must be numeric.
//
if (!ShellIsDecimalDigitCharacter(*String)) {
return (FALSE);
}
//
// loop through the characters and use the lib function
//
Count++;
return (FALSE);
}
continue;
}
if (!ShellIsDecimalDigitCharacter(*String)) {
return (FALSE);
}
}
return (FALSE);
}
return (TRUE);
}
/**
Verify that the DateString is valid and if so set that as the current
date.
@param[in] DateString The pointer to a string representation of the date.
@retval SHELL_INVALID_PARAMETER DateString was NULL.
@retval SHELL_INVALID_PARAMETER DateString was mis-formatted.
@retval SHELL_SUCCESS The operation was successful.
**/
)
{
return (SHELL_INVALID_PARAMETER);
}
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), gShellLevel2HiiHandle, L"gRT->GetTime", Status);
return (SHELL_DEVICE_ERROR);
}
if (DateStringCopy == NULL) {
return (SHELL_OUT_OF_RESOURCES);
}
}
}
}
}
}
}
}
} else {
}
}
return (SHELL_SUCCESS);
}
return (SHELL_INVALID_PARAMETER);
}
/**
Function for 'date' command.
@param[in] ImageHandle Handle to the Image (NULL if Internal).
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
**/
)
{
ProblemParam = NULL;
//
// initialize the shell lib (we must be in non-auto-init...)
//
Status = ShellInitialize();
//
// parse the command line
//
} else {
}
} else {
//
// check for "-?"
//
} else {
//
// If there are 0 value parameters, then print the current date
// else If there are any value paramerers, then print error
//
//
// get the current date
//
//
// ShellPrintEx the date in SFO or regular format
//
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DATE_SFO_FORMAT), gShellLevel2HiiHandle, TheTime.Month, TheTime.Day, TheTime.Year);
} else {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DATE_FORMAT), gShellLevel2HiiHandle, TheTime.Month, TheTime.Day, TheTime.Year);
}
} else {
} else {
//
// perform level 3 operation here.
//
} else {
}
if (ShellStatus != SHELL_SUCCESS) {
}
}
}
}
}
//
// free the command line package
//
//
// return the status
//
return (ShellStatus);
}
//
// Note "-tz" is invalid for this (non-interactive) version of 'time'.
//
{L"-d", TypeValue},
};
{L"-d", TypeValue},
{L"-tz", TypeValue},
};
/**
Verify that the TimeString is valid and if so set that as the current
time.
@param[in] TimeString The pointer to a string representation of the time.
@param[in] Tz The value to set for TimeZone.
@param[in] Daylight The value to set for Daylight.
@retval SHELL_INVALID_PARAMETER TimeString was NULL.
@retval SHELL_INVALID_PARAMETER TimeString was mis-formatted.
@retval SHELL_SUCCESS The operation was successful.
**/
)
{
return (SHELL_INVALID_PARAMETER);
}
if (Daylight != 0xFF &&((Daylight & (EFI_TIME_IN_DAYLIGHT|EFI_TIME_ADJUST_DAYLIGHT)) != Daylight)) {
return (SHELL_INVALID_PARAMETER);
}
if (TimeString != NULL) {
}
}
}
}
}
}
}
}
if (Daylight != 0xFF) {
}
return (SHELL_SUCCESS);
}
return (SHELL_INVALID_PARAMETER);
}
/**
Function for 'time' command.
@param[in] ImageHandle Handle to the Image (NULL if Internal).
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
**/
)
{
ProblemParam = NULL;
//
// Initialize variables
//
//
// initialize the shell lib (we must be in non-auto-init...)
//
Status = ShellInitialize();
//
// parse the command line
//
} else {
}
} else {
}
} else {
//
// check for "-?"
//
} else {
//
// If there are no parameters, then print the current time
//
//
// ShellPrintEx the current time
//
TzMinutes = 0;
} else {
}
-1,
-1,
NULL,
);
} else if (ShellCommandLineGetFlag(Package, L"-d") && ShellCommandLineGetValue(Package, L"-d") == NULL) {
TzMinutes = 0;
} else {
}
-1,
-1,
NULL,
);
case 0:
break;
case EFI_TIME_ADJUST_DAYLIGHT:
break;
case EFI_TIME_IN_DAYLIGHT:
break;
break;
default:
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_ERROR), gShellLevel2HiiHandle, L"gRT->GetTime", L"TheTime.Daylight", TheTime.Daylight);
}
} else {
} else {
//
// perform level 3 operation here.
//
if (TempLocation[0] == L'-') {
} else {
}
}
} else {
//
// intentionally out of bounds value will prevent changing it...
//
Tz = 1441;
}
if (TempLocation != NULL) {
}
} else {
//
// invalid = will not use
//
Daylight = 0xFF;
}
if (ShellStatus == SHELL_SUCCESS) {
if (ShellStatus != SHELL_SUCCESS) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, ShellCommandLineGetRawValue(Package, 1));
}
}
}
}
}
}
//
// free the command line package
//
//
// return the status
//
return (ShellStatus);
}
typedef struct {
{L"-l", TypeFlag},
{L"-f", TypeFlag},
};
{L"-l", TypeFlag},
{L"-f", TypeFlag},
{L"-s", TypeValue},
};
{0 , STRING_TOKEN (STR_TIMEZONE_0)},
};
/**
Verify that the TimeZoneString is valid and if so set that as the current
timezone.
@param[in] TimeZoneString The pointer to a string representation of the timezone.
@retval SHELL_INVALID_PARAMETER TimeZoneString was NULL.
@retval SHELL_INVALID_PARAMETER TimeZoneString was mis-formatted.
@retval SHELL_SUCCESS The operation was successful.
**/
)
{
if (TimeZoneString == NULL) {
return (SHELL_INVALID_PARAMETER);
}
return (SHELL_INVALID_PARAMETER);
}
return (SHELL_DEVICE_ERROR);
}
TimeZoneCopy = NULL;
if (TimeZoneCopy == NULL) {
return (SHELL_OUT_OF_RESOURCES);
}
}
if (*Walker == L'-') {
} else {
}
}
} else {
}
}
for ( LoopVar = 0
; LoopVar++
){
break;
}
}
return (SHELL_SUCCESS);
}
return (SHELL_INVALID_PARAMETER);
}
/**
Function for 'timezone' command.
@param[in] ImageHandle Handle to the Image (NULL if Internal).
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
**/
)
{
//
// non interactive
//
ProblemParam = NULL;
//
// initialize the shell lib (we must be in non-auto-init...)
//
Status = ShellInitialize();
//
// parse the command line
//
} else {
}
} else {
}
} else {
//
// check for "-?"
//
} else {
} else {
//
// Set the time zone
//
if (ShellStatus != SHELL_SUCCESS) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, ShellCommandLineGetValue(Package, L"-s"));
}
}
}
//
// Print a list of all time zones
//
for ( LoopVar = 0
; LoopVar++
){
}
} else {
//
// Get Current Time Zone Info
//
for ( LoopVar = 0
; LoopVar++
){
//
// Print all info about current time zone
//
} else {
//
// Print basic info only
//
TzMinutes = 0;
} else {
}
-1,
-1,
NULL,
}
break;
}
}
if (!Found) {
//
// Print basic info only
//
TzMinutes = 0;
} else {
}
-1,
-1,
NULL,
}
}
} else {
//
// TimeZone was EFI_UNSPECIFIED_TIMEZONE (unknown) from GetTime()
//
}
}
}
//
// free the command line package
//
return (ShellStatus);
}