added experimental code to pass unvalidated configuration items to a module
This commit is contained in:
parent
f049aa4b09
commit
c23e2a4a7c
@ -2045,7 +2045,7 @@ static qse_httpd_server_t* attach_server (qse_httpd_t* httpd, int num, qse_xli_l
|
|||||||
static int load_hook_modules (qse_httpd_t* httpd, qse_xli_list_t* hook_list)
|
static int load_hook_modules (qse_httpd_t* httpd, qse_xli_list_t* hook_list)
|
||||||
{
|
{
|
||||||
qse_char_t buf[32];
|
qse_char_t buf[32];
|
||||||
qse_xli_pair_t* pair;
|
qse_xli_pair_t* pair, * cfg;
|
||||||
httpd_xtn_t* httpd_xtn;
|
httpd_xtn_t* httpd_xtn;
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
@ -2065,7 +2065,8 @@ static int load_hook_modules (qse_httpd_t* httpd, qse_xli_list_t* hook_list)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qse_httpd_loadmod (httpd, ((qse_xli_str_t*)pair->val)->ptr);
|
cfg = qse_xli_findpair (httpd_xtn->xli, (qse_xli_list_t*)pair->val, QSE_T("config"));
|
||||||
|
qse_httpd_loadmod (httpd, ((qse_xli_str_t*)pair->val)->ptr, (cfg? cfg->val: QSE_NULL));
|
||||||
/* TODO: error handling and logging */
|
/* TODO: error handling and logging */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,10 @@ max-nproc = none;
|
|||||||
#hooks {
|
#hooks {
|
||||||
# module "ext-1" {
|
# module "ext-1" {
|
||||||
# file = "ext";
|
# file = "ext";
|
||||||
|
# config {
|
||||||
|
# item1 = abc;
|
||||||
|
# item2 = def;
|
||||||
|
# }
|
||||||
# }
|
# }
|
||||||
#}
|
#}
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
#include <qse/cmn/time.h>
|
#include <qse/cmn/time.h>
|
||||||
#include <qse/cmn/tmr.h>
|
#include <qse/cmn/tmr.h>
|
||||||
#include <qse/cmn/env.h>
|
#include <qse/cmn/env.h>
|
||||||
|
#include <qse/xli/xli.h>
|
||||||
|
|
||||||
typedef struct qse_httpd_t qse_httpd_t;
|
typedef struct qse_httpd_t qse_httpd_t;
|
||||||
typedef struct qse_httpd_mate_t qse_httpd_mate_t;
|
typedef struct qse_httpd_mate_t qse_httpd_mate_t;
|
||||||
@ -103,7 +103,8 @@ 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) (
|
||||||
qse_httpd_mod_t* mod
|
qse_httpd_mod_t* mod,
|
||||||
|
const qse_xli_list_t* cfg
|
||||||
);
|
);
|
||||||
|
|
||||||
typedef void (*qse_httpd_mod_unload_t) (
|
typedef void (*qse_httpd_mod_unload_t) (
|
||||||
@ -1419,8 +1420,9 @@ QSE_EXPORT int qse_httpd_rewriteurl (
|
|||||||
);
|
);
|
||||||
|
|
||||||
QSE_EXPORT int qse_httpd_loadmod (
|
QSE_EXPORT int qse_httpd_loadmod (
|
||||||
qse_httpd_t* httpd,
|
qse_httpd_t* httpd,
|
||||||
const qse_char_t* name
|
const qse_char_t* name,
|
||||||
|
const qse_xli_list_t* list
|
||||||
);
|
);
|
||||||
|
|
||||||
QSE_EXPORT qse_httpd_mod_t* qse_httpd_findmod (
|
QSE_EXPORT qse_httpd_mod_t* qse_httpd_findmod (
|
||||||
|
@ -115,6 +115,7 @@ enum qse_xli_trait_t
|
|||||||
* "tg" is stored into the tag field of qse_xli_str_t. */
|
* "tg" is stored into the tag field of qse_xli_str_t. */
|
||||||
QSE_XLI_STRTAG = (1 << 10),
|
QSE_XLI_STRTAG = (1 << 10),
|
||||||
|
|
||||||
|
/** enable pair validation against pair definitions while reading */
|
||||||
QSE_XLI_VALIDATE = (1 << 11)
|
QSE_XLI_VALIDATE = (1 << 11)
|
||||||
};
|
};
|
||||||
typedef enum qse_xli_trait_t qse_xli_trait_t;
|
typedef enum qse_xli_trait_t qse_xli_trait_t;
|
||||||
@ -679,7 +680,6 @@ QSE_EXPORT int qse_xli_write (
|
|||||||
qse_xli_io_impl_t io
|
qse_xli_io_impl_t io
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
QSE_EXPORT void* qse_getxlipairxtn (
|
QSE_EXPORT void* qse_getxlipairxtn (
|
||||||
qse_xli_pair_t* pair
|
qse_xli_pair_t* pair
|
||||||
);
|
);
|
||||||
|
@ -2236,7 +2236,7 @@ static void unload_all_modules (qse_httpd_t* httpd)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int qse_httpd_loadmod (qse_httpd_t* httpd, const qse_char_t* name)
|
int qse_httpd_loadmod (qse_httpd_t* httpd, const qse_char_t* name, const qse_xli_list_t* cfg)
|
||||||
{
|
{
|
||||||
qse_httpd_mod_t* mod;
|
qse_httpd_mod_t* mod;
|
||||||
qse_size_t name_len, prefix_len, postfix_len, fullname_len;
|
qse_size_t name_len, prefix_len, postfix_len, fullname_len;
|
||||||
@ -2308,7 +2308,7 @@ int qse_httpd_loadmod (qse_httpd_t* httpd, const qse_char_t* name)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (load == QSE_NULL || load (mod) <= -1)
|
if (load == QSE_NULL || load (mod, cfg) <= -1)
|
||||||
{
|
{
|
||||||
httpd->opt.scb.mod.close (httpd, mod->handle);
|
httpd->opt.scb.mod.close (httpd, mod->handle);
|
||||||
qse_httpd_freemem (httpd, mod);
|
qse_httpd_freemem (httpd, mod);
|
||||||
|
Loading…
Reference in New Issue
Block a user