Bladeren bron

Update code for macOS

Fix CMake lib dependencies for crypto/SSL. Also ensure websockets work on macOS for both client and server.
master
TheoryOfNekomata 1 jaar geleden
bovenliggende
commit
0dbe2342dc
9 gewijzigde bestanden met toevoegingen van 81 en 42 verwijderingen
  1. +29
    -15
      CMakeLists.txt
  2. +8
    -0
      src/packages/compat/IZ_windows.h
  3. +6
    -4
      src/packages/config/IZ_config.c
  4. +15
    -3
      src/packages/game/IZ_app_input.c
  5. +1
    -9
      src/packages/io/IZ_io.c
  6. +2
    -3
      src/packages/io/IZ_io.h
  7. +1
    -2
      src/packages/midi/IZ_midi.c
  8. +17
    -5
      src/packages/string/IZ_string.c
  9. +2
    -1
      src/packages/string/IZ_string.h

+ 29
- 15
CMakeLists.txt Bestand weergeven

@@ -151,7 +151,7 @@ add_executable(
src/packages/string/IZ_string.h
src/packages/io/IZ_io.c
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)
target_link_libraries(
@@ -173,9 +173,8 @@ elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
SDL2_image
SDL2_ttf
portmidi
# FIXME
# libcrypto
# libssl
crypto
ssl
websockets
)
endif()
@@ -265,8 +264,8 @@ add_executable(
dependencies/sqlite/sqlite3.c
dependencies/minIni/dev/minIni.h
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/IZ_app.c
src/packages/server/IZ_app.h
@@ -287,17 +286,32 @@ add_executable(
src/packages/string/IZ_string.h
src/packages/io/IZ_io.c
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(
asset-inv
dependencies/minIni/dev/minIni.h


+ 8
- 0
src/packages/compat/IZ_windows.h Bestand weergeven

@@ -0,0 +1,8 @@
#ifndef IZ_WINDOWS_H
#define IZ_WINDOWS_H

#ifndef IZ_WIN64
typedef int errno_t;
#endif

#endif //IZ_WINDOWS_H

+ 6
- 4
src/packages/config/IZ_config.c Bestand weergeven

@@ -200,16 +200,18 @@ void IZ_ConfigLoadGuid(IZ_ConfigItem* item, const char* config_path) {
default_value = *((SDL_GUID *) item->default_value);
}

char buffer[128];
char buffer[33];
if (item->transformer.deserialize && item->transformer.serialize) {
IZ_ConfigDeserializeGUID* deserialize = item->transformer.deserialize;
IZ_ConfigSerializeGUID* serialize = item->transformer.serialize;
const char serialized_default_value[128];
const char serialized_default_value[33];
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);
} 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);
}
IZ_ConfigEnsureValidGuid(item, raw_value, default_value);


+ 15
- 3
src/packages/game/IZ_app_input.c Bestand weergeven

@@ -1,5 +1,15 @@
#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) {
SDL_Event e;
IZ_InputState* input_state = IZ_AppGetInputState(app);
@@ -10,8 +20,9 @@ IZ_ProcedureResult IZ_AppHandleSDLEvents(struct IZ_App* app) {
return 1;
}

#ifdef IZ_DEBUG
if (e.type == SDL_KEYDOWN) {
if (e.key.keysym.sym == SDLK_PAGEUP) {
if (e.key.keysym.sym == IZ_DEBUG_CONNECT) {
IZ_NetClientConnect(
net_state,
(IZ_WSClientInitializeParams) {
@@ -20,12 +31,13 @@ IZ_ProcedureResult IZ_AppHandleSDLEvents(struct IZ_App* app) {
.port = 42069,
}
);
} else if (e.key.keysym.sym == SDLK_PAGEDOWN) {
} else if (e.key.keysym.sym == IZ_DEBUG_DISCONNECT) {
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);
}
}
#endif

IZ_InputHandleSDLEvents(input_state, e);
}


+ 1
- 9
src/packages/io/IZ_io.c Bestand weergeven

@@ -16,7 +16,7 @@ int IZ_sprintf(char* buffer, size_t buffer_size, const char* format, ...) {
#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
return fopen_s(file, filename, mode);
#else
@@ -24,11 +24,3 @@ errno_t IZ_fopen(struct _iobuf** file, const char* filename, const char* mode) {
return *file == NULL ? 1 : 0;
#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
}

+ 2
- 3
src/packages/io/IZ_io.h Bestand weergeven

@@ -3,11 +3,10 @@

#include <stdio.h>
#include <stdarg.h>
#include "../compat/IZ_windows.h"

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

+ 1
- 2
src/packages/midi/IZ_midi.c Bestand weergeven

@@ -25,8 +25,7 @@ char* IZ_MIDIGetNoteName(unsigned char midi_note) {

unsigned char IZ_MIDIGetNoteFromName(const char* name) {
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;
const char base_pitch_name[] = "c d ef g a b";


+ 17
- 5
src/packages/string/IZ_string.c Bestand weergeven

@@ -4,7 +4,8 @@ errno_t IZ_memcpy(void* const dest, const rsize_t dest_size, const void* const s
#if defined IZ_WIN64
return memcpy_s(dest, dest_size, source, source_size);
#else
return memcpy(dest, source, dest_size - 1);
memcpy(dest, source, dest_size);
return 0;
#endif
}

@@ -12,15 +13,26 @@ errno_t IZ_strcat(char* dest, rsize_t source_size, const char* source) {
#if defined IZ_WIN64
return strcat_s(dest, source_size, source);
#else
return strcat(dest, source);
strcat(dest, source);
return 0;
#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
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
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
}



+ 2
- 1
src/packages/string/IZ_string.h Bestand weergeven

@@ -2,12 +2,13 @@
#define IZ_STRING_H

#include <string.h>
#include "../compat/IZ_windows.h"

errno_t IZ_memcpy(void*, rsize_t, const void*, rsize_t);

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);



Laden…
Annuleren
Opslaan