Annotation of src/usr.bin/telnet/defs.h, Revision 1.1
1.1 ! deraadt 1: /*
! 2: * Copyright (c) 1989, 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. Neither the name of the University nor the names of its contributors
! 14: * may be used to endorse or promote products derived from this software
! 15: * without specific prior written permission.
! 16: *
! 17: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
! 18: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
! 19: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
! 20: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
! 21: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
! 22: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
! 23: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
! 24: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
! 25: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
! 26: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
! 27: * SUCH DAMAGE.
! 28: *
! 29: * @(#)defs.h 8.1 (Berkeley) 6/4/93
! 30: */
! 31:
! 32: /*
! 33: * Telnet server defines
! 34: */
! 35:
! 36: #ifndef __DEFS_H__
! 37: #define __DEFS_H__
! 38:
! 39: #if defined(PRINTOPTIONS) && defined(DIAGNOSTICS)
! 40: #define TELOPTS
! 41: #define TELCMDS
! 42: #define SLC_NAMES
! 43: #endif
! 44:
! 45: #if !defined(TIOCSCTTY) && defined(TCSETCTTY)
! 46: # define TIOCSCTTY TCSETCTTY
! 47: #endif
! 48:
! 49: #ifndef TIOCPKT_FLUSHWRITE
! 50: #define TIOCPKT_FLUSHWRITE 0x02
! 51: #endif
! 52:
! 53: #ifndef TIOCPKT_NOSTOP
! 54: #define TIOCPKT_NOSTOP 0x10
! 55: #endif
! 56:
! 57: #ifndef TIOCPKT_DOSTOP
! 58: #define TIOCPKT_DOSTOP 0x20
! 59: #endif
! 60:
! 61: /*
! 62: * I/O data buffers defines
! 63: */
! 64: #define NETSLOP 4096
! 65: #ifdef _CRAY
! 66: #undef BUFSIZ
! 67: #define BUFSIZ 2048
! 68: #endif
! 69:
! 70: #define NIACCUM(c) { *netip++ = c; \
! 71: ncc++; \
! 72: }
! 73:
! 74: /* clock manipulations */
! 75: #define settimer(x) (clocks.x = ++clocks.system)
! 76: #define sequenceIs(x,y) (clocks.x < clocks.y)
! 77:
! 78: /*
! 79: * Structures of information for each special character function.
! 80: */
! 81: typedef struct {
! 82: unsigned char flag; /* the flags for this function */
! 83: cc_t val; /* the value of the special character */
! 84: } slcent, *Slcent;
! 85:
! 86: typedef struct {
! 87: slcent defset; /* the default settings */
! 88: slcent current; /* the current settings */
! 89: cc_t *sptr; /* a pointer to the char in */
! 90: /* system data structures */
! 91: } slcfun, *Slcfun;
! 92:
! 93: #ifdef DIAGNOSTICS
! 94: /*
! 95: * Diagnostics capabilities
! 96: */
! 97: #define TD_REPORT 0x01 /* Report operations to client */
! 98: #define TD_EXERCISE 0x02 /* Exercise client's implementation */
! 99: #define TD_NETDATA 0x04 /* Display received data stream */
! 100: #define TD_PTYDATA 0x08 /* Display data passed to pty */
! 101: #define TD_OPTIONS 0x10 /* Report just telnet options */
! 102: #endif /* DIAGNOSTICS */
! 103:
! 104: /*
! 105: * We keep track of each side of the option negotiation.
! 106: */
! 107:
! 108: #define MY_STATE_WILL 0x01
! 109: #define MY_WANT_STATE_WILL 0x02
! 110: #define MY_STATE_DO 0x04
! 111: #define MY_WANT_STATE_DO 0x08
! 112:
! 113: /*
! 114: * Macros to check the current state of things
! 115: */
! 116:
! 117: #define my_state_is_do(opt) (options[opt]&MY_STATE_DO)
! 118: #define my_state_is_will(opt) (options[opt]&MY_STATE_WILL)
! 119: #define my_want_state_is_do(opt) (options[opt]&MY_WANT_STATE_DO)
! 120: #define my_want_state_is_will(opt) (options[opt]&MY_WANT_STATE_WILL)
! 121:
! 122: #define my_state_is_dont(opt) (!my_state_is_do(opt))
! 123: #define my_state_is_wont(opt) (!my_state_is_will(opt))
! 124: #define my_want_state_is_dont(opt) (!my_want_state_is_do(opt))
! 125: #define my_want_state_is_wont(opt) (!my_want_state_is_will(opt))
! 126:
! 127: #define set_my_state_do(opt) (options[opt] |= MY_STATE_DO)
! 128: #define set_my_state_will(opt) (options[opt] |= MY_STATE_WILL)
! 129: #define set_my_want_state_do(opt) (options[opt] |= MY_WANT_STATE_DO)
! 130: #define set_my_want_state_will(opt) (options[opt] |= MY_WANT_STATE_WILL)
! 131:
! 132: #define set_my_state_dont(opt) (options[opt] &= ~MY_STATE_DO)
! 133: #define set_my_state_wont(opt) (options[opt] &= ~MY_STATE_WILL)
! 134: #define set_my_want_state_dont(opt) (options[opt] &= ~MY_WANT_STATE_DO)
! 135: #define set_my_want_state_wont(opt) (options[opt] &= ~MY_WANT_STATE_WILL)
! 136:
! 137: /*
! 138: * Tricky code here. What we want to know is if the MY_STATE_WILL
! 139: * and MY_WANT_STATE_WILL bits have the same value. Since the two
! 140: * bits are adjacent, a little arithmetic will show that by adding
! 141: * in the lower bit, the upper bit will be set if the two bits were
! 142: * different, and clear if they were the same.
! 143: */
! 144: #define my_will_wont_is_changing(opt) \
! 145: ((options[opt]+MY_STATE_WILL) & MY_WANT_STATE_WILL)
! 146:
! 147: #define my_do_dont_is_changing(opt) \
! 148: ((options[opt]+MY_STATE_DO) & MY_WANT_STATE_DO)
! 149:
! 150: /*
! 151: * Make everything symmetrical
! 152: */
! 153:
! 154: #define HIS_STATE_WILL MY_STATE_DO
! 155: #define HIS_WANT_STATE_WILL MY_WANT_STATE_DO
! 156: #define HIS_STATE_DO MY_STATE_WILL
! 157: #define HIS_WANT_STATE_DO MY_WANT_STATE_WILL
! 158:
! 159: #define his_state_is_do my_state_is_will
! 160: #define his_state_is_will my_state_is_do
! 161: #define his_want_state_is_do my_want_state_is_will
! 162: #define his_want_state_is_will my_want_state_is_do
! 163:
! 164: #define his_state_is_dont my_state_is_wont
! 165: #define his_state_is_wont my_state_is_dont
! 166: #define his_want_state_is_dont my_want_state_is_wont
! 167: #define his_want_state_is_wont my_want_state_is_dont
! 168:
! 169: #define set_his_state_do set_my_state_will
! 170: #define set_his_state_will set_my_state_do
! 171: #define set_his_want_state_do set_my_want_state_will
! 172: #define set_his_want_state_will set_my_want_state_do
! 173:
! 174: #define set_his_state_dont set_my_state_wont
! 175: #define set_his_state_wont set_my_state_dont
! 176: #define set_his_want_state_dont set_my_want_state_wont
! 177: #define set_his_want_state_wont set_my_want_state_dont
! 178:
! 179: #define his_will_wont_is_changing my_do_dont_is_changing
! 180: #define his_do_dont_is_changing my_will_wont_is_changing
! 181:
! 182: #endif /* __DEFS_H__ */