diff --git a/qse/cmd/awk/awk.c b/qse/cmd/awk/awk.c index a3ac84e4..9e7a229c 100644 --- a/qse/cmd/awk/awk.c +++ b/qse/cmd/awk/awk.c @@ -356,7 +356,8 @@ static void on_statement (qse_awk_rtx_t* rtx, qse_awk_nde_t* nde) 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, ...) @@ -1082,7 +1083,7 @@ static int awk_main (int argc, qse_char_t* argv[]) rtx = qse_awk_rtx_openstd ( 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 */ arg.console_cmgr ); @@ -1106,7 +1107,7 @@ static int awk_main (int argc, qse_char_t* argv[]) set_intr_run (); 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); unset_intr_run (); diff --git a/qse/cmd/http/httpd.c b/qse/cmd/http/httpd.c index 6b4e43f0..55ec3614 100644 --- a/qse/cmd/http/httpd.c +++ b/qse/cmd/http/httpd.c @@ -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.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.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.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) { - 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[]) diff --git a/qse/cmd/sed/sed.c b/qse/cmd/sed/sed.c index 9fd690f6..2999c268 100644 --- a/qse/cmd/sed/sed.c +++ b/qse/cmd/sed/sed.c @@ -154,7 +154,8 @@ static qse_mmgr_t xma_mmgr = 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[]) diff --git a/qse/include/qse/xli/xli.h b/qse/include/qse/xli/xli.h index cc93c089..71b1d447 100644 --- a/qse/include/qse/xli/xli.h +++ b/qse/include/qse/xli/xli.h @@ -335,12 +335,17 @@ enum qse_xli_scm_flag_t QSE_XLI_SCM_VALSTR = (1 << 2), QSE_XLI_SCM_VALLIST = (1 << 3), 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 { - int flags; + int flags; int str_minseg; int str_maxseg; }; diff --git a/qse/lib/xli/read.c b/qse/lib/xli/read.c index e2b6de6d..f54e036d 100644 --- a/qse/lib/xli/read.c +++ b/qse/lib/xli/read.c @@ -23,8 +23,7 @@ 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); - +static int read_list (qse_xli_t* xli, qse_xli_list_t* list, int skip_validation); enum { @@ -140,7 +139,7 @@ static int get_char (qse_xli_t* xli) } xli->rio.inp->b.pos = 0; - xli->rio.inp->b.len = n; + xli->rio.inp->b.len = n; } if (xli->rio.inp->last.c == QSE_T('\n')) @@ -211,7 +210,7 @@ static int classify_ident (qse_xli_t* xli, const qse_cstr_t* name) int n; kwent_t* kwp; - mid = (left + right) / 2; + mid = (left + right) / 2; kwp = &kwtab[mid]; n = qse_strxncmp (kwp->name.ptr, kwp->name.len, name->ptr, name->len); @@ -660,7 +659,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) +static int read_pair (qse_xli_t* xli, const qse_char_t* keytag, int skip_validation) { qse_cstr_t key; qse_xli_loc_t kloc; @@ -682,7 +681,7 @@ static int read_pair (qse_xli_t* xli, const qse_char_t* keytag) if (xli->opt.trait & QSE_XLI_KEYNODUP) key_nodup = 1; if (xli->opt.trait & QSE_XLI_KEYALIAS) key_alias = 1; - + kloc = xli->tok.loc; key.len = QSE_STR_LEN(xli->tok.name); key.ptr = qse_strdup (QSE_STR_PTR(xli->tok.name), xli->mmgr); @@ -700,7 +699,7 @@ static int read_pair (qse_xli_t* xli, const qse_char_t* keytag) goto oops; } - if (xli->opt.trait & QSE_XLI_VALIDATE) + if (!skip_validation && (xli->opt.trait & QSE_XLI_VALIDATE)) { qse_rbt_pair_t* pair; @@ -708,7 +707,7 @@ static int read_pair (qse_xli_t* xli, const qse_char_t* keytag) if (pair == QSE_NULL) { qse_xli_seterror (xli, QSE_XLI_EUDKEY, (const qse_cstr_t*)&key, &kloc); - goto oops; + goto oops; } scm = (qse_xli_scm_t*)QSE_RBT_VPTR(pair); @@ -900,8 +899,12 @@ static int read_pair (qse_xli_t* xli, const qse_char_t* keytag) /* insert a pair with an empty list */ pair = qse_xli_insertpairwithemptylist (xli, parlist, QSE_NULL, key.ptr, name, keytag); 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)) { @@ -933,7 +936,7 @@ static int read_pair (qse_xli_t* xli, const qse_char_t* keytag) { /* check the value type */ qse_xli_seterror (xli, QSE_XLI_ENOVAL, (const qse_cstr_t*)&key, &kloc); - goto oops; + goto oops; } xli->tok_status &= ~TOK_STATUS_ENABLE_NSTR; @@ -989,7 +992,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) +static int __read_list (qse_xli_t* xli, int skip_validation) { while (1) { @@ -1030,13 +1033,13 @@ static int __read_list (qse_xli_t* xli) return -1; } - x = read_pair (xli, keytag); + x = read_pair (xli, keytag, skip_validation); QSE_MMGR_FREE (xli->mmgr, keytag); if (x <= -1) return -1; } 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)) { @@ -1051,7 +1054,7 @@ static int __read_list (qse_xli_t* xli) 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; @@ -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. * 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) <= -1) + if (get_token (xli) <= -1 || __read_list (xli, skip_validation) <= -1) { free_list_link (xli, link); return -1; @@ -1080,7 +1083,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) <= -1) + if (get_char (xli) <= -1 || get_token (xli) <= -1 || __read_list (xli, 0) <= -1) { free_list_link (xli, link); return -1; diff --git a/qse/lib/xli/xli.c b/qse/lib/xli/xli.c index e4c4ce00..cbf0faea 100644 --- a/qse/lib/xli/xli.c +++ b/qse/lib/xli/xli.c @@ -196,7 +196,7 @@ static void insert_atom ( { if (parent == QSE_NULL) parent = &xli->root->list; - if (peer == QSE_NULL) + if (peer == QSE_NULL) { /* insert it to the tail */ atom->prev = parent->tail; @@ -362,7 +362,7 @@ qse_xli_pair_t* qse_xli_insertpairwithstrs ( str = (qse_xli_str_t*)tmp->val; for (i = 1; i < count; i++) { - str = qse_xli_addsegtostr (xli, str, QSE_NULL, &value[i]); + str = qse_xli_addsegtostr (xli, str, QSE_NULL, &value[i]); if (str == QSE_NULL) { free_atom (xli->root, (qse_xli_atom_t*)tmp); @@ -487,7 +487,7 @@ static void free_list (qse_xli_root_list_t* root, qse_xli_list_t* list) while (p) { n = p->next; - free_atom (root, p); + free_atom (root, p); p = n; } @@ -623,7 +623,7 @@ struct fqpn_seg_t union { qse_size_t number; - qse_cstr_t alias; + qse_cstr_t alias; } idx; }; @@ -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('[')) { - /* index is specified */ + /* index is specified */ ptr++; /* skip [ */ if (QSE_ISDIGIT(*ptr))