/***************************************************************************
                             AREA.IDX Structures
 ***************************************************************************/


struct _aidx
{
  word  area;       /* Same format as area.areano */
  dword offset;
  dword name_crc;   /* Currently undefined, but reserved by Maximus.       *
                     * This will probably become a CRC-32 of the           *
                     * area.name string, below... but is currently not     *
                     * implemented.                                        */
};


/***************************************************************************
                             AREA.DAT Structures
 ***************************************************************************/

#ifdef NEVER

/*  NOTE:  The _area structure has a dynamic length!  To access this file, *
 *         you should read the first _area structure from the file, and    *
 *         check the struct_len byte.  Then, to access the file, you seek  *
 *         to each new location, instead of reading straight through.      *
 *                                                                         *
 *         For example, to read all of the _area file into an array, you   *
 *         MUST do it like this, for upward compatiblity:                  */

  {
    struct _area area[NUM_AREAS];

    int x,
        slen;

    if ((areafile=open(area_name,O_RDONLY | O_BINARY))==-1)
      Error();

    /* Read the first record of the file, to grab the structure-length     *
     * byte.                                                               */

    read(areafile,&area[0],sizeof(struct _area));
    slen=area[0].struct_len;

    for (x=0;! eof(area_data);x++)
    {
      /* Note this lseek() call, which positions the pointer to the        *
       * start of the next record, no matter how long the previous         *
       * record was.                                                       */

      lseek(areafile,x*(long)struct_len,SEEK_SET);
      read(areafile,&area[x],sizeof(struct _area));
    }

    close(areafile);
  }

#endif


struct _override
{
  int priv;   /* Override priv level */
  byte lock;  /* Override lock setting */

  byte ch;    /* First letter of menu option to apply override to */
};



#define AREA_id   0x54414441L /* "ADAT" */

struct _area
{
  long id;              /* Unique identifier for AREA.DAT structure.       *
                         * Should be AREA_id, above.                       */

  word struct_len;      /* Length of _area structure -- this needs only    *
                         * to be read from the first record in an area     *
                         * data file, since it can be assumed to remain    *
                         * the same throughout the entire file.  This is   *
                         * GUARANTEED to be at offset two for all future   *
                         * versions of this structure.                     */

  word areano;          /* This is the integer representation of this      *
                         * area's name, and will be obsoleted very         *
                         * shortly, even though the current version of     *
                         * Maximus uses this internally.  Use the 'name'   *
                         * element instead:  It is a standard string, and  *
                         * is what will be supported in future versions.   *
                         * One of the items on our "To Do" list is to      *
                         * completely go with area names.  This means that *
                         * we'll be using a string for an area "number",   *
                         * and it could theoretically be as long as could  *
                         * fit in the 'name' variable, as long as it is a  *
                         * single word.  ie. "BinkleyTerm" could be a      *
                         * valid area name!  By using the 'name' element   *
                         * as a straight ASCII string, you'll have         *
                         * automatic support for future versions of Max.   */

  byte name[40];        /* String format of area's name.  USE THIS!        */

  /*************************************************************************/
  /**                        Message Area Information                     **/
  /*************************************************************************/

  word area_type;       /* Message base type.  0x00 = *.MSG.  Others are   *
                         * currently undefined, and rsvd by Maximus.       */

  byte msgpath[80],     /* Path to messages                                */
       msgname[40],     /* The 'tag' of the area, for use in ECHOTOSS.LOG  */
       msginfo[80],     /* The DIR.BBS-like description for msg section    */
       msgbar[80],      /* Barricade file for message area                 */
       origin[62];      /* The ORIGIN line for this area                   */


  sword msgpriv;        /* This is the priv required to access the msg     *
                         * section of this area.                           */
  byte msglock;         /* The lock for the message area                   */

  byte fill1;

  sword origin_aka;     /* This is the AKA number to use on the origin     *
                         * line.  See the normal SysOp documentation on    *
                         * the "Origin" statement, for info on how this    *
                         * number is used.                                 */

  /*************************************************************************/
  /**                        File Area Information                        **/
  /*************************************************************************/


  byte filepath[80],    /* Path for downloads                              */
       uppath[80],      /* Path for uploads                                */
       filebar[80],     /* Barricade file for file areas                   */
       filesbbs[80],    /* Path to FILES.BBS-like catalog for this area    */
       fileinfo[80];    /* The DIR.BBS-like description for file section   */

  sword filepriv;       /* This is the priv required to access the file    *
                         * section of this area.                           */
  byte filelock;        /* The locks for the file area                     */
  byte fill2;

  /*************************************************************************/
  /**                      Miscellaneous Information                      **/
  /*************************************************************************/


  byte msgmenuname[13], /* Alternate *.MNU name to use for this msg.area   */
       filemenuname[13];/* Alternate *.MNU name to use for this file area  */

  word attrib[MAXCLASS];/* This is an array of attributes for the          *
                         * msg/file areas.  These are dependant on PRIV    *
                         * level.  Once you have the CLASS number for a    *
                         * particular user (via Find_Class_Number()), you  *
                         * can find the attributes for that particular     *
                         * priv level like this: "area.attrib[class]"      *
                         * ...which will get you the attribute for that    *
                         * priv level.                                     */

  /*************************************************************************/
  /**                      Stuff hacked on later                          **/
  /*************************************************************************/

  struct _override movr[MAX_OVR]; /* Override privs for msg/file areas */
  struct _override fovr[MAX_OVR];

};


/* Area attributes, for area.attrib[] (above) */

#define  SYSMAIL   0x0001 /* is a mail area                                */
#define  NOPUBLIC  0x0004 /* OPUS: Disallow public messages                */
#define  NOPRIVATE 0x0008 /* OPUS: Disallow private messages               */
#define  ANON_OK   0x0010 /* OPUS: Enable anonymous messages               */
#define  ECHOMAIL  0x0020 /* OPUS: Set=Echomail Clear=Not Echomail         */
#define  HIGHBIT   0x0040 /* MAX:  Allow high-bit chars in this area       */
#define  NREALNAME 0x0200 /* MAX:  Don't use ^aREALNAME for this area      */
#define  UREALNAME 0x0400 /* MAX:  Use usr.realname instead of usr.name    */

