/* Structures and command IDs collected from TechPrg.guide */

struct BBSMsg {
    struct Message Msg; /* An exec message */
    int SendingNode;    /* The number of the node sending the message or
                           -1 if sent by a utility */
    UWORD ID;           /* The ID number of the command this message is
                           supposed to cause TechCon to perform */
    void *result;       /* The result field pointing to whatever result
                           data is returned by the call (if any) */
    int Ret;            /* Used by some calls for all kinds of stuff
                           (used to be a result field) */
    void *data;         /* Additional data for the command, whenever the
                           command requires any */
};

#define ID_BEGINMSGH    11
#define ID_ENDMSGH      12
#define ID_LOADMSG      13
#define ID_SAVEMSG      14
#define ID_UPDATEMSG    15
#define ID_GETMSGAREA   16
#define ID_GETFILEROOT  17
#define ID_UPDATEFILES  18
#define ID_LOADUSER     19
#define ID_SAVEUSER     20
#define ID_GETUSERPATH  21
#define ID_KILLUSER     22
#define ID_GETINDEX     23
#define ID_GETUSERNUM   26
#define ID_FREEDVEC     27
#define ID_INCOPENCOUNT 28
#define ID_DECOPENCOUNT 29
#define ID_GETNUMAREAS  30
#define ID_GETNUMNODES  31
#define ID_GETUSERNAME  37
#define ID_GETSIGS      43
#define ID_SETLOWMSG    44
#define ID_DELMSGFILE   45

struct SigDat {         /* SIG configuration structure */
    struct MinNode Node;
    int SigNum;
    char *Name;
    int MinAcc;
    int Mask;
    struct MinList Areas; /* List of nodes with ln_Name fields pointing to
                             a struct AreaCfg */
};

struct FAreaCfg {       /* File area configuration structure */
    UBYTE *Name;
    int MinAcc;
    int UpAcc;
    int DownAcc;
    int Mask;
    int UpMask;
    int DownMask;
    struct MinList *FreeDL;     /* List of nodes with ln_Name fields
                                   pointing to a parsed pattern */
    struct MinList *NoUpload;   /* List of nodes with ln_Name fields
                                   pointing to a parsed pattern */
    UBYTE *Redirect;
};

struct FidoNode {       /* FidoNet address structure */
    struct Node nd;
    int Zone;
    int Net;
    int Node;
    int Point;
};

struct AreaCfg {        /* Message area configuration */
    int AreaNr;
    UBYTE *Name;
    int Type;
    ULONG LowMsg;
    ULONG HiMsg;
    int MsgFile;
    int MinAcc;
    int ReadAcc;
    int WriteAcc;
    int RPAcc;
    int Mask;
    int ReadMask;
    int WriteMask;
    int RPMask;
    UBYTE *EchoTag;
    UBYTE *Origin;
    ULONG HiWater;
    int NoImport;
    struct MinList *ExportTo;   /* List of struct FidoNodes */
    struct MinList *Misc;       /* List of nodes w/ ln_Name pointing to a
                                   string */
    struct FidoNode *AKA;
    int nmdt;   /* PRIVATE - don't touch */
    BPTR mdt;   /* PRIVATE - don't touch */
    BPTR idx;   /* PRIVATE - don't touch */
    int mod;   /* Set this if you change anything during a message handling
                  session */
};

struct LoadedMsg {      /* This is what LoadMsg() returns (for some reason) */
    struct FMsg *msg;
    ULONG Length;
};

struct MsgReq {         /* Used for lots of stuff */
    int Area;
    ULONG MsgNum;
    struct FMsg *bmsg;
    ULONG MsgLen;
    UBYTE *MText;
    UBYTE *ToUser;
};

struct MsgId {          /* A binary parsed version of a MSGID: or REPLY:
                           field */
    UWORD Zone;
    UWORD Net;
    UWORD Node;
    UWORD Point;
    ULONG ID;
};

struct IndexEntry {     /* Message index */
    ULONG MsgNum;
    UWORD FileNum;
    UWORD OffSet;
    ULONG MsgLen;
    struct MsgId MSGID;
    struct MsgId REPLY;
};

#define MSG_PRIVATE     0x0001
#define MSG_LOCAL       0x0002 /* Stupid, I don't remember what this is for
                                  (ignore it) */
#define MSG_RECEIVED    0x0004
#define MSG_SENT        0x0008 /* Has been sent (FidoNet) */
#define MSG_FILEATT     0x0010 /* Has a file attached */
#define MSG_KILLSENT    0x0020 /* On local, kill on receive (not useful) */
#define MSG_DEAD        0x0040 /* A dead message - Loading will fail */

struct MemMsg {         /* Recommended format for message storage in memory */
    ULONG MsgNum;
    ULONG Original;
    ULONG FirstReply;
    ULONG PrevReply;
    ULONG NextReply;
    UWORD Bits;
    UWORD OrigZone;
    UWORD OrigNet;
    UWORD OrigNode;
    UWORD OrigPoint;
    UWORD DestZone;
    UWORD DestNet;
    UWORD DestNode;
    UWORD DestPoint;
    UBYTE DateTime[20];
    UBYTE *AttFile;
    UBYTE *FromUser;
    UBYTE *ToUser;
    UBYTE *Subject;
    UBYTE *MsgText;
};

struct FMsg {           /* Message format as found in .MDT files */
    ULONG MsgNum;
    ULONG Original;
    ULONG FirstReply;
    ULONG PrevReply;
    ULONG NextReply;
    UWORD Bits;
    UWORD OrigZone;
    UWORD OrigNet;
    UWORD OrigNode;
    UWORD OrigPoint;
    UWORD DestZone;
    UWORD DestNet;
    UWORD DestNode;
    UWORD DestPoint;
    UBYTE DateTime[20];
        /* Null terminated attached file name (full, w/path) */
        /* Null terminated from */
        /* Null terminated to */
        /* Null terminated subject */
        /* Null terminated message text */
};

struct FileNode {       /* File structure */
    struct Node Node;
    UBYTE *Name;
    UBYTE *Comment;
    ULONG Size;
    ULONG Prot;
    ULONG Days;
    ULONG Mins;
    ULONG Ticks;
    UBYTE *Uploader;
    UWORD LongDesc;
    UBYTE **DescLines;
    UWORD Number;
    unsigned Free : 1;
};

struct DirNode {        /* Directory structure */
    struct Node Node;
    UBYTE *DirName;
    struct MinList *flist; /* List of struct FileNodes */
    struct MinList *dlist; /* List of struct DirNodes */
    struct DirNode *Parent; /* This node can be found in Parent->dlist */
    struct FAreaCfg *fc;
    unsigned HasExt : 1;
};

struct UserVal {        /* This is actually in the file like this */
    UWORD Lines;
    WORD Access;
    LONG BytesLeft;
    LONG FilesLeft;
    ULONG BytesDown;
    ULONG FilesDown;
    ULONG BytesUp;
    ULONG FilesUp;
    UWORD ByteRatio;
    UWORD FileRatio;
    ULONG Messages;
    WORD TimeDay;
    WORD TimeCall;
    WORD TimeLeft;
    WORD CallsDay;
    WORD CallsLeft;
    WORD TimeBank;
    WORD MaxTimeBank;
    ULONG AvgCps;
    ULONG AvgCpsMul;
    ULONG Mask;
    ULONG TotalCalls;
    ULONG LastCall;
    unsigned StripCols : 1;
    unsigned SlowTerm : 1;
    unsigned SimpleTerm : 1;
    unsigned StripAll : 1;
};

struct BBSUser {        /* User structure */
    UBYTE *Name;
    UBYTE *Password;
    UBYTE *CharSet;
    UBYTE *Extension;
    UBYTE *Locale;      /* Used to be a locale, now a string file
                           (determines language, anyhow) */
    UBYTE *Protocol;
    ULONG *HighRead;    /* Array of highread pointers */
    UBYTE *AMode;       /* Array of 'S' or 'N' */
    struct MinList Misc; /* A list of nodes with ln_Name ptr to string
                            containing misc definition for user */
    int Number;
    struct UserVal val;
};
