OpenSS7
SS7 for the
Common Man

© Copyright 1997-2004,OpenSS7 Corporation, All Rights Reserved.
Last modified:

Home Overview Status News Documentation Resources About
   
 Overview
 Status
 News
 Documentation
 Resources
 About

   
Home Index Prev Next More Download Info FAQ Mail   Home -> Resources -> Browse Source -> strss7/lib/libxnet/t_open.c


File /code/strss7/lib/libxnet/t_open.c



#ident "@(#) $RCSfile: t_open.c,v $ $Name:  $($Revision: 0.8.2.2 $) $Date: 2003/05/27 11:21:51 $"

static char const ident[] = "$RCSfile: t_open.c,v $ $Name:  $($Revision: 0.8.2.2 $) $Date: 2003/05/27 11:21:51 $";

#include <unistd.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/xti.h>

int t_open(const char *name, int oflag, struct t_info *info)
{
	int fd = 0;
	if (oflag & ~(O_RDWR | O_NONBLOCK | O_NDELAY | O_NOFOLLOW))
		goto tbadflag;
	if (!(oflag & O_RDWR))
		goto tbadflag;
	if (oflag & O_NOFOLLOW) {
		struct stat fstat;
		if (lstat(name, &fstat) < 0)
			goto tbadname;
		if (!S_ISCHR(fstat.st_mode))
			goto tbadname;
	} else {
		struct stat fstat;
		if (stat(name, &fstat) < 0)
			goto tbadname;
		if (!S_ISCHR(fstat.st_mode))
			goto tbadname;
	}
	if ((fd = open(name, oflag)) < 0)
		goto openerror;
	if (t_getinfo(fd, info) < 0)
		goto error;
	return (fd);
      tbadflag:
	t_errno = TBADFLAG;
	goto error;
      tbadname:
	t_errno = TBADNAME;
	goto error;
      error:
	if (fd > 0)
		close(fd);
	return (-1);
      openerror:
	switch (errno) {
	case EISDIR:
	case ENAMETOOLONG:
	case ENOENT:
	case ELOOP:
		goto tbadname;
	default:
	case EACCES:
	case ENXIO:
	case ENODEV:
	case EROFS:
	case ETXTBSY:
	case ENFILE:
	case EMFILE:
		break;
	}
	t_errno = TSYSERR;
	goto error;
}



Home Index Prev Next More Download Info FAQ Mail   Home -> Resources -> Browse Source -> strss7/lib/libxnet/t_open.c

OpenSS7
SS7 for the
Common Man
Home Overview Status News Documentation Resources About

© Copyright 1997-2004,OpenSS7 Corporation, All Rights Reserved.
Last modified: