1: #include "vmodem.h"
2: #include ssdef
3: #include tt2def
4: #include ttdef
5: #define SS_NORMAL SS$_NORMAL
6: #define MODE2OK /* CAF 7-3-89 */
7:
8: /* VMS structures */
9: /*
10: * TT_INFO structures are used for passing information about
11: * the terminal. Used in GTTY and STTY calls.
12: */
13: struct tt_info ttys, ttysnew, ttystemp;
14:
15: /*
16: *
17: */
18:
19: /*
20: * return 1 iff stdout and stderr are different devices
21: * indicating this program operating with a modem on a
22: * different line
23: */
24: int Fromcu; /* Were called from cu or yam */
25: from_cu()
26: {
27: }
28: cucheck()
29: {
30: }
31:
32:
33:
34: /*
35: * mode(n)
36: * 3: save old tty stat, set raw mode with INPPUT flow control
37: * 2: set OUTPUT XON/XOFF for sb/sz with ZMODEM or YMODEM-g
38: * 1: save old tty stat, set raw mode for XMODEM/YMODEM
39: * 0: restore original tty mode
40: */
41: mode(n)
42: {
43: int *iptr, parameters;
44: static savedmodes = FALSE;
45:
46: vfile("mode:%d", n);
47:
48: if (!savedmodes) {
49: if (gtty(&ttys) != SS$_NORMAL)
50: death("SETMODES: error return from GTTY (1)");
51: if (gtty(&ttysnew) != SS$_NORMAL)
52: death("SETMODES: error return from GTTY (2)");
53: savedmodes = TRUE;
54: }
55:
56: /*
57: * Set new terminal parameters.
58: * Note: there are three bytes of terminal characteristics,
59: * so we should make sure the fourth byte of the integer is unchanged.
60: */
61: switch (n) {
62: case 1:
63: case 2:
64: case 3:
65: iptr = &(ttysnew.dev_characteristics.bcharacteristics);
66: parameters = *iptr;
67:
68: parameters &= ~TT$M_ESCAPE; /* ESCAPE OFF */
69: parameters &= ~TT$M_HOSTSYNC; /* HOSTSYNC OFF */
70: parameters |= TT$M_NOECHO; /* NOECHO ON */
71: parameters |= TT$M_PASSALL; /* PASSALL ON */
72: parameters &= ~TT$M_READSYNC; /* READSYNC OFF */
73: parameters &= ~TT$M_TTSYNC; /* TTSYNC OFF */
74: parameters &= ~TT$M_WRAP; /* WRAP OFF */
75: parameters |= TT$M_EIGHTBIT; /* EIGHTBIT ON */
76: if (n == 3) {
77: parameters |= TT$M_HOSTSYNC; /* HOSTSYNC On */
78: }
79: if (n == 2) {
80: parameters |= TT$M_TTSYNC; /* TTSYNC On */
81: }
82:
83: *iptr = parameters;
84:
85: if (stty(&ttysnew) != SS_NORMAL)
86: fatal("SETMODES: error return from STTY");
87: break;
88: case 0:
89: stty(&ttys); /* Restore original modes */
90: /* error return to /dev/null */
91: break;
92: }
93: }
94:
95:
96:
97: /* set tty modes for vrzsz transfers */
98: setmodes()
99: {
100: /* Device characteristics for VMS */
101: }
102:
103: fatal(msg)
104: char *msg;
105: {
106: mode(0); /* put back normal tty modes */
107: printf("vrzsz: %s\n", msg);
108: exit(SS_NORMAL);
109: }
110:
111: /* Call this instead if funny modes haven't been set yet */
112: death(msg)
113: char *msg;
114: {
115: printf("vrzsz: %s\n", msg);
116: exit(SS_NORMAL);
117: }
118:
119: #define LSIZE 64 /* Size of send & receive buffers */
120: #ifdef BUFREAD
121:
122: char Rxlbuf[LSIZE+1];
123: int Rxleft=0; /* number of characters in Rxlbuf */
124: char *Rxcdq = Rxlbuf; /* pointer for removing chars from Rxlbuf */
125:
126: /*
127: * This version of readline is reasoably well suited for
128: * reading many characters.
129: *
130: * timeout is in tenths of seconds
131: */
132:
133: readline(timeout)
134: int timeout;
135: {
136: register int c;
137: extern errno;
138:
139: if (--Rxleft>=0)
140: return (*Rxcdq++ & 0377);
141: #ifdef DEBUGG
142: eprintf("Calling read: ");
143: #endif
144: if ((c = timeout/10)<2)
145: c=2;
146:
147: do {
148: Rxleft = raw_read(LSIZE, Rxcdq=Rxlbuf, 1);
149: } while (Rxleft == SS$_TIMEOUT && --c >= 0);
150: #ifdef DEBUGG
151: eprintf("Read returned %d bytes\n", Rxleft);
152: #endif
153: if (Rxleft == SS$_TIMEOUT || --Rxleft < 0) {
154: Rxleft = 0;
155: return TIMEOUT;
156: }
157: return (*Rxcdq++ & 0377);
158: }
159:
160: purgeline()
161: {
162: Rxleft=0;
163: }
164:
165:
166: #else /* BUFREAD */
167:
168:
169: /* get a byte from data stream -- timeout if "dseconds" elapses */
170: /* NOTE, however, that this function returns an INT, not a BYTE!!! */
171: readline(dseconds)
172: {
173: int seconds;
174: int ret, c;
175:
176: seconds = dseconds/10;
177: if (seconds < 2)
178: seconds = 2;
179: ret = raw_read(1, &c, seconds);
180:
181: if (ret == SS$_TIMEOUT)
182: return(TIMEOUT);
183:
184: return(c & 0377); /* return the char */
185: }
186:
187: purgeline()
188: {
189: int c;
190:
191: do {
192: c = readline(1);
193: } while (c != TIMEOUT);
194: }
195: #endif
196:
197:
198: #ifdef BUFWRITE
199: char Txlbuf[LSIZE+1];
200: int Txleft=LSIZE; /* number of characters in Txlbuf */
201: char *Txcq = Txlbuf; /* pointer for removing chars from Rxlbuf */
202:
203: sendline(c)
204: {
205: if (--Txleft >= 0)
206: *Txcq++ = c;
207: else {
208: Txleft = 0;
209: flushmoc();
210: --Txleft;
211: *Txcq++ = c;
212: }
213: }
214:
215: flushmoc()
216: {
217: register int n;
218:
219: n = LSIZE - Txleft;
220: Txcq=Txlbuf; Txleft = LSIZE;
221: raw_wbuf(n, Txlbuf);
222: }
223:
224: /*
225: * Wait for the modem line outbuffer to drain
226: */
227: flushmo()
228: {
229: fflush(stdout);
230: flushmoc();
231: }
232:
233: #else /* BUFWRITE */
234:
235: /* send a byte to data stream */
236: sendline(data)
237: {
238: char dataout;
239:
240: dataout = data;
241: raw_write(dataout);
242:
243: }
244:
245: flushmo() {}
246: flushmoc() {}
247: #endif
248:
249: sendbrk()
250: {
251: }
252:
253:
254: /* End of vrzsz.c */
Defined functions
mode
defined in line
41; used 1 times
readline
defined in line
171; used 24 times
- in line 192
- in /usr/src/local/zmodem/rz.c line
489,
503,
582,
588-601(5),
623,
649,
1504-1506(2)
- in /usr/src/local/zmodem/zm.c line
433,
444-448(2),
692,
698,
812,
829-835(4),
876
Defined variables
Txcq
defined in line
201; used 3 times
ttys
defined in line
13; used 2 times
Defined macros
Usage of this include