/*
 *  libopen.c:  the openfifo() function
 *
 *  Copyright (c) 2000 David Parsons. All rights reserved.
 *
 *  This software is released under a berkeley-style copyright; the
 *  details can be found in the file COPYRIGHT.
 */
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>


FILE *
openfifo(char *fifo)
{
    struct stat st;
    int fd;


    if ( (fd = open(fifo, O_WRONLY)) == -1)
	return 0;

    if (fstat(fd, &st) == 0 && S_ISFIFO(st.st_mode))
	return fdopen(fd, "w");

    return 0;
}
