enhanced cmd/http/httpd.c to load host/location-specific configuration data
This commit is contained in:
parent
357aec132a
commit
847a08c455
@ -595,8 +595,8 @@ static int comparg (int argc, qse_char_t* argv[], struct arg_t* arg)
|
||||
goto oops;
|
||||
}
|
||||
|
||||
qse_htb_setmancbs (gvm,
|
||||
qse_gethtbmancbs(QSE_HTB_MANCBS_INLINE_VALUE_COPIER)
|
||||
qse_htb_setstyle (gvm,
|
||||
qse_gethtbstyle(QSE_HTB_STYLE_INLINE_VALUE_COPIER)
|
||||
);
|
||||
|
||||
while ((c = qse_getopt (argc, argv, &opt)) != QSE_CHAR_EOF)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -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;
|
||||
|
||||
|
@ -1141,7 +1141,7 @@ int Awk::open ()
|
||||
|
||||
*(Awk**)QSE_XTN(functionMap) = this;
|
||||
|
||||
static qse_htb_mancbs_t mancbs =
|
||||
static qse_htb_style_t style =
|
||||
{
|
||||
{
|
||||
QSE_HTB_COPIER_INLINE,
|
||||
@ -1156,7 +1156,7 @@ int Awk::open ()
|
||||
QSE_HTB_SIZER_DEFAULT,
|
||||
QSE_HTB_HASHER_DEFAULT
|
||||
};
|
||||
qse_htb_setmancbs (functionMap, &mancbs);
|
||||
qse_htb_setstyle (functionMap, &style);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -206,8 +206,8 @@ StdAwk::Run* StdAwk::parse (Source& in, Source& out)
|
||||
this->setError (QSE_AWK_ENOMEM);
|
||||
return QSE_NULL;
|
||||
}
|
||||
qse_htb_setmancbs (&this->cmgrtab,
|
||||
qse_gethtbmancbs(QSE_HTB_MANCBS_INLINE_KEY_COPIER));
|
||||
qse_htb_setstyle (&this->cmgrtab,
|
||||
qse_gethtbstyle(QSE_HTB_STYLE_INLINE_KEY_COPIER));
|
||||
this->cmgrtab_inited = true;
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ qse_awk_t* qse_awk_open (qse_mmgr_t* mmgr, qse_size_t xtnsize, qse_awk_prm_t* pr
|
||||
{
|
||||
qse_awk_t* awk;
|
||||
|
||||
static qse_htb_mancbs_t treefuncbs =
|
||||
static qse_htb_style_t treefuncbs =
|
||||
{
|
||||
{
|
||||
QSE_HTB_COPIER_INLINE,
|
||||
@ -90,7 +90,7 @@ qse_awk_t* qse_awk_open (qse_mmgr_t* mmgr, qse_size_t xtnsize, qse_awk_prm_t* pr
|
||||
QSE_HTB_HASHER_DEFAULT
|
||||
};
|
||||
|
||||
static qse_htb_mancbs_t fncusercbs =
|
||||
static qse_htb_style_t fncusercbs =
|
||||
{
|
||||
{
|
||||
QSE_HTB_COPIER_INLINE,
|
||||
@ -156,8 +156,8 @@ qse_awk_t* qse_awk_open (qse_mmgr_t* mmgr, qse_size_t xtnsize, qse_awk_prm_t* pr
|
||||
);
|
||||
if (awk->sio_names == QSE_NULL) goto oops;
|
||||
*(qse_awk_t**)QSE_XTN(awk->sio_names) = awk;
|
||||
qse_htb_setmancbs (awk->sio_names,
|
||||
qse_gethtbmancbs(QSE_HTB_MANCBS_INLINE_KEY_COPIER)
|
||||
qse_htb_setstyle (awk->sio_names,
|
||||
qse_gethtbstyle(QSE_HTB_STYLE_INLINE_KEY_COPIER)
|
||||
);
|
||||
|
||||
/* TODO: initial map size?? */
|
||||
@ -166,15 +166,15 @@ qse_awk_t* qse_awk_open (qse_mmgr_t* mmgr, qse_size_t xtnsize, qse_awk_prm_t* pr
|
||||
);
|
||||
if (awk->tree.funs == QSE_NULL) goto oops;
|
||||
*(qse_awk_t**)QSE_XTN(awk->tree.funs) = awk;
|
||||
qse_htb_setmancbs (awk->tree.funs, &treefuncbs);
|
||||
qse_htb_setstyle (awk->tree.funs, &treefuncbs);
|
||||
|
||||
awk->parse.funs = qse_htb_open (
|
||||
mmgr, QSE_SIZEOF(awk), 256, 70, QSE_SIZEOF(qse_char_t), 1
|
||||
);
|
||||
if (awk->parse.funs == QSE_NULL) goto oops;
|
||||
*(qse_awk_t**)QSE_XTN(awk->parse.funs) = awk;
|
||||
qse_htb_setmancbs (awk->parse.funs,
|
||||
qse_gethtbmancbs(QSE_HTB_MANCBS_INLINE_KEY_COPIER)
|
||||
qse_htb_setstyle (awk->parse.funs,
|
||||
qse_gethtbstyle(QSE_HTB_STYLE_INLINE_KEY_COPIER)
|
||||
);
|
||||
|
||||
awk->parse.named = qse_htb_open (
|
||||
@ -182,8 +182,8 @@ qse_awk_t* qse_awk_open (qse_mmgr_t* mmgr, qse_size_t xtnsize, qse_awk_prm_t* pr
|
||||
);
|
||||
if (awk->parse.named == QSE_NULL) goto oops;
|
||||
*(qse_awk_t**)QSE_XTN(awk->parse.named) = awk;
|
||||
qse_htb_setmancbs (awk->parse.named,
|
||||
qse_gethtbmancbs(QSE_HTB_MANCBS_INLINE_KEY_COPIER)
|
||||
qse_htb_setstyle (awk->parse.named,
|
||||
qse_gethtbstyle(QSE_HTB_STYLE_INLINE_KEY_COPIER)
|
||||
);
|
||||
|
||||
awk->parse.gbls = qse_lda_open (mmgr, QSE_SIZEOF(awk), 128);
|
||||
@ -234,13 +234,13 @@ qse_awk_t* qse_awk_open (qse_mmgr_t* mmgr, qse_size_t xtnsize, qse_awk_prm_t* pr
|
||||
);
|
||||
if (awk->fnc.user == QSE_NULL) goto oops;
|
||||
*(qse_awk_t**)QSE_XTN(awk->fnc.user) = awk;
|
||||
qse_htb_setmancbs (awk->fnc.user, &fncusercbs);
|
||||
qse_htb_setstyle (awk->fnc.user, &fncusercbs);
|
||||
|
||||
awk->modtab = qse_rbt_open (mmgr, 0, QSE_SIZEOF(qse_char_t), 1);
|
||||
if (awk->modtab == QSE_NULL) goto oops;
|
||||
qse_rbt_setmancbs (
|
||||
qse_rbt_setstyle (
|
||||
awk->modtab,
|
||||
qse_getrbtmancbs(QSE_RBT_MANCBS_INLINE_COPIERS)
|
||||
qse_getrbtstyle(QSE_RBT_STYLE_INLINE_COPIERS)
|
||||
);
|
||||
|
||||
if (qse_awk_initgbls (awk) <= -1) goto oops;
|
||||
|
@ -595,7 +595,7 @@ int qse_awk_mod_dir (qse_awk_mod_t* mod, qse_awk_t* awk)
|
||||
qse_awk_seterrnum (awk, QSE_AWK_ENOMEM, QSE_NULL);
|
||||
return -1;
|
||||
}
|
||||
qse_rbt_setmancbs (rbt, qse_getrbtmancbs(QSE_RBT_MANCBS_INLINE_COPIERS));
|
||||
qse_rbt_setstyle (rbt, qse_getrbtstyle(QSE_RBT_STYLE_INLINE_COPIERS));
|
||||
|
||||
mod->ctx = rbt;
|
||||
return 0;
|
||||
|
@ -1422,7 +1422,7 @@ int qse_awk_mod_uci (qse_awk_mod_t* mod, qse_awk_t* awk)
|
||||
qse_awk_seterrnum (awk, QSE_AWK_ENOMEM, QSE_NULL);
|
||||
return -1;
|
||||
}
|
||||
qse_rbt_setmancbs (rbt, qse_getrbtmancbs(QSE_RBT_MANCBS_INLINE_COPIERS));
|
||||
qse_rbt_setstyle (rbt, qse_getrbtstyle(QSE_RBT_STYLE_INLINE_COPIERS));
|
||||
|
||||
mod->ctx = rbt;
|
||||
return 0;
|
||||
|
@ -894,7 +894,7 @@ static void same_namedval (qse_htb_t* map, void* dptr, qse_size_t dlen)
|
||||
|
||||
static int init_rtx (qse_awk_rtx_t* rtx, qse_awk_t* awk, qse_awk_rio_t* rio)
|
||||
{
|
||||
static qse_htb_mancbs_t mancbs_for_named =
|
||||
static qse_htb_style_t style_for_named =
|
||||
{
|
||||
{
|
||||
QSE_HTB_COPIER_INLINE,
|
||||
@ -942,7 +942,7 @@ static int init_rtx (qse_awk_rtx_t* rtx, qse_awk_t* awk, qse_awk_rio_t* rio)
|
||||
rtx->named = qse_htb_open (MMGR(rtx), QSE_SIZEOF(rtx), 1024, 70, QSE_SIZEOF(qse_char_t), 1);
|
||||
if (rtx->named == QSE_NULL) goto oops_5;
|
||||
*(qse_awk_rtx_t**)QSE_XTN(rtx->named) = rtx;
|
||||
qse_htb_setmancbs (rtx->named, &mancbs_for_named);
|
||||
qse_htb_setstyle (rtx->named, &style_for_named);
|
||||
|
||||
rtx->format.tmp.ptr = (qse_char_t*)
|
||||
QSE_AWK_ALLOC (rtx->awk, 4096*QSE_SIZEOF(qse_char_t*));
|
||||
|
@ -2095,8 +2095,8 @@ qse_awk_rtx_t* qse_awk_rtx_openstd (
|
||||
qse_awk_seterrnum (awk, QSE_AWK_ENOMEM, QSE_NULL);
|
||||
return QSE_NULL;
|
||||
}
|
||||
qse_htb_setmancbs (&rxtn->cmgrtab,
|
||||
qse_gethtbmancbs(QSE_HTB_MANCBS_INLINE_COPIERS));
|
||||
qse_htb_setstyle (&rxtn->cmgrtab,
|
||||
qse_gethtbstyle(QSE_HTB_STYLE_INLINE_COPIERS));
|
||||
rxtn->cmgrtab_inited = 1;
|
||||
}
|
||||
|
||||
|
@ -488,7 +488,7 @@ static void same_mapval (qse_htb_t* map, void* dptr, qse_size_t dlen)
|
||||
|
||||
qse_awk_val_t* qse_awk_rtx_makemapval (qse_awk_rtx_t* rtx)
|
||||
{
|
||||
static qse_htb_mancbs_t mancbs =
|
||||
static qse_htb_style_t style =
|
||||
{
|
||||
/* the key is copied inline into a pair and is freed when the pair
|
||||
* is destroyed. not setting copier for a value means that the pointer
|
||||
@ -559,7 +559,7 @@ qse_awk_val_t* qse_awk_rtx_makemapval (qse_awk_rtx_t* rtx)
|
||||
return QSE_NULL;
|
||||
}
|
||||
*(qse_awk_rtx_t**)QSE_XTN(val->map) = rtx;
|
||||
qse_htb_setmancbs (val->map, &mancbs);
|
||||
qse_htb_setstyle (val->map, &style);
|
||||
/* END CHECK */
|
||||
|
||||
return (qse_awk_val_t*)val;
|
||||
|
@ -32,8 +32,8 @@
|
||||
#define sizer_t qse_htb_sizer_t
|
||||
#define walker_t qse_htb_walker_t
|
||||
#define cbserter_t qse_htb_cbserter_t
|
||||
#define mancbs_t qse_htb_mancbs_t
|
||||
#define mancbs_kind_t qse_htb_mancbs_kind_t
|
||||
#define style_t qse_htb_style_t
|
||||
#define style_kind_t qse_htb_style_kind_t
|
||||
|
||||
#define KPTR(p) QSE_HTB_KPTR(p)
|
||||
#define KLEN(p) QSE_HTB_KLEN(p)
|
||||
@ -53,10 +53,13 @@ QSE_INLINE pair_t* qse_htb_allocpair (
|
||||
htb_t* htb, void* kptr, size_t klen, void* vptr, size_t vlen)
|
||||
{
|
||||
pair_t* n;
|
||||
copier_t kcop = htb->mancbs->copier[QSE_HTB_KEY];
|
||||
copier_t vcop = htb->mancbs->copier[QSE_HTB_VAL];
|
||||
copier_t kcop, vcop;
|
||||
size_t as;
|
||||
|
||||
size_t as = SIZEOF(pair_t);
|
||||
kcop = htb->style->copier[QSE_HTB_KEY];
|
||||
vcop = htb->style->copier[QSE_HTB_VAL];
|
||||
|
||||
as = SIZEOF(pair_t);
|
||||
if (kcop == QSE_HTB_COPIER_INLINE) as += KTOB(htb,klen);
|
||||
if (vcop == QSE_HTB_COPIER_INLINE) as += VTOB(htb,vlen);
|
||||
|
||||
@ -106,8 +109,8 @@ QSE_INLINE pair_t* qse_htb_allocpair (
|
||||
VPTR(n) = vcop (htb, vptr, vlen);
|
||||
if (VPTR(n) != QSE_NULL)
|
||||
{
|
||||
if (htb->mancbs->freeer[QSE_HTB_KEY] != QSE_NULL)
|
||||
htb->mancbs->freeer[QSE_HTB_KEY] (htb, KPTR(n), KLEN(n));
|
||||
if (htb->style->freeer[QSE_HTB_KEY] != QSE_NULL)
|
||||
htb->style->freeer[QSE_HTB_KEY] (htb, KPTR(n), KLEN(n));
|
||||
QSE_MMGR_FREE (htb->mmgr, n);
|
||||
return QSE_NULL;
|
||||
}
|
||||
@ -118,10 +121,10 @@ QSE_INLINE pair_t* qse_htb_allocpair (
|
||||
|
||||
QSE_INLINE void qse_htb_freepair (htb_t* htb, pair_t* pair)
|
||||
{
|
||||
if (htb->mancbs->freeer[QSE_HTB_KEY] != QSE_NULL)
|
||||
htb->mancbs->freeer[QSE_HTB_KEY] (htb, KPTR(pair), KLEN(pair));
|
||||
if (htb->mancbs->freeer[QSE_HTB_VAL] != QSE_NULL)
|
||||
htb->mancbs->freeer[QSE_HTB_VAL] (htb, VPTR(pair), VLEN(pair));
|
||||
if (htb->style->freeer[QSE_HTB_KEY] != QSE_NULL)
|
||||
htb->style->freeer[QSE_HTB_KEY] (htb, KPTR(pair), KLEN(pair));
|
||||
if (htb->style->freeer[QSE_HTB_VAL] != QSE_NULL)
|
||||
htb->style->freeer[QSE_HTB_VAL] (htb, VPTR(pair), VLEN(pair));
|
||||
QSE_MMGR_FREE (htb->mmgr, pair);
|
||||
}
|
||||
|
||||
@ -133,14 +136,14 @@ static QSE_INLINE pair_t* change_pair_val (
|
||||
/* if the old value and the new value are the same,
|
||||
* it just calls the handler for this condition.
|
||||
* No value replacement occurs. */
|
||||
if (htb->mancbs->keeper != QSE_NULL)
|
||||
if (htb->style->keeper != QSE_NULL)
|
||||
{
|
||||
htb->mancbs->keeper (htb, vptr, vlen);
|
||||
htb->style->keeper (htb, vptr, vlen);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
copier_t vcop = htb->mancbs->copier[QSE_HTB_VAL];
|
||||
copier_t vcop = htb->style->copier[QSE_HTB_VAL];
|
||||
void* ovptr = VPTR(pair);
|
||||
size_t ovlen = VLEN(pair);
|
||||
|
||||
@ -176,9 +179,9 @@ static QSE_INLINE pair_t* change_pair_val (
|
||||
}
|
||||
|
||||
/* free up the old value */
|
||||
if (htb->mancbs->freeer[QSE_HTB_VAL] != QSE_NULL)
|
||||
if (htb->style->freeer[QSE_HTB_VAL] != QSE_NULL)
|
||||
{
|
||||
htb->mancbs->freeer[QSE_HTB_VAL] (htb, ovptr, ovlen);
|
||||
htb->style->freeer[QSE_HTB_VAL] (htb, ovptr, ovlen);
|
||||
}
|
||||
}
|
||||
|
||||
@ -186,9 +189,9 @@ static QSE_INLINE pair_t* change_pair_val (
|
||||
return pair;
|
||||
}
|
||||
|
||||
static mancbs_t mancbs[] =
|
||||
static style_t style[] =
|
||||
{
|
||||
/* == QSE_HTB_MANCBS_DEFAULT == */
|
||||
/* == QSE_HTB_STYLE_DEFAULT == */
|
||||
{
|
||||
{
|
||||
QSE_HTB_COPIER_DEFAULT,
|
||||
@ -204,7 +207,7 @@ static mancbs_t mancbs[] =
|
||||
QSE_HTB_HASHER_DEFAULT
|
||||
},
|
||||
|
||||
/* == QSE_HTB_MANCBS_INLINE_COPIERS == */
|
||||
/* == QSE_HTB_STYLE_INLINE_COPIERS == */
|
||||
{
|
||||
{
|
||||
QSE_HTB_COPIER_INLINE,
|
||||
@ -220,7 +223,7 @@ static mancbs_t mancbs[] =
|
||||
QSE_HTB_HASHER_DEFAULT
|
||||
},
|
||||
|
||||
/* == QSE_HTB_MANCBS_INLINE_KEY_COPIER == */
|
||||
/* == QSE_HTB_STYLE_INLINE_KEY_COPIER == */
|
||||
{
|
||||
{
|
||||
QSE_HTB_COPIER_INLINE,
|
||||
@ -236,7 +239,7 @@ static mancbs_t mancbs[] =
|
||||
QSE_HTB_HASHER_DEFAULT
|
||||
},
|
||||
|
||||
/* == QSE_HTB_MANCBS_INLINE_VALUE_COPIER == */
|
||||
/* == QSE_HTB_STYLE_INLINE_VALUE_COPIER == */
|
||||
{
|
||||
{
|
||||
QSE_HTB_COPIER_DEFAULT,
|
||||
@ -253,9 +256,9 @@ static mancbs_t mancbs[] =
|
||||
}
|
||||
};
|
||||
|
||||
const mancbs_t* qse_gethtbmancbs (mancbs_kind_t kind)
|
||||
const style_t* qse_gethtbstyle (style_kind_t kind)
|
||||
{
|
||||
return &mancbs[kind];
|
||||
return &style[kind];
|
||||
}
|
||||
|
||||
htb_t* qse_htb_open (
|
||||
@ -318,7 +321,7 @@ int qse_htb_init (
|
||||
htb->threshold = htb->capa * htb->factor / 100;
|
||||
if (htb->capa > 0 && htb->threshold <= 0) htb->threshold = 1;
|
||||
|
||||
htb->mancbs = &mancbs[0];
|
||||
htb->style = &style[0];
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -338,15 +341,15 @@ void* qse_htb_getxtn (qse_htb_t* htb)
|
||||
return QSE_XTN (htb);
|
||||
}
|
||||
|
||||
const mancbs_t* qse_htb_getmancbs (const htb_t* htb)
|
||||
const style_t* qse_htb_getstyle (const htb_t* htb)
|
||||
{
|
||||
return htb->mancbs;
|
||||
return htb->style;
|
||||
}
|
||||
|
||||
void qse_htb_setmancbs (htb_t* htb, const mancbs_t* mancbs)
|
||||
void qse_htb_setstyle (htb_t* htb, const style_t* style)
|
||||
{
|
||||
QSE_ASSERT (mancbs != QSE_NULL);
|
||||
htb->mancbs = mancbs;
|
||||
QSE_ASSERT (style != QSE_NULL);
|
||||
htb->style = style;
|
||||
}
|
||||
|
||||
size_t qse_htb_getsize (const htb_t* htb)
|
||||
@ -364,12 +367,12 @@ pair_t* qse_htb_search (const htb_t* htb, const void* kptr, size_t klen)
|
||||
pair_t* pair;
|
||||
size_t hc;
|
||||
|
||||
hc = htb->mancbs->hasher(htb,kptr,klen) % htb->capa;
|
||||
hc = htb->style->hasher(htb,kptr,klen) % htb->capa;
|
||||
pair = htb->bucket[hc];
|
||||
|
||||
while (pair != QSE_NULL)
|
||||
{
|
||||
if (htb->mancbs->comper (htb, KPTR(pair), KLEN(pair), kptr, klen) == 0)
|
||||
if (htb->style->comper (htb, KPTR(pair), KLEN(pair), kptr, klen) == 0)
|
||||
{
|
||||
return pair;
|
||||
}
|
||||
@ -385,9 +388,9 @@ static QSE_INLINE_ALWAYS int reorganize (htb_t* htb)
|
||||
size_t i, hc, new_capa;
|
||||
pair_t** new_buck;
|
||||
|
||||
if (htb->mancbs->sizer)
|
||||
if (htb->style->sizer)
|
||||
{
|
||||
new_capa = htb->mancbs->sizer (htb, htb->capa + 1);
|
||||
new_capa = htb->style->sizer (htb, htb->capa + 1);
|
||||
|
||||
/* if no change in capacity, return success
|
||||
* without reorganization */
|
||||
@ -423,7 +426,7 @@ static QSE_INLINE_ALWAYS int reorganize (htb_t* htb)
|
||||
{
|
||||
pair_t* next = NEXT(pair);
|
||||
|
||||
hc = htb->mancbs->hasher (htb,
|
||||
hc = htb->style->hasher (htb,
|
||||
KPTR(pair),
|
||||
KLEN(pair)) % new_capa;
|
||||
|
||||
@ -454,7 +457,7 @@ static pair_t* insert (
|
||||
pair_t* pair, * p, * prev, * next;
|
||||
size_t hc;
|
||||
|
||||
hc = htb->mancbs->hasher(htb,kptr,klen) % htb->capa;
|
||||
hc = htb->style->hasher(htb,kptr,klen) % htb->capa;
|
||||
pair = htb->bucket[hc];
|
||||
prev = QSE_NULL;
|
||||
|
||||
@ -462,7 +465,7 @@ static pair_t* insert (
|
||||
{
|
||||
next = NEXT(pair);
|
||||
|
||||
if (htb->mancbs->comper (htb, KPTR(pair), KLEN(pair), kptr, klen) == 0)
|
||||
if (htb->style->comper (htb, KPTR(pair), KLEN(pair), kptr, klen) == 0)
|
||||
{
|
||||
/* found a pair with a matching key */
|
||||
switch (opt)
|
||||
@ -509,7 +512,7 @@ static pair_t* insert (
|
||||
* more bucket collision and performance penalty. */
|
||||
if (reorganize(htb) == 0)
|
||||
{
|
||||
hc = htb->mancbs->hasher(htb,kptr,klen) % htb->capa;
|
||||
hc = htb->style->hasher(htb,kptr,klen) % htb->capa;
|
||||
}
|
||||
}
|
||||
|
||||
@ -556,7 +559,7 @@ pair_t* qse_htb_cbsert (
|
||||
pair_t* pair, * p, * prev, * next;
|
||||
size_t hc;
|
||||
|
||||
hc = htb->mancbs->hasher(htb,kptr,klen) % htb->capa;
|
||||
hc = htb->style->hasher(htb,kptr,klen) % htb->capa;
|
||||
pair = htb->bucket[hc];
|
||||
prev = QSE_NULL;
|
||||
|
||||
@ -564,7 +567,7 @@ pair_t* qse_htb_cbsert (
|
||||
{
|
||||
next = NEXT(pair);
|
||||
|
||||
if (htb->mancbs->comper (htb, KPTR(pair), KLEN(pair), kptr, klen) == 0)
|
||||
if (htb->style->comper (htb, KPTR(pair), KLEN(pair), kptr, klen) == 0)
|
||||
{
|
||||
/* found a pair with a matching key */
|
||||
p = cbserter (htb, pair, kptr, klen, ctx);
|
||||
@ -596,7 +599,7 @@ pair_t* qse_htb_cbsert (
|
||||
* more bucket collision and performance penalty. */
|
||||
if (reorganize(htb) == 0)
|
||||
{
|
||||
hc = htb->mancbs->hasher(htb,kptr,klen) % htb->capa;
|
||||
hc = htb->style->hasher(htb,kptr,klen) % htb->capa;
|
||||
}
|
||||
}
|
||||
|
||||
@ -617,13 +620,13 @@ int qse_htb_delete (htb_t* htb, const void* kptr, size_t klen)
|
||||
pair_t* pair, * prev;
|
||||
size_t hc;
|
||||
|
||||
hc = htb->mancbs->hasher(htb,kptr,klen) % htb->capa;
|
||||
hc = htb->style->hasher(htb,kptr,klen) % htb->capa;
|
||||
pair = htb->bucket[hc];
|
||||
prev = QSE_NULL;
|
||||
|
||||
while (pair != QSE_NULL)
|
||||
{
|
||||
if (htb->mancbs->comper (htb, KPTR(pair), KLEN(pair), kptr, klen) == 0)
|
||||
if (htb->style->comper (htb, KPTR(pair), KLEN(pair), kptr, klen) == 0)
|
||||
{
|
||||
if (prev == QSE_NULL)
|
||||
htb->bucket[hc] = NEXT(pair);
|
||||
|
@ -30,8 +30,8 @@
|
||||
#define keeper_t qse_rbt_keeper_t
|
||||
#define walker_t qse_rbt_walker_t
|
||||
#define cbserter_t qse_rbt_cbserter_t
|
||||
#define mancbs_t qse_rbt_mancbs_t
|
||||
#define mancbs_kind_t qse_rbt_mancbs_kind_t
|
||||
#define style_t qse_rbt_style_t
|
||||
#define style_kind_t qse_rbt_style_kind_t
|
||||
|
||||
#define KPTR(p) QSE_RBT_KPTR(p)
|
||||
#define KLEN(p) QSE_RBT_KLEN(p)
|
||||
@ -64,8 +64,8 @@ QSE_INLINE pair_t* qse_rbt_allocpair (
|
||||
{
|
||||
pair_t* n;
|
||||
|
||||
copier_t kcop = rbt->mancbs->copier[QSE_RBT_KEY];
|
||||
copier_t vcop = rbt->mancbs->copier[QSE_RBT_VAL];
|
||||
copier_t kcop = rbt->style->copier[QSE_RBT_KEY];
|
||||
copier_t vcop = rbt->style->copier[QSE_RBT_VAL];
|
||||
|
||||
size_t as = SIZEOF(pair_t);
|
||||
if (kcop == QSE_RBT_COPIER_INLINE) as += KTOB(rbt,klen);
|
||||
@ -116,8 +116,8 @@ QSE_INLINE pair_t* qse_rbt_allocpair (
|
||||
VPTR(n) = vcop (rbt, vptr, vlen);
|
||||
if (VPTR(n) != QSE_NULL)
|
||||
{
|
||||
if (rbt->mancbs->freeer[QSE_RBT_KEY] != QSE_NULL)
|
||||
rbt->mancbs->freeer[QSE_RBT_KEY] (rbt, KPTR(n), KLEN(n));
|
||||
if (rbt->style->freeer[QSE_RBT_KEY] != QSE_NULL)
|
||||
rbt->style->freeer[QSE_RBT_KEY] (rbt, KPTR(n), KLEN(n));
|
||||
QSE_MMGR_FREE (rbt->mmgr, n);
|
||||
return QSE_NULL;
|
||||
}
|
||||
@ -128,14 +128,14 @@ QSE_INLINE pair_t* qse_rbt_allocpair (
|
||||
|
||||
QSE_INLINE void qse_rbt_freepair (rbt_t* rbt, pair_t* pair)
|
||||
{
|
||||
if (rbt->mancbs->freeer[QSE_RBT_KEY] != QSE_NULL)
|
||||
rbt->mancbs->freeer[QSE_RBT_KEY] (rbt, KPTR(pair), KLEN(pair));
|
||||
if (rbt->mancbs->freeer[QSE_RBT_VAL] != QSE_NULL)
|
||||
rbt->mancbs->freeer[QSE_RBT_VAL] (rbt, VPTR(pair), VLEN(pair));
|
||||
if (rbt->style->freeer[QSE_RBT_KEY] != QSE_NULL)
|
||||
rbt->style->freeer[QSE_RBT_KEY] (rbt, KPTR(pair), KLEN(pair));
|
||||
if (rbt->style->freeer[QSE_RBT_VAL] != QSE_NULL)
|
||||
rbt->style->freeer[QSE_RBT_VAL] (rbt, VPTR(pair), VLEN(pair));
|
||||
QSE_MMGR_FREE (rbt->mmgr, pair);
|
||||
}
|
||||
|
||||
static mancbs_t mancbs[] =
|
||||
static style_t style[] =
|
||||
{
|
||||
{
|
||||
{
|
||||
@ -190,9 +190,9 @@ static mancbs_t mancbs[] =
|
||||
}
|
||||
};
|
||||
|
||||
const mancbs_t* qse_getrbtmancbs (mancbs_kind_t kind)
|
||||
const style_t* qse_getrbtstyle (style_kind_t kind)
|
||||
{
|
||||
return &mancbs[kind];
|
||||
return &style[kind];
|
||||
}
|
||||
|
||||
rbt_t* qse_rbt_open (mmgr_t* mmgr, size_t xtnsize, int kscale, int vscale)
|
||||
@ -228,7 +228,7 @@ int qse_rbt_init (rbt_t* rbt, mmgr_t* mmgr, int kscale, int vscale)
|
||||
rbt->scale[QSE_RBT_VAL] = (vscale < 1)? 1: vscale;
|
||||
rbt->size = 0;
|
||||
|
||||
rbt->mancbs = &mancbs[0];
|
||||
rbt->style = &style[0];
|
||||
|
||||
/* self-initializing nil */
|
||||
QSE_MEMSET(&rbt->xnil, 0, QSE_SIZEOF(rbt->xnil));
|
||||
@ -257,15 +257,15 @@ void* qse_rbt_getxtn (qse_rbt_t* rbt)
|
||||
return QSE_XTN (rbt);
|
||||
}
|
||||
|
||||
const mancbs_t* qse_rbt_getmancbs (const rbt_t* rbt)
|
||||
const style_t* qse_rbt_getstyle (const rbt_t* rbt)
|
||||
{
|
||||
return rbt->mancbs;
|
||||
return rbt->style;
|
||||
}
|
||||
|
||||
void qse_rbt_setmancbs (rbt_t* rbt, const mancbs_t* mancbs)
|
||||
void qse_rbt_setstyle (rbt_t* rbt, const style_t* style)
|
||||
{
|
||||
QSE_ASSERT (mancbs != QSE_NULL);
|
||||
rbt->mancbs = mancbs;
|
||||
QSE_ASSERT (style != QSE_NULL);
|
||||
rbt->style = style;
|
||||
}
|
||||
|
||||
size_t qse_rbt_getsize (const rbt_t* rbt)
|
||||
@ -279,7 +279,7 @@ pair_t* qse_rbt_search (const rbt_t* rbt, const void* kptr, size_t klen)
|
||||
|
||||
while (!IS_NIL(rbt,pair))
|
||||
{
|
||||
int n = rbt->mancbs->comper (rbt, kptr, klen, KPTR(pair), KLEN(pair));
|
||||
int n = rbt->style->comper (rbt, kptr, klen, KPTR(pair), KLEN(pair));
|
||||
if (n == 0) return pair;
|
||||
|
||||
if (n > 0) pair = pair->right;
|
||||
@ -429,14 +429,14 @@ static pair_t* change_pair_val (
|
||||
/* if the old value and the new value are the same,
|
||||
* it just calls the handler for this condition.
|
||||
* No value replacement occurs. */
|
||||
if (rbt->mancbs->keeper != QSE_NULL)
|
||||
if (rbt->style->keeper != QSE_NULL)
|
||||
{
|
||||
rbt->mancbs->keeper (rbt, vptr, vlen);
|
||||
rbt->style->keeper (rbt, vptr, vlen);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
copier_t vcop = rbt->mancbs->copier[QSE_RBT_VAL];
|
||||
copier_t vcop = rbt->style->copier[QSE_RBT_VAL];
|
||||
void* ovptr = VPTR(pair);
|
||||
size_t ovlen = VLEN(pair);
|
||||
|
||||
@ -495,9 +495,9 @@ static pair_t* change_pair_val (
|
||||
}
|
||||
|
||||
/* free up the old value */
|
||||
if (rbt->mancbs->freeer[QSE_RBT_VAL] != QSE_NULL)
|
||||
if (rbt->style->freeer[QSE_RBT_VAL] != QSE_NULL)
|
||||
{
|
||||
rbt->mancbs->freeer[QSE_RBT_VAL] (rbt, ovptr, ovlen);
|
||||
rbt->style->freeer[QSE_RBT_VAL] (rbt, ovptr, ovlen);
|
||||
}
|
||||
}
|
||||
|
||||
@ -513,7 +513,7 @@ static pair_t* insert (
|
||||
|
||||
while (!IS_NIL(rbt,x_cur))
|
||||
{
|
||||
int n = rbt->mancbs->comper (rbt, kptr, klen, KPTR(x_cur), KLEN(x_cur));
|
||||
int n = rbt->style->comper (rbt, kptr, klen, KPTR(x_cur), KLEN(x_cur));
|
||||
if (n == 0)
|
||||
{
|
||||
switch (opt)
|
||||
@ -552,7 +552,7 @@ static pair_t* insert (
|
||||
else
|
||||
{
|
||||
/* perform normal binary insert */
|
||||
int n = rbt->mancbs->comper (rbt, kptr, klen, KPTR(x_par), KLEN(x_par));
|
||||
int n = rbt->style->comper (rbt, kptr, klen, KPTR(x_par), KLEN(x_par));
|
||||
if (n > 0)
|
||||
{
|
||||
QSE_ASSERT (x_par->right == &rbt->xnil);
|
||||
@ -607,7 +607,7 @@ pair_t* qse_rbt_cbsert (
|
||||
|
||||
while (!IS_NIL(rbt,x_cur))
|
||||
{
|
||||
int n = rbt->mancbs->comper (rbt, kptr, klen, KPTR(x_cur), KLEN(x_cur));
|
||||
int n = rbt->style->comper (rbt, kptr, klen, KPTR(x_cur), KLEN(x_cur));
|
||||
if (n == 0)
|
||||
{
|
||||
/* back up the contents of the current pair
|
||||
@ -672,7 +672,7 @@ pair_t* qse_rbt_cbsert (
|
||||
else
|
||||
{
|
||||
/* perform normal binary insert */
|
||||
int n = rbt->mancbs->comper (rbt, kptr, klen, KPTR(x_par), KLEN(x_par));
|
||||
int n = rbt->style->comper (rbt, kptr, klen, KPTR(x_par), KLEN(x_par));
|
||||
if (n > 0)
|
||||
{
|
||||
QSE_ASSERT (x_par->right == &rbt->xnil);
|
||||
|
@ -37,7 +37,7 @@ static void free_hdrval (qse_htb_t* htb, void* vptr, qse_size_t vlen)
|
||||
|
||||
int qse_htre_init (qse_htre_t* re, qse_mmgr_t* mmgr)
|
||||
{
|
||||
static qse_htb_mancbs_t mancbs =
|
||||
static qse_htb_style_t style =
|
||||
{
|
||||
{
|
||||
QSE_HTB_COPIER_DEFAULT,
|
||||
@ -59,8 +59,8 @@ int qse_htre_init (qse_htre_t* re, qse_mmgr_t* mmgr)
|
||||
if (qse_htb_init (&re->hdrtab, mmgr, 60, 70, 1, 1) <= -1) return -1;
|
||||
if (qse_htb_init (&re->trailers, mmgr, 20, 70, 1, 1) <= -1) return -1;
|
||||
|
||||
qse_htb_setmancbs (&re->hdrtab, &mancbs);
|
||||
qse_htb_setmancbs (&re->trailers, &mancbs);
|
||||
qse_htb_setstyle (&re->hdrtab, &style);
|
||||
qse_htb_setstyle (&re->trailers, &style);
|
||||
|
||||
qse_mbs_init (&re->content, mmgr, 0);
|
||||
#if 0
|
||||
|
@ -399,7 +399,7 @@ static QSE_INLINE int task_main_dir (
|
||||
dir = (task_dir_t*)task->ctx;
|
||||
x = task;
|
||||
|
||||
if (qse_mbsend (dir->path.ptr, QSE_MT("/")))
|
||||
if (qse_mbsend (dir->qpath.ptr, QSE_MT("/")))
|
||||
{
|
||||
if (httpd->opt.scb.dir.open (httpd, dir->path.ptr, &handle) <= -1)
|
||||
{
|
||||
|
@ -2209,8 +2209,11 @@ static qse_mchar_t* merge_paths (
|
||||
qse_size_t idx = 0;
|
||||
|
||||
ta[idx++] = base;
|
||||
ta[idx++] = QSE_MT("/");
|
||||
ta[idx++] = path;
|
||||
if (path[0] != QSE_MT('\0'))
|
||||
{
|
||||
ta[idx++] = QSE_MT("/");
|
||||
ta[idx++] = path;
|
||||
}
|
||||
ta[idx++] = QSE_NULL;
|
||||
xpath = qse_mbsadup (ta, QSE_NULL, httpd->mmgr);
|
||||
if (xpath == QSE_NULL)
|
||||
@ -2231,11 +2234,17 @@ static void merge_paths_to_buf (
|
||||
* to hold the result. it doesn't duplicate the result */
|
||||
qse_size_t len = 0;
|
||||
len += qse_mbscpy (&xpath[len], base);
|
||||
len += qse_mbscpy (&xpath[len], QSE_MT("/"));
|
||||
|
||||
if (plen == (qse_size_t)-1)
|
||||
{
|
||||
len += qse_mbscpy (&xpath[len], QSE_MT("/"));
|
||||
len += qse_mbscpy (&xpath[len], path);
|
||||
else
|
||||
}
|
||||
else if (plen > 0)
|
||||
{
|
||||
len += qse_mbscpy (&xpath[len], QSE_MT("/"));
|
||||
len += qse_mbsncpy (&xpath[len], path, plen);
|
||||
}
|
||||
qse_canonmbspath (xpath, xpath, 0);
|
||||
}
|
||||
|
||||
@ -2245,6 +2254,9 @@ struct rsrc_tmp_t
|
||||
const qse_mchar_t* idxfile;
|
||||
qse_mchar_t* xpath;
|
||||
|
||||
qse_size_t qpath_len;
|
||||
const qse_mchar_t* qpath_rp;
|
||||
|
||||
qse_httpd_serverstd_root_t root;
|
||||
qse_httpd_serverstd_realm_t realm;
|
||||
qse_httpd_serverstd_auth_t auth;
|
||||
@ -2295,7 +2307,7 @@ static int attempt_cgi (
|
||||
|
||||
QSE_ASSERT (tmp->qpath[0] == QSE_T('/'));
|
||||
|
||||
ptr = tmp->qpath + 1;
|
||||
ptr = tmp->qpath_rp + 1;
|
||||
while (*ptr != QSE_MT('\0'))
|
||||
{
|
||||
slash = qse_mbschr (ptr, QSE_MT('/'));
|
||||
@ -2309,8 +2321,9 @@ static int attempt_cgi (
|
||||
/* a slash is found and the segment is not empty.
|
||||
*
|
||||
* tmp->xpath should be large enough to hold the merge path made of
|
||||
* the subsegments of the original query path and docroot. */
|
||||
merge_paths_to_buf (httpd, tmp->root.u.path, tmp->qpath, slash - tmp->qpath, tmp->xpath);
|
||||
* the subsegments of the original query path and docroot.
|
||||
*/
|
||||
merge_paths_to_buf (httpd, tmp->root.u.path.val, tmp->qpath_rp, slash - tmp->qpath_rp, tmp->xpath);
|
||||
xpath_changed = 1;
|
||||
|
||||
stx = stat_file (httpd, tmp->xpath, &st, 0);
|
||||
@ -2326,7 +2339,10 @@ static int attempt_cgi (
|
||||
{
|
||||
if (server_xtn->query (httpd, client->server, req, tmp->xpath, QSE_HTTPD_SERVERSTD_CGI, &cgi) >= 0 && cgi.cgi)
|
||||
{
|
||||
script = qse_mbsxdup (tmp->qpath, slash - tmp->qpath , httpd->mmgr);
|
||||
/* the script name is composed of the orginal query path.
|
||||
* the pointer held in 'slash' is valid for tmp->qpath as
|
||||
* tmp->qpath_rp is at most the tail part of tmp->qpath. */
|
||||
script = qse_mbsxdup (tmp->qpath, slash - tmp->qpath, httpd->mmgr);
|
||||
suffix = qse_mbsdup (slash, httpd->mmgr);
|
||||
if (!script || !suffix) goto oops;
|
||||
|
||||
@ -2351,8 +2367,8 @@ static int attempt_cgi (
|
||||
}
|
||||
}
|
||||
|
||||
/* restore the xpath because it has changed... */
|
||||
if (xpath_changed) merge_paths_to_buf (httpd, tmp->root.u.path, tmp->qpath, (qse_size_t)-1, tmp->xpath);
|
||||
/* restore xpath because it has changed... */
|
||||
if (xpath_changed) merge_paths_to_buf (httpd, tmp->root.u.path.val, tmp->qpath_rp, (qse_size_t)-1, tmp->xpath);
|
||||
}
|
||||
|
||||
return 0; /* not a cgi */
|
||||
@ -2363,7 +2379,7 @@ bingo:
|
||||
target->u.cgi.path = tmp->xpath;
|
||||
target->u.cgi.script = script;
|
||||
target->u.cgi.suffix = suffix;
|
||||
target->u.cgi.root = tmp->root.u.path;
|
||||
target->u.cgi.root = tmp->root.u.path.val;
|
||||
target->u.cgi.shebang = shebang;
|
||||
return 1;
|
||||
|
||||
@ -2387,6 +2403,7 @@ static int make_resource (
|
||||
|
||||
QSE_MEMSET (&tmp, 0, QSE_SIZEOF(tmp));
|
||||
tmp.qpath = qse_htre_getqpath(req);
|
||||
tmp.qpath_len = qse_mbslen (tmp.qpath);
|
||||
|
||||
QSE_MEMSET (target, 0, QSE_SIZEOF(*target));
|
||||
|
||||
@ -2411,9 +2428,11 @@ static int make_resource (
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/* default to the root directory. */
|
||||
if (!tmp.root.u.path) tmp.root.u.path = QSE_MT("/");
|
||||
if (!tmp.root.u.path.val) tmp.root.u.path.val = QSE_MT("/");
|
||||
|
||||
tmp.qpath_rp = (tmp.root.u.path.rpl >= tmp.qpath_len)?
|
||||
&tmp.qpath[tmp.qpath_len]: &tmp.qpath[tmp.root.u.path.rpl];
|
||||
|
||||
if (tmp.realm.authreq && tmp.realm.name)
|
||||
{
|
||||
@ -2458,7 +2477,7 @@ static int make_resource (
|
||||
}
|
||||
|
||||
auth_ok:
|
||||
tmp.xpath = merge_paths (httpd, tmp.root.u.path, tmp.qpath);
|
||||
tmp.xpath = merge_paths (httpd, tmp.root.u.path.val, tmp.qpath_rp);
|
||||
if (tmp.xpath == QSE_NULL) return -1;
|
||||
|
||||
stx = stat_file (httpd, tmp.xpath, &st, 0);
|
||||
@ -2620,13 +2639,20 @@ static int query_server (
|
||||
|
||||
switch (code)
|
||||
{
|
||||
case QSE_HTTPD_SERVERSTD_SSL:
|
||||
/* you must specify the certificate and the key file to be able
|
||||
* to use SSL */
|
||||
qse_httpd_seterrnum (httpd, QSE_HTTPD_ENOENT);
|
||||
return -1;
|
||||
|
||||
case QSE_HTTPD_SERVERSTD_NAME:
|
||||
*(const qse_mchar_t**)result = QSE_NULL;
|
||||
break;
|
||||
|
||||
case QSE_HTTPD_SERVERSTD_ROOT:
|
||||
((qse_httpd_serverstd_root_t*)result)->type = QSE_HTTPD_SERVERSTD_ROOT_PATH;
|
||||
((qse_httpd_serverstd_root_t*)result)->u.path = QSE_NULL;
|
||||
((qse_httpd_serverstd_root_t*)result)->u.path.val = QSE_NULL;
|
||||
((qse_httpd_serverstd_root_t*)result)->u.path.rpl = 0;
|
||||
break;
|
||||
|
||||
case QSE_HTTPD_SERVERSTD_REALM:
|
||||
@ -2685,12 +2711,6 @@ static int query_server (
|
||||
case QSE_HTTPD_SERVERSTD_FILEACC:
|
||||
*(int*)result = 200;
|
||||
return 0;
|
||||
|
||||
case QSE_HTTPD_SERVERSTD_SSL:
|
||||
/* you must specify the certificate and the key file to be able
|
||||
* to use SSL */
|
||||
qse_httpd_seterrnum (httpd, QSE_HTTPD_ENOENT);
|
||||
return -1;
|
||||
}
|
||||
|
||||
qse_httpd_seterrnum (httpd, QSE_HTTPD_EINVAL);
|
||||
|
@ -97,9 +97,9 @@ int qse_sed_init (qse_sed_t* sed, qse_mmgr_t* mmgr)
|
||||
|
||||
if (qse_map_init (&sed->tmp.labs, mmgr,
|
||||
128, 70, QSE_SIZEOF(qse_char_t), 1) <= -1) goto oops_3;
|
||||
qse_map_setmancbs (
|
||||
qse_map_setstyle (
|
||||
&sed->tmp.labs,
|
||||
qse_getmapmancbs(QSE_MAP_MANCBS_INLINE_KEY_COPIER)
|
||||
qse_getmapstyle(QSE_MAP_STYLE_INLINE_KEY_COPIER)
|
||||
);
|
||||
|
||||
/* init_append (sed); */
|
||||
@ -3911,7 +3911,7 @@ int qse_sed_exec (qse_sed_t* sed, qse_sed_io_impl_t inf, qse_sed_io_impl_t outf)
|
||||
qse_ssize_t n;
|
||||
int ret = 0;
|
||||
|
||||
static qse_map_mancbs_t mancbs =
|
||||
static qse_map_style_t style =
|
||||
{
|
||||
{
|
||||
QSE_MAP_COPIER_INLINE,
|
||||
@ -3955,7 +3955,7 @@ int qse_sed_exec (qse_sed_t* sed, qse_sed_io_impl_t inf, qse_sed_io_impl_t outf)
|
||||
return -1;
|
||||
}
|
||||
*(qse_sed_t**)QSE_XTN(&sed->e.out.files) = sed;
|
||||
qse_map_setmancbs (&sed->e.out.files, &mancbs);
|
||||
qse_map_setstyle (&sed->e.out.files, &style);
|
||||
|
||||
sed->e.in.fun = inf;
|
||||
sed->e.in.eof = 0;
|
||||
|
@ -72,8 +72,8 @@ int qse_xli_init (qse_xli_t* xli, qse_mmgr_t* mmgr)
|
||||
);
|
||||
if (xli->sio_names == QSE_NULL) goto oops;
|
||||
*(qse_xli_t**)QSE_XTN(xli->sio_names) = xli;
|
||||
qse_htb_setmancbs (xli->sio_names,
|
||||
qse_gethtbmancbs(QSE_HTB_MANCBS_INLINE_KEY_COPIER)
|
||||
qse_htb_setstyle (xli->sio_names,
|
||||
qse_gethtbstyle(QSE_HTB_STYLE_INLINE_KEY_COPIER)
|
||||
);
|
||||
|
||||
xli->root.type = QSE_XLI_LIST;
|
||||
@ -433,9 +433,9 @@ static qse_xli_pair_t* find_pair_byindex (
|
||||
qse_xli_pair_t* qse_xli_findpairbyname (qse_xli_t* xli, const qse_xli_list_t* list, const qse_char_t* name)
|
||||
{
|
||||
const qse_char_t* ptr;
|
||||
qse_cstr_t seg;
|
||||
qse_xli_list_t* curlist;
|
||||
const qse_xli_list_t* curlist;
|
||||
qse_xli_pair_t* pair;
|
||||
qse_cstr_t seg;
|
||||
|
||||
curlist = list? list: &xli->root;
|
||||
|
||||
@ -557,9 +557,9 @@ noent:
|
||||
qse_size_t qse_xli_getnumpairsbyname (qse_xli_t* xli, const qse_xli_list_t* list, const qse_char_t* name)
|
||||
{
|
||||
const qse_char_t* ptr;
|
||||
qse_cstr_t seg;
|
||||
qse_xli_list_t* curlist;
|
||||
const qse_xli_list_t* curlist;
|
||||
qse_xli_pair_t* pair;
|
||||
qse_cstr_t seg;
|
||||
|
||||
curlist = list? list: &xli->root;
|
||||
|
||||
@ -679,7 +679,9 @@ qse_size_t qse_xli_getnumpairsbyname (qse_xli_t* xli, const qse_xli_list_t* list
|
||||
curlist = (qse_xli_list_t*)pair->val;
|
||||
}
|
||||
|
||||
return pair;
|
||||
/* this part must never be reached */
|
||||
qse_xli_seterrnum (xli, QSE_XLI_EINTERN, QSE_NULL);
|
||||
return 0;
|
||||
|
||||
inval:
|
||||
qse_xli_seterrnum (xli, QSE_XLI_EINVAL, QSE_NULL);
|
||||
|
Loading…
x
Reference in New Issue
Block a user