/*
**  Glue functions for the RCS system needed for the Amiga
*/

#include <stdio.h>
#include <errno.h>
#include <proto/exec.h>
#include <exec/tasks.h>
#include <ios1.h>
#include <dos.h>
#include <fcntl.h>
#include <exec/exec.h>
#include <libraries/dosextens.h>
#include "stat.h"
#include <stdarg.h>



umask(mode)
{
	return mode;
}

/*
** This function is used in place of the lattice library function of
** the same name.  It handles all modes, not just "rwed".
*/
chmod(name,mode)
char	*name;
int	mode;
{
	long	amigamode;
	int	success;

	amigamode = mode;
	success = SetProtection(name,amigamode);
	if (success)
		return(0);
	errno = ENOENT;
	return(-1);
}

int stat(name,buf)
char	*name;
struct stat *buf;
{
	long l;
	struct FileInfoBlock *fp,*malloc();

	if ((l=Lock(name, ACCESS_READ)) == 0)
		return(-1);
	fp = malloc(sizeof(struct FileInfoBlock));
	Examine(l, fp);
	buf->st_attr = fp->fib_Protection;
	buf->st_size = fp->fib_Size;
	buf->st_type = fp->fib_DirEntryType;
	UnLock(l);
	free(fp);
	buf->st_mtime = getft(name);
	return 0;
}

isatty(fd)
int		fd;
{
	long IsInteractive();
	struct UFB	*ufb;

	ufb = chkufb(fd);
	if (ufb == NULL)
		return(-1);
	return(IsInteractive(ufb->ufbfh) != 0);
}
