CHECK_FUNCTION_EXISTS(_snprintf LWS_HAVE__SNPRINTF)
CHECK_FUNCTION_EXISTS(_vsnprintf LWS_HAVE__VSNPRINTF)
CHECK_FUNCTION_EXISTS(getloadavg LWS_HAVE_GETLOADAVG)
+CHECK_FUNCTION_EXISTS(atoll LWS_HAVE_ATOLL)
+CHECK_FUNCTION_EXISTS(_atoi64 LWS_HAVE__ATOI64)
+CHECK_FUNCTION_EXISTS(_stat32i64 LWS_HAVE__STAT32I64)
if (NOT LWS_HAVE_GETIFADDRS)
if (LWS_WITHOUT_BUILTIN_GETIFADDRS)
message(" LWS_WITH_SOCKS5 = ${LWS_WITH_SOCKS5}")
message(" LWS_HAVE_SYS_CAPABILITY_H = ${LWS_HAVE_SYS_CAPABILITY_H}")
message(" LWS_HAVE_LIBCAP = ${LWS_HAVE_LIBCAP}")
+message(" LWS_HAVE_ATOLL = ${LWS_HAVE_ATOLL}")
+message(" LWS_HAVE__ATOI64 = ${LWS_HAVE__ATOI64}")
+message(" LWS_HAVE_STAT32I64 = ${LWS_HAVE_STAT32I64}")
message("---------------------------------------------------------------------")
if (lws_hdr_total_length(wsi, WSI_TOKEN_HTTP_CONTENT_LENGTH)) {
wsi->u.http.content_length =
- atoi(lws_hdr_simple_ptr(wsi,
+ atoll(lws_hdr_simple_ptr(wsi,
WSI_TOKEN_HTTP_CONTENT_LENGTH));
lwsl_notice("%s: incoming content length %llu\n", __func__,
(unsigned long long)wsi->u.http.content_length);
*amount = 0;
}
- priv->inflate.avail_out = len;
+ priv->inflate.avail_out = (unsigned int)len;
priv->inflate.next_out = buf;
spin:
cur += ramount;
- priv->inflate.avail_in = ramount;
+ priv->inflate.avail_in = (unsigned int)ramount;
priv->inflate.next_in = priv->rbuf;
}
if (rlen > len)
rlen = len;
/* provide stuff from canned header */
- memcpy(buf, hd + fd->pos, rlen);
+ memcpy(buf, hd + fd->pos, (size_t)rlen);
fd->pos += rlen;
buf += rlen;
len -= rlen;
if (rlen > len)
rlen = len;
- memcpy(buf, priv->u.trailer8 + cur, rlen);
+ memcpy(buf, priv->u.trailer8 + cur, (size_t)rlen);
*amount += rlen;
fd->pos += rlen;
*/
LWS_VISIBLE int
-lws_read(struct lws *wsi, unsigned char *buf, size_t len)
+lws_read(struct lws *wsi, unsigned char *buf, lws_filepos_t len)
{
unsigned char *last_char, *oldbuf = buf;
- int body_chunk_len;
+ lws_filepos_t body_chunk_len;
size_t n;
lwsl_debug("%s: incoming len %d state %d\n", __func__, (int)len, wsi->state);
}
lwsl_parser("issuing %d bytes to parser\n", (int)len);
- if (lws_handshake_client(wsi, &buf, len))
+ if (lws_handshake_client(wsi, &buf, (size_t)len))
goto bail;
last_char = buf;
- if (lws_handshake_server(wsi, &buf, len))
+ if (lws_handshake_server(wsi, &buf, (size_t)len))
/* Handshake indicates this session is done. */
goto bail;
#endif
n = wsi->protocol->callback(wsi,
LWS_CALLBACK_HTTP_BODY, wsi->user_space,
- buf, body_chunk_len);
+ buf, (size_t)body_chunk_len);
if (n)
goto bail;
- n = body_chunk_len;
+ n = (size_t)body_chunk_len;
#ifdef LWS_WITH_CGI
}
#endif
case LWSS_ESTABLISHED:
case LWSS_AWAITING_CLOSE_ACK:
case LWSS_SHUTDOWN:
- if (lws_handshake_client(wsi, &buf, len))
+ if (lws_handshake_client(wsi, &buf, (size_t)len))
goto bail;
switch (wsi->mode) {
case LWSCM_WS_SERVING:
- if (lws_interpret_incoming_packet(wsi, &buf, len) < 0) {
+ if (lws_interpret_incoming_packet(wsi, &buf, (size_t)len) < 0) {
lwsl_info("interpret_incoming_packet has bailed\n");
goto bail;
}
n = vsnprintf(str, size, format, ap);
va_end(ap);
- if (n >= size)
+ if (n >= (int)size)
return size;
return n;
#if (defined(WIN32) || defined(_WIN32)) && !defined(__MINGW32__)
/* ... */
-#if !defined(ssize_t)
-typedef SSIZE_T ssize_t;
+#define ssize_t SSIZE_T
#endif
+
+#if defined(WIN32) && defined(LWS_HAVE__STAT32I64)
+#include <sys/types.h>
+#include <sys/stat.h>
#endif
#if defined(LWS_HAVE_STDINT_H)
#endif
#endif
-typedef size_t lws_filepos_t;
-typedef ssize_t lws_fileofs_t;
+typedef unsigned long long lws_filepos_t;
+typedef long long lws_fileofs_t;
typedef uint32_t lws_fop_flags_t;
/** struct lws_pollargs - argument structure for all external poll related calls
* useful when integrating with other app poll loop service code.
*/
LWS_VISIBLE LWS_EXTERN int
-lws_read(struct lws *wsi, unsigned char *buf, size_t len);
+lws_read(struct lws *wsi, unsigned char *buf, lws_filepos_t len);
/**
* lws_set_allocator() - custom allocator support
HANDLE ret;
WCHAR buf[MAX_PATH];
lws_fop_fd_t fop_fd;
+ LARGE_INTEGER llFileSize = {0};
MultiByteToWideChar(CP_UTF8, 0, filename, -1, buf, ARRAY_SIZE(buf));
if (((*flags) & 7) == _O_RDONLY) {
fop_fd->filesystem_priv = NULL; /* we don't use it */
fop_fd->flags = *flags;
fop_fd->len = GetFileSize(ret, NULL);
+ if(GetFileSizeEx(ret, &llFileSize))
+ fop_fd->len = llFileSize.QuadPart;
+
fop_fd->pos = 0;
return fop_fd;
LWS_VISIBLE lws_fileofs_t
_lws_plat_file_seek_cur(lws_fop_fd_t fop_fd, lws_fileofs_t offset)
{
- return SetFilePointer((HANDLE)fop_fd->fd, offset, NULL, FILE_CURRENT);
+ LARGE_INTEGER l;
+
+ l.QuadPart = offset;
+ return SetFilePointerEx((HANDLE)fop_fd->fd, l, NULL, FILE_CURRENT);
}
LWS_VISIBLE int
wp == LWS_WRITE_HTTP_FINAL) &&
wsi->u.http.content_length) {
wsi->u.http.content_remain -= len;
- lwsl_info("%s: content_remain = %lu\n", __func__,
- (unsigned long)wsi->u.http.content_remain);
+ lwsl_info("%s: content_remain = %llu\n", __func__,
+ (unsigned long long)wsi->u.http.content_remain);
if (!wsi->u.http.content_remain) {
lwsl_info("%s: selecting final write mode\n", __func__);
wp = LWS_WRITE_HTTP_FINAL;
if (wsi->sending_chunked) {
args.p = (char *)p;
args.len = n;
- args.max_len = poss + 128;
+ args.max_len = (unsigned int)poss + 128;
args.final = wsi->u.http.filepos + n ==
wsi->u.http.filelen;
if (user_callback_handle_rxflow(
#include <mstcpip.h>
#include <io.h>
+#if !defined(LWS_HAVE_ATOLL)
+#if defined(LWS_HAVE__ATOI64)
+#define atoll _atoi64
+#else
+#warning No atoll or _atoi64 available, using atoi
+#define atoll atoi
+#endif
+#endif
+
#ifndef __func__
#define __func__ __FUNCTION__
#endif
const struct lws_plat_file_ops *fops;
const char *vpath;
lws_fop_flags_t fflags = LWS_O_RDONLY;
+#if defined(WIN32) && defined(LWS_HAVE__STAT32I64)
+ struct _stat32i64 st;
+#else
struct stat st;
+#endif
int spin = 0;
#endif
char path[256], sym[512];
goto bail;
}
#else
+#if defined(LWS_HAVE__STAT32I64)
+ if (_stat32i64(path, &st)) {
+ lwsl_info("unable to stat %s\n", path);
+ goto bail;
+ }
+#else
if (stat(path, &st)) {
lwsl_info("unable to stat %s\n", path);
goto bail;
}
#endif
+#endif
wsi->u.http.fop_fd->mod_time = (uint32_t)st.st_mtime;
fflags |= LWS_FOP_FLAG_MOD_TIME_VALID;
return 0;
if (wsi->u.http.content_remain &&
- (int)wsi->u.http.content_remain < *len)
- n = wsi->u.http.content_remain;
+ wsi->u.http.content_remain < *len)
+ n = (int)wsi->u.http.content_remain;
else
n = *len;
eff_buf.token_len = context->pt_serv_buf_size;
}
- if (eff_buf.token_len > context->pt_serv_buf_size)
+ if ((unsigned int)eff_buf.token_len > context->pt_serv_buf_size)
eff_buf.token_len = context->pt_serv_buf_size;
eff_buf.token_len = lws_ssl_capable_read(wsi,
len = lws_vfs_get_length(fops_fd);
- *buf = malloc(len);
+ *buf = malloc((size_t)len);
if (!buf)
goto bail;
#cmakedefine LWS_HAVE_SYS_CAPABILITY_H
#cmakedefine LWS_HAVE_LIBCAP
+#cmakedefine LWS_HAVE_ATOLL
+#cmakedefine LWS_HAVE__ATOI64
+#cmakedefine LWS_HAVE__STAT32I64
+
/* OpenSSL various APIs */
#cmakedefine LWS_HAVE_TLS_CLIENT_METHOD
int main(int argc, char **argv)
{
- int n = 0, m, debug_level = 7;
+ int n = 0, debug_level = 7;
#ifndef _WIN32
+ int m;
int status, syslog_options = LOG_PID | LOG_PERROR;
#endif