Back to index

glibc  2.9
Functions
termios.c File Reference
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <termios.h>

Go to the source code of this file.

Functions

void reset_input_mode (void)
void set_input_mode (void)
int main (void)

Function Documentation

int main ( void  )

Definition at line 44 of file termios.c.

{
  char c;

  set_input_mode ();

  while (1)
    {
      read (STDIN_FILENO, &c, 1);
      if (c == '\004')             /* @kbd{C-d} */
       break;
      else
       putchar (c);
    }

  return EXIT_SUCCESS;
}

Here is the call graph for this function:

void reset_input_mode ( void  )

Definition at line 11 of file termios.c.

{
  tcsetattr (STDIN_FILENO, TCSANOW, &saved_attributes);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void set_input_mode ( void  )

Definition at line 17 of file termios.c.

{
  struct termios tattr;
  char *name;

  /* Make sure stdin is a terminal. */
  if (!isatty (STDIN_FILENO))
    {
      fprintf (stderr, "Not a terminal.\n");
      exit (EXIT_FAILURE);
    }

  /* Save the terminal attributes so we can restore them later. */
  tcgetattr (STDIN_FILENO, &saved_attributes);
  atexit (reset_input_mode);

/*@group*/
  /* Set the funny terminal modes. */
  tcgetattr (STDIN_FILENO, &tattr);
  tattr.c_lflag &= ~(ICANON|ECHO); /* Clear ICANON and ECHO.  */
  tattr.c_cc[VMIN] = 1;
  tattr.c_cc[VTIME] = 0;
  tcsetattr (STDIN_FILENO, TCSAFLUSH, &tattr);
}

Here is the call graph for this function:

Here is the caller graph for this function: