1 /*=========================================================================*\
2 * Input/Output abstraction
3 * LuaSocket toolkit
4 *
5 * RCS ID: $Id: io.c,v 1.6 2005/09/29 06:11:41 diego Exp $
6 \*=========================================================================*/
7 #include "io.h"
8 
9 /*=========================================================================*\
10 * Exported functions
11 \*=========================================================================*/
12 /*-------------------------------------------------------------------------*\
13 * Initializes C structure
14 \*-------------------------------------------------------------------------*/
io_init(p_io io,p_send send,p_recv recv,p_error error,void * ctx)15 void io_init(p_io io, p_send send, p_recv recv, p_error error, void *ctx) {
16     io->send = send;
17     io->recv = recv;
18     io->error = error;
19     io->ctx = ctx;
20 }
21 
22 /*-------------------------------------------------------------------------*\
23 * I/O error strings
24 \*-------------------------------------------------------------------------*/
io_strerror(int err)25 const char *io_strerror(int err) {
26     switch (err) {
27         case IO_DONE: return NULL;
28         case IO_CLOSED: return "closed";
29         case IO_TIMEOUT: return "timeout";
30         default: return "unknown error";
31     }
32 }
33