added qse_awk_pushecb()/qse_awk_popecb()/qse_sed_pushecb()/qse_sed_popecb()/qse_httpd_pushecb()/qse_httpd_popecb().
started reorganizing samples/httpd01 to net/httpd-std.c
This commit is contained in:
@ -617,6 +617,8 @@ struct qse_awk_prm_t
|
||||
};
|
||||
typedef struct qse_awk_prm_t qse_awk_prm_t;
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
/**
|
||||
* The qse_awk_sio_t type defines a script stream handler set.
|
||||
* The qse_awk_parse() function calls the input and output handler to parse
|
||||
@ -664,6 +666,8 @@ struct qse_awk_sio_t
|
||||
};
|
||||
typedef struct qse_awk_sio_t qse_awk_sio_t;
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
/**
|
||||
* The qse_awk_rio_t type defines a runtime I/O handler set.
|
||||
* @sa qse_awk_rtx_t
|
||||
@ -676,56 +680,93 @@ struct qse_awk_rio_t
|
||||
};
|
||||
typedef struct qse_awk_rio_t qse_awk_rio_t;
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
/**
|
||||
* The qse_awk_rcb_close_t type defines the callback function
|
||||
* The qse_awk_ecb_close_t type defines the callback function
|
||||
* called when an awk object is closed.
|
||||
*/
|
||||
typedef void (*qse_awk_ecb_close_t) (
|
||||
qse_awk_t* awk /**< awk */
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_awk_ecb_clear_t type defines the callback function
|
||||
* called when an awk object is cleared.
|
||||
*/
|
||||
typedef void (*qse_awk_ecb_clear_t) (
|
||||
qse_awk_t* awk /**< awk */
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_awk_ecb_t type defines an event callback set.
|
||||
* You can register a callback function set with
|
||||
* qse_awk_pushecb(). The callback functions in the registered
|
||||
* set are called in the reverse order of registration.
|
||||
*/
|
||||
typedef struct qse_awk_ecb_t qse_awk_ecb_t;
|
||||
struct qse_awk_ecb_t
|
||||
{
|
||||
/**
|
||||
* called by qse_awk_close().
|
||||
*/
|
||||
qse_awk_ecb_close_t close;
|
||||
|
||||
/**
|
||||
* called by qse_awk_clear().
|
||||
*/
|
||||
qse_awk_ecb_clear_t clear;
|
||||
|
||||
/* internal use only. don't touch this field */
|
||||
qse_awk_ecb_t* next;
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
/**
|
||||
* The qse_awk_rtx_ecb_close_t type defines the callback function
|
||||
* called when the runtime context is closed.
|
||||
*/
|
||||
typedef void (*qse_awk_rcb_close_t) (
|
||||
qse_awk_rtx_t* rtx, /**< runtime context */
|
||||
void* ctx /**< user-defined data */
|
||||
typedef void (*qse_awk_rtx_ecb_close_t) (
|
||||
qse_awk_rtx_t* rtx /**< runtime context */
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* The qse_awk_rcb_stmt_t type defines the callback function for each
|
||||
* The qse_awk_rtx_ecb_stmt_t type defines the callback function for each
|
||||
* statement.
|
||||
*/
|
||||
typedef void (*qse_awk_rcb_stmt_t) (
|
||||
typedef void (*qse_awk_rtx_ecb_stmt_t) (
|
||||
qse_awk_rtx_t* rtx, /**< runtime context */
|
||||
qse_awk_nde_t* nde, /**< node */
|
||||
void* ctx /**< user-defined data */
|
||||
qse_awk_nde_t* nde /**< node */
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_awk_rcb_t type defines a runtime callback set. You can
|
||||
* register a callback function set with qse_awk_rtx_pushrcb().
|
||||
* The callback functions in the set registered are called in a
|
||||
* proper context in the reverse order of registeration.
|
||||
* The qse_awk_rtx_ecb_t type defines an event callback set for a
|
||||
* runtime context. You can register a callback function set with
|
||||
* qse_awk_rtx_pushecb(). The callback functions in the registered
|
||||
* set are called in the reverse order of registration.
|
||||
*/
|
||||
typedef struct qse_awk_rcb_t qse_awk_rcb_t;
|
||||
struct qse_awk_rcb_t
|
||||
typedef struct qse_awk_rtx_ecb_t qse_awk_rtx_ecb_t;
|
||||
struct qse_awk_rtx_ecb_t
|
||||
{
|
||||
/**
|
||||
* called by qse_awk_rtx_close().
|
||||
*/
|
||||
qse_awk_rcb_close_t close;
|
||||
qse_awk_rtx_ecb_close_t close;
|
||||
|
||||
/**
|
||||
* called by qse_awk_rtx_loop() and qse_awk_rtx_call() for
|
||||
* each statement executed.
|
||||
*/
|
||||
qse_awk_rcb_stmt_t stmt;
|
||||
|
||||
/**
|
||||
* A caller may store a user-defined data pointer into this field. This
|
||||
* is passed to an actual callback.
|
||||
*/
|
||||
void* ctx;
|
||||
qse_awk_rtx_ecb_stmt_t stmt;
|
||||
|
||||
/* internal use only. don't touch this field */
|
||||
qse_awk_rcb_t* next;
|
||||
qse_awk_rtx_ecb_t* next;
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
/**
|
||||
* The qse_awk_option_t type defines various options to change the behavior
|
||||
* of #qse_awk_t.
|
||||
@ -1381,6 +1422,23 @@ void qse_awk_setmaxdepth (
|
||||
qse_size_t depth /**< maximum depth */
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_awk_popecb() function pops an awk event callback set
|
||||
* and returns the pointer to it. If no callback set can be popped,
|
||||
* it returns #QSE_NULL.
|
||||
*/
|
||||
qse_awk_ecb_t* qse_awk_popecb (
|
||||
qse_awk_t* awk /**< awk */
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_awk_pushecb() function register a runtime callback set.
|
||||
*/
|
||||
void qse_awk_pushecb (
|
||||
qse_awk_t* awk, /**< awk */
|
||||
qse_awk_ecb_t* ecb /**< callback set */
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_awk_addgbl() function adds an intrinsic global variable.
|
||||
* @return the ID of the global variable added on success, -1 on failure.
|
||||
@ -1717,20 +1775,20 @@ void qse_awk_rtx_setrio (
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_awk_rtx_poprcb() function pops a runtime callback set
|
||||
* The qse_awk_rtx_popecb() function pops a runtime callback set
|
||||
* and returns the pointer to it. If no callback set can be popped,
|
||||
* it returns #QSE_NULL.
|
||||
*/
|
||||
qse_awk_rcb_t* qse_awk_rtx_poprcb (
|
||||
qse_awk_rtx_ecb_t* qse_awk_rtx_popecb (
|
||||
qse_awk_rtx_t* rtx /**< runtime context */
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_awk_rtx_pushrcb() function register a runtime callback set.
|
||||
* The qse_awk_rtx_pushecb() function register a runtime callback set.
|
||||
*/
|
||||
void qse_awk_rtx_pushrcb (
|
||||
qse_awk_rtx_t* rtx, /**< runtime context */
|
||||
qse_awk_rcb_t* rcb /**< callback set */
|
||||
void qse_awk_rtx_pushecb (
|
||||
qse_awk_rtx_t* rtx, /**< runtime context */
|
||||
qse_awk_rtx_ecb_t* ecb /**< callback set */
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -216,6 +216,15 @@
|
||||
} \
|
||||
)
|
||||
|
||||
/**
|
||||
* The QSE_FV() macro is used to specify a initial value
|
||||
* for a field of an aggregate type.
|
||||
*/
|
||||
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901)
|
||||
# define QSE_FV(field,value) field = value
|
||||
#else
|
||||
# define QSE_FV(field,value) value
|
||||
#endif
|
||||
|
||||
/* number of characters to number of bytes */
|
||||
#define QSE_NCTONB(x) ((x)*sizeof(qse_char_t))
|
||||
|
@ -305,6 +305,32 @@ struct qse_httpd_client_t
|
||||
} task;
|
||||
};
|
||||
|
||||
/**
|
||||
* The qse_httpd_ecb_close_t type defines the callback function
|
||||
* called when an httpd object is closed.
|
||||
*/
|
||||
typedef void (*qse_httpd_ecb_close_t) (
|
||||
qse_httpd_t* httpd /**< httpd */
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_httpd_ecb_t type defines an event callback set.
|
||||
* You can register a callback function set with
|
||||
* qse_httpd_pushecb(). The callback functions in the registered
|
||||
* set are called in the reverse order of registration.
|
||||
*/
|
||||
typedef struct qse_httpd_ecb_t qse_httpd_ecb_t;
|
||||
struct qse_httpd_ecb_t
|
||||
{
|
||||
/**
|
||||
* called by qse_httpd_close().
|
||||
*/
|
||||
qse_httpd_ecb_close_t close;
|
||||
|
||||
/* internal use only. don't touch this field */
|
||||
qse_httpd_ecb_t* next;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@ -344,6 +370,23 @@ void qse_httpd_setoption (
|
||||
int option
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_httpd_popecb() function pops an httpd event callback set
|
||||
* and returns the pointer to it. If no callback set can be popped,
|
||||
* it returns #QSE_NULL.
|
||||
*/
|
||||
qse_httpd_ecb_t* qse_httpd_popecb (
|
||||
qse_httpd_t* httpd /**< httpd */
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_httpd_pushecb() function register a runtime callback set.
|
||||
*/
|
||||
void qse_httpd_pushecb (
|
||||
qse_httpd_t* httpd, /**< httpd */
|
||||
qse_httpd_ecb_t* ecb /**< callback set */
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_httpd_loop() function starts a httpd server loop.
|
||||
*/
|
||||
@ -360,7 +403,6 @@ void qse_httpd_stop (
|
||||
qse_httpd_t* httpd
|
||||
);
|
||||
|
||||
|
||||
int qse_httpd_addserver (
|
||||
qse_httpd_t* httpd,
|
||||
const qse_char_t* uri
|
||||
@ -502,6 +544,23 @@ void qse_httpd_freemem (
|
||||
void* ptr
|
||||
);
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
|
||||
qse_httpd_t* qse_httpd_openstd (
|
||||
qse_size_t xtnsize
|
||||
);
|
||||
|
||||
qse_httpd_t* qse_httpd_openstdwithmmgr (
|
||||
qse_mmgr_t* mmgr,
|
||||
qse_size_t xtnsize
|
||||
);
|
||||
|
||||
void* qse_httpd_getxtnstd (
|
||||
qse_httpd_t* httpd
|
||||
);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -345,6 +345,32 @@ typedef int (*qse_sed_lformatter_t) (
|
||||
int (*cwriter) (qse_sed_t*, qse_char_t)
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_sed_ecb_close_t type defines the callback function
|
||||
* called when an sed object is closed.
|
||||
*/
|
||||
typedef void (*qse_sed_ecb_close_t) (
|
||||
qse_sed_t* sed /**< sed */
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_sed_ecb_t type defines an event callback set.
|
||||
* You can register a callback function set with
|
||||
* qse_sed_pushecb(). The callback functions in the registered
|
||||
* set are called in the reverse order of registration.
|
||||
*/
|
||||
typedef struct qse_sed_ecb_t qse_sed_ecb_t;
|
||||
struct qse_sed_ecb_t
|
||||
{
|
||||
/**
|
||||
* called by qse_sed_close().
|
||||
*/
|
||||
qse_sed_ecb_close_t close;
|
||||
|
||||
/* internal use only. don't touch this field */
|
||||
qse_sed_ecb_t* next;
|
||||
};
|
||||
|
||||
#ifdef QSE_ENABLE_SEDTRACER
|
||||
enum qse_sed_exec_op_t
|
||||
{
|
||||
@ -515,6 +541,23 @@ void qse_sed_seterror (
|
||||
const qse_sed_loc_t* errloc /**< error location */
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_sed_popecb() function pops an sed event callback set
|
||||
* and returns the pointer to it. If no callback set can be popped,
|
||||
* it returns #QSE_NULL.
|
||||
*/
|
||||
qse_sed_ecb_t* qse_sed_popecb (
|
||||
qse_sed_t* sed /**< sed */
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_sed_pushecb() function register a runtime callback set.
|
||||
*/
|
||||
void qse_sed_pushecb (
|
||||
qse_sed_t* sed, /**< sed */
|
||||
qse_sed_ecb_t* ecb /**< callback set */
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_sed_comp() function compiles editing commands into an internal form.
|
||||
* @return 0 on success, -1 on error
|
||||
|
Reference in New Issue
Block a user