#ifndef RECCOON_MSGBASE_H
#define RECCOON_MSGBASE_H TRUE
/*
**  $Filename: Reccoon/Msgbase.h $
**  $Release: 0.58 $
**  $Revision: 58.1 $
**  $Date: 94/02/21 $
**
**  Reccoon message base structures.
**
**  (C) Copyright 1991-94 Niclas Emdelius.
**          All Rights Reserved
*/ 

#ifndef RECCOON_RECCOON_H
#include <Reccoon/Reccoon2.h>
#endif

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

struct msgflags
{
	unsigned int private 	:1;	// Private as default?
	unsigned int privatereq :1;	// Private request?
	unsigned int anonym 	:1;	// Allow anonymous letters (future)
	unsigned int reply	:1;	// Allow replies
	unsigned int write	:1;	// Allow users to write in area (soon obsolete)
	unsigned int read	:1;	// Allow users to read in area  (soon obsolete)
	unsigned int netmail	:1;	// This is a Netmail area
	unsigned int echomail	:1;	// This is a EchoMail area
	unsigned int handle	:1;	// Use handle as default?
	unsigned int handlereq  :1;	// Handle Request?
	unsigned int linked	:1;	// Messages linked
	unsigned int unused	:21;
};

/* One MsgAccess structure per user and message-area. */

/* Simple access-demo: (I hope your C-compiler doesn't mind the comments)

BOOL ShowMsgAccess( ULONG area, UWORD usernum )
{
struct UsrList * ul;
struct MsgList * ml;

	ml = GetMsgArea(area);	// Get pointer to msgarea
	if(!ml) return(0);	// Nu such area

	ul = GetUser(usernum);	// Load user
	if(!ul) return(0);	// User not found

	printf("Access for %s in area %s:\n\n", ul->usr.username, ml->msgarea.msgareaname);

	if(ul->msgaccess[ml->msgarea.order].read)	puts("Read");
	if(ul->msgaccess[ml->msgarea.order].write)	puts("Write");
	if(ul->msgaccess[ml->msgarea.order].readprivate)puts("Read Private");

	...etc...

	FreeUser(ul->usernum);	// Free user from memory

	return(1);
}

*/

struct MsgAccess
{
	unsigned int read	:1;	// Read messages
	unsigned int write	:1;	// Write messages
	unsigned int readprivate :1;	// Read private
	unsigned int visible	:1;	// Visible in AreaList
	unsigned int delete	:1;	// Delete any message (future)
	unsigned int deleteown	:1;	// Delete own messages (future)
	unsigned int edit	:1;	// Edit any message (future)
	unsigned int editown	:1;	// Edit own messages (future)
	unsigned int masked	:1;	// Masked in in globalread (future)
	unsigned int sysop	:1;	// Message sysopmenu
	unsigned int ownsysop   :1;	// Message sysopmenu for own Msgs
	unsigned int fattach	:1;	// File attach
	unsigned int direct	:1;	// Direct NetMails
	unsigned int crash	:1;	// Crash NetMails
	unsigned int locked	:1;	// This MsgAccess-structure should not be transposed.
	unsigned int unused	:17;
};

//*** Check out the MsgList structure in Reccoon/Shared.h if you
//*** want to know how to access messagearea-configuration. 

struct MsgArea
{

	UBYTE		msgareaname[30];	// Name of message area
	UBYTE		tagname[20];		// FidoNet tagname
	UWORD		msgmenu;		// Menupage (future)
	ULONG		msglow;			// Lowest msg
	ULONG		water;			// Last mailproced
	UWORD		nrofmessages;		// Nr of messages in this area
	UWORD		maxmessages;		// Maximum nr of messages
	UWORD		lowzone;		// Lowest allowed Zone number
	UWORD		highzone;		// Highest allowed Zone number
	UWORD		fido_aka;		// AKA to use
	UWORD		minaccess;		// Minimum accesslevel
	UWORD		sig;			// Message SIG
	UWORD		filarea;		// Attached filearea (future)
	UWORD		minage;			// How old an user have to be
	ULONG		order;			// Structure number in MsgAccess, Lastread etc.
	struct msgflags msgflags;		// Flags
};

/*** The MsgBaseX.INX file ***/

struct msg
{

	ULONG 		number;		// Place in MsgBaseX.INX (structure number)
	UBYTE 		to[22];		// To
	UBYTE 		from[22];	// From
	UBYTE 		subject[80];	// Subject
	ULONG 		txtpos;		// Where in MsgBaseX.MSG (byte)
	UWORD 		msglength;	// Length of message  (bytes)
	UWORD 		readby;		// Read count
	struct TimeDate date;		// Date and clock
	UWORD 		acclevel;	// Acc. required to read msg
	UWORD 		replies[15];	// Replies (should I extend it?)
	UWORD 		original;	// Original Message

	UWORD 		destzone;	// To Zone	(netmail only)
	UWORD 		destnet;	// To Net
	UWORD 		destnode;	// To Node
	UWORD 		destpoint;	// To Point
	UWORD 		origzone;	// From Zone
	UWORD 		orignet;	// From Net
	UWORD 		orignode;	// From Node
	UWORD 		origpoint;	// From Point

	unsigned int 	deleted    :1;	// Deleted?
	unsigned int 	recieved   :1;	// Recieved?
	unsigned int 	private    :1;	// Private message?
	unsigned int 	fattach    :1;	// Is there an attached file? (future)
	unsigned int 	forwarded  :1;	// Is message forwarded? (future)
	unsigned int 	mailproced :1;	// Mailproced?
	unsigned int 	direct 	   :1;	// Direct NetMail (future)
	unsigned int 	crash  	   :1;	// Crash this netmail (future)
	unsigned int	to_all	   :1;	// Send to ALL users?
	unsigned int 	unusedbits :23;	// Unused bits
};

/*** The waiting-mail structure. ***/

struct wmail
{
		ULONG	msgarea;
		UWORD	msgnum;
		UBYTE	unused[4];
};

//** This structure is not used anywhere but in Recclib's CreateMsg().
//** I have not made any Origin-string editor or something simular, and
//** I haven't tested this at all, but it SHOULD work to define an
//** originstring for each messagearea. However, in the future I'll remove
//** this crap, and store the origin-strings in some better way.

struct origin
{
	ULONG	msgarea;	// This origin belongs to area #
	UBYTE 	origin[80];	// *Origin: string (zone:net/node.point)
};


#endif
