deprecated qse_ubi_t and introduced qse_httpd_hnd_t

This commit is contained in:
hyung-hwan 2014-09-16 14:14:51 +00:00
parent 3a30d67411
commit 94f015ea98
19 changed files with 195 additions and 330 deletions

View File

@ -234,9 +234,6 @@ QSE_EXPORT qse_fio_hnd_t qse_fio_gethandle (
const qse_fio_t* fio const qse_fio_t* fio
); );
QSE_EXPORT qse_ubi_t qse_fio_gethandleasubi (
const qse_fio_t* fio
);
/** /**
* The qse_fio_seek() function changes the current file position. * The qse_fio_seek() function changes the current file position.

View File

@ -167,11 +167,6 @@ QSE_EXPORT qse_nwio_hnd_t qse_nwio_gethandle (
const qse_nwio_t* nwio const qse_nwio_t* nwio
); );
QSE_EXPORT qse_ubi_t qse_nwio_gethandleasubi (
const qse_nwio_t* nwio
);
QSE_EXPORT qse_cmgr_t* qse_nwio_getcmgr ( QSE_EXPORT qse_cmgr_t* qse_nwio_getcmgr (
qse_nwio_t* nwio qse_nwio_t* nwio
); );

View File

@ -299,16 +299,6 @@ QSE_EXPORT qse_pio_hnd_t qse_pio_gethandle (
qse_pio_hid_t hid /**< handle ID */ qse_pio_hid_t hid /**< handle ID */
); );
/**
* The qse_pio_gethandleasubi() function gets a pipe handle wrapped
* in the #qse_ubi_t type.
* @return pipe handle
*/
QSE_EXPORT qse_ubi_t qse_pio_gethandleasubi (
const qse_pio_t* pio, /**< pio object */
qse_pio_hid_t hid /**< handle ID */
);
/** /**
* The qse_pio_getchild() function gets a process handle. * The qse_pio_getchild() function gets a process handle.
* @return process handle * @return process handle

View File

@ -201,10 +201,6 @@ QSE_EXPORT qse_sio_hnd_t qse_sio_gethandle (
const qse_sio_t* sio const qse_sio_t* sio
); );
QSE_EXPORT qse_ubi_t qse_sio_gethandleasubi (
const qse_sio_t* sio
);
/** /**
* The qse_sio_getpath() returns the file path used to open the stream. * The qse_sio_getpath() returns the file path used to open the stream.
* It returns #QSE_NULL if #QSE_SIO_HANDLE was on or #QSE_SIO_KEEPPATH * It returns #QSE_NULL if #QSE_SIO_HANDLE was on or #QSE_SIO_KEEPPATH

View File

@ -36,6 +36,8 @@ typedef struct qse_httpd_client_t qse_httpd_client_t;
typedef struct qse_httpd_dns_t qse_httpd_dns_t; typedef struct qse_httpd_dns_t qse_httpd_dns_t;
typedef struct qse_httpd_urs_t qse_httpd_urs_t; typedef struct qse_httpd_urs_t qse_httpd_urs_t;
typedef qse_intptr_t qse_httpd_hnd_t;
enum qse_httpd_errnum_t enum qse_httpd_errnum_t
{ {
QSE_HTTPD_ENOERR, QSE_HTTPD_ENOERR,
@ -87,8 +89,6 @@ enum qse_httpd_trait_t
}; };
typedef enum qse_httpd_trait_t qse_httpd_trait_t; typedef enum qse_httpd_trait_t qse_httpd_trait_t;
typedef struct qse_httpd_mod_t qse_httpd_mod_t; typedef struct qse_httpd_mod_t qse_httpd_mod_t;
typedef int (*qse_httpd_mod_load_t) ( typedef int (*qse_httpd_mod_load_t) (
@ -149,7 +149,7 @@ struct qse_httpd_peer_t
{ {
qse_nwad_t nwad; qse_nwad_t nwad;
qse_nwad_t local; /* local side address facing the peer */ qse_nwad_t local; /* local side address facing the peer */
qse_ubi_t handle; qse_httpd_hnd_t handle;
}; };
enum qse_httpd_mux_mask_t enum qse_httpd_mux_mask_t
@ -161,7 +161,7 @@ enum qse_httpd_mux_mask_t
typedef int (*qse_httpd_muxcb_t) ( typedef int (*qse_httpd_muxcb_t) (
qse_httpd_t* httpd, qse_httpd_t* httpd,
void* mux, void* mux,
qse_ubi_t handle, qse_httpd_hnd_t handle,
int mask, /* ORed of qse_httpd_mux_mask_t */ int mask, /* ORed of qse_httpd_mux_mask_t */
void* cbarg void* cbarg
); );
@ -244,7 +244,7 @@ typedef void (*qse_httpd_urs_close_t) (
typedef int (*qse_httpd_urs_recv_t) ( typedef int (*qse_httpd_urs_recv_t) (
qse_httpd_t* httpd, qse_httpd_t* httpd,
qse_httpd_urs_t* urs, qse_httpd_urs_t* urs,
qse_ubi_t handle qse_httpd_hnd_t handle
); );
typedef int (*qse_httpd_urs_send_t) ( typedef int (*qse_httpd_urs_send_t) (
@ -318,12 +318,12 @@ struct qse_httpd_scb_t
{ {
void* (*open) (qse_httpd_t* httpd, qse_httpd_muxcb_t muxcb); void* (*open) (qse_httpd_t* httpd, qse_httpd_muxcb_t muxcb);
void (*close) (qse_httpd_t* httpd, void* mux); void (*close) (qse_httpd_t* httpd, void* mux);
int (*addhnd) (qse_httpd_t* httpd, void* mux, qse_ubi_t handle, int mask, void* cbarg); int (*addhnd) (qse_httpd_t* httpd, void* mux, qse_httpd_hnd_t handle, int mask, void* cbarg);
int (*delhnd) (qse_httpd_t* httpd, void* mux, qse_ubi_t handle); int (*delhnd) (qse_httpd_t* httpd, void* mux, qse_httpd_hnd_t handle);
int (*poll) (qse_httpd_t* httpd, void* mux, const qse_ntime_t* tmout); int (*poll) (qse_httpd_t* httpd, void* mux, const qse_ntime_t* tmout);
int (*readable) (qse_httpd_t* httpd, qse_ubi_t handle, const qse_ntime_t* tmout); int (*readable) (qse_httpd_t* httpd, qse_httpd_hnd_t handle, const qse_ntime_t* tmout);
int (*writable) (qse_httpd_t* httpd, qse_ubi_t handle, const qse_ntime_t* tmout); int (*writable) (qse_httpd_t* httpd, qse_httpd_hnd_t handle, const qse_ntime_t* tmout);
} mux; } mux;
struct struct
@ -333,17 +333,17 @@ struct qse_httpd_scb_t
int (*ropen) ( int (*ropen) (
qse_httpd_t* httpd, const qse_mchar_t* path, qse_httpd_t* httpd, const qse_mchar_t* path,
qse_ubi_t* handle); qse_httpd_hnd_t* handle);
int (*wopen) ( int (*wopen) (
qse_httpd_t* httpd, const qse_mchar_t* path, qse_httpd_t* httpd, const qse_mchar_t* path,
qse_ubi_t* handle); qse_httpd_hnd_t* handle);
void (*close) (qse_httpd_t* httpd, qse_ubi_t handle); void (*close) (qse_httpd_t* httpd, qse_httpd_hnd_t handle);
qse_ssize_t (*read) ( qse_ssize_t (*read) (
qse_httpd_t* httpd, qse_ubi_t handle, qse_httpd_t* httpd, qse_httpd_hnd_t handle,
qse_mchar_t* buf, qse_size_t len); qse_mchar_t* buf, qse_size_t len);
qse_ssize_t (*write) ( qse_ssize_t (*write) (
qse_httpd_t* httpd, qse_ubi_t handle, qse_httpd_t* httpd, qse_httpd_hnd_t handle,
const qse_mchar_t* buf, qse_size_t len); const qse_mchar_t* buf, qse_size_t len);
} file; } file;
@ -357,10 +357,10 @@ struct qse_httpd_scb_t
int (*open) ( int (*open) (
qse_httpd_t* httpd, const qse_mchar_t* path, qse_httpd_t* httpd, const qse_mchar_t* path,
qse_ubi_t* handle); qse_httpd_hnd_t* handle);
void (*close) (qse_httpd_t* httpd, qse_ubi_t handle); void (*close) (qse_httpd_t* httpd, qse_httpd_hnd_t handle);
int (*read) ( int (*read) (
qse_httpd_t* httpd, qse_ubi_t handle, qse_httpd_t* httpd, qse_httpd_hnd_t handle,
qse_httpd_dirent_t* ent); qse_httpd_dirent_t* ent);
} dir; } dir;
@ -388,7 +388,7 @@ struct qse_httpd_scb_t
qse_ssize_t (*sendfile) ( qse_ssize_t (*sendfile) (
qse_httpd_t* httpd, qse_httpd_t* httpd,
qse_httpd_client_t* client, qse_httpd_client_t* client,
qse_ubi_t handle, qse_foff_t* offset, qse_size_t count); qse_httpd_hnd_t handle, qse_foff_t* offset, qse_size_t count);
/* event notification */ /* event notification */
int (*accepted) ( int (*accepted) (
@ -403,7 +403,7 @@ struct qse_httpd_scb_t
{ {
int (*open) (qse_httpd_t* httpd, qse_httpd_dns_t* dns); int (*open) (qse_httpd_t* httpd, qse_httpd_dns_t* dns);
void (*close) (qse_httpd_t* httpd, qse_httpd_dns_t* dns); void (*close) (qse_httpd_t* httpd, qse_httpd_dns_t* dns);
int (*recv) (qse_httpd_t* httpd, qse_httpd_dns_t* dns, qse_ubi_t handle); int (*recv) (qse_httpd_t* httpd, qse_httpd_dns_t* dns, qse_httpd_hnd_t handle);
int (*send) (qse_httpd_t* httpd, qse_httpd_dns_t* dns, int (*send) (qse_httpd_t* httpd, qse_httpd_dns_t* dns,
const qse_mchar_t* name, qse_httpd_resolve_t resol, const qse_mchar_t* name, qse_httpd_resolve_t resol,
const qse_httpd_dns_server_t* dns_server, void* ctx); const qse_httpd_dns_server_t* dns_server, void* ctx);
@ -531,7 +531,7 @@ struct qse_httpd_task_trigger_t
struct struct
{ {
int mask; /* QSE_HTTPD_TASK_TRIGGER_READ | QSE_HTTPD_TASK_TRIGGER_WRITE */ int mask; /* QSE_HTTPD_TASK_TRIGGER_READ | QSE_HTTPD_TASK_TRIGGER_WRITE */
qse_ubi_t handle; qse_httpd_hnd_t handle;
} v[QSE_HTTPD_TASK_TRIGGER_MAX]; } v[QSE_HTTPD_TASK_TRIGGER_MAX];
}; };
@ -573,8 +573,8 @@ struct qse_httpd_client_t
QSE_HTTPD_MATE_HDR; QSE_HTTPD_MATE_HDR;
/* == PUBLIC == */ /* == PUBLIC == */
qse_ubi_t handle; qse_httpd_hnd_t handle;
qse_ubi_t handle2; qse_httpd_hnd_t handle2;
qse_nwad_t remote_addr; qse_nwad_t remote_addr;
qse_nwad_t local_addr; qse_nwad_t local_addr;
qse_nwad_t orgdst_addr; qse_nwad_t orgdst_addr;
@ -649,7 +649,7 @@ struct qse_httpd_server_t
qse_httpd_server_dope_t dope; qse_httpd_server_dope_t dope;
/* set by server.open callback */ /* set by server.open callback */
qse_ubi_t handle; qse_httpd_hnd_t handle;
/* private */ /* private */
qse_httpd_t* httpd; qse_httpd_t* httpd;
@ -664,7 +664,7 @@ struct qse_httpd_dns_t
QSE_HTTPD_MATE_HDR; QSE_HTTPD_MATE_HDR;
/* == PUBLIC == */ /* == PUBLIC == */
qse_ubi_t handle[5]; qse_httpd_hnd_t handle[5];
/* the number of effective slots in the handle array */ /* the number of effective slots in the handle array */
int handle_count; int handle_count;
@ -681,7 +681,7 @@ struct qse_httpd_urs_t
QSE_HTTPD_MATE_HDR; QSE_HTTPD_MATE_HDR;
/* == PUBLIC == */ /* == PUBLIC == */
qse_ubi_t handle[5]; qse_httpd_hnd_t handle[5];
int handle_count; int handle_count;
unsigned long handle_mask; unsigned long handle_mask;
void* ctx; void* ctx;

View File

@ -28,6 +28,8 @@
typedef struct qse_upxd_t qse_upxd_t; typedef struct qse_upxd_t qse_upxd_t;
typedef qse_intptr_t qse_upxd_hnd_t;
enum qse_upxd_errnum_t enum qse_upxd_errnum_t
{ {
QSE_UPXD_ENOERR, QSE_UPXD_ENOERR,
@ -52,7 +54,7 @@ typedef struct qse_upxd_session_t qse_upxd_session_t;
typedef struct qse_upxd_sock_t qse_upxd_sock_t; typedef struct qse_upxd_sock_t qse_upxd_sock_t;
struct qse_upxd_sock_t struct qse_upxd_sock_t
{ {
qse_ubi_t handle; qse_upxd_hnd_t handle;
qse_nwad_t bind; qse_nwad_t bind;
const qse_char_t* dev; const qse_char_t* dev;
qse_nwad_t from; qse_nwad_t from;
@ -89,7 +91,7 @@ struct qse_upxd_session_t
typedef int (*qse_upxd_muxcb_t) ( typedef int (*qse_upxd_muxcb_t) (
qse_upxd_t* upxd, qse_upxd_t* upxd,
void* mux, void* mux,
qse_ubi_t handle, qse_upxd_hnd_t handle,
void* cbarg void* cbarg
); );
@ -121,9 +123,9 @@ struct qse_upxd_cbs_t
void* (*open) (qse_upxd_t* upxd); void* (*open) (qse_upxd_t* upxd);
void (*close) (qse_upxd_t* upxd, void* mux); void (*close) (qse_upxd_t* upxd, void* mux);
int (*addhnd) ( int (*addhnd) (
qse_upxd_t* upxd, void* mux, qse_ubi_t handle, qse_upxd_t* upxd, void* mux, qse_upxd_hnd_t handle,
qse_upxd_muxcb_t cbfun, void* cbarg); qse_upxd_muxcb_t cbfun, void* cbarg);
int (*delhnd) (qse_upxd_t* upxd, void* mux, qse_ubi_t handle); int (*delhnd) (qse_upxd_t* upxd, void* mux, qse_upxd_hnd_t handle);
int (*poll) (qse_upxd_t* upxd, void* mux, qse_ntime_t timeout); int (*poll) (qse_upxd_t* upxd, void* mux, qse_ntime_t timeout);
} mux; } mux;
}; };

View File

@ -748,70 +748,6 @@ typedef struct qse_tmgr_t qse_tmgr_t;
# error Unsupported platform # error Unsupported platform
#endif #endif
/**
* The qse_ubi_t type defines a union type that includes most of built-in
* data types and numeric types defined in the library.
*/
union qse_ubi_t
{
char c;
unsigned char uc;
short s;
unsigned short us;
int i;
unsigned int ui;
long l;
unsigned long ul;
#if defined(QSE_SIZEOF_LONG_LONG) && (QSE_SIZEOF_LONG_LONG > 0)
long long ll;
unsigned long long ull;
#endif
float f;
double d;
#if defined(QSE_SIZEOF_LONG_DOUBLE) && (QSE_SIZEOF_LONG_DOUBLE > 0)
long double ld;
#endif
void* ptr;
qse_byte_t byte;
qse_int_t sint;
qse_uint_t uint;
qse_long_t slong;
qse_ulong_t ulong;
qse_size_t size;
qse_ssize_t ssize;
qse_word_t word;
qse_intptr_t intptr;
qse_uintptr_t uintptr;
qse_intmax_t intmax;
qse_uintmax_t uintmax;
qse_flt_t flt;
qse_char_t ch;
qse_mchar_t mch;
qse_wchar_t wch;
qse_cint_t cint;
qse_mcint_t mcint;
qse_wcint_t wcint;
qse_int8_t int8;
qse_uint8_t uint8;
qse_int16_t int16;
qse_uint16_t uint16;
qse_int32_t int32;
qse_uint32_t uint32;
#if defined(QSE_HAVE_INT64_T)
qse_int64_t int64;
qse_uint64_t uint64;
#endif
#if defined(QSE_HAVE_INT128_T)
qse_int128_t int128;
qse_uint128_t uint128;
#endif
qse_foff_t foff;
};
typedef union qse_ubi_t qse_ubi_t;
/* /*
* Note QSE_MBLEN_MAX was set to 2 when autoconf ran for _WIN32 * Note QSE_MBLEN_MAX was set to 2 when autoconf ran for _WIN32
* with mingw32. This is bad since it can't handle UTF-8. Here are * with mingw32. This is bad since it can't handle UTF-8. Here are

View File

@ -938,25 +938,6 @@ qse_fio_hnd_t qse_fio_gethandle (const qse_fio_t* fio)
return fio->handle; return fio->handle;
} }
qse_ubi_t qse_fio_gethandleasubi (const qse_fio_t* fio)
{
qse_ubi_t handle;
#if defined(_WIN32)
handle.ptr = fio->handle;
#elif defined(__OS2__)
handle.ul = fio->handle;
#elif defined(__DOS__)
handle.i = fio->handle;
#elif defined(vms) || defined(__vms)
handle.ptr = fio->handle;
#else
handle.i = fio->handle;
#endif
return handle;
}
qse_fio_off_t qse_fio_seek ( qse_fio_off_t qse_fio_seek (
qse_fio_t* fio, qse_fio_off_t offset, qse_fio_ori_t origin) qse_fio_t* fio, qse_fio_off_t offset, qse_fio_ori_t origin)
{ {

View File

@ -849,22 +849,6 @@ qse_nwio_hnd_t qse_nwio_gethandle (const qse_nwio_t* nwio)
return nwio->handle; return nwio->handle;
} }
qse_ubi_t qse_nwio_gethandleasubi (const qse_nwio_t* nwio)
{
qse_ubi_t ubi;
#if defined(_WIN32)
ubi.intptr = nwio->handle;
#elif defined(__OS2__)
ubi.i = nwio->handle;
#elif defined(__DOS__)
ubi.i = nwio->handle;
#else
ubi.i = nwio->handle;
#endif
return ubi;
}
qse_ssize_t qse_nwio_flush (qse_nwio_t* nwio) qse_ssize_t qse_nwio_flush (qse_nwio_t* nwio)
{ {
qse_ssize_t n; qse_ssize_t n;

View File

@ -1966,23 +1966,6 @@ qse_pio_hnd_t qse_pio_gethandle (const qse_pio_t* pio, qse_pio_hid_t hid)
return pio->pin[hid].handle; return pio->pin[hid].handle;
} }
qse_ubi_t qse_pio_gethandleasubi (const qse_pio_t* pio, qse_pio_hid_t hid)
{
qse_ubi_t handle;
#if defined(_WIN32)
handle.ptr = pio->pin[hid].handle;
#elif defined(__OS2__)
handle.ul = pio->pin[hid].handle;
#elif defined(__DOS__)
handle.i = pio->pin[hid].handle;
#else
handle.i = pio->pin[hid].handle;
#endif
return handle;
}
qse_pio_pid_t qse_pio_getchild (const qse_pio_t* pio) qse_pio_pid_t qse_pio_getchild (const qse_pio_t* pio)
{ {
return pio->child; return pio->child;

View File

@ -290,11 +290,6 @@ qse_sio_hnd_t qse_sio_gethandle (const qse_sio_t* sio)
return QSE_FIO_HANDLE(&sio->file); return QSE_FIO_HANDLE(&sio->file);
} }
qse_ubi_t qse_sio_gethandleasubi (const qse_sio_t* sio)
{
return qse_fio_gethandleasubi (&sio->file);
}
const qse_char_t* qse_sio_getpath (qse_sio_t* sio) const qse_char_t* qse_sio_getpath (qse_sio_t* sio)
{ {
/* this path is valid if QSE_SIO_HANDLE is off and QSE_SIO_KEEPPATH is on */ /* this path is valid if QSE_SIO_HANDLE is off and QSE_SIO_KEEPPATH is on */

View File

@ -1498,8 +1498,8 @@ static int task_main_cgi (
* writes it back to the client. so add a trigger for * writes it back to the client. so add a trigger for
* checking the data availability from the child process */ * checking the data availability from the child process */
task->trigger.v[0].mask = QSE_HTTPD_TASK_TRIGGER_READ; task->trigger.v[0].mask = QSE_HTTPD_TASK_TRIGGER_READ;
task->trigger.v[0].handle = qse_pio_gethandleasubi (&cgi->pio, QSE_PIO_OUT); task->trigger.v[0].handle = qse_pio_gethandle (&cgi->pio, QSE_PIO_OUT);
task->trigger.v[1].handle = qse_pio_gethandleasubi (&cgi->pio, QSE_PIO_IN); task->trigger.v[1].handle = qse_pio_gethandle (&cgi->pio, QSE_PIO_IN);
task->trigger.cmask = 0; task->trigger.cmask = 0;
if (cgi->reqfwdbuf) if (cgi->reqfwdbuf)

View File

@ -33,7 +33,7 @@ struct task_dir_t
qse_http_version_t version; qse_http_version_t version;
int keepalive; int keepalive;
int method; int method;
qse_ubi_t handle; qse_httpd_hnd_t handle;
}; };
typedef struct task_dseg_t task_dseg_t; typedef struct task_dseg_t task_dseg_t;
@ -47,7 +47,7 @@ struct task_dseg_t
qse_mcstr_t qpath; qse_mcstr_t qpath;
qse_mcstr_t head; qse_mcstr_t head;
qse_mcstr_t foot; qse_mcstr_t foot;
qse_ubi_t handle; qse_httpd_hnd_t handle;
qse_httpd_dirent_t dent; qse_httpd_dirent_t dent;
#define HEADER_ADDED (1 << 0) #define HEADER_ADDED (1 << 0)
@ -439,7 +439,7 @@ send_dirlist:
static qse_httpd_task_t* entask_directory_segment ( static qse_httpd_task_t* entask_directory_segment (
qse_httpd_t* httpd, qse_httpd_client_t* client, qse_httpd_t* httpd, qse_httpd_client_t* client,
qse_httpd_task_t* pred, qse_ubi_t handle, task_dir_t* dir) qse_httpd_task_t* pred, qse_httpd_hnd_t handle, task_dir_t* dir)
{ {
qse_httpd_task_t task; qse_httpd_task_t task;
task_dseg_t data; task_dseg_t data;

View File

@ -52,7 +52,7 @@ struct task_file_t
int flags; int flags;
int status; int status;
qse_htre_t* req; qse_htre_t* req;
qse_ubi_t handle; qse_httpd_hnd_t handle;
} put; } put;
} u; } u;
}; };
@ -62,7 +62,7 @@ struct task_file_t
typedef struct task_getfseg_t task_getfseg_t; typedef struct task_getfseg_t task_getfseg_t;
struct task_getfseg_t struct task_getfseg_t
{ {
qse_ubi_t handle; qse_httpd_hnd_t handle;
qse_foff_t left; qse_foff_t left;
qse_foff_t offset; qse_foff_t offset;
}; };
@ -128,7 +128,7 @@ more_work:
static qse_httpd_task_t* entask_getfseg ( static qse_httpd_task_t* entask_getfseg (
qse_httpd_t* httpd, qse_httpd_client_t* client, qse_httpd_t* httpd, qse_httpd_client_t* client,
qse_httpd_task_t* pred, qse_httpd_task_t* pred,
qse_ubi_t handle, qse_foff_t offset, qse_foff_t size) qse_httpd_hnd_t handle, qse_foff_t offset, qse_foff_t size)
{ {
qse_httpd_task_t task; qse_httpd_task_t task;
task_getfseg_t data; task_getfseg_t data;
@ -175,7 +175,7 @@ static QSE_INLINE int task_main_getfile (
{ {
task_file_t* file; task_file_t* file;
qse_httpd_task_t* x; qse_httpd_task_t* x;
qse_ubi_t handle; qse_httpd_hnd_t handle;
int fileopen = 0; int fileopen = 0;
qse_httpd_stat_t st; qse_httpd_stat_t st;
@ -267,8 +267,7 @@ static QSE_INLINE int task_main_getfile (
{ {
if (file->method == QSE_HTTP_HEAD) goto no_file_send; if (file->method == QSE_HTTP_HEAD) goto no_file_send;
x = entask_getfseg ( x = entask_getfseg (
httpd, client, x, httpd, client, x, handle,
handle,
file->u.get.range.from, file->u.get.range.from,
(file->u.get.range.to - file->u.get.range.from + 1) (file->u.get.range.to - file->u.get.range.from + 1)
); );
@ -338,7 +337,7 @@ no_file_send:
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
static int write_file (qse_httpd_t* httpd, qse_ubi_t handle, const qse_mchar_t* ptr, qse_size_t len) static int write_file (qse_httpd_t* httpd, qse_httpd_hnd_t handle, const qse_mchar_t* ptr, qse_size_t len)
{ {
qse_ssize_t n; qse_ssize_t n;
qse_size_t pos = 0; qse_size_t pos = 0;

View File

@ -293,8 +293,8 @@ static int dns_open (qse_httpd_t* httpd, qse_httpd_dns_t* dns)
httpd_xtn = qse_httpd_getxtn (httpd); httpd_xtn = qse_httpd_getxtn (httpd);
dns->handle[0].i = QSE_INVALID_SCKHND; dns->handle[0] = QSE_INVALID_SCKHND;
dns->handle[1].i = QSE_INVALID_SCKHND; dns->handle[1] = QSE_INVALID_SCKHND;
dc = (dns_ctx_t*) qse_httpd_callocmem (httpd, QSE_SIZEOF(dns_ctx_t)); dc = (dns_ctx_t*) qse_httpd_callocmem (httpd, QSE_SIZEOF(dns_ctx_t));
if (dc == NULL) goto oops; if (dc == NULL) goto oops;
@ -360,11 +360,11 @@ static int dns_open (qse_httpd_t* httpd, qse_httpd_dns_t* dns)
httpd->opt.rcb.logact (httpd, &msg); httpd->opt.rcb.logact (httpd, &msg);
} }
dns->handle[0].i = open_udp_socket (httpd, AF_INET, SOCK_DGRAM, IPPROTO_UDP); dns->handle[0] = open_udp_socket (httpd, AF_INET, SOCK_DGRAM, IPPROTO_UDP);
#if defined(AF_INET6) #if defined(AF_INET6)
dns->handle[1].i = open_udp_socket (httpd, AF_INET6, SOCK_DGRAM, IPPROTO_UDP); dns->handle[1] = open_udp_socket (httpd, AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
#endif #endif
if (!qse_isvalidsckhnd(dns->handle[0].i) && !qse_isvalidsckhnd(dns->handle[1].i)) if (!qse_isvalidsckhnd(dns->handle[0]) && !qse_isvalidsckhnd(dns->handle[1]))
{ {
goto oops; goto oops;
} }
@ -376,9 +376,9 @@ static int dns_open (qse_httpd_t* httpd, qse_httpd_dns_t* dns)
if (dc->skadlen >= 0) if (dc->skadlen >= 0)
{ {
if (nwad.type == QSE_NWAD_IN4) if (nwad.type == QSE_NWAD_IN4)
dc->dns_socket = dns->handle[0].i; dc->dns_socket = dns->handle[0];
else else
dc->dns_socket = dns->handle[1].i; dc->dns_socket = dns->handle[1];
} }
else else
{ {
@ -386,16 +386,16 @@ static int dns_open (qse_httpd_t* httpd, qse_httpd_dns_t* dns)
} }
dns->handle_count = 2; dns->handle_count = 2;
if (qse_isvalidsckhnd(dns->handle[0].i)) dns->handle_mask |= (1 << 0); if (qse_isvalidsckhnd(dns->handle[0])) dns->handle_mask |= (1 << 0);
if (qse_isvalidsckhnd(dns->handle[1].i)) dns->handle_mask |= (1 << 1); if (qse_isvalidsckhnd(dns->handle[1])) dns->handle_mask |= (1 << 1);
dns->ctx = dc; dns->ctx = dc;
return 0; return 0;
oops: oops:
if (qse_isvalidsckhnd(dns->handle[0].i)) qse_closesckhnd (dns->handle[0].i); if (qse_isvalidsckhnd(dns->handle[0])) qse_closesckhnd (dns->handle[0]);
if (qse_isvalidsckhnd(dns->handle[1].i)) qse_closesckhnd (dns->handle[1].i); if (qse_isvalidsckhnd(dns->handle[1])) qse_closesckhnd (dns->handle[1]);
if (dc) qse_httpd_freemem (httpd, dc); if (dc) qse_httpd_freemem (httpd, dc);
return -1; return -1;
@ -444,8 +444,8 @@ static void dns_close (qse_httpd_t* httpd, qse_httpd_dns_t* dns)
} }
} }
if (qse_isvalidsckhnd(dns->handle[0].i)) qse_closesckhnd (dns->handle[0].i); if (qse_isvalidsckhnd(dns->handle[0])) qse_closesckhnd (dns->handle[0]);
if (qse_isvalidsckhnd(dns->handle[1].i)) qse_closesckhnd (dns->handle[1].i); if (qse_isvalidsckhnd(dns->handle[1])) qse_closesckhnd (dns->handle[1]);
qse_httpd_freemem (httpd, dns->ctx); qse_httpd_freemem (httpd, dns->ctx);
} }
@ -533,7 +533,7 @@ static dns_ans_t* dns_get_answer_from_cache (dns_ctx_t* dc, const qse_mchar_t* n
return QSE_NULL; return QSE_NULL;
} }
static int dns_recv (qse_httpd_t* httpd, qse_httpd_dns_t* dns, qse_ubi_t handle) static int dns_recv (qse_httpd_t* httpd, qse_httpd_dns_t* dns, qse_httpd_hnd_t handle)
{ {
dns_ctx_t* dc = (dns_ctx_t*)dns->ctx; dns_ctx_t* dc = (dns_ctx_t*)dns->ctx;
httpd_xtn_t* httpd_xtn; httpd_xtn_t* httpd_xtn;
@ -563,7 +563,7 @@ printf ("DNS_RECV....\n");
httpd_xtn = qse_httpd_getxtn (httpd); httpd_xtn = qse_httpd_getxtn (httpd);
fromlen = QSE_SIZEOF(fromaddr); fromlen = QSE_SIZEOF(fromaddr);
len = recvfrom (handle.i, buf, QSE_SIZEOF(buf), 0, (struct sockaddr*)&fromaddr, &fromlen); len = recvfrom (handle, buf, QSE_SIZEOF(buf), 0, (struct sockaddr*)&fromaddr, &fromlen);
if (len < QSE_SIZEOF(*hdr)) goto done; /* packet too small */ if (len < QSE_SIZEOF(*hdr)) goto done; /* packet too small */
@ -871,9 +871,9 @@ printf ("DNS REALLY SENING>>>>>>>>>>>>>>>>>>>>>>>\n");
if (req->dns_skadlen <= -1) goto default_dns_server; if (req->dns_skadlen <= -1) goto default_dns_server;
if (dns_server->nwad.type == QSE_NWAD_IN4) if (dns_server->nwad.type == QSE_NWAD_IN4)
req->dns_socket = dns->handle[0].i; req->dns_socket = dns->handle[0];
else else
req->dns_socket = dns->handle[1].i; req->dns_socket = dns->handle[1];
dns_flags = dns_server->flags; dns_flags = dns_server->flags;
} }

View File

@ -99,8 +99,8 @@ static int urs_open (qse_httpd_t* httpd, qse_httpd_urs_t* urs)
httpd_xtn = qse_httpd_getxtn (httpd); httpd_xtn = qse_httpd_getxtn (httpd);
urs->handle[0].i = QSE_INVALID_SCKHND; urs->handle[0] = QSE_INVALID_SCKHND;
urs->handle[1].i = QSE_INVALID_SCKHND; urs->handle[1] = QSE_INVALID_SCKHND;
dc = (urs_ctx_t*) qse_httpd_callocmem (httpd, QSE_SIZEOF(urs_ctx_t)); dc = (urs_ctx_t*) qse_httpd_callocmem (httpd, QSE_SIZEOF(urs_ctx_t));
if (dc == NULL) goto oops; if (dc == NULL) goto oops;
@ -128,12 +128,12 @@ static int urs_open (qse_httpd_t* httpd, qse_httpd_urs_t* urs)
type = SOCK_DGRAM; type = SOCK_DGRAM;
#endif #endif
urs->handle[0].i = open_udp_socket (httpd, AF_INET, type, proto); urs->handle[0] = open_udp_socket (httpd, AF_INET, type, proto);
#if defined(AF_INET6) #if defined(AF_INET6)
urs->handle[1].i = open_udp_socket (httpd, AF_INET6, type, proto); urs->handle[1] = open_udp_socket (httpd, AF_INET6, type, proto);
#endif #endif
if (!qse_isvalidsckhnd(urs->handle[0].i) && !qse_isvalidsckhnd(urs->handle[1].i)) if (!qse_isvalidsckhnd(urs->handle[0]) && !qse_isvalidsckhnd(urs->handle[1]))
{ {
goto oops; goto oops;
} }
@ -145,9 +145,9 @@ static int urs_open (qse_httpd_t* httpd, qse_httpd_urs_t* urs)
if (dc->skadlen >= 0) if (dc->skadlen >= 0)
{ {
if (nwad.type == QSE_NWAD_IN4) if (nwad.type == QSE_NWAD_IN4)
dc->urs_socket = urs->handle[0].i; dc->urs_socket = urs->handle[0];
else else
dc->urs_socket = urs->handle[1].i; dc->urs_socket = urs->handle[1];
} }
else else
{ {
@ -158,21 +158,21 @@ static int urs_open (qse_httpd_t* httpd, qse_httpd_urs_t* urs)
if (proto == IPPROTO_SCTP) if (proto == IPPROTO_SCTP)
{ {
/* TODO: error ahndleing */ /* TODO: error ahndleing */
if (qse_isvalidsckhnd(urs->handle[0].i)) listen (urs->handle[0].i, 99); if (qse_isvalidsckhnd(urs->handle[0])) listen (urs->handle[0], 99);
if (qse_isvalidsckhnd(urs->handle[1].i)) listen (urs->handle[1].i, 99); if (qse_isvalidsckhnd(urs->handle[1])) listen (urs->handle[1], 99);
} }
#endif #endif
urs->handle_count = 2; urs->handle_count = 2;
if (qse_isvalidsckhnd(urs->handle[0].i)) urs->handle_mask |= (1 << 0); if (qse_isvalidsckhnd(urs->handle[0])) urs->handle_mask |= (1 << 0);
if (qse_isvalidsckhnd(urs->handle[1].i)) urs->handle_mask |= (1 << 1); if (qse_isvalidsckhnd(urs->handle[1])) urs->handle_mask |= (1 << 1);
urs->ctx = dc; urs->ctx = dc;
return 0; return 0;
oops: oops:
if (qse_isvalidsckhnd(urs->handle[0].i)) qse_closesckhnd (urs->handle[0].i); if (qse_isvalidsckhnd(urs->handle[0])) qse_closesckhnd (urs->handle[0]);
if (qse_isvalidsckhnd(urs->handle[1].i)) qse_closesckhnd (urs->handle[1].i); if (qse_isvalidsckhnd(urs->handle[1])) qse_closesckhnd (urs->handle[1]);
if (dc) qse_httpd_freemem (httpd, dc); if (dc) qse_httpd_freemem (httpd, dc);
return -1; return -1;
@ -208,13 +208,13 @@ static void urs_close (qse_httpd_t* httpd, qse_httpd_urs_t* urs)
QSE_ASSERT (dc->req_count == 0); QSE_ASSERT (dc->req_count == 0);
if (qse_isvalidsckhnd(urs->handle[0].i)) qse_closesckhnd (urs->handle[0].i); if (qse_isvalidsckhnd(urs->handle[0])) qse_closesckhnd (urs->handle[0]);
if (qse_isvalidsckhnd(urs->handle[1].i)) qse_closesckhnd (urs->handle[1].i); if (qse_isvalidsckhnd(urs->handle[1])) qse_closesckhnd (urs->handle[1]);
qse_httpd_freemem (httpd, urs->ctx); qse_httpd_freemem (httpd, urs->ctx);
} }
static int urs_recv (qse_httpd_t* httpd, qse_httpd_urs_t* urs, qse_ubi_t handle) static int urs_recv (qse_httpd_t* httpd, qse_httpd_urs_t* urs, qse_httpd_hnd_t handle)
{ {
urs_ctx_t* dc = (urs_ctx_t*)urs->ctx; urs_ctx_t* dc = (urs_ctx_t*)urs->ctx;
httpd_xtn_t* httpd_xtn; httpd_xtn_t* httpd_xtn;
@ -234,7 +234,7 @@ printf ("URS_RECV............................................\n");
/* TODO: use recvmsg with MSG_ERRQUEUE... set socket option IP_RECVERR... */ /* TODO: use recvmsg with MSG_ERRQUEUE... set socket option IP_RECVERR... */
fromlen = QSE_SIZEOF(fromaddr); fromlen = QSE_SIZEOF(fromaddr);
len = recvfrom (handle.i, dc->rcvbuf, QSE_SIZEOF(dc->rcvbuf) - 1, 0, (struct sockaddr*)&fromaddr, &fromlen); len = recvfrom (handle, dc->rcvbuf, QSE_SIZEOF(dc->rcvbuf) - 1, 0, (struct sockaddr*)&fromaddr, &fromlen);
/* TODO: check if fromaddr matches the dc->skad... */ /* TODO: check if fromaddr matches the dc->skad... */
@ -410,9 +410,9 @@ printf ("... URS_SEND.....................\n");
if (req->urs_skadlen <= -1) goto default_urs_server; if (req->urs_skadlen <= -1) goto default_urs_server;
if (urs_server->nwad.type == QSE_NWAD_IN4) if (urs_server->nwad.type == QSE_NWAD_IN4)
req->urs_socket = urs->handle[0].i; req->urs_socket = urs->handle[0];
else else
req->urs_socket = urs->handle[1].i; req->urs_socket = urs->handle[1];
} }
else else
{ {

View File

@ -107,6 +107,15 @@
# include <openssl/engine.h> # include <openssl/engine.h>
#endif #endif
#define HANDLE_TO_FIO(x) ((qse_fio_t*)(x))
#define FIO_TO_HANDLE(x) ((qse_httpd_hnd_t)(x))
#if defined(HAVE_SSL)
#define HANDLE_TO_SSL(x) ((SSL*)(x))
#define SSL_TO_HANDLE(x) ((qse_httpd_hnd_t)(x))
#endif
typedef struct server_xtn_t server_xtn_t; typedef struct server_xtn_t server_xtn_t;
struct server_xtn_t struct server_xtn_t
{ {
@ -378,7 +387,7 @@ static qse_httpd_errnum_t direrr_to_errnum (qse_dir_errnum_t e)
/* ------------------------------------------------------------------- */ /* ------------------------------------------------------------------- */
static QSE_INLINE qse_ssize_t __send_file ( static QSE_INLINE qse_ssize_t __send_file (
qse_httpd_t* httpd, qse_sck_hnd_t out_fd, qse_ubi_t in_fd, qse_httpd_t* httpd, qse_sck_hnd_t out_fd, qse_httpd_hnd_t in_fd,
qse_foff_t* offset, qse_size_t count) qse_foff_t* offset, qse_size_t count)
{ {
/* TODO: os2 warp 4.5 has send_file. support it??? load it dynamically??? */ /* TODO: os2 warp 4.5 has send_file. support it??? load it dynamically??? */
@ -392,7 +401,7 @@ static QSE_INLINE qse_ssize_t __send_file (
qse_ssize_t ret; qse_ssize_t ret;
qse_fio_hnd_t fh; qse_fio_hnd_t fh;
fh = qse_fio_gethandle (in_fd.ptr); fh = qse_fio_gethandle (HANDLE_TO_FIO(in_fd));
#if !defined(_LP64) && (QSE_SIZEOF_VOID_P<8) && defined(HAVE_SENDFILE64) #if !defined(_LP64) && (QSE_SIZEOF_VOID_P<8) && defined(HAVE_SENDFILE64)
ret = sendfile64 (out_fd, fh, offset, count); ret = sendfile64 (out_fd, fh, offset, count);
@ -407,7 +416,7 @@ static QSE_INLINE qse_ssize_t __send_file (
qse_ssize_t ret; qse_ssize_t ret;
qse_fio_hnd_t fh; qse_fio_hnd_t fh;
fh = qse_fio_gethandle (in_fd.ptr); fh = qse_fio_gethandle (HANDLE_TO_FIO(in_fd));
ret = sendfile (out_fd, fh, offset, count); ret = sendfile (out_fd, fh, offset, count);
if (ret <= -1) qse_httpd_seterrnum (httpd, SKERR_TO_ERRNUM()); if (ret <= -1) qse_httpd_seterrnum (httpd, SKERR_TO_ERRNUM());
return ret; return ret;
@ -417,7 +426,7 @@ static QSE_INLINE qse_ssize_t __send_file (
qse_ssize_t ret; qse_ssize_t ret;
qse_fio_hnd_t fh; qse_fio_hnd_t fh;
fh = qse_fio_gethandle (in_fd.ptr); fh = qse_fio_gethandle (HANDLE_TO_FIO(in_fd));
ret = sendfile64 (out_fd, fh, offset, count); ret = sendfile64 (out_fd, fh, offset, count);
if (ret <= -1) qse_httpd_seterrnum (httpd, SKERR_TO_ERRNUM()); if (ret <= -1) qse_httpd_seterrnum (httpd, SKERR_TO_ERRNUM());
return ret; return ret;
@ -435,7 +444,7 @@ static QSE_INLINE qse_ssize_t __send_file (
ssize_t ret; ssize_t ret;
qse_fio_hnd_t fh; qse_fio_hnd_t fh;
fh = qse_fio_gethandle(in_fd.ptr); fh = qse_fio_gethandle (HANDLE_TO_FIO(in_fd));
vec.sfv_fd = fh; vec.sfv_fd = fh;
vec.sfv_flag = 0; vec.sfv_flag = 0;
@ -471,17 +480,17 @@ on failure xfer != ret.
qse_ssize_t ret; qse_ssize_t ret;
qse_foff_t foff; qse_foff_t foff;
if (offset && (foff = qse_fio_seek (in_fd.ptr, *offset, QSE_FIO_BEGIN)) != *offset) if (offset && (foff = qse_fio_seek (HANDLE_TO_FIO(in_fd), *offset, QSE_FIO_BEGIN)) != *offset)
{ {
if (foff == (qse_foff_t)-1) if (foff == (qse_foff_t)-1)
qse_httpd_seterrnum (httpd, fioerr_to_errnum(qse_fio_geterrnum(in_fd.ptr))); qse_httpd_seterrnum (httpd, fioerr_to_errnum(qse_fio_geterrnum(HANDLE_TO_FIO(in_fd))));
else else
qse_httpd_seterrnum (httpd, QSE_HTTPD_ESYSERR); qse_httpd_seterrnum (httpd, QSE_HTTPD_ESYSERR);
return (qse_ssize_t)-1; return (qse_ssize_t)-1;
} }
if (count > QSE_COUNTOF(buf)) count = QSE_COUNTOF(buf); if (count > QSE_COUNTOF(buf)) count = QSE_COUNTOF(buf);
ret = qse_fio_read (in_fd.ptr, buf, count); ret = qse_fio_read (HANDLE_TO_FIO(in_fd), buf, count);
if (ret > 0) if (ret > 0)
{ {
ret = send (out_fd, buf, ret, 0); ret = send (out_fd, buf, ret, 0);
@ -493,7 +502,7 @@ on failure xfer != ret.
} }
else if (ret <= -1) else if (ret <= -1)
{ {
qse_httpd_seterrnum (httpd, fioerr_to_errnum(qse_fio_geterrnum(in_fd.ptr))); qse_httpd_seterrnum (httpd, fioerr_to_errnum(qse_fio_geterrnum(HANDLE_TO_FIO(in_fd))));
} }
return ret; return ret;
@ -504,7 +513,7 @@ on failure xfer != ret.
/* ------------------------------------------------------------------- */ /* ------------------------------------------------------------------- */
static QSE_INLINE qse_ssize_t __send_file_ssl ( static QSE_INLINE qse_ssize_t __send_file_ssl (
qse_httpd_t* httpd, void* xout, qse_ubi_t in_fd, qse_httpd_t* httpd, void* xout, qse_httpd_hnd_t in_fd,
qse_foff_t* offset, qse_size_t count) qse_foff_t* offset, qse_size_t count)
{ {
#if defined(HAVE_SSL) #if defined(HAVE_SSL)
@ -513,17 +522,17 @@ static QSE_INLINE qse_ssize_t __send_file_ssl (
qse_foff_t foff; qse_foff_t foff;
SSL* out = (SSL*)xout; SSL* out = (SSL*)xout;
if (offset && (foff = qse_fio_seek (in_fd.ptr, *offset, QSE_FIO_BEGIN)) != *offset) if (offset && (foff = qse_fio_seek (HANDLE_TO_FIO(in_fd), *offset, QSE_FIO_BEGIN)) != *offset)
{ {
if (foff == (qse_foff_t)-1) if (foff == (qse_foff_t)-1)
qse_httpd_seterrnum (httpd, fioerr_to_errnum(qse_fio_geterrnum(in_fd.ptr))); qse_httpd_seterrnum (httpd, fioerr_to_errnum(qse_fio_geterrnum(HANDLE_TO_FIO(in_fd))));
else else
qse_httpd_seterrnum (httpd, QSE_HTTPD_ESYSERR); qse_httpd_seterrnum (httpd, QSE_HTTPD_ESYSERR);
return (qse_ssize_t)-1; return (qse_ssize_t)-1;
} }
if (count > QSE_COUNTOF(buf)) count = QSE_COUNTOF(buf); if (count > QSE_COUNTOF(buf)) count = QSE_COUNTOF(buf);
ret = qse_fio_read (in_fd.ptr, buf, count); ret = qse_fio_read (HANDLE_TO_FIO(in_fd), buf, count);
if (ret > 0) if (ret > 0)
{ {
ret = SSL_write (out, buf, count); ret = SSL_write (out, buf, count);
@ -542,7 +551,7 @@ static QSE_INLINE qse_ssize_t __send_file_ssl (
} }
else if (ret <= -1) else if (ret <= -1)
{ {
qse_httpd_seterrnum (httpd, fioerr_to_errnum(qse_fio_geterrnum(in_fd.ptr))); qse_httpd_seterrnum (httpd, fioerr_to_errnum(qse_fio_geterrnum(HANDLE_TO_FIO(in_fd))));
} }
return ret; return ret;
@ -911,7 +920,7 @@ bind_ok:
if (set_socket_nonblock (httpd, fd, 1) <= -1) goto oops; if (set_socket_nonblock (httpd, fd, 1) <= -1) goto oops;
server->handle.i = fd; server->handle = fd;
return 0; return 0;
oops: oops:
@ -922,7 +931,7 @@ oops:
static void server_close (qse_httpd_t* httpd, qse_httpd_server_t* server) static void server_close (qse_httpd_t* httpd, qse_httpd_server_t* server)
{ {
qse_closesckhnd (server->handle.i); qse_closesckhnd (server->handle);
} }
static int server_accept ( static int server_accept (
@ -939,7 +948,7 @@ static int server_accept (
int flag; int flag;
addrlen = QSE_SIZEOF(addr); addrlen = QSE_SIZEOF(addr);
fd = accept (server->handle.i, (struct sockaddr*)&addr, &addrlen); fd = accept (server->handle, (struct sockaddr*)&addr, &addrlen);
if (!qse_isvalidsckhnd(fd)) if (!qse_isvalidsckhnd(fd))
{ {
qse_httpd_seterrnum (httpd, SKERR_TO_ERRNUM()); qse_httpd_seterrnum (httpd, SKERR_TO_ERRNUM());
@ -1005,7 +1014,7 @@ qse_fprintf (QSE_STDERR, QSE_T("Error: too many client?\n"));
} }
#endif #endif
client->handle.i = fd; client->handle = fd;
return 0; return 0;
oops: oops:
@ -1117,7 +1126,7 @@ static int peer_open (qse_httpd_t* httpd, qse_httpd_peer_t* peer)
/*if (set_socket_nonblock (httpd, fd, 0) <= -1) goto oops;*/ /*if (set_socket_nonblock (httpd, fd, 0) <= -1) goto oops;*/
peer->handle.i = fd; peer->handle = fd;
return connected; return connected;
oops: oops:
@ -1131,7 +1140,7 @@ oops:
static void peer_close (qse_httpd_t* httpd, qse_httpd_peer_t* peer) static void peer_close (qse_httpd_t* httpd, qse_httpd_peer_t* peer)
{ {
qse_closesckhnd (peer->handle.i); qse_closesckhnd (peer->handle);
} }
static int peer_connected (qse_httpd_t* httpd, qse_httpd_peer_t* peer) static int peer_connected (qse_httpd_t* httpd, qse_httpd_peer_t* peer)
@ -1141,7 +1150,7 @@ static int peer_connected (qse_httpd_t* httpd, qse_httpd_peer_t* peer)
DWORD ret; DWORD ret;
len = QSE_SIZEOF(ret); len = QSE_SIZEOF(ret);
if (getsockopt (peer->handle.i, SOL_SOCKET, SO_ERROR, (char*)&ret, &len) == SOCKET_ERROR) if (getsockopt (peer->handle, SOL_SOCKET, SO_ERROR, (char*)&ret, &len) == SOCKET_ERROR)
{ {
qse_httpd_seterrnum (httpd, skerr_to_errnum (ret)); qse_httpd_seterrnum (httpd, skerr_to_errnum (ret));
return -1; return -1;
@ -1162,7 +1171,7 @@ static int peer_connected (qse_httpd_t* httpd, qse_httpd_peer_t* peer)
int ret; int ret;
len = QSE_SIZEOF(ret); len = QSE_SIZEOF(ret);
if (getsockopt (peer->handle.i, SOL_SOCKET, SO_ERROR, (char*)&ret, &len) == -1) if (getsockopt (peer->handle, SOL_SOCKET, SO_ERROR, (char*)&ret, &len) == -1)
{ {
qse_httpd_seterrnum (httpd, skerr_to_errnum (ret)); qse_httpd_seterrnum (httpd, skerr_to_errnum (ret));
return -1; return -1;
@ -1189,7 +1198,7 @@ static int peer_connected (qse_httpd_t* httpd, qse_httpd_peer_t* peer)
int ret; int ret;
len = QSE_SIZEOF(ret); len = QSE_SIZEOF(ret);
if (getsockopt (peer->handle.i, SOL_SOCKET, SO_ERROR, &ret, &len) <= -1) if (getsockopt (peer->handle, SOL_SOCKET, SO_ERROR, &ret, &len) <= -1)
{ {
qse_httpd_seterrnum (httpd, skerr_to_errnum (ret)); qse_httpd_seterrnum (httpd, skerr_to_errnum (ret));
return -1; return -1;
@ -1214,7 +1223,7 @@ static qse_ssize_t peer_recv (
qse_httpd_seterrnum (httpd, QSE_HTTPD_ENOIMPL); qse_httpd_seterrnum (httpd, QSE_HTTPD_ENOIMPL);
return -1; return -1;
#else #else
qse_ssize_t ret = recv (peer->handle.i, buf, bufsize, 0); qse_ssize_t ret = recv (peer->handle, buf, bufsize, 0);
if (ret <= -1) qse_httpd_seterrnum (httpd, SKERR_TO_ERRNUM()); if (ret <= -1) qse_httpd_seterrnum (httpd, SKERR_TO_ERRNUM());
return ret; return ret;
#endif #endif
@ -1228,7 +1237,7 @@ static qse_ssize_t peer_send (
qse_httpd_seterrnum (httpd, QSE_HTTPD_ENOIMPL); qse_httpd_seterrnum (httpd, QSE_HTTPD_ENOIMPL);
return -1; return -1;
#else #else
qse_ssize_t ret = send (peer->handle.i, buf, bufsize, 0); qse_ssize_t ret = send (peer->handle, buf, bufsize, 0);
if (ret <= -1) qse_httpd_seterrnum (httpd, SKERR_TO_ERRNUM()); if (ret <= -1) qse_httpd_seterrnum (httpd, SKERR_TO_ERRNUM());
return ret; return ret;
#endif #endif
@ -1246,16 +1255,16 @@ struct mux_xtn_t
static void dispatch_muxcb (qse_mux_t* mux, const qse_mux_evt_t* evt) static void dispatch_muxcb (qse_mux_t* mux, const qse_mux_evt_t* evt)
{ {
mux_xtn_t* xtn; mux_xtn_t* xtn;
qse_ubi_t ubi; qse_httpd_hnd_t handle;
int mask = 0; int mask = 0;
xtn = qse_mux_getxtn (mux); xtn = qse_mux_getxtn (mux);
ubi.i = evt->hnd; handle = evt->hnd;
if (evt->mask & QSE_MUX_IN) mask |= QSE_HTTPD_MUX_READ; if (evt->mask & QSE_MUX_IN) mask |= QSE_HTTPD_MUX_READ;
if (evt->mask & QSE_MUX_OUT) mask |= QSE_HTTPD_MUX_WRITE; if (evt->mask & QSE_MUX_OUT) mask |= QSE_HTTPD_MUX_WRITE;
xtn->cbfun (xtn->httpd, mux, ubi, mask, evt->data); xtn->cbfun (xtn->httpd, mux, handle, mask, evt->data);
} }
static void* mux_open (qse_httpd_t* httpd, qse_httpd_muxcb_t cbfun) static void* mux_open (qse_httpd_t* httpd, qse_httpd_muxcb_t cbfun)
@ -1282,11 +1291,11 @@ static void mux_close (qse_httpd_t* httpd, void* vmux)
} }
static int mux_addhnd ( static int mux_addhnd (
qse_httpd_t* httpd, void* vmux, qse_ubi_t handle, int mask, void* data) qse_httpd_t* httpd, void* vmux, qse_httpd_hnd_t handle, int mask, void* data)
{ {
qse_mux_evt_t evt; qse_mux_evt_t evt;
evt.hnd = handle.i; evt.hnd = handle;
evt.mask = 0; evt.mask = 0;
if (mask & QSE_HTTPD_MUX_READ) evt.mask |= QSE_MUX_IN; if (mask & QSE_HTTPD_MUX_READ) evt.mask |= QSE_MUX_IN;
if (mask & QSE_HTTPD_MUX_WRITE) evt.mask |= QSE_MUX_OUT; if (mask & QSE_HTTPD_MUX_WRITE) evt.mask |= QSE_MUX_OUT;
@ -1301,10 +1310,10 @@ static int mux_addhnd (
return 0; return 0;
} }
static int mux_delhnd (qse_httpd_t* httpd, void* vmux, qse_ubi_t handle) static int mux_delhnd (qse_httpd_t* httpd, void* vmux, qse_httpd_hnd_t handle)
{ {
qse_mux_evt_t evt; qse_mux_evt_t evt;
evt.hnd = handle.i; evt.hnd = handle;
if (qse_mux_delete ((qse_mux_t*)vmux, &evt) <= -1) if (qse_mux_delete ((qse_mux_t*)vmux, &evt) <= -1)
{ {
qse_httpd_seterrnum (httpd, muxerr_to_errnum(qse_mux_geterrnum((qse_mux_t*)vmux))); qse_httpd_seterrnum (httpd, muxerr_to_errnum(qse_mux_geterrnum((qse_mux_t*)vmux)));
@ -1324,13 +1333,13 @@ static int mux_poll (qse_httpd_t* httpd, void* vmux, const qse_ntime_t* tmout)
return 0; return 0;
} }
static int mux_readable (qse_httpd_t* httpd, qse_ubi_t handle, const qse_ntime_t* tmout) static int mux_readable (qse_httpd_t* httpd, qse_httpd_hnd_t handle, const qse_ntime_t* tmout)
{ {
#if defined(__OS2__) && !defined(TCPV40HDRS) #if defined(__OS2__) && !defined(TCPV40HDRS)
long tv; long tv;
tv = tmout? QSE_SECNSEC_TO_MSEC (tmout->sec, tmout->nsec): -1; tv = tmout? QSE_SECNSEC_TO_MSEC (tmout->sec, tmout->nsec): -1;
return os2_select (&handle.i, 1, 0, 0, tv); return os2_select (&handle, 1, 0, 0, tv);
#elif defined(__DOS__) #elif defined(__DOS__)
@ -1342,7 +1351,7 @@ static int mux_readable (qse_httpd_t* httpd, qse_ubi_t handle, const qse_ntime_t
struct timeval tv, * tvp; struct timeval tv, * tvp;
FD_ZERO (&r); FD_ZERO (&r);
FD_SET (handle.i, &r); FD_SET (handle, &r);
if (tmout) if (tmout)
{ {
@ -1352,16 +1361,16 @@ static int mux_readable (qse_httpd_t* httpd, qse_ubi_t handle, const qse_ntime_t
} }
else tvp = QSE_NULL; else tvp = QSE_NULL;
return select (handle.i + 1, &r, QSE_NULL, QSE_NULL, tvp); return select (handle + 1, &r, QSE_NULL, QSE_NULL, tvp);
#endif #endif
} }
static int mux_writable (qse_httpd_t* httpd, qse_ubi_t handle, const qse_ntime_t* tmout) static int mux_writable (qse_httpd_t* httpd, qse_httpd_hnd_t handle, const qse_ntime_t* tmout)
{ {
#if defined(__OS2__) && !defined(TCPV40HDRS) #if defined(__OS2__) && !defined(TCPV40HDRS)
long tv; long tv;
tv = tmout? QSE_SECNSEC_TO_MSEC (tmout->sec, tmout->nsec): -1; tv = tmout? QSE_SECNSEC_TO_MSEC (tmout->sec, tmout->nsec): -1;
return os2_select (&handle.i, 0, 1, 0, tv); return os2_select (&handle, 0, 1, 0, tv);
#elif defined(__DOS__) #elif defined(__DOS__)
@ -1373,7 +1382,7 @@ static int mux_writable (qse_httpd_t* httpd, qse_ubi_t handle, const qse_ntime_t
struct timeval tv, * tvp; struct timeval tv, * tvp;
FD_ZERO (&w); FD_ZERO (&w);
FD_SET (handle.i, &w); FD_SET (handle, &w);
if (tmout) if (tmout)
{ {
@ -1383,7 +1392,7 @@ static int mux_writable (qse_httpd_t* httpd, qse_ubi_t handle, const qse_ntime_t
} }
else tvp = QSE_NULL; else tvp = QSE_NULL;
return select (handle.i + 1, QSE_NULL, &w, QSE_NULL, tvp); return select (handle + 1, QSE_NULL, &w, QSE_NULL, tvp);
#endif #endif
} }
@ -1598,14 +1607,14 @@ static qse_fio_t* __open_file (qse_httpd_t* httpd, const qse_mchar_t* path, int
} }
static int file_ropen ( static int file_ropen (
qse_httpd_t* httpd, const qse_mchar_t* path, qse_ubi_t* handle) qse_httpd_t* httpd, const qse_mchar_t* path, qse_httpd_hnd_t* handle)
{ {
qse_fio_t* fio; qse_fio_t* fio;
fio = __open_file (httpd, path, QSE_FIO_READ | QSE_FIO_MBSPATH, 0); fio = __open_file (httpd, path, QSE_FIO_READ | QSE_FIO_MBSPATH, 0);
if (fio == QSE_NULL) return -1; if (fio == QSE_NULL) return -1;
handle->ptr = fio; *handle = FIO_TO_HANDLE(fio);
if (httpd->opt.trait & QSE_HTTPD_LOGACT) if (httpd->opt.trait & QSE_HTTPD_LOGACT)
{ {
qse_httpd_act_t msg; qse_httpd_act_t msg;
@ -1621,14 +1630,14 @@ static int file_ropen (
static int file_wopen ( static int file_wopen (
qse_httpd_t* httpd, const qse_mchar_t* path, qse_httpd_t* httpd, const qse_mchar_t* path,
qse_ubi_t* handle) qse_httpd_hnd_t* handle)
{ {
qse_fio_t* fio; qse_fio_t* fio;
fio = __open_file (httpd, path, QSE_FIO_WRITE | QSE_FIO_CREATE | QSE_FIO_TRUNCATE | QSE_FIO_MBSPATH, 0644); fio = __open_file (httpd, path, QSE_FIO_WRITE | QSE_FIO_CREATE | QSE_FIO_TRUNCATE | QSE_FIO_MBSPATH, 0644);
if (fio == QSE_NULL) return -1; if (fio == QSE_NULL) return -1;
handle->ptr = fio; *handle = FIO_TO_HANDLE(fio);
if (httpd->opt.trait & QSE_HTTPD_LOGACT) if (httpd->opt.trait & QSE_HTTPD_LOGACT)
{ {
qse_httpd_act_t msg; qse_httpd_act_t msg;
@ -1642,27 +1651,27 @@ static int file_wopen (
return 0; return 0;
} }
static void file_close (qse_httpd_t* httpd, qse_ubi_t handle) static void file_close (qse_httpd_t* httpd, qse_httpd_hnd_t handle)
{ {
qse_fio_fini (handle.ptr); qse_fio_fini (HANDLE_TO_FIO(handle));
qse_httpd_freemem (httpd, handle.ptr); qse_httpd_freemem (httpd, HANDLE_TO_FIO(handle));
} }
static qse_ssize_t file_read ( static qse_ssize_t file_read (
qse_httpd_t* httpd, qse_ubi_t handle, qse_mchar_t* buf, qse_size_t len) qse_httpd_t* httpd, qse_httpd_hnd_t handle, qse_mchar_t* buf, qse_size_t len)
{ {
qse_ssize_t n; qse_ssize_t n;
n = qse_fio_read (handle.ptr, buf, len); n = qse_fio_read (HANDLE_TO_FIO(handle), buf, len);
if (n <= -1) qse_httpd_seterrnum (httpd, fioerr_to_errnum(qse_fio_geterrnum(handle.ptr))); if (n <= -1) qse_httpd_seterrnum (httpd, fioerr_to_errnum(qse_fio_geterrnum(HANDLE_TO_FIO(handle))));
return n; return n;
} }
static qse_ssize_t file_write ( static qse_ssize_t file_write (
qse_httpd_t* httpd, qse_ubi_t handle, const qse_mchar_t* buf, qse_size_t len) qse_httpd_t* httpd, qse_httpd_hnd_t handle, const qse_mchar_t* buf, qse_size_t len)
{ {
qse_ssize_t n; qse_ssize_t n;
n = qse_fio_write (handle.ptr, buf, len); n = qse_fio_write (HANDLE_TO_FIO(handle), buf, len);
if (n <= -1) qse_httpd_seterrnum (httpd, fioerr_to_errnum(qse_fio_geterrnum(handle.ptr))); if (n <= -1) qse_httpd_seterrnum (httpd, fioerr_to_errnum(qse_fio_geterrnum(HANDLE_TO_FIO(handle))));
return n; return n;
} }
@ -1759,7 +1768,10 @@ struct dir_t
qse_dir_t* dp; qse_dir_t* dp;
}; };
static int dir_open (qse_httpd_t* httpd, const qse_mchar_t* path, qse_ubi_t* handle) #define HANDLE_TO_DIR(x) ((dir_t*)(x))
#define DIR_TO_HANDLE(x) ((qse_httpd_hnd_t)(x))
static int dir_open (qse_httpd_t* httpd, const qse_mchar_t* path, qse_httpd_hnd_t* handle)
{ {
dir_t* d; dir_t* d;
qse_dir_errnum_t direrrnum; qse_dir_errnum_t direrrnum;
@ -1803,15 +1815,15 @@ static int dir_open (qse_httpd_t* httpd, const qse_mchar_t* path, qse_ubi_t* han
httpd->opt.rcb.logact (httpd, &msg); httpd->opt.rcb.logact (httpd, &msg);
} }
handle->ptr = d; *handle = DIR_TO_HANDLE(d);
return 0; return 0;
} }
static void dir_close (qse_httpd_t* httpd, qse_ubi_t handle) static void dir_close (qse_httpd_t* httpd, qse_httpd_hnd_t handle)
{ {
dir_t* d; dir_t* d;
d = (dir_t*)handle.ptr; d = HANDLE_TO_DIR(handle);
qse_dir_close (d->dp); qse_dir_close (d->dp);
@ -1819,14 +1831,14 @@ static void dir_close (qse_httpd_t* httpd, qse_ubi_t handle)
QSE_MMGR_FREE (httpd->mmgr, d); QSE_MMGR_FREE (httpd->mmgr, d);
} }
static int dir_read (qse_httpd_t* httpd, qse_ubi_t handle, qse_httpd_dirent_t* dirent) static int dir_read (qse_httpd_t* httpd, qse_httpd_hnd_t handle, qse_httpd_dirent_t* dirent)
{ {
dir_t* d; dir_t* d;
qse_dir_ent_t de; qse_dir_ent_t de;
qse_mchar_t* fpath; qse_mchar_t* fpath;
int n; int n;
d = (dir_t*)handle.ptr; d = HANDLE_TO_DIR(handle);
n = qse_dir_read (d->dp, &de); n = qse_dir_read (d->dp, &de);
if (n <= -1) if (n <= -1)
@ -1856,13 +1868,13 @@ static int dir_read (qse_httpd_t* httpd, qse_ubi_t handle, qse_httpd_dirent_t* d
static void client_close (qse_httpd_t* httpd, qse_httpd_client_t* client) static void client_close (qse_httpd_t* httpd, qse_httpd_client_t* client)
{ {
qse_shutsckhnd (client->handle.i, QSE_SHUTSCKHND_RW); qse_shutsckhnd (client->handle, QSE_SHUTSCKHND_RW);
qse_closesckhnd (client->handle.i); qse_closesckhnd (client->handle);
} }
static void client_shutdown (qse_httpd_t* httpd, qse_httpd_client_t* client) static void client_shutdown (qse_httpd_t* httpd, qse_httpd_client_t* client)
{ {
qse_shutsckhnd (client->handle.i, QSE_SHUTSCKHND_RW); qse_shutsckhnd (client->handle, QSE_SHUTSCKHND_RW);
} }
static qse_ssize_t client_recv ( static qse_ssize_t client_recv (
@ -1872,17 +1884,17 @@ static qse_ssize_t client_recv (
if (client->status & QSE_HTTPD_CLIENT_SECURE) if (client->status & QSE_HTTPD_CLIENT_SECURE)
{ {
#if defined(HAVE_SSL) #if defined(HAVE_SSL)
int ret = SSL_read (client->handle2.ptr, buf, bufsize); int ret = SSL_read (HANDLE_TO_SSL(client->handle2), buf, bufsize);
if (ret <= -1) if (ret <= -1)
{ {
int err = SSL_get_error(client->handle2.ptr,ret); int err = SSL_get_error(HANDLE_TO_SSL(client->handle2),ret);
if (err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE) if (err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE)
qse_httpd_seterrnum (httpd, QSE_HTTPD_EAGAIN); qse_httpd_seterrnum (httpd, QSE_HTTPD_EAGAIN);
else else
qse_httpd_seterrnum (httpd, QSE_HTTPD_ESYSERR); qse_httpd_seterrnum (httpd, QSE_HTTPD_ESYSERR);
} }
if (SSL_pending (client->handle2.ptr) > 0) if (SSL_pending (HANDLE_TO_SSL(client->handle2)) > 0)
client->status |= QSE_HTTPD_CLIENT_PENDING; client->status |= QSE_HTTPD_CLIENT_PENDING;
else else
client->status &= ~QSE_HTTPD_CLIENT_PENDING; client->status &= ~QSE_HTTPD_CLIENT_PENDING;
@ -1900,7 +1912,7 @@ static qse_ssize_t client_recv (
return -1; return -1;
#else #else
qse_ssize_t ret; qse_ssize_t ret;
ret = recv (client->handle.i, buf, bufsize, 0); ret = recv (client->handle, buf, bufsize, 0);
if (ret <= -1) qse_httpd_seterrnum (httpd, SKERR_TO_ERRNUM()); if (ret <= -1) qse_httpd_seterrnum (httpd, SKERR_TO_ERRNUM());
return ret; return ret;
#endif #endif
@ -1914,10 +1926,10 @@ static qse_ssize_t client_send (
if (client->status & QSE_HTTPD_CLIENT_SECURE) if (client->status & QSE_HTTPD_CLIENT_SECURE)
{ {
#if defined(HAVE_SSL) #if defined(HAVE_SSL)
int ret = SSL_write (client->handle2.ptr, buf, bufsize); int ret = SSL_write (HANDLE_TO_SSL(client->handle2), buf, bufsize);
if (ret <= -1) if (ret <= -1)
{ {
int err = SSL_get_error(client->handle2.ptr,ret); int err = SSL_get_error(HANDLE_TO_SSL(client->handle2),ret);
if (err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE) if (err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE)
qse_httpd_seterrnum (httpd, QSE_HTTPD_EAGAIN); qse_httpd_seterrnum (httpd, QSE_HTTPD_EAGAIN);
else else
@ -1935,7 +1947,7 @@ static qse_ssize_t client_send (
qse_httpd_seterrnum (httpd, QSE_HTTPD_ENOIMPL); qse_httpd_seterrnum (httpd, QSE_HTTPD_ENOIMPL);
return -1; return -1;
#else #else
qse_ssize_t ret = send (client->handle.i, buf, bufsize, 0); qse_ssize_t ret = send (client->handle, buf, bufsize, 0);
if (ret <= -1) qse_httpd_seterrnum (httpd, SKERR_TO_ERRNUM()); if (ret <= -1) qse_httpd_seterrnum (httpd, SKERR_TO_ERRNUM());
return ret; return ret;
#endif #endif
@ -1944,15 +1956,15 @@ static qse_ssize_t client_send (
static qse_ssize_t client_sendfile ( static qse_ssize_t client_sendfile (
qse_httpd_t* httpd, qse_httpd_client_t* client, qse_httpd_t* httpd, qse_httpd_client_t* client,
qse_ubi_t handle, qse_foff_t* offset, qse_size_t count) qse_httpd_hnd_t handle, qse_foff_t* offset, qse_size_t count)
{ {
if (client->status & QSE_HTTPD_CLIENT_SECURE) if (client->status & QSE_HTTPD_CLIENT_SECURE)
{ {
return __send_file_ssl (httpd, client->handle2.ptr, handle, offset, count); return __send_file_ssl (httpd, HANDLE_TO_SSL(client->handle2), handle, offset, count);
} }
else else
{ {
return __send_file (httpd, client->handle.i, handle, offset, count); return __send_file (httpd, client->handle, handle, offset, count);
} }
} }
@ -1976,18 +1988,19 @@ static int client_accepted (qse_httpd_t* httpd, qse_httpd_client_t* client)
} }
QSE_ASSERT (xtn->ssl_ctx != QSE_NULL); QSE_ASSERT (xtn->ssl_ctx != QSE_NULL);
QSE_ASSERT (QSE_SIZEOF(client->handle2) >= QSE_SIZEOF(ssl));
if (client->handle2.ptr) if (HANDLE_TO_SSL(client->handle2))
{ {
ssl = client->handle2.ptr; ssl = HANDLE_TO_SSL(client->handle2);
} }
else else
{ {
ssl = SSL_new (xtn->ssl_ctx); ssl = SSL_new (xtn->ssl_ctx);
if (ssl == QSE_NULL) return -1; if (ssl == QSE_NULL) return -1;
client->handle2.ptr = ssl; client->handle2 = SSL_TO_HANDLE(ssl);
if (SSL_set_fd (ssl, client->handle.i) == 0) if (SSL_set_fd (ssl, client->handle) == 0)
{ {
/* don't free ssl here since client_closed() /* don't free ssl here since client_closed()
* will free it */ * will free it */
@ -2000,8 +2013,7 @@ static int client_accepted (qse_httpd_t* httpd, qse_httpd_client_t* client)
ret = SSL_accept (ssl); ret = SSL_accept (ssl);
if (ret <= 0) if (ret <= 0)
{ {
int err; int err = SSL_get_error(ssl, ret);
err = SSL_get_error(ssl,ret);
if (err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE) if (err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE)
{ {
/* handshaking isn't complete. */ /* handshaking isn't complete. */
@ -2034,10 +2046,10 @@ static void client_closed (qse_httpd_t* httpd, qse_httpd_client_t* client)
if (client->status & QSE_HTTPD_CLIENT_SECURE) if (client->status & QSE_HTTPD_CLIENT_SECURE)
{ {
#if defined(HAVE_SSL) #if defined(HAVE_SSL)
if (client->handle2.ptr) if ((SSL*)client->handle2)
{ {
SSL_shutdown ((SSL*)client->handle2.ptr); /* is this needed? */ SSL_shutdown ((SSL*)client->handle2); /* is this needed? */
SSL_free ((SSL*)client->handle2.ptr); SSL_free ((SSL*)client->handle2);
} }
#endif #endif
} }

View File

@ -53,7 +53,7 @@ struct htrd_xtn_t
static void free_server_list (qse_httpd_t* httpd); static void free_server_list (qse_httpd_t* httpd);
static int perform_client_task ( static int perform_client_task (
qse_httpd_t* httpd, void* mux, qse_ubi_t handle, int mask, void* cbarg); qse_httpd_t* httpd, void* mux, qse_httpd_hnd_t handle, int mask, void* cbarg);
static void unload_all_modules (qse_httpd_t* httpd); static void unload_all_modules (qse_httpd_t* httpd);
qse_http_version_t qse_http_v11 = { 1, 1 }; qse_http_version_t qse_http_v11 = { 1, 1 };
@ -391,7 +391,7 @@ static QSE_INLINE int dequeue_task (
{ {
if (client->status & QSE_HTTPD_CLIENT_TASK_TRIGGER_RW_IN_MUX(i)) if (client->status & QSE_HTTPD_CLIENT_TASK_TRIGGER_RW_IN_MUX(i))
{ {
QSE_ASSERT (task->core.trigger.v[i].handle.i != client->handle.i); QSE_ASSERT (task->core.trigger.v[i].handle != client->handle);
httpd->opt.scb.mux.delhnd (httpd, httpd->mux, task->core.trigger.v[i].handle); httpd->opt.scb.mux.delhnd (httpd, httpd->mux, task->core.trigger.v[i].handle);
client->status &= ~QSE_HTTPD_CLIENT_TASK_TRIGGER_RW_IN_MUX(i); client->status &= ~QSE_HTTPD_CLIENT_TASK_TRIGGER_RW_IN_MUX(i);
} }
@ -627,7 +627,7 @@ static int is_client_allowed (qse_httpd_t* httpd, qse_httpd_client_t* client)
#endif #endif
static int accept_client ( static int accept_client (
qse_httpd_t* httpd, void* mux, qse_ubi_t handle, int mask, void* cbarg) qse_httpd_t* httpd, void* mux, qse_httpd_hnd_t handle, int mask, void* cbarg)
{ {
qse_httpd_server_t* server; qse_httpd_server_t* server;
qse_httpd_client_t clibuf; qse_httpd_client_t clibuf;
@ -647,7 +647,7 @@ static int accept_client (
/* TODO: proper logging */ /* TODO: proper logging */
qse_char_t tmp[128]; qse_char_t tmp[128];
qse_nwadtostr (&server->dope.nwad, tmp, QSE_COUNTOF(tmp), QSE_NWADTOSTR_ALL); qse_nwadtostr (&server->dope.nwad, tmp, QSE_COUNTOF(tmp), QSE_NWADTOSTR_ALL);
qse_printf (QSE_T("failed to accept from server [%s] [%d]\n"), tmp, server->handle.i); qse_printf (QSE_T("failed to accept from server [%s] [%d]\n"), tmp, server->handle);
#endif #endif
return -1; return -1;
@ -909,9 +909,6 @@ static int activate_dns (qse_httpd_t* httpd)
int i; int i;
QSE_MEMSET (&httpd->dns, 0, QSE_SIZEOF(httpd->dns)); QSE_MEMSET (&httpd->dns, 0, QSE_SIZEOF(httpd->dns));
for (i = 0; i < QSE_COUNTOF(httpd->dns.handle); i++)
httpd->dns.handle[i].i = -1;
if (httpd->opt.scb.dns.open (httpd, &httpd->dns) <= -1) return -1; if (httpd->opt.scb.dns.open (httpd, &httpd->dns) <= -1) return -1;
httpd->dns.type = QSE_HTTPD_DNS; httpd->dns.type = QSE_HTTPD_DNS;
@ -956,7 +953,6 @@ static int activate_urs (qse_httpd_t* httpd)
int i; int i;
QSE_MEMSET (&httpd->urs, 0, QSE_SIZEOF(httpd->urs)); QSE_MEMSET (&httpd->urs, 0, QSE_SIZEOF(httpd->urs));
if (httpd->opt.scb.urs.open (httpd, &httpd->urs) <= -1) return -1; if (httpd->opt.scb.urs.open (httpd, &httpd->urs) <= -1) return -1;
httpd->urs.type = QSE_HTTPD_URS; httpd->urs.type = QSE_HTTPD_URS;
@ -1035,7 +1031,7 @@ reread:
else if (m == 0) else if (m == 0)
{ {
#if 0 #if 0
qse_printf (QSE_T("Debug: connection closed %d\n"), client->handle.i); qse_printf (QSE_T("Debug: connection closed %d\n"), client->handle);
#endif #endif
/* reading from the client returned 0. this typically /* reading from the client returned 0. this typically
* happens when the client closes the connection or * happens when the client closes the connection or
@ -1051,14 +1047,14 @@ qse_printf (QSE_T("Debug: connection closed %d\n"), client->handle.i);
* http reader is not waiting for any more feeds. */ * http reader is not waiting for any more feeds. */
client->status |= QSE_HTTPD_CLIENT_MUTE; client->status |= QSE_HTTPD_CLIENT_MUTE;
#if 0 #if 0
qse_printf (QSE_T(">>>>> Marking client %d as MUTE\n"), client->handle.i); qse_printf (QSE_T(">>>>> Marking client %d as MUTE\n"), client->handle);
#endif #endif
return 0; return 0;
} }
else else
{ {
#if 0 #if 0
qse_printf (QSE_T(">>>>> Returning failure for client %d\n"), client->handle.i); qse_printf (QSE_T(">>>>> Returning failure for client %d\n"), client->handle);
#endif #endif
httpd->errnum = QSE_HTTPD_EDISCON; httpd->errnum = QSE_HTTPD_EDISCON;
return -1; return -1;
@ -1066,7 +1062,7 @@ qse_printf (QSE_T(">>>>> Returning failure for client %d\n"), client->handle.i);
} }
#if 0 #if 0
qse_printf (QSE_T("!!!!!FEEDING %d from %d ["), (int)m, (int)client->handle.i); qse_printf (QSE_T("!!!!!FEEDING %d from %d ["), (int)m, (int)client->handle);
#if !defined(__WATCOMC__) #if !defined(__WATCOMC__)
{ {
int i; int i;
@ -1091,7 +1087,7 @@ qse_printf (QSE_T("]\n"));
} }
#if 0 #if 0
qse_printf (QSE_T("Error: http error while processing %d ["), (int)client->handle.i); qse_printf (QSE_T("Error: http error while processing %d ["), (int)client->handle);
{ {
int i; int i;
for (i = 0; i < m; i++) qse_printf (QSE_T("%hc"), buf[i]); for (i = 0; i < m; i++) qse_printf (QSE_T("%hc"), buf[i]);
@ -1103,7 +1099,7 @@ qse_printf (QSE_T("]\n"));
#if 0 #if 0
qse_printf (QSE_T("!!!!!FEEDING OK OK OK OK %d from %d\n"), (int)m, (int)client->handle.i); qse_printf (QSE_T("!!!!!FEEDING OK OK OK OK %d from %d\n"), (int)m, (int)client->handle);
#endif #endif
if (client->status & QSE_HTTPD_CLIENT_PENDING) if (client->status & QSE_HTTPD_CLIENT_PENDING)
@ -1223,7 +1219,7 @@ static int update_mux_for_current_task (qse_httpd_t* httpd, qse_httpd_client_t*
int expected_trigger_mux_mask = 0; int expected_trigger_mux_mask = 0;
int expected_trigger_mux_status = 0; int expected_trigger_mux_status = 0;
if (task->trigger.v[i].handle.i == client->handle.i) continue; /* TODO: no direct comparision */ if (task->trigger.v[i].handle == client->handle) continue;
if (task->trigger.v[i].mask & QSE_HTTPD_TASK_TRIGGER_READ) if (task->trigger.v[i].mask & QSE_HTTPD_TASK_TRIGGER_READ)
{ {
@ -1370,14 +1366,13 @@ static int update_mux_for_next_task (qse_httpd_t* httpd, qse_httpd_client_t* cli
static int invoke_client_task ( static int invoke_client_task (
qse_httpd_t* httpd, qse_httpd_client_t* client, qse_httpd_t* httpd, qse_httpd_client_t* client,
qse_ubi_t handle, int mask) qse_httpd_hnd_t handle, int mask)
{ {
qse_httpd_task_t* task; qse_httpd_task_t* task;
qse_size_t i; qse_size_t i;
int n, trigger_fired; int n, trigger_fired;
/* TODO: handle comparison callback ... */ if (handle == client->handle && (mask & QSE_HTTPD_MUX_READ))
if (handle.i == client->handle.i && (mask & QSE_HTTPD_MUX_READ)) /* TODO: no direct comparision */
{ {
/* keep reading from the client-side as long as /* keep reading from the client-side as long as
* it's readable. */ * it's readable. */
@ -1407,7 +1402,7 @@ static int invoke_client_task (
trigger_fired = 0; trigger_fired = 0;
clear_trigger_mask_result (task); clear_trigger_mask_result (task);
if (handle.i == client->handle.i) /* TODO: no direct comparison */ if (handle == client->handle)
{ {
if (mask & QSE_HTTPD_MUX_READ) if (mask & QSE_HTTPD_MUX_READ)
{ {
@ -1426,7 +1421,7 @@ static int invoke_client_task (
{ {
for (i = 0; i < QSE_COUNTOF(task->trigger.v); i++) for (i = 0; i < QSE_COUNTOF(task->trigger.v); i++)
{ {
if (task->trigger.v[i].handle.i == handle.i) /* TODO: no direct comparision */ if (task->trigger.v[i].handle == handle)
{ {
if (mask & QSE_HTTPD_MUX_READ) if (mask & QSE_HTTPD_MUX_READ)
{ {
@ -1496,7 +1491,7 @@ static int invoke_client_task (
} }
static int perform_client_task ( static int perform_client_task (
qse_httpd_t* httpd, void* mux, qse_ubi_t handle, int mask, void* cbarg) qse_httpd_t* httpd, void* mux, qse_httpd_hnd_t handle, int mask, void* cbarg)
{ {
qse_httpd_client_t* client; qse_httpd_client_t* client;
@ -1535,7 +1530,7 @@ oops:
return -1; return -1;
} }
static int perform_dns (qse_httpd_t* httpd, void* mux, qse_ubi_t handle, int mask, void* cbarg) static int perform_dns (qse_httpd_t* httpd, void* mux, qse_httpd_hnd_t handle, int mask, void* cbarg)
{ {
qse_httpd_dns_t* dns = (qse_httpd_dns_t*)cbarg; qse_httpd_dns_t* dns = (qse_httpd_dns_t*)cbarg;
@ -1545,7 +1540,7 @@ static int perform_dns (qse_httpd_t* httpd, void* mux, qse_ubi_t handle, int mas
return httpd->opt.scb.dns.recv (httpd, dns, handle); return httpd->opt.scb.dns.recv (httpd, dns, handle);
} }
static int perform_urs (qse_httpd_t* httpd, void* mux, qse_ubi_t handle, int mask, void* cbarg) static int perform_urs (qse_httpd_t* httpd, void* mux, qse_httpd_hnd_t handle, int mask, void* cbarg)
{ {
qse_httpd_urs_t* urs = (qse_httpd_urs_t*)cbarg; qse_httpd_urs_t* urs = (qse_httpd_urs_t*)cbarg;
@ -1609,7 +1604,7 @@ qse_httpd_task_t* qse_httpd_entask (
} }
static int dispatch_mux ( static int dispatch_mux (
qse_httpd_t* httpd, void* mux, qse_ubi_t handle, int mask, void* cbarg) qse_httpd_t* httpd, void* mux, qse_httpd_hnd_t handle, int mask, void* cbarg)
{ {
switch (((qse_httpd_mate_t*)cbarg)->type) switch (((qse_httpd_mate_t*)cbarg)->type)
{ {

View File

@ -115,7 +115,7 @@ QSE_INLINE void qse_upxd_freemem (qse_upxd_t* upxd, void* ptr)
static int perform_session_task ( static int perform_session_task (
qse_upxd_t* upxd, void* mux, qse_ubi_t handle, void* cbarg) qse_upxd_t* upxd, void* mux, qse_upxd_hnd_t handle, void* cbarg)
{ {
qse_upxd_server_session_t* session; qse_upxd_server_session_t* session;
qse_upxd_server_t* server; qse_upxd_server_t* server;
@ -154,7 +154,7 @@ static int perform_session_task (
} }
static int perform_server_task ( static int perform_server_task (
qse_upxd_t* upxd, void* mux, qse_ubi_t handle, void* cbarg) qse_upxd_t* upxd, void* mux, qse_upxd_hnd_t handle, void* cbarg)
{ {
qse_upxd_server_t* server; qse_upxd_server_t* server;
qse_upxd_server_session_t* session; qse_upxd_server_session_t* session;