home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / bsd_srcs / usr.bin / telnet / externs.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-04-18  |  13.2 KB  |  458 lines

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