added some module handling code

This commit is contained in:
hyung-hwan 2014-09-05 15:52:19 +00:00
parent bfeb437225
commit d4439858d3
10 changed files with 323 additions and 140 deletions

View File

@ -50,6 +50,19 @@
<if cond="PLATFORM_UNIX=='1'"></if>
</set>
<set var="HTTPDMODPREFIX">
<if cond="PLATFORM_WIN32=='1'">qsehttpd-</if>
<if cond="PLATFORM_OS2=='1'">httpd-</if>
<if cond="PLATFORM_MSDOS=='1'">httpd-</if>
<if cond="PLATFORM_UNIX=='1'">libqsehttpd-</if>
</set>
<set var="HTTPDMODPOSTFIX">
<if cond="PLATFORM_WIN32=='1'"></if>
<if cond="PLATFORM_OS2=='1'"></if>
<if cond="PLATFORM_MSDOS=='1'"></if>
<if cond="PLATFORM_UNIX=='1'"></if>
</set>
<!-- =========================================================
Varibles to use as conditionals
========================================================= -->

View File

@ -30,13 +30,13 @@
# define QSE_INVALID_SCKHND (~(qse_sck_hnd_t)0)
#elif defined(__OS2__)
typedef int qse_sck_hnd_t;
# define QSE_INVALID_SCKHND -1
# define QSE_INVALID_SCKHND (-1)
#elif defined(__DOS__)
typedef int qse_sck_hnd_t;
# define QSE_INVALID_SCKHND -1
# define QSE_INVALID_SCKHND (-1)
#else
typedef int qse_sck_hnd_t;
# define QSE_INVALID_SCKHND -1
# define QSE_INVALID_SCKHND (-1)
#endif
#if (QSE_SIZEOF_SOCKLEN_T == QSE_SIZEOF_INT)

View File

@ -89,21 +89,7 @@ enum qse_httpd_trait_t
};
typedef enum qse_httpd_trait_t qse_httpd_trait_t;
#if !defined(QSE_HTTPD_DEFAULT_MODPREFIX)
# if defined(_WIN32)
# define QSE_HTTPD_DEFAULT_MODPREFIX "qsehttpd-"
# elif defined(__OS2__)
# define QSE_HTTPD_DEFAULT_MODPREFIX "htd-"
# elif defined(__DOS__)
# define QSE_HTTPD_DEFAULT_MODPREFIX "htd-"
# else
# define QSE_HTTPD_DEFAULT_MODPREFIX "libqsehttpd-"
# endif
#endif
#if !defined(QSE_HTTPD_DEFAULT_MODPOSTFIX)
# define QSE_HTTPD_DEFAULT_MODPOSTFIX ""
#endif
typedef struct qse_httpd_mod_t qse_httpd_mod_t;
@ -111,7 +97,7 @@ typedef int (*qse_httpd_mod_load_t) (
qse_httpd_mod_t* mod
);
typedef int (*qse_httpd_mod_unload_t) (
typedef void (*qse_httpd_mod_unload_t) (
qse_httpd_mod_t* mod
);
@ -125,22 +111,21 @@ typedef int (*qse_httpd_mod_urs_prerewrite_t) (
struct qse_httpd_mod_t
{
/* set before mod.open().
* mod.open() and other callbacks can refer to these. */
/* private */
qse_httpd_mod_t* next;
void* handle; /* set to the return value of mod.open() */
/* module may access these fields for rererence */
qse_httpd_t* httpd;
qse_char_t* name; /* portable module name */
qse_char_t* fullname; /* name to use when loading module from the system. */
/* mod.open() may set this */
void* handle; /* mod.open() can set this */
/* module's entry point may set these items */
void* ctx;
qse_httpd_mod_unload_t unload;
qse_httpd_mod_urs_prerewrite_t urs_prerewrite;
/* private */
qse_httpd_mod_t* next;
/* more fields will get added here for expansion in the future. */
};
typedef struct qse_httpd_stat_t qse_httpd_stat_t;
@ -265,9 +250,9 @@ struct qse_httpd_scb_t
{
struct
{
int (*open) (qse_httpd_t* httpd, qse_httpd_mod_t* mod);
void (*close) (qse_httpd_t* httpd, qse_httpd_mod_t* mod);
void* (*symbol) (qse_httpd_t* httpd, qse_httpd_mod_t* mod, const qse_char_t* name);
void* (*open) (qse_httpd_t* httpd, const qse_char_t* fullname);
void (*close) (qse_httpd_t* httpd, void* handle);
void* (*symbol) (qse_httpd_t* httpd, void* handle, const qse_char_t* name);
} mod; /* module */
struct
@ -643,7 +628,13 @@ struct qse_httpd_dns_t
/* == PUBLIC == */
qse_ubi_t handle[5];
int handle_count;
/* the number of effective slots in the handle array */
int handle_count;
/* handle validity mask. for example, if handle[2] is valid, (1 << 2) must be set. */
unsigned long handle_mask;
void* ctx;
};
@ -655,6 +646,7 @@ struct qse_httpd_urs_t
/* == PUBLIC == */
qse_ubi_t handle[5];
int handle_count;
unsigned long handle_mask;
void* ctx;
};

View File

@ -1,9 +1,17 @@
AUTOMAKE_OPTIONS = nostdinc
AM_CPPFLAGS = \
CPPFLAGS_ALL_COMMON = \
-I$(top_builddir)/include \
-I$(top_srcdir)/include
if WIN32
# you must adjust the value of DEFAULT_MODPOSTFIX according
# to the first number in -version-info below
CPPFLAGS_HTTPD_MOD = -DQSE_HTTPD_DEFAULT_MODPREFIX=\"libqsehttpd-\" -DQSE_HTTPD_DEFAULT_MODPOSTFIX=\"-1\"
else
CPPFLAGS_HTTPD_MOD = -DQSE_HTTPD_DEFAULT_MODPREFIX=\"$(libdir)/libqsehttpd-\" -DQSE_HTTPD_DEFAULT_MODPOSTFIX=\"\"
endif
lib_LTLIBRARIES = libqsehttp.la
libqsehttp_la_SOURCES = \
httpd.h \
@ -24,6 +32,7 @@ libqsehttp_la_SOURCES = \
httpd-text.c \
upxd.c
libqsehttp_la_LDFLAGS = -L../cmn -version-info 1:0:0 -no-undefined
libqsehttp_la_LIBADD = -lqsecmn $(SOCKET_LIBS) $(SENDFILE_LIBS) $(SSL_LIBS)
libqsehttp_la_CPPFLAGS = $(CPPFLAGS_ALL_COMMON) $(CPPFLAGS_HTTPD_MOD) $(LTDLINCL)
libqsehttp_la_LDFLAGS = -L../cmn -version-info 1:0:0 -no-undefined
libqsehttp_la_LIBADD = -lqsecmn $(SOCKET_LIBS) $(SENDFILE_LIBS) $(SSL_LIBS) $(LIBLTDL)

View File

@ -99,10 +99,14 @@ am__installdirs = "$(DESTDIR)$(libdir)"
LTLIBRARIES = $(lib_LTLIBRARIES)
am__DEPENDENCIES_1 =
libqsehttp_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \
$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
am_libqsehttp_la_OBJECTS = http.lo htre.lo htrd.lo httpd.lo \
httpd-cgi.lo httpd-dir.lo httpd-file.lo httpd-proxy.lo \
httpd-std.lo httpd-task.lo httpd-text.lo upxd.lo
$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
$(am__DEPENDENCIES_1)
am_libqsehttp_la_OBJECTS = libqsehttp_la-http.lo libqsehttp_la-htre.lo \
libqsehttp_la-htrd.lo libqsehttp_la-httpd.lo \
libqsehttp_la-httpd-cgi.lo libqsehttp_la-httpd-dir.lo \
libqsehttp_la-httpd-file.lo libqsehttp_la-httpd-proxy.lo \
libqsehttp_la-httpd-std.lo libqsehttp_la-httpd-task.lo \
libqsehttp_la-httpd-text.lo libqsehttp_la-upxd.lo
libqsehttp_la_OBJECTS = $(am_libqsehttp_la_OBJECTS)
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
@ -322,10 +326,15 @@ top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AUTOMAKE_OPTIONS = nostdinc
AM_CPPFLAGS = \
CPPFLAGS_ALL_COMMON = \
-I$(top_builddir)/include \
-I$(top_srcdir)/include
@WIN32_FALSE@CPPFLAGS_HTTPD_MOD = -DQSE_HTTPD_DEFAULT_MODPREFIX=\"$(libdir)/libqsehttpd-\" -DQSE_HTTPD_DEFAULT_MODPOSTFIX=\"\"
# you must adjust the value of DEFAULT_MODPOSTFIX according
# to the first number in -version-info below
@WIN32_TRUE@CPPFLAGS_HTTPD_MOD = -DQSE_HTTPD_DEFAULT_MODPREFIX=\"libqsehttpd-\" -DQSE_HTTPD_DEFAULT_MODPOSTFIX=\"-1\"
lib_LTLIBRARIES = libqsehttp.la
libqsehttp_la_SOURCES = \
httpd.h \
@ -346,8 +355,9 @@ libqsehttp_la_SOURCES = \
httpd-text.c \
upxd.c
libqsehttp_la_LDFLAGS = -L../cmn -version-info 1:0:0 -no-undefined
libqsehttp_la_LIBADD = -lqsecmn $(SOCKET_LIBS) $(SENDFILE_LIBS) $(SSL_LIBS)
libqsehttp_la_CPPFLAGS = $(CPPFLAGS_ALL_COMMON) $(CPPFLAGS_HTTPD_MOD) $(LTDLINCL)
libqsehttp_la_LDFLAGS = -L../cmn -version-info 1:0:0 -no-undefined
libqsehttp_la_LIBADD = -lqsecmn $(SOCKET_LIBS) $(SENDFILE_LIBS) $(SSL_LIBS) $(LIBLTDL)
all: all-am
.SUFFIXES:
@ -423,18 +433,18 @@ mostlyclean-compile:
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htrd.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htre.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/http.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/httpd-cgi.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/httpd-dir.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/httpd-file.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/httpd-proxy.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-text.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)/libqsehttp_la-htrd.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libqsehttp_la-htre.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libqsehttp_la-http.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libqsehttp_la-httpd-cgi.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libqsehttp_la-httpd-dir.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libqsehttp_la-httpd-file.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libqsehttp_la-httpd-proxy.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libqsehttp_la-httpd-std.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libqsehttp_la-httpd-task.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libqsehttp_la-httpd-text.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libqsehttp_la-httpd.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libqsehttp_la-upxd.Plo@am__quote@
.c.o:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@ -457,6 +467,90 @@ distclean-compile:
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
libqsehttp_la-http.lo: http.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libqsehttp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libqsehttp_la-http.lo -MD -MP -MF $(DEPDIR)/libqsehttp_la-http.Tpo -c -o libqsehttp_la-http.lo `test -f 'http.c' || echo '$(srcdir)/'`http.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libqsehttp_la-http.Tpo $(DEPDIR)/libqsehttp_la-http.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='http.c' object='libqsehttp_la-http.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libqsehttp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libqsehttp_la-http.lo `test -f 'http.c' || echo '$(srcdir)/'`http.c
libqsehttp_la-htre.lo: htre.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libqsehttp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libqsehttp_la-htre.lo -MD -MP -MF $(DEPDIR)/libqsehttp_la-htre.Tpo -c -o libqsehttp_la-htre.lo `test -f 'htre.c' || echo '$(srcdir)/'`htre.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libqsehttp_la-htre.Tpo $(DEPDIR)/libqsehttp_la-htre.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='htre.c' object='libqsehttp_la-htre.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libqsehttp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libqsehttp_la-htre.lo `test -f 'htre.c' || echo '$(srcdir)/'`htre.c
libqsehttp_la-htrd.lo: htrd.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libqsehttp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libqsehttp_la-htrd.lo -MD -MP -MF $(DEPDIR)/libqsehttp_la-htrd.Tpo -c -o libqsehttp_la-htrd.lo `test -f 'htrd.c' || echo '$(srcdir)/'`htrd.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libqsehttp_la-htrd.Tpo $(DEPDIR)/libqsehttp_la-htrd.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='htrd.c' object='libqsehttp_la-htrd.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libqsehttp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libqsehttp_la-htrd.lo `test -f 'htrd.c' || echo '$(srcdir)/'`htrd.c
libqsehttp_la-httpd.lo: httpd.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libqsehttp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libqsehttp_la-httpd.lo -MD -MP -MF $(DEPDIR)/libqsehttp_la-httpd.Tpo -c -o libqsehttp_la-httpd.lo `test -f 'httpd.c' || echo '$(srcdir)/'`httpd.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libqsehttp_la-httpd.Tpo $(DEPDIR)/libqsehttp_la-httpd.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='httpd.c' object='libqsehttp_la-httpd.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libqsehttp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libqsehttp_la-httpd.lo `test -f 'httpd.c' || echo '$(srcdir)/'`httpd.c
libqsehttp_la-httpd-cgi.lo: httpd-cgi.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libqsehttp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libqsehttp_la-httpd-cgi.lo -MD -MP -MF $(DEPDIR)/libqsehttp_la-httpd-cgi.Tpo -c -o libqsehttp_la-httpd-cgi.lo `test -f 'httpd-cgi.c' || echo '$(srcdir)/'`httpd-cgi.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libqsehttp_la-httpd-cgi.Tpo $(DEPDIR)/libqsehttp_la-httpd-cgi.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='httpd-cgi.c' object='libqsehttp_la-httpd-cgi.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libqsehttp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libqsehttp_la-httpd-cgi.lo `test -f 'httpd-cgi.c' || echo '$(srcdir)/'`httpd-cgi.c
libqsehttp_la-httpd-dir.lo: httpd-dir.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libqsehttp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libqsehttp_la-httpd-dir.lo -MD -MP -MF $(DEPDIR)/libqsehttp_la-httpd-dir.Tpo -c -o libqsehttp_la-httpd-dir.lo `test -f 'httpd-dir.c' || echo '$(srcdir)/'`httpd-dir.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libqsehttp_la-httpd-dir.Tpo $(DEPDIR)/libqsehttp_la-httpd-dir.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='httpd-dir.c' object='libqsehttp_la-httpd-dir.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libqsehttp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libqsehttp_la-httpd-dir.lo `test -f 'httpd-dir.c' || echo '$(srcdir)/'`httpd-dir.c
libqsehttp_la-httpd-file.lo: httpd-file.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libqsehttp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libqsehttp_la-httpd-file.lo -MD -MP -MF $(DEPDIR)/libqsehttp_la-httpd-file.Tpo -c -o libqsehttp_la-httpd-file.lo `test -f 'httpd-file.c' || echo '$(srcdir)/'`httpd-file.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libqsehttp_la-httpd-file.Tpo $(DEPDIR)/libqsehttp_la-httpd-file.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='httpd-file.c' object='libqsehttp_la-httpd-file.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libqsehttp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libqsehttp_la-httpd-file.lo `test -f 'httpd-file.c' || echo '$(srcdir)/'`httpd-file.c
libqsehttp_la-httpd-proxy.lo: httpd-proxy.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libqsehttp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libqsehttp_la-httpd-proxy.lo -MD -MP -MF $(DEPDIR)/libqsehttp_la-httpd-proxy.Tpo -c -o libqsehttp_la-httpd-proxy.lo `test -f 'httpd-proxy.c' || echo '$(srcdir)/'`httpd-proxy.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libqsehttp_la-httpd-proxy.Tpo $(DEPDIR)/libqsehttp_la-httpd-proxy.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='httpd-proxy.c' object='libqsehttp_la-httpd-proxy.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libqsehttp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libqsehttp_la-httpd-proxy.lo `test -f 'httpd-proxy.c' || echo '$(srcdir)/'`httpd-proxy.c
libqsehttp_la-httpd-std.lo: httpd-std.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libqsehttp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libqsehttp_la-httpd-std.lo -MD -MP -MF $(DEPDIR)/libqsehttp_la-httpd-std.Tpo -c -o libqsehttp_la-httpd-std.lo `test -f 'httpd-std.c' || echo '$(srcdir)/'`httpd-std.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libqsehttp_la-httpd-std.Tpo $(DEPDIR)/libqsehttp_la-httpd-std.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='httpd-std.c' object='libqsehttp_la-httpd-std.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libqsehttp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libqsehttp_la-httpd-std.lo `test -f 'httpd-std.c' || echo '$(srcdir)/'`httpd-std.c
libqsehttp_la-httpd-task.lo: httpd-task.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libqsehttp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libqsehttp_la-httpd-task.lo -MD -MP -MF $(DEPDIR)/libqsehttp_la-httpd-task.Tpo -c -o libqsehttp_la-httpd-task.lo `test -f 'httpd-task.c' || echo '$(srcdir)/'`httpd-task.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libqsehttp_la-httpd-task.Tpo $(DEPDIR)/libqsehttp_la-httpd-task.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='httpd-task.c' object='libqsehttp_la-httpd-task.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libqsehttp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libqsehttp_la-httpd-task.lo `test -f 'httpd-task.c' || echo '$(srcdir)/'`httpd-task.c
libqsehttp_la-httpd-text.lo: httpd-text.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libqsehttp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libqsehttp_la-httpd-text.lo -MD -MP -MF $(DEPDIR)/libqsehttp_la-httpd-text.Tpo -c -o libqsehttp_la-httpd-text.lo `test -f 'httpd-text.c' || echo '$(srcdir)/'`httpd-text.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libqsehttp_la-httpd-text.Tpo $(DEPDIR)/libqsehttp_la-httpd-text.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='httpd-text.c' object='libqsehttp_la-httpd-text.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libqsehttp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libqsehttp_la-httpd-text.lo `test -f 'httpd-text.c' || echo '$(srcdir)/'`httpd-text.c
libqsehttp_la-upxd.lo: upxd.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libqsehttp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libqsehttp_la-upxd.lo -MD -MP -MF $(DEPDIR)/libqsehttp_la-upxd.Tpo -c -o libqsehttp_la-upxd.lo `test -f 'upxd.c' || echo '$(srcdir)/'`upxd.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libqsehttp_la-upxd.Tpo $(DEPDIR)/libqsehttp_la-upxd.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='upxd.c' object='libqsehttp_la-upxd.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libqsehttp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libqsehttp_la-upxd.lo `test -f 'upxd.c' || echo '$(srcdir)/'`upxd.c
mostlyclean-libtool:
-rm -f *.lo

View File

@ -293,6 +293,9 @@ static int dns_open (qse_httpd_t* httpd, qse_httpd_dns_t* dns)
httpd_xtn = qse_httpd_getxtn (httpd);
dns->handle[0].i = QSE_INVALID_SCKHND;
dns->handle[1].i = QSE_INVALID_SCKHND;
dc = (dns_ctx_t*) qse_httpd_callocmem (httpd, QSE_SIZEOF(dns_ctx_t));
if (dc == NULL) goto oops;
@ -383,6 +386,9 @@ static int dns_open (qse_httpd_t* httpd, qse_httpd_dns_t* dns)
}
dns->handle_count = 2;
if (qse_isvalidsckhnd(dns->handle[0].i)) dns->handle_mask |= (1 << 0);
if (qse_isvalidsckhnd(dns->handle[1].i)) dns->handle_mask |= (1 << 1);
dns->ctx = dc;
return 0;
@ -438,11 +444,8 @@ static void dns_close (qse_httpd_t* httpd, qse_httpd_dns_t* dns)
}
}
for (i = 0; i < dns->handle_count; i++)
{
if (qse_isvalidsckhnd(dns->handle[i].i))
qse_closesckhnd (dns->handle[i].i);
}
if (qse_isvalidsckhnd(dns->handle[0].i)) qse_closesckhnd (dns->handle[0].i);
if (qse_isvalidsckhnd(dns->handle[1].i)) qse_closesckhnd (dns->handle[1].i);
qse_httpd_freemem (httpd, dns->ctx);
}

View File

@ -1,44 +1,60 @@
static int mod_open (qse_httpd_t* httpd, qse_httpd_mod_t* mod)
static void* mod_open (qse_httpd_t* httpd, const qse_char_t* sysname)
{
#if defined(USE_LTDL)
void* h;
qse_mchar_t* modpath;
h = lt_dlopenext (mod->fullname);
if (h == QSE_NULL)
#if defined(QSE_CHAR_IS_MCHAR)
modpath = sysname;
#else
modpath = qse_wcstombsdup (sysname, QSE_NULL, httpd->mmgr);
if (!modpath)
{
qse_httpd_seterrnum (httpd, syserr_to_errnum(errno));
return -1;
qse_httpd_seterrnum (httpd, QSE_HTTPD_ENOMEM);
return QSE_NULL;
}
#endif
mod->handle = h;
return 0;
h = lt_dlopenext (modpath);
if (!h) qse_httpd_seterrnum (httpd, syserr_to_errnum(errno));
#if defined(QSE_CHAR_IS_MCHAR)
/* do nothing */
#else
QSE_MMGR_FREE (httpd->mmgr, modpath);
#endif
return h;
#elif defined(_WIN32)
HMODULE h;
h = LoadLibrary (sysname);
if (!h) qse_httpd_seterrnum (httpd, syserr_to_errnum(GetLastError());
QSE_ASSERT (QSE_SIZEOF(h) <= QSE_SIZEOF(void*));
h = LoadLibrary (mod->fullname);
if (h == QSE_NULL)
{
qse_httpd_seterrnum (httpd, syserr_to_errnum(GetLastError()));
return -1;
}
mod->handle = h;
return 0;
return h;
#elif defined(__OS2__)
HMODULE h;
qse_mchar_t* modpath;
char errbuf[CCHMAXPATH];
APIRET rc;
QSE_ASSERT (QSE_SIZEOF(h) <= QSE_SIZEOF(void*));
#if defined(QSE_CHAR_IS_MCHAR)
modpath = sysname;
#else
modpath = qse_wcstombsdup (sysname, QSE_NULL, httpd->mmgr);
if (!modpath)
{
qse_httpd_seterrnum (httpd, QSE_HTTPD_ENOMEM);
return QSE_NULL;
}
#endif
/* DosLoadModule() seems to have severe limitation on
* the file name it can load (max-8-letters.xxx) */
@ -46,18 +62,17 @@ static int mod_open (qse_httpd_t* httpd, qse_httpd_mod_t* mod)
if (rc != NO_ERROR)
{
qse_httpd_seterrnum (httpd, syserr_to_errnum(rc));
return -1;
h = QSE_NULL;
}
if (h == QSE_NULL)
{
qse_httpd_seterrnum (httpd, QSE_HTTPD_ENOENT); /* is this error code ok? */
return -1;
}
mod->handle = h;
return 0;
#if defined(QSE_CHAR_IS_MCHAR)
/* do nothing */
#else
QSE_MMGR_FREE (httpd->mmgr, modpath);
#endif
QSE_ASSERT (QSE_SIZEOF(h) <= QSE_SIZEOF(void*));
return h;
#elif defined(__DOS__)
@ -65,39 +80,53 @@ static int mod_open (qse_httpd_t* httpd, qse_httpd_mod_t* mod)
* dos-extender only. the best is to enable QSE_ENABLE_STATIC_MODULE
* when building for DOS. */
void* h;
qse_mchar_t* modpath;
#if defined(QSE_CHAR_IS_MCHAR)
modpath = sysname;
#else
modpath = qse_wcstombsdup (sysname, QSE_NULL, httpd->mmgr);
if (!modpath)
{
qse_httpd_seterrnum (httpd, QSE_HTTPD_ENOMEM);
return QSE_NULL;
}
#endif
h = LoadModule (modpath);
if (h == QSE_NULL)
{
qse_httpd_seterrnum (httpd, syserr_to_errnum(errno));
return -1;
}
if (!h) qse_httpd_seterrnum (httpd, syserr_to_errnum(errno));
mod->handle = h;
return 0;
#if defined(QSE_CHAR_IS_MCHAR)
/* do nothing */
#else
QSE_MMGR_FREE (httpd->mmgr, modpath);
#endif
QSE_ASSERT (QSE_SIZEOF(h) <= QSE_SIZEOF(void*));
return h;
#else
qse_httpd_seterrnum (httpd, QSE_HTTPD_ENOIMPL);
return -1;
return QSE_NULL;
#endif
}
static void mod_close (qse_httpd_t* httpd, qse_httpd_mod_t* mod)
static void mod_close (qse_httpd_t* httpd, void* handle)
{
#if defined(USE_LTDL)
lt_dlclose (mod->handle);
lt_dlclose (handle);
#elif defined(_WIN32)
FreeLibrary ((HMODULE)mod->handle);
FreeLibrary ((HMODULE)handle);
#elif defined(__OS2__)
DosFreeModule ((HMODULE)mod->handle);
DosFreeModule ((HMODULE)handle);
#elif defined(__DOS__)
FreeModule (mod->handle);
FreeModule (handle);
#else
/* nothing to do */
#endif
}
static void* mod_symbol (qse_httpd_t* httpd, qse_httpd_mod_t* handle, const qse_char_t* name)
static void* mod_symbol (qse_httpd_t* httpd, void* handle, const qse_char_t* name)
{
void* s;
qse_mchar_t* mname;
@ -114,15 +143,15 @@ static void* mod_symbol (qse_httpd_t* httpd, qse_httpd_mod_t* handle, const qse_
#endif
#if defined(USE_LTDL)
s = lt_dlsym (mod->handle, mname);
s = lt_dlsym (handle, mname);
if (s == QSE_NULL) qse_httpd_seterrnum (httpd, syserr_to_errnum(errno));
#elif defined(_WIN32)
s = GetProcAddress ((HMODULE)mod->handle, mname);
s = GetProcAddress ((HMODULE)handle, mname);
if (s == QSE_NULL) qse_httpd_seterrnum (httpd, syserr_to_errnum(GetLastError()));
#elif defined(__OS2__)
{
APIRET rc;
rc = DosQueryProcAddr ((HMODULE)mod->handle, 0, mname, (PFN*)&s);
rc = DosQueryProcAddr ((HMODULE)handle, 0, mname, (PFN*)&s);
if (rc != NO_ERROR)
{
qse_httpd_seterrnum (httpd, syserr_to_errnum(rc));
@ -130,7 +159,7 @@ static void* mod_symbol (qse_httpd_t* httpd, qse_httpd_mod_t* handle, const qse_
}
}
#elif defined(__DOS__)
s = GetProcAddress (mod->handle, mname);
s = GetProcAddress (handle, mname);
if (s == QSE_NULL) qse_httpd_seterrnum (httpd, syserr_to_errnum(errno));
#else
s = QSE_NULL;

View File

@ -99,6 +99,9 @@ static int urs_open (qse_httpd_t* httpd, qse_httpd_urs_t* urs)
httpd_xtn = qse_httpd_getxtn (httpd);
urs->handle[0].i = QSE_INVALID_SCKHND;
urs->handle[1].i = QSE_INVALID_SCKHND;
dc = (urs_ctx_t*) qse_httpd_callocmem (httpd, QSE_SIZEOF(urs_ctx_t));
if (dc == NULL) goto oops;
@ -124,7 +127,7 @@ static int urs_open (qse_httpd_t* httpd, qse_httpd_urs_t* urs)
#else
type = SOCK_DGRAM;
#endif
urs->handle[0].i = open_udp_socket (httpd, AF_INET, type, proto);
#if defined(AF_INET6)
urs->handle[1].i = open_udp_socket (httpd, AF_INET6, type, proto);
@ -159,7 +162,10 @@ static int urs_open (qse_httpd_t* httpd, qse_httpd_urs_t* urs)
if (qse_isvalidsckhnd(urs->handle[1].i)) listen (urs->handle[1].i, 99);
}
#endif
urs->handle_count = 2;
if (qse_isvalidsckhnd(urs->handle[0].i)) urs->handle_mask |= (1 << 0);
if (qse_isvalidsckhnd(urs->handle[1].i)) urs->handle_mask |= (1 << 1);
urs->ctx = dc;
return 0;
@ -202,12 +208,8 @@ static void urs_close (qse_httpd_t* httpd, qse_httpd_urs_t* urs)
QSE_ASSERT (dc->req_count == 0);
for (i = 0; i < urs->handle_count; i++)
{
if (qse_isvalidsckhnd(urs->handle[i].i))
qse_closesckhnd (urs->handle[i].i);
}
if (qse_isvalidsckhnd(urs->handle[0].i)) qse_closesckhnd (urs->handle[0].i);
if (qse_isvalidsckhnd(urs->handle[1].i)) qse_closesckhnd (urs->handle[1].i);
qse_httpd_freemem (httpd, urs->ctx);
}

View File

@ -46,6 +46,10 @@
# define EPOCH_DIFF_YEARS (QSE_EPOCH_YEAR-QSE_EPOCH_YEAR_WIN)
# define EPOCH_DIFF_DAYS ((qse_long_t)EPOCH_DIFF_YEARS*365+EPOCH_DIFF_YEARS/4-3)
# define EPOCH_DIFF_SECS ((qse_long_t)EPOCH_DIFF_DAYS*24*60*60)
# if defined(QSE_HAVE_CONFIG_H)
# include <ltdl.h>
# define USE_LTDL
# endif
#elif defined(__OS2__)
# include <types.h>
@ -91,6 +95,10 @@
# if defined(HAVE_NETINET_SCTP_H)
# include <netinet/sctp.h>
# endif
# include <unistd.h>
# include <ltdl.h>
# define USE_LTDL
#endif
#if defined(HAVE_SSL)
@ -635,6 +643,10 @@ static void cleanup_standard_httpd (qse_httpd_t* httpd)
#if defined(HAVE_SSL)
if (xtn->ssl_ctx) fini_xtn_ssl (xtn);
#endif
#if defined(USE_LTDL)
lt_dlexit ();
#endif
}
qse_httpd_t* qse_httpd_openstd (qse_size_t xtnsize)
@ -652,6 +664,18 @@ qse_httpd_t* qse_httpd_openstdwithmmgr (qse_mmgr_t* mmgr, qse_size_t xtnsize)
xtn = (httpd_xtn_t*)qse_httpd_getxtn (httpd);
#if defined(USE_LTDL)
/* lt_dlinit() can be called more than once and
* lt_dlexit() shuts down libltdl if it's called as many times as
* corresponding lt_dlinit(). so it's safe to call lt_dlinit()
* and lt_dlexit() at the library level. */
if (lt_dlinit () != 0)
{
qse_httpd_close (httpd);
return QSE_NULL;
}
#endif
set_httpd_callbacks (httpd);
xtn->ecb.close = cleanup_standard_httpd;

View File

@ -25,6 +25,23 @@
#include <qse/cmn/mbwc.h>
#include <qse/cmn/sio.h>
#if !defined(QSE_HTTPD_DEFAULT_MODPREFIX)
# if defined(_WIN32)
# define QSE_HTTPD_DEFAULT_MODPREFIX "qsehttpd-"
# elif defined(__OS2__)
# define QSE_HTTPD_DEFAULT_MODPREFIX "htd-"
# elif defined(__DOS__)
# define QSE_HTTPD_DEFAULT_MODPREFIX "htd-"
# else
# define QSE_HTTPD_DEFAULT_MODPREFIX "libqsehttpd-"
# endif
#endif
#if !defined(QSE_HTTPD_DEFAULT_MODPOSTFIX)
# define QSE_HTTPD_DEFAULT_MODPOSTFIX ""
#endif
typedef struct htrd_xtn_t htrd_xtn_t;
typedef struct tmr_xtn_t tmr_xtn_t;
@ -61,11 +78,6 @@ qse_httpd_t* qse_httpd_open (qse_mmgr_t* mmgr, qse_size_t xtnsize)
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_MMGR_FREE (httpd->mmgr, httpd);
}
@ -88,9 +100,15 @@ int qse_httpd_init (qse_httpd_t* httpd, qse_mmgr_t* mmgr)
void qse_httpd_fini (qse_httpd_t* httpd)
{
qse_httpd_ecb_t* ecb;
unload_all_modules (httpd);
for (ecb = httpd->ecb; ecb; ecb = ecb->next)
if (ecb->close) ecb->close (httpd);
free_server_list (httpd);
qse_tmr_close (httpd->tmr);
unload_all_modules (httpd);
}
void qse_httpd_stop (qse_httpd_t* httpd)
@ -878,14 +896,15 @@ static int activate_dns (qse_httpd_t* httpd)
for (i = 0; i < httpd->dns.handle_count; i++)
{
if (httpd->dns.handle[i].i >= 0)
if (httpd->dns.handle_mask & (1 << i))
{
if (httpd->opt.scb.mux.addhnd (httpd, httpd->mux, httpd->dns.handle[i], QSE_HTTPD_MUX_READ, &httpd->dns) <= -1)
{
while (i > 0)
{
qse_ubi_t handle = httpd->dns.handle[--i];
if (handle.i >= 0) httpd->opt.scb.mux.delhnd (httpd, httpd->mux, handle);
--i;
if (httpd->dns.handle_mask & (1 << i))
httpd->opt.scb.mux.delhnd (httpd, httpd->mux, httpd->dns.handle[i]);
}
httpd->opt.scb.dns.close (httpd, &httpd->dns);
return -1;
@ -902,7 +921,7 @@ static void deactivate_dns (qse_httpd_t* httpd)
for (i = 0; i < httpd->dns.handle_count; i++)
{
if (httpd->dns.handle[i].i >= 0)
if (httpd->dns.handle_mask & (1 << i))
httpd->opt.scb.mux.delhnd (httpd, httpd->mux, httpd->dns.handle[i]);
}
@ -912,12 +931,9 @@ static void deactivate_dns (qse_httpd_t* httpd)
static int activate_urs (qse_httpd_t* httpd)
{
/* TODO: how to disable URS??? */
int i;
QSE_MEMSET (&httpd->urs, 0, QSE_SIZEOF(httpd->urs));
for (i = 0; i < QSE_COUNTOF(httpd->urs.handle); i++)
httpd->urs.handle[i].i = -1;
if (httpd->opt.scb.urs.open (httpd, &httpd->urs) <= -1) return -1;
@ -925,15 +941,19 @@ static int activate_urs (qse_httpd_t* httpd)
for (i = 0; i < httpd->dns.handle_count; i++)
{
if (httpd->opt.scb.mux.addhnd (httpd, httpd->mux, httpd->urs.handle[i], QSE_HTTPD_MUX_READ, &httpd->urs) <= -1)
if (httpd->urs.handle_mask & (1 << i))
{
while (i > 0)
if (httpd->opt.scb.mux.addhnd (httpd, httpd->mux, httpd->urs.handle[i], QSE_HTTPD_MUX_READ, &httpd->urs) <= -1)
{
qse_ubi_t handle = httpd->urs.handle[--i];
httpd->opt.scb.mux.delhnd (httpd, httpd->mux, handle);
while (i > 0)
{
--i;
if (httpd->urs.handle_mask & (1 << i))
httpd->opt.scb.mux.delhnd (httpd, httpd->mux, httpd->urs.handle[i]);
}
httpd->opt.scb.urs.close (httpd, &httpd->urs);
return -1;
}
httpd->opt.scb.urs.close (httpd, &httpd->urs);
return -1;
}
}
@ -946,7 +966,7 @@ static void deactivate_urs (qse_httpd_t* httpd)
for (i = 0; i < httpd->urs.handle_count; i++)
{
if (httpd->urs.handle[i].i >= 0)
if (httpd->urs.handle_mask & (1 << i))
httpd->opt.scb.mux.delhnd (httpd, httpd->mux, httpd->urs.handle[i]);
}
@ -1900,7 +1920,7 @@ static void unload_all_modules (qse_httpd_t* httpd)
httpd->modlist = mod->next;
if (mod->unload) mod->unload (mod);
httpd->opt.scb.mod.close (httpd, mod);
httpd->opt.scb.mod.close (httpd, mod->handle );
qse_httpd_freemem (httpd, mod);
}
}
@ -1944,11 +1964,10 @@ int qse_httpd_loadmod (qse_httpd_t* httpd, const qse_char_t* name)
* +2: _\0
*/
fullname_len = prefix_len + name_len + postfix_len;
mod = qse_httpd_allocmem (httpd, QSE_SIZEOF(*mod) + (name_len + 1 + fullname_len + 1 + 15 + name_len + 2) * QSE_SIZEOF(qse_char_t));
mod = qse_httpd_callocmem (httpd, QSE_SIZEOF(*mod) + (name_len + 1 + fullname_len + 1 + 15 + name_len + 2) * QSE_SIZEOF(qse_char_t));
if (mod == QSE_NULL) return -1;
QSE_MEMSET (mod, 0, QSE_SIZEOF(*mod));
mod->httpd = httpd;
mod->name = (qse_char_t*)(mod + 1);
mod->fullname = mod->name + name_len + 1;
entry_point_name = mod->fullname + fullname_len + 1;
@ -1956,33 +1975,31 @@ int qse_httpd_loadmod (qse_httpd_t* httpd, const qse_char_t* name)
qse_strjoin (mod->fullname, prefix, name, postfix, QSE_NULL);
qse_strjoin (entry_point_name, QSE_T("_qse_httpd_mod_"), name, QSE_NULL);
printf ("%ls %ls %ls\n", mod->name, mod->fullname, entry_point_name);
if (httpd->opt.scb.mod.open (httpd, mod) <= -1)
mod->handle = httpd->opt.scb.mod.open (httpd, mod->fullname);
if (!mod->handle)
{
printf ("FAIL => %ls %ls %ls\n", mod->name, mod->fullname, entry_point_name);
qse_httpd_freemem (httpd, mod);
return -1;
}
printf ("OK => %ls %ls %ls\n", mod->name, mod->fullname, entry_point_name);
/* attempt qse_httpd_mod_xxx */
load = httpd->opt.scb.mod.symbol (httpd, mod, &entry_point_name[1]);
load = httpd->opt.scb.mod.symbol (httpd, mod->handle, &entry_point_name[1]);
if (!load)
{
/* attempt _qse_awk_mod_xxx */
load = httpd->opt.scb.mod.symbol (httpd, mod, &entry_point_name[0]);
load = httpd->opt.scb.mod.symbol (httpd, mod->handle, &entry_point_name[0]);
if (!load)
{
/* attempt qse_awk_mod_xxx_ */
entry_point_name[15 + name_len] = QSE_T('_');
entry_point_name[15 + name_len + 1] = QSE_T('\0');
load = httpd->opt.scb.mod.symbol (httpd, mod, &entry_point_name[1]);
load = httpd->opt.scb.mod.symbol (httpd, mod->handle, &entry_point_name[1]);
}
}
if (load == QSE_NULL || load (mod) <= -1)
{
httpd->opt.scb.mod.close (httpd, mod);
httpd->opt.scb.mod.close (httpd, mod->handle);
qse_httpd_freemem (httpd, mod);
return -1;
}