f->f_type = F_UNUSED; logerror("sendto");
switch (errno) { case EHOSTDOWN: case EHOSTUNREACH: case ENETDOWN: case ENOBUFS:  break; default: f->f_type = F_UNUSED; logerror("sendto"); break; }
fprintlog(struct filed *f, int flags, char *msg){	struct iovec iov[6];	struct iovec *v;	int l;	char line[MAXLINE + 1], repbuf[80], greetings[500];	v = iov;	if (f->f_type == F_WALL) {		if ((l = snprintf(greetings, sizeof(greetings),		    "\r\n\7Message from syslogd@%s at %.24s ...\r\n",		    f->f_prevhost, ctime(&now))) >= sizeof(greetings) ||		    l == -1)			l = strlen(greetings);		v->iov_base = greetings;		v->iov_len = l;		v++;		v->iov_base = "";		v->iov_len = 0;		v++;	} else {		v->iov_base = f->f_lasttime;		v->iov_len = 15;		v++;		v->iov_base = " ";		v->iov_len = 1;		v++;	}	v->iov_base = f->f_prevhost;	v->iov_len = strlen(v->iov_base);	v++;	v->iov_base = " ";	v->iov_len = 1;	v++;	if (msg) {		v->iov_base = msg;		v->iov_len = strlen(msg);	} else if (f->f_prevcount > 1) {		if ((l = snprintf(repbuf, sizeof(repbuf),		    "last message repeated %d times", f->f_prevcount)) >=		    sizeof(repbuf) || l == -1)			l = strlen(repbuf);		v->iov_base = repbuf;		v->iov_len = l;	} else {		v->iov_base = f->f_prevline;		v->iov_len = f->f_prevlen;	}	v++;	dprintf("Logging to %s", TypeNames[f->f_type]);	f->f_time = now;	switch (f->f_type) {	case F_UNUSED:		dprintf("\n");		break;	case F_FORW:		dprintf(" %s\n", f->f_un.f_forw.f_hname);		if ((l = snprintf(line, sizeof(line), "<%d>%.15s %s",		    f->f_prevpri, (char *)iov[0].iov_base,		    (char *)iov[4].iov_base)) >= sizeof(line) || l == -1)			l = strlen(line);		if (sendto(pfd[PFD_INET].fd, line, l, 0,		    (struct sockaddr *)&f->f_un.f_forw.f_addr,		    f->f_un.f_forw.f_addr.ss_len) != l) {			f->f_type = F_UNUSED;			logerror("sendto");		}		break;	case F_CONSOLE:		if (flags & IGN_CONS) {			dprintf(" (ignored)\n");			break;		}		/* FALLTHROUGH */	case F_TTY:	case F_FILE:		dprintf(" %s\n", f->f_un.f_fname);		if (f->f_type != F_FILE) {			v->iov_base = "\r\n";			v->iov_len = 2;		} else {			v->iov_base = "\n";			v->iov_len = 1;		}	again:		if (writev(f->f_file, iov, 6) < 0) {			int e = errno;			(void)close(f->f_file);			/*			 * Check for errors on TTY's due to loss of tty			 */			if (e == EAGAIN) {				/*				 * Silently drop messages on blocked write.				 * This can happen when logging to a locked tty.				 */				break;			} else if ((e == EIO || e == EBADF) &&			    f->f_type != F_FILE) {				f->f_file = priv_open_tty(f->f_un.f_fname);				if (f->f_file < 0) {					f->f_type = F_UNUSED;					logerror(f->f_un.f_fname);				} else					goto again;			} else {				f->f_type = F_UNUSED;				f->f_file = -1;				errno = e;				logerror(f->f_un.f_fname);			}		} else if (flags & SYNC_FILE)			(void)fsync(f->f_file);		break;	case F_USERS:	case F_WALL:		dprintf("\n");		v->iov_base = "\r\n";		v->iov_len = 2;		wallmsg(f, iov);		break;	case F_MEMBUF:		dprintf("\n");		snprintf(line, sizeof(line), "%.15s %s %s",		    (char *)iov[0].iov_base, (char *)iov[2].iov_base, 		    (char *)iov[4].iov_base);		if (ringbuf_append_line(f->f_un.f_mb.f_rb, line) == 1)			f->f_un.f_mb.f_overflow = 1;		break;	}	f->f_prevcount = 0;}