/*
 *  CELLS       An Implementation of the WireWorld cellular automata
 *              as described in Scientific American, Jan 1990.
 *
 *              Copyright 1990 by Davide P. Cervone.
 *  You may use this code, provided this copyright notice is kept intact.
 *  See the CELLS.HELP file for complete information on distribution conditions.
 */

/*
 *  File:  cDos.h       Header for AmigaDOS stuff
 */


#include <libraries/dos.h>
#include <libraries/dosextens.h>

/*
 *  Some defines that make dealing with DOS structires easier
 */

#define BCPL_TO_C(s,x)      ((struct s *)(BADDR((ULONG)x)))
#define BCPL_TO_CHAR(x)     ((char *)(BADDR((ULONG)x)))
#define BCPL_TO_SIZE(x)     ((int)(*(BCPL_TO_CHAR(x))))
#define ROOTNODE(x)         ((struct RootNode *)x)
#define DOSINFO(x)          BCPL_TO_C(DosInfo,x)
#define FILELOCK(x)         BCPL_TO_C(FileLock,x)
#define DEVLIST(x)          BCPL_TO_C(DeviceList,x)
#define CLI(x)              BCPL_TO_C(CommandLineInterface,(x->pr_CLI))
#define FIRSTDEV\
   DEVLIST(DOSINFO(ROOTNODE(DOSBase->dl_Root)->rn_Info)->di_DevInfo)


/*
 *  Sets the current directory to the specified lock
 */

#define SETCURDIR(l)        UnLock(CurrentDir(l))


/*
 *  Returns a NULL if directory name is blank
 */

#define RETURN(dir)         return((*dir == 0)? NULL: dir)


/*
 *  What type of file are we looking for?
 */

#define TYPE_DIR    0
#define TYPE_FILE   1


/*
 *  Force a directory name lookup in NewDirectory?
 */
#define LOOKUPDIR   1
#define NOLOOKUP    0


/*
 *  Error return codes for NextDrive()
 */

#define NOERROR     0
#define NOVOLMOUNT  -1
#define NOVOLOTHER  -2


/*
 *  Linked list of files displayed by the File Requester (when directory
 *  scanning is activated).
 */

struct FileInfo
{
   struct FileInfo *Next,*Prev;
   char *Name;
   UWORD NameLen;
   UWORD Flags;
      #define FI_DIRECTORY      BIT(8)
};

typedef struct FileInfo         *FILEINFO;
typedef struct FileLock         *LOCK;
typedef struct FileInfoBlock    *FIB;
typedef struct InfoData         *INFODATA;

extern struct DosLibrary *DOSBase;
extern LOCK Lock(), DupLock(), ParentDir(), CurrentDir(), CreateDir();
extern struct Process *FindTask();
extern int IoErr();

extern UWORD Mounted;           /* Flags for currently mounted floppies */
