├── COPYING ├── Makefile ├── README ├── README.md ├── crc.c ├── crc.doc ├── crctab.c ├── gz ├── mailer.rz ├── minirb.c ├── minirb.doc ├── rbsb.c ├── rz.c ├── rz.doc ├── sz.c ├── sz.doc ├── undos.c ├── undos.doc ├── zm.c ├── zmodem.h ├── zmr.c └── zupl.t /COPYING: -------------------------------------------------------------------------------- 1 | Rz ans Sz are Copyrighted shareware programs. Commercial Use of 2 | these programs is subject to licensing conditions detailed in 3 | the sz.c source code. "Commercial Use" includes use of this 4 | program to transfer files to/from any commercial or shareware 5 | program not published by Omen Technology INC. Please print the 6 | "mailer.rz" file, fill out the form and return it with your 7 | registration. 8 | 9 | It is a violation of this program's Copyright to distribute 10 | binaries without the accompanying *.doc, README, and COPYING 11 | files. 12 | 13 | This software may be freely used to support file transfer 14 | operations to or from duly licensed Omen Technology products. 15 | This includes DSZ, GSZ, ZCOMM, Professional-YAM and PowerCom. 16 | Those desiring to use rz/sz this way must add the 17 | following to the sz compile line: -DCOMPL 18 | 19 | Use with other commercial or shareware programs 20 | (Crosstalk, Procomm, etc.) REQUIRES REGISTRATION. 21 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for Unix/Xenix rz and sz programs 2 | # Some targets may not be up to date 3 | CC=cc 4 | OFLAG= -O 5 | 6 | 7 | nothing: 8 | @echo 9 | @echo "Please study the #ifdef's in crctab.c, rbsb.c, rz.c and sz.c," 10 | @echo "make any necessary hacks for oddball or merged SYSV/BSD systems," 11 | @echo "then type 'make SYSTEM' where SYSTEM is one of:" 12 | @echo 13 | @echo " posix POSIX compliant systems" 14 | @echo " aix AIX systems" 15 | @echo " next NeXtstep v3.x (POSIX)" 16 | @echo " odt SCO Open Desktop" 17 | @echo " everest SCO Open Desktop (elf, strict)" 18 | @echo " sysvr4 SYSTEM 5.4 Unix" 19 | @echo " sysvr3 SYSTEM 5.3 Unix with mkdir(2), COHERENT 4.2" 20 | @echo " sysv SYSTEM 3/5 Unix" 21 | @echo " sysiii SYS III/V Older Unix or Xenix compilers" 22 | @echo " xenix Xenix" 23 | @echo " x386 386 Xenix" 24 | @echo " bsd Berkeley 4.x BSD, Ultrix, V7" 25 | @echo " tandy Tandy 6000 Xenix" 26 | @echo " dnix DIAB Dnix 5.2" 27 | @echo " dnix5r3 DIAB Dnix 5.3" 28 | @echo " amiga 3000UX running SVR4" 29 | @echo " POSIX POSIX compliant systems (SCO Open Desktop, strict)" 30 | @echo 31 | @echo " undos Make the undos, todos, etc. program." 32 | @echo " doc Format the man pages with nroff" 33 | @echo 34 | 35 | all:doc usenet unixforum sshar shar zoo 36 | 37 | usenet:doc 38 | shar -c -a -n rzsz -o /tmp/rzsz -l64 \ 39 | COPYING README Makefile undos.c zmodem.h zm.c rz.c rbsb.c \ 40 | crc.c crctab.c minirb.c mailer.rz zmr.c *.doc gz sz.c *.t 41 | 42 | sshar:doc 43 | shar -c -a -n rzsz -o /tmp/rzsz -l64 \ 44 | COPYING README Makefile undos.c zmodem.h zm.c rz.c rbsb.c \ 45 | crc.c crctab.c mailer.rz zmr.c *.doc gz sz.c 46 | 47 | shar:doc 48 | shar -c COPYING README Makefile zmodem.h zm.c \ 49 | undos.c zmr.c sz.c rz.c crctab.c \ 50 | mailer.rz crc.c rbsb.c minirb.c *.doc gz *.t >/tmp/rzsz.sh 51 | cp /tmp/rzsz.sh /u/t/yam 52 | 53 | unixforum: shar 54 | rm -f /tmp/rzsz.sh.gz 55 | gzip -9 /tmp/rzsz.sh 56 | cp /tmp/rzsz.sh.gz /u/t/yam 57 | 58 | doc:rz.doc sz.doc crc.doc minirb.doc undos.doc 59 | 60 | clean: 61 | rm -f *.o *.out sz sb sx zcommand zcommandi rz rb rx rc 62 | rm -f undos tounix todos unmac tomac tocpm unparity 63 | 64 | minirb.doc:minirb.1 65 | nroff -man minirb.1 | col >minirb.doc 66 | 67 | rz.doc:rz.1 servers.mi 68 | nroff -man rz.1 | col >rz.doc 69 | 70 | sz.doc:sz.1 servers.mi 71 | nroff -man sz.1 | col >sz.doc 72 | 73 | crc.doc:crc.1 74 | nroff -man crc.1 | col >crc.doc 75 | 76 | undos.doc:undos.1 77 | nroff -man undos.1 | col >undos.doc 78 | 79 | zoo: doc 80 | -rm -f /tmp/rzsz.zoo 81 | zoo ah /tmp/rzsz COPYING README Makefile zmodem.h zm.c sz.c rz.c \ 82 | undos.c mailer.rz crctab.c rbsb.c *.doc \ 83 | zmr.c crc.c gz *.t minirb.c 84 | touch /tmp/rzsz.zoo 85 | chmod og-w /tmp/rzsz.zoo 86 | mv /tmp/rzsz.zoo /u/t/yam 87 | -rm -f rzsz.zip 88 | zip rzsz readme mailer.rz makefile zmodem.h zm.c sz.c rz.c 89 | zip rzsz undos.c crctab.c rbsb.c *.doc file_id.diz 90 | zip rzsz zmr.c crc.c gz *.t minirb.c 91 | mv rzsz.zip /u/t/yam 92 | 93 | tag: doc xenix 94 | -rm -f /tmp/rzsz 95 | tar cvf /tmp/rzsz COPYING README Makefile zmodem.h zm.c sz.c rz.c \ 96 | mailer.rz crctab.c rbsb.c *.doc \ 97 | undos.c zmr.c crc.c gz *.t minirb.c rz sz crc undos 98 | gzip -9 /tmp/rzsz 99 | mv /tmp/rzsz.gz /u/t/yam/rzsz.tag 100 | 101 | tar:doc 102 | tar cvf /tmp/rzsz.tar COPYING README Makefile zmodem.h zm.c sz.c rz.c \ 103 | undos.c mailer.rz crctab.c rbsb.c \ 104 | zmr.c crc.c *.1 gz *.t minirb.c 105 | 106 | tags: 107 | ctags sz.c rz.c zm.c zmr.c rbsb.c 108 | 109 | .PRECIOUS:rz sz 110 | 111 | xenix: 112 | /usr/ods30/bin/cc \ 113 | -I/usr/ods30/usr/include -I/usr/ods30/usr/include/sys \ 114 | -M2 $(CFLAGS) $(RFLAGS) $(OFLAG) -s -DSMALL -DUSG -DNFGVMIN -DREADCHECK sz.c -lx -o sz 115 | size sz; file sz 116 | -rm -f sb sx zcommand zcommandi 117 | ln sz sb 118 | ln sz sx 119 | ln sz zcommand 120 | ln sz zcommandi 121 | /usr/ods30/bin/cc \ 122 | -I/usr/ods30/usr/include -I/usr/ods30/usr/include/sys \ 123 | -M2 $(CFLAGS) $(RFLAGS) $(OFLAG) -s -DUSG -DMD rz.c -o rz 124 | size rz; file rz 125 | -rm -f rb rx rc 126 | ln rz rb 127 | ln rz rx 128 | ln rz rc 129 | /usr/ods30/bin/cc \ 130 | -I/usr/ods30/usr/include -I/usr/ods30/usr/include/sys \ 131 | -M2 $(CFLAGS) $(OFLAG) -s undos.c -o undos 132 | size undos; file undos 133 | -rm -f tounix todos unmac tomac tocpm unparity 134 | ln undos tounix 135 | ln undos todos 136 | ln undos unmac 137 | ln undos tomac 138 | ln undos tocpm 139 | ln undos unparity 140 | 141 | x386: 142 | $(CC) $(CFLAGS) $(RFLAGS) $(OFLAG) -DUSG -DMD rz.c -o rz 143 | size rz 144 | -rm -f rb rx rc 145 | ln rz rb 146 | ln rz rx 147 | ln rz rc 148 | $(CC) $(CFLAGS) $(RFLAGS) $(OFLAG) -DUSG -DNFGVMIN -DREADCHECK sz.c -lx -o sz 149 | size sz 150 | -rm -f sb sx zcommand zcommandi 151 | ln sz sb 152 | ln sz sx 153 | ln sz zcommand 154 | ln sz zcommandi 155 | 156 | sysv: 157 | $(CC) $(CFLAGS) $(RFLAGS) $(OFLAG) -DUSG -DMD -DOLD rz.c -o rz 158 | size rz 159 | -rm -f rb rx rc 160 | ln rz rb 161 | ln rz rx 162 | ln rz rc 163 | $(CC) $(CFLAGS) $(RFLAGS) $(OFLAG) -DUSG -DSV -DNFGVMIN -DOLD sz.c -o sz 164 | size sz 165 | -rm -f sb sx zcommand zcommandi 166 | ln sz sb 167 | ln sz sx 168 | ln sz zcommand 169 | ln sz zcommandi 170 | 171 | sysiii: 172 | $(CC) $(CFLAGS) $(RFLAGS) $(OFLAG) -DUSG -DOLD rz.c -o rz 173 | size rz 174 | -rm -f rb rx rc 175 | ln rz rb 176 | ln rz rx 177 | ln rz rc 178 | $(CC) $(CFLAGS) $(RFLAGS) $(OFLAG) -DSV -DUSG -DNFGVMIN -DOLD sz.c -o sz 179 | size sz 180 | -rm -f sb sx zcommand zcommandi 181 | ln sz sb 182 | ln sz sx 183 | ln sz zcommand 184 | ln sz zcommandi 185 | 186 | sysvr3: 187 | $(CC) $(CFLAGS) $(RFLAGS) $(OFLAG) -DUSG -DMD=2 rz.c -o rz 188 | size rz 189 | -rm -f rb rx rc 190 | ln rz rb 191 | ln rz rx 192 | ln rz rc 193 | $(CC) $(CFLAGS) $(RFLAGS) $(OFLAG) -DSV -DUSG -DNFGVMIN sz.c -o sz 194 | size sz 195 | -rm -f sb sx zcommand zcommandi 196 | ln sz sb 197 | ln sz sx 198 | ln sz zcommand 199 | ln sz zcommandi 200 | 201 | sysvr4: 202 | $(CC) $(CFLAGS) $(RFLAGS) $(OFLAG) -DUSG -DMD=2 rz.c -o rz 203 | size rz 204 | -rm -f rb rx rc 205 | ln rz rb 206 | ln rz rx 207 | ln rz rc 208 | $(CC) $(CFLAGS) $(RFLAGS) $(OFLAG) -DSV -DUSG sz.c -o sz 209 | size sz 210 | -rm -f sb sx zcommand zcommandi 211 | ln sz sb 212 | ln sz sx 213 | ln sz zcommand 214 | ln sz zcommandi 215 | 216 | odt: 217 | cc -O -n $(RFLAGS) -DUSG -DMD=2 rz.c -o rz 218 | size rz 219 | -rm -f rb rx rc 220 | ln rz rb 221 | ln rz rx 222 | ln rz rc 223 | cc -O -n $(RFLAGS) -DUSG -DREADCHECK sz.c -lx -o sz 224 | size sz 225 | -rm -f sb sx zcommand zcommandi 226 | ln sz sb 227 | ln sz sx 228 | ln sz zcommand 229 | ln sz zcommandi 230 | 231 | everest: 232 | cc -b elf -w 3 -O3 $(RFLAGS) -DUSG -DMD=2 rz.c -o rz 233 | size rz 234 | -rm -f rb rx rc 235 | ln rz rb 236 | ln rz rx 237 | ln rz rc 238 | cc -b elf -w 3 $(RFLAGS) -O3 -DUSG -DREADCHECK sz.c -lx -o sz 239 | size sz 240 | -rm -f sb sx zcommand zcommandi 241 | ln sz sb 242 | ln sz sx 243 | ln sz zcommand 244 | ln sz zcommandi 245 | 246 | posix: 247 | $(CC) $(CFLAGS) $(RFLAGS) $(OFLAG) -DPOSIX -DMD=2 rz.c -o rz 248 | size rz 249 | -rm -f rb rx rc 250 | ln rz rb 251 | ln rz rx 252 | ln rz rc 253 | $(CC) $(CFLAGS) $(RFLAGS) $(OFLAG) -DPOSIX sz.c -o sz 254 | size sz 255 | -rm -f sb sx zcommand zcommandi 256 | ln sz sb 257 | ln sz sx 258 | ln sz zcommand 259 | ln sz zcommandi 260 | 261 | POSIX: 262 | @echo "Well, stricter, as in *safer sex* ..." 263 | $(CC) $(CFLAGS) $(RFLAGS) $(OFLAG) -DPOSIX -DMD=2 -DCOMPL rz.c -o rz 264 | size rz 265 | -rm -f rb rx rc 266 | ln rz rb 267 | ln rz rx 268 | ln rz rc 269 | $(CC) $(CFLAGS) $(RFLAGS) $(OFLAG) -DPOSIX -DCOMPL sz.c -o sz 270 | size sz 271 | -rm -f sb sx zcommand zcommandi 272 | ln sz sb 273 | ln sz sx 274 | ln sz zcommand 275 | ln sz zcommandi 276 | 277 | 278 | bsd: 279 | $(CC) $(CFLAGS) $(RFLAGS) $(OFLAG) -DMD=2 -Dstrchr=index -DV7 rz.c -o rz 280 | size rz 281 | -rm -f rb rx rc 282 | ln rz rb 283 | ln rz rx 284 | ln rz rc 285 | $(CC) $(CFLAGS) $(RFLAGS) $(OFLAG) -DV7 -DNFGVMIN sz.c -o sz 286 | size sz 287 | -rm -f sb sx zcommand zcommandi 288 | ln sz sb 289 | ln sz sx 290 | ln sz zcommand 291 | ln sz zcommandi 292 | 293 | tandy: 294 | $(CC) $(CFLAGS) $(RFLAGS) $(OFLAGS) -n -DUSG -DMD -DT6K sz.c -lx -o sz 295 | size sz 296 | -rm -f sb sx zcommand zcommandi 297 | ln sz sb 298 | ln sz sx 299 | ln sz zcommand 300 | ln sz zcommandi 301 | $(CC) $(CFLAGS) $(RFLAGS) $(OFLAGS) -n -DUSG -DMD -DT6K rz.c -lx -o rz 302 | size rz 303 | -rm -f rb rx rc 304 | ln rz rb 305 | ln rz rx 306 | ln rz rc 307 | 308 | dnix: 309 | $(CC) $(CFLAGS) $(RFLAGS) $(OFLAG) -DUSG -DMD rz.c -o rz 310 | size rz 311 | -rm -f rb rx rc 312 | ln rz rb 313 | ln rz rx 314 | ln rz rc 315 | $(CC) $(CFLAGS) $(RFLAGS) $(OFLAG) -DSV -DUSG -DNFGVMIN -DREADCHECK sz.c -o sz 316 | size sz 317 | -rm -f sb sx zcommand zcommandi 318 | ln sz sb 319 | ln sz sx 320 | ln sz zcommand 321 | ln sz zcommandi 322 | 323 | dnix5r3: 324 | $(CC) $(CFLAGS) $(RFLAGS) $(OFLAG) -DUSG -DMD=2 rz.c -o rz 325 | size rz 326 | -rm -f rb rx rc 327 | ln rz rb 328 | ln rz rx 329 | ln rz rc 330 | $(CC) $(CFLAGS) $(RFLAGS) $(OFLAG) -DUSG -DSV -DNFGVMIN -DREADCHECK sz.c -o sz 331 | size sz 332 | -rm -f sb sx zcommand zcommandi 333 | ln sz sb 334 | ln sz sx 335 | ln sz zcommand 336 | ln sz zcommandi 337 | 338 | 339 | amiga: 340 | $(CC) $(CFLAGS) $(OFLAG) -DUSG -DNFGVMIN -g rz.c -o rz 341 | size rz 342 | -rm -f rb rx rc 343 | ln rz rb 344 | ln rz rx 345 | ln rz rc 346 | $(CC) $(CFLAGS) $(OFLAG) -DUSG -DSV -DNFGVMIN -g sz.c -o sz 347 | size sz 348 | -rm -f sb sx zcommand zcommandi 349 | ln sz sb 350 | ln sz sx 351 | ln sz zcommand 352 | ln sz zcommandi 353 | 354 | aix: 355 | @echo "As of July 26 1996, ..." 356 | @echo "IBM sez if you have the very latest PTFs, 'make posix' will work." 357 | @echo "" 358 | 359 | next: 360 | LIBS=-lposix 361 | $(CC) -g -posix $(OFLAG) -DPOSIX -DMD=2 rz.c -o rz 362 | size rz 363 | -rm -f rb rx rc 364 | ln rz rb 365 | ln rz rx 366 | ln rz rc 367 | $(CC) -g -posix $(OFLAG) -DPOSIX sz.c -o sz 368 | size sz 369 | -rm -f sb sx zcommand zcommandi 370 | ln sz sb 371 | ln sz sx 372 | ln sz zcommand 373 | ln sz zcommandi 374 | 375 | undos: undos.c 376 | cc -O undos.c -o undos 377 | -rm -f tounix todos unmac tomac tocpm unparity 378 | ln undos tounix 379 | ln undos todos 380 | ln undos unmac 381 | ln undos tomac 382 | ln undos tocpm 383 | ln undos unparity 384 | 385 | 386 | lint: 387 | lint -DUSG -DSV -DOLD sz.c >/tmp/sz.fluff 388 | lint -DUSG -DSV -DOLD rz.c >/tmp/rz.fluff 389 | 390 | 391 | sz: nothing 392 | sb: nothing 393 | rz: nothing 394 | rb: nothing 395 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | Unix Rz and sz support XMODEM, YMODEM, and ZMODEM transfers via 2 | the dial-in controlling TTY (or PTY) port. Also included is the 3 | "undos" program which converts between Unix, MSDOS, CP/M, and 4 | Macintosh text file end of line conventions. 5 | 6 | The contents of this archive can be uploaded to a remote Unix or 7 | Xenix system by ZCOMM or Professional-YAM using the supplied 8 | zupl.t script. Connect to your Unix/Xenix system, select an 9 | empty directory, and then give the YAM/ZCOMM command: "source 10 | zupl.t". This will upload minirb.c, compile it, and then use 11 | minirb to bootstrap upload the rz/sz files. 12 | 13 | Once these files are on your Unix system, you can type "make". 14 | The Makefile will list the various systems it knows how to 15 | compile the programs for, and the command to do so (e.g., 16 | "make bsd"). 17 | 18 | The Makefile is self explanatory; just say "make". 19 | 20 | Unregistered users can obtain support on a consulting basis. 21 | Please call 503-614-0430 to arrange consulting support. 22 | 23 | Registered users can obtain free support for problems not 24 | involving terminal servers or third party software using email 25 | or the regular Omen Technology phone number. 26 | 27 | Rz and sz work best with comm programs that properly support 28 | ZMODEM command and file AutoDownload (Pro-YAM and ZCOMM). 29 | 30 | The "GSZ" shareware program allows ZMODEM file transfers with 31 | DOS comm programs. GSZ provides a "mini term function" that 32 | supports ZMODEM AutoDownload. GSZ (part of GSZ.ZIP) and ZCOMM 33 | (ZCOMMEXE.ZIP, ZCOMMDOC.ZIP, ZCOMMHLP.ZIP) are available on 34 | TeleGodzilla and other fine bulletin boards. 35 | 36 | This software may be freely used to support file transfer 37 | operations to or from duly licensed Omen Technology products. 38 | This includes DSZ, GSZ, ZCOMM, Professional-YAM and PowerCom. 39 | Institutions desiring to use rz/sz this way should add the 40 | following to the sz compile line: -DCOMPL 41 | Programs based on stolen or public domain ZMODEM materials are 42 | not included. Use with other commercial or shareware programs 43 | (Crosstalk, Procomm, etc.) REQUIRES REGISTRATION. 44 | 45 | Rz ans Sz are Copyrighted shareware programs. Commercial Use of 46 | these programs is subject to licensing conditions detailed in 47 | the sz.c source code. "Commercial Use" includes use of this 48 | program to transfer files to/from any commercial or shareware 49 | program not published by Omen Technology INC. Please print the 50 | "mailer.rz" file, fill out the form and return same with your 51 | registration. 52 | 53 | 1.xx and 2.xx versions of rz and sz (April 1988) are Public Domain, 54 | but lack recent enhancements and bug fixes. 55 | 56 | The Man pages are formatted for those without Unix nroff. For 57 | best results, use less(1) (available on comp.sources.misc) as 58 | your manual page reader. The troff sources for the rz/sz man pages 59 | are included with copies of Unix Professional-YAM, and are provided 60 | to registered sites as described in the mailer.rz file. 61 | 62 | Please check our web page www.omen.com for the latest information. 63 | 64 | FTP access is now available at ftp.cs.pdx.edu pub/zmodem 65 | directory. This account has the latest and greatest selection 66 | of OMEN files available for FTP. The files in this direcotryy 67 | are uploaded with ZMODEM directly from the Omen home system, 68 | preserving modification dates and file contents. 69 | 70 | Apr 30 1997: Rz handling of -N fixed. Sz buffering fixed 71 | to prevent spurious Bad Seek errors. 72 | 73 | Aug 2 1996: The paranoid can now disable command uploads: see rz.doc 74 | 75 | Mar 19 1996: Rz can now write its output to standard output 76 | (see rz.doc). 77 | 78 | Jan 28 1995: Sz now accepts standard input: "ls -l | sz -" 79 | See sz.doc. Sz is now compiled with buffering to support 80 | input from sources that do not allow seeks (pipes, etc.). 81 | <> the ZMODEM window size is set to 82 | guarantee error recovery will fit within the buffer. In 83 | some applications it may be desireable to increase the 84 | buffer size in the sz.c source code. 85 | 86 | June 22 1994: sz -e now escapes the all ones character (0xFF). 87 | This is useful in some terminal server applications. 88 | Sz now understands receiver specified control character 89 | prefixing (ZCOMM/Professional-YAM zmresc string parameter). 90 | 91 | Apr 23 1994: Added -DOLD compiler flag for antique SYSV 92 | compilers without a standard /usr/include/stdlib.h header file. 93 | This causes rbsb.c to define char *getenv() etc. instead of 94 | getting these definitons from stdlib.h. You may have to fiddle 95 | with the declarations in rbsb.c #ifdef OLD to get a clean compile. 96 | 97 | Registration and support has been clarified and simplified 98 | (see mailer.rz). 99 | 100 | Feb 18 94: A bug in sz that caused constipation at the end of a 101 | file under certain options was corrected. 102 | 103 | Jan 27 1994: Minor bugfixes and improvements, documentation 104 | improved. 105 | 106 | May 16 1993: More bugfixes, POSIX support. Tested on SCO Unix, 107 | BSDI 1.0, and SunOS 4.1.2. Code simplified to avoid certain 108 | compiler brain damage. (Some complaints about redefinitons 109 | with some POSIX compiles.) (Void and Unsigned Long are required.) 110 | 111 | Jan 2 1992: Documentation on the sz -T command has been 112 | improved. Please use this command and Professional-YAM to 113 | diagnose file transfer problems before calling for support. 114 | 115 | 116 | VMS systems are now supported with native VMS versions in 117 | RZSZ.TLB. The rz and sz in RZSZ.TLB support wild cards and 118 | VMS record types. 119 | 120 | New for 1989: ZMODEM compression and other compatible 121 | extensions have been added to the rz and sz programs. 122 | Please read the comments in the rz.c and sz.c source code 123 | for licensing information. 124 | 125 | 126 | In order for us to handle problem reports, we must have the 127 | exact error messages displayed by Professional-YAM. If 128 | transfers do not work at all, we must have complete results of 129 | the sz -T test procedure! If you are not using an Omen 130 | Technology product to talk to rz/sz and have not registered 131 | rz/sz, contact the author of the communications program you have 132 | purchased for support. Some heavily marketed programs do not 133 | properly support the XMODEM, YMODEM, and/orZMODEM protocols. 134 | 135 | Chuck Forsberg WA7KGX caf@omen.COM http://www.omen.com 136 | Omen Technology Inc "The High Reliability Software" 137 | Author of YMODEM, ZMODEM, Professional-YAM, ZCOMM, GSZ and DSZ 138 | TeleGodzilla BBS: 503-617-1698 FTP: ftp.cs.pdx.edu pub/zmodem 139 | POB 4681 Portland OR 97208 503-614-0430 FAX:503-629-0665 140 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # rzsz 2 | rzsz base on 3.48 3 | -------------------------------------------------------------------------------- /crc.c: -------------------------------------------------------------------------------- 1 | /*% cc -O -K -dos % -o crc.exe 2 | */ 3 | 4 | /* 5 | * Crc - 32 BIT ANSI X3.66 CRC checksum files 6 | */ 7 | #include 8 | #define OK 0 9 | #define ERROR (-1) 10 | #define LINT_ARGS 11 | 12 | /**********************************************************************\ 13 | |* *| 14 | |* Demonstration program to compute the 32-bit CRC used as the frame *| 15 | |* check sequence in ADCCP (ANSI X3.66, also known as FIPS PUB 71 *| 16 | |* and FED-STD-1003, the U.S. versions of CCITT's X.25 link-level *| 17 | |* protocol). The 32-bit FCS was added via the Federal Register, *| 18 | |* 1 June 1982, p.23798. I presume but don't know for certain that *| 19 | |* this polynomial is or will be included in CCITT V.41, which *| 20 | |* defines the 16-bit CRC (often called CRC-CCITT) polynomial. FIPS *| 21 | |* PUB 78 says that the 32-bit FCS reduces otherwise undetected *| 22 | |* errors by a factor of 10^-5 over 16-bit FCS. *| 23 | |* *| 24 | \**********************************************************************/ 25 | 26 | /* Need an unsigned type capable of holding 32 bits; */ 27 | typedef unsigned long int UNS_32_BITS; 28 | 29 | /* 30 | * Copyright (C) 1986 Gary S. Brown. You may use this program, or 31 | * code or tables extracted from it, as desired without restriction. 32 | */ 33 | /* First, the polynomial itself and its table of feedback terms. The */ 34 | /* polynomial is */ 35 | /* X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0 */ 36 | /* Note that we take it "backwards" and put the highest-order term in */ 37 | /* the lowest-order bit. The X^32 term is "implied"; the LSB is the */ 38 | /* X^31 term, etc. The X^0 term (usually shown as "+1") results in */ 39 | /* the MSB being 1. */ 40 | 41 | /* Note that the usual hardware shift register implementation, which */ 42 | /* is what we're using (we're merely optimizing it by doing eight-bit */ 43 | /* chunks at a time) shifts bits into the lowest-order term. In our */ 44 | /* implementation, that means shifting towards the right. Why do we */ 45 | /* do it this way? Because the calculated CRC must be transmitted in */ 46 | /* order from highest-order term to lowest-order term. UARTs transmit */ 47 | /* characters in order from LSB to MSB. By storing the CRC this way, */ 48 | /* we hand it to the UART in the order low-byte to high-byte; the UART */ 49 | /* sends each low-bit to hight-bit; and the result is transmission bit */ 50 | /* by bit from highest- to lowest-order term without requiring any bit */ 51 | /* shuffling on our part. Reception works similarly. */ 52 | 53 | /* The feedback terms table consists of 256, 32-bit entries. Notes: */ 54 | /* */ 55 | /* 1. The table can be generated at runtime if desired; code to do so */ 56 | /* is shown later. It might not be obvious, but the feedback */ 57 | /* terms simply represent the results of eight shift/xor opera- */ 58 | /* tions for all combinations of data and CRC register values. */ 59 | /* */ 60 | /* 2. The CRC accumulation logic is the same for all CRC polynomials, */ 61 | /* be they sixteen or thirty-two bits wide. You simply choose the */ 62 | /* appropriate table. Alternatively, because the table can be */ 63 | /* generated at runtime, you can start by generating the table for */ 64 | /* the polynomial in question and use exactly the same "updcrc", */ 65 | /* if your application needn't simultaneously handle two CRC */ 66 | /* polynomials. (Note, however, that XMODEM is strange.) */ 67 | /* */ 68 | /* 3. For 16-bit CRCs, the table entries need be only 16 bits wide; */ 69 | /* of course, 32-bit entries work OK if the high 16 bits are zero. */ 70 | /* */ 71 | /* 4. The values must be right-shifted by eight bits by the "updcrc" */ 72 | /* logic; the shift must be unsigned (bring in zeroes). On some */ 73 | /* hardware you could probably optimize the shift in assembler by */ 74 | /* using byte-swap instructions. */ 75 | 76 | static UNS_32_BITS crc_32_tab[] = { /* CRC polynomial 0xedb88320 */ 77 | 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 78 | 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 79 | 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 80 | 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, 81 | 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 82 | 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 83 | 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, 84 | 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 85 | 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, 86 | 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, 87 | 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 88 | 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, 89 | 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 90 | 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 91 | 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, 92 | 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 93 | 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 94 | 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 95 | 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, 96 | 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 97 | 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 98 | 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, 99 | 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 100 | 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, 101 | 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, 102 | 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 103 | 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, 104 | 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 105 | 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 106 | 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, 107 | 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, 108 | 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d 109 | }; 110 | 111 | #define UPDC32(octet, crc) (crc_32_tab[((crc) ^ (octet)) & 0xff] ^ ((crc) >> 8)) 112 | 113 | int Block = 0; /* Pad file with 032's to multiple of Block */ 114 | 115 | main(argc, argv) 116 | char **argv; 117 | { 118 | register errors = 0; 119 | 120 | if (! strcmp(argv[1], "-x")) { 121 | Block = 128; --argc; ++argv; 122 | } 123 | if (! strcmp(argv[1], "-k")) { 124 | Block = 1024; --argc; ++argv; 125 | } 126 | while( --argc > 0) 127 | errors |= crc32file( *++argv); 128 | exit(errors != 0); 129 | } 130 | 131 | crc32file(name) 132 | char *name; 133 | { 134 | register FILE *fin; 135 | register unsigned long oldcrc32; 136 | register unsigned long crc32; 137 | register unsigned long oldcrc; 138 | register c; 139 | register long charcnt; 140 | register long l; 141 | 142 | oldcrc32 = 0xFFFFFFFF; charcnt = 0; 143 | #ifdef M_I86SM 144 | if ((fin=fopen(name, "rb"))==NULL) 145 | #else 146 | if ((fin=fopen(name, "r"))==NULL) 147 | #endif 148 | { 149 | perror(name); 150 | return ERROR; 151 | } 152 | while ((c=getc(fin))!=EOF) { 153 | ++charcnt; 154 | oldcrc32 = UPDC32(c, oldcrc32); 155 | } 156 | 157 | if (ferror(fin)) { 158 | perror(name); 159 | fclose(fin); return ERROR; 160 | } 161 | else { 162 | if (Block) { 163 | for (l = charcnt; l % Block; ++l) 164 | oldcrc32 = UPDC32(032, oldcrc32); 165 | } 166 | crc32 = oldcrc32; oldcrc = oldcrc32 = ~oldcrc32; 167 | 168 | printf("%08lX %7ld ", oldcrc, charcnt); 169 | if (Block == 128) 170 | printf("%5ld+%3ld ", charcnt/Block, charcnt%Block); 171 | if (Block == 1024) 172 | printf("%5ld+%4ld ", charcnt/Block, charcnt%Block); 173 | printf(" %s\n", name); 174 | } 175 | 176 | fclose(fin); return OK; 177 | } 178 | 179 | /* End of crc.c */ 180 | -------------------------------------------------------------------------------- /crc.doc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CCCCRRRRCCCC((((1111)))) OOOOmmmmeeeennnn TTTTeeeecccchhhhnnnnoooollllooooggggyyyy IIIINNNNCCCC ((((OOOOMMMMEEEENNNN)))) CCCCRRRRCCCC((((1111)))) 5 | 6 | 7 | 8 | NNNNAAAAMMMMEEEE 9 | crc - checksum files 10 | 11 | SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS 12 | ccccrrrrcccc file ... 13 | 14 | DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN 15 | For each file, _c_r_c calculates and prints a 32-bit CRC, the 16 | byte count, and the file name. It is typically used to 17 | validate files transferred between different systems, and is 18 | useful in detecting subtle disk corruption. _C_r_c uses a 19 | checksum compatible with the DOS version of crc, the 32 bit 20 | CRC used by PKZIP, as well as the "crc" command in ZCOMM and 21 | Professional-YAM (high reliability communications programs). 22 | 23 | The 32-bit CRC used is the frame check sequence in ADCCP 24 | (ANSI X3.66, also known as FIPS PUB 71 and FED-STD-1003, the 25 | U.S. versions of CCITT's X.25 link-level protocol). 26 | 27 | 32 bit CRC code courtesy Gary S. Brown. 28 | 29 | BBBBUUUUGGGGSSSS 30 | Although extremely unlikely, files with different data may 31 | still produce the same crc value. 32 | 33 | SSSSEEEEEEEE AAAALLLLSSSSOOOO 34 | undos(OMEN), todos(OMEN), tocpm(OMEN), sum(1), wc(1). 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | Page 1 (printed 1/20/94) 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /crctab.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Crc calculation stuff 3 | */ 4 | 5 | /* crctab calculated by Mark G. Mendel, Network Systems Corporation */ 6 | static unsigned short crctab[256] = { 7 | 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7, 8 | 0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef, 9 | 0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6, 10 | 0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de, 11 | 0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485, 12 | 0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d, 13 | 0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4, 14 | 0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc, 15 | 0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823, 16 | 0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b, 17 | 0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12, 18 | 0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a, 19 | 0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41, 20 | 0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49, 21 | 0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70, 22 | 0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78, 23 | 0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f, 24 | 0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067, 25 | 0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e, 26 | 0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256, 27 | 0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d, 28 | 0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, 29 | 0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c, 30 | 0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634, 31 | 0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab, 32 | 0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3, 33 | 0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a, 34 | 0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92, 35 | 0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9, 36 | 0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1, 37 | 0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8, 38 | 0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0 39 | }; 40 | 41 | /* 42 | * updcrc macro derived from article Copyright (C) 1986 Stephen Satchell. 43 | * NOTE: First srgument must be in range 0 to 255. 44 | * Second argument is referenced twice. 45 | * 46 | * Programmers may incorporate any or all code into their programs, 47 | * giving proper credit within the source. Publication of the 48 | * source routines is permitted so long as proper credit is given 49 | * to Stephen Satchell, Satchell Evaluations and Chuck Forsberg, 50 | * Omen Technology. 51 | */ 52 | 53 | #define updcrc(cp, crc) ( crctab[((crc >> 8) & 255)] ^ (crc << 8) ^ cp) 54 | 55 | /* 56 | * Copyright (C) 1986 Gary S. Brown. You may use this program, or 57 | * code or tables extracted from it, as desired without restriction. 58 | */ 59 | 60 | /* First, the polynomial itself and its table of feedback terms. The */ 61 | /* polynomial is */ 62 | /* X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0 */ 63 | /* Note that we take it "backwards" and put the highest-order term in */ 64 | /* the lowest-order bit. The X^32 term is "implied"; the LSB is the */ 65 | /* X^31 term, etc. The X^0 term (usually shown as "+1") results in */ 66 | /* the MSB being 1. */ 67 | 68 | /* Note that the usual hardware shift register implementation, which */ 69 | /* is what we're using (we're merely optimizing it by doing eight-bit */ 70 | /* chunks at a time) shifts bits into the lowest-order term. In our */ 71 | /* implementation, that means shifting towards the right. Why do we */ 72 | /* do it this way? Because the calculated CRC must be transmitted in */ 73 | /* order from highest-order term to lowest-order term. UARTs transmit */ 74 | /* characters in order from LSB to MSB. By storing the CRC this way, */ 75 | /* we hand it to the UART in the order low-byte to high-byte; the UART */ 76 | /* sends each low-bit to hight-bit; and the result is transmission bit */ 77 | /* by bit from highest- to lowest-order term without requiring any bit */ 78 | /* shuffling on our part. Reception works similarly. */ 79 | 80 | /* The feedback terms table consists of 256, 32-bit entries. Notes: */ 81 | /* */ 82 | /* The table can be generated at runtime if desired; code to do so */ 83 | /* is shown later. It might not be obvious, but the feedback */ 84 | /* terms simply represent the results of eight shift/xor opera- */ 85 | /* tions for all combinations of data and CRC register values. */ 86 | /* */ 87 | /* The values must be right-shifted by eight bits by the "updcrc" */ 88 | /* logic; the shift must be unsigned (bring in zeroes). On some */ 89 | /* hardware you could probably optimize the shift in assembler by */ 90 | /* using byte-swap instructions. */ 91 | 92 | static unsigned long cr3tab[] = { /* CRC polynomial 0xedb88320 */ 93 | 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 94 | 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 95 | 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 96 | 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, 97 | 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 98 | 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 99 | 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, 100 | 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 101 | 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, 102 | 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, 103 | 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 104 | 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, 105 | 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 106 | 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 107 | 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, 108 | 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 109 | 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 110 | 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 111 | 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, 112 | 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 113 | 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 114 | 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, 115 | 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 116 | 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, 117 | 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, 118 | 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 119 | 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, 120 | 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 121 | 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 122 | 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, 123 | 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, 124 | 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d 125 | }; 126 | 127 | #ifdef NFGM 128 | unsigned long 129 | UPDC32(b, c) 130 | unsigned long c; 131 | { 132 | return (cr3tab[((int)c ^ b) & 0xff] ^ ((c >> 8) & 0x00FFFFFF)); 133 | } 134 | 135 | #else 136 | 137 | #define UPDC32(b, c) (cr3tab[((int)c ^ b) & 0xff] ^ ((c >> 8) & 0x00FFFFFF)) 138 | #endif 139 | 140 | /* End of crctab.c */ 141 | -------------------------------------------------------------------------------- /gz: -------------------------------------------------------------------------------- 1 | exec zcommand "sz $*" 2 | -------------------------------------------------------------------------------- /mailer.rz: -------------------------------------------------------------------------------- 1 | RZ/SZ Version 3.XX License form (Worldwide) 2 | 3 | Remit To: Omen Technology INC FAX: 503-629-0665 4 | POB 4681 5 | Portland OR 97208-4681 6 | 7 | Unregistered users support hotline: 900-555-7836 at $4.69 per minute. 8 | 9 | Federal TAX ID #: 930858776 Oregon TAX ID #: 536565 10 | 11 | Payment of This License authorizes the installation and use of 12 | the "rz/sz" programs and/or derivative products derived from 13 | this code by compilation, inclusion, decompilation, or reverse 14 | engineering, on the specified computers. 15 | 16 | This license covers current and future Version 3.XX releases of the 17 | "rz" and "sz" programs. 18 | 19 | RZ/SZ Version 3.XX per user Quantity Discount Schedule, (per 20 | purchase). Each machine this software is used on has at least 21 | one user. The software must be registered according to the 22 | maximum number of users that may be using the software at one 23 | time. 24 | 25 | USERS REGISTRATION 26 | ----- ------------ 27 | 1-4 $99.00 INCLUDES SUPPORT 28 | 5-10 $149.00 INCLUDES SUPPORT 29 | 11-20 $199.00 INCLUDES SUPPORT 30 | 21+ $10.00 per user INCLUDES SUPPORT 31 | 32 | - $199 Educational campus site (college owned machines) 33 | 34 | 40-99 $500 each machine INCLUDES SUPPORT * (see below) 35 | - $1000 Other campus site INCLUDES SUPPORT ** (see below) 36 | 37 | "Machine" means a computer system with an arbitrary number of physically 38 | co-located processors sharing a common logical identity. 39 | 40 | $99 to $199 registrations include: 41 | Telephone and internet mail support for a specified contact individual 42 | 43 | $500 and $1000 registrations include: 44 | A copy of Unix Professional-YAM with rz/sz man page troff source 45 | 46 | Otherwise support is available by consulting contract. 47 | 48 | ____ RZ/SZ Version 3.XX Registrations ______ 49 | 50 | ____ OPTIONAL: Update disk (current rz/sz sources as on FTP site) 51 | 5.25 inch DOS $ 15.00 ______ 52 | 3.5 inch DOS $ 20.00 53 | (Contact Omen for other formats) 54 | 55 | ____ Shipping and Handling (Credit card orders) $ 5.00 ______ 56 | 57 | (Overseas air mailed at no extra charge) Total ______ 58 | Purchase orders less than $150 must be prepaid. 59 | 60 | 61 | Company Name ___________________________________________________________ 62 | 63 | Address ___________________________________________________________________ 64 | 65 | ___________________________________________________________________ 66 | 67 | ___________________________________________________________________ 68 | 69 | * Specified contact individual ____________________________________________ 70 | 71 | ** 2nd Specified contact individual _______________________________________ 72 | 73 | I hereby agree that the licenses paid for are equal to or greater than any 74 | number of simultaneous invocations of the Programs, and that additional 75 | licenses will be purchased prior to increasing the number of simultaneous 76 | invocations of the Programs. 77 | 78 | I agree that these Programs are made available in the hope it will be 79 | useful, BUT WITHOUT ANY WARRANTY OF ANY KIND OR LIABILITY FOR ANY DAMAGES 80 | OF ANY KIND. 81 | 82 | Name ___________________________________________________________________ 83 | 84 | Title ___________________________________________________________________ 85 | 86 | 87 | Signature __________________________________________________________________ 88 | 89 | Date ___________________ Phone (_____) ____________________ 90 | 91 | 92 | Payment by: Check (U.S. bank or branch) enclosed ( ) Visa/Mastercard ( ) 93 | 94 | Card # _____________________________________________ EXPIRES _____________ 95 | 96 | Name of Cardholder ________________________________________________________ 97 | 98 | -------------------------------------------------------------------------------- /minirb.c: -------------------------------------------------------------------------------- 1 | char* Version= "minirb 3.02 12-21-94 Copyright 1994 Omen Technology INC"; 2 | #include 3 | #include 4 | #include 5 | 6 | FILE *fout; long Bytesleft; int Blklen; char secbuf[1024]; char linbuf[1024]; 7 | int Lleft=0; jmp_buf tohere; 8 | 9 | void mode(n) { if (n) system("stty raw -echo"); else system("stty echo -raw"); } 10 | 11 | void alrm(c) { longjmp(tohere, -1); } 12 | 13 | void bibi(n) { 14 | mode(0); fprintf(stderr, "minirb: signal %d; exiting", n); exit(128+n); } 15 | 16 | main() { 17 | mode(1); if (signal(SIGINT, bibi) == SIG_IGN) { 18 | signal(SIGINT, SIG_IGN); signal(SIGKILL, SIG_IGN); } else { 19 | signal(SIGINT, bibi); signal(SIGKILL, bibi); } 20 | printf("%s\r\n\n\n", Version); 21 | printf("Send your files with a YAM/ZCOMM \042sb file ...\042 command\r\n"); 22 | wcreceive(); mode(0); exit(0); } 23 | 24 | wcreceive() { 25 | for (;;) { 26 | if (wcrxpn(secbuf) == -1) break; 27 | if (secbuf[0]==0) return; 28 | if (procheader(secbuf)== -1 || wcrx()== -1) break; } } 29 | 30 | wcrxpn(rpn) char *rpn; { register c; 31 | et_tu: 32 | sendline(025); Lleft=0; while ((c = wcgetsec(rpn)) != 0) { 33 | if (c == -10) { sendline(6); Lleft=0; rdln(2); goto et_tu; } return -1; } 34 | sendline(6); return 0; } 35 | 36 | wcrx() { register int sectnum, sectcurr, sendchar, cblklen; 37 | sectnum=0; sendchar=025; 38 | for (;;) { 39 | sendline(sendchar); Lleft=0; sectcurr=wcgetsec(secbuf); 40 | if (sectcurr==(sectnum+1 & 0377)) { 41 | sectnum++; cblklen = Bytesleft>Blklen ? Blklen:Bytesleft; 42 | fwrite(secbuf, cblklen, 1, fout); 43 | if ((Bytesleft-=cblklen) < 0) Bytesleft = 0; 44 | sendchar=6; } 45 | else if (sectcurr==(sectnum&0377)) sendchar=6; 46 | else if (sectcurr== -10) { fclose(fout); sendline(6); Lleft=0; return 0; } 47 | else return -1; } } 48 | 49 | wcgetsec(rxbuf) char *rxbuf; { 50 | register checksum, wcj, firstch; register char *p; int sectcurr, errors; 51 | for (errors=0; errors<15; errors++) { 52 | if ((firstch=rdln(5))==2) { Blklen=1024; goto get2; } 53 | if (firstch==1) { Blklen=128; 54 | get2: 55 | sectcurr=rdln(2); checksum=0; 56 | if ((sectcurr+(rdln(2)))==0377) { 57 | for (p=rxbuf,wcj=Blklen; --wcj>=0; ) { 58 | if ((firstch=rdln(2)) < 0) goto bilge; 59 | checksum += (*p++ = firstch); } 60 | if ((firstch=rdln(2)) < 0) goto bilge; 61 | if (((checksum-firstch)&0377)==0) return sectcurr; 62 | } } 63 | else if (firstch==4) return -10; 64 | else if (firstch==24) return -1; 65 | bilge: while(rdln(2)!= -2) ; 66 | sendline(025); Lleft=0; } 67 | return -1; } 68 | 69 | rdln(timeout) int timeout; { static char *cdq; 70 | if (--Lleft >= 0) return (*cdq++ & 0377); 71 | if (setjmp(tohere)) { Lleft = 0; return -2; } 72 | signal(SIGALRM, alrm); alarm(timeout); 73 | Lleft=read(0, cdq=linbuf, 1024); alarm(0); 74 | if (Lleft < 1) return -2; 75 | --Lleft; return (*cdq++ & 0377); } 76 | 77 | procheader(name) char *name; { register char *p; 78 | Bytesleft = 2000000000L; p = name + 1 + strlen(name); 79 | if (*p) sscanf(p, "%ld", &Bytesleft); 80 | if ((fout=fopen(name, "w")) == NULL) return -1; 81 | return 0; } 82 | 83 | sendline(c) { char d; d = c; write(1, &d, 1); } 84 | 85 | /* End of minirb.c */ 86 | -------------------------------------------------------------------------------- /minirb.doc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | MMMMIIIINNNNIIIIRRRRBBBB((((1111)))) OOOOmmmmeeeennnn TTTTeeeecccchhhhnnnnoooollllooooggggyyyy IIIINNNNCCCC ((((OOOOMMMMEEEENNNN TTTTEEEECCCCHHHHNNNNOOOOLLLLOOOOGGGGYYYY)))) MMMMIIIINNNNIIIIRRRRBBBB((((1111)))) 5 | 6 | 7 | 8 | NNNNAAAAMMMMEEEE 9 | minirb - Bootstrap YMODEM file receive 10 | By Chuck Forsberg Omen Technology INC 11 | "The High Reliability Communications Software" 12 | 13 | SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS 14 | mmmmiiiinnnniiiirrrrbbbb 15 | 16 | DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN 17 | _M_i_n_i_r_b receives one or more files with YMODEM file transfer 18 | protocol. _M_i_n_i_r_b was developed for use as a bootstrap to 19 | simplify uploading of the longer _r_z and _s_z programs, 20 | contained in the _r_z_s_z._z_i_p "zip" archive or the _r_z_s_z._s_h shell 21 | archive. 22 | 23 | SSSSEEEEEEEE AAAALLLLSSSSOOOO 24 | Professional-YAM manual 25 | 26 | NNNNOOOOTTTTEEEESSSS 27 | The source file _m_i_n_i_r_b._c has been ruthlessly pruned (3k, 85 28 | lines) to simplify uploading without benefit of an error 29 | correcting file transfer protocol. Do not reformat or add 30 | tabs to the source file as this will complicate uploading. 31 | 32 | _M_i_n_i_r_b uses the YMODEM header file length information to 33 | avoid storing extraneous characters on Unix. _M_i_n_i_r_b uses 8 34 | bit checksum which may not be compatible with some programs 35 | claiming to support YMODEM transfers. Please read the 36 | uploading suggestions in the "_F_i_l_e _T_r_a_n_s_f_e_r _B_a_s_i_c_s" 37 | (Reg.)chapter of the Professional-YAM or ZCOMM user's 38 | manual. 39 | 40 | _M_i_n_i_r_b does not remove any characters from uploaded files. 41 | The rz and sz source files supplied by Omen Technology do 42 | not contain extraneous characters that would affect Unix C 43 | compilers. Some PCDOS editors do add extraneous characters; 44 | It may be necessary to remove these with a Unix editor such 45 | as vi(1) or the undos(OMEN) program. 46 | 47 | _M_i_n_i_r_b calls the Unix stty(1) utility to set and reset raw 48 | tty mode, avoiding sgtty/BSD/termio/POSIX incompatibilities. 49 | 50 | 51 | SSSSEEEEEEEE AAAALLLLSSSSOOOO 52 | Omen Technology PPPPrrrrooooffffeeeessssssssiiiioooonnnnaaaallll----YYYYAAAAMMMM manual, undos(OMEN), 53 | crc(OMEN), wc(1). 54 | 55 | Minirb Copyright 1994 Omen Technology INC All Rights 56 | Reserved 57 | 58 | 59 | 60 | 61 | 62 | 63 | Page 1 (printed 4/21/95) 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /rbsb.c: -------------------------------------------------------------------------------- 1 | /* 2 | * V7/BSD HACKERS: SEE NOTES UNDER mode(2) !!! 3 | * 4 | * This file is #included so the main file can set parameters such as HOWMANY. 5 | * See the main files (rz.c/sz.c) for compile instructions. 6 | */ 7 | 8 | char *Copyr = "Copyright 1994 Omen Technology Inc All Rights Reserved"; 9 | 10 | #ifdef V7 11 | #include 12 | #include 13 | #define STAT 14 | #include 15 | #define OS "V7/BSD" 16 | char *getenv(), *ttyname(); 17 | #ifdef LLITOUT 18 | long Locmode; /* Saved "local mode" for 4.x BSD "new driver" */ 19 | long Locbit = LLITOUT; /* Bit SUPPOSED to disable output translations */ 20 | #include 21 | #endif 22 | #endif 23 | 24 | #ifdef USG 25 | #include 26 | #include 27 | #define STAT 28 | #include 29 | #define OS "SYS III/V" 30 | #define MODE2OK 31 | #include 32 | #ifndef OLD 33 | #include 34 | #endif 35 | #include 36 | #endif 37 | 38 | #ifdef POSIX 39 | #define USG 40 | #include 41 | #include 42 | #include 43 | #define STAT 44 | #include 45 | #define OS "POSIX" 46 | #include 47 | #include 48 | #include 49 | #ifndef READCHECK 50 | #ifndef FIONREAD 51 | #define SV 52 | #endif 53 | #endif 54 | #endif 55 | 56 | #ifdef OLD 57 | char *ttyname(); 58 | char *getenv(); 59 | #define time_t long 60 | #endif 61 | 62 | 63 | #ifdef T6K 64 | #include /* JPRadley: for the Tandy 6000 */ 65 | #endif 66 | 67 | #include 68 | 69 | #if HOWMANY > 255 70 | Howmany must be 255 or less 71 | #endif 72 | 73 | /* 74 | * Some systems (Venix, Coherent, Regulus) may not support tty raw mode 75 | * read(2) the same way as Unix. ONEREAD must be defined to force one 76 | * character reads for these systems. Added 7-01-84 CAF 77 | */ 78 | 79 | #define sendline(c) putc(c & 0377, Ttystream) 80 | #define xsendline(c) putc(c, Ttystream) 81 | 82 | char *Nametty; 83 | FILE *Ttystream; 84 | int Tty; 85 | char linbuf[HOWMANY]; 86 | char xXbuf[BUFSIZ]; 87 | int Lleft=0; /* number of characters in linbuf */ 88 | jmp_buf tohere; /* For the interrupt on RX timeout */ 89 | #ifdef ONEREAD 90 | /* Sorry, Regulus and some others don't work right in raw mode! */ 91 | int Readnum = 1; /* Number of bytes to ask for in read() from modem */ 92 | #else 93 | int Readnum = HOWMANY; /* Number of bytes to ask for in read() from modem */ 94 | #endif 95 | int Verbose=0; 96 | 97 | 98 | /* 99 | * The following uses an external rdchk() routine if available, 100 | * otherwise defines the function for BSD or fakes it for SYSV. 101 | */ 102 | 103 | #ifndef READCHECK 104 | #ifdef FIONREAD 105 | #define READCHECK 106 | /* 107 | * Return non 0 iff something to read from io descriptor f 108 | */ 109 | rdchk(f) 110 | { 111 | static long lf; 112 | 113 | ioctl(f, FIONREAD, &lf); 114 | return ((int) lf); 115 | } 116 | 117 | #else /* FIONREAD */ 118 | 119 | #ifdef SV 120 | #define READCHECK 121 | #include 122 | 123 | int checked = 0; 124 | /* 125 | * Nonblocking I/O is a bit different in System V, Release 2 126 | * Note: this rdchk vsn throws away a byte, OK for ZMODEM 127 | * sender because protocol design anticipates this problem. 128 | */ 129 | #define EATSIT 130 | rdchk(f) 131 | { 132 | int lf, savestat; 133 | static char bchecked; 134 | 135 | savestat = fcntl(f, F_GETFL) ; 136 | #ifdef O_NDELAY 137 | fcntl(f, F_SETFL, savestat | O_NDELAY) ; 138 | #else 139 | fcntl(f, F_SETFL, savestat | O_NONBLOCK) ; 140 | #endif 141 | lf = read(f, &bchecked, 1) ; 142 | fcntl(f, F_SETFL, savestat) ; 143 | checked = bchecked & 0377; /* force unsigned byte */ 144 | return(lf) ; 145 | } 146 | #endif 147 | #endif 148 | #endif 149 | 150 | 151 | struct { 152 | unsigned baudr; 153 | int speedcode; 154 | } speeds[] = { 155 | 110, B110, 156 | #ifdef B150 157 | 150, B150, 158 | #endif 159 | 300, B300, 160 | 600, B600, 161 | 1200, B1200, 162 | 2400, B2400, 163 | 4800, B4800, 164 | 9600, B9600, 165 | #ifdef B19200 166 | 19200, B19200, 167 | #endif 168 | #ifdef EXTA 169 | 19200, EXTA, 170 | #endif 171 | #ifdef B38400 172 | 38400, B38400, 173 | #endif 174 | #ifdef EXTB 175 | 38400, EXTB, 176 | #endif 177 | 0, 0 178 | }; 179 | static unsigned 180 | getspeed(code) 181 | { 182 | register n; 183 | 184 | for (n=0; speeds[n].baudr; ++n) 185 | if (speeds[n].speedcode == code) 186 | return speeds[n].baudr; 187 | if (code > 49) 188 | return ((unsigned)code); 189 | return 1; /* Assume fifo if ioctl failed */ 190 | } 191 | 192 | 193 | #ifdef ICANON 194 | #ifdef POSIX 195 | struct termios oldtty, tty; 196 | #else 197 | struct termio oldtty, tty; 198 | #endif 199 | #else 200 | struct sgttyb oldtty, tty; 201 | struct tchars oldtch, tch; 202 | #endif 203 | 204 | /* 205 | * mode(n) 206 | * 3: save old tty stat, set raw mode with flow control 207 | * 2: set XON/XOFF for sb/sz with ZMODEM or YMODEM-g 208 | * 1: save old tty stat, set raw mode 209 | * 0: restore original tty mode 210 | */ 211 | mode(n) 212 | { 213 | static did0 = FALSE; 214 | 215 | vfile("mode:%d", n); 216 | switch(n) { 217 | #ifdef USG 218 | case 2: /* Un-raw mode used by sz, sb when -g detected */ 219 | #ifdef POSIX 220 | if(!did0) 221 | (void) tcgetattr(Tty, &oldtty); 222 | #else 223 | if(!did0) 224 | (void) ioctl(Tty, TCGETA, &oldtty); 225 | #endif 226 | tty = oldtty; 227 | 228 | tty.c_iflag = BRKINT|IXON; 229 | 230 | tty.c_oflag = 0; /* Transparent output */ 231 | 232 | tty.c_cflag &= ~(PARENB|CSIZE); /* Disable parity */ 233 | tty.c_cflag |= (CREAD|CS8); /* Set character size = 8 */ 234 | 235 | 236 | #ifdef READCHECK 237 | tty.c_lflag = Zmodem ? 0 : ISIG; 238 | tty.c_cc[VINTR] = Zmodem ? -1:030; /* Interrupt char */ 239 | #else 240 | tty.c_lflag = ISIG; 241 | tty.c_cc[VINTR] = Zmodem ? 03:030; /* Interrupt char */ 242 | #endif 243 | tty.c_cc[VQUIT] = -1; /* Quit char */ 244 | #ifdef NFGVMIN 245 | tty.c_cc[VMIN] = 1; 246 | #else 247 | tty.c_cc[VMIN] = 3; /* This many chars satisfies reads */ 248 | #endif 249 | tty.c_cc[VTIME] = 1; /* or in this many tenths of seconds */ 250 | 251 | #ifdef POSIX 252 | (void) tcsetattr(Tty, TCSADRAIN, &tty); 253 | #else 254 | (void) ioctl(Tty, TCSETAW, &tty); 255 | #endif 256 | did0 = TRUE; 257 | return OK; 258 | case 1: 259 | case 3: 260 | #ifdef POSIX 261 | if(!did0) 262 | (void) tcgetattr(Tty, &oldtty); 263 | #else 264 | if(!did0) 265 | (void) ioctl(Tty, TCGETA, &oldtty); 266 | #endif 267 | tty = oldtty; 268 | 269 | tty.c_iflag = n==3 ? (IXON|IXOFF) : IXOFF; 270 | 271 | tty.c_lflag = 0; 272 | 273 | tty.c_oflag = 0; 274 | 275 | tty.c_cflag &= ~(CSIZE|PARENB); /* disable parity */ 276 | tty.c_cflag |= CS8; /* Set character size = 8 */ 277 | #ifdef NFGVMIN 278 | tty.c_cc[VMIN] = 1; /* This many chars satisfies reads */ 279 | #else 280 | tty.c_cc[VMIN] = HOWMANY; /* This many chars satisfies reads */ 281 | #endif 282 | tty.c_cc[VTIME] = 1; /* or in this many tenths of seconds */ 283 | #ifdef POSIX 284 | (void) tcsetattr(Tty, TCSADRAIN, &tty); 285 | #else 286 | (void) ioctl(Tty, TCSETAW, &tty); 287 | #endif 288 | did0 = TRUE; 289 | #ifdef POSIX 290 | Baudrate = getspeed(cfgetospeed(&tty)); 291 | #else 292 | Baudrate = getspeed(tty.c_cflag & CBAUD); 293 | #endif 294 | vfile("Baudrate = %u\n", Baudrate); 295 | return OK; 296 | #endif 297 | #ifdef V7 298 | /* 299 | * NOTE: this should transmit all 8 bits and at the same time 300 | * respond to XOFF/XON flow control. If no FIONREAD or other 301 | * rdchk() alternative, also must respond to INTRRUPT char 302 | * This doesn't work with V7. It should work with LLITOUT, 303 | * but LLITOUT was broken on the machine I tried it on. 304 | */ 305 | case 2: /* Un-raw mode used by sz, sb when -g detected */ 306 | if(!did0) { 307 | ioctl(Tty, TIOCEXCL, 0); 308 | ioctl(Tty, TIOCGETP, &oldtty); 309 | ioctl(Tty, TIOCGETC, &oldtch); 310 | #ifdef LLITOUT 311 | ioctl(Tty, TIOCLGET, &Locmode); 312 | #endif 313 | } 314 | tty = oldtty; 315 | tch = oldtch; 316 | #ifdef READCHECK 317 | tch.t_intrc = Zmodem ? -1:030; /* Interrupt char */ 318 | #else 319 | tch.t_intrc = Zmodem ? 03:030; /* Interrupt char */ 320 | #endif 321 | tty.sg_flags |= (ODDP|EVENP|CBREAK); 322 | tty.sg_flags &= ~(ALLDELAY|CRMOD|ECHO|LCASE); 323 | ioctl(Tty, TIOCSETP, &tty); 324 | ioctl(Tty, TIOCSETC, &tch); 325 | #ifdef LLITOUT 326 | ioctl(Tty, TIOCLBIS, &Locbit); 327 | #else 328 | bibi(99); /* un-raw doesn't work w/o lit out */ 329 | #endif 330 | did0 = TRUE; 331 | return OK; 332 | case 1: 333 | case 3: 334 | if(!did0) { 335 | ioctl(Tty, TIOCEXCL, 0); 336 | ioctl(Tty, TIOCGETP, &oldtty); 337 | ioctl(Tty, TIOCGETC, &oldtch); 338 | #ifdef LLITOUT 339 | ioctl(Tty, TIOCLGET, &Locmode); 340 | #endif 341 | } 342 | tty = oldtty; 343 | tty.sg_flags |= (RAW|TANDEM); 344 | tty.sg_flags &= ~ECHO; 345 | ioctl(Tty, TIOCSETP, &tty); 346 | did0 = TRUE; 347 | Baudrate = getspeed(tty.sg_ospeed); 348 | return OK; 349 | #endif 350 | case 0: 351 | if(!did0) 352 | return ERROR; 353 | #ifdef USG 354 | #ifdef POSIX 355 | (void) tcdrain(Tty); /* Wait for output to drain */ 356 | (void) tcflush(Tty, TCIFLUSH); /* Flush input queue */ 357 | (void) tcsetattr(Tty, TCSADRAIN, &oldtty); /* Restore */ 358 | (void) tcflow(Tty, TCOON); /* Restart output */ 359 | #else 360 | (void) ioctl(Tty, TCSBRK, 1); /* Wait for output to drain */ 361 | (void) ioctl(Tty, TCFLSH, 1); /* Flush input queue */ 362 | (void) ioctl(Tty, TCSETAW, &oldtty); /* Restore modes */ 363 | (void) ioctl(Tty, TCXONC,1); /* Restart output */ 364 | #endif 365 | #endif 366 | #ifdef V7 367 | ioctl(Tty, TIOCSETP, &oldtty); 368 | ioctl(Tty, TIOCSETC, &oldtch); 369 | ioctl(Tty, TIOCNXCL, 0); 370 | #ifdef LLITOUT 371 | ioctl(Tty, TIOCLSET, &Locmode); 372 | #endif 373 | #endif 374 | 375 | return OK; 376 | default: 377 | return ERROR; 378 | } 379 | } 380 | 381 | sendbrk() 382 | { 383 | #ifdef V7 384 | #ifdef TIOCSBRK 385 | #define CANBREAK 386 | sleep(1); 387 | ioctl(Tty, TIOCSBRK, 0); 388 | sleep(1); 389 | ioctl(Tty, TIOCCBRK, 0); 390 | #endif 391 | #endif 392 | #ifdef USG 393 | #define CANBREAK 394 | #ifdef POSIX 395 | tcsendbreak(Tty, 200); 396 | #else 397 | ioctl(Tty, TCSBRK, 0); 398 | #endif 399 | #endif 400 | } 401 | 402 | /* Initialize tty device for serial file xfer */ 403 | inittty() 404 | { 405 | if ((Nametty = ttyname(2)) && *Nametty) { 406 | Tty = open(Nametty, 2); 407 | } else { 408 | Tty = open(Nametty = "/dev/tty", 2); 409 | } 410 | 411 | if (Tty <= 0) { 412 | perror(Nametty); exit(2); 413 | } 414 | Ttystream = fdopen(Tty, "w"); 415 | } 416 | 417 | flushmoc() 418 | { 419 | fflush(Ttystream); 420 | } 421 | flushmo() 422 | { 423 | fflush(Ttystream); 424 | } 425 | 426 | /* 427 | * This version of readline is reasoably well suited for 428 | * reading many characters. 429 | * 430 | * timeout is in tenths of seconds 431 | */ 432 | void 433 | alrm(c) 434 | { 435 | longjmp(tohere, -1); 436 | } 437 | readline(timeout) 438 | int timeout; 439 | { 440 | register n; 441 | static char *cdq; /* pointer for removing chars from linbuf */ 442 | 443 | if (--Lleft >= 0) { 444 | if (Verbose > 8) { 445 | fprintf(stderr, "%02x ", *cdq&0377); 446 | } 447 | return (*cdq++ & 0377); 448 | } 449 | n = timeout/10; 450 | if (n < 2) 451 | n = 2; 452 | if (Verbose > 5) 453 | fprintf(stderr, "Calling read: alarm=%d Readnum=%d ", 454 | n, Readnum); 455 | if (setjmp(tohere)) { 456 | #ifdef TIOCFLUSH 457 | /* ioctl(Tty, TIOCFLUSH, 0); */ 458 | #endif 459 | Lleft = 0; 460 | if (Verbose>1) 461 | fprintf(stderr, "Readline:TIMEOUT\n"); 462 | return TIMEOUT; 463 | } 464 | signal(SIGALRM, alrm); alarm(n); 465 | errno = 0; 466 | Lleft=read(Tty, cdq=linbuf, Readnum); 467 | alarm(0); 468 | if (Verbose > 5) { 469 | fprintf(stderr, "Read returned %d bytes errno=%d\n", 470 | Lleft, errno); 471 | } 472 | if (Lleft < 1) 473 | return TIMEOUT; 474 | if (Verbose > 8) { 475 | for (n = Lleft; --n >= 0; ) { 476 | fprintf(stderr, "%02x ", *cdq&0377); 477 | } 478 | fprintf(stderr, "\n"); 479 | } 480 | --Lleft; 481 | return (*cdq++ & 0377); 482 | } 483 | 484 | 485 | 486 | /* 487 | * Purge the modem input queue of all characters 488 | */ 489 | purgeline() 490 | { 491 | Lleft = 0; 492 | #ifdef USG 493 | #ifdef POSIX 494 | tcflush(Tty, 0); 495 | #else 496 | ioctl(Tty, TCFLSH, 0); 497 | #endif 498 | #else 499 | lseek(Tty, 0L, 2); 500 | #endif 501 | } 502 | 503 | 504 | /* send cancel string to get the other end to shut up */ 505 | canit() 506 | { 507 | static char canistr[] = { 508 | 24,24,24,24,24,24,24,24,24,24,8,8,8,8,8,8,8,8,8,8,0 509 | }; 510 | 511 | zmputs(canistr); 512 | Lleft=0; /* Do read next time ... */ 513 | } 514 | 515 | /* 516 | * Send a string to the modem, processing for \336 (sleep 1 sec) 517 | * and \335 (break signal) 518 | */ 519 | zmputs(s) 520 | char *s; 521 | { 522 | register c; 523 | 524 | while (*s) { 525 | switch (c = *s++) { 526 | case '\336': 527 | sleep(1); continue; 528 | case '\335': 529 | sendbrk(); continue; 530 | default: 531 | sendline(c); 532 | } 533 | } 534 | flushmo(); 535 | } 536 | 537 | 538 | /* VARARGS1 */ 539 | vfile(f, a, b, c, d) 540 | char *f; 541 | long a, b, c, d; 542 | { 543 | if (Verbose > 2) { 544 | fprintf(stderr, f, a, b, c, d); 545 | fprintf(stderr, "\n"); 546 | } 547 | } 548 | 549 | /* End of rbsb.c */ 550 | -------------------------------------------------------------------------------- /rz.c: -------------------------------------------------------------------------------- 1 | #define VERSION "3.48 01-27-98" 2 | #define PUBDIR "/usr/spool/uucppublic" 3 | 4 | /* 5 | * 6 | * rz.c By Chuck Forsberg 7 | * Copyright 1997 Omen Technology Inc All Rights Reserved 8 | * 9 | * A program for Unix to receive files and commands from computers running 10 | * Professional-YAM, PowerCom, YAM, IMP, or programs supporting XMODEM. 11 | * rz uses Unix buffered input to reduce wasted CPU time. 12 | * 13 | * 14 | ********************************************************************* 15 | ********************************************************************* 16 | * 17 | * 18 | * This version implements numerous enhancements including ZMODEM 19 | * Run Length Encoding and variable length headers. These 20 | * features were not funded by the original Telenet development 21 | * contract. 22 | * 23 | * 24 | * This software may be freely used for educational (didactic 25 | * only) purposes. "Didactic" means it is used as a study item 26 | * in a course teaching the workings of computer protocols. 27 | * 28 | * This software may also be freely used to support file transfer 29 | * operations to or from duly licensed Omen Technology products. 30 | * This includes DSZ, GSZ, ZCOMM, Professional-YAM and PowerCom. 31 | * Institutions desiring to use rz/sz this way should add the 32 | * following to the sz compile line: -DCOMPL 33 | * Programs based on stolen or public domain ZMODEM materials are 34 | * not included. Use with other commercial or shareware programs 35 | * (Crosstalk, Procomm, etc.) REQUIRES REGISTRATION. 36 | * 37 | * 38 | * Any programs which incorporate part or all of this code must be 39 | * provided in source form with this notice intact except by 40 | * prior written permission from Omen Technology Incorporated. 41 | * This includes compiled executables of this program. 42 | * 43 | * The .doc files and the file "mailer.rz" must also be included. 44 | * 45 | * Use of this software for commercial or administrative purposes 46 | * except when exclusively limited to interfacing Omen Technology 47 | * products requires license payment of $20.00 US per user 48 | * (less in quantity, see mailer.rz). Use of this code by 49 | * inclusion, decompilation, reverse engineering or any other means 50 | * constitutes agreement to these conditions and acceptance of 51 | * liability to license the materials and payment of reasonable 52 | * legal costs necessary to enforce this license agreement. 53 | * 54 | * 55 | * Omen Technology Inc 56 | * Post Office Box 4681 57 | * Portland OR 97208 58 | * 59 | * This code is made available in the hope it will be useful, 60 | * BUT WITHOUT ANY WARRANTY OF ANY KIND OR LIABILITY FOR ANY 61 | * DAMAGES OF ANY KIND. 62 | * 63 | * 64 | * -DMD may be added to compiler command line to compile in 65 | * Directory-creating routines from Public Domain TAR by John Gilmore 66 | * 67 | * USG UNIX (3.0) ioctl conventions courtesy Jeff Martin 68 | */ 69 | 70 | char *Copyrrz = "Copyright 1997 Omen Technology Inc All Rights Reserved"; 71 | 72 | 73 | #define LOGFILE "/tmp/rzlog" 74 | #define LOGFILE2 "rzlog" 75 | #include 76 | #include 77 | #include 78 | #include 79 | extern int errno; 80 | 81 | #define OK 0 82 | #define FALSE 0 83 | #define TRUE 1 84 | #define ERROR (-1) 85 | 86 | /* 87 | * Max value for HOWMANY is 255. 88 | * A larger value reduces system overhead but may evoke kernel bugs. 89 | */ 90 | #ifndef HOWMANY 91 | #define HOWMANY 96 92 | #endif 93 | 94 | /* Ward Christensen / CP/M parameters - Don't change these! */ 95 | #define ENQ 005 96 | #define CAN ('X'&037) 97 | #define XOFF ('s'&037) 98 | #define XON ('q'&037) 99 | #define SOH 1 100 | #define STX 2 101 | #define EOT 4 102 | #define ACK 6 103 | #define NAK 025 104 | #define CPMEOF 032 105 | #define WANTCRC 0103 /* send C not NAK to get crc not checksum */ 106 | #define TIMEOUT (-2) 107 | #define RCDO (-3) 108 | #define GCOUNT (-4) 109 | #define ERRORMAX 5 110 | #define RETRYMAX 5 111 | #define WCEOT (-10) 112 | #define PATHLEN 257 /* ready for 4.2 bsd ? */ 113 | #define UNIXFILE 0xF000 /* The S_IFMT file mask bit for stat */ 114 | 115 | int Zmodem=0; /* ZMODEM protocol requested */ 116 | int Nozmodem = 0; /* If invoked as "rb" */ 117 | unsigned Baudrate = 9600; 118 | 119 | 120 | #include "rbsb.c" /* most of the system dependent stuff here */ 121 | #include "crctab.c" 122 | char endmsg[90] = {0}; /* Possible message to display on exit */ 123 | char Zsendmask[33]; /* Additional control chars to mask */ 124 | 125 | char *substr(); 126 | FILE *fout; 127 | 128 | /* 129 | * Routine to calculate the free bytes on the current file system 130 | * ~0 means many free bytes (unknown) 131 | */ 132 | long getfree() 133 | { 134 | return(2147483647); /* many free bytes ... */ 135 | } 136 | 137 | int Lastrx; 138 | long rxbytes; 139 | int Crcflg; 140 | int Firstsec; 141 | int Eofseen; /* indicates cpm eof (^Z) has been received */ 142 | int errors; 143 | int Restricted=0; /* restricted; no /.. or ../ in filenames */ 144 | 145 | #define DEFBYTL 2000000000L /* default rx file size */ 146 | long Bytesleft; /* number of bytes of incoming file left */ 147 | long Modtime; /* Unix style mod time for incoming file */ 148 | int Filemode; /* Unix style mode for incoming file */ 149 | long Totalleft; 150 | long Filesleft; 151 | char Pathname[PATHLEN]; 152 | char *Progname; /* the name by which we were called */ 153 | 154 | int Batch=0; 155 | int Thisbinary; /* current file is to be received in bin mode */ 156 | int Rxbinary=FALSE; /* receive all files in bin mode */ 157 | int Rxascii=FALSE; /* receive files in ascii (translate) mode */ 158 | int Blklen; /* record length of received packets */ 159 | 160 | #ifdef SEGMENTS 161 | int chinseg = 0; /* Number of characters received in this data seg */ 162 | char secbuf[1+(SEGMENTS+1)*1024]; 163 | #else 164 | char secbuf[1025]; 165 | #endif 166 | 167 | 168 | time_t timep[2]; 169 | char Lzmanag; /* Local file management request */ 170 | char Lzconv; /* Local ZMODEM file conversion request */ 171 | char zconv; /* ZMODEM file conversion request */ 172 | char zmanag; /* ZMODEM file management request */ 173 | char ztrans; /* ZMODEM file transport request */ 174 | int Zctlesc; /* Encode control characters */ 175 | int Zrwindow = 1400; /* RX window size (controls garbage count) */ 176 | 177 | /* 178 | * Log an error 179 | */ 180 | void 181 | zperr1(s,p,u) 182 | char *s, *p, *u; 183 | { 184 | if (Verbose <= 0) 185 | return; 186 | fprintf(stderr, "Retry %d: ", errors); 187 | fprintf(stderr, s); 188 | fprintf(stderr, "\n"); 189 | } 190 | 191 | void 192 | zperr2(s,p,u) 193 | char *s, *p, *u; 194 | { 195 | if (Verbose <= 0) 196 | return; 197 | fprintf(stderr, "Retry %d: ", errors); 198 | fprintf(stderr, s, p); 199 | fprintf(stderr, "\n"); 200 | } 201 | 202 | void 203 | zperr3(s,p,u) 204 | char *s, *p, *u; 205 | { 206 | if (Verbose <= 0) 207 | return; 208 | fprintf(stderr, "Retry %d: ", errors); 209 | fprintf(stderr, s, p, u); 210 | fprintf(stderr, "\n"); 211 | } 212 | 213 | #include "zm.c" 214 | #include "zmr.c" 215 | 216 | int tryzhdrtype=ZRINIT; /* Header type to send corresponding to Last rx close */ 217 | 218 | /* called by signal interrupt or terminate to clean things up */ 219 | void 220 | bibi(n) 221 | { 222 | if (Zmodem) 223 | zmputs(Attn); 224 | canit(); mode(0); 225 | fprintf(stderr, "rz: caught signal %d; exiting", n); 226 | exit(3); 227 | } 228 | 229 | main(argc, argv) 230 | char *argv[]; 231 | { 232 | register char *cp; 233 | register npats; 234 | char *virgin, **patts; 235 | int exitcode = 0; 236 | 237 | Rxtimeout = 100; 238 | setbuf(stderr, NULL); 239 | if (((cp = getenv("RESTRICTED")) != 0) && *cp == '1') 240 | Restricted=TRUE; 241 | if ((cp=getenv("SHELL")) && (substr(cp, "rsh") || substr(cp, "rksh"))) 242 | Restricted=TRUE; 243 | 244 | chkinvok(virgin=argv[0]); 245 | inittty(); 246 | npats = 0; 247 | while (--argc) { 248 | cp = *++argv; 249 | if (*cp == '-') { 250 | ++cp; 251 | while( *cp) { 252 | if (isdigit(*cp)) { 253 | ++cp; continue; 254 | } 255 | switch(*cp++) { 256 | case '\\': 257 | *cp = toupper(*cp); continue; 258 | case 'a': 259 | if (!Batch || Nozmodem) 260 | Rxascii=TRUE; 261 | else 262 | usage(); 263 | break; 264 | case 't': 265 | if (isdigit(*cp)) 266 | Rxtimeout = atoi(cp); 267 | else { 268 | if (--argc < 1) 269 | usage(); 270 | Rxtimeout = atoi(*++argv); 271 | } 272 | if (Rxtimeout<1 || Rxtimeout>1000) 273 | usage(); 274 | break; 275 | case 'w': 276 | if (isdigit(*cp)) 277 | Zrwindow = atoi(cp); 278 | else { 279 | if (--argc < 1) 280 | usage(); 281 | Zrwindow = atoi(*++argv); 282 | } 283 | break; 284 | case 'v': 285 | ++Verbose; break; 286 | case 'y': 287 | Lzmanag = ZMCLOB; 288 | break; 289 | default: 290 | usage(); 291 | } 292 | } 293 | } 294 | else if ( !npats && argc>0) { 295 | if (argv[0][0]) { 296 | npats=argc; 297 | patts=argv; 298 | } 299 | } 300 | } 301 | if (npats > 1) 302 | usage(); 303 | if (Batch && npats) 304 | usage(); 305 | if (Verbose) { 306 | if (freopen(LOGFILE, "a", stderr)==NULL) 307 | if (freopen(LOGFILE2, "a", stderr)==NULL) { 308 | fprintf(stderr, "Can't open log file!\n"); 309 | exit(2); 310 | } 311 | setbuf(stderr, NULL); 312 | fprintf(stderr, "argv[0]=%s Progname=%s\n", virgin, Progname); 313 | } 314 | vfile("%s %s for %s tty=%s\n", Progname, VERSION, OS, Nametty); 315 | mode(1); 316 | if (signal(SIGINT, bibi) == SIG_IGN) { 317 | signal(SIGINT, SIG_IGN); signal(SIGKILL, SIG_IGN); 318 | } 319 | else { 320 | signal(SIGINT, bibi); signal(SIGKILL, bibi); 321 | } 322 | signal(SIGTERM, bibi); 323 | if (wcreceive(npats, patts)==ERROR) { 324 | exitcode=1; 325 | canit(); 326 | } 327 | if (exitcode && !Zmodem) /* bellow again with all thy might. */ 328 | canit(); 329 | if (endmsg[0]) 330 | fprintf(stderr, " %s: %s\r\n", Progname, endmsg); 331 | fprintf(stderr, "%s %s finished.\r\n", Progname, VERSION); 332 | fflush(stderr); 333 | #ifndef REGISTERED 334 | /* Removing or disabling this code without registering is theft */ 335 | if (!Usevhdrs) { 336 | fprintf(stderr, "\n\n\n**** UNREGISTERED COPY *****\r\n"); 337 | fprintf(stderr, "Please read the License Agreement in rz.doc\r\n"); 338 | fflush(stderr); 339 | sleep(10); 340 | } 341 | #endif 342 | mode(0); 343 | if(exitcode) 344 | exit(1); 345 | exit(0); 346 | /* NOTREACHED */ 347 | } 348 | 349 | 350 | usage() 351 | { 352 | fprintf(stderr, 353 | "Receive Files and Commands with ZMODEM/YMODEM/XMODEM Protocol\n\n"); 354 | fprintf(stderr,"Usage: rz [-v] [-wN] [-tT] (ZMODEM)\n"); 355 | fprintf(stderr,"or rb [-avy] [-tT] (YMODEM)\n"); 356 | fprintf(stderr,"or rc [-avy] [-tT] file (XMODEM-CRC)\n"); 357 | fprintf(stderr,"or rx [-avy] [-tT] file (XMODEM)\n\n"); 358 | fprintf(stderr, 359 | "Supports the following incoming ZMODEM options given to the sending program:\n\ 360 | compression (-Z), binary (-b), ASCII CR/LF>NL (-a), newer(-n),\n\ 361 | newer+longer(-N), protect (-p), Crash Recovery (-r),\n\ 362 | clobber (-y), match+clobber (-Y), and append (-+).\n\n"); 363 | fprintf(stderr,"%s %s for %s by Chuck Forsberg, Omen Technology INC\n", 364 | Progname, VERSION, OS); 365 | fprintf(stderr, "\t\t\042The High Reliability Software\042\n\n"); 366 | fprintf(stderr,"Copyright (c) 1997 Omen Technology INC All Rights Reserved\n"); 367 | fprintf(stderr, 368 | "See rz.doc and README for option descriptions and licensing information.\n\n"); 369 | fprintf(stderr, 370 | "This program is designed to talk to terminal programs,\nnot to be called by one.\n"); 371 | #ifndef REGISTERED 372 | fprintf(stderr, "\n\n\n **** UNREGISTERED COPY *****\r\n"); 373 | fprintf(stderr, "Please read the License Agreement in rz.doc\r\n"); 374 | #endif 375 | exit(2); 376 | } 377 | 378 | /* 379 | * Let's receive something already. 380 | */ 381 | 382 | char *rbmsg = "%s ready. Type \"%s file ...\" to your modem program\n\r"; 383 | 384 | wcreceive(argc, argp) 385 | char **argp; 386 | { 387 | register c; 388 | 389 | if (Batch || argc==0) { 390 | Crcflg=1; 391 | fprintf(stderr, rbmsg, Progname, Nozmodem?"sb":"sz"); 392 | if (c=tryz()) { 393 | if (c == ZCOMPL) 394 | return OK; 395 | if (c == ERROR) 396 | goto fubar; 397 | c = rzfiles(); 398 | if (c) 399 | goto fubar; 400 | } else { 401 | for (;;) { 402 | if (wcrxpn(secbuf)== ERROR) 403 | goto fubar; 404 | if (secbuf[0]==0) 405 | return OK; 406 | if (procheader(secbuf)) 407 | goto fubar; 408 | if (wcrx()==ERROR) 409 | goto fubar; 410 | } 411 | } 412 | } else { 413 | Bytesleft = DEFBYTL; Filemode = 0; Modtime = 0L; 414 | 415 | procheader(""); strcpy(Pathname, *argp); checkpath(Pathname); 416 | fprintf(stderr, "\nrz: ready to receive %s\r\n", Pathname); 417 | if ((fout=fopen(Pathname, "w")) == NULL) 418 | return ERROR; 419 | if (wcrx()==ERROR) 420 | goto fubar; 421 | } 422 | return OK; 423 | fubar: 424 | canit(); 425 | Modtime = 1; 426 | if (fout) 427 | fclose(fout); 428 | if (Restricted) { 429 | unlink(Pathname); 430 | fprintf(stderr, "\r\nrz: %s removed.\r\n", Pathname); 431 | } 432 | return ERROR; 433 | } 434 | 435 | 436 | /* 437 | * Fetch a pathname from the other end as a C ctyle ASCIZ string. 438 | * Length is indeterminate as long as less than Blklen 439 | * A null string represents no more files (YMODEM) 440 | */ 441 | wcrxpn(rpn) 442 | char *rpn; /* receive a pathname */ 443 | { 444 | register c; 445 | 446 | purgeline(); 447 | 448 | et_tu: 449 | Firstsec=TRUE; Eofseen=FALSE; 450 | sendline(Crcflg?WANTCRC:NAK); flushmo(); 451 | Lleft=0; /* Do read next time ... */ 452 | switch (c = wcgetsec(rpn, 100)) { 453 | case WCEOT: 454 | zperr2( "Pathname fetch returned %d", c); 455 | sendline(ACK); flushmo(); 456 | Lleft=0; /* Do read next time ... */ 457 | readline(1); 458 | goto et_tu; 459 | case 0: 460 | sendline(ACK); flushmo(); return OK; 461 | default: 462 | return ERROR; 463 | } 464 | } 465 | 466 | /* 467 | * Adapted from CMODEM13.C, written by 468 | * Jack M. Wierda and Roderick W. Hart 469 | */ 470 | 471 | wcrx() 472 | { 473 | register int sectnum, sectcurr; 474 | register char sendchar; 475 | int cblklen; /* bytes to dump this block */ 476 | 477 | Firstsec=TRUE;sectnum=0; Eofseen=FALSE; 478 | sendchar=Crcflg?WANTCRC:NAK; 479 | 480 | for (;;) { 481 | sendline(sendchar); /* send it now, we're ready! */ 482 | flushmo(); 483 | Lleft=0; /* Do read next time ... */ 484 | sectcurr=wcgetsec(secbuf, (sectnum&0177)?50:130); 485 | if (sectcurr==(sectnum+1 &0377)) { 486 | sectnum++; 487 | cblklen = Bytesleft>Blklen ? Blklen:Bytesleft; 488 | if (putsec(secbuf, cblklen)==ERROR) 489 | return ERROR; 490 | if ((Bytesleft-=cblklen) < 0) 491 | Bytesleft = 0; 492 | sendchar=ACK; 493 | } 494 | else if (sectcurr==(sectnum&0377)) { 495 | zperr1( "Received dup Sector"); 496 | sendchar=ACK; 497 | } 498 | else if (sectcurr==WCEOT) { 499 | if (closeit()) 500 | return ERROR; 501 | sendline(ACK); flushmo(); 502 | Lleft=0; /* Do read next time ... */ 503 | return OK; 504 | } 505 | else if (sectcurr==ERROR) 506 | return ERROR; 507 | else { 508 | zperr1( "Sync Error"); 509 | return ERROR; 510 | } 511 | } 512 | /* NOTREACHED */ 513 | } 514 | 515 | /* 516 | * Wcgetsec fetches a Ward Christensen type sector. 517 | * Returns sector number encountered or ERROR if valid sector not received, 518 | * or CAN CAN received 519 | * or WCEOT if eot sector 520 | * time is timeout for first char, set to 4 seconds thereafter 521 | ***************** NO ACK IS SENT IF SECTOR IS RECEIVED OK ************** 522 | * (Caller must do that when he is good and ready to get next sector) 523 | */ 524 | 525 | wcgetsec(rxbuf, maxtime) 526 | char *rxbuf; 527 | int maxtime; 528 | { 529 | register checksum, wcj, firstch; 530 | register unsigned short oldcrc; 531 | register char *p; 532 | int sectcurr; 533 | 534 | for (Lastrx=errors=0; errors=0; ) { 546 | if ((firstch=readline(1)) < 0) 547 | goto bilge; 548 | oldcrc=updcrc(firstch, oldcrc); 549 | checksum += (*p++ = firstch); 550 | } 551 | if ((firstch=readline(1)) < 0) 552 | goto bilge; 553 | if (Crcflg) { 554 | oldcrc=updcrc(firstch, oldcrc); 555 | if ((firstch=readline(1)) < 0) 556 | goto bilge; 557 | oldcrc=updcrc(firstch, oldcrc); 558 | if (oldcrc & 0xFFFF) 559 | zperr1( "CRC"); 560 | else { 561 | Firstsec=FALSE; 562 | return sectcurr; 563 | } 564 | } 565 | else if (((checksum-firstch)&0377)==0) { 566 | Firstsec=FALSE; 567 | return sectcurr; 568 | } 569 | else 570 | zperr1( "Checksum"); 571 | } 572 | else 573 | zperr1("Sector number garbled"); 574 | } 575 | /* make sure eot really is eot and not just mixmash */ 576 | else if (firstch==EOT && Lleft==0) 577 | return WCEOT; 578 | else if (firstch==CAN) { 579 | if (Lastrx==CAN) { 580 | zperr1( "Sender CANcelled"); 581 | return ERROR; 582 | } else { 583 | Lastrx=CAN; 584 | continue; 585 | } 586 | } 587 | else if (firstch==TIMEOUT) { 588 | if (Firstsec) 589 | goto humbug; 590 | bilge: 591 | zperr1( "TIMEOUT"); 592 | } 593 | else 594 | zperr1( "Got 0%o sector header", firstch); 595 | 596 | humbug: 597 | Lastrx=0; 598 | while(readline(1)!=TIMEOUT) 599 | ; 600 | if (Firstsec) { 601 | sendline(Crcflg?WANTCRC:NAK); flushmo(); 602 | Lleft=0; /* Do read next time ... */ 603 | } else { 604 | maxtime=40; sendline(NAK); flushmo(); 605 | Lleft=0; /* Do read next time ... */ 606 | } 607 | } 608 | /* try to stop the bubble machine. */ 609 | canit(); 610 | return ERROR; 611 | } 612 | 613 | 614 | /* 615 | * Process incoming file information header 616 | * Returns 0 for success, other codes for errors 617 | * or skip conditions. 618 | */ 619 | procheader(name) 620 | char *name; 621 | { 622 | register char *openmode, *p; 623 | static dummy; 624 | struct stat f; 625 | 626 | /* set default parameters and overrides */ 627 | openmode = "w"; 628 | Thisbinary = (!Rxascii) || Rxbinary; 629 | if (zconv == ZCBIN && Lzconv != ZCRESUM) 630 | Lzconv = zconv; /* Remote Binary override */ 631 | if (Lzconv) 632 | zconv = Lzconv; 633 | if (Lzmanag) 634 | zmanag = Lzmanag; 635 | 636 | /* 637 | * Process ZMODEM remote file management requests 638 | */ 639 | if (!Rxbinary && zconv == ZCNL) /* Remote ASCII override */ 640 | Thisbinary = 0; 641 | if (zconv == ZCBIN) /* Remote Binary override */ 642 | Thisbinary = TRUE; 643 | else if (zmanag == ZMAPND) 644 | openmode = "a"; 645 | 646 | Bytesleft = DEFBYTL; Filemode = 0; Modtime = 0L; 647 | 648 | if (!name || !*name) 649 | return 0; 650 | 651 | p = name + 1 + strlen(name); 652 | if (*p) { /* file coming from Unix or DOS system */ 653 | sscanf(p, "%ld%lo%o%lo%d%ld%d%d", 654 | &Bytesleft, &Modtime, &Filemode, 655 | &dummy, &Filesleft, &Totalleft, &dummy, &dummy); 656 | if (Filemode & UNIXFILE) 657 | ++Thisbinary; 658 | if (Verbose) { 659 | fprintf(stderr, "Incoming: %s %ld %lo %o\n", 660 | name, Bytesleft, Modtime, Filemode); 661 | fprintf(stderr, "YMODEM header: %s\n", p); 662 | } 663 | } 664 | 665 | 666 | else { /* File coming from CP/M system */ 667 | for (p=name; *p; ++p) /* change / to _ */ 668 | if ( *p == '/') 669 | *p = '_'; 670 | 671 | if ( *--p == '.') /* zap trailing period */ 672 | *p = 0; 673 | } 674 | 675 | strcpy(Pathname, name); 676 | checkpath(name); 677 | 678 | if (*name && stat(name, &f)!= -1) { 679 | zmanag &= ZMMASK; 680 | if (zmanag==ZMPROT) 681 | goto skipfile; 682 | vfile("Current %s is %ld %lo", name, f.st_size, f.st_mtime); 683 | if (Thisbinary && zconv==ZCRESUM) { 684 | rxbytes = f.st_size & ~511; 685 | if (Bytesleft < rxbytes) { 686 | rxbytes = 0; goto doopen; 687 | } else 688 | openit(name, "r+"); 689 | if ( !fout) 690 | return ZFERR; 691 | if (fseek(fout, rxbytes, 0)) { 692 | closeit(); 693 | return ZFERR; 694 | } 695 | vfile("Crash recovery at %ld", rxbytes); 696 | return 0; 697 | } 698 | switch (zmanag & ZMMASK) { 699 | case ZMNEWL: 700 | if (Bytesleft > f.st_size) 701 | goto doopen; 702 | case ZMNEW: 703 | if ((f.st_mtime+1) >= Modtime) 704 | goto skipfile; 705 | goto doopen; 706 | case ZMCLOB: 707 | case ZMAPND: 708 | goto doopen; 709 | default: 710 | goto skipfile; 711 | } 712 | } else if (zmanag & ZMSKNOLOC) { 713 | skipfile: 714 | vfile("Skipping %s", name); 715 | return ZSKIP; 716 | } 717 | doopen: 718 | openit(name, openmode); 719 | #ifdef MD 720 | if ( !fout) 721 | if (make_dirs(name)) 722 | openit(name, openmode); 723 | #endif 724 | if ( !fout) 725 | return ZFERR; 726 | return 0; 727 | } 728 | 729 | openit(name, openmode) 730 | char *name, *openmode; 731 | { 732 | if (strcmp(name, "-")) 733 | fout = fopen(name, openmode); 734 | else if (isatty(1)) 735 | fout = fopen("stdout", "a"); 736 | else 737 | fout = stdout; 738 | } 739 | 740 | #ifdef MD 741 | /* 742 | * Directory-creating routines from Public Domain TAR by John Gilmore 743 | */ 744 | 745 | /* 746 | * After a file/link/symlink/dir creation has failed, see if 747 | * it's because some required directory was not present, and if 748 | * so, create all required dirs. 749 | */ 750 | make_dirs(pathname) 751 | register char *pathname; 752 | { 753 | register char *p; /* Points into path */ 754 | int madeone = 0; /* Did we do anything yet? */ 755 | int save_errno = errno; /* Remember caller's errno */ 756 | 757 | if (errno != ENOENT) 758 | return 0; /* Not our problem */ 759 | 760 | for (p = strchr(pathname, '/'); p != NULL; p = strchr(p+1, '/')) { 761 | /* Avoid mkdir of empty string, if leading or double '/' */ 762 | if (p == pathname || p[-1] == '/') 763 | continue; 764 | /* Avoid mkdir where last part of path is '.' */ 765 | if (p[-1] == '.' && (p == pathname+1 || p[-2] == '/')) 766 | continue; 767 | *p = 0; /* Truncate the path there */ 768 | if ( !mkdir(pathname, 0777)) { /* Try to create it as a dir */ 769 | vfile("Made directory %s\n", pathname); 770 | madeone++; /* Remember if we made one */ 771 | *p = '/'; 772 | continue; 773 | } 774 | *p = '/'; 775 | if (errno == EEXIST) /* Directory already exists */ 776 | continue; 777 | /* 778 | * Some other error in the mkdir. We return to the caller. 779 | */ 780 | break; 781 | } 782 | errno = save_errno; /* Restore caller's errno */ 783 | return madeone; /* Tell them to retry if we made one */ 784 | } 785 | 786 | #if (MD != 2) 787 | #define TERM_SIGNAL(status) ((status) & 0x7F) 788 | #define TERM_COREDUMP(status) (((status) & 0x80) != 0) 789 | #define TERM_VALUE(status) ((status) >> 8) 790 | /* 791 | * Make a directory. Compatible with the mkdir() system call on 4.2BSD. 792 | */ 793 | mkdir(dpath, dmode) 794 | char *dpath; 795 | int dmode; 796 | { 797 | int cpid, status; 798 | struct stat statbuf; 799 | 800 | if (stat(dpath,&statbuf) == 0) { 801 | errno = EEXIST; /* Stat worked, so it already exists */ 802 | return -1; 803 | } 804 | 805 | /* If stat fails for a reason other than non-existence, return error */ 806 | if (errno != ENOENT) return -1; 807 | 808 | switch (cpid = fork()) { 809 | 810 | case -1: /* Error in fork() */ 811 | return(-1); /* Errno is set already */ 812 | 813 | case 0: /* Child process */ 814 | /* 815 | * Cheap hack to set mode of new directory. Since this 816 | * child process is going away anyway, we zap its umask. 817 | * FIXME, this won't suffice to set SUID, SGID, etc. on this 818 | * directory. Does anybody care? 819 | */ 820 | status = umask(0); /* Get current umask */ 821 | status = umask(status | (0777 & ~dmode)); /* Set for mkdir */ 822 | execl("/bin/mkdir", "mkdir", dpath, (char *)0); 823 | _exit(2); /* Can't exec /bin/mkdir */ 824 | 825 | default: /* Parent process */ 826 | while (cpid != wait(&status)) ; /* Wait for kid to finish */ 827 | } 828 | 829 | if (TERM_SIGNAL(status) != 0 || TERM_VALUE(status) != 0) { 830 | errno = EIO; /* We don't know why, but */ 831 | return -1; /* /bin/mkdir failed */ 832 | } 833 | 834 | return 0; 835 | } 836 | #endif /* MD != 2 */ 837 | #endif /* MD */ 838 | 839 | /* 840 | * Putsec writes the n characters of buf to receive file fout. 841 | * If not in binary mode, carriage returns, and all characters 842 | * starting with CPMEOF are discarded. 843 | */ 844 | putsec(buf, n) 845 | char *buf; 846 | register n; 847 | { 848 | register char *p; 849 | 850 | if (n == 0) 851 | return OK; 852 | if (Thisbinary) { 853 | for (p=buf; --n>=0; ) 854 | putc( *p++, fout); 855 | } 856 | else { 857 | if (Eofseen) 858 | return OK; 859 | for (p=buf; --n>=0; ++p ) { 860 | if ( *p == '\r') 861 | continue; 862 | if (*p == CPMEOF) { 863 | Eofseen=TRUE; return OK; 864 | } 865 | putc(*p ,fout); 866 | } 867 | } 868 | return OK; 869 | } 870 | 871 | /* 872 | * substr(string, token) searches for token in string s 873 | * returns pointer to token within string if found, NULL otherwise 874 | */ 875 | char * 876 | substr(s, t) 877 | register char *s,*t; 878 | { 879 | register char *ss,*tt; 880 | /* search for first char of token */ 881 | for (ss=s; *s; s++) 882 | if (*s == *t) 883 | /* compare token with substring */ 884 | for (ss=s,tt=t; ;) { 885 | if (*tt == 0) 886 | return s; 887 | if (*ss++ != *tt++) 888 | break; 889 | } 890 | return NULL; 891 | } 892 | 893 | 894 | /* 895 | * If called as rb use YMODEM protocol, etc. 896 | */ 897 | chkinvok(s) 898 | char *s; 899 | { 900 | register char *p; 901 | 902 | p = s; 903 | while (*p == '-') 904 | s = ++p; 905 | while (*p) 906 | if (*p++ == '/') 907 | s = p; 908 | if (*s == 'v') { 909 | Verbose=1; ++s; 910 | } 911 | Progname = s; 912 | if (s[0]=='r' && s[1]=='z') 913 | Batch = TRUE; 914 | if (s[0]=='r' && s[1]=='c') 915 | Crcflg = TRUE; 916 | if (s[0]=='r' && s[1]=='b') 917 | Batch = Nozmodem = TRUE; 918 | } 919 | 920 | /* 921 | * Totalitarian Communist pathname processing 922 | */ 923 | checkpath(name) 924 | char *name; 925 | { 926 | if (Restricted) { 927 | if (fopen(name, "r") != NULL) { 928 | canit(); 929 | fprintf(stderr, "\r\nrz: %s exists\n", name); 930 | bibi(-1); 931 | } 932 | /* restrict pathnames to current tree or uucppublic */ 933 | if ( substr(name, "../") 934 | || (name[0]== '/' && strncmp(name, PUBDIR, strlen(PUBDIR))) ) { 935 | canit(); 936 | fprintf(stderr,"\r\nrz:\tSecurity Violation\r\n"); 937 | bibi(-1); 938 | } 939 | } 940 | } 941 | /* 942 | * Ack a ZFIN packet, let byegones be byegones 943 | */ 944 | void 945 | ackbibi() 946 | { 947 | register n; 948 | 949 | vfile("ackbibi:"); 950 | Readnum = 1; 951 | stohdr(0L); 952 | for (n=3; --n>=0; ) { 953 | purgeline(); 954 | zshhdr(4,ZFIN, Txhdr); 955 | switch (readline(100)) { 956 | case 'O': 957 | readline(1); /* Discard 2nd 'O' */ 958 | vfile("ackbibi complete"); 959 | return; 960 | case RCDO: 961 | return; 962 | case TIMEOUT: 963 | default: 964 | break; 965 | } 966 | } 967 | } 968 | 969 | 970 | /* 971 | * Initialize for Zmodem receive attempt, try to activate Zmodem sender 972 | * Handles ZSINIT frame 973 | * Return ZFILE if Zmodem filename received, -1 on error, 974 | * ZCOMPL if transaction finished, else 0 975 | */ 976 | tryz() 977 | { 978 | register c, n; 979 | register cmdzack1flg; 980 | 981 | if (Nozmodem) /* Check for "rb" program name */ 982 | return 0; 983 | 984 | 985 | for (n=15; --n>=0; ) { 986 | /* Set buffer length (0) and capability flags */ 987 | #ifdef SEGMENTS 988 | stohdr(SEGMENTS*1024L); 989 | #else 990 | stohdr(0L); 991 | #endif 992 | #ifdef CANBREAK 993 | Txhdr[ZF0] = CANFC32|CANFDX|CANOVIO|CANBRK; 994 | #else 995 | Txhdr[ZF0] = CANFC32|CANFDX|CANOVIO; 996 | #endif 997 | if (Zctlesc) 998 | Txhdr[ZF0] |= TESCCTL; 999 | Txhdr[ZF0] |= CANRLE; 1000 | Txhdr[ZF1] = CANVHDR; 1001 | /* tryzhdrtype may == ZRINIT */ 1002 | zshhdr(4,tryzhdrtype, Txhdr); 1003 | if (tryzhdrtype == ZSKIP) /* Don't skip too far */ 1004 | tryzhdrtype = ZRINIT; /* CAF 8-21-87 */ 1005 | again: 1006 | switch (zgethdr(Rxhdr)) { 1007 | case ZRQINIT: 1008 | if (Rxhdr[ZF3] & 0x80) 1009 | Usevhdrs = 1; /* we can var header */ 1010 | continue; 1011 | case ZEOF: 1012 | continue; 1013 | case TIMEOUT: 1014 | continue; 1015 | case ZFILE: 1016 | zconv = Rxhdr[ZF0]; 1017 | zmanag = Rxhdr[ZF1]; 1018 | ztrans = Rxhdr[ZF2]; 1019 | if (Rxhdr[ZF3] & ZCANVHDR) 1020 | Usevhdrs = TRUE; 1021 | tryzhdrtype = ZRINIT; 1022 | c = zrdata(secbuf, 1024); 1023 | if (c == GOTCRCW) 1024 | return ZFILE; 1025 | zshhdr(4,ZNAK, Txhdr); 1026 | goto again; 1027 | case ZSINIT: 1028 | Zctlesc = TESCCTL & Rxhdr[ZF0]; 1029 | if (zrdata(Attn, ZATTNLEN) == GOTCRCW) { 1030 | stohdr(1L); 1031 | zshhdr(4,ZACK, Txhdr); 1032 | goto again; 1033 | } 1034 | zshhdr(4,ZNAK, Txhdr); 1035 | goto again; 1036 | case ZFREECNT: 1037 | stohdr(getfree()); 1038 | zshhdr(4,ZACK, Txhdr); 1039 | goto again; 1040 | case ZCOMMAND: 1041 | #ifdef REGISTERED 1042 | /* Enabling this code without registering is theft */ 1043 | if (Restricted) { 1044 | sprintf(endmsg, "ZCOMMAND Restricted."); 1045 | return ERROR; 1046 | } 1047 | #endif 1048 | cmdzack1flg = Rxhdr[ZF0]; 1049 | if (zrdata(secbuf, 1024) == GOTCRCW) { 1050 | void exec2(); 1051 | 1052 | if (cmdzack1flg & ZCACK1) 1053 | stohdr(0L); 1054 | else 1055 | stohdr((long)sys2(secbuf)); 1056 | purgeline(); /* dump impatient questions */ 1057 | do { 1058 | zshhdr(4,ZCOMPL, Txhdr); 1059 | } 1060 | while (++errors<20 && zgethdr(Rxhdr) != ZFIN); 1061 | ackbibi(); 1062 | if (cmdzack1flg & ZCACK1) 1063 | exec2(secbuf); 1064 | return ZCOMPL; 1065 | } 1066 | zshhdr(4,ZNAK, Txhdr); goto again; 1067 | case ZCOMPL: 1068 | goto again; 1069 | default: 1070 | continue; 1071 | case ZFIN: 1072 | ackbibi(); return ZCOMPL; 1073 | case ZCAN: 1074 | return ERROR; 1075 | } 1076 | } 1077 | return 0; 1078 | } 1079 | 1080 | /* 1081 | * Receive 1 or more files with ZMODEM protocol 1082 | */ 1083 | rzfiles() 1084 | { 1085 | register c; 1086 | 1087 | for (;;) { 1088 | switch (c = rzfile()) { 1089 | case ZEOF: 1090 | case ZSKIP: 1091 | case ZFERR: 1092 | switch (tryz()) { 1093 | case ZCOMPL: 1094 | return OK; 1095 | default: 1096 | return ERROR; 1097 | case ZFILE: 1098 | break; 1099 | } 1100 | continue; 1101 | default: 1102 | return c; 1103 | case ERROR: 1104 | return ERROR; 1105 | } 1106 | } 1107 | /* NOTREACHED */ 1108 | } 1109 | 1110 | /* 1111 | * Receive a file with ZMODEM protocol 1112 | * Assumes file name frame is in secbuf 1113 | */ 1114 | rzfile() 1115 | { 1116 | register c, n; 1117 | 1118 | Eofseen=FALSE; 1119 | n = 20; rxbytes = 0l; 1120 | 1121 | if (c = procheader(secbuf)) { 1122 | return (tryzhdrtype = c); 1123 | } 1124 | 1125 | for (;;) { 1126 | #ifdef SEGMENTS 1127 | chinseg = 0; 1128 | #endif 1129 | stohdr(rxbytes); 1130 | zshhdr(4,ZRPOS, Txhdr); 1131 | nxthdr: 1132 | switch (c = zgethdr(Rxhdr)) { 1133 | default: 1134 | vfile("rzfile: Wrong header %d", c); 1135 | if ( --n < 0) { 1136 | sprintf(endmsg, "rzfile: Wrong header %d", c); 1137 | return ERROR; 1138 | } 1139 | continue; 1140 | case ZCAN: 1141 | sprintf(endmsg, "Sender CANcelled"); 1142 | return ERROR; 1143 | case ZNAK: 1144 | #ifdef SEGMENTS 1145 | putsec(secbuf, chinseg); 1146 | chinseg = 0; 1147 | #endif 1148 | if ( --n < 0) { 1149 | sprintf(endmsg, "rzfile: got ZNAK", c); 1150 | return ERROR; 1151 | } 1152 | continue; 1153 | case TIMEOUT: 1154 | #ifdef SEGMENTS 1155 | putsec(secbuf, chinseg); 1156 | chinseg = 0; 1157 | #endif 1158 | if ( --n < 0) { 1159 | sprintf(endmsg, "rzfile: TIMEOUT", c); 1160 | return ERROR; 1161 | } 1162 | continue; 1163 | case ZFILE: 1164 | zrdata(secbuf, 1024); 1165 | continue; 1166 | case ZEOF: 1167 | #ifdef SEGMENTS 1168 | putsec(secbuf, chinseg); 1169 | chinseg = 0; 1170 | #endif 1171 | if (rclhdr(Rxhdr) != rxbytes) { 1172 | /* 1173 | * Ignore eof if it's at wrong place - force 1174 | * a timeout because the eof might have gone 1175 | * out before we sent our zrpos. 1176 | */ 1177 | errors = 0; goto nxthdr; 1178 | } 1179 | if (closeit()) { 1180 | tryzhdrtype = ZFERR; 1181 | vfile("rzfile: closeit returned <> 0"); 1182 | sprintf(endmsg,"Error closing file"); 1183 | return ERROR; 1184 | } 1185 | vfile("rzfile: normal EOF"); 1186 | return c; 1187 | case ERROR: /* Too much garbage in header search error */ 1188 | #ifdef SEGMENTS 1189 | putsec(secbuf, chinseg); 1190 | chinseg = 0; 1191 | #endif 1192 | if ( --n < 0) { 1193 | sprintf(endmsg, "Persistent CRC or other ERROR"); 1194 | return ERROR; 1195 | } 1196 | zmputs(Attn); 1197 | continue; 1198 | case ZSKIP: 1199 | #ifdef SEGMENTS 1200 | putsec(secbuf, chinseg); 1201 | chinseg = 0; 1202 | #endif 1203 | Modtime = 1; 1204 | closeit(); 1205 | sprintf(endmsg, "Sender SKIPPED file"); 1206 | return c; 1207 | case ZDATA: 1208 | if (rclhdr(Rxhdr) != rxbytes) { 1209 | if ( --n < 0) { 1210 | sprintf(endmsg,"Data has bad addr"); 1211 | return ERROR; 1212 | } 1213 | #ifdef SEGMENTS 1214 | putsec(secbuf, chinseg); 1215 | chinseg = 0; 1216 | #endif 1217 | zmputs(Attn); continue; 1218 | } 1219 | moredata: 1220 | if (Verbose>1) 1221 | fprintf(stderr, "%7ld ZMODEM%s\n", 1222 | rxbytes, Crc32r?" CRC-32":""); 1223 | #ifdef SEGMENTS 1224 | if (chinseg >= (1024 * SEGMENTS)) { 1225 | putsec(secbuf, chinseg); 1226 | chinseg = 0; 1227 | } 1228 | switch (c = zrdata(secbuf+chinseg, 1024)) 1229 | #else 1230 | switch (c = zrdata(secbuf, 1024)) 1231 | #endif 1232 | { 1233 | case ZCAN: 1234 | #ifdef SEGMENTS 1235 | putsec(secbuf, chinseg); 1236 | chinseg = 0; 1237 | #endif 1238 | sprintf(endmsg, "Sender CANcelled"); 1239 | return ERROR; 1240 | case ERROR: /* CRC error */ 1241 | #ifdef SEGMENTS 1242 | putsec(secbuf, chinseg); 1243 | chinseg = 0; 1244 | #endif 1245 | if ( --n < 0) { 1246 | sprintf(endmsg, "Persistent CRC or other ERROR"); 1247 | return ERROR; 1248 | } 1249 | zmputs(Attn); 1250 | continue; 1251 | case TIMEOUT: 1252 | #ifdef SEGMENTS 1253 | putsec(secbuf, chinseg); 1254 | chinseg = 0; 1255 | #endif 1256 | if ( --n < 0) { 1257 | sprintf(endmsg, "TIMEOUT"); 1258 | return ERROR; 1259 | } 1260 | continue; 1261 | case GOTCRCW: 1262 | n = 20; 1263 | #ifdef SEGMENTS 1264 | chinseg += Rxcount; 1265 | putsec(secbuf, chinseg); 1266 | chinseg = 0; 1267 | #else 1268 | putsec(secbuf, Rxcount); 1269 | #endif 1270 | rxbytes += Rxcount; 1271 | stohdr(rxbytes); 1272 | sendline(XON); 1273 | zshhdr(4,ZACK, Txhdr); 1274 | goto nxthdr; 1275 | case GOTCRCQ: 1276 | n = 20; 1277 | #ifdef SEGMENTS 1278 | chinseg += Rxcount; 1279 | #else 1280 | putsec(secbuf, Rxcount); 1281 | #endif 1282 | rxbytes += Rxcount; 1283 | stohdr(rxbytes); 1284 | zshhdr(4,ZACK, Txhdr); 1285 | goto moredata; 1286 | case GOTCRCG: 1287 | n = 20; 1288 | #ifdef SEGMENTS 1289 | chinseg += Rxcount; 1290 | #else 1291 | putsec(secbuf, Rxcount); 1292 | #endif 1293 | rxbytes += Rxcount; 1294 | goto moredata; 1295 | case GOTCRCE: 1296 | n = 20; 1297 | #ifdef SEGMENTS 1298 | chinseg += Rxcount; 1299 | #else 1300 | putsec(secbuf, Rxcount); 1301 | #endif 1302 | rxbytes += Rxcount; 1303 | goto nxthdr; 1304 | } 1305 | } 1306 | } 1307 | } 1308 | 1309 | 1310 | /* 1311 | * Close the receive dataset, return OK or ERROR 1312 | */ 1313 | closeit() 1314 | { 1315 | time_t time(); 1316 | 1317 | if (fout == stdout) { 1318 | fflush(stdout); fout = 0; return OK; 1319 | } 1320 | if (fclose(fout)==ERROR) { 1321 | fprintf(stderr, "File close ERROR\n"); 1322 | return ERROR; 1323 | } 1324 | if (Modtime) { 1325 | timep[0] = time(NULL); 1326 | timep[1] = Modtime; 1327 | utime(Pathname, timep); 1328 | } 1329 | if ( 1330 | #ifdef POSIX 1331 | S_ISREG(Filemode) 1332 | #else 1333 | (Filemode&S_IFMT) == S_IFREG 1334 | #endif 1335 | ) 1336 | chmod(Pathname, (unsigned short)(07777 & Filemode)); 1337 | return OK; 1338 | } 1339 | 1340 | 1341 | /* 1342 | * Strip leading ! if present, do shell escape. 1343 | */ 1344 | sys2(s) 1345 | register char *s; 1346 | { 1347 | if (*s == '!') 1348 | ++s; 1349 | return system(s); 1350 | } 1351 | /* 1352 | * Strip leading ! if present, do exec. 1353 | */ 1354 | void 1355 | exec2(s) 1356 | register char *s; 1357 | { 1358 | if (*s == '!') 1359 | ++s; 1360 | mode(0); 1361 | execl("/bin/sh", "sh", "-c", s); 1362 | } 1363 | 1364 | /* End of rz.c */ 1365 | -------------------------------------------------------------------------------- /rz.doc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | RRRRZZZZ((((1111)))) OOOOmmmmeeeennnn TTTTeeeecccchhhhnnnnoooollllooooggggyyyy IIIINNNNCCCC ((((OOOOMMMMEEEENNNN)))) RRRRZZZZ((((1111)))) 5 | 6 | 7 | 8 | NNNNAAAAMMMMEEEE 9 | rx, rc, rb, rz - Receive Files and Commands with X/Y/ZMODEM 10 | 11 | SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS 12 | rrrrzzzz [-vvvv] [-wwwwWWWWIIIINNNNDDDDOOOOWWWW] [-ttttTTTTIIIIMMMMEEEEOOOOUUUUTTTT] 13 | rrrrbbbb [-vvvvyyyy] [-ttttTTTTIIIIMMMMEEEEOOOOUUUUTTTT] 14 | rrrrcccc [-vvvvyyyy] [-ttttTTTTIIIIMMMMEEEEOOOOUUUUTTTT] _f_i_l_e 15 | rrrrxxxx [-vvvvyyyy] [-ttttTTTTIIIIMMMMEEEEOOOOUUUUTTTT] _f_i_l_e 16 | ggggzzzz _f_i_l_e ... 17 | 18 | LLLLIIIICCCCEEEENNNNSSSSEEEE AAAAGGGGRRRREEEEEEEEMMMMEEEENNNNTTTT 19 | This is a Copyrighted shareware program. Commercial use of 20 | this program is subject to licensing conditions detailed in 21 | the rz.c source code. "Commercial Use" includes any use of 22 | this program to receive files from a commercial or shareware 23 | program not published by Omen Technology INC. 24 | 25 | Registration information is provided in the file mailer.rz. 26 | 27 | Use of this program constitutes agreement to the License 28 | Agreement. 29 | 30 | Please check http://www.omen.com for more information. 31 | 32 | SSSSUUUUPPPPPPPPOOOORRRRTTTT 33 | Users who have not purchased support as part of their 34 | registration may call 503-614-0430 to arrange for technical 35 | support on a consulting basis. 36 | 37 | Registered users encountering problems using this program on 38 | standard serial ports to transfer files with Professional- 39 | YAM or ZCOMM may call the support number listed in the 40 | Professional-YAM/ZCOMM documentation. Solutions to nearly 41 | all file transfer problems are described in the 42 | Professional-YAM/ZCOMM documentation. 43 | 44 | DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN 45 | This program uses error correcting protocols to receive 46 | files over a dial-in serial port from a variety of programs 47 | running under PC-DOS, CP/M, Unix, and other operating 48 | systems. It is invoked from a shell prompt manually, or 49 | automatically as a result of an "sz file ..." command given 50 | to the calling program. 51 | 52 | To obtain the maximum performance and full functionality of 53 | this program we recommend its use with GSZ, Professional-YAM 54 | or ZCOMM. 55 | 56 | This program is intended to act as a server for terminal 57 | programs, not to act as one. This program is not designed 58 | to be called from _c_u(_1), _t_i_p(_1), or other communications 59 | programs. Unix flavors of Omen Technology's Professional- 60 | 61 | 62 | 63 | Page 1 (printed 1/27/98) 64 | 65 | 66 | 67 | 68 | 69 | 70 | RRRRZZZZ((((1111)))) OOOOmmmmeeeennnn TTTTeeeecccchhhhnnnnoooollllooooggggyyyy IIIINNNNCCCC ((((OOOOMMMMEEEENNNN)))) RRRRZZZZ((((1111)))) 71 | 72 | 73 | 74 | YAM communications software are suitable for dial-out 75 | applications. Unix Professional-YAM supports dial-out 76 | applications with telephone directory, a powerful script 77 | language with learn function, high quality multiple protocol 78 | support, and UUCP port arbitration. 79 | 80 | 81 | RRRRzzzz (Receive ZMODEM) receives one or more files with the 82 | ZMODEM protocol. Pathnames are supplied by the sending 83 | program, and directories are created if necessary. (See the 84 | example below.) if standard output is not redirected to a 85 | file or pipe, output is appended to a file named "stdout". 86 | 87 | Normally, the "rz" command is automatically issued by the 88 | calling ZMODEM program, but defective ZMODEM implementations 89 | may require starting _r_z manually. 90 | 91 | RRRRbbbb receives file(s) with YMODEM, accepting either standard 92 | 128 byte sectors or 1024 byte sectors (Pro-YAM/ZCOMM sb ----kkkk 93 | option). The user should determine when the 1024 byte block 94 | length actually improves throughput. 95 | 96 | If True YMODEM (Omen Technology trademark) file information 97 | (file length, etc.) is received, the file length controls 98 | the number of bytes written to the output dataset and the 99 | modify time (iff non zero) are set accordingly. 100 | 101 | If True YMODEM file information is not received, slashes in 102 | the pathname are changed to underscore, and any trailing 103 | period in the pathname is eliminated. This conversion is 104 | useful for files received from CP/M and other historical 105 | systems. 106 | 107 | RRRRcccc receives a single _f_i_l_e with XMODEM-CRC or XMODEM-1k-CRC 108 | protocol. The user should determine when the 1024 byte 109 | block length actually improves throughput without causing 110 | problems. The user must supply the file name to both 111 | sending and receiving programs. Up to 1023 garbage 112 | characters may be added to the received file. 113 | 114 | RRRRxxxx receives a single _f_i_l_e with XMODEM or XMODEM-1k protocol. 115 | The user should determine when the 1024 byte block length 116 | actually improves throughput without causing problems. The 117 | user must supply the file name to both sending and receiving 118 | programs. Up to 1023 garbage characters may be added to the 119 | received file. 120 | 121 | GGGGzzzz is a shell script which calls _s_z to command Pro-YAM or 122 | ZCOMM to transmit the specified files. Pathnames used with 123 | _g_z must be escaped if they have special significance to the 124 | Unix shell. 125 | EXAMPLE: gz "-a C:*.c D:*.h" 126 | 127 | 128 | 129 | Page 2 (printed 1/27/98) 130 | 131 | 132 | 133 | 134 | 135 | 136 | RRRRZZZZ((((1111)))) OOOOmmmmeeeennnn TTTTeeeecccchhhhnnnnoooollllooooggggyyyy IIIINNNNCCCC ((((OOOOMMMMEEEENNNN)))) RRRRZZZZ((((1111)))) 137 | 138 | 139 | 140 | If invoked with a leading ``v'', _r_z will report progress to 141 | /tmp/rzlog. 142 | EXAMPLE: ln rz vrz; rz=vrz; export rz 143 | 144 | If the RESTRICTED shell environment variable is set to 1, or 145 | if the SHELL environment variable includes _r_s_h or _r_k_s_h 146 | (restricted shell), registered copies of _r_z will not accept 147 | command uploads, absolute pathnames, references to a parent 148 | directory, will not modify an existing file, and removes any 149 | files received in error. 150 | EXAMPLE: RESTRICTED=1 rz 151 | 152 | 153 | The meanings of the available options are: 154 | 155 | ttttTTTTIIIIMMMMEEEEOOOOUUUUTTTT 156 | Change TIMEOUT to _T_I_M_E_O_U_T tenths of seconds. 157 | vvvv Verbose causes a list of file names to be appended to 158 | /tmp/rzlog . More v's generate more detailed debugging 159 | output. 160 | wwwwWWWWIIIINNNNDDDDOOOOWWWW 161 | Use a receive window of WINDOW bytes. Details in the 162 | Professional-YAM user manual. 163 | (Pro-YAM command) 164 | <_A_L_T-_2> 165 | Pro-YAM Command: _s_z *._h *._c 166 | This automatically invokes _r_z on the connected system, and 167 | sends all .h and .c files in the current directory. 168 | 169 | _s_z -_n -_R_f . 170 | This Professional-YAM command recursively follows the 171 | current directory tree (.) (Pro-YAM -R option), sends the 172 | full relative pathname (-f), for files that are newer (-n) 173 | than their copies on the destination system. 174 | 175 | _r_z | _s_o_r_t >/_t_m_p/_s_o_r_t_e_d 176 | _s_z _O_N_A_M_E=- *._l_s_t 177 | The first command manually starts rrrrzzzz with output piped to 178 | the sort command. The second command instructs 179 | Professional-YAM, ZCOMM, GSZ or DSZ to sene the files using 180 | "-" as pathname, which instructs rrrrzzzz to output the received 181 | data to its standard output. The end result is a single 182 | file containing all the lines of the .lst files sorted 183 | alphabetically. 184 | 185 | 186 | 187 | DDDDIIIIAAAAGGGGNNNNOOOOSSSSTTTTIIIICCCCSSSS 188 | Exit status is as follows: 0 for successful transfers. 1 if 189 | unrecoverable errors are detected. 2 if syntax errors or 190 | file access problems are detected. 3 if the program was 191 | terminated by a caught interrupt. 192 | 193 | 194 | 195 | Page 3 (printed 1/27/98) 196 | 197 | 198 | 199 | 200 | 201 | 202 | RRRRZZZZ((((1111)))) OOOOmmmmeeeennnn TTTTeeeecccchhhhnnnnoooollllooooggggyyyy IIIINNNNCCCC ((((OOOOMMMMEEEENNNN)))) RRRRZZZZ((((1111)))) 203 | 204 | 205 | 206 | SSSSEEEEEEEE AAAALLLLSSSSOOOO 207 | Professional-YAM, ZCOMM, DSZ, crc(omen), sz(omen), 208 | usq(omen), undos(omen) 209 | 210 | Compile time options required for various operating systems 211 | are described in the source file. 212 | 213 | SSSSEEEERRRRVVVVEEEERRRR////NNNNEEEETTTTWWWWOOOORRRRKKKK NNNNOOOOTTTTEEEESSSS 214 | Terminals on some timesharing systems are connected 215 | indirectly to the host with TTTTEEEERRRRMMMMIIIINNNNAAAALLLL SSSSEEEERRRRVVVVEEEERRRRSSSS operating over 216 | networks. Terminal servers often interfere with file 217 | transfers by "eating" control characters and/or losing data. 218 | 219 | Accessing a distant system using tttteeeellllnnnneeeetttt on a local Unix 220 | system entails the same problems. If tttteeeellllnnnneeeetttt does not work 221 | well, try rrrrllllooooggggiiiinnnn with the ----8888 option. Set the escape 222 | character to ^P (control P) which is protected by ZMODEM. 223 | 224 | When terminal servers interfere with file transfers, server 225 | commands are often available to help the problem. When 226 | possible, enable the server and modems for hardware flow 227 | control in and out. Set the terminal server to telnet 228 | transparent mode. Some typical commands are "SET TERMINAL 229 | DOWNLOAD", "set session passall", and "SET TERMINAL NO ESC", 230 | but there is no standard set of commands suitable for all 231 | terminal servers. Normally these commands are given before 232 | attempting file transfers, but one user has reported that 233 | the command must be given _a_f_t_e_r the file transfer is 234 | started(!). Until terminal server vendors improve the 235 | quality of their product, you may have to get on their case 236 | until they adequately support high performance file 237 | transfers. 238 | 239 | The telnet protcol used by the _t_e_l_n_e_t program and terminal 240 | servers uses 0xFF (377 octal) for special control functions. 241 | The 0xFF character may cause problems if it appears in the 242 | data stream, especially uploading at high speeds. With 243 | ZCOMM or Professional-YAM the 0xFF character can be 244 | protected by giving the command: 245 | set zmtxesc ? 246 | 247 | Escaping control characters with ZMODEM (sz -e) may help if 248 | the transfer gets stuck in the same place on every attempt. 249 | Professional-YAM and ZCOMM allow selection of which control 250 | characters need to be escaped. In extreme cases 7-bit 251 | transmission may be required (see the Professional-YAM/ZCOMM 252 | manual). If you encounter problems with control characters 253 | you should identify which control characters are causing the 254 | problem. Please refer to the sz -T command in sz.doc for 255 | more help. 256 | 257 | Flow control between the server and modem is often 258 | 259 | 260 | 261 | Page 4 (printed 1/27/98) 262 | 263 | 264 | 265 | 266 | 267 | 268 | RRRRZZZZ((((1111)))) OOOOmmmmeeeennnn TTTTeeeecccchhhhnnnnoooollllooooggggyyyy IIIINNNNCCCC ((((OOOOMMMMEEEENNNN)))) RRRRZZZZ((((1111)))) 269 | 270 | 271 | 272 | defective. This rarely causes a problem in interactive 273 | applications whose short bursts (a screenfull at most) fit 274 | within the available memory buffers. Streaming protocols 275 | such as YMODEM-g, long packet SuperKermit, and ZMODEM can 276 | overload the available buffering. Some terminal servers 277 | support commands to enable hardware flow control such as 278 | "TERM FLOWCONTROL HARDWARE IN OUT"; this assumes the modem 279 | attached to the server is properly configured. 280 | 281 | If the terminal server is too brain damaged to support flow 282 | control, ZMODEM lets you fake it by setting a window size. 283 | Try 284 | sz -w2048 file... 285 | to enable software flow control. Experiment with different 286 | window sizes for best results. 287 | 288 | Terminal servers are designed to accept keyboard input from 289 | human operators. They may lose data when a program sends 290 | more data to the host faster than humans type. Some servers 291 | allow larger input buffers to support file uploads. If you 292 | can upload short files (less than 100 bytes) but not longer 293 | files, try 294 | sz -w1024 file... 295 | with your uploading program. (Not all programs support this 296 | option; use ZCOMM or Professional-YAM.) 297 | 298 | When both flow control and character transparency are 299 | problems, use 300 | sz -ew1024 file... 301 | as a starting point. 302 | 303 | Sometimes the terminal server software is defective and must 304 | be corrected. Please contact the network's vendor for 305 | corrective procedures. An alternative is to install direct 306 | serial ports for users desiring to upload files. 307 | 308 | We have also encountered problems when networking software 309 | fails to pass data after a large amount of data has been 310 | sent to the host. This has happened on a PPP internet 311 | connection which prevented uploads of large amounts of data 312 | via either FTP or a ZMODEM upload (via TELNET). The PPP 313 | connection grinds to a standstill and not even PING works. 314 | The same ZMODEM/TELNET combination easily uploaded ten times 315 | as much to a nearby machine connected by Ethernet. 316 | 317 | 318 | PPPPOOOORRRRTTTT WWWWAAAATTTTCCCCHHHHEEEERRRRSSSS 319 | Some systems enforce a timeout which disconnects a user 320 | after several minutes of keyboard inactivity. Long, error 321 | free ZMODEM transfers do not generate keyboard activity 322 | (this is why ZMODEM is so efficient). Restricting the 323 | window size with 324 | 325 | 326 | 327 | Page 5 (printed 1/27/98) 328 | 329 | 330 | 331 | 332 | 333 | 334 | RRRRZZZZ((((1111)))) OOOOmmmmeeeennnn TTTTeeeecccchhhhnnnnoooollllooooggggyyyy IIIINNNNCCCC ((((OOOOMMMMEEEENNNN)))) RRRRZZZZ((((1111)))) 335 | 336 | 337 | 338 | sz -w16384 file... 339 | option generates terminal input at regular intervals even 340 | when no error correction is needed. If problems persist, 341 | try setting a packet length. 342 | sz -l1024 file... 343 | (The default ZMODEM packet length is the file length.) 344 | 345 | NNNNOOOOTTTTEEEESSSS 346 | RRRRzzzz,,,, rrrrbbbb,,,, (Reg.)and rrrrxxxx are hard links to the rz executable. 347 | These links are automatically made by the Makefile. 348 | 349 | ZMODEM's support of XOFF/XON flow control allows proper 350 | operation in many environments that do not support XMODEM 351 | uploads. Unfortunately, not all Unix versions support input 352 | flow control. The TTY input buffering on some systems may 353 | not adequately buffer long blocks or streaming input at high 354 | speed. You should suspect this problem when you can't send 355 | data to the Unix system at high speeds using ZMODEM, 356 | YMODEM-1k or XMODEM-1k, but YMODEM with 128 byte blocks 357 | works properly. 358 | 359 | The DSZ or Pro-YAM zzzzmmmmooooddddeeeemmmm llll numeric parameter may be set to 360 | a value between 64 and 1024 to limit the burst length 361 | ("zmodem pl128"). Although this compromises ZMODEM's 362 | throughput, ZMODEM's superior reliability remains intact. 363 | 364 | If a program that does not properly implement the specified 365 | file transfer protocol causes _r_z to "hang" the port after a 366 | failed transfer, either wait for _r_z to time out or keyboard 367 | a dozen Ctrl-X characters. Every reported instance of this 368 | problem has been corrected by using ZCOMM, Pro-YAM, DSZ, or 369 | other program with a correct implementation of the specified 370 | protocol. 371 | 372 | Many programs claiming to support YMODEM only support XMODEM 373 | with 1k blocks, and they often don't get that quite right. 374 | 375 | In the case of a few poorly designed microcomputers, sending 376 | serial data to a tty port at sustained high speeds has been 377 | known to cause lockups, system halts, kernel panics, and 378 | occasional antisocial behaviour. This problem is not unique 379 | to _r_z; newer versions of Kermit, CRT terminals with screen 380 | transmission, and line noise have the same effect. When 381 | experimenting with high speed input to a system, consider 382 | rebooting the system if the file transfers are not 383 | successful, especially if the personality of the system 384 | appears altered. 385 | 386 | The Unix "ulimit" parameter must be set high enough to 387 | permit large file transfers to Unix. 388 | 389 | Telebit modems must not be set to "spoof" UUCP, XMODEM, 390 | 391 | 392 | 393 | Page 6 (printed 1/27/98) 394 | 395 | 396 | 397 | 398 | 399 | 400 | RRRRZZZZ((((1111)))) OOOOmmmmeeeennnn TTTTeeeecccchhhhnnnnoooollllooooggggyyyy IIIINNNNCCCC ((((OOOOMMMMEEEENNNN)))) RRRRZZZZ((((1111)))) 401 | 402 | 403 | 404 | YMODEM, or KERMIT. Setting one of these spoofing modes 405 | interferes with other protocols. Telebit's YMODEM spoofing 406 | interferes with YMODEM transfers. 407 | 408 | 32 bit CRC code courtesy Gary S. Brown. Directory creation 409 | code from John Gilmore's PD TAR program. 410 | 411 | NNNNEEEETTTTWWWWOOOORRRRKKKK NNNNOOOOTTTTEEEESSSS 412 | Escaping all control characters (sz -e) may help if the 413 | transfer gets stuck in the same place on every attempt. 414 | Professional-YAM and ZCOMM allow selection of which control 415 | characters need to be escaped. 416 | 417 | In extreme cases 7-bit transmission may be required (see 418 | Professional-YAM/ZCOMM manual). 7-bit transmission requires 419 | rz version 4.50 or higher. 420 | 421 | Please refer to the sz -T command in sz.doc for more help. 422 | 423 | BBBBUUUUGGGGSSSS 424 | This version of _r_z does not support some ZMODEM features. 425 | Unix flavors of Professional-YAM may be linked to "rz" to 426 | support these features. 427 | 428 | The ASCII option's CR/LF to NL translation merely deletes 429 | CR's; undos(omen) performs a more intelligent translation. 430 | 431 | ZZZZMMMMOOOODDDDEEEEMMMM CCCCAAAAPPPPAAAABBBBIIIILLLLIIIITTTTIIIIEEEESSSS 432 | _R_z supports ZMODEM command execution (zcommand), incoming 433 | ZMODEM binary (-b), ASCII (-a), escape controls (-e), 434 | newer(-n), newer+longer(-N), protect (-p), Crash Recovery(- 435 | r), clobber (-y), match+clobber (-Y), compression(-Z), and 436 | append (-+) requests. Other options sent by the sender are 437 | ignored. Crash recovery (-r) cannot be combined with other 438 | options. The default is protect (-p) and binary (-b). 439 | 440 | Unix Professional-YAM provides higher performance and other 441 | features not supported by _r_z. Please contact Omen Technology 442 | Inc for product information. 443 | 444 | http://www.omen.com 445 | 446 | Omen Technology INC 447 | Post Office Box 4681 448 | Portland OR 97208 449 | 503-614-0430 (Sales) 450 | 451 | 452 | FFFFIIIILLLLEEEESSSS 453 | rz.c, crctab.c, rbsb.c, zm.c, zmr.c, zmodem.h, rz.1 454 | 455 | /tmp/rzlog stores debugging output generated with -vv option 456 | 457 | 458 | 459 | Page 7 (printed 1/27/98) 460 | 461 | 462 | 463 | -------------------------------------------------------------------------------- /sz.doc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | SSSSZZZZ((((1111)))) OOOOmmmmeeeennnn TTTTeeeecccchhhhnnnnoooollllooooggggyyyy IIIINNNNCCCC ((((OOOOMMMMEEEENNNN)))) SSSSZZZZ((((1111)))) 5 | 6 | 7 | 8 | NNNNAAAAMMMMEEEE 9 | sx, sb, sz - Send Files with ZMODEM, YMODEM, or XMODEM 10 | zcommand, zcommandi - Send Commands with ZMODEM 11 | 12 | SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS 13 | sz [-++++aaaabbbbddddeeeeffffkkkkLLLLllllNNNNnnnnooooppppttttuuuuvvvvxxxxyyyyYYYYZZZZ] _f_i_l_e ... 14 | sb [-ddddffffkkkkttttuuuuvvvv] _f_i_l_e ... 15 | sx [-kkkkttttuuuuvvvv] _f_i_l_e 16 | zcommand [-oooottttvvvv] CCCCOOOOMMMMMMMMAAAANNNNDDDD 17 | zcommandi [-oooottttvvvv] CCCCOOOOMMMMMMMMAAAANNNNDDDD 18 | sz -T 19 | 20 | 21 | LLLLIIIICCCCEEEENNNNSSSSEEEE AAAAGGGGRRRREEEEEEEEMMMMEEEENNNNTTTT 22 | This is a copyrighted shareware program. Commercial use of 23 | this program is subject to licensing conditions detailed in 24 | the rz.c source code. "Commercial Use" includes any use of 25 | this program to send files to a commercial or shareware 26 | program not published or licensed by Omen Technology INC. 27 | 28 | Registration information is provided in the file mailer.rz. 29 | 30 | Use of this program constitutes agreement to the License 31 | Agreement. 32 | 33 | Please check http://www.omen.com for more information. 34 | 35 | SSSSUUUUPPPPPPPPOOOORRRRTTTT 36 | Users who have not purchased support as part of their 37 | registration may call 503-614-0430 to arrange for technical 38 | support on a consulting basis. 39 | 40 | Registered users encountering problems using this program on 41 | standard serial ports to transfer files with Professional- 42 | YAM or ZCOMM may call the support number listed in the 43 | Professional-YAM/ZCOMM documentation. Solutions to nearly 44 | all file transfer problems are described in the 45 | Professional-YAM/ZCOMM documentation. 46 | 47 | DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN 48 | SSSSzzzz (send ZMODEM) uses the ZMODEM, YMODEM or XMODEM error 49 | correcting protocol to send one or more files over a dial-in 50 | serial port to a variety of programs running under PC-DOS, 51 | CP/M, Unix, VMS, and other operating systems. 52 | 53 | To obtain the maximum performance and full functionality of 54 | this program we recommend its use with GSZ, Professional-YAM 55 | or ZCOMM. 56 | 57 | This program is intended to act as a server for terminal 58 | programs, not to act as one. This program is not designed 59 | to be called from _c_u(_1) _t_i_p(_1), or other communications 60 | 61 | 62 | 63 | Page 1 (printed 1/27/98) 64 | 65 | 66 | 67 | 68 | 69 | 70 | SSSSZZZZ((((1111)))) OOOOmmmmeeeennnn TTTTeeeecccchhhhnnnnoooollllooooggggyyyy IIIINNNNCCCC ((((OOOOMMMMEEEENNNN)))) SSSSZZZZ((((1111)))) 71 | 72 | 73 | 74 | programs. Unix flavors of Omen Technology's Professional- 75 | YAM communications software are available for dial-out 76 | applications. Unix Professional-YAM supports dial-out 77 | applications with telephone directory, a powerful script 78 | language with learn function, high quality multiple protocol 79 | support, and UUCP port arbitration. 80 | 81 | SSSSzzzz sends one or more files with ZMODEM protocol. 82 | 83 | ZMODEM greatly simplifies file transfers compared to XMODEM. 84 | In addition to a friendly user interface, ZMODEM provides 85 | Personal Computer and other users an efficient, accurate, 86 | and robust file transfer method. 87 | 88 | ZMODEM provides complete EEEENNNNDDDD----TTTTOOOO----EEEENNNNDDDD data integrity between 89 | application programs. ZMODEM's 32 bit CRC catches errors 90 | that sneak into even the most advanced networks. 91 | 92 | Advanced file management features include AutoDownload 93 | (Automatic file Download initiated without user 94 | intervention), Display of individual and total file lengths 95 | and transmission time estimates, Crash Recovery, selective 96 | file transfers, and preservation of exact file date and 97 | length. 98 | 99 | The ----yyyy option instructs the receiver to open the file for 100 | writing unconditionally. The ----aaaa option causes the receiver 101 | to convert Unix newlines to PC-DOS carriage returns and 102 | linefeeds. 103 | 104 | 105 | SSSSbbbb sends one or more files with YMODEM or ZMODEM protocol. 106 | The initial ZMODEM initialization is not sent. When 107 | requested by the receiver, ssssbbbb supports YYYYMMMMOOOODDDDEEEEMMMM----gggg with 108 | "cbreak" tty mode, XON/XOFF flow control, and interrupt 109 | character set to CAN (^X). YYYYMMMMOOOODDDDEEEEMMMM----gggg (Professional-YAM gggg 110 | option) increases YMODEM throughput over error free channels 111 | (direct connection, X.PC, etc.) by disabling error recovery. 112 | 113 | On Unix systems, additional information about the file is 114 | transmitted. If the receiving program uses this 115 | information, the transmitted file length controls the exact 116 | number of bytes written to the output dataset and the modify 117 | time are set accordingly. 118 | 119 | 120 | SSSSxxxx sends a single _f_i_l_e with XXXXMMMMOOOODDDDEEEEMMMM or XXXXMMMMOOOODDDDEEEEMMMM----1111kkkk protocol 121 | (sometimes incorrectly called "ymodem"). The user must 122 | supply the file name to both sending and receiving programs. 123 | 124 | Iff sssszzzz is invoked with $SHELL set and iff that variable 125 | contains the string _r_s_h or _r_k_s_h (restricted shell), sssszzzz 126 | 127 | 128 | 129 | Page 2 (printed 1/27/98) 130 | 131 | 132 | 133 | 134 | 135 | 136 | SSSSZZZZ((((1111)))) OOOOmmmmeeeennnn TTTTeeeecccchhhhnnnnoooollllooooggggyyyy IIIINNNNCCCC ((((OOOOMMMMEEEENNNN)))) SSSSZZZZ((((1111)))) 137 | 138 | 139 | 140 | operates in restricted mode. Restricted mode restricts 141 | pathnames to the current directory and PUBDIR (usually 142 | /usr/spool/uucppublic) and/or subdirectories thereof. 143 | 144 | 145 | The fourth form sends a single COMMAND to a ZMODEM receiver 146 | for execution. ZZZZccccoooommmmmmmmaaaannnndddd exits with the COMMAND return 147 | value. If COMMAND includes spaces or characters special to 148 | the shell, it must be quoted. 149 | 150 | 151 | The fifth form sends a single COMMAND to a ZMODEM receiver 152 | for execution. ZZZZccccoooommmmmmmmaaaannnnddddiiii exits as soon as the receiver has 153 | correctly received the command, before it is executed. 154 | 155 | 156 | The sixth form (sz -T) outputs all 256 code combinations to 157 | the terminal. The hex value of the character, a space, and 158 | the raw character are sent, 8 per line. In you are having 159 | difficulty sending files, this command lets you see which 160 | character codes are being eaten by the operating system or 161 | network. The terminal program must be set to display all 162 | 256 codes in a distinct form. Check that each code is sent, 163 | and that the 8th bit on codes 0x80 to 0xFF is set. 164 | 165 | Sz -T then allows the caller to input characters which are 166 | echoed in hex. You should check that all control characters 167 | can be input this way. 168 | 169 | 170 | 171 | The meanings of the available options are: 172 | 173 | ++++ Instruct the receiver to append transmitted data to an 174 | existing file (ZMODEM only). 175 | aaaa Instruct the ZMODEM receiver to convert text file 176 | format as appropriate for the receiving system. Valid 177 | only for ZMODEM. 178 | bbbb (ZMODEM) Binary override: transfer file without any 179 | translation. 180 | cccc Instruct the receiver to change the pathname if the 181 | destination file exists. 182 | dddd Change all instances of "." to "/" in the transmitted 183 | pathname. Thus, C.omenB0000 (which is unacceptable to 184 | MSDOS or CP/M) is transmitted as C/omenB0000. If the 185 | resultant filename has more than 8 characters in the 186 | stem, a "." is inserted to allow a total of eleven. 187 | eeee Escape all control characters and the all ones 188 | character (0xFF); normally only XON, XOFF, and Ctrl-X 189 | are escaped. 190 | ffff Send Full pathname. Normally directory prefixes are 191 | stripped from the transmitted filename. 192 | 193 | 194 | 195 | Page 3 (printed 1/27/98) 196 | 197 | 198 | 199 | 200 | 201 | 202 | SSSSZZZZ((((1111)))) OOOOmmmmeeeennnn TTTTeeeecccchhhhnnnnoooollllooooggggyyyy IIIINNNNCCCC ((((OOOOMMMMEEEENNNN)))) SSSSZZZZ((((1111)))) 203 | 204 | 205 | 206 | gggg Send ESC-[-?-3-4-l to start DSZ from Kermit. 207 | kkkk (XMODEM/YMODEM) Send files using 1024 byte blocks 208 | rather than the default 128 byte blocks. 1024 byte 209 | packets speed file transfers at high bit rates. 210 | (ZMODEM streams the data for the best possible 211 | throughput.) 212 | LLLLNNNN Use ZMODEM sub-packets of length N. A larger N (32 <= 213 | N <= 1024) gives slightly higher throughput, a smaller 214 | N speeds error recovery. The default is 128 below 300 215 | baud, 256 above 300 baud, or 1024 above 2400 baud. 216 | llllNNNN Wait for the receiver to acknowledge correct data every 217 | NNNN (32 <= N) characters. This may be used to avoid 218 | network overrun when XOFF flow control is lacking. 219 | nnnn (ZMODEM) Send each file if destination file does not 220 | exist. Overwrite destination file if source file is 221 | newer than the destination file. 222 | NNNN (ZMODEM) Send each file if destination file does not 223 | exist. Overwrite destination file if source file is 224 | newer or longer than the destination file. 225 | oooo (ZMODEM) Disable automatic selection of 32 bit CRC. 226 | pppp (ZMODEM) Protect existing destination files by skipping 227 | transfer if the destination file exists. 228 | rrrr (ZMODEM) Resume interrupted file transfer. If the 229 | source file is longer than the destination file, the 230 | transfer commences at the offset in the source file 231 | that equals the length of the destination file. 232 | rrrrrrrr As above, but compares the files (the portion common to 233 | sender and receiver) before resuming the transfer. 234 | ttttttttiiiimmmm Change timeout to _t_i_m tenths of seconds. 235 | uuuu Unlink the file after successful transmission. Users 236 | should not manually abort or skip file transfers when 237 | this option is used. 238 | wwwwNNNN Limit the transmit window size to N bytes (ZMODEM). 239 | vvvv Verbose causes a list of file names to be appended to 240 | /tmp/szlog . More v's generate more output. 241 | xxxx Count skipped files as errors. 242 | yyyy Instruct a ZMODEM receiving program to overwrite any 243 | existing file with the same name. 244 | YYYY Instruct a ZMODEM receiving program to overwrite any 245 | existing file with the same name, and to skip any 246 | source files that do have a file with the same pathname 247 | on the destination system. 248 | ZZZZ Use ZMODEM file compression to speed file transfer. 249 | 250 | DDDDIIIIAAAAGGGGNNNNOOOOSSSSTTTTIIIICCCCSSSS 251 | Exit status is as follows: 0 for successful transfers. 1 if 252 | unrecoverable errors are detected. 2 if syntax errors or 253 | file access problems are detected. 3 if the program was 254 | terminated by a caught interrupt. 255 | 256 | EEEEXXXXAAAAMMMMPPPPLLLLEEEESSSS 257 | 258 | 259 | 260 | 261 | Page 4 (printed 1/27/98) 262 | 263 | 264 | 265 | 266 | 267 | 268 | SSSSZZZZ((((1111)))) OOOOmmmmeeeennnn TTTTeeeecccchhhhnnnnoooollllooooggggyyyy IIIINNNNCCCC ((((OOOOMMMMEEEENNNN)))) SSSSZZZZ((((1111)))) 269 | 270 | 271 | 272 | ZZZZMMMMOOOODDDDEEEEMMMM FFFFiiiilllleeee TTTTrrrraaaannnnssssffffeeeerrrr (Unix to DSZ/ZCOMM/Professional-YAM) 273 | %%%% sssszzzz ----aaaa ****....cccc 274 | This single command transfers all .c files in the current 275 | Unix directory with conversion (----aaaa) to end of line 276 | conventions appropriate to the receiving environment. With 277 | ZMODEM AutoDownload enabled, Professional-YAM and ZCOMM 278 | will automatically receive the files after performing a 279 | security check. 280 | 281 | %%%% sssszzzz ----YYYYaaaannnn ****....cccc ****....hhhh 282 | Send only the .c and .h files that exist on both systems, 283 | and are newer on the sending system than the corresponding 284 | version on the receiving system, converting Unix to DOS text 285 | format. 286 | 287 | ZZZZMMMMOOOODDDDEEEEMMMM CCCCoooommmmmmmmaaaannnndddd DDDDoooowwwwnnnnllllooooaaaadddd (Unix to Professional-YAM) 288 | cpszall:all 289 | zcommand "c:;cd /yam/dist" 290 | sz -ya $(YD)/*.me 291 | sz -yb y*.exe 292 | zcommand "cd /yam" 293 | zcommandi "!insms" 294 | This Makefile fragment uses zzzzccccoooommmmmmmmaaaannnndddd to issue commands to 295 | Professional-YAM to change current disk and directory. 296 | Next, sssszzzz transfers the ._m_e files from the $YD directory, 297 | commanding the receiver to overwrite the old files and to 298 | convert from Unix end of line conventions to PC-DOS 299 | conventions. The third line transfers some ._e_x_e files. The 300 | fourth and fifth lines command Pro-YAM to change directory 301 | and execute a PC-DOS batch file _i_n_s_m_s . Since the batch file 302 | takes considerable time, the zzzzccccoooommmmmmmmaaaannnnddddiiii form is used to allow 303 | the program to exit immediately. 304 | 305 | XXXXMMMMOOOODDDDEEEEMMMM FFFFiiiilllleeee TTTTrrrraaaannnnssssffffeeeerrrr (Unix to Crosstalk) 306 | % ssssxxxx ffffoooooooo....cccc 307 | EEEESSSSCCCC 308 | rrrrxxxx ffffoooooooo....cccc 309 | The above three commands transfer a single file from Unix to 310 | a PC and Crosstalk. This combination is much slower and 311 | less reliable than ZMODEM. 312 | 313 | EEEERRRRRRRROOOORRRR MMMMEEEESSSSSSSSAAAAGGGGEEEESSSS 314 | "Caught signal 99" indicates the program was not properly 315 | compiled, refer to "bibi(99)" in rbsb.c for details. 316 | 317 | SSSSEEEEEEEE AAAALLLLSSSSOOOO 318 | rz(omen), ZCOMM User's Manual, Professional-YAM User's 319 | Manual, crc(omen), sq(omen), todos(omen), tocpm(omen), 320 | tomac(omen), yam(omen) 321 | 322 | Compile time options required for various operating systems 323 | are described in the source file. 324 | 325 | 326 | 327 | Page 5 (printed 1/27/98) 328 | 329 | 330 | 331 | 332 | 333 | 334 | SSSSZZZZ((((1111)))) OOOOmmmmeeeennnn TTTTeeeecccchhhhnnnnoooollllooooggggyyyy IIIINNNNCCCC ((((OOOOMMMMEEEENNNN)))) SSSSZZZZ((((1111)))) 335 | 336 | 337 | 338 | FFFFIIIILLLLEEEESSSS 339 | 32 bit CRC code courtesy Gary S. Brown. 340 | 341 | sz.c, crctab.c, rbsb.c, zm.c, zmr.c, zmodem.h Unix source 342 | files 343 | 344 | /tmp/szlog stores debugging output (sz -vv) 345 | 346 | TTTTEEEESSSSTTTTIIIINNNNGGGG FFFFEEEEAAAATTTTUUUURRRREEEE 347 | The command "sz -T file" exercises the AAAAttttttttnnnn sequence error 348 | recovery by commanding errors with unterminated packets. 349 | The receiving program should complain five times about 350 | binary data packets being too long. Each time sssszzzz is 351 | interrupted, it should send a ZDATA header followed by 352 | another defective packet. If the receiver does not detect 353 | five long data packets, the AAAAttttttttnnnn sequence is not 354 | interrupting the sender, and the MMMMyyyyaaaattttttttnnnn string in sssszzzz....cccc must 355 | be modified. 356 | 357 | After 5 packets, sssszzzz stops the "transfer" and prints the 358 | total number of characters "sent" (Tcount). The difference 359 | between Tcount and 5120 represents the number of characters 360 | stored in various buffers when the Attn sequence is 361 | generated. 362 | 363 | SSSSEEEERRRRVVVVEEEERRRR////NNNNEEEETTTTWWWWOOOORRRRKKKK NNNNOOOOTTTTEEEESSSS 364 | Terminals on some timesharing systems are connected 365 | indirectly to the host with TTTTEEEERRRRMMMMIIIINNNNAAAALLLL SSSSEEEERRRRVVVVEEEERRRRSSSS operating over 366 | networks. Terminal servers often interfere with file 367 | transfers by "eating" control characters and/or losing data. 368 | 369 | Accessing a distant system using tttteeeellllnnnneeeetttt on a local Unix 370 | system entails the same problems. If tttteeeellllnnnneeeetttt does not work 371 | well, try rrrrllllooooggggiiiinnnn with the ----8888 option. Set the escape 372 | character to ^P (control P) which is protected by ZMODEM. 373 | 374 | When terminal servers interfere with file transfers, server 375 | commands are often available to help the problem. When 376 | possible, enable the server and modems for hardware flow 377 | control in and out. Set the terminal server to telnet 378 | transparent mode. Some typical commands are "SET TERMINAL 379 | DOWNLOAD", "set session passall", and "SET TERMINAL NO ESC", 380 | but there is no standard set of commands suitable for all 381 | terminal servers. Normally these commands are given before 382 | attempting file transfers, but one user has reported that 383 | the command must be given _a_f_t_e_r the file transfer is 384 | started(!). Until terminal server vendors improve the 385 | quality of their product, you may have to get on their case 386 | until they adequately support high performance file 387 | transfers. 388 | 389 | The telnet protcol used by the _t_e_l_n_e_t program and terminal 390 | 391 | 392 | 393 | Page 6 (printed 1/27/98) 394 | 395 | 396 | 397 | 398 | 399 | 400 | SSSSZZZZ((((1111)))) OOOOmmmmeeeennnn TTTTeeeecccchhhhnnnnoooollllooooggggyyyy IIIINNNNCCCC ((((OOOOMMMMEEEENNNN)))) SSSSZZZZ((((1111)))) 401 | 402 | 403 | 404 | servers uses 0xFF (377 octal) for special control functions. 405 | The 0xFF character may cause problems if it appears in the 406 | data stream, especially uploading at high speeds. With 407 | ZCOMM or Professional-YAM the 0xFF character can be 408 | protected by giving the command: 409 | set zmtxesc ? 410 | 411 | Escaping control characters with ZMODEM (sz -e) may help if 412 | the transfer gets stuck in the same place on every attempt. 413 | Professional-YAM and ZCOMM allow selection of which control 414 | characters need to be escaped. In extreme cases 7-bit 415 | transmission may be required (see the Professional-YAM/ZCOMM 416 | manual). If you encounter problems with control characters 417 | you should identify which control characters are causing the 418 | problem. Please refer to the sz -T command in sz.doc for 419 | more help. 420 | 421 | Flow control between the server and modem is often 422 | defective. This rarely causes a problem in interactive 423 | applications whose short bursts (a screenfull at most) fit 424 | within the available memory buffers. Streaming protocols 425 | such as YMODEM-g, long packet SuperKermit, and ZMODEM can 426 | overload the available buffering. Some terminal servers 427 | support commands to enable hardware flow control such as 428 | "TERM FLOWCONTROL HARDWARE IN OUT"; this assumes the modem 429 | attached to the server is properly configured. 430 | 431 | If the terminal server is too brain damaged to support flow 432 | control, ZMODEM lets you fake it by setting a window size. 433 | Try 434 | sz -w2048 file... 435 | to enable software flow control. Experiment with different 436 | window sizes for best results. 437 | 438 | Terminal servers are designed to accept keyboard input from 439 | human operators. They may lose data when a program sends 440 | more data to the host faster than humans type. Some servers 441 | allow larger input buffers to support file uploads. If you 442 | can upload short files (less than 100 bytes) but not longer 443 | files, try 444 | sz -w1024 file... 445 | with your uploading program. (Not all programs support this 446 | option; use ZCOMM or Professional-YAM.) 447 | 448 | When both flow control and character transparency are 449 | problems, use 450 | sz -ew1024 file... 451 | as a starting point. 452 | 453 | Sometimes the terminal server software is defective and must 454 | be corrected. Please contact the network's vendor for 455 | corrective procedures. An alternative is to install direct 456 | 457 | 458 | 459 | Page 7 (printed 1/27/98) 460 | 461 | 462 | 463 | 464 | 465 | 466 | SSSSZZZZ((((1111)))) OOOOmmmmeeeennnn TTTTeeeecccchhhhnnnnoooollllooooggggyyyy IIIINNNNCCCC ((((OOOOMMMMEEEENNNN)))) SSSSZZZZ((((1111)))) 467 | 468 | 469 | 470 | serial ports for users desiring to upload files. 471 | 472 | We have also encountered problems when networking software 473 | fails to pass data after a large amount of data has been 474 | sent to the host. This has happened on a PPP internet 475 | connection which prevented uploads of large amounts of data 476 | via either FTP or a ZMODEM upload (via TELNET). The PPP 477 | connection grinds to a standstill and not even PING works. 478 | The same ZMODEM/TELNET combination easily uploaded ten times 479 | as much to a nearby machine connected by Ethernet. 480 | 481 | 482 | PPPPOOOORRRRTTTT WWWWAAAATTTTCCCCHHHHEEEERRRRSSSS 483 | Some systems enforce a timeout which disconnects a user 484 | after several minutes of keyboard inactivity. Long, error 485 | free ZMODEM transfers do not generate keyboard activity 486 | (this is why ZMODEM is so efficient). Restricting the 487 | window size with 488 | sz -w16384 file... 489 | option generates terminal input at regular intervals even 490 | when no error correction is needed. If problems persist, 491 | try setting a packet length. 492 | sz -l1024 file... 493 | (The default ZMODEM packet length is the file length.) 494 | 495 | NNNNOOOOTTTTEEEESSSS 496 | SSSSzzzz,,,, ssssbbbb,,,, ssssxxxx,,,, (Reg.)and zzzzccccoooommmmmmmmaaaannnndddd are hard links to the 497 | compiled sz program. These links are generated by the 498 | Makefile. 499 | 500 | SSSSzzzz is now compiled with internal buffering to allow sending 501 | datasets piped to its standard input (286 version excluded). 502 | ps -ef | sz - 503 | The file is sent as "szPID" where PID is the process ID of 504 | sending sz. 505 | 506 | Particular attention must be paid to flow control. The 507 | modem and Unix must agree on the flow control method. Sz 508 | does not set or reset flow control modes (if any). Most 509 | Unix systems use XON/XOFF ("software") flow control. 510 | 511 | Telebit modems must not be set to "spoof" UUCP, XMODEM, 512 | YMODEM, or KERMIT. Setting one of these spoofing modes 513 | interferes with other protocols. Telebit's YMODEM spoofing 514 | interferes with YMODEM transfers. 515 | 516 | If a program that does not properly implement the specified 517 | file transfer protocol causes _s_b to "hang" the port after a 518 | failed transfer, either wait for _s_b to time out or keyboard 519 | a dozen Ctrl-X characters. Every reported instance of this 520 | problem has been corrected by using ZCOMM, Pro-YAM, DSZ, or 521 | other program with a correct implementation of the specified 522 | 523 | 524 | 525 | Page 8 (printed 1/27/98) 526 | 527 | 528 | 529 | 530 | 531 | 532 | SSSSZZZZ((((1111)))) OOOOmmmmeeeennnn TTTTeeeecccchhhhnnnnoooollllooooggggyyyy IIIINNNNCCCC ((((OOOOMMMMEEEENNNN)))) SSSSZZZZ((((1111)))) 533 | 534 | 535 | 536 | protocol. 537 | 538 | Many programs claiming to support YMODEM only support XMODEM 539 | with 1k blocks, and they often don't get that quite right. 540 | XMODEM transfers add up to 127 garbage bytes per file. 541 | XMODEM-1k and YMODEM-1k transfers use 128 byte blocks to 542 | avoid extra padding. 543 | 544 | YMODEM programs use the file length transmitted at the 545 | beginning of the transfer to prune the file to the correct 546 | length; this may cause problems with source files that grow 547 | during the course of the transfer. This problem does not 548 | pertain to ZMODEM transfers, which preserve the exact file 549 | length unconditionally. 550 | 551 | Most ZMODEM options are merely passed to the receiving 552 | program; some programs do not implement all of these 553 | options. 554 | 555 | Circular buffering and a ZMODEM sliding window should be 556 | used when input is from pipes instead of acknowledging 557 | frames each 1024 bytes. If no files can be opened, sssszzzz sends 558 | a ZMODEM command to echo a suitable complaint; perhaps it 559 | should check for the presence of at least one accessible 560 | file before getting hot and bothered. 561 | 562 | Unix Professional-YAM provides higher performance and other 563 | features not supported by _s_z. Please contact Omen Technology 564 | Inc for product information. 565 | 566 | http://www.omen.com 567 | 568 | Omen Technology INC 569 | Post Office Box 4681 570 | Portland OR 97208 571 | 503-614-0430 (Sales) 572 | 573 | 574 | BBBBUUUUGGGGSSSS 575 | Some third party software packages do not properly implement 576 | the ZMODEM protocol. This often causes problems when users 577 | attempt to use the -a or other options. 578 | 579 | On at least one BSD system, sz would abend it got within a 580 | few kilobytes of the end of file. 581 | Using the "-w8192" option fixed the problem. The real cause 582 | is unknown, perhaps a bug in the kernel TTY output routines. 583 | 584 | The test mode leaves a zero length file on the receiving 585 | system. 586 | 587 | 588 | 589 | 590 | 591 | Page 9 (printed 1/27/98) 592 | 593 | 594 | 595 | -------------------------------------------------------------------------------- /undos.c: -------------------------------------------------------------------------------- 1 | /*% cc -xenix -M0 -compat -Osa -K -i % -o undos 2 | * 3 | * Undos - change DOS format files to Unix, etc. 4 | */ 5 | char ID[] = 6 | "Undos Rev 03-06-94 Copyright Omen Technology Inc All Rights Reserved\n"; 7 | 8 | /* 9 | ************************************************************************** 10 | * 11 | * undos.c By Chuck Forsberg, Omen Technology INC 12 | * Copyright 1997 Omen Technology Inc All Rights Reserved 13 | * 14 | ********************************************************************* 15 | ********************************************************************* 16 | * 17 | * 18 | * This software may be freely used for educational (didactic 19 | * only) purposes. "Didactic" means it is used as a study item 20 | * in a course teaching the workings of computer protocols. 21 | * 22 | * This software may also be freely used to support file transfer 23 | * operations to or from duly licensed Omen Technology products. 24 | * This includes DSZ, GSZ, ZCOMM, Professional-YAM and PowerCom. 25 | * Use with other commercial or shareware programs 26 | * (Crosstalk, Procomm, etc.) REQUIRES REGISTRATION. 27 | * 28 | * 29 | * Any programs which incorporate part or all of this code must be 30 | * provided in source form with this notice intact except by 31 | * prior written permission from Omen Technology Incorporated. 32 | * This includes compiled executables of this program. 33 | * 34 | * The .doc files and the file "mailer.rz" must also be included. 35 | * 36 | * Use of this software for commercial or administrative purposes 37 | * except when exclusively limited to interfacing Omen Technology 38 | * products requires license payment of $20.00 US per user 39 | * (less in quantity, see mailer.rz). Use of this code by 40 | * inclusion, decompilation, reverse engineering or any other means 41 | * constitutes agreement to these conditions and acceptance of 42 | * liability to license the materials and payment of reasonable 43 | * legal costs necessary to enforce this license agreement. 44 | * 45 | * 46 | * Omen Technology Inc 47 | * Post Office Box 4681 48 | * Portland OR 97208 49 | * 50 | * This code is made available in the hope it will be useful, 51 | * BUT WITHOUT ANY WARRANTY OF ANY KIND OR LIABILITY FOR ANY 52 | * DAMAGES OF ANY KIND. 53 | * 54 | */ 55 | 56 | 57 | 58 | #include 59 | #include 60 | #include 61 | #include 62 | #include 63 | #include 64 | #include 65 | 66 | #define LL 10240 67 | #define SUB 032 68 | 69 | 70 | #if 0 71 | struct utimbuf { 72 | time_t actime; /* access time */ 73 | time_t modtime; /* modification time */ 74 | }; 75 | #endif 76 | 77 | void usage(), xperror(), chngfmt(); 78 | 79 | char Lbuf[LL+2]; 80 | char *Progname; 81 | int Todos = 0; 82 | int Tocpm = 0; 83 | int Tomac = 0; 84 | int Unmac = 0; 85 | int Strip = 0; 86 | int Stripsp = 0; 87 | int Graphics = 0; 88 | int Unparity = 0; 89 | int Munged = 0; 90 | int Lineflush = 0; /* Flush output at end of each line */ 91 | 92 | main(argc, argv) 93 | char **argv; 94 | { 95 | Progname = *argv; 96 | if (! strcmp(Progname, "tocpm")) 97 | Todos = Tocpm = 1; 98 | if (! strcmp(Progname, "todos")) 99 | Todos = 1; 100 | if (! strcmp(Progname, "unmac")) 101 | Unmac = 1; 102 | if (! strcmp(Progname, "tomac")) 103 | Tomac = 1; 104 | if (! strcmp(Progname, "unparity")) 105 | Unparity = 1; 106 | 107 | if (! strcmp(argv[1], "-p")) { 108 | ++Strip; ++Stripsp; --argc; ++argv; 109 | } 110 | if (! strcmp(argv[1], "-s")) { 111 | ++Strip; --argc; ++argv; 112 | } 113 | if (! strcmp(argv[1], "-g")) { 114 | Strip = 0; ++Graphics; --argc; ++argv; 115 | } 116 | 117 | 118 | if (argc == 1) { 119 | chngfmt(NULL); exit(0); 120 | } 121 | 122 | if (argc<2 || *argv[1]== '-') 123 | usage(); 124 | while (--argc >= 1) 125 | chngfmt(*++argv); 126 | exit(Munged); 127 | } 128 | 129 | void 130 | usage() 131 | { 132 | fprintf(stderr, ID); 133 | fprintf(stderr, "\nUsage: {undos|tounix|todos|tocpm|unmac|tomac} [-p] [-s] [file ...]\n"); 134 | fprintf(stderr, " -p Strip trailing spaces, parity bit, ignore bytes < 007\n"); 135 | fprintf(stderr, " -s Strip parity bit, ignore bytes < 007\n"); 136 | fprintf(stderr, " -g Allow Graphics (line drawing) characters\n"); 137 | fprintf(stderr, "-or- unparity [file ...]\n"); 138 | exit(1); 139 | } 140 | 141 | void 142 | chngfmt(name) 143 | char *name; 144 | { 145 | register c; 146 | register char *p; 147 | register n; 148 | register FILE *fin; 149 | FILE *fout; 150 | int linno = 0; 151 | long fpos; 152 | struct stat st, ost; 153 | struct utimbuf times; 154 | char outnam[64]; 155 | int nlong = LL; 156 | 157 | if (name) { 158 | if (stat(name, &st)) { 159 | xperror(name); return; 160 | } 161 | if ((st.st_mode & S_IFMT) != S_IFREG) { 162 | fprintf(stderr, "%s: %s is not a regular file\n", Progname, name); 163 | return; 164 | } 165 | if ((fin = fopen(name, "r")) == NULL) { 166 | xperror(name); return; 167 | } 168 | strcpy(outnam, "undosXXXXXX"); 169 | mktemp(outnam); 170 | if ((fout = fopen(outnam, "w")) == NULL) { 171 | xperror(outnam); exit(2); 172 | } 173 | } else { 174 | fin = stdin; fout = stdout; 175 | } 176 | if (fstat(fileno(fout), &ost)) { 177 | xperror("Can't fstat output!"); return; 178 | } 179 | if ((ost.st_mode & S_IFMT) != S_IFREG) { 180 | Lineflush = 1; 181 | } 182 | 183 | if (Unparity) { 184 | while ((c = getc(fin)) != EOF) 185 | if (putc((c & 0177), fout) == EOF) { 186 | xperror(outnam); exit(2); 187 | } 188 | goto closeit; 189 | } 190 | for (;;) { 191 | ++linno; 192 | Lbuf[0] = 0; 193 | for (p=Lbuf+1, n=LL; --n>0; ) { 194 | ignore: 195 | if ((c = getc(fin)) == EOF) 196 | break; 197 | if ( !c) 198 | goto ignore; 199 | if (c & 0200 && !Graphics) { 200 | if (Strip) { 201 | if ((c &= 0177) < 7) 202 | goto ignore; 203 | } else if (name) 204 | goto thisbin; 205 | } 206 | if (c < '\7') { 207 | if (Strip) { 208 | if ((c &= 0177) < 7) 209 | goto ignore; 210 | } else if (name) 211 | goto thisbin; 212 | } 213 | if (c == SUB) { 214 | if (linno == 1 && name) /* ARC or ZOO file */ 215 | goto thisbin; 216 | break; 217 | } 218 | if (c == '\r' && Unmac) 219 | c = '\n'; 220 | *p++ = c; 221 | if (c == '\n') 222 | break; 223 | } 224 | *p = '\0'; 225 | if (n < nlong) 226 | nlong = n; 227 | 228 | if (n == 0 && name) { 229 | thisbin: 230 | if (n) { 231 | fprintf(stderr, "%s: %s is a binary file", Progname, name); 232 | fprintf(stderr, " line=%d char =%2X\n", linno, c); 233 | } else { 234 | fprintf(stderr, "line=%d char =%2X\n", linno, c); 235 | fprintf(stderr, "%s: %s has long line!\n", Progname, name); 236 | if (!Unmac) 237 | fprintf(stderr, "Try unmac?\n"); 238 | } 239 | Munged = 1; fclose(fin); fclose(fout); 240 | unlink(outnam); return; 241 | } 242 | 243 | if (Todos) { 244 | if (*--p == '\n' && p[-1] != '\r') { 245 | *p++ = '\r'; *p++ = '\n'; *p = 0; 246 | } 247 | } else if (Tomac) { 248 | if (*--p == '\n') { 249 | if (p[-1] == '\r') 250 | --p; 251 | *p++ = '\r'; *p = 0; 252 | } 253 | } else { 254 | if (*--p == '\n' && *--p == '\r') { 255 | while (p>(Lbuf+1) && p[-1] == '\r') 256 | --p; 257 | if (Stripsp) 258 | while (p>(Lbuf+1) && p[-1] == ' ') 259 | --p; 260 | *p++ = '\n'; *p = 0; 261 | } 262 | } 263 | if (Lbuf[1] && fputs(Lbuf+1, fout) == EOF) { 264 | xperror(outnam); exit(2); 265 | } 266 | switch (c) { 267 | case EOF: 268 | if (ferror(fin)) { 269 | xperror(name); exit(3); 270 | } 271 | case SUB: 272 | if (Tocpm) { 273 | fpos = ftell(fout); 274 | do { 275 | putc(SUB, fout); 276 | } while (++fpos & 127); 277 | } 278 | closeit: 279 | if ( !name) 280 | return; 281 | fclose(fout); fclose(fin); 282 | if (st.st_nlink > 1) 283 | sprintf(Lbuf, "trap '' 1 2 3 15; cp %s %s", outnam, name); 284 | else 285 | sprintf(Lbuf, "mv %s %s", outnam, name); 286 | system(Lbuf); 287 | times.actime = st.st_atime; 288 | times.modtime = st.st_mtime; 289 | if (utime(name, ×)) { 290 | xperror("Can't set file date"); 291 | } 292 | if (st.st_nlink > 1) 293 | unlink(outnam); 294 | nlong = LL - nlong; 295 | if (nlong > 132) 296 | fprintf(stderr, "Longest line in %s has %d bytes.\n", 297 | name ? name:"stdin", nlong); 298 | return; 299 | } 300 | if (Lineflush) 301 | fflush(fout); 302 | } 303 | } 304 | 305 | void 306 | xperror(s) 307 | char *s; 308 | { 309 | register char *p; 310 | extern int sys_nerr; 311 | extern char *sys_errlist[]; 312 | extern errno; 313 | 314 | if (errno >= sys_nerr) 315 | p = "Gloryovsky: a New Error!"; 316 | else 317 | p = sys_errlist[errno]; 318 | fprintf(stderr, "%s: %s: %s\n", Progname, s, p); 319 | } 320 | 321 | -------------------------------------------------------------------------------- /undos.doc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | UUUUNNNNDDDDOOOOSSSS((((1111)))) OOOOmmmmeeeennnn TTTTeeeecccchhhhnnnnoooollllooooggggyyyy IIIINNNNCCCC ((((OOOOMMMMEEEENNNN)))) UUUUNNNNDDDDOOOOSSSS((((1111)))) 5 | 6 | 7 | 8 | NNNNAAAAMMMMEEEE 9 | undos,tounix,todos,tocpm,tomac,unmac,unparity - Change ASCII 10 | file format for target operating system 11 | 12 | SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS 13 | uuuunnnnddddoooossss [ ----ssss ] [ file ...] 14 | ttttoooouuuunnnniiiixxxx [ ----ssss ] [ file ...] 15 | ttttooooddddoooossss [ ----ssss ] [ file ...] 16 | ttttooooccccppppmmmm [ ----ssss ] [ file ...] 17 | uuuunnnnmmmmaaaacccc [ ----ssss ] [ file ...] 18 | ttttoooommmmaaaacccc [ ----ssss ] [ file ...] 19 | uuuunnnnppppaaaarrrriiiittttyyyy [ file ...] 20 | 21 | DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN 22 | UUUUnnnnddddoooossss and ttttoooouuuunnnniiiixxxx convert DOS or CP/M format source files to 23 | Unix format by deleting carriage returns preceding linefeeds 24 | and eliminating characters starting with CPMEOF (^Z). 25 | 26 | TTTTooooddddoooossss converts Unix format source files to DOS format by 27 | adding a carriage return (if not already present) before 28 | each linefeed, and eliminates characters starting with 29 | CPMEOF (^Z). TTTTooooccccppppmmmm additionally appends CPMEOF (^Z) 30 | characters to the resulting file to make the file length a 31 | multiple of the 128 byte CP/M record length. 32 | 33 | Any combination of uuuunnnnddddoooossss,,,, ttttooooddddoooossss,,,, or ttttooooccccppppmmmm (without flags) 34 | may be applied to a proper ASCII file without destroying 35 | information. Lone carriage returns used to force 36 | overprinting are not translated to CR/LF pairs. 37 | 38 | UUUUnnnnmmmmaaaacccc converts files with lines terminated only by carriage 39 | return to Unix format. UUUUnnnnmmmmaaaacccc should only be used to 40 | translate files whose lines are terminated by lone carriage 41 | returns. 42 | 43 | TTTToooommmmaaaacccc converts Unix format files to Macintosh format (lines 44 | terminated by carriage return only). 45 | 46 | The optional flag ----ssss Strips the parity bit on all characters 47 | and discards all resulting characters with values less than 48 | 7. 49 | 50 | UUUUnnnnppppaaaarrrriiiittttyyyy strips the parity bit from each character and 51 | writes the result unconditionally. 52 | 53 | The access and modification times of the modified files are 54 | set to those of the original files. 55 | 56 | Without filenames, the programs act as filters. 57 | 58 | DDDDIIIIAAAAGGGGNNNNOOOOSSSSTTTTIIIICCCCSSSS 59 | Refuses to translate files in which "binary" characters 60 | 61 | 62 | 63 | Page 1 (printed 7/4/97) 64 | 65 | 66 | 67 | 68 | 69 | 70 | UUUUNNNNDDDDOOOOSSSS((((1111)))) OOOOmmmmeeeennnn TTTTeeeecccchhhhnnnnoooollllooooggggyyyy IIIINNNNCCCC ((((OOOOMMMMEEEENNNN)))) UUUUNNNNDDDDOOOOSSSS((((1111)))) 71 | 72 | 73 | 74 | (less than 7 or greater than 127) are seen before EOF or 75 | CPMEOF unless the ----ssss option is used. Refuses to translate 76 | files with ultra long lines. Refuses to translate special 77 | files. 78 | 79 | NNNNOOOOTTTTEEEESSSS 80 | Should be executed with the current directory in the same 81 | filesystem as the target files for minimum disk i/o. An 82 | extra copy operation is required for files with multiple 83 | links. 84 | 85 | BBBBUUUUGGGGSSSS 86 | Does not detect short files without linefeeds. UUUUnnnnmmmmaaaacccc and 87 | ttttoooommmmaaaacccc cannot handle files with CR-only overprinting. (ASCII 88 | allows either LF or CR/LF to delimit lines, but not CR.) 89 | 90 | SSSSEEEEEEEE AAAALLLLSSSSOOOO 91 | yam(omen), zcomm(omen), rz(omen), sz(omen) 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | Page 2 (printed 7/4/97) 130 | 131 | 132 | 133 | -------------------------------------------------------------------------------- /zm.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Z M . C 3 | * Copyright 1994 Omen Technology Inc All Rights Reserved 4 | * ZMODEM protocol primitives 5 | * 6 | * Entry point Functions: 7 | * zsbhdr(type, hdr) send binary header 8 | * zshhdr(type, hdr) send hex header 9 | * zgethdr(hdr) receive header - binary or hex 10 | * zsdata(buf, len, frameend) send data 11 | * zrdata(buf, len) receive data 12 | * stohdr(pos) store position data in Txhdr 13 | * long rclhdr(hdr) recover position offset from header 14 | * 15 | * 16 | * This version implements numerous enhancements including ZMODEM 17 | * Run Length Encoding and variable length headers. These 18 | * features were not funded by the original Telenet development 19 | * contract. 20 | * 21 | * This software may be freely used for educational (didactic 22 | * only) purposes. This software may also be freely used to 23 | * support file transfer operations to or from licensed Omen 24 | * Technology products. Use with other commercial or shareware 25 | * programs (Crosstalk, Procomm, etc.) REQUIRES REGISTRATION. 26 | * 27 | * Any programs which use part or all of this software must be 28 | * provided in source form with this notice intact except by 29 | * written permission from Omen Technology Incorporated. 30 | * 31 | * Use of this software for commercial or administrative purposes 32 | * except when exclusively limited to interfacing Omen Technology 33 | * products requires a per port license payment of $20.00 US per 34 | * port (less in quantity). Use of this code by inclusion, 35 | * decompilation, reverse engineering or any other means 36 | * constitutes agreement to these conditions and acceptance of 37 | * liability to license the materials and payment of reasonable 38 | * legal costs necessary to enforce this license agreement. 39 | * 40 | * 41 | * Omen Technology Inc 42 | * Post Office Box 4681 43 | * Portland OR 97208 44 | * 45 | * This code is made available in the hope it will be useful, 46 | * BUT WITHOUT ANY WARRANTY OF ANY KIND OR LIABILITY FOR ANY 47 | * DAMAGES OF ANY KIND. 48 | * 49 | */ 50 | 51 | #ifndef CANFDX 52 | #include "zmodem.h" 53 | int Rxtimeout = 100; /* Tenths of seconds to wait for something */ 54 | #endif 55 | 56 | /* Globals used by ZMODEM functions */ 57 | int Rxframeind; /* ZBIN ZBIN32, or ZHEX type of frame */ 58 | int Rxtype; /* Type of header received */ 59 | int Rxhlen; /* Length of header received */ 60 | int Rxcount; /* Count of data bytes received */ 61 | char Rxhdr[ZMAXHLEN]; /* Received header */ 62 | char Txhdr[ZMAXHLEN]; /* Transmitted header */ 63 | long Rxpos; /* Received file position */ 64 | long Txpos; /* Transmitted file position */ 65 | int Txfcs32; /* TURE means send binary frames with 32 bit FCS */ 66 | int Crc32t; /* Controls 32 bit CRC being sent */ 67 | /* 1 == CRC32, 2 == CRC32 + RLE */ 68 | int Crc32r; /* Indicates/controls 32 bit CRC being received */ 69 | /* 0 == CRC16, 1 == CRC32, 2 == CRC32 + RLE */ 70 | int Usevhdrs; /* Use variable length headers */ 71 | int Znulls; /* Number of nulls to send at beginning of ZDATA hdr */ 72 | char Attn[ZATTNLEN+1]; /* Attention string rx sends to tx on err */ 73 | char *Altcan; /* Alternate canit string */ 74 | 75 | static lastsent; /* Last char we sent */ 76 | 77 | static char *frametypes[] = { 78 | "No Response to Error Correction Request", /* -4 */ 79 | "No Carrier Detect", /* -3 */ 80 | "TIMEOUT", /* -2 */ 81 | "ERROR", /* -1 */ 82 | #define FTOFFSET 4 83 | "ZRQINIT", 84 | "ZRINIT", 85 | "ZSINIT", 86 | "ZACK", 87 | "ZFILE", 88 | "ZSKIP", 89 | "ZNAK", 90 | "ZABORT", 91 | "ZFIN", 92 | "ZRPOS", 93 | "ZDATA", 94 | "ZEOF", 95 | "ZFERR", 96 | "ZCRC", 97 | "ZCHALLENGE", 98 | "ZCOMPL", 99 | "ZCAN", 100 | "ZFREECNT", 101 | "ZCOMMAND", 102 | "ZSTDERR", 103 | "xxxxx" 104 | #define FRTYPES 22 /* Total number of frame types in this array */ 105 | /* not including psuedo negative entries */ 106 | }; 107 | 108 | static char badcrc[] = "Bad CRC"; 109 | 110 | /* Send ZMODEM binary header hdr of type type */ 111 | zsbhdr(len, type, hdr) 112 | register char *hdr; 113 | { 114 | register int n; 115 | register unsigned short crc; 116 | 117 | #ifndef DSZ 118 | vfile("zsbhdr: %c %d %s %lx", Usevhdrs?'v':'f', len, 119 | frametypes[type+FTOFFSET], rclhdr(hdr)); 120 | #endif 121 | if (type == ZDATA) 122 | for (n = Znulls; --n >=0; ) 123 | xsendline(0); 124 | 125 | xsendline(ZPAD); xsendline(ZDLE); 126 | 127 | switch (Crc32t=Txfcs32) { 128 | case 2: 129 | zsbh32(len, hdr, type, Usevhdrs?ZVBINR32:ZBINR32); 130 | flushmo(); break; 131 | case 1: 132 | zsbh32(len, hdr, type, Usevhdrs?ZVBIN32:ZBIN32); break; 133 | default: 134 | if (Usevhdrs) { 135 | xsendline(ZVBIN); 136 | zsendline(len); 137 | } 138 | else 139 | xsendline(ZBIN); 140 | zsendline(type); 141 | crc = updcrc(type, 0); 142 | 143 | for (n=len; --n >= 0; ++hdr) { 144 | zsendline(*hdr); 145 | crc = updcrc((0377& *hdr), crc); 146 | } 147 | crc = updcrc(0,updcrc(0,crc)); 148 | zsendline(((int)(crc>>8))); 149 | zsendline(crc); 150 | } 151 | if (type != ZDATA) 152 | flushmo(); 153 | } 154 | 155 | 156 | /* Send ZMODEM binary header hdr of type type */ 157 | zsbh32(len, hdr, type, flavour) 158 | register char *hdr; 159 | { 160 | register int n; 161 | register unsigned long crc; 162 | 163 | xsendline(flavour); 164 | if (Usevhdrs) 165 | zsendline(len); 166 | zsendline(type); 167 | crc = 0xFFFFFFFFL; crc = UPDC32(type, crc); 168 | 169 | for (n=len; --n >= 0; ++hdr) { 170 | crc = UPDC32((0377 & *hdr), crc); 171 | zsendline(*hdr); 172 | } 173 | crc = ~crc; 174 | for (n=4; --n >= 0;) { 175 | zsendline((int)crc); 176 | crc >>= 8; 177 | } 178 | } 179 | 180 | /* Send ZMODEM HEX header hdr of type type */ 181 | zshhdr(len, type, hdr) 182 | register char *hdr; 183 | { 184 | register int n; 185 | register unsigned short crc; 186 | 187 | #ifndef DSZ 188 | vfile("zshhdr: %c %d %s %lx", Usevhdrs?'v':'f', len, 189 | frametypes[type+FTOFFSET], rclhdr(hdr)); 190 | #endif 191 | sendline(ZPAD); sendline(ZPAD); sendline(ZDLE); 192 | if (Usevhdrs) { 193 | sendline(ZVHEX); 194 | zputhex(len); 195 | } 196 | else 197 | sendline(ZHEX); 198 | zputhex(type); 199 | Crc32t = 0; 200 | 201 | crc = updcrc(type, 0); 202 | for (n=len; --n >= 0; ++hdr) { 203 | zputhex(*hdr); crc = updcrc((0377 & *hdr), crc); 204 | } 205 | crc = updcrc(0,updcrc(0,crc)); 206 | zputhex(((int)(crc>>8))); zputhex(crc); 207 | 208 | /* Make it printable on remote machine */ 209 | sendline(015); sendline(0212); 210 | /* 211 | * Uncork the remote in case a fake XOFF has stopped data flow 212 | */ 213 | if (type != ZFIN && type != ZACK) 214 | sendline(021); 215 | flushmo(); 216 | } 217 | 218 | /* 219 | * Send binary array buf of length length, with ending ZDLE sequence frameend 220 | */ 221 | static char *Zendnames[] = { "ZCRCE", "ZCRCG", "ZCRCQ", "ZCRCW"}; 222 | zsdata(buf, length, frameend) 223 | register char *buf; 224 | { 225 | register unsigned short crc; 226 | 227 | #ifndef DSZ 228 | vfile("zsdata: %d %s", length, Zendnames[frameend-ZCRCE&3]); 229 | #endif 230 | switch (Crc32t) { 231 | case 1: 232 | zsda32(buf, length, frameend); break; 233 | case 2: 234 | zsdar32(buf, length, frameend); break; 235 | default: 236 | crc = 0; 237 | for (;--length >= 0; ++buf) { 238 | zsendline(*buf); crc = updcrc((0377 & *buf), crc); 239 | } 240 | xsendline(ZDLE); xsendline(frameend); 241 | crc = updcrc(frameend, crc); 242 | 243 | crc = updcrc(0,updcrc(0,crc)); 244 | zsendline(((int)(crc>>8))); zsendline(crc); 245 | } 246 | if (frameend == ZCRCW) 247 | xsendline(XON); 248 | if (frameend != ZCRCG) 249 | flushmo(); 250 | } 251 | 252 | zsda32(buf, length, frameend) 253 | register char *buf; 254 | { 255 | register int c; 256 | register unsigned long crc; 257 | 258 | crc = 0xFFFFFFFFL; 259 | for (;--length >= 0; ++buf) { 260 | c = *buf & 0377; 261 | zsendline(c); 262 | crc = UPDC32(c, crc); 263 | } 264 | xsendline(ZDLE); xsendline(frameend); 265 | crc = UPDC32(frameend, crc); 266 | 267 | crc = ~crc; 268 | for (c=4; --c >= 0;) { 269 | zsendline((int)crc); crc >>= 8; 270 | } 271 | } 272 | 273 | /* 274 | * Receive array buf of max length with ending ZDLE sequence 275 | * and CRC. Returns the ending character or error code. 276 | * NB: On errors may store length+1 bytes! 277 | */ 278 | zrdata(buf, length) 279 | register char *buf; 280 | { 281 | register int c; 282 | register unsigned short crc; 283 | register char *end; 284 | register int d; 285 | 286 | switch (Crc32r) { 287 | case 1: 288 | return zrdat32(buf, length); 289 | case 2: 290 | return zrdatr32(buf, length); 291 | } 292 | 293 | crc = Rxcount = 0; end = buf + length; 294 | while (buf <= end) { 295 | if ((c = zdlread()) & ~0377) { 296 | crcfoo: 297 | switch (c) { 298 | case GOTCRCE: 299 | case GOTCRCG: 300 | case GOTCRCQ: 301 | case GOTCRCW: 302 | crc = updcrc((d=c)&0377, crc); 303 | if ((c = zdlread()) & ~0377) 304 | goto crcfoo; 305 | crc = updcrc(c, crc); 306 | if ((c = zdlread()) & ~0377) 307 | goto crcfoo; 308 | crc = updcrc(c, crc); 309 | if (crc & 0xFFFF) { 310 | zperr1(badcrc); 311 | return ERROR; 312 | } 313 | Rxcount = length - (end - buf); 314 | #ifndef DSZ 315 | vfile("zrdata: %d %s", Rxcount, 316 | Zendnames[d-GOTCRCE&3]); 317 | #endif 318 | return d; 319 | case GOTCAN: 320 | zperr1("Sender Canceled"); 321 | return ZCAN; 322 | case TIMEOUT: 323 | zperr1("TIMEOUT"); 324 | return c; 325 | default: 326 | garbitch(); return c; 327 | } 328 | } 329 | *buf++ = c; 330 | crc = updcrc(c, crc); 331 | } 332 | #ifdef DSZ 333 | garbitch(); 334 | #else 335 | zperr1("Data subpacket too long"); 336 | #endif 337 | return ERROR; 338 | } 339 | 340 | zrdat32(buf, length) 341 | register char *buf; 342 | { 343 | register int c; 344 | register unsigned long crc; 345 | register char *end; 346 | register int d; 347 | 348 | crc = 0xFFFFFFFFL; Rxcount = 0; end = buf + length; 349 | while (buf <= end) { 350 | if ((c = zdlread()) & ~0377) { 351 | crcfoo: 352 | switch (c) { 353 | case GOTCRCE: 354 | case GOTCRCG: 355 | case GOTCRCQ: 356 | case GOTCRCW: 357 | d = c; c &= 0377; 358 | crc = UPDC32(c, crc); 359 | if ((c = zdlread()) & ~0377) 360 | goto crcfoo; 361 | crc = UPDC32(c, crc); 362 | if ((c = zdlread()) & ~0377) 363 | goto crcfoo; 364 | crc = UPDC32(c, crc); 365 | if ((c = zdlread()) & ~0377) 366 | goto crcfoo; 367 | crc = UPDC32(c, crc); 368 | if ((c = zdlread()) & ~0377) 369 | goto crcfoo; 370 | crc = UPDC32(c, crc); 371 | if (crc != 0xDEBB20E3) { 372 | zperr1(badcrc); 373 | return ERROR; 374 | } 375 | Rxcount = length - (end - buf); 376 | #ifndef DSZ 377 | vfile("zrdat32: %d %s", Rxcount, 378 | Zendnames[d-GOTCRCE&3]); 379 | #endif 380 | return d; 381 | case GOTCAN: 382 | zperr1("Sender Canceled"); 383 | return ZCAN; 384 | case TIMEOUT: 385 | zperr1("TIMEOUT"); 386 | return c; 387 | default: 388 | garbitch(); return c; 389 | } 390 | } 391 | *buf++ = c; 392 | crc = UPDC32(c, crc); 393 | } 394 | zperr1("Data subpacket too long"); 395 | return ERROR; 396 | } 397 | 398 | garbitch() 399 | { 400 | zperr1("Garbled data subpacket"); 401 | } 402 | 403 | /* 404 | * Read a ZMODEM header to hdr, either binary or hex. 405 | * 406 | * Set Rxhlen to size of header (default 4) (valid iff good hdr) 407 | * On success, set Zmodem to 1, set Rxpos and return type of header. 408 | * Otherwise return negative on error. 409 | * Return ERROR instantly if ZCRCW sequence, for fast error recovery. 410 | */ 411 | zgethdr(hdr) 412 | char *hdr; 413 | { 414 | register int c, n, cancount; 415 | 416 | n = Zrwindow + Baudrate; 417 | Rxframeind = Rxtype = 0; 418 | 419 | startover: 420 | cancount = 5; 421 | again: 422 | switch (c = readline(Rxtimeout)) { 423 | case 021: case 0221: 424 | goto again; 425 | case RCDO: 426 | case TIMEOUT: 427 | goto fifi; 428 | case CAN: 429 | gotcan: 430 | if (--cancount <= 0) { 431 | c = ZCAN; goto fifi; 432 | } 433 | switch (c = readline(Rxtimeout)) { 434 | case TIMEOUT: 435 | goto again; 436 | case ZCRCW: 437 | switch (readline(Rxtimeout)) { 438 | case TIMEOUT: 439 | c = ERROR; goto fifi; 440 | case RCDO: 441 | goto fifi; 442 | default: 443 | goto agn2; 444 | } 445 | case RCDO: 446 | goto fifi; 447 | default: 448 | break; 449 | case CAN: 450 | if (--cancount <= 0) { 451 | c = ZCAN; goto fifi; 452 | } 453 | goto again; 454 | } 455 | /* **** FALL THRU TO **** */ 456 | default: 457 | agn2: 458 | if ( --n == 0) { 459 | c = GCOUNT; goto fifi; 460 | } 461 | goto startover; 462 | case ZPAD: /* This is what we want. */ 463 | break; 464 | } 465 | cancount = 5; 466 | splat: 467 | switch (c = noxrd7()) { 468 | case ZPAD: 469 | goto splat; 470 | case RCDO: 471 | case TIMEOUT: 472 | goto fifi; 473 | default: 474 | goto agn2; 475 | case ZDLE: /* This is what we want. */ 476 | break; 477 | } 478 | 479 | 480 | Rxhlen = 4; /* Set default length */ 481 | Rxframeind = c = noxrd7(); 482 | switch (c) { 483 | case ZVBIN32: 484 | if ((Rxhlen = c = zdlread()) < 0) 485 | goto fifi; 486 | if (c > ZMAXHLEN) 487 | goto agn2; 488 | Crc32r = 1; c = zrbhd32(hdr); break; 489 | case ZBIN32: 490 | if (Usevhdrs) 491 | goto agn2; 492 | Crc32r = 1; c = zrbhd32(hdr); break; 493 | case ZVBINR32: 494 | if ((Rxhlen = c = zdlread()) < 0) 495 | goto fifi; 496 | if (c > ZMAXHLEN) 497 | goto agn2; 498 | Crc32r = 2; c = zrbhd32(hdr); break; 499 | case ZBINR32: 500 | if (Usevhdrs) 501 | goto agn2; 502 | Crc32r = 2; c = zrbhd32(hdr); break; 503 | case RCDO: 504 | case TIMEOUT: 505 | goto fifi; 506 | case ZVBIN: 507 | if ((Rxhlen = c = zdlread()) < 0) 508 | goto fifi; 509 | if (c > ZMAXHLEN) 510 | goto agn2; 511 | Crc32r = 0; c = zrbhdr(hdr); break; 512 | case ZBIN: 513 | if (Usevhdrs) 514 | goto agn2; 515 | Crc32r = 0; c = zrbhdr(hdr); break; 516 | case ZVHEX: 517 | if ((Rxhlen = c = zgethex()) < 0) 518 | goto fifi; 519 | if (c > ZMAXHLEN) 520 | goto agn2; 521 | Crc32r = 0; c = zrhhdr(hdr); break; 522 | case ZHEX: 523 | if (Usevhdrs) 524 | goto agn2; 525 | Crc32r = 0; c = zrhhdr(hdr); break; 526 | case CAN: 527 | goto gotcan; 528 | default: 529 | goto agn2; 530 | } 531 | for (n = Rxhlen; ++n < ZMAXHLEN; ) /* Clear unused hdr bytes */ 532 | hdr[n] = 0; 533 | Rxpos = hdr[ZP3] & 0377; 534 | Rxpos = (Rxpos<<8) + (hdr[ZP2] & 0377); 535 | Rxpos = (Rxpos<<8) + (hdr[ZP1] & 0377); 536 | Rxpos = (Rxpos<<8) + (hdr[ZP0] & 0377); 537 | fifi: 538 | switch (c) { 539 | case GOTCAN: 540 | c = ZCAN; 541 | /* **** FALL THRU TO **** */ 542 | case ZNAK: 543 | case ZCAN: 544 | case ERROR: 545 | case TIMEOUT: 546 | case RCDO: 547 | case GCOUNT: 548 | zperr2("Got %s", frametypes[c+FTOFFSET]); 549 | /* **** FALL THRU TO **** */ 550 | #ifndef DSZ 551 | default: 552 | if (c >= -4 && c <= FRTYPES) 553 | vfile("zgethdr: %c %d %s %lx", Rxframeind, Rxhlen, 554 | frametypes[c+FTOFFSET], Rxpos); 555 | else 556 | vfile("zgethdr: %c %d %lx", Rxframeind, c, Rxpos); 557 | #endif 558 | } 559 | /* Use variable length headers if we got one */ 560 | if (c >= 0 && c <= FRTYPES && Rxframeind & 040) 561 | Usevhdrs = 1; 562 | return c; 563 | } 564 | 565 | /* Receive a binary style header (type and position) */ 566 | zrbhdr(hdr) 567 | register char *hdr; 568 | { 569 | register int c, n; 570 | register unsigned short crc; 571 | 572 | if ((c = zdlread()) & ~0377) 573 | return c; 574 | Rxtype = c; 575 | crc = updcrc(c, 0); 576 | 577 | for (n=Rxhlen; --n >= 0; ++hdr) { 578 | if ((c = zdlread()) & ~0377) 579 | return c; 580 | crc = updcrc(c, crc); 581 | *hdr = c; 582 | } 583 | if ((c = zdlread()) & ~0377) 584 | return c; 585 | crc = updcrc(c, crc); 586 | if ((c = zdlread()) & ~0377) 587 | return c; 588 | crc = updcrc(c, crc); 589 | if (crc & 0xFFFF) { 590 | zperr1(badcrc); 591 | return ERROR; 592 | } 593 | #ifdef ZMODEM 594 | Protocol = ZMODEM; 595 | #endif 596 | Zmodem = 1; 597 | return Rxtype; 598 | } 599 | 600 | /* Receive a binary style header (type and position) with 32 bit FCS */ 601 | zrbhd32(hdr) 602 | register char *hdr; 603 | { 604 | register int c, n; 605 | register unsigned long crc; 606 | 607 | if ((c = zdlread()) & ~0377) 608 | return c; 609 | Rxtype = c; 610 | crc = 0xFFFFFFFFL; crc = UPDC32(c, crc); 611 | #ifdef DEBUGZ 612 | vfile("zrbhd32 c=%X crc=%lX", c, crc); 613 | #endif 614 | 615 | for (n=Rxhlen; --n >= 0; ++hdr) { 616 | if ((c = zdlread()) & ~0377) 617 | return c; 618 | crc = UPDC32(c, crc); 619 | *hdr = c; 620 | #ifdef DEBUGZ 621 | vfile("zrbhd32 c=%X crc=%lX", c, crc); 622 | #endif 623 | } 624 | for (n=4; --n >= 0;) { 625 | if ((c = zdlread()) & ~0377) 626 | return c; 627 | crc = UPDC32(c, crc); 628 | #ifdef DEBUGZ 629 | vfile("zrbhd32 c=%X crc=%lX", c, crc); 630 | #endif 631 | } 632 | if (crc != 0xDEBB20E3) { 633 | zperr1(badcrc); 634 | return ERROR; 635 | } 636 | #ifdef ZMODEM 637 | Protocol = ZMODEM; 638 | #endif 639 | Zmodem = 1; 640 | return Rxtype; 641 | } 642 | 643 | 644 | /* Receive a hex style header (type and position) */ 645 | zrhhdr(hdr) 646 | char *hdr; 647 | { 648 | register int c; 649 | register unsigned short crc; 650 | register int n; 651 | 652 | if ((c = zgethex()) < 0) 653 | return c; 654 | Rxtype = c; 655 | crc = updcrc(c, 0); 656 | 657 | for (n=Rxhlen; --n >= 0; ++hdr) { 658 | if ((c = zgethex()) < 0) 659 | return c; 660 | crc = updcrc(c, crc); 661 | *hdr = c; 662 | } 663 | if ((c = zgethex()) < 0) 664 | return c; 665 | crc = updcrc(c, crc); 666 | if ((c = zgethex()) < 0) 667 | return c; 668 | crc = updcrc(c, crc); 669 | if (crc & 0xFFFF) { 670 | zperr1(badcrc); return ERROR; 671 | } 672 | c = readline(Rxtimeout); 673 | if (c < 0) 674 | return c; 675 | c = readline(Rxtimeout); 676 | #ifdef ZMODEM 677 | Protocol = ZMODEM; 678 | #endif 679 | Zmodem = 1; 680 | if (c < 0) 681 | return c; 682 | return Rxtype; 683 | } 684 | 685 | /* Send a byte as two hex digits */ 686 | zputhex(c) 687 | register int c; 688 | { 689 | static char digits[] = "0123456789abcdef"; 690 | 691 | #ifdef DEBUGZ 692 | if (Verbose>8) 693 | vfile("zputhex: %02X", c); 694 | #endif 695 | sendline(digits[(c&0xF0)>>4]); 696 | sendline(digits[(c)&0xF]); 697 | } 698 | 699 | /* 700 | * Send character c with ZMODEM escape sequence encoding. 701 | */ 702 | zsendline(c) 703 | register c; 704 | { 705 | switch (c &= 0377) { 706 | case 0377: 707 | lastsent = c; 708 | if (Zctlesc || Zsendmask[32]) { 709 | xsendline(ZDLE); c = ZRUB1; 710 | } 711 | xsendline(c); 712 | break; 713 | case ZDLE: 714 | xsendline(ZDLE); xsendline (lastsent = (c ^= 0100)); 715 | break; 716 | case 021: case 023: 717 | case 0221: case 0223: 718 | xsendline(ZDLE); c ^= 0100; xsendline(lastsent = c); 719 | break; 720 | default: 721 | if (((c & 0140) == 0) && (Zctlesc || Zsendmask[c & 037])) { 722 | xsendline(ZDLE); c ^= 0100; 723 | } 724 | xsendline(lastsent = c); 725 | } 726 | } 727 | 728 | /* Decode two lower case hex digits into an 8 bit byte value */ 729 | zgethex() 730 | { 731 | register int c; 732 | 733 | c = zgeth1(); 734 | #ifdef DEBUGZ 735 | if (Verbose>8) 736 | vfile("zgethex: %02X", c); 737 | #endif 738 | return c; 739 | } 740 | zgeth1() 741 | { 742 | register int c, n; 743 | 744 | if ((c = noxrd7()) < 0) 745 | return c; 746 | n = c - '0'; 747 | if (n > 9) 748 | n -= ('a' - ':'); 749 | if (n & ~0xF) 750 | return ERROR; 751 | if ((c = noxrd7()) < 0) 752 | return c; 753 | c -= '0'; 754 | if (c > 9) 755 | c -= ('a' - ':'); 756 | if (c & ~0xF) 757 | return ERROR; 758 | c += (n<<4); 759 | return c; 760 | } 761 | 762 | /* 763 | * Read a byte, checking for ZMODEM escape encoding 764 | * including CAN*5 which represents a quick abort 765 | */ 766 | zdlread() 767 | { 768 | register int c; 769 | 770 | again: 771 | /* Quick check for non control characters */ 772 | if ((c = readline(Rxtimeout)) & 0140) 773 | return c; 774 | switch (c) { 775 | case ZDLE: 776 | break; 777 | case 023: 778 | case 0223: 779 | case 021: 780 | case 0221: 781 | goto again; 782 | default: 783 | if (Zctlesc && !(c & 0140)) { 784 | goto again; 785 | } 786 | return c; 787 | } 788 | again2: 789 | if ((c = readline(Rxtimeout)) < 0) 790 | return c; 791 | if (c == CAN && (c = readline(Rxtimeout)) < 0) 792 | return c; 793 | if (c == CAN && (c = readline(Rxtimeout)) < 0) 794 | return c; 795 | if (c == CAN && (c = readline(Rxtimeout)) < 0) 796 | return c; 797 | switch (c) { 798 | case CAN: 799 | return GOTCAN; 800 | case ZCRCE: 801 | case ZCRCG: 802 | case ZCRCQ: 803 | case ZCRCW: 804 | return (c | GOTOR); 805 | case ZRUB0: 806 | return 0177; 807 | case ZRUB1: 808 | return 0377; 809 | case 023: 810 | case 0223: 811 | case 021: 812 | case 0221: 813 | goto again2; 814 | default: 815 | if (Zctlesc && ! (c & 0140)) { 816 | goto again2; 817 | } 818 | if ((c & 0140) == 0100) 819 | return (c ^ 0100); 820 | break; 821 | } 822 | if (Verbose>1) 823 | zperr2("Bad escape sequence %x", c); 824 | return ERROR; 825 | } 826 | 827 | /* 828 | * Read a character from the modem line with timeout. 829 | * Eat parity, XON and XOFF characters. 830 | */ 831 | noxrd7() 832 | { 833 | register int c; 834 | 835 | for (;;) { 836 | if ((c = readline(Rxtimeout)) < 0) 837 | return c; 838 | switch (c &= 0177) { 839 | case XON: 840 | case XOFF: 841 | continue; 842 | default: 843 | if (Zctlesc && !(c & 0140)) 844 | continue; 845 | case '\r': 846 | case '\n': 847 | case ZDLE: 848 | return c; 849 | } 850 | } 851 | /* NOTREACHED */ 852 | } 853 | 854 | /* Store long integer pos in Txhdr */ 855 | stohdr(pos) 856 | long pos; 857 | { 858 | Txhdr[ZP0] = pos; 859 | Txhdr[ZP1] = pos>>8; 860 | Txhdr[ZP2] = pos>>16; 861 | Txhdr[ZP3] = pos>>24; 862 | } 863 | 864 | /* Recover a long integer from a header */ 865 | long 866 | rclhdr(hdr) 867 | register char *hdr; 868 | { 869 | register long l; 870 | 871 | l = (hdr[ZP3] & 0377); 872 | l = (l << 8) | (hdr[ZP2] & 0377); 873 | l = (l << 8) | (hdr[ZP1] & 0377); 874 | l = (l << 8) | (hdr[ZP0] & 0377); 875 | return l; 876 | } 877 | 878 | /* End of zm.c */ 879 | -------------------------------------------------------------------------------- /zmodem.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Z M O D E M . H Manifest constants for ZMODEM 3 | * application to application file transfer protocol 4 | * Copyright 1993 Omen Technology Inc All Rights Reserved 5 | */ 6 | #define ZPAD '*' /* 052 Padding character begins frames */ 7 | #define ZDLE 030 /* Ctrl-X Zmodem escape - `ala BISYNC DLE */ 8 | #define ZDLEE (ZDLE^0100) /* Escaped ZDLE as transmitted */ 9 | #define ZBIN 'A' /* Binary frame indicator (CRC-16) */ 10 | #define ZHEX 'B' /* HEX frame indicator */ 11 | #define ZBIN32 'C' /* Binary frame with 32 bit FCS */ 12 | #define ZBINR32 'D' /* RLE packed Binary frame with 32 bit FCS */ 13 | #define ZVBIN 'a' /* Binary frame indicator (CRC-16) */ 14 | #define ZVHEX 'b' /* HEX frame indicator */ 15 | #define ZVBIN32 'c' /* Binary frame with 32 bit FCS */ 16 | #define ZVBINR32 'd' /* RLE packed Binary frame with 32 bit FCS */ 17 | #define ZRESC 0176 /* RLE flag/escape character */ 18 | #define ZMAXHLEN 16 /* Max header information length NEVER CHANGE */ 19 | #define ZMAXSPLEN 1024 /* Max subpacket length NEVER CHANGE */ 20 | 21 | /* Frame types (see array "frametypes" in zm.c) */ 22 | #define ZRQINIT 0 /* Request receive init */ 23 | #define ZRINIT 1 /* Receive init */ 24 | #define ZSINIT 2 /* Send init sequence (optional) */ 25 | #define ZACK 3 /* ACK to above */ 26 | #define ZFILE 4 /* File name from sender */ 27 | #define ZSKIP 5 /* To sender: skip this file */ 28 | #define ZNAK 6 /* Last packet was garbled */ 29 | #define ZABORT 7 /* Abort batch transfers */ 30 | #define ZFIN 8 /* Finish session */ 31 | #define ZRPOS 9 /* Resume data trans at this position */ 32 | #define ZDATA 10 /* Data packet(s) follow */ 33 | #define ZEOF 11 /* End of file */ 34 | #define ZFERR 12 /* Fatal Read or Write error Detected */ 35 | #define ZCRC 13 /* Request for file CRC and response */ 36 | #define ZCHALLENGE 14 /* Receiver's Challenge */ 37 | #define ZCOMPL 15 /* Request is complete */ 38 | #define ZCAN 16 /* Other end canned session with CAN*5 */ 39 | #define ZFREECNT 17 /* Request for free bytes on filesystem */ 40 | #define ZCOMMAND 18 /* Command from sending program */ 41 | #define ZSTDERR 19 /* Output to standard error, data follows */ 42 | 43 | /* ZDLE sequences */ 44 | #define ZCRCE 'h' /* CRC next, frame ends, header packet follows */ 45 | #define ZCRCG 'i' /* CRC next, frame continues nonstop */ 46 | #define ZCRCQ 'j' /* CRC next, frame continues, ZACK expected */ 47 | #define ZCRCW 'k' /* CRC next, ZACK expected, end of frame */ 48 | #define ZRUB0 'l' /* Translate to rubout 0177 */ 49 | #define ZRUB1 'm' /* Translate to rubout 0377 */ 50 | 51 | /* zdlread return values (internal) */ 52 | /* -1 is general error, -2 is timeout */ 53 | #define GOTOR 0400 54 | #define GOTCRCE (ZCRCE|GOTOR) /* ZDLE-ZCRCE received */ 55 | #define GOTCRCG (ZCRCG|GOTOR) /* ZDLE-ZCRCG received */ 56 | #define GOTCRCQ (ZCRCQ|GOTOR) /* ZDLE-ZCRCQ received */ 57 | #define GOTCRCW (ZCRCW|GOTOR) /* ZDLE-ZCRCW received */ 58 | #define GOTCAN (GOTOR|030) /* CAN*5 seen */ 59 | 60 | /* Byte positions within header array */ 61 | #define ZF0 3 /* First flags byte */ 62 | #define ZF1 2 63 | #define ZF2 1 64 | #define ZF3 0 65 | #define ZP0 0 /* Low order 8 bits of position */ 66 | #define ZP1 1 67 | #define ZP2 2 68 | #define ZP3 3 /* High order 8 bits of file position */ 69 | 70 | /* Parameters for ZRINIT header */ 71 | #define ZRPXWN 8 /* 9th byte in header contains window size/256 */ 72 | #define ZRPXQQ 9 /* 10th to 14th bytes contain quote mask */ 73 | /* Bit Masks for ZRINIT flags byte ZF0 */ 74 | #define CANFDX 01 /* Rx can send and receive true FDX */ 75 | #define CANOVIO 02 /* Rx can receive data during disk I/O */ 76 | #define CANBRK 04 /* Rx can send a break signal */ 77 | #define CANRLE 010 /* Receiver can decode RLE */ 78 | #define CANLZW 020 /* Receiver can uncompress */ 79 | #define CANFC32 040 /* Receiver can use 32 bit Frame Check */ 80 | #define ESCCTL 0100 /* Receiver expects ctl chars to be escaped */ 81 | #define ESC8 0200 /* Receiver expects 8th bit to be escaped */ 82 | 83 | /* Bit Masks for ZRINIT flags byte ZF1 */ 84 | #define CANVHDR 01 /* Variable headers OK */ 85 | #define ZRRQWN 8 /* Receiver specified window size in ZRPXWN */ 86 | #define ZRRQQQ 16 /* Additional control chars to quote in ZRPXQQ */ 87 | #define ZRQNVH (ZRRQWN|ZRRQQQ) /* Variable len hdr reqd to access info */ 88 | 89 | /* Parameters for ZSINIT frame */ 90 | #define ZATTNLEN 32 /* Max length of attention string */ 91 | #define ALTCOFF ZF1 /* Offset to alternate canit string, 0 if not used */ 92 | /* Bit Masks for ZSINIT flags byte ZF0 */ 93 | #define TESCCTL 0100 /* Transmitter expects ctl chars to be escaped */ 94 | #define TESC8 0200 /* Transmitter expects 8th bit to be escaped */ 95 | 96 | /* Parameters for ZFILE frame */ 97 | /* Conversion options one of these in ZF0 */ 98 | #define ZCBIN 1 /* Binary transfer - inhibit conversion */ 99 | #define ZCNL 2 /* Convert NL to local end of line convention */ 100 | #define ZCRESUM 3 /* Resume interrupted file transfer */ 101 | /* Management include options, one of these ored in ZF1 */ 102 | #define ZMSKNOLOC 0200 /* Skip file if not present at rx */ 103 | /* Management options, one of these ored in ZF1 */ 104 | #define ZMMASK 037 /* Mask for the choices below */ 105 | #define ZMNEWL 1 /* Transfer if source newer or longer */ 106 | #define ZMCRC 2 /* Transfer if different file CRC or length */ 107 | #define ZMAPND 3 /* Append contents to existing file (if any) */ 108 | #define ZMCLOB 4 /* Replace existing file */ 109 | #define ZMNEW 5 /* Transfer if source newer */ 110 | /* Number 5 is alive ... */ 111 | #define ZMDIFF 6 /* Transfer if dates or lengths different */ 112 | #define ZMPROT 7 /* Protect destination file */ 113 | #define ZMCHNG 8 /* Change filename if destination exists */ 114 | /* Transport options, one of these in ZF2 */ 115 | #define ZTLZW 1 /* Lempel-Ziv compression */ 116 | #define ZTRLE 3 /* Run Length encoding */ 117 | /* Extended options for ZF3, bit encoded */ 118 | #define ZXSPARS 64 /* Encoding for sparse file operations */ 119 | #define ZCANVHDR 01 /* Variable headers OK */ 120 | /* Receiver window size override */ 121 | #define ZRWOVR 4 /* byte position for receive window override/256 */ 122 | 123 | /* Parameters for ZCOMMAND frame ZF0 (otherwise 0) */ 124 | #define ZCACK1 1 /* Acknowledge, then do command */ 125 | 126 | long rclhdr(); 127 | 128 | /* Globals used by ZMODEM functions */ 129 | extern Rxframeind; /* ZBIN ZBIN32, or ZHEX type of frame */ 130 | extern Rxtype; /* Type of header received */ 131 | extern Rxcount; /* Count of data bytes received */ 132 | extern Rxtimeout; /* Tenths of seconds to wait for something */ 133 | extern long Rxpos; /* Received file position */ 134 | extern long Txpos; /* Transmitted file position */ 135 | extern Txfcs32; /* TURE means send binary frames with 32 bit FCS */ 136 | extern Crc32t; /* Display flag indicating 32 bit CRC being sent */ 137 | extern Crc32; /* Display flag indicating 32 bit CRC being received */ 138 | extern Znulls; /* Number of nulls to send at beginning of ZDATA hdr */ 139 | extern char Attn[ZATTNLEN+1]; /* Attention string rx sends to tx on err */ 140 | extern char *Altcan; /* Alternate canit string */ 141 | 142 | /* End of zmodem.h */ 143 | -------------------------------------------------------------------------------- /zmr.c: -------------------------------------------------------------------------------- 1 | /* 2 | * File: zmr.c 3 | * Copyright 1988, 1994 Omen Technology Inc All Rights Reserved 4 | * 5 | * 6 | * 7 | * This module implements ZMODEM Run Length Encoding, an 8 | * extension that was not funded by the original Telenet 9 | * development contract. 10 | * 11 | * This software may be freely used for educational (didactic 12 | * only) purposes. This software may also be freely used to 13 | * support file transfer operations to or from licensed Omen 14 | * Technology products. Use with other commercial or shareware 15 | * programs (Crosstalk, Procomm, etc.) REQUIRES REGISTRATION. 16 | * 17 | * Any programs which use part or all of this software must be 18 | * provided in source form with this notice intact except by 19 | * written permission from Omen Technology Incorporated. 20 | * 21 | * Use of this software for commercial or administrative purposes 22 | * except when exclusively limited to interfacing Omen Technology 23 | * products requires a per port license payment of $20.00 US per 24 | * port (less in quantity). Use of this code by inclusion, 25 | * decompilation, reverse engineering or any other means 26 | * constitutes agreement to these conditions and acceptance of 27 | * liability to license the materials and payment of reasonable 28 | * legal costs necessary to enforce this license agreement. 29 | * 30 | * 31 | * Omen Technology Inc 32 | * Post Office Box 4681 33 | * Portland OR 97208 34 | * 35 | * This code is made available in the hope it will be useful, 36 | * BUT WITHOUT ANY WARRANTY OF ANY KIND OR LIABILITY FOR ANY 37 | * DAMAGES OF ANY KIND. 38 | * 39 | * ZMODEM RLE compression and decompression functions 40 | */ 41 | 42 | /* Send data subpacket RLE encoded with 32 bit FCS */ 43 | zsdar32(buf, length, frameend) 44 | char *buf; 45 | { 46 | register int c, l, n; 47 | register unsigned long crc; 48 | 49 | crc = 0xFFFFFFFFL; l = *buf++ & 0377; 50 | if (length == 1) { 51 | zsendline(l); crc = UPDC32(l, crc); 52 | if (l == ZRESC) { 53 | zsendline(1); crc = UPDC32(1, crc); 54 | } 55 | } else { 56 | for (n = 0; --length >= 0; ++buf) { 57 | if ((c = *buf & 0377) == l && n < 126 && length>0) { 58 | ++n; continue; 59 | } 60 | switch (n) { 61 | case 0: 62 | zsendline(l); 63 | crc = UPDC32(l, crc); 64 | if (l == ZRESC) { 65 | zsendline(0100); crc = UPDC32(0100, crc); 66 | } 67 | l = c; break; 68 | case 1: 69 | if (l != ZRESC) { 70 | zsendline(l); zsendline(l); 71 | crc = UPDC32(l, crc); 72 | crc = UPDC32(l, crc); 73 | n = 0; l = c; break; 74 | } 75 | /* **** FALL THRU TO **** */ 76 | default: 77 | zsendline(ZRESC); crc = UPDC32(ZRESC, crc); 78 | if (l == 040 && n < 34) { 79 | n += 036; 80 | zsendline(n); crc = UPDC32(n, crc); 81 | } 82 | else { 83 | n += 0101; 84 | zsendline(n); crc = UPDC32(n, crc); 85 | zsendline(l); crc = UPDC32(l, crc); 86 | } 87 | n = 0; l = c; break; 88 | } 89 | } 90 | } 91 | xsendline(ZDLE); xsendline(frameend); 92 | crc = UPDC32(frameend, crc); 93 | 94 | crc = ~crc; 95 | for (length=4; --length >= 0;) { 96 | zsendline((int)crc); crc >>= 8; 97 | } 98 | } 99 | 100 | 101 | /* Receive data subpacket RLE encoded with 32 bit FCS */ 102 | zrdatr32(buf, length) 103 | register char *buf; 104 | { 105 | register int c; 106 | register unsigned long crc; 107 | register char *end; 108 | register int d; 109 | 110 | crc = 0xFFFFFFFFL; Rxcount = 0; end = buf + length; 111 | d = 0; /* Use for RLE decoder state */ 112 | while (buf <= end) { 113 | if ((c = zdlread()) & ~0377) { 114 | crcfoo: 115 | switch (c) { 116 | case GOTCRCE: 117 | case GOTCRCG: 118 | case GOTCRCQ: 119 | case GOTCRCW: 120 | d = c; c &= 0377; 121 | crc = UPDC32(c, crc); 122 | if ((c = zdlread()) & ~0377) 123 | goto crcfoo; 124 | crc = UPDC32(c, crc); 125 | if ((c = zdlread()) & ~0377) 126 | goto crcfoo; 127 | crc = UPDC32(c, crc); 128 | if ((c = zdlread()) & ~0377) 129 | goto crcfoo; 130 | crc = UPDC32(c, crc); 131 | if ((c = zdlread()) & ~0377) 132 | goto crcfoo; 133 | crc = UPDC32(c, crc); 134 | if (crc != 0xDEBB20E3) { 135 | zperr1(badcrc); 136 | return ERROR; 137 | } 138 | Rxcount = length - (end - buf); 139 | #ifndef DSZ 140 | vfile("zrdatr32: %d %s", Rxcount, 141 | Zendnames[d-GOTCRCE&3]); 142 | #endif 143 | return d; 144 | case GOTCAN: 145 | zperr1("Sender Canceled"); 146 | return ZCAN; 147 | case TIMEOUT: 148 | zperr1("TIMEOUT"); 149 | return c; 150 | default: 151 | zperr1("Bad data subpacket"); 152 | return c; 153 | } 154 | } 155 | crc = UPDC32(c, crc); 156 | switch (d) { 157 | case 0: 158 | if (c == ZRESC) { 159 | d = -1; continue; 160 | } 161 | *buf++ = c; continue; 162 | case -1: 163 | if (c >= 040 && c < 0100) { 164 | d = c - 035; c = 040; goto spaces; 165 | } 166 | if (c == 0100) { 167 | d = 0; 168 | *buf++ = ZRESC; continue; 169 | } 170 | d = c; continue; 171 | default: 172 | d -= 0100; 173 | if (d < 1) 174 | goto badpkt; 175 | spaces: 176 | if ((buf + d) > end) 177 | goto badpkt; 178 | while ( --d >= 0) 179 | *buf++ = c; 180 | d = 0; continue; 181 | } 182 | } 183 | badpkt: 184 | zperr1("Data subpacket too long"); 185 | return ERROR; 186 | } 187 | 188 | /* End of zmr.c */ 189 | -------------------------------------------------------------------------------- /zupl.t: -------------------------------------------------------------------------------- 1 | echo "ProYAM/ZCOMM script to upload minirb and rz/sz to *nix" 2 | if S>1200 pt1 3 | ena -t 4 | if !fminirb.c echo "Can't find minirb.c !!"; abort 5 | putw "stty -echo; cat >minirb.c\r" 6 | f -xHr minirb.c 7 | putw "\r\4" 8 | putw "stty echo\r" 9 | dis -h 10 | pat 1 "rwx" 11 | pat 2 "%" 12 | put "cc minirb.c -o minirb; ls -l minirb\r" 13 | wait -f120 14 | if 1 goto okok 15 | echo "The compiiation appears to have failed." 16 | echo "Please compile minirb.c to minirb, then" 17 | echo "hit F5 to upload the rest of the rz/sz files." 18 | set f5 19 | @putw minirb\r; sb README zmodem.h zm.c zmr.c sz.c rz.c crctab.c rbsb.c *.doc gz 20 | t 21 | return 22 | okok: echo "Minirb Compilation Appears Successful." 23 | put minirb\r 24 | sb README ?akefile zmodem.h zm.c zmr.c sz.c rz.c crc.c crctab.c rbsb.c *.doc gz 25 | t 26 | return 27 | --------------------------------------------------------------------------------