if (write(log_file, buf, b - buf) == -1) {
if (write(log_file, log_buffer, b - log_buffer) == -1) {
void log_request(struct request *r){	const char *s;	char tmp[20];	long cl;	int i, l, n;	int left;	char buf[800];	char *b;	static int l1, l2;	int rok;	if (log_file == -1)		return;	if (log_columns <= 0) {		if (l1 == 0) {			l1 = 1;			log_d("log_request: nothing to log!");		}		return;	}	left = sizeof buf - log_columns;	if (left < 0) {		if (l2 == 0) {			l2 = 1;			log_d("log_request: buffer too small!?!?");		}		return;	}	b = buf;	rok = r->processed;	for (i = 0; i < log_columns; i++) {		l = sizeof buf;		s = 0;		switch (log_column[i]) {		case ML_CTIME:			s = ctime(&current_time);			l = 24;			break;		case ML_USERNAME:			if (rok && r->user[0])				s = r->user;			break;		case ML_ADDRESS:			sprintf(tmp, "%s", inet_ntoa(r->cn->peer.sin_addr));			s = tmp;			break;		case ML_PORT:			sprintf(tmp, "%hu", ntohs(r->cn->peer.sin_port));			s = tmp;			break;		case ML_SERVERNAME:			if (rok && r->vs)				s = r->vs->fullname;			break;		case ML_METHOD:			if (rok)				s = r->method_s;			break;		case ML_URI:			if (rok)				s = r->url;			break;		case ML_VERSION:			if (rok)				s = r->version;			break;		case ML_STATUS:			if (rok) {				s = r->status_line;				l = 3;			}			break;		case ML_CONTENT_LENGTH:			if (rok) {				cl = r->num_content;				if (cl >= 0)					cl = r->content_length;				if (cl < 0)					cl = 0;				sprintf(tmp, "%ld", cl);				s = tmp;			}			break;		case ML_REFERER:			if (rok)				s = r->referer;			break;		case ML_USER_AGENT:			if (rok)				s = r->user_agent;			break;		case ML_BYTES_READ:			sprintf(tmp, "%lu", r->cn->nread);			s = tmp;			break;		case ML_BYTES_WRITTEN:			sprintf(tmp, "%lu", r->cn->nwritten);			s = tmp;			break;		case ML_QUERY_STRING:			if (rok)				s = r->args;			break;		}		if (s == 0 || *s == 0) {			if (left) {				*b++ = '-';				--left;			}		} else {			n = strlen(s);			if (n > l)				n = l;			if (n > left)				n = left;			memcpy(b, s, n);			left -= n;			b += n;		}		*b++ = '\t';	}	b[-1] = '\n';	if (write(log_file, buf, b - buf) == -1) {		gotsigterm = 1;		log_d("log_request: cannot write to log file");		lerror("write");	}	return;}