Category : C Source Code
Archive   : WINKERM.ZIP
Filename : KERMPROT.H

 
Output of file : KERMPROT.H contained in archive : WINKERM.ZIP
/*******************************************************************************
** **
** Kermit for Microsoft Windows **
** ---------------------------- **
** KERMPROT.H **
** **
** This include file contains the definitions, variables, and function **
** prototypes used during a Kermit protocol. **
** **
*******************************************************************************/

// DEFINITIONS ----------------------------------------------------------------

#define MAXSP 1000
#define MAXRP 2000

#define MAXTRY 5
#define SP 32

#define KERMITSEND 's'
#define KERMITRECEIVE 'v'
#define KERMITSERVER 'x'
#define KERMITGET 'r'
#define KERMITHOST 'c'
#define KERMITGENERIC 'g'

/* Macros */
#define tochar(ch) ((ch) + SP)
#define unchar(ch) ((ch) - SP)
#define ctl(ch) ((ch) ^ 64)

// DATA STORAGE DECLARATIONS --------------------------------------------------

CLASS char strbuf[500];

/* Kermit Protocol Negotiation */
CLASS int spsiz, /* Send Packet Size */
rpsiz, /* Receive Packet Size */
timint, /* Timeout Interval (Send Timeout) stimo??? */
rtimo, /* Request Timeout (Receive Timeout) */
spadn, /* Send Padding (Number of Characters) */
rpadn, /* Receive Padding (Number of Characters) */
bctr, /* Block Check Type Requested */
bctu, /* Block Check Type Used */
ebq, /* 8th-bit Quote Prefix */
ebqflg, /* 8th-bit Quoting Flag */
rqf, /* Request (8th-bit) Quoting Flag */
rq, /* Received 8th-bit Quote Bid */
sq, /* Sent 8th-bit Quote Bid */
rpt, /* Repeat Count */
rptq, /* Repeat Quote Prefix */
rptflg; /* Repeat Quoting Flag */


CLASS int capas, /* Position of Capabilities Mask */
atcapb, /* Attribute Capability */
atcapr, /* Requested */
atcapu, /* Used */
swcapb, /* Sliding Window Capability */
swcapr, /* Requested */
swcapu, /* Used */
lpcapb, /* Long Packet Capability */
lpcapr, /* Requested */
lpcapu; /* Used */

CLASS char spadc, /* Send Pad Character */
rpadc, /* Receive Pad Character */
seol, /* Send End of Line Character */
reol, /* Receive End of Line Character */
sctlq, /* Send Control Quote Character */
rctlq; /* Receive Control Quote Character */

/* Packet Control */
CLASS int seq, /* Current Packet Sequence Number */
size, /* Size of Current Send Packet Data */
osize, /* Size of Previous Send Packet Data */
maxsiz, /* Maximum Size of Send Packet Data Field */
rln, /* Length of Last Packet Received */
rsn, /* Sequence Number of Last Packet Received */
limit, /* Send Retry Limit */
sndpkl, /* Length of Current Send Packet */
local, /* TRUE if operator is at console */
delay; /* Delay Before Send (in seconds) */

CLASS char sndpkt[MAXSP+100], /* Send Packet */
rcvpkt[MAXRP+200], /* Receive Packet */
*rdatap, /* Pointer to Receive Packet Data Area */
data[MAXRP+1], /* Packet Data Buffer */
*isp, /* Input String Pointer */
*osp, /* Output String Pointer */
smark, /* Send Start of Packet Mark Character */
rmark, /* Receive Start of Packet Mark Character */
ssc, /* ??? */
cmarg[80]; /* ??? */

/* File Control */
CLASS char filnam[80]; /* Name of Current File */
CLASS long filsiz; /* Length of Active File */

CLASS int nfils, /* Number of Files in Send Group */
cx, /* Cancel File Flag */
cz, /* Cancel Batch Flag */
cr, /* Operator Retry Request Flag */
ce, /* Stop Transfer Flag (w/ Error) */
cc, /* Abort Transfer Flag (Immediately) */
xflag, /* Data to Screen Flag */
xpkt; /* Flag to Send X Packet */

CLASS FILE *ifp; /* Input File Pointer */
CLASS FILE *ofp; /* Output File Pointer */

/* Flags */
CLASS int server, /* Server Operation Flag */
start, /* Preset Transaction Type */
first, /* First Input From File Flag */
clrinl, /* Clear Input Line Flag */
parity, /* Parity Flag (7 Bit Data) */
keep; /* Keep Incomplete Files Flag */

/* Status Display */
typedef struct tagStatsBlk {
int Packets; /* Number of Packets Sent */
long Bytes; /* Number of Bytes Sent/Received */
int Retries; /* Number of Send Retries */
} StatsBlk;

CLASS StatsBlk Stats;

CLASS HWND hSendList;

// MACRO DEFINITIONS ----------------------------------------------------------

#define RESUME(x) if (server) { SERVE; } else EndKermit(x)
#define ERR(s) error(s); RESUME(-1)
#define BEGIN(x) state=x
#define SERVE tinit(); server = 1; BEGIN(sserv)

// KERMIT PROTOCOL STATES -----------------------------------------------------

#define ssfil 01
#define ssdat 02
#define sseot 03
#define ssatr 04
#define ssatx 05

#define srini 11
#define srfil 12
#define srdat 13
#define sratt 14

#define sipkt 21
#define srgen 22
#define sserv 23
#define ssgen 24

// FUNCTIONS PROTOTYPES -------------------------------------------------------

/* System Dependent Functions (Physical Layer) */
void ttflui(void);
int ttinl(char *dest, int X, char eol, int timo);
short ttol(char *s, int n);
void tchar(char c);
void tmsg(char *s, ...);
void traw(char *s, int len);

/* System Dependent Functions (Presentation Layer) */
int zopeni(char *name);
int zopeno(char *name);
int zclosi(void);
int zcloso(int x);
void zrtol(char *n1, char *n2, int warn);
void zltor(char *n1, char *n2);
int zgetc(void);
int zputc(int c);

/* Application Layer */
void message(char *t, char *s);
void ShowRetries(int Retries);
void ShowPackets(int Packets);
void ShowBytes(long Bytes);
void ShowTypeIn(char TypeIn);
void ShowTypeOut(char TypeOut);
BOOL FAR PASCAL StatusDlgProc(HWND hDlg, unsigned message,
WORD wParam, LONG lParam);
BOOL FAR PASCAL SendDlgProc(HWND hDlg, unsigned message,
WORD wParam, LONG lParam);
BOOL FAR PASCAL ParmDlgProc(HWND hDlg, unsigned message,
WORD wParam, LONG lParam);
BOOL StartKermit(int Command);
BOOL EndKermit(int Result);

/* Presentation Layer */
int NEAR getpkt(int maxlen);
int NEAR gnchar (void);
void NEAR encode(int a, int next);
int NEAR decode(void);
int NEAR pnchar (int c);
int NEAR encstr(char *s);
void NEAR decstr(char *s);
void NEAR spar(char *s);
char NEAR *rpar(void);
int NEAR sattr(void);
int NEAR rdattr(char *s);
char *NEAR setatt(char *s);

/* Session Layer */

/* Transport Layer */
int NEAR input(void);
void NEAR nxtpkt (void);
void NEAR tinit(void);
void error(char *s);
int NEAR ack(void);
int NEAR ackl(char *s);
int NEAR nak(void);
int NEAR sinit(char c);
int NEAR sfile(void);
int NEAR sdata(void);
int NEAR seof(char *s);
int NEAR seot(void);
int NEAR gnfile(void);
void NEAR rinit(void);
int NEAR rcvfil(void);
int NEAR closof(void);
int NEAR scmd(char t, char *s);

/* Datalink Layer */
int NEAR spack(char type, int n, int len, char *d);
int NEAR resend(void);
int NEAR chk3(char *s);
int NEAR chk1(char *packet);
long NEAR chksum(char *p);
char NEAR rpack (void);


  3 Responses to “Category : C Source Code
Archive   : WINKERM.ZIP
Filename : KERMPROT.H

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/