[xiph-commits] r8196 - icecast/trunk/icecast/src

msmith at motherfish-iii.xiph.org msmith at motherfish-iii.xiph.org
Thu Nov 11 14:36:03 PST 2004


Author: msmith
Date: 2004-11-11 14:36:03 -0800 (Thu, 11 Nov 2004)
New Revision: 8196

Modified:
   icecast/trunk/icecast/src/compat.h
   icecast/trunk/icecast/src/fserve.c
   icecast/trunk/icecast/src/fserve.h
Log:
Use 64 bit content-length for fileserving (if supported by system)



Modified: icecast/trunk/icecast/src/compat.h
===================================================================
--- icecast/trunk/icecast/src/compat.h	2004-11-11 22:25:00 UTC (rev 8195)
+++ icecast/trunk/icecast/src/compat.h	2004-11-11 22:36:03 UTC (rev 8196)
@@ -10,6 +10,9 @@
  *                      and others (see AUTHORS for details).
  */
 
+#ifndef __COMPAT_H__
+#define __COMPAT_H__
+
 /* compat.h
  * 
  * This file contains most of the ugliness for header portability
@@ -29,3 +32,12 @@
 #    include <inttypes.h>
 #  endif
 #endif
+
+#ifdef _WIN32
+#define FORMAT_INT64      "%I64d"
+#else
+#define FORMAT_INT64      "%lld"
+#endif
+
+#endif /* __COMPAT_H__ */
+

Modified: icecast/trunk/icecast/src/fserve.c
===================================================================
--- icecast/trunk/icecast/src/fserve.c	2004-11-11 22:25:00 UTC (rev 8195)
+++ icecast/trunk/icecast/src/fserve.c	2004-11-11 22:36:03 UTC (rev 8196)
@@ -47,6 +47,7 @@
 #include "logging.h"
 #include "cfgfile.h"
 #include "util.h"
+#include "compat.h"
 
 #include "fserve.h"
 
@@ -379,7 +380,7 @@
     client->content_length = 0;
     client->buf = malloc(BUFSIZE);
     if (stat(path, &file_buf) == 0) {
-        client->content_length = file_buf.st_size;
+        client->content_length = (int64_t)file_buf.st_size;
     }
 
     global_lock();
@@ -400,7 +401,7 @@
     httpclient->respcode = 200;
     bytes = sock_write(httpclient->con->sock,
             "HTTP/1.0 200 OK\r\n"
-            "Content-Length: %ld\r\n"
+            "Content-Length: " FORMAT_INT64 "\r\n"
             "Content-Type: %s\r\n\r\n",
             client->content_length,
             fserve_content_type(path));

Modified: icecast/trunk/icecast/src/fserve.h
===================================================================
--- icecast/trunk/icecast/src/fserve.h	2004-11-11 22:25:00 UTC (rev 8195)
+++ icecast/trunk/icecast/src/fserve.h	2004-11-11 22:36:03 UTC (rev 8196)
@@ -14,6 +14,7 @@
 #define __FSERVE_H__
 
 #include <stdio.h>
+#include "compat.h"
 
 typedef struct _fserve_t
 {
@@ -21,7 +22,7 @@
 
     FILE *file;
     int offset;
-    off_t content_length;
+    int64_t content_length;
     int datasize;
     int ready;
     unsigned char *buf;



More information about the commits mailing list