diff options
author | Baptiste Coudurier <baptiste.coudurier@gmail.com> | 2008-09-07 04:56:44 +0000 |
---|---|---|
committer | Baptiste Coudurier <baptiste.coudurier@gmail.com> | 2008-09-07 04:56:44 +0000 |
commit | a3aa4fed629a3842817f090180b2f26a91ae4a46 (patch) | |
tree | 9643365d40eac798107225f9792a4024ae9f0eda /ffserver.c | |
parent | 24b8aa84d07d74ad121b4fac16f337c6e5394da9 (diff) | |
download | ffmpeg-a3aa4fed629a3842817f090180b2f26a91ae4a46.tar.gz |
cleanup, merge snprintf calls
Originally committed as revision 15240 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'ffserver.c')
-rw-r--r-- | ffserver.c | 110 |
1 files changed, 55 insertions, 55 deletions
diff --git a/ffserver.c b/ffserver.c index 60f69f0c7e..19cf41ac58 100644 --- a/ffserver.c +++ b/ffserver.c @@ -1323,14 +1323,14 @@ static int http_parse_request(HTTPContext *c) if (stream->stream_type == STREAM_TYPE_REDIRECT) { c->http_error = 301; q = c->buffer; - q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "HTTP/1.0 301 Moved\r\n"); - q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "Location: %s\r\n", stream->feed_filename); - q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "Content-type: text/html\r\n"); - q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "\r\n"); - q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "<html><head><title>Moved</title></head><body>\r\n"); - q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "You should be <a href=\"%s\">redirected</a>.\r\n", stream->feed_filename); - q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "</body></html>\r\n"); - + q += snprintf(q, c->buffer_size, + "HTTP/1.0 301 Moved\r\n" + "Location: %s\r\n" + "Content-type: text/html\r\n" + "\r\n" + "<html><head><title>Moved</title></head><body>\r\n" + "You should be <a href=\"%s\">redirected</a>.\r\n" + "</body></html>\r\n", stream->feed_filename, stream->feed_filename); /* prepare output buffer */ c->buffer_ptr = c->buffer; c->buffer_end = q; @@ -1361,15 +1361,15 @@ static int http_parse_request(HTTPContext *c) if (c->post == 0 && max_bandwidth < current_bandwidth) { c->http_error = 200; q = c->buffer; - q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "HTTP/1.0 200 Server too busy\r\n"); - q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "Content-type: text/html\r\n"); - q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "\r\n"); - q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "<html><head><title>Too busy</title></head><body>\r\n"); - q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "<p>The server is too busy to serve your request at this time.</p>\r\n"); - q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "<p>The bandwidth being served (including your stream) is %lldkbit/sec, and this exceeds the limit of %lldkbit/sec.</p>\r\n", - current_bandwidth, max_bandwidth); - q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "</body></html>\r\n"); - + q += snprintf(q, c->buffer_size, + "HTTP/1.0 200 Server too busy\r\n" + "Content-type: text/html\r\n" + "\r\n" + "<html><head><title>Too busy</title></head><body>\r\n" + "<p>The server is too busy to serve your request at this time.</p>\r\n" + "<p>The bandwidth being served (including your stream) is %lldkbit/sec, " + "and this exceeds the limit of %lldkbit/sec.</p>\r\n" + "</body></html>\r\n", current_bandwidth, max_bandwidth); /* prepare output buffer */ c->buffer_ptr = c->buffer; c->buffer_end = q; @@ -1412,30 +1412,30 @@ static int http_parse_request(HTTPContext *c) q = c->buffer; switch(redir_type) { case REDIR_ASX: - q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "HTTP/1.0 200 ASX Follows\r\n"); - q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "Content-type: video/x-ms-asf\r\n"); - q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "\r\n"); - q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "<ASX Version=\"3\">\r\n"); - //q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "<!-- Autogenerated by ffserver -->\r\n"); - q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "<ENTRY><REF HREF=\"http://%s/%s%s\"/></ENTRY>\r\n", - hostbuf, filename, info); - q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "</ASX>\r\n"); + q += snprintf(q, c->buffer_size, + "HTTP/1.0 200 ASX Follows\r\n" + "Content-type: video/x-ms-asf\r\n" + "\r\n" + "<ASX Version=\"3\">\r\n" + //"<!-- Autogenerated by ffserver -->\r\n" + "<ENTRY><REF HREF=\"http://%s/%s%s\"/></ENTRY>\r\n" + "</ASX>\r\n", hostbuf, filename, info); break; case REDIR_RAM: - q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "HTTP/1.0 200 RAM Follows\r\n"); - q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "Content-type: audio/x-pn-realaudio\r\n"); - q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "\r\n"); - q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "# Autogenerated by ffserver\r\n"); - q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "http://%s/%s%s\r\n", - hostbuf, filename, info); + q += snprintf(q, c->buffer_size, + "HTTP/1.0 200 RAM Follows\r\n" + "Content-type: audio/x-pn-realaudio\r\n" + "\r\n" + "# Autogenerated by ffserver\r\n" + "http://%s/%s%s\r\n", hostbuf, filename, info); break; case REDIR_ASF: - q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "HTTP/1.0 200 ASF Redirect follows\r\n"); - q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "Content-type: video/x-ms-asf\r\n"); - q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "\r\n"); - q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "[Reference]\r\n"); - q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "Ref1=http://%s/%s%s\r\n", - hostbuf, filename, info); + q += snprintf(q, c->buffer_size, + "HTTP/1.0 200 ASF Redirect follows\r\n" + "Content-type: video/x-ms-asf\r\n" + "\r\n" + "[Reference]\r\n" + "Ref1=http://%s/%s%s\r\n", hostbuf, filename, info); break; case REDIR_RTSP: { @@ -1445,13 +1445,12 @@ static int http_parse_request(HTTPContext *c) p = strrchr(hostname, ':'); if (p) *p = '\0'; - q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "HTTP/1.0 200 RTSP Redirect follows\r\n"); - /* XXX: incorrect mime type ? */ - q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "Content-type: application/x-rtsp\r\n"); - q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "\r\n"); - q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "rtsp://%s:%d/%s\r\n", - hostname, ntohs(my_rtsp_addr.sin_port), - filename); + q += snprintf(q, c->buffer_size, + "HTTP/1.0 200 RTSP Redirect follows\r\n" + /* XXX: incorrect mime type ? */ + "Content-type: application/x-rtsp\r\n" + "\r\n" + "rtsp://%s:%d/%s\r\n", hostname, ntohs(my_rtsp_addr.sin_port), filename); } break; case REDIR_SDP: @@ -1460,9 +1459,10 @@ static int http_parse_request(HTTPContext *c) int sdp_data_size, len; struct sockaddr_in my_addr; - q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "HTTP/1.0 200 OK\r\n"); - q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "Content-type: application/sdp\r\n"); - q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "\r\n"); + q += snprintf(q, c->buffer_size, + "HTTP/1.0 200 OK\r\n" + "Content-type: application/sdp\r\n" + "\r\n"); len = sizeof(my_addr); getsockname(c->fd, (struct sockaddr *)&my_addr, &len); @@ -1608,14 +1608,14 @@ static int http_parse_request(HTTPContext *c) send_error: c->http_error = 404; q = c->buffer; - q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "HTTP/1.0 404 Not Found\r\n"); - q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "Content-type: %s\r\n", "text/html"); - q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "\r\n"); - q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "<HTML>\n"); - q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "<HEAD><TITLE>404 Not Found</TITLE></HEAD>\n"); - q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "<BODY>%s</BODY>\n", msg); - q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "</HTML>\n"); - + q += snprintf(q, c->buffer_size, + "HTTP/1.0 404 Not Found\r\n" + "Content-type: text/html\r\n" + "\r\n" + "<HTML>\n" + "<HEAD><TITLE>404 Not Found</TITLE></HEAD>\n" + "<BODY>%s</BODY>\n" + "</HTML>\n", msg); /* prepare output buffer */ c->buffer_ptr = c->buffer; c->buffer_end = q; |