
#include "com_sun_sysid_SysidNativeBridge.h"
#include <stdio.h>
#include <termio.h>
#include <termios.h>

JNIEXPORT void JNICALL 
Java_com_sun_sysid_SysidNativeBridge_echoOff_1native(JNIEnv *env, jclass class)
{
  struct termios termio;
  int res;

  /* get the current status of the terminal */
  if( (res = tcgetattr( 1, &termio)) ) {
    fprintf( stderr, "Error %d getting terminal attributes!\n", res);
  }
  
  termio.c_lflag &= ~ECHO;

  if( (res = tcsetattr( 1, TCSANOW, &termio)) ) {
    fprintf( stderr, "Error %d setting terminal attributes!\n", res);
  }
}

JNIEXPORT void JNICALL 
Java_com_sun_sysid_SysidNativeBridge_echoOn_1native(JNIEnv *env, jclass class)
{
  struct termios termio;
  int res;
  
  /* get the current status of the terminal */
  if( (res = tcgetattr( 1, &termio)) ) {
    fprintf( stderr, "Error %d getting terminal attributes!\n", res);
  }
  
  termio.c_lflag |= ECHO;

  if( (res = tcsetattr( 1, TCSANOW, &termio)) ) {
    fprintf( stderr, "Error %d setting terminal attributes!\n", res);
  }
}
