#include <ak/filesystem.h>

#define I_ROOT		0
#define I_DIR		1
#define I_FIL		2
#define I_EXT		3
#define I_DAT		4
#define I_UNK		5
#define I_UNREADABLE	6
#define I_S_LNK 	7
#define I_H_LNK_DIR	8
#define I_H_LNK_FIL	9

Static	struct	Root
{	ulong	*blocks;
	ulong	*bblocks;
};
Static	struct	Dir
{	ulong	parent; 	/* WARNING!!! parent must be first */
	ulong	*blocks;
	ulong	chain;
	ulong	next;
};
Static	struct	Fil
{	ulong	parent; 	/* WARNING!!! parent must be first */
	ulong	num;
	ulong	*blocks;
	ulong	bytesize;
	ulong	chain;
	ulong	extension;
	ulong	next;
};
Static	struct	Ext
{	ulong	parent; 	/* WARNING!!! parent must be first */
	ulong	num;
	ulong	*blocks;
	ulong	extension;
};
Static	struct	Dat
{	ulong	key;
	ulong	seqnum;
	ulong	size;
	ulong	nextd;
};
Static	struct	Lnk
{	ulong	parent; 	/* WARNING!!! parent must be first */
	ulong	chain;
};
Static	struct	DirLnk
{	ulong	parent; 	/* WARNING!!! parent must be first */
	ulong	prev;
	ulong	next;
	ulong	chain;
};
Static	struct	FilLnk
{	ulong	parent; 	/* WARNING!!! parent must be first */
	ulong	prev;
	ulong	next;
	ulong	chain;
};
Static	struct	Info
{	union
	{	struct	Root	*root;
		struct	Dir	*dir;
		struct	Fil	*fil;
		struct	Ext	*ext;
		struct	Dat	*dat;
		struct	Lnk	*lnk;
		struct	DirLnk	*dirlnk;
		struct	FilLnk	*fillnk;
		LONG	ret;	/* I_UNREADABLE */
	} Obj;
	ushort	type;
	ushort	flags;
}	*InfoList;

/* Bits for  flags  in Info structure */
#define E_CHKSUM	(1 << 0)
#define E_SHORT 	(1 << 1)
#define E_COUNT 	(1 << 2)
#define E_FIRST 	(1 << 3)
#define E_KEY		(1 << 4)
#define E_BMFLG 	(1 << 5)
#define E_HTSIZ 	(1 << 6)
#define E_BADNAME	(1 << 7)
#define E_OFSLINK	(1 << 9)
#define E_PREVLINK	(1 << 10)
#define E_NEXTLINK	(1 << 11)
#define I_USED		(1 << 15)

Static	struct	Names
{	struct	Names	*prev;
	struct	Names	*next;
	ulong	block;
	char	name[BLOCKFILENAMELENGTH+1];
};
