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