Added first part of zmodem sources

This commit is contained in:
Michiel Broek 2004-11-07 13:21:58 +00:00
parent d7242cd944
commit 4e180b5cd4
2 changed files with 203 additions and 3 deletions

View File

@ -12,7 +12,8 @@ SRCS = signature.c filesub.c language.c mbtoberep.c \
exitinfo.c mbsebbs.c menu.c pop3.c lastcallers.c \ exitinfo.c mbsebbs.c menu.c pop3.c lastcallers.c \
timeout.c chat.c file.c misc.c \ timeout.c chat.c file.c misc.c \
offline.c user.c mbnewusr.c input.c whoson.c \ offline.c user.c mbnewusr.c input.c whoson.c \
door.c dispfile.c userlist.c timestats.c logentry.c door.c dispfile.c userlist.c timestats.c logentry.c \
zmrle.c zmmisc.c
HDRS = signature.h filesub.h language.h mbsebbs.h misc.h offline.h \ HDRS = signature.h filesub.h language.h mbsebbs.h misc.h offline.h \
timeout.h bbslist.h email.h fsedit.h lineedit.h \ timeout.h bbslist.h email.h fsedit.h lineedit.h \
msgutil.h oneline.h user.h bye.h morefile.h \ msgutil.h oneline.h user.h bye.h morefile.h \
@ -20,13 +21,15 @@ HDRS = signature.h filesub.h language.h mbsebbs.h misc.h offline.h \
change.h exitinfo.h newuser.h \ change.h exitinfo.h newuser.h \
pinfo.h chat.h file.h menu.h transfer.h \ pinfo.h chat.h file.h menu.h transfer.h \
pop3.h timecheck.h mbnewusr.h input.h whoson.h \ pop3.h timecheck.h mbnewusr.h input.h whoson.h \
door.h dispfile.h userlist.h timestats.h logentry.h lastcallers.h door.h dispfile.h userlist.h timestats.h logentry.h lastcallers.h \
zmrle.h zmmisc.h zmodem.h
MBSEBBS_OBJS = signature.o bbslist.o chat.o file.o funcs.o mail.o menu.o \ MBSEBBS_OBJS = signature.o bbslist.o chat.o file.o funcs.o mail.o menu.o \
misc.o pinfo.o oneline.o page.o fsedit.o transfer.o \ misc.o pinfo.o oneline.o page.o fsedit.o transfer.o \
bye.o change.o mbsebbs.o timeout.o user.o timecheck.o \ bye.o change.o mbsebbs.o timeout.o user.o timecheck.o \
exitinfo.o filesub.o lineedit.o offline.o language.o msgutil.o \ exitinfo.o filesub.o lineedit.o offline.o language.o msgutil.o \
pop3.o email.o input.o whoson.o door.o dispfile.o userlist.o timestats.o \ pop3.o email.o input.o whoson.o door.o dispfile.o userlist.o timestats.o \
logentry.o morefile.o lastcallers.o term.o ttyio.o openport.o logentry.o morefile.o lastcallers.o term.o ttyio.o openport.o \
zmrle.o zmmisc.o
MBSEBBS_LIBS = ../lib/libmbse.a ../lib/libmsgbase.a ../lib/libdbase.a ../lib/libmbinet.a ../lib/libnodelist.a MBSEBBS_LIBS = ../lib/libmbse.a ../lib/libmsgbase.a ../lib/libdbase.a ../lib/libmbinet.a ../lib/libnodelist.a
MBNEWUSR_OBJS = mbnewusr.o newuser.o language.o timeout.o dispfile.o oneline.o ttyio.o \ MBNEWUSR_OBJS = mbnewusr.o newuser.o language.o timeout.o dispfile.o oneline.o ttyio.o \
timecheck.o input.o exitinfo.o funcs.o misc.o change.o door.o term.o openport.o \ timecheck.o input.o exitinfo.o funcs.o misc.o change.o door.o term.o openport.o \
@ -129,4 +132,6 @@ dispfile.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h ../lib/msg
userlist.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h userlist.h language.h input.h timeout.h term.h ttyio.h userlist.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h userlist.h language.h input.h timeout.h term.h ttyio.h
timestats.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h timestats.h funcs.h language.h input.h exitinfo.h term.h timestats.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h timestats.h funcs.h language.h input.h exitinfo.h term.h
logentry.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h logentry.h logentry.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h logentry.h
zmrle.o: ../config.h ../lib/mbselib.h ../lib/nodelist.h ttyio.h zmodem.h zmrle.h
zmmisc.o: ../config.h ../lib/mbselib.h ../lib/nodelist.h ttyio.h zmodem.h zmrle.h zmmisc.h
# End of generated dependencies # End of generated dependencies

195
mbsebbs/zmrle.c Normal file
View File

@ -0,0 +1,195 @@
/*
* File: zmr.c
* Copyright 1988, 1994 Omen Technology Inc All Rights Reserved
*
* $Id$
*
* This module implements ZMODEM Run Length Encoding, an
* extension that was not funded by the original Telenet
* development contract.
*
* This software may be freely used for non commercial and
* educational (didactic only) purposes. This software may also
* be freely used to support file transfer operations to or from
* licensed Omen Technology products. Any programs which use
* part or all of this software must be provided in source form
* with this notice intact except by written permission from Omen
* Technology Incorporated.
*
* Use of this software for commercial or administrative purposes
* except when exclusively limited to interfacing Omen Technology
* products requires a per port license payment of $20.00 US per
* port (less in quantity). Use of this code by inclusion,
* decompilation, reverse engineering or any other means
* constitutes agreement to these conditions and acceptance of
* liability to license the materials and payment of reasonable
* legal costs necessary to enforce this license agreement.
*
*
* Omen Technology Inc FAX: 503-621-3745
* Post Office Box 4681
* Portland OR 97208
*
* This code is made available in the hope it will be useful,
* BUT WITHOUT ANY WARRANTY OF ANY KIND OR LIABILITY FOR ANY
* DAMAGES OF ANY KIND.
*
* ZMODEM RLE compression and decompression functions
*/
#include "../config.h"
#include "../lib/mbselib.h"
#include "../lib/nodelist.h"
#include "ttyio.h"
#include "zmodem.h"
#include "zmrle.h"
/*
* Send data subpacket RLE encoded with 32 bit FCS
*/
void zsdar32(char *buf, int length, int frameend)
{
register int c, l, n;
register unsigned long crc;
crc = 0xFFFFFFFFL; l = *buf++ & 0377;
if (length == 1) {
zsendline(l); crc = updcrc32(l, crc);
if (l == ZRESC) {
zsendline(1); crc = updcrc32(1, crc);
}
} else {
for (n = 0; --length >= 0; ++buf) {
if ((c = *buf & 0377) == l && n < 126 && length>0) {
++n; continue;
}
switch (n) {
case 0:
zsendline(l);
crc = updcrc32(l, crc);
if (l == ZRESC) {
zsendline(0100); crc = updcrc32(0100, crc);
}
l = c; break;
case 1:
if (l != ZRESC) {
zsendline(l); zsendline(l);
crc = updcrc32(l, crc);
crc = updcrc32(l, crc);
n = 0; l = c; break;
}
/* **** FALL THRU TO **** */
default:
zsendline(ZRESC); crc = updcrc32(ZRESC, crc);
if (l == 040 && n < 34) {
n += 036;
zsendline(n); crc = updcrc32(n, crc);
}
else {
n += 0101;
zsendline(n); crc = updcrc32(n, crc);
zsendline(l); crc = updcrc32(l, crc);
}
n = 0; l = c; break;
}
}
}
PUTCHAR(ZDLE); PUTCHAR(frameend);
crc = updcrc32(frameend, crc);
crc = ~crc;
for (length=4; --length >= 0;) {
zsendline((int)crc); crc >>= 8;
}
}
/*
* Receive data subpacket RLE encoded with 32 bit FCS
*/
int zrdatr32(register char *buf, int length)
{
register int c;
register unsigned long crc;
register char *end;
register int d;
crc = 0xFFFFFFFFL; Rxcount = 0; end = buf + length;
d = 0; /* Use for RLE decoder state */
while (buf <= end) {
if ((c = zdlread()) & ~0377) {
crcfoo:
switch (c) {
case GOTCRCE:
case GOTCRCG:
case GOTCRCQ:
case GOTCRCW:
d = c; c &= 0377;
crc = updcrc32(c, crc);
if ((c = zdlread()) & ~0377)
goto crcfoo;
crc = updcrc32(c, crc);
if ((c = zdlread()) & ~0377)
goto crcfoo;
crc = updcrc32(c, crc);
if ((c = zdlread()) & ~0377)
goto crcfoo;
crc = updcrc32(c, crc);
if ((c = zdlread()) & ~0377)
goto crcfoo;
crc = updcrc32(c, crc);
if (crc != 0xDEBB20E3) {
Syslog('+', "Zmodem zrdatr32: Bad CRC");
return TERROR;
}
Rxcount = length - (end - buf);
Syslog('z', "zrdatr32: %d %s", Rxcount,
Zendnames[(d-GOTCRCE)&3]);
return d;
case GOTCAN:
Syslog('+', "Zmodem: Sender Canceled");
return ZCAN;
case TIMEOUT:
Syslog('+', "Zmodem: TIMEOUT");
return c;
default:
Syslog('+', "Zmodem: Bad data subpacket");
return c;
}
}
crc = updcrc32(c, crc);
switch (d) {
case 0:
if (c == ZRESC) {
d = -1; continue;
}
*buf++ = c; continue;
case -1:
if (c >= 040 && c < 0100) {
d = c - 035; c = 040; goto spaces;
}
if (c == 0100) {
d = 0;
*buf++ = ZRESC; continue;
}
d = c; continue;
default:
d -= 0100;
if (d < 1)
goto badpkt;
spaces:
if ((buf + d) > end)
goto badpkt;
while ( --d >= 0)
*buf++ = c;
d = 0; continue;
}
}
badpkt:
Syslog('+', "Zmodem: Data subpacket too long");
return TERROR;
}