#include <extUtil.h>


/* summiert keystrokes, wenn key= "RETURN" dann 1, sonst 0 */
/*   record ist dann auszuwerten.                           */
int parser( unsigned char gkey, unsigned char *record )
{
  int j;
  static int i={0};
  static unsigned char  echo[20]={"echo -n \" \""};
  static unsigned char  keystroke[MAX_LINE_LENGTH];

  if (gkey == ( unsigned char )0xff0d)
  {
    /* parser output */
    strcpy( record, keystroke); 

    for (j=0; j<MAX_LINE_LENGTH; j++) keystroke[j]=( unsigned char )0x20;
    system("echo");
    i=0;
    return(1);
  }
  else
  {
    if (gkey == ( unsigned char )0xff08)
    {
      if (i>1) i=i-2;
    }
    else
    {
      keystroke[i] = gkey;
    }
    keystroke[i+1]=(unsigned char)NULL;

    echo[9]=gkey;
    echo[12]=(unsigned char)NULL;
    system(echo);
    i++;
  }
  return(0);
}

