]> git.proxmox.com Git - mirror_edk2.git/blobdiff - StdLib/LibC/Uefi/InteractiveIO/CanonRead.c
edk2: Remove AppPkg, StdLib, StdLibPrivateInternalFiles
[mirror_edk2.git] / StdLib / LibC / Uefi / InteractiveIO / CanonRead.c
diff --git a/StdLib/LibC/Uefi/InteractiveIO/CanonRead.c b/StdLib/LibC/Uefi/InteractiveIO/CanonRead.c
deleted file mode 100644 (file)
index 8c8e076..0000000
+++ /dev/null
@@ -1,167 +0,0 @@
-/** @file\r
-  Canonical Interactive Input Function.\r
-\r
-  The functions assume that isatty() is TRUE at the time they are called.\r
-\r
-  Copyright (c) 2012 - 2014, Intel Corporation. All rights reserved.<BR>\r
-  This program and the accompanying materials are licensed and made available\r
-  under the terms and conditions of the BSD License which accompanies this\r
-  distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php.\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-**/\r
-#include  <Uefi.h>\r
-\r
-#include  <LibConfig.h>\r
-\r
-#include  <errno.h>\r
-#include  <sys/syslimits.h>\r
-#include  <sys/termios.h>\r
-#include  <Device/IIO.h>\r
-#include  <MainData.h>\r
-#include  "IIOutilities.h"\r
-#include  "IIOechoCtrl.h"\r
-\r
-/** Read a line from the input file in canonical mode.\r
-    Perform echoing and input processing as directed by the termios flags.\r
-\r
-    @param[in]    filp      A pointer to a file descriptor structure.\r
-\r
-    @return     The number of characters in the input buffer, or -1 if there\r
-                was an error.\r
-**/\r
-ssize_t\r
-IIO_CanonRead (\r
-  struct __filedes *filp\r
-  )\r
-{\r
-  cIIO             *This;\r
-  cFIFO            *InBuf;\r
-  struct termios   *Termio;\r
-  struct __filedes *fpOut;\r
-  size_t            NumRead;\r
-  wint_t            InChar;\r
-  tcflag_t          IFlag;\r
-  tcflag_t          LFlag;\r
-  BOOLEAN           EchoIsOK;\r
-  BOOLEAN           Activate;\r
-  BOOLEAN           FirstRead;\r
-  int               OutMode;\r
-  UINTN             MaxColumn;\r
-  UINTN             MaxRow;\r
-\r
-  NumRead   = MAX_INPUT;    // Workaround "potentially uninitialized" warning\r
-  EchoIsOK  = FALSE;\r
-  FirstRead = TRUE;\r
-  This      = filp->devdata;\r
-  Termio    = &This->Termio;\r
-  InBuf     = This->InBuf;\r
-\r
-  // Get a copy of the flags we are going to use\r
-  IFlag = Termio->c_iflag;\r
-  LFlag = Termio->c_lflag;\r
-\r
-  /* Determine what the current screen size is. Also validates the output device. */\r
-  OutMode = IIO_GetOutputSize(STDOUT_FILENO, &MaxColumn, &MaxRow);\r
-  if(OutMode >= 0) {\r
-    /*  Set the maximum screen dimensions. */\r
-    This->MaxColumn = MaxColumn;\r
-    This->MaxRow    = MaxRow;\r
-\r
-    /*  Record where the cursor is at the beginning of this Input operation.\r
-        The currently set stdout device is used to determine this.  If there is\r
-        no stdout, or stdout is not an interactive device, nothing is recorded.\r
-    */\r
-    if (IIO_GetCursorPosition(STDOUT_FILENO, &This->InitialXY.Column, &This->InitialXY.Row) >= 0) {\r
-      This->CurrentXY.Column  = This->InitialXY.Column;\r
-      This->CurrentXY.Row     = This->InitialXY.Row;\r
-      EchoIsOK  = TRUE;   // Can only echo to stdout\r
-    }\r
-  }\r
-\r
-  // For now, we only echo to stdout.\r
-  fpOut = &gMD->fdarray[STDOUT_FILENO];\r
-\r
-  //  Input and process characters until BufferSize is exhausted.\r
-  do {\r
-    InChar = IIO_GetInChar(filp, FirstRead);\r
-    if (InChar == WEOF) {\r
-      NumRead = 0;\r
-      break;\r
-    }\r
-    FirstRead = FALSE;\r
-    Activate  = TRUE;\r
-    if(InChar == CHAR_CARRIAGE_RETURN) {\r
-      if((IFlag & IGNCR) != 0) {\r
-        continue;   // Restart the do loop, discarding the CR\r
-      }\r
-      else if((IFlag & ICRNL) != 0) {\r
-        InChar = L'\n';\r
-      }\r
-    }\r
-    else if(InChar == CHAR_LINEFEED) {\r
-      if((IFlag & INLCR) != 0) {\r
-        InChar = L'\r';\r
-      }\r
-    }\r
-    else if(CCEQ(Termio->c_cc[VINTR], InChar)) {\r
-      if((LFlag & ISIG) != 0) {\r
-        // Raise Signal\r
-        // Flush Input Buffer\r
-        // Return to caller\r
-        InChar = IIO_ECHO_DISCARD;\r
-        errno = EINTR;\r
-      }\r
-      else {\r
-        Activate = FALSE;\r
-      }\r
-    }\r
-    else if(CCEQ(Termio->c_cc[VQUIT], InChar)) {\r
-      if((LFlag & ISIG) != 0) {\r
-        // Raise Signal\r
-        // Flush Input Buffer\r
-        // Return to caller\r
-        InChar = IIO_ECHO_DISCARD;\r
-        errno = EINTR;\r
-      }\r
-      else {\r
-        Activate = FALSE;\r
-      }\r
-    }\r
-    else if(CCEQ(Termio->c_cc[VEOF], InChar)) {\r
-      InChar = WEOF;\r
-      NumRead = 0;\r
-      EchoIsOK = FALSE;   // Buffer, but don't echo this character\r
-    }\r
-    else if(CCEQ(Termio->c_cc[VEOL], InChar)) {\r
-      EchoIsOK = FALSE;   // Buffer, but don't echo this character\r
-    }\r
-    else if(CCEQ(Termio->c_cc[VERASE], InChar)) {\r
-      InChar = IIO_ECHO_ERASE;\r
-      Activate = FALSE;\r
-    }\r
-    else if(CCEQ(Termio->c_cc[VKILL], InChar)) {\r
-      InChar = IIO_ECHO_KILL;\r
-      Activate = FALSE;\r
-    }\r
-    else {\r
-      if((InChar < TtySpecKeyMin) || (InChar >= TtyFunKeyMax)) {\r
-        Activate = FALSE;\r
-      }\r
-    }\r
-    /** The Echo function is responsible for:\r
-          * Adding the character to the input buffer, if appropriate.\r
-          * Removing characters from the input buffer for ERASE and KILL processing.\r
-          * Visually removing characters from the screen if ECHOE is set.\r
-          * Ensuring one can not backspace beyond the beginning of the input text.\r
-          * Sending final echo strings to output.\r
-    **/\r
-    (void)This->Echo(fpOut, (wchar_t)InChar, EchoIsOK);\r
-    NumRead = InBuf->Count(InBuf, AsElements);\r
-  } while((NumRead < MAX_INPUT) &&\r
-          (Activate == FALSE));\r
-\r
-  return (ssize_t)NumRead;\r
-}\r