[xiph-commits] r14223 - icecast/trunk/icecast/src
karl at svn.xiph.org
karl at svn.xiph.org
Fri Nov 23 08:27:11 PST 2007
Author: karl
Date: 2007-11-23 08:27:10 -0800 (Fri, 23 Nov 2007)
New Revision: 14223
Modified:
icecast/trunk/icecast/src/compat.h
icecast/trunk/icecast/src/fserve.c
icecast/trunk/icecast/src/logging.c
icecast/trunk/icecast/src/source.c
Log:
type cleanups. Use C99 defines if available and a missed sock_t on win32. This
resolves some warnings on win32 and x86_64
Modified: icecast/trunk/icecast/src/compat.h
===================================================================
--- icecast/trunk/icecast/src/compat.h 2007-11-23 12:35:01 UTC (rev 14222)
+++ icecast/trunk/icecast/src/compat.h 2007-11-23 16:27:10 UTC (rev 14223)
@@ -43,22 +43,15 @@
# define int64_t __int64
# define uint64_t unsigned __int64
# define uint32_t unsigned int
+# define PRIu64 "I64u"
#else
# define PATH_SEPARATOR "/"
-# if defined(HAVE_STDINT_H)
-# include <stdint.h>
-# elif defined(HAVE_INTTYPES_H)
+# if defined(HAVE_INTTYPES_H)
# include <inttypes.h>
+# elif defined(HAVE_STDINT_H)
+# include <stdint.h>
# endif
#endif
-#ifdef _WIN32
-#define FORMAT_INT64 "%I64d"
-#define FORMAT_UINT64 "%I64u"
-#else
-#define FORMAT_INT64 "%lld"
-#define FORMAT_UINT64 "%llu"
-#endif
-
#endif /* __COMPAT_H__ */
Modified: icecast/trunk/icecast/src/fserve.c
===================================================================
--- icecast/trunk/icecast/src/fserve.c 2007-11-23 12:35:01 UTC (rev 14222)
+++ icecast/trunk/icecast/src/fserve.c 2007-11-23 16:27:10 UTC (rev 14223)
@@ -32,6 +32,9 @@
#else
#include <winsock2.h>
#include <windows.h>
+#define fseeko fseek
+#define PRIdMAX "ld"
+#define SCNdMAX "ld"
#define snprintf _snprintf
#define strncasecmp _strnicmp
#define S_ISREG(mode) ((mode) & _S_IFREG)
@@ -76,7 +79,7 @@
static struct pollfd *ufds = NULL;
#else
static fd_set fds;
-static int fd_max = -1;
+static sock_t fd_max = SOCK_ERROR;
#endif
typedef struct {
@@ -164,17 +167,17 @@
if(client_tree_changed) {
client_tree_changed = 0;
FD_ZERO(&fds);
- fd_max = -1;
+ fd_max = SOCK_ERROR;
fclient = active_list;
while (fclient) {
FD_SET (fclient->client->con->sock, &fds);
- if (fclient->client->con->sock > fd_max)
+ if (fclient->client->con->sock > fd_max || fd_max == SOCK_ERROR)
fd_max = fclient->client->con->sock;
fclient = fclient->next;
}
}
/* hack for windows, select needs at least 1 descriptor */
- if (fd_max == -1)
+ if (fd_max == SOCK_ERROR)
thread_sleep (200000);
else
{
@@ -377,8 +380,8 @@
int bytes;
struct stat file_buf;
const char *range = NULL;
- int64_t new_content_len = 0;
- int64_t rangenumber = 0, content_length;
+ off_t new_content_len = 0;
+ off_t rangenumber = 0, content_length;
int rangeproblem = 0;
int ret = 0;
char *fullpath;
@@ -499,14 +502,14 @@
}
free (fullpath);
- content_length = (int64_t)file_buf.st_size;
+ content_length = file_buf.st_size;
range = httpp_getvar (httpclient->parser, "range");
/* full http range handling is currently not done but we deal with the common case */
if (range != NULL) {
ret = 0;
if (strncasecmp (range, "bytes=", 6) == 0)
- ret = sscanf (range+6, FORMAT_INT64 "-", &rangenumber);
+ ret = sscanf (range+6, "%" SCNdMAX "-", &rangenumber);
if (ret != 1) {
/* format not correct, so lets just assume
@@ -517,7 +520,7 @@
rangeproblem = 1;
}
if (!rangeproblem) {
- ret = fseek (file, rangenumber, SEEK_SET);
+ ret = fseeko (file, rangenumber, SEEK_SET);
if (ret != -1) {
new_content_len = content_length - rangenumber;
if (new_content_len < 0) {
@@ -533,7 +536,7 @@
time_t now;
int strflen;
struct tm result;
- int64_t endpos = rangenumber+new_content_len-1;
+ off_t endpos = rangenumber+new_content_len-1;
char *type;
if (endpos < 0) {
@@ -548,9 +551,9 @@
"HTTP/1.1 206 Partial Content\r\n"
"Date: %s\r\n"
"Accept-Ranges: bytes\r\n"
- "Content-Length: " FORMAT_INT64 "\r\n"
- "Content-Range: bytes " FORMAT_INT64 \
- "-" FORMAT_INT64 "/" FORMAT_INT64 "\r\n"
+ "Content-Length: %" PRIdMAX "\r\n"
+ "Content-Range: bytes %" PRIdMAX \
+ "-%" PRIdMAX "/%" PRIdMAX "\r\n"
"Content-Type: %s\r\n\r\n",
currenttime,
new_content_len,
@@ -574,7 +577,7 @@
bytes = snprintf (httpclient->refbuf->data, BUFSIZE,
"HTTP/1.0 200 OK\r\n"
"Accept-Ranges: bytes\r\n"
- "Content-Length: " FORMAT_INT64 "\r\n"
+ "Content-Length: %" PRIdMAX "\r\n"
"Content-Type: %s\r\n\r\n",
content_length,
type);
Modified: icecast/trunk/icecast/src/logging.c
===================================================================
--- icecast/trunk/icecast/src/logging.c 2007-11-23 12:35:01 UTC (rev 14222)
+++ icecast/trunk/icecast/src/logging.c 2007-11-23 16:27:10 UTC (rev 14223)
@@ -150,7 +150,7 @@
user_agent = "-";
log_write_direct (accesslog,
- "%s - %s [%s] \"%s\" %d " FORMAT_UINT64 " \"%s\" \"%s\" %lu",
+ "%s - %s [%s] \"%s\" %d %" PRIu64 " \"%s\" \"%s\" %lu",
client->con->ip,
username,
datebuf,
Modified: icecast/trunk/icecast/src/source.c
===================================================================
--- icecast/trunk/icecast/src/source.c 2007-11-23 12:35:01 UTC (rev 14222)
+++ icecast/trunk/icecast/src/source.c 2007-11-23 16:27:10 UTC (rev 14223)
@@ -461,9 +461,9 @@
if (current >= source->client_stats_update)
{
stats_event_args (source->mount, "total_bytes_read",
- FORMAT_UINT64, source->format->read_bytes);
+ "%"PRIu64, source->format->read_bytes);
stats_event_args (source->mount, "total_bytes_sent",
- FORMAT_UINT64, source->format->sent_bytes);
+ "%"PRIu64, source->format->sent_bytes);
source->client_stats_update = current + 5;
}
if (fds < 0)
More information about the commits
mailing list