io_error(oops, buf, bufsize, dir, mode) int oops;			 unsigned char *buf;		 int bufsize;			 int dir;			 int mode;			 {
int io_error(oops, buf, bufsize, dir, mode) int oops;	 unsigned char *buf;	 int bufsize;	 int dir;	 int mode;	 {
io_error(oops, buf, bufsize, dir, mode)int oops;			/* the error flag; < 0 indicates a problem */unsigned char *buf;		/* the data in question */int bufsize;			/* the size of the data buffer */int dir;			/* the direction; input or output */int mode;			/* the fd on which we got the error */{	if(oops >= 0) return 0;	/* do we have an error ? */#ifdef EAGAIN	if(errno == EAGAIN){		perror("System 5 I/O error!");		fprintf(stderr,"A System 5 style I/O error was detected.  This program requires BSD 4.2\n");		fprintf(stderr,"behaviour.  This is probably a result of compile-time environment.\n");		exit(3);	}#endif	if(dir == READ_MSG){		if(errno == EINTR) return 0;	/* never retry read */		if(errno == EWOULDBLOCK){			LOGL4("READ would block (?!), sleeping and retrying!\n");			usleep(100000);	/* sleep a bit */			return 1;		/* and retry */		}		if(mode == IP_MODE){			perror("reading from raw ip socket");			exit(2);		} else if(mode == UDP_MODE){			perror("reading from udp socket");			exit(2);		} else if(mode == TTY_MODE){			perror("reading from tty device");			exit(2);		} else {			perror("reading from unknown I/O");			exit(2);		}	} else if(dir == SEND_MSG){		if(errno == EINTR) return 1;	/* always retry on writes */		if(mode == IP_MODE){			if(errno == EMSGSIZE){	/* msg too big, drop it */				perror("message dropped on raw ip socket");				fprintf(stderr,"message was %d bytes long.\n",bufsize);				return 0;			}			if(errno == ENOBUFS){	/* congestion; sleep + retry */				LOGL4("send congestion on raw ip, sleeping and retrying!\n");				usleep(100000);				return 1;			}			if(errno == EWOULDBLOCK){				LOGL4("send on raw ip would block, sleeping and retrying!\n");				usleep(100000);	/* sleep a bit */				return 1;		/* and retry */			}			perror("writing to raw ip socket");			exit(2);		} else if(mode == UDP_MODE){			if(errno == EMSGSIZE){	/* msg too big, drop it */				perror("message dropped on udp socket");				fprintf(stderr,"message was %d bytes long.\n",bufsize);				return 0;			}			if(errno == ENOBUFS){	/* congestion; sleep + retry */				LOGL4("send congestion on udp, sleeping and retrying!\n");				usleep(100000);				return 1;			}			if(errno == EWOULDBLOCK){				LOGL4("send on udp would block, sleeping and retrying!\n");				usleep(100000);	/* sleep a bit */				return 1;		/* and retry */			}			perror("writing to udp socket");			exit(2);		} else if(mode == TTY_MODE){			if(errno == EWOULDBLOCK){				LOGL4("write to tty would block, sleeping and retrying!\n");				usleep(100000);	/* sleep a bit */				return 1;		/* and retry */			}			perror("writing to tty device");			exit(2);		} else {			perror("writing to unknown I/O");			exit(2);		}	} else {		perror("Unknown direction and I/O");		exit(2);	}	return 0;}