Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uunet!tut.cis.ohio-state.edu!sppy00!dwb From: dwb@sppy00.UUCP (David Burhans) Newsgroups: comp.lang.c Subject: Re: true unbuffered input. Message-ID: <686@sppy00.UUCP> Date: 16 Jan 90 18:29:46 GMT References: <1990Jan15.222652.21085@hellgate.utah.edu> Reply-To: dwb@sppy00.UUCP (David Burhans) Distribution: usa Organization: Online Computer Library Center, Dublin, Ohio. Lines: 41 In article <1990Jan15.222652.21085@hellgate.utah.edu> efinley%ug.utah.edu@cs.utah.edu (Elliott Finley) writes: > >I can't seem to get true unbuffered input. ...stuff deleted... To do this you meed to change the your mode from cooked to CBREAK or RAW. Use ioctl(2) to accomplish this change. Man pages of interest: ioctl(2), tty(4). Include files of interest: sgtty.h, sys/ioctl.h. An example program follows: ---------------------------------------------------------------- #include #include main() { int c; struct sgttyb oldargs, newargs; printf("stdin:%d\n",fileno(stdin)); ioctl(fileno(stdin), TIOCGETP, &oldargs); newargs = oldargs; newargs.sg_flags |= CBREAK; newargs.sg_flags &= ~(ECHO | CRMOD); ioctl(fileno(stdin), TIOCSETP, &newargs); while(c = getchar(), c != '\004') { /* while c != ^D */ switch (c) { case '\033': fputs("", stdout); break; case '\n': fputs("\\n\n\r", stdout); break; case '\r': fputs("\\r\n\r", stdout); break; case '\t': fputs("\\t", stdout); break; default: fprintf(stdout,"%c",c); break; } } ioctl(fileno(stdin), TIOCSETP, &oldargs); } -- dwb@sppy00 {att|killer|pyramid}!osu-cis!sppy00!dwb David Burhans/6565 Frantz Rd./Columbus, Oh 43017 **** Views expressed above were randomly generated with a six sided die and as such are not the views of my employer. *****