simplified relocation handling
deleted qse_httpd_entaskredir() and related definitions added virtual(function pointer) cgi support. improved pio to read /dev/fd implemented QSE_PIO_FNCCMD for qse_pio_t
This commit is contained in:
@ -59,6 +59,10 @@ enum qse_pio_flag_t
|
||||
* them to prevent inheritance. */
|
||||
QSE_PIO_NOCLOEXEC = (1 << 5),
|
||||
|
||||
/** indidate that the command to qse_pio_open() is a pointer to
|
||||
* #qse_pio_fnc_t. supported on unix/linux only */
|
||||
QSE_PIO_FNCCMD = (1 << 6),
|
||||
|
||||
/** write to stdin of a child process */
|
||||
QSE_PIO_WRITEIN = (1 << 8),
|
||||
/** read stdout of a child process */
|
||||
@ -113,6 +117,16 @@ enum qse_pio_hid_t
|
||||
};
|
||||
typedef enum qse_pio_hid_t qse_pio_hid_t;
|
||||
|
||||
|
||||
typedef int (*qse_pio_fncptr_t) (void* ctx, qse_env_char_t** envir);
|
||||
|
||||
typedef struct qse_pio_fnc_t qse_pio_fnc_t;
|
||||
struct qse_pio_fnc_t
|
||||
{
|
||||
qse_pio_fncptr_t ptr;
|
||||
void* ctx;
|
||||
};
|
||||
|
||||
/**
|
||||
* The qse_pio_errnum_t type defines error numbers.
|
||||
*/
|
||||
@ -177,6 +191,7 @@ struct qse_pio_pin_t
|
||||
qse_pio_t* self;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* The qse_pio_t type defines a structure to store status for piped I/O
|
||||
* to a child process. The qse_pio_xxx() funtions are written around this
|
||||
|
@ -28,6 +28,8 @@
|
||||
#include <qse/cmn/nwad.h>
|
||||
#include <qse/cmn/time.h>
|
||||
#include <qse/cmn/tmr.h>
|
||||
#include <qse/cmn/env.h>
|
||||
|
||||
|
||||
typedef struct qse_httpd_t qse_httpd_t;
|
||||
typedef struct qse_httpd_mate_t qse_httpd_mate_t;
|
||||
@ -689,6 +691,19 @@ struct qse_httpd_urs_t
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
/* ensure to define qse_httpd_fncptr_t to the same as
|
||||
* qse_pio_fncptr_t in <qse/cmn/pio.h> */
|
||||
typedef int (*qse_httpd_fncptr_t) (void* ctx, qse_env_char_t** envir);
|
||||
|
||||
typedef struct qse_httpd_fnc_t qse_httpd_fnc_t;
|
||||
struct qse_httpd_fnc_t
|
||||
{
|
||||
qse_httpd_fncptr_t ptr;
|
||||
void* ctx;
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* The qse_httpd_rsrc_type_t defines the resource type than can
|
||||
* be entasked with qse_httpd_entaskrsrc().
|
||||
@ -702,7 +717,6 @@ enum qse_httpd_rsrc_type_t
|
||||
QSE_HTTPD_RSRC_FILE,
|
||||
QSE_HTTPD_RSRC_PROXY,
|
||||
QSE_HTTPD_RSRC_RELOC,
|
||||
QSE_HTTPD_RSRC_REDIR,
|
||||
QSE_HTTPD_RSRC_TEXT
|
||||
};
|
||||
typedef enum qse_httpd_rsrc_type_t qse_httpd_rsrc_type_t;
|
||||
@ -711,16 +725,39 @@ enum qse_httpd_rsrc_flag_t
|
||||
{
|
||||
QSE_HTTPD_RSRC_100_CONTINUE = (1 << 0)
|
||||
};
|
||||
typedef enum qse_httpd_rsrc_flag_t qse_httpd_rsrc_flag_t;
|
||||
|
||||
enum qse_httpd_rsrc_cgi_flag_t
|
||||
{
|
||||
/* non-parsed header */
|
||||
QSE_HTTPD_RSRC_CGI_NPH = (1 << 0),
|
||||
|
||||
/* 'path' points to qse_httpd_fncptr_t && 'shebang' points to its context */
|
||||
QSE_HTTPD_RSRC_CGI_FNC = (1 << 1)
|
||||
};
|
||||
typedef enum qse_httpd_rsrc_cgi_flag_t qse_httpd_rsrc_cgi_flag_t;
|
||||
|
||||
|
||||
typedef struct qse_httpd_rsrc_cgi_t qse_httpd_rsrc_cgi_t;
|
||||
struct qse_httpd_rsrc_cgi_t
|
||||
{
|
||||
const qse_mchar_t* path;
|
||||
const qse_mchar_t* script;
|
||||
const qse_mchar_t* suffix;
|
||||
/* bitwised-ORed of #qse_httpd_rsrc_cgi_flag_t */
|
||||
int flags;
|
||||
|
||||
/* script path resolved against file system */
|
||||
const qse_mchar_t* path;
|
||||
|
||||
/* script path as in qpath */
|
||||
const qse_mchar_t* script;
|
||||
|
||||
/* trailing part of qpath excluding the script path.
|
||||
* for a qpath of /tmp/abc.cgi/a/b/c, if /tmp/abc.cgi is a script path,
|
||||
* /a/b/c forms the suffix.*/
|
||||
const qse_mchar_t* suffix;
|
||||
|
||||
const qse_mchar_t* root;
|
||||
|
||||
const qse_mchar_t* shebang;
|
||||
int nph;
|
||||
};
|
||||
|
||||
enum qse_httpd_rsrc_proxy_flag_t
|
||||
@ -733,6 +770,7 @@ enum qse_httpd_rsrc_proxy_flag_t
|
||||
QSE_HTTPD_RSRC_PROXY_DNS_SERVER = (1 << 5), /* dns address specified */
|
||||
QSE_HTTPD_RSRC_PROXY_URS_SERVER = (1 << 6), /* urs address specified */
|
||||
};
|
||||
typedef enum qse_httpd_rsrc_proxy_flag_t qse_httpd_rsrc_proxy_flag_t;
|
||||
|
||||
typedef struct qse_httpd_rsrc_proxy_t qse_httpd_rsrc_proxy_t;
|
||||
struct qse_httpd_rsrc_proxy_t
|
||||
@ -774,6 +812,21 @@ struct qse_httpd_rsrc_dir_t
|
||||
const qse_mchar_t* foot;
|
||||
};
|
||||
|
||||
enum qse_httpd_rsrc_reloc_flag_t
|
||||
{
|
||||
QSE_HTTPD_RSRC_RELOC_PERMANENT = (1 << 0),
|
||||
QSE_HTTPD_RSRC_RELOC_KEEPMETHOD = (1 << 1),
|
||||
QSE_HTTPD_RSRC_RELOC_APPENDSLASH = (1 << 2)
|
||||
};
|
||||
typedef enum qse_httpd_rsrc_reloc_flag_t qse_httpd_rsrc_reloc_flag_t;
|
||||
|
||||
typedef struct qse_httpd_rsrc_reloc_t qse_httpd_rsrc_reloc_t;
|
||||
struct qse_httpd_rsrc_reloc_t
|
||||
{
|
||||
int flags;
|
||||
const qse_mchar_t* dst;
|
||||
};
|
||||
|
||||
typedef struct qse_httpd_rsrc_t qse_httpd_rsrc_t;
|
||||
struct qse_httpd_rsrc_t
|
||||
{
|
||||
@ -802,15 +855,7 @@ struct qse_httpd_rsrc_t
|
||||
|
||||
qse_httpd_rsrc_proxy_t proxy;
|
||||
|
||||
struct
|
||||
{
|
||||
const qse_mchar_t* dst;
|
||||
} reloc;
|
||||
|
||||
struct
|
||||
{
|
||||
const qse_mchar_t* dst;
|
||||
} redir;
|
||||
qse_httpd_rsrc_reloc_t reloc;
|
||||
|
||||
struct
|
||||
{
|
||||
@ -1071,22 +1116,13 @@ QSE_EXPORT qse_httpd_task_t* qse_httpd_entaskauth (
|
||||
);
|
||||
|
||||
QSE_EXPORT qse_httpd_task_t* qse_httpd_entaskreloc (
|
||||
qse_httpd_t* httpd,
|
||||
qse_httpd_client_t* client,
|
||||
qse_httpd_task_t* pred,
|
||||
const qse_mchar_t* dst,
|
||||
qse_htre_t* req
|
||||
qse_httpd_t* httpd,
|
||||
qse_httpd_client_t* client,
|
||||
qse_httpd_task_t* pred,
|
||||
const qse_httpd_rsrc_reloc_t* reloc,
|
||||
qse_htre_t* req
|
||||
);
|
||||
|
||||
QSE_EXPORT qse_httpd_task_t* qse_httpd_entaskredir (
|
||||
qse_httpd_t* httpd,
|
||||
qse_httpd_client_t* client,
|
||||
qse_httpd_task_t* pred,
|
||||
const qse_mchar_t* dst,
|
||||
qse_htre_t* req
|
||||
);
|
||||
|
||||
|
||||
QSE_EXPORT qse_httpd_task_t* qse_httpd_entasknomod (
|
||||
qse_httpd_t* httpd,
|
||||
qse_httpd_client_t* client,
|
||||
|
@ -90,9 +90,17 @@ struct qse_httpd_serverstd_auth_t
|
||||
typedef struct qse_httpd_serverstd_cgi_t qse_httpd_serverstd_cgi_t;
|
||||
struct qse_httpd_serverstd_cgi_t
|
||||
{
|
||||
int cgi: 1;
|
||||
int nph: 1;
|
||||
const qse_mchar_t* shebang; /* optional, can be #QSE_NULL */
|
||||
unsigned int cgi: 1;
|
||||
unsigned int nph: 1;
|
||||
|
||||
/* optional, can be #QSE_NULL. */
|
||||
qse_httpd_fncptr_t fncptr;
|
||||
|
||||
/* optional, can be #QSE_NULL. if fncptr not #QSE_NULL, shebang is
|
||||
* interpreted as void* and used as a context pointer to fnc.
|
||||
* if fncptr is #QSE_NULL, it provides a pointer to the path
|
||||
* to the program interpreter for executing a cgi script. */
|
||||
const qse_mchar_t* shebang;
|
||||
};
|
||||
|
||||
typedef struct qse_httpd_serverstd_index_t qse_httpd_serverstd_index_t;
|
||||
@ -135,7 +143,22 @@ struct qse_httpd_serverstd_query_info_t
|
||||
{
|
||||
qse_httpd_client_t* client;
|
||||
qse_htre_t* req;
|
||||
qse_mchar_t* xpath; /* query path combined with document root */
|
||||
|
||||
/**
|
||||
* set to a query path combined with document root for these query types.
|
||||
* - #QSE_HTTPD_SERVERSTD_CGI
|
||||
* - #QSE_HTTPD_SERVERSTD_MIME
|
||||
* - #QSE_HTTPD_SERVERSTD_DIRACC
|
||||
* - #QSE_HTTPD_SERVERSTD_FILEACC
|
||||
* - #QSE_HTTPD_SERVERSTD_DIRHEAD
|
||||
* - #QSE_HTTPD_SERVERSTD_DIRFOOT
|
||||
*
|
||||
* set to #QSE_NULL for other query types.
|
||||
*/
|
||||
qse_mchar_t* xpath;
|
||||
|
||||
/** indiates that stat() failed over xpath when it's not #QSE_NULL. */
|
||||
int xpath_nx;
|
||||
};
|
||||
typedef struct qse_httpd_serverstd_query_info_t qse_httpd_serverstd_query_info_t;
|
||||
|
||||
|
Reference in New Issue
Block a user