Changeset 391 for python/trunk/Modules/termios.c
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Modules/termios.c
r2 r391 45 45 static int fdconv(PyObject* obj, void* p) 46 46 { 47 48 49 50 51 52 53 54 47 int fd; 48 49 fd = PyObject_AsFileDescriptor(obj); 50 if (fd >= 0) { 51 *(int*)p = fd; 52 return 1; 53 } 54 return 0; 55 55 } 56 56 … … 69 69 termios_tcgetattr(PyObject *self, PyObject *args) 70 70 { 71 72 73 74 75 76 77 78 79 if (!PyArg_ParseTuple(args, "O&:tcgetattr", 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 71 int fd; 72 struct termios mode; 73 PyObject *cc; 74 speed_t ispeed, ospeed; 75 PyObject *v; 76 int i; 77 char ch; 78 79 if (!PyArg_ParseTuple(args, "O&:tcgetattr", 80 fdconv, (void*)&fd)) 81 return NULL; 82 83 if (tcgetattr(fd, &mode) == -1) 84 return PyErr_SetFromErrno(TermiosError); 85 86 ispeed = cfgetispeed(&mode); 87 ospeed = cfgetospeed(&mode); 88 89 cc = PyList_New(NCCS); 90 if (cc == NULL) 91 return NULL; 92 for (i = 0; i < NCCS; i++) { 93 ch = (char)mode.c_cc[i]; 94 v = PyString_FromStringAndSize(&ch, 1); 95 if (v == NULL) 96 goto err; 97 PyList_SetItem(cc, i, v); 98 } 99 100 /* Convert the MIN and TIME slots to integer. On some systems, the 101 MIN and TIME slots are the same as the EOF and EOL slots. So we 102 only do this in noncanonical input mode. */ 103 if ((mode.c_lflag & ICANON) == 0) { 104 v = PyInt_FromLong((long)mode.c_cc[VMIN]); 105 if (v == NULL) 106 goto err; 107 PyList_SetItem(cc, VMIN, v); 108 v = PyInt_FromLong((long)mode.c_cc[VTIME]); 109 if (v == NULL) 110 goto err; 111 PyList_SetItem(cc, VTIME, v); 112 } 113 114 if (!(v = PyList_New(7))) 115 goto err; 116 117 PyList_SetItem(v, 0, PyInt_FromLong((long)mode.c_iflag)); 118 PyList_SetItem(v, 1, PyInt_FromLong((long)mode.c_oflag)); 119 PyList_SetItem(v, 2, PyInt_FromLong((long)mode.c_cflag)); 120 PyList_SetItem(v, 3, PyInt_FromLong((long)mode.c_lflag)); 121 PyList_SetItem(v, 4, PyInt_FromLong((long)ispeed)); 122 PyList_SetItem(v, 5, PyInt_FromLong((long)ospeed)); 123 PyList_SetItem(v, 6, cc); 124 if (PyErr_Occurred()){ 125 Py_DECREF(v); 126 goto err; 127 } 128 return v; 129 129 err: 130 131 130 Py_DECREF(cc); 131 return NULL; 132 132 } 133 133 … … 146 146 termios_tcsetattr(PyObject *self, PyObject *args) 147 147 { 148 149 150 151 152 153 154 if (!PyArg_ParseTuple(args, "O&iO:tcsetattr", 155 156 157 158 PyErr_SetString(PyExc_TypeError, 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 PyErr_Format(PyExc_TypeError, 178 179 180 181 182 183 184 185 186 187 188 189 190 191 PyErr_SetString(PyExc_TypeError, 148 int fd, when; 149 struct termios mode; 150 speed_t ispeed, ospeed; 151 PyObject *term, *cc, *v; 152 int i; 153 154 if (!PyArg_ParseTuple(args, "O&iO:tcsetattr", 155 fdconv, &fd, &when, &term)) 156 return NULL; 157 if (!PyList_Check(term) || PyList_Size(term) != 7) { 158 PyErr_SetString(PyExc_TypeError, 159 "tcsetattr, arg 3: must be 7 element list"); 160 return NULL; 161 } 162 163 /* Get the old mode, in case there are any hidden fields... */ 164 if (tcgetattr(fd, &mode) == -1) 165 return PyErr_SetFromErrno(TermiosError); 166 mode.c_iflag = (tcflag_t) PyInt_AsLong(PyList_GetItem(term, 0)); 167 mode.c_oflag = (tcflag_t) PyInt_AsLong(PyList_GetItem(term, 1)); 168 mode.c_cflag = (tcflag_t) PyInt_AsLong(PyList_GetItem(term, 2)); 169 mode.c_lflag = (tcflag_t) PyInt_AsLong(PyList_GetItem(term, 3)); 170 ispeed = (speed_t) PyInt_AsLong(PyList_GetItem(term, 4)); 171 ospeed = (speed_t) PyInt_AsLong(PyList_GetItem(term, 5)); 172 cc = PyList_GetItem(term, 6); 173 if (PyErr_Occurred()) 174 return NULL; 175 176 if (!PyList_Check(cc) || PyList_Size(cc) != NCCS) { 177 PyErr_Format(PyExc_TypeError, 178 "tcsetattr: attributes[6] must be %d element list", 179 NCCS); 180 return NULL; 181 } 182 183 for (i = 0; i < NCCS; i++) { 184 v = PyList_GetItem(cc, i); 185 186 if (PyString_Check(v) && PyString_Size(v) == 1) 187 mode.c_cc[i] = (cc_t) * PyString_AsString(v); 188 else if (PyInt_Check(v)) 189 mode.c_cc[i] = (cc_t) PyInt_AsLong(v); 190 else { 191 PyErr_SetString(PyExc_TypeError, 192 192 "tcsetattr: elements of attributes must be characters or integers"); 193 194 195 196 197 198 199 200 201 202 203 204 205 193 return NULL; 194 } 195 } 196 197 if (cfsetispeed(&mode, (speed_t) ispeed) == -1) 198 return PyErr_SetFromErrno(TermiosError); 199 if (cfsetospeed(&mode, (speed_t) ospeed) == -1) 200 return PyErr_SetFromErrno(TermiosError); 201 if (tcsetattr(fd, when, &mode) == -1) 202 return PyErr_SetFromErrno(TermiosError); 203 204 Py_INCREF(Py_None); 205 return Py_None; 206 206 } 207 207 … … 216 216 termios_tcsendbreak(PyObject *self, PyObject *args) 217 217 { 218 219 220 if (!PyArg_ParseTuple(args, "O&i:tcsendbreak", 221 222 223 224 225 226 227 218 int fd, duration; 219 220 if (!PyArg_ParseTuple(args, "O&i:tcsendbreak", 221 fdconv, &fd, &duration)) 222 return NULL; 223 if (tcsendbreak(fd, duration) == -1) 224 return PyErr_SetFromErrno(TermiosError); 225 226 Py_INCREF(Py_None); 227 return Py_None; 228 228 } 229 229 … … 236 236 termios_tcdrain(PyObject *self, PyObject *args) 237 237 { 238 239 240 if (!PyArg_ParseTuple(args, "O&:tcdrain", 241 242 243 244 245 246 247 238 int fd; 239 240 if (!PyArg_ParseTuple(args, "O&:tcdrain", 241 fdconv, &fd)) 242 return NULL; 243 if (tcdrain(fd) == -1) 244 return PyErr_SetFromErrno(TermiosError); 245 246 Py_INCREF(Py_None); 247 return Py_None; 248 248 } 249 249 … … 259 259 termios_tcflush(PyObject *self, PyObject *args) 260 260 { 261 262 263 if (!PyArg_ParseTuple(args, "O&i:tcflush", 264 265 266 267 268 269 270 261 int fd, queue; 262 263 if (!PyArg_ParseTuple(args, "O&i:tcflush", 264 fdconv, &fd, &queue)) 265 return NULL; 266 if (tcflush(fd, queue) == -1) 267 return PyErr_SetFromErrno(TermiosError); 268 269 Py_INCREF(Py_None); 270 return Py_None; 271 271 } 272 272 … … 282 282 termios_tcflow(PyObject *self, PyObject *args) 283 283 { 284 285 286 if (!PyArg_ParseTuple(args, "O&i:tcflow", 287 288 289 290 291 292 293 284 int fd, action; 285 286 if (!PyArg_ParseTuple(args, "O&i:tcflow", 287 fdconv, &fd, &action)) 288 return NULL; 289 if (tcflow(fd, action) == -1) 290 return PyErr_SetFromErrno(TermiosError); 291 292 Py_INCREF(Py_None); 293 return Py_None; 294 294 } 295 295 296 296 static PyMethodDef termios_methods[] = 297 297 { 298 {"tcgetattr", termios_tcgetattr, 299 300 {"tcsetattr", termios_tcsetattr, 301 302 {"tcsendbreak", termios_tcsendbreak, 303 304 {"tcdrain", termios_tcdrain, 305 306 {"tcflush", termios_tcflush, 307 308 {"tcflow", termios_tcflow, 309 310 298 {"tcgetattr", termios_tcgetattr, 299 METH_VARARGS, termios_tcgetattr__doc__}, 300 {"tcsetattr", termios_tcsetattr, 301 METH_VARARGS, termios_tcsetattr__doc__}, 302 {"tcsendbreak", termios_tcsendbreak, 303 METH_VARARGS, termios_tcsendbreak__doc__}, 304 {"tcdrain", termios_tcdrain, 305 METH_VARARGS, termios_tcdrain__doc__}, 306 {"tcflush", termios_tcflush, 307 METH_VARARGS, termios_tcflush__doc__}, 308 {"tcflow", termios_tcflow, 309 METH_VARARGS, termios_tcflow__doc__}, 310 {NULL, NULL} 311 311 }; 312 312 … … 321 321 322 322 static struct constant { 323 324 323 char *name; 324 long value; 325 325 } termios_constants[] = { 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 326 /* cfgetospeed(), cfsetospeed() constants */ 327 {"B0", B0}, 328 {"B50", B50}, 329 {"B75", B75}, 330 {"B110", B110}, 331 {"B134", B134}, 332 {"B150", B150}, 333 {"B200", B200}, 334 {"B300", B300}, 335 {"B600", B600}, 336 {"B1200", B1200}, 337 {"B1800", B1800}, 338 {"B2400", B2400}, 339 {"B4800", B4800}, 340 {"B9600", B9600}, 341 {"B19200", B19200}, 342 {"B38400", B38400}, 343 343 #ifdef B57600 344 344 {"B57600", B57600}, 345 345 #endif 346 346 #ifdef B115200 347 347 {"B115200", B115200}, 348 348 #endif 349 349 #ifdef B230400 350 350 {"B230400", B230400}, 351 351 #endif 352 352 #ifdef CBAUDEX 353 {"CBAUDEX", CBAUDEX}, 354 #endif 355 356 /* tcsetattr() constants */ 357 {"TCSANOW", TCSANOW}, 358 {"TCSADRAIN", TCSADRAIN}, 359 {"TCSAFLUSH", TCSAFLUSH}, 360 361 /* tcflush() constants */ 362 {"TCIFLUSH", TCIFLUSH}, 363 {"TCOFLUSH", TCOFLUSH}, 364 {"TCIOFLUSH", TCIOFLUSH}, 365 366 /* tcflow() constants */ 367 {"TCOOFF", TCOOFF}, 368 {"TCOON", TCOON}, 369 {"TCIOFF", TCIOFF}, 370 {"TCION", TCION}, 371 372 /* struct termios.c_iflag constants */ 373 {"IGNBRK", IGNBRK}, 374 {"BRKINT", BRKINT}, 375 {"IGNPAR", IGNPAR}, 376 {"PARMRK", PARMRK}, 377 {"INPCK", INPCK}, 378 {"ISTRIP", ISTRIP}, 379 {"INLCR", INLCR}, 380 {"IGNCR", IGNCR}, 381 {"ICRNL", ICRNL}, 353 {"CBAUDEX", CBAUDEX}, 354 #endif 355 356 /* tcsetattr() constants */ 357 {"TCSANOW", TCSANOW}, 358 {"TCSADRAIN", TCSADRAIN}, 359 {"TCSAFLUSH", TCSAFLUSH}, 360 #ifdef TCSASOFT 361 {"TCSASOFT", TCSASOFT}, 362 #endif 363 364 /* tcflush() constants */ 365 {"TCIFLUSH", TCIFLUSH}, 366 {"TCOFLUSH", TCOFLUSH}, 367 {"TCIOFLUSH", TCIOFLUSH}, 368 369 /* tcflow() constants */ 370 {"TCOOFF", TCOOFF}, 371 {"TCOON", TCOON}, 372 {"TCIOFF", TCIOFF}, 373 {"TCION", TCION}, 374 375 /* struct termios.c_iflag constants */ 376 {"IGNBRK", IGNBRK}, 377 {"BRKINT", BRKINT}, 378 {"IGNPAR", IGNPAR}, 379 {"PARMRK", PARMRK}, 380 {"INPCK", INPCK}, 381 {"ISTRIP", ISTRIP}, 382 {"INLCR", INLCR}, 383 {"IGNCR", IGNCR}, 384 {"ICRNL", ICRNL}, 382 385 #ifdef IUCLC 383 384 #endif 385 386 387 386 {"IUCLC", IUCLC}, 387 #endif 388 {"IXON", IXON}, 389 {"IXANY", IXANY}, 390 {"IXOFF", IXOFF}, 388 391 #ifdef IMAXBEL 389 390 #endif 391 392 393 392 {"IMAXBEL", IMAXBEL}, 393 #endif 394 395 /* struct termios.c_oflag constants */ 396 {"OPOST", OPOST}, 394 397 #ifdef OLCUC 395 398 {"OLCUC", OLCUC}, 396 399 #endif 397 400 #ifdef ONLCR 398 401 {"ONLCR", ONLCR}, 399 402 #endif 400 403 #ifdef OCRNL 401 404 {"OCRNL", OCRNL}, 402 405 #endif 403 406 #ifdef ONOCR 404 407 {"ONOCR", ONOCR}, 405 408 #endif 406 409 #ifdef ONLRET 407 410 {"ONLRET", ONLRET}, 408 411 #endif 409 412 #ifdef OFILL 410 413 {"OFILL", OFILL}, 411 414 #endif 412 415 #ifdef OFDEL 413 416 {"OFDEL", OFDEL}, 414 417 #endif 415 418 #ifdef NLDLY 416 419 {"NLDLY", NLDLY}, 417 420 #endif 418 421 #ifdef CRDLY 419 422 {"CRDLY", CRDLY}, 420 423 #endif 421 424 #ifdef TABDLY 422 425 {"TABDLY", TABDLY}, 423 426 #endif 424 427 #ifdef BSDLY 425 428 {"BSDLY", BSDLY}, 426 429 #endif 427 430 #ifdef VTDLY 428 431 {"VTDLY", VTDLY}, 429 432 #endif 430 433 #ifdef FFDLY 431 432 #endif 433 434 434 {"FFDLY", FFDLY}, 435 #endif 436 437 /* struct termios.c_oflag-related values (delay mask) */ 435 438 #ifdef NL0 436 439 {"NL0", NL0}, 437 440 #endif 438 441 #ifdef NL1 439 442 {"NL1", NL1}, 440 443 #endif 441 444 #ifdef CR0 442 445 {"CR0", CR0}, 443 446 #endif 444 447 #ifdef CR1 445 448 {"CR1", CR1}, 446 449 #endif 447 450 #ifdef CR2 448 451 {"CR2", CR2}, 449 452 #endif 450 453 #ifdef CR3 451 454 {"CR3", CR3}, 452 455 #endif 453 456 #ifdef TAB0 454 457 {"TAB0", TAB0}, 455 458 #endif 456 459 #ifdef TAB1 457 460 {"TAB1", TAB1}, 458 461 #endif 459 462 #ifdef TAB2 460 463 {"TAB2", TAB2}, 461 464 #endif 462 465 #ifdef TAB3 463 466 {"TAB3", TAB3}, 464 467 #endif 465 468 #ifdef XTABS 466 469 {"XTABS", XTABS}, 467 470 #endif 468 471 #ifdef BS0 469 472 {"BS0", BS0}, 470 473 #endif 471 474 #ifdef BS1 472 475 {"BS1", BS1}, 473 476 #endif 474 477 #ifdef VT0 475 478 {"VT0", VT0}, 476 479 #endif 477 480 #ifdef VT1 478 481 {"VT1", VT1}, 479 482 #endif 480 483 #ifdef FF0 481 484 {"FF0", FF0}, 482 485 #endif 483 486 #ifdef FF1 484 485 #endif 486 487 488 489 490 491 492 493 494 487 {"FF1", FF1}, 488 #endif 489 490 /* struct termios.c_cflag constants */ 491 {"CSIZE", CSIZE}, 492 {"CSTOPB", CSTOPB}, 493 {"CREAD", CREAD}, 494 {"PARENB", PARENB}, 495 {"PARODD", PARODD}, 496 {"HUPCL", HUPCL}, 497 {"CLOCAL", CLOCAL}, 495 498 #ifdef CIBAUD 496 499 {"CIBAUD", CIBAUD}, 497 500 #endif 498 501 #ifdef CRTSCTS 499 500 #endif 501 502 503 504 505 506 507 508 509 510 502 {"CRTSCTS", (long)CRTSCTS}, 503 #endif 504 505 /* struct termios.c_cflag-related values (character size) */ 506 {"CS5", CS5}, 507 {"CS6", CS6}, 508 {"CS7", CS7}, 509 {"CS8", CS8}, 510 511 /* struct termios.c_lflag constants */ 512 {"ISIG", ISIG}, 513 {"ICANON", ICANON}, 511 514 #ifdef XCASE 512 513 #endif 514 515 516 517 515 {"XCASE", XCASE}, 516 #endif 517 {"ECHO", ECHO}, 518 {"ECHOE", ECHOE}, 519 {"ECHOK", ECHOK}, 520 {"ECHONL", ECHONL}, 518 521 #ifdef ECHOCTL 519 522 {"ECHOCTL", ECHOCTL}, 520 523 #endif 521 524 #ifdef ECHOPRT 522 525 {"ECHOPRT", ECHOPRT}, 523 526 #endif 524 527 #ifdef ECHOKE 525 528 {"ECHOKE", ECHOKE}, 526 529 #endif 527 530 #ifdef FLUSHO 528 529 #endif 530 531 531 {"FLUSHO", FLUSHO}, 532 #endif 533 {"NOFLSH", NOFLSH}, 534 {"TOSTOP", TOSTOP}, 532 535 #ifdef PENDIN 533 534 #endif 535 536 537 538 539 540 541 542 543 544 536 {"PENDIN", PENDIN}, 537 #endif 538 {"IEXTEN", IEXTEN}, 539 540 /* indexes into the control chars array returned by tcgetattr() */ 541 {"VINTR", VINTR}, 542 {"VQUIT", VQUIT}, 543 {"VERASE", VERASE}, 544 {"VKILL", VKILL}, 545 {"VEOF", VEOF}, 546 {"VTIME", VTIME}, 547 {"VMIN", VMIN}, 545 548 #ifdef VSWTC 546 547 548 549 550 #endif 551 552 553 554 549 /* The #defines above ensure that if either is defined, both are, 550 * but both may be omitted by the system headers. ;-( */ 551 {"VSWTC", VSWTC}, 552 {"VSWTCH", VSWTCH}, 553 #endif 554 {"VSTART", VSTART}, 555 {"VSTOP", VSTOP}, 556 {"VSUSP", VSUSP}, 557 {"VEOL", VEOL}, 555 558 #ifdef VREPRINT 556 559 {"VREPRINT", VREPRINT}, 557 560 #endif 558 561 #ifdef VDISCARD 559 562 {"VDISCARD", VDISCARD}, 560 563 #endif 561 564 #ifdef VWERASE 562 565 {"VWERASE", VWERASE}, 563 566 #endif 564 567 #ifdef VLNEXT 565 568 {"VLNEXT", VLNEXT}, 566 569 #endif 567 570 #ifdef VEOL2 568 571 {"VEOL2", VEOL2}, 569 572 #endif 570 573 571 574 572 575 #ifdef B460800 573 576 {"B460800", B460800}, 574 577 #endif 575 578 #ifdef CBAUD 576 579 {"CBAUD", CBAUD}, 577 580 #endif 578 581 #ifdef CDEL 579 582 {"CDEL", CDEL}, 580 583 #endif 581 584 #ifdef CDSUSP 582 585 {"CDSUSP", CDSUSP}, 583 586 #endif 584 587 #ifdef CEOF 585 588 {"CEOF", CEOF}, 586 589 #endif 587 590 #ifdef CEOL 588 591 {"CEOL", CEOL}, 589 592 #endif 590 593 #ifdef CEOL2 591 594 {"CEOL2", CEOL2}, 592 595 #endif 593 596 #ifdef CEOT 594 597 {"CEOT", CEOT}, 595 598 #endif 596 599 #ifdef CERASE 597 600 {"CERASE", CERASE}, 598 601 #endif 599 602 #ifdef CESC 600 603 {"CESC", CESC}, 601 604 #endif 602 605 #ifdef CFLUSH 603 606 {"CFLUSH", CFLUSH}, 604 607 #endif 605 608 #ifdef CINTR 606 609 {"CINTR", CINTR}, 607 610 #endif 608 611 #ifdef CKILL 609 612 {"CKILL", CKILL}, 610 613 #endif 611 614 #ifdef CLNEXT 612 615 {"CLNEXT", CLNEXT}, 613 616 #endif 614 617 #ifdef CNUL 615 618 {"CNUL", CNUL}, 616 619 #endif 617 620 #ifdef COMMON 618 621 {"COMMON", COMMON}, 619 622 #endif 620 623 #ifdef CQUIT 621 624 {"CQUIT", CQUIT}, 622 625 #endif 623 626 #ifdef CRPRNT 624 627 {"CRPRNT", CRPRNT}, 625 628 #endif 626 629 #ifdef CSTART 627 630 {"CSTART", CSTART}, 628 631 #endif 629 632 #ifdef CSTOP 630 633 {"CSTOP", CSTOP}, 631 634 #endif 632 635 #ifdef CSUSP 633 636 {"CSUSP", CSUSP}, 634 637 #endif 635 638 #ifdef CSWTCH 636 639 {"CSWTCH", CSWTCH}, 637 640 #endif 638 641 #ifdef CWERASE 639 642 {"CWERASE", CWERASE}, 640 643 #endif 641 644 #ifdef EXTA 642 645 {"EXTA", EXTA}, 643 646 #endif 644 647 #ifdef EXTB 645 648 {"EXTB", EXTB}, 646 649 #endif 647 650 #ifdef FIOASYNC 648 651 {"FIOASYNC", FIOASYNC}, 649 652 #endif 650 653 #ifdef FIOCLEX 651 654 {"FIOCLEX", FIOCLEX}, 652 655 #endif 653 656 #ifdef FIONBIO 654 657 {"FIONBIO", FIONBIO}, 655 658 #endif 656 659 #ifdef FIONCLEX 657 660 {"FIONCLEX", FIONCLEX}, 658 661 #endif 659 662 #ifdef FIONREAD 660 663 {"FIONREAD", FIONREAD}, 661 664 #endif 662 665 #ifdef IBSHIFT 663 666 {"IBSHIFT", IBSHIFT}, 664 667 #endif 665 668 #ifdef INIT_C_CC 666 669 {"INIT_C_CC", INIT_C_CC}, 667 670 #endif 668 671 #ifdef IOCSIZE_MASK 669 672 {"IOCSIZE_MASK", IOCSIZE_MASK}, 670 673 #endif 671 674 #ifdef IOCSIZE_SHIFT 672 675 {"IOCSIZE_SHIFT", IOCSIZE_SHIFT}, 673 676 #endif 674 677 #ifdef NCC 675 678 {"NCC", NCC}, 676 679 #endif 677 680 #ifdef NCCS 678 681 {"NCCS", NCCS}, 679 682 #endif 680 683 #ifdef NSWTCH 681 684 {"NSWTCH", NSWTCH}, 682 685 #endif 683 686 #ifdef N_MOUSE 684 687 {"N_MOUSE", N_MOUSE}, 685 688 #endif 686 689 #ifdef N_PPP 687 690 {"N_PPP", N_PPP}, 688 691 #endif 689 692 #ifdef N_SLIP 690 693 {"N_SLIP", N_SLIP}, 691 694 #endif 692 695 #ifdef N_STRIP 693 696 {"N_STRIP", N_STRIP}, 694 697 #endif 695 698 #ifdef N_TTY 696 699 {"N_TTY", N_TTY}, 697 700 #endif 698 701 #ifdef TCFLSH 699 702 {"TCFLSH", TCFLSH}, 700 703 #endif 701 704 #ifdef TCGETA 702 705 {"TCGETA", TCGETA}, 703 706 #endif 704 707 #ifdef TCGETS 705 708 {"TCGETS", TCGETS}, 706 709 #endif 707 710 #ifdef TCSBRK 708 711 {"TCSBRK", TCSBRK}, 709 712 #endif 710 713 #ifdef TCSBRKP 711 714 {"TCSBRKP", TCSBRKP}, 712 715 #endif 713 716 #ifdef TCSETA 714 717 {"TCSETA", TCSETA}, 715 718 #endif 716 719 #ifdef TCSETAF 717 720 {"TCSETAF", TCSETAF}, 718 721 #endif 719 722 #ifdef TCSETAW 720 723 {"TCSETAW", TCSETAW}, 721 724 #endif 722 725 #ifdef TCSETS 723 726 {"TCSETS", TCSETS}, 724 727 #endif 725 728 #ifdef TCSETSF 726 729 {"TCSETSF", TCSETSF}, 727 730 #endif 728 731 #ifdef TCSETSW 729 732 {"TCSETSW", TCSETSW}, 730 733 #endif 731 734 #ifdef TCXONC 732 735 {"TCXONC", TCXONC}, 733 736 #endif 734 737 #ifdef TIOCCONS 735 738 {"TIOCCONS", TIOCCONS}, 736 739 #endif 737 740 #ifdef TIOCEXCL 738 741 {"TIOCEXCL", TIOCEXCL}, 739 742 #endif 740 743 #ifdef TIOCGETD 741 744 {"TIOCGETD", TIOCGETD}, 742 745 #endif 743 746 #ifdef TIOCGICOUNT 744 747 {"TIOCGICOUNT", TIOCGICOUNT}, 745 748 #endif 746 749 #ifdef TIOCGLCKTRMIOS 747 750 {"TIOCGLCKTRMIOS", TIOCGLCKTRMIOS}, 748 751 #endif 749 752 #ifdef TIOCGPGRP 750 753 {"TIOCGPGRP", TIOCGPGRP}, 751 754 #endif 752 755 #ifdef TIOCGSERIAL 753 756 {"TIOCGSERIAL", TIOCGSERIAL}, 754 757 #endif 755 758 #ifdef TIOCGSOFTCAR 756 759 {"TIOCGSOFTCAR", TIOCGSOFTCAR}, 757 760 #endif 758 761 #ifdef TIOCGWINSZ 759 762 {"TIOCGWINSZ", TIOCGWINSZ}, 760 763 #endif 761 764 #ifdef TIOCINQ 762 765 {"TIOCINQ", TIOCINQ}, 763 766 #endif 764 767 #ifdef TIOCLINUX 765 768 {"TIOCLINUX", TIOCLINUX}, 766 769 #endif 767 770 #ifdef TIOCMBIC 768 771 {"TIOCMBIC", TIOCMBIC}, 769 772 #endif 770 773 #ifdef TIOCMBIS 771 774 {"TIOCMBIS", TIOCMBIS}, 772 775 #endif 773 776 #ifdef TIOCMGET 774 777 {"TIOCMGET", TIOCMGET}, 775 778 #endif 776 779 #ifdef TIOCMIWAIT 777 780 {"TIOCMIWAIT", TIOCMIWAIT}, 778 781 #endif 779 782 #ifdef TIOCMSET 780 783 {"TIOCMSET", TIOCMSET}, 781 784 #endif 782 785 #ifdef TIOCM_CAR 783 786 {"TIOCM_CAR", TIOCM_CAR}, 784 787 #endif 785 788 #ifdef TIOCM_CD 786 789 {"TIOCM_CD", TIOCM_CD}, 787 790 #endif 788 791 #ifdef TIOCM_CTS 789 792 {"TIOCM_CTS", TIOCM_CTS}, 790 793 #endif 791 794 #ifdef TIOCM_DSR 792 795 {"TIOCM_DSR", TIOCM_DSR}, 793 796 #endif 794 797 #ifdef TIOCM_DTR 795 798 {"TIOCM_DTR", TIOCM_DTR}, 796 799 #endif 797 800 #ifdef TIOCM_LE 798 801 {"TIOCM_LE", TIOCM_LE}, 799 802 #endif 800 803 #ifdef TIOCM_RI 801 804 {"TIOCM_RI", TIOCM_RI}, 802 805 #endif 803 806 #ifdef TIOCM_RNG 804 807 {"TIOCM_RNG", TIOCM_RNG}, 805 808 #endif 806 809 #ifdef TIOCM_RTS 807 810 {"TIOCM_RTS", TIOCM_RTS}, 808 811 #endif 809 812 #ifdef TIOCM_SR 810 813 {"TIOCM_SR", TIOCM_SR}, 811 814 #endif 812 815 #ifdef TIOCM_ST 813 816 {"TIOCM_ST", TIOCM_ST}, 814 817 #endif 815 818 #ifdef TIOCNOTTY 816 819 {"TIOCNOTTY", TIOCNOTTY}, 817 820 #endif 818 821 #ifdef TIOCNXCL 819 822 {"TIOCNXCL", TIOCNXCL}, 820 823 #endif 821 824 #ifdef TIOCOUTQ 822 825 {"TIOCOUTQ", TIOCOUTQ}, 823 826 #endif 824 827 #ifdef TIOCPKT 825 828 {"TIOCPKT", TIOCPKT}, 826 829 #endif 827 830 #ifdef TIOCPKT_DATA 828 831 {"TIOCPKT_DATA", TIOCPKT_DATA}, 829 832 #endif 830 833 #ifdef TIOCPKT_DOSTOP 831 834 {"TIOCPKT_DOSTOP", TIOCPKT_DOSTOP}, 832 835 #endif 833 836 #ifdef TIOCPKT_FLUSHREAD 834 837 {"TIOCPKT_FLUSHREAD", TIOCPKT_FLUSHREAD}, 835 838 #endif 836 839 #ifdef TIOCPKT_FLUSHWRITE 837 840 {"TIOCPKT_FLUSHWRITE", TIOCPKT_FLUSHWRITE}, 838 841 #endif 839 842 #ifdef TIOCPKT_NOSTOP 840 843 {"TIOCPKT_NOSTOP", TIOCPKT_NOSTOP}, 841 844 #endif 842 845 #ifdef TIOCPKT_START 843 846 {"TIOCPKT_START", TIOCPKT_START}, 844 847 #endif 845 848 #ifdef TIOCPKT_STOP 846 849 {"TIOCPKT_STOP", TIOCPKT_STOP}, 847 850 #endif 848 851 #ifdef TIOCSCTTY 849 852 {"TIOCSCTTY", TIOCSCTTY}, 850 853 #endif 851 854 #ifdef TIOCSERCONFIG 852 855 {"TIOCSERCONFIG", TIOCSERCONFIG}, 853 856 #endif 854 857 #ifdef TIOCSERGETLSR 855 858 {"TIOCSERGETLSR", TIOCSERGETLSR}, 856 859 #endif 857 860 #ifdef TIOCSERGETMULTI 858 861 {"TIOCSERGETMULTI", TIOCSERGETMULTI}, 859 862 #endif 860 863 #ifdef TIOCSERGSTRUCT 861 864 {"TIOCSERGSTRUCT", TIOCSERGSTRUCT}, 862 865 #endif 863 866 #ifdef TIOCSERGWILD 864 867 {"TIOCSERGWILD", TIOCSERGWILD}, 865 868 #endif 866 869 #ifdef TIOCSERSETMULTI 867 870 {"TIOCSERSETMULTI", TIOCSERSETMULTI}, 868 871 #endif 869 872 #ifdef TIOCSERSWILD 870 873 {"TIOCSERSWILD", TIOCSERSWILD}, 871 874 #endif 872 875 #ifdef TIOCSER_TEMT 873 876 {"TIOCSER_TEMT", TIOCSER_TEMT}, 874 877 #endif 875 878 #ifdef TIOCSETD 876 879 {"TIOCSETD", TIOCSETD}, 877 880 #endif 878 881 #ifdef TIOCSLCKTRMIOS 879 882 {"TIOCSLCKTRMIOS", TIOCSLCKTRMIOS}, 880 883 #endif 881 884 #ifdef TIOCSPGRP 882 885 {"TIOCSPGRP", TIOCSPGRP}, 883 886 #endif 884 887 #ifdef TIOCSSERIAL 885 888 {"TIOCSSERIAL", TIOCSSERIAL}, 886 889 #endif 887 890 #ifdef TIOCSSOFTCAR 888 891 {"TIOCSSOFTCAR", TIOCSSOFTCAR}, 889 892 #endif 890 893 #ifdef TIOCSTI 891 894 {"TIOCSTI", TIOCSTI}, 892 895 #endif 893 896 #ifdef TIOCSWINSZ 894 897 {"TIOCSWINSZ", TIOCSWINSZ}, 895 898 #endif 896 899 #ifdef TIOCTTYGSTRUCT 897 898 #endif 899 900 901 900 {"TIOCTTYGSTRUCT", TIOCTTYGSTRUCT}, 901 #endif 902 903 /* sentinel */ 904 {NULL, 0} 902 905 }; 903 906 … … 906 909 PyInit_termios(void) 907 910 { 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 911 PyObject *m; 912 struct constant *constant = termios_constants; 913 914 m = Py_InitModule4("termios", termios_methods, termios__doc__, 915 (PyObject *)NULL, PYTHON_API_VERSION); 916 if (m == NULL) 917 return; 918 919 if (TermiosError == NULL) { 920 TermiosError = PyErr_NewException("termios.error", NULL, NULL); 921 } 922 Py_INCREF(TermiosError); 923 PyModule_AddObject(m, "error", TermiosError); 924 925 while (constant->name != NULL) { 926 PyModule_AddIntConstant(m, constant->name, constant->value); 927 ++constant; 928 } 926 929 }
Note:
See TracChangeset
for help on using the changeset viewer.