This commit is contained in:
Jupeyy 2021-06-15 03:24:23 +02:00
parent 0393ac0f88
commit 9dfea5511a
13 changed files with 30 additions and 55 deletions

View file

@ -1465,14 +1465,14 @@ set_src(BASE GLOB_RECURSE src/base
color.h color.h
detect.h detect.h
dynamic.h dynamic.h
hash.c hash.cpp
hash.h hash.h
hash_bundled.c hash_bundled.cpp
hash_ctxt.h hash_ctxt.h
hash_libtomcrypt.c hash_libtomcrypt.cpp
hash_openssl.c hash_openssl.cpp
math.h math.h
system.c system.cpp
system.h system.h
tl/algorithm.h tl/algorithm.h
tl/allocator.h tl/allocator.h
@ -1482,9 +1482,9 @@ set_src(BASE GLOB_RECURSE src/base
tl/sorted_array.h tl/sorted_array.h
tl/string.h tl/string.h
tl/threading.h tl/threading.h
unicode/confusables.c unicode/confusables.cpp
unicode/confusables_data.h unicode/confusables_data.h
unicode/tolower.c unicode/tolower.cpp
unicode/tolower_data.h unicode/tolower_data.h
vmath.h vmath.h
) )

View file

@ -3,10 +3,6 @@
#include <stddef.h> #include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
enum enum
{ {
SHA256_DIGEST_LENGTH = 256 / 8, SHA256_DIGEST_LENGTH = 256 / 8,
@ -38,11 +34,6 @@ int md5_comp(MD5_DIGEST digest1, MD5_DIGEST digest2);
static const SHA256_DIGEST SHA256_ZEROED = {{0}}; static const SHA256_DIGEST SHA256_ZEROED = {{0}};
static const MD5_DIGEST MD5_ZEROED = {{0}}; static const MD5_DIGEST MD5_ZEROED = {{0}};
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
inline bool operator==(const SHA256_DIGEST &that, const SHA256_DIGEST &other) inline bool operator==(const SHA256_DIGEST &that, const SHA256_DIGEST &other)
{ {
return sha256_comp(that, other) == 0; return sha256_comp(that, other) == 0;
@ -59,6 +50,5 @@ inline bool operator!=(const MD5_DIGEST &that, const MD5_DIGEST &other)
{ {
return !(that == other); return !(that == other);
} }
#endif
#endif // BASE_HASH_H #endif // BASE_HASH_H

View file

@ -6,7 +6,7 @@
void md5_update(MD5_CTX *ctxt, const void *data, size_t data_len) void md5_update(MD5_CTX *ctxt, const void *data, size_t data_len)
{ {
md5_append(ctxt, data, data_len); md5_append(ctxt, (const md5_byte_t *)data, data_len);
} }
MD5_DIGEST md5_finish(MD5_CTX *ctxt) MD5_DIGEST md5_finish(MD5_CTX *ctxt)

View file

@ -12,10 +12,6 @@
#include <engine/external/md5/md5.h> #include <engine/external/md5/md5.h>
#endif #endif
#ifdef __cplusplus
extern "C" {
#endif
#if defined(CONF_OPENSSL) #if defined(CONF_OPENSSL)
// SHA256_CTX is defined in <openssl/sha.h> // SHA256_CTX is defined in <openssl/sha.h>
#else #else
@ -37,8 +33,4 @@ void md5_init(MD5_CTX *ctxt);
void md5_update(MD5_CTX *ctxt, const void *data, size_t data_len); void md5_update(MD5_CTX *ctxt, const void *data, size_t data_len);
MD5_DIGEST md5_finish(MD5_CTX *ctxt); MD5_DIGEST md5_finish(MD5_CTX *ctxt);
#ifdef __cplusplus
}
#endif
#endif // BASE_HASH_CTXT_H #endif // BASE_HASH_CTXT_H

View file

@ -126,7 +126,7 @@ static void sha_init(sha256_state *md)
static void sha_process(sha256_state *md, const void *src, u32 inlen) static void sha_process(sha256_state *md, const void *src, u32 inlen)
{ {
const u32 block_size = 64; const u32 block_size = 64;
const unsigned char *in = src; const unsigned char *in = (const unsigned char *)src;
while(inlen > 0) while(inlen > 0)
{ {

View file

@ -14,7 +14,7 @@
#include <sys/types.h> #include <sys/types.h>
#if defined(CONF_WEBSOCKETS) #if defined(CONF_WEBSOCKETS)
#include "engine/shared/websockets.h" #include <engine/shared/websockets.h>
#endif #endif
#if defined(CONF_FAMILY_UNIX) #if defined(CONF_FAMILY_UNIX)
@ -68,9 +68,7 @@
#include <sys/filio.h> #include <sys/filio.h>
#endif #endif
#if defined(__cplusplus)
extern "C" { extern "C" {
#endif
IOHANDLE io_stdin() IOHANDLE io_stdin()
{ {
@ -164,7 +162,7 @@ static void logger_file(const char *line, void *user)
static void logger_stdout_sync(const char *line, void *user) static void logger_stdout_sync(const char *line, void *user)
{ {
size_t length = str_length(line); size_t length = str_length(line);
wchar_t *wide = malloc(length * sizeof(*wide)); wchar_t *wide = (wchar_t *)malloc(length * sizeof(*wide));
const char *p = line; const char *p = line;
int wlen = 0; int wlen = 0;
HANDLE console; HANDLE console;
@ -437,7 +435,7 @@ static void aio_handle_free_and_unlock(ASYNCIO *aio) RELEASE(aio->lock)
static void aio_thread(void *user) static void aio_thread(void *user)
{ {
ASYNCIO *aio = user; ASYNCIO *aio = (ASYNCIO *)user;
lock_wait(aio->lock); lock_wait(aio->lock);
while(1) while(1)
@ -497,7 +495,7 @@ static void aio_thread(void *user)
ASYNCIO *aio_new(IOHANDLE io) ASYNCIO *aio_new(IOHANDLE io)
{ {
ASYNCIO *aio = malloc(sizeof(*aio)); ASYNCIO *aio = (ASYNCIO *)malloc(sizeof(*aio));
if(!aio) if(!aio)
{ {
return 0; return 0;
@ -507,7 +505,7 @@ ASYNCIO *aio_new(IOHANDLE io)
sphore_init(&aio->sphore); sphore_init(&aio->sphore);
aio->thread = 0; aio->thread = 0;
aio->buffer = malloc(ASYNC_BUFSIZE); aio->buffer = (unsigned char *)malloc(ASYNC_BUFSIZE);
if(!aio->buffer) if(!aio->buffer)
{ {
sphore_destroy(&aio->sphore); sphore_destroy(&aio->sphore);
@ -591,7 +589,7 @@ void aio_write_unlocked(ASYNCIO *aio, const void *buffer, unsigned size)
unsigned int new_written = buffer_len(aio) + size + 1; unsigned int new_written = buffer_len(aio) + size + 1;
unsigned int next_size = next_buffer_size(aio->buffer_size, new_written); unsigned int next_size = next_buffer_size(aio->buffer_size, new_written);
unsigned int next_len = 0; unsigned int next_len = 0;
unsigned char *next_buffer = malloc(next_size); unsigned char *next_buffer = (unsigned char *)malloc(next_size);
struct BUFFERS buffers; struct BUFFERS buffers;
buffer_ptrs(aio, &buffers); buffer_ptrs(aio, &buffers);
@ -696,7 +694,7 @@ static unsigned long __stdcall thread_run(void *user)
#error not implemented #error not implemented
#endif #endif
{ {
struct THREAD_RUN *data = user; struct THREAD_RUN *data = (THREAD_RUN *)user;
void (*threadfunc)(void *) = data->threadfunc; void (*threadfunc)(void *) = data->threadfunc;
void *u = data->u; void *u = data->u;
free(data); free(data);
@ -706,7 +704,7 @@ static unsigned long __stdcall thread_run(void *user)
void *thread_init(void (*threadfunc)(void *), void *u, const char *name) void *thread_init(void (*threadfunc)(void *), void *u, const char *name)
{ {
struct THREAD_RUN *data = malloc(sizeof(*data)); struct THREAD_RUN *data = (THREAD_RUN *)malloc(sizeof(*data));
data->threadfunc = threadfunc; data->threadfunc = threadfunc;
data->u = u; data->u = u;
#if defined(CONF_FAMILY_UNIX) #if defined(CONF_FAMILY_UNIX)
@ -1145,7 +1143,7 @@ void net_addr_str_v6(const unsigned short ip[8], int port, char *buffer, int buf
} }
else else
{ {
char *colon = i == 0 || i == longest_seq_start + longest_seq_len ? "" : ":"; const char *colon = (i == 0 || i == longest_seq_start + longest_seq_len) ? "" : ":";
w += str_format(buffer + w, buffer_size - w, "%s%x", colon, ip[i]); w += str_format(buffer + w, buffer_size - w, "%s%x", colon, ip[i]);
} }
} }
@ -1731,14 +1729,14 @@ int net_udp_recv(NETSOCKET sock, NETADDR *addr, void *buffer, int maxsize, MMSGS
{ {
socklen_t fromlen = sizeof(struct sockaddr_in); socklen_t fromlen = sizeof(struct sockaddr_in);
bytes = recvfrom(sock.ipv4sock, (char *)buffer, maxsize, 0, (struct sockaddr *)&sockaddrbuf, &fromlen); bytes = recvfrom(sock.ipv4sock, (char *)buffer, maxsize, 0, (struct sockaddr *)&sockaddrbuf, &fromlen);
*data = buffer; *data = (unsigned char *)buffer;
} }
if(bytes <= 0 && sock.ipv6sock >= 0) if(bytes <= 0 && sock.ipv6sock >= 0)
{ {
socklen_t fromlen = sizeof(struct sockaddr_in6); socklen_t fromlen = sizeof(struct sockaddr_in6);
bytes = recvfrom(sock.ipv6sock, (char *)buffer, maxsize, 0, (struct sockaddr *)&sockaddrbuf, &fromlen); bytes = recvfrom(sock.ipv6sock, (char *)buffer, maxsize, 0, (struct sockaddr *)&sockaddrbuf, &fromlen);
*data = buffer; *data = (unsigned char *)buffer;
} }
#endif #endif
@ -1747,8 +1745,8 @@ int net_udp_recv(NETSOCKET sock, NETADDR *addr, void *buffer, int maxsize, MMSGS
{ {
socklen_t fromlen = sizeof(struct sockaddr); socklen_t fromlen = sizeof(struct sockaddr);
struct sockaddr_in *sockaddrbuf_in = (struct sockaddr_in *)&sockaddrbuf; struct sockaddr_in *sockaddrbuf_in = (struct sockaddr_in *)&sockaddrbuf;
bytes = websocket_recv(sock.web_ipv4sock, buffer, maxsize, sockaddrbuf_in, fromlen); bytes = websocket_recv(sock.web_ipv4sock, (unsigned char *)buffer, maxsize, sockaddrbuf_in, fromlen);
*data = buffer; *data = (unsigned char *)buffer;
sockaddrbuf_in->sin_family = AF_WEBSOCKET_INET; sockaddrbuf_in->sin_family = AF_WEBSOCKET_INET;
} }
#endif #endif
@ -2912,7 +2910,7 @@ static int byteval(const char *byte, unsigned char *dst)
int str_hex_decode(void *dst, int dst_size, const char *src) int str_hex_decode(void *dst, int dst_size, const char *src)
{ {
unsigned char *cdst = dst; unsigned char *cdst = (unsigned char *)dst;
int slen = str_length(src); int slen = str_length(src);
int len = slen / 2; int len = slen / 2;
int i; int i;
@ -3602,7 +3600,7 @@ void secure_random_fill(void *bytes, unsigned length)
dbg_break(); dbg_break();
} }
#if defined(CONF_FAMILY_WINDOWS) #if defined(CONF_FAMILY_WINDOWS)
if(!CryptGenRandom(secure_random_data.provider, length, bytes)) if(!CryptGenRandom(secure_random_data.provider, length, (unsigned char *)bytes))
{ {
dbg_msg("secure", "CryptGenRandom failed, last_error=%ld", GetLastError()); dbg_msg("secure", "CryptGenRandom failed, last_error=%ld", GetLastError());
dbg_break(); dbg_break();
@ -3650,7 +3648,4 @@ int secure_rand_below(int below)
} }
} }
} }
#if defined(__cplusplus)
} }
#endif

View file

@ -27,7 +27,7 @@
#include <sys/socket.h> #include <sys/socket.h>
#endif #endif
#ifdef __cplusplus #if defined(__cplusplus)
extern "C" { extern "C" {
#endif #endif
@ -2219,7 +2219,7 @@ int secure_rand(void);
*/ */
int secure_rand_below(int below); int secure_rand_below(int below);
#ifdef __cplusplus #if defined(__cplusplus)
} }
#endif #endif

View file

@ -9,14 +9,16 @@ static int compul(const void *a, const void *b)
return ul_a->upper - ul_b->upper; return ul_a->upper - ul_b->upper;
} }
extern "C" {
int str_utf8_tolower(int code) int str_utf8_tolower(int code)
{ {
struct UPPER_LOWER key; struct UPPER_LOWER key;
struct UPPER_LOWER *res; struct UPPER_LOWER *res;
key.upper = code; key.upper = code;
res = bsearch(&key, tolower, NUM_TOLOWER, sizeof(struct UPPER_LOWER), compul); res = (UPPER_LOWER *)bsearch(&key, tolower, NUM_TOLOWER, sizeof(struct UPPER_LOWER), compul);
if(res == NULL) if(res == NULL)
return code; return code;
return res->lower; return res->lower;
} }
}

View file

@ -14,8 +14,6 @@
#endif #endif
#include <libwebsockets.h> #include <libwebsockets.h>
extern "C" {
#include "websockets.h" #include "websockets.h"
// not sure why would anyone need more than one but well... // not sure why would anyone need more than one but well...
@ -307,5 +305,5 @@ int websocket_fd_set(int socket, fd_set *set)
} }
return max; return max;
} }
}
#endif #endif

View file

@ -2622,8 +2622,6 @@ void CMenus::OnStateChange(int NewState, int OldState)
} }
} }
extern "C" void font_debug_render();
void CMenus::OnRender() void CMenus::OnRender()
{ {
if(Client()->State() != IClient::STATE_ONLINE && Client()->State() != IClient::STATE_DEMOPLAYBACK) if(Client()->State() != IClient::STATE_ONLINE && Client()->State() != IClient::STATE_DEMOPLAYBACK)