1*86d7f5d3SJohn Marino /*- 2*86d7f5d3SJohn Marino * Copyright (c) 1998 Brian Somers <brian@Awfulhak.org> 3*86d7f5d3SJohn Marino * All rights reserved. 4*86d7f5d3SJohn Marino * 5*86d7f5d3SJohn Marino * Redistribution and use in source and binary forms, with or without 6*86d7f5d3SJohn Marino * modification, are permitted provided that the following conditions 7*86d7f5d3SJohn Marino * are met: 8*86d7f5d3SJohn Marino * 1. Redistributions of source code must retain the above copyright 9*86d7f5d3SJohn Marino * notice, this list of conditions and the following disclaimer. 10*86d7f5d3SJohn Marino * 2. Redistributions in binary form must reproduce the above copyright 11*86d7f5d3SJohn Marino * notice, this list of conditions and the following disclaimer in the 12*86d7f5d3SJohn Marino * documentation and/or other materials provided with the distribution. 13*86d7f5d3SJohn Marino * 14*86d7f5d3SJohn Marino * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15*86d7f5d3SJohn Marino * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16*86d7f5d3SJohn Marino * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17*86d7f5d3SJohn Marino * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18*86d7f5d3SJohn Marino * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19*86d7f5d3SJohn Marino * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20*86d7f5d3SJohn Marino * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21*86d7f5d3SJohn Marino * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22*86d7f5d3SJohn Marino * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23*86d7f5d3SJohn Marino * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24*86d7f5d3SJohn Marino * SUCH DAMAGE. 25*86d7f5d3SJohn Marino * 26*86d7f5d3SJohn Marino * $FreeBSD: src/usr.sbin/ppp/prompt.h,v 1.5.2.3 2002/09/01 02:12:32 brian Exp $ 27*86d7f5d3SJohn Marino * $DragonFly: src/usr.sbin/ppp/prompt.h,v 1.2 2003/06/17 04:30:01 dillon Exp $ 28*86d7f5d3SJohn Marino */ 29*86d7f5d3SJohn Marino 30*86d7f5d3SJohn Marino #define LOCAL_AUTH 0x01 31*86d7f5d3SJohn Marino #define LOCAL_NO_AUTH 0x02 32*86d7f5d3SJohn Marino #define LOCAL_DENY 0x03 33*86d7f5d3SJohn Marino #define LOCAL_CX 0x04 /* OR'd value - require a context */ 34*86d7f5d3SJohn Marino #define LOCAL_CX_OPT 0x08 /* OR'd value - optional context */ 35*86d7f5d3SJohn Marino 36*86d7f5d3SJohn Marino struct server; 37*86d7f5d3SJohn Marino struct datalink; 38*86d7f5d3SJohn Marino struct bundle; 39*86d7f5d3SJohn Marino struct cmdargs; 40*86d7f5d3SJohn Marino 41*86d7f5d3SJohn Marino struct prompt { 42*86d7f5d3SJohn Marino struct fdescriptor desc; 43*86d7f5d3SJohn Marino int fd_in, fd_out; 44*86d7f5d3SJohn Marino struct datalink *TermMode; /* The modem we're talking directly to */ 45*86d7f5d3SJohn Marino FILE *Term; /* sits on top of fd_out */ 46*86d7f5d3SJohn Marino u_char auth; /* Local Authorized status */ 47*86d7f5d3SJohn Marino struct server *owner; /* who created me */ 48*86d7f5d3SJohn Marino struct bundle *bundle; /* who I'm controlling */ 49*86d7f5d3SJohn Marino unsigned nonewline : 1; /* need a newline before our prompt ? */ 50*86d7f5d3SJohn Marino unsigned needprompt : 1; /* Show a prompt at the next UpdateSet() */ 51*86d7f5d3SJohn Marino unsigned active : 1; /* Is the prompt active (^Z) */ 52*86d7f5d3SJohn Marino unsigned readtilde : 1; /* We've read a ``~'' from fd_in */ 53*86d7f5d3SJohn Marino 54*86d7f5d3SJohn Marino struct { 55*86d7f5d3SJohn Marino const char *type; /* Type of connection */ 56*86d7f5d3SJohn Marino char from[40]; /* Source of connection */ 57*86d7f5d3SJohn Marino } src; 58*86d7f5d3SJohn Marino 59*86d7f5d3SJohn Marino struct prompt *next; /* Maintained in log.c */ 60*86d7f5d3SJohn Marino u_long logmask; /* Maintained in log.c */ 61*86d7f5d3SJohn Marino 62*86d7f5d3SJohn Marino struct termios oldtio; /* Original tty mode */ 63*86d7f5d3SJohn Marino struct termios comtio; /* Command level tty mode */ 64*86d7f5d3SJohn Marino }; 65*86d7f5d3SJohn Marino 66*86d7f5d3SJohn Marino #define descriptor2prompt(d) \ 67*86d7f5d3SJohn Marino ((d)->type == PROMPT_DESCRIPTOR ? (struct prompt *)(d) : NULL) 68*86d7f5d3SJohn Marino 69*86d7f5d3SJohn Marino #define PROMPT_STD (-1) 70*86d7f5d3SJohn Marino extern struct prompt *prompt_Create(struct server *, struct bundle *, int); 71*86d7f5d3SJohn Marino extern void prompt_Destroy(struct prompt *, int); 72*86d7f5d3SJohn Marino extern void prompt_Required(struct prompt *); 73*86d7f5d3SJohn Marino #ifdef __GNUC__ 74*86d7f5d3SJohn Marino extern void prompt_Printf(struct prompt *, const char *, ...) 75*86d7f5d3SJohn Marino __attribute__ ((format (printf, 2, 3))); 76*86d7f5d3SJohn Marino #else 77*86d7f5d3SJohn Marino extern void prompt_Printf(struct prompt *, const char *, ...); 78*86d7f5d3SJohn Marino #endif 79*86d7f5d3SJohn Marino #ifdef __GNUC__ 80*86d7f5d3SJohn Marino extern void prompt_vPrintf(struct prompt *, const char *, va_list) 81*86d7f5d3SJohn Marino __attribute__ ((format (printf, 2, 0))); 82*86d7f5d3SJohn Marino #else 83*86d7f5d3SJohn Marino extern void prompt_vPrintf(struct prompt *, const char *, va_list); 84*86d7f5d3SJohn Marino #endif 85*86d7f5d3SJohn Marino #define PROMPT_DONT_WANT_INT 1 86*86d7f5d3SJohn Marino #define PROMPT_WANT_INT 0 87*86d7f5d3SJohn Marino extern void prompt_TtyInit(struct prompt *); 88*86d7f5d3SJohn Marino extern void prompt_TtyCommandMode(struct prompt *); 89*86d7f5d3SJohn Marino extern void prompt_TtyTermMode(struct prompt *, struct datalink *); 90*86d7f5d3SJohn Marino extern void prompt_TtyOldMode(struct prompt *); 91*86d7f5d3SJohn Marino extern pid_t prompt_pgrp(struct prompt *); 92*86d7f5d3SJohn Marino extern int PasswdCommand(struct cmdargs const *); 93*86d7f5d3SJohn Marino extern void prompt_Suspend(struct prompt *); 94*86d7f5d3SJohn Marino extern void prompt_Continue(struct prompt *); 95*86d7f5d3SJohn Marino #define prompt_IsTermMode(p, dl) ((p)->TermMode == (dl) ? 1 : 0) 96*86d7f5d3SJohn Marino #define prompt_IsController(p) (!(p) || (p)->owner ? 0 : 1) 97*86d7f5d3SJohn Marino #define prompt_Required(p) ((p)->needprompt = 1) 98