comp.lang.ada
 help / color / mirror / Atom feed
From: g_harrison@vger.nsu.edu (George C. Harrison, Norfolk State University)
Subject: Re: 1-char input with Ada tasks
Date: 4 Apr 91 15:09:49 GMT	[thread overview]
Message-ID: <807.27fb097d@vger.nsu.edu> (raw)
In-Reply-To: 2986@sparko.gwu.edu

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 <stdio.h>
#include <termio.h>
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 ---------------------------------

  reply	other threads:[~1991-04-04 15:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1991-04-03 17:58 1-char input with Ada tasks Michael Feldman
1991-04-04 15:09 ` George C. Harrison, Norfolk State University [this message]
1991-04-05 18:18   ` Michael Feldman
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox