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

Fix: Corrected printf() and scanf() style calls on win*

This commit is contained in:
Philipp Schafft 2024-10-25 23:29:07 +00:00
parent 1ca62d4ead
commit 8ccc536e1f

View File

@ -30,13 +30,9 @@
#include <unistd.h> #include <unistd.h>
#include <sys/time.h> #include <sys/time.h>
#include <sys/socket.h> #include <sys/socket.h>
#define SCN_OFF_T SCNdMAX
#define PRI_OFF_T PRIdMAX
#else #else
#include <winsock2.h> #include <winsock2.h>
#include <windows.h> #include <windows.h>
#define SCN_OFF_T "ld"
#define PRI_OFF_T "ld"
#ifndef S_ISREG #ifndef S_ISREG
#define S_ISREG(mode) ((mode) & _S_IFREG) #define S_ISREG(mode) ((mode) & _S_IFREG)
#endif #endif
@ -524,8 +520,12 @@ int fserve_client_create (client_t *httpclient)
/* 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, "%" SCN_OFF_T "-", &rangenumber); long long unsigned int in = 0;
ret = sscanf(range+6, "%llu-", &in);
rangenumber = in;
}
if (ret != 1) { if (ret != 1) {
/* format not correct, so lets just assume /* format not correct, so lets just assume
@ -566,13 +566,13 @@ int fserve_client_create (client_t *httpclient)
} }
bytes += snprintf (httpclient->refbuf->data + bytes, BUFSIZE - bytes, bytes += snprintf (httpclient->refbuf->data + bytes, BUFSIZE - bytes,
"Accept-Ranges: bytes\r\n" "Accept-Ranges: bytes\r\n"
"Content-Length: %" PRI_OFF_T "\r\n" "Content-Length: %llu\r\n"
"Content-Range: bytes %" PRI_OFF_T \ "Content-Range: bytes %llu" \
"-%" PRI_OFF_T "/%" PRI_OFF_T "\r\n\r\n", "-%llu/%llu\r\n\r\n",
new_content_len, (long long unsigned int)new_content_len,
rangenumber, (long long unsigned int)rangenumber,
endpos, (long long unsigned int)endpos,
content_length); (long long unsigned int)content_length);
free (type); free (type);
} }
else { else {
@ -598,8 +598,8 @@ int fserve_client_create (client_t *httpclient)
} }
bytes += snprintf (httpclient->refbuf->data + bytes, BUFSIZE - bytes, bytes += snprintf (httpclient->refbuf->data + bytes, BUFSIZE - bytes,
"Accept-Ranges: bytes\r\n" "Accept-Ranges: bytes\r\n"
"Content-Length: %" PRI_OFF_T "\r\n\r\n", "Content-Length: %llu\r\n\r\n",
content_length); (long long unsigned int)content_length);
free (type); free (type);
} }
httpclient->refbuf->len = bytes; httpclient->refbuf->len = bytes;