PreviousUpNext

15.3.529  src/lib/std/src/psx/posix-tty.api

## posix-tty.api
#
# Api for POSIX 1003.1 operations on terminal devices

# Compiled by:
#     src/lib/std/src/standard-core.sublib






###                        "I wanted to avoid special IO for terminals."
###
###                                            -- Ken Thompson


stipulate
    package hi  =  host_int;                                            # host_int                              is from   src/lib/std/src/psx/host-int.pkg
    package hu  =  host_unt;                                            # host_unt                              is from   src/lib/std/types-only/bind-largest32.pkg
    package hug =  host_unt_guts;                                       # host_unt_guts                         is from   src/lib/std/src/bind-sysword-32.pkg
    package wv  =  vector_of_one_byte_unts;                             # vector_of_one_byte_unts               is from   src/lib/std/src/vector-of-one-byte-unts.pkg
    package g2d =  exceptions_guts;                                     # exceptions_guts                       is from   src/lib/std/src/exceptions-guts.pkg
herein

    api  Posix_Tty {
        #
        eqtype Process_Id;                      #  process ID 
        eqtype File_Descriptor;                 #  file descriptor 

        package i:
        api {
            include api Bit_Flags;              # Bit_Flags     is from   src/lib/std/src/bit-flags.api

            brkint:  Flags;
            icrnl:   Flags;
            ignbrk:  Flags;
            igncr:   Flags;
            ignpar:  Flags;
            inlcr:   Flags;
            inpck:   Flags;
            istrip:  Flags;
            ixoff:   Flags;
            ixon:    Flags;
            parmrk:  Flags;
        };

        package o:
        api {
            include api Bit_Flags;              # Bit_Flags     is from   src/lib/std/src/bit-flags.api

            opost:  Flags;
        };

        package c:
          api {
            include api Bit_Flags;              # Bit_Flags     is from   src/lib/std/src/bit-flags.api

             clocal:  Flags;
             cread:   Flags;
             csize:   Flags;
             cs5:     Flags;
             cs6:     Flags;
             cs7:     Flags;
             cs8:     Flags;
             cstopb:  Flags;
             hupcl:   Flags;
             parenb:  Flags;
             parodd:  Flags;
          };

        package l:
          api {
            include api Bit_Flags;              # Bit_Flags     is from   src/lib/std/src/bit-flags.api

             echo:    Flags;
             echoe:   Flags;
             echok:   Flags;
             echonl:  Flags;
             icanon:  Flags;
             iexten:  Flags;
             isig:    Flags;
             noflsh:  Flags;
             tostop:  Flags;
          };

        package v:
          api {
             eof:    Int;
             eol:    Int;
             erase:  Int;
             intr:   Int;
             kill:   Int;
             min:    Int;
             quit:   Int;
             susp:   Int;
             time:   Int;
             start:  Int;
             stop:   Int;

             nccs:  Int;

             Cc;

             cc:       List ((Int, Char)) -> Cc;
             update:  ((Cc, List ((Int, Char)))) -> Cc;
             sub:     ((Cc, Int)) -> Char;
          };

        eqtype Speed;
        compare_speed:  (Speed, Speed) -> g2d::Order;                           # exceptions_guts       is from   src/lib/std/src/exceptions-guts.pkg
        speed_to_unt:  Speed -> hu::Unt;
        unt_to_speed:  hu::Unt -> Speed;
        b0:      Speed;
        b50:     Speed;
        b75:     Speed;
        b110:    Speed;
        b134:    Speed;
        b150:    Speed;
        b200:    Speed;
        b300:    Speed;
        b600:    Speed;
        b1200:   Speed;
        b1800:   Speed;
        b2400:   Speed;
        b4800:   Speed;
        b9600:   Speed;
        b19200:  Speed;
        b38400:  Speed;

        Termios;

        termios:  { iflag:  i::Flags,
                       oflag:  o::Flags,
                       cflag:  c::Flags,
                       lflag:  l::Flags,
                       cc:  v::Cc,
                       ispeed:  Speed,
                       ospeed:  Speed } -> Termios;

        fields_of:  Termios -> { iflag:  i::Flags,
                                   oflag:  o::Flags,
                                   cflag:  c::Flags,
                                   lflag:  l::Flags,
                                   cc:  v::Cc,
                                   ispeed:  Speed,
                                   ospeed:  Speed };

        getiflag:   Termios -> i::Flags;
        getoflag:   Termios -> o::Flags;
        getcflag:   Termios -> c::Flags;
        getlflag:   Termios -> l::Flags;
        getcc:      Termios -> v::Cc;

        getospeed:  Termios -> Speed;
        setospeed:  ((Termios, Speed)) -> Termios;
        getispeed:  Termios -> Speed;
        setispeed:  ((Termios, Speed)) -> Termios;

        package tc:
          api {
            eqtype Set_Action;

             sanow:    Set_Action;
             sadrain:  Set_Action;
             saflush:  Set_Action;

            eqtype Flow_Action;

             ooff:  Flow_Action;
             oon:   Flow_Action;
             ioff:  Flow_Action;
             ion:   Flow_Action;

            eqtype Queue_Sel;

             iflush:   Queue_Sel;
             oflush:   Queue_Sel;
             ioflush:  Queue_Sel;
          };

        getattr:  File_Descriptor -> Termios;
        setattr:  (File_Descriptor, tc::Set_Action, Termios) -> Void;

        sendbreak:  (File_Descriptor, Int) -> Void;
        drain:   File_Descriptor -> Void;
        flush:  (File_Descriptor, tc::Queue_Sel) -> Void;
        flow:  (File_Descriptor, tc::Flow_Action) -> Void;

        getpgrp:  File_Descriptor -> Process_Id;
        setpgrp: (File_Descriptor,   Process_Id) -> Void;



        #######################################################################
        # Below stuff is intended only for one-time use during
        # booting, to switch from direct to indirect syscalls:                          # For background see Note[1]            in   src/lib/std/src/unsafe/mythryl-callable-c-library-interface.pkg

        Sy_Int =  hi::Int;

             osval4__syscall:   String -> Sy_Int;
        set__osval4__ref:     ({ lib_name: String, fun_name: String, io_call: (String -> Sy_Int) } -> (String -> Sy_Int)) -> Void;

        Termio_Rep
            =
            ( hug::Unt,                 #  iflags 
              hug::Unt,                 #  oflags 
              hug::Unt,                 #  Cflags 
              hug::Unt,                 #  lflags 
              wv::Vector,               #  Cc 
              hug::Unt,                 #  inspeed 
              hug::Unt                  #  outspeed 
            );

             tcgetattr__syscall:    Int -> Termio_Rep;
        set__tcgetattr__ref:      ({ lib_name: String, fun_name: String, io_call: (Int -> Termio_Rep) } -> (Int -> Termio_Rep)) -> Void;

             tcsetattr__syscall:    (Int, Sy_Int, Termio_Rep) -> Void;
        set__tcsetattr__ref:      ({ lib_name: String, fun_name: String, io_call: ((Int, Sy_Int, Termio_Rep) -> Void) } -> ((Int, Sy_Int, Termio_Rep) -> Void)) -> Void;

             tcsendbreak__syscall:    (Int, Int) -> Void;
        set__tcsendbreak__ref:      ({ lib_name: String, fun_name: String, io_call: ((Int, Int) -> Void) } -> ((Int, Int) -> Void)) -> Void;

             tcdrain__syscall:    Int -> Void;
        set__tcdrain__ref:      ({ lib_name: String, fun_name: String, io_call: (Int -> Void) } -> (Int -> Void)) -> Void;

             tcflush__syscall:    (Int, Sy_Int) -> Void;
        set__tcflush__ref:      ({ lib_name: String, fun_name: String, io_call: ((Int, Sy_Int) -> Void) } -> ((Int, Sy_Int) -> Void)) -> Void;

             tcflow__syscall:    (Int, Sy_Int) -> Void;
        set__tcflow__ref:      ({ lib_name: String, fun_name: String, io_call: ((Int, Sy_Int) -> Void) } -> ((Int, Sy_Int) -> Void)) -> Void;

             tcgetpgrp__syscall:    Int -> Sy_Int;
        set__tcgetpgrp__ref:      ({ lib_name: String, fun_name: String, io_call: (Int -> Sy_Int) } -> (Int -> Sy_Int)) -> Void;

             tcsetpgrp__syscall:    (Int, Sy_Int) -> Void;
        set__tcsetpgrp__ref:      ({ lib_name: String, fun_name: String, io_call: ((Int, Sy_Int) -> Void) } -> ((Int, Sy_Int) -> Void)) -> Void;
    };                                                                                  # Api Posix_Tty 
end;


## COPYRIGHT (c) 1995 AT&T Bell Laboratories.
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2015,
## released per terms of SMLNJ-COPYRIGHT.


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext