enhanced cmd/http/httpd.c to load host/location-specific configuration data
This commit is contained in:
@ -49,7 +49,7 @@
|
||||
* int i;
|
||||
*
|
||||
* s1 = qse_htb_open (QSE_MMGR_GETDFL(), 0, 30, 75, 1, 1); // error handling skipped
|
||||
* qse_htb_setmancbs (s1, qse_gethtbmancbs(QSE_HTB_MANCBS_INLINE_COPIERS));
|
||||
* qse_htb_setstyle (s1, qse_gethtbstyle(QSE_HTB_STYLE_INLINE_COPIERS));
|
||||
*
|
||||
* for (i = 0; i < 20; i++)
|
||||
* {
|
||||
@ -202,9 +202,9 @@ struct qse_htb_pair_t
|
||||
qse_htb_pair_t* next;
|
||||
};
|
||||
|
||||
typedef struct qse_htb_mancbs_t qse_htb_mancbs_t;
|
||||
typedef struct qse_htb_style_t qse_htb_style_t;
|
||||
|
||||
struct qse_htb_mancbs_t
|
||||
struct qse_htb_style_t
|
||||
{
|
||||
qse_htb_copier_t copier[2];
|
||||
qse_htb_freeer_t freeer[2];
|
||||
@ -215,22 +215,22 @@ struct qse_htb_mancbs_t
|
||||
};
|
||||
|
||||
/**
|
||||
* The qse_htb_mancbs_kind_t type defines the type of predefined
|
||||
* The qse_htb_style_kind_t type defines the type of predefined
|
||||
* callback set for pair manipulation.
|
||||
*/
|
||||
enum qse_htb_mancbs_kind_t
|
||||
enum qse_htb_style_kind_t
|
||||
{
|
||||
/** store the key and the value pointer */
|
||||
QSE_HTB_MANCBS_DEFAULT,
|
||||
QSE_HTB_STYLE_DEFAULT,
|
||||
/** copy both key and value into the pair */
|
||||
QSE_HTB_MANCBS_INLINE_COPIERS,
|
||||
QSE_HTB_STYLE_INLINE_COPIERS,
|
||||
/** copy the key into the pair but store the value pointer */
|
||||
QSE_HTB_MANCBS_INLINE_KEY_COPIER,
|
||||
QSE_HTB_STYLE_INLINE_KEY_COPIER,
|
||||
/** copy the value into the pair but store the key pointer */
|
||||
QSE_HTB_MANCBS_INLINE_VALUE_COPIER
|
||||
QSE_HTB_STYLE_INLINE_VALUE_COPIER
|
||||
};
|
||||
|
||||
typedef enum qse_htb_mancbs_kind_t qse_htb_mancbs_kind_t;
|
||||
typedef enum qse_htb_style_kind_t qse_htb_style_kind_t;
|
||||
|
||||
/**
|
||||
* The qse_htb_t type defines a hash table.
|
||||
@ -239,7 +239,7 @@ struct qse_htb_t
|
||||
{
|
||||
qse_mmgr_t* mmgr;
|
||||
|
||||
const qse_htb_mancbs_t* mancbs;
|
||||
const qse_htb_style_t* style;
|
||||
|
||||
qse_byte_t scale[2]; /**< length scale */
|
||||
qse_byte_t factor; /**< load factor in percentage */
|
||||
@ -300,11 +300,11 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The qse_gethtbmancbs() functions returns a predefined callback set for
|
||||
* The qse_gethtbstyle() functions returns a predefined callback set for
|
||||
* pair manipulation.
|
||||
*/
|
||||
QSE_EXPORT const qse_htb_mancbs_t* qse_gethtbmancbs (
|
||||
qse_htb_mancbs_kind_t kind
|
||||
QSE_EXPORT const qse_htb_style_t* qse_gethtbstyle (
|
||||
qse_htb_style_kind_t kind
|
||||
);
|
||||
|
||||
/**
|
||||
@ -364,19 +364,22 @@ QSE_EXPORT void* qse_htb_getxtn (
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_htb_getmancbs() function gets manipulation callback function set.
|
||||
* The qse_htb_getstyle() function gets manipulation callback function set.
|
||||
*/
|
||||
QSE_EXPORT const qse_htb_mancbs_t* qse_htb_getmancbs (
|
||||
QSE_EXPORT const qse_htb_style_t* qse_htb_getstyle (
|
||||
const qse_htb_t* htb /**< hash table */
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_htb_setmancbs() function sets internal manipulation callback
|
||||
* The qse_htb_setstyle() function sets internal manipulation callback
|
||||
* functions for data construction, destruction, resizing, hashing, etc.
|
||||
* The callback structure pointed to by \a style must outlive the hash
|
||||
* table pointed to by \a htb as the hash table doesn't copy the contents
|
||||
* of the structure.
|
||||
*/
|
||||
QSE_EXPORT void qse_htb_setmancbs (
|
||||
qse_htb_t* htb, /**< hash table */
|
||||
const qse_htb_mancbs_t* mancbs /**< callback function set */
|
||||
QSE_EXPORT void qse_htb_setstyle (
|
||||
qse_htb_t* htb, /**< hash table */
|
||||
const qse_htb_style_t* style /**< callback function set */
|
||||
);
|
||||
|
||||
/**
|
||||
@ -533,7 +536,7 @@ QSE_EXPORT qse_htb_pair_t* qse_htb_update (
|
||||
* QSE_MMGR_GETDFL(), 0, 10, 70,
|
||||
* QSE_SIZEOF(qse_char_t), QSE_SIZEOF(qse_char_t)
|
||||
* ); // note error check is skipped
|
||||
* qse_htb_setmancbs (s1, &mancbs1);
|
||||
* qse_htb_setstyle (s1, &style1);
|
||||
*
|
||||
* for (i = 0; i < QSE_COUNTOF(vals); i++)
|
||||
* {
|
||||
|
@ -29,19 +29,19 @@
|
||||
|
||||
#if defined(QSE_MAP_AS_HTB)
|
||||
# include <qse/cmn/htb.h>
|
||||
# define QSE_MAP_MANCBS_DEFAULT QSE_HTB_MANCBS_DEFAULT
|
||||
# define QSE_MAP_MANCBS_INLINE_COPIERS QSE_HTB_MANCBS_INLINE_COPIERS
|
||||
# define QSE_MAP_MANCBS_INLINE_KEY_COPIER QSE_HTB_MANCBS_INLINE_KEY_COPIER
|
||||
# define QSE_MAP_MANCBS_INLINE_VALUE_COPIER QSE_HTB_MANCBS_INLINE_VALUE_COPIER
|
||||
# define qse_getmapmancbs(kind) qse_gethtbmancbs(kind)
|
||||
# define QSE_MAP_STYLE_DEFAULT QSE_HTB_STYLE_DEFAULT
|
||||
# define QSE_MAP_STYLE_INLINE_COPIERS QSE_HTB_STYLE_INLINE_COPIERS
|
||||
# define QSE_MAP_STYLE_INLINE_KEY_COPIER QSE_HTB_STYLE_INLINE_KEY_COPIER
|
||||
# define QSE_MAP_STYLE_INLINE_VALUE_COPIER QSE_HTB_STYLE_INLINE_VALUE_COPIER
|
||||
# define qse_getmapstyle(kind) qse_gethtbstyle(kind)
|
||||
# define qse_map_open(mmgr,ext,capa,factor,ks,vs) qse_htb_open(mmgr,ext,capa,factor,ks,vs)
|
||||
# define qse_map_close(map) qse_htb_close(map)
|
||||
# define qse_map_init(map,mmgr,capa,factor,ks,vs) qse_htb_init(map,mmgr,capa,factor,ks,vs)
|
||||
# define qse_map_fini(map) qse_htb_fini(map)
|
||||
# define qse_map_getsize(map) qse_htb_getsize(map)
|
||||
# define qse_map_getcapa(map) qse_htb_getcapa(map)
|
||||
# define qse_map_getmancbs(map) qse_htb_getmancbs(map)
|
||||
# define qse_map_setmancbs(map,cbs) qse_htb_setmancbs(map,cbs)
|
||||
# define qse_map_getstyle(map) qse_htb_getstyle(map)
|
||||
# define qse_map_setstyle(map,cbs) qse_htb_setstyle(map,cbs)
|
||||
# define qse_map_search(map,kptr,klen) qse_htb_search(map,kptr,klen)
|
||||
# define qse_map_upsert(map,kptr,klen,vptr,vlen) qse_htb_upsert(map,kptr,klen,vptr,vlen)
|
||||
# define qse_map_ensert(map,kptr,klen,vptr,vlen) qse_htb_ensert(map,kptr,klen,vptr,vlen)
|
||||
@ -59,7 +59,7 @@
|
||||
# define qse_map_id_t qse_htb_id_t
|
||||
# define qse_map_t qse_htb_t
|
||||
# define qse_map_pair_t qse_htb_pair_t
|
||||
# define qse_map_mancbs_t qse_htb_mancbs_t
|
||||
# define qse_map_style_t qse_htb_style_t
|
||||
# define qse_map_cbserter_t qse_htb_cbserter_t
|
||||
# define qse_map_walker_t qse_htb_walker_t
|
||||
# define QSE_MAP_COPIER_SIMPLE QSE_HTB_COPIER_SIMPLE
|
||||
@ -87,19 +87,19 @@
|
||||
# define QSE_MAP_VLEN(p) QSE_HTB_VLEN(p)
|
||||
#elif defined(QSE_MAP_AS_RBT)
|
||||
# include <qse/cmn/rbt.h>
|
||||
# define QSE_MAP_MANCBS_DEFAULT QSE_RBT_MANCBS_DEFAULT
|
||||
# define QSE_MAP_MANCBS_INLINE_COPIERS QSE_RBT_MANCBS_INLINE_COPIERS
|
||||
# define QSE_MAP_MANCBS_INLINE_KEY_COPIER QSE_RBT_MANCBS_INLINE_KEY_COPIER
|
||||
# define QSE_MAP_MANCBS_INLINE_VALUE_COPIER QSE_RBT_MANCBS_INLINE_VALUE_COPIER
|
||||
# define qse_getmapmancbs(kind) qse_getrbtmancbs(kind)
|
||||
# define QSE_MAP_STYLE_DEFAULT QSE_RBT_STYLE_DEFAULT
|
||||
# define QSE_MAP_STYLE_INLINE_COPIERS QSE_RBT_STYLE_INLINE_COPIERS
|
||||
# define QSE_MAP_STYLE_INLINE_KEY_COPIER QSE_RBT_STYLE_INLINE_KEY_COPIER
|
||||
# define QSE_MAP_STYLE_INLINE_VALUE_COPIER QSE_RBT_STYLE_INLINE_VALUE_COPIER
|
||||
# define qse_getmapstyle(kind) qse_getrbtstyle(kind)
|
||||
# define qse_map_open(mmgr,ext,capa,factor,ks,vs) qse_rbt_open(mmgr,ext,ks,vs)
|
||||
# define qse_map_close(map) qse_rbt_close(map)
|
||||
# define qse_map_init(map,mmgr,capa,factor,ks,vs) qse_rbt_init(map,mmgr,ks,vs)
|
||||
# define qse_map_fini(map) qse_rbt_fini(map)
|
||||
# define qse_map_getsize(map) qse_rbt_getsize(map)
|
||||
# define qse_map_getcapa(map) qse_rbt_getsize(map)
|
||||
# define qse_map_getmancbs(map) qse_rbt_getmancbs(map)
|
||||
# define qse_map_setmancbs(map,cbs) qse_rbt_setmancbs(map,cbs)
|
||||
# define qse_map_getstyle(map) qse_rbt_getstyle(map)
|
||||
# define qse_map_setstyle(map,cbs) qse_rbt_setstyle(map,cbs)
|
||||
# define qse_map_search(map,kptr,klen) qse_rbt_search(map,kptr,klen)
|
||||
# define qse_map_upsert(map,kptr,klen,vptr,vlen) qse_rbt_upsert(map,kptr,klen,vptr,vlen)
|
||||
# define qse_map_ensert(map,kptr,klen,vptr,vlen) qse_rbt_ensert(map,kptr,klen,vptr,vlen)
|
||||
@ -117,7 +117,7 @@
|
||||
# define qse_map_id_t qse_rbt_id_t
|
||||
# define qse_map_t qse_rbt_t
|
||||
# define qse_map_pair_t qse_rbt_pair_t
|
||||
# define qse_map_mancbs_t qse_rbt_mancbs_t
|
||||
# define qse_map_style_t qse_rbt_style_t
|
||||
# define qse_map_cbserter_t qse_rbt_cbserter_t
|
||||
# define qse_map_walker_t qse_rbt_walker_t
|
||||
# define QSE_MAP_COPIER_SIMPLE QSE_RBT_COPIER_SIMPLE
|
||||
|
@ -49,7 +49,7 @@
|
||||
* int i;
|
||||
*
|
||||
* s1 = qse_rbt_open (QSE_MMGR_GETDFL(), 0, 1, 1); // error handling skipped
|
||||
* qse_rbt_setmancbs (s1, qse_getrbtmancbs(QSE_RBT_MANCBS_INLINE_COPIERS));
|
||||
* qse_rbt_setstyle (s1, qse_getrbtstyle(QSE_RBT_STYLE_INLINE_COPIERS));
|
||||
*
|
||||
* for (i = 0; i < 20; i++)
|
||||
* {
|
||||
@ -183,13 +183,13 @@ struct qse_rbt_pair_t
|
||||
qse_rbt_pair_t* child[2]; /* left and right */
|
||||
};
|
||||
|
||||
typedef struct qse_rbt_mancbs_t qse_rbt_mancbs_t;
|
||||
typedef struct qse_rbt_style_t qse_rbt_style_t;
|
||||
|
||||
/**
|
||||
* The qse_rbt_mancbs_t type defines callback function sets for key/value
|
||||
* The qse_rbt_style_t type defines callback function sets for key/value
|
||||
* pair manipulation.
|
||||
*/
|
||||
struct qse_rbt_mancbs_t
|
||||
struct qse_rbt_style_t
|
||||
{
|
||||
qse_rbt_copier_t copier[2]; /**< key and value copier */
|
||||
qse_rbt_freeer_t freeer[2]; /**< key and value freeer */
|
||||
@ -198,22 +198,22 @@ struct qse_rbt_mancbs_t
|
||||
};
|
||||
|
||||
/**
|
||||
* The qse_rbt_mancbs_kind_t type defines the type of predefined
|
||||
* The qse_rbt_style_kind_t type defines the type of predefined
|
||||
* callback set for pair manipulation.
|
||||
*/
|
||||
enum qse_rbt_mancbs_kind_t
|
||||
enum qse_rbt_style_kind_t
|
||||
{
|
||||
/** store the key and the value pointer */
|
||||
QSE_RBT_MANCBS_DEFAULT,
|
||||
QSE_RBT_STYLE_DEFAULT,
|
||||
/** copy both key and value into the pair */
|
||||
QSE_RBT_MANCBS_INLINE_COPIERS,
|
||||
QSE_RBT_STYLE_INLINE_COPIERS,
|
||||
/** copy the key into the pair but store the value pointer */
|
||||
QSE_RBT_MANCBS_INLINE_KEY_COPIER,
|
||||
QSE_RBT_STYLE_INLINE_KEY_COPIER,
|
||||
/** copy the value into the pair but store the key pointer */
|
||||
QSE_RBT_MANCBS_INLINE_VALUE_COPIER
|
||||
QSE_RBT_STYLE_INLINE_VALUE_COPIER
|
||||
};
|
||||
|
||||
typedef enum qse_rbt_mancbs_kind_t qse_rbt_mancbs_kind_t;
|
||||
typedef enum qse_rbt_style_kind_t qse_rbt_style_kind_t;
|
||||
|
||||
/**
|
||||
* The qse_rbt_t type defines a red-black tree.
|
||||
@ -222,7 +222,7 @@ struct qse_rbt_t
|
||||
{
|
||||
qse_mmgr_t* mmgr;
|
||||
|
||||
const qse_rbt_mancbs_t* mancbs;
|
||||
const qse_rbt_style_t* style;
|
||||
|
||||
qse_byte_t scale[2]; /**< length scale */
|
||||
|
||||
@ -271,11 +271,11 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The qse_getrbtmancbs() functions returns a predefined callback set for
|
||||
* The qse_getrbtstyle() functions returns a predefined callback set for
|
||||
* pair manipulation.
|
||||
*/
|
||||
QSE_EXPORT const qse_rbt_mancbs_t* qse_getrbtmancbs (
|
||||
qse_rbt_mancbs_kind_t kind
|
||||
QSE_EXPORT const qse_rbt_style_t* qse_getrbtstyle (
|
||||
qse_rbt_style_kind_t kind
|
||||
);
|
||||
|
||||
/**
|
||||
@ -322,19 +322,22 @@ QSE_EXPORT void* qse_rbt_getxtn (
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_rbt_getmancbs() function gets manipulation callback function set.
|
||||
* The qse_rbt_getstyle() function gets manipulation callback function set.
|
||||
*/
|
||||
QSE_EXPORT const qse_rbt_mancbs_t* qse_rbt_getmancbs (
|
||||
QSE_EXPORT const qse_rbt_style_t* qse_rbt_getstyle (
|
||||
const qse_rbt_t* rbt /**< red-black tree */
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_rbt_setmancbs() function sets internal manipulation callback
|
||||
* The qse_rbt_setstyle() function sets internal manipulation callback
|
||||
* functions for data construction, destruction, comparison, etc.
|
||||
* The callback structure pointed to by \a style must outlive the tree
|
||||
* pointed to by \a htb as the tree doesn't copy the contents of the
|
||||
* structure.
|
||||
*/
|
||||
QSE_EXPORT void qse_rbt_setmancbs (
|
||||
qse_rbt_t* rbt, /**< red-black tree */
|
||||
const qse_rbt_mancbs_t* mancbs /**< callback function set */
|
||||
QSE_EXPORT void qse_rbt_setstyle (
|
||||
qse_rbt_t* rbt, /**< red-black tree */
|
||||
const qse_rbt_style_t* style /**< callback function set */
|
||||
);
|
||||
|
||||
/**
|
||||
@ -483,7 +486,7 @@ QSE_EXPORT qse_rbt_pair_t* qse_rbt_update (
|
||||
* QSE_MMGR_GETDFL(), 0,
|
||||
* QSE_SIZEOF(qse_char_t), QSE_SIZEOF(qse_char_t)
|
||||
* ); // note error check is skipped
|
||||
* qse_rbt_setmancbs (s1, &mancbs1);
|
||||
* qse_rbt_setstyle (s1, &style1);
|
||||
*
|
||||
* for (i = 0; i < QSE_COUNTOF(vals); i++)
|
||||
* {
|
||||
|
@ -1542,12 +1542,12 @@ QSE_EXPORT qse_wchar_t* qse_wcsxnend (
|
||||
);
|
||||
|
||||
#if defined(QSE_CHAR_IS_MCHAR)
|
||||
# define qse_strend(str,sub) qse_mbsxend(str,sub)
|
||||
# define qse_strend(str,sub) qse_mbsend(str,sub)
|
||||
# define qse_strxend(str,len,sub) qse_mbsxend(str,len,sub)
|
||||
# define qse_strnend(str,sub,len) qse_mbsnend(str,sub,len)
|
||||
# define qse_strxnend(str,len1,sub,len2) qse_mbsxnend(str,len1,sub,len2)
|
||||
#else
|
||||
# define qse_strend(str,sub) qse_wcsxend(str,sub)
|
||||
# define qse_strend(str,sub) qse_wcsend(str,sub)
|
||||
# define qse_strxend(str,len,sub) qse_wcsxend(str,len,sub)
|
||||
# define qse_strnend(str,sub,len) qse_wcsnend(str,sub,len)
|
||||
# define qse_strxnend(str,len1,sub,len2) qse_wcsxnend(str,len1,sub,len2)
|
||||
|
@ -51,7 +51,11 @@ struct qse_httpd_serverstd_root_t
|
||||
qse_httpd_serverstd_root_type_t type;
|
||||
union
|
||||
{
|
||||
const qse_mchar_t* path;
|
||||
struct
|
||||
{
|
||||
const qse_mchar_t* val;
|
||||
qse_size_t rpl; /* replacement length */
|
||||
} path;
|
||||
qse_nwad_t nwad;
|
||||
} u;
|
||||
};
|
||||
@ -94,6 +98,8 @@ struct qse_httpd_serverstd_ssl_t
|
||||
|
||||
enum qse_httpd_serverstd_query_code_t
|
||||
{
|
||||
QSE_HTTPD_SERVERSTD_SSL, /* qse_httpd_serverstd_ssl_t */
|
||||
|
||||
QSE_HTTPD_SERVERSTD_NAME, /* const qse_mchar_t* */
|
||||
QSE_HTTPD_SERVERSTD_ROOT, /* qse_httpd_serverstd_root_t */
|
||||
QSE_HTTPD_SERVERSTD_REALM, /* qse_httpd_serverstd_realm_t */
|
||||
@ -105,9 +111,8 @@ enum qse_httpd_serverstd_query_code_t
|
||||
QSE_HTTPD_SERVERSTD_CGI, /* qse_httpd_serverstd_cgi_t */
|
||||
QSE_HTTPD_SERVERSTD_MIME, /* const qse_mchar_t* */
|
||||
QSE_HTTPD_SERVERSTD_DIRACC, /* int (http error code) */
|
||||
QSE_HTTPD_SERVERSTD_FILEACC, /* int (http error code) */
|
||||
QSE_HTTPD_SERVERSTD_FILEACC /* int (http error code) */
|
||||
|
||||
QSE_HTTPD_SERVERSTD_SSL /* qse_httpd_serverstd_ssl_t */
|
||||
};
|
||||
typedef enum qse_httpd_serverstd_query_code_t qse_httpd_serverstd_query_code_t;
|
||||
|
||||
|
Reference in New Issue
Block a user