]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/Misc.c
add comments to function declarations and definitions and updated to match coding...
[mirror_edk2.git] / ShellPkg / Library / UefiShellDebug1CommandsLib / HexEdit / Misc.c
index da11789625635ff730d806e0eb17d25480dd7564..d6961c5bb71949e43fb170dfdbb29f6165b8f398 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Implementation of various string and line routines\r
   \r
-  Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved. <BR>\r
+  Copyright (TempVarC) 2005 - 2011, 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
 \r
 extern BOOLEAN  HEditorMouseAction;\r
 \r
-VOID\r
-HEditorClearLine (\r
-  IN UINTN Row\r
-  )\r
-/*++\r
-\r
-Routine Description: \r
-\r
-  Clear line at Row\r
-\r
-Arguments:  \r
-\r
-  Row -- row number to be cleared ( start from 1 )\r
-\r
-Returns:  \r
-\r
-  EFI_SUCCESS\r
-\r
---*/\r
-{\r
-  CHAR16  Line[200];\r
-  UINTN   Index;\r
-  UINTN   Limit;\r
-  UINTN   StartCol;\r
-\r
-  if (HEditorMouseAction) {\r
-    Limit     = 3 * 0x10;\r
-    StartCol  = 10;\r
-  } else {\r
-    Limit     = HMainEditor.ScreenSize.Column;\r
-    StartCol  = 1;\r
-  }\r
-  //\r
-  // prepare a blank line\r
-  //\r
-  for (Index = 0; Index < Limit; Index++) {\r
-    Line[Index] = ' ';\r
-  }\r
-\r
-  if (Row == HMainEditor.ScreenSize.Row && Limit == HMainEditor.ScreenSize.Column) {\r
-    //\r
-    // if '\0' is still at position 80, it will cause first line error\r
-    //\r
-    Line[Limit - 1] = '\0';\r
-  } else {\r
-    Line[Limit] = '\0';\r
-  }\r
-  //\r
-  // print out the blank line\r
-  //\r
-  ShellPrintEx ((INT32)StartCol - 1, (INT32)Row - 1, Line);\r
-}\r
-\r
-HEFI_EDITOR_LINE *\r
-HLineDup (\r
-  IN  HEFI_EDITOR_LINE *Src\r
-  )\r
-/*++\r
-\r
-Routine Description: \r
-\r
-  Duplicate a line\r
-\r
-Arguments:  \r
-\r
-  Src -- line to be duplicated\r
-\r
-Returns:  \r
-\r
-  NULL -- wrong\r
-  Not NULL -- line created\r
-\r
---*/\r
-{\r
-  HEFI_EDITOR_LINE  *Dest;\r
-\r
-  //\r
-  // allocate for the line structure\r
-  //\r
-  Dest = AllocateZeroPool (sizeof (HEFI_EDITOR_LINE));\r
-  if (Dest == NULL) {\r
-    return NULL;\r
-  }\r
-\r
-  Dest->Signature = EFI_EDITOR_LINE_LIST;\r
-  Dest->Size      = Src->Size;\r
-\r
-  CopyMem (Dest->Buffer, Src->Buffer, 0x10);\r
-\r
-  Dest->Link = Src->Link;\r
-\r
-  return Dest;\r
-}\r
-\r
+/**\r
+  Free a line and it's internal buffer.\r
+  \r
+  @param[in] Src    The line to be freed.\r
+**/\r
 VOID\r
 HLineFree (\r
   IN  HEFI_EDITOR_LINE *Src\r
   )\r
-/*++\r
-\r
-Routine Description: \r
-\r
-  Free a line and it's internal buffer\r
-\r
-Arguments:  \r
-\r
-  Src -- line to be freed\r
-\r
-Returns:  \r
-\r
-  None\r
-\r
---*/\r
 {\r
   if (Src == NULL) {\r
     return ;\r
@@ -138,26 +34,18 @@ Returns:
 \r
 }\r
 \r
+/**\r
+  Advance to the next Count lines.\r
+\r
+  @param[in] Count      The line number to advance.\r
+\r
+  @retval NULL An error occured.\r
+  @return A pointer to the line after advance.\r
+**/\r
 HEFI_EDITOR_LINE *\r
-_HLineAdvance (\r
+HLineAdvance (\r
   IN  UINTN Count\r
   )\r
-/*++\r
-\r
-Routine Description: \r
-\r
-  Advance to the next Count lines\r
-\r
-Arguments:  \r
-\r
-  Count -- line number to advance\r
-\r
-Returns:  \r
-\r
-  NULL -- wrong\r
-  Not NULL -- line after advance\r
-\r
---*/\r
 {\r
   UINTN             Index;\r
   HEFI_EDITOR_LINE  *Line;\r
@@ -181,26 +69,18 @@ Returns:
   return Line;\r
 }\r
 \r
+/**\r
+  Retreat to the previous Count lines.\r
+\r
+  @param[in] Count    The line number to retreat.\r
+\r
+  @retval NULL An error occured.\r
+  @return A pointer to the line after retreat.\r
+**/\r
 HEFI_EDITOR_LINE *\r
-_HLineRetreat (\r
+HLineRetreat (\r
   IN  UINTN Count\r
   )\r
-/*++\r
-\r
-Routine Description: \r
-\r
-  Retreat to the previous Count lines\r
-\r
-Arguments:  \r
-\r
-  Count -- line number to retreat\r
-\r
-Returns:  \r
-\r
-  NULL -- wrong\r
-  Not NULL -- line after retreat\r
-\r
---*/\r
 {\r
   UINTN             Index;\r
   HEFI_EDITOR_LINE  *Line;\r
@@ -224,28 +104,20 @@ Returns:
   return Line;\r
 }\r
 \r
+/**\r
+  Advance/Retreat lines.\r
+\r
+  @param[in] Count      The line number to advance/retreat.\r
+                            >0 : advance\r
+                            <0: retreat  \r
+\r
+  @retval NULL An error occured.\r
+  @return A pointer to the line after move.\r
+**/\r
 HEFI_EDITOR_LINE *\r
 HMoveLine (\r
   IN  INTN Count\r
   )\r
-/*++\r
-\r
-Routine Description: \r
-\r
-  Advance/Retreat lines\r
-\r
-Arguments:  \r
-\r
-  Count -- line number to advance/retreat\r
-    >0 : advance\r
-    <0: retreat  \r
-\r
-Returns:  \r
-\r
-  NULL -- wrong\r
-  Not NULL -- line after advance\r
-\r
---*/\r
 {\r
   HEFI_EDITOR_LINE  *Line;\r
   UINTN             AbsCount;\r
@@ -257,37 +129,28 @@ Returns:
   //\r
   if (Count <= 0) {\r
     AbsCount  = (UINTN)ABS(Count);\r
-    Line      = _HLineRetreat (AbsCount);\r
+    Line      = HLineRetreat (AbsCount);\r
   } else {\r
-    Line = _HLineAdvance ((UINTN)Count);\r
+    Line = HLineAdvance ((UINTN)Count);\r
   }\r
 \r
   return Line;\r
 }\r
 \r
+/**\r
+  Advance/Retreat lines and set CurrentLine in BufferImage to it.\r
+\r
+  @param[in] Count    The line number to advance/retreat.\r
+                          >0 : advance\r
+                          <0: retreat\r
+\r
+  @retval NULL An error occured.\r
+  @return A pointer to the line after move.\r
+**/\r
 HEFI_EDITOR_LINE *\r
 HMoveCurrentLine (\r
   IN  INTN Count\r
   )\r
-/*++\r
-\r
-Routine Description: \r
-\r
-  Advance/Retreat lines and set CurrentLine in BufferImage to it\r
-\r
-Arguments:  \r
-\r
-  Count -- line number to advance/retreat\r
-    >0 : advance\r
-    <0: retreat\r
-\r
-Returns:  \r
-\r
-  NULL -- wrong\r
-  Not NULL -- line after advance\r
-\r
-\r
---*/\r
 {\r
   HEFI_EDITOR_LINE  *Line;\r
   UINTN             AbsCount;\r
@@ -298,9 +161,9 @@ Returns:
   //\r
   if (Count <= 0) {\r
     AbsCount  = (UINTN)ABS(Count);\r
-    Line      = _HLineRetreat (AbsCount);\r
+    Line      = HLineRetreat (AbsCount);\r
   } else {\r
-    Line = _HLineAdvance ((UINTN)Count);\r
+    Line = HLineAdvance ((UINTN)Count);\r
   }\r
 \r
   if (Line == NULL) {\r
@@ -313,34 +176,26 @@ Returns:
 }\r
 \r
 \r
-EFI_STATUS\r
-HFreeLines (\r
-  IN LIST_ENTRY   *ListHead,\r
-  IN HEFI_EDITOR_LINE *Lines\r
-  )\r
-/*++\r
-\r
-Routine Description: \r
-\r
-  Free all the lines in HBufferImage\r
+/**\r
+  Free all the lines in HBufferImage.\r
     Fields affected:\r
     Lines\r
     CurrentLine\r
     NumLines\r
     ListHead \r
 \r
-Arguments:  \r
-\r
-  ListHead - The list head\r
-  Lines - The lines\r
-\r
-Returns:  \r
+  @param[in] ListHead     The list head.\r
+  @param[in] Lines        The lines.\r
 \r
-  EFI_SUCCESS\r
-\r
---*/\r
+  @retval EFI_SUCCESS     The operation was successful.\r
+**/\r
+EFI_STATUS\r
+HFreeLines (\r
+  IN LIST_ENTRY   *ListHead,\r
+  IN HEFI_EDITOR_LINE *Lines\r
+  )\r
 {\r
-  LIST_ENTRY    *Link;\r
+  LIST_ENTRY        *Link;\r
   HEFI_EDITOR_LINE  *Line;\r
 \r
   //\r
@@ -363,83 +218,13 @@ Returns:
   return EFI_SUCCESS;\r
 }\r
 \r
-UINTN\r
-HStrStr (\r
-  IN  CHAR16  *Str,\r
-  IN  CHAR16  *Pat\r
-  )\r
-/*++\r
-\r
-Routine Description: \r
-\r
-  Search Pat in Str\r
-\r
-Arguments:  \r
-\r
-  Str -- mother string\r
-  Pat -- search pattern\r
-\r
-\r
-Returns:  \r
-\r
-  0 : not found\r
-  >= 1 : found position + 1\r
-\r
---*/\r
-{\r
-  INTN  *Failure;\r
-  INTN  i;\r
-  INTN  j;\r
-  INTN  Lenp;\r
-  INTN  Lens;\r
-\r
-  //\r
-  // this function copies from some lib\r
-  //\r
-  Lenp        = StrLen (Pat);\r
-  Lens        = StrLen (Str);\r
+/**\r
+  Get the X information for the mouse.\r
 \r
-  Failure     = AllocateZeroPool ((UINTN)(Lenp * sizeof (INTN)));\r
-  if (Failure == NULL) {\r
-    return 0;\r
-  }\r
-  Failure[0]  = -1;\r
-  for (j = 1; j < Lenp; j++) {\r
-    i = Failure[j - 1];\r
-    while ((Pat[j] != Pat[i + 1]) && (i >= 0)) {\r
-      i = Failure[i];\r
-    }\r
-\r
-    if (Pat[j] == Pat[i + 1]) {\r
-      Failure[j] = i + 1;\r
-    } else {\r
-      Failure[j] = -1;\r
-    }\r
-  }\r
-\r
-  i = 0;\r
-  j = 0;\r
-  while (i < Lens && j < Lenp) {\r
-    if (Str[i] == Pat[j]) {\r
-      i++;\r
-      j++;\r
-    } else if (j == 0) {\r
-      i++;\r
-    } else {\r
-      j = Failure[j - 1] + 1;\r
-    }\r
-  }\r
-\r
-  FreePool (Failure);\r
-\r
-  //\r
-  // 0: not found\r
-  // >=1 : found position + 1\r
-  //\r
-  return ((j == Lenp) ? (i - Lenp) : -1) + 1;\r
-\r
-}\r
+  @param[in] GuidX      The change.\r
 \r
+  @return the new information.\r
+**/\r
 INT32\r
 HGetTextX (\r
   IN INT32 GuidX\r
@@ -454,6 +239,13 @@ HGetTextX (
   return Gap;\r
 }\r
 \r
+/**\r
+  Get the Y information for the mouse.\r
+\r
+  @param[in] GuidY      The change.\r
+\r
+  @return the new information.\r
+**/\r
 INT32\r
 HGetTextY (\r
   IN INT32 GuidY\r
@@ -468,77 +260,3 @@ HGetTextY (
 \r
   return Gap;\r
 }\r
-\r
-EFI_STATUS\r
-HXtoi (\r
-  IN  CHAR16  *Str,\r
-  OUT UINTN   *Value\r
-  )\r
-/*++\r
-Routine Description:\r
-\r
-  convert hex string to uint\r
-  \r
-Arguments:\r
-\r
-  Str   - The string\r
-  Value - The value\r
-\r
-Returns:\r
-\r
-\r
---*/\r
-{\r
-  UINT64  u;\r
-  CHAR16  c;\r
-  UINTN   Size;\r
-\r
-  Size = sizeof (UINTN);\r
-\r
-  //\r
-  // skip leading white space\r
-  //\r
-  while (*Str && *Str == ' ') {\r
-    Str += 1;\r
-  }\r
-\r
-  if (StrLen (Str) > Size * 2) {\r
-    return EFI_LOAD_ERROR;\r
-  }\r
-  //\r
-  // convert hex digits\r
-  //\r
-  u = 0;\r
-  c = *Str;\r
-  while (c) {\r
-    c = *Str;\r
-    Str++;\r
-\r
-    if (c == 0) {\r
-      break;\r
-    }\r
-    //\r
-    // not valid char\r
-    //\r
-    if (!((c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F') || (c >= '0' && c <= '9') || (c == '\0'))) {\r
-      return EFI_LOAD_ERROR;\r
-    }\r
-\r
-    if (c >= 'a' && c <= 'f') {\r
-      c -= 'a' - 'A';\r
-    }\r
-\r
-    if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F')) {\r
-      u = LShiftU64 (u, 4) + (c - (c >= 'A' ? 'A' - 10 : '0'));\r
-    } else {\r
-      //\r
-      // '\0'\r
-      //\r
-      break;\r
-    }\r
-  }\r
-\r
-  *Value = (UINTN) u;\r
-\r
-  return EFI_SUCCESS;\r
-}\r