mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-07 13:14:51 +00:00
Keep a handle on our current ``term'' in struct prompt
so that the `term' command works on the correct link.
This commit is contained in:
parent
aef795cc3b
commit
1b35f8f703
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/cvs2svn/branches/MP/; revision=33509
@ -17,7 +17,7 @@
|
|||||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
*
|
*
|
||||||
* $Id: command.c,v 1.131.2.21 1998/02/17 01:05:36 brian Exp $
|
* $Id: command.c,v 1.131.2.22 1998/02/17 19:27:51 brian Exp $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
@ -808,7 +808,7 @@ TerminalCommand(struct cmdargs const *arg)
|
|||||||
datalink_Up(arg->cx, 0, 0);
|
datalink_Up(arg->cx, 0, 0);
|
||||||
prompt_Printf(&prompt, "Entering terminal mode.\n");
|
prompt_Printf(&prompt, "Entering terminal mode.\n");
|
||||||
prompt_Printf(&prompt, "Type `~?' for help.\n");
|
prompt_Printf(&prompt, "Type `~?' for help.\n");
|
||||||
prompt_TtyTermMode(&prompt);
|
prompt_TtyTermMode(&prompt, arg->cx);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* $Id: prompt.c,v 1.1.2.4 1998/02/17 01:05:47 brian Exp $
|
* $Id: prompt.c,v 1.1.2.5 1998/02/17 19:28:00 brian Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
@ -113,31 +113,28 @@ static void
|
|||||||
prompt_Read(struct descriptor *d, struct bundle *bundle, const fd_set *fdset)
|
prompt_Read(struct descriptor *d, struct bundle *bundle, const fd_set *fdset)
|
||||||
{
|
{
|
||||||
struct prompt *p = descriptor2prompt(d);
|
struct prompt *p = descriptor2prompt(d);
|
||||||
struct datalink *dl = NULL;
|
|
||||||
int n;
|
int n;
|
||||||
char ch;
|
char ch;
|
||||||
static int ttystate;
|
static int ttystate;
|
||||||
char linebuff[LINE_LEN];
|
char linebuff[LINE_LEN];
|
||||||
|
|
||||||
if (p->TermMode) {
|
if (p->TermMode != NULL) {
|
||||||
dl = bundle2datalink(bundle, NULL);
|
if (p->TermMode->state == DATALINK_CLOSED) {
|
||||||
|
|
||||||
if (dl->state == DATALINK_CLOSED) {
|
|
||||||
prompt_Printf(p, "Exiting terminal mode.\n");
|
prompt_Printf(p, "Exiting terminal mode.\n");
|
||||||
prompt_TtyCommandMode(&prompt);
|
prompt_TtyCommandMode(&prompt);
|
||||||
prompt_nonewline = 0;
|
prompt_nonewline = 0;
|
||||||
prompt_Display(&prompt, bundle);
|
prompt_Display(&prompt, bundle);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dl->state != DATALINK_OPEN)
|
if (p->TermMode->state != DATALINK_OPEN)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogPrintf(LogDEBUG, "descriptor2prompt; %p -> %p\n", d, p);
|
LogPrintf(LogDEBUG, "descriptor2prompt; %p -> %p\n", d, p);
|
||||||
LogPrintf(LogDEBUG, "termode = %d, p->fd_in = %d, mode = %d\n",
|
LogPrintf(LogDEBUG, "termode = %p, p->fd_in = %d, mode = %d\n",
|
||||||
p->TermMode, p->fd_in, mode);
|
p->TermMode, p->fd_in, mode);
|
||||||
|
|
||||||
if (!p->TermMode) {
|
if (p->TermMode == NULL) {
|
||||||
n = read(p->fd_in, linebuff, sizeof linebuff - 1);
|
n = read(p->fd_in, linebuff, sizeof linebuff - 1);
|
||||||
if (n > 0) {
|
if (n > 0) {
|
||||||
if (linebuff[n-1] == '\n')
|
if (linebuff[n-1] == '\n')
|
||||||
@ -184,7 +181,6 @@ prompt_Read(struct descriptor *d, struct bundle *bundle, const fd_set *fdset)
|
|||||||
PacketMode(bundle, 0);
|
PacketMode(bundle, 0);
|
||||||
break;
|
break;
|
||||||
case '.':
|
case '.':
|
||||||
p->TermMode = 1;
|
|
||||||
prompt_TtyCommandMode(&prompt);
|
prompt_TtyCommandMode(&prompt);
|
||||||
prompt_nonewline = 0;
|
prompt_nonewline = 0;
|
||||||
prompt_Display(&prompt, bundle);
|
prompt_Display(&prompt, bundle);
|
||||||
@ -247,7 +243,7 @@ prompt_Init(struct prompt *p, int fd)
|
|||||||
p->fd_in = p->fd_out = fd;
|
p->fd_in = p->fd_out = fd;
|
||||||
p->Term = fdopen(fd, "a+");
|
p->Term = fdopen(fd, "a+");
|
||||||
}
|
}
|
||||||
p->TermMode = 0;
|
p->TermMode = NULL;
|
||||||
tcgetattr(STDIN_FILENO, &p->oldtio); /* Save original tty mode */
|
tcgetattr(STDIN_FILENO, &p->oldtio); /* Save original tty mode */
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@ -258,7 +254,7 @@ prompt_Display(struct prompt *p, struct bundle *bundle)
|
|||||||
{
|
{
|
||||||
const char *pconnect, *pauth;
|
const char *pconnect, *pauth;
|
||||||
|
|
||||||
if (!p->Term || p->TermMode || CleaningUp)
|
if (!p->Term || p->TermMode != NULL || CleaningUp)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (prompt_nonewline)
|
if (prompt_nonewline)
|
||||||
@ -372,14 +368,14 @@ prompt_TtyCommandMode(struct prompt *p)
|
|||||||
stat |= O_NONBLOCK;
|
stat |= O_NONBLOCK;
|
||||||
(void) fcntl(p->fd_in, F_SETFL, stat);
|
(void) fcntl(p->fd_in, F_SETFL, stat);
|
||||||
}
|
}
|
||||||
p->TermMode = 0;
|
p->TermMode = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set tty into terminal mode which is used while we invoke term command.
|
* Set tty into terminal mode which is used while we invoke term command.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
prompt_TtyTermMode(struct prompt *p)
|
prompt_TtyTermMode(struct prompt *p, struct datalink *dl)
|
||||||
{
|
{
|
||||||
int stat;
|
int stat;
|
||||||
|
|
||||||
@ -389,7 +385,7 @@ prompt_TtyTermMode(struct prompt *p)
|
|||||||
stat &= ~O_NONBLOCK;
|
stat &= ~O_NONBLOCK;
|
||||||
(void) fcntl(p->fd_in, F_SETFL, stat);
|
(void) fcntl(p->fd_in, F_SETFL, stat);
|
||||||
}
|
}
|
||||||
p->TermMode = 1;
|
p->TermMode = dl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -23,13 +23,13 @@
|
|||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* $Id: prompt.h,v 1.1.2.1 1998/02/10 03:23:39 brian Exp $
|
* $Id: prompt.h,v 1.1.2.2 1998/02/16 00:01:00 brian Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct prompt {
|
struct prompt {
|
||||||
struct descriptor desc;
|
struct descriptor desc;
|
||||||
int fd_in, fd_out;
|
int fd_in, fd_out;
|
||||||
int TermMode;
|
struct datalink *TermMode; /* The modem we're talking directly to */
|
||||||
FILE *Term; /* sits on top of fd_out */
|
FILE *Term; /* sits on top of fd_out */
|
||||||
|
|
||||||
struct termios oldtio; /* Original tty mode */
|
struct termios oldtio; /* Original tty mode */
|
||||||
@ -54,7 +54,7 @@ extern void prompt_vPrintf(struct prompt *, const char *, _BSD_VA_LIST_);
|
|||||||
#define PROMPT_WANT_INT 0
|
#define PROMPT_WANT_INT 0
|
||||||
extern void prompt_TtyInit(struct prompt *, int);
|
extern void prompt_TtyInit(struct prompt *, int);
|
||||||
extern void prompt_TtyCommandMode(struct prompt *);
|
extern void prompt_TtyCommandMode(struct prompt *);
|
||||||
extern void prompt_TtyTermMode(struct prompt *);
|
extern void prompt_TtyTermMode(struct prompt *, struct datalink *);
|
||||||
extern void prompt_TtyOldMode(struct prompt *);
|
extern void prompt_TtyOldMode(struct prompt *);
|
||||||
extern pid_t prompt_pgrp(struct prompt *);
|
extern pid_t prompt_pgrp(struct prompt *);
|
||||||
#define prompt_IsTermMode(p) ((p)->TermMode ? 1 : 0)
|
#define prompt_IsTermMode(p) ((p)->TermMode ? 1 : 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user