attempting to add dynamic modules into httpd
This commit is contained in:
parent
b54964ac85
commit
4b0f12a896
@ -78,7 +78,8 @@ enum
|
|||||||
|
|
||||||
struct cgi_t
|
struct cgi_t
|
||||||
{
|
{
|
||||||
enum {
|
enum
|
||||||
|
{
|
||||||
CGI_PREFIX,
|
CGI_PREFIX,
|
||||||
CGI_SUFFIX,
|
CGI_SUFFIX,
|
||||||
CGI_NAME,
|
CGI_NAME,
|
||||||
@ -129,7 +130,8 @@ struct access_t
|
|||||||
{
|
{
|
||||||
/* TODO: support more types like ACCESS_GLOB
|
/* TODO: support more types like ACCESS_GLOB
|
||||||
not-only the base name, find a way to use query path or xpath */
|
not-only the base name, find a way to use query path or xpath */
|
||||||
enum {
|
enum
|
||||||
|
{
|
||||||
ACCESS_PREFIX,
|
ACCESS_PREFIX,
|
||||||
ACCESS_SUFFIX,
|
ACCESS_SUFFIX,
|
||||||
ACCESS_NAME,
|
ACCESS_NAME,
|
||||||
@ -353,7 +355,6 @@ static int daemonize (int devnull)
|
|||||||
|
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
static int make_resource (
|
static int make_resource (
|
||||||
qse_httpd_t* httpd, qse_httpd_client_t* client,
|
qse_httpd_t* httpd, qse_httpd_client_t* client,
|
||||||
qse_htre_t* req, qse_httpd_rsrc_t* rsrc)
|
qse_htre_t* req, qse_httpd_rsrc_t* rsrc)
|
||||||
@ -1779,6 +1780,37 @@ static qse_httpd_server_t* attach_server (qse_httpd_t* httpd, int num, qse_xli_l
|
|||||||
return xserver;
|
return xserver;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int load_hook_modules (qse_httpd_t* httpd, qse_xli_list_t* hook_list)
|
||||||
|
{
|
||||||
|
qse_char_t buf[32];
|
||||||
|
qse_xli_pair_t* pair;
|
||||||
|
httpd_xtn_t* httpd_xtn;
|
||||||
|
|
||||||
|
int i;
|
||||||
|
|
||||||
|
httpd_xtn = qse_httpd_getxtnstd (httpd);
|
||||||
|
|
||||||
|
for (i = 0; ; i++)
|
||||||
|
{
|
||||||
|
qse_strxfmt (buf, QSE_COUNTOF(buf), QSE_T("module[%d]"), i);
|
||||||
|
pair = qse_xli_findpair (httpd_xtn->xli, hook_list, buf);
|
||||||
|
if (pair == QSE_NULL) break;
|
||||||
|
|
||||||
|
pair = qse_xli_findpair (httpd_xtn->xli, (qse_xli_list_t*)pair->val, QSE_T("file"));
|
||||||
|
if (pair == QSE_NULL)
|
||||||
|
{
|
||||||
|
/* TODO: log warning when file is not found in module */
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qse_httpd_loadmod (httpd, ((qse_xli_str_t*)pair->val)->ptr);
|
||||||
|
/* TODO: error handling and logging */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
static int open_config_file (qse_httpd_t* httpd)
|
static int open_config_file (qse_httpd_t* httpd)
|
||||||
{
|
{
|
||||||
httpd_xtn_t* httpd_xtn;
|
httpd_xtn_t* httpd_xtn;
|
||||||
@ -1791,108 +1823,115 @@ static int open_config_file (qse_httpd_t* httpd)
|
|||||||
qse_xli_scm_t scm;
|
qse_xli_scm_t scm;
|
||||||
} defs[] =
|
} defs[] =
|
||||||
{
|
{
|
||||||
{ QSE_T("name"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
{ QSE_T("name"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||||
{ QSE_T("max-nofile"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
{ QSE_T("max-nofile"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||||
{ QSE_T("max-nproc"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
{ QSE_T("max-nproc"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||||
{ QSE_T("server-default"), { QSE_XLI_SCM_VALLIST | QSE_XLI_SCM_KEYNODUP, 0, 0 } },
|
|
||||||
{ QSE_T("server-default.ssl-cert-file"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
|
||||||
{ QSE_T("server-default.ssl-key-file"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
|
||||||
{ QSE_T("server-default.root"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
|
||||||
{ QSE_T("server-default.realm"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 0, 1 } },
|
|
||||||
{ QSE_T("server-default.auth"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 0, 1 } },
|
|
||||||
{ QSE_T("server-default.index"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 0xFFFF } },
|
|
||||||
{ QSE_T("server-default.auth-rule"), { QSE_XLI_SCM_VALLIST | QSE_XLI_SCM_KEYNODUP, 0, 0 } },
|
|
||||||
{ QSE_T("server-default.auth-rule.prefix"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 1, 1 } },
|
|
||||||
{ QSE_T("server-default.auth-rule.suffix"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 1, 1 } },
|
|
||||||
{ QSE_T("server-default.auth-rule.name"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 1, 1 } },
|
|
||||||
{ QSE_T("server-default.auth-rule.other"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
|
||||||
{ QSE_T("server-default.cgi"), { QSE_XLI_SCM_VALLIST | QSE_XLI_SCM_KEYNODUP, 0, 0 } },
|
|
||||||
{ QSE_T("server-default.cgi.prefix"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 0, 2 } },
|
|
||||||
{ QSE_T("server-default.cgi.suffix"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 0, 2 } },
|
|
||||||
{ QSE_T("server-default.cgi.name"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 0, 2 } },
|
|
||||||
{ QSE_T("server-default.mime"), { QSE_XLI_SCM_VALLIST | QSE_XLI_SCM_KEYNODUP, 0, 0 } },
|
|
||||||
{ QSE_T("server-default.mime.prefix"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 1, 1 } },
|
|
||||||
{ QSE_T("server-default.mime.suffix"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 1, 1 } },
|
|
||||||
{ QSE_T("server-default.mime.name"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 1, 1 } },
|
|
||||||
{ QSE_T("server-default.mime.other"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
|
||||||
{ QSE_T("server-default.dir-access"), { QSE_XLI_SCM_VALLIST | QSE_XLI_SCM_KEYNODUP, 0, 0 } },
|
|
||||||
{ QSE_T("server-default.dir-access.prefix"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 1, 1 } },
|
|
||||||
{ QSE_T("server-default.dir-access.suffix"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 1, 1 } },
|
|
||||||
{ QSE_T("server-default.dir-access.name"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 1, 1 } },
|
|
||||||
{ QSE_T("server-default.dir-access.other"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
|
||||||
{ QSE_T("server-default.file-access"), { QSE_XLI_SCM_VALLIST | QSE_XLI_SCM_KEYNODUP, 0, 0 } },
|
|
||||||
{ QSE_T("server-default.file-access.prefix"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 1, 1 } },
|
|
||||||
{ QSE_T("server-default.file-access.suffix"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 1, 1 } },
|
|
||||||
{ QSE_T("server-default.file-access.name"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 1, 1 } },
|
|
||||||
{ QSE_T("server-default.file-access.other"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
|
||||||
{ QSE_T("server-default.dir-head"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
|
||||||
{ QSE_T("server-default.dir-foot"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
|
||||||
{ QSE_T("server-default.error-head"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
|
||||||
{ QSE_T("server-default.error-foot"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
|
||||||
{ QSE_T("server-default.proxy"), { QSE_XLI_SCM_VALLIST | QSE_XLI_SCM_KEYNODUP, 0, 0 } },
|
|
||||||
{ QSE_T("server-default.proxy.http"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
|
||||||
{ QSE_T("server-default.proxy.connect"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
|
||||||
{ QSE_T("server-default.proxy.pseudonym"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
|
||||||
{ QSE_T("server-default.proxy.dns-enabled"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
|
||||||
{ QSE_T("server-default.proxy.dns-server"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
|
||||||
{ QSE_T("server-default.proxy.dns-timeout"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
|
||||||
{ QSE_T("server-default.proxy.dns-retries"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
|
||||||
{ QSE_T("server-default.proxy.urs-enabled"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
|
||||||
{ QSE_T("server-default.proxy.urs-server"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
|
||||||
{ QSE_T("server-default.proxy.urs-timeout"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
|
||||||
{ QSE_T("server-default.proxy.urs-retries"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
|
||||||
|
|
||||||
{ QSE_T("server"), { QSE_XLI_SCM_VALLIST, 0, 0 } },
|
{ QSE_T("hooks"), { QSE_XLI_SCM_VALLIST | QSE_XLI_SCM_KEYNODUP, 0, 0 } },
|
||||||
{ QSE_T("server.bind"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
{ QSE_T("hooks.module"), { QSE_XLI_SCM_VALLIST | QSE_XLI_SCM_KEYALIAS, 0, 0 } },
|
||||||
{ QSE_T("server.ssl"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
{ QSE_T("hooks.module.file"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||||
{ QSE_T("server.ssl-cert-file"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
/*{ QSE_T("hooks.module.config"), { QSE_XLI_SCM_VALLIST | QSE_XLI_SCM_KEYNODUP | QSE_SLI_SCM_SKIPVALIDATE, 0, 0 } },*/
|
||||||
{ QSE_T("server.ssl-key-file"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
|
||||||
{ QSE_T("server.host"), { QSE_XLI_SCM_VALLIST | QSE_XLI_SCM_KEYALIAS, 0, 0 } },
|
{ QSE_T("server-default"), { QSE_XLI_SCM_VALLIST | QSE_XLI_SCM_KEYNODUP, 0, 0 } },
|
||||||
{ QSE_T("server.host.location"), { QSE_XLI_SCM_VALLIST | QSE_XLI_SCM_KEYALIAS, 0, 0 } },
|
{ QSE_T("server-default.ssl-cert-file"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||||
{ QSE_T("server.host.location.root"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 0, 1 } },
|
{ QSE_T("server-default.ssl-key-file"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||||
{ QSE_T("server.host.location.realm"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 0, 1 } },
|
{ QSE_T("server-default.root"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||||
{ QSE_T("server.host.location.auth"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
{ QSE_T("server-default.realm"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 0, 1 } },
|
||||||
{ QSE_T("server.host.location.index"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 0xFFFF } },
|
{ QSE_T("server-default.auth"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 0, 1 } },
|
||||||
{ QSE_T("server.host.location.auth-rule"), { QSE_XLI_SCM_VALLIST | QSE_XLI_SCM_KEYNODUP, 0, 0 } },
|
{ QSE_T("server-default.index"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 0xFFFF } },
|
||||||
{ QSE_T("server.host.location.auth-rule.prefix"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 1, 1 } },
|
{ QSE_T("server-default.auth-rule"), { QSE_XLI_SCM_VALLIST | QSE_XLI_SCM_KEYNODUP, 0, 0 } },
|
||||||
{ QSE_T("server.host.location.auth-rule.suffix"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 1, 1 } },
|
{ QSE_T("server-default.auth-rule.prefix"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 1, 1 } },
|
||||||
{ QSE_T("server.host.location.auth-rule.name"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 1, 1 } },
|
{ QSE_T("server-default.auth-rule.suffix"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 1, 1 } },
|
||||||
{ QSE_T("server.host.location.auth-rule.other"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
{ QSE_T("server-default.auth-rule.name"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 1, 1 } },
|
||||||
{ QSE_T("server.host.location.cgi"), { QSE_XLI_SCM_VALLIST | QSE_XLI_SCM_KEYNODUP, 0, 0 } },
|
{ QSE_T("server-default.auth-rule.other"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||||
{ QSE_T("server.host.location.cgi.prefix"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 0, 2 } },
|
{ QSE_T("server-default.cgi"), { QSE_XLI_SCM_VALLIST | QSE_XLI_SCM_KEYNODUP, 0, 0 } },
|
||||||
{ QSE_T("server.host.location.cgi.suffix"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 0, 2 } },
|
{ QSE_T("server-default.cgi.prefix"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 0, 2 } },
|
||||||
{ QSE_T("server.host.location.cgi.name"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 0, 2 } },
|
{ QSE_T("server-default.cgi.suffix"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 0, 2 } },
|
||||||
{ QSE_T("server.host.location.mime"), { QSE_XLI_SCM_VALLIST | QSE_XLI_SCM_KEYNODUP, 0, 0 } },
|
{ QSE_T("server-default.cgi.name"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 0, 2 } },
|
||||||
{ QSE_T("server.host.location.mime.prefix"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 1, 1 } },
|
{ QSE_T("server-default.mime"), { QSE_XLI_SCM_VALLIST | QSE_XLI_SCM_KEYNODUP, 0, 0 } },
|
||||||
{ QSE_T("server.host.location.mime.suffix"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 1, 1 } },
|
{ QSE_T("server-default.mime.prefix"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 1, 1 } },
|
||||||
{ QSE_T("server.host.location.mime.name"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 1, 1 } },
|
{ QSE_T("server-default.mime.suffix"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 1, 1 } },
|
||||||
{ QSE_T("server.host.location.mime.other"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
{ QSE_T("server-default.mime.name"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 1, 1 } },
|
||||||
{ QSE_T("server.host.location.dir-access"), { QSE_XLI_SCM_VALLIST | QSE_XLI_SCM_KEYNODUP, 0, 0 } },
|
{ QSE_T("server-default.mime.other"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||||
{ QSE_T("server.host.location.dir-access.prefix"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 1, 1 } },
|
{ QSE_T("server-default.dir-access"), { QSE_XLI_SCM_VALLIST | QSE_XLI_SCM_KEYNODUP, 0, 0 } },
|
||||||
{ QSE_T("server.host.location.dir-access.suffix"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 1, 1 } },
|
{ QSE_T("server-default.dir-access.prefix"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 1, 1 } },
|
||||||
{ QSE_T("server.host.location.dir-access.name"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 1, 1 } },
|
{ QSE_T("server-default.dir-access.suffix"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 1, 1 } },
|
||||||
{ QSE_T("server.host.location.dir-access.other"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
{ QSE_T("server-default.dir-access.name"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 1, 1 } },
|
||||||
{ QSE_T("server.host.location.file-access"), { QSE_XLI_SCM_VALLIST | QSE_XLI_SCM_KEYNODUP, 0, 0 } },
|
{ QSE_T("server-default.dir-access.other"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||||
{ QSE_T("server.host.location.file-access.prefix"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 1, 1 } },
|
{ QSE_T("server-default.file-access"), { QSE_XLI_SCM_VALLIST | QSE_XLI_SCM_KEYNODUP, 0, 0 } },
|
||||||
{ QSE_T("server.host.location.file-access.suffix"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 1, 1 } },
|
{ QSE_T("server-default.file-access.prefix"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 1, 1 } },
|
||||||
{ QSE_T("server.host.location.file-access.name"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 1, 1 } },
|
{ QSE_T("server-default.file-access.suffix"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 1, 1 } },
|
||||||
{ QSE_T("server.host.location.file-access.other"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
{ QSE_T("server-default.file-access.name"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 1, 1 } },
|
||||||
{ QSE_T("server.host.location.dir-head"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
{ QSE_T("server-default.file-access.other"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||||
{ QSE_T("server.host.location.dir-foot"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
{ QSE_T("server-default.dir-head"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||||
{ QSE_T("server.host.location.error-head"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
{ QSE_T("server-default.dir-foot"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||||
{ QSE_T("server.host.location.error-foot"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
{ QSE_T("server-default.error-head"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||||
{ QSE_T("server.host.location.proxy"), { QSE_XLI_SCM_VALLIST | QSE_XLI_SCM_KEYNODUP, 0, 0 } },
|
{ QSE_T("server-default.error-foot"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||||
{ QSE_T("server.host.location.proxy.http"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
{ QSE_T("server-default.proxy"), { QSE_XLI_SCM_VALLIST | QSE_XLI_SCM_KEYNODUP, 0, 0 } },
|
||||||
{ QSE_T("server.host.location.proxy.connect"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
{ QSE_T("server-default.proxy.http"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||||
{ QSE_T("server.host.location.proxy.pseudonym"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
{ QSE_T("server-default.proxy.connect"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||||
{ QSE_T("server.host.location.proxy.dns-enabled"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
{ QSE_T("server-default.proxy.pseudonym"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||||
{ QSE_T("server.host.location.proxy.dns-server"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
{ QSE_T("server-default.proxy.dns-enabled"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||||
{ QSE_T("server.host.location.proxy.dns-timeout"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
{ QSE_T("server-default.proxy.dns-server"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||||
{ QSE_T("server.host.location.proxy.dns-retries"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
{ QSE_T("server-default.proxy.dns-timeout"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||||
{ QSE_T("server.host.location.proxy.urs-enabled"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
{ QSE_T("server-default.proxy.dns-retries"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||||
{ QSE_T("server.host.location.proxy.urs-server"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
{ QSE_T("server-default.proxy.urs-enabled"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||||
{ QSE_T("server.host.location.proxy.urs-timeout"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
{ QSE_T("server-default.proxy.urs-server"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||||
{ QSE_T("server.host.location.proxy.urs-retries"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
{ QSE_T("server-default.proxy.urs-timeout"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||||
|
{ QSE_T("server-default.proxy.urs-retries"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||||
|
|
||||||
|
{ QSE_T("server"), { QSE_XLI_SCM_VALLIST, 0, 0 } },
|
||||||
|
{ QSE_T("server.bind"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||||
|
{ QSE_T("server.ssl"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||||
|
{ QSE_T("server.ssl-cert-file"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||||
|
{ QSE_T("server.ssl-key-file"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||||
|
{ QSE_T("server.host"), { QSE_XLI_SCM_VALLIST | QSE_XLI_SCM_KEYALIAS, 0, 0 } },
|
||||||
|
{ QSE_T("server.host.location"), { QSE_XLI_SCM_VALLIST | QSE_XLI_SCM_KEYALIAS, 0, 0 } },
|
||||||
|
{ QSE_T("server.host.location.root"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 0, 1 } },
|
||||||
|
{ QSE_T("server.host.location.realm"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 0, 1 } },
|
||||||
|
{ QSE_T("server.host.location.auth"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||||
|
{ QSE_T("server.host.location.index"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 0xFFFF } },
|
||||||
|
{ QSE_T("server.host.location.auth-rule"), { QSE_XLI_SCM_VALLIST | QSE_XLI_SCM_KEYNODUP, 0, 0 } },
|
||||||
|
{ QSE_T("server.host.location.auth-rule.prefix"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 1, 1 } },
|
||||||
|
{ QSE_T("server.host.location.auth-rule.suffix"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 1, 1 } },
|
||||||
|
{ QSE_T("server.host.location.auth-rule.name"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 1, 1 } },
|
||||||
|
{ QSE_T("server.host.location.auth-rule.other"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||||
|
{ QSE_T("server.host.location.cgi"), { QSE_XLI_SCM_VALLIST | QSE_XLI_SCM_KEYNODUP, 0, 0 } },
|
||||||
|
{ QSE_T("server.host.location.cgi.prefix"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 0, 2 } },
|
||||||
|
{ QSE_T("server.host.location.cgi.suffix"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 0, 2 } },
|
||||||
|
{ QSE_T("server.host.location.cgi.name"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 0, 2 } },
|
||||||
|
{ QSE_T("server.host.location.mime"), { QSE_XLI_SCM_VALLIST | QSE_XLI_SCM_KEYNODUP, 0, 0 } },
|
||||||
|
{ QSE_T("server.host.location.mime.prefix"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 1, 1 } },
|
||||||
|
{ QSE_T("server.host.location.mime.suffix"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 1, 1 } },
|
||||||
|
{ QSE_T("server.host.location.mime.name"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 1, 1 } },
|
||||||
|
{ QSE_T("server.host.location.mime.other"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||||
|
{ QSE_T("server.host.location.dir-access"), { QSE_XLI_SCM_VALLIST | QSE_XLI_SCM_KEYNODUP, 0, 0 } },
|
||||||
|
{ QSE_T("server.host.location.dir-access.prefix"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 1, 1 } },
|
||||||
|
{ QSE_T("server.host.location.dir-access.suffix"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 1, 1 } },
|
||||||
|
{ QSE_T("server.host.location.dir-access.name"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 1, 1 } },
|
||||||
|
{ QSE_T("server.host.location.dir-access.other"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||||
|
{ QSE_T("server.host.location.file-access"), { QSE_XLI_SCM_VALLIST | QSE_XLI_SCM_KEYNODUP, 0, 0 } },
|
||||||
|
{ QSE_T("server.host.location.file-access.prefix"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 1, 1 } },
|
||||||
|
{ QSE_T("server.host.location.file-access.suffix"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 1, 1 } },
|
||||||
|
{ QSE_T("server.host.location.file-access.name"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYALIAS, 1, 1 } },
|
||||||
|
{ QSE_T("server.host.location.file-access.other"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||||
|
{ QSE_T("server.host.location.dir-head"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||||
|
{ QSE_T("server.host.location.dir-foot"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||||
|
{ QSE_T("server.host.location.error-head"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||||
|
{ QSE_T("server.host.location.error-foot"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||||
|
{ QSE_T("server.host.location.proxy"), { QSE_XLI_SCM_VALLIST | QSE_XLI_SCM_KEYNODUP, 0, 0 } },
|
||||||
|
{ QSE_T("server.host.location.proxy.http"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||||
|
{ QSE_T("server.host.location.proxy.connect"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||||
|
{ QSE_T("server.host.location.proxy.pseudonym"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||||
|
{ QSE_T("server.host.location.proxy.dns-enabled"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||||
|
{ QSE_T("server.host.location.proxy.dns-server"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||||
|
{ QSE_T("server.host.location.proxy.dns-timeout"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||||
|
{ QSE_T("server.host.location.proxy.dns-retries"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||||
|
{ QSE_T("server.host.location.proxy.urs-enabled"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||||
|
{ QSE_T("server.host.location.proxy.urs-server"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||||
|
{ QSE_T("server.host.location.proxy.urs-timeout"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||||
|
{ QSE_T("server.host.location.proxy.urs-retries"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
|
||||||
|
{ QSE_T("server.host.location.proxy.urs-prerewrite"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -2028,6 +2067,9 @@ static int load_config (qse_httpd_t* httpd)
|
|||||||
set_limit (httpd, QSE_T("max-nproc"), RLIMIT_NPROC);
|
set_limit (httpd, QSE_T("max-nproc"), RLIMIT_NPROC);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
pair = qse_xli_findpair (httpd_xtn->xli, QSE_NULL, QSE_T("hooks"));
|
||||||
|
if (pair) load_hook_modules (httpd, (qse_xli_list_t*)pair->val);
|
||||||
|
|
||||||
for (i = 0; ; i++)
|
for (i = 0; ; i++)
|
||||||
{
|
{
|
||||||
qse_char_t buf[32];
|
qse_char_t buf[32];
|
||||||
@ -2140,6 +2182,12 @@ static int prerewrite_url (qse_httpd_t* httpd, qse_httpd_client_t* client, qse_h
|
|||||||
httpd_xtn = qse_httpd_getxtnstd (httpd);
|
httpd_xtn = qse_httpd_getxtnstd (httpd);
|
||||||
|
|
||||||
printf ("PREREWRITING.....................\n");
|
printf ("PREREWRITING.....................\n");
|
||||||
|
if (qse_htre_getqmethodtype(req) == QSE_HTTP_CONNECT)
|
||||||
|
{
|
||||||
|
*url = QSE_NULL;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* TODO: override prerewrite url */
|
/* TODO: override prerewrite url */
|
||||||
return httpd_xtn->org_urs_prerewrite (httpd, client, req, host, url);
|
return httpd_xtn->org_urs_prerewrite (httpd, client, req, host, url);
|
||||||
}
|
}
|
||||||
|
@ -87,6 +87,20 @@ 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;
|
||||||
|
struct qse_httpd_mod_t
|
||||||
|
{
|
||||||
|
/* set before mod.open() */
|
||||||
|
qse_char_t* name;
|
||||||
|
|
||||||
|
/* manipulatable by the implementer */
|
||||||
|
void* handle;
|
||||||
|
|
||||||
|
/* private */
|
||||||
|
qse_httpd_mod_t* next;
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct qse_httpd_stat_t qse_httpd_stat_t;
|
typedef struct qse_httpd_stat_t qse_httpd_stat_t;
|
||||||
struct qse_httpd_stat_t
|
struct qse_httpd_stat_t
|
||||||
{
|
{
|
||||||
@ -155,8 +169,6 @@ typedef void (*qse_httpd_rewrite_t) (
|
|||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
typedef int (*qse_httpd_urs_open_t) (
|
typedef int (*qse_httpd_urs_open_t) (
|
||||||
qse_httpd_t* httpd,
|
qse_httpd_t* httpd,
|
||||||
qse_httpd_urs_t* urs
|
qse_httpd_urs_t* urs
|
||||||
@ -182,13 +194,21 @@ typedef int (*qse_httpd_urs_send_t) (
|
|||||||
void* ctx
|
void* ctx
|
||||||
);
|
);
|
||||||
|
|
||||||
/* on success, url must point to a null-teminated string which
|
/* Success is indicated by a positive return value including 0.
|
||||||
* can be freed with qse_httpd_freemem() when not needed anymore.
|
* When it's 0, url must point to #QSE_NULL or a null-teminated
|
||||||
* the return value of 0 indicates that the string is the final
|
* string. When it's greater than 0, url must point to a null-terminated
|
||||||
* rewriting result and no sending to urs-server is required.
|
* string. The null-terminated string is freed with qse_httpd_freemem()
|
||||||
* if the return value is greater than 0, the string sent to the
|
* when not needed.
|
||||||
* urs-server for the actual rewriting. a negative return value
|
*
|
||||||
* indicates failure.
|
* The return value of 0 indicates that the string is the final
|
||||||
|
* rewriting result and no sending to urs-server is required. The URL of
|
||||||
|
* #QSE_NULL , when the return value is 0, indicates that no translation
|
||||||
|
* is required.
|
||||||
|
*
|
||||||
|
* If the return value is greater than 0, the string is sent to the
|
||||||
|
* urs-server for the actual rewriting.
|
||||||
|
*
|
||||||
|
* A negative return value indicates failure.
|
||||||
*/
|
*/
|
||||||
typedef int (*qse_httpd_urs_prerewrite_t) (
|
typedef int (*qse_httpd_urs_prerewrite_t) (
|
||||||
qse_httpd_t* httpd,
|
qse_httpd_t* httpd,
|
||||||
@ -201,6 +221,13 @@ typedef int (*qse_httpd_urs_prerewrite_t) (
|
|||||||
typedef struct qse_httpd_scb_t qse_httpd_scb_t;
|
typedef struct qse_httpd_scb_t qse_httpd_scb_t;
|
||||||
struct qse_httpd_scb_t
|
struct qse_httpd_scb_t
|
||||||
{
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
int (*open) (qse_httpd_t* httpd, qse_httpd_mod_t* mod);
|
||||||
|
void (*close) (qse_httpd_t* httpd, qse_httpd_mod_t* mod);
|
||||||
|
void* (*symbol) (qse_httpd_t* httpd, qse_httpd_mod_t* mod, const qse_char_t* name);
|
||||||
|
} mod; /* module */
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
int (*open) (qse_httpd_t* httpd, qse_httpd_server_t* server);
|
int (*open) (qse_httpd_t* httpd, qse_httpd_server_t* server);
|
||||||
@ -233,17 +260,13 @@ struct qse_httpd_scb_t
|
|||||||
int (*delhnd) (qse_httpd_t* httpd, void* mux, qse_ubi_t handle);
|
int (*delhnd) (qse_httpd_t* httpd, void* mux, qse_ubi_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) (
|
int (*readable) (qse_httpd_t* httpd, qse_ubi_t handle, const qse_ntime_t* tmout);
|
||||||
qse_httpd_t* httpd, qse_ubi_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_ubi_t handle, const qse_ntime_t* tmout);
|
|
||||||
} mux;
|
} mux;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
int (*stat) (
|
int (*stat) (qse_httpd_t* httpd, const qse_mchar_t* path, qse_httpd_stat_t* stat);
|
||||||
qse_httpd_t* httpd, const qse_mchar_t* path,
|
|
||||||
qse_httpd_stat_t* stat);
|
|
||||||
int (*purge) (qse_httpd_t* httpd, const qse_mchar_t* path);
|
int (*purge) (qse_httpd_t* httpd, const qse_mchar_t* path);
|
||||||
|
|
||||||
int (*ropen) (
|
int (*ropen) (
|
||||||
@ -751,6 +774,7 @@ struct qse_httpd_ecb_t
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
@ -18,6 +18,7 @@ libqsehttp_la_SOURCES = \
|
|||||||
httpd-proxy.c \
|
httpd-proxy.c \
|
||||||
httpd-std.c \
|
httpd-std.c \
|
||||||
httpd-std-dns.h \
|
httpd-std-dns.h \
|
||||||
|
httpd-std-mod.h \
|
||||||
httpd-std-urs.h \
|
httpd-std-urs.h \
|
||||||
httpd-task.c \
|
httpd-task.c \
|
||||||
httpd-text.c \
|
httpd-text.c \
|
||||||
|
@ -340,6 +340,7 @@ libqsehttp_la_SOURCES = \
|
|||||||
httpd-proxy.c \
|
httpd-proxy.c \
|
||||||
httpd-std.c \
|
httpd-std.c \
|
||||||
httpd-std-dns.h \
|
httpd-std-dns.h \
|
||||||
|
httpd-std-mod.h \
|
||||||
httpd-std-urs.h \
|
httpd-std-urs.h \
|
||||||
httpd-task.c \
|
httpd-task.c \
|
||||||
httpd-text.c \
|
httpd-text.c \
|
||||||
|
@ -2072,7 +2072,7 @@ static int task_main_proxy (
|
|||||||
/* proxy->url_to_rewrite is the final rewritten URL by prerewrite().
|
/* proxy->url_to_rewrite is the final rewritten URL by prerewrite().
|
||||||
* pass QSE_NULL as the second parameter to on_url_rewritten() to
|
* pass QSE_NULL as the second parameter to on_url_rewritten() to
|
||||||
* indicate that the original URL is not known */
|
* indicate that the original URL is not known */
|
||||||
on_url_rewritten (httpd, QSE_NULL, proxy->url_to_rewrite, task);
|
on_url_rewritten (httpd, QSE_NULL, (proxy->url_to_rewrite? proxy->url_to_rewrite: QSE_MT("")), task);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
216
qse/lib/http/httpd-std-mod.h
Normal file
216
qse/lib/http/httpd-std-mod.h
Normal file
@ -0,0 +1,216 @@
|
|||||||
|
#if !defined(QSE_HTTPD_DEFAULT_MODPREFIX)
|
||||||
|
# if defined(_WIN32)
|
||||||
|
# define QSE_HTTPD_DEFAULT_MODPREFIX "qsehttpd-"
|
||||||
|
# elif defined(__OS2__)
|
||||||
|
# define QSE_HTTPD_DEFAULT_MODPREFIX "htd-"
|
||||||
|
# elif defined(__DOS__)
|
||||||
|
# define QSE_HTTPD_DEFAULT_MODPREFIX "htd-"
|
||||||
|
# else
|
||||||
|
# define QSE_HTTPD_DEFAULT_MODPREFIX "libqsehttpd-"
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(QSE_HTTPD_DEFAULT_MODPOSTFIX)
|
||||||
|
# define QSE_HTTPD_DEFAULT_MODPOSTFIX ""
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
static int mod_open (qse_httpd_t* httpd, qse_httpd_mod_t* mod)
|
||||||
|
{
|
||||||
|
#if defined(USE_LTDL)
|
||||||
|
void* h;
|
||||||
|
qse_mchar_t* modpath;
|
||||||
|
const qse_char_t* tmp[4];
|
||||||
|
int count;
|
||||||
|
|
||||||
|
count = 0;
|
||||||
|
if (spec->prefix) tmp[count++] = spec->prefix;
|
||||||
|
tmp[count++] = mod->name;
|
||||||
|
if (spec->postfix) tmp[count++] = spec->postfix;
|
||||||
|
tmp[count] = QSE_NULL;
|
||||||
|
|
||||||
|
#if defined(QSE_CHAR_IS_MCHAR)
|
||||||
|
modpath = qse_mbsadup (tmp, QSE_NULL, httpd->mmgr);
|
||||||
|
#else
|
||||||
|
modpath = qse_wcsatombsdup (tmp, QSE_NULL, httpd->mmgr);
|
||||||
|
#endif
|
||||||
|
if (!modpath)
|
||||||
|
{
|
||||||
|
qse_httpd_seterrnum (httpd, QSE_HTTPD_ENOMEM, QSE_NULL);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
h = lt_dlopenext (modpath);
|
||||||
|
|
||||||
|
QSE_MMGR_FREE (httpd->mmgr, modpath);
|
||||||
|
|
||||||
|
if (h == QSE_NULL) return -1;
|
||||||
|
mod->handle = h;
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
|
||||||
|
#elif defined(_WIN32)
|
||||||
|
|
||||||
|
HMODULE h;
|
||||||
|
qse_char_t* modpath;
|
||||||
|
const qse_char_t* tmp[4];
|
||||||
|
int count;
|
||||||
|
|
||||||
|
count = 0;
|
||||||
|
if (spec->prefix) tmp[count++] = spec->prefix;
|
||||||
|
tmp[count++] = spec->name;
|
||||||
|
if (spec->postfix) tmp[count++] = spec->postfix;
|
||||||
|
tmp[count] = QSE_NULL;
|
||||||
|
|
||||||
|
modpath = qse_stradup (tmp, QSE_NULL, httpd->mmgr);
|
||||||
|
if (!modpath)
|
||||||
|
{
|
||||||
|
qse_httpd_seterrnum (httpd, QSE_HTTPD_ENOMEM, QSE_NULL);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
h = LoadLibrary (modpath);
|
||||||
|
|
||||||
|
QSE_MMGR_FREE (httpd->mmgr, modpath);
|
||||||
|
|
||||||
|
QSE_ASSERT (QSE_SIZEOF(h) <= QSE_SIZEOF(void*));
|
||||||
|
|
||||||
|
if (h == QSE_NULL) return -1;
|
||||||
|
mod->handle = h;
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
#elif defined(__OS2__)
|
||||||
|
|
||||||
|
HMODULE h;
|
||||||
|
qse_mchar_t* modpath;
|
||||||
|
const qse_char_t* tmp[4];
|
||||||
|
int count;
|
||||||
|
char errbuf[CCHMAXPATH];
|
||||||
|
APIRET rc;
|
||||||
|
|
||||||
|
count = 0;
|
||||||
|
if (spec->prefix) tmp[count++] = spec->prefix;
|
||||||
|
tmp[count++] = spec->name;
|
||||||
|
if (spec->postfix) tmp[count++] = spec->postfix;
|
||||||
|
tmp[count] = QSE_NULL;
|
||||||
|
|
||||||
|
#if defined(QSE_CHAR_IS_MCHAR)
|
||||||
|
modpath = qse_mbsadup (tmp, QSE_NULL, httpd->mmgr);
|
||||||
|
#else
|
||||||
|
modpath = qse_wcsatombsdup (tmp, QSE_NULL, httpd->mmgr);
|
||||||
|
#endif
|
||||||
|
if (!modpath)
|
||||||
|
{
|
||||||
|
qse_httpd_seterrnum (httpd, QSE_HTTPD_ENOMEM, QSE_NULL);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* DosLoadModule() seems to have severe limitation on
|
||||||
|
* the file name it can load (max-8-letters.xxx) */
|
||||||
|
rc = DosLoadModule (errbuf, QSE_COUNTOF(errbuf) - 1, modpath, &h);
|
||||||
|
if (rc != NO_ERROR) h = QSE_NULL;
|
||||||
|
|
||||||
|
QSE_MMGR_FREE (httpd->mmgr, modpath);
|
||||||
|
|
||||||
|
QSE_ASSERT (QSE_SIZEOF(h) <= QSE_SIZEOF(void*));
|
||||||
|
|
||||||
|
if (h == QSE_NULL) return -1;
|
||||||
|
mod->handle = h;
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
|
||||||
|
#elif defined(__DOS__)
|
||||||
|
|
||||||
|
/* the DOS code here is not generic enough. it's for a specific
|
||||||
|
* dos-extender only. the best is to enable QSE_ENABLE_STATIC_MODULE
|
||||||
|
* when building for DOS. */
|
||||||
|
void* h;
|
||||||
|
qse_mchar_t* modpath;
|
||||||
|
const qse_char_t* tmp[4];
|
||||||
|
int count;
|
||||||
|
|
||||||
|
count = 0;
|
||||||
|
if (spec->prefix) tmp[count++] = spec->prefix;
|
||||||
|
tmp[count++] = spec->name;
|
||||||
|
if (spec->postfix) tmp[count++] = spec->postfix;
|
||||||
|
tmp[count] = QSE_NULL;
|
||||||
|
|
||||||
|
#if defined(QSE_CHAR_IS_MCHAR)
|
||||||
|
modpath = qse_mbsadup (tmp, QSE_NULL, httpd->mmgr);
|
||||||
|
#else
|
||||||
|
modpath = qse_wcsatombsdup (tmp, QSE_NULL, httpd->mmgr);
|
||||||
|
#endif
|
||||||
|
if (!modpath)
|
||||||
|
{
|
||||||
|
qse_httpd_seterrnum (httpd, QSE_HTTPD_ENOMEM, QSE_NULL);
|
||||||
|
return 01;
|
||||||
|
}
|
||||||
|
|
||||||
|
h = LoadModule (modpath);
|
||||||
|
|
||||||
|
QSE_MMGR_FREE (httpd->mmgr, modpath);
|
||||||
|
|
||||||
|
QSE_ASSERT (QSE_SIZEOF(h) <= QSE_SIZEOF(void*));
|
||||||
|
|
||||||
|
if (h == QSE_NULL) return -1;
|
||||||
|
mod->handle = h;
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
#else
|
||||||
|
qse_httpd_seterrnum (httpd, QSE_HTTPD_ENOIMPL);
|
||||||
|
return -1;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static void mod_close (qse_httpd_t* httpd, qse_httpd_mod_t* mod)
|
||||||
|
{
|
||||||
|
#if defined(USE_LTDL)
|
||||||
|
lt_dlclose (mod->handle);
|
||||||
|
#elif defined(_WIN32)
|
||||||
|
FreeLibrary ((HMODULE)mod->handle);
|
||||||
|
#elif defined(__OS2__)
|
||||||
|
DosFreeModule ((HMODULE)mod->handle);
|
||||||
|
#elif defined(__DOS__)
|
||||||
|
FreeModule (mod->handle);
|
||||||
|
#else
|
||||||
|
/* nothing to do */
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static void* mod_symbol (qse_httpd_t* httpd, qse_httpd_mod_t* handle, const qse_char_t* name)
|
||||||
|
{
|
||||||
|
void* s;
|
||||||
|
qse_mchar_t* mname;
|
||||||
|
|
||||||
|
#if defined(QSE_CHAR_IS_MCHAR)
|
||||||
|
mname = name;
|
||||||
|
#else
|
||||||
|
mname = qse_wcstombsdup (name, QSE_NULL, httpd->mmgr);
|
||||||
|
if (!mname)
|
||||||
|
{
|
||||||
|
qse_httpd_seterrnum (httpd, QSE_HTTPD_ENOMEM);
|
||||||
|
return QSE_NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(USE_LTDL)
|
||||||
|
s = lt_dlsym (mod->handle, mname);
|
||||||
|
#elif defined(_WIN32)
|
||||||
|
s = GetProcAddress ((HMODULE)mod->handle, mname);
|
||||||
|
#elif defined(__OS2__)
|
||||||
|
if (DosQueryProcAddr ((HMODULE)mod->handle, 0, mname, (PFN*)&s) != NO_ERROR) s = QSE_NULL;
|
||||||
|
#elif defined(__DOS__)
|
||||||
|
s = GetProcAddress (mod->handle, mname);
|
||||||
|
#else
|
||||||
|
s = QSE_NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(QSE_CHAR_IS_MCHAR)
|
||||||
|
/* nothing to do */
|
||||||
|
#else
|
||||||
|
QSE_MMGR_FREE (httpd->mmgr, mname);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
@ -2294,6 +2294,7 @@ static qse_size_t hash_string (const qse_mchar_t *str)
|
|||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include "httpd-std-mod.h"
|
||||||
#include "httpd-std-dns.h"
|
#include "httpd-std-dns.h"
|
||||||
#include "httpd-std-urs.h"
|
#include "httpd-std-urs.h"
|
||||||
|
|
||||||
@ -2301,72 +2302,87 @@ static qse_size_t hash_string (const qse_mchar_t *str)
|
|||||||
|
|
||||||
static qse_httpd_scb_t httpd_system_callbacks =
|
static qse_httpd_scb_t httpd_system_callbacks =
|
||||||
{
|
{
|
||||||
/* server */
|
/* module */
|
||||||
{ server_open,
|
{
|
||||||
server_close,
|
mod_open,
|
||||||
server_accept
|
mod_close,
|
||||||
|
mod_symbol
|
||||||
},
|
},
|
||||||
|
|
||||||
{ peer_open,
|
/* server */
|
||||||
peer_close,
|
{
|
||||||
peer_connected,
|
server_open,
|
||||||
peer_recv,
|
server_close,
|
||||||
peer_send
|
server_accept
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
peer_open,
|
||||||
|
peer_close,
|
||||||
|
peer_connected,
|
||||||
|
peer_recv,
|
||||||
|
peer_send
|
||||||
},
|
},
|
||||||
|
|
||||||
/* multiplexer */
|
/* multiplexer */
|
||||||
{ mux_open,
|
{
|
||||||
mux_close,
|
mux_open,
|
||||||
mux_addhnd,
|
mux_close,
|
||||||
mux_delhnd,
|
mux_addhnd,
|
||||||
mux_poll,
|
mux_delhnd,
|
||||||
|
mux_poll,
|
||||||
|
|
||||||
mux_readable,
|
mux_readable,
|
||||||
mux_writable
|
mux_writable
|
||||||
},
|
},
|
||||||
|
|
||||||
/* file operation */
|
/* file operation */
|
||||||
{ file_stat,
|
{
|
||||||
file_purge,
|
file_stat,
|
||||||
file_ropen,
|
file_purge,
|
||||||
file_wopen,
|
file_ropen,
|
||||||
file_close,
|
file_wopen,
|
||||||
file_read,
|
file_close,
|
||||||
file_write
|
file_read,
|
||||||
|
file_write
|
||||||
},
|
},
|
||||||
|
|
||||||
/* directory operation */
|
/* directory operation */
|
||||||
{ dir_stat,
|
{
|
||||||
dir_make,
|
dir_stat,
|
||||||
dir_purge,
|
dir_make,
|
||||||
dir_open,
|
dir_purge,
|
||||||
dir_close,
|
dir_open,
|
||||||
dir_read
|
dir_close,
|
||||||
|
dir_read
|
||||||
},
|
},
|
||||||
|
|
||||||
/* client connection */
|
/* client connection */
|
||||||
{ client_close,
|
{
|
||||||
client_shutdown,
|
client_close,
|
||||||
client_recv,
|
client_shutdown,
|
||||||
client_send,
|
client_recv,
|
||||||
client_sendfile,
|
client_send,
|
||||||
client_accepted,
|
client_sendfile,
|
||||||
client_closed
|
client_accepted,
|
||||||
|
client_closed
|
||||||
},
|
},
|
||||||
|
|
||||||
/* dns */
|
/* dns */
|
||||||
{ dns_open,
|
{
|
||||||
dns_close,
|
dns_open,
|
||||||
dns_recv,
|
dns_close,
|
||||||
dns_send
|
dns_recv,
|
||||||
|
dns_send
|
||||||
},
|
},
|
||||||
|
|
||||||
/* urs */
|
/* urs */
|
||||||
{ urs_open,
|
{
|
||||||
urs_close,
|
urs_open,
|
||||||
urs_recv,
|
urs_close,
|
||||||
urs_send,
|
urs_recv,
|
||||||
urs_prerewrite
|
urs_send,
|
||||||
|
urs_prerewrite
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -37,6 +37,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_ubi_t handle, int mask, void* cbarg);
|
||||||
|
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 };
|
||||||
|
|
||||||
@ -89,6 +90,7 @@ void qse_httpd_fini (qse_httpd_t* httpd)
|
|||||||
{
|
{
|
||||||
free_server_list (httpd);
|
free_server_list (httpd);
|
||||||
qse_tmr_close (httpd->tmr);
|
qse_tmr_close (httpd->tmr);
|
||||||
|
unload_all_modules (httpd);
|
||||||
}
|
}
|
||||||
|
|
||||||
void qse_httpd_stop (qse_httpd_t* httpd)
|
void qse_httpd_stop (qse_httpd_t* httpd)
|
||||||
@ -1844,3 +1846,61 @@ void qse_httpd_removetimerevent (qse_httpd_t* httpd, qse_tmr_index_t index)
|
|||||||
{
|
{
|
||||||
qse_tmr_remove (httpd->tmr, index);
|
qse_tmr_remove (httpd->tmr, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void unload_all_modules (qse_httpd_t* httpd)
|
||||||
|
{
|
||||||
|
qse_httpd_mod_t* mod;
|
||||||
|
|
||||||
|
while (httpd->modlist)
|
||||||
|
{
|
||||||
|
mod = httpd->modlist;
|
||||||
|
httpd->modlist = mod->next;
|
||||||
|
|
||||||
|
/* call fini */
|
||||||
|
httpd->opt.scb.mod.close (httpd, mod);
|
||||||
|
qse_httpd_freemem (httpd, mod);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int qse_httpd_loadmod (qse_httpd_t* httpd, const qse_char_t* name)
|
||||||
|
{
|
||||||
|
qse_httpd_mod_t* mod;
|
||||||
|
qse_size_t name_len;
|
||||||
|
|
||||||
|
/* TODO: no singly linked list speed up */
|
||||||
|
name_len = qse_strlen(name);
|
||||||
|
|
||||||
|
mod = qse_httpd_allocmem (httpd, QSE_SIZEOF(*mod) + name_len + 1);
|
||||||
|
if (mod == QSE_NULL) return -1;
|
||||||
|
|
||||||
|
QSE_MEMSET (mod, 0, QSE_SIZEOF(*mod));
|
||||||
|
mod->name = mod + 1;
|
||||||
|
qse_strcpy (mod->name, name);
|
||||||
|
|
||||||
|
if (httpd->opt.scb.mod.open (httpd, mod) <= -1)
|
||||||
|
{
|
||||||
|
qse_httpd_freemem (httpd, mod);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* TODO: find init and execute it. if it fails, unload it. */
|
||||||
|
|
||||||
|
mod->next = httpd->modlist;
|
||||||
|
httpd->modlist = mod;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
qse_httpd_mod_t* qse_httpd_findmod (qse_httpd_t* httpd, const qse_char_t* name)
|
||||||
|
{
|
||||||
|
qse_httpd_mod_t* mod;
|
||||||
|
|
||||||
|
/* TODO: no sequential search. speed up */
|
||||||
|
for (mod = httpd->modlist; mod; mod = mod->next)
|
||||||
|
{
|
||||||
|
if (qse_strcmp (mod->name, name) == 0) return mod;
|
||||||
|
}
|
||||||
|
|
||||||
|
return QSE_NULL;
|
||||||
|
}
|
||||||
|
@ -52,6 +52,8 @@ struct qse_httpd_t
|
|||||||
qse_mchar_t sname[128]; /* server name for the server header */
|
qse_mchar_t sname[128]; /* server name for the server header */
|
||||||
qse_mchar_t gtbuf[10][64]; /* GMT time buffers */
|
qse_mchar_t gtbuf[10][64]; /* GMT time buffers */
|
||||||
|
|
||||||
|
qse_httpd_mod_t* modlist;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
struct
|
struct
|
||||||
|
Loading…
x
Reference in New Issue
Block a user