Mesen-SX/Lua/io.c

34 lines
1.1 KiB
C
Raw Normal View History

2019-05-12 21:18:05 -04:00
/*=========================================================================*\
* Input/Output abstraction
* LuaSocket toolkit
\*=========================================================================*/
#include "io.h"
/*=========================================================================*\
* Exported functions
\*=========================================================================*/
/*-------------------------------------------------------------------------*\
* Initializes C structure
\*-------------------------------------------------------------------------*/
2020-12-19 23:31:32 +03:00
void io_init(p_io io, p_send send, p_recv recv, p_error error, void* ctx)
{
io->send = send;
io->recv = recv;
io->error = error;
io->ctx = ctx;
2019-05-12 21:18:05 -04:00
}
/*-------------------------------------------------------------------------*\
* I/O error strings
\*-------------------------------------------------------------------------*/
2020-12-19 23:31:32 +03:00
const char* io_strerror(int err)
{
switch (err)
{
case IO_DONE: return NULL;
case IO_CLOSED: return "closed";
case IO_TIMEOUT: return "timeout";
default: return "unknown error";
}
2019-05-12 21:18:05 -04:00
}