1 /* 2 * Copyright (c) 1989 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms are permitted 6 * provided that the above copyright notice and this paragraph are 7 * duplicated in all such forms and that any documentation, 8 * advertising materials, and other materials related to such 9 * distribution and use acknowledge that the software was developed 10 * by the University of California, Berkeley. The name of the 11 * University may not be used to endorse or promote products derived 12 * from this software without specific prior written permission. 13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 16 * 17 * @(#)defs.h 5.3 (Berkeley) 11/10/89 18 */ 19 20 /* 21 * Telnet server defines 22 */ 23 #include <sys/types.h> 24 #include <sys/param.h> 25 26 #ifndef BSD 27 # define BSD 43 28 #endif 29 30 #if BSD > 43 31 #define USE_TERMIO 32 #endif 33 34 #ifdef CRAY 35 # define NEWINIT 36 # define SYSV_TERMIO 37 # define NO_GETTYTAB 38 # define signal sigset 39 #endif /* CRAY */ 40 41 #ifdef SYSV_TERMIO 42 # define USE_TERMIO 43 #endif 44 45 #include <sys/socket.h> 46 #ifndef CRAY 47 #include <sys/wait.h> 48 #endif /* CRAY */ 49 #include <sys/file.h> 50 #include <sys/stat.h> 51 #include <sys/time.h> 52 #include <sys/ioctl.h> 53 54 #include <netinet/in.h> 55 56 #include <arpa/telnet.h> 57 58 #include <stdio.h> 59 #include <signal.h> 60 #include <errno.h> 61 #include <netdb.h> 62 #include <syslog.h> 63 #include <ctype.h> 64 #include <strings.h> 65 66 #ifndef USE_TERMIO 67 #include <sgtty.h> 68 #else 69 # ifdef SYSV_TERMIO 70 # include <termio.h> 71 # else 72 # include <termios.h> 73 # endif 74 #endif 75 76 #ifdef CRAY 77 #include <sys/fcntl.h> 78 # ifdef CRAY1 79 # include <sys/pty.h> 80 # ifndef FD_ZERO 81 # include <sys/select.h> 82 # endif /* FD_ZERO */ 83 # endif /* CRAY1 */ 84 85 #include <memory.h> 86 #endif /* CRAY */ 87 88 #if defined(TCSIG) || defined(TIOCPKT_IOCTL) 89 # define LINEMODE 90 # define KLUDGELINEMODE 91 #endif 92 93 #ifndef FD_SET 94 typedef struct fd_set { int fds_bits[1]; } fd_set; 95 96 #define FD_SET(n, p) ((p)->fds_bits[0] |= (1<<(n))) 97 #define FD_CLR(n, p) ((p)->fds_bits[0] &= ~(1<<(n))) 98 #define FD_ISSET(n, p) ((p)->fds_bits[0] & (1<<(n))) 99 #define FD_ZERO(p) ((p)->fds_bits[0] = 0) 100 #endif /* FD_SET */ 101 102 #define OPT_NO 0 /* won't do this option */ 103 #define OPT_YES 1 /* will do this option */ 104 #define OPT_YES_BUT_ALWAYS_LOOK 2 105 #define OPT_NO_BUT_ALWAYS_LOOK 3 106 107 /* 108 * I/O data buffers defines 109 */ 110 #define NETSLOP 64 111 #ifdef CRAY 112 #undef BUFSIZ 113 #define BUFSIZ 2048 114 #endif 115 116 #define NIACCUM(c) { *netip++ = c; \ 117 ncc++; \ 118 } 119 120 /* clock manipulations */ 121 #define settimer(x) (clocks.x = ++clocks.system) 122 #define sequenceIs(x,y) (clocks.x < clocks.y) 123 124 /* 125 * Linemode support states, in decreasing order of importance 126 */ 127 #define REAL_LINEMODE 0x02 128 #define KLUDGE_LINEMODE 0x01 129 #define NO_LINEMODE 0x00 130 131 /* 132 * Structures of information for each special character function. 133 */ 134 typedef struct { 135 unsigned char flag; /* the flags for this function */ 136 unsigned char val; /* the value of the special character */ 137 } slcent, *Slcent; 138 139 typedef struct { 140 slcent defset; /* the default settings */ 141 slcent current; /* the current settings */ 142 unsigned char *sptr; /* a pointer to the char in */ 143 /* system data structures */ 144 } slcfun, *Slcfun; 145