1
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2024-12-04 14:46:30 -05:00

type cleanups. Use C99 defines if available and a missed sock_t on win32. This

resolves some warnings on win32 and x86_64

svn path=/icecast/trunk/icecast/; revision=14223
This commit is contained in:
Karl Heyes 2007-11-23 16:27:10 +00:00
parent 89dac2e3cf
commit 7b6b874b02
4 changed files with 24 additions and 28 deletions

View File

@ -43,22 +43,15 @@
# define int64_t __int64 # define int64_t __int64
# define uint64_t unsigned __int64 # define uint64_t unsigned __int64
# define uint32_t unsigned int # define uint32_t unsigned int
# define PRIu64 "I64u"
#else #else
# define PATH_SEPARATOR "/" # define PATH_SEPARATOR "/"
# if defined(HAVE_STDINT_H) # if defined(HAVE_INTTYPES_H)
# include <stdint.h>
# elif defined(HAVE_INTTYPES_H)
# include <inttypes.h> # include <inttypes.h>
# elif defined(HAVE_STDINT_H)
# include <stdint.h>
# endif # endif
#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__ */ #endif /* __COMPAT_H__ */

View File

@ -32,6 +32,9 @@
#else #else
#include <winsock2.h> #include <winsock2.h>
#include <windows.h> #include <windows.h>
#define fseeko fseek
#define PRIdMAX "ld"
#define SCNdMAX "ld"
#define snprintf _snprintf #define snprintf _snprintf
#define strncasecmp _strnicmp #define strncasecmp _strnicmp
#define S_ISREG(mode) ((mode) & _S_IFREG) #define S_ISREG(mode) ((mode) & _S_IFREG)
@ -76,7 +79,7 @@ static int client_tree_changed=0;
static struct pollfd *ufds = NULL; static struct pollfd *ufds = NULL;
#else #else
static fd_set fds; static fd_set fds;
static int fd_max = -1; static sock_t fd_max = SOCK_ERROR;
#endif #endif
typedef struct { typedef struct {
@ -164,17 +167,17 @@ int fserve_client_waiting (void)
if(client_tree_changed) { if(client_tree_changed) {
client_tree_changed = 0; client_tree_changed = 0;
FD_ZERO(&fds); FD_ZERO(&fds);
fd_max = -1; fd_max = SOCK_ERROR;
fclient = active_list; fclient = active_list;
while (fclient) { while (fclient) {
FD_SET (fclient->client->con->sock, &fds); 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; fd_max = fclient->client->con->sock;
fclient = fclient->next; fclient = fclient->next;
} }
} }
/* hack for windows, select needs at least 1 descriptor */ /* hack for windows, select needs at least 1 descriptor */
if (fd_max == -1) if (fd_max == SOCK_ERROR)
thread_sleep (200000); thread_sleep (200000);
else else
{ {
@ -377,8 +380,8 @@ int fserve_client_create (client_t *httpclient, const char *path)
int bytes; int bytes;
struct stat file_buf; struct stat file_buf;
const char *range = NULL; const char *range = NULL;
int64_t new_content_len = 0; off_t new_content_len = 0;
int64_t rangenumber = 0, content_length; off_t rangenumber = 0, content_length;
int rangeproblem = 0; int rangeproblem = 0;
int ret = 0; int ret = 0;
char *fullpath; char *fullpath;
@ -499,14 +502,14 @@ int fserve_client_create (client_t *httpclient, const char *path)
} }
free (fullpath); free (fullpath);
content_length = (int64_t)file_buf.st_size; content_length = file_buf.st_size;
range = httpp_getvar (httpclient->parser, "range"); range = httpp_getvar (httpclient->parser, "range");
/* full http range handling is currently not done but we deal with the common case */ /* full http range handling is currently not done but we deal with the common case */
if (range != NULL) { if (range != NULL) {
ret = 0; ret = 0;
if (strncasecmp (range, "bytes=", 6) == 0) if (strncasecmp (range, "bytes=", 6) == 0)
ret = sscanf (range+6, FORMAT_INT64 "-", &rangenumber); ret = sscanf (range+6, "%" SCNdMAX "-", &rangenumber);
if (ret != 1) { if (ret != 1) {
/* format not correct, so lets just assume /* format not correct, so lets just assume
@ -517,7 +520,7 @@ int fserve_client_create (client_t *httpclient, const char *path)
rangeproblem = 1; rangeproblem = 1;
} }
if (!rangeproblem) { if (!rangeproblem) {
ret = fseek (file, rangenumber, SEEK_SET); ret = fseeko (file, rangenumber, SEEK_SET);
if (ret != -1) { if (ret != -1) {
new_content_len = content_length - rangenumber; new_content_len = content_length - rangenumber;
if (new_content_len < 0) { if (new_content_len < 0) {
@ -533,7 +536,7 @@ int fserve_client_create (client_t *httpclient, const char *path)
time_t now; time_t now;
int strflen; int strflen;
struct tm result; struct tm result;
int64_t endpos = rangenumber+new_content_len-1; off_t endpos = rangenumber+new_content_len-1;
char *type; char *type;
if (endpos < 0) { if (endpos < 0) {
@ -548,9 +551,9 @@ int fserve_client_create (client_t *httpclient, const char *path)
"HTTP/1.1 206 Partial Content\r\n" "HTTP/1.1 206 Partial Content\r\n"
"Date: %s\r\n" "Date: %s\r\n"
"Accept-Ranges: bytes\r\n" "Accept-Ranges: bytes\r\n"
"Content-Length: " FORMAT_INT64 "\r\n" "Content-Length: %" PRIdMAX "\r\n"
"Content-Range: bytes " FORMAT_INT64 \ "Content-Range: bytes %" PRIdMAX \
"-" FORMAT_INT64 "/" FORMAT_INT64 "\r\n" "-%" PRIdMAX "/%" PRIdMAX "\r\n"
"Content-Type: %s\r\n\r\n", "Content-Type: %s\r\n\r\n",
currenttime, currenttime,
new_content_len, new_content_len,
@ -574,7 +577,7 @@ int fserve_client_create (client_t *httpclient, const char *path)
bytes = snprintf (httpclient->refbuf->data, BUFSIZE, bytes = snprintf (httpclient->refbuf->data, BUFSIZE,
"HTTP/1.0 200 OK\r\n" "HTTP/1.0 200 OK\r\n"
"Accept-Ranges: bytes\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-Type: %s\r\n\r\n",
content_length, content_length,
type); type);

View File

@ -150,7 +150,7 @@ void logging_access(client_t *client)
user_agent = "-"; user_agent = "-";
log_write_direct (accesslog, 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, client->con->ip,
username, username,
datebuf, datebuf,

View File

@ -461,9 +461,9 @@ static refbuf_t *get_next_buffer (source_t *source)
if (current >= source->client_stats_update) if (current >= source->client_stats_update)
{ {
stats_event_args (source->mount, "total_bytes_read", 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", 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; source->client_stats_update = current + 5;
} }
if (fds < 0) if (fds < 0)