+++ /dev/null
-/** @file\r
- NonCanonical Interactive Input Function.\r
-\r
- The functions assume that isatty() is TRUE at the time they are called.\r
- If _S_IWTTY is set, the device returns WIDE characters.\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 <LibConfig.h>\r
-\r
-#include <sys/syslimits.h>\r
-#include <sys/termios.h>\r
-#include <Containers/Fifo.h>\r
-#include <Device/IIO.h>\r
-\r
-/** Perform a noncanonical read of input.\r
-\r
- @param[in] filp Pointer to a file descriptor structure.\r
- @param[in] BufferSize Maximum number of bytes to return.\r
-\r
- @retval -1 An error has occurred. Reason in errno.\r
- @retval -1 No data returned. None was ready.\r
- @retval >0 The number of elements returned\r
-**/\r
-ssize_t\r
-IIO_NonCanonRead (\r
- struct __filedes *filp\r
- )\r
-{\r
- cIIO *This;\r
- cFIFO *InBuf;\r
- struct termios *Termio;\r
- ssize_t NumRead;\r
- cc_t tioMin;\r
- cc_t tioTime;\r
- UINT32 InputType;\r
- wchar_t InChar; // Intermediate character buffer\r
-\r
- NumRead = -1;\r
- InChar = 0; // Initialize so compilers don't complain.\r
- This = filp->devdata;\r
- Termio = &This->Termio;\r
- InBuf = This->InBuf;\r
- tioMin = Termio->c_cc[VMIN];\r
- tioTime = Termio->c_cc[VTIME];\r
-\r
- if(tioMin >= MAX_INPUT) {\r
- tioMin = MAX_INPUT;\r
- }\r
- /* There are four types of processing that may be done, based on\r
- the values of tioMin and tioTime.\r
- Min Time Type\r
- --- ---- ----\r
- 0 0 0 Return buffer contents or 1 new char\r
- 0 >0 1 Return 0 or 1 character depending on timeout\r
- >0 0 2 Buffer Min chars. Return BufferSize chars.\r
- >0 >0 3 Return up to Min chars. Unless the inter-byte timer expires.\r
-\r
- Currently, only type 0 is implemented.\r
- */\r
- InputType = 0;\r
- if(tioMin != 0) InputType = 2;\r
- if(tioTime != 0) ++InputType;\r
- //switch(InputType) {\r
- // case 0:\r
- if(InBuf->IsEmpty(InBuf)) {\r
- NumRead = filp->f_ops->fo_read(filp, &filp->f_offset, sizeof(wchar_t), &InChar);\r
- if(NumRead > 0) {\r
- (void) InBuf->Write(InBuf, &InChar, 1); // Buffer the character\r
- }\r
- }\r
- // break;\r
- // case 1:\r
- // break;\r
- // case 2:\r
- // break;\r
- // case 3:\r
- // break;\r
- //}\r
- return NumRead;\r
-}\r