#ifndef RECCOON_FILEBASE_H
#define RECCOON_FILEBASE_H TRUE
/*
**  $Filename: Reccoon/Filebase.h $
**  $Release: 0.59 $
**  $Revision: 59.1 $
**  $Date: 94/09/12 $
**
**  Reccoon filebase 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


/* File-access flags. One structure per user and filearea. */

struct FileAccess
{
    unsigned int upload :1; // Upload files
    unsigned int download   :1; // Download files
    unsigned int free   :1; // Free download
    unsigned int visible    :1; // Visible in arealist
    unsigned int masked :1; // Masked in in globalsearch
    unsigned int sysop  :1; // Validate, remove credits etc. when editing
    unsigned int edit   :1; // Edit any file
    unsigned int editown    :1; // Edit own uploads
    unsigned int validate   :1; // Auto validate files
    unsigned int listunval  :1; // List unvalidated files
    unsigned int view   :1; // View/Test archive?
    unsigned int locked :1; // This FileAccess-structure should not be transposed
    unsigned int unused :20;
};

/* One set of flags for each filearea. */

struct FileAreaFlags
{
    unsigned int    freqable    :1; // Allow Filerequests? (unused)
    unsigned int    filecomment :1; // Put description as a filecomment?
    unsigned int    noselectarea    :1; // Don't let user select upload area (future)
    unsigned int    msdos       :1; // MS-DOS filenames
    unsigned int    fileecho    :1; // FileEcho area
    unsigned int    added       :1; // Files have been added since last export
    unsigned int    unusedbits  :10;    // unused
    unsigned int    unusedbits2 :16;    // unused
};

/* Filearea information. Use GetFileArea or check out the ctrl->fileareas */
/* list if you want to access the fileareas. */

struct FileArea
{
    UBYTE       filpath[PATHSIZE];  // Path to files
    UBYTE       filname[30];        // Name of filearea
    UWORD       filmenupage;        // Menupage for filearea
    UWORD       filesysop;      // Sysop of this area (obsolete)
    UWORD       aka;            // AKA to use in file-echo
    UWORD       minaccess;      // Minimum accesslevel
    UWORD       msgarea;        // Attached MsgArea (future)            */
    UWORD       sig;            // Filearea SIG

    struct FileAreaFlags flags;     // Flags

    ULONG       order;          // Structure number in FileAccess etc.
    UWORD       mindlbaud;      // Minimum download baudrate
    UWORD       minulbaud;      // Minimum upload baudrate
    UWORD       minage;         // How old an user have to be
    ULONG       minul;          // Minimum upload-space before UL (in kb)
    UBYTE       tagname[20];        // Tagname
};

/* Fileheaders in FileBaseX.DAT */

struct oldfil       // No longer in use, will dissappear soon
{
    UBYTE           filename[32];   // Name of file
    ULONG           size;       // File length
    UBYTE           uploader[36];   // Uploader name
    struct  TimeDate    date;       // Date and clock
    struct  TimeDate    lastdl;     // Last downloaded (future)
    UWORD           dloads;     // Nr of downloads (future)
    UBYTE           desc1[80];  // Description 1
    UBYTE           desc2[80];  // Description 2
    UWORD           minaccess;  // Minimum access level

    unsigned int        unvalidated :1; // Unvalidated?
    unsigned int        free    :1; // Free download?
    unsigned int        proced  :1; // Processed with ReccProc?
    unsigned int        offline :1; // File not on HD? (unused)
    unsigned int        unused  :28;
};

struct fil                          // This structure is put together within rcn
{
    UBYTE           filename[32];   // Name of file
    struct  TimeDate    date;       // Date and clock
    ULONG           size;           // File length
    UBYTE           uploader[36];   // Uploader name
    struct  TimeDate    lastdl;     // Last downloaded
    UWORD           dloads;         // Nr of downloads
    UWORD           minaccess;      // Minimum access level
    unsigned int        unvalidated :1; // Unvalidated?
    unsigned int        free    :1; // Free download?
    unsigned int        proced  :1; // Processed with ReccProc?
    unsigned int        offline :1; // File not on HD? (unused)
    unsigned int        unused  :28;
    UBYTE           *desc;          // The COMPLETE description (NO LIMIT!!! =))
};

struct filinx                       // The format of the .INX file
{
    UBYTE           filename[32];   // Name of file
    struct  TimeDate    date;       // Date and clock
    ULONG   pos;                    // Position in FileBasex.DAT
    ULONG   len;                    // Length of description
};

struct filstore                     // The way the fileinfo is stored in the .DAT file
{
    ULONG           size;           // File length
    UBYTE           uploader[36];   // Uploader name
    struct  TimeDate    lastdl;     // Last downloaded
    UWORD           dloads;         // Nr of downloads
    UWORD           minaccess;      // Minimum access level

    unsigned int        unvalidated :1; // Unvalidated?
    unsigned int        free    :1; // Free download?
    unsigned int        proced  :1; // Processed with ReccProc?
    unsigned int        offline :1; // File not on HD? (unused)
    unsigned int        unused  :28;
};

/* Note! After the above structure, the description lies as PURE text */

/* Marked files for Download, View and/or Edit */

struct MarkedFile
{
    struct RNode    node;           // A double linked list
    ULONG       area;           // Filearea
    ULONG       filenr;         // Structure number in FileBaseX.INX
    UBYTE       filename[PATHSIZE+32];  // Complete filename. Must be used.
    ULONG       size;           // Filesize
    struct fil  fil;            // Copy of file's fil structure
    unsigned int    free     :1;        // Free download?
    unsigned int    sent     :1;        // File sent?
    unsigned int    unlisted :1;        // File not listed in filearea (future)
    unsigned int    unused   :29;
};

#endif
