Commit d92b5fcfb0

Nikita Ronja <nikita@NetBSD.org>
2023-03-30 21:57:37
Add NetBSD termios constants to std.c.netbsd
1 parent 66520c8
Changed files (1)
lib
lib/std/c/netbsd.zig
@@ -915,6 +915,143 @@ pub const T = struct {
     pub const IOCXMTFRAME = 0x80087444;
 };
 
+// Term
+const V = struct {
+    pub const EOF = 0; // ICANON
+    pub const EOL = 1; // ICANON
+    pub const EOL2 = 2; // ICANON
+    pub const ERASE = 3; // ICANON
+    pub const WERASE = 4; // ICANON
+    pub const KILL = 5; // ICANON
+    pub const REPRINT = 6; // ICANON
+    //  7    spare 1
+    pub const INTR = 8; // ISIG
+    pub const QUIT = 9; // ISIG
+    pub const SUSP = 10; // ISIG
+    pub const DSUSP = 11; // ISIG
+    pub const START = 12; // IXON, IXOFF
+    pub const STOP = 13; // IXON, IXOFF
+    pub const LNEXT = 14; // IEXTEN
+    pub const DISCARD = 15; // IEXTEN
+    pub const MIN = 16; // !ICANON
+    pub const TIME = 17; // !ICANON
+    pub const STATUS = 18; // ICANON
+    //  19      spare 2
+};
+
+// Input flags - software input processing
+pub const IGNBRK: tcflag_t = 0x00000001; // ignore BREAK condition
+pub const BRKINT: tcflag_t = 0x00000002; // map BREAK to SIGINT
+pub const IGNPAR: tcflag_t = 0x00000004; // ignore (discard) parity errors
+pub const PARMRK: tcflag_t = 0x00000008; // mark parity and framing errors
+pub const INPCK: tcflag_t = 0x00000010; // enable checking of parity errors
+pub const ISTRIP: tcflag_t = 0x00000020; // strip 8th bit off chars
+pub const INLCR: tcflag_t = 0x00000040; // map NL into CR
+pub const IGNCR: tcflag_t = 0x00000080; // ignore CR
+pub const ICRNL: tcflag_t = 0x00000100; // map CR to NL (ala CRMOD)
+pub const IXON: tcflag_t = 0x00000200; // enable output flow control
+pub const IXOFF: tcflag_t = 0x00000400; // enable input flow control
+pub const IXANY: tcflag_t = 0x00000800; // any char will restart after stop
+pub const IMAXBEL: tcflag_t = 0x00002000; // ring bell on input queue full
+
+// Output flags - software output processing
+pub const OPOST: tcflag_t = 0x00000001; // enable following output processing
+pub const ONLCR: tcflag_t = 0x00000002; // map NL to CR-NL (ala CRMOD)
+pub const OXTABS: tcflag_t = 0x00000004; // expand tabs to spaces
+pub const ONOEOT: tcflag_t = 0x00000008; // discard EOT's (^D) on output
+pub const OCRNL: tcflag_t = 0x00000010; // map CR to NL
+pub const ONOCR: tcflag_t = 0x00000040; // discard CR's when on column 0
+pub const ONLRET: tcflag_t = 0x00000080; // move to column 0 on CR
+
+// Control flags - hardware control of terminal
+pub const CIGNORE: tcflag_t = 0x00000001; // ignore control flags
+pub const CSIZE: tcflag_t = 0x00000300; // character size mask
+pub const CS5: tcflag_t = 0x00000000; // 5 bits (pseudo)
+pub const CS6: tcflag_t = 0x00000100; // 6 bits
+pub const CS7: tcflag_t = 0x00000200; // 7 bits
+pub const CS8: tcflag_t = 0x00000300; // 8 bits
+pub const CSTOPB: tcflag_t = 0x00000400; // send 2 stop bits
+pub const CREAD: tcflag_t = 0x00000800; // enable receiver
+pub const PARENB: tcflag_t = 0x00001000; // parity enable
+pub const PARODD: tcflag_t = 0x00002000; // odd parity, else even
+pub const HUPCL: tcflag_t = 0x00004000; // hang up on last close
+pub const CLOCAL: tcflag_t = 0x00008000; // ignore modem status lines
+pub const CRTSCTS: tcflag_t = 0x00010000; // RTS/CTS full-duplex flow control
+pub const CRTS_IFLOW: tcflag_t = CRTSCTS; // XXX compat
+pub const CCTS_OFLOW: tcflag_t = CRTSCTS; // XXX compat
+pub const CDTRCTS: tcflag_t = 0x00020000; // DTR/CTS full-duplex flow control
+pub const MDMBUF: tcflag_t = 0x00100000; // DTR/DCD hardware flow control
+pub const CHWFLOW: tcflag_t = (MDMBUF | CRTSCTS | CDTRCTS); // all types of hw flow control
+
+pub const tcflag_t = c_uint;
+pub const speed_t = c_uint;
+pub const cc_t = u8;
+
+pub const NCCS = 20;
+
+pub const termios = extern struct {
+    iflag: tcflag_t, // input flags
+    oflag: tcflag_t, // output flags
+    cflag: tcflag_t, // control flags
+    lflag: tcflag_t, // local flags
+    cc: [NCCS]cc_t, // control chars
+    ispeed: c_int, // input speed
+    ospeed: c_int, // output speed
+};
+
+// Commands passed to tcsetattr() for setting the termios structure.
+pub const TCSA = struct {
+    pub const NOW = 0; // make change immediate
+    pub const DRAIN = 1; // drain output, then chage
+    pub const FLUSH = 2; // drain output, flush input
+    pub const SOFT = 0x10; // flag - don't alter h.w. state
+};
+
+// Standard speeds
+pub const B0: c_uint = 0;
+pub const B50: c_uint = 50;
+pub const B75: c_uint = 75;
+pub const B110: c_uint = 110;
+pub const B134: c_uint = 134;
+pub const B150: c_uint = 150;
+pub const B200: c_uint = 200;
+pub const B300: c_uint = 300;
+pub const B600: c_uint = 600;
+pub const B1200: c_uint = 1200;
+pub const B1800: c_uint = 1800;
+pub const B2400: c_uint = 2400;
+pub const B4800: c_uint = 4800;
+pub const B9600: c_uint = 9600;
+pub const B19200: c_uint = 19200;
+pub const B38400: c_uint = 38400;
+pub const B7200: c_uint = 7200;
+pub const B14400: c_uint = 14400;
+pub const B28800: c_uint = 28800;
+pub const B57600: c_uint = 57600;
+pub const B76800: c_uint = 76800;
+pub const B115200: c_uint = 115200;
+pub const B230400: c_uint = 230400;
+pub const B460800: c_uint = 460800;
+pub const B500000: c_uint = 500000;
+pub const B921600: c_uint = 921600;
+pub const B1000000: c_uint = 1000000;
+pub const B1500000: c_uint = 1500000;
+pub const B2000000: c_uint = 2000000;
+pub const B2500000: c_uint = 2500000;
+pub const B3000000: c_uint = 3000000;
+pub const B3500000: c_uint = 3500000;
+pub const B4000000: c_uint = 4000000;
+pub const EXTA: c_uint = 19200;
+pub const EXTB: c_uint = 38400;
+
+pub const TCIFLUSH = 1;
+pub const TCOFLUSH = 2;
+pub const TCIOFLUSH = 3;
+pub const TCOOFF = 1;
+pub const TCOON = 2;
+pub const TCIOFF = 3;
+pub const TCION = 4;
+
 pub const winsize = extern struct {
     ws_row: u16,
     ws_col: u16,