home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / archives / ckc190.zip / ckcnet.h < prev    next >
C/C++ Source or Header  |  1994-12-09  |  21KB  |  701 lines

  1. /* ckcnet.h -- Symbol and macro definitions for C-Kermit network support */
  2.  
  3. /*
  4.   Author: Frank da Cruz (fdc@columbia.edu, FDCCU@CUVMA.BITNET),
  5.   Columbia University Academic Information Systems, New York City.
  6.  
  7.   Copyright (C) 1985, 1994, Trustees of Columbia University in the City of New
  8.   York.  The C-Kermit software may not be, in whole or in part, licensed or
  9.   sold for profit as a software product itself, nor may it be included in or
  10.   distributed with commercial products or otherwise distributed by commercial
  11.   concerns to their clients or customers without written permission of the
  12.   Office of Kermit Development and Distribution, Columbia University.  This
  13.   copyright notice must not be removed, altered, or obscured.
  14. */
  15. #ifndef CKCNET_H
  16. #define CKCNET_H
  17.  
  18. /* Network types */
  19.  
  20. #define NET_NONE 0            /* None */
  21. #define NET_TCPB 1            /* TCP/IP Berkeley (socket) */
  22. #define NET_TCPA 2            /* TCP/IP AT&T (streams) */
  23. #define NET_SX25 3            /* SUNOS SunLink X.25 */
  24. #define NET_DEC  4            /* DECnet */
  25. #define NET_VPSI 5            /* VAX PSI */
  26. #define NET_PIPE 6            /* LAN Manager Named Pipe */
  27. #define NET_VX25 7            /* Stratus VOS X.25 */
  28. #define NET_BIOS 8            /* IBM NetBios */
  29.  
  30. #ifdef OS2                /* In OS/2, only the 32-bit */
  31. #ifndef __32BIT__            /* version gets NETBIOS */
  32. #ifdef CK_NETBIOS
  33. #undef CK_NETBIOS
  34. #endif /* CK_NETBIOS */
  35. #endif /* __32BIT__ */
  36. #endif /* OS2 */
  37.  
  38. #ifdef NPIPE                /* For items in common to */
  39. #define NPIPEORBIOS            /* Named Pipes and NETBIOS */
  40. #endif /* NPIPE */
  41. #ifdef CK_NETBIOS
  42. #ifndef NPIPEORBIOS
  43. #define NPIPEORBIOS
  44. #endif /* NPIPEORBIOS */
  45. #endif /* CK_NETBIOS */
  46.  
  47. /* Network virtual terminal protocols */
  48.  
  49. #define NP_NONE 0            /* None (async) */
  50. #define NP_TELNET 1            /* TCP/IP telnet */
  51. #define NP_VTP 2            /* ISO Virtual Terminal Protocol */
  52. #define NP_X3 3                /* CCITT X.3 */
  53. #define NP_X28 4            /* CCITT X.28 */
  54. #define NP_X29 5            /* CCITT X.29 */
  55. #define NP_CTERM 20            /* DEC CTERM */
  56. #define NP_LAT 21            /* DEC LAT */
  57. /* others here... */
  58.  
  59. /* TELNET Newline Mode */
  60.        
  61. #define TNL_CR     0            /* CR sends bare carriage return */
  62. #define TNL_CRNUL  1            /* CR and NUL */
  63. #define TNL_CRLF   2            /* CR and LF */
  64.  
  65. #ifdef COMMENT /* no longer used but might come in handy again later... */
  66. /*
  67.   CK_READ0 can (and should) be defined if and only if:
  68.   (a) read(fd,&x,0) can be used harmlessly on a TCP/IP socket connection.
  69.   (b) read(fd,&x,0) returns 0 if the connection is up, -1 if it is down.
  70. */
  71. #ifndef CK_READ0
  72. #ifdef TCPSOCKET
  73. #ifdef SUNOS41                /* It works in SunOS 4.1 */
  74. #define CK_READ0
  75. #else
  76. #ifdef NEXT                /* and NeXTSTEP */
  77. #define CK_READ0
  78. #endif /* NEXT */
  79. #endif /* SUNOS41 */
  80. #endif /* TCPSOCKET */
  81. #endif /* CK_READ0 */
  82. #endif /* COMMENT */
  83.  
  84. /* Basic network function prototypes, common to all. */
  85.  
  86. _PROTOTYP( int netopen, (char *, int *, int) );
  87. _PROTOTYP( int netclos, (void) );
  88. _PROTOTYP( int netflui, (void) );
  89. _PROTOTYP( int nettchk, (void) );
  90. _PROTOTYP( int netbreak, (void) );
  91. _PROTOTYP( int netinc, (int) );
  92. _PROTOTYP( int nettol, (char *, int) );
  93. _PROTOTYP( int nettoc, (char) );
  94.  
  95. /*
  96.   SunLink X.25 support by Marcello Frutig, Catholic University,
  97.   Rio de Janeiro, Brazil, 1990.
  98.  
  99.   Maybe this can be adapted to VAX PSI and other X.25 products too.
  100. */
  101. #ifndef SUNOS4                /* Only valid for SUNOS4 */
  102. #ifndef SOLARIS
  103. #ifdef SUNX25
  104. #undef SUNX25
  105. #endif /* SUNX25 */
  106. #endif /* SOLARIS */
  107. #endif /* SUNOS4 */
  108.  
  109. #ifdef STRATUSX25
  110. #define ANYX25
  111. #define MAX_USER_DATA 128 /* SUN defines this in a header file, I believe. */
  112. #endif /* STRATUSX25 */
  113.  
  114. #ifdef SUNX25
  115. #define ANYX25
  116. #endif /* SUNX25 */
  117.  
  118. #ifdef ANYX25
  119. #ifndef NETCONN                /* ANYX25 implies NETCONN */
  120. #define NETCONN
  121. #endif /* NETCONN */
  122.  
  123. #define MAXPADPARMS                18    /* Number of PAD parameters */
  124. #define MAXCUDATA           12    /* Max length of X.25 call user data */
  125. #define X29PID                1   /* X.29 protocol ID */
  126. #define X29PIDLEN            4   /* X.29 protocol ID length */
  127.  
  128. #define X29_SET_PARMS               2
  129. #define X29_READ_PARMS              4
  130. #define X29_SET_AND_READ_PARMS      6
  131. #define X29_INVITATION_TO_CLEAR     1
  132. #define X29_PARAMETER_INDICATION    0
  133. #define X29_INDICATION_OF_BREAK     3
  134. #define X29_ERROR                   5
  135.  
  136. #define INVALID_PAD_PARM            1
  137.  
  138. #define PAD_BREAK_CHARACTER         0
  139.  
  140. #define PAD_ESCAPE                  1
  141. #define PAD_ECHO                    2
  142. #define PAD_DATA_FORWARD_CHAR       3
  143. #define PAD_DATA_FORWARD_TIMEOUT    4
  144. #define PAD_FLOW_CONTROL_BY_PAD     5
  145. #define PAD_SUPPRESSION_OF_SIGNALS  6
  146. #define PAD_BREAK_ACTION            7
  147. #define PAD_SUPPRESSION_OF_DATA     8
  148. #define PAD_PADDING_AFTER_CR        9
  149. #define PAD_LINE_FOLDING           10
  150. #define PAD_LINE_SPEED             11
  151. #define PAD_FLOW_CONTROL_BY_USER   12
  152. #define PAD_LF_AFTER_CR            13
  153. #define PAD_PADDING_AFTER_LF       14
  154. #define PAD_EDITING                15
  155. #define PAD_CHAR_DELETE_CHAR       16
  156. #define PAD_BUFFER_DELETE_CHAR     17
  157. #define PAD_BUFFER_DISPLAY_CHAR    18
  158.  
  159. #define MAXIX25 MAX_USER_DATA*7
  160. #define MAXOX25 MAX_USER_DATA
  161. #endif /* ANYX25 */
  162.  
  163. #ifdef SUNX25
  164. #include <sys/ioctl.h>            /* X.25 includes, Sun only */
  165. #include <sys/param.h>
  166. #include <sys/systm.h>
  167. #ifndef SOLARIS
  168. #include <sys/mbuf.h>
  169. #endif /* SOLARIS */
  170. #include <sys/socket.h>
  171. #include <sys/protosw.h>
  172. #ifdef SOLARIS
  173. #include <sys/sockio.h>
  174. #else
  175. #include <sys/domain.h>
  176. #endif /* SOLARIS */
  177. #include <sys/socketvar.h>
  178. #include <net/if.h>
  179. #include <sundev/syncstat.h>
  180. #include <netx25/x25_pk.h>
  181. #include <netx25/x25_ctl.h>
  182. #include <netx25/x25_ioctl.h>
  183. #endif /* SUNX25 */
  184.  
  185. #ifdef ANYX25
  186.  
  187. /* C-Kermit X.3 / X.25 / X.29 / X.121 support functions */
  188.  
  189. _PROTOTYP( VOID shopad, (void) );
  190. _PROTOTYP( VOID shox25, (void) );
  191. _PROTOTYP( VOID initpad, (void) );
  192. _PROTOTYP( VOID setpad, (CHAR *, int) );
  193. _PROTOTYP( VOID readpad, (CHAR *, int, CHAR *) );
  194. _PROTOTYP( int qbitpkt, (CHAR *, int) );
  195. _PROTOTYP( VOID setqbit, (void) );
  196. _PROTOTYP( VOID resetqbit, (void) );
  197. _PROTOTYP( VOID breakact, (void) );
  198. _PROTOTYP( int pkx121, (char *, CHAR *) );
  199. _PROTOTYP( SIGTYP x25oobh, (int) );
  200. _PROTOTYP( int x25diag, (void) );
  201. _PROTOTYP( int x25intr, (char) );
  202. _PROTOTYP( int x25reset, (char, char) );
  203. _PROTOTYP( int x25clear, (void) );
  204. _PROTOTYP( int x25stat, (void) );
  205. _PROTOTYP( int x25in, (int, CHAR *) );
  206. _PROTOTYP( int setpadp, (void) );
  207. _PROTOTYP( int setx25, (void) );
  208. _PROTOTYP( int x25xin, (int, CHAR *) );
  209. _PROTOTYP( int x25inl, (CHAR *, int, int, CHAR) );
  210.  
  211. #endif /* ANYX25 */
  212.  
  213. /* CMU-OpenVMS/IP */
  214.  
  215. #ifdef CMU_TCPIP            /* CMU_TCPIP implies TCPSOCKET */
  216. #ifndef TCPSOCKET
  217. #define TCPSOCKET
  218. #endif /* TCPSOCKET */
  219. #ifndef TCPIPLIB
  220. #define TCPIPLIB
  221. #endif /* TCPIPLIB */
  222. #endif /* CMU_TCPIP */
  223.  
  224. /* DEC TCP/IP for (Open)VMS, previously known as UCX */
  225.  
  226. #ifdef DEC_TCPIP            /* DEC_TCPIP implies TCPSOCKET */
  227. #ifndef TCPSOCKET
  228. #define TCPSOCKET
  229. #endif /* TCPSOCKET */
  230. #ifndef TCPIPLIB
  231. #define TCPIPLIB
  232. #endif /* TCPIPLIB */
  233. #endif /* DEC_TCPIP */
  234.  
  235. /* TGV/SRI MultiNet, TCP/IP for VAX/VMS */
  236.  
  237. #ifdef MULTINET                /* MULTINET implies TCPSOCKET */
  238. #ifndef TCPSOCKET
  239. #define TCPSOCKET
  240. #endif /* TCPSOCKET */
  241. #ifndef TCPIPLIB
  242. #define TCPIPLIB
  243. #endif /* TCPIPLIB */
  244. #ifndef TGVORWIN            /* MULTINET and WINTCP */
  245. #define TGVORWIN            /* share a lot of code... */
  246. #endif /* TGVORWIN */
  247. #endif /* MULTINET */
  248.  
  249. /* Wollongong TCP/IP for VAX/VMS */
  250.  
  251. #ifdef WINTCP                /* WINTCP implies TCPSOCKET */
  252. #ifndef TCPSOCKET
  253. #define TCPSOCKET
  254. #endif /* TCPSOCKET */
  255. #ifndef TCPIPLIB
  256. #define TCPIPLIB
  257. #endif /* TCPIPLIB */
  258. #ifndef TGVORWIN            /* WINTCP and MULTINET */
  259. #define TGVORWIN            /* share a lot of code... */
  260. #endif /* TGVORWIN */
  261. #endif /* WINTCP */
  262.  
  263. /* Wollongong TCP/IP for AT&T Sys V */
  264.  
  265. #ifdef WOLLONGONG            /* WOLLONGONG implies TCPSOCKET */
  266. #ifndef TCPSOCKET            /* Don't confuse WOLLONGONG */
  267. #define TCPSOCKET            /* (which is for UNIX) with */
  268. #endif /* TCPSOCKET */            /* WINTCP, which is for VMS! */
  269. #endif /* WOLLONGONG */
  270.  
  271. #ifdef EXCELAN                /* EXCELAN implies TCPSOCKET */
  272. #ifndef TCPSOCKET
  273. #define TCPSOCKET
  274. #endif /* TCPSOCKET */
  275. #endif /* EXCELAN */
  276.  
  277. #ifdef INTERLAN                /* INTERLAN implies TCPSOCKET */
  278. #ifndef TCPSOCKET
  279. #define TCPSOCKET
  280. #endif /* TCPSOCKET */
  281. #endif /* INTERLAN */
  282.  
  283. /* Telnet protocol */
  284.  
  285. #ifdef TCPSOCKET            /* TCPSOCKET implies TNCODE */
  286. #ifndef TNCODE                /* Which means... */
  287. #define TNCODE                /* Compile in telnet code */
  288. #endif /* TNCODE */
  289. #endif /* TCPSOCKET */
  290.  
  291. #ifdef SUNX25                /* SUNX25 implies TCPSOCKET */
  292. #ifndef TCPSOCKET            /* But doesn't imply TNCODE */
  293. #define TCPSOCKET
  294. #endif /* TCPSOCKET */
  295. #endif /* SUNX25 */
  296.  
  297. /* This is the TCPSOCKET section... */
  298.  
  299. #ifdef TCPSOCKET
  300.  
  301. #ifndef NETCONN                /* TCPSOCKET implies NETCONN */
  302. #define NETCONN
  303. #endif /* NETCONN */
  304.  
  305. /* BSD sockets library header files */
  306.  
  307. #ifdef UNIX                /* UNIX section */
  308.  
  309. #ifdef SVR4
  310. /*
  311.   These suggested by Rob Healey, rhealey@kas.helios.mn.org, to avoid
  312.   bugs in Berkeley compatibility library on Sys V R4 systems, but untested
  313.   by me (fdc).  Remove this bit if it gives you trouble.
  314.   (Later corrected by Marc Boucher <mboucher@iro.umontreal.ca> because
  315.   bzero/bcopy are not argument-compatible with memset/memcpy|memmove.)
  316. */
  317. #define bzero(s,n) memset(s,0,n)
  318. #ifdef SOLARIS
  319. #ifdef SUNX25
  320. #undef bzero
  321. /*
  322.   WOULD YOU BELIEVE... That the Solaris X.25 /opt/SUNWcomm/lib/libsockx25
  323.   library references bzero, even though the use of bzero is forbidden in
  324.   Solaris?  Look for the function definition in ckcnet.c.
  325. */
  326. _PROTOTYP( void bzero, (char *, int) );
  327. #endif /* SUNX25 */
  328. #define bcopy(h,a,l) memcpy(a,h,l)
  329. #else
  330. #define bcopy(h,a,l) memmove(a,h,l)
  331. #endif /* SOLARIS */
  332. #else /* !SVR4 */
  333. #ifdef PTX                /* Sequent DYNIX PTX 1.3 */
  334. #define bzero(s,n) memset(s,0,n)
  335. #define bcopy(h,a,l) memcpy(a,h,l)
  336. #endif /* PTX */
  337. #endif /* SVR4 */
  338.  
  339. #ifdef INTERLAN                /* Racal-Interlan TCP/IP */
  340. #include <interlan/socket.h>
  341. #include <interlan/il_types.h>
  342. #include <interlan/telnet.h>
  343. #include <interlan/il_errno.h>
  344. #include <interlan/in.h>
  345. #include <interlan/telnet.h>        /* Why twice ? ? ? */
  346. #else                    /* Normal BSD TCP/IP library */
  347. #ifndef HPUX
  348. #include <arpa/telnet.h>
  349. #endif /* HPUX */
  350. #include <sys/socket.h>
  351. #ifdef WOLLONGONG
  352. #include <sys/in.h>
  353. #else
  354. #include <netinet/in.h>
  355. #endif /* WOLLONGONG */
  356. #endif /* INTERLAN */
  357.  
  358. #ifndef EXCELAN
  359. #include <netdb.h>
  360. #ifndef INTERLAN
  361. #ifdef WOLLONGONG
  362. #define minor                /* Do not include <sys/macros.h> */
  363. #include <sys/inet.h>
  364. #else
  365. #ifndef OXOS
  366. #ifndef HPUX
  367. #include <arpa/inet.h>
  368. #endif /* HPUX */
  369. #else /* OXOS */
  370. /* In too many releases of X/OS, <arpa/inet.h> declares inet_addr() as
  371.  * ``struct in_addr''.  This is definitively wrong, and could cause
  372.  * core dumps.  Instead of including that bad file, inet_addr() is
  373.  * correctly declared here.  Of course, all the declarations done there
  374.  * has been copied here.
  375.  */
  376. unsigned long inet_addr();
  377. char    *inet_ntoa();
  378. struct    in_addr inet_makeaddr();
  379. unsigned long inet_network();
  380. #endif /* OXOS */
  381. #endif /* WOLLONGONG */
  382. #endif /* INTERLAN */
  383. #endif /* EXCELAN */
  384.  
  385. #ifdef EXCELAN                /* Excelan TCP/IP */
  386. #ifndef bzero
  387. #define bzero(s,n) memset(s,0,n)
  388. #endif /* bzero */
  389. #ifndef bcopy
  390. #define bcopy(h,a,l) memcpy(a,h,l)
  391. #endif /* bcopy */
  392. #include <ex_errno.h>
  393. #endif /* EXCELAN */
  394.  
  395. #ifdef I386IX                /* Interactive Sys V R3 network. */
  396. /* #define TELOPTS */            /* This might need defining. */
  397. #define ORG_NLONG ENAMETOOLONG        /* Resolve conflicting symbols */
  398. #undef ENAMETOOLONG            /* in <errno.h> and <net/errno.h> */
  399. #define ORG_NEMPTY ENOTEMPTY
  400. #undef ENOTEMPTY
  401. #include <net/errno.h>
  402. #undef ENAMETOOLONG
  403. #define ENAMETOOLONG ORG_NLONG
  404. #undef ENOTEMPTY
  405. #define ENOTEMPTY ORG_NEMPTY
  406. #endif /* I386IX */
  407. /*
  408.   Data type of the inet_addr() function...
  409.   We define INADDRX if it is of type struct inaddr.
  410.   If it is undefined, unsigned long is assumed.
  411.   Look at <arpa/inet.h> to find out.  The following known cases are
  412.   handled here.  Other systems that need it can be added here, or else
  413.   -DINADDRX can be included in the CFLAGS on the cc command line.
  414. */
  415. #ifdef DGUX540                /* Data General UX 5.4 */
  416. #ifndef DGUX543                /* But not DG/US 5.4R3.00 */
  417. #define INADDRX
  418. #endif /* DGUX543 */
  419. #endif /* DGUX540 */
  420.  
  421. #ifdef DU2                /* DEC Ultrix 2.0 */
  422. #define INADDRX
  423. #endif /* DU2 */
  424.  
  425. #else /* Not UNIX */
  426.  
  427. #ifdef VMS                /* (Open)VMS section */
  428.  
  429. #ifdef WINTCP                /* TWG WIN/TCP = PathWay for VMS */
  430. #include <errno.h>
  431. #include "twg$tcp:[netdist.include.sys]types.h"
  432. #include "twg$tcp:[netdist.include.sys]socket.h"
  433. #include "twg$tcp:[netdist.include]netdb.h"
  434. #include "twg$tcp:[netdist.include.sys]domain.h"
  435. #include "twg$tcp:[netdist.include.sys]protosw.h"
  436. #include "twg$tcp:[netdist.include.netinet]in.h"
  437. #include "twg$tcp:[netdist.include.sys]ioctl.h"
  438. #endif /* WINTCP */
  439.  
  440. #ifdef MULTINET                /* TGV MultiNet */
  441. #include "multinet_root:[multinet.include]errno.h"
  442. #include "multinet_root:[multinet.include.sys]types.h"
  443. #include "multinet_root:[multinet.include.sys]socket.h"
  444. #include "multinet_root:[multinet.include]netdb.h"
  445. #include "multinet_root:[multinet.include.netinet]in.h"
  446. #include "multinet_root:[multinet.include.sys]ioctl.h"
  447. #ifdef __DECC
  448. /*
  449.    If compiling under DEC C the socket calls must not be prefixed with
  450.    DECC$.  This is done by using the compiler switch /Prefix=Ansi_C89.
  451.    However, this causes some calls that should be prefixed to not be
  452.    (which I think is a bug in the compiler - I've been told these calls
  453.    are present in ANSI compilers).  At any rate, such calls are fixed
  454.    here by explicitly prefixing them.
  455. */
  456. #define close decc$close
  457. #define alarm decc$alarm
  458. #endif /* __DECC */
  459. #endif /* MULTINET */
  460.  
  461. #ifdef DEC_TCPIP
  462. #include <in.h>
  463. #include <netdb.h>
  464. #include <socket.h>
  465. #include "ckvioc.h"
  466. #define socket_errno errno
  467. #define bzero(s,n) memset(s,0,n)
  468. #define bcopy(h,a,l) memmove(a,h,l)
  469. #define socket_read     read
  470. #define socket_write     write
  471. #define socket_ioctl    ioctl
  472. #define socket_close    close
  473. /*
  474.   UCX supports select(), but does not provide the needed symbol and
  475.   structure definitions in any header file, so ...
  476. */
  477. #include <types.h>
  478. #ifndef NBBY
  479. /*-
  480.  * Copyright (c) 1982, 1986, 1991, 1993
  481.  *    The Regents of the University of California.  All rights reserved.
  482.  *
  483.  * Redistribution and use in source and binary forms, with or without
  484.  * modification, are permitted provided that the following conditions
  485.  * are met:
  486.  * 1. Redistributions of source code must retain the above copyright
  487.  *    notice, this list of conditions and the following disclaimer.
  488.  * 2. Redistributions in binary form must reproduce the above copyright
  489.  *    notice, this list of conditions and the following disclaimer in the
  490.  *    documentation and/or other materials provided with the distribution.
  491.  * 3. All advertising materials mentioning features or use of this software
  492.  *    must display the following acknowledgement:
  493.  *    This product includes software developed by the University of
  494.  *    California, Berkeley and its contributors.
  495.  * 4. Neither the name of the University nor the names of its contributors
  496.  *    may be used to endorse or promote products derived from this software
  497.  *    without specific prior written permission.
  498.  *
  499.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  500.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  501.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  502.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  503.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  504.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  505.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  506.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  507.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  508.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  509.  * SUCH DAMAGE.
  510.  *
  511.  *    @(#)types.h    8.1 (Berkeley) 6/2/93
  512.  */
  513.  
  514. #define    NBBY    8        /* number of bits in a byte */
  515.  
  516. /*
  517.  * Select uses bit masks of file descriptors in longs.  These macros
  518.  * manipulate such bit fields (the filesystem macros use chars).
  519.  * FD_SETSIZE may be defined by the user, but the default here should
  520.  * be enough for most uses.
  521.  */
  522. #ifndef    FD_SETSIZE
  523. #define    FD_SETSIZE    256
  524. #endif
  525.  
  526. typedef long    fd_mask;
  527. #define NFDBITS    (sizeof(fd_mask) * NBBY)    /* bits per mask */
  528.  
  529. #ifndef howmany
  530. #define    howmany(x, y)    (((x)+((y)-1))/(y))
  531. #endif
  532.  
  533. typedef    struct fd_set {
  534.     fd_mask    fds_bits[howmany(FD_SETSIZE, NFDBITS)];
  535. } fd_set;
  536.  
  537. #define    FD_SET(n, p)    ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
  538. #define    FD_CLR(n, p)    ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
  539. #define    FD_ISSET(n, p)    ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
  540. #define    FD_COPY(f, t)    bcopy(f, t, sizeof(*(f)))
  541. #define    FD_ZERO(p)    bzero(p, sizeof(*(p)))
  542.  
  543. #endif /* !NBBY */
  544. #endif /* DEC_TCPIP */
  545.  
  546. #ifdef CMU_TCPIP
  547. #include <types.h>
  548. #include <in.h>
  549. #include <netdb.h>
  550. #include <socket.h>
  551. #include <ioctl.h>
  552. #include "ckvioc.h"
  553. #define socket_errno errno
  554. #define bzero(s,n) memset(s,0,n) 
  555. #define bcopy(h,a,l) memmove(a,h,l)
  556. /*
  557.  * Routines supplied in LIBCMU.OLB
  558.  */
  559. #define socket_ioctl    ioctl
  560. #define socket_read     cmu_read
  561. #define socket_write     cmu_write
  562. #define socket_close    cmu_close
  563. #endif /* CMU_TCPIP */
  564.  
  565. #else /* Not VMS */
  566.  
  567. #ifdef OS2
  568. #include "ckonet.h"
  569. #endif /* OS2 */
  570.  
  571. #ifdef STRATUS  /* Stratus VOS using OS TCP/IP products S235, S236, S237 */
  572. #include <tcp_socket.h>
  573. /* This gets used some places when TCPSOCKET is defined. */
  574. /* OS TCP provides bzero(), but not bcopy()... go figure. */
  575. #define bcopy(s,d,z) memcpy(d,s,z)
  576. #endif /* STRATUS */
  577.  
  578. #endif /* VMS */
  579. #endif /* UNIX */
  580. #endif /* TCPSOCKET */
  581.  
  582. #ifdef TNCODE                /* If we're compiling telnet code... */
  583. /*
  584.   Make sure telnet symbols are defined; can't rely on library header files
  585.   for any of them.
  586. */
  587. #ifndef IAC                /* First the telnet commands */
  588. #define IAC 255
  589. #endif /* IAC */
  590. #ifndef DONT
  591. #define DONT 254
  592. #endif /* DONT */
  593. #ifndef DO
  594. #define DO 253
  595. #endif /* DO */
  596. #ifndef WONT
  597. #define WONT 252
  598. #endif /* WONT */
  599. #ifndef WILL
  600. #define WILL 251
  601. #endif /* WILL */
  602. #ifndef SB
  603. #define SB 250
  604. #endif /* SB */
  605. #ifndef BREAK
  606. #define BREAK 243
  607. #endif /* BREAK */
  608. #ifndef SE
  609. #define SE 240
  610. #endif /* SE */
  611.  
  612. #ifndef TELOPT_ECHO            /* Then the options */
  613. #define TELOPT_ECHO 1
  614. #endif /* TELOPT_ECHO */
  615. #ifndef TELOPT_SGA
  616. #define    TELOPT_SGA 3
  617. #endif /* TELOPT_SGA */
  618. #ifndef TELOPT_STATUS
  619. #define    TELOPT_STATUS 5
  620. #endif /* TELOPT_STATUS */
  621. #ifndef TELOPT_TTYPE
  622. #define    TELOPT_TTYPE 24
  623. #endif /* TELOPT_TTYPE */
  624. #ifndef NTELOPTS
  625. #define    NTELOPTS 24
  626. #endif /* NTELOPTS */
  627.  
  628. /* Systems where we know we can define NAWS automatically. */
  629.  
  630. /*
  631.    NOTE: in the future we should separate the notion of TELNET NAWS
  632.    negotiation from "finding out my own screen size".  This might be as
  633.    simple as moving the following section out of the TNCODE section,
  634.    but then its name will be confusing, etc.
  635. */
  636. #ifndef NONAWS                /* Unless they said not to... */
  637. #ifndef CK_NAWS                /* and it's not already enabled... */
  638. #ifdef SUNOS41                /* SunOS 4.1 */
  639. #define CK_NAWS
  640. #else
  641. #ifdef NEXT                /* NeXTSTEP */
  642. #define CK_NAWS
  643. #else
  644. #ifdef BSD44                /* 4.4BSD */
  645. #define CK_NAWS
  646. #else
  647. #ifdef OS2                /* OS/2 */
  648. #define CK_NAWS
  649. #else
  650. #ifdef SVR4                /* System V R4 */
  651. #define CK_NAWS
  652. #else
  653. #ifdef OSF                /* OSF/1 */
  654. #define CK_NAWS
  655. #else
  656. #ifdef VMS                /* VMS */
  657. #define CK_NAWS
  658. #else
  659. #ifdef AIXRS                /* AIX/6000 */
  660. #define CK_NAWS
  661. #else
  662. #ifdef SOLARIS                /* Solaris 2.x */
  663. #define CK_NAWS
  664. #else
  665. #ifdef DU4                /* DEC ULTRIX 4.x */
  666. #define CK_NAWS
  667. #else
  668. #ifdef QNX                /* DEC ULTRIX 4.x */
  669. #define CK_NAWS
  670. #endif /* QNX */
  671. #endif /* DU4 */
  672. #endif /* SOLARIS */
  673. #endif /* AIXRS */
  674. #endif /* VMS */
  675. #endif /* OSF */
  676. #endif /* SVR4 */
  677. #endif /* OS2 */
  678. #endif /* BSD44 */
  679. #endif /* NEXT */
  680. #endif /* SUNOS41 */
  681. #endif /* CK_NAWS */
  682. #endif /* NONAWS */
  683.  
  684. #ifdef CK_NAWS
  685. #ifndef TELOPT_NAWS
  686. #define TELOPT_NAWS 31
  687. #endif /* TELOPT_NAWS */
  688. #endif /* CK_NAWS */
  689.  
  690. /* Telnet protocol functions defined in C-Kermit */
  691.  
  692. _PROTOTYP( int tn_ini, (void) );    /* Telnet protocol support */
  693. _PROTOTYP( int tn_sopt, (int, int) );
  694. _PROTOTYP( int tn_doop, (CHAR, int, int (*)(int) ) );
  695. _PROTOTYP( int tn_sttyp, (void) );
  696. _PROTOTYP( int tnsndbrk, (void) );
  697.  
  698. #endif /* TNCODE */
  699.  
  700. #endif /* CKCNET_H */
  701.