#ifndef DIGNET_H
#define DIGNET_H

/*
**	dignet.library include
**
**	Copyright © 1997 by Kenneth "Kenny" Nilsen/Digital Surface
**
**	$VER: DIGNET_H 1.3 (14.7.97)
**
*/

/*      C include by Stellan Klebom (melazy@kuai.se) */


#ifndef	EXEC_TYPES_H
#  include <exec/types.h>
#endif


/*
 *  Error codes
 */

#define	DNETERROR_OK		0	/* everything is ok */
#define	DNETERROR_OVERFLOW	-1	/* buffer overflow (your string buffer) */
#define	DNETERROR_WRONGNET	-2	/* you tried to free wrong net structure */
#define DNETERROR_TIMEOUT	-3	/* timed out waiting to receivce chars */
#define DNETERROR_POINTERERROR	-4	/* wrong pointer (null ptr.) */
#define DNETERROR_OUTOFMEMORY	-5	/* not enough memory (Send/ReceiveNet()) */
#define DNETERROR_FILEERROR	-6	/* file not found (Send/ReceiveNet()) */
#define DNETERROR_PROTOCOL	-7	/* protocol error (not a protocol?) */

/*
 *  IOEXT
 */

#define DNIOEXT_SIZEOF		80	/* max size for IOEXT structure */

/*
 *  InitModem buffer size
 */

#define INITMODEMBUFFER		16	/* minimum length of initmodem's buffer */

/*
 *  The public resource list structure
 */

   typedef struct {
	ULONG	DNRT_ID;		/* net ID */
	APTR	DNRT_NET;		/* ptr. to netstructure */
	APTR	DNRT_TASK;		/* ptr. to task structure using the net */
	STRPTR	DNRT_TASKNAME;		/* ptr. to task name of that task */
	STRPTR	DNRT_DEVICENAME;	/* ptr. to device name in use */
	UWORD	DNRT_UNIT;		/* unit number in use */
	APTR	DNRT_SP;		/* Return address */
	APTR	DNRT_MESSAGEPORT;	/* ptr. to message port of device */
	APTR	DNRT_MESSAGESTRUCT;	/* ptr. to IO message of device */
	ULONG	DNRT_LASTCOMMAND;	/* command number on last librarycall */
	WORD	DNRT_TASKSTATUS;	/* BOOL on the tasks existance (true=ok) */
	ULONG	DNRT_reserved0;		/* reserved for future extensions */
	ULONG	DNRT_reserved1;
	ULONG	DNRT_reserved2;
	ULONG	DNRT_reserved3;
	ULONG	DNRT_reserved4;
    } DIGNETRT;

/*
 *  Command numbers:
 */

#define	CMDALLOCNET		1
#define	CMDREADNET		2
#define	CMDWRITENET		3
#define	CMDQUERYNET		4
#define	CMDABORTNET		5
#define	CMDINITIOEXT		6
#define	CMDREADIOEXT		7
#define	CMDSENDNET		8
#define	CMDRECEIVENET		9
#define	CMDTIMEOUT		10
#define	CMDREADSTRING		11
#define	CMDWRITESTRING		12
#define	CMDGETNETPORT		13
#define	CMDINITMODEM		14
#define	CMDCALLMODEMDT		15
#define	CMDCALLMODEMDP		16
#define	CMDWAITMODEM		17
#define	CMDHANGUPMODEM		18
#define	CMDSTOPWAITING		19
#define	CMDFLUSHNET		20
#define	CMDSETBAUD		21
#define	CMDCONVERTMODEMSTRING	22
#define	CMDGETIOMSG		23
#define	CMDGETMODEMSTATUS	24
#define	CMDGETCURRENTDEVICE	25
#define	CMDGETCURRENTUNIT	26
#define	CMDGETBAUDRATE		27
#define	CMDPARSECONNECT		28
#define	CMDSETDEFAULT		29
#define	CMDCONVERTTOPC		30
#define	CMDCONVERTTOAMIGA	31
#define	CMDFREECONVERT		32
#define	CMDOBTAINNET		33
/* new from v4 */
#define	CMDWAITTEXT		34
#define	CMDCONVERSETEXT		35
#define	CMDCAPTURETEXTSTART	36
#define	CMDCAPTURETEXTEND	37
#define	CMDSETPARITY		38
#define	CMDSETHANDSHAKE		39
#define	CMDSETSTOPBITS		40
#define	CMDSETBITWIDTH		41
#define	CMDGETPARITY		42
#define	CMDGETHANDSHAKE		43
#define	CMDGETSTOPBITS		44
#define	CMDGETBITWIDTH		45

    typedef struct {

	CHAR	DNU_FILENAME[108];		/* name of file without path */
	ULONG	DNU_FILESIZE;			/* size of file in bytes */
	ULONG	DNU_RATE;			/* transfer rate bytes/s */
	STRUCT	DNU_EXPECTED,ds_SIZEOF;		/* expected time on transfer */
	STRUCT	DNU_USED,ds_SIZEOF;		/* time used on transfer */
	UWORD	DNU_STATUS;			/* status flags */
	LONG	DNU_HOOK;			/* hook to be called after each */
						/* block transfer */
    } DNUPDATE;

#define	DNUSTATUS_OK		$0		/* everything is ok */
#define	DNUSTATUS_ERROR		$1		/* transfer had an error */
#define	DNUSTATUS_RESENDING	$2		/* resending block/file */
#define	DNUSTATUS_WAITING	$4		/* waiting to receive/send file */
#define	DNUSTATUS_ABORT		$8		/* was aborted */
						/* (if you set this flag the */
						/* protocol will be aborted) */
#define	DNUSTATUS_END		$10		/* end of file (done) */

/*
To let user abort a protocol transfer you need to create a subtask that will
check for user input such as keypress/mousebutton/gadget etc. If user want to
abort transfer you must set the _abort flag. The other end of the protocol
will read  this as user abort and end. If not this flag can be interacted the
protocol will not stop until the whole file is transfered/resent error free.
*/

/* CaptureTextStart modes: */

#define	DNCAPTURENEW		0
#define	DNCAPTUREAPPEND		-1

/* Modes for SetParity */

#define	DNPARITYNONE		0
#define	DNPARITYEVEN		1
#define	DNPARITYODD		2
#define	DNPARITYMARK		3
#define	DNPARITYSPACE		4

/* Modes for SetHandshake */

#define	DNHANDSHAKENONE		0
#define	DNHANDSHAKE7WIRE	1		/* RTS/CTS  */
#define	DNHANDSHAKEX		2		/* XON/XOFF */

#endif /* DIGNET_H */
