~ubuntu-branches/ubuntu/natty/ncurses/natty

« back to all changes in this revision

Viewing changes to ncurses/tinfo/lib_ttyflags.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2007-05-17 09:00:42 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20070517090042-86fgxrr6j5jzagot
Tags: 5.6-0ubuntu1
* New upstream version.
  - Remove patches applied upstream: ncurses.upstream, signed-chars.
  - Update patches: debian-backspace.
* Build-depend on g++-multilib instead of lib{32,64}c*-dev-*.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/****************************************************************************
2
 
 * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
 
2
 * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc.              *
3
3
 *                                                                          *
4
4
 * Permission is hereby granted, free of charge, to any person obtaining a  *
5
5
 * copy of this software and associated documentation files (the            *
38
38
#include <curses.priv.h>
39
39
#include <term.h>               /* cur_term */
40
40
 
41
 
MODULE_ID("$Id: lib_ttyflags.c,v 1.11 2003/05/17 23:50:37 tom Exp $")
42
 
 
43
 
#undef tabs
44
 
 
45
 
#ifdef TAB3
46
 
# define tabs TAB3
47
 
#else
48
 
# ifdef XTABS
49
 
#  define tabs XTABS
50
 
# else
51
 
#  ifdef OXTABS
52
 
#   define tabs OXTABS
53
 
#  else
54
 
#   define tabs 0
55
 
#  endif
56
 
# endif
57
 
#endif
 
41
MODULE_ID("$Id: lib_ttyflags.c,v 1.13 2006/12/10 01:31:54 tom Exp $")
58
42
 
59
43
NCURSES_EXPORT(int)
60
44
_nc_get_tty_mode(TTY * buf)
61
45
{
62
 
    if (cur_term == 0
63
 
        || GET_TTY(cur_term->Filedes, buf) != 0) {
 
46
    int result = OK;
 
47
 
 
48
    if (cur_term == 0) {
 
49
        result = ERR;
 
50
    } else {
 
51
        for (;;) {
 
52
            if (GET_TTY(cur_term->Filedes, buf) != 0) {
 
53
                if (errno == EINTR)
 
54
                    continue;
 
55
                result = ERR;
 
56
            }
 
57
            break;
 
58
        }
 
59
    }
 
60
 
 
61
    if (result == ERR)
64
62
        memset(buf, 0, sizeof(*buf));
65
 
        return (ERR);
66
 
    }
 
63
 
67
64
    TR(TRACE_BITS, ("_nc_get_tty_mode(%d): %s",
68
65
                    cur_term->Filedes, _nc_trace_ttymode(buf)));
69
 
    return (OK);
 
66
    return (result);
70
67
}
71
68
 
72
69
NCURSES_EXPORT(int)
73
70
_nc_set_tty_mode(TTY * buf)
74
71
{
75
 
    if (cur_term == 0
76
 
        || SET_TTY(cur_term->Filedes, buf) != 0) {
77
 
        if ((errno == ENOTTY) && (SP != 0))
78
 
            SP->_notty = TRUE;
79
 
        return (ERR);
 
72
    int result = OK;
 
73
 
 
74
    if (cur_term == 0) {
 
75
        result = ERR;
 
76
    } else {
 
77
        for (;;) {
 
78
            if (SET_TTY(cur_term->Filedes, buf) != 0) {
 
79
                if (errno == EINTR)
 
80
                    continue;
 
81
                if ((errno == ENOTTY) && (SP != 0))
 
82
                    SP->_notty = TRUE;
 
83
                result = ERR;
 
84
            }
 
85
            break;
 
86
        }
80
87
    }
81
88
    TR(TRACE_BITS, ("_nc_set_tty_mode(%d): %s",
82
89
                    cur_term->Filedes, _nc_trace_ttymode(buf)));
83
 
    return (OK);
 
90
    return (result);
84
91
}
85
92
 
86
93
NCURSES_EXPORT(int)
89
96
    T((T_CALLED("def_shell_mode()")));
90
97
 
91
98
    /*
92
 
     * Turn off the XTABS bit in the tty structure if it was on.  If XTABS
93
 
     * was on, remove the tab and backtab capabilities.
 
99
     * If XTABS was on, remove the tab and backtab capabilities.
94
100
     */
95
101
 
96
102
    if (_nc_get_tty_mode(&cur_term->Ottyb) != OK)
97
103
        returnCode(ERR);
98
104
#ifdef TERMIOS
99
 
    if (cur_term->Ottyb.c_oflag & tabs)
 
105
    if (cur_term->Ottyb.c_oflag & OFLAGS_TABS)
100
106
        tab = back_tab = NULL;
101
107
#else
102
108
    if (cur_term->Ottyb.sg_flags & XTABS)
110
116
{
111
117
    T((T_CALLED("def_prog_mode()")));
112
118
 
 
119
    /*
 
120
     * Turn off the XTABS bit in the tty structure if it was on.
 
121
     */
 
122
 
113
123
    if (_nc_get_tty_mode(&cur_term->Nttyb) != OK)
114
124
        returnCode(ERR);
115
125
#ifdef TERMIOS
116
 
    cur_term->Nttyb.c_oflag &= ~tabs;
 
126
    cur_term->Nttyb.c_oflag &= ~OFLAGS_TABS;
117
127
#else
118
128
    cur_term->Nttyb.sg_flags &= ~XTABS;
119
129
#endif