renamed QSE_XLI_SCM_RELAXED to QSE_XLI_SCM_VALIFFY.
added qse_httpd_configmod(). changed qse_httpd_loadmod() to return qse_httpd_mod_t*
This commit is contained in:
parent
c23e2a4a7c
commit
49febef055
@ -360,14 +360,14 @@ struct qse_awk_mod_data_t
|
||||
qse_awk_mod_t mod;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int qse_awk_init (qse_awk_t* awk, qse_mmgr_t* mmgr, const qse_awk_prm_t* prm);
|
||||
void qse_awk_fini (qse_awk_t* awk);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
#include "awk.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
@ -37,7 +37,7 @@ QSE_EXPORT void* qse_awk_stdmodopen (qse_awk_t* awk, const qse_awk_mod_spec_t* s
|
||||
QSE_EXPORT void qse_awk_stdmodclose (qse_awk_t* awk, void* handle);
|
||||
QSE_EXPORT void* qse_awk_stdmodsym (qse_awk_t* awk, void* handle, const qse_char_t* name);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -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, const qse_xli_list_t* cfg)
|
||||
qse_httpd_mod_t* qse_httpd_loadmod (qse_httpd_t* httpd, const qse_char_t* name)
|
||||
{
|
||||
qse_httpd_mod_t* mod;
|
||||
qse_size_t name_len, prefix_len, postfix_len, fullname_len;
|
||||
@ -2276,7 +2276,7 @@ int qse_httpd_loadmod (qse_httpd_t* httpd, const qse_char_t* name, const qse_xli
|
||||
*/
|
||||
fullname_len = prefix_len + name_len + postfix_len;
|
||||
mod = qse_httpd_callocmem (httpd, QSE_SIZEOF(*mod) + (name_len + 1 + fullname_len + 1 + 15 + name_len + 2) * QSE_SIZEOF(qse_char_t));
|
||||
if (mod == QSE_NULL) return -1;
|
||||
if (mod == QSE_NULL) return QSE_NULL;
|
||||
|
||||
mod->httpd = httpd;
|
||||
mod->name = (qse_char_t*)(mod + 1);
|
||||
@ -2290,7 +2290,7 @@ int qse_httpd_loadmod (qse_httpd_t* httpd, const qse_char_t* name, const qse_xli
|
||||
if (!mod->handle)
|
||||
{
|
||||
qse_httpd_freemem (httpd, mod);
|
||||
return -1;
|
||||
return QSE_NULL;
|
||||
}
|
||||
|
||||
/* attempt qse_httpd_mod_xxx */
|
||||
@ -2308,16 +2308,35 @@ int qse_httpd_loadmod (qse_httpd_t* httpd, const qse_char_t* name, const qse_xli
|
||||
}
|
||||
}
|
||||
|
||||
if (load == QSE_NULL || load (mod, cfg) <= -1)
|
||||
if (!load || load (mod) <= -1)
|
||||
{
|
||||
httpd->opt.scb.mod.close (httpd, mod->handle);
|
||||
qse_httpd_freemem (httpd, mod);
|
||||
return -1;
|
||||
return QSE_NULL;
|
||||
}
|
||||
|
||||
/* link the loaded module to the module list */
|
||||
mod->next = httpd->modlist;
|
||||
httpd->modlist = mod;
|
||||
return 0;
|
||||
|
||||
return mod;
|
||||
}
|
||||
|
||||
int qse_httpd_configmod (qse_httpd_t* httpd, qse_httpd_mod_t* mod, const qse_char_t* key, const qse_char_t* value)
|
||||
{
|
||||
QSE_ASSERT (httpd == mod->httpd);
|
||||
|
||||
if (mod->config)
|
||||
{
|
||||
return mod->config (mod, key, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* not allowed to set the module configuration
|
||||
* without the 'config' handler */
|
||||
httpd->errnum = QSE_HTTPD_EACCES;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
qse_httpd_mod_t* qse_httpd_findmod (qse_httpd_t* httpd, const qse_char_t* name)
|
||||
|
@ -134,7 +134,7 @@ struct qse_httpd_real_task_t
|
||||
|
||||
#define MAX_NWAD_TEXT_SIZE 96
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
@ -206,7 +206,7 @@ qse_httpd_peer_t* qse_httpd_decacheproxypeer (
|
||||
int secure
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -23,13 +23,15 @@
|
||||
|
||||
static int get_char (qse_xli_t* xli);
|
||||
static int get_token (qse_xli_t* xli);
|
||||
static int read_list (qse_xli_t* xli, qse_xli_list_t* list, int skip_validation);
|
||||
static int read_list (qse_xli_t* xli, qse_xli_list_t* list, const qse_xli_scm_t* override);
|
||||
|
||||
enum
|
||||
{
|
||||
TOK_STATUS_ENABLE_NSTR = (1 << 0)
|
||||
};
|
||||
|
||||
static qse_xli_scm_t scm_val_iffy = { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 };
|
||||
|
||||
static int close_current_stream (qse_xli_t* xli)
|
||||
{
|
||||
qse_ssize_t n;
|
||||
@ -659,7 +661,7 @@ static int get_token (qse_xli_t* xli)
|
||||
return get_token_into (xli, &xli->tok);
|
||||
}
|
||||
|
||||
static int read_pair (qse_xli_t* xli, const qse_char_t* keytag, int skip_validation)
|
||||
static int read_pair (qse_xli_t* xli, const qse_char_t* keytag, const qse_xli_scm_t* override)
|
||||
{
|
||||
qse_cstr_t key;
|
||||
qse_xli_loc_t kloc;
|
||||
@ -669,8 +671,8 @@ static int read_pair (qse_xli_t* xli, const qse_char_t* keytag, int skip_validat
|
||||
qse_size_t dotted_curkey_len;
|
||||
qse_char_t* strtag;
|
||||
|
||||
qse_xli_scm_t* scm = QSE_NULL;
|
||||
int key_nodup = 0, key_alias = 0;
|
||||
const qse_xli_scm_t* scm = QSE_NULL;
|
||||
int key_nodup = 0, key_alias = 0, val_iffy = 0;
|
||||
|
||||
key.ptr = QSE_NULL;
|
||||
name = QSE_NULL;
|
||||
@ -699,7 +701,10 @@ static int read_pair (qse_xli_t* xli, const qse_char_t* keytag, int skip_validat
|
||||
goto oops;
|
||||
}
|
||||
|
||||
if (!skip_validation && (xli->opt.trait & QSE_XLI_VALIDATE))
|
||||
if (xli->opt.trait & QSE_XLI_VALIDATE)
|
||||
{
|
||||
if (override) scm = override;
|
||||
else
|
||||
{
|
||||
qse_rbt_pair_t* pair;
|
||||
|
||||
@ -711,9 +716,11 @@ static int read_pair (qse_xli_t* xli, const qse_char_t* keytag, int skip_validat
|
||||
}
|
||||
|
||||
scm = (qse_xli_scm_t*)QSE_RBT_VPTR(pair);
|
||||
}
|
||||
|
||||
if (scm->flags & QSE_XLI_SCM_KEYNODUP) key_nodup = 2;
|
||||
if (scm->flags & QSE_XLI_SCM_KEYALIAS) key_alias = 2;
|
||||
if (scm->flags & QSE_XLI_SCM_VALIFFY) val_iffy = 1;
|
||||
}
|
||||
|
||||
if (key_nodup)
|
||||
@ -901,10 +908,10 @@ static int read_pair (qse_xli_t* xli, const qse_char_t* keytag, int skip_validat
|
||||
if (pair == QSE_NULL) goto oops;
|
||||
|
||||
/* skip validations of child pairs if the schema for the
|
||||
* current pair is set with QSE_XLI_SCM_RELAXED.
|
||||
* current pair is set with QSE_XLI_SCM_VALIFFY.
|
||||
* the schema for the child pairs, if specified, must not
|
||||
* take effect. */
|
||||
if (read_list (xli, (qse_xli_list_t*)pair->val, (scm && (scm->flags & QSE_XLI_SCM_RELAXED))) <= -1) goto oops;
|
||||
if (read_list (xli, (qse_xli_list_t*)pair->val, (val_iffy? &scm_val_iffy: QSE_NULL)) <= -1) goto oops;
|
||||
|
||||
if (!MATCH (xli, TOK_RBRACE))
|
||||
{
|
||||
@ -992,7 +999,7 @@ static void free_list_link (qse_xli_t* xli, qse_xli_list_link_t* link)
|
||||
qse_xli_freemem (xli, link);
|
||||
}
|
||||
|
||||
static int __read_list (qse_xli_t* xli, int skip_validation)
|
||||
static int __read_list (qse_xli_t* xli, const qse_xli_scm_t* override)
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
@ -1033,13 +1040,13 @@ static int __read_list (qse_xli_t* xli, int skip_validation)
|
||||
return -1;
|
||||
}
|
||||
|
||||
x = read_pair (xli, keytag, skip_validation);
|
||||
x = read_pair (xli, keytag, override);
|
||||
QSE_MMGR_FREE (xli->mmgr, keytag);
|
||||
if (x <= -1) return -1;
|
||||
}
|
||||
else if (MATCH (xli, TOK_IDENT))
|
||||
{
|
||||
if (read_pair (xli, QSE_NULL, skip_validation) <= -1) return -1;
|
||||
if (read_pair (xli, QSE_NULL, override) <= -1) return -1;
|
||||
}
|
||||
else if (MATCH (xli, TOK_TEXT))
|
||||
{
|
||||
@ -1054,7 +1061,7 @@ static int __read_list (qse_xli_t* xli, int skip_validation)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int read_list (qse_xli_t* xli, qse_xli_list_t* parlist, int skip_validation)
|
||||
static int read_list (qse_xli_t* xli, qse_xli_list_t* parlist, const qse_xli_scm_t* override)
|
||||
{
|
||||
qse_xli_list_link_t* link;
|
||||
|
||||
@ -1064,7 +1071,7 @@ static int read_list (qse_xli_t* xli, qse_xli_list_t* parlist, int skip_validati
|
||||
/* get_token() here is to read the token after the left brace.
|
||||
* it must be called after the xli->parlink has been updated
|
||||
* in case there are comments at the beginning of the list */
|
||||
if (get_token (xli) <= -1 || __read_list (xli, skip_validation) <= -1)
|
||||
if (get_token (xli) <= -1 || __read_list (xli, override) <= -1)
|
||||
{
|
||||
free_list_link (xli, link);
|
||||
return -1;
|
||||
@ -1083,7 +1090,7 @@ static int read_root_list (qse_xli_t* xli)
|
||||
link = make_list_link (xli, &xli->root->list);
|
||||
if (link == QSE_NULL) return -1;
|
||||
|
||||
if (get_char (xli) <= -1 || get_token (xli) <= -1 || __read_list (xli, 0) <= -1)
|
||||
if (get_char (xli) <= -1 || get_token (xli) <= -1 || __read_list (xli, QSE_NULL) <= -1)
|
||||
{
|
||||
free_list_link (xli, link);
|
||||
return -1;
|
||||
|
Loading…
Reference in New Issue
Block a user