/
MudOS_0.9.19/bin/
MudOS_0.9.19/doc/concepts/
MudOS_0.9.19/doc/driver/
MudOS_0.9.19/doc/efuns/bitstrings/
MudOS_0.9.19/doc/efuns/buffers/
MudOS_0.9.19/doc/efuns/communication/
MudOS_0.9.19/doc/efuns/core/
MudOS_0.9.19/doc/efuns/mappings/
MudOS_0.9.19/doc/efuns/math/
MudOS_0.9.19/doc/efuns/security/
MudOS_0.9.19/doc/lpc/constructs/
MudOS_0.9.19/doc/lpc/types/
MudOS_0.9.19/doc/platforms/
MudOS_0.9.19/etc/
MudOS_0.9.19/mudlib/
MudOS_0.9.19/mudlib/lil/
MudOS_0.9.19/mudlib/lil/clone/
MudOS_0.9.19/mudlib/lil/command/
MudOS_0.9.19/mudlib/lil/data/
MudOS_0.9.19/mudlib/lil/etc/
MudOS_0.9.19/mudlib/lil/include/
MudOS_0.9.19/mudlib/lil/inherit/
MudOS_0.9.19/mudlib/lil/inherit/master/
MudOS_0.9.19/mudlib/lil/log/
MudOS_0.9.19/mudlib/lil/single/
MudOS_0.9.19/mudlib/lil/u/
MudOS_0.9.19/src/testsuite/
MudOS_0.9.19/src/testsuite/clone/
MudOS_0.9.19/src/testsuite/command/
MudOS_0.9.19/src/testsuite/data/
MudOS_0.9.19/src/testsuite/etc/
MudOS_0.9.19/src/testsuite/include/
MudOS_0.9.19/src/testsuite/inherit/
MudOS_0.9.19/src/testsuite/inherit/master/
MudOS_0.9.19/src/testsuite/log/
MudOS_0.9.19/src/testsuite/single/
MudOS_0.9.19/src/testsuite/single/efuns/
MudOS_0.9.19/src/testsuite/u/
/*
  ioctl.c: part of the MudOS release -- Truilkan@TMI

  isolates the code which sets the various socket modes since various
  machines seem to need this done in different ways.
*/

#include <stdio.h>
#include "config.h"
#ifdef SunOS_5
#include <unistd.h>
#endif
#include <sys/types.h>
#ifndef LATTICE
#include <sys/ioctl.h>
#include <sys/socket.h>
#else
#include "amiga.h"
#endif
#if defined(_SEQUENT_) || defined(OLD_ULTRIX)
#include <fcntl.h>
#endif
#if defined(SVR4)
#include <fcntl.h>
#include <sys/filio.h>
#include <sys/sockio.h>
#endif
#include "lint.h"

/*
 * set process receiving SIGIO/SIGURG signals to us.
 */

INLINE int set_socket_owner(fd, which)
int fd, which;
{
#ifdef OLD_ULTRIX
	return fcntl(fd, F_SETOWN, which);
#else
	return ioctl(fd, SIOCSPGRP, &which);
#endif
}

/*
 * allow receipt of asynchronous I/O signals.
 */

INLINE int set_socket_async(fd, which)
int fd, which;
{
#ifdef OLD_ULTRIX
	return fcntl(fd, F_SETFL, FASYNC);
#else
	return ioctl(fd, FIOASYNC, &which);
#endif
}

/*
 * set socket non-blocking
 */

INLINE int set_socket_nonblocking(fd, which)
int fd, which;
{
#if !defined(OLD_ULTRIX) && !defined(_SEQUENT_)
	int result;
#endif

#ifdef OLD_ULTRIX
    if (which)
       return fcntl(fd, F_SETFL, FNDELAY);
    else
       return fcntl(fd, F_SETFL, FNBLOCK);
#else

#ifdef _SEQUENT_
	int flags = fcntl(fd, F_GETFL, 0);
	if (flags == -1)
		return (-1);
	if (which)
		flags |= O_NONBLOCK;
	else
		flags &= ~O_NONBLOCK;
	return fcntl(fd, F_SETFL, flags);
#else
	result = ioctl(fd, FIONBIO, &which);
	if (result == -1) {
		fprintf(stderr, "Try using cc instead of gcc to correct this error.\n");
	}
	return result;
#endif

#endif
}