Skip to content
Snippets Groups Projects
Commit e1d0ddb0 authored by rswindell's avatar rswindell
Browse files

New project: Synchronet External X/Y/Zmodem (formerly STP)

parent f947dd64
No related branches found
No related tags found
No related merge requests found
......@@ -207,6 +207,18 @@ Package=<4>
###############################################################################
Project: "sexyz"=.\sexyz.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "smbutil"=.\smbutil.dsp - Package Owner=<4>
Package=<5>
......
This diff is collapsed.
# Microsoft Developer Studio Project File - Name="sexyz" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=sexyz - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "sexyz.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "sexyz.mak" CFG="sexyz - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "sexyz - Win32 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "sexyz - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "sexyz - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "msvc.win32.exe.release"
# PROP Intermediate_Dir "msvc.win32.exe.release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /I "..\xpdev" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "SBBS_EXPORTS" /YX /FD /c
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /nologo /subsystem:console /machine:I386
!ELSEIF "$(CFG)" == "sexyz - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "sexyz___Win32_Debug"
# PROP BASE Intermediate_Dir "sexyz___Win32_Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "msvc.win32.exe.debug"
# PROP Intermediate_Dir "msvc.win32.exe.debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\xpdev" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "SBBS_EXPORTS" /YX /FD /GZ /c
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
!ENDIF
# Begin Target
# Name "sexyz - Win32 Release"
# Name "sexyz - Win32 Debug"
# Begin Source File
SOURCE=.\crc16.c
# End Source File
# Begin Source File
SOURCE=.\crc32.c
# End Source File
# Begin Source File
SOURCE=..\xpdev\dirwrap.c
# End Source File
# Begin Source File
SOURCE=..\xpdev\genwrap.c
# End Source File
# Begin Source File
SOURCE=.\sexyz.c
# End Source File
# Begin Source File
SOURCE=..\xpdev\sockwrap.c
# End Source File
# Begin Source File
SOURCE=.\telnet.c
# End Source File
# Begin Source File
SOURCE=.\xmodem.c
# End Source File
# Begin Source File
SOURCE=.\zmodem.c
# End Source File
# End Target
# End Project
/* sexyz.h */
/* Synchronet External X/Y/ZMODEM Transfer Program */
/* $Id$ */
/****************************************************************************
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2003 Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* See the GNU General Public License for more details: gpl.txt or *
* http://www.fsf.org/copyleft/gpl.html *
* *
* Anonymous FTP access to the most recent released source is available at *
* ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net *
* *
* Anonymous CVS access to the development source and modification history *
* is available at cvs.synchro.net:/cvsroot/sbbs, example: *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs login *
* (just hit return, no password is necessary) *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs checkout src *
* *
* For Synchronet coding style and modification guidelines, see *
* http://www.synchro.net/source.html *
* *
* You are encouraged to submit any modifications (preferably in Unix diff *
* format) via e-mail to mods@synchro.net *
* *
* Note: If this box doesn't appear square, then you need to fix your tabs. *
****************************************************************************/
#include "xmodem.h"
#include "zmodem.h"
#define MAXERRORS 10
#if 0
#define DLE CTRL_P /* Data link escape */
#define XON CTRL_Q /* Resume transmission */
#define XOFF CTRL_S /* Pause transmission */
#define SOH CTRL_A /* Start of header */
#define EOT CTRL_D /* End of transmission */
#define ACK CTRL_F /* Acknowledge */
#define NAK CTRL_U /* Negative Acknowledge */
#define CAN CTRL_X /* Cancel */
#endif
#define CPMEOF CTRL_Z /* CP/M End of file (^Z) */
#define LOC_ABORT 0x2e03 /* Local abort key (^C) */
#define SEND (1<<0) /* Sending file(s) */
#define RECV (1<<1) /* Receiving file(s) */
#define XMODEM (1<<2) /* Use Xmodem */
#define YMODEM (1<<3) /* Use Ymodem */
#define ZMODEM (1<<4) /* Use Zmodem */
#define CRC (1<<5) /* Use CRC error correction */
#define GMODE (1<<6) /* For Qmodem-G and Ymodem-G */
#define DIR (1<<7) /* Directory specified to download to */
#define DEBUG (1<<8) /* Debug output */
#define OVERWRITE (1<<9) /* Overwrite receiving files */
#define IGNORE_DCD (1<<10) /* Ignore DCD */
#define ALARM (1<<11) /* Alarm when starting and stopping xfer */
#define NO_LOCAL (1<<12) /* Don't check local keyboard */
#define PAUSE_ABEND (1<<13) /* Pause on abnormal exit */
#define TELNET (1<<14) /* Telnet IAC escaping */
/* Zmodem mode bits */
#define CTRL_ESC (1<<0) /* Escape all control chars */
#define VAR_HDRS (1<<1) /* Use variable headers */
#define NOINP 0x0100 /* input buffer empty (incom only) */
uint recv_byte(SOCKET sock, int timeout, long mode);
int send_byte(SOCKET sock, uchar ch, int timeout, long mode);
char* chr(uchar ch);
void bail(int code);
\ No newline at end of file
/* xmodem.c */
/* Synchronet X/YMODEM Functions */
/* $Id$ */
/****************************************************************************
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2003 Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* See the GNU General Public License for more details: gpl.txt or *
* http://www.fsf.org/copyleft/gpl.html *
* *
* Anonymous FTP access to the most recent released source is available at *
* ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net *
* *
* Anonymous CVS access to the development source and modification history *
* is available at cvs.synchro.net:/cvsroot/sbbs, example: *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs login *
* (just hit return, no password is necessary) *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs checkout src *
* *
* For Synchronet coding style and modification guidelines, see *
* http://www.synchro.net/source.html *
* *
* You are encouraged to submit any modifications (preferably in Unix diff *
* format) via e-mail to mods@synchro.net *
* *
* Note: If this box doesn't appear square, then you need to fix your tabs. *
****************************************************************************/
#include "sexyz.h"
#include "genwrap.h" /* YIELD */
#include "conwrap.h" /* kbhit */
#define getcom(t) recv_byte(xm->sock,t,xm->mode)
#define putcom(ch) send_byte(xm->sock,ch,10,xm->mode)
#define newline() fprintf(xm->statfp,"\n");
void xmodem_put_nak(xmodem_t* xm)
{
while(getcom(1)!=NOINP && (xm->mode&NO_LOCAL || kbhit()!=LOC_ABORT))
; /* wait for any trailing data */
putcom(NAK);
}
void xmodem_cancel(xmodem_t* xm)
{
int i;
for(i=0;i<8;i++)
putcom(CAN);
for(i=0;i<10;i++)
putcom('\b');
}
/****************************************************************************/
/* Receive a X/Ymodem block (sector) from COM port */
/* hdrblock is 1 if attempting to get Ymodem header block, 0 if data block */
/* Returns blocknum if all went well, -1 on error or CAN, and -EOT if EOT */
/****************************************************************************/
int xmodem_get_block(xmodem_t* xm, uchar* block, uint block_size, BOOL hdrblock)
{
uchar block_num; /* Block number received in header */
uchar chksum,calc_chksum;
int i,errors,eot=0,can=0;
uint b;
ushort crc,calc_crc;
for(errors=0;errors<MAXERRORS;errors++) {
i=getcom(10);
if(eot && i!=EOT)
eot=0;
if(can && i!=CAN)
can=0;
switch(i) {
case SOH: /* 128 byte blocks */
block_size=128;
break;
case STX: /* 1024 byte blocks */
block_size=1024;
break;
case EOT:
if((xm->mode&(YMODEM|GMODE))==YMODEM && !eot) {
eot=1;
xmodem_put_nak(xm); /* chuck's double EOT trick */
continue;
}
return(-EOT);
case CAN:
newline();
if(!can) { /* must get two CANs in a row */
can=1;
fprintf(xm->statfp,"Received CAN Expected SOH, STX, or EOT\n");
continue;
}
fprintf(xm->statfp,"Cancelled remotely\n");
bail(-1);
break;
case NOINP: /* Nothing came in */
continue;
default:
newline();
fprintf(xm->statfp,"Received %s Expected SOH, STX, or EOT\n",chr((uchar)i));
if(hdrblock) /* Trying to get Ymodem header block */
return(-1);
xmodem_put_nak(xm);
continue;
}
i=getcom(1);
if(i==NOINP) {
xmodem_put_nak(xm);
continue;
}
block_num=i;
i=getcom(1);
if(i==NOINP) {
xmodem_put_nak(xm);
continue;
}
if(block_num!=(uchar)~i) {
newline();
fprintf(xm->statfp,"Block number error\n");
xmodem_put_nak(xm);
continue;
}
calc_crc=calc_chksum=0;
for(b=0;b<block_size;b++) {
i=getcom(1);
if(i==NOINP)
break;
block[b]=i;
if(xm->mode&CRC)
calc_crc=ucrc16(block[b],calc_crc);
else
calc_chksum+=block[b];
}
if(b<block_size) {
xmodem_put_nak(xm);
continue;
}
if(xm->mode&CRC) {
crc=getcom(1)<<8;
crc|=getcom(1);
}
else
chksum=getcom(1);
if(xm->mode&CRC) {
if(crc==calc_crc)
break;
newline();
fprintf(xm->statfp,"CRC error\n");
}
else /* CHKSUM */
{
if(chksum==calc_chksum)
break;
newline();
fprintf(xm->statfp,"Checksum error\n");
}
if(xm->mode&GMODE) { /* Don't bother sending a NAK. He's not listening */
xmodem_cancel(xm);
bail(1);
}
xmodem_put_nak(xm);
}
if(errors>=MAXERRORS) {
newline();
fprintf(xm->statfp,"Too many errors\n");
return(-1);
}
return(block_num);
}
/*****************/
/* Sends a block */
/*****************/
void xmodem_put_block(xmodem_t* xm, uchar* block, uint block_size, ulong block_num)
{
uchar ch,chksum;
uint i;
ushort crc;
if(block_size==128)
putcom(SOH);
else /* 1024 */
putcom(STX);
ch=(uchar)(block_num&0xff);
putcom(ch);
putcom((uchar)~ch);
chksum=0;
crc=0;
for(i=0;i<block_size;i++) {
putcom(block[i]);
if(xm->mode&CRC)
crc=ucrc16(block[i],crc);
else
chksum+=block[i];
}
if(xm->mode&CRC) {
putcom((uchar)(crc >> 8));
putcom((uchar)(crc&0xff));
}
else
putcom(chksum);
YIELD();
}
/************************************************************/
/* Gets an acknowledgement - usually after sending a block */
/* Returns 1 if ack received, 0 otherwise. */
/************************************************************/
int xmodem_get_ack(xmodem_t* xm, int tries)
{
int i,errors,can=0;
for(errors=0;errors<tries;errors++) {
if(xm->mode&GMODE) { /* Don't wait for ACK on Ymodem-G */
if(getcom(0)==CAN) {
newline();
fprintf(xm->statfp,"Cancelled remotely\n");
xmodem_cancel(xm);
bail(1);
}
return(1);
}
i=getcom(10);
if(can && i!=CAN)
can=0;
if(i==ACK)
return(1);
if(i==CAN) {
if(can) {
newline();
fprintf(xm->statfp,"Cancelled remotely\n");
xmodem_cancel(xm);
bail(1);
}
can=1;
}
if(i!=NOINP) {
newline();
fprintf(xm->statfp,"Received %s Expected ACK\n",chr((uchar)i));
if(i!=CAN)
return(0);
}
}
return(0);
}
/* xmodem.h */
/* Synchronet X/YMODEM Functions */
/* $Id$ */
/****************************************************************************
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2003 Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* See the GNU General Public License for more details: gpl.txt or *
* http://www.fsf.org/copyleft/gpl.html *
* *
* Anonymous FTP access to the most recent released source is available at *
* ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net *
* *
* Anonymous CVS access to the development source and modification history *
* is available at cvs.synchro.net:/cvsroot/sbbs, example: *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs login *
* (just hit return, no password is necessary) *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs checkout src *
* *
* For Synchronet coding style and modification guidelines, see *
* http://www.synchro.net/source.html *
* *
* You are encouraged to submit any modifications (preferably in Unix diff *
* format) via e-mail to mods@synchro.net *
* *
* Note: If this box doesn't appear square, then you need to fix your tabs. *
****************************************************************************/
#ifndef _XMODEM_H_
#define _XMODEM_H_
#include <stdio.h> /* FILE */
#include <sockwrap.h> /* SOCKET */
#include "crc16.h"
typedef struct {
SOCKET sock; /* socket descriptor */
long mode;
FILE* statfp;
FILE* errfp;
} xmodem_t;
void xmodem_cancel(xmodem_t* xm);
int xmodem_get_ack(xmodem_t* xm, int tries);
void xmodem_put_nak(xmodem_t* xm);
int xmodem_get_block(xmodem_t* xm, uchar* block, uint block_size, BOOL hdrblock);
void xmodem_put_block(xmodem_t* xm, uchar* block, uint block_size, ulong block_num);
#endif /* Don't add anything after this line */
\ No newline at end of file
This diff is collapsed.
/*
* zmodem.h
* zmodem constants
* (C) Mattheij Computer Service 1994
*/
/* $Id$ */
#ifndef _ZMODEM_H
#define _ZMODEM_H
/*
* ascii constants
*/
#ifndef SOH
#define SOH 0x01
#define STX 0x02
#define EOT 0x04
#define ENQ 0x05
#define ACK 0x06
#if 0
#define LF 0x0a
#define CR 0x0d
#endif
#define XON 0x11
#define XOFF 0x13
#define NAK 0x15
#define CAN 0x18
#endif
/*
* zmodem constants
*/
#define ZMAXHLEN 0x10 /* maximum header information length */
#define ZMAXSPLEN 0x400 /* maximum subpacket length */
#define ZPAD 0x2a /* pad character; begins frames */
#define ZDLE 0x18 /* ctrl-x zmodem escape */
#define ZDLEE 0x58 /* escaped ZDLE */
#define ZBIN 0x41 /* binary frame indicator (CRC16) */
#define ZHEX 0x42 /* hex frame indicator */
#define ZBIN32 0x43 /* binary frame indicator (CRC32) */
#define ZBINR32 0x44 /* run length encoded binary frame (CRC32) */
#define ZVBIN 0x61 /* binary frame indicator (CRC16) */
#define ZVHEX 0x62 /* hex frame indicator */
#define ZVBIN32 0x63 /* binary frame indicator (CRC32) */
#define ZVBINR32 0x64 /* run length encoded binary frame (CRC32) */
#define ZRESC 0x7e /* run length encoding flag / escape character */
/*
* zmodem frame types
*/
#define ZRQINIT 0x00 /* request receive init (s->r) */
#define ZRINIT 0x01 /* receive init (r->s) */
#define ZSINIT 0x02 /* send init sequence (optional) (s->r) */
#define ZACK 0x03 /* ack to ZRQINIT ZRINIT or ZSINIT (s<->r) */
#define ZFILE 0x04 /* file name (s->r) */
#define ZSKIP 0x05 /* skip this file (r->s) */
#define ZNAK 0x06 /* last packet was corrupted (?) */
#define ZABORT 0x07 /* abort batch transfers (?) */
#define ZFIN 0x08 /* finish session (s<->r) */
#define ZRPOS 0x09 /* resume data transmission here (r->s) */
#define ZDATA 0x0a /* data packet(s) follow (s->r) */
#define ZEOF 0x0b /* end of file reached (s->r) */
#define ZFERR 0x0c /* fatal read or write error detected (?) */
#define ZCRC 0x0d /* request for file CRC and response (?) */
#define ZCHALLENGE 0x0e /* security challenge (r->s) */
#define ZCOMPL 0x0f /* request is complete (?) */
#define ZCAN 0x10 /* pseudo frame;
other end cancelled session with 5* CAN */
#define ZFREECNT 0x11 /* request free bytes on file system (s->r) */
#define ZCOMMAND 0x12 /* issue command (s->r) */
#define ZSTDERR 0x13 /* output data to stderr (??) */
/*
* ZDLE sequences
*/
#define ZCRCE 0x68 /* CRC next, frame ends, header packet follows */
#define ZCRCG 0x69 /* CRC next, frame continues nonstop */
#define ZCRCQ 0x6a /* CRC next, frame continuous, ZACK expected */
#define ZCRCW 0x6b /* CRC next, frame ends, ZACK expected */
#define ZRUB0 0x6c /* translate to rubout 0x7f */
#define ZRUB1 0x6d /* translate to rubout 0xff */
/*
* frame specific data.
* entries are prefixed with their location in the header array.
*/
/*
* Byte positions within header array
*/
#define FTYPE 0 /* frame type */
#define ZF0 4 /* First flags byte */
#define ZF1 3
#define ZF2 2
#define ZF3 1
#define ZP0 1 /* Low order 8 bits of position */
#define ZP1 2
#define ZP2 3
#define ZP3 4 /* High order 8 bits of file position */
/*
* ZRINIT frame
* zmodem receiver capability flags
*/
#define ZF0_CANFDX 0x01 /* Receiver can send and receive true full duplex */
#define ZF0_CANOVIO 0x02 /* receiver can receive data during disk I/O */
#define ZF0_CANBRK 0x04 /* receiver can send a break signal */
#define ZF0_CANCRY 0x08 /* Receiver can decrypt DONT USE */
#define ZF0_CANLZW 0x10 /* Receiver can uncompress DONT USE */
#define ZF0_CANFC32 0x20 /* Receiver can use 32 bit Frame Check */
#define ZF0_ESCCTL 0x40 /* Receiver expects ctl chars to be escaped */
#define ZF0_ESC8 0x80 /* Receiver expects 8th bit to be escaped */
#define ZF1_CANVHDR 0x01 /* Variable headers OK */
/*
* ZSINIT frame
* zmodem sender capability
*/
#define ZF0_TESCCTL 0x40 /* Transmitter expects ctl chars to be escaped */
#define ZF0_TESC8 0x80 /* Transmitter expects 8th bit to be escaped */
#define ZATTNLEN 0x20 /* Max length of attention string */
#define ALTCOFF ZF1 /* Offset to alternate canit string, 0 if not used */
/*
* ZFILE frame
*/
/*
* Conversion options one of these in ZF0
*/
#define ZF0_ZCBIN 1 /* Binary transfer - inhibit conversion */
#define ZF0_ZCNL 2 /* Convert NL to local end of line convention */
#define ZF0_ZCRESUM 3 /* Resume interrupted file transfer */
/*
* Management include options, one of these ored in ZF1
*/
#define ZF1_ZMSKNOLOC 0x80 /* Skip file if not present at rx */
#define ZF1_ZMMASK 0x1f /* Mask for the choices below */
#define ZF1_ZMNEWL 1 /* Transfer if source newer or longer */
#define ZF1_ZMCRC 2 /* Transfer if different file CRC or length */
#define ZF1_ZMAPND 3 /* Append contents to existing file (if any) */
#define ZF1_ZMCLOB 4 /* Replace existing file */
#define ZF1_ZMNEW 5 /* Transfer if source newer */
#define ZF1_ZMDIFF 6 /* Transfer if dates or lengths different */
#define ZF1_ZMPROT 7 /* Protect destination file */
#define ZF1_ZMCHNG 8 /* Change filename if destination exists */
/*
* Transport options, one of these in ZF2
*/
#define ZF2_ZTNOR 0 /* no compression */
#define ZF2_ZTLZW 1 /* Lempel-Ziv compression */
#define ZF2_ZTRLE 3 /* Run Length encoding */
/*
* Extended options for ZF3, bit encoded
*/
#define ZF3_ZCANVHDR 0x01 /* Variable headers OK */
/* Receiver window size override */
#define ZF3_ZRWOVR 0x04 /* byte position for receive window override/256 */
#define ZF3_ZXSPARS 0x40 /* encoding for sparse file operations */
/*
* ZCOMMAND frame
*/
#define ZF0_ZCACK1 0x01 /* Acknowledge, then do command */
typedef struct {
SOCKET sock; /* socket descriptor */
unsigned char rxd_header[ZMAXHLEN]; /* last received header */
int rxd_header_len; /* last received header size */
/*
* receiver capability flags
* extracted from the ZRINIT frame as received
*/
int can_full_duplex;
int can_overlap_io;
int can_break;
int can_fcs_32;
int want_fcs_16;
int escape_all_control_characters; /* guess */
int escape_8th_bit;
int use_variable_headers; /* use variable length headers */
/*
* file management options.
* only one should be on
*/
int management_newer;
int management_clobber;
int management_protect;
/* from zmtx.c */
#define MAX_SUBPACKETSIZE 1024
int n_files_remaining;
int n_bytes_remaining;
unsigned char tx_data_subpacket[MAX_SUBPACKETSIZE];
long current_file_size;
time_t transfer_start;
int receive_32_bit_data;
int raw_trace;
int use_crc16;
long ack_file_pos; /* file position used in acknowledgement of correctly */
/* received data subpackets */
int last_sent;
int n_cans;
long mode;
} zmodem_t;
int zmodem_get_zrinit(zmodem_t* zm);
void zmodem_parse_zrinit(zmodem_t* zm);
int zmodem_send_zfin(zmodem_t* zm);
int zmodem_send_file(zmodem_t* zm, char* name, FILE* fp);
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment