]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c
MdeModulePkg: Refine function comments in Keyword Handler Protocol
[mirror_edk2.git] / MdeModulePkg / Universal / HiiDatabaseDxe / ConfigKeywordHandler.c
index b978669687145069b260d574051aa71fa1c09484..5e7aca96816e4d8fce42dcbe30b86f4f84c19090 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 Implementation of interfaces function for EFI_CONFIG_KEYWORD_HANDLER_PROTOCOL.\r
 \r
-Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2015 - 2016, 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
@@ -1583,6 +1583,8 @@ GetWidth (
     return (UINT16) sizeof (BOOLEAN);\r
     \r
   case EFI_IFR_PASSWORD_OP:\r
+    return (UINT16)((UINTN) ((EFI_IFR_PASSWORD *) OpCodeData)->MaxSize * sizeof (CHAR16));\r
+\r
   case EFI_IFR_STRING_OP:\r
     return (UINT16)((UINTN) ((EFI_IFR_STRING *) OpCodeData)->MaxSize * sizeof (CHAR16));\r
 \r
@@ -1758,7 +1760,7 @@ ConstructConfigHdr (
   //\r
   // Append L"&NAME="\r
   //\r
-  StrCpyS (String, MaxLen, L"&NAME=");\r
+  StrCatS (ReturnString, MaxLen, L"&NAME=");\r
   String += StrLen (String);\r
 \r
   if (Name != NULL) {\r
@@ -1773,7 +1775,7 @@ ConstructConfigHdr (
   //\r
   // Append L"&PATH="\r
   //\r
-  StrCpyS (String, MaxLen, L"&PATH=");\r
+  StrCatS (ReturnString, MaxLen, L"&PATH=");\r
   String += StrLen (String);\r
 \r
   //\r
@@ -2044,14 +2046,10 @@ ExtractConfigRequest (
       StringPtr = *ConfigRequest;\r
 \r
       StrCpyS (StringPtr, MaxLen, ConfigHdr);\r
-      StringPtr += StrLen (StringPtr);\r
 \r
-      *StringPtr = L'&';\r
-      StringPtr++;\r
+      StrCatS (StringPtr, MaxLen, L"&");\r
 \r
-      StrCpyS (StringPtr, MaxLen, RequestElement);\r
-      StringPtr += StrLen (StringPtr);\r
-      *StringPtr = L'\0';\r
+      StrCatS (StringPtr, MaxLen, RequestElement);\r
 \r
       FreePool (ConfigHdr);\r
       FreePool (RequestElement);\r
@@ -2152,23 +2150,17 @@ ExtractConfigResp (
       StringPtr = *ConfigResp;\r
 \r
       StrCpyS (StringPtr, MaxLen, ConfigHdr);\r
-      StringPtr += StrLen (StringPtr);\r
 \r
-      *StringPtr = L'&';\r
-      StringPtr++;\r
+      StrCatS (StringPtr, MaxLen, L"&");\r
 \r
-      StrCpyS (StringPtr, MaxLen, RequestElement);\r
-      StringPtr += StrLen (StringPtr);\r
-      \r
-      *StringPtr = L'&';\r
-      StringPtr++;\r
 \r
-      StrCpyS (StringPtr, MaxLen, L"VALUE=");\r
-      StringPtr += StrLen (StringPtr);\r
+      StrCatS (StringPtr, MaxLen, RequestElement);\r
+\r
+      StrCatS (StringPtr, MaxLen, L"&");\r
+\r
+      StrCatS (StringPtr, MaxLen, L"VALUE=");\r
 \r
-      StrCpyS (StringPtr, MaxLen, ValueElement);\r
-      StringPtr += StrLen (StringPtr);\r
-      *StringPtr = L'\0';\r
+      StrCatS (StringPtr, MaxLen, ValueElement);\r
 \r
       FreePool (ConfigHdr);\r
       FreePool (RequestElement);\r
@@ -2452,43 +2444,33 @@ GenerateKeywordResp (
   // 2.1 Copy NameSpaceId section.\r
   //\r
   StrCpyS (RespStr, RespStrLen, L"NAMESPACE=");\r
-  RespStr += StrLen (RespStr);\r
-  StrCpyS (RespStr, RespStrLen, UnicodeNameSpace);\r
-  RespStr += StrLen (RespStr);\r
+\r
+  StrCatS (RespStr, RespStrLen, UnicodeNameSpace);\r
 \r
   //\r
   // 2.2 Copy PathHdr section.\r
   //\r
-  StrCpyS (RespStr, RespStrLen, PathHdr);\r
-  RespStr += StrLen (RespStr);\r
+  StrCatS (RespStr, RespStrLen, PathHdr);\r
 \r
   //\r
   // 2.3 Copy Keyword section.\r
   //\r
-  StrCpyS (RespStr, RespStrLen, L"KEYWORD=");\r
-  RespStr += StrLen (RespStr);\r
-  StrCpyS (RespStr, RespStrLen, KeywordData);\r
-  RespStr += StrLen (RespStr);\r
+  StrCatS (RespStr, RespStrLen, L"KEYWORD=");\r
+\r
+  StrCatS (RespStr, RespStrLen, KeywordData);\r
 \r
   //\r
   // 2.4 Copy the Value section.\r
   //\r
-  StrCpyS (RespStr, RespStrLen, ValueStr);\r
-  RespStr += StrLen (RespStr);\r
+  StrCatS (RespStr, RespStrLen, ValueStr);\r
 \r
   //\r
   // 2.5 Copy ReadOnly section if exist.\r
   //\r
   if (ReadOnly) {\r
-    StrCpyS (RespStr, RespStrLen, L"&READONLY");\r
-    RespStr += StrLen (RespStr);\r
+    StrCatS (RespStr, RespStrLen, L"&READONLY");\r
   }\r
 \r
-  //\r
-  // 2.6 Add the end.\r
-  //\r
-  *RespStr = L'\0';\r
-\r
   if (UnicodeNameSpace != NULL) {\r
     FreePool (UnicodeNameSpace);\r
   }\r
@@ -2536,12 +2518,9 @@ MergeToMultiKeywordResp (
   FreePool (*MultiKeywordResp);\r
   *MultiKeywordResp = StringPtr;\r
 \r
-  StringPtr += StrLen (StringPtr);\r
-\r
-  *StringPtr = L'&';\r
-  StringPtr++;\r
+  StrCatS (StringPtr, MultiKeywordRespLen / sizeof (CHAR16), L"&");\r
 \r
-  StrCpyS (StringPtr, MultiKeywordRespLen / sizeof (CHAR16), *KeywordResp);\r
+  StrCatS (StringPtr, MultiKeywordRespLen / sizeof (CHAR16), *KeywordResp);\r
 \r
   return EFI_SUCCESS;\r
 }\r
@@ -2775,8 +2754,9 @@ Done:
   @param Progress         On return, points to a character in the KeywordString. \r
                           Points to the string's NULL terminator if the request \r
                           was successful. Points to the most recent '&' before \r
-                          the first failing string element if the request was \r
-                          not successful.\r
+                          the first failing name / value pair (or the beginning\r
+                          of the string if the failure is in the first name / value\r
+                          pair) if the request was not successful.\r
 \r
   @param ProgressErr      If during the processing of the KeywordString there was\r
                           a failure, this parameter gives additional information \r
@@ -2829,6 +2809,7 @@ EfiConfigKeywordHandlerSetData (
   BOOLEAN                             ReadOnly;\r
   EFI_STRING                          InternalProgress;\r
   CHAR16                              *TempString;\r
+  CHAR16                              *KeywordStartPos;\r
 \r
   if (This == NULL || Progress == NULL || ProgressErr == NULL || KeywordString == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
@@ -2843,6 +2824,7 @@ EfiConfigKeywordHandlerSetData (
   KeywordData     = NULL;\r
   ValueElement    = NULL;\r
   ConfigResp      = NULL;\r
+  KeywordStartPos = NULL;\r
   KeywordStringId = 0;\r
 \r
   //\r
@@ -2886,6 +2868,7 @@ EfiConfigKeywordHandlerSetData (
     //\r
     // 3. Extract keyword from the KeywordRequest string.\r
     //\r
+    KeywordStartPos = StringPtr;\r
     Status = ExtractKeyword(StringPtr, &KeywordData, &NextStringPtr);\r
     if (EFI_ERROR (Status)) {\r
       //\r
@@ -2942,8 +2925,8 @@ EfiConfigKeywordHandlerSetData (
     // 8. Check the readonly flag.\r
     //\r
     if (ExtractReadOnlyFromOpCode (OpCode) != ReadOnly) {\r
-      *ProgressErr = KEYWORD_HANDLER_INCOMPATIBLE_VALUE_DETECTED;\r
-      Status = EFI_INVALID_PARAMETER;\r
+      *ProgressErr = KEYWORD_HANDLER_ACCESS_NOT_PERMITTED;\r
+      Status = EFI_ACCESS_DENIED;\r
       goto Done;      \r
     }\r
     \r
@@ -2970,6 +2953,7 @@ EfiConfigKeywordHandlerSetData (
       FreePool (ConfigResp);\r
       ConfigResp = NULL;\r
     }\r
+    KeywordStartPos = NULL;\r
   }\r
 \r
   //\r
@@ -2988,7 +2972,11 @@ EfiConfigKeywordHandlerSetData (
   *ProgressErr = KEYWORD_HANDLER_NO_ERROR;\r
 \r
 Done:\r
-  *Progress = KeywordString + (StringPtr - TempString);\r
+  if (KeywordStartPos != NULL) {\r
+    *Progress = KeywordString + (KeywordStartPos - TempString);\r
+  } else {\r
+    *Progress = KeywordString + (StringPtr - TempString);\r
+  }\r
 \r
   ASSERT (TempString != NULL);\r
   FreePool (TempString);\r
@@ -3010,7 +2998,7 @@ Done:
   if (MultiConfigResp != NULL && MultiConfigResp != ConfigResp) {\r
     FreePool (MultiConfigResp);\r
   }\r
-  \r
+\r
   return Status;\r
 }\r
 \r
@@ -3045,8 +3033,9 @@ Done:
   \r
   @param Progress       On return, points to a character in the KeywordString. Points\r
                         to the string's NULL terminator if the request was successful. \r
-                        Points to the most recent '&' before the first failing string\r
-                        element if the request was not successful.\r
+                        Points to the most recent '&' before the first failing name / value\r
+                        pair (or the beginning of the string if the failure is in the first\r
+                        name / value pair) if the request was not successful.\r
                         \r
   @param ProgressErr    If during the processing of the KeywordString there was a\r
                         failure, this parameter gives additional information about the \r