/* unixlib.h: */

/* UNIX-like tools for the Commodore Amiga;
   by F Munkert;
   1993
*/

#include <time.h>

typedef unsigned long ino_t;
typedef unsigned long dev_t;

/* getopt.c: */

extern char *optarg;
extern int optind;

extern int getopt (int, char **, char *);



/* stat.h: */

struct	stat {	
  int       st_dev;
  int       st_ino;
  int       st_mode;
  int       st_nlink;
  int       st_uid;
  int       st_gid;
  int       st_rdev;
  int	    st_size;
  time_t    st_atime;
  time_t    st_mtime;
  time_t    st_ctime;
};

#define R_OK 4
#define W_OK 2
#define X_OK 1
#define F_OK 0

#define S_ISFIFO(mode)	0
#define S_ISLNK(mode)	0
#define S_ISSOCK(mode)	0
#define S_ISCHR(mode)	0
#define S_ISDIR(mode)	((mode&0xF000) == 0x4000)
#define S_ISBLK(mode)	0
#define S_ISREG(mode)	((mode&0xF000) == 0x8000) 

#ifdef LATTICE
#undef S_IFREG
#undef S_IFDIR
#undef S_IFMT
#endif

#define	S_IFREG		0x8000	/* regular */
#define	S_IFDIR		0x4000	/* directory */

#define S_IFMT		0x7000  /* mask for S_IFREG and S_IFDIR */

#define	S_IRWXU	00700		/* read, write, execute: owner */
#define	S_IRUSR	00400		/* read permission: owner */
#define	S_IWUSR	00200		/* write permission: owner */
#define	S_IXUSR	00100		/* execute permission: owner */
#define	S_IRWXG	00070		/* read, write, execute: group */
#define	S_IRGRP	00040		/* read permission: group */
#define	S_IWGRP	00020		/* write permission: group */
#define	S_IXGRP	00010		/* execute permission: group */
#define	S_IRWXO	00007		/* read, write, execute: other */
#define	S_IROTH	00004		/* read permission: other */
#define	S_IWOTH	00002		/* write permission: other */
#define	S_IXOTH	00001		/* execute permission: other */

int stat (const char *p_name, struct stat *p_stat);
int lstat (const char *p_name, struct stat *p_stat);

#ifdef LATTICE
int access (const char *, int);
#else
int access (char *, int);
#endif

/* misc.c: */

int chmod (const char *p_pathname, int p_mode);

/* readdir.c: */

typedef struct dirent {
  unsigned short  d_reclen;
  char            d_name[31];
} dirent_t;

typedef struct DIR {
  char		  *lock;
  char		  *fib;
  short		  dir_index;
  int		  phase;
  dirent_t	  dirent;
} DIR;

DIR *opendir (const char *p_pathname);
struct dirent *readdir (DIR *p_dir_ptr);
int closedir (DIR *p_dir_ptr);

#ifndef LATTICE
#define ENOTDIR EINVAL
#endif

/* filename.c: */

void remove_dot_files (char *);
