tty.c revision 3f54fd611f536639ec30dd53c48e5ec1897cc7d9
/***********************************************************************
* *
* This software is part of the BSD package *
*Copyright (c) 1978-2006 The Regents of the University of California an*
* *
* Redistribution and use in source and binary forms, with or *
* without modification, are permitted provided that the following *
* conditions are met: *
* *
* 1. Redistributions of source code must retain the above *
* copyright notice, this list of conditions and the *
* following disclaimer. *
* *
* 2. Redistributions in binary form must reproduce the above *
* copyright notice, this list of conditions and the *
* materials provided with the distribution. *
* *
* 3. Neither the name of The Regents of the University of California*
* names of its contributors may be used to endorse or *
* promote products derived from this software without *
* specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF *
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS *
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED *
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON *
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, *
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY *
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
* POSSIBILITY OF SUCH DAMAGE. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* 1. Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in *
* distribution. *
* 3. Neither the name of the University nor the names of its *
* contributors may be used to endorse or promote products derived *
* from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS" *
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS *
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF *
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND *
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, *
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT *
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF *
* SUCH DAMAGE. *
* *
* Kurt Shoens (UCB) *
* gsf *
* *
***********************************************************************/
#pragma prototyped
/*
* Mail -- a mail program
*
* Interactive header editing.
*/
#include "mailx.h"
/*
* tty stuff swiped from ksh
*/
#ifdef _hdr_termios
# include <termios.h>
# ifndef ECHOCTL
# endif /* ECHOCTL */
# ifndef CNSUSP
# endif /* CNSUSP */
# endif /* sgi */
# ifdef _NEXT_SOURCE
# define _lib_tcgetattr 1
# define _lib_tcgetpgrp 1
# endif /* _NEXT_SOURCE */
#else
# if defined(_sys_termios) && defined(_lib_tcgetattr)
# define _hdr_termios
# else
# endif /* _sys_termios */
#endif /* _hdr_termios */
#ifdef _hdr_termios
# ifndef TCSANOW
# endif /* TCSANOW */
/* The following corrects bugs in some implementations */
# if defined(TCSADFLUSH) && !defined(TCSAFLUSH)
# define TCSAFLUSH TCSADFLUSH
# endif /* TCSADFLUSH */
# ifndef _lib_tcgetattr
# endif /* _lib_tcgetattr */
# if SHOPT_OLDTERMIO /* use both termios and termio */
# ifdef _hdr_termio
# include <termio.h>
# else
# ifdef _sys_termio
# define _hdr_termio 1
# else
# endif /* _sys_termio */
# endif /* _hdr_termio */
# endif /* SHOPT_OLDTERMIO */
#else
# ifdef _hdr_termio
# include <termio.h>
# else
# ifdef _sys_termio
# define _hdr_termio 1
# endif /* _sys_termio */
# endif /* _hdr_termio */
# ifdef _hdr_termio
# ifdef _sys_bsdtty
# endif /* _sys_bsdtty */
# else
# ifdef _hdr_sgtty
# include <sgtty.h>
# ifndef LPENDIN
# ifdef _sys_nttyio
# endif /* _sys_nttyio */
# endif /* LPENDIN */
# ifdef TIOCSETN
# endif /* TIOCSETN */
# ifdef TIOCGETP
# else
# endif /* TIOCGETP */
# endif /* _hdr_sgtty */
# endif /* hdr_termio */
# ifndef TCSANOW
# ifdef TCSETAW
# ifdef u370
/* delays are too long, don't wait for output to drain */
# else
# endif /* u370 */
# else
# ifdef TIOCSETN
# endif /* TIOCSETN */
# endif /* TCSETAW */
# endif /* TCSANOW */
#endif /* _hdr_termios */
/* set ECHOCTL if driver can echo control charaters as ^c */
#ifdef LCTLECH
# ifndef ECHOCTL
# endif /* !ECHOCTL */
#endif /* LCTLECH */
#ifdef LNEW_CTLECH
# ifndef ECHOCTL
# define ECHOCTL LNEW_CTLECH
# endif /* !ECHOCTL */
#endif /* LNEW_CTLECH */
#ifdef LNEW_PENDIN
# ifndef PENDIN
# define PENDIN LNEW_PENDIN
# endif /* !PENDIN */
#endif /* LNEW_PENDIN */
#ifndef ECHOCTL
# ifndef VEOL
# define RAWONLY 1
# endif /* !VEOL */
#endif /* !ECHOCTL */
/*
* Output label on wfd and return next char on rfd with no echo.
* Return < -1 is -(signal + 1).
*/
int
{
register int r;
int n;
unsigned char c;
if (!label)
n = 0;
r = -1;
r = -(SIGINT + 1);
r = -(SIGQUIT + 1);
else if (c == '\r')
r = '\n';
else
r = c;
}
if (n) {
while (n-- > 0)
}
return r;
}
/*
* Edit buf on rfd,wfd with label.
* Do not backspace over label.
*/
int
{
register int r;
unsigned char c;
size--;
if (label)
if (last)
for (;;) {
break;
if (last == 0)
else {
last--;
}
}
last = 0;
}
r = last;
break;
}
r = -(SIGINT + 1);
break;
}
r = -(SIGQUIT + 1);
break;
}
r = -1;
break;
}
else {
if (c == '\r')
c = '\n';
if (c == '\n') {
r = --last;
break;
}
r = last;
}
}
if (r >= 0)
return r;
}
/*
* Edit the fields in type.
*/
void
{
register char* s;
int r;
r = 0;
s = "";
continue;
}
break;
}
if (r < -1)
kill(0, -(r + 1));
}