more work porting C client to posix

This commit is contained in:
UnknownShadow200 2018-07-16 22:19:37 +10:00
parent fe3fd7396b
commit 0ebec8142a
8 changed files with 257 additions and 98 deletions

View file

@ -85,11 +85,11 @@ namespace ClassicalSharp {
return File.Exists(path);
}
public static DateTime FileGetWriteTime(string path) {
public static DateTime FileGetModifiedTime(string path) {
return File.GetLastWriteTimeUtc(path);
}
public static void FileSetWriteTime(string path, DateTime time) {
public static void FileSetModifiedTime(string path, DateTime time) {
File.SetLastWriteTimeUtc(path, time);
}

View file

@ -54,7 +54,7 @@ namespace ClassicalSharp.Textures {
return new DateTime(ticks, DateTimeKind.Utc);
} else {
string path = MakePath(url);
return Platform.FileGetWriteTime(path);
return Platform.FileGetModifiedTime(path);
}
}

View file

@ -48,13 +48,13 @@ ReturnCode Platform_DirectoryCreate(STRING_PURE String* path);
bool Platform_FileExists(STRING_PURE String* path);
typedef void Platform_EnumFilesCallback(STRING_PURE String* filename, void* obj);
ReturnCode Platform_EnumFiles(STRING_PURE String* path, void* obj, Platform_EnumFilesCallback callback);
ReturnCode Platform_FileGetWriteTime(STRING_PURE String* path, DateTime* time);
ReturnCode Platform_FileGetModifiedTime(STRING_PURE String* path, DateTime* time);
ReturnCode Platform_FileCreate(void** file, STRING_PURE String* path);
ReturnCode Platform_FileOpen(void** file, STRING_PURE String* path);
ReturnCode Platform_FileAppend(void** file, STRING_PURE String* path);
ReturnCode Platform_FileRead(void* file, UInt8* buffer, UInt32 count, UInt32* bytesRead);
ReturnCode Platform_FileWrite(void* file, UInt8* buffer, UInt32 count, UInt32* bytesWritten);
ReturnCode Platform_FileWrite(void* file, UInt8* buffer, UInt32 count, UInt32* bytesWrote);
ReturnCode Platform_FileClose(void* file);
ReturnCode Platform_FileSeek(void* file, Int32 offset, Int32 seekType);
ReturnCode Platform_FilePosition(void* file, UInt32* position);

View file

@ -4,20 +4,31 @@
#include "PackedCol.h"
#include "Drawer2D.h"
#include "Stream.h"
#include "ErrorHandler.h"
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <unistd.h>
#include <dirent.h>
#include <fcntl.h>
#include <time.h>
#include <pthread.h>
#include <sys/ioctl.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#define UNIX_EPOCH 62135596800
UChar* Platform_NewLine = "\n";
UChar Platform_DirectorySeparator = '/';
extern ReturnCode ReturnCode_FileShareViolation = 1000000000; /* TODO: not used apparently */
extern ReturnCode ReturnCode_FileNotFound = ENOENT;
extern ReturnCode ReturnCode_NotSupported = EPERM;
ReturnCode ReturnCode_FileShareViolation = 1000000000; /* TODO: not used apparently */
ReturnCode ReturnCode_FileNotFound = ENOENT;
ReturnCode ReturnCode_NotSupported = EPERM;
extern ReturnCode ReturnCode_SocketInProgess;
extern ReturnCode ReturnCode_SocketWouldBlock = EWOULDBLOCK;
ReturnCode ReturnCode_SocketWouldBlock = EWOULDBLOCK;
static void Platform_UnicodeExpand(UInt8* dst, STRING_PURE String* src) {
if (src->length > FILENAME_SIZE) ErrorHandler_Fail("String too long to expand");
@ -32,7 +43,7 @@ static void Platform_UnicodeExpand(UInt8* dst, STRING_PURE String* src) {
void Platform_Init(void);
void Platform_Free(void);
void Platform_Exit(ReturnCode code);
void Platform_Exit(ReturnCode code) { exit(code); }
STRING_PURE String Platform_GetCommandLineArgs(void);
void* Platform_MemAlloc(UInt32 numElems, UInt32 elemsSize) {
@ -57,14 +68,42 @@ void Platform_MemCpy(void* dst, void* src, UInt32 numBytes) {
memcpy(dst, src, numBytes);
}
void Platform_Log(STRING_PURE String* message);
void Platform_LogConst(const UChar* message);
#define Platform_Log1(format, a1) Platform_Log4(format, a1, NULL, NULL, NULL)
#define Platform_Log2(format, a1, a2) Platform_Log4(format, a1, a2, NULL, NULL)
#define Platform_Log3(format, a1, a2, a3) Platform_Log4(format, a1, a2, a3, NULL)
void Platform_Log4(const UChar* format, const void* a1, const void* a2, const void* a3, const void* a4);
void Platform_CurrentUTCTime(DateTime* time);
void Platform_CurrentLocalTime(DateTime* time);
void Platform_Log(STRING_PURE String* message) { puts(message->buffer); puts("\n"); }
void Platform_LogConst(const UChar* message) { puts(message); puts("\n"); }
void Platform_Log4(const UChar* format, const void* a1, const void* a2, const void* a3, const void* a4) {
UChar msgBuffer[String_BufferSize(512)];
String msg = String_InitAndClearArray(msgBuffer);
String_Format4(&msg, format, a1, a2, a3, a4);
Platform_Log(&msg);
}
void Platform_FromSysTime(DateTime* time, struct tm* sysTime) {
time->Year = sysTime->tm_year + 1900;
time->Month = sysTime->tm_mon + 1;
time->Day = sysTime->tm_mday;
time->Hour = sysTime->tm_hour;
time->Minute = sysTime->tm_min;
time->Second = sysTime->tm_sec;
time->Milli = 0;
}
void Platform_CurrentUTCTime(DateTime* time_) {
struct timeval cur; struct tm utc_time;
gettimeofday(&cur, NULL);
time_->Milli = cur.tv_usec / 1000;
gmtime_r(&cur.tv_sec, &utc_time);
Platform_FromSysTime(time_, &utc_time);
}
void Platform_CurrentLocalTime(DateTime* time_) {
struct timeval cur; struct tm loc_time;
gettimeofday(&cur, NULL);
time_->Milli = cur.tv_usec / 1000;
localtime_r(&cur.tv_sec, &loc_time);
Platform_FromSysTime(time_, &loc_time);
}
bool Platform_DirectoryExists(STRING_PURE String* path) {
UInt8 data[1024]; Platform_UnicodeExpand(data, path);
@ -75,24 +114,97 @@ bool Platform_DirectoryExists(STRING_PURE String* path) {
ReturnCode Platform_DirectoryCreate(STRING_PURE String* path) {
UInt8 data[1024]; Platform_UnicodeExpand(data, path);
/* read/write/search permissions for owner and group, and with read/search permissions for others. */
int result = mkdir(data, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
return result == 0 ? 0 : errno;
/* TODO: Is the default mode in all cases */
return mkdir(data, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) == -1 ? errno : 0;
}
bool Platform_FileExists(STRING_PURE String* path);
typedef void Platform_EnumFilesCallback(STRING_PURE String* filename, void* obj);
ReturnCode Platform_EnumFiles(STRING_PURE String* path, void* obj, Platform_EnumFilesCallback callback);
ReturnCode Platform_FileGetWriteTime(STRING_PURE String* path, DateTime* time);
bool Platform_FileExists(STRING_PURE String* path) {
UInt8 data[1024]; Platform_UnicodeExpand(data, path);
struct stat sb;
return stat(data, &sb) == 0 && S_ISREG(sb.st_mode);
}
ReturnCode Platform_FileCreate(void** file, STRING_PURE String* path);
ReturnCode Platform_FileOpen(void** file, STRING_PURE String* path);
ReturnCode Platform_FileAppend(void** file, STRING_PURE String* path);
ReturnCode Platform_FileRead(void* file, UInt8* buffer, UInt32 count, UInt32* bytesRead);
ReturnCode Platform_FileWrite(void* file, UInt8* buffer, UInt32 count, UInt32* bytesWritten);
ReturnCode Platform_FileClose(void* file);
ReturnCode Platform_FileSeek(void* file, Int32 offset, Int32 seekType);
ReturnCode Platform_FilePosition(void* file, UInt32* position);
ReturnCode Platform_FileLength(void* file, UInt32* length);
ReturnCode Platform_EnumFiles(STRING_PURE String* path, void* obj, Platform_EnumFilesCallback callback) {
UInt8 data[1024]; Platform_UnicodeExpand(data, path);
DIR* dirPtr = opendir(data);
if (dirPtr == NULL) return errno;
struct dirent* entry;
while (entry = readdir(dirPtr)) {
puts(ep->d_name);
/* TODO: does this also include subdirectories */
}
int result = errno; /* return code from readdir */
closedir(dirPtr);
return result;
}
ReturnCode Platform_FileGetModifiedTime(STRING_PURE String* path, DateTime* time) {
UInt8 data[1024]; Platform_UnicodeExpand(data, path);
struct stat sb;
if (stat(data, &sb) == -1) return errno;
DateTime_FromTotalMs(time, UNIX_EPOCH + sb.st_mtime);
return 0;
}
ReturnCode Platform_FileDo(void** file, STRING_PURE String* path, int mode) {
UInt8 data[1024]; Platform_UnicodeExpand(data, path);
*file = open(data, mode);
return *file == -1 ? errno : 0;
}
ReturnCode Platform_FileOpen(void** file, STRING_PURE String* path) {
return Platform_FileDo(file, path, O_RDONLY);
}
ReturnCode Platform_FileCreate(void** file, STRING_PURE String* path) {
return Platform_FileDo(file, path, O_WRONLY | O_CREAT | O_TRUNC);
}
ReturnCode Platform_FileAppend(void** file, STRING_PURE String* path) {
ReturnCode code = Platform_FileDo(file, path, O_WRONLY | O_CREAT);
if (code != 0) return code;
return Platform_FileSeek(*file, 0, STREAM_SEEKFROM_END);
}
ReturnCode Platform_FileRead(void* file, UInt8* buffer, UInt32 count, UInt32* bytesRead) {
ssize_t bytes = read((int)file, buffer, count);
if (bytes == -1) { *bytesRead = 0; return errno; }
*bytesRead = bytes; return 0;
}
ReturnCode Platform_FileWrite(void* file, UInt8* buffer, UInt32 count, UInt32* bytesWrote) {
ssize_t bytes = write((int)file, buffer, count);
if (bytes == -1) { *bytesWrote = 0; return errno; }
*bytesWrote = bytes; return 0;
}
ReturnCode Platform_FileClose(void* file) {
return close((int)file) == -1 ? errno : 0;
}
ReturnCode Platform_FileSeek(void* file, Int32 offset, Int32 seekType) {
int mode = -1;
switch (seekType) {
case STREAM_SEEKFROM_BEGIN: mode = SEEK_SET; break;
case STREAM_SEEKFROM_CURRENT: mode = SEEK_CUR; break;
case STREAM_SEEKFROM_END: mode = SEEK_END; break;
}
return lseek((int)file, offset, mode) == -1 ? errno : 0;
}
ReturnCode Platform_FilePosition(void* file, UInt32* position) {
off_t pos = lseek((int)file, 0, SEEK_CUR);
if (pos == -1) { *position = -1; return errno; }
*position = pos; return 0;
}
ReturnCode Platform_FileLength(void* file, UInt32* length) {
struct stat st;
if (fstat((int)file, &st) == -1) { *length = -1; return errno; }
*length = st.st_size; return 0;
}
void Platform_ThreadSleep(UInt32 milliseconds);
typedef void Platform_ThreadFunc(void);
@ -121,16 +233,77 @@ void Platform_SetBitmap(struct Bitmap* bmp);
struct Size2D Platform_TextDraw(struct DrawTextArgs* args, Int32 x, Int32 y, PackedCol col);
void Platform_ReleaseBitmap(void);
void Platform_SocketCreate(void** socket);
ReturnCode Platform_SocketAvailable(void* socket, UInt32* available);
ReturnCode Platform_SocketSetBlocking(void* socket, bool blocking);
ReturnCode Platform_SocketGetError(void* socket, ReturnCode* result);
void Platform_SocketCreate(void** socketResult) {
*socketResult = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (*socketResult == -1) {
ErrorHandler_FailWithCode(errno, "Failed to create socket");
}
}
ReturnCode Platform_SocketConnect(void* socket, STRING_PURE String* ip, Int32 port);
ReturnCode Platform_SocketRead(void* socket, UInt8* buffer, UInt32 count, UInt32* modified);
ReturnCode Platform_SocketWrite(void* socket, UInt8* buffer, UInt32 count, UInt32* modified);
ReturnCode Platform_SocketClose(void* socket);
ReturnCode Platform_SocketSelect(void* socket, Int32 selectMode, bool* success);
ReturnCode Platform_SocketAvailable(void* socket, UInt32* available) {
return ioctl(socket, FIONREAD, available);
}
ReturnCode Platform_SocketSetBlocking(void* socket, bool blocking) {
Int32 blocking_raw = blocking ? 0 : -1;
return ioctl(socket, FIONBIO, &blocking_raw);
}
ReturnCode Platform_SocketGetError(void* socket, ReturnCode* result) {
Int32 resultSize = sizeof(ReturnCode);
return getsockopt(socket, SOL_SOCKET, SO_ERROR, result, &resultSize);
}
ReturnCode Platform_SocketConnect(void* socket, STRING_PURE String* ip, Int32 port) {
struct sockaddr_in addr;
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = inet_addr(ip->buffer);
addr.sin_port = htons((UInt16)port);
ReturnCode result = connect(socket, (struct sockaddr*)(&addr), sizeof(addr));
return result == -1 ? errno : 0;
}
ReturnCode Platform_SocketRead(void* socket, UInt8* buffer, UInt32 count, UInt32* modified) {
Int32 recvCount = recv(socket, buffer, count, 0);
if (recvCount != -1) { *modified = recvCount; return 0; }
*modified = 0; return errno;
}
ReturnCode Platform_SocketWrite(void* socket, UInt8* buffer, UInt32 count, UInt32* modified) {
Int32 sentCount = send(socket, buffer, count, 0);
if (sentCount != -1) { *modified = sentCount; return 0; }
*modified = 0; return errno;
}
ReturnCode Platform_SocketClose(void* socket) {
ReturnCode result = 0;
ReturnCode result1 = shutdown(socket, SHUT_RDWR);
if (result1 == -1) result = errno;
ReturnCode result2 = closesocket(socket);
if (result2 == -1) result = errno;
return result;
}
ReturnCode Platform_SocketSelect(void* socket, Int32 selectMode, bool* success) {
void* args[2]; args[0] = (void*)1; args[1] = socket;
struct timeval time = { 0 };
Int32 selectCount;
if (selectMode == SOCKET_SELECT_READ) {
selectCount = select(1, &args, NULL, NULL, &time);
} else if (selectMode == SOCKET_SELECT_WRITE) {
selectCount = select(1, NULL, &args, NULL, &time);
} else if (selectMode == SOCKET_SELECT_ERROR) {
selectCount = select(1, NULL, NULL, &args, &time);
} else {
selectCount = -1;
}
if (selectCount != -1) { *success = args[0] != 0; return 0; }
*success = false; return errno;
}
void Platform_HttpInit(void);
ReturnCode Platform_HttpMakeRequest(struct AsyncRequest* request, void** handle);

View file

@ -352,31 +352,35 @@ void Stream_WriteU32_BE(struct Stream* stream, UInt32 value) {
*#########################################################################################################################*/
bool Stream_ReadUtf8Char(struct Stream* stream, UInt16* codepoint) {
UInt32 read = 0;
UInt8 header;
ReturnCode code = stream->Read(stream, &header, 1, &read);
UInt8 data;
ReturnCode result = stream->Read(stream, &data, 1, &read);
if (read == 0) return false; /* end of stream */
if (!ErrorHandler_Check(code)) { Stream_Fail(stream, code, "reading utf8 from"); }
if (!ErrorHandler_Check(result)) { Stream_Fail(stream, result, "reading utf8 from"); }
/* Header byte is just the raw codepoint (common case) */
if (header <= 0x7F) { *codepoint = header; return true; }
if (data <= 0x7F) { *codepoint = data; return true; }
/* Header byte encodes variable number of following bytes */
/* The remaining bits of the header form first part of the character */
Int32 byteCount = 0, i;
for (i = 7; i >= 0; i--) {
if ((header & (1 << i)) != 0) {
if ((data & (1 << i)) != 0) {
byteCount++;
header &= (UInt8)~(1 << i);
data &= (UInt8)~(1 << i);
} else {
break;
}
}
*codepoint = header;
*codepoint = data;
for (i = 0; i < byteCount - 1; i++) {
result = stream->Read(stream, &data, 1, &read);
if (read == 0) return false; /* end of stream */
if (!ErrorHandler_Check(result)) { Stream_Fail(stream, result, "reading utf8 from"); }
*codepoint <<= 6;
/* Top two bits of each are always 10 */
*codepoint |= (UInt16)(Stream_ReadU8(stream) & 0x3F);
*codepoint |= (UInt16)(data & 0x3F);
}
return true;
}

View file

@ -345,7 +345,7 @@ void TextureCache_GetLastModified(STRING_PURE String* url, DateTime* time) {
DateTime_FromTotalMs(time, ticks / TEXCACHE_TICKS_PER_MS);
} else {
String path; TexCache_InitAndMakePath(url);
ReturnCode result = Platform_FileGetWriteTime(&path, time);
ReturnCode result = Platform_FileGetModifiedTime(&path, time);
ErrorHandler_CheckOrFail(result, "TextureCache - get file last modified time")
}
}

View file

@ -202,13 +202,12 @@ ReturnCode Platform_EnumFiles(STRING_PURE String* path, void* obj, Platform_Enum
callback(&filename, obj);
} while (FindNextFileW(find, &data));
/* get return code from FindNextFile before closing find handle */
ReturnCode code = GetLastError();
ReturnCode code = GetLastError(); /* return code from FindNextFile */
FindClose(find);
return code == ERROR_NO_MORE_FILES ? 0 : code;
}
ReturnCode Platform_FileGetWriteTime(STRING_PURE String* path, DateTime* time) {
ReturnCode Platform_FileGetModifiedTime(STRING_PURE String* path, DateTime* time) {
void* file;
ReturnCode result = Platform_FileOpen(&file, path);
if (result != 0) return result;
@ -219,7 +218,6 @@ ReturnCode Platform_FileGetWriteTime(STRING_PURE String* path, DateTime* time) {
FileTimeToSystemTime(&writeTime, &sysTime);
Platform_FromSysTime(time, &sysTime);
} else {
Platform_MemSet(time, 0, sizeof(DateTime));
result = GetLastError();
}
@ -228,25 +226,21 @@ ReturnCode Platform_FileGetWriteTime(STRING_PURE String* path, DateTime* time) {
}
ReturnCode Platform_FileDo(void** file, STRING_PURE String* path, DWORD access, DWORD createMode) {
WCHAR data[512]; Platform_UnicodeExpand(data, path);
*file = CreateFileW(data, access, FILE_SHARE_READ, NULL, createMode, 0, NULL);
return *file != INVALID_HANDLE_VALUE ? 0 : GetLastError();
}
ReturnCode Platform_FileOpen(void** file, STRING_PURE String* path) {
WCHAR data[512]; Platform_UnicodeExpand(data, path);
HANDLE handle = CreateFileW(data, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
*file = (void*)handle;
return handle != INVALID_HANDLE_VALUE ? 0 : GetLastError();
return Platform_FileDo(file, path, GENERIC_READ, OPEN_EXISTING);
}
ReturnCode Platform_FileCreate(void** file, STRING_PURE String* path) {
WCHAR data[512]; Platform_UnicodeExpand(data, path);
HANDLE handle = CreateFileW(data, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
*file = (void*)handle;
return handle != INVALID_HANDLE_VALUE ? 0 : GetLastError();
return Platform_FileDo(file, path, GENERIC_WRITE, CREATE_ALWAYS);
}
ReturnCode Platform_FileAppend(void** file, STRING_PURE String* path) {
WCHAR data[512]; Platform_UnicodeExpand(data, path);
HANDLE handle = CreateFileW(data, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
*file = (void*)handle;
if (handle == INVALID_HANDLE_VALUE) return GetLastError();
ReturnCode code = Platform_FileDo(file, path, GENERIC_WRITE, OPEN_ALWAYS);
if (code != 0) return code;
return Platform_FileSeek(*file, 0, STREAM_SEEKFROM_END);
}
@ -255,8 +249,8 @@ ReturnCode Platform_FileRead(void* file, UInt8* buffer, UInt32 count, UInt32* by
return success ? 0 : GetLastError();
}
ReturnCode Platform_FileWrite(void* file, UInt8* buffer, UInt32 count, UInt32* bytesWritten) {
BOOL success = WriteFile((HANDLE)file, buffer, count, bytesWritten, NULL);
ReturnCode Platform_FileWrite(void* file, UInt8* buffer, UInt32 count, UInt32* bytesWrote) {
BOOL success = WriteFile((HANDLE)file, buffer, count, bytesWrote, NULL);
return success ? 0 : GetLastError();
}
@ -265,17 +259,14 @@ ReturnCode Platform_FileClose(void* file) {
}
ReturnCode Platform_FileSeek(void* file, Int32 offset, Int32 seekType) {
DWORD pos;
DWORD mode = -1;
switch (seekType) {
case STREAM_SEEKFROM_BEGIN:
pos = SetFilePointer(file, offset, NULL, FILE_BEGIN); break;
case STREAM_SEEKFROM_CURRENT:
pos = SetFilePointer(file, offset, NULL, FILE_CURRENT); break;
case STREAM_SEEKFROM_END:
pos = SetFilePointer(file, offset, NULL, FILE_END); break;
default:
ErrorHandler_Fail("Invalid SeekType provided when seeking file");
case STREAM_SEEKFROM_BEGIN: mode = FILE_BEGIN; break;
case STREAM_SEEKFROM_CURRENT: mode = FILE_CURRENT; break;
case STREAM_SEEKFROM_END: mode = FILE_END; break;
}
DWORD pos = SetFilePointer(file, offset, NULL, mode);
return pos == INVALID_SET_FILE_POINTER ? GetLastError() : 0;
}
@ -511,26 +502,20 @@ ReturnCode Platform_SocketConnect(void* socket, STRING_PURE String* ip, Int32 po
addr.sin_addr.s_addr = inet_addr(ip->buffer);
addr.sin_port = htons((UInt16)port);
ReturnCode result = connect(socket, (SOCKADDR*)(&addr), sizeof(addr));
ReturnCode result = connect(socket, (struct sockaddr*)(&addr), sizeof(addr));
return result == SOCKET_ERROR ? WSAGetLastError() : 0;
}
ReturnCode Platform_SocketRead(void* socket, UInt8* buffer, UInt32 count, UInt32* modified) {
Int32 recvCount = recv(socket, buffer, count, 0);
if (recvCount == SOCKET_ERROR) {
*modified = 0; return WSAGetLastError();
} else {
*modified = recvCount; return 0;
}
if (recvCount == SOCKET_ERROR) { *modified = recvCount; return 0; }
*modified = 0; return WSAGetLastError();
}
ReturnCode Platform_SocketWrite(void* socket, UInt8* buffer, UInt32 count, UInt32* modified) {
Int32 sentCount = send(socket, buffer, count, 0);
if (sentCount == SOCKET_ERROR) {
*modified = 0; return WSAGetLastError();
} else {
*modified = sentCount; return 0;
}
if (sentCount != SOCKET_ERROR) { *modified = sentCount; return 0; }
*modified = 0; return WSAGetLastError();
}
ReturnCode Platform_SocketClose(void* socket) {
@ -545,7 +530,7 @@ ReturnCode Platform_SocketClose(void* socket) {
ReturnCode Platform_SocketSelect(void* socket, Int32 selectMode, bool* success) {
void* args[2]; args[0] = (void*)1; args[1] = socket;
TIMEVAL time = { 0 };
struct timeval time = { 0 };
Int32 selectCount;
if (selectMode == SOCKET_SELECT_READ) {
@ -558,11 +543,8 @@ ReturnCode Platform_SocketSelect(void* socket, Int32 selectMode, bool* success)
selectCount = SOCKET_ERROR;
}
if (selectCount == SOCKET_ERROR) {
*success = false; return WSAGetLastError();
} else {
*success = args[0] != 0; return 0;
}
if (selectCount != SOCKET_ERROR) { *success = args[0] != 0; return 0; }
*success = false; return WSAGetLastError();
}
HINTERNET hInternet;

View file

@ -570,7 +570,7 @@ void Window_ProcessEvents(void) {
String_Clear(&clipboard_paste_text);
UInt16 codepoint;
while (Stream_ReadUtf8Char(&mem, &codepoint)) {
String_append(&clipboard_paste_text, Convert_UnicodeToCP437(codepoint));
String_Append(&clipboard_paste_text, Convert_UnicodeToCP437(codepoint));
}
}
XFree(data);