… | |
… | |
2 | * File: ptytty.C |
2 | * File: ptytty.C |
3 | *----------------------------------------------------------------------* |
3 | *----------------------------------------------------------------------* |
4 | * |
4 | * |
5 | * All portions of code are copyright by their respective author/s. |
5 | * All portions of code are copyright by their respective author/s. |
6 | * Copyright (c) 1999-2001 Geoff Wing <gcw@pobox.com> |
6 | * Copyright (c) 1999-2001 Geoff Wing <gcw@pobox.com> |
7 | * Copyright (c) 2004 Marc Lehmann <pcg@goof.com> |
7 | * Copyright (c) 2004-2006 Marc Lehmann <pcg@goof.com> |
8 | * |
8 | * |
9 | * This program is free software; you can redistribute it and/or modify |
9 | * This program is free software; you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by |
10 | * it under the terms of the GNU General Public License as published by |
11 | * the Free Software Foundation; either version 2 of the License, or |
11 | * the Free Software Foundation; either version 2 of the License, or |
12 | * (at your option) any later version. |
12 | * (at your option) any later version. |
… | |
… | |
396 | |
396 | |
397 | void |
397 | void |
398 | |
398 | |
399 | rxvt_ptytty::close_tty () |
399 | rxvt_ptytty::close_tty () |
400 | { |
400 | { |
401 | if (tty >= 0) close (tty); |
401 | if (tty < 0) |
|
|
402 | return; |
|
|
403 | |
|
|
404 | close (tty); |
402 | tty = -1; |
405 | tty = -1; |
403 | } |
406 | } |
404 | |
407 | |
405 | void |
408 | void |
406 | rxvt_ptytty::put () |
409 | rxvt_ptytty::put () |
407 | { |
410 | { |
408 | #ifndef NO_SETOWNER_TTYDEV |
411 | #ifndef NO_SETOWNER_TTYDEV |
409 | if (tty >= 0) |
|
|
410 | privileges (RESTORE); |
412 | privileges (RESTORE); |
411 | #endif |
413 | #endif |
412 | |
414 | |
413 | if (pty >= 0) close (pty); |
415 | if (pty >= 0) close (pty); |
414 | close_tty (); |
416 | close_tty (); |
415 | free (name); |
417 | free (name); |
… | |
… | |
452 | |
454 | |
453 | void |
455 | void |
454 | rxvt_ptytty::set_utf8_mode (bool on) |
456 | rxvt_ptytty::set_utf8_mode (bool on) |
455 | { |
457 | { |
456 | #ifdef IUTF8 |
458 | #ifdef IUTF8 |
457 | if (pty != -1) |
459 | if (pty < 0) |
458 | { |
460 | return; |
|
|
461 | |
459 | struct termios tio; |
462 | struct termios tio; |
460 | |
463 | |
461 | if (tcgetattr (pty, &tio) != -1) |
464 | if (tcgetattr (pty, &tio) != -1) |
|
|
465 | { |
|
|
466 | tcflag_t new_cflag = tio.c_iflag; |
|
|
467 | |
|
|
468 | if (on) |
|
|
469 | new_cflag |= IUTF8; |
|
|
470 | else |
|
|
471 | new_cflag &= ~IUTF8; |
|
|
472 | |
|
|
473 | if (new_cflag != tio.c_iflag) |
462 | { |
474 | { |
463 | tcflag_t new_cflag = tio.c_iflag; |
|
|
464 | |
|
|
465 | if (on) |
|
|
466 | new_cflag |= IUTF8; |
|
|
467 | else |
|
|
468 | new_cflag &= ~IUTF8; |
|
|
469 | |
|
|
470 | if (new_cflag != tio.c_iflag) |
|
|
471 | { |
|
|
472 | tio.c_iflag = new_cflag; |
475 | tio.c_iflag = new_cflag; |
473 | tcsetattr (pty, TCSANOW, &tio); |
476 | tcsetattr (pty, TCSANOW, &tio); |
474 | } |
|
|
475 | } |
477 | } |
476 | } |
478 | } |
477 | #endif |
479 | #endif |
478 | } |
480 | } |
479 | |
481 | |