/* Function to read entire file into a buffer. */
# include	<stdio.h>
# include	<sys/types.h>
# include	<sys/stat.h>
# include	<fcntl.h>

char	*
read_file(name)
char	*name;
{	char	*malloc();
	char	*cp;
	struct stat sbuf;
	int	fd;
	
	if (stat(name, &sbuf) < 0)
		return NULL;
	fd = open(name, O_RDONLY);
	if (fd < 0)
		return NULL;
	cp = malloc(sbuf.st_size + 1);
	if (cp == NULL)
		return NULL;
	read(fd, cp, sbuf.st_size);
	close(fd);
	cp[sbuf.st_size] = NULL;
	return cp;
}
