Fix CMake lib dependencies for crypto/SSL. Also ensure websockets work on macOS for both client and server.master
@@ -151,7 +151,7 @@ add_executable( | |||||
src/packages/string/IZ_string.h | src/packages/string/IZ_string.h | ||||
src/packages/io/IZ_io.c | src/packages/io/IZ_io.c | ||||
src/packages/io/IZ_io.h | src/packages/io/IZ_io.h | ||||
src/packages/log/IZ_log.c src/packages/log/IZ_log.h src/packages/timer/IZ_timer.c src/packages/timer/IZ_timer.h) | |||||
src/packages/log/IZ_log.c src/packages/log/IZ_log.h src/packages/timer/IZ_timer.c src/packages/timer/IZ_timer.h src/packages/compat/IZ_windows.h) | |||||
if (WIN32) | if (WIN32) | ||||
target_link_libraries( | target_link_libraries( | ||||
@@ -173,9 +173,8 @@ elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") | |||||
SDL2_image | SDL2_image | ||||
SDL2_ttf | SDL2_ttf | ||||
portmidi | portmidi | ||||
# FIXME | |||||
# libcrypto | |||||
# libssl | |||||
crypto | |||||
ssl | |||||
websockets | websockets | ||||
) | ) | ||||
endif() | endif() | ||||
@@ -265,8 +264,8 @@ add_executable( | |||||
dependencies/sqlite/sqlite3.c | dependencies/sqlite/sqlite3.c | ||||
dependencies/minIni/dev/minIni.h | dependencies/minIni/dev/minIni.h | ||||
dependencies/minIni/dev/minIni.c | dependencies/minIni/dev/minIni.c | ||||
src/packages/log/IZ_intercept.h | |||||
src/packages/log/IZ_intercept.c | |||||
src/packages/log/IZ_intercept.h | |||||
src/packages/log/IZ_intercept.c | |||||
src/packages/server/main.c | src/packages/server/main.c | ||||
src/packages/server/IZ_app.c | src/packages/server/IZ_app.c | ||||
src/packages/server/IZ_app.h | src/packages/server/IZ_app.h | ||||
@@ -287,17 +286,32 @@ add_executable( | |||||
src/packages/string/IZ_string.h | src/packages/string/IZ_string.h | ||||
src/packages/io/IZ_io.c | src/packages/io/IZ_io.c | ||||
src/packages/io/IZ_io.h | src/packages/io/IZ_io.h | ||||
src/packages/log/IZ_log.c src/packages/log/IZ_log.h src/packages/timer/IZ_timer.c src/packages/timer/IZ_timer.h) | |||||
target_link_libraries( | |||||
server | |||||
SDL2main | |||||
SDL2 | |||||
libcrypto | |||||
libssl | |||||
websockets | |||||
src/packages/log/IZ_log.c | |||||
src/packages/log/IZ_log.h | |||||
src/packages/timer/IZ_timer.c | |||||
src/packages/timer/IZ_timer.h | |||||
) | ) | ||||
if (WIN32) | |||||
target_link_libraries( | |||||
server | |||||
SDL2main | |||||
SDL2 | |||||
libcrypto | |||||
libssl | |||||
websockets | |||||
) | |||||
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") | |||||
target_link_libraries( | |||||
server | |||||
SDL2main | |||||
SDL2 | |||||
crypto | |||||
ssl | |||||
websockets | |||||
) | |||||
endif() | |||||
add_executable( | add_executable( | ||||
asset-inv | asset-inv | ||||
dependencies/minIni/dev/minIni.h | dependencies/minIni/dev/minIni.h | ||||
@@ -0,0 +1,8 @@ | |||||
#ifndef IZ_WINDOWS_H | |||||
#define IZ_WINDOWS_H | |||||
#ifndef IZ_WIN64 | |||||
typedef int errno_t; | |||||
#endif | |||||
#endif //IZ_WINDOWS_H |
@@ -200,16 +200,18 @@ void IZ_ConfigLoadGuid(IZ_ConfigItem* item, const char* config_path) { | |||||
default_value = *((SDL_GUID *) item->default_value); | default_value = *((SDL_GUID *) item->default_value); | ||||
} | } | ||||
char buffer[128]; | |||||
char buffer[33]; | |||||
if (item->transformer.deserialize && item->transformer.serialize) { | if (item->transformer.deserialize && item->transformer.serialize) { | ||||
IZ_ConfigDeserializeGUID* deserialize = item->transformer.deserialize; | IZ_ConfigDeserializeGUID* deserialize = item->transformer.deserialize; | ||||
IZ_ConfigSerializeGUID* serialize = item->transformer.serialize; | IZ_ConfigSerializeGUID* serialize = item->transformer.serialize; | ||||
const char serialized_default_value[128]; | |||||
const char serialized_default_value[33]; | |||||
serialize(default_value, serialized_default_value); | serialize(default_value, serialized_default_value); | ||||
ini_gets(item->section, item->key, serialized_default_value, buffer, 128, config_path); | |||||
ini_gets(item->section, item->key, serialized_default_value, buffer, 33, config_path); | |||||
raw_value = deserialize(buffer); | raw_value = deserialize(buffer); | ||||
} else { | } else { | ||||
ini_gets(item->section, item->key, "00000000000000000000000000000000", buffer, 128, config_path); | |||||
char guid_string_default_value[33]; | |||||
SDL_GUIDToString(default_value, guid_string_default_value, 33); | |||||
ini_gets(item->section, item->key, guid_string_default_value, buffer, 33, config_path); | |||||
raw_value = SDL_GUIDFromString(buffer); | raw_value = SDL_GUIDFromString(buffer); | ||||
} | } | ||||
IZ_ConfigEnsureValidGuid(item, raw_value, default_value); | IZ_ConfigEnsureValidGuid(item, raw_value, default_value); | ||||
@@ -1,5 +1,15 @@ | |||||
#include "IZ_app_input.h" | #include "IZ_app_input.h" | ||||
#ifdef IZ_WIN64 | |||||
#define IZ_DEBUG_CONNECT SDLK_PAGEUP | |||||
#define IZ_DEBUG_DISCONNECT SDLK_PAGEDOWN | |||||
#define IZ_DEBUG_SEND_MESSAGE SDLK_INSERT | |||||
#elif IZ_MACOS | |||||
#define IZ_DEBUG_CONNECT SDLK_EQUALS | |||||
#define IZ_DEBUG_DISCONNECT SDLK_MINUS | |||||
#define IZ_DEBUG_SEND_MESSAGE SDLK_BACKSLASH | |||||
#endif | |||||
IZ_ProcedureResult IZ_AppHandleSDLEvents(struct IZ_App* app) { | IZ_ProcedureResult IZ_AppHandleSDLEvents(struct IZ_App* app) { | ||||
SDL_Event e; | SDL_Event e; | ||||
IZ_InputState* input_state = IZ_AppGetInputState(app); | IZ_InputState* input_state = IZ_AppGetInputState(app); | ||||
@@ -10,8 +20,9 @@ IZ_ProcedureResult IZ_AppHandleSDLEvents(struct IZ_App* app) { | |||||
return 1; | return 1; | ||||
} | } | ||||
#ifdef IZ_DEBUG | |||||
if (e.type == SDL_KEYDOWN) { | if (e.type == SDL_KEYDOWN) { | ||||
if (e.key.keysym.sym == SDLK_PAGEUP) { | |||||
if (e.key.keysym.sym == IZ_DEBUG_CONNECT) { | |||||
IZ_NetClientConnect( | IZ_NetClientConnect( | ||||
net_state, | net_state, | ||||
(IZ_WSClientInitializeParams) { | (IZ_WSClientInitializeParams) { | ||||
@@ -20,12 +31,13 @@ IZ_ProcedureResult IZ_AppHandleSDLEvents(struct IZ_App* app) { | |||||
.port = 42069, | .port = 42069, | ||||
} | } | ||||
); | ); | ||||
} else if (e.key.keysym.sym == SDLK_PAGEDOWN) { | |||||
} else if (e.key.keysym.sym == IZ_DEBUG_DISCONNECT) { | |||||
IZ_NetClientDisconnect(net_state); | IZ_NetClientDisconnect(net_state); | ||||
} else if (e.key.keysym.sym == SDLK_INSERT) { | |||||
} else if (e.key.keysym.sym == IZ_DEBUG_SEND_MESSAGE) { | |||||
IZ_NetClientSendTextMessage(net_state, "hello", 5); | IZ_NetClientSendTextMessage(net_state, "hello", 5); | ||||
} | } | ||||
} | } | ||||
#endif | |||||
IZ_InputHandleSDLEvents(input_state, e); | IZ_InputHandleSDLEvents(input_state, e); | ||||
} | } | ||||
@@ -16,7 +16,7 @@ int IZ_sprintf(char* buffer, size_t buffer_size, const char* format, ...) { | |||||
#endif | #endif | ||||
} | } | ||||
errno_t IZ_fopen(struct _iobuf** file, const char* filename, const char* mode) { | |||||
errno_t IZ_fopen(FILE** file, const char* filename, const char* mode) { | |||||
#if defined IZ_WIN64 | #if defined IZ_WIN64 | ||||
return fopen_s(file, filename, mode); | return fopen_s(file, filename, mode); | ||||
#else | #else | ||||
@@ -24,11 +24,3 @@ errno_t IZ_fopen(struct _iobuf** file, const char* filename, const char* mode) { | |||||
return *file == NULL ? 1 : 0; | return *file == NULL ? 1 : 0; | ||||
#endif | #endif | ||||
} | } | ||||
errno_t IZ_vsprintf(char* buffer, size_t buffer_size, const char* format, va_list args) { | |||||
#if defined IZ_WIN64 | |||||
return vsprintf_s(buffer, buffer_size, format, args); | |||||
#else | |||||
return vsprintf(buffer, format, args); | |||||
#endif | |||||
} |
@@ -3,11 +3,10 @@ | |||||
#include <stdio.h> | #include <stdio.h> | ||||
#include <stdarg.h> | #include <stdarg.h> | ||||
#include "../compat/IZ_windows.h" | |||||
int IZ_sprintf(char*, size_t, const char*, ...); | int IZ_sprintf(char*, size_t, const char*, ...); | ||||
errno_t IZ_fopen(struct _iobuf**, const char*, const char*); | |||||
errno_t IZ_vsprintf(char* buffer, size_t buffer_size, const char* format, va_list); | |||||
errno_t IZ_fopen(FILE**, const char*, const char*); | |||||
#endif | #endif |
@@ -25,8 +25,7 @@ char* IZ_MIDIGetNoteName(unsigned char midi_note) { | |||||
unsigned char IZ_MIDIGetNoteFromName(const char* name) { | unsigned char IZ_MIDIGetNoteFromName(const char* name) { | ||||
char name_copy[8]; | char name_copy[8]; | ||||
IZ_memcpy(name_copy, 8, name, 8); | |||||
IZ_strlwr(name_copy, 8); | |||||
IZ_strlwr(name_copy, name, 8); | |||||
unsigned char octave; | unsigned char octave; | ||||
const char base_pitch_name[] = "c d ef g a b"; | const char base_pitch_name[] = "c d ef g a b"; | ||||
@@ -4,7 +4,8 @@ errno_t IZ_memcpy(void* const dest, const rsize_t dest_size, const void* const s | |||||
#if defined IZ_WIN64 | #if defined IZ_WIN64 | ||||
return memcpy_s(dest, dest_size, source, source_size); | return memcpy_s(dest, dest_size, source, source_size); | ||||
#else | #else | ||||
return memcpy(dest, source, dest_size - 1); | |||||
memcpy(dest, source, dest_size); | |||||
return 0; | |||||
#endif | #endif | ||||
} | } | ||||
@@ -12,15 +13,26 @@ errno_t IZ_strcat(char* dest, rsize_t source_size, const char* source) { | |||||
#if defined IZ_WIN64 | #if defined IZ_WIN64 | ||||
return strcat_s(dest, source_size, source); | return strcat_s(dest, source_size, source); | ||||
#else | #else | ||||
return strcat(dest, source); | |||||
strcat(dest, source); | |||||
return 0; | |||||
#endif | #endif | ||||
} | } | ||||
errno_t IZ_strlwr(char* str, rsize_t str_size) { | |||||
errno_t IZ_strlwr(char* dest, const char* str, rsize_t str_size) { | |||||
#if defined IZ_WIN64 | #if defined IZ_WIN64 | ||||
return _strlwr_s(str, str_size); | |||||
errno_t copy_result = memcpy_s(dest, str_size, str, str_size); | |||||
if (copy_result) { | |||||
return copy_result; | |||||
} | |||||
return _strlwr_s(dest, str_size); | |||||
#else | #else | ||||
return _strlwr(str); | |||||
memcpy(dest, str, str_size -1); | |||||
for (unsigned int i = 0; i < str_size; i += 1) { | |||||
if ('A' <= dest[i] && dest[i] <= 'Z') { | |||||
dest[i] += 0x20; | |||||
} | |||||
} | |||||
return 0; | |||||
#endif | #endif | ||||
} | } | ||||
@@ -2,12 +2,13 @@ | |||||
#define IZ_STRING_H | #define IZ_STRING_H | ||||
#include <string.h> | #include <string.h> | ||||
#include "../compat/IZ_windows.h" | |||||
errno_t IZ_memcpy(void*, rsize_t, const void*, rsize_t); | errno_t IZ_memcpy(void*, rsize_t, const void*, rsize_t); | ||||
errno_t IZ_strcat(char*, rsize_t, const char*); | errno_t IZ_strcat(char*, rsize_t, const char*); | ||||
errno_t IZ_strlwr(char*, rsize_t); | |||||
errno_t IZ_strlwr(char*, const char*, rsize_t); | |||||
void* IZ_memset(void*, int, rsize_t); | void* IZ_memset(void*, int, rsize_t); | ||||