Fixed incompatabilities between GCC and MSCV

Build errors have been fixed, but there are build warnings remaining about unsafe conversions, because Visual C++'s network conversion functions have a differing return type to mine. To be fixed in the future.
This commit is contained in:
Unknown 2017-05-28 18:09:29 +01:00
parent ae61464aee
commit 5778310798
8 changed files with 35 additions and 29 deletions

View File

@ -41,7 +41,7 @@ namespace fr
* *
* @param header_end_pos The position in 'body' of the end of the header * @param header_end_pos The position in 'body' of the end of the header
*/ */
void parse_header(ssize_t header_end_pos); void parse_header(int32_t header_end_pos);
/*! /*!
* Parses the POST data from the body * Parses the POST data from the body
@ -64,7 +64,7 @@ namespace fr
//State //State
bool header_ended; bool header_ended;
ssize_t last_parsed_character; int32_t last_parsed_character;
size_t content_length; size_t content_length;
}; };

View File

@ -41,7 +41,7 @@ namespace fr
* *
* @param header_end_pos The position in 'body' of the end of the header * @param header_end_pos The position in 'body' of the end of the header
*/ */
void parse_header(ssize_t header_end_pos); void parse_header(int32_t header_end_pos);
//State //State
bool header_ended; bool header_ended;

View File

@ -28,6 +28,9 @@
#endif #endif
#ifdef __GNUC__
#define htonll(x) ((1==htonl(1)) ? (x) : ((uint64_t)htonl((x) & 0xFFFFFFFF) << 32) | htonl((x) >> 32)) #define htonll(x) ((1==htonl(1)) ? (x) : ((uint64_t)htonl((x) & 0xFFFFFFFF) << 32) | htonl((x) >> 32))
#define ntohll(x) ((1==ntohl(1)) ? (x) : ((uint64_t)ntohl((x) & 0xFFFFFFFF) << 32) | ntohl((x) >> 32)) #define ntohll(x) ((1==ntohl(1)) ? (x) : ((uint64_t)ntohl((x) & 0xFFFFFFFF) << 32) | ntohl((x) >> 32))
@ -66,6 +69,8 @@ inline double ntohd(double val)
memcpy(&val, &ret, sizeof(val)); memcpy(&val, &ret, sizeof(val));
return val; return val;
} }
#endif
inline void *get_sin_addr(struct sockaddr *sa) inline void *get_sin_addr(struct sockaddr *sa)
{ {
if(sa->sa_family == AF_INET) if(sa->sa_family == AF_INET)

View File

@ -53,6 +53,7 @@ namespace fr
*/ */
bool load_ca_certs_from_memory(const std::string &ca_certs) bool load_ca_certs_from_memory(const std::string &ca_certs)
{ {
std::cerr << "Note: load_ca_certs_from_memory() seems to be broken. Please use load_ca_certs_from_file() until this is resolved." << std::endl;
int error = mbedtls_x509_crt_parse(&cacert, (const unsigned char *)ca_certs.c_str(), ca_certs.size()); int error = mbedtls_x509_crt_parse(&cacert, (const unsigned char *)ca_certs.c_str(), ca_certs.size());
if(error < 0) if(error < 0)
{ {

View File

@ -52,7 +52,7 @@ namespace fr
return true; return true;
} }
void HttpRequest::parse_header(ssize_t header_end_pos) void HttpRequest::parse_header(int32_t header_end_pos)
{ {
//Split the header into lines //Split the header into lines
size_t line = 0; size_t line = 0;
@ -74,7 +74,7 @@ namespace fr
//Store content length value if it exists //Store content length value if it exists
auto length_header_iter = header_data.find("content-length"); auto length_header_iter = header_data.find("content-length");
if(length_header_iter != header_data.end()) if(length_header_iter != header_data.end())
content_length = std::stoull(length_header_iter->second); content_length = (size_t)std::stoull(length_header_iter->second);
} }
std::string HttpRequest::construct(const std::string &host) const std::string HttpRequest::construct(const std::string &host) const

View File

@ -62,7 +62,7 @@ namespace fr
return response; return response;
} }
void HttpResponse::parse_header(ssize_t header_end_pos) void HttpResponse::parse_header(int32_t header_end_pos)
{ {
//Split the header into lines //Split the header into lines
size_t line = 0; size_t line = 0;

View File

@ -83,7 +83,7 @@ namespace fr
if(!connected()) if(!connected())
return Socket::Disconnected; return Socket::Disconnected;
ssize_t bytes_remaining = buffer_size; int32_t bytes_remaining = buffer_size;
size_t bytes_read = 0; size_t bytes_read = 0;
while(bytes_remaining > 0) while(bytes_remaining > 0)
{ {

View File

@ -25,7 +25,7 @@ namespace fr
size_t sent = 0; size_t sent = 0;
while(sent < size) while(sent < size)
{ {
ssize_t status = ::send(socket_descriptor, data + sent, size - sent, 0); int32_t status = ::send(socket_descriptor, data + sent, size - sent, 0);
if(status > 0) if(status > 0)
{ {
sent += status; sent += status;
@ -53,7 +53,7 @@ namespace fr
received = 0; received = 0;
//Read RECV_CHUNK_SIZE bytes into the recv buffer //Read RECV_CHUNK_SIZE bytes into the recv buffer
ssize_t status = ::recv(socket_descriptor, (char*)data, buffer_size, 0); int32_t status = ::recv(socket_descriptor, (char*)data, buffer_size, 0);
if(status > 0) if(status > 0)
{ {