home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / archives / ckc192.zip / CKCNET.H < prev    next >
C/C++ Source or Header  |  1996-11-24  |  26KB  |  917 lines

  1. /* ckcnet.h -- Symbol and macro definitions for C-Kermit network support */
  2.  
  3. /*
  4.   Author: Frank da Cruz <fdc@columbia.edu>
  5.   Columbia University Academic Information Systems, New York City.
  6.  
  7.   Copyright (C) 1985, 1996, 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. #define NET_SLAT 9            /* Meridian Technologies' SuperLAT */
  30. #define NET_FILE 10            /* Read from a file */
  31.  
  32. #ifdef OS2                /* In OS/2, only the 32-bit */
  33. #ifndef __32BIT__            /* version gets NETBIOS */
  34. #ifdef CK_NETBIOS
  35. #undef CK_NETBIOS
  36. #endif /* CK_NETBIOS */
  37. #endif /* __32BIT__ */
  38. #endif /* OS2 */
  39.  
  40. #ifdef _M_PPC
  41. #ifdef SUPERLAT
  42. #undef SUPERLAT
  43. #endif /* SUPERLAT */
  44. #endif /* _M_PPC */
  45.  
  46. #ifdef _M_ALPHA
  47. #ifdef SUPERLAT
  48. #undef SUPERLAT
  49. #endif /* SUPERLAT */
  50. #endif /* _M_ALPHA */
  51.  
  52. #ifdef NPIPE                /* For items in common to */
  53. #define NPIPEORBIOS            /* Named Pipes and NETBIOS */
  54. #endif /* NPIPE */
  55. #ifdef CK_NETBIOS
  56. #ifndef NPIPEORBIOS
  57. #define NPIPEORBIOS
  58. #endif /* NPIPEORBIOS */
  59. #endif /* CK_NETBIOS */
  60.  
  61. /* Network virtual terminal protocols */
  62.  
  63. #define NP_NONE 0            /* None (async) */
  64. #define NP_TELNET 1            /* TCP/IP telnet */
  65. #define NP_VTP 2            /* ISO Virtual Terminal Protocol */
  66. #define NP_X3 3                /* CCITT X.3 */
  67. #define NP_X28 4            /* CCITT X.28 */
  68. #define NP_X29 5            /* CCITT X.29 */
  69. #define NP_RLOGIN 6         /* TCP/IP Rlogin */
  70. #define NP_KERMIT 7         /* TCP/IP Kermit */
  71. #define NP_FTP    8         /* TCP/IP FTP */
  72.  
  73. #define NP_CTERM 20            /* DEC CTERM */
  74. #define NP_LAT 21            /* DEC LAT */
  75. /* others here... */
  76.  
  77. /* TELNET Newline Mode */
  78.        
  79. #define TNL_CR     0            /* CR sends bare carriage return */
  80. #define TNL_CRNUL  1            /* CR and NUL */
  81. #define TNL_CRLF   2            /* CR and LF */
  82. #define TNL_LF     3            /* LF instead of CR */
  83.  
  84. /* TELNET Binary Mode */
  85.  
  86. #define    TN_BM_RF 0       /*  Negotiation REFUSED */
  87. #define    TN_BM_AC 1       /*  Negotiation ACCEPTED */
  88. #define    TN_BM_RQ 2       /*  Negotiation REQUESTED */
  89.  
  90. /* RLOGIN Modes */
  91. #define    RL_RAW     0     /*  Do Not Process XON/XOFF */
  92. #define    RL_COOKED  1     /*  Do Process XON/XOFF */
  93.  
  94. /* Basic network function prototypes, common to all. */
  95.  
  96. _PROTOTYP( int netopen, (char *, int *, int) );
  97. _PROTOTYP( int netclos, (void) );
  98. _PROTOTYP( int netflui, (void) );
  99. _PROTOTYP( int nettchk, (void) );
  100. _PROTOTYP( int netbreak, (void) );
  101. _PROTOTYP( int netinc, (int) );
  102. _PROTOTYP( int netxin, (int, char*) );
  103. _PROTOTYP( int nettol, (char *, int) );
  104. _PROTOTYP( int nettoc, (char) );
  105.  
  106. /*
  107.   SunLink X.25 support by Marcello Frutig, Catholic University,
  108.   Rio de Janeiro, Brazil, 1990.
  109.  
  110.   Maybe this can be adapted to VAX PSI and other X.25 products too.
  111. */
  112. #ifndef SUNOS4                /* Only valid for SUNOS4 */
  113. #ifndef SOLARIS
  114. #ifdef SUNX25
  115. #undef SUNX25
  116. #endif /* SUNX25 */
  117. #endif /* SOLARIS */
  118. #endif /* SUNOS4 */
  119.  
  120. #ifdef STRATUSX25
  121. #define ANYX25
  122. #define MAX_USER_DATA 128 /* SUN defines this in a header file, I believe. */
  123. #endif /* STRATUSX25 */
  124.  
  125. #ifdef SUNX25
  126. #define ANYX25
  127. #endif /* SUNX25 */
  128.  
  129. #ifdef ANYX25
  130. #ifndef NETCONN                /* ANYX25 implies NETCONN */
  131. #define NETCONN
  132. #endif /* NETCONN */
  133.  
  134. #define MAXPADPARMS                22    /* Number of PAD parameters */
  135. #define MAXCUDATA           12    /* Max length of X.25 call user data */
  136. #define X29PID                1   /* X.29 protocol ID */
  137. #define X29PIDLEN            4   /* X.29 protocol ID length */
  138.  
  139. #define X29_SET_PARMS               2
  140. #define X29_READ_PARMS              4
  141. #define X29_SET_AND_READ_PARMS      6
  142. #define X29_INVITATION_TO_CLEAR     1
  143. #define X29_PARAMETER_INDICATION    0
  144. #define X29_INDICATION_OF_BREAK     3
  145. #define X29_ERROR                   5
  146.  
  147. #define INVALID_PAD_PARM            1
  148.  
  149. #define PAD_BREAK_CHARACTER         0
  150.  
  151. #define PAD_ESCAPE                  1
  152. #define PAD_ECHO                    2
  153. #define PAD_DATA_FORWARD_CHAR       3
  154. #define PAD_DATA_FORWARD_TIMEOUT    4
  155. #define PAD_FLOW_CONTROL_BY_PAD     5
  156. #define PAD_SUPPRESSION_OF_SIGNALS  6
  157. #define PAD_BREAK_ACTION            7
  158. #define PAD_SUPPRESSION_OF_DATA     8
  159. #define PAD_PADDING_AFTER_CR        9
  160. #define PAD_LINE_FOLDING           10
  161. #define PAD_LINE_SPEED             11
  162. #define PAD_FLOW_CONTROL_BY_USER   12
  163. #define PAD_LF_AFTER_CR            13
  164. #define PAD_PADDING_AFTER_LF       14
  165. #define PAD_EDITING                15
  166. #define PAD_CHAR_DELETE_CHAR       16
  167. #define PAD_BUFFER_DELETE_CHAR     17
  168. #define PAD_BUFFER_DISPLAY_CHAR    18
  169.  
  170. #define MAXIX25 MAX_USER_DATA*7
  171. #define MAXOX25 MAX_USER_DATA
  172. #endif /* ANYX25 */
  173.  
  174. #ifdef SUNX25
  175. #include <sys/ioctl.h>            /* X.25 includes, Sun only */
  176. #include <sys/param.h>
  177. #include <sys/systm.h>
  178. #ifndef SOLARIS
  179. #include <sys/mbuf.h>
  180. #endif /* SOLARIS */
  181. #include <sys/socket.h>
  182. #include <sys/protosw.h>
  183. #ifdef SOLARIS
  184. #include <sys/sockio.h>
  185. #else
  186. #include <sys/domain.h>
  187. #endif /* SOLARIS */
  188. #include <sys/socketvar.h>
  189. #include <net/if.h>
  190. #include <sundev/syncstat.h>
  191. #include <netx25/x25_pk.h>
  192. #include <netx25/x25_ctl.h>
  193. #include <netx25/x25_ioctl.h>
  194. #endif /* SUNX25 */
  195.  
  196. #ifdef ANYX25
  197.  
  198. /* C-Kermit X.3 / X.25 / X.29 / X.121 support functions */
  199.  
  200. _PROTOTYP( VOID shopad, (void) );
  201. _PROTOTYP( VOID shox25, (void) );
  202. _PROTOTYP( VOID initpad, (void) );
  203. _PROTOTYP( VOID setpad, (CHAR *, int) );
  204. _PROTOTYP( VOID readpad, (CHAR *, int, CHAR *) );
  205. _PROTOTYP( int qbitpkt, (CHAR *, int) );
  206. _PROTOTYP( VOID setqbit, (void) );
  207. _PROTOTYP( VOID resetqbit, (void) );
  208. _PROTOTYP( VOID breakact, (void) );
  209. _PROTOTYP( int pkx121, (char *, CHAR *) );
  210. _PROTOTYP( SIGTYP x25oobh, (int) );
  211. _PROTOTYP( int x25diag, (void) );
  212. _PROTOTYP( int x25intr, (char) );
  213. _PROTOTYP( int x25reset, (char, char) );
  214. _PROTOTYP( int x25clear, (void) );
  215. _PROTOTYP( int x25stat, (void) );
  216. _PROTOTYP( int x25in, (int, CHAR *) );
  217. _PROTOTYP( int setpadp, (void) );
  218. _PROTOTYP( int setx25, (void) );
  219. _PROTOTYP( int x25xin, (int, CHAR *) );
  220. _PROTOTYP( int x25inl, (CHAR *, int, int, CHAR) );
  221.  
  222. #endif /* ANYX25 */
  223.  
  224. /* CMU-OpenVMS/IP */
  225.  
  226. #ifdef CMU_TCPIP            /* CMU_TCPIP implies TCPSOCKET */
  227. #ifndef TCPSOCKET
  228. #define TCPSOCKET
  229. #endif /* TCPSOCKET */
  230. #ifndef TCPIPLIB
  231. #define TCPIPLIB
  232. #endif /* TCPIPLIB */
  233. #endif /* CMU_TCPIP */
  234.  
  235. /* DEC TCP/IP for (Open)VMS, previously known as UCX */
  236.  
  237. #ifdef DEC_TCPIP            /* DEC_TCPIP implies TCPSOCKET */
  238. #ifndef TCPSOCKET
  239. #define TCPSOCKET
  240. #endif /* TCPSOCKET */
  241. #ifndef TCPIPLIB
  242. #define TCPIPLIB
  243. #endif /* TCPIPLIB */
  244. #endif /* DEC_TCPIP */
  245.  
  246. /* TGV/SRI MultiNet, TCP/IP for VAX/VMS */
  247.  
  248. #ifdef MULTINET                /* MULTINET implies TCPSOCKET */
  249. #ifndef TCPSOCKET
  250. #define TCPSOCKET
  251. #endif /* TCPSOCKET */
  252. #ifndef TCPIPLIB
  253. #define TCPIPLIB
  254. #endif /* TCPIPLIB */
  255. #ifndef TGVORWIN            /* MULTINET and WINTCP */
  256. #define TGVORWIN            /* share a lot of code... */
  257. #endif /* TGVORWIN */
  258. #endif /* MULTINET */
  259.  
  260. /* Wollongong TCP/IP for VAX/VMS */
  261.  
  262. #ifdef WINTCP                /* WINTCP implies TCPSOCKET */
  263. #ifndef TCPSOCKET
  264. #define TCPSOCKET
  265. #endif /* TCPSOCKET */
  266. #ifndef TCPIPLIB
  267. #define TCPIPLIB
  268. #endif /* TCPIPLIB */
  269. #ifndef TGVORWIN            /* WINTCP and MULTINET */
  270. #define TGVORWIN            /* share a lot of code... */
  271. #endif /* TGVORWIN */
  272. #endif /* WINTCP */
  273.  
  274. /* Wollongong TCP/IP for AT&T Sys V */
  275.  
  276. #ifdef WOLLONGONG            /* WOLLONGONG implies TCPSOCKET */
  277. #ifndef TCPSOCKET            /* Don't confuse WOLLONGONG */
  278. #define TCPSOCKET            /* (which is for UNIX) with */
  279. #endif /* TCPSOCKET */            /* WINTCP, which is for VMS! */
  280. #endif /* WOLLONGONG */
  281.  
  282. #ifdef EXCELAN                /* EXCELAN implies TCPSOCKET */
  283. #ifndef TCPSOCKET
  284. #define TCPSOCKET
  285. #endif /* TCPSOCKET */
  286. #endif /* EXCELAN */
  287.  
  288. #ifdef INTERLAN                /* INTERLAN implies TCPSOCKET */
  289. #ifndef TCPSOCKET
  290. #define TCPSOCKET
  291. #endif /* TCPSOCKET */
  292. #endif /* INTERLAN */
  293.  
  294. #ifdef COMMENT /* no longer used but might come in handy again later... */
  295. /*
  296.   CK_READ0 can (and should) be defined if and only if:
  297.   (a) read(fd,&x,0) can be used harmlessly on a TCP/IP socket connection.
  298.   (b) read(fd,&x,0) returns 0 if the connection is up, -1 if it is down.
  299. */
  300. #ifndef CK_READ0
  301. #ifdef TCPSOCKET
  302. #ifdef SUNOS41                /* It works in SunOS 4.1 */
  303. #define CK_READ0
  304. #else
  305. #ifdef NEXT                /* and NeXTSTEP */
  306. #define CK_READ0
  307. #endif /* NEXT */
  308. #endif /* SUNOS41 */
  309. #endif /* TCPSOCKET */
  310. #endif /* CK_READ0 */
  311. #endif /* COMMENT */
  312.  
  313. /* Telnet protocol */
  314.  
  315. #ifdef TCPSOCKET            /* TCPSOCKET implies TNCODE */
  316. #ifndef TNCODE                /* Which means... */
  317. #define TNCODE                /* Compile in telnet code */
  318. #endif /* TNCODE */
  319. #ifndef RLOGCODE            /* What about Rlogin? */
  320. #ifndef NORLOGIN
  321. /*
  322.   Rlogin can be enabled only for UNIX versions that have both SIGURG
  323.   (SCO doesn't) and CK_TTGWSIZ (OSF/1 doesn't), so we don't assume that
  324.   any others have these without verifying first.  Not that it really makes
  325.   much difference since you can only use Rlogin if you are root...
  326. */
  327. #ifdef SUNOS41
  328. #define RLOGCODE
  329. #else
  330. #ifdef SOLARIS
  331. #define RLOGCODE
  332. #else
  333. #ifdef HPUX9
  334. #define RLOGCODE
  335. #else
  336. #ifdef NEXT
  337. #define RLOGCODE
  338. #else
  339. #ifdef AIX41
  340. #define RLOGCODE
  341. #else
  342. #ifdef UNIXWARE
  343. #define RLOGCODE
  344. #else
  345. #ifdef IRIX51
  346. #define RLOGCODE
  347. #else
  348. #ifdef IRIX60
  349. #define RLOGCODE
  350. #else
  351. #ifdef QNX
  352. #define RLOGCODE
  353. #else
  354. #ifdef __linux__
  355. #define RLOGCODE
  356. #endif /* __linux__ */
  357. #endif /* QNX */
  358. #endif /* IRIX60 */
  359. #endif /* IRIX51 */
  360. #endif /* UNIXWARE */
  361. #endif /* AIX41 */
  362. #endif /* NEXT */
  363. #endif /* SOLARIS */
  364. #endif /* HPUX9 */
  365. #endif /* SUNOS41 */
  366. #endif /* NORLOGIN */
  367. #ifdef VMS                /* VMS */
  368. #define RLOGCODE
  369. #endif /* VMS */
  370. #endif /* RLOGCODE */
  371. #endif /* TCPSOCKET */
  372.  
  373. #ifdef SUNX25                /* SUNX25 implies TCPSOCKET */
  374. #ifndef TCPSOCKET            /* But doesn't imply TNCODE */
  375. #define TCPSOCKET
  376. #endif /* TCPSOCKET */
  377. #endif /* SUNX25 */
  378.  
  379. /* This is the TCPSOCKET section... */
  380.  
  381. #ifdef TCPSOCKET
  382.  
  383. #ifndef NETCONN                /* TCPSOCKET implies NETCONN */
  384. #define NETCONN
  385. #endif /* NETCONN */
  386.  
  387. #ifdef TCPSOCKET            /* select() is required to support */
  388. #ifndef NOLISTEN            /* incoming connections. */
  389. #ifndef SELECT
  390. #ifndef OS2
  391. #define NOLISTEN
  392. #endif /* OS2 */
  393. #endif /* SELECT */
  394. #endif /* NOLISTEN */
  395. #endif /* TCPSOCKET */
  396.  
  397. /* BSD sockets library header files */
  398.  
  399. #ifdef UNIX                /* UNIX section */
  400.  
  401. #ifdef SVR4
  402. /*
  403.   These suggested by Rob Healey, rhealey@kas.helios.mn.org, to avoid
  404.   bugs in Berkeley compatibility library on Sys V R4 systems, but untested
  405.   by me (fdc).  Remove this bit if it gives you trouble.
  406.   (Later corrected by Marc Boucher <mboucher@iro.umontreal.ca> because
  407.   bzero/bcopy are not argument-compatible with memset/memcpy|memmove.)
  408. */
  409. #define bzero(s,n) memset(s,0,n)
  410. #ifdef SOLARIS
  411. #ifdef SUNX25
  412. #undef bzero
  413. /*
  414.   WOULD YOU BELIEVE... That the Solaris X.25 /opt/SUNWcomm/lib/libsockx25
  415.   library references bzero, even though the use of bzero is forbidden in
  416.   Solaris?  Look for the function definition in ckcnet.c.
  417. */
  418. _PROTOTYP( void bzero, (char *, int) );
  419. #endif /* SUNX25 */
  420. #define bcopy(h,a,l) memcpy(a,h,l)
  421. #else
  422. #define bcopy(h,a,l) memmove(a,h,l)
  423. #endif /* SOLARIS */
  424. #else /* !SVR4 */
  425. #ifdef PTX                /* Sequent DYNIX PTX 1.3 */
  426. #define bzero(s,n) memset(s,0,n)
  427. #define bcopy(h,a,l) memcpy(a,h,l)
  428. #endif /* PTX */
  429. #endif /* SVR4 */
  430.  
  431. #ifdef INTERLAN                /* Racal-Interlan TCP/IP */
  432. #include <interlan/socket.h>
  433. #include <interlan/il_types.h>
  434. #include <interlan/telnet.h>
  435. #include <interlan/il_errno.h>
  436. #include <interlan/in.h>
  437. #include <interlan/telnet.h>        /* Why twice ? ? ? */
  438. #else                    /* Normal BSD TCP/IP library */
  439. #ifndef HPUX
  440. #include <arpa/telnet.h>
  441. #endif /* HPUX */
  442. #include <sys/socket.h>
  443. #ifdef WOLLONGONG
  444. #include <sys/in.h>
  445. #else
  446. #include <netinet/in.h>
  447. #endif /* WOLLONGONG */
  448. #endif /* INTERLAN */
  449.  
  450. #ifndef EXCELAN
  451. #include <netdb.h>
  452. #ifndef INTERLAN
  453. #ifdef WOLLONGONG
  454. #define minor                /* Do not include <sys/macros.h> */
  455. #include <sys/inet.h>
  456. #else
  457. #ifndef OXOS
  458. #ifndef HPUX
  459. #include <arpa/inet.h>
  460. #endif /* HPUX */
  461. #else /* OXOS */
  462. /* In too many releases of X/OS, <arpa/inet.h> declares inet_addr() as
  463.  * ``struct in_addr''.  This is definitively wrong, and could cause
  464.  * core dumps.  Instead of including that bad file, inet_addr() is
  465.  * correctly declared here.  Of course, all the declarations done there
  466.  * has been copied here.
  467.  */
  468. unsigned long inet_addr();
  469. char    *inet_ntoa();
  470. struct    in_addr inet_makeaddr();
  471. unsigned long inet_network();
  472. #endif /* OXOS */
  473. #endif /* WOLLONGONG */
  474. #endif /* INTERLAN */
  475. #endif /* EXCELAN */
  476.  
  477. #ifdef EXCELAN                /* Excelan TCP/IP */
  478. #ifndef bzero
  479. #define bzero(s,n) memset(s,0,n)
  480. #endif /* bzero */
  481. #ifndef bcopy
  482. #define bcopy(h,a,l) memcpy(a,h,l)
  483. #endif /* bcopy */
  484. #include <ex_errno.h>
  485. #endif /* EXCELAN */
  486.  
  487. #ifdef I386IX                /* Interactive Sys V R3 network. */
  488. /* #define TELOPTS */            /* This might need defining. */
  489. #define ORG_NLONG ENAMETOOLONG        /* Resolve conflicting symbols */
  490. #undef ENAMETOOLONG            /* in <errno.h> and <net/errno.h> */
  491. #define ORG_NEMPTY ENOTEMPTY
  492. #undef ENOTEMPTY
  493. #include <net/errno.h>
  494. #undef ENAMETOOLONG
  495. #define ENAMETOOLONG ORG_NLONG
  496. #undef ENOTEMPTY
  497. #define ENOTEMPTY ORG_NEMPTY
  498. #include <netinet/tcp.h>        /* for inet_addr() */
  499. #endif /* I386IX */
  500. /*
  501.   Data type of the inet_addr() function...
  502.   We define INADDRX if it is of type struct inaddr.
  503.   If it is undefined, unsigned long is assumed.
  504.   Look at <arpa/inet.h> to find out.  The following known cases are
  505.   handled here.  Other systems that need it can be added here, or else
  506.   -DINADDRX can be included in the CFLAGS on the cc command line.
  507. */
  508. #ifndef NOINADDRX
  509. #ifdef DGUX540                /* Data General UX 5.40 */
  510. #define INADDRX
  511. #endif /* DGUX540 */
  512. #ifdef DU2                /* DEC Ultrix 2.0 */
  513. #define INADDRX
  514. #endif /* DU2 */
  515. #endif /* NOINADDRX */
  516.  
  517. #else /* Not UNIX */
  518.  
  519. #ifdef VMS                /* (Open)VMS section */
  520.  
  521. #ifdef WINTCP                /* WIN/TCP = PathWay for VMS */
  522. #ifdef OLD_TWG
  523. #include "twg$tcp:[netdist.include.sys]errno.h"
  524. #include "twg$tcp:[netdist.include.sys]types2.h"   /* avoid some duplicates */
  525. #else
  526. #include <errno.h>
  527. #include "twg$tcp:[netdist.include.sys]types.h"
  528. #endif /* OLD_TWG */
  529. #include "twg$tcp:[netdist.include.sys]socket.h"
  530. #include "twg$tcp:[netdist.include]netdb.h"
  531. #include "twg$tcp:[netdist.include.sys]domain.h"
  532. #include "twg$tcp:[netdist.include.sys]protosw.h"
  533. #include "twg$tcp:[netdist.include.netinet]in.h"
  534. #include "twg$tcp:[netdist.include.sys]ioctl.h"
  535. #endif /* WINTCP */
  536.  
  537. #ifdef MULTINET                /* TGV MultiNet */
  538. #include "multinet_root:[multinet.include]errno.h"
  539. #include "multinet_root:[multinet.include.sys]types.h"
  540. #include "multinet_root:[multinet.include.sys]socket.h"
  541. #include "multinet_root:[multinet.include]netdb.h"
  542. #include "multinet_root:[multinet.include.netinet]in.h"
  543. #include "multinet_root:[multinet.include.arpa]inet.h"
  544. #include "multinet_root:[multinet.include.sys]ioctl.h"
  545. /*
  546.   We should be able to pick these up from <strings.h> but it's
  547.   not portable between VAXC and DECC.
  548. */
  549. _PROTOTYP( void bzero, (char *, int) );
  550. _PROTOTYP( void bcopy, (char *, char *, int) );
  551. #ifdef __DECC
  552. /*
  553.    If compiling under DEC C the socket calls must not be prefixed with
  554.    DECC$.  This is done by using the compiler switch /Prefix=Ansi_C89.
  555.    However, this causes some calls that should be prefixed to not be
  556.    (which I think is a bug in the compiler - I've been told these calls
  557.    are present in ANSI compilers).  At any rate, such calls are fixed
  558.    here by explicitly prefixing them.
  559. */
  560. #ifdef COMMENT
  561. /*
  562.    But this causes errors with VMS 6.2 / DEC C 5.3-006 / MultiNet 4.0A on
  563.    a VAX (but not on an Alpha).  So now what happens if we skip doing this?
  564. */
  565. #define close decc$close
  566. #define alarm decc$alarm
  567. #endif /* COMMENT */
  568. #endif /* __DECC */
  569. #endif /* MULTINET */
  570.  
  571. #ifdef DEC_TCPIP
  572. #include <in.h>
  573. #include <netdb.h>
  574. #include <socket.h>
  575. #include "ckvioc.h"
  576. #define socket_errno errno
  577. /*
  578.   Translation: In <strings.h>, which exists only for DECC >= 5.2, bzero()
  579.   and bcopy() are declared only for OpenVMS >= 7.0.  This still might need
  580.   adjustment for DECC 5.0 and (if there is such a thing) 5.1.
  581. */
  582. #ifdef __DECC_VER
  583. #ifdef VMSV70
  584. /*
  585.   Note: you can't use "#if (__VMS_VER>=70000000)" because that is not
  586.   portable and kills non-VMS builds.
  587. */
  588. #include <strings.h>
  589. #else
  590. #define bzero(s,n) memset(s,0,n)
  591. #define bcopy(h,a,l) memmove(a,h,l)
  592. #endif /* VMSV70 */
  593. #else
  594. #define bzero(s,n) memset(s,0,n)
  595. #define bcopy(h,a,l) memmove(a,h,l)
  596. #endif /* __DECC_VER */
  597. #define socket_read     read
  598. #define socket_write     write
  599. #define socket_ioctl    ioctl
  600. #define socket_close    close
  601. #ifdef __DECC
  602. int ioctl (int d, int request, void *argp);
  603. #else
  604. int ioctl (int d, int request, char *argp);
  605. #endif /* DECC */
  606. /*
  607.   UCX supports select(), but does not provide the needed symbol and
  608.   structure definitions in any header file, so ...
  609. */
  610. #include <types.h>
  611. #ifndef NBBY
  612. /*-
  613.  * Copyright (c) 1982, 1986, 1991, 1993
  614.  *    The Regents of the University of California.  All rights reserved.
  615.  *
  616.  * Redistribution and use in source and binary forms, with or without
  617.  * modification, are permitted provided that the following conditions
  618.  * are met:
  619.  * 1. Redistributions of source code must retain the above copyright
  620.  *    notice, this list of conditions and the following disclaimer.
  621.  * 2. Redistributions in binary form must reproduce the above copyright
  622.  *    notice, this list of conditions and the following disclaimer in the
  623.  *    documentation and/or other materials provided with the distribution.
  624.  * 3. All advertising materials mentioning features or use of this software
  625.  *    must display the following acknowledgement:
  626.  *    This product includes software developed by the University of
  627.  *    California, Berkeley and its contributors.
  628.  * 4. Neither the name of the University nor the names of its contributors
  629.  *    may be used to endorse or promote products derived from this software
  630.  *    without specific prior written permission.
  631.  *
  632.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  633.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  634.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  635.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  636.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  637.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  638.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  639.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  640.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  641.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  642.  * SUCH DAMAGE.
  643.  *
  644.  *    @(#)types.h    8.1 (Berkeley) 6/2/93
  645.  */
  646.  
  647. #define    NBBY    8        /* number of bits in a byte */
  648.  
  649. /*
  650.  * Select uses bit masks of file descriptors in longs.  These macros
  651.  * manipulate such bit fields (the filesystem macros use chars).
  652.  * FD_SETSIZE may be defined by the user, but the default here should
  653.  * be enough for most uses.
  654.  */
  655. #ifndef    FD_SETSIZE
  656. #define    FD_SETSIZE    256
  657. #endif
  658.  
  659. typedef long    fd_mask;
  660. #define NFDBITS    (sizeof(fd_mask) * NBBY)    /* bits per mask */
  661.  
  662. #ifndef howmany
  663. #define    howmany(x, y)    (((x)+((y)-1))/(y))
  664. #endif
  665.  
  666. typedef    struct fd_set {
  667.     fd_mask    fds_bits[howmany(FD_SETSIZE, NFDBITS)];
  668. } fd_set;
  669.  
  670. #define    FD_SET(n, p)    ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
  671. #define    FD_CLR(n, p)    ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
  672. #define    FD_ISSET(n, p)    ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
  673. #define    FD_COPY(f, t)    bcopy(f, t, sizeof(*(f)))
  674. #define    FD_ZERO(p)    bzero(p, sizeof(*(p)))
  675.  
  676. #endif /* !NBBY */
  677. #endif /* DEC_TCPIP */
  678.  
  679. #ifdef CMU_TCPIP
  680. #include <types.h>
  681. #include <in.h>
  682. #include <netdb.h>
  683. #include <socket.h>
  684. #include <ioctl.h>
  685. #include "ckvioc.h"
  686. #define socket_errno errno
  687. #define bzero(s,n) memset(s,0,n) 
  688. #define bcopy(h,a,l) memmove(a,h,l)
  689. /*
  690.  * Routines supplied in LIBCMU.OLB
  691.  */
  692. #define socket_ioctl    ioctl
  693. #define socket_read     cmu_read
  694. #define socket_write     cmu_write
  695. #define socket_close    cmu_close
  696. #endif /* CMU_TCPIP */
  697.  
  698. #else /* Not VMS */
  699.  
  700. #ifdef BEBOX
  701. #define TCPIPLIB
  702. #define socket_close(x) closesocket(x)
  703. #endif /* BEBOX */
  704.  
  705. #ifdef OS2
  706. #include "ckonet.h"
  707. #ifndef NT
  708. #include <nerrno.h>
  709. #endif
  710. #endif /* OS2 */
  711.  
  712. #ifdef STRATUS  /* Stratus VOS using OS TCP/IP products S235, S236, S237 */
  713. #include <tcp_socket.h>
  714. /* This gets used some places when TCPSOCKET is defined. */
  715. /* OS TCP provides bzero(), but not bcopy()... go figure. */
  716. #define bcopy(s,d,z) memcpy(d,s,z)
  717. #endif /* STRATUS */
  718.  
  719. #ifdef OSK
  720. #include <inet/in.h>
  721. #include <inet/netdb.h>
  722. #include <inet/socket.h>
  723. #define bzero(s,n) memset(s,0,n)
  724. #define bcopy(h,a,l) memcpy(a,h,l)
  725. typedef char * caddr_t; /* core address type */
  726. #endif /* OSK */
  727.  
  728. #endif /* VMS */
  729. #endif /* UNIX */
  730. #endif /* TCPSOCKET */
  731.  
  732. #ifdef TNCODE                /* If we're compiling telnet code... */
  733. /*
  734.   Make sure telnet symbols are defined; can't rely on library header files
  735.   for any of them.
  736. */
  737. #ifndef IAC                /* First the telnet commands */
  738. #define IAC 255
  739. #endif /* IAC */
  740. #ifndef DONT
  741. #define DONT 254
  742. #endif /* DONT */
  743. #ifndef DO
  744. #define DO 253
  745. #endif /* DO */
  746. #ifndef WONT
  747. #define WONT 252
  748. #endif /* WONT */
  749. #ifndef WILL
  750. #define WILL 251
  751. #endif /* WILL */
  752. #ifndef SB
  753. #define SB 250
  754. #endif /* SB */
  755. #ifndef BREAK
  756. #define BREAK 243
  757. #endif /* BREAK */
  758. #ifndef SE
  759. #define SE 240
  760. #endif /* SE */
  761.  
  762. /* Then the options */
  763. #ifndef TELOPT_BINARY 
  764. #define TELOPT_BINARY 0
  765. #endif /* TELOPT_BINARY */
  766. #ifndef TELOPT_ECHO            
  767. #define TELOPT_ECHO 1
  768. #endif /* TELOPT_ECHO */
  769. #ifndef TELOPT_SGA
  770. #define    TELOPT_SGA 3
  771. #endif /* TELOPT_SGA */
  772. #ifndef TELOPT_STATUS
  773. #define    TELOPT_STATUS 5
  774. #endif /* TELOPT_STATUS */
  775. #ifndef TELOPT_TTYPE
  776. #define    TELOPT_TTYPE 24
  777. #endif /* TELOPT_TTYPE */
  778. #ifndef TELOPT_NAWS
  779. #define TELOPT_NAWS 31
  780. #endif  /* TELOPT_NAWS */
  781. #ifndef NTELOPTS
  782. #define    NTELOPTS 24
  783. #endif /* NTELOPTS */
  784. #ifndef TELOPT_NEWENVIRON
  785. #define TELOPT_NEWENVIRON 39
  786. #endif /* TELOPT_NEWENVIRON */
  787.  
  788. #ifdef OS2
  789. #define CK_ENVIRONMENT
  790. #endif /* OS2 */
  791.  
  792. /* Systems where we know we can define TELNET NAWS automatically. */
  793.  
  794. #ifndef CK_NAWS                /* In other words, if both */
  795. #ifdef CK_TTGWSIZ            /* TNCODE and TTGWSIZ are defined */
  796. #define CK_NAWS                /* then we can do NAWS. */
  797. #endif /* CK_TTGWSIZ */
  798. #endif /* CK_NAWS */
  799.  
  800. /* Telnet protocol functions defined in C-Kermit */
  801.  
  802. _PROTOTYP( int tn_ini, (void) );    /* Telnet protocol support */
  803. _PROTOTYP( int tn_sopt, (int, int) );
  804. _PROTOTYP( int tn_doop, (CHAR, int, int (*)(int) ) );
  805. _PROTOTYP( int tn_sttyp, (void) );
  806. _PROTOTYP( int tn_snenv, (CHAR *, int) ) ;
  807. _PROTOTYP( int tnsndbrk, (void) );
  808.  
  809. #ifndef NOTCPOPTS
  810. /*
  811.   Automatically define NOTCPOPTS for configurations where they can't be
  812.   used at runtime or cause too much trouble at compile time.
  813. */
  814. #ifdef CMU_TCPIP            /* CMU/Tek */
  815. #define NOTCPOPTS
  816. #endif /* CMU_TCPIP */
  817. #ifdef MULTINET                /* Multinet on Alpha */
  818. #ifdef __alpha
  819. #define NOTCPOPTS
  820. #endif /* __alpha */
  821. #endif /* MULTINET */
  822. #endif /* NOTCPOPTS */
  823.  
  824. #ifdef NOTCPOPTS
  825. #ifdef TCP_NODELAY
  826. #undef TCP_NODELAY
  827. #endif /* TCP_NODELAY */
  828. #ifdef SO_LINGER
  829. #undef SO_LINGER
  830. #endif /* SO_LINGER */
  831. #ifdef SO_KEEPALIVE
  832. #undef SO_KEEPALIVE
  833. #endif /* SO_KEEPALIVE */
  834. #ifdef SO_SNDBUF
  835. #undef SO_SNDBUF
  836. #endif /* SO_SNDBUF */
  837. #ifdef SO_RCVBUF
  838. #undef SO_RCVBUF
  839. #endif /* SO_RCVBUF */
  840. #endif /* NOTCPOPTS */
  841.  
  842. #ifdef SOL_SOCKET
  843. #ifdef TCP_NODELAY
  844. _PROTOTYP( int no_delay, (int) );
  845. #endif /* TCP_NODELAY */
  846. #ifdef SO_KEEPALIVE
  847. _PROTOTYP( int keepalive, (int) ) ;
  848. #endif /* SO_KEEPALIVE */
  849. #ifdef SO_LINGER 
  850. _PROTOTYP( int ck_linger, (int, int) ) ;
  851. #endif /* SO_LINGER */
  852. #ifdef SO_SNDBUF
  853. _PROTOTYP( int sendbuf,(int) ) ; 
  854. #endif /* SO_SNDBUF */
  855. #ifdef SO_RCVBUF
  856. _PROTOTYP( int recvbuf, (int) ) ;
  857. #endif /* SO_RCVBUF */
  858. #endif /* SOL_SOCKET */
  859.  
  860. /* On HP-9000/500 HP-UX 5.21 this stuff is not defined in any header file */
  861.  
  862. #ifdef hp9000s500
  863. #ifndef NEEDSELECTDEFS
  864. #define NEEDSELECTDEFS
  865. #endif /* NEEDSELECTDEFS */
  866. #endif /* hp9000s500 */
  867.  
  868. #ifdef NEEDSELECTDEFS
  869. typedef long fd_mask;
  870. #ifndef NBBY
  871. #define NBBY 8
  872. #endif /* NBBY */
  873. #ifndef FD_SETSIZE
  874. #define FD_SETSIZE 32
  875. #endif /* FD_SETSIZE */
  876. #ifndef NFDBITS
  877. #define NFDBITS (sizeof(fd_mask) * NBBY)
  878. #endif /* NFDBITS */
  879. #ifndef howmany
  880. #define howmany(x,y) (((x)+((y)-1))/(y))
  881. #endif /* howmany */
  882. typedef struct fd_set {
  883.     fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)];
  884. } fd_set;
  885. #ifndef FD_SET
  886. #define FD_SET(n,p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
  887. #endif /* FD_SET */
  888. #ifndef FD_CLR
  889. #define FD_CLR(n,p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
  890. #endif /* FD_CLR */
  891. #ifndef FD_ISSET
  892. #define FD_ISSET(n,p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
  893. #endif /* FD_ISSET */
  894. #ifndef FD_COPY
  895. #define FD_COPY(f,t) (bcopy(f,t,sizeof(*(f)))
  896. #endif /* FD_COPY */
  897. #ifndef FD_ZERO
  898. #define FD_ZERO(p) bzero((char *)(p),sizeof(*(p)))
  899. #endif /* FD_ZERO */
  900. #endif /* NEEDSELECTDEFS */
  901.  
  902. #endif /* TNCODE */
  903.  
  904. #ifdef RLOGCODE
  905. #ifndef CK_TTGWSIZ
  906. SORRY_RLOGIN_REQUIRES_TTGWSIZ_see_ckcplm.doc
  907. #endif /* CK_TTGWSIZ */
  908. #endif /* RLOGCODE */
  909.  
  910. #ifdef CK_NAWS
  911. #ifndef CK_TTGWSIZ
  912. SORRY_CK_NAWS_REQUIRES_TTGWSIZ_see_ckcplm.doc
  913. #endif /* CK_TTGWSIZ */
  914. #endif /* CK_NAWS */
  915.  
  916. #endif /* CKCNET_H */
  917.