lynx-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: lynx-dev Q: control lynx from C


From: Klaus Peter Wegge
Subject: Re: lynx-dev Q: control lynx from C
Date: Mon, 22 Feb 1999 18:39:23 +0100 (MET)

there is a very simple way to control lynx 
from a C Programm. Perhaps this is, what you are looking for!
Compile the very small "lynxin" programm attached to this mail.
I tested it in LINUX.
Then type:
lynxin | lynx

lynxin will read the keystrokes from the keybord and flush them to
stdout imediately.
OK, this program is rather silly.
But you can use it as a skeleton for example for connecting a voice
recognition machine as a frontend to lynx without modifying
lynx.

Regards

Klaus-Peter

/* file lynxin.cc */

#include <stdio.h>
#include <sys/ioctl.h>
#include <termio.h>
#include <unistd.h>

#define TRUE 1
#define FALSE 0

void init_func(int firsttime)
{
        static struct termio n, o;
        if (firsttime)
        {
                ioctl(fileno(stdin), TCGETA, &o);
                ioctl(fileno(stdin), TCGETA, &n);
                n.c_lflag &= ~ICRNL;
                n.c_lflag &= ~ECHO;
                n.c_lflag &= ~ECHOE;
                n.c_lflag &= ~ECHOK;
                n.c_lflag &= ~ICANON;
                n.c_cc[VMIN] = 1;
                n.c_cc[VTIME] = 0;
                ioctl(fileno(stdin), TCSETA, &n);
        }
        else
                ioctl(fileno(stdin), TCSETA, &o);
}

int main (void)
{
  int c;
  char ch;
  init_func(TRUE);
  while((c = getchar()) >0) {
     ch = c;
     write(1, &ch, 1);
  }
  init_func(FALSE);
}

reply via email to

[Prev in Thread] Current Thread [Next in Thread]