Annotation of 43BSDReno/contrib/mh/miscellany/less/ttyin.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Routines dealing with getting input from the keyboard (i.e. from the user).
                      3:  */
                      4: 
                      5: #include "less.h"
                      6: 
                      7: /*
                      8:  * The boolean "reading" is set true or false according to whether
                      9:  * we are currently reading from the keyboard.
                     10:  * This information is used by the signal handling stuff in signal.c.
                     11:  * {{ There are probably some race conditions here
                     12:  *    involving the variable "reading". }}
                     13:  */
                     14: public int reading;
                     15: 
                     16: static int tty;
                     17: 
                     18: /*
                     19:  * Open keyboard for input.
                     20:  * (Just use file descriptor 2.)
                     21:  */
                     22:        public void
                     23: open_getc()
                     24: {
                     25:        tty = 2;
                     26: }
                     27: 
                     28: /*
                     29:  * Get a character from the keyboard.
                     30:  */
                     31:        public int
                     32: getc()
                     33: {
                     34:        char c;
                     35:        int result;
                     36: 
                     37:        reading = 1;
                     38:        do
                     39:        {
                     40:                flush();
                     41:                result = read(tty, &c, 1);
                     42:        } while (result != 1);
                     43:        reading = 0;
                     44:        return (c & 0177);
                     45: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.