xref: /freebsd/usr.sbin/ppp/prompt.h (revision 1b35f8f70349c56eaae8c72a3de1e59db56da9c0)
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  *
261b35f8f7SBrian Somers  *	$Id: prompt.h,v 1.1.2.2 1998/02/16 00:01:00 brian Exp $
2785b542cfSBrian Somers  */
2885b542cfSBrian Somers 
2985b542cfSBrian Somers struct prompt {
3085b542cfSBrian Somers   struct descriptor desc;
3185b542cfSBrian Somers   int fd_in, fd_out;
321b35f8f7SBrian Somers   struct datalink *TermMode;	/* The modem we're talking directly to */
3385b542cfSBrian Somers   FILE *Term;			/* sits on top of fd_out */
3485b542cfSBrian Somers 
3585b542cfSBrian Somers   struct termios oldtio;	/* Original tty mode */
3685b542cfSBrian Somers   struct termios comtio;	/* Command level tty mode */
3785b542cfSBrian Somers };
3885b542cfSBrian Somers 
3985b542cfSBrian Somers #define prompt2descriptor(p) (&(p)->desc)
4085b542cfSBrian Somers #define descriptor2prompt(d) \
4185b542cfSBrian Somers   ((d)->type == PROMPT_DESCRIPTOR ? (struct prompt *)(d) : NULL)
4285b542cfSBrian Somers 
4385b542cfSBrian Somers extern struct prompt prompt;
4485b542cfSBrian Somers 
4585b542cfSBrian Somers #define prompt_Active(p) ((p)->Term ? 1 : 0)
4685b542cfSBrian Somers #define PROMPT_NONE -2
4785b542cfSBrian Somers #define PROMPT_STD  -1
4885b542cfSBrian Somers extern int  prompt_Init(struct prompt *, int);
493006ec67SBrian Somers extern void prompt_Display(struct prompt *, struct bundle *);
5085b542cfSBrian Somers extern void prompt_Drop(struct prompt *, int);
5185b542cfSBrian Somers extern void prompt_Printf(struct prompt *, const char *, ...);
5285b542cfSBrian Somers extern void prompt_vPrintf(struct prompt *, const char *, _BSD_VA_LIST_);
5385b542cfSBrian Somers #define PROMPT_DONT_WANT_INT 1
5485b542cfSBrian Somers #define PROMPT_WANT_INT 0
5585b542cfSBrian Somers extern void prompt_TtyInit(struct prompt *, int);
5685b542cfSBrian Somers extern void prompt_TtyCommandMode(struct prompt *);
571b35f8f7SBrian Somers extern void prompt_TtyTermMode(struct prompt *, struct datalink *);
5885b542cfSBrian Somers extern void prompt_TtyOldMode(struct prompt *);
5985b542cfSBrian Somers extern pid_t prompt_pgrp(struct prompt *);
6085b542cfSBrian Somers #define prompt_IsTermMode(p) ((p)->TermMode ? 1 : 0)
61