home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / gnunet10.zip / source / telnet / externs.h < prev    next >
C/C++ Source or Header  |  1996-02-12  |  14KB  |  492 lines

  1. /*
  2.  * Copyright (c) 1988, 1990, 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.  *    @(#)externs.h    8.3 (Berkeley) 5/30/95
  34.  */
  35.  
  36. #ifndef    BSD
  37. # define BSD 43
  38. #endif
  39.  
  40. #ifdef HAVE_TERMIOS_H
  41. #define USE_TERMIO
  42. #endif
  43.  
  44. #ifdef HAVE_TERMIO_H
  45. #define USE_TERMIO
  46. #define SYSV_TERMIO
  47. #endif
  48.  
  49. /*
  50.  * ucb stdio.h defines BSD as something wierd
  51.  */
  52. #if defined(sun) && defined(__svr4__)
  53. #define BSD 43
  54. #endif
  55.  
  56. #ifndef    USE_TERMIO
  57. # if BSD > 43 || defined(SYSV_TERMIO)
  58. #  define USE_TERMIO
  59. # endif
  60. #endif
  61.  
  62. #include <stdio.h>
  63. #include <setjmp.h>
  64. #if defined(CRAY) && !defined(NO_BSD_SETJMP)
  65. #include <bsdsetjmp.h>
  66. #endif
  67. #ifndef    FILIO_H
  68. #include <sys/ioctl.h>
  69. #else
  70. #include <sys/filio.h>
  71. #endif
  72. #ifdef CRAY
  73. # include <errno.h>
  74. #endif /* CRAY */
  75. #ifdef    USE_TERMIO
  76. # ifndef    VINTR
  77. #  ifdef SYSV_TERMIO
  78. #   include <sys/termio.h>
  79. #  else
  80. #   include <sys/termios.h>
  81. #   define termio termios
  82. #  endif
  83. # endif
  84. #endif
  85. #if defined(NO_CC_T) || !defined(USE_TERMIO)
  86. # if !defined(USE_TERMIO)
  87. typedef char cc_t;
  88. # else
  89. typedef unsigned char cc_t;
  90. # endif
  91. #endif
  92.  
  93. #ifndef    NO_STRING_H
  94. #include <string.h>
  95. #else
  96. #include <strings.h>
  97. #endif
  98.  
  99. #ifndef    _POSIX_VDISABLE
  100. # ifdef sun
  101. #  include <sys/param.h>    /* pick up VDISABLE definition, mayby */
  102. # endif
  103. # ifdef VDISABLE
  104. #  define _POSIX_VDISABLE VDISABLE
  105. # else
  106. #  define _POSIX_VDISABLE ((cc_t)'\377')
  107. # endif
  108. #endif
  109.  
  110. #define    SUBBUFSIZE    256
  111.  
  112. #ifndef CRAY
  113. extern int errno;        /* outside this world */
  114. #endif /* !CRAY */
  115.  
  116. #if    !defined(P)
  117. # ifdef    __STDC__
  118. #  define    P(x)    x
  119. # else
  120. #  define    P(x)    ()
  121. # endif
  122. #endif
  123.  
  124. extern int
  125.     autologin,        /* Autologin enabled */
  126.     skiprc,        /* Don't process the ~/.telnetrc file */
  127.     eight,        /* use eight bit mode (binary in and/or out */
  128.     flushout,        /* flush output */
  129.     connected,        /* Are we connected to the other side? */
  130.     globalmode,        /* Mode tty should be in */
  131.     In3270,            /* Are we in 3270 mode? */
  132.     telnetport,        /* Are we connected to the telnet port? */
  133.     localflow,        /* Flow control handled locally */
  134.     restartany,        /* If flow control, restart output on any character */
  135.     localchars,        /* we recognize interrupt/quit */
  136.     donelclchars,        /* the user has set "localchars" */
  137.     showoptions,
  138.     net,        /* Network file descriptor */
  139.     tin,        /* Terminal input file descriptor */
  140.     tout,        /* Terminal output file descriptor */
  141.     crlf,        /* Should '\r' be mapped to <CR><LF> (or <CR><NUL>)? */
  142.     autoflush,        /* flush output when interrupting? */
  143.     autosynch,        /* send interrupt characters with SYNCH? */
  144.     SYNCHing,        /* Is the stream in telnet SYNCH mode? */
  145.     donebinarytoggle,    /* the user has put us in binary */
  146.     dontlecho,        /* do we suppress local echoing right now? */
  147.     crmod,
  148.     netdata,        /* Print out network data flow */
  149.     prettydump,        /* Print "netdata" output in user readable format */
  150. #if    defined(unix)
  151. #if    defined(TN3270)
  152.     cursesdata,        /* Print out curses data flow */
  153.     apitrace,        /* Trace API transactions */
  154. #endif    /* defined(TN3270) */
  155.     termdata,        /* Print out terminal data flow */
  156. #endif    /* defined(unix) */
  157.     debug;            /* Debug level */
  158.  
  159. extern cc_t escape;    /* Escape to command mode */
  160. extern cc_t rlogin;    /* Rlogin mode escape character */
  161. #ifdef    KLUDGELINEMODE
  162. extern cc_t echoc;    /* Toggle local echoing */
  163. #endif
  164.  
  165. extern char
  166.     *prompt;        /* Prompt for command. */
  167.  
  168. extern char
  169.     doopt[],
  170.     dont[],
  171.     will[],
  172.     wont[],
  173.     options[],        /* All the little options */
  174.     *hostname;        /* Who are we connected to? */
  175. #ifdef    ENCRYPTION
  176. extern void (*encrypt_output) P((unsigned char *, int));
  177. extern int (*decrypt_input) P((int));
  178. #endif    /* ENCRYPTION */
  179.  
  180. /*
  181.  * We keep track of each side of the option negotiation.
  182.  */
  183.  
  184. #define    MY_STATE_WILL        0x01
  185. #define    MY_WANT_STATE_WILL    0x02
  186. #define    MY_STATE_DO        0x04
  187. #define    MY_WANT_STATE_DO    0x08
  188.  
  189. /*
  190.  * Macros to check the current state of things
  191.  */
  192.  
  193. #define    my_state_is_do(opt)        (options[opt]&MY_STATE_DO)
  194. #define    my_state_is_will(opt)        (options[opt]&MY_STATE_WILL)
  195. #define my_want_state_is_do(opt)    (options[opt]&MY_WANT_STATE_DO)
  196. #define my_want_state_is_will(opt)    (options[opt]&MY_WANT_STATE_WILL)
  197.  
  198. #define    my_state_is_dont(opt)        (!my_state_is_do(opt))
  199. #define    my_state_is_wont(opt)        (!my_state_is_will(opt))
  200. #define my_want_state_is_dont(opt)    (!my_want_state_is_do(opt))
  201. #define my_want_state_is_wont(opt)    (!my_want_state_is_will(opt))
  202.  
  203. #define    set_my_state_do(opt)        {options[opt] |= MY_STATE_DO;}
  204. #define    set_my_state_will(opt)        {options[opt] |= MY_STATE_WILL;}
  205. #define    set_my_want_state_do(opt)    {options[opt] |= MY_WANT_STATE_DO;}
  206. #define    set_my_want_state_will(opt)    {options[opt] |= MY_WANT_STATE_WILL;}
  207.  
  208. #define    set_my_state_dont(opt)        {options[opt] &= ~MY_STATE_DO;}
  209. #define    set_my_state_wont(opt)        {options[opt] &= ~MY_STATE_WILL;}
  210. #define    set_my_want_state_dont(opt)    {options[opt] &= ~MY_WANT_STATE_DO;}
  211. #define    set_my_want_state_wont(opt)    {options[opt] &= ~MY_WANT_STATE_WILL;}
  212.  
  213. /*
  214.  * Make everything symetrical
  215.  */
  216.  
  217. #define    HIS_STATE_WILL            MY_STATE_DO
  218. #define    HIS_WANT_STATE_WILL        MY_WANT_STATE_DO
  219. #define HIS_STATE_DO            MY_STATE_WILL
  220. #define HIS_WANT_STATE_DO        MY_WANT_STATE_WILL
  221.  
  222. #define    his_state_is_do            my_state_is_will
  223. #define    his_state_is_will        my_state_is_do
  224. #define his_want_state_is_do        my_want_state_is_will
  225. #define his_want_state_is_will        my_want_state_is_do
  226.  
  227. #define    his_state_is_dont        my_state_is_wont
  228. #define    his_state_is_wont        my_state_is_dont
  229. #define his_want_state_is_dont        my_want_state_is_wont
  230. #define his_want_state_is_wont        my_want_state_is_dont
  231.  
  232. #define    set_his_state_do        set_my_state_will
  233. #define    set_his_state_will        set_my_state_do
  234. #define    set_his_want_state_do        set_my_want_state_will
  235. #define    set_his_want_state_will        set_my_want_state_do
  236.  
  237. #define    set_his_state_dont        set_my_state_wont
  238. #define    set_his_state_wont        set_my_state_dont
  239. #define    set_his_want_state_dont        set_my_want_state_wont
  240. #define    set_his_want_state_wont        set_my_want_state_dont
  241.  
  242.  
  243. extern FILE
  244.     *NetTrace;        /* Where debugging output goes */
  245. extern unsigned char
  246.     NetTraceFile[];    /* Name of file where debugging output goes */
  247. extern void
  248.     SetNetTrace P((char *));    /* Function to change where debugging goes */
  249.  
  250. extern jmp_buf
  251.     peerdied,
  252.     toplevel;        /* For error conditions. */
  253.  
  254. extern void
  255.     command P((int, char *, int)),
  256.     Dump P((int, unsigned char *, int)),
  257.     init_3270 P((void)),
  258.     printoption P((char *, int, int)),
  259.     printsub P((int, unsigned char *, int)),
  260.     sendnaws P((void)),
  261.     setconnmode P((int)),
  262.     setcommandmode P((void)),
  263.     setneturg P((void)),
  264.     sys_telnet_init P((void)),
  265.     telnet P((char *)),
  266.     tel_enter_binary P((int)),
  267.     TerminalFlushOutput P((void)),
  268.     TerminalNewMode P((int)),
  269.     TerminalRestoreState P((void)),
  270.     TerminalSaveState P((void)),
  271.     tninit P((void)),
  272.     upcase P((char *)),
  273.     willoption P((int)),
  274.     wontoption P((int));
  275.  
  276. extern void
  277.     send_do P((int, int)),
  278.     send_dont P((int, int)),
  279.     send_will P((int, int)),
  280.     send_wont P((int, int));
  281.  
  282. extern void
  283.     lm_will P((unsigned char *, int)),
  284.     lm_wont P((unsigned char *, int)),
  285.     lm_do P((unsigned char *, int)),
  286.     lm_dont P((unsigned char *, int)),
  287.     lm_mode P((unsigned char *, int, int));
  288.  
  289. extern void
  290.     slc_init P((void)),
  291.     slcstate P((void)),
  292.     slc_mode_export P((void)),
  293.     slc_mode_import P((int)),
  294.     slc_import P((int)),
  295.     slc_export P((void)),
  296.     slc P((unsigned char *, int)),
  297.     slc_check P((void)),
  298.     slc_start_reply P((void)),
  299.     slc_add_reply P((int, int, int)),
  300.     slc_end_reply P((void));
  301. extern int
  302.     slc_update P((void));
  303.  
  304. extern void
  305.     env_opt P((unsigned char *, int)),
  306.     env_opt_start P((void)),
  307.     env_opt_start_info P((void)),
  308.     env_opt_add P((unsigned char *)),
  309.     env_opt_end P((int));
  310.  
  311. extern unsigned char
  312.     *env_default P((int, int)),
  313.     *env_getvalue P((unsigned char *));
  314.  
  315. extern int
  316.     get_status P((void)),
  317.     dosynch P((void));
  318.  
  319. extern cc_t
  320.     *tcval P((int));
  321.  
  322. #ifndef    USE_TERMIO
  323.  
  324. extern struct    tchars ntc;
  325. extern struct    ltchars nltc;
  326. extern struct    sgttyb nttyb;
  327.  
  328. # define termEofChar        ntc.t_eofc
  329. # define termEraseChar        nttyb.sg_erase
  330. # define termFlushChar        nltc.t_flushc
  331. # define termIntChar        ntc.t_intrc
  332. # define termKillChar        nttyb.sg_kill
  333. # define termLiteralNextChar    nltc.t_lnextc
  334. # define termQuitChar        ntc.t_quitc
  335. # define termSuspChar        nltc.t_suspc
  336. # define termRprntChar        nltc.t_rprntc
  337. # define termWerasChar        nltc.t_werasc
  338. # define termStartChar        ntc.t_startc
  339. # define termStopChar        ntc.t_stopc
  340. # define termForw1Char        ntc.t_brkc
  341. extern cc_t termForw2Char;
  342. extern cc_t termAytChar;
  343.  
  344. # define termEofCharp        (cc_t *)&ntc.t_eofc
  345. # define termEraseCharp        (cc_t *)&nttyb.sg_erase
  346. # define termFlushCharp        (cc_t *)&nltc.t_flushc
  347. # define termIntCharp        (cc_t *)&ntc.t_intrc
  348. # define termKillCharp        (cc_t *)&nttyb.sg_kill
  349. # define termLiteralNextCharp    (cc_t *)&nltc.t_lnextc
  350. # define termQuitCharp        (cc_t *)&ntc.t_quitc
  351. # define termSuspCharp        (cc_t *)&nltc.t_suspc
  352. # define termRprntCharp        (cc_t *)&nltc.t_rprntc
  353. # define termWerasCharp        (cc_t *)&nltc.t_werasc
  354. # define termStartCharp        (cc_t *)&ntc.t_startc
  355. # define termStopCharp        (cc_t *)&ntc.t_stopc
  356. # define termForw1Charp        (cc_t *)&ntc.t_brkc
  357. # define termForw2Charp        (cc_t *)&termForw2Char
  358. # define termAytCharp        (cc_t *)&termAytChar
  359.  
  360. # else
  361.  
  362. extern struct    termio new_tc;
  363.  
  364. # define termEofChar        new_tc.c_cc[VEOF]
  365. # define termEraseChar        new_tc.c_cc[VERASE]
  366. # define termIntChar        new_tc.c_cc[VINTR]
  367. # define termKillChar        new_tc.c_cc[VKILL]
  368. # define termQuitChar        new_tc.c_cc[VQUIT]
  369.  
  370. # ifndef    VSUSP
  371. extern cc_t termSuspChar;
  372. # else
  373. #  define termSuspChar        new_tc.c_cc[VSUSP]
  374. # endif
  375. # if    defined(VFLUSHO) && !defined(VDISCARD)
  376. #  define VDISCARD VFLUSHO
  377. # endif
  378. # ifndef    VDISCARD
  379. extern cc_t termFlushChar;
  380. # else
  381. #  define termFlushChar        new_tc.c_cc[VDISCARD]
  382. # endif
  383. # ifndef VWERASE
  384. extern cc_t termWerasChar;
  385. # else
  386. #  define termWerasChar        new_tc.c_cc[VWERASE]
  387. # endif
  388. # ifndef    VREPRINT
  389. extern cc_t termRprntChar;
  390. # else
  391. #  define termRprntChar        new_tc.c_cc[VREPRINT]
  392. # endif
  393. # ifndef    VLNEXT
  394. extern cc_t termLiteralNextChar;
  395. # else
  396. #  define termLiteralNextChar    new_tc.c_cc[VLNEXT]
  397. # endif
  398. # ifndef    VSTART
  399. extern cc_t termStartChar;
  400. # else
  401. #  define termStartChar        new_tc.c_cc[VSTART]
  402. # endif
  403. # ifndef    VSTOP
  404. extern cc_t termStopChar;
  405. # else
  406. #  define termStopChar        new_tc.c_cc[VSTOP]
  407. # endif
  408. # ifndef    VEOL
  409. extern cc_t termForw1Char;
  410. # else
  411. #  define termForw1Char        new_tc.c_cc[VEOL]
  412. # endif
  413. # ifndef    VEOL2
  414. extern cc_t termForw2Char;
  415. # else
  416. #  define termForw2Char        new_tc.c_cc[VEOL]
  417. # endif
  418. # ifndef    VSTATUS
  419. extern cc_t termAytChar;
  420. #else
  421. #  define termAytChar        new_tc.c_cc[VSTATUS]
  422. #endif
  423.  
  424. # if !defined(CRAY) || defined(__STDC__)
  425. #  define termEofCharp        &termEofChar
  426. #  define termEraseCharp    &termEraseChar
  427. #  define termIntCharp        &termIntChar
  428. #  define termKillCharp        &termKillChar
  429. #  define termQuitCharp        &termQuitChar
  430. #  define termSuspCharp        &termSuspChar
  431. #  define termFlushCharp    &termFlushChar
  432. #  define termWerasCharp    &termWerasChar
  433. #  define termRprntCharp    &termRprntChar
  434. #  define termLiteralNextCharp    &termLiteralNextChar
  435. #  define termStartCharp    &termStartChar
  436. #  define termStopCharp        &termStopChar
  437. #  define termForw1Charp    &termForw1Char
  438. #  define termForw2Charp    &termForw2Char
  439. #  define termAytCharp        &termAytChar
  440. # else
  441.     /* Work around a compiler bug */
  442. #  define termEofCharp        0
  443. #  define termEraseCharp    0
  444. #  define termIntCharp        0
  445. #  define termKillCharp        0
  446. #  define termQuitCharp        0
  447. #  define termSuspCharp        0
  448. #  define termFlushCharp    0
  449. #  define termWerasCharp    0
  450. #  define termRprntCharp    0
  451. #  define termLiteralNextCharp    0
  452. #  define termStartCharp    0
  453. #  define termStopCharp        0
  454. #  define termForw1Charp    0
  455. #  define termForw2Charp    0
  456. #  define termAytCharp        0
  457. # endif
  458. #endif
  459.  
  460.  
  461. /* Ring buffer structures which are shared */
  462.  
  463. extern Ring
  464.     netoring,
  465.     netiring,
  466.     ttyoring,
  467.     ttyiring;
  468.  
  469. /* Tn3270 section */
  470. #if    defined(TN3270)
  471.  
  472. extern int
  473.     HaveInput,        /* Whether an asynchronous I/O indication came in */
  474.     noasynchtty,    /* Don't do signals on I/O (SIGURG, SIGIO) */
  475.     noasynchnet,    /* Don't do signals on I/O (SIGURG, SIGIO) */
  476.     sigiocount,        /* Count of SIGIO receptions */
  477.     shell_active;    /* Subshell is active */
  478.  
  479. extern char
  480.     *Ibackp,        /* Oldest byte of 3270 data */
  481.     Ibuf[],        /* 3270 buffer */
  482.     *Ifrontp,        /* Where next 3270 byte goes */
  483.     tline[],
  484.     *transcom;        /* Transparent command */
  485.  
  486. extern int
  487.     settranscom P((int, char**));
  488.  
  489. extern void
  490.     inputAvailable P((int));
  491. #endif    /* defined(TN3270) */
  492.