[BACK]Return to externs.h CVS log [TXT][DIR] Up to [local] / src / usr.bin / telnet

Annotation of src/usr.bin/telnet/externs.h, Revision 1.5

1.5     ! fgsch       1: /*     $OpenBSD: externs.h,v 1.4 1998/03/12 17:31:32 deraadt Exp $     */
1.3       art         2: /* $KTH: externs.h,v 1.16 1997/11/29 02:28:35 joda Exp $ */
1.2       niklas      3:
1.1       deraadt     4: /*
                      5:  * Copyright (c) 1988, 1990, 1993
                      6:  *     The Regents of the University of California.  All rights reserved.
                      7:  *
                      8:  * Redistribution and use in source and binary forms, with or without
                      9:  * modification, are permitted provided that the following conditions
                     10:  * are met:
                     11:  * 1. Redistributions of source code must retain the above copyright
                     12:  *    notice, this list of conditions and the following disclaimer.
                     13:  * 2. Redistributions in binary form must reproduce the above copyright
                     14:  *    notice, this list of conditions and the following disclaimer in the
                     15:  *    documentation and/or other materials provided with the distribution.
                     16:  * 3. All advertising materials mentioning features or use of this software
                     17:  *    must display the following acknowledgement:
                     18:  *     This product includes software developed by the University of
                     19:  *     California, Berkeley and its contributors.
                     20:  * 4. Neither the name of the University nor the names of its contributors
                     21:  *    may be used to endorse or promote products derived from this software
                     22:  *    without specific prior written permission.
                     23:  *
                     24:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     25:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     26:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     27:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     28:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     29:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     30:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     31:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     32:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     33:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     34:  * SUCH DAMAGE.
                     35:  *
1.3       art        36:  *     @(#)externs.h   8.3 (Berkeley) 5/30/95
1.1       deraadt    37:  */
                     38:
                     39: #ifndef        BSD
                     40: # define BSD 43
                     41: #endif
                     42:
                     43: #ifndef        _POSIX_VDISABLE
                     44: # ifdef sun
                     45: #  include <sys/param.h>       /* pick up VDISABLE definition, mayby */
                     46: # endif
                     47: # ifdef VDISABLE
                     48: #  define _POSIX_VDISABLE VDISABLE
                     49: # else
                     50: #  define _POSIX_VDISABLE ((cc_t)'\377')
                     51: # endif
                     52: #endif
                     53:
                     54: #define        SUBBUFSIZE      256
                     55:
                     56: extern int
                     57:     autologin,         /* Autologin enabled */
                     58:     skiprc,            /* Don't process the ~/.telnetrc file */
                     59:     eight,             /* use eight bit mode (binary in and/or out */
1.3       art        60:     binary,
1.1       deraadt    61:     flushout,          /* flush output */
                     62:     connected,         /* Are we connected to the other side? */
                     63:     globalmode,                /* Mode tty should be in */
                     64:     telnetport,                /* Are we connected to the telnet port? */
1.3       art        65:     In3270,            /* Are we in 3270 mode? */
1.1       deraadt    66:     localflow,         /* Flow control handled locally */
                     67:     restartany,                /* If flow control, restart output on any character */
                     68:     localchars,                /* we recognize interrupt/quit */
1.2       niklas     69:     donelclchars,      /* the user has set "localchars" */
1.1       deraadt    70:     showoptions,
                     71:     net,               /* Network file descriptor */
                     72:     tin,               /* Terminal input file descriptor */
                     73:     tout,              /* Terminal output file descriptor */
                     74:     crlf,              /* Should '\r' be mapped to <CR><LF> (or <CR><NUL>)? */
                     75:     autoflush,         /* flush output when interrupting? */
                     76:     autosynch,         /* send interrupt characters with SYNCH? */
                     77:     SYNCHing,          /* Is the stream in telnet SYNCH mode? */
                     78:     donebinarytoggle,  /* the user has put us in binary */
                     79:     dontlecho,         /* do we suppress local echoing right now? */
                     80:     crmod,
                     81:     netdata,           /* Print out network data flow */
                     82:     prettydump,                /* Print "netdata" output in user readable format */
1.4       deraadt    83: #if    defined(TN3270)
                     84:     cursesdata,                /* Print out curses data flow */
                     85:     apitrace,          /* Trace API transactions */
                     86: #endif /* defined(TN3270) */
1.1       deraadt    87:     termdata,          /* Print out terminal data flow */
1.3       art        88:     debug;             /* Debug level */
1.1       deraadt    89:
                     90: extern cc_t escape;    /* Escape to command mode */
                     91: extern cc_t rlogin;    /* Rlogin mode escape character */
                     92: #ifdef KLUDGELINEMODE
                     93: extern cc_t echoc;     /* Toggle local echoing */
                     94: #endif
                     95:
                     96: extern char
                     97:     *prompt;           /* Prompt for command. */
                     98:
                     99: extern char
                    100:     doopt[],
                    101:     dont[],
                    102:     will[],
                    103:     wont[],
                    104:     options[],         /* All the little options */
                    105:     *hostname;         /* Who are we connected to? */
1.3       art       106: #if    defined(ENCRYPTION)
                    107: extern void (*encrypt_output) (unsigned char *, int);
                    108: extern int (*decrypt_input) (int);
                    109: #endif
1.1       deraadt   110:
                    111: /*
                    112:  * We keep track of each side of the option negotiation.
                    113:  */
                    114:
                    115: #define        MY_STATE_WILL           0x01
                    116: #define        MY_WANT_STATE_WILL      0x02
                    117: #define        MY_STATE_DO             0x04
                    118: #define        MY_WANT_STATE_DO        0x08
                    119:
                    120: /*
                    121:  * Macros to check the current state of things
                    122:  */
                    123:
                    124: #define        my_state_is_do(opt)             (options[opt]&MY_STATE_DO)
                    125: #define        my_state_is_will(opt)           (options[opt]&MY_STATE_WILL)
                    126: #define my_want_state_is_do(opt)       (options[opt]&MY_WANT_STATE_DO)
                    127: #define my_want_state_is_will(opt)     (options[opt]&MY_WANT_STATE_WILL)
                    128:
                    129: #define        my_state_is_dont(opt)           (!my_state_is_do(opt))
                    130: #define        my_state_is_wont(opt)           (!my_state_is_will(opt))
                    131: #define my_want_state_is_dont(opt)     (!my_want_state_is_do(opt))
                    132: #define my_want_state_is_wont(opt)     (!my_want_state_is_will(opt))
                    133:
                    134: #define        set_my_state_do(opt)            {options[opt] |= MY_STATE_DO;}
                    135: #define        set_my_state_will(opt)          {options[opt] |= MY_STATE_WILL;}
                    136: #define        set_my_want_state_do(opt)       {options[opt] |= MY_WANT_STATE_DO;}
                    137: #define        set_my_want_state_will(opt)     {options[opt] |= MY_WANT_STATE_WILL;}
                    138:
                    139: #define        set_my_state_dont(opt)          {options[opt] &= ~MY_STATE_DO;}
                    140: #define        set_my_state_wont(opt)          {options[opt] &= ~MY_STATE_WILL;}
                    141: #define        set_my_want_state_dont(opt)     {options[opt] &= ~MY_WANT_STATE_DO;}
                    142: #define        set_my_want_state_wont(opt)     {options[opt] &= ~MY_WANT_STATE_WILL;}
                    143:
                    144: /*
                    145:  * Make everything symetrical
                    146:  */
                    147:
                    148: #define        HIS_STATE_WILL                  MY_STATE_DO
                    149: #define        HIS_WANT_STATE_WILL             MY_WANT_STATE_DO
                    150: #define HIS_STATE_DO                   MY_STATE_WILL
                    151: #define HIS_WANT_STATE_DO              MY_WANT_STATE_WILL
                    152:
                    153: #define        his_state_is_do                 my_state_is_will
                    154: #define        his_state_is_will               my_state_is_do
                    155: #define his_want_state_is_do           my_want_state_is_will
                    156: #define his_want_state_is_will         my_want_state_is_do
                    157:
                    158: #define        his_state_is_dont               my_state_is_wont
                    159: #define        his_state_is_wont               my_state_is_dont
                    160: #define his_want_state_is_dont         my_want_state_is_wont
                    161: #define his_want_state_is_wont         my_want_state_is_dont
                    162:
                    163: #define        set_his_state_do                set_my_state_will
                    164: #define        set_his_state_will              set_my_state_do
                    165: #define        set_his_want_state_do           set_my_want_state_will
                    166: #define        set_his_want_state_will         set_my_want_state_do
                    167:
                    168: #define        set_his_state_dont              set_my_state_wont
                    169: #define        set_his_state_wont              set_my_state_dont
                    170: #define        set_his_want_state_dont         set_my_want_state_wont
                    171: #define        set_his_want_state_wont         set_my_want_state_dont
                    172:
                    173:
                    174: extern FILE
                    175:     *NetTrace;         /* Where debugging output goes */
                    176: extern unsigned char
                    177:     NetTraceFile[];    /* Name of file where debugging output goes */
                    178: extern void
1.3       art       179:     SetNetTrace (char *);      /* Function to change where debugging goes */
1.1       deraadt   180:
                    181: extern jmp_buf
                    182:     peerdied,
                    183:     toplevel;          /* For error conditions. */
                    184:
1.3       art       185: /* authenc.c */
1.1       deraadt   186:
1.3       art       187: #if    defined(AUTHENTICATION) || defined(ENCRYPTION)
                    188: int net_write(unsigned char *str, int len);
                    189: void net_encrypt(void);
                    190: int telnet_spin(void);
                    191: char *telnet_getenv(char *val);
                    192: char *telnet_gets(char *prompt, char *result, int length, int echo);
                    193: #endif
                    194:
                    195: /* commands.c */
                    196:
                    197: struct env_lst *env_define (unsigned char *, unsigned char *);
                    198: struct env_lst *env_find(unsigned char *var);
                    199: void env_init (void);
                    200: void env_undefine (unsigned char *);
                    201: void env_export (unsigned char *);
                    202: void env_unexport (unsigned char *);
                    203: void env_send (unsigned char *);
                    204: void env_list (void);
                    205: unsigned char * env_default(int init, int welldefined);
                    206: unsigned char * env_getvalue(unsigned char *var);
                    207:
                    208: void set_escape_char(char *s);
                    209: unsigned long sourceroute(char *arg, char **cpp, int *lenp);
                    210:
                    211: #if    defined(AUTHENTICATION)
                    212: int auth_enable (char *);
                    213: int auth_disable (char *);
                    214: int auth_status (void);
                    215: #endif
                    216:
                    217: #if defined(ENCRYPTION)
                    218: int    EncryptEnable (char *, char *);
                    219: int    EncryptDisable (char *, char *);
                    220: int    EncryptType (char *, char *);
                    221: int    EncryptStart (char *);
                    222: int    EncryptStartInput (void);
                    223: int    EncryptStartOutput (void);
                    224: int    EncryptStop (char *);
                    225: int    EncryptStopInput (void);
                    226: int    EncryptStopOutput (void);
                    227: int    EncryptStatus (void);
                    228: #endif
                    229:
                    230: #ifdef SIGINFO
                    231: void ayt_status(void);
                    232: #endif
                    233: int tn(int argc, char **argv);
                    234: void command(int top, char *tbuf, int cnt);
                    235:
                    236: /* main.c */
                    237:
                    238: void tninit(void);
                    239: void usage(void);
                    240:
                    241: /* network.c */
                    242:
                    243: void init_network(void);
                    244: int stilloob(void);
                    245: void setneturg(void);
                    246: int netflush(void);
                    247:
                    248: /* sys_bsd.c */
                    249:
                    250: void init_sys(void);
                    251: int TerminalWrite(char *buf, int n);
                    252: int TerminalRead(unsigned char *buf, int n);
                    253: int TerminalAutoFlush(void);
                    254: int TerminalSpecialChars(int c);
                    255: void TerminalFlushOutput(void);
                    256: void TerminalSaveState(void);
                    257: void TerminalDefaultChars(void);
                    258: void TerminalNewMode(int f);
                    259: cc_t *tcval(int func);
                    260: void TerminalSpeeds(long *input_speed, long *output_speed);
                    261: int TerminalWindowSize(long *rows, long *cols);
                    262: int NetClose(int fd);
                    263: void NetNonblockingIO(int fd, int onoff);
                    264: int process_rings(int netin, int netout, int netex, int ttyin, int ttyout,
                    265:                  int poll);
                    266:
                    267: /* telnet.c */
                    268:
                    269: void init_telnet(void);
                    270:
                    271: void tel_leave_binary(int rw);
                    272: void tel_enter_binary(int rw);
                    273: int opt_welldefined(char *ep);
                    274: int telrcv(void);
                    275: int rlogin_susp(void);
                    276: void intp(void);
                    277: void sendbrk(void);
                    278: void sendabort(void);
                    279: void sendsusp(void);
                    280: void sendeof(void);
                    281: void sendayt(void);
                    282:
                    283: void xmitAO(void);
                    284: void xmitEL(void);
                    285: void xmitEC(void);
                    286:
                    287:
                    288: void     Dump (char, unsigned char *, int);
                    289: void     printoption (char *, int, int);
                    290: void     printsub (char, unsigned char *, int);
                    291: void     sendnaws (void);
                    292: void     setconnmode (int);
                    293: void     setcommandmode (void);
                    294: void     setneturg (void);
                    295: void     sys_telnet_init (void);
                    296: void     telnet (char *);
                    297: void     tel_enter_binary (int);
                    298: void     TerminalFlushOutput (void);
                    299: void     TerminalNewMode (int);
                    300: void     TerminalRestoreState (void);
                    301: void     TerminalSaveState (void);
                    302: void     tninit (void);
                    303: void     willoption (int);
                    304: void     wontoption (int);
                    305:
                    306:
                    307: void     send_do (int, int);
                    308: void     send_dont (int, int);
                    309: void     send_will (int, int);
                    310: void     send_wont (int, int);
                    311:
                    312: void     lm_will (unsigned char *, int);
                    313: void     lm_wont (unsigned char *, int);
                    314: void     lm_do (unsigned char *, int);
                    315: void     lm_dont (unsigned char *, int);
                    316: void     lm_mode (unsigned char *, int, int);
                    317:
                    318: void     slc_init (void);
                    319: void     slcstate (void);
                    320: void     slc_mode_export (void);
                    321: void     slc_mode_import (int);
                    322: void     slc_import (int);
                    323: void     slc_export (void);
                    324: void     slc (unsigned char *, int);
                    325: void     slc_check (void);
                    326: void     slc_start_reply (void);
                    327: void     slc_add_reply (unsigned char, unsigned char, cc_t);
                    328: void     slc_end_reply (void);
                    329: int     slc_update (void);
                    330:
                    331: void     env_opt (unsigned char *, int);
                    332: void     env_opt_start (void);
                    333: void     env_opt_start_info (void);
                    334: void     env_opt_add (unsigned char *);
                    335: void     env_opt_end (int);
                    336:
                    337: unsigned char     *env_default (int, int);
                    338: unsigned char     *env_getvalue (unsigned char *);
                    339:
                    340: int get_status (void);
                    341: int dosynch (void);
                    342:
                    343: cc_t *tcval (int);
                    344:
                    345: int quit (void);
                    346:
                    347: /* terminal.c */
                    348:
                    349: void init_terminal(void);
                    350: int ttyflush(int drop);
                    351: int getconnmode(void);
                    352:
                    353: /* utilities.c */
                    354:
                    355: int SetSockOpt(int fd, int level, int option, int yesno);
                    356: void SetNetTrace(char *file);
                    357: void Dump(char direction, unsigned char *buffer, int length);
                    358: void printoption(char *direction, int cmd, int option);
                    359: void optionstatus(void);
                    360: void printsub(char direction, unsigned char *pointer, int length);
                    361: void EmptyTerminal(void);
                    362: void SetForExit(void);
                    363: void Exit(int returnCode);
                    364: void ExitString(char *string, int returnCode);
1.1       deraadt   365:
1.3       art       366: extern struct  termios new_tc;
1.1       deraadt   367:
                    368: # define termEofChar           new_tc.c_cc[VEOF]
                    369: # define termEraseChar         new_tc.c_cc[VERASE]
                    370: # define termIntChar           new_tc.c_cc[VINTR]
                    371: # define termKillChar          new_tc.c_cc[VKILL]
                    372: # define termQuitChar          new_tc.c_cc[VQUIT]
                    373:
                    374: # ifndef       VSUSP
                    375: extern cc_t termSuspChar;
                    376: # else
                    377: #  define termSuspChar         new_tc.c_cc[VSUSP]
                    378: # endif
                    379: # if   defined(VFLUSHO) && !defined(VDISCARD)
                    380: #  define VDISCARD VFLUSHO
                    381: # endif
                    382: # ifndef       VDISCARD
                    383: extern cc_t termFlushChar;
                    384: # else
                    385: #  define termFlushChar                new_tc.c_cc[VDISCARD]
                    386: # endif
                    387: # ifndef VWERASE
                    388: extern cc_t termWerasChar;
                    389: # else
                    390: #  define termWerasChar                new_tc.c_cc[VWERASE]
                    391: # endif
                    392: # ifndef       VREPRINT
                    393: extern cc_t termRprntChar;
                    394: # else
                    395: #  define termRprntChar                new_tc.c_cc[VREPRINT]
                    396: # endif
                    397: # ifndef       VLNEXT
                    398: extern cc_t termLiteralNextChar;
                    399: # else
                    400: #  define termLiteralNextChar  new_tc.c_cc[VLNEXT]
                    401: # endif
                    402: # ifndef       VSTART
                    403: extern cc_t termStartChar;
                    404: # else
                    405: #  define termStartChar                new_tc.c_cc[VSTART]
                    406: # endif
                    407: # ifndef       VSTOP
                    408: extern cc_t termStopChar;
                    409: # else
                    410: #  define termStopChar         new_tc.c_cc[VSTOP]
                    411: # endif
                    412: # ifndef       VEOL
                    413: extern cc_t termForw1Char;
                    414: # else
                    415: #  define termForw1Char                new_tc.c_cc[VEOL]
                    416: # endif
                    417: # ifndef       VEOL2
                    418: extern cc_t termForw2Char;
                    419: # else
                    420: #  define termForw2Char                new_tc.c_cc[VEOL]
                    421: # endif
                    422: # ifndef       VSTATUS
                    423: extern cc_t termAytChar;
                    424: #else
                    425: #  define termAytChar          new_tc.c_cc[VSTATUS]
                    426: #endif
                    427:
                    428: /* Ring buffer structures which are shared */
                    429:
                    430: extern Ring
                    431:     netoring,
                    432:     netiring,
                    433:     ttyoring,
                    434:     ttyiring;
                    435:
1.4       deraadt   436: /* Tn3270 section */
                    437: #if    defined(TN3270)
                    438:
                    439: extern int
                    440:     HaveInput,         /* Whether an asynchronous I/O indication came in */
                    441:     noasynchtty,       /* Don't do signals on I/O (SIGURG, SIGIO) */
                    442:     noasynchnet,       /* Don't do signals on I/O (SIGURG, SIGIO) */
                    443:     sigiocount,                /* Count of SIGIO receptions */
                    444:     shell_active;      /* Subshell is active */
                    445:
                    446: extern char
                    447:     *Ibackp,           /* Oldest byte of 3270 data */
                    448:     Ibuf[],            /* 3270 buffer */
                    449:     *Ifrontp,          /* Where next 3270 byte goes */
1.5     ! fgsch     450:     tline[200],
1.4       deraadt   451:     *transcom;         /* Transparent command */
                    452:
                    453: extern int
                    454:     settranscom P((int, char**));
                    455:
                    456: extern void
                    457:     inputAvailable P((int));
                    458: #endif /* defined(TN3270) */