Moving on to beta2.

This commit is contained in:
Diego Nehab
2004-07-01 03:32:09 +00:00
parent 7aaba59909
commit 7115c12fbc
16 changed files with 391 additions and 443 deletions

View File

@ -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 */