added _instsize to qse_httpd_t, qse_httpd_server_t, qse_httpd_client_t, etc

This commit is contained in:
2019-06-25 02:36:32 +00:00
parent 74b48b87ec
commit 03bdfda578
17 changed files with 270 additions and 298 deletions

View File

@ -1559,12 +1559,16 @@ QSE_EXPORT void qse_awk_close (
qse_awk_t* awk /**< awk */
);
#if defined(QSE_HAVE_INLINE)
/**
* The qse_awk_getxtn() function returns the pointer to the extension area
* placed behind the actual awk object.
*/
static QSE_INLINE void* qse_awk_getxtn (qse_awk_t* awk) { return (void*)((qse_uint8_t*)awk + ((qse_awk_alt_t*)awk)->_instsize); }
/**
* The qse_awk_getmmgr() function gets the memory manager used in
* qse_awk_open().
*/
#if defined(QSE_HAVE_INLINE)
static QSE_INLINE void* qse_awk_getxtn (qse_awk_t* awk) { return (void*)((qse_uint8_t*)awk + ((qse_awk_alt_t*)awk)->_instsize); }
static QSE_INLINE qse_mmgr_t* qse_awk_getmmgr (qse_awk_t* awk) { return ((qse_awk_alt_t*)awk)->_mmgr; }
static QSE_INLINE qse_cmgr_t* qse_awk_getcmgr (qse_awk_t* awk) { return ((qse_awk_alt_t*)awk)->_cmgr; }
static QSE_INLINE void qse_awk_setcmgr (qse_awk_t* awk, qse_cmgr_t* cmgr) { ((qse_awk_alt_t*)awk)->_cmgr = cmgr; }
@ -1609,7 +1613,7 @@ QSE_EXPORT void qse_awk_clear (
* The qse_awk_geterrstr() gets an error string getter.
*/
QSE_EXPORT qse_awk_errstr_t qse_awk_geterrstr (
const qse_awk_t* awk /**< awk */
qse_awk_t* awk /**< awk */
);
/**
@ -1647,7 +1651,7 @@ QSE_EXPORT void qse_awk_seterrstr (
* \return error number
*/
QSE_EXPORT qse_awk_errnum_t qse_awk_geterrnum (
const qse_awk_t* awk /**< awk */
qse_awk_t* awk /**< awk */
);
/**
@ -1655,7 +1659,7 @@ QSE_EXPORT qse_awk_errnum_t qse_awk_geterrnum (
* last error has occurred.
*/
QSE_EXPORT const qse_awk_loc_t* qse_awk_geterrloc (
const qse_awk_t* awk /**< awk */
qse_awk_t* awk /**< awk */
);
/**
@ -1665,7 +1669,7 @@ QSE_EXPORT const qse_awk_loc_t* qse_awk_geterrloc (
* \return error message
*/
QSE_EXPORT const qse_char_t* qse_awk_geterrmsg (
const qse_awk_t* awk /**< awk */
qse_awk_t* awk /**< awk */
);
QSE_EXPORT const qse_char_t* qse_awk_backuperrmsg (
@ -1678,7 +1682,7 @@ QSE_EXPORT const qse_char_t* qse_awk_backuperrmsg (
* pointed to by \a errinf from \a awk.
*/
QSE_EXPORT void qse_awk_geterrinf (
const qse_awk_t* awk, /**< awk */
qse_awk_t* awk, /**< awk */
qse_awk_errinf_t* errinf /**< error information buffer */
);
@ -1718,7 +1722,7 @@ QSE_EXPORT void qse_awk_seterrinf (
* The qse_awk_geterror() function gets error information via parameters.
*/
QSE_EXPORT void qse_awk_geterror (
const qse_awk_t* awk, /**< awk */
qse_awk_t* awk, /**< awk */
qse_awk_errnum_t* errnum, /**< error number */
const qse_char_t** errmsg, /**< error message */
qse_awk_loc_t* errloc /**< error location */
@ -2331,7 +2335,7 @@ QSE_EXPORT qse_htb_t* qse_awk_rtx_getnvmap (
* \return error number
*/
QSE_EXPORT qse_awk_errnum_t qse_awk_rtx_geterrnum (
const qse_awk_rtx_t* rtx /**< runtime context */
qse_awk_rtx_t* rtx /**< runtime context */
);
/**
@ -2340,7 +2344,7 @@ QSE_EXPORT qse_awk_errnum_t qse_awk_rtx_geterrnum (
* \return error location
*/
QSE_EXPORT const qse_awk_loc_t* qse_awk_rtx_geterrloc (
const qse_awk_rtx_t* rtx /**< runtime context */
qse_awk_rtx_t* rtx /**< runtime context */
);
/**
@ -2349,7 +2353,7 @@ QSE_EXPORT const qse_awk_loc_t* qse_awk_rtx_geterrloc (
* \return error message
*/
QSE_EXPORT const qse_char_t* qse_awk_rtx_geterrmsg (
const qse_awk_rtx_t* rtx /**< runtime context */
qse_awk_rtx_t* rtx /**< runtime context */
);
QSE_EXPORT const qse_char_t* qse_awk_rtx_backuperrmsg (
@ -2361,7 +2365,7 @@ QSE_EXPORT const qse_char_t* qse_awk_rtx_backuperrmsg (
* pointed to by \a errinf from a runtime context \a rtx.
*/
QSE_EXPORT void qse_awk_rtx_geterrinf (
const qse_awk_rtx_t* rtx, /**< runtime context */
qse_awk_rtx_t* rtx, /**< runtime context */
qse_awk_errinf_t* errinf /**< error information */
);
@ -2372,7 +2376,7 @@ QSE_EXPORT void qse_awk_rtx_geterrinf (
* \a errmsg; the error line into memory pointed to by \a errlin.
*/
QSE_EXPORT void qse_awk_rtx_geterror (
const qse_awk_rtx_t* rtx, /**< runtime context */
qse_awk_rtx_t* rtx, /**< runtime context */
qse_awk_errnum_t* errnum, /**< error number */
const qse_char_t** errmsg, /**< error message */
qse_awk_loc_t* errloc /**< error location */

View File

@ -37,6 +37,18 @@
#include <qse/si/nwad.h>
typedef struct qse_httpd_t qse_httpd_t;
#define QSE_HTTPD_HDR \
qse_size_t _instsize; \
qse_mmgr_t* _mmgr
typedef struct qse_httpd_alt_t qse_httpd_alt_t;
struct qse_httpd_alt_t
{
/* ensure that qse_httpd_alt_t matches the beginning part of qse_httpd_t */
QSE_HTTPD_HDR;
};
typedef struct qse_httpd_mate_t qse_httpd_mate_t;
typedef struct qse_httpd_server_t qse_httpd_server_t;
typedef struct qse_httpd_client_t qse_httpd_client_t;
@ -676,6 +688,7 @@ typedef enum qse_httpd_mate_type_t qse_httpd_mate_type_t;
/* it contains header fields common between
* qse_httpd_cleint_t and qse_httpd_server_t. */
#define QSE_HTTPD_MATE_HDR \
qse_size_t _instsize; \
qse_httpd_mate_type_t type
struct qse_httpd_mate_t
@ -1077,13 +1090,22 @@ QSE_EXPORT void qse_httpd_close (
qse_httpd_t* httpd
);
QSE_EXPORT qse_mmgr_t* qse_httpd_getmmgr (
qse_httpd_t* httpd
);
QSE_EXPORT void* qse_httpd_getxtn (
qse_httpd_t* httpd
);
#if defined(QSE_HAVE_INLINE)
/**
* The qse_httpd_getxtn() function returns the pointer to the extension area
* placed behind the actual httpd object.
*/
static QSE_INLINE void* qse_httpd_getxtn (qse_httpd_t* httpd) { return (void*)((qse_uint8_t*)httpd + ((qse_httpd_alt_t*)httpd)->_instsize); }
/**
* The qse_httpd_gethttpd() function gets the memory manager used in
* qse_httpd_open().
*/
static QSE_INLINE qse_mmgr_t* qse_httpd_getmmgr (qse_httpd_t* httpd) { return ((qse_httpd_alt_t*)httpd)->_mmgr; }
#else
# define qse_httpd_getxtn(httpd) ((void*)((qse_uint8_t*)httpd + ((qse_httpd_alt_t*)httpd)->_instsize))
# define qse_httpd_getmmgr(httpd) (((qse_httpd_alt_t*)(httpd))->_mmgr)
#endif /* QSE_HAVE_INLINE */
QSE_EXPORT qse_httpd_errnum_t qse_httpd_geterrnum (
qse_httpd_t* httpd
@ -1140,9 +1162,6 @@ QSE_EXPORT void qse_httpd_stop (
QSE_EXPORT void qse_httpd_impede (
qse_httpd_t* httpd
);
#define qse_httpd_getserverxtn(httpd,server) ((void*)(server+1))
QSE_EXPORT qse_httpd_server_t* qse_httpd_attachserver (
qse_httpd_t* httpd,
const qse_httpd_server_dope_t* dope,
@ -1154,6 +1173,12 @@ QSE_EXPORT void qse_httpd_detachserver (
qse_httpd_server_t* server
);
#if defined(QSE_HAVE_INLINE)
static QSE_INLINE void* qse_httpd_getserverxtn (qse_httpd_t* httpd, qse_httpd_server_t* server) { return (void*)((qse_uint8_t*)server + ((qse_httpd_mate_t*)server)->_instsize); }
#else
# define qse_httpd_getserverxtn(httpd, server) ((void*)((qse_uint8_t*)server + ((qse_httpd_mate_t*)server)->_instsize))
#endif
QSE_EXPORT qse_httpd_server_t* qse_httpd_getfirstserver (
qse_httpd_t* httpd
);

View File

@ -233,10 +233,6 @@ QSE_EXPORT qse_httpd_t* qse_httpd_openstdwithmmgr (
qse_httpd_errnum_t* errnum
);
QSE_EXPORT void* qse_httpd_getxtnstd (
qse_httpd_t* httpd
);
QSE_EXPORT qse_httpd_server_t* qse_httpd_attachserverstd (
qse_httpd_t* httpd,
const qse_httpd_server_dope_t* dope,
@ -268,11 +264,6 @@ QSE_EXPORT int qse_httpd_setserverstdopt (
const void* value
);
QSE_EXPORT void* qse_httpd_getserverstdxtn (
qse_httpd_t* httpd,
qse_httpd_server_t* server
);
QSE_EXPORT int qse_httpd_loopstd (
qse_httpd_t* httpd,
const qse_httpd_dnsstd_t* dns,

View File

@ -306,13 +306,10 @@ protected:
private:
static ssize_t sin (
sed_t* s, io_cmd_t cmd, io_arg_t* arg, char_t* buf, size_t len);
static ssize_t xin (
sed_t* s, io_cmd_t cmd, io_arg_t* arg, char_t* buf, size_t len);
static ssize_t xout (
sed_t* s, io_cmd_t cmd, io_arg_t* arg, char_t* dat, size_t len);
static const char_t* xerrstr (const sed_t* s, errnum_t num);
static ssize_t sin (sed_t* s, io_cmd_t cmd, io_arg_t* arg, char_t* buf, size_t len);
static ssize_t xin (sed_t* s, io_cmd_t cmd, io_arg_t* arg, char_t* buf, size_t len);
static ssize_t xout (sed_t* s, io_cmd_t cmd, io_arg_t* arg, char_t* dat, size_t len);
static const char_t* xerrstr (sed_t* s, errnum_t num);
};
/////////////////////////////////

View File

@ -62,6 +62,17 @@
*/
typedef struct qse_sed_t qse_sed_t;
#define QSE_SED_HDR \
qse_size_t _instsize; \
qse_mmgr_t* _mmgr
typedef struct qse_sed_alt_t qse_sed_alt_t;
struct qse_sed_alt_t
{
/* ensure that qse_sed_alt_t matches the beginning part of qse_sed_t */
QSE_SED_HDR;
};
typedef struct qse_sed_loc_t qse_sed_loc_t;
typedef struct qse_sed_adr_t qse_sed_adr_t;
typedef struct qse_sed_cmd_t qse_sed_cmd_t;
@ -274,7 +285,7 @@ typedef enum qse_sed_errnum_t qse_sed_errnum_t;
* editor with the qse_sed_seterrstr() function to customize an error string.
*/
typedef const qse_char_t* (*qse_sed_errstr_t) (
const qse_sed_t* sed, /**< stream editor */
qse_sed_t* sed, /**< stream editor */
qse_sed_errnum_t num /**< an error number */
);
@ -436,22 +447,23 @@ QSE_EXPORT void qse_sed_close (
qse_sed_t* sed /**< stream editor */
);
/**
* The qse_sed_getmmgr() function returns the memory
* manager used in qse_sed_open().
*/
QSE_EXPORT qse_mmgr_t* qse_sed_getmmgr (
qse_sed_t* sed
);
#if defined(QSE_HAVE_INLINE)
/**
* The qse_sed_getxtn() function returns the pointer
* to the beginning of the extension area created with
* The qse_sed_getxtn() function returns the pointer to the extension area
* placed behind the actual sed object.
*/
static QSE_INLINE void* qse_sed_getxtn (qse_sed_t* sed) { return (void*)((qse_uint8_t*)sed + ((qse_sed_alt_t*)sed)->_instsize); }
/**
* The qse_sed_getmmgr() function gets the memory manager used in
* qse_sed_open().
*/
QSE_EXPORT void* qse_sed_getxtn (
qse_sed_t* sed
);
static QSE_INLINE qse_mmgr_t* qse_sed_getmmgr (qse_sed_t* sed) { return ((qse_sed_alt_t*)sed)->_mmgr; }
#else
# define qse_sed_getxtn(sed) ((void*)((qse_uint8_t*)sed + ((qse_sed_alt_t*)sed)->_instsize))
# define qse_sed_getmmgr(sed) (((qse_sed_alt_t*)(sed))->_mmgr)
#endif /* QSE_HAVE_INLINE */
/**
@ -492,7 +504,7 @@ QSE_EXPORT int qse_sed_setopt (
* The qse_sed_geterrstr() gets an error string getter.
*/
QSE_EXPORT qse_sed_errstr_t qse_sed_geterrstr (
const qse_sed_t* sed /**< stream editor */
qse_sed_t* sed /**< stream editor */
);
/**
@ -529,7 +541,7 @@ QSE_EXPORT void qse_sed_seterrstr (
* @return error number
*/
QSE_EXPORT qse_sed_errnum_t qse_sed_geterrnum (
const qse_sed_t* sed /**< stream editor */
qse_sed_t* sed /**< stream editor */
);
/**
@ -538,7 +550,7 @@ QSE_EXPORT qse_sed_errnum_t qse_sed_geterrnum (
* @return error location
*/
QSE_EXPORT const qse_sed_loc_t* qse_sed_geterrloc (
const qse_sed_t* sed /**< stream editor */
qse_sed_t* sed /**< stream editor */
);
/**
@ -546,7 +558,7 @@ QSE_EXPORT const qse_sed_loc_t* qse_sed_geterrloc (
* @return error message pointer
*/
QSE_EXPORT const qse_char_t* qse_sed_geterrmsg (
const qse_sed_t* sed /**< stream editor */
qse_sed_t* sed /**< stream editor */
);
/**
@ -555,7 +567,7 @@ QSE_EXPORT const qse_char_t* qse_sed_geterrmsg (
* to by each parameter.
*/
QSE_EXPORT void qse_sed_geterror (
const qse_sed_t* sed, /**< stream editor */
qse_sed_t* sed, /**< stream editor */
qse_sed_errnum_t* errnum, /**< error number */
const qse_char_t** errmsg, /**< error message */
qse_sed_loc_t* errloc /**< error location */

View File

@ -103,8 +103,7 @@ extern "C" {
/**
* The qse_sed_openstd() function creates a stream editor with the default
* memory manager and initializes it. Use qse_sed_getxtnstd() to get the
* pointer to the extension area. Do not use qse_sed_getxtn() for this.
* memory manager and initializes it.
* \return pointer to a stream editor on success, #QSE_NULL on failure.
*/
QSE_EXPORT qse_sed_t* qse_sed_openstd (
@ -115,8 +114,7 @@ QSE_EXPORT qse_sed_t* qse_sed_openstd (
/**
* The qse_sed_openstdwithmmgr() function creates a stream editor with a
* user-defined memory manager. It is equivalent to qse_sed_openstd(),
* except that you can specify your own memory manager.Use qse_sed_getxtnstd(),
* not qse_sed_getxtn() to get the pointer to the extension area.
* except that you can specify your own memory manager.
* \return pointer to a stream editor on success, #QSE_NULL on failure.
*/
QSE_EXPORT qse_sed_t* qse_sed_openstdwithmmgr (
@ -125,15 +123,6 @@ QSE_EXPORT qse_sed_t* qse_sed_openstdwithmmgr (
qse_sed_errnum_t* errnum
);
/**
* The qse_sed_getxtnstd() gets the pointer to extension space.
* Note that you must not call qse_sed_getxtn() for a stream editor
* created with qse_sed_openstd() and qse_sed_openstdwithmmgr().
*/
QSE_EXPORT void* qse_sed_getxtnstd (
qse_sed_t* sed /**< stream editor */
);
/**
* The qse_sed_compstd() function compiles sed scripts specified in
* an array of stream resources. The end of the array is indicated