mirror of
https://github.com/lunarmodules/luasocket.git
synced 2025-07-19 07:19:58 +02:00
Moving on to beta2.
This commit is contained in:
22
src/io.h
22
src/io.h
@ -17,14 +17,15 @@
|
||||
#include <stdio.h>
|
||||
#include <lua.h>
|
||||
|
||||
#include "timeout.h"
|
||||
|
||||
/* IO error codes */
|
||||
enum {
|
||||
IO_DONE, /* operation completed successfully */
|
||||
IO_RETRY, /* please try again */
|
||||
IO_TIMEOUT, /* operation timed out */
|
||||
IO_CLOSED, /* the connection has been closed */
|
||||
IO_REFUSED, /* transfer has been refused */
|
||||
IO_ERROR /* something else wrong... */
|
||||
IO_CLIPPED, /* maxium bytes count reached */
|
||||
IO_USER /* last element in enum is user custom error */
|
||||
};
|
||||
|
||||
/* interface to send function */
|
||||
@ -33,7 +34,13 @@ typedef int (*p_send) (
|
||||
const char *data, /* pointer to buffer with data to send */
|
||||
size_t count, /* number of bytes to send from buffer */
|
||||
size_t *sent, /* number of bytes sent uppon return */
|
||||
int timeout /* number of miliseconds left for transmission */
|
||||
p_tm tm /* timeout control */
|
||||
);
|
||||
|
||||
/* returns an error string */
|
||||
typedef const char *(*p_geterr) (
|
||||
void *ctx, /* context needed by geterror */
|
||||
int code /* error code */
|
||||
);
|
||||
|
||||
/* interface to recv function */
|
||||
@ -42,7 +49,7 @@ typedef int (*p_recv) (
|
||||
char *data, /* pointer to buffer where data will be writen */
|
||||
size_t count, /* number of bytes to receive into buffer */
|
||||
size_t *got, /* number of bytes received uppon return */
|
||||
int timeout /* number of miliseconds left for transmission */
|
||||
p_tm tm /* timeout control */
|
||||
);
|
||||
|
||||
/* IO driver definition */
|
||||
@ -50,11 +57,12 @@ typedef struct t_io_ {
|
||||
void *ctx; /* context needed by send/recv */
|
||||
p_send send; /* send function pointer */
|
||||
p_recv recv; /* receive function pointer */
|
||||
p_geterr geterr; /* receive function pointer */
|
||||
} t_io;
|
||||
typedef t_io *p_io;
|
||||
|
||||
const char *io_strerror(int code);
|
||||
void io_pusherror(lua_State *L, int code);
|
||||
void io_init(p_io io, p_send send, p_recv recv, void *ctx);
|
||||
void io_pusherror(lua_State *L, p_io io, int code);
|
||||
void io_init(p_io io, p_send send, p_recv recv, p_geterr geterr, void *ctx);
|
||||
|
||||
#endif /* IO_H */
|
||||
|
Reference in New Issue
Block a user