sprintf(cl_start, "%*ld", cl_end - cl_start, r->content_length);
sprintf(cl_start, "%*ld", (int) (cl_end - cl_start), r->content_length);
static int prepare_reply(struct request *r){	struct pool *p;	int send_message;	char gbuf[40];	struct simple_list *h;	const char *status_line;	char *cl_start, *cl_end;	time_t et;	if (r->forked)		return 0;	if (r->in_content_length || r->in_transfer_encoding) {		if (debug)			log_d("client sent request-body; turning off keepalive");		r->cn->keepalive = 0;	}	p = &r->cn->output;	send_message = r->cn->rfd == -1 && r->method != M_HEAD && r->status != 204 && r->status != 304;	status_line = http_code_phrase(r->status);	cl_start = cl_end = 0;	if (send_message) {		r->num_content = 0;		r->content_type = "text/html";		r->content_length = p->ceiling - p->floor; /* hack - this gives us enough room in the output to change it to something less */	}	if (r->status >= 400)		r->last_modified = 0;	if (pool_print(p, "HTTP/1.1 %s\r\nServer: %s\r\nDate: %s\r\n", status_line, server_version, rfctime(current_time, gbuf)) == -1)		return -1;	switch (r->status) {	case 206:		if (pool_print(p, "Content-Range: bytes %lu-%lu/%lu\r\n", r->range_floor, r->range_ceiling, r->range_total) == -1)			return -1;		break;	case 302:		if (r->location)			if (pool_print(p, "Location: %s\r\n", r->location) == -1)				return -1;		break;	case 401:		if (r->c && r->c->realm)			if (pool_print(p, "WWW-Authenticate: Basic realm=\"%s\"\r\n", r->c->realm) == -1)				return -1;		break;	case 405:		if (pool_print(p, "Allow: GET, HEAD\r\n") == -1)			return -1;		break;	case 416:		if (pool_print(p, "Content-Range: bytes */%lu\r\n", r->range_total) == -1)			return -1;		break;	}	if (r->num_content >= 0) {		if (pool_print(p, "Content-Type: %s\r\n", r->content_type) == -1)			return -1;		if (r->content_length >= 0) {			if (pool_print(p, "Content-Length: ") == -1)				return -1;			cl_start = p->end;			if (pool_print(p, "%ld", r->content_length) == -1)				return -1;			cl_end = p->end;			if (pool_print(p, "\r\n") == -1)				return -1;		}		if (r->last_modified)			if (pool_print(p, "Last-Modified: %s\r\n", rfctime(r->last_modified, gbuf)) == -1)				return -1;	}	if (r->cn->keepalive) {		if (r->protocol_minor == 0)			if (pool_print(p, "Connection: keep-alive\r\n") == -1)				return -1;	} else if (r->protocol_minor)		if (pool_print(p, "Connection: close\r\n") == -1)			return -1;	if (r->c && r->status == 200) {		if (r->c->expire_interval) {			et = current_time + r->c->expire_interval;			if (pool_print(p, "Expires: %s\r\n", rfctime(et, gbuf)) == -1)				return -1;		}		for (h = r->c->extra_headers; h; h = h->next)			if (pool_print(p, "%s\r\n", h->name) == -1)				return -1;	}	if (pool_print(p, "\r\n") == -1)		return -1;	p->middle = p->end;	if (send_message == 0)		return 0;	if (pool_print(p, "<title>%s</title>\n<h1>%s</h1>\n", status_line, status_line) == -1)		return -1;	switch (r->status) {	case 302:		if (pool_print(p, "This document has moved to URL <a href=\"%s\">%s</a>.\n", r->location, r->location) == -1)			return -1;		break;	case 401:		if (pool_print(p, "You need proper authorization to use this resource.\n") == -1)			return -1;		break;	case 400:	case 405:	case 501:	case 505:		if (pool_print(p, "Your request was not understood or not allowed by this server.\n") == -1)			return -1;		break;	case 403:		if (pool_print(p, "Access to this resource has been denied to you.\n") == -1)			return -1;		break;	case 404:		if (pool_print(p, "The resource requested could not be found on this server.\n") == -1)			return -1;		break;	case 503:		if (pool_print(p, "The server is temporarily busy.\n") == -1)			return -1;		break;	}	if (r->c && r->c->admin)		if (pool_print(p, "<p>Please contact the site administrator at <i>%s</i>.\n", r->c->admin) == -1)			return -1;	r->content_length = p->end - p->middle;	if (cl_start == 0) {		log_d("cl_start is null!?!?");		return -1;	}	sprintf(cl_start, "%*ld", cl_end - cl_start, r->content_length);	*cl_end = '\r';	return 0;}