From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: ** X-Spam-Status: No, score=2.6 required=5.0 tests=BAYES_40,INVALID_DATE, MSGID_SHORT,REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uunet!seas.gwu.edu!mfeldman From: mfeldman@seas.gwu.edu (Michael Feldman) Newsgroups: comp.lang.ada Subject: single-character C input (2 of 2) Message-ID: <2168@sparko.gwu.edu> Date: 22 Sep 90 20:20:24 GMT Reply-To: mfeldman@seas.gwu.edu (Michael Feldman) Organization: The George Washington University, Washington D.C. List-Id: Here is the C side of the single-character input package. Note the authorship below. It is distributed as part of the shareware package Ada-Tutor. --------------------------------------------------------------------------- Prof. Michael Feldman Department of Electrical Engineering and Computer Science The George Washington University Washington, DC 20052 202-994-5253 mfeldman@seas.gwu.edu --------------------------------------------------------------------------- /* ONECHAR.C Ver. 1.22 18-FEB-1989 Software Innovations Technology 1083 Mandarin Drive NE, Palm Bay, FL 32905-4706 (407)951-0233 This file is for use with UNIX.ADA. It is a Unix System V routine to allow the capture and return of one character from the terminal. This program was written by Dave Hill, 7549 Wynford Street, Salt Lake City, UT 84121. Software Innovations Technology is grateful to Mr. Hill for permission to include ONECHAR.C with ADA-TUTR. */ #include #include char onechar() { static struct termio newsets, oldsets; char c; ioctl(fileno(stdin), TCGETA, &newsets); ioctl(fileno(stdin), TCGETA, &oldsets); /* used by cooked */ newsets.c_cc[4] = '\001'; newsets.c_cc[5] = '\0'; newsets.c_lflag &= ~ (ICANON); ioctl(fileno(stdin), TCSETAF, &newsets); c = getchar(); ioctl(fileno(stdin), TCSETAF, &oldsets); return (c); }