Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
c30e0acb
Commit
c30e0acb
authored
22 years ago
by
rswindell
Browse files
Options
Downloads
Patches
Plain Diff
Beginning of port to Win32/socket - just X and Ymodem(-G) for now.
parent
a3faf9d9
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/stp/make.bat
+1
-2
1 addition, 2 deletions
src/stp/make.bat
src/stp/stp.c
+1256
-1651
1256 additions, 1651 deletions
src/stp/stp.c
with
1257 additions
and
1653 deletions
src/stp/make.bat
+
1
−
2
View file @
c30e0acb
@echo
off
bcc32
-I
..\xpdev
;
..\sbbs3
stp
.c ..\xpdev\dirwrap.c ..\xpdev\genwrap.c ..\xpdev\sockwrap.c ..\sbbs3\crc16.c
bcc
-P-c -N -C -ms -w-pro
stp
rciols
.obj ..\mswait\dos\mswaits.obj
This diff is collapsed.
Click to expand it.
src/stp/stp.c
+
1256
−
1651
View file @
c30e0acb
...
@@ -4,25 +4,30 @@
...
@@ -4,25 +4,30 @@
/* Synchronet Transfer Protocols */
/* Synchronet Transfer Protocols */
#include
<io.h>
#include
<dos.h>
#include
<dir.h>
#include
<time.h>
#include
<time.h>
#include
<alloc.h>
#include
<stdio.h>
#include
<stdio.h>
#include
<fcntl.h>
#include
<errno.h>
#include
<errno.h>
#include
<string.h>
#include
<string.h>
#include
<stdlib.h>
#include
<stdlib.h>
#include
<stdarg.h>
#include
<stdarg.h>
#include
<sys/stat.h>
#include
<sys/stat.h>
#include
"conwrap.h"
#include
"genwrap.h"
#include
"dirwrap.h"
#include
"filewrap.h"
#include
"sockwrap.h"
#include
"crc16.h"
#define STP 1
#define STP 1
#include
"zmodem.h"
#include
"zmodem.h"
#define MAXERRORS 10
#define MAXERRORS 10
#if 0
#define ERROR -1
#define ERROR -1
/* Various Character/Ctrl-Code Definitions */
/* Various Character/Ctrl-Code Definitions */
#define SP 32 /* Space bar */
#define SP 32 /* Space bar */
...
@@ -32,22 +37,24 @@
...
@@ -32,22 +37,24 @@
#define LF 10 /* Line Feed */
#define LF 10 /* Line Feed */
#define TAB 9 /* Horizontal Tabulation */
#define TAB 9 /* Horizontal Tabulation */
#define BS 8 /* Back Space */
#define BS 8 /* Back Space */
#define SOH 1
/* Start of header */
#define STX 2 /* Start of text */
#define STX 2 /* Start of text */
#define ETX 3 /* End of text */
#define ETX 3 /* End of text */
#define EOT 4
/* End of transmission */
#define ACK 6
/* Acknowledge */
#define DLE 16
/* Data link escape */
#define XON 17
/* Ctrl-Q - resume transmission */
#define XOFF 19
/* Ctrl-S - pause transmission */
#define NAK 21
/* Negative Acknowledge */
#define CAN 24
/* Cancel */
#define CPMEOF 26
/* CP/M End of file (^Z) */
#define LOC_ABORT 0x2e03
/* Local abort key (^C) */
#define uchar unsigned char
#endif
#define uint unsigned int
#define ulong unsigned long
#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 */
#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 SEND (1<<0)
/* Sending file(s) */
#define RECV (1<<1)
/* Receiving file(s) */
#define RECV (1<<1)
/* Receiving file(s) */
...
@@ -93,89 +100,7 @@
...
@@ -93,89 +100,7 @@
#define OVRR 0x02
/* Overrun */
#define OVRR 0x02
/* Overrun */
#define RXLOST 0x01
/* Receive buffer overflow */
#define RXLOST 0x01
/* Receive buffer overflow */
/* rioctl() arguments */
void
cancel
(
void
);
/* returns mode or state flags in high 8 bits, status flags in low 8 bits */
/* the following return mode in high 8 bits */
#define IOMODE 0
/* no operation */
#define IOSM 1
/* i/o set mode flags */
#define IOCM 2
/* i/o clear mode flags */
#define GVERS 0x007
/* get version */
#define GUART 0x107
/* get uart */
#define GIRQN 0x207
/* get IRQ number */
#define GBAUD 0x307
/* get baud */
/* the following return state in high 8 bits */
#define IOSTATE 4
/* no operation */
#define IOSS 5
/* i/o set state flags */
#define IOCS 6
/* i/o clear state flags */
#define IOFB 0x308
/* i/o buffer flush */
#define IOFI 0x208
/* input buffer flush */
#define IOFO 0x108
/* output buffer flush */
#define IOCE 9
/* i/o clear error flags */
#define TS_INT28 1
#define TS_WINOS2 2
#define TS_NODV 4
/* return count (16bit) */
#define RXBC 0x000a
/* get receive buffer count */
#define RXBS 0x010a
/* get receive buffer size */
#define TXBC 0x000b
/* get transmit buffer count */
#define TXBS 0x010b
/* get transmit buffer size */
#define TXBF 0x020b
/* get transmit buffer free space */
#define TXSYNC 0x000c
/* sync transmition (seconds<<8|0x0c) */
#define IDLE 0x000d
/* suspend communication routines */
#define RESUME 0x010d
/* return from suspended state */
#define RLERC 0x000e
/* read line error count and clear */
#define CPTON 0x0110
/* set input translation flag for ctrl-p on */
#define CPTOFF 0x0010
/* set input translation flag for ctrl-p off */
#define GETCPT 0x8010
/* return the status of ctrl-p translation */
#define MSR 0x0011
/* read modem status register */
#define FIFOCTL 0x0012
/* FIFO UART control */
#define TSTYPE 0x0013
/* Time-slice API type */
#define GETTST 0x8013
/* Get Time-slice API type */
/* ivhctl() arguments */
#define INT29R 1
/* copy int 29h output to remote */
#define INT29L 2
/* Use _putlc for int 29h */
#define INT16 0x10
/* return remote chars to int 16h calls */
#define INTCLR 0
/* release int 16h, int 29h */
#define DCDHIGH (rioctl(IOSTATE)&DCD || mode&IGNORE_DCD)
/**************/
/* Prototypes */
/**************/
/* LCLOLL.ASM */
int
lclini
(
int
);
void
lclxy
(
int
,
int
);
int
lclwx
(
void
);
int
lclwy
(
void
);
int
lclatr
(
int
);
int
lclaes
(
void
);
void
lputc
(
int
);
long
lputs
(
char
far
*
);
uint
lkbrd
(
int
);
/* RCIOLL.ASM */
int
rioini
(
int
com
,
int
irq
);
/* initialize com,irq */
int
setbaud
(
int
rate
);
/* set baud rate */
int
rioctl
(
int
action
);
/* remote i/o control */
int
dtr
(
char
onoff
);
/* set/reset dtr */
int
incom
(
void
);
/* receive character */
int
ivhctl
(
int
intcode
);
/* local i/o redirection */
void
riosync
();
void
cancel
();
extern
mswtyp
;
extern
uint
riobp
;
uint
asmrev
;
/***************/
/***************/
/* Global Vars */
/* Global Vars */
...
@@ -189,6 +114,9 @@ ulong block_num; /* Block number */
...
@@ -189,6 +114,9 @@ ulong block_num; /* Block number */
ulong
last_block_num
;
/* Last block number sent */
ulong
last_block_num
;
/* Last block number sent */
uint
flows
=
0
;
/* Number of flow controls */
uint
flows
=
0
;
/* Number of flow controls */
FILE
*
errfp
;
FILE
*
statfp
;
/**************************************/
/**************************************/
/* Zmodem specific, from Chuck's RZSZ */
/* Zmodem specific, from Chuck's RZSZ */
/**************************************/
/**************************************/
...
@@ -205,81 +133,49 @@ int Rxtype; /* Type of header received */
...
@@ -205,81 +133,49 @@ int Rxtype; /* Type of header received */
int
Rxhlen
;
/* Length of header received */
int
Rxhlen
;
/* Length of header received */
int
Rxcount
;
/* Count of data bytes received */
int
Rxcount
;
/* Count of data bytes received */
/********/
SOCKET
sock
;
/* Code */
#define DCDHIGH socket_check(sock, NULL, NULL, 0)
/********/
int
cbreakh
()
#ifdef _WINSOCKAPI_
{
return
(
1
);
}
/****************************************************************************/
WSADATA
WSAData
;
/* Performs printf() through local assembly routines */
static
BOOL
WSAInitialized
=
FALSE
;
/****************************************************************************/
int
lprintf
(
char
*
fmat
,
...
)
static
BOOL
winsock_startup
(
void
)
{
{
va_list
argptr
;
int
status
;
/* Status Code */
char
sbuf
[
2048
];
int
chcount
;
va_start
(
argptr
,
fmat
);
if
((
status
=
WSAStartup
(
MAKEWORD
(
1
,
1
),
&
WSAData
))
==
0
)
{
chcount
=
vsprintf
(
sbuf
,
fmat
,
argptr
);
fprintf
(
statfp
,
"%s %s
\n
"
,
WSAData
.
szDescription
,
WSAData
.
szSystemStatus
);
va_end
(
argptr
);
WSAInitialized
=
TRUE
;
lputs
(
sbuf
);
return
(
TRUE
);
return
(
chcount
);
}
}
void
newline
()
fprintf
(
errfp
,
"!WinSock startup ERROR %d
\n
"
,
status
);
{
return
(
FALSE
);
if
(
lclwx
()
>
1
)
lputs
(
"
\r\n
"
);
}
}
/****************************************************************************/
#else
/* No WINSOCK */
/* Network open function. Opens all files DENYALL and retries LOOP_NOPEN */
/* number of times if the attempted file is already open or denying access */
/* for some other reason. All files are opened in BINARY mode. */
/****************************************************************************/
int
nopen
(
char
*
str
,
int
access
)
{
char
count
=
0
,
logstr
[
256
];
int
file
,
share
;
if
(
access
==
O_RDONLY
)
share
=
O_DENYWRITE
;
#define winsock_startup() (TRUE)
else
share
=
O_DENYALL
;
while
(((
file
=
open
(
str
,
O_BINARY
|
share
|
access
,
S_IWRITE
))
==-
1
)
&&
errno
==
EACCES
&&
count
++<
LOOP_NOPEN
);
if
(
file
==-
1
&&
errno
==
EACCES
)
lprintf
(
"
\7\r\n
NOPEN: ACCESS DENIED
\r\n\7
"
);
return
(
file
);
}
#endif
/****************************************************************************/
/********/
/* Converts an ASCII Hex string into an ulong */
/* Code */
/****************************************************************************/
/********/
ulong
ahtoul
(
char
*
str
)
{
ulong
l
,
val
=
0
;
while
((
l
=
(
*
str
++
)
|
0x20
)
!=
0x20
)
void
newline
(
void
)
val
=
(
l
&
0xf
)
+
(
l
>>
6
&
1
)
*
9
+
val
*
16
;
{
return
(
val
);
#if 0
if(lclwx()>1)
fprintf(statfp,"\n");
#endif
}
}
/****************************************************************************/
int
incom
(
void
);
/* Checks the disk drive for the existence of a file. Returns 1 if it */
int
outcom
(
char
);
/* exists, 0 if it doesn't. */
/****************************************************************************/
char
fexist
(
char
*
filespec
)
{
struct
ffblk
f
;
if
(
findfirst
(
filespec
,
&
f
,
0
)
==
NULL
)
return
(
1
);
return
(
0
);
}
/****************************************************************************/
/****************************************************************************/
/* Truncates white-space chars off end of 'str' and terminates at first tab */
/* Truncates white-space chars off end of 'str' and terminates at first tab */
...
@@ -301,16 +197,18 @@ void bail(int code)
...
@@ -301,16 +197,18 @@ void bail(int code)
{
{
if
(
mode
&
ALARM
)
{
if
(
mode
&
ALARM
)
{
sound
(
2000
);
BEEP
(
2000
,
500
);
mswait
(
500
);
BEEP
(
1000
,
500
);
sound
(
1000
);
}
mswait
(
500
);
nosound
();
}
riosync
();
rioini
(
0
,
0
);
/* uninstall com routines */
newline
();
newline
();
l
printf
(
"Exiting - Error level: %d Flow restraint count: %u
\
r\
n
"
,
code
,
flows
);
f
printf
(
statfp
,
"Exiting - Error level: %d Flow restraint count: %u
\n
"
,
code
,
flows
);
fcloseall
();
fcloseall
();
#ifdef _WINSOCKAPI_
if
(
WSAInitialized
&&
WSACleanup
()
!=
0
)
fprintf
(
statfp
,
"!WSACleanup ERROR %d
\n
"
,
ERROR_VALUE
);
#endif
exit
(
code
);
exit
(
code
);
}
}
...
@@ -334,16 +232,19 @@ while(time(NULL)-start<(long)timeout) { /* wait up to ten seconds */
...
@@ -334,16 +232,19 @@ while(time(NULL)-start<(long)timeout) { /* wait up to ten seconds */
return
(
ch
);
return
(
ch
);
if
(
!
DCDHIGH
)
{
if
(
!
DCDHIGH
)
{
newline
();
newline
();
lprintf
(
"No carrier
\r\n
"
);
fprintf
(
statfp
,
"No carrier
\n
"
);
bail
(
1
);
}
bail
(
1
);
mswait
(
0
);
}
if
(
!
(
mode
&
NO_LOCAL
)
&&
lkbrd
(
0
)
==
LOC_ABORT
)
{
YIELD
();
if
(
!
(
mode
&
NO_LOCAL
)
&&
kbhit
()
==
LOC_ABORT
)
{
newline
();
newline
();
l
printf
(
"Local abort
\
r\
n
"
);
f
printf
(
statfp
,
"Local abort
\n
"
);
cancel
();
cancel
();
bail
(
1
);
}
}
bail
(
1
);
}
}
newline
();
newline
();
l
printf
(
"Input timeout
\
r\
n
"
);
f
printf
(
statfp
,
"Input timeout
\n
"
);
return
(
NOINP
);
return
(
NOINP
);
}
}
...
@@ -355,34 +256,39 @@ void putcom(uchar ch)
...
@@ -355,34 +256,39 @@ void putcom(uchar ch)
int
i
=
0
;
int
i
=
0
;
while
(
outcom
(
ch
)
&
TXBOF
&&
i
<
180
)
{
/* 10 sec delay */
while
(
outcom
(
ch
)
&
TXBOF
&&
i
<
180
)
{
/* 10 sec delay */
if
(
!
i
)
lputc
(
'F'
);
if
(
!
i
)
fprintf
(
statfp
,
"F"
);
if
(
!
DCDHIGH
)
{
if
(
!
DCDHIGH
)
{
newline
();
newline
();
lprintf
(
"No carrier
\r\n
"
);
fprintf
(
statfp
,
"No carrier
\n
"
);
bail
(
1
);
}
bail
(
1
);
}
i
++
;
i
++
;
mswait
(
1
);
YIELD
(
);
if
(
!
(
mode
&
NO_LOCAL
)
&&
l
kb
rd
(
0
)
==
LOC_ABORT
)
{
if
(
!
(
mode
&
NO_LOCAL
)
&&
kb
hit
(
)
==
LOC_ABORT
)
{
newline
();
newline
();
lprintf
(
"Local abort
\r\n
"
);
fprintf
(
statfp
,
"Local abort
\n
"
);
bail
(
1
);
}
}
bail
(
1
);
}
}
if
(
i
)
{
if
(
i
)
{
l
printf
(
"
\b
\b
"
);
f
printf
(
statfp
,
"
\b
\b
"
);
flows
++
;
flows
++
;
if
(
i
==
180
)
{
if
(
i
==
180
)
{
newline
();
newline
();
lprintf
(
"Output timeout
\r\n
"
);
fprintf
(
statfp
,
"Output timeout
\n
"
);
bail
(
1
);
}
}
bail
(
1
);
}
}
}
}
void
put_nak
()
void
put_nak
(
void
)
{
{
while
(
getcom
(
1
)
!=
NOINP
&&
(
mode
&
NO_LOCAL
||
l
kb
rd
(
0
)
!=
LOC_ABORT
))
while
(
getcom
(
1
)
!=
NOINP
&&
(
mode
&
NO_LOCAL
||
kb
hit
(
)
!=
LOC_ABORT
))
;
/* wait for any trailing data */
;
/* wait for any trailing data */
putcom
(
NAK
);
putcom
(
NAK
);
}
}
void
cancel
()
void
cancel
(
void
)
{
{
int
i
;
int
i
;
...
@@ -392,46 +298,6 @@ for(i=0;i<10;i++)
...
@@ -392,46 +298,6 @@ for(i=0;i<10;i++)
putcom
(
BS
);
putcom
(
BS
);
}
}
/********************************/
/* Update the CRC bytes */
/********************************/
/****
void update_crc(uchar c, uchar *crc1, uchar *crc2)
{
int i, temp;
uchar carry, c_crc1, c_crc2;
for (i=0; i < 8; i++) {
temp = c * 2;
c = temp; /* rotate left */
carry
=
((
temp
>
255
)
?
1
:
0
);
temp
=
(
*
crc2
)
*
2
;
(
*
crc2
)
=
temp
;
(
*
crc2
)
|=
carry
;
/* rotate with carry */
c_crc2
=
((
temp
>
255
)
?
1
:
0
);
temp
=
(
*
crc1
)
*
2
;
(
*
crc1
)
=
temp
;
(
*
crc1
)
|=
c_crc2
;
c_crc1
=
((
temp
>
255
)
?
1
:
0
);
if
(
c_crc1
)
{
(
*
crc2
)
^=
0x21
;
(
*
crc1
)
^=
0x10
;
}
}
}
***
*/
void
ucrc16
(
uchar
ch
,
uint
*
rcrc
)
{
uint
i
,
cy
;
uchar
nch
=
ch
;
for
(
i
=
0
;
i
<
8
;
i
++
)
{
cy
=*
rcrc
&
0x8000
;
*
rcrc
<<=
1
;
if
(
nch
&
0x80
)
*
rcrc
|=
1
;
nch
<<=
1
;
if
(
cy
)
*
rcrc
^=
0x1021
;
}
}
char
*
chr
(
uchar
ch
)
char
*
chr
(
uchar
ch
)
{
{
static
char
str
[
25
];
static
char
str
[
25
];
...
@@ -453,38 +319,8 @@ switch(ch) {
...
@@ -453,38 +319,8 @@ switch(ch) {
return
(
"CAN"
);
return
(
"CAN"
);
default:
default:
sprintf
(
str
,
"%02Xh"
,
ch
);
sprintf
(
str
,
"%02Xh"
,
ch
);
return
(
str
);
}
return
(
str
);
}
}
/****************************************************************/
/* Gets the filename from the filename and optional path in buf */
/****************************************************************/
char
*
justfname
(
char
*
buf
,
char
*
out
)
{
char
*
p1
,
*
p2
;
if
(
mode
&
DEBUG
)
lprintf
(
"justfname: in: '%s'
\r\n
"
,
buf
);
p1
=
buf
;
while
(
*
p1
)
{
if
((
p2
=
strchr
(
p1
,
':'
))
!=
NULL
)
{
/* Remove path */
p1
=
p2
+
1
;
continue
;
}
if
((
p2
=
strchr
(
p1
,
'/'
))
!=
NULL
)
{
p1
=
p2
+
1
;
continue
;
}
if
((
p2
=
strchr
(
p1
,
'\\'
))
!=
NULL
)
{
p1
=
p2
+
1
;
continue
;
}
break
;
}
if
(
!*
p1
)
{
lprintf
(
"Invalid filename
\r\n
"
);
strcpy
(
out
,
""
);
}
else
strcpy
(
out
,
p1
);
/* Use just the filename */
if
(
mode
&
DEBUG
)
lprintf
(
"justfname: out: '%s'
\r\n
"
,
out
);
return
(
out
);
}
}
/****************************************************************************/
/****************************************************************************/
...
@@ -495,8 +331,9 @@ return(out);
...
@@ -495,8 +331,9 @@ return(out);
int
get_block
(
int
hdrblock
)
int
get_block
(
int
hdrblock
)
{
{
uchar
chksum
,
calc_chksum
;
uchar
chksum
,
calc_chksum
;
int
i
,
b
,
errors
,
eot
=
0
,
can
=
0
;
int
i
,
errors
,
eot
=
0
,
can
=
0
;
uint
crc
,
calc_crc
;
uint
b
;
ushort
crc
,
calc_crc
;
for
(
errors
=
0
;
errors
<
MAXERRORS
;
errors
++
)
{
for
(
errors
=
0
;
errors
<
MAXERRORS
;
errors
++
)
{
i
=
getcom
(
10
);
i
=
getcom
(
10
);
...
@@ -515,39 +352,45 @@ for(errors=0;errors<MAXERRORS;errors++) {
...
@@ -515,39 +352,45 @@ for(errors=0;errors<MAXERRORS;errors++) {
if
((
mode
&
(
YMODEM
|
GMODE
))
==
YMODEM
&&
!
eot
)
{
if
((
mode
&
(
YMODEM
|
GMODE
))
==
YMODEM
&&
!
eot
)
{
eot
=
1
;
eot
=
1
;
put_nak
();
/* chuck's double EOT trick */
put_nak
();
/* chuck's double EOT trick */
continue
;
}
continue
;
}
return
(
EOT
);
return
(
EOT
);
case
CAN
:
case
CAN
:
newline
();
newline
();
if
(
!
can
)
{
/* must get two CANs in a row */
if
(
!
can
)
{
/* must get two CANs in a row */
can
=
1
;
can
=
1
;
lprintf
(
"Received CAN Expected SOH, STX, or EOT
\r\n
"
);
fprintf
(
statfp
,
"Received CAN Expected SOH, STX, or EOT
\n
"
);
continue
;
}
continue
;
lprintf
(
"Cancelled remotely
\r\n
"
);
}
fprintf
(
statfp
,
"Cancelled remotely
\n
"
);
return
(
-
1
);
return
(
-
1
);
case
NOINP
:
/* Nothing came in */
case
NOINP
:
/* Nothing came in */
continue
;
continue
;
default:
default:
newline
();
newline
();
l
printf
(
"Received %s Expected SOH, STX, or EOT
\
r\
n
"
,
chr
(
i
));
f
printf
(
statfp
,
"Received %s Expected SOH, STX, or EOT
\n
"
,
chr
(
i
));
if
(
hdrblock
)
/* Trying to get Ymodem header block */
if
(
hdrblock
)
/* Trying to get Ymodem header block */
return
(
-
1
);
return
(
-
1
);
put_nak
();
put_nak
();
continue
;
}
continue
;
}
i
=
getcom
(
1
);
i
=
getcom
(
1
);
if
(
i
==
NOINP
)
{
if
(
i
==
NOINP
)
{
put_nak
();
put_nak
();
continue
;
}
continue
;
}
hdr_block_num
=
i
;
hdr_block_num
=
i
;
i
=
getcom
(
1
);
i
=
getcom
(
1
);
if
(
i
==
NOINP
)
{
if
(
i
==
NOINP
)
{
put_nak
();
put_nak
();
continue
;
}
continue
;
}
if
(
hdr_block_num
!=
(
uchar
)
~
i
)
{
if
(
hdr_block_num
!=
(
uchar
)
~
i
)
{
newline
();
newline
();
l
printf
(
"Block number error
\
r\
n
"
);
f
printf
(
statfp
,
"Block number error
\n
"
);
put_nak
();
put_nak
();
continue
;
}
continue
;
}
calc_crc
=
calc_chksum
=
0
;
calc_crc
=
calc_chksum
=
0
;
for
(
b
=
0
;
b
<
block_size
;
b
++
)
{
for
(
b
=
0
;
b
<
block_size
;
b
++
)
{
i
=
getcom
(
1
);
i
=
getcom
(
1
);
...
@@ -555,54 +398,62 @@ for(errors=0;errors<MAXERRORS;errors++) {
...
@@ -555,54 +398,62 @@ for(errors=0;errors<MAXERRORS;errors++) {
break
;
break
;
block
[
b
]
=
i
;
block
[
b
]
=
i
;
if
(
mode
&
CRC
)
if
(
mode
&
CRC
)
ucrc16
(
block
[
b
],
&
calc_crc
);
calc_crc
=
ucrc16
(
block
[
b
],
calc_crc
);
else
else
calc_chksum
+=
block
[
b
];
}
calc_chksum
+=
block
[
b
];
}
if
(
b
<
block_size
)
{
if
(
b
<
block_size
)
{
put_nak
();
put_nak
();
continue
;
}
continue
;
}
if
(
mode
&
CRC
)
{
if
(
mode
&
CRC
)
{
crc
=
getcom
(
1
)
<<
8
;
crc
=
getcom
(
1
)
<<
8
;
crc
|=
getcom
(
1
);
}
crc
|=
getcom
(
1
);
}
else
else
chksum
=
getcom
(
1
);
chksum
=
getcom
(
1
);
if
(
mode
&
CRC
)
{
if
(
mode
&
CRC
)
{
ucrc16
(
0
,
&
calc_crc
);
calc_crc
=
ucrc16
(
0
,
calc_crc
);
ucrc16
(
0
,
&
calc_crc
);
calc_crc
=
ucrc16
(
0
,
calc_crc
);
if
(
crc
==
calc_crc
)
if
(
crc
==
calc_crc
)
break
;
break
;
newline
();
newline
();
lprintf
(
"CRC error
\r\n
"
);
}
fprintf
(
statfp
,
"CRC error
\n
"
);
}
else
{
/* CHKSUM */
else
{
/* CHKSUM */
if
(
chksum
==
calc_chksum
)
if
(
chksum
==
calc_chksum
)
break
;
break
;
newline
();
newline
();
lprintf
(
"Checksum error
\r\n
"
);
}
fprintf
(
statfp
,
"Checksum error
\n
"
);
}
if
(
mode
&
GMODE
)
{
/* Don't bother sending a NAK. He's not listening */
if
(
mode
&
GMODE
)
{
/* Don't bother sending a NAK. He's not listening */
cancel
();
cancel
();
bail
(
1
);
}
bail
(
1
);
put_nak
();
}
}
put_nak
();
}
if
(
errors
>=
MAXERRORS
)
{
if
(
errors
>=
MAXERRORS
)
{
newline
();
newline
();
lprintf
(
"Too many errors
\r\n
"
);
fprintf
(
statfp
,
"Too many errors
\n
"
);
return
(
-
1
);
}
return
(
-
1
);
}
return
(
0
);
return
(
0
);
}
}
/*****************/
/*****************/
/* Sends a block */
/* Sends a block */
/*****************/
/*****************/
void
put_block
()
void
put_block
(
void
)
{
{
uchar
ch
,
chksum
;
uchar
ch
,
chksum
;
int
i
;
u
int
i
;
u
int
crc
;
u
short
crc
;
if
(
block_size
==
128
)
if
(
block_size
==
128
)
putcom
(
SOH
);
putcom
(
SOH
);
...
@@ -615,15 +466,17 @@ chksum=crc=0;
...
@@ -615,15 +466,17 @@ chksum=crc=0;
for
(
i
=
0
;
i
<
block_size
;
i
++
)
{
for
(
i
=
0
;
i
<
block_size
;
i
++
)
{
putcom
(
block
[
i
]);
putcom
(
block
[
i
]);
if
(
mode
&
CRC
)
if
(
mode
&
CRC
)
ucrc16
(
block
[
i
],
&
crc
);
crc
=
ucrc16
(
block
[
i
],
crc
);
else
else
chksum
+=
block
[
i
];
}
chksum
+=
block
[
i
];
}
if
(
mode
&
CRC
)
{
if
(
mode
&
CRC
)
{
ucrc16
(
0
,
&
crc
);
crc
=
ucrc16
(
0
,
crc
);
ucrc16
(
0
,
&
crc
);
crc
=
ucrc16
(
0
,
crc
);
putcom
(
crc
>>
8
);
putcom
(
crc
>>
8
);
putcom
(
crc
&
0xff
);
}
putcom
(
crc
&
0xff
);
}
else
else
putcom
(
chksum
);
putcom
(
chksum
);
}
}
...
@@ -632,7 +485,7 @@ else
...
@@ -632,7 +485,7 @@ else
/* Gets an acknowledgement - usually after sending a block */
/* Gets an acknowledgement - usually after sending a block */
/* Returns 1 if ack received, 0 otherwise. */
/* Returns 1 if ack received, 0 otherwise. */
/************************************************************/
/************************************************************/
int
get_ack
()
int
get_ack
(
void
)
{
{
int
i
,
errors
,
can
=
0
;
int
i
,
errors
,
can
=
0
;
...
@@ -641,10 +494,12 @@ for(errors=0;errors<MAXERRORS;errors++) {
...
@@ -641,10 +494,12 @@ for(errors=0;errors<MAXERRORS;errors++) {
if
(
mode
&
GMODE
)
{
/* Don't wait for ACK on Ymodem-G */
if
(
mode
&
GMODE
)
{
/* Don't wait for ACK on Ymodem-G */
if
(
incom
()
==
CAN
)
{
if
(
incom
()
==
CAN
)
{
newline
();
newline
();
l
printf
(
"Cancelled remotely
\
r\
n
"
);
f
printf
(
statfp
,
"Cancelled remotely
\n
"
);
cancel
();
cancel
();
bail
(
1
);
}
bail
(
1
);
return
(
1
);
}
}
return
(
1
);
}
i
=
getcom
(
10
);
i
=
getcom
(
10
);
if
(
can
&&
i
!=
CAN
)
if
(
can
&&
i
!=
CAN
)
...
@@ -654,15 +509,19 @@ for(errors=0;errors<MAXERRORS;errors++) {
...
@@ -654,15 +509,19 @@ for(errors=0;errors<MAXERRORS;errors++) {
if
(
i
==
CAN
)
{
if
(
i
==
CAN
)
{
if
(
can
)
{
if
(
can
)
{
newline
();
newline
();
l
printf
(
"Cancelled remotely
\
r\
n
"
);
f
printf
(
statfp
,
"Cancelled remotely
\n
"
);
cancel
();
cancel
();
bail
(
1
);
}
bail
(
1
);
can
=
1
;
}
}
can
=
1
;
}
if
(
i
!=
NOINP
)
{
if
(
i
!=
NOINP
)
{
newline
();
newline
();
l
printf
(
"Received %s Expected ACK
\
r\
n
"
,
chr
(
i
));
f
printf
(
statfp
,
"Received %s Expected ACK
\n
"
,
chr
(
i
));
if
(
i
!=
CAN
)
if
(
i
!=
CAN
)
return
(
0
);
}
}
return
(
0
);
}
}
return
(
0
);
return
(
0
);
}
}
...
@@ -670,20 +529,8 @@ return(0);
...
@@ -670,20 +529,8 @@ return(0);
/****************************************************************************/
/****************************************************************************/
/* Syncronizes the remote and local machines */
/* Syncronizes the remote and local machines */
/****************************************************************************/
/****************************************************************************/
void
riosync
()
void
riosync
(
void
)
{
{
int
i
=
0
;
while
(
rioctl
(
TXBC
)
&&
i
<
180
)
{
/* 10 sec */
if
(
!
(
mode
&
NO_LOCAL
)
&&
lkbrd
(
0
)
==
LOC_ABORT
)
{
newline
();
lprintf
(
"Local abort
\r\n
"
);
cancel
();
break
;
}
if
(
!
DCDHIGH
)
break
;
mswait
(
1
);
i
++
;
}
}
}
/*********************************************************/
/*********************************************************/
...
@@ -719,23 +566,26 @@ putcom(digits[val&0xF]);
...
@@ -719,23 +566,26 @@ putcom(digits[val&0xF]);
/***********************/
/***********************/
void
putzhhdr
(
char
type
)
void
putzhhdr
(
char
type
)
{
{
uint
i
,
crc
=
0
;
uint
i
;
ushort
crc
=
0
;
putcom
(
ZPAD
);
putcom
(
ZPAD
);
putcom
(
ZPAD
);
putcom
(
ZPAD
);
putcom
(
ZDLE
);
putcom
(
ZDLE
);
if
(
zmode
&
VAR_HDRS
)
{
if
(
zmode
&
VAR_HDRS
)
{
putcom
(
ZVHEX
);
putcom
(
ZVHEX
);
putzhex
(
4
);
}
putzhex
(
4
);
}
else
else
putcom
(
ZHEX
);
putcom
(
ZHEX
);
putzhex
(
type
);
putzhex
(
type
);
ucrc16
(
type
,
&
crc
);
crc
=
ucrc16
(
type
,
crc
);
for
(
i
=
0
;
i
<
4
;
i
++
)
{
for
(
i
=
0
;
i
<
4
;
i
++
)
{
putzhex
(
Txhdr
[
i
]);
putzhex
(
Txhdr
[
i
]);
ucrc16
(
Txhdr
[
i
],
&
crc
);
}
crc
=
ucrc16
(
Txhdr
[
i
],
crc
);
ucrc16
(
0
,
&
crc
);
}
ucrc16
(
0
,
&
crc
);
crc
=
ucrc16
(
0
,
crc
);
crc
=
ucrc16
(
0
,
crc
);
putzhex
(
crc
>>
8
);
putzhex
(
crc
>>
8
);
putzhex
(
crc
&
0xff
);
putzhex
(
crc
&
0xff
);
putcom
(
CR
);
putcom
(
CR
);
...
@@ -785,14 +635,17 @@ else
...
@@ -785,14 +635,17 @@ else
else
{
else
{
putcom
(
ZDLE
);
putcom
(
ZDLE
);
ch
^=
0x40
;
ch
^=
0x40
;
putcom
(
lastsent
=
ch
);
}
putcom
(
lastsent
=
ch
);
}
break
;
break
;
default:
default:
if
(
zmode
&
CTRL_ESC
&&
!
(
ch
&
0x60
))
{
/* it's a ctrl char */
if
(
zmode
&
CTRL_ESC
&&
!
(
ch
&
0x60
))
{
/* it's a ctrl char */
putcom
(
ZDLE
);
putcom
(
ZDLE
);
ch
^=
0x40
;
}
ch
^=
0x40
;
}
putcom
(
lastsent
=
ch
);
putcom
(
lastsent
=
ch
);
break
;
}
break
;
}
}
}
/*
/*
...
@@ -813,7 +666,8 @@ while(1) {
...
@@ -813,7 +666,8 @@ while(1) {
continue
;
continue
;
if
(
zmode
&
CTRL_ESC
&&
!
(
i
&
0x60
))
if
(
zmode
&
CTRL_ESC
&&
!
(
i
&
0x60
))
continue
;
continue
;
return
(
i
);
}
return
(
i
);
}
while
(
1
)
{
/* Escaped characters */
while
(
1
)
{
/* Escaped characters */
if
((
i
=
getcom
(
Rxtimeout
))
<
0
)
if
((
i
=
getcom
(
Rxtimeout
))
<
0
)
...
@@ -846,8 +700,10 @@ while(1) { /* Escaped characters */
...
@@ -846,8 +700,10 @@ while(1) { /* Escaped characters */
continue
;
continue
;
if
((
i
&
0x60
)
==
0x40
)
if
((
i
&
0x60
)
==
0x40
)
return
(
i
^
0x40
);
return
(
i
^
0x40
);
break
;
}
break
;
break
;
}
}
break
;
}
return
(
ERROR
);
return
(
ERROR
);
}
}
...
@@ -875,315 +731,39 @@ while(1) {
...
@@ -875,315 +731,39 @@ while(1) {
default:
default:
if
(
!
(
i
&
0x60
)
&&
zmode
&
CTRL_ESC
)
if
(
!
(
i
&
0x60
)
&&
zmode
&
CTRL_ESC
)
continue
;
continue
;
return
(
i
);
}
}
return
(
i
);
}
#if 0
int getzhdr()
{
int done=0;
while(!done) {
i=getcom(10);
switch(i) {
case NOINP:
done=1;
continue;
case XON:
case XON|0x80:
continue;
case ZPAD|0x80:
case ZPAD:
break;
case CAN:
cancount++;
if(cancount>=5) {
i=ZCAN;
done=1;
break; }
i=getcom(10);
switch(i) {
case NOINP:
continue;
case ZCRCW:
switch(getcom(10)) {
case NOINP:
i=ERROR
done=1;
break;
case RCDO:
done=1;
break;
default:
continue; }
break;
case RCDO:
done=1;
break;
case CAN:
cancount++;
if(cancount>=5) {
i=ZCAN;
done=1;
continue;
default:
break; }
continue;
default:
continue; }
i=Rxframeind=getcom7();
switch (i) {
case ZVBIN32:
if((Rxhlen=c=getzcom())<0)
goto fifi;
if(c>ZMAXHLEN)
goto agn2;
Crc32r=1;
c=zrbhd32(hdr);
break;
case ZBIN32:
if(zmode&VAR_HDRS)
goto agn2;
Crc32r=1;
c=zrbhd32(hdr);
break;
case ZVBINR32:
if((Rxhlen=c=getzcom())<0)
goto fifi;
if(c>ZMAXHLEN)
goto agn2;
Crc32r=2;
c=zrbhd32(hdr);
break;
case ZBINR32:
if(zmode&VAR_HDRS)
goto agn2;
Crc32r=2;
c=zrbhd32(hdr);
break;
case RCDO:
case TIMEOUT:
goto fifi;
case ZVBIN:
if((Rxhlen=c=getzcom())<0)
goto fifi;
if(c>ZMAXHLEN)
goto agn2;
Crc32r=0;
c=zrbhdr(hdr);
break;
case ZBIN:
if(zmode&VAR_HDRS)
goto agn2;
Crc32r=0;
c=zrbhdr(hdr);
break;
case ZVHEX:
if((Rxhlen=c=zgethex()) < 0)
goto fifi;
if(c>ZMAXHLEN)
goto agn2;
Crc32r=0;
c=zrhhdr(hdr);
break;
case ZHEX:
if(zmode&VAR_HDRS)
goto agn2;
Crc32r=0;
c=zrhhdr(hdr);
break;
case CAN:
goto gotcan;
default:
goto agn2;
}
/****************************************************************************/
/* Get the receiver's init parameters */
/****************************************************************************/
int getzrxinit()
{
int i;
struct stat f;
for(i=0;i<10;i++) {
switch(zgethdr(Rxhdr,1)) {
case ZCHALLENGE: /* Echo receiver's challenge numbr */
ltohdr(Rxpos);
putzhhdr(ZACK);
continue;
case ZCOMMAND: /* They didn't see out ZRQINIT */
ltohdr(0L);
putzhhdr(ZRQINIT);
continue;
case ZRINIT:
Rxflags=Rxhdr[ZF0]&0x7f;
if(Rxhdr[ZF1]&CANVHDR)
zmode|=VAR_HDRS;
Txfcs32 = (Wantfcs32 && (Rxflags & CANFC32));
Zctlesc |= Rxflags & TESCCTL;
Rxbuflen = (0377 & Rxhdr[ZP0])+((0377 & Rxhdr[ZP1])<<8);
if ( !(Rxflags & CANFDX))
Txwindow = 0;
/* Override to force shorter frame length */
if (Rxbuflen && (Rxbuflen>Tframlen) && (Tframlen>=32))
Rxbuflen = Tframlen;
if ( !Rxbuflen && (Tframlen>=32) && (Tframlen<=1024))
Rxbuflen = Tframlen;
vfile("Rxbuflen=%d", Rxbuflen);
/*
* If input is not a regular file, force ACK's to
* prevent running beyond the buffer limits
*/
if ( !Command) {
fstat(fileno(in), &f);
if ((f.st_mode & S_IFMT) != S_IFREG) {
Canseek = -1;
ef TXBSIZE
Txwindow = TXBSIZE - 1024;
Txwspac = TXBSIZE/4;
e
return ERROR;
if
}
}
/* Set initial subpacket length */
if (blklen < 1024) { /* Command line override? */
if (Effbaud > 300)
blklen = 256;
if (Effbaud > 1200)
blklen = 512;
if (Effbaud > 2400)
blklen = 1024;
}
if (Rxbuflen && blklen>Rxbuflen)
blklen = Rxbuflen;
if (blkopt && blklen > blkopt)
blklen = blkopt;
vfile("Rxbuflen=%d blklen=%d", Rxbuflen, blklen);
vfile("Txwindow = %u Txwspac = %d", Txwindow, Txwspac);
if (Lztrans == ZTRLE && (Rxflags & CANRLE))
Txfcs32 = 2;
else
Lztrans = 0;
return (sendzsinit());
case ZCAN:
case TIMEOUT:
return ERROR;
case ZRQINIT:
if (Rxhdr[ZF0] == ZCOMMAND)
continue;
default:
putzhhdr(ZNAK);
continue; } }
return(ERROR);
}
getzdata(char *buf, int length)
{
int c,d;
uint crc;
char *end;
switch (Crc32r) {
case 1:
return zrdat32(buf, length);
case 2:
return zrdatr32(buf, length);
}
crc = Rxcount = 0; end = buf + length;
while (buf <= end) {
if ((c = getzcom()) & ~0377) {
crcfoo:
switch (c) {
case GOTCRCE:
case GOTCRCG:
case GOTCRCQ:
case GOTCRCW:
crc = updcrc((d=c)&0377, crc);
if ((c = getzcom()) & ~0377)
goto crcfoo;
crc = updcrc(c, crc);
if ((c = getzcom()) & ~0377)
goto crcfoo;
crc = updcrc(c, crc);
if (crc & 0xFFFF) {
zperr(badcrc);
return ERROR;
}
Rxcount = length - (end - buf);
#ifndef DSZ
vfile("zrdata: %d %s", Rxcount,
Zendnames[d-GOTCRCE&3]);
#endif
return d;
case GOTCAN:
zperr("Sender Canceled");
return ZCAN;
case TIMEOUT:
zperr("TIMEOUT");
return c;
default:
garbitch(); return c;
}
}
}
*buf++ = c;
crc = updcrc(c, crc);
}
}
#ifdef DSZ
garbitch();
#else
zperr("Data subpacket too long");
#endif
return
ERROR
;
}
}
#endif
/************************************************/
/************************************************/
/* Dump the current blockm contents - for debug */
/* Dump the current blockm contents - for debug */
/************************************************/
/************************************************/
void
dump_block
()
void
dump_block
()
{
{
long
l
;
uint
l
;
for
(
l
=
0
;
l
<
block_size
;
l
++
)
for
(
l
=
0
;
l
<
block_size
;
l
++
)
lprintf
(
"%02X "
,
block
[
l
]);
fprintf
(
statfp
,
"%02X "
,
block
[
l
]);
lputs
(
"
\r\n
"
);
fprintf
(
statfp
,
"
\n
"
);
}
}
char
*
usage
=
static
const
char
*
usage
=
"usage: STP <port> [chan] [opts] <cmd> [file | path | +list]
\r\n\r\n
"
"usage: STP <socket> [opts] <cmd> [file | path | +list]
\n\n
"
"where:
\r\n\r\n
"
"where:
\n\n
"
"port = COM port (1-4), D for DigiBoard, or UART I/O address (hex)
\r\n
"
"socket = TCP socket descriptor
\n
"
"chan = IRQ channel (2-15) or DigiBoard channel (4+)
\r\n
"
"opts = o to overwrite files when receiving
\n
"
"opts = b# to set DTE rate to #bps
\r\n
"
" d to disable dropped carrier detection
\n
"
" t# to set time-slice API type (default=1)
\r\n
"
" a to sound alarm at start and stop of transfer
\n
"
" o to overwrite files when receiving
\r\n
"
" l to disable local keyboard (Ctrl-C) checking
\n
"
" d to disable dropped carrier detection
\r\n
"
"cmd = sx to send Xmodem rx to recv Xmodem
\n
"
" a to sound alarm at start and stop of transfer
\r\n
"
" sX to send Xmodem-1k rc to recv Xmodem-CRC
\n
"
" l to disable local keyboard (Ctrl-C) checking
\r\n
"
" sy to send Ymodem ry to recv Ymodem
\n
"
"cmd = sx to send Xmodem rx to recv Xmodem
\r\n
"
" sY to send Ymodem-1k rg to recv Ymodem-G
\n
"
" sX to send Xmodem-1k rc to recv Xmodem-CRC
\r\n
"
" sz to send Zmodem rz to recv Zmodem
\n
"
" sy to send Ymodem ry to recv Ymodem
\r\n
"
"file = filename to send or receive
\n
"
" sY to send Ymodem-1k rg to recv Ymodem-G
\r\n
"
"path = path to receive files into
\n
"
" sz to send Zmodem rz to recv Zmodem
\r\n
"
"list = name of text file with list of filenames to send or receive
\n
"
;
"file = filename to send or receive
\r\n
"
"path = path to receive files into
\r\n
"
"list = name of text file with list of filenames to send or receive
\r\n
"
;
/***************/
/***************/
/* Entry Point */
/* Entry Point */
...
@@ -1192,71 +772,39 @@ int main(int argc, char **argv)
...
@@ -1192,71 +772,39 @@ int main(int argc, char **argv)
{
{
char
str
[
256
],
tmp
[
256
],
tmp2
[
256
],
irq
,
errors
,
*
p
,
*
p2
,
first_block
char
str
[
256
],
tmp
[
256
],
tmp2
[
256
],
irq
,
errors
,
*
p
,
*
p2
,
first_block
,
*
fname
[
MAX_FNAMES
],
fnames
=
0
,
fnum
,
success
;
,
*
fname
[
MAX_FNAMES
],
fnames
=
0
,
fnum
,
success
;
int
ch
,
i
,
j
,
k
,
file
,
last
,
total_files
=
0
,
sent_files
=
0
,
can
;
int
ch
,
i
,
j
,
k
,
last
,
total_files
=
0
,
sent_files
=
0
,
can
;
uint
base
=
0
,
baud
=
0
,
cps
;
uint
file_bytes_left
;
long
b
,
l
,
m
,
file_bytes_left
,
serial_num
;
uint
cps
;
long
b
,
l
,
m
;
long
serial_num
;
long
fsize
;
ulong
file_bytes
=
0
,
total_bytes
=
0
,
sent_bytes
=
0
;
ulong
file_bytes
=
0
,
total_bytes
=
0
,
sent_bytes
=
0
;
ulong
val
;
time_t
t
,
startall
,
startfile
,
ftime
;
time_t
t
,
startall
,
startfile
,
ftime
;
struct
ffblk
ff
;
glob_t
g
;
struct
ftime
ft
;
int
gi
;
struct
date
dosdate
;
FILE
*
fp
;
struct
time
dostime
;
FILE
*
log
=
NULL
;
FILE
*
stream
,
*
log
=
NULL
;
mswtyp
=
TS_INT28
;
/* default to int 28 only */
ctrlbrk
(
cbreakh
);
errfp
=
stderr
;
statfp
=
stdout
;
if
((
asmrev
=*
(
&
riobp
-
1
))
!=
19
)
{
fprintf
(
statfp
,
"
\n
Synchronet Transfer Protocols v1.00"
printf
(
"Wrong rciol.obj
\n
"
);
" Copyright 2003 Rob Swindell
\n\n
"
);
exit
(
1
);
}
lclini
(
0xd
<<
8
);
fprintf
(
statfp
,
"Command line: "
);
lprintf
(
"
\r\n
Synchronet Transfer Protocols v1.00"
" Developed 1993-1997 Rob Swindell
\r\n\r\n
"
);
lputs
(
"Command line: "
);
for
(
i
=
1
;
i
<
argc
;
i
++
)
for
(
i
=
1
;
i
<
argc
;
i
++
)
l
printf
(
"%s "
,
argv
[
i
]);
f
printf
(
statfp
,
"%s "
,
argv
[
i
]);
lputs
(
"
\r\n
"
);
fprintf
(
statfp
,
"
\n
"
,
statfp
);
if
(
argc
<
3
)
{
if
(
argc
<
3
)
{
lprintf
(
usage
);
fprintf
(
errfp
,
usage
);
exit
(
1
);
}
exit
(
1
);
}
i
=
1
;
base
=
ahtoul
(
argv
[
i
]);
if
(
base
>
4
&&
base
<
0x100
)
/* 'D' and 'FFFF' are the same */
base
=
0xffff
;
if
(
base
!=
0xffff
&&
base
<
5
)
switch
(
atoi
(
argv
[
i
]))
{
case
1
:
base
=
0x3f8
;
irq
=
4
;
break
;
case
2
:
base
=
0x2f8
;
irq
=
3
;
break
;
case
3
:
base
=
0x3e8
;
irq
=
4
;
break
;
case
4
:
base
=
0x2e8
;
irq
=
3
;
break
;
default:
lprintf
(
"Invalid COM Port (%s)
\r\n
"
,
argv
[
1
]);
lprintf
(
usage
);
exit
(
1
);
}
if
(
base
>
4
||
isdigit
(
argv
[
i
+
1
][
0
]))
sock
=
atoi
(
argv
[
1
]);
irq
=
atoi
(
argv
[
++
i
]);
for
(
i
++
;
i
<
argc
;
i
++
)
{
for
(
i
=
2
;
i
<
argc
;
i
++
)
{
if
(
!
(
mode
&
(
SEND
|
RECV
)))
{
if
(
!
(
mode
&
(
SEND
|
RECV
)))
{
if
(
toupper
(
argv
[
i
][
0
])
==
'S'
||
toupper
(
argv
[
i
][
0
])
==
'R'
)
{
/* cmd */
if
(
toupper
(
argv
[
i
][
0
])
==
'S'
||
toupper
(
argv
[
i
][
0
])
==
'R'
)
{
/* cmd */
...
@@ -1290,15 +838,11 @@ for(i++;i<argc;i++) {
...
@@ -1290,15 +838,11 @@ for(i++;i<argc;i++) {
mode
|=
(
ZMODEM
|
CRC
);
mode
|=
(
ZMODEM
|
CRC
);
break
;
break
;
default:
default:
lprintf
(
"Unrecognized command '%s'
\r\n\r\n
"
,
argv
[
i
]);
fprintf
(
statfp
,
"Unrecognized command '%s'
\n\n
"
,
argv
[
i
]);
lprintf
(
usage
);
fprintf
(
statfp
,
usage
);
exit
(
1
);
}
}
exit
(
1
);
}
else
if
(
toupper
(
argv
[
i
][
0
])
==
'B'
)
}
baud
=
atoi
(
argv
[
i
]
+
1
);
else
if
(
toupper
(
argv
[
i
][
0
])
==
'T'
)
mswtyp
=
atoi
(
argv
[
i
]
+
1
);
else
if
(
toupper
(
argv
[
i
][
0
])
==
'O'
)
else
if
(
toupper
(
argv
[
i
][
0
])
==
'O'
)
mode
|=
OVERWRITE
;
mode
|=
OVERWRITE
;
...
@@ -1313,116 +857,115 @@ for(i++;i<argc;i++) {
...
@@ -1313,116 +857,115 @@ for(i++;i<argc;i++) {
mode
|=
NO_LOCAL
;
mode
|=
NO_LOCAL
;
else
if
(
argv
[
i
][
0
]
==
'*'
)
else
if
(
argv
[
i
][
0
]
==
'*'
)
mode
|=
DEBUG
;
}
mode
|=
DEBUG
;
}
else
if
(
argv
[
i
][
0
]
==
'+'
)
{
else
if
(
argv
[
i
][
0
]
==
'+'
)
{
if
(
mode
&
DIR
)
{
if
(
mode
&
DIR
)
{
lprintf
(
"Cannot specify both directory and filename
\r\n
"
);
fprintf
(
statfp
,
"Cannot specify both directory and filename
\n
"
);
exit
(
1
);
}
exit
(
1
);
}
sprintf
(
str
,
"%s"
,
argv
[
i
]
+
1
);
sprintf
(
str
,
"%s"
,
argv
[
i
]
+
1
);
if
((
f
ile
=
n
open
(
str
,
O_RDONLY
))
==-
1
if
((
f
p
=
f
open
(
str
,
"rb"
))
==
NULL
)
{
||
(
stream
=
fdopen
(
file
,
"rb"
))
==
NULL
)
{
fprintf
(
statfp
,
"Error opening filelist %s
\n
"
,
str
);
lprintf
(
"Error opening filelist %s
\r\n
"
,
str
);
exit
(
1
);
exit
(
1
);
}
}
while
(
!
feof
(
stream
)
&&
!
ferror
(
stream
)
&&
fnames
<
MAX_FNAMES
)
{
while
(
!
feof
(
fp
)
&&
!
ferror
(
fp
)
&&
fnames
<
MAX_FNAMES
)
{
if
(
!
fgets
(
str
,
128
,
stream
))
if
(
!
fgets
(
str
,
128
,
fp
))
break
;
break
;
truncsp
(
str
);
truncsp
(
str
);
strupr
(
str
);
if
((
fname
[
fnames
]
=
(
char
*
)
malloc
(
strlen
(
str
)
+
1
))
==
NULL
)
{
if
((
fname
[
fnames
]
=
(
char
*
)
malloc
(
strlen
(
str
)
+
1
))
==
NULL
)
{
lprintf
(
"Error allocating memory for filename
\r\n
"
);
fprintf
(
statfp
,
"Error allocating memory for filename
\n
"
);
exit
(
1
);
}
exit
(
1
);
strcpy
(
fname
[
fnames
++
],
str
);
}
}
fclose
(
stream
);
}
strcpy
(
fname
[
fnames
++
],
str
);
}
fclose
(
fp
);
}
else
if
(
mode
&
(
SEND
|
RECV
)){
else
if
(
mode
&
(
SEND
|
RECV
)){
if
((
fname
[
fnames
]
=
(
char
*
)
malloc
(
128
))
==
NULL
)
{
if
((
fname
[
fnames
]
=
(
char
*
)
malloc
(
128
))
==
NULL
)
{
lprintf
(
"Error allocating memory for filename
\r\n
"
);
fprintf
(
statfp
,
"Error allocating memory for filename
\n
"
);
exit
(
1
);
}
exit
(
1
);
}
strcpy
(
fname
[
fnames
],
argv
[
i
]);
strcpy
(
fname
[
fnames
],
argv
[
i
]);
strupr
(
fname
[
fnames
]);
if
(
isdir
(
fname
[
fnames
]))
{
/* is a directory */
j
=
strlen
(
fname
[
fnames
]);
if
(
fname
[
fnames
][
j
-
1
]
==
'\\'
/* Ends in \ */
||
!
strcmp
(
fname
[
fnames
]
+
1
,
":"
))
{
/* Drive letter only */
/* || !findfirst(fname[fnames],&ff,FA_DIREC)) { is a directory */
if
(
mode
&
DIR
)
{
if
(
mode
&
DIR
)
{
lprintf
(
"Only one directory can be specified
\r\n
"
);
fprintf
(
statfp
,
"Only one directory can be specified
\n
"
);
exit
(
1
);
}
exit
(
1
);
}
if
(
fnames
)
{
if
(
fnames
)
{
lprintf
(
"Cannot specify both directory and filename
\r\n
"
);
fprintf
(
statfp
,
"Cannot specify both directory and filename
\n
"
);
exit
(
1
);
}
exit
(
1
);
}
if
(
mode
&
SEND
)
{
if
(
mode
&
SEND
)
{
lprintf
(
"Cannot send directory '%s'
\r\n
"
,
fname
[
fnames
]);
fprintf
(
statfp
,
"Cannot send directory '%s'
\n
"
,
fname
[
fnames
]);
exit
(
1
);}
exit
(
1
);
mode
|=
DIR
;
}
}
fnames
++
;
}
}
mode
|=
DIR
;
}
fnames
++
;
}
}
if
(
!
(
mode
&
(
SEND
|
RECV
)))
{
if
(
!
(
mode
&
(
SEND
|
RECV
)))
{
lprintf
(
"No command specified
\r\n
"
);
fprintf
(
statfp
,
"No command specified
\n
"
);
lprintf
(
usage
);
fprintf
(
statfp
,
usage
);
exit
(
1
);
}
exit
(
1
);
}
if
(
mode
&
(
SEND
|
XMODEM
)
&&
!
fnames
)
{
/* Sending with any or recv w/Xmodem */
if
(
mode
&
(
SEND
|
XMODEM
)
&&
!
fnames
)
{
/* Sending with any or recv w/Xmodem */
lprintf
(
"Must specify filename or filelist
\r\n
"
);
fprintf
(
statfp
,
"Must specify filename or filelist
\n
"
);
lprintf
(
usage
);
fprintf
(
statfp
,
usage
);
exit
(
1
);
}
exit
(
1
);
}
i
=
strlen
(
fname
[
0
]);
/* Make sure the directory ends in \ or : */
if
(
mode
&
DIR
&&
fname
[
0
][
i
-
1
]
!=
'\\'
&&
fname
[
0
][
i
-
1
]
!=
':'
)
strcat
(
fname
[
0
],
"
\\
"
);
i
=
rioini
(
base
,
irq
);
if
(
mode
&
DIR
)
if
(
i
)
{
backslash
(
fname
[
0
]);
lprintf
(
"STP: Error (%d) initializing COM port base %x irq %d
\r\n
"
,
i
,
base
,
irq
);
exit
(
1
);
}
if
(
mode
&
ALARM
)
{
if
(
mode
&
ALARM
)
{
sound
(
1000
);
BEEP
(
1000
,
500
);
mswait
(
500
);
BEEP
(
2000
,
500
);
sound
(
2000
);
}
mswait
(
500
);
nosound
();
}
if
(
baud
)
{
i
=
setbaud
(
baud
);
if
(
i
)
{
lprintf
(
"STP: Error setting baud rate to %u
\r\n
"
,
baud
);
bail
(
1
);
}
}
else
baud
=
rioctl
(
GBAUD
);
rioctl
(
IOSM
|
CTSCK
|
RTSCK
);
if
(
!
winsock_startup
())
bail
(
2
);
rioctl
(
TSTYPE
|
mswtyp
);
/* set time-slice API type */
/* Non-blocking socket I/O */
val
=
1
;
ioctlsocket
(
sock
,
FIONBIO
,
&
val
);
if
(
!
DCDHIGH
)
{
if
(
!
DCDHIGH
)
{
newline
();
newline
();
lprintf
(
"No carrier
\r\n
"
);
fprintf
(
statfp
,
"No carrier
\n
"
);
bail
(
1
);
}
bail
(
1
);
}
p
=
getenv
(
"DSZLOG"
);
p
=
getenv
(
"DSZLOG"
);
if
(
p
)
{
if
(
p
)
{
if
((
file
=
open
(
p
,
O_WRONLY
|
O_BINARY
|
O_CREAT
,
S_IWRITE
|
S_IREAD
))
==-
1
if
((
log
=
fopen
(
p
,
"wb"
))
==
NULL
)
{
||
(
log
=
fdopen
(
file
,
"wb"
))
==
NULL
)
{
fprintf
(
statfp
,
"Error opening DSZLOG file '%s'
\n
"
,
p
);
lprintf
(
"Error opening DSZLOG file '%s'
\r\n
"
,
p
);
bail
(
1
);
bail
(
1
);
}
}
setvbuf
(
log
,
NULL
,
_IOFBF
,
16
*
1024
);
}
setvbuf
(
log
,
NULL
,
_IOFBF
,
16
*
1024
);
}
startall
=
time
(
NULL
);
startall
=
time
(
NULL
);
if
(
mode
&
RECV
)
{
if
(
mode
&
RECV
)
{
if
(
fnames
>
1
)
if
(
fnames
>
1
)
l
printf
(
"Receiving %u files
\
r\
n
"
,
fnames
);
f
printf
(
statfp
,
"Receiving %u files
\n
"
,
fnames
);
fnum
=
0
;
fnum
=
0
;
while
(
1
)
{
while
(
1
)
{
if
(
mode
&
XMODEM
)
{
if
(
mode
&
XMODEM
)
{
strcpy
(
str
,
fname
[
0
]);
strcpy
(
str
,
fname
[
0
]);
file_bytes
=
file_bytes_left
=
0x7fffffff
;
file_bytes
=
file_bytes_left
=
0x7fffffff
;
serial_num
=-
1
;
}
serial_num
=-
1
;
}
else
if
(
mode
&
YMODEM
)
{
else
if
(
mode
&
YMODEM
)
{
l
printf
(
"Fetching Ymodem header block
\
r\
n
"
);
f
printf
(
statfp
,
"Fetching Ymodem header block
\n
"
);
for
(
errors
=
0
;
errors
<
MAXERRORS
;
errors
++
)
{
for
(
errors
=
0
;
errors
<
MAXERRORS
;
errors
++
)
{
if
(
errors
>
3
&&
mode
&
CRC
&&
!
(
mode
&
GMODE
))
if
(
errors
>
3
&&
mode
&
CRC
&&
!
(
mode
&
GMODE
))
mode
&=~
CRC
;
mode
&=~
CRC
;
...
@@ -1432,25 +975,32 @@ if(mode&RECV) {
...
@@ -1432,25 +975,32 @@ if(mode&RECV) {
putcom
(
'C'
);
putcom
(
'C'
);
else
/* NAK for checksum */
else
/* NAK for checksum */
putcom
(
NAK
);
putcom
(
NAK
);
#if 0
for(i=60;i;i--) {
for(i=60;i;i--) {
if(rioctl(RXBC)) /* no chars in-bound */
if(rioctl(RXBC)) /* no chars in-bound */
break;
break;
mswait
(
100
);
}
/* so wait */
SLEEP
(100); /* so wait */
}
if(!i) { /* none after 6 secs */
if(!i) { /* none after 6 secs */
if(errors)
if(errors)
lprintf
(
"Ymodem header timeout (%d)
\r\n
"
,
errors
);
fprintf(statfp,"Ymodem header timeout (%d)\n",errors);
continue
;
}
continue;
}
#endif
if
(
!
get_block
(
1
))
{
/* block received successfully */
if
(
!
get_block
(
1
))
{
/* block received successfully */
putcom
(
ACK
);
putcom
(
ACK
);
break
;
}
}
break
;
}
}
if
(
errors
==
MAXERRORS
)
{
if
(
errors
==
MAXERRORS
)
{
l
printf
(
"Error fetching Ymodem header block
\
r\
n
"
);
f
printf
(
statfp
,
"Error fetching Ymodem header block
\n
"
);
cancel
();
cancel
();
bail
(
1
);
}
bail
(
1
);
}
if
(
!
block
[
0
])
{
if
(
!
block
[
0
])
{
lputs
(
"Received Ymodem termination block
\r\n
"
);
fprintf
(
statfp
,
"Received Ymodem termination block
\n
"
);
bail
(
0
);
}
bail
(
0
);
}
p
=
block
+
strlen
(
block
)
+
1
;
p
=
block
+
strlen
(
block
)
+
1
;
sscanf
(
p
,
"%ld %lo %lo %lo %d %ld"
sscanf
(
p
,
"%ld %lo %lo %lo %d %ld"
,
&
file_bytes
/* file size (decimal) */
,
&
file_bytes
/* file size (decimal) */
...
@@ -1471,29 +1021,34 @@ if(mode&RECV) {
...
@@ -1471,29 +1021,34 @@ if(mode&RECV) {
total_bytes
=
file_bytes
;
total_bytes
=
file_bytes
;
if
(
!
serial_num
)
if
(
!
serial_num
)
serial_num
=-
1
;
serial_num
=-
1
;
strupr
(
block
);
fprintf
(
statfp
,
"Incoming filename: %.64s "
,
block
);
lprintf
(
"Incoming filename: %.64s "
,
block
);
if
(
mode
&
DIR
)
if
(
mode
&
DIR
)
sprintf
(
str
,
"%s%s"
,
fname
[
0
],
jus
tfname
(
block
,
tmp
));
sprintf
(
str
,
"%s%s"
,
fname
[
0
],
ge
tfname
(
block
));
else
{
else
{
jus
tfname
(
block
,
str
);
ge
tfname
(
block
);
for
(
i
=
0
;
i
<
fnames
;
i
++
)
{
for
(
i
=
0
;
i
<
fnames
;
i
++
)
{
if
(
!
fname
[
i
][
0
])
/* name blank or already used */
if
(
!
fname
[
i
][
0
])
/* name blank or already used */
continue
;
continue
;
jus
tfname
(
fname
[
i
]
,
tmp
);
ge
tfname
(
fname
[
i
]);
if
(
!
stricmp
(
tmp
,
str
))
{
if
(
!
stricmp
(
tmp
,
str
))
{
strcpy
(
str
,
fname
[
i
]);
strcpy
(
str
,
fname
[
i
]);
fname
[
i
][
0
]
=
0
;
fname
[
i
][
0
]
=
0
;
break
;
}
}
break
;
}
}
if
(
i
==
fnames
)
{
/* Not found in list */
if
(
i
==
fnames
)
{
/* Not found in list */
if
(
fnames
)
if
(
fnames
)
lputs
(
" - Not in receive list!"
);
fprintf
(
statfp
,
" - Not in receive list!"
);
if
(
!
fnames
||
fnum
>=
fnames
||
!
fname
[
fnum
][
0
])
if
(
!
fnames
||
fnum
>=
fnames
||
!
fname
[
fnum
][
0
])
jus
tfname
(
block
,
str
);
/* worst case */
ge
tfname
(
block
);
/* worst case */
else
{
else
{
strcpy
(
str
,
fname
[
fnum
]);
strcpy
(
str
,
fname
[
fnum
]);
fname
[
fnum
][
0
]
=
0
;
}
}
}
fname
[
fnum
][
0
]
=
0
;
lputs
(
"
\r\n
"
);
}
}
}
}
fprintf
(
statfp
,
"
\n
"
);
}
else
{
/* Zmodem */
else
{
/* Zmodem */
#if 0
#if 0
...
@@ -1524,7 +1079,8 @@ if(mode&RECV) {
...
@@ -1524,7 +1079,8 @@ if(mode&RECV) {
tryzhdrtype=ZRINIT;
tryzhdrtype=ZRINIT;
if(getzdata(block, 1024)==GOTCRCW) {
if(getzdata(block, 1024)==GOTCRCW) {
/* something */
/* something */
done=1; }
done=1;
}
putzhhdr(ZNAK);
putzhhdr(ZNAK);
done=0;
done=0;
break;
break;
...
@@ -1533,7 +1089,8 @@ if(mode&RECV) {
...
@@ -1533,7 +1089,8 @@ if(mode&RECV) {
zmode|=CTRL_ESC;
zmode|=CTRL_ESC;
if (getzdata(attn,ZATTNLEN)==GOTCRCW) {
if (getzdata(attn,ZATTNLEN)==GOTCRCW) {
ltohdr(1L);
ltohdr(1L);
putzhhdr(ZACK); }
putzhhdr(ZACK);
}
else
else
putzhhdr(ZNAK);
putzhhdr(ZNAK);
done=0;
done=0;
...
@@ -1572,7 +1129,9 @@ if(mode&RECV) {
...
@@ -1572,7 +1129,9 @@ if(mode&RECV) {
ackbibi();
ackbibi();
return ZCOMPL;
return ZCOMPL;
case ZCAN:
case ZCAN:
return ERROR; } }
return ERROR;
}
}
#endif
#endif
}
}
...
@@ -1580,28 +1139,29 @@ if(mode&RECV) {
...
@@ -1580,28 +1139,29 @@ if(mode&RECV) {
if
(
!
(
mode
&
DIR
)
&&
fnames
&&
fnum
>
fnames
)
{
if
(
!
(
mode
&
DIR
)
&&
fnames
&&
fnum
>
fnames
)
{
newline
();
newline
();
l
printf
(
"Attempt to send more files than specified
\
r\
n
"
);
f
printf
(
statfp
,
"Attempt to send more files than specified
\n
"
);
cancel
();
cancel
();
break
;
}
break
;
}
k
=
strlen
(
str
);
/* strip out control characters and high ASCII */
k
=
strlen
(
str
);
/* strip out control characters and high ASCII */
for
(
i
=
j
=
0
;
i
<
k
;
i
++
)
for
(
i
=
j
=
0
;
i
<
k
;
i
++
)
if
(
str
[
i
]
>
SP
&&
(
uchar
)
str
[
i
]
<
0x7f
)
if
(
str
[
i
]
>
SP
&&
(
uchar
)
str
[
i
]
<
0x7f
)
str
[
j
++
]
=
str
[
i
];
str
[
j
++
]
=
str
[
i
];
str
[
j
]
=
0
;
str
[
j
]
=
0
;
strupr
(
str
);
if
(
fexist
(
str
)
&&
!
(
mode
&
OVERWRITE
))
{
if
(
fexist
(
str
)
&&
!
(
mode
&
OVERWRITE
))
{
l
printf
(
"%s already exists
\
r\
n
"
,
str
);
f
printf
(
statfp
,
"%s already exists
\n
"
,
str
);
cancel
();
cancel
();
bail
(
1
);
}
bail
(
1
);
if
((
file
=
nopen
(
str
,
O_WRONLY
|
O_CREAT
|
O_TRUNC
))
==-
1
}
||
(
stream
=
f
d
open
(
file
,
"wb"
))
==
NULL
)
{
if
((
fp
=
fopen
(
str
,
"wb"
))
==
NULL
)
{
l
printf
(
"Error creating %s
\
r\
n
"
,
str
);
f
printf
(
statfp
,
"Error creating %s
\n
"
,
str
);
cancel
();
cancel
();
bail
(
1
);
}
bail
(
1
);
setvbuf
(
stream
,
NULL
,
_IOFBF
,
8
*
1024
);
}
setvbuf
(
fp
,
NULL
,
_IOFBF
,
8
*
1024
);
startfile
=
time
(
NULL
);
startfile
=
time
(
NULL
);
l
printf
(
"Receiving %s (%lu bytes) via %s %s
\
r\
n
"
f
printf
(
statfp
,
"Receiving %s (%lu bytes) via %s %s
\n
"
,
str
,
str
,
mode
&
XMODEM
?
0
:
file_bytes
,
mode
&
XMODEM
?
0
:
file_bytes
,
mode
&
XMODEM
?
"Xmodem"
:
mode
&
YMODEM
?
mode
&
GMODE
?
"Ymodem-G"
,
mode
&
XMODEM
?
"Xmodem"
:
mode
&
YMODEM
?
mode
&
GMODE
?
"Ymodem-G"
...
@@ -1624,34 +1184,42 @@ if(mode&RECV) {
...
@@ -1624,34 +1184,42 @@ if(mode&RECV) {
break
;
break
;
if
(
i
)
{
/* other error */
if
(
i
)
{
/* other error */
cancel
();
cancel
();
bail
(
1
);
}
bail
(
1
);
}
if
(
file_bytes_left
<=
0L
)
{
/* No more bytes to send */
if
(
file_bytes_left
<=
0L
)
{
/* No more bytes to send */
newline
();
newline
();
lputs
(
"Attempt to send more than header specified
\r\n
"
);
fprintf
(
statfp
,
"Attempt to send more than header specified
\n
"
);
break
;
}
break
;
if
(
hdr_block_num
==
((
block_num
+
1
)
&
0xff
))
{
/* correct block */
}
if
(
hdr_block_num
==
(
uchar
)((
block_num
+
1
)
&
0xff
))
{
/* correct block */
block_num
++
;
block_num
++
;
if
(
file_bytes_left
<
block_size
)
{
if
(
file_bytes_left
<
block_size
)
{
if
(
fwrite
(
block
,
1
,
file_bytes_left
,
stream
)
if
(
fwrite
(
block
,
1
,
file_bytes_left
,
fp
)
!=
file_bytes_left
)
{
!=
file_bytes_left
)
{
newline
();
newline
();
l
printf
(
"Error writing to file
\
r\
n
"
);
f
printf
(
statfp
,
"Error writing to file
\n
"
);
cancel
();
cancel
();
bail
(
1
);
}
}
bail
(
1
);
}
}
else
{
else
{
if
(
fwrite
(
block
,
1
,
block_size
,
stream
)
if
(
fwrite
(
block
,
1
,
block_size
,
fp
)
!=
block_size
)
{
!=
block_size
)
{
newline
();
newline
();
l
printf
(
"Error writing to file
\
r\
n
"
);
f
printf
(
statfp
,
"Error writing to file
\n
"
);
cancel
();
cancel
();
bail
(
1
);
}
}
bail
(
1
);
file_bytes_left
-=
block_size
;
}
}
}
file_bytes_left
-=
block_size
;
}
else
{
else
{
newline
();
newline
();
l
printf
(
"Block number %u instead of %u
\
r\
n
"
f
printf
(
statfp
,
"Block number %u instead of %u
\n
"
,
hdr_block_num
,(
block_num
+
1
)
&
0xff
);
,
hdr_block_num
,(
block_num
+
1
)
&
0xff
);
// dump_block();
// dump_block();
errors
++
;
}
errors
++
;
}
t
=
time
(
NULL
)
-
startfile
;
t
=
time
(
NULL
)
-
startfile
;
if
(
!
t
)
t
=
1
;
if
(
!
t
)
t
=
1
;
cps
=
(
uint
)((
block_num
*
(
long
)
block_size
)
/
t
);
/* cps so far */
cps
=
(
uint
)((
block_num
*
(
long
)
block_size
)
/
t
);
/* cps so far */
...
@@ -1661,7 +1229,7 @@ if(mode&RECV) {
...
@@ -1661,7 +1229,7 @@ if(mode&RECV) {
if
(
l
<
0
)
l
=
0
;
if
(
l
<
0
)
l
=
0
;
b
=
blocks
(
file_bytes
);
b
=
blocks
(
file_bytes
);
if
(
mode
&
YMODEM
)
if
(
mode
&
YMODEM
)
l
printf
(
"
\r
Block (%lu%s): %lu/%lu Byte: %lu Time: %lu:%02lu "
f
printf
(
statfp
,
"
\r
Block (%lu%s): %lu/%lu Byte: %lu Time: %lu:%02lu "
"Left: %lu:%02lu CPS: %u %lu%% "
"Left: %lu:%02lu CPS: %u %lu%% "
,
block_size
%
1024L
?
block_size
:
block_size
/
1024L
,
block_size
%
1024L
?
block_size
:
block_size
/
1024L
,
block_size
%
1024L
?
""
:
"k"
,
block_size
%
1024L
?
""
:
"k"
...
@@ -1676,7 +1244,7 @@ if(mode&RECV) {
...
@@ -1676,7 +1244,7 @@ if(mode&RECV) {
,(
long
)(((
float
)
block_num
/
(
float
)
b
)
*
100
.
0
)
,(
long
)(((
float
)
block_num
/
(
float
)
b
)
*
100
.
0
)
);
);
else
/* Xmodem */
else
/* Xmodem */
l
printf
(
"
\r
Block (%lu%s): %lu Byte: %lu Time: %lu:%02lu "
f
printf
(
statfp
,
"
\r
Block (%lu%s): %lu Byte: %lu Time: %lu:%02lu "
"CPS: %u "
"CPS: %u "
,
block_size
%
1024L
?
block_size
:
block_size
/
1024L
,
block_size
%
1024L
?
block_size
:
block_size
/
1024L
,
block_size
%
1024L
?
""
:
"k"
,
block_size
%
1024L
?
""
:
"k"
...
@@ -1689,50 +1257,44 @@ if(mode&RECV) {
...
@@ -1689,50 +1257,44 @@ if(mode&RECV) {
}
}
putcom
(
ACK
);
putcom
(
ACK
);
if
(
!
(
mode
&
XMODEM
)
&&
ftime
)
{
if
(
!
(
mode
&
XMODEM
)
&&
ftime
)
unixtodos
(
ftime
,
&
dosdate
,
&
dostime
);
setfdate
(
str
,
ftime
);
if
(
dosdate
.
da_year
>=
1980
)
{
fclose
(
fp
);
ft
.
ft_min
=
dostime
.
ti_min
;
ft
.
ft_hour
=
dostime
.
ti_hour
;
ft
.
ft_tsec
=
dostime
.
ti_sec
/
2
;
ft
.
ft_year
=
dosdate
.
da_year
-
1980
;
ft
.
ft_day
=
dosdate
.
da_day
;
ft
.
ft_month
=
dosdate
.
da_mon
;
setftime
(
file
,
&
ft
);
}
}
fclose
(
stream
);
t
=
time
(
NULL
)
-
startfile
;
t
=
time
(
NULL
)
-
startfile
;
if
(
!
t
)
t
=
1
;
if
(
!
t
)
t
=
1
;
l
=
(
block_num
-
1
)
*
(
long
)
block_size
;
l
=
(
block_num
-
1
)
*
(
long
)
block_size
;
if
(
l
>
file_bytes
)
if
(
l
>
file_bytes
)
l
=
file_bytes
;
l
=
file_bytes
;
newline
();
newline
();
l
printf
(
"Successsful - Time: %lu:%02lu CPS: %lu
\
r\
n
"
f
printf
(
statfp
,
"Successsful - Time: %lu:%02lu CPS: %lu
\n
"
,
t
/
60
,
t
%
60
,
l
/
t
);
,
t
/
60
,
t
%
60
,
l
/
t
);
if
(
log
)
{
if
(
log
)
{
fprintf
(
log
,
"%c %6lu %5u bps %4lu cps %3u errors %5u %4u "
fprintf
(
log
,
"%c %6lu %5u bps %4lu cps %3u errors %5u %4u "
"%s %d
\
r\
n
"
"%s %d
\n
"
,
mode
&
ZMODEM
?
'Z'
:
'R'
,
mode
&
ZMODEM
?
'Z'
:
'R'
,
l
,
l
,
baud
,
30000
/*
baud
*/
,
l
/
t
,
l
/
t
,
errors
,
errors
,
flows
,
flows
,
block_size
,
block_size
,
str
,
str
,
serial_num
);
}
,
serial_num
);
}
if
(
mode
&
XMODEM
)
if
(
mode
&
XMODEM
)
break
;
break
;
total_files
--
;
total_files
--
;
total_bytes
-=
file_bytes
;
total_bytes
-=
file_bytes
;
if
(
total_files
>
1
&&
total_bytes
)
if
(
total_files
>
1
&&
total_bytes
)
l
printf
(
"Remaining - Time: %lu:%02lu Files: %u Bytes: %lu
\
r\
n
"
f
printf
(
statfp
,
"Remaining - Time: %lu:%02lu Files: %u Bytes: %lu
\n
"
,(
total_bytes
/
cps
)
/
60
,(
total_bytes
/
cps
)
/
60
,(
total_bytes
/
cps
)
%
60
,(
total_bytes
/
cps
)
%
60
,
total_files
,
total_files
,
total_bytes
,
total_bytes
);
);
}
}
bail
(
0
);
}
bail
(
0
);
}
/********/
/********/
/* SEND */
/* SEND */
...
@@ -1742,26 +1304,38 @@ if(mode&RECV) {
...
@@ -1742,26 +1304,38 @@ if(mode&RECV) {
/* Search through all to find total files and bytes */
/* Search through all to find total files and bytes */
/****************************************************/
/****************************************************/
for
(
fnum
=
0
;
fnum
<
fnames
;
fnum
++
)
{
for
(
fnum
=
0
;
fnum
<
fnames
;
fnum
++
)
{
last
=
findfirst
(
fname
[
fnum
],
&
ff
,
0
);
/* incase wildcards are used */
if
(
glob
(
fname
[
fnum
],
0
,
NULL
,
&
g
))
{
if
(
last
)
fprintf
(
statfp
,
"%s not found
\n
"
,
fname
[
fnum
]);
lprintf
(
"%s not found
\r\n
"
,
fname
[
fnum
]);
continue
;
while
(
!
last
)
{
}
for
(
i
=
0
;
i
<
(
int
)
g
.
gl_pathc
;
i
++
)
{
if
(
isdir
(
g
.
gl_pathv
[
i
]))
continue
;
total_files
++
;
total_files
++
;
total_bytes
+=
ff
.
ff_fsize
;
total_bytes
+=
flength
(
g
.
gl_pathv
[
i
]);
last
=
findnext
(
&
ff
);
}
}
}
globfree
(
&
g
);
}
if
(
fnames
>
1
)
if
(
fnames
>
1
)
l
printf
(
"Sending %u files (%lu bytes total)
\
r\
n
"
f
printf
(
statfp
,
"Sending %u files (%lu bytes total)
\n
"
,
total_files
,
total_bytes
);
,
total_files
,
total_bytes
);
#if 0
rioctl(IOFB);
rioctl(IOFB);
#endif
/***********************************************/
/***********************************************/
/* Send every file matching names or filespecs */
/* Send every file matching names or filespecs */
/***********************************************/
/***********************************************/
for
(
fnum
=
0
;
fnum
<
fnames
;
fnum
++
)
{
for
(
fnum
=
0
;
fnum
<
fnames
;
fnum
++
)
{
last
=
findfirst
(
fname
[
fnum
],
&
ff
,
0
);
if
(
glob
(
fname
[
fnum
],
0
,
NULL
,
&
g
))
{
while
(
!
last
)
{
fprintf
(
statfp
,
"%s not found
\n
"
,
fname
[
fnum
]);
continue
;
}
for
(
gi
=
0
;
gi
<
(
int
)
g
.
gl_pathc
;
gi
++
)
{
if
(
isdir
(
g
.
gl_pathv
[
gi
]))
continue
;
fsize
=
flength
(
g
.
gl_pathv
[
gi
]);
if
(
mode
&
ZMODEM
)
{
if
(
mode
&
ZMODEM
)
{
#if 0
#if 0
putcom('r'); putcom('z'); putcom(CR); /* send rz\r */
putcom('r'); putcom('z'); putcom(CR); /* send rz\r */
...
@@ -1779,28 +1353,39 @@ for(fnum=0;fnum<fnames;fnum++) {
...
@@ -1779,28 +1353,39 @@ for(fnum=0;fnum<fnames;fnum++) {
can
=
0
;
can
=
0
;
if
(
i
==
NAK
)
{
/* csum */
if
(
i
==
NAK
)
{
/* csum */
mode
&=~
CRC
;
mode
&=~
CRC
;
break
;
}
break
;
}
if
(
i
==
'C'
)
{
if
(
i
==
'C'
)
{
mode
|=
CRC
;
mode
|=
CRC
;
break
;
}
break
;
}
if
(
i
==
'G'
)
{
if
(
i
==
'G'
)
{
mode
|=
(
GMODE
|
CRC
);
mode
|=
(
GMODE
|
CRC
);
break
;
}
break
;
}
if
(
i
==
CAN
)
{
if
(
i
==
CAN
)
{
if
(
can
)
{
if
(
can
)
{
newline
();
newline
();
lprintf
(
"Cancelled remotely
\r\n
"
);
fprintf
(
statfp
,
"Cancelled remotely
\n
"
);
bail
(
1
);
}
bail
(
1
);
can
=
1
;
}
}
can
=
1
;
}
#if 0
rioctl(IOFB); /* flush buffers cause we have crap-o-la */
rioctl(IOFB); /* flush buffers cause we have crap-o-la */
#endif
if
(
i
!=
NOINP
)
{
if
(
i
!=
NOINP
)
{
newline
();
newline
();
lprintf
(
"Received %s Expected NAK, C, or G
\r\n
"
fprintf
(
statfp
,
"Received %s Expected NAK, C, or G
\n
"
,
chr
(
i
));
}
}
,
chr
(
i
));
}
}
if
(
errors
==
MAXERRORS
)
{
if
(
errors
==
MAXERRORS
)
{
l
printf
(
"Timeout starting transfer
\
r\
n
"
);
f
printf
(
statfp
,
"Timeout starting transfer
\n
"
);
cancel
();
cancel
();
bail
(
1
);
}
}
/* X/Ymodem */
bail
(
1
);
}
}
/* X/Ymodem */
strcpy
(
str
,
fname
[
fnum
]);
strcpy
(
str
,
fname
[
fnum
]);
if
(
strchr
(
str
,
'*'
)
||
strchr
(
str
,
'?'
))
{
/* wildcards used */
if
(
strchr
(
str
,
'*'
)
||
strchr
(
str
,
'?'
))
{
/* wildcards used */
...
@@ -1811,38 +1396,32 @@ for(fnum=0;fnum<fnames;fnum++) {
...
@@ -1811,38 +1396,32 @@ for(fnum=0;fnum<fnames;fnum++) {
*
(
p
+
1
)
=
NULL
;
*
(
p
+
1
)
=
NULL
;
else
else
str
[
0
]
=
0
;
str
[
0
]
=
0
;
strcat
(
str
,
ff
.
ff_name
);
}
strcat
(
str
,
g
.
gl_pathv
[
gi
]);
}
l
printf
(
"Sending %s (%lu bytes) via %s %s
\
r\
n
"
f
printf
(
statfp
,
"Sending %s (%lu bytes) via %s %s
\n
"
,
str
,
ff
.
ff_
fsize
,
str
,
fsize
,
mode
&
XMODEM
?
"Xmodem"
:
mode
&
YMODEM
?
mode
&
GMODE
?
"Ymodem-G"
,
mode
&
XMODEM
?
"Xmodem"
:
mode
&
YMODEM
?
mode
&
GMODE
?
"Ymodem-G"
:
"Ymodem"
:
"Zmodem"
:
"Ymodem"
:
"Zmodem"
,
mode
&
CRC
?
"CRC-16"
:
"Checksum"
);
,
mode
&
CRC
?
"CRC-16"
:
"Checksum"
);
if
((
file
=
nopen
(
str
,
O_RDONLY
))
==-
1
if
((
fp
=
fopen
(
str
,
"rb"
))
==
NULL
)
{
||
(
stream
=
fdopen
(
file
,
"rb"
))
==
NULL
)
{
fprintf
(
statfp
,
"Error opening %s for read
\n
"
,
str
);
lprintf
(
"Error opening %s for read
\r\n
"
,
str
);
cancel
();
cancel
();
bail
(
1
);
}
bail
(
1
);
setvbuf
(
stream
,
NULL
,
_IOFBF
,
8
*
1024
);
}
setvbuf
(
fp
,
NULL
,
_IOFBF
,
8
*
1024
);
#if 0
rioctl(IOFB); /* flush buffers cause extra 'G', 'C', or NAKs */
rioctl(IOFB); /* flush buffers cause extra 'G', 'C', or NAKs */
#endif
if
(
!
(
mode
&
XMODEM
))
{
if
(
!
(
mode
&
XMODEM
))
{
getftime
(
file
,
&
ft
);
t
=
fdate
(
str
);
dostime
.
ti_min
=
ft
.
ft_min
;
dostime
.
ti_hour
=
ft
.
ft_hour
;
dostime
.
ti_hund
=
0
;
dostime
.
ti_sec
=
ft
.
ft_tsec
*
2
;
dosdate
.
da_year
=
1980
+
ft
.
ft_year
;
dosdate
.
da_day
=
ft
.
ft_day
;
dosdate
.
da_mon
=
ft
.
ft_month
;
t
=
dostounix
(
&
dosdate
,
&
dostime
);
memset
(
block
,
NULL
,
128
);
memset
(
block
,
NULL
,
128
);
strcpy
(
block
,
ff
.
ff_name
);
strcpy
(
block
,
g
.
gl_pathv
[
gi
]);
strlwr
(
block
);
sprintf
(
block
+
strlen
(
block
)
+
1
,
"%lu %lo 0 0 %d %ld"
sprintf
(
block
+
strlen
(
block
)
+
1
,
"%lu %lo 0 0 %d %ld"
,
ff
.
ff_
fsize
,
t
,
total_files
-
sent_files
,
total_bytes
-
sent_bytes
);
,
fsize
,
t
,
total_files
-
sent_files
,
total_bytes
-
sent_bytes
);
/*
/*
l
printf("Sending Ymodem block '%s'\
r\
n",block+strlen(block)+1);
f
printf(
statfp,
"Sending Ymodem block '%s'\n",block+strlen(block)+1);
*/
*/
block_num
=
0
;
block_num
=
0
;
i
=
block_size
;
i
=
block_size
;
...
@@ -1850,12 +1429,14 @@ for(fnum=0;fnum<fnames;fnum++) {
...
@@ -1850,12 +1429,14 @@ for(fnum=0;fnum<fnames;fnum++) {
for
(
errors
=
0
;
errors
<
MAXERRORS
;
errors
++
)
{
for
(
errors
=
0
;
errors
<
MAXERRORS
;
errors
++
)
{
put_block
();
put_block
();
if
(
get_ack
())
if
(
get_ack
())
break
;
}
break
;
}
if
(
errors
==
MAXERRORS
)
{
if
(
errors
==
MAXERRORS
)
{
newline
();
newline
();
l
printf
(
"Failed to send header block
\
r\
n
"
);
f
printf
(
statfp
,
"Failed to send header block
\n
"
);
cancel
();
cancel
();
bail
(
1
);
}
bail
(
1
);
}
block_size
=
i
;
/* Restore block size */
block_size
=
i
;
/* Restore block size */
mode
&=~
GMODE
;
mode
&=~
GMODE
;
for
(
errors
=
can
=
0
;
errors
<
MAXERRORS
;
errors
++
)
{
for
(
errors
=
can
=
0
;
errors
<
MAXERRORS
;
errors
++
)
{
...
@@ -1864,52 +1445,64 @@ for(fnum=0;fnum<fnames;fnum++) {
...
@@ -1864,52 +1445,64 @@ for(fnum=0;fnum<fnames;fnum++) {
can
=
0
;
can
=
0
;
if
(
i
==
NAK
)
{
/* csum */
if
(
i
==
NAK
)
{
/* csum */
mode
&=~
CRC
;
mode
&=~
CRC
;
break
;
}
break
;
}
if
(
i
==
'C'
)
{
if
(
i
==
'C'
)
{
mode
|=
CRC
;
mode
|=
CRC
;
break
;
}
break
;
}
if
(
i
==
'G'
)
{
if
(
i
==
'G'
)
{
mode
|=
(
GMODE
|
CRC
);
mode
|=
(
GMODE
|
CRC
);
break
;
}
break
;
}
if
(
i
==
CAN
)
{
if
(
i
==
CAN
)
{
if
(
can
)
{
if
(
can
)
{
newline
();
newline
();
lprintf
(
"Cancelled remotely
\r\n
"
);
fprintf
(
statfp
,
"Cancelled remotely
\n
"
);
bail
(
1
);
}
bail
(
1
);
can
=
1
;
}
}
can
=
1
;
}
#if 0
rioctl(IOFB);
rioctl(IOFB);
#endif
if
(
i
!=
NOINP
)
{
if
(
i
!=
NOINP
)
{
newline
();
newline
();
lprintf
(
"Received %s Expected NAK, C, or G
\r\n
"
fprintf
(
statfp
,
"Received %s Expected NAK, C, or G
\n
"
,
chr
(
i
));
}
}
,
chr
(
i
));
}
}
if
(
errors
==
MAXERRORS
)
{
if
(
errors
==
MAXERRORS
)
{
newline
();
newline
();
l
printf
(
"Too many errors waiting for receiver
\
r\
n
"
);
f
printf
(
statfp
,
"Too many errors waiting for receiver
\n
"
);
cancel
();
cancel
();
bail
(
1
);
}
}
bail
(
1
);
}
}
last_block_num
=
block_num
=
1
;
last_block_num
=
block_num
=
1
;
startfile
=
time
(
NULL
);
startfile
=
time
(
NULL
);
errors
=
0
;
errors
=
0
;
while
((
block_num
-
1
)
*
(
long
)
block_size
<
ff
.
ff_
fsize
&&
errors
<
MAXERRORS
)
{
while
((
block_num
-
1
)
*
(
long
)
block_size
<
fsize
&&
errors
<
MAXERRORS
)
{
if
(
last_block_num
==
block_num
)
{
/* block_num didn't increment */
if
(
last_block_num
==
block_num
)
{
/* block_num didn't increment */
fseek
(
stream
,(
block_num
-
1
)
*
(
long
)
block_size
,
SEEK_SET
);
fseek
(
fp
,(
block_num
-
1
)
*
(
long
)
block_size
,
SEEK_SET
);
i
=
fread
(
block
,
1
,
block_size
,
stream
);
i
=
fread
(
block
,
1
,
block_size
,
fp
);
while
(
i
<
block_size
)
while
(
i
<
block_size
)
block
[
i
++
]
=
CPMEOF
;
}
block
[
i
++
]
=
CPMEOF
;
}
last_block_num
=
block_num
;
last_block_num
=
block_num
;
put_block
();
put_block
();
i
=
fread
(
block
,
1
,
block_size
,
stream
);
/* read next block from disk */
i
=
fread
(
block
,
1
,
block_size
,
fp
);
/* read next block from disk */
while
(
i
<
block_size
)
while
(
i
<
block_size
)
block
[
i
++
]
=
CPMEOF
;
block
[
i
++
]
=
CPMEOF
;
t
=
time
(
NULL
)
-
startfile
;
t
=
time
(
NULL
)
-
startfile
;
if
(
!
t
)
t
=
1
;
/* t is time so far */
if
(
!
t
)
t
=
1
;
/* t is time so far */
cps
=
(
uint
)((
block_num
*
(
long
)
block_size
)
/
t
);
/* cps so far */
cps
=
(
uint
)((
block_num
*
(
long
)
block_size
)
/
t
);
/* cps so far */
if
(
!
cps
)
cps
=
1
;
if
(
!
cps
)
cps
=
1
;
l
=
ff
.
ff_
fsize
/
cps
;
/* total transfer est time */
l
=
fsize
/
cps
;
/* total transfer est time */
l
-=
t
;
/* now, it's est time left */
l
-=
t
;
/* now, it's est time left */
if
(
l
<
0
)
l
=
0
;
if
(
l
<
0
)
l
=
0
;
b
=
blocks
(
ff
.
ff_
fsize
);
b
=
blocks
(
fsize
);
l
printf
(
"
\r
Block (%lu%s): %lu/%lu Byte: %lu "
f
printf
(
statfp
,
"
\r
Block (%lu%s): %lu/%lu Byte: %lu "
"Time: %lu:%02lu Left: %lu:%02lu CPS: %u %lu%% "
"Time: %lu:%02lu Left: %lu:%02lu CPS: %u %lu%% "
,
block_size
%
1024L
?
block_size
:
block_size
/
1024L
,
block_size
%
1024L
?
block_size
:
block_size
/
1024L
,
block_size
%
1024L
?
""
:
"k"
,
block_size
%
1024L
?
""
:
"k"
...
@@ -1926,18 +1519,21 @@ for(fnum=0;fnum<fnames;fnum++) {
...
@@ -1926,18 +1519,21 @@ for(fnum=0;fnum<fnames;fnum++) {
if
(
!
get_ack
())
if
(
!
get_ack
())
errors
++
;
errors
++
;
else
else
block_num
++
;
}
block_num
++
;
fclose
(
stream
);
}
fclose
(
fp
);
success
=
0
;
success
=
0
;
if
((
block_num
-
1
)
*
(
long
)
block_size
>=
ff
.
ff_
fsize
)
{
if
((
long
)(
block_num
-
1
)
*
(
long
)
block_size
>=
fsize
)
{
sent_files
++
;
sent_files
++
;
sent_bytes
+=
ff
.
ff_
fsize
;
sent_bytes
+=
fsize
;
riosync
();
riosync
();
l
printf
(
"
\n
"
);
f
printf
(
statfp
,
"
\n
"
);
for
(
i
=
0
;
i
<
10
;
i
++
)
{
for
(
i
=
0
;
i
<
10
;
i
++
)
{
lprintf
(
"
\r
Sending EOT (%d)"
,
i
+
1
);
fprintf
(
statfp
,
"
\r
Sending EOT (%d)"
,
i
+
1
);
#if 0
rioctl(IOFI);
rioctl(IOFI);
#endif
putcom
(
EOT
);
putcom
(
EOT
);
ch
=
getcom
(
10
);
ch
=
getcom
(
10
);
if
(
ch
==
ACK
)
if
(
ch
==
ACK
)
...
@@ -1946,23 +1542,27 @@ for(fnum=0;fnum<fnames;fnum++) {
...
@@ -1946,23 +1542,27 @@ for(fnum=0;fnum<fnames;fnum++) {
continue
;
/* chuck's double EOT trick so don't complain */
continue
;
/* chuck's double EOT trick so don't complain */
if
(
ch
!=
NOINP
)
{
if
(
ch
!=
NOINP
)
{
newline
();
newline
();
lprintf
(
"Received %s Expected ACK
\r\n
"
fprintf
(
statfp
,
"Received %s Expected ACK
\n
"
,
chr
(
ch
));
}
}
,
chr
(
ch
));
}
}
if
(
i
==
3
)
if
(
i
==
3
)
l
printf
(
"
\r
No ACK on EOT
\n
"
);
f
printf
(
statfp
,
"
\r
No ACK on EOT
\n
"
);
t
=
time
(
NULL
)
-
startfile
;
t
=
time
(
NULL
)
-
startfile
;
if
(
!
t
)
t
=
1
;
if
(
!
t
)
t
=
1
;
lprintf
(
"
\r
Successsful - Time: %lu:%02lu CPS: %lu
\r\n
"
fprintf
(
statfp
,
"
\r
Successsful - Time: %lu:%02lu CPS: %lu
\n
"
,
t
/
60
,
t
%
60
,
ff
.
ff_fsize
/
t
);
,
t
/
60
,
t
%
60
,
fsize
/
t
);
success
=
1
;
}
success
=
1
;
}
else
{
else
{
newline
();
newline
();
lputs
(
"Unsuccessful!
\
r\
n
"
);
fprintf
(
statfp
,
"Unsuccessful!
\n
"
);
t
=
time
(
NULL
)
-
startfile
;
t
=
time
(
NULL
)
-
startfile
;
if
(
!
t
)
t
=
1
;
}
if
(
!
t
)
t
=
1
;
}
if
(
total_files
>
1
&&
total_files
-
sent_files
>
1
)
if
(
total_files
>
1
&&
total_files
-
sent_files
>
1
)
l
printf
(
"Remaining - Time: %lu:%02lu Files: %u Bytes: %lu
\
r\
n
"
f
printf
(
statfp
,
"Remaining - Time: %lu:%02lu Files: %u Bytes: %lu
\n
"
,((
total_bytes
-
sent_bytes
)
/
cps
)
/
60
,((
total_bytes
-
sent_bytes
)
/
cps
)
/
60
,((
total_bytes
-
sent_bytes
)
/
cps
)
%
60
,((
total_bytes
-
sent_bytes
)
/
cps
)
%
60
,
total_files
-
sent_files
,
total_files
-
sent_files
...
@@ -1970,20 +1570,21 @@ for(fnum=0;fnum<fnames;fnum++) {
...
@@ -1970,20 +1570,21 @@ for(fnum=0;fnum<fnames;fnum++) {
);
);
if
(
log
)
{
if
(
log
)
{
l
=
(
block_num
-
1
)
*
(
long
)
block_size
;
l
=
(
block_num
-
1
)
*
(
long
)
block_size
;
if
(
l
>
ff
.
ff_
fsize
)
if
(
l
>
fsize
)
l
=
ff
.
ff_
fsize
;
l
=
fsize
;
fprintf
(
log
,
"%c %6lu %5u bps %4lu cps %3u errors %5u %4u "
fprintf
(
log
,
"%c %6lu %5u bps %4lu cps %3u errors %5u %4u "
"%s -1
\
r\
n
"
"%s -1
\n
"
,
success
?
(
mode
&
ZMODEM
?
'z'
:
'S'
)
:
'E'
,
success
?
(
mode
&
ZMODEM
?
'z'
:
'S'
)
:
'E'
,
l
,
l
,
baud
,
30000
/*
baud
*/
,
l
/
t
,
l
/
t
,
errors
,
errors
,
flows
,
flows
,
block_size
,
block_size
,
fname
[
fnum
]);
}
,
fname
[
fnum
]);
}
last
=
findnext
(
&
ff
);
}
}
}
}
if
(
mode
&
XMODEM
)
if
(
mode
&
XMODEM
)
bail
(
0
);
bail
(
0
);
mode
&=~
GMODE
;
mode
&=~
GMODE
;
...
@@ -1996,7 +1597,8 @@ else if(i=='G')
...
@@ -1996,7 +1597,8 @@ else if(i=='G')
mode
|=
(
GMODE
|
CRC
);
mode
|=
(
GMODE
|
CRC
);
if
(
i
!=
NOINP
&&
i
!=
NAK
&&
i
!=
'C'
&&
i
!=
'G'
)
{
if
(
i
!=
NOINP
&&
i
!=
NAK
&&
i
!=
'C'
&&
i
!=
'G'
)
{
newline
();
newline
();
lprintf
(
"Received %s Expected NAK, C, or G
\r\n
"
,
chr
(
i
));
}
fprintf
(
statfp
,
"Received %s Expected NAK, C, or G
\n
"
,
chr
(
i
));
}
else
if
(
i
!=
NOINP
)
{
else
if
(
i
!=
NOINP
)
{
block_num
=
0
;
block_num
=
0
;
block
[
0
]
=
0
;
block
[
0
]
=
0
;
...
@@ -2004,13 +1606,16 @@ else if(i!=NOINP) {
...
@@ -2004,13 +1606,16 @@ else if(i!=NOINP) {
put_block
();
put_block
();
if
(
!
get_ack
())
{
if
(
!
get_ack
())
{
newline
();
newline
();
lprintf
(
"Failed to receive ACK after terminating block
\r\n
"
);
}
}
fprintf
(
statfp
,
"Failed to receive ACK after terminating block
\n
"
);
}
}
if
(
total_files
>
1
)
{
if
(
total_files
>
1
)
{
t
=
time
(
NULL
)
-
startall
;
t
=
time
(
NULL
)
-
startall
;
if
(
!
t
)
t
=
1
;
if
(
!
t
)
t
=
1
;
newline
();
newline
();
lprintf
(
"Overall - Time %02lu:%02lu Bytes: %lu CPS: %lu
\r\n
"
fprintf
(
statfp
,
"Overall - Time %02lu:%02lu Bytes: %lu CPS: %lu
\n
"
,
t
/
60
,
t
%
60
,
sent_bytes
,
sent_bytes
/
t
);
}
,
t
/
60
,
t
%
60
,
sent_bytes
,
sent_bytes
/
t
);
}
bail
(
0
);
bail
(
0
);
return
(
0
);
return
(
0
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment