Initial import from FreeBSD RELENG_4:
[dragonfly.git] / libexec / telnetd / ext.h
1 /*
2  * Copyright (c) 1989, 1993
3  *      The Regents of the University of California.  All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. All advertising materials mentioning features or use of this software
14  *    must display the following acknowledgement:
15  *      This product includes software developed by the University of
16  *      California, Berkeley and its contributors.
17  * 4. Neither the name of the University nor the names of its contributors
18  *    may be used to endorse or promote products derived from this software
19  *    without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31  * SUCH DAMAGE.
32  *
33  *      @(#)ext.h       8.2 (Berkeley) 12/15/93
34  * $FreeBSD: src/libexec/telnetd/ext.h,v 1.7.2.4 2002/04/13 11:07:12 markm Exp $
35  */
36
37 /*
38  * Telnet server variable declarations
39  */
40 extern char     options[256];
41 extern char     do_dont_resp[256];
42 extern char     will_wont_resp[256];
43 extern int      linemode;       /* linemode on/off */
44 #ifdef  LINEMODE
45 extern int      uselinemode;    /* what linemode to use (on/off) */
46 extern int      editmode;       /* edit modes in use */
47 extern int      useeditmode;    /* edit modes to use */
48 extern int      alwayslinemode; /* command line option */
49 extern int      lmodetype;      /* Client support for linemode */
50 #endif  /* LINEMODE */
51 extern int      flowmode;       /* current flow control state */
52 extern int      restartany;     /* restart output on any character state */
53 #ifdef DIAGNOSTICS
54 extern int      diagnostic;     /* telnet diagnostic capabilities */
55 #endif /* DIAGNOSTICS */
56 #ifdef BFTPDAEMON
57 extern int      bftpd;          /* behave as bftp daemon */
58 #endif /* BFTPDAEMON */
59
60 extern slcfun   slctab[NSLC + 1];       /* slc mapping table */
61
62 char    *terminaltype;
63
64 /*
65  * I/O data buffers, pointers, and counters.
66  */
67 extern char     ptyobuf[BUFSIZ+NETSLOP], *pfrontp, *pbackp;
68
69 extern char     netibuf[BUFSIZ], *netip;
70
71 extern char     netobuf[BUFSIZ], *nfrontp, *nbackp;
72 extern char     *neturg;                /* one past last bye of urgent data */
73
74 extern int      pcc, ncc;
75
76 extern int      pty, net;
77 extern char     line[16];
78 extern int      SYNCHing;               /* we are in TELNET SYNCH mode */
79
80 extern void
81         _termstat(void),
82         add_slc(char, char, cc_t),
83         check_slc(void),
84         change_slc(char, char, cc_t),
85         cleanup(int),
86         clientstat(int, int, int),
87         copy_termbuf(char *, size_t),
88         deferslc(void),
89         defer_terminit(void),
90         do_opt_slc(unsigned char *, int),
91         doeof(void),
92         dooption(int),
93         dontoption(int),
94         edithost(char *, char *),
95         fatal(int, const char *),
96         fatalperror(int, const char *),
97         get_slc_defaults(void),
98         init_env(void),
99         init_termbuf(void),
100         interrupt(void),
101         localstat(void),
102         flowstat(void),
103         netclear(void),
104         netflush(void),
105 #ifdef DIAGNOSTICS
106         printoption(const char *, int),
107         printdata(const char *, char *, int),
108         printsub(char, unsigned char *, int),
109 #endif
110         process_slc(unsigned char, unsigned char, cc_t),
111         ptyflush(void),
112         putchr(int),
113         putf(char *, char *),
114         recv_ayt(void),
115         send_do(int, int),
116         send_dont(int, int),
117         send_slc(void),
118         send_status(void),
119         send_will(int, int),
120         send_wont(int, int),
121         sendbrk(void),
122         sendsusp(void),
123         set_termbuf(void),
124         start_login(char *, int, char *),
125         start_slc(int),
126         start_slave(char *, int, char *),
127         suboption(void),
128         telrcv(void),
129         ttloop(void),
130         tty_binaryin(int),
131         tty_binaryout(int);
132
133 extern int
134         end_slc(unsigned char **),
135         getnpty(void),
136 #ifndef convex
137         getpty(int *),
138 #endif
139         login_tty(int),
140         spcset(int, cc_t *, cc_t **),
141         stilloob(int),
142         terminit(void),
143         termstat(void),
144         tty_flowmode(void),
145         tty_restartany(void),
146         tty_isbinaryin(void),
147         tty_isbinaryout(void),
148         tty_iscrnl(void),
149         tty_isecho(void),
150         tty_isediting(void),
151         tty_islitecho(void),
152         tty_isnewmap(void),
153         tty_israw(void),
154         tty_issofttab(void),
155         tty_istrapsig(void),
156         tty_linemode(void);
157
158 extern void
159         tty_rspeed(int),
160         tty_setecho(int),
161         tty_setedit(int),
162         tty_setlinemode(int),
163         tty_setlitecho(int),
164         tty_setsig(int),
165         tty_setsofttab(int),
166         tty_tspeed(int),
167         willoption(int),
168         wontoption(int);
169
170 int     output_data(const char *, ...) __printflike(1, 2);
171 void    output_datalen(const char *, int);
172 void    startslave(char *, int, char *);
173
174
175
176 /*
177  * The following are some clocks used to decide how to interpret
178  * the relationship between various variables.
179  */
180
181 extern struct {
182     int
183         system,                 /* what the current time is */
184         echotoggle,             /* last time user entered echo character */
185         modenegotiated,         /* last time operating mode negotiated */
186         didnetreceive,          /* last time we read data from network */
187         ttypesubopt,            /* ttype subopt is received */
188         tspeedsubopt,           /* tspeed subopt is received */
189         environsubopt,          /* environ subopt is received */
190         oenvironsubopt,         /* old environ subopt is received */
191         xdisplocsubopt,         /* xdisploc subopt is received */
192         baseline,               /* time started to do timed action */
193         gotDM;                  /* when did we last see a data mark */
194 } clocks;
195
196 #ifndef DEFAULT_IM
197 #   ifdef ultrix
198 #    define DEFAULT_IM  "\r\n\r\nULTRIX (%h) (%t)\r\n\r\r\n\r"
199 #   else
200 #    ifdef __FreeBSD__
201 #     define DEFAULT_IM  "\r\n\r\nFreeBSD (%h) (%t)\r\n\r\r\n\r"
202 #    else
203 #    define DEFAULT_IM  "\r\n\r\n4.4 BSD UNIX (%h) (%t)\r\n\r\r\n\r"
204 #    endif
205 #   endif
206 #endif