added qse_httpd_entaskpath().
renames qse_httpd_entaskXXX() functions to a newer style
This commit is contained in:
		| @ -165,9 +165,9 @@ void qse_htrd_setrecbs ( | ||||
|  * callback function if it has processed a proper htrd request.  | ||||
|  */ | ||||
| int qse_htrd_feed ( | ||||
| 	qse_htrd_t*       htrd, /**< htrd */ | ||||
| 	const qse_htoc_t* req,  /**< request octets */ | ||||
| 	qse_size_t        len   /**< number of octets */ | ||||
| 	qse_htrd_t*        htrd, /**< htrd */ | ||||
| 	const qse_mchar_t* req,  /**< request octets */ | ||||
| 	qse_size_t         len   /**< number of octets */ | ||||
| ); | ||||
|  | ||||
| int qse_htrd_read ( | ||||
|  | ||||
| @ -31,8 +31,6 @@ | ||||
| #include <qse/cmn/htb.h> | ||||
| #include <qse/cmn/time.h> | ||||
|  | ||||
| typedef qse_mchar_t qse_htoc_t; | ||||
|  | ||||
| /* octet buffer */ | ||||
| typedef qse_mbs_t qse_htob_t; | ||||
|  | ||||
| @ -80,11 +78,20 @@ typedef qse_foff_t qse_http_range_int_t; | ||||
| typedef qse_ulong_t qse_http_range_int_t; | ||||
| #endif | ||||
|  | ||||
| enum qse_http_range_type_t | ||||
| { | ||||
| 	QSE_HTTP_RANGE_NONE, | ||||
| 	QSE_HTTP_RANGE_PROPER, | ||||
| 	QSE_HTTP_RANGE_SUFFIX | ||||
| }; | ||||
| typedef enum qse_http_range_type_t qse_http_range_type_t; | ||||
| /** | ||||
|  * The qse_http_range_t type defines a structure that can represent | ||||
|  * a value for the @b Range: http header.  | ||||
|  * | ||||
|  * If suffix is non-zero, 'from' is meaningleass and 'to' indicates  | ||||
|  * If type is #QSE_HTTP_RANGE_NONE, this range is not valid. | ||||
|  *  | ||||
|  * If type is #QSE_HTTP_RANGE_SUFFIX, 'from' is meaningleass and 'to' indicates  | ||||
|  * the number of bytes from the back.  | ||||
|  *  - -500    => last 500 bytes | ||||
|  * | ||||
| @ -95,16 +102,17 @@ typedef qse_ulong_t qse_http_range_int_t; | ||||
|  *  range.to = range.to + range.from - 1; | ||||
|  * @endcode | ||||
|  * | ||||
|  * If suffix is zero, 'from' and 'to' represents a proper range where | ||||
|  * the value of 0 indicates the first byte. This doesn't require any adjustment. | ||||
|  * If type is #QSE_HTTP_RANGE_PROPER, 'from' and 'to' represents a proper range | ||||
|  * where the value of 0 indicates the first byte. This doesn't require any  | ||||
|  * adjustment. | ||||
|  *  - 0-999   => first 1000 bytes | ||||
|  *  - 99-     => from the 100th bytes to the end. | ||||
|  */ | ||||
| struct qse_http_range_t | ||||
| { | ||||
| 	int suffix;                /**< suffix indicator */ | ||||
| 	qse_http_range_int_t from; /**< starting offset */ | ||||
| 	qse_http_range_int_t to;   /**< ending offset */ | ||||
| 	qse_http_range_type_t type; /**< type indicator */ | ||||
| 	qse_http_range_int_t from;  /**< starting offset */ | ||||
| 	qse_http_range_int_t to;    /**< ending offset */ | ||||
| }; | ||||
| typedef struct qse_http_range_t qse_http_range_t; | ||||
|  | ||||
| @ -112,12 +120,12 @@ typedef struct qse_http_range_t qse_http_range_t; | ||||
| extern "C" { | ||||
| #endif | ||||
|  | ||||
| const qse_htoc_t* qse_gethttpmethodname ( | ||||
| const qse_mchar_t* qse_gethttpmethodname ( | ||||
| 	qse_http_method_t type | ||||
| ); | ||||
|  | ||||
| int qse_gethttpmethodtype ( | ||||
| 	const qse_htoc_t* name,  | ||||
| 	const qse_mchar_t* name,  | ||||
| 	qse_http_method_t* method | ||||
| ); | ||||
|  | ||||
|  | ||||
| @ -46,16 +46,38 @@ typedef enum qse_httpd_errnum_t qse_httpd_errnum_t; | ||||
| typedef struct qse_httpd_cbs_t qse_httpd_cbs_t; | ||||
| struct qse_httpd_cbs_t | ||||
| { | ||||
| 	int (*handle_request)         (qse_httpd_t* httpd, qse_httpd_client_t* client, qse_htre_t* req); | ||||
| 	int (*handle_expect_continue) (qse_httpd_t* httpd, qse_httpd_client_t* client, qse_htre_t* req); | ||||
| 	int (*handle_request) ( | ||||
| 		qse_httpd_t* httpd, qse_httpd_client_t* client, qse_htre_t* req); | ||||
| 	int (*handle_expect_continue) ( | ||||
| 		qse_httpd_t* httpd, qse_httpd_client_t* client, qse_htre_t* req); | ||||
| }; | ||||
|  | ||||
| typedef struct qse_httpd_task_t qse_httpd_task_t; | ||||
|  | ||||
| typedef int (*qse_httpd_task_init_t) ( | ||||
| 	qse_httpd_t* httpd, | ||||
| 	qse_httpd_client_t* client, | ||||
| 	qse_httpd_task_t* task | ||||
| ); | ||||
|  | ||||
| typedef void (*qse_httpd_task_fini_t) (	 | ||||
| 	qse_httpd_t* httpd, | ||||
| 	qse_httpd_client_t* client, | ||||
| 	qse_httpd_task_t* task | ||||
| ); | ||||
|  | ||||
| typedef int (*qse_httpd_task_main_t) ( | ||||
| 	qse_httpd_t* httpd, | ||||
| 	qse_httpd_client_t* client, | ||||
| 	qse_httpd_task_t* task | ||||
| ); | ||||
|  | ||||
| struct qse_httpd_task_t | ||||
| { | ||||
| 	int   (*init) (qse_httpd_t* httpd, qse_httpd_client_t* client, qse_httpd_task_t* task); | ||||
| 	void  (*fini) (qse_httpd_t* httpd, qse_httpd_client_t* client, qse_httpd_task_t* task); | ||||
| 	int   (*main) (qse_httpd_t* httpd, qse_httpd_client_t* client, qse_httpd_task_t* task); | ||||
| 	/* you must not call another entask functions from within initailizer */ | ||||
| 	qse_httpd_task_init_t init; | ||||
| 	qse_httpd_task_fini_t fini; | ||||
| 	qse_httpd_task_main_t main; | ||||
| 	void* ctx; | ||||
| }; | ||||
|  | ||||
| @ -106,6 +128,12 @@ int qse_httpd_addlisteners ( | ||||
| 	const qse_char_t* uri | ||||
| ); | ||||
|  | ||||
|  | ||||
| void qse_httpd_markclientbad ( | ||||
| 	qse_httpd_t*        httpd, | ||||
| 	qse_httpd_client_t* client | ||||
| ); | ||||
|  | ||||
| #define qse_httpd_gettaskxtn(httpd,task) ((void*)(task+1)) | ||||
|  | ||||
| int qse_httpd_entask ( | ||||
| @ -115,27 +143,35 @@ int qse_httpd_entask ( | ||||
| 	qse_size_t              xtnsize | ||||
| ); | ||||
|  | ||||
| int qse_httpd_entasksendtext ( | ||||
| int qse_httpd_entasktext ( | ||||
| 	qse_httpd_t*        httpd, | ||||
| 	qse_httpd_client_t* client, | ||||
| 	const qse_mchar_t*  text | ||||
| ); | ||||
|  | ||||
| int qse_httpd_entasksendfmt ( | ||||
| int qse_httpd_entaskformat ( | ||||
| 	qse_httpd_t*        httpd, | ||||
| 	qse_httpd_client_t* client, | ||||
| 	const qse_mchar_t*  fmt, | ||||
| 	... | ||||
| ); | ||||
|  | ||||
| int qse_httpd_entasksendfile ( | ||||
| int qse_httpd_entaskfile ( | ||||
| 	qse_httpd_t*        httpd, | ||||
| 	qse_httpd_client_t* client, | ||||
| 	int                 fd, | ||||
| 	qse_ubi_t           handle, | ||||
| 	qse_foff_t          offset, | ||||
| 	qse_foff_t          size | ||||
| ); | ||||
|  | ||||
| int qse_httpd_entaskpath ( | ||||
| 	qse_httpd_t*              httpd, | ||||
| 	qse_httpd_client_t*       client, | ||||
| 	const qse_mchar_t*        name, | ||||
| 	const qse_http_range_t*   range, | ||||
| 	const qse_http_version_t* version | ||||
| ); | ||||
|  | ||||
| int qse_httpd_entaskdisconnect ( | ||||
| 	qse_httpd_t*        httpd, | ||||
| 	qse_httpd_client_t* client | ||||
|  | ||||
		Reference in New Issue
	
	Block a user