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:
hyung-hwan 2012-09-07 15:13:55 +00:00
parent 69b118fcbf
commit ea3ebef8f1
16 changed files with 1930 additions and 64 deletions

View File

@ -350,8 +350,7 @@ static void dprint_return (qse_awk_rtx_t* rtx, qse_awk_val_t* ret)
} }
#ifdef ENABLE_CALLBACK #ifdef ENABLE_CALLBACK
static void on_statement ( static void on_statement (qse_awk_rtx_t* rtx, qse_awk_nde_t* nde)
qse_awk_rtx_t* rtx, qse_awk_nde_t* nde, void* data)
{ {
dprint (QSE_T("running %d at line %d\n"), (int)nde->type, (int)nde->loc.line); dprint (QSE_T("running %d at line %d\n"), (int)nde->type, (int)nde->loc.line);
} }
@ -975,13 +974,18 @@ static int awk_main (int argc, qse_char_t* argv[])
qse_awk_t* awk = QSE_NULL; qse_awk_t* awk = QSE_NULL;
qse_awk_rtx_t* rtx = QSE_NULL; qse_awk_rtx_t* rtx = QSE_NULL;
qse_awk_val_t* retv; qse_awk_val_t* retv;
#ifdef ENABLE_CALLBACK
qse_awk_rcb_t rcb;
#endif
int i; int i;
struct arg_t arg; struct arg_t arg;
int ret = -1; int ret = -1;
#ifdef ENABLE_CALLBACK
static qse_awk_rtx_ecb_t rtx_ecb =
{
QSE_FV(.close, QSE_NULL),
QSE_FV(.stmt, on_statement)
};
#endif
/* TODO: change it to support multiple source files */ /* TODO: change it to support multiple source files */
qse_awk_parsestd_t psin; qse_awk_parsestd_t psin;
qse_awk_parsestd_t psout; qse_awk_parsestd_t psout;
@ -1080,12 +1084,6 @@ static int awk_main (int argc, qse_char_t* argv[])
goto oops; goto oops;
} }
#ifdef ENABLE_CALLBACK
qse_memset (&rcb, 0, QSE_SIZEOF(rcb));
rcb.stmt = on_statement;
rcb.ctx = &arg;
#endif
rtx = qse_awk_rtx_openstd ( rtx = qse_awk_rtx_openstd (
awk, 0, QSE_T("qseawk"), awk, 0, QSE_T("qseawk"),
(const qse_char_t*const*)arg.icf.ptr, (const qse_char_t*const*)arg.icf.ptr,
@ -1104,7 +1102,7 @@ static int awk_main (int argc, qse_char_t* argv[])
app_rtx = rtx; app_rtx = rtx;
#ifdef ENABLE_CALLBACK #ifdef ENABLE_CALLBACK
qse_awk_rtx_pushrcb (rtx, &rcb); qse_awk_rtx_pushecb (rtx, &rtx_ecb);
#endif #endif
set_intr_run (); set_intr_run ();

View File

@ -617,6 +617,8 @@ struct qse_awk_prm_t
}; };
typedef struct qse_awk_prm_t 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_sio_t type defines a script stream handler set.
* The qse_awk_parse() function calls the input and output handler to parse * 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; typedef struct qse_awk_sio_t qse_awk_sio_t;
/* ------------------------------------------------------------------------ */
/** /**
* The qse_awk_rio_t type defines a runtime I/O handler set. * The qse_awk_rio_t type defines a runtime I/O handler set.
* @sa qse_awk_rtx_t * @sa qse_awk_rtx_t
@ -676,56 +680,93 @@ struct qse_awk_rio_t
}; };
typedef struct qse_awk_rio_t 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. * called when the runtime context is closed.
*/ */
typedef void (*qse_awk_rcb_close_t) ( typedef void (*qse_awk_rtx_ecb_close_t) (
qse_awk_rtx_t* rtx, /**< runtime context */ qse_awk_rtx_t* rtx /**< runtime context */
void* ctx /**< user-defined data */
); );
/** /**
* 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. * 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_rtx_t* rtx, /**< runtime context */
qse_awk_nde_t* nde, /**< node */ qse_awk_nde_t* nde /**< node */
void* ctx /**< user-defined data */
); );
/** /**
* The qse_awk_rcb_t type defines a runtime callback set. You can * The qse_awk_rtx_ecb_t type defines an event callback set for a
* register a callback function set with qse_awk_rtx_pushrcb(). * runtime context. You can register a callback function set with
* The callback functions in the set registered are called in a * qse_awk_rtx_pushecb(). The callback functions in the registered
* proper context in the reverse order of registeration. * set are called in the reverse order of registration.
*/ */
typedef struct qse_awk_rcb_t qse_awk_rcb_t; typedef struct qse_awk_rtx_ecb_t qse_awk_rtx_ecb_t;
struct qse_awk_rcb_t struct qse_awk_rtx_ecb_t
{ {
/** /**
* called by qse_awk_rtx_close(). * 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 * called by qse_awk_rtx_loop() and qse_awk_rtx_call() for
* each statement executed. * each statement executed.
*/ */
qse_awk_rcb_stmt_t stmt; qse_awk_rtx_ecb_stmt_t stmt;
/**
* A caller may store a user-defined data pointer into this field. This
* is passed to an actual callback.
*/
void* ctx;
/* internal use only. don't touch this field */ /* 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 * The qse_awk_option_t type defines various options to change the behavior
* of #qse_awk_t. * of #qse_awk_t.
@ -1381,6 +1422,23 @@ void qse_awk_setmaxdepth (
qse_size_t depth /**< maximum depth */ 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. * The qse_awk_addgbl() function adds an intrinsic global variable.
* @return the ID of the global variable added on success, -1 on failure. * @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, * and returns the pointer to it. If no callback set can be popped,
* it returns #QSE_NULL. * 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 */ 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 ( void qse_awk_rtx_pushecb (
qse_awk_rtx_t* rtx, /**< runtime context */ qse_awk_rtx_t* rtx, /**< runtime context */
qse_awk_rcb_t* rcb /**< callback set */ qse_awk_rtx_ecb_t* ecb /**< callback set */
); );
/** /**

View File

@ -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 */ /* number of characters to number of bytes */
#define QSE_NCTONB(x) ((x)*sizeof(qse_char_t)) #define QSE_NCTONB(x) ((x)*sizeof(qse_char_t))

View File

@ -305,6 +305,32 @@ struct qse_httpd_client_t
} task; } 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 #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
@ -344,6 +370,23 @@ void qse_httpd_setoption (
int option 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. * The qse_httpd_loop() function starts a httpd server loop.
*/ */
@ -360,7 +403,6 @@ void qse_httpd_stop (
qse_httpd_t* httpd qse_httpd_t* httpd
); );
int qse_httpd_addserver ( int qse_httpd_addserver (
qse_httpd_t* httpd, qse_httpd_t* httpd,
const qse_char_t* uri const qse_char_t* uri
@ -502,6 +544,23 @@ void qse_httpd_freemem (
void* ptr 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 #ifdef __cplusplus
} }
#endif #endif

View File

@ -345,6 +345,32 @@ typedef int (*qse_sed_lformatter_t) (
int (*cwriter) (qse_sed_t*, qse_char_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 #ifdef QSE_ENABLE_SEDTRACER
enum qse_sed_exec_op_t enum qse_sed_exec_op_t
{ {
@ -515,6 +541,23 @@ void qse_sed_seterror (
const qse_sed_loc_t* errloc /**< error location */ 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. * The qse_sed_comp() function compiles editing commands into an internal form.
* @return 0 on success, -1 on error * @return 0 on success, -1 on error

View File

@ -262,8 +262,14 @@ oops:
int qse_awk_close (qse_awk_t* awk) int qse_awk_close (qse_awk_t* awk)
{ {
qse_awk_ecb_t* ecb;
if (qse_awk_clear (awk) <= -1) return -1; if (qse_awk_clear (awk) <= -1) return -1;
/*qse_awk_clrfnc (awk);*/ /*qse_awk_clrfnc (awk);*/
for (ecb = awk->ecb; ecb; ecb = ecb->next)
if (ecb->close) ecb->close (awk);
qse_htb_close (awk->fnc.user); qse_htb_close (awk->fnc.user);
qse_lda_close (awk->parse.params); qse_lda_close (awk->parse.params);
@ -287,6 +293,11 @@ int qse_awk_close (qse_awk_t* awk)
int qse_awk_clear (qse_awk_t* awk) int qse_awk_clear (qse_awk_t* awk)
{ {
qse_awk_ecb_t* ecb;
for (ecb = awk->ecb; ecb; ecb = ecb->next)
if (ecb->clear) ecb->clear (awk);
awk->stopall = QSE_FALSE; awk->stopall = QSE_FALSE;
clear_token (&awk->tok); clear_token (&awk->tok);
@ -439,3 +450,18 @@ void qse_awk_setmaxdepth (qse_awk_t* awk, int types, qse_size_t depth)
awk->parse.depth.max.incl = depth; awk->parse.depth.max.incl = depth;
} }
} }
qse_awk_ecb_t* qse_awk_popecb (qse_awk_t* awk)
{
qse_awk_ecb_t* top = awk->ecb;
if (top) awk->ecb = top->next;
return top;
}
void qse_awk_pushecb (qse_awk_t* awk, qse_awk_ecb_t* ecb)
{
ecb->next = awk->ecb;
awk->ecb = ecb;
}

View File

@ -235,6 +235,7 @@ struct qse_awk_t
qse_awk_errinf_t errinf; qse_awk_errinf_t errinf;
qse_bool_t stopall; qse_bool_t stopall;
qse_awk_ecb_t* ecb;
}; };
struct qse_awk_chain_t struct qse_awk_chain_t
@ -371,7 +372,7 @@ struct qse_awk_rtx_t
qse_awk_errinf_t errinf; qse_awk_errinf_t errinf;
qse_awk_t* awk; qse_awk_t* awk;
qse_awk_rcb_t* rcb; qse_awk_rtx_ecb_t* ecb;
}; };

View File

@ -744,10 +744,10 @@ qse_awk_rtx_t* qse_awk_rtx_open (
void qse_awk_rtx_close (qse_awk_rtx_t* rtx) void qse_awk_rtx_close (qse_awk_rtx_t* rtx)
{ {
qse_awk_rcb_t* rcb; qse_awk_rtx_ecb_t* ecb;
for (rcb = rtx->rcb; rcb; rcb = rcb->next) for (ecb = rtx->ecb; ecb; ecb = ecb->next)
if (rcb->close) rcb->close (rtx, rcb->ctx); if (ecb->close) ecb->close (rtx);
/* NOTE: /* NOTE:
* the close callbacks are called before data in rtx * the close callbacks are called before data in rtx
@ -784,17 +784,17 @@ void qse_awk_rtx_setrio (qse_awk_rtx_t* rtx, const qse_awk_rio_t* rio)
rtx->rio.handler[QSE_AWK_RIO_CONSOLE] = rio->console; rtx->rio.handler[QSE_AWK_RIO_CONSOLE] = rio->console;
} }
qse_awk_rcb_t* qse_awk_rtx_poprcb (qse_awk_rtx_t* rtx) qse_awk_rtx_ecb_t* qse_awk_rtx_popecb (qse_awk_rtx_t* rtx)
{ {
qse_awk_rcb_t* top = rtx->rcb; qse_awk_rtx_ecb_t* top = rtx->ecb;
if (top) rtx->rcb = top->next; if (top) rtx->ecb = top->next;
return top; return top;
} }
void qse_awk_rtx_pushrcb (qse_awk_rtx_t* rtx, qse_awk_rcb_t* rcb) void qse_awk_rtx_pushecb (qse_awk_rtx_t* rtx, qse_awk_rtx_ecb_t* ecb)
{ {
rcb->next = rtx->rcb; ecb->next = rtx->ecb;
rtx->rcb = rcb; rtx->ecb = ecb;
} }
static void free_namedval (qse_htb_t* map, void* dptr, qse_size_t dlen) static void free_namedval (qse_htb_t* map, void* dptr, qse_size_t dlen)
@ -1826,10 +1826,10 @@ static int run_block0 (qse_awk_rtx_t* rtx, qse_awk_nde_blk_t* nde)
} }
#define ON_STATEMENT(rtx,nde) QSE_BLOCK ( \ #define ON_STATEMENT(rtx,nde) QSE_BLOCK ( \
qse_awk_rcb_t* rcb; \ qse_awk_rtx_ecb_t* ecb; \
if ((rtx)->awk->stopall) (rtx)->exit_level = EXIT_ABORT; \ if ((rtx)->awk->stopall) (rtx)->exit_level = EXIT_ABORT; \
for (rcb = (rtx)->rcb; rcb; rcb = rcb->next) \ for (ecb = (rtx)->ecb; ecb; ecb = ecb->next) \
if (rcb->stmt) rcb->stmt (rtx, nde, rcb->ctx); \ if (ecb->stmt) ecb->stmt (rtx, nde); \
) )
static int run_statement (qse_awk_rtx_t* rtx, qse_awk_nde_t* nde) static int run_statement (qse_awk_rtx_t* rtx, qse_awk_nde_t* nde)

View File

@ -1478,7 +1478,7 @@ static qse_ssize_t awk_rio_console (
return -1; return -1;
} }
static void fini_rxtn (qse_awk_rtx_t* rtx, void* ctx) static void fini_rxtn (qse_awk_rtx_t* rtx)
{ {
rxtn_t* rxtn = (rxtn_t*) QSE_XTN (rtx); rxtn_t* rxtn = (rxtn_t*) QSE_XTN (rtx);
@ -1876,11 +1876,10 @@ qse_awk_rtx_t* qse_awk_rtx_openstd (
const qse_char_t*const ocf[], const qse_char_t*const ocf[],
qse_cmgr_t* cmgr) qse_cmgr_t* cmgr)
{ {
static qse_awk_rcb_t rcb = static qse_awk_rtx_ecb_t ecb =
{ {
fini_rxtn, QSE_FV (.close, fini_rxtn),
QSE_NULL, QSE_FV (.stmt, QSE_NULL)
QSE_NULL
}; };
qse_awk_rtx_t* rtx; qse_awk_rtx_t* rtx;
@ -1921,7 +1920,7 @@ qse_awk_rtx_t* qse_awk_rtx_openstd (
rxtn->cmgrtab_inited = 1; rxtn->cmgrtab_inited = 1;
} }
qse_awk_rtx_pushrcb (rtx, &rcb); qse_awk_rtx_pushecb (rtx, &ecb);
rxtn->seed = (qse_gettime (&now) <= -1)? 0u: (qse_long_t)now; rxtn->seed = (qse_gettime (&now) <= -1)? 0u: (qse_long_t)now;
/* i don't care if the seed becomes negative or overflows. /* i don't care if the seed becomes negative or overflows.

View File

@ -16,6 +16,7 @@ libqsenet_la_SOURCES = \
httpd-cgi.c \ httpd-cgi.c \
httpd-proxy.c \ httpd-proxy.c \
httpd-resol.c \ httpd-resol.c \
httpd-std.c \
httpd-task.c \ httpd-task.c \
upxd.c upxd.c

View File

@ -79,8 +79,8 @@ am__installdirs = "$(DESTDIR)$(libdir)"
LTLIBRARIES = $(lib_LTLIBRARIES) LTLIBRARIES = $(lib_LTLIBRARIES)
libqsenet_la_DEPENDENCIES = libqsenet_la_DEPENDENCIES =
am_libqsenet_la_OBJECTS = http.lo htre.lo htrd.lo httpd.lo \ am_libqsenet_la_OBJECTS = http.lo htre.lo htrd.lo httpd.lo \
httpd-cgi.lo httpd-proxy.lo httpd-resol.lo httpd-task.lo \ httpd-cgi.lo httpd-proxy.lo httpd-resol.lo httpd-std.lo \
upxd.lo httpd-task.lo upxd.lo
libqsenet_la_OBJECTS = $(am_libqsenet_la_OBJECTS) libqsenet_la_OBJECTS = $(am_libqsenet_la_OBJECTS)
libqsenet_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ libqsenet_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
@ -273,6 +273,7 @@ libqsenet_la_SOURCES = \
httpd-cgi.c \ httpd-cgi.c \
httpd-proxy.c \ httpd-proxy.c \
httpd-resol.c \ httpd-resol.c \
httpd-std.c \
httpd-task.c \ httpd-task.c \
upxd.c upxd.c
@ -358,6 +359,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/httpd-cgi.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/httpd-cgi.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/httpd-proxy.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/httpd-proxy.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/httpd-resol.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/httpd-resol.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/httpd-std.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/httpd-task.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/httpd-task.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/httpd.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/httpd.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/upxd.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/upxd.Plo@am__quote@

1627
qse/lib/net/httpd-std.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -84,6 +84,11 @@ qse_httpd_t* qse_httpd_open (qse_mmgr_t* mmgr, qse_size_t xtnsize)
void qse_httpd_close (qse_httpd_t* httpd) void qse_httpd_close (qse_httpd_t* httpd)
{ {
qse_httpd_ecb_t* ecb;
for (ecb = httpd->ecb; ecb; ecb = ecb->next)
if (ecb->close) ecb->close (httpd);
qse_httpd_fini (httpd); qse_httpd_fini (httpd);
QSE_MMGR_FREE (httpd->mmgr, httpd); QSE_MMGR_FREE (httpd->mmgr, httpd);
} }
@ -128,6 +133,23 @@ void qse_httpd_setoption (qse_httpd_t* httpd, int option)
httpd->option = option; httpd->option = option;
} }
/* --------------------------------------------------- */
qse_httpd_ecb_t* qse_httpd_popecb (qse_httpd_t* httpd)
{
qse_httpd_ecb_t* top = httpd->ecb;
if (top) httpd->ecb = top->next;
return top;
}
void qse_httpd_pushecb (qse_httpd_t* httpd, qse_httpd_ecb_t* ecb)
{
ecb->next = httpd->ecb;
httpd->ecb = ecb;
}
/* --------------------------------------------------- */
QSE_INLINE void* qse_httpd_allocmem (qse_httpd_t* httpd, qse_size_t size) QSE_INLINE void* qse_httpd_allocmem (qse_httpd_t* httpd, qse_size_t size)
{ {
void* ptr = QSE_MMGR_ALLOC (httpd->mmgr, size); void* ptr = QSE_MMGR_ALLOC (httpd->mmgr, size);

View File

@ -29,7 +29,8 @@ struct qse_httpd_t
{ {
QSE_DEFINE_COMMON_FIELDS (httpd) QSE_DEFINE_COMMON_FIELDS (httpd)
qse_httpd_errnum_t errnum; qse_httpd_errnum_t errnum;
qse_httpd_cbs_t* cbs; qse_httpd_ecb_t* ecb; /* event callbacks */
qse_httpd_cbs_t* cbs;
int option; int option;
int stopreq; int stopreq;

View File

@ -75,6 +75,11 @@ qse_sed_t* qse_sed_open (qse_mmgr_t* mmgr, qse_size_t xtnsize)
void qse_sed_close (qse_sed_t* sed) void qse_sed_close (qse_sed_t* sed)
{ {
qse_sed_ecb_t* ecb;
for (ecb = sed->ecb; ecb; ecb = ecb->next)
if (ecb->close) ecb->close (sed);
qse_sed_fini (sed); qse_sed_fini (sed);
QSE_MMGR_FREE (sed->mmgr, sed); QSE_MMGR_FREE (sed->mmgr, sed);
} }
@ -4142,6 +4147,19 @@ void qse_sed_setlinenum (qse_sed_t* sed, qse_size_t num)
sed->e.in.num = num; sed->e.in.num = num;
} }
qse_sed_ecb_t* qse_sed_popecb (qse_sed_t* sed)
{
qse_sed_ecb_t* top = sed->ecb;
if (top) sed->ecb = top->next;
return top;
}
void qse_sed_pushecb (qse_sed_t* sed, qse_sed_ecb_t* ecb)
{
ecb->next = sed->ecb;
sed->ecb = ecb;
}
#ifdef QSE_ENABLE_SEDTRACER #ifdef QSE_ENABLE_SEDTRACER
qse_sed_exec_tracer_t qse_sed_getexectracer (qse_sed_t* sed) qse_sed_exec_tracer_t qse_sed_getexectracer (qse_sed_t* sed)
{ {

View File

@ -99,6 +99,8 @@ struct qse_sed_t
} rex; } rex;
} depth; } depth;
qse_sed_ecb_t* ecb;
/** source text pointers */ /** source text pointers */
struct struct
{ {