/* EPIPE.h ------ EnhancedPIPE V1.0 ŽSSi\97 ------------------ (P) 13-9-97 ----- */

#ifndef USER_EPIPE_H
#define USER_EPIPE_H

#include <exec/types.h>


/*
 * The following structure can be read in from the '<pipename>.bininfo' filehandle.
 *
 * ATTENTION: The max. number of bytes read in is the length you specify at
 *            the Read() command. Be sure, that it is big enough to hold the
 *            whole struct.
 *            Sure is to first read in 4 bytes (the ULONG length), and then again
 *            read in as many bytes as length is.
 */

#define EPIPE_BININFO_LENGTH (sizeof(struct EPIPE_bininfo))

struct EPIPE_bininfo
{
	ULONG length;       /* total length of the structure */
	
	ULONG flags;        /* BIF_... (see later) */
	LONG	readrequest;  /* total length of the current readrequest */
	LONG  readactual;   /* number of bytes read by the request by now */
	LONG	writerequest; /* total length of the current writerequest */
	LONG  writeactual;  /* number of bytes written into the request by now */
	BYTE	signalnum;		/* signalnum des TriggerFH oder -1 */
};

#define BIF_READFH    (1<<0) /* Pipe has a readfilehandle opened currently */
#define BIF_WRITEFH   (1<<1) /* Pipe has a writefilehandle opened currenty */
#define BIF_TRIGGERFH (1<<2) /* Pipe has a triggerfilehandle opened currently */
#define BIF_FORCEFH   (1<<3) /* Pipe has a forcefilehandle opened currently */


/*
 * If you read in from the '<pipename>.info' filehandle, then be sure that your read buffer
 * is at least as big as:
 */

#define EPIPE_INFOSTR_LENGTH (32)

/* You will get a newline and null terminated string that will contain...
 *
 * a 'R' if a readfilehandle is currently opened, followed by the total length and the number
 *       of bytes already read in decimal format
 *
 * a 'W' if a writefilehandle is currently opened, followed by the total length and the number
 *       of bytes already written in decimal format
 *
 * a 'T' if a triggerfilehandle is currenty opened.
 *
 * a 'F' if a forcefilehandle is currenty opened.
 *
 * Example:
 *
 *    "R377,10 T\n"
 *
 * This means that the pipe has currently an read request that wants to read 377 bytes,
 * 10 bytes are already transferred to it, and there is an open triggerfilehandle.
 *
 *
 * ATTENTION: The '<pipename>.info' filehandle can ONLY BE READ >ONCE<, then you have to reopen it.
 */

#endif /* USER_EPIPE_H */
