added qse_shutsckhnd()
This commit is contained in:
		| @ -55,6 +55,14 @@ | |||||||
| 	typedef int qse_sck_len_t; | 	typedef int qse_sck_len_t; | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  | enum qse_shutsckhnd_how_t | ||||||
|  | { | ||||||
|  | 	QSE_SHUTSCKHND_R  = 0, | ||||||
|  | 	QSE_SHUTSCKHND_W  = 1, | ||||||
|  | 	QSE_SHUTSCKHND_RW = 2 | ||||||
|  | }; | ||||||
|  | typedef enum qse_shutsckhnd_how_t qse_shutsckhnd_how_t; | ||||||
|  |  | ||||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||||
| extern "C" { | extern "C" { | ||||||
| #endif | #endif | ||||||
| @ -67,6 +75,12 @@ QSE_EXPORT void qse_closesckhnd ( | |||||||
| 	qse_sck_hnd_t handle | 	qse_sck_hnd_t handle | ||||||
| ); | ); | ||||||
|  |  | ||||||
|  |  | ||||||
|  | QSE_EXPORT void qse_shutsckhnd ( | ||||||
|  | 	qse_sck_hnd_t        handle, | ||||||
|  | 	qse_shutsckhnd_how_t how | ||||||
|  | ); | ||||||
|  |  | ||||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||||
| } | } | ||||||
| #endif | #endif | ||||||
|  | |||||||
| @ -51,6 +51,10 @@ | |||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  |  | ||||||
|  | #if !defined(SHUT_RDWR) | ||||||
|  | #	define SHUT_RDWR 2 | ||||||
|  | #endif | ||||||
|  |  | ||||||
| QSE_INLINE int qse_isvalidsckhnd (qse_sck_hnd_t handle) | QSE_INLINE int qse_isvalidsckhnd (qse_sck_hnd_t handle) | ||||||
| { | { | ||||||
| #if defined(_WIN32) | #if defined(_WIN32) | ||||||
| @ -80,6 +84,22 @@ QSE_INLINE void qse_closesckhnd (qse_sck_hnd_t handle) | |||||||
| #endif | #endif | ||||||
| } | } | ||||||
|  |  | ||||||
|  | QSE_INLINE void qse_shutsckhnd (qse_sck_hnd_t handle, qse_shutsckhnd_how_t how) | ||||||
|  | { | ||||||
|  | 	static int how_v[] = { SHUT_RD, SHUT_WR, SHUT_RDWR }; | ||||||
|  |  | ||||||
|  | #if defined(_WIN32) | ||||||
|  | 	shutdown (handle, how_v[how]); | ||||||
|  | #elif defined(__OS2__) | ||||||
|  | 	shutdown (handle, how_v[how]); | ||||||
|  | #elif defined(__DOS__) | ||||||
|  | 	/* TODO: */ | ||||||
|  | #else | ||||||
|  | 	shutdown (handle, how_v[how]); | ||||||
|  | #endif | ||||||
|  | } | ||||||
|  |  | ||||||
|  |  | ||||||
| #if 0 | #if 0 | ||||||
| qse_sck_hnd_t | qse_sck_hnd_t | ||||||
|  |  | ||||||
|  | |||||||
| @ -461,7 +461,7 @@ on failure xfer != ret. | |||||||
|  |  | ||||||
| #else | #else | ||||||
|  |  | ||||||
| 	qse_mchar_t buf[MAX_SEND_SIZE]; | 	qse_mchar_t buf[MAX_SEND_SIZE]; /* TODO: move this into client, server, or httpd */ | ||||||
| 	qse_ssize_t ret; | 	qse_ssize_t ret; | ||||||
| 	qse_foff_t foff; | 	qse_foff_t foff; | ||||||
|  |  | ||||||
| @ -1829,36 +1829,16 @@ static int dir_read (qse_httpd_t* httpd, qse_ubi_t handle, qse_httpd_dirent_t* d | |||||||
| } | } | ||||||
|  |  | ||||||
| /* ------------------------------------------------------------------- */ | /* ------------------------------------------------------------------- */ | ||||||
| #if !defined(SHUT_RDWR) |  | ||||||
| #	define SHUT_RDWR 2 |  | ||||||
| #endif |  | ||||||
|  |  | ||||||
| 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); | ||||||
| #if defined(_WIN32) |  | ||||||
| 	shutdown (client->handle.i, SHUT_RDWR); |  | ||||||
| #elif defined(__OS2__) |  | ||||||
| 	shutdown (client->handle.i, SHUT_RDWR); |  | ||||||
| #elif defined(__DOS__) |  | ||||||
| 	/* TODO: */ |  | ||||||
| #else |  | ||||||
| 	shutdown (client->handle.i, SHUT_RDWR); |  | ||||||
| #endif |  | ||||||
| 	qse_closesckhnd (client->handle.i); | 	qse_closesckhnd (client->handle.i); | ||||||
| } | } | ||||||
|  |  | ||||||
| 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) | ||||||
| { | { | ||||||
| #if defined(_WIN32) | 	qse_shutsckhnd (client->handle.i, QSE_SHUTSCKHND_RW); | ||||||
| 	shutdown (client->handle.i, SHUT_RDWR); |  | ||||||
| #elif defined(__OS2__) |  | ||||||
| 	shutdown (client->handle.i, SHUT_RDWR); |  | ||||||
| #elif defined(__DOS__) |  | ||||||
| 	/* TODO: */ |  | ||||||
| #else |  | ||||||
| 	shutdown (client->handle.i, SHUT_RDWR); |  | ||||||
| #endif |  | ||||||
| } | } | ||||||
|  |  | ||||||
| static qse_ssize_t client_recv ( | static qse_ssize_t client_recv ( | ||||||
| @ -1954,7 +1934,6 @@ static qse_ssize_t client_sendfile ( | |||||||
|  |  | ||||||
| static int client_accepted (qse_httpd_t* httpd, qse_httpd_client_t* client) | static int client_accepted (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) | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user