#ifndef RECCOON_MSGBASE_H
#define RECCOON_MSGBASE_H TRUE
/*
**  $Filename: Reccoon/Msgbase.h $
**  $Release: 0.59 $
**  $Revision: 59.2 $
**  $Date: 94/11/27 $
**
**  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 dupecheck  :1; // Allow dupechecking?
    unsigned int link   :1; // Allow MSGID Linking?
    unsigned int email  :1; // EMail area (Future)
    unsigned int cross  :1; // Allow crossreply (Future)
    unsigned int unused :17;
};

/* 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       oldtagname[20];     // FidoNet tagname (obsolete)
    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
    UBYTE       tagname[60];        // FidoNet tagname (done this way to allow old prgs to work)
};

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

struct msg
{

    ULONG       number;     // Place in MsgBaseX.INX (structure number)
    UBYTE       to[36];     // To   (Filename incase of filedesc)
    UBYTE       from[36];   // From (Filesize incase of filedesc (as a string))
    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    filedesc   :1;  // This actually a filedescription
    unsigned int    unusedbits :22;  // 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 similar, 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)
};


/*
** Character translation-tables according to FSC-0054.004, for supporting
** the CHARSET and CHRS cludge in echomail messages.
*/

struct LookupTable
{
    ULONG   id;         // 0 if FTSC
    UWORD   version;        // Table version
    UWORD   level;          // What level of translation
    UBYTE   reserved[8];
    UBYTE   from[8];        // From chrset 
    UBYTE   to[8];          // To chrset
    UBYTE   table[128][2];      // The table, two bytes per chr.
};

/*
** Flag-field in RConfig:FSEds.CFG
*/

#define FSFLG_TYPEMASK 0x03     // Doortype-mask
#define FSFLG_RCNTYPE 0x00      // Reccoon-door
#define FSFLG_PARAGONTYPE 0x01      // Paragon-door
#define FSFLG_CLITYPE 0x02      // CLI-door
#define FSFLG_AREXXTYPE 0x03        // ARexx-script

#define FSFLG_QUOTEMASK 0x0c        // Quote-file-mask
#define FSFLG_NOQUOTE 0x00      // No quotefile created
#define FSFLG_PARAGONQUOTE 0x04     // Paragon-quote style
#define FSFLG_RESERVED1QUOTE 0x08 
#define FSFLG_RESERVED2QUOTE 0x0c

#define FSFLG_MSGMASK 0x30      // How-to-create-the-message-mask
#define FSFLG_NOMSG 0x00        // No message created
#define FSFLG_PARAGONMSG 0x10       // Paragon-style message created
#define FSFLG_RESERVED1MSG 0x20
#define FSFLG_RESERVED2MSG 0x30

#define FSFLG_HEADERMASK 0x40       // Header-type
#define FSFLG_NOHEADER 0x00     // No headerfile-created
#define FSFLG_FSEDHEADER 0x40       // Dave's headerfile created.

#define FSFLG_REQMASK 0x80      // Requirements
#define FSFLG_ANSIREQ 0x80      // Editor requires ANSI
#define FSFLG_NOREQ 0x00        // No requirements

#define FSFLG_RESERVEDMASK 0xff00   // Future

#endif
