added experimental code to pass unvalidated configuration items to a module
This commit is contained in:
		| @ -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) | ||||
| { | ||||
| 	qse_char_t buf[32]; | ||||
| 	qse_xli_pair_t* pair; | ||||
| 	qse_xli_pair_t* pair, * cfg; | ||||
| 	httpd_xtn_t* httpd_xtn; | ||||
| 	 | ||||
| 	int i; | ||||
| @ -2065,7 +2065,8 @@ static int load_hook_modules (qse_httpd_t* httpd, qse_xli_list_t* hook_list) | ||||
| 		} | ||||
| 		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 */ | ||||
| 		} | ||||
| 	} | ||||
| @ -2239,11 +2240,11 @@ static int open_config_file (qse_httpd_t* httpd) | ||||
| 	xli_in.type = QSE_XLI_IOSTD_FILE; | ||||
| 	xli_in.u.file.path = httpd_xtn->cfgfile; | ||||
| 	xli_in.u.file.cmgr = QSE_NULL; | ||||
| 	 | ||||
|  | ||||
| 	if (qse_xli_readstd (httpd_xtn->xli, &xli_in) <= -1) | ||||
| 	{ | ||||
| 		const qse_xli_loc_t* errloc; | ||||
|          | ||||
|  | ||||
| 		errloc = qse_xli_geterrloc (httpd_xtn->xli); | ||||
|  | ||||
| 		if (errloc->line > 0 || errloc->colm > 0) | ||||
| @ -2361,7 +2362,7 @@ static int load_config (qse_httpd_t* httpd) | ||||
| 		else | ||||
| 		{ | ||||
| 			qse_httpd_server_t* server; | ||||
| 	 | ||||
|  | ||||
| 			server = attach_server (httpd, i, (qse_xli_list_t*)pair->val); | ||||
| 			if (server) | ||||
| 			{ | ||||
|  | ||||
| @ -12,6 +12,10 @@ max-nproc = none; | ||||
| #hooks { | ||||
| #	module "ext-1" { | ||||
| #		file = "ext"; | ||||
| #		config { | ||||
| #			item1 = abc; | ||||
| #			item2 = def; | ||||
| #		} | ||||
| #	} | ||||
| #} | ||||
|  | ||||
|  | ||||
| @ -29,7 +29,7 @@ | ||||
| #include <qse/cmn/time.h> | ||||
| #include <qse/cmn/tmr.h> | ||||
| #include <qse/cmn/env.h> | ||||
|  | ||||
| #include <qse/xli/xli.h> | ||||
|  | ||||
| typedef struct qse_httpd_t        qse_httpd_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 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) ( | ||||
| @ -1419,8 +1420,9 @@ QSE_EXPORT int qse_httpd_rewriteurl ( | ||||
| ); | ||||
|  | ||||
| QSE_EXPORT int qse_httpd_loadmod ( | ||||
| 	qse_httpd_t*      httpd, | ||||
| 	const qse_char_t* name | ||||
| 	qse_httpd_t*          httpd, | ||||
| 	const qse_char_t*     name, | ||||
| 	const qse_xli_list_t* list | ||||
| ); | ||||
|  | ||||
| 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. */ | ||||
| 	QSE_XLI_STRTAG    = (1 << 10),  | ||||
|  | ||||
| 	/** enable pair validation against pair definitions while reading */ | ||||
| 	QSE_XLI_VALIDATE  = (1 << 11) | ||||
| }; | ||||
| typedef enum qse_xli_trait_t qse_xli_trait_t; | ||||
| @ -668,7 +669,7 @@ QSE_EXPORT int qse_xli_undefinepair ( | ||||
| QSE_EXPORT void qse_xli_undefinepairs ( | ||||
| 	qse_xli_t* xli | ||||
| ); | ||||
| 			 | ||||
|  | ||||
| QSE_EXPORT int qse_xli_read ( | ||||
| 	qse_xli_t*        xli, | ||||
| 	qse_xli_io_impl_t io | ||||
| @ -679,7 +680,6 @@ QSE_EXPORT int qse_xli_write ( | ||||
| 	qse_xli_io_impl_t io | ||||
| ); | ||||
|  | ||||
|  | ||||
| QSE_EXPORT void* qse_getxlipairxtn ( | ||||
| 	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_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); | ||||
| 		qse_httpd_freemem (httpd, mod); | ||||
|  | ||||
		Reference in New Issue
	
	Block a user