2004-08-20 01:49:14 -04:00
|
|
|
#define BUF_SIZE (8 * 1024)
|
|
|
|
|
2004-12-10 22:21:08 -05:00
|
|
|
#ifndef WIN32
|
|
|
|
#define INVALID_HANDLE_VALUE -1
|
|
|
|
#endif
|
|
|
|
|
2004-10-31 14:36:42 -05:00
|
|
|
typedef enum {
|
|
|
|
PORT_READ,
|
|
|
|
PORT_RECV,
|
|
|
|
PORT_WRITE,
|
|
|
|
PORT_SPECIAL
|
|
|
|
} PORT_MODE;
|
2004-08-12 23:40:28 -04:00
|
|
|
|
2004-08-12 17:36:36 -04:00
|
|
|
typedef struct {
|
|
|
|
CELL header;
|
2004-08-16 19:29:07 -04:00
|
|
|
PORT_MODE type;
|
2004-10-31 14:36:42 -05:00
|
|
|
bool closed;
|
2004-12-10 21:46:42 -05:00
|
|
|
F_FIXNUM fd;
|
2004-11-27 22:26:05 -05:00
|
|
|
CELL buffer;
|
2004-08-19 19:06:43 -04:00
|
|
|
|
|
|
|
/* top of buffer */
|
|
|
|
CELL buf_fill;
|
|
|
|
/* current read/write position */
|
|
|
|
CELL buf_pos;
|
|
|
|
|
2004-08-15 21:50:44 -04:00
|
|
|
/* tagged partial line used by read_line_fd */
|
|
|
|
CELL line;
|
2004-08-16 20:42:30 -04:00
|
|
|
/* is it ready to be returned? */
|
2004-08-19 20:48:41 -04:00
|
|
|
/* with the read# IO_TASK, this means that the operation is done */
|
2004-08-16 20:42:30 -04:00
|
|
|
bool line_ready;
|
2004-08-19 19:06:43 -04:00
|
|
|
|
2004-08-19 20:48:41 -04:00
|
|
|
/* count for read# */
|
2004-12-10 21:46:42 -05:00
|
|
|
F_FIXNUM count;
|
2004-08-19 20:48:41 -04:00
|
|
|
|
2004-08-15 22:45:08 -04:00
|
|
|
/* tagged client info used by accept_fd */
|
|
|
|
CELL client_host;
|
|
|
|
CELL client_port;
|
2004-08-16 19:29:07 -04:00
|
|
|
/* untagged fd of accepted connection */
|
2004-08-15 22:45:08 -04:00
|
|
|
CELL client_socket;
|
2004-08-20 21:16:47 -04:00
|
|
|
|
|
|
|
/* a pending I/O error or F */
|
|
|
|
CELL io_error;
|
2004-12-10 21:46:42 -05:00
|
|
|
} F_PORT;
|
|
|
|
|
|
|
|
F_PORT* untag_port(CELL tagged);
|
|
|
|
F_PORT* port(PORT_MODE type, CELL fd);
|
|
|
|
void init_line_buffer(F_PORT* port, F_FIXNUM count);
|
|
|
|
void fixup_port(F_PORT* port);
|
|
|
|
void collect_port(F_PORT* port);
|
|
|
|
void postpone_io_error(F_PORT* port, const char* func);
|
2004-08-20 21:16:47 -04:00
|
|
|
void io_error(const char* func);
|
2004-12-10 21:46:42 -05:00
|
|
|
void pending_io_error(F_PORT* port);
|
2004-09-02 21:51:19 -04:00
|
|
|
void primitive_pending_io_error(void);
|