removed many debugging messages from httpd

This commit is contained in:
2013-02-22 05:01:33 +00:00
parent 394cb34c04
commit 624a917b45
15 changed files with 249 additions and 118 deletions

View File

@ -35,6 +35,7 @@
#include <stdarg.h>
#include <stdlib.h>
#include <locale.h>
#include <stdio.h>
#define ENABLE_CALLBACK
#define ABORT(label) goto label

View File

@ -5,6 +5,10 @@ AM_CPPFLAGS = \
-I$(top_srcdir)/include \
-I$(includedir)
qsecfgdir = $(sysconfdir)/qse
qsecfg_DATA = httpd.conf httpd-mime.conf
bin_PROGRAMS = qsehttpd
qsehttpd_SOURCES = httpd.c

View File

@ -15,6 +15,7 @@
@SET_MAKE@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
@ -51,7 +52,7 @@ mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/include/qse/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
am__installdirs = "$(DESTDIR)$(bindir)"
am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(qsecfgdir)"
PROGRAMS = $(bin_PROGRAMS)
am_qsehttpd_OBJECTS = httpd.$(OBJEXT)
qsehttpd_OBJECTS = $(am_qsehttpd_OBJECTS)
@ -92,6 +93,34 @@ am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
SOURCES = $(qsehttpd_SOURCES)
DIST_SOURCES = $(qsehttpd_SOURCES)
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
*) f=$$p;; \
esac;
am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
am__install_max = 40
am__nobase_strip_setup = \
srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
am__nobase_strip = \
for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
am__nobase_list = $(am__nobase_strip_setup); \
for p in $$list; do echo "$$p $$p"; done | \
sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
$(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
if (++n[$$2] == $(am__install_max)) \
{ print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
END { for (dir in files) print dir, files[dir] }'
am__base_list = \
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
am__uninstall_files_from_dir = { \
test -z "$$files" \
|| { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
|| { echo " ( cd '$$dir' && rm -f" $$files ")"; \
$(am__cd) "$$dir" && rm -f $$files; }; \
}
DATA = $(qsecfg_DATA)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
@ -275,6 +304,8 @@ AM_CPPFLAGS = \
-I$(top_srcdir)/include \
-I$(includedir)
qsecfgdir = $(sysconfdir)/qse
qsecfg_DATA = httpd.conf httpd-mime.conf
qsehttpd_SOURCES = httpd.c
qsehttpd_LDFLAGS = -L../../lib/xli -L../../lib/http -L../../lib/cmn -L$(libdir)
qsehttpd_LDADD = -lqsexli -lqsehttp -lqsecmn $(am__append_1)
@ -393,6 +424,24 @@ mostlyclean-libtool:
clean-libtool:
-rm -rf .libs _libs
install-qsecfgDATA: $(qsecfg_DATA)
@$(NORMAL_INSTALL)
test -z "$(qsecfgdir)" || $(MKDIR_P) "$(DESTDIR)$(qsecfgdir)"
@list='$(qsecfg_DATA)'; test -n "$(qsecfgdir)" || list=; \
for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
echo "$$d$$p"; \
done | $(am__base_list) | \
while read files; do \
echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(qsecfgdir)'"; \
$(INSTALL_DATA) $$files "$(DESTDIR)$(qsecfgdir)" || exit $$?; \
done
uninstall-qsecfgDATA:
@$(NORMAL_UNINSTALL)
@list='$(qsecfg_DATA)'; test -n "$(qsecfgdir)" || list=; \
files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
dir='$(DESTDIR)$(qsecfgdir)'; $(am__uninstall_files_from_dir)
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
@ -478,9 +527,9 @@ distdir: $(DISTFILES)
done
check-am: all-am
check: check-am
all-am: Makefile $(PROGRAMS)
all-am: Makefile $(PROGRAMS) $(DATA)
installdirs:
for dir in "$(DESTDIR)$(bindir)"; do \
for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(qsecfgdir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-am
@ -535,7 +584,7 @@ info: info-am
info-am:
install-data-am:
install-data-am: install-qsecfgDATA
install-dvi: install-dvi-am
@ -581,7 +630,7 @@ ps: ps-am
ps-am:
uninstall-am: uninstall-binPROGRAMS
uninstall-am: uninstall-binPROGRAMS uninstall-qsecfgDATA
.MAKE: install-am install-strip
@ -593,11 +642,11 @@ uninstall-am: uninstall-binPROGRAMS
install-dvi-am install-exec install-exec-am install-html \
install-html-am install-info install-info-am install-man \
install-pdf install-pdf-am install-ps install-ps-am \
install-strip installcheck installcheck-am installdirs \
maintainer-clean maintainer-clean-generic mostlyclean \
mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
pdf pdf-am ps ps-am tags uninstall uninstall-am \
uninstall-binPROGRAMS
install-qsecfgDATA install-strip installcheck installcheck-am \
installdirs maintainer-clean maintainer-clean-generic \
mostlyclean mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \
uninstall-am uninstall-binPROGRAMS uninstall-qsecfgDATA
# Tell versions [3.59,3.63) of GNU make to not export all variables.

View File

@ -12,6 +12,7 @@
#include <signal.h>
#include <locale.h>
#include <stdio.h>
#if defined(_WIN32)
# include <winsock2.h>
@ -72,69 +73,57 @@ static void sig_reconf (int sig)
}
}
static void setup_signal_handler (int signum, void(*handler)(int))
{
#if defined(HAVE_SIGACTION)
struct sigaction act;
qse_memset (&act, 0, QSE_SIZEOF(act));
act.sa_handler = handler;
sigaction (signum, &act, QSE_NULL);
#else
signal (signum, handler);
#endif
}
static void setup_signal_handlers ()
{
struct sigaction act;
#if defined(SIGINT)
qse_memset (&act, 0, QSE_SIZEOF(act));
act.sa_handler = sig_stop;
sigaction (SIGINT, &act, QSE_NULL);
setup_signal_handler (SIGINT, sig_stop);
#endif
#if defined(SIGTERM)
qse_memset (&act, 0, QSE_SIZEOF(act));
act.sa_handler = sig_stop;
sigaction (SIGTERM, &act, QSE_NULL);
setup_signal_handler (SIGTERM, sig_stop);
#endif
#if defined(SIGHUP)
qse_memset (&act, 0, QSE_SIZEOF(act));
act.sa_handler = sig_reconf;
sigaction (SIGHUP, &act, QSE_NULL);
setup_signal_handler (SIGHUP, sig_reconf);
#endif
#if defined(SIGUSR1)
qse_memset (&act, 0, QSE_SIZEOF(act));
act.sa_handler = sig_reconf;
sigaction (SIGUSR1, &act, QSE_NULL);
setup_signal_handler (SIGUSR1, sig_reconf);
#endif
#if defined(SIGPIPE)
qse_memset (&act, 0, QSE_SIZEOF(act));
act.sa_handler = SIG_IGN;
sigaction (SIGPIPE, &act, QSE_NULL);
setup_signal_handler (SIGPIPE, SIG_IGN);
#endif
}
static void restore_signal_handlers ()
{
struct sigaction act;
#if defined(SIGINT)
qse_memset (&act, 0, QSE_SIZEOF(act));
act.sa_handler = SIG_DFL;
sigaction (SIGINT, &act, QSE_NULL);
setup_signal_handler (SIGINT, SIG_DFL);
#endif
#if defined(SIGTERM)
qse_memset (&act, 0, QSE_SIZEOF(act));
act.sa_handler = SIG_DFL;
sigaction (SIGTERM, &act, QSE_NULL);
setup_signal_handler (SIGTERM, SIG_DFL);
#endif
#if defined(SIGHUP)
qse_memset (&act, 0, QSE_SIZEOF(act));
act.sa_handler = SIG_DFL;
sigaction (SIGHUP, &act, QSE_NULL);
setup_signal_handler (SIGHUP, SIG_DFL);
#endif
#if defined(SIGUSR1)
qse_memset (&act, 0, QSE_SIZEOF(act));
act.sa_handler = SIG_DFL;
sigaction (SIGUSR1, &act, QSE_NULL);
setup_signal_handler (SIGUSR1, SIG_DFL);
#endif
#if defined(SIGPIPE)
qse_memset (&act, 0, QSE_SIZEOF(act));
act.sa_handler = SIG_DFL;
sigaction (SIGPIPE, &act, QSE_NULL);
setup_signal_handler (SIGPIPE, SIG_DFL);
#endif
}
@ -192,6 +181,7 @@ enum
struct cgi_t
{
enum {
CGI_PREFIX,
CGI_SUFFIX,
CGI_NAME,
CGI_MAX
@ -207,6 +197,7 @@ struct cgi_t
struct mime_t
{
enum {
MIME_PREFIX,
MIME_SUFFIX,
MIME_NAME,
MIME_OTHER,
@ -224,6 +215,7 @@ struct access_t
/* TODO: support more types like ACCESS_GLOB
not-only the base name, find a way to use query path or xpath */
enum {
ACCESS_PREFIX,
ACCESS_SUFFIX,
ACCESS_NAME,
ACCESS_OTHER,
@ -490,7 +482,8 @@ static int query_server (
struct cgi_t* cgi;
for (cgi = server_xtn->cgi[i].head; cgi; cgi = cgi->next)
{
if ((cgi->type == CGI_SUFFIX && qse_mbsend (xpath_base, cgi->spec)) ||
if ((cgi->type == CGI_PREFIX && qse_mbsbeg (xpath_base, cgi->spec)) ||
(cgi->type == CGI_SUFFIX && qse_mbsend (xpath_base, cgi->spec)) ||
(cgi->type == CGI_NAME && qse_mbscmp (xpath_base, cgi->spec) == 0))
{
scgi->cgi = 1;
@ -517,7 +510,8 @@ static int query_server (
struct mime_t* mime;
for (mime = server_xtn->mime[i].head; mime; mime = mime->next)
{
if ((mime->type == MIME_SUFFIX && qse_mbsend (xpath_base, mime->spec)) ||
if ((mime->type == MIME_PREFIX && qse_mbsbeg (xpath_base, mime->spec)) ||
(mime->type == MIME_SUFFIX && qse_mbsend (xpath_base, mime->spec)) ||
(mime->type == MIME_NAME && qse_mbscmp (xpath_base, mime->spec) == 0) ||
mime->type == MIME_OTHER)
{
@ -546,7 +540,8 @@ static int query_server (
struct access_t* access;
for (access = server_xtn->access[id][i].head; access; access = access->next)
{
if ((access->type == ACCESS_SUFFIX && qse_mbsend (xpath_base, access->spec)) ||
if ((access->type == ACCESS_PREFIX && qse_mbsbeg (xpath_base, access->spec)) ||
(access->type == ACCESS_SUFFIX && qse_mbsend (xpath_base, access->spec)) ||
(access->type == ACCESS_NAME && qse_mbscmp (xpath_base, access->spec) == 0) ||
access->type == ACCESS_OTHER)
{
@ -645,14 +640,9 @@ static int load_server_config (
struct cgi_t* cgi;
int type;
if (qse_strcmp (pair->key, QSE_T("suffix")) == 0)
{
type = CGI_SUFFIX;
}
else if (qse_strcmp (pair->key, QSE_T("name")) == 0)
{
type = CGI_NAME;
}
if (qse_strcmp (pair->key, QSE_T("prefix")) == 0) type = CGI_PREFIX;
else if (qse_strcmp (pair->key, QSE_T("suffix")) == 0) type = CGI_SUFFIX;
else if (qse_strcmp (pair->key, QSE_T("name")) == 0) type = CGI_NAME;
else continue;
cgi = qse_httpd_callocmem (httpd, QSE_SIZEOF(*cgi));
@ -726,7 +716,8 @@ static int load_server_config (
struct mime_t* mime;
int type;
if (qse_strcmp (pair->key, QSE_T("suffix")) == 0 && pair->name) type = MIME_SUFFIX;
if (qse_strcmp (pair->key, QSE_T("prefix")) == 0 && pair->name) type = MIME_PREFIX;
else if (qse_strcmp (pair->key, QSE_T("suffix")) == 0 && pair->name) type = MIME_SUFFIX;
else if (qse_strcmp (pair->key, QSE_T("name")) == 0 && pair->name) type = MIME_NAME;
else if (qse_strcmp (pair->key, QSE_T("other")) == 0 && !pair->name) type = MIME_OTHER;
else continue;
@ -793,7 +784,8 @@ static int load_server_config (
const qse_char_t* tmp;
int type, value;
if (qse_strcmp (pair->key, QSE_T("suffix")) == 0 && pair->name) type = ACCESS_SUFFIX;
if (qse_strcmp (pair->key, QSE_T("prefix")) == 0 && pair->name) type = ACCESS_PREFIX;
else if (qse_strcmp (pair->key, QSE_T("suffix")) == 0 && pair->name) type = ACCESS_SUFFIX;
else if (qse_strcmp (pair->key, QSE_T("name")) == 0 && pair->name) type = ACCESS_NAME;
else if (qse_strcmp (pair->key, QSE_T("other")) == 0 && !pair->name) type = ACCESS_OTHER;
else continue;

View File

@ -17,9 +17,9 @@ default {
"index.cgi";
cgi {
name "t3.nph" = "nph";
#name "t3.nph" = "nph";
suffix ".cgi";
suffix ".ant" = "nph", "";
suffix ".nph" = "nph";
suffix ".awk" = "cgi", "/usr/bin/qseawk -f";
# glob is not supported yet
@ -32,20 +32,22 @@ default {
# control access to directories
dir-access {
# suffix ".xxxx" = ok;
# name "xxxxx" = ok;
other = noent;
#prefix ".xxxx" = ok;
#suffix ".xxxx" = ok;
#name "xxxxx" = ok;
#other = noent;
}
# control access to normal files.
# cgi scripts are not control by these.
file-access {
#prefix "index.html." = ok;
suffix ".html" = ok;
suffix ".css" = ok;
suffix ".js" = ok;
suffix ".png" = ok;
suffix ".jpg" = ok;
other = noent;
#other = noent;
}
dir-css = "<style type='text/css'>body { background-color:#d0e4fe; font-size: 0.9em; } div.header { font-weight: bold; margin-bottom: 5px; } div.footer { border-top: 1px solid #99AABB; text-align: right; } table { font-size: 0.9em; } td { white-space: nowrap; } td.size { text-align: right; }</style>";

View File

@ -33,6 +33,7 @@
#include <qse/cmn/glob.h>
#include <locale.h>
#include <stdio.h>
#if defined(_WIN32)
# include <windows.h>