xref: /freebsd/usr.sbin/ppp/prompt.h (revision f91ad6b0b7c831f92e5a3a47afccf2bc8a0b60e6)
185b542cfSBrian Somers /*-
285b542cfSBrian Somers  * Copyright (c) 1998 Brian Somers <brian@Awfulhak.org>
385b542cfSBrian Somers  * All rights reserved.
485b542cfSBrian Somers  *
585b542cfSBrian Somers  * Redistribution and use in source and binary forms, with or without
685b542cfSBrian Somers  * modification, are permitted provided that the following conditions
785b542cfSBrian Somers  * are met:
885b542cfSBrian Somers  * 1. Redistributions of source code must retain the above copyright
985b542cfSBrian Somers  *    notice, this list of conditions and the following disclaimer.
1085b542cfSBrian Somers  * 2. Redistributions in binary form must reproduce the above copyright
1185b542cfSBrian Somers  *    notice, this list of conditions and the following disclaimer in the
1285b542cfSBrian Somers  *    documentation and/or other materials provided with the distribution.
1385b542cfSBrian Somers  *
1485b542cfSBrian Somers  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1585b542cfSBrian Somers  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1685b542cfSBrian Somers  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1785b542cfSBrian Somers  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1885b542cfSBrian Somers  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1985b542cfSBrian Somers  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2085b542cfSBrian Somers  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2185b542cfSBrian Somers  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2285b542cfSBrian Somers  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2385b542cfSBrian Somers  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2485b542cfSBrian Somers  * SUCH DAMAGE.
2585b542cfSBrian Somers  *
26f91ad6b0SBrian Somers  *	$Id: prompt.h,v 1.1.2.4 1998/04/03 19:25:51 brian Exp $
2785b542cfSBrian Somers  */
2885b542cfSBrian Somers 
29b6217683SBrian Somers #define LOCAL_AUTH	0x01
30b6217683SBrian Somers #define LOCAL_NO_AUTH	0x02
31b6217683SBrian Somers #define LOCAL_DENY	0x03
32b6217683SBrian Somers #define LOCAL_CX	0x04	/* OR'd value - require a context */
33b6217683SBrian Somers #define LOCAL_CX_OPT	0x08	/* OR'd value - optional context */
34b6217683SBrian Somers 
35b6217683SBrian Somers struct server;
36b6217683SBrian Somers struct bundle;
37b6217683SBrian Somers 
3885b542cfSBrian Somers struct prompt {
3985b542cfSBrian Somers   struct descriptor desc;
4085b542cfSBrian Somers   int fd_in, fd_out;
411b35f8f7SBrian Somers   struct datalink *TermMode;	/* The modem we're talking directly to */
4285b542cfSBrian Somers   FILE *Term;			/* sits on top of fd_out */
43b6217683SBrian Somers   u_char auth;			/* Local Authorized status */
44b6217683SBrian Somers   struct server *owner;         /* who created me */
45b6217683SBrian Somers   struct bundle *bundle;	/* who I'm controlling */
46b6217683SBrian Somers   unsigned nonewline : 1;	/* need a newline before our prompt ? */
47b6217683SBrian Somers   unsigned needprompt : 1;	/* Show a prompt at the next UpdateSet() */
48f91ad6b0SBrian Somers   unsigned active : 1;		/* Is the prompt active (^Z) */
49b6217683SBrian Somers 
50b6217683SBrian Somers   char who[40];			/* Where do I come from */
51b6217683SBrian Somers 
52b6217683SBrian Somers   struct prompt *lognext;	/* Maintained in log.c */
53b6217683SBrian Somers   u_long logmask;		/* Maintained in log.c */
5485b542cfSBrian Somers 
5585b542cfSBrian Somers   struct termios oldtio;	/* Original tty mode */
5685b542cfSBrian Somers   struct termios comtio;	/* Command level tty mode */
5785b542cfSBrian Somers };
5885b542cfSBrian Somers 
5985b542cfSBrian Somers #define prompt2descriptor(p) (&(p)->desc)
6085b542cfSBrian Somers #define descriptor2prompt(d) \
6185b542cfSBrian Somers   ((d)->type == PROMPT_DESCRIPTOR ? (struct prompt *)(d) : NULL)
6285b542cfSBrian Somers 
63b6217683SBrian Somers #define PROMPT_STD (-1)
64b6217683SBrian Somers extern struct prompt *prompt_Create(struct server *, struct bundle *, int);
65b6217683SBrian Somers extern void prompt_Destroy(struct prompt *, int);
66b6217683SBrian Somers extern void prompt_DestroyUnclean(struct prompt *);
67b6217683SBrian Somers extern void prompt_Required(struct prompt *);
6885b542cfSBrian Somers extern void prompt_Printf(struct prompt *, const char *, ...);
6985b542cfSBrian Somers extern void prompt_vPrintf(struct prompt *, const char *, _BSD_VA_LIST_);
7085b542cfSBrian Somers #define PROMPT_DONT_WANT_INT 1
7185b542cfSBrian Somers #define PROMPT_WANT_INT 0
7285b542cfSBrian Somers extern void prompt_TtyInit(struct prompt *, int);
7385b542cfSBrian Somers extern void prompt_TtyCommandMode(struct prompt *);
741b35f8f7SBrian Somers extern void prompt_TtyTermMode(struct prompt *, struct datalink *);
7585b542cfSBrian Somers extern void prompt_TtyOldMode(struct prompt *);
7685b542cfSBrian Somers extern pid_t prompt_pgrp(struct prompt *);
77b6217683SBrian Somers extern int PasswdCommand(struct cmdargs const *);
78f91ad6b0SBrian Somers extern void prompt_Suspend(struct prompt *);
79f91ad6b0SBrian Somers extern void prompt_Continue(struct prompt *);
80b6217683SBrian Somers #define prompt_IsTermMode(p, dl) ((p)->TermMode == (dl) ? 1 : 0)
81b6217683SBrian Somers #define prompt_IsController(p) (!(p) || (p)->owner ? 0 : 1)
82b6217683SBrian Somers #define prompt_Required(p) ((p)->needprompt = 1)
83