/* odin.h */
/* headerfile for odin.library. V1.11 13-jun-90 */

#ifndef ODIN_H
#define ODIN_H 1

#ifndef EXEC_NODES_H
#include "exec/nodes.h"
#endif
#ifndef EXEC_LISTS_H
#include "exec/lists.h"
#endif
#ifndef EXEC_SEMAPHORES_H
#include "exec/semaphores.h"
#endif
#ifndef EXEC_LIBRARIES_H
#include "exec/libraries.h"
#endif
#ifndef EXEC_TASKS_H
#include "exec/tasks.h"
#endif
#ifndef LIBRARIES_DOSEXTENS_H
#include "libraries/dosextens.h"
#endif

#define ODINNAME "odin.library"

struct OdinBase {
	struct Library		odin_LibNode;
	BPTR			odin_SegList;
	UBYTE			odin_Flags;
	/* You MUST ObtainSemaphore() this before using 
	 * the WaitList!
	 */ 
	struct SignalSemaphore	odin_Sem;	/* signal semaphore */
	struct MinList		odin_WaitList;
};

#define odin_Sizeof sizeof(struct OdinBase)

/* prefix for envelopes */

typedef struct _Env {
	struct MinNode	e_link;		/* first a link for use in e-space */
	STRPTR		e_name;		/* the name of this envelope */
	ULONG		e_len;		/* bytelength of whole envelope */
	struct _Env *	(*e_copyfunc)();/* opt. C-function for copying */
	struct _Env *	(*e_proc)();	/* C-func. to call in Eval() */
} Envelope;

#define e_sizeof (ULONG)sizeof(Envelope)

/* wait-structure used in WaitList. Used internally */

struct WaitStruct {
	struct MinNode	ow_link;
	Envelope	*ow_envelope;
	struct Task	*ow_waittask;
	UBYTE		ow_sigbit;
	BYTE		ow_type;
};

#define ow_sizeof (ULONG)sizeof(struct WaitStruct)

/* ow_types */

#define RD_REQUEST 0
#define IN_REQUEST 1

/* the et parameter to Eval() */

#define EVAL_PROCESS (long)0
#define EVAL_TASK    (long)1

#ifndef ANSI
/* function returntypes */
#define NoCopyFunc 0L
extern Envelope *In(),*Rd(),*Rdp(),*Inp();
extern void Out(),CopyOut();
extern struct Task *Eval();
extern struct Task *StartTask();
extern struct Process *StartProcess();
extern Envelope *AwaitNamedEnvelope();
extern Envelope *PollNamedEnvelope();
extern void OutEmptyEnvelope();
extern Envelope *CreateEnvelope(),*InitEnvelope();
extern void DisposeEnvelope();

#else
/* ANSI function-prototypes, worked with PDC 3.33 */
#define NoCopyFunc (Envelope *(*cf)())0L
extern Envelope *In(Envelope *);
extern Envelope *Rd(Envelope *);
extern Envelope *Rdp(Envelope *);
extern Envelope *Inp(Envelope *);
extern void Out(Envelope *);
extern CopyOut(Envelope *);
extern struct Task *Eval(Envelope *,long,ULONG,long);
extern struct Task *StartTask(void(),char *,long,long);
extern struct Process *StartProcess(void(),char *,long,long);
extern Envelope *AwaitNamedEnvelope(char *);
extern Envelope *PollNamedEnvelope(char *);
extern void OutEmptyEnvelope(char *);
extern Envelope *CreateEnvelope(char *,ULONG);
extern Envelope *InitEnvelope(Envelope *,char *,ULONG,Envelope *(*copyfunc)());
extern void DisposeEnvelope(Envelope *);
#endif /* ANSI */

#endif /* ODIN_H */
