Dec 232017
 
Protocol Engine for Turbo Pascal -- allows ZModem, YModem, etc. integration.
File PROT018S.ZIP from The Programmer’s Corner in
Category Pascal Source Code
Protocol Engine for Turbo Pascal — allows ZModem, YModem, etc. integration.
File Name File Size Zip Size Zip Type
ANSI_DRV.PAS 8030 1758 deflated
LICENSE.FRM 3228 1234 deflated
PROTCOMM.PAS 16405 3945 deflated
PROTENG.50S 68416 31772 deflated
PROTENG.55S 83136 32455 deflated
PROTENG.60S 51536 20308 deflated
PROTENG.70S 64992 28514 deflated
PROTENG.DOC 21248 7154 deflated
PROTMAP.DOC 8943 1876 deflated
TERM.EXE 63392 28070 deflated
TERM.PAS 13233 3805 deflated
TPCREAD.ME 199 165 deflated

Download File PROT018S.ZIP Here

Contents of the PROTENG.DOC file







Copyright 1993 Mark Dignam and Mick Howland - Omen Computer Services
Perth Omen Bulletin Board System - 3:690/[email protected]



The Protocol Engine for Turbo Pascal.


The EASY way to get your Turbo Pascal programs to transfer files!






T A B L E O F C O N T E N T S


Disclaimer . . . . . . . . . . . . . . . . . . . . . . 1.0
License Details . . . . . . . . . . . . . . . . . . . 1.1

What is a Protocol Engine? . . . . . . . . . . . . . . 2.0
Objectives . . . . . . . . . . . . . . . . . . . . . 2.1
Features . . . . . . . . . . . . . . . . . . . . . . 2.2

Contents of This Archive . . . . . . . . . . . . . . . 3.0

Programming Details . . . . . . . . . . . . . . . . . 4.0
Sending Files . . . . . . . . . . . . . . . . . . . . 4.1
Receiving Files . . . . . . . . . . . . . . . . . . . 4.2
External Hooks . . . . . . . . . . . . . . . . . . . 4.3

Dump of the Protocol Engine's Header . . . . . . . . . 5.0

Release Details . . . . . . . . . . . . . . . . . . . 6.0

Idiosyncrasies . . . . . . . . . . . . . . . . . . . . 7.0

Version History . . . . . . . . . . . . . . . . . . . 8.0

Contacting the Authors . . . . . . . . . . . . . . . . 9.0


1.0) DISCLAIMER

This software is provided without any guarantee, either expressed or
implied. All responsibilities for its use rest with the user of the
software and not the author.

1.1) LICENSE AGREEMENT.

The Protocol Engine is not in the Public Domain. The Protocol Engine is
also not free.

Non-registered users are granted a limited, 30 day license to determine
whether or not the program meets their needs. Continued use of the
Protocol Engine beyond the 30-day evaluation time period requires
registration of the program. Use of non-registered copies of the
Protocol Engine beyond the original evaluation period is strictly
prohibited.

The Protocol Engine may be copied and distributed to others, subject to
the above restrictions and the following:

Only the non-registered version may be copied and distributed
to others. This contains only the pre-compiled units, the
support source code files and the documentation. These are
the ONLY files that may be copied freely. The full source
code for the Protocol Engine MUST not distributed at any
time.

The Protocol Engine must be copied in unmodified form,
including the file containing this license information.

Complete documentation and support files must be included.

No copying fee of any type may be assessed other than basic
charges for the cost of the copying medium.

Sysops (bulletin board SYStem OPerators) may make the Protocol Engine
available for downloading by their users as long as all above
conditions are met.

Commercial Distributors of Public Domain, ShareWare, or User-Supported
software may also distribute The Protocol Engine subject to the above
conditions.

All parts of it, including the source code, the compiled TPU's and the
documents will remain copyright. Any executable programs that are
created or compiled using either sections or all of The Protocol Engine
are for you to do with as you wish. I do not wish a royalty payment
for any of your executables, but a note to the effect that the Protocol
Engine was used in a product would be appreciated.

Please refer to the enclosed LICENSE.FRM for more information.


The following names are trademarks and/or registered names:

Turbo Pascal Borland International.

Thanks for the code and/or designs:

Micheal Quinlan Async4 Pascal Unit
Mark G. Mendel Crc16 Tables and UpdCrc
Stephen Satchell - Satchell Evaluations Crc32 Design
Chuck Forsberg - Omen Technology The Ymodem and
Zmodem Protocols
Gary S. Brown Crc32 tables
System Enhancement Assocaties The Sealink Protocol
Ward Christensen The Xmodem (original!)
Protocol



ABOUT PROTOCOL ENGINE


2.0) What is a Protocol Engine?

It is a set of software routines that take all the hard work out of
writing communication software. In this one easy-to-use Turbo Pascal
(versions 5, 5.5, 6, 7 and Borland Pascal 1.0) Unit are ALL the
procedures and functions required to transfer files from one computer
to another. Various methods of error checking are available, that are
fully compatible with the standard protocols used by conventional
terminal programs.


2.1) Objectives.

Protocol Engine has been to designed to fufill two major objectives:

a) It is very easy to use for even the novice programmer. This was
achieved by using a small linked array of strings to transfer the
filenames between the main program and the unit and then calling a
simple Boolean function for each different method.

b) It has a low DataSegment overhead , while retaining large Transmit
and Receive buffers. It is suitable for Binkley/FrontDoor transfers and
high speed modem links. The current DataSegment use is less than 5k,
while still having up to 15k disk buffering.


2.2) Features.

The Protocol Engine has support for Xmodem, Xmodem with 1k Blocks,
Ymodem Batch, YmodemG Batch, Zmodem (both Crc16 and Crc32), Sealink and
Yapp (a packet radio protocol).

When using Zmodem method of transferring files, the Protocol Engine
fully supports crash recovery in both send and receive modes. In all
batch modes, there is the option to overwrite or create a new file when
receiving.

Since Protocol Engine requires an asynchronous unit to handle high
speed communications, a Comm unit is included with full source code.
This unit is a modified version of the Public Domain ASYNC4. It handles
both Fossil and Non_Fossil environments with ease at speeds upto 38400
baud.

The Protocol Engine also has "external hooks" defined to allow the end
programmer to link in their own code into the Protocol Engine. These
hooks will be called when certain events happen, as the Protocol Engine
is being executed. This allows the end user to further customize the
look of the Engine, and insert more features into their own software.

3.0) Contents of this Archive.

ANSI_DRV.PAS Source Code for a Ansi Screen Unit
PROTCOMM.PAS A Half Decent Comms Unit.

The first two Files are support source code for the Protocol Engine.
Users are free to use these files as they wish. The Ansi unit was
written for another project. It may or may not have bugs - it works for
me! The Comms unit is a very modified version of ASYNC4 with Fossil
Support and internal 16650 support.

TERM.EXE A quick Terminal program written using the Protocol Engine.
TERM.PAS The source code for the above program.

This demo program shows the use of the Protocol Engine. It has all of
the transfer protocols in it, along with Ansi and Doorway emulation
modes.

The next three files are the Turbo Pascal units. The numbers in the
extension field are for the relevant version of Turbo Pascal. To use:
copy the version that relates to your compiler to Proteng.tpu!

PROTENG.50S Protocol Engine for Turbo Pascal 5.0
PROTENG.55S Protocol Engine for Turbo Pascal 5.5
PROTENG.60S Protocol Engine for Turbo Pascal 6.0
PROTENG.70S Protocol Engine for Turbo Pascal 7.0 and
Borland Pascal 1.0

PROTENG.DOC This Document!
LICENSE.FRM License Form - for registration.
PROTMAP.DOC State Table of all the protocols.

4.0) Programming Details.

4.1) Sending Files.

To send a list of files, you must set up the transfer by first giving
the Protocol Engine the list of names to send. Simply call the function
AddNameToList with the FULL path and filename included. If the function
returns TRUE, the call was successful, and the name has been added onto
the heap, ready to send. If the function returns FALSE, the function
couldn't allocate the memory to hold the full path. Since this list is
stored in a linked array of strings the error usually only occurs if
you run out of heap space.

The only way out is to send the files that are stacked on the heap, and
then send the remaining files, in a second transfer.

The next step is to actually transfer the files. Define a boolean
variable and then call the Protocol Engine, with the name of the
protocol you wish to use. Eg:

Goodtransfer := ZmodemTx;

The returned value will indicate COMPLETE success or failure. The
global variable NumberOfFiles, will contain the total number of files
that have been sent. If the transfer got aborted at some point midway
through the set, the Boolean will return as FALSE, and NumberOfFiles
will indicate which file(s) were not successfully sent.

4.2) Receiving files.

Receiving files is just as easy. First you set up the global variable
UploadPath. This MUST contain the full path of where you wish the
received files to be saved. If you select a transfer mode that doesn't
send the filename (such as Xmodem or Xmodem1K) this global variable
must hold the FULL filename, including path.

You can disable or enable overwriting of existing files, by setting the
global variable OverWrite. This also enables download recovery when
using Zmodem.

Then it is simply a matter of calling the required protocol with a
boolean variable to hold the success flag. Eg:

GoodRx := ZmodemRx;

When the function returns to you, the global NumberOfFiles will contain
the total number of files that have been received successfully. The
filenames are recovered by calling the GetNameFromList procedure
repeatly, saving the names into your own array, until it returns back
that the name list is clear.

4.3) The External Hooks.

The external hooks have been provided to allow the programmer a bit
more control of the file transfer. There are three hooks provided:

a) StartOfFile. This will be called at the start of each file. If in
transmit mode, or in a batch receive mode that supports file length, it
will also contain the total bytes within the file.

b) EveryBlock. This will be called, after every logical block has been
sent. It will pass the current byte count of the file being
transferred.

c) EndOfFile. This will called at the end of each transfer, along with
the filename, and success of the transfer.

To use the external hooks, you must define a procedure exactly the same
as the ones in the header. ie:

StartOfFile: _StartFile; {Called at start of EVERY file}

Then you need to write your procedure with the FAR option set ie:

{$F+}
Procedure DummyStartOfFile(F : Str64; Fs : Longint);

begin
{ insert your code here!}
{ and it will called at the start of EACH file transfer}
end;
{$F-}

As the last step - you need to set StartOfFile to your procedure like
this:

StartOfFile := DummyStartofFile;


5.0) Dump of the Protocol Engine Header

{ }
{ Copyright 1993 Mark Dignam - Omen Computer Services - Perth Omen BBS. }
{ This program ,including the source code MAY not be modified, changed }
{ or altered in any way without written permission of the author. }
{ }
{ Protocol Engine Main Module }

Unit ProtEng;

INTERFACE

uses crt,dos,protcomm;

{ This unit MUST use its own serial driver. It has very efficient i/o buffering}
{ but it will use a fossil driver, if one is found at run time. }

Type
Str64 = String[64]; {A type which is used everywhere within }
{ProtEng for the passing of filenames }

_StartFile = Procedure(Fname : str64; FSize : Longint);
_EveryBlock = Procedure(CurrentOffset : Longint);
_EndFile = Procedure(Fname : Str64; GoodTransfer : Boolean);

{ External Procedure Hooks. This are the prototypes for the calls that will be}
{ made by the Protocol Engine at these times }

Const
MaxZBlockSize : Word = 1024;
MaxRetrys : Byte = 10;
Version = 'v0.18a';

{ MaxZblockSize is the biggest Zmodem block to send. Most mailers can accept }
{ 8k blocks, however Terminal programs usually only handle 1k blocks }

{ MaxRetrys is the number of errors in any one transfer that will force a }
{ error abort }

Var
OverWrite : Boolean; {Can overwrite on Rx }
StartOfFile : _StartFile; {Called at start of EVERY file }
EveryBlock : _EveryBlock; {Called before every block transferred }
EndOfFile : _EndFile; {Called after every file, good or bad }
NumberOfFiles : Byte; {How many files got rxed/txed }
UploadPath : Str64; {Where to put the files. In Batch mode }
{this must be set to the upload directory}
{for a single file mode, such as Xmodem }
{this string contains the FULL filename }
WindowType : Byte; {This byte controls the type of display }
{during a file transfer. It can be one of}
{three values 0 = No Display }
{ 1 = Plain Line_of_text }
{ 2 = Window display }

Function Xmodemrx : Boolean;
Function XmodemTX : Boolean;
Function Xmodem1kTX : Boolean;
Function Xmodem1kRx : Boolean;
Function YmodemTX : Boolean;
Function YmodemGTX : Boolean;
Function YappRX : Boolean;
Function YappTx : Boolean;
Function YmodemRx : Boolean;
Function YmodemGRX : Boolean;
Function SealinkTx : Boolean;
Function SealinkRx : Boolean;
Function ZmodemTX : Boolean;
Function ZmodemRX : Boolean;

Function AddNametoList(Var Fname : Str64): Boolean;

{ Adds a Filename to the linked list. Will return false if not enough memory }
{ to store the name }

Procedure GetNameFromList(Var Fname : Str64; var MoreFiles : Boolean);

{ Retrieves and removes the first name from the linked list. Also returns }
{ back if there any more names in the linked list. Fname will be empty if }
{ no name found. It also returns any memory freed back to the heap }

Procedure ClearNameList;

{ Clears the linked list and returns memory to the heap }


6.0) Release Details.

The most current version of the Protocol Engine will always be
available from the authors BBS, the Perth Omen (3:690/660.0) which is
online 24hours/days at all speeds upto v32, +61-9-244-2111. It is a
FREE download to all, and can be picked up by first time callers. It
can also be FileRequested at any time by using the magic filename of
PROTENG.

The Protocol Engine is available in three versions:

a) the compiled TPU's with sample terminal program. This includes the
source for the terminal program, the communications unit and the Ansi
unit. There is NO source supplied for the TPU's. It will also have an
annoying copyright message hard coded into the TPU's. This is the
shareware demonstration version that will allowed on BBS's.

b) As above, but without the annoying message. This will cost $20.00
Australian for registration (plus $5 postage if needed) and will be a
full legal copy with BBS support.

c) The FULL source code. This version has over 150k of Pascal source
for the entire Protocol engine with NO royalties attached. This will
cost $100.00 Australian (plus $5 postage where needed) and BBS support
will be given through the Perth Omen BBS.


7.0) Idiosyncrasies.

a) The Protocol Engine fails to acknowledge filenames and/or paths
which are sent to it for transfer and don't exist. The user must ensure
that the upload and download paths exist.

If Receiving: The upload directory MUST have a trailing "\" if in batch
mode, or the complete name and path if in single file mode. However,
if a file is uploaded with a pathname in the filename header - the path
in the header is stripped - and your path is put in its place.

If Sending: The filenames must be complete names with full paths. If
the file doesn't exist, Protocol Engine will skip it but leave a error
in the global variable IoResult. This will catch you out in the end.
Turbo Pascal never forgets the error, and when you DO get some sort of
error, Turbo will display the OLDEST one!

b) Due to the fact that a program such as the Protocol Engine requires
a tight interface to the serial ports, a communications unit is
included. This unit MUST be used for the Protocol Engine to work
correctly, without making major changes to the source of the Protocol
Engine. You may substitute your own comms unit in place of the
supplied ProtComm unit, but it is at your risk. If you do so, you MUST
create substitute procedures and functions for EVERY routine contained
within ProtComm.


8.0) History Of the Protocol Engine.



V0.00 The Idea is Born!

v0.12 The first beta version is released in Perth.
Looks good so far!
No Sealink yet
Need to modify packet

v0.13 Started to put in Sealink [email protected] AGH!
Numberoffiles now reflects how many successful files
Fixed Zmodem send with TX buffers

v0.14 First Real Beta release.
Fixed TINY bug in Zmodem Start - Mailers refused to
auto_download.

v0.15 Added hooks for StartFile,EndFile and Everyblock.
Added linked list code for Filename passing.
Fixed Bug (not really my bug!) with transfers into Front
Door, because FD can't handle ZDLE Escaped $7f,$ff (as
per Zmodem specs! Tsk Tsk Joho!)
Added WindowType Flag.

v0.16 Minor cosmetic bug fixes. Fixed MAJOR bug in comm unit
for 16650 support!

v0.17 Re_Wrote XModem code, allowing Sealink to be put in.
Ended up being tighter and easier to debug!
Added Dv Time Giveaway. Added CPS in window (waste of CPU!)

v0.18 Finally Finished! First Decent Release... I Think!
Fixed annoying buglets in Timing at end of files, when
using high speeds modems + big fossil buffers.


9.0) Contacting the Authors.

For any further details or the latest version, the authors may be
contacted at the Perth Omen BBS (3:690/[email protected]) on +61-9-244-2111
(multiline) all speeds upto v32, or by voice on +61-9-244-1954 (any
time between 0300GMT and 1600GMT).

Mark Dignam.
Mick Howland.



 December 23, 2017  Add comments

Leave a Reply