1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949
|
/*
A termios library for Ruby.
Copyright (C) 1999, 2000, 2002 akira yamada.
$Id: termios.c,v 1.8 2002/10/12 15:15:25 akira Exp $
*/
#include "ruby.h"
#include "rubyio.h"
#include <termios.h>
#include <unistd.h>
#include <string.h>
static VALUE mTermios;
static VALUE cTermios;
static VALUE tcsetattr_opt, tcflush_qs, tcflow_act;
static ID id_iflag, id_oflag, id_cflag, id_lflag, id_cc, id_ispeed, id_ospeed;
static VALUE
termios_set_iflag(self, value)
VALUE self, value;
{
Check_Type(value, T_FIXNUM);
rb_ivar_set(self, id_iflag, value);
return value;
}
static VALUE
termios_set_oflag(self, value)
VALUE self, value;
{
Check_Type(value, T_FIXNUM);
rb_ivar_set(self, id_oflag, value);
return value;
}
static VALUE
termios_set_cflag(self, value)
VALUE self, value;
{
Check_Type(value, T_FIXNUM);
rb_ivar_set(self, id_cflag, value);
return value;
}
static VALUE
termios_set_lflag(self, value)
VALUE self, value;
{
Check_Type(value, T_FIXNUM);
rb_ivar_set(self, id_lflag, value);
return value;
}
static VALUE
termios_set_cc(self, value)
VALUE self, value;
{
Check_Type(value, T_ARRAY);
rb_ivar_set(self, id_cc, value);
return value;
}
static VALUE
termios_set_ispeed(self, value)
VALUE self, value;
{
Check_Type(value, T_FIXNUM);
rb_ivar_set(self, id_ispeed, value);
return value;
}
static VALUE
termios_set_ospeed(self, value)
VALUE self, value;
{
Check_Type(value, T_FIXNUM);
rb_ivar_set(self, id_ospeed, value);
return value;
}
static VALUE
termios_initialize(argc, argv, self)
int argc;
VALUE *argv;
VALUE self;
{
VALUE c_iflag, c_oflag, c_cflag, c_lflag, c_cc, c_ispeed, c_ospeed;
VALUE cc_ary;
int i;
cc_ary = rb_ary_new2(NCCS);
for (i = 0; i < NCCS; i++) {
rb_ary_store(cc_ary, i, INT2FIX(0));
}
rb_ivar_set(self, id_iflag, Qnil);
rb_ivar_set(self, id_oflag, Qnil);
rb_ivar_set(self, id_cflag, Qnil);
rb_ivar_set(self, id_lflag, Qnil);
rb_ivar_set(self, id_cc, cc_ary);
rb_ivar_set(self, id_ispeed, Qnil);
rb_ivar_set(self, id_ospeed, Qnil);
rb_scan_args(argc, argv, "07",
&c_iflag, &c_oflag, &c_cflag, &c_lflag,
&c_cc, &c_ispeed, &c_ospeed);
if (!NIL_P(c_iflag))
termios_set_iflag(self, c_iflag);
if (!NIL_P(c_oflag))
termios_set_oflag(self, c_oflag);
if (!NIL_P(c_cflag))
termios_set_cflag(self, c_cflag);
if (!NIL_P(c_lflag))
termios_set_lflag(self, c_lflag);
if (!NIL_P(c_cc))
termios_set_cc(self, c_cc);
if (!NIL_P(c_ispeed))
termios_set_ispeed(self, c_ispeed);
if (!NIL_P(c_ospeed))
termios_set_ispeed(self, c_ospeed);
return self;
}
static VALUE
termios_to_Termios(t)
struct termios *t;
{
int i;
VALUE obj, cc_ary;
obj = rb_funcall(cTermios, rb_intern("new"), 0);
termios_set_iflag(obj, INT2FIX(t->c_iflag));
termios_set_oflag(obj, INT2FIX(t->c_oflag));
termios_set_cflag(obj, INT2FIX(t->c_cflag));
termios_set_lflag(obj, INT2FIX(t->c_lflag));
cc_ary = rb_ary_new2(NCCS);
for (i = 0; i < NCCS; i++) {
rb_ary_store(cc_ary, i, INT2FIX(t->c_cc[i]));
}
termios_set_cc(obj, cc_ary);
termios_set_ispeed(obj, INT2FIX(cfgetispeed(t)));
termios_set_ospeed(obj, INT2FIX(cfgetospeed(t)));
return obj;
}
static void
Termios_to_termios(obj, t)
VALUE obj;
struct termios *t;
{
int i;
VALUE cc_ary;
t->c_iflag = FIX2INT(rb_ivar_get(obj, id_iflag));
t->c_oflag = FIX2INT(rb_ivar_get(obj, id_oflag));
t->c_cflag = FIX2INT(rb_ivar_get(obj, id_cflag));
t->c_lflag = FIX2INT(rb_ivar_get(obj, id_lflag));
cc_ary = rb_ivar_get(obj, id_cc);
for (i = 0; i < NCCS; i++) {
if (TYPE(RARRAY(cc_ary)->ptr[i]) == T_FIXNUM) {
t->c_cc[i] = NUM2INT(RARRAY(cc_ary)->ptr[i]);
}
else {
t->c_cc[i] = 0;
}
}
cfsetispeed(t, FIX2INT(rb_ivar_get(obj, id_ispeed)));
cfsetospeed(t, FIX2INT(rb_ivar_get(obj, id_ospeed)));
}
static VALUE
termios_tcgetattr(io)
VALUE io;
{
struct termios t;
OpenFile *fptr;
Check_Type(io, T_FILE);
GetOpenFile(io, fptr);
if (tcgetattr(fileno(fptr->f), &t) < 0) {
rb_raise(rb_eRuntimeError,
"can't get terminal parameters (%s)", strerror(errno));
}
return termios_to_Termios(&t);
}
static VALUE
termios_s_tcgetattr(obj, io)
VALUE obj, io;
{
return termios_tcgetattr(io);
}
static VALUE
termios_tcsetattr(io, opt, param)
VALUE io, opt, param;
{
VALUE old;
OpenFile *fptr;
struct termios t;
int tcsetattr_option;
Check_Type(io, T_FILE);
Check_Type(opt, T_FIXNUM);
if (CLASS_OF(param) != cTermios) {
char *type = rb_class2name(CLASS_OF(param));
rb_raise(rb_eArgError,
"wrong argument type %s (expected Termios::Termios)",
type);
}
tcsetattr_option = FIX2INT(opt);
if (rb_ary_includes(tcsetattr_opt, opt) != Qtrue) {
rb_raise(rb_eArgError,
"wrong option value %d", tcsetattr_option);
}
old = termios_tcgetattr(io);
GetOpenFile(io, fptr);
Termios_to_termios(param, &t);
if (tcsetattr(fileno(fptr->f), tcsetattr_option, &t) < 0) {
rb_raise(rb_eRuntimeError,
"can't set terminal parameters (%s)", strerror(errno));
}
return old;
}
static VALUE
termios_s_tcsetattr(obj, io, opt, param)
VALUE obj, io, opt, param;
{
return termios_tcsetattr(io, opt, param);
}
static VALUE
termios_tcsendbreak(io, duration)
VALUE io, duration;
{
OpenFile *fptr;
Check_Type(io, T_FILE);
Check_Type(duration, T_FIXNUM);
GetOpenFile(io, fptr);
if (tcsendbreak(fileno(fptr->f), FIX2INT(duration)) < 0) {
rb_raise(rb_eRuntimeError,
"can't transmits break (%s)", strerror(errno));
}
return Qtrue;
}
static VALUE
termios_s_tcsendbreak(obj, io, duration)
VALUE obj, io, duration;
{
return termios_tcsendbreak(io, duration);
}
static VALUE
termios_tcdrain(io)
VALUE io;
{
OpenFile *fptr;
Check_Type(io, T_FILE);
GetOpenFile(io, fptr);
if (tcdrain(fileno(fptr->f)) < 0) {
rb_raise(rb_eRuntimeError, "can't drain (%s)", strerror(errno));
}
return Qtrue;
}
static VALUE
termios_s_tcdrain(obj, io)
VALUE obj, io;
{
return termios_tcdrain(io);
}
static VALUE
termios_tcflush(io, qs)
VALUE io, qs;
{
OpenFile *fptr;
int queue_selector;
Check_Type(io, T_FILE);
Check_Type(qs, T_FIXNUM);
queue_selector = FIX2INT(qs);
if (rb_ary_includes(tcflush_qs, qs) != Qtrue) {
rb_raise(rb_eTypeError,
"wrong queue-selector value %d", queue_selector);
}
GetOpenFile(io, fptr);
if (tcflush(fileno(fptr->f), queue_selector) < 0) {
rb_raise(rb_eRuntimeError, "can't flush (%s)", strerror(errno));
}
return Qtrue;
}
static VALUE
termios_s_tcflush(obj, io, qs)
VALUE obj, io, qs;
{
return termios_tcflush(io, qs);
}
static VALUE
termios_tcflow(io, act)
VALUE io, act;
{
OpenFile *fptr;
int action;
Check_Type(io, T_FILE);
Check_Type(act, T_FIXNUM);
action = FIX2INT(act);
if (rb_ary_includes(tcflow_act, act) != Qtrue) {
rb_raise(rb_eArgError,
"wrong action value %d", action);
}
GetOpenFile(io, fptr);
if (tcflow(fileno(fptr->f), action) < 0) {
rb_raise(rb_eRuntimeError,
"can't control transmitting data flow (%s)", strerror(errno));
}
return Qtrue;
}
static VALUE
termios_s_tcflow(obj, io, act)
VALUE obj, io, act;
{
return termios_tcflow(io, act);
}
static VALUE
termios_tcgetpgrp(io)
VALUE io;
{
OpenFile *fptr;
int pid;
Check_Type(io, T_FILE);
GetOpenFile(io, fptr);
if ((pid = tcgetpgrp(fileno(fptr->f))) < 0) {
rb_raise(rb_eRuntimeError,
"can't get process group id (%s)", strerror(errno));
}
return INT2FIX(pid);
}
static VALUE
termios_s_tcgetpgrp(obj, io)
VALUE obj, io;
{
return termios_tcgetpgrp(io);
}
static VALUE
termios_tcsetpgrp(io, pgrpid)
VALUE io, pgrpid;
{
OpenFile *fptr;
Check_Type(io, T_FILE);
Check_Type(pgrpid, T_FIXNUM);
GetOpenFile(io, fptr);
if (tcsetpgrp(fileno(fptr->f), FIX2INT(pgrpid)) < 0) {
rb_raise(rb_eRuntimeError,
"can't set process group id (%s)", strerror(errno));
}
return Qtrue;
}
static VALUE
termios_s_tcsetpgrp(obj, io, pgrpid)
VALUE obj, io, pgrpid;
{
return termios_tcsetpgrp(io, pgrpid);
}
static VALUE
termios_s_newtermios(argc, argv, klass)
int argc;
VALUE *argv;
VALUE klass;
{
return rb_funcall2(cTermios, rb_intern("new"), argc, argv);
}
void
Init_termios()
{
VALUE ccindex, iflags, oflags, cflags, lflags, bauds;
/* module Termios */
mTermios = rb_define_module("Termios");
rb_define_module_function(mTermios,"tcgetattr", termios_s_tcgetattr, 1);
rb_define_module_function(mTermios, "getattr", termios_s_tcgetattr, 1);
rb_define_method(mTermios, "tcgetattr", termios_tcgetattr, 0);
rb_define_module_function(mTermios,"tcsetattr", termios_s_tcsetattr, 3);
rb_define_module_function(mTermios, "setattr", termios_s_tcsetattr, 3);
rb_define_method(mTermios, "tcsetattr", termios_tcsetattr, 2);
rb_define_module_function(mTermios,"tcsendbreak",termios_s_tcsendbreak,2);
rb_define_module_function(mTermios, "sendbreak",termios_s_tcsendbreak,2);
rb_define_method(mTermios, "tcsendbreak",termios_tcsendbreak, 1);
rb_define_module_function(mTermios,"tcdrain", termios_s_tcdrain, 1);
rb_define_module_function(mTermios, "drain", termios_s_tcdrain, 1);
rb_define_method(mTermios, "tcdrain", termios_tcdrain, 0);
rb_define_module_function(mTermios,"tcflush", termios_s_tcflush, 2);
rb_define_module_function(mTermios, "flush", termios_s_tcflush, 2);
rb_define_method(mTermios, "tcflush", termios_tcflush, 1);
rb_define_module_function(mTermios,"tcflow", termios_s_tcflow, 2);
rb_define_module_function(mTermios, "flow", termios_s_tcflow, 2);
rb_define_method(mTermios, "tcflow", termios_tcflow, 1);
rb_define_module_function(mTermios,"tcgetpgrp", termios_s_tcgetpgrp, 1);
rb_define_module_function(mTermios, "getpgrp", termios_s_tcgetpgrp, 1);
rb_define_method(mTermios, "tcgetpgrp", termios_tcgetpgrp, 0);
rb_define_module_function(mTermios,"tcsetpgrp", termios_s_tcsetpgrp, 2);
rb_define_module_function(mTermios, "setpgrp", termios_s_tcsetpgrp, 2);
rb_define_method(mTermios, "tcsetpgrp", termios_tcsetpgrp, 1);
rb_define_module_function(mTermios,"new_termios",termios_s_newtermios, -1);
/* class Termios::Termios */
cTermios = rb_define_class_under(mTermios, "Termios", rb_cObject);
id_iflag = rb_intern("@iflag");
id_oflag = rb_intern("@oflag");
id_cflag = rb_intern("@cflag");
id_lflag = rb_intern("@lflag");
id_cc = rb_intern("@cc");
id_ispeed = rb_intern("@ispeed");
id_ospeed = rb_intern("@ospeed");
rb_attr(cTermios, rb_intern("iflag"), 1, 0, Qtrue);
rb_attr(cTermios, rb_intern("oflag"), 1, 0, Qtrue);
rb_attr(cTermios, rb_intern("cflag"), 1, 0, Qtrue);
rb_attr(cTermios, rb_intern("lflag"), 1, 0, Qtrue);
rb_attr(cTermios, rb_intern("cc"), 1, 0, Qtrue);
rb_attr(cTermios, rb_intern("ispeed"), 1, 0, Qtrue);
rb_attr(cTermios, rb_intern("ospeed"), 1, 0, Qtrue);
rb_define_private_method(cTermios, "initialize", termios_initialize, -1);
rb_define_method(cTermios, "iflag=", termios_set_iflag, 1);
rb_define_method(cTermios, "oflag=", termios_set_oflag, 1);
rb_define_method(cTermios, "cflag=", termios_set_cflag, 1);
rb_define_method(cTermios, "lflag=", termios_set_lflag, 1);
rb_define_method(cTermios, "cc=", termios_set_cc, 1);
rb_define_method(cTermios, "ispeed=", termios_set_ispeed, 1);
rb_define_method(cTermios, "ospeed=", termios_set_ospeed, 1);
rb_define_alias(cTermios, "c_iflag", "iflag");
rb_define_alias(cTermios, "c_iflag=", "iflag=");
rb_define_alias(cTermios, "c_oflag", "oflag");
rb_define_alias(cTermios, "c_oflag=", "oflag=");
rb_define_alias(cTermios, "c_cflag", "cflag");
rb_define_alias(cTermios, "c_cflag=", "cflag=");
rb_define_alias(cTermios, "c_lflag", "lflag");
rb_define_alias(cTermios, "c_lflag=", "lflag=");
rb_define_alias(cTermios, "c_cc", "cc");
rb_define_alias(cTermios, "c_cc=", "cc=");
rb_define_alias(cTermios, "c_ispeed", "ispeed");
rb_define_alias(cTermios, "c_ispeed=", "ispeed=");
rb_define_alias(cTermios, "c_ospeed", "ospeed");
rb_define_alias(cTermios, "c_ospeed=", "ospeed=");
/* constants under Termios module */
rb_define_const(mTermios, "NCCS", INT2FIX(NCCS));
ccindex = rb_hash_new();
rb_define_const(mTermios, "CCINDEX", ccindex);
iflags = rb_hash_new();
rb_define_const(mTermios, "IFLAGS", iflags);
oflags = rb_hash_new();
rb_define_const(mTermios, "OFLAGS", oflags);
cflags = rb_hash_new();
rb_define_const(mTermios, "CFLAGS", cflags);
lflags = rb_hash_new();
rb_define_const(mTermios, "LFLAGS", lflags);
bauds = rb_hash_new();
rb_define_const(mTermios, "BAUDS", bauds);
tcsetattr_opt = rb_ary_new();
rb_define_const(mTermios, "SETATTR_OPTS", tcsetattr_opt);
tcflush_qs = rb_ary_new();
rb_define_const(mTermios, "FLUSH_QSELECTORS", tcflush_qs);
tcflow_act = rb_ary_new();
rb_define_const(mTermios, "FLOW_ACTIONS", tcflow_act);
#define define_flag(hash, flag) \
{ \
rb_define_const(mTermios, #flag, INT2FIX(flag)); \
rb_hash_aset(hash, rb_const_get(mTermios, rb_intern(#flag)), \
ID2SYM(rb_intern(#flag))); \
}
#define define_flag2(ary, flag) \
{ \
rb_define_const(mTermios, #flag, INT2FIX(flag)); \
rb_ary_push(ary, rb_const_get(mTermios, rb_intern(#flag)));\
}
/* c_cc characters */
#ifdef VINTR
define_flag(ccindex, VINTR);
#endif
#ifdef VQUIT
define_flag(ccindex, VQUIT);
#endif
#ifdef VERASE
define_flag(ccindex, VERASE);
#endif
#ifdef VKILL
define_flag(ccindex, VKILL);
#endif
#ifdef VEOF
define_flag(ccindex, VEOF);
#endif
#ifdef VTIME
define_flag(ccindex, VTIME);
#endif
#ifdef VMIN
define_flag(ccindex, VMIN);
#endif
#ifdef VSWTC
define_flag(ccindex, VSWTC);
#endif
#ifdef VSTART
define_flag(ccindex, VSTART);
#endif
#ifdef VSTOP
define_flag(ccindex, VSTOP);
#endif
#ifdef VSUSP
define_flag(ccindex, VSUSP);
#endif
#ifdef VEOL
define_flag(ccindex, VEOL);
#endif
#ifdef VREPRINT
define_flag(ccindex, VREPRINT);
#endif
#ifdef VDISCARD
define_flag(ccindex, VDISCARD);
#endif
#ifdef VWERASE
define_flag(ccindex, VWERASE);
#endif
#ifdef VLNEXT
define_flag(ccindex, VLNEXT);
#endif
#ifdef VEOL2
define_flag(ccindex, VEOL2);
#endif
/* c_iflag bits */
#ifdef IGNBRK
define_flag(iflags, IGNBRK);
#endif
#ifdef BRKINT
define_flag(iflags, BRKINT);
#endif
#ifdef IGNPAR
define_flag(iflags, IGNPAR);
#endif
#ifdef PARMRK
define_flag(iflags, PARMRK);
#endif
#ifdef INPCK
define_flag(iflags, INPCK);
#endif
#ifdef ISTRIP
define_flag(iflags, ISTRIP);
#endif
#ifdef INLCR
define_flag(iflags, INLCR);
#endif
#ifdef IGNCR
define_flag(iflags, IGNCR);
#endif
#ifdef ICRNL
define_flag(iflags, ICRNL);
#endif
#ifdef IUCLC
define_flag(iflags, IUCLC);
#endif
#ifdef IXON
define_flag(iflags, IXON);
#endif
#ifdef IXANY
define_flag(iflags, IXANY);
#endif
#ifdef IXOFF
define_flag(iflags, IXOFF);
#endif
#ifdef IMAXBEL
define_flag(iflags, IMAXBEL);
#endif
/* c_oflag bits */
#ifdef OPOST
define_flag(oflags, OPOST);
#endif
#ifdef OLCUC
define_flag(oflags, OLCUC);
#endif
#ifdef ONLCR
define_flag(oflags, ONLCR);
#endif
#ifdef OCRNL
define_flag(oflags, OCRNL);
#endif
#ifdef ONOCR
define_flag(oflags, ONOCR);
#endif
#ifdef ONLRET
define_flag(oflags, ONLRET);
#endif
#ifdef OFILL
define_flag(oflags, OFILL);
#endif
#ifdef OFDEL
define_flag(oflags, OFDEL);
#endif
#ifdef NLDLY
define_flag(oflags, NLDLY);
#endif
#ifdef NL0
define_flag(oflags, NL0);
#endif
#ifdef NL1
define_flag(oflags, NL1);
#endif
#ifdef CRDLY
define_flag(oflags, CRDLY);
#endif
#ifdef CR0
define_flag(oflags, CR0);
#endif
#ifdef CR1
define_flag(oflags, CR1);
#endif
#ifdef CR2
define_flag(oflags, CR2);
#endif
#ifdef CR3
define_flag(oflags, CR3);
#endif
#ifdef TABDLY
define_flag(oflags, TABDLY);
#endif
#ifdef TAB0
define_flag(oflags, TAB0);
#endif
#ifdef TAB1
define_flag(oflags, TAB1);
#endif
#ifdef TAB2
define_flag(oflags, TAB2);
#endif
#ifdef TAB3
define_flag(oflags, TAB3);
#endif
#ifdef XTABS
define_flag(oflags, XTABS);
#endif
#ifdef BSDLY
define_flag(oflags, BSDLY);
#endif
#ifdef BS0
define_flag(oflags, BS0);
#endif
#ifdef BS1
define_flag(oflags, BS1);
#endif
#ifdef VTDLY
define_flag(oflags, VTDLY);
#endif
#ifdef VT0
define_flag(oflags, VT0);
#endif
#ifdef VT1
define_flag(oflags, VT1);
#endif
#ifdef FFDLY
define_flag(oflags, FFDLY);
#endif
#ifdef FF0
define_flag(oflags, FF0);
#endif
#ifdef FF1
define_flag(oflags, FF1);
#endif
/* c_cflag bit meaning */
#ifdef CBAUD
define_flag(cflags, CBAUD);
#endif
#ifdef B0
define_flag(bauds, B0);
#endif
#ifdef B50
define_flag(bauds, B50);
#endif
#ifdef B75
define_flag(bauds, B75);
#endif
#ifdef B110
define_flag(bauds, B110);
#endif
#ifdef B134
define_flag(bauds, B134);
#endif
#ifdef B150
define_flag(bauds, B150);
#endif
#ifdef B200
define_flag(bauds, B200);
#endif
#ifdef B300
define_flag(bauds, B300);
#endif
#ifdef B600
define_flag(bauds, B600);
#endif
#ifdef B1200
define_flag(bauds, B1200);
#endif
#ifdef B1800
define_flag(bauds, B1800);
#endif
#ifdef B2400
define_flag(bauds, B2400);
#endif
#ifdef B4800
define_flag(bauds, B4800);
#endif
#ifdef B9600
define_flag(bauds, B9600);
#endif
#ifdef B19200
define_flag(bauds, B19200);
#endif
#ifdef B38400
define_flag(bauds, B38400);
#endif
#ifdef EXTA
define_flag(cflags, EXTA);
#endif
#ifdef EXTB
define_flag(cflags, EXTB);
#endif
#ifdef CSIZE
define_flag(cflags, CSIZE);
#endif
#ifdef CS5
define_flag(cflags, CS5);
#endif
#ifdef CS6
define_flag(cflags, CS6);
#endif
#ifdef CS7
define_flag(cflags, CS7);
#endif
#ifdef CS8
define_flag(cflags, CS8);
#endif
#ifdef CSTOPB
define_flag(cflags, CSTOPB);
#endif
#ifdef CREAD
define_flag(cflags, CREAD);
#endif
#ifdef PARENB
define_flag(cflags, PARENB);
#endif
#ifdef PARODD
define_flag(cflags, PARODD);
#endif
#ifdef HUPCL
define_flag(cflags, HUPCL);
#endif
#ifdef CLOCAL
define_flag(cflags, CLOCAL);
#endif
#ifdef CBAUDEX
define_flag(cflags, CBAUDEX);
#endif
#ifdef B57600
define_flag(bauds, B57600);
#endif
#ifdef B115200
define_flag(bauds, B115200);
#endif
#ifdef B230400
define_flag(bauds, B230400);
#endif
#ifdef B460800
define_flag(bauds, B460800);
#endif
#ifdef CIBAUD
define_flag(cflags, CIBAUD);
#endif
#ifdef CRTSCTS
define_flag(cflags, CRTSCTS);
#endif
/* c_lflag bits */
#ifdef ISIG
define_flag(lflags, ISIG);
#endif
#ifdef ICANON
define_flag(lflags, ICANON);
#endif
#ifdef XCASE
define_flag(lflags, XCASE);
#endif
#ifdef ECHO
define_flag(lflags, ECHO);
#endif
#ifdef ECHOE
define_flag(lflags, ECHOE);
#endif
#ifdef ECHOK
define_flag(lflags, ECHOK);
#endif
#ifdef ECHONL
define_flag(lflags, ECHONL);
#endif
#ifdef NOFLSH
define_flag(lflags, NOFLSH);
#endif
#ifdef TOSTOP
define_flag(lflags, TOSTOP);
#endif
#ifdef ECHOCTL
define_flag(lflags, ECHOCTL);
#endif
#ifdef ECHOPRT
define_flag(lflags, ECHOPRT);
#endif
#ifdef ECHOKE
define_flag(lflags, ECHOKE);
#endif
#ifdef FLUSHO
define_flag(lflags, FLUSHO);
#endif
#ifdef PENDIN
define_flag(lflags, PENDIN);
#endif
#ifdef IEXTEN
define_flag(lflags, IEXTEN);
#endif
/* tcflow() and TCXONC use these */
#ifdef TCOOFF
define_flag2(tcflow_act, TCOOFF);
#endif
#ifdef TCOON
define_flag2(tcflow_act, TCOON);
#endif
#ifdef TCIOFF
define_flag2(tcflow_act, TCIOFF);
#endif
#ifdef TCION
define_flag2(tcflow_act, TCION);
#endif
/* tcflush() and TCFLSH use these */
#ifdef TCIFLUSH
define_flag2(tcflush_qs, TCIFLUSH);
#endif
#ifdef TCOFLUSH
define_flag2(tcflush_qs, TCOFLUSH);
#endif
#ifdef TCIOFLUSH
define_flag2(tcflush_qs, TCIOFLUSH);
#endif
/* tcsetattr uses these */
#ifdef TCSANOW
define_flag2(tcsetattr_opt, TCSANOW);
#endif
#ifdef TCSADRAIN
define_flag2(tcsetattr_opt, TCSADRAIN);
#endif
#ifdef TCSAFLUSH
define_flag2(tcsetattr_opt, TCSAFLUSH);
#endif
#ifdef TCSASOFT
define_flag2(tcsetattr_opt, TCSASOFT);
#endif
}
|