/* Copy one line data from buffer data to the line buffer. */
EFI_STATUS ProfileGetLine(IN UINT8 *Buffer, IN UINTN BufferSize, IN OUT UINT8 *LineBuffer, IN OUT UINTN *LineSize)
/* Copy one line data from buffer data to the line buffer. */
EFI_STATUS ProfileGetLine(IN UINT8 *Buffer, IN UINTN BufferSize, IN OUT UINT8 *LineBuffer, IN OUT UINTN *LineSize)
{
  UINTN  Length;
  UINT8  *PtrBuf;
  UINTN  PtrEnd;
  PtrBuf = Buffer;
  PtrEnd = (UINTN)Buffer + BufferSize;
  while ((UINTN)PtrBuf < PtrEnd) {
    if ((*PtrBuf == 0x0D) || (*PtrBuf == 0x0A)) {
      break;
    }
    PtrBuf++;
  }
  if ((UINTN)PtrBuf >= (PtrEnd - 1)) {
    Length = BufferSize;
  } else if (*(PtrBuf + 1) == 0x0A) {
    Length = (UINTN)PtrBuf - (UINTN)Buffer + 2;
  } else {
    Length = (UINTN)PtrBuf - (UINTN)Buffer + 1;
  }
  if (Length > (*LineSize)) {
    *LineSize = Length;
    return EFI_BUFFER_TOO_SMALL;
  }
  SetMem (LineBuffer, *LineSize, 0x0);
  *LineSize = Length;
  CopyMem (LineBuffer, Buffer, Length);
  return EFI_SUCCESS;
}