1 /** 2 * D header file for POSIX. 3 * 4 * Copyright: Public Domain 5 * License: Public Domain 6 * Authors: Sean Kelly 7 * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition 8 */ 9 module tango.stdc.posix.termios; 10 11 private import tango.stdc.posix.config; 12 public import tango.stdc.posix.sys.types; // for pid_t 13 private import tango.core.Octal; 14 extern (C): 15 16 // 17 // Required 18 // 19 /* 20 cc_t 21 speed_t 22 tcflag_t 23 24 NCCS 25 26 struct termios 27 { 28 tcflag_t c_iflag; 29 tcflag_t c_oflag; 30 tcflag_t c_cflag; 31 tcflag_t c_lflag; 32 cc_t[NCCS] c_cc; 33 } 34 35 VEOF 36 VEOL 37 VERASE 38 VINTR 39 VKILL 40 VMIN 41 VQUIT 42 VSTART 43 VSTOP 44 VSUSP 45 VTIME 46 47 BRKINT 48 ICRNL 49 IGNBRK 50 IGNCR 51 IGNPAR 52 INLCR 53 INPCK 54 ISTRIP 55 IXOFF 56 IXON 57 PARMRK 58 59 OPOST 60 61 B0 62 B50 63 B75 64 B110 65 B134 66 B150 67 B200 68 B300 69 B600 70 B1200 71 B1800 72 B2400 73 B4800 74 B9600 75 B19200 76 B38400 77 78 CSIZE 79 CS5 80 CS6 81 CS7 82 CS8 83 CSTOPB 84 CREAD 85 PARENB 86 PARODD 87 HUPCL 88 CLOCAL 89 90 ECHO 91 ECHOE 92 ECHOK 93 ECHONL 94 ICANON 95 IEXTEN 96 ISIG 97 NOFLSH 98 TOSTOP 99 100 TCSANOW 101 TCSADRAIN 102 TCSAFLUSH 103 104 TCIFLUSH 105 TCIOFLUSH 106 TCOFLUSH 107 108 TCIOFF 109 TCION 110 TCOOFF 111 TCOON 112 113 speed_t cfgetispeed(in termios*); 114 speed_t cfgetospeed(in termios*); 115 int cfsetispeed(termios*, speed_t); 116 int cfsetospeed(termios*, speed_t); 117 int tcdrain(int); 118 int tcflow(int, int); 119 int tcflush(int, int); 120 int tcgetattr(int, termios*); 121 int tcsendbreak(int, int); 122 int tcsetattr(int, int, in termios*); 123 */ 124 125 version(OSX) 126 { 127 alias ubyte cc_t; 128 alias uint speed_t; 129 alias uint tcflag_t; 130 131 const NCCS = 20; 132 133 struct termios 134 { 135 tcflag_t c_iflag; 136 tcflag_t c_oflag; 137 tcflag_t c_cflag; 138 tcflag_t c_lflag; 139 cc_t[NCCS] c_cc; 140 speed_t c_ispeed; 141 speed_t c_ospeed; 142 } 143 144 const VEOF = 0; 145 const VEOL = 1; 146 const VERASE = 3; 147 const VINTR = 8; 148 const VKILL = 5; 149 const VMIN = 16; 150 const VQUIT = 9; 151 const VSTART = 12; 152 const VSTOP = 13; 153 const VSUSP = 10; 154 const VTIME = 17; 155 156 const BRKINT = 0x0000002; 157 const ICRNL = 0x0000100; 158 const IGNBRK = 0x0000001; 159 const IGNCR = 0x0000080; 160 const IGNPAR = 0x0000004; 161 const INLCR = 0x0000040; 162 const INPCK = 0x0000010; 163 const ISTRIP = 0x0000020; 164 const IXOFF = 0x0000400; 165 const IXON = 0x0000200; 166 const PARMRK = 0x0000008; 167 168 const OPOST = 0x0000001; 169 170 // Posix baudrates 171 const B0 = 0; 172 const B50 = 50; 173 const B75 = 75; 174 const B110 = 110; 175 const B134 = 134; 176 const B150 = 150; 177 const B200 = 200; 178 const B300 = 300; 179 const B600 = 600; 180 const B1200 = 1200; 181 const B1800 = 1800; 182 const B2400 = 2400; 183 const B4800 = 4800; 184 const B9600 = 9600; 185 const B19200 = 19200; 186 const B38400 = 38400; 187 188 // Non-Posix baudrates 189 const B7200 = 7200; 190 const B14400 = 14400; 191 const B28800 = 28800; 192 const B57600 = 57600; 193 const B76800 = 76800; 194 const B115200 = 115200; 195 const B230400 = 230400; 196 197 const CSIZE = 0x0000300; 198 const CS5 = 0x0000000; 199 const CS6 = 0x0000100; 200 const CS7 = 0x0000200; 201 const CS8 = 0x0000300; 202 const CSTOPB = 0x0000400; 203 const CREAD = 0x0000800; 204 const PARENB = 0x0001000; 205 const PARODD = 0x0002000; 206 const HUPCL = 0x0004000; 207 const CLOCAL = 0x0008000; 208 209 const ECHO = 0x00000008; 210 const ECHOE = 0x00000002; 211 const ECHOK = 0x00000004; 212 const ECHONL = 0x00000010; 213 const ICANON = 0x00000100; 214 const IEXTEN = 0x00000400; 215 const ISIG = 0x00000080; 216 const NOFLSH = 0x80000000; 217 const TOSTOP = 0x00400000; 218 219 const TCSANOW = 0; 220 const TCSADRAIN = 1; 221 const TCSAFLUSH = 2; 222 223 const TCIFLUSH = 1; 224 const TCOFLUSH = 2; 225 const TCIOFLUSH = 3; 226 227 const TCIOFF = 3; 228 const TCION = 4; 229 const TCOOFF = 1; 230 const TCOON = 2; 231 232 speed_t cfgetispeed(in termios*); 233 speed_t cfgetospeed(in termios*); 234 int cfsetispeed(termios*, speed_t); 235 int cfsetospeed(termios*, speed_t); 236 int tcdrain(int); 237 int tcflow(int, int); 238 int tcflush(int, int); 239 int tcgetattr(int, termios*); 240 int tcsendbreak(int, int); 241 int tcsetattr(int, int, in termios*); 242 243 } 244 else version( linux ) 245 { 246 alias ubyte cc_t; 247 alias uint speed_t; 248 alias uint tcflag_t; 249 250 const NCCS = 32; 251 252 struct termios 253 { 254 tcflag_t c_iflag; 255 tcflag_t c_oflag; 256 tcflag_t c_cflag; 257 tcflag_t c_lflag; 258 cc_t c_line; 259 cc_t[NCCS] c_cc; 260 speed_t c_ispeed; 261 speed_t c_ospeed; 262 } 263 264 const VEOF = 4; 265 const VEOL = 11; 266 const VERASE = 2; 267 const VINTR = 0; 268 const VKILL = 3; 269 const VMIN = 6; 270 const VQUIT = 1; 271 const VSTART = 8; 272 const VSTOP = 9; 273 const VSUSP = 10; 274 const VTIME = 5; 275 276 const BRKINT = octal!2; 277 const ICRNL = octal!400; 278 const IGNBRK = octal!1; 279 const IGNCR = octal!200; 280 const IGNPAR = octal!4; 281 const INLCR = octal!100; 282 const INPCK = octal!20; 283 const ISTRIP = octal!40; 284 const IXOFF = octal!10000; 285 const IXON = octal!2000; 286 const PARMRK = octal!10; 287 288 const OPOST = octal!1; 289 290 // Posix baudrates 291 const B0 = 0; 292 const B50 = octal!1; 293 const B75 = octal!2; 294 const B110 = octal!3; 295 const B134 = octal!4; 296 const B150 = octal!5; 297 const B200 = octal!6; 298 const B300 = octal!7; 299 const B600 = octal!10; 300 const B1200 = octal!11; 301 const B1800 = octal!12; 302 const B2400 = octal!13; 303 const B4800 = octal!14; 304 const B9600 = octal!15; 305 const B19200 = octal!16; 306 const B38400 = octal!17; 307 308 // Non-Posix baudrates 309 const B57600 = octal!10001; 310 const B115200 = octal!10002; 311 const B230400 = octal!10003; 312 const B460800 = octal!10004; 313 const B500000 = octal!10005; 314 const B576000 = octal!10006; 315 const B921600 = octal!10007; 316 const B1000000 = octal!10010; 317 const B1152000 = octal!10011; 318 const B1500000 = octal!10012; 319 const B2000000 = octal!10013; 320 const B2500000 = octal!10014; 321 const B3000000 = octal!10015; 322 const B3500000 = octal!10016; 323 const B4000000 = octal!10017; 324 325 const CSIZE = octal!60; 326 const CS5 = 0; 327 const CS6 = octal!20; 328 const CS7 = octal!40; 329 const CS8 = octal!60; 330 const CSTOPB = octal!100; 331 const CREAD = octal!200; 332 const PARENB = octal!400; 333 const PARODD = octal!1000; 334 const HUPCL = octal!2000; 335 const CLOCAL = octal!4000; 336 337 const ECHO = octal!10; 338 const ECHOE = octal!20; 339 const ECHOK = octal!40; 340 const ECHONL = octal!100; 341 const ICANON = octal!2; 342 const IEXTEN = octal!100000; 343 const ISIG = octal!1; 344 const NOFLSH = octal!200; 345 const TOSTOP = octal!400; 346 347 const TCSANOW = 0; 348 const TCSADRAIN = 1; 349 const TCSAFLUSH = 2; 350 351 const TCIFLUSH = 0; 352 const TCOFLUSH = 1; 353 const TCIOFLUSH = 2; 354 355 const TCIOFF = 2; 356 const TCION = 3; 357 const TCOOFF = 0; 358 const TCOON = 1; 359 360 speed_t cfgetispeed(in termios*); 361 speed_t cfgetospeed(in termios*); 362 int cfsetispeed(termios*, speed_t); 363 int cfsetospeed(termios*, speed_t); 364 int tcdrain(int); 365 int tcflow(int, int); 366 int tcflush(int, int); 367 int tcgetattr(int, termios*); 368 int tcsendbreak(int, int); 369 int tcsetattr(int, int, in termios*); 370 } 371 else version (FreeBSD) 372 { 373 alias ubyte cc_t; 374 alias uint speed_t; 375 alias uint tcflag_t; 376 377 const NCCS = 20; 378 379 struct termios 380 { 381 tcflag_t c_iflag; 382 tcflag_t c_oflag; 383 tcflag_t c_cflag; 384 tcflag_t c_lflag; 385 cc_t[NCCS] c_cc; 386 speed_t c_ispeed; 387 speed_t c_ospeed; 388 } 389 390 const VEOF = 0; 391 const VEOL = 1; 392 const VERASE = 3; 393 const VINTR = 8; 394 const VKILL = 5; 395 const VMIN = 16; 396 const VQUIT = 9; 397 const VSTART = 12; 398 const VSTOP = 13; 399 const VSUSP = 10; 400 const VTIME = 17; 401 402 const BRKINT = 0x0000002; 403 const ICRNL = 0x0000100; 404 const IGNBRK = 0x0000001; 405 const IGNCR = 0x0000080; 406 const IGNPAR = 0x0000004; 407 const INLCR = 0x0000040; 408 const INPCK = 0x0000010; 409 const ISTRIP = 0x0000020; 410 const IXOFF = 0x0000400; 411 const IXON = 0x0000200; 412 const PARMRK = 0x0000008; 413 414 const OPOST = 0x0000001; 415 416 // Posix baudrates 417 const B0 = 0; 418 const B50 = 50; 419 const B75 = 75; 420 const B110 = 110; 421 const B134 = 134; 422 const B150 = 150; 423 const B200 = 200; 424 const B300 = 300; 425 const B600 = 600; 426 const B1200 = 1200; 427 const B1800 = 1800; 428 const B2400 = 2400; 429 const B4800 = 4800; 430 const B9600 = 9600; 431 const B19200 = 19200; 432 const B38400 = 38400; 433 434 // Non-Posix baudrates 435 const B7200 = 7200; 436 const B14400 = 14400; 437 const B28800 = 28800; 438 const B57600 = 57600; 439 const B76800 = 76800; 440 const B115200 = 115200; 441 const B230400 = 230400; 442 const B460800 = 460800; 443 const B921600 = 921600; 444 445 const CSIZE = 0x0000300; 446 const CS5 = 0x0000000; 447 const CS6 = 0x0000100; 448 const CS7 = 0x0000200; 449 const CS8 = 0x0000300; 450 const CSTOPB = 0x0000400; 451 const CREAD = 0x0000800; 452 const PARENB = 0x0001000; 453 const PARODD = 0x0002000; 454 const HUPCL = 0x0004000; 455 const CLOCAL = 0x0008000; 456 457 const ECHO = 0x00000008; 458 const ECHOE = 0x00000002; 459 const ECHOK = 0x00000004; 460 const ECHONL = 0x00000010; 461 const ICANON = 0x00000100; 462 const IEXTEN = 0x00000400; 463 const ISIG = 0x00000080; 464 const NOFLSH = 0x80000000; 465 const TOSTOP = 0x00400000; 466 467 const TCSANOW = 0; 468 const TCSADRAIN = 1; 469 const TCSAFLUSH = 2; 470 471 const TCIFLUSH = 1; 472 const TCOFLUSH = 2; 473 const TCIOFLUSH = 3; 474 475 const TCIOFF = 3; 476 const TCION = 4; 477 const TCOOFF = 1; 478 const TCOON = 2; 479 480 speed_t cfgetispeed(in termios*); 481 speed_t cfgetospeed(in termios*); 482 int cfsetispeed(termios*, speed_t); 483 int cfsetospeed(termios*, speed_t); 484 int tcdrain(int); 485 int tcflow(int, int); 486 int tcflush(int, int); 487 int tcgetattr(int, termios*); 488 int tcsendbreak(int, int); 489 int tcsetattr(int, int, in termios*); 490 491 } 492 else version ( solaris ) 493 { 494 alias ubyte cc_t; 495 alias uint speed_t; 496 alias uint tcflag_t; 497 498 const NCCS = 19; 499 500 struct termios 501 { 502 tcflag_t c_iflag; /* input modes */ 503 tcflag_t c_oflag; /* output modes */ 504 tcflag_t c_cflag; /* control modes */ 505 tcflag_t c_lflag; /* line discipline modes */ 506 cc_t[NCCS] c_cc; /* control chars */ 507 } 508 509 const VEOF = 4; 510 const VEOL = 5; 511 const VERASE = 2; 512 const VINTR = 0; 513 const VKILL = 3; 514 const VMIN = 4; 515 const VQUIT = 1; 516 const VSTART = 8; 517 const VSTOP = 9; 518 const VSUSP = 11; 519 const VTIME = 5; 520 521 const BRKINT = octal!2; 522 const ICRNL = octal!400; 523 const IGNBRK = octal!1; 524 const IGNCR = octal!200; 525 const IGNPAR = octal!4; 526 const INLCR = octal!100; 527 const INPCK = octal!20; 528 const ISTRIP = octal!40; 529 const IXOFF = octal!10000; 530 const IXON = octal!2000; 531 const PARMRK = octal!10; 532 533 const OPOST = octal!1; 534 535 // Posix baudrates 536 const B0 = 0; 537 const B50 = 1; 538 const B75 = 2; 539 const B110 = 3; 540 const B134 = 4; 541 const B150 = 5; 542 const B200 = 6; 543 const B300 = 7; 544 const B600 = 8; 545 const B1200 = 9; 546 const B1800 = 10; 547 const B2400 = 11; 548 const B4800 = 12; 549 const B9600 = 13; 550 const B19200 = 14; 551 const B38400 = 15; 552 553 // Non-Posix baudrates 554 const B57600 = 16; 555 const B76800 = 17; 556 const B115200 = 18; 557 const B153600 = 19; 558 const B230400 = 20; 559 const B307200 = 21; 560 const B460800 = 22; 561 562 const CSIZE = octal!60; 563 const CS5 = 0; 564 const CS6 = octal!20; 565 const CS7 = octal!40; 566 const CS8 = octal!60; 567 const CSTOPB = octal!100; 568 const CREAD = octal!200; 569 const PARENB = octal!400; 570 const PARODD = octal!1000; 571 const HUPCL = octal!2000; 572 const CLOCAL = octal!4000; 573 574 const ECHO = octal!10; 575 const ECHOE = octal!20; 576 const ECHOK = octal!40; 577 const ECHONL = octal!100; 578 const ICANON = octal!2; 579 const IEXTEN = octal!100000; 580 const ISIG = octal!1; 581 const NOFLSH = octal!200; 582 const TOSTOP = octal!400; 583 584 const TIOC = ('T'<<8); 585 586 const TCSANOW = TIOC|14; 587 const TCSADRAIN = TIOC|15; 588 const TCSAFLUSH = TIOC|16; 589 590 const TCIFLUSH = 0; 591 const TCOFLUSH = 1; 592 const TCIOFLUSH = 2; 593 594 const TCIOFF = 2; 595 const TCION = 3; 596 const TCOOFF = 0; 597 const TCOON = 1; 598 599 speed_t cfgetispeed(in termios*); 600 speed_t cfgetospeed(in termios*); 601 int cfsetispeed(termios*, speed_t); 602 int cfsetospeed(termios*, speed_t); 603 int tcdrain(int); 604 int tcflow(int, int); 605 int tcflush(int, int); 606 int tcgetattr(int, termios*); 607 int tcsendbreak(int, int); 608 int tcsetattr(int, int, in termios*); 609 } 610 611 // 612 // XOpen (XSI) 613 // 614 /* 615 IXANY 616 617 ONLCR 618 OCRNL 619 ONOCR 620 ONLRET 621 OFILL 622 NLDLY 623 NL0 624 NL1 625 CRDLY 626 CR0 627 CR1 628 CR2 629 CR3 630 TABDLY 631 TAB0 632 TAB1 633 TAB2 634 TAB3 635 BSDLY 636 BS0 637 BS1 638 VTDLY 639 VT0 640 VT1 641 FFDLY 642 FF0 643 FF1 644 645 pid_t tcgetsid(int); 646 */ 647 648 version( linux ) 649 { 650 const IXANY = octal!4000; 651 652 const ONLCR = octal!4; 653 const OCRNL = octal!10; 654 const ONOCR = octal!20; 655 const ONLRET = octal!40; 656 const OFILL = octal!100; 657 const NLDLY = octal!400; 658 const NL0 = 0; 659 const NL1 = octal!400; 660 const CRDLY = octal!3000; 661 const CR0 = 0; 662 const CR1 = octal!1000; 663 const CR2 = octal!2000; 664 const CR3 = octal!3000; 665 const TABDLY = octal!14000; 666 const TAB0 = 0; 667 const TAB1 = octal!4000; 668 const TAB2 = octal!10000; 669 const TAB3 = octal!14000; 670 const BSDLY = octal!20000; 671 const BS0 = 0; 672 const BS1 = octal!20000; 673 const VTDLY = octal!40000; 674 const VT0 = 0; 675 const VT1 = octal!40000; 676 const FFDLY = octal!100000; 677 const FF0 = 0; 678 const FF1 = octal!100000; 679 680 pid_t tcgetsid(int); 681 } 682 else version( solaris ) 683 { 684 const IXANY = octal!4000; 685 686 const ONLCR = octal!4; 687 const OCRNL = octal!10; 688 const ONOCR = octal!20; 689 const ONLRET = octal!40; 690 const OFILL = octal!100; 691 const NLDLY = octal!400; 692 const NL0 = 0; 693 const NL1 = octal!400; 694 const CRDLY = octal!3000; 695 const CR0 = 0; 696 const CR1 = octal!1000; 697 const CR2 = octal!2000; 698 const CR3 = octal!3000; 699 const TABDLY = octal!14000; 700 const TAB0 = 0; 701 const TAB1 = octal!4000; 702 const TAB2 = octal!10000; 703 const TAB3 = octal!14000; 704 705 const BSDLY = octal!20000; 706 const BS0 = 0; 707 const BS1 = octal!20000; 708 const VTDLY = octal!40000; 709 const VT0 = 0; 710 const VT1 = octal!40000; 711 const FFDLY = octal!100000; 712 const FF0 = 0; 713 const FF1 = octal!100000; 714 715 pid_t tcgetsid(int); 716 }