added a new option QSE_XLI_SCM_RELAXED to skip validation of child pairs under a list value

This commit is contained in:
hyung-hwan 2014-11-12 05:59:47 +00:00
parent 47d8710232
commit f049aa4b09
6 changed files with 42 additions and 30 deletions

View File

@ -356,7 +356,8 @@ static void on_statement (qse_awk_rtx_t* rtx, qse_awk_nde_t* nde)
static void print_version (void) static void print_version (void)
{ {
qse_fprintf (QSE_STDOUT, QSE_T("QSEAWK version %hs\n"), QSE_PACKAGE_VERSION); qse_fprintf (QSE_STDOUT, QSE_T("QSEAWK %hs\n"), QSE_PACKAGE_VERSION);
qse_fprintf (QSE_STDOUT, QSE_T("Copyright 2006-2014 Chung, Hyung-Hwan\n"));
} }
static void print_error (const qse_char_t* fmt, ...) static void print_error (const qse_char_t* fmt, ...)
@ -1082,7 +1083,7 @@ static int awk_main (int argc, qse_char_t* argv[])
rtx = qse_awk_rtx_openstd ( rtx = qse_awk_rtx_openstd (
awk, 0, QSE_T("qseawk"), awk, 0, QSE_T("qseawk"),
(arg.call? QSE_NULL: arg.icf.ptr), /* console input */ (arg.call? QSE_NULL: (const qse_char_t**)arg.icf.ptr), /* console input */
QSE_NULL, /* console output */ QSE_NULL, /* console output */
arg.console_cmgr arg.console_cmgr
); );
@ -1106,7 +1107,7 @@ static int awk_main (int argc, qse_char_t* argv[])
set_intr_run (); set_intr_run ();
retv = arg.call? retv = arg.call?
qse_awk_rtx_callwithstrs (rtx, arg.call, arg.icf.ptr, arg.icf.size): qse_awk_rtx_callwithstrs (rtx, arg.call, (const qse_char_t**)arg.icf.ptr, arg.icf.size):
qse_awk_rtx_loop (rtx); qse_awk_rtx_loop (rtx);
unset_intr_run (); unset_intr_run ();

View File

@ -2092,7 +2092,8 @@ static int open_config_file (qse_httpd_t* httpd)
{ QSE_T("hooks"), { QSE_XLI_SCM_VALLIST | QSE_XLI_SCM_KEYNODUP, 0, 0 } }, { QSE_T("hooks"), { QSE_XLI_SCM_VALLIST | QSE_XLI_SCM_KEYNODUP, 0, 0 } },
{ QSE_T("hooks.module"), { QSE_XLI_SCM_VALLIST | QSE_XLI_SCM_KEYALIAS, 0, 0 } }, { QSE_T("hooks.module"), { QSE_XLI_SCM_VALLIST | QSE_XLI_SCM_KEYALIAS, 0, 0 } },
{ QSE_T("hooks.module.file"), { 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("hooks.module.config"), { QSE_XLI_SCM_VALLIST | QSE_XLI_SCM_KEYNODUP | QSE_SLI_SCM_SKIPVALIDATE, 0, 0 } },*/ { QSE_T("hooks.module.config"), { QSE_XLI_SCM_VALLIST |
QSE_XLI_SCM_KEYNODUP | QSE_XLI_SCM_RELAXED, 0, 0 } },
{ QSE_T("server-default"), { QSE_XLI_SCM_VALLIST | QSE_XLI_SCM_KEYNODUP, 0, 0 } }, { 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-cert-file"), { QSE_XLI_SCM_VALSTR | QSE_XLI_SCM_KEYNODUP, 1, 1 } },
@ -2503,7 +2504,8 @@ static void logact_httpd (qse_httpd_t* httpd, const qse_httpd_act_t* act)
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
static void print_version (void) static void print_version (void)
{ {
qse_printf (QSE_T("QSEHTTPD version %hs\n"), QSE_PACKAGE_VERSION); qse_fprintf (QSE_STDOUT, QSE_T("QSEHTTPD %hs\n"), QSE_PACKAGE_VERSION);
qse_fprintf (QSE_STDOUT, QSE_T("Copyright 2006-2014 Chung, Hyung-Hwan\n"));
} }
static void print_usage (qse_sio_t* out, int argc, qse_char_t* argv[]) static void print_usage (qse_sio_t* out, int argc, qse_char_t* argv[])

View File

@ -154,7 +154,8 @@ static qse_mmgr_t xma_mmgr =
static void print_version (void) static void print_version (void)
{ {
qse_printf (QSE_T("QSESED version %hs\n"), QSE_PACKAGE_VERSION); qse_fprintf (QSE_STDOUT, QSE_T("QSESED %hs\n"), QSE_PACKAGE_VERSION);
qse_fprintf (QSE_STDOUT, QSE_T("Copyright 2006-2014 Chung, Hyung-Hwan\n"));
} }
static void print_usage (qse_sio_t* out, int argc, qse_char_t* argv[]) static void print_usage (qse_sio_t* out, int argc, qse_char_t* argv[])

View File

@ -335,8 +335,13 @@ enum qse_xli_scm_flag_t
QSE_XLI_SCM_VALSTR = (1 << 2), QSE_XLI_SCM_VALSTR = (1 << 2),
QSE_XLI_SCM_VALLIST = (1 << 3), QSE_XLI_SCM_VALLIST = (1 << 3),
QSE_XLI_SCM_KEYNODUP = (1 << 4), QSE_XLI_SCM_KEYNODUP = (1 << 4),
QSE_XLI_SCM_KEYALIAS = (1 << 5) QSE_XLI_SCM_KEYALIAS = (1 << 5),
/* skips the validation of child pairs under a list.
* useful with #QSE_XLI_SCM_VALLIST only. */
QSE_XLI_SCM_RELAXED = (1 << 6)
}; };
typedef enum qse_xli_scm_flag_t qse_xli_scm_flag_t;
struct qse_xli_scm_t struct qse_xli_scm_t
{ {

View File

@ -23,8 +23,7 @@
static int get_char (qse_xli_t* xli); static int get_char (qse_xli_t* xli);
static int get_token (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); static int read_list (qse_xli_t* xli, qse_xli_list_t* list, int skip_validation);
enum enum
{ {
@ -660,7 +659,7 @@ static int get_token (qse_xli_t* xli)
return get_token_into (xli, &xli->tok); return get_token_into (xli, &xli->tok);
} }
static int read_pair (qse_xli_t* xli, const qse_char_t* keytag) static int read_pair (qse_xli_t* xli, const qse_char_t* keytag, int skip_validation)
{ {
qse_cstr_t key; qse_cstr_t key;
qse_xli_loc_t kloc; qse_xli_loc_t kloc;
@ -700,7 +699,7 @@ static int read_pair (qse_xli_t* xli, const qse_char_t* keytag)
goto oops; goto oops;
} }
if (xli->opt.trait & QSE_XLI_VALIDATE) if (!skip_validation && (xli->opt.trait & QSE_XLI_VALIDATE))
{ {
qse_rbt_pair_t* pair; qse_rbt_pair_t* pair;
@ -901,7 +900,11 @@ static int read_pair (qse_xli_t* xli, const qse_char_t* keytag)
pair = qse_xli_insertpairwithemptylist (xli, parlist, QSE_NULL, key.ptr, name, keytag); pair = qse_xli_insertpairwithemptylist (xli, parlist, QSE_NULL, key.ptr, name, keytag);
if (pair == QSE_NULL) goto oops; if (pair == QSE_NULL) goto oops;
if (read_list (xli, (qse_xli_list_t*)pair->val) <= -1) goto oops; /* skip validations of child pairs if the schema for the
* current pair is set with QSE_XLI_SCM_RELAXED.
* 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 (!MATCH (xli, TOK_RBRACE)) if (!MATCH (xli, TOK_RBRACE))
{ {
@ -989,7 +992,7 @@ static void free_list_link (qse_xli_t* xli, qse_xli_list_link_t* link)
qse_xli_freemem (xli, link); qse_xli_freemem (xli, link);
} }
static int __read_list (qse_xli_t* xli) static int __read_list (qse_xli_t* xli, int skip_validation)
{ {
while (1) while (1)
{ {
@ -1030,13 +1033,13 @@ static int __read_list (qse_xli_t* xli)
return -1; return -1;
} }
x = read_pair (xli, keytag); x = read_pair (xli, keytag, skip_validation);
QSE_MMGR_FREE (xli->mmgr, keytag); QSE_MMGR_FREE (xli->mmgr, keytag);
if (x <= -1) return -1; if (x <= -1) return -1;
} }
else if (MATCH (xli, TOK_IDENT)) else if (MATCH (xli, TOK_IDENT))
{ {
if (read_pair (xli, QSE_NULL) <= -1) return -1; if (read_pair (xli, QSE_NULL, skip_validation) <= -1) return -1;
} }
else if (MATCH (xli, TOK_TEXT)) else if (MATCH (xli, TOK_TEXT))
{ {
@ -1051,7 +1054,7 @@ static int __read_list (qse_xli_t* xli)
return 0; return 0;
} }
static int read_list (qse_xli_t* xli, qse_xli_list_t* parlist) static int read_list (qse_xli_t* xli, qse_xli_list_t* parlist, int skip_validation)
{ {
qse_xli_list_link_t* link; qse_xli_list_link_t* link;
@ -1061,7 +1064,7 @@ static int read_list (qse_xli_t* xli, qse_xli_list_t* parlist)
/* get_token() here is to read the token after the left brace. /* get_token() here is to read the token after the left brace.
* it must be called after the xli->parlink has been updated * it must be called after the xli->parlink has been updated
* in case there are comments at the beginning of the list */ * in case there are comments at the beginning of the list */
if (get_token (xli) <= -1 || __read_list (xli) <= -1) if (get_token (xli) <= -1 || __read_list (xli, skip_validation) <= -1)
{ {
free_list_link (xli, link); free_list_link (xli, link);
return -1; return -1;
@ -1080,7 +1083,7 @@ static int read_root_list (qse_xli_t* xli)
link = make_list_link (xli, &xli->root->list); link = make_list_link (xli, &xli->root->list);
if (link == QSE_NULL) return -1; if (link == QSE_NULL) return -1;
if (get_char (xli) <= -1 || get_token (xli) <= -1 || __read_list (xli) <= -1) if (get_char (xli) <= -1 || get_token (xli) <= -1 || __read_list (xli, 0) <= -1)
{ {
free_list_link (xli, link); free_list_link (xli, link);
return -1; return -1;

View File

@ -640,7 +640,7 @@ const qse_char_t* get_next_fqpn_segment (qse_xli_t* xli, const qse_char_t* fqpn,
if (*ptr == QSE_T('[')) if (*ptr == QSE_T('['))
{ {
/* index is specified */ /* index is specified */
ptr++; /* skip [ */ ptr++; /* skip [ */
if (QSE_ISDIGIT(*ptr)) if (QSE_ISDIGIT(*ptr))