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=1.9 required=5.0 tests=BAYES_50,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!elroy.jpl.nasa.gov!decwrl!mcnc!uvaarpa!vger.nsu.edu!g_harrison From: g_harrison@vger.nsu.edu (George C. Harrison, Norfolk State University) Newsgroups: comp.lang.ada Subject: Re: 1-char input with Ada tasks Message-ID: <807.27fb097d@vger.nsu.edu> Date: 4 Apr 91 15:09:49 GMT References: <2986@sparko.gwu.edu> List-Id: In article <2986@sparko.gwu.edu>, mfeldman@seas.gwu.edu (Michael Feldman) writes: > Recently someone posted a nice portable (Unix-oriented) solution to > the problem of getting a single character from the keyboard in the > presence of tasks. As I recall, there was a brief C program interfaced > to Ada, and a task which polled for input. Can somebody re-post this? > > Mike Feldman > --------------------------------------------------------------------------- > Prof. Michael Feldman > Department of Electrical Engineering and Computer Science > The George Washington University > Washington, DC 20052 U.S.A. > > phone 202-994-5253 > fax 202-994-5296 > email mfeldman@seas.gwu.edu > --------------------------------------------------------------------------- This is not EXACTLY what you may want but... >From John Herro's ADA-TUTR: -- UNIX.ADA Ver. 1.21 18-FEB-1989 -- Copyright 1988-1989 John J. Herro -- Software Innovations Technology -- 1083 Mandarin Drive NE, Palm Bay, FL 32905-4706 (407)951-0233 -- -- Compile this before compiling ADA_TUTR.ADA on a UNIX based system. You must -- also compile ONECHAR.C with a C compiler before linking. See first page of -- ADA_TUTR.ADA for more details. -- package body CUSTOM_IO is etc.... procedure GET(CHAR : out CHARACTER) is function ONECHAR return CHARACTER; pragma INTERFACE (C, ONECHAR); begin CHAR := ONECHAR; end GET; /* Complements of Dave Hill of Salt Lake City...... for more see ADA-TUTR by John Herro */ #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); } -- George C. Harrison ----------------------- ----- Professor of Computer Science ----------------------- ----- Norfolk State University ----------------------- ----- 2401 Corprew Avenue, Norfolk, Virginia 23504 ----------------------- ----- INTERNET: g_harrison@vger.nsu.edu ---------------------------------