author | Michael Krelin <hacker@klever.net> | 2005-06-11 14:49:35 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2005-06-11 14:49:35 (UTC) |
commit | 621221c40a42683a185b15b99c03fd6c8b6f7d90 (patch) (side-by-side diff) | |
tree | 061f1e7a9fb7b16122eed9715c1a180629dbd953 | |
parent | 01e3789f5b7c3b2c0282b70eb203d11c76d3c8f3 (diff) | |
download | sitecing-621221c40a42683a185b15b99c03fd6c8b6f7d90.zip sitecing-621221c40a42683a185b15b99c03fd6c8b6f7d90.tar.gz sitecing-621221c40a42683a185b15b99c03fd6c8b6f7d90.tar.bz2 |
1. added missing include
2. fixed typo in Makefile
3. fixed zero-size output segfault
-rw-r--r-- | include/sitecing/acomponent.h | 1 | ||||
-rw-r--r-- | lib/sitecing_interface_cgi.cc | 4 | ||||
-rw-r--r-- | src/Makefile.am | 2 |
3 files changed, 5 insertions, 2 deletions
diff --git a/include/sitecing/acomponent.h b/include/sitecing/acomponent.h index 160e854..461f8a6 100644 --- a/include/sitecing/acomponent.h +++ b/include/sitecing/acomponent.h @@ -1,35 +1,36 @@ #ifndef __SITECING_ACOMPONENT_H #define __SITECING_ACOMPONENT_H +#include <cstdarg> #include "sitecing/sitecing_interface.h" /** * @file * @brief The acomponent class declaration. */ namespace sitecing { /** * An abstract base class for sitecing components. */ class acomponent { public: /** * Pointer to the interface object, used to communicate with the * site-C-ing core. */ sitecing_interface *__SCIF; acomponent(); virtual ~acomponent(); /** * Set the interface to core pointer. * @param scif the pointer to the interface object. */ virtual void __set_interface(sitecing_interface *scif=0); /** * Invoked if the interface to the core has changed. * @param oscif pointer to the old interface object. */ diff --git a/lib/sitecing_interface_cgi.cc b/lib/sitecing_interface_cgi.cc index 59ae25a..1acb23c 100644 --- a/lib/sitecing_interface_cgi.cc +++ b/lib/sitecing_interface_cgi.cc @@ -1,51 +1,53 @@ #include <cassert> #include "sitecing/sitecing_interface_cgi.h" namespace sitecing { sitecing_interface_cgi::sitecing_interface_cgi(sitespace *s) : outs(&prebuffer), sitecing_interface(&outs), ss(s), cgigw(NULL), headers_flushed(false) { } void sitecing_interface_cgi::prepare(kingate::cgi_gateway *cg) { cgigw = cg; headers.clear(); headers["Content-Type"] = "text/html"; prebuffer.str(""); headers_flushed = false; set_buffering(true); } void sitecing_interface_cgi::flush(bool keep_buffering) { assert(cgigw); flush_headers(); if(is_buffering()) { streampos count = prebuffer.pubseekoff(0,ios_base::cur,ios_base::out); - cgigw->out().write(prebuffer.str().c_str(),count); + if(count>0) { + cgigw->out().write(prebuffer.str().c_str(),count); + } prebuffer.str(""); } cgigw->out().flush(); set_buffering(keep_buffering); } void sitecing_interface_cgi::set_buffering(bool do_buffer) { if(!do_buffer) flush_headers(); outs.rdbuf(do_buffer?&prebuffer:cgigw->out().rdbuf()); } bool sitecing_interface_cgi::is_buffering() { return outs.rdbuf()==&prebuffer; } void sitecing_interface_cgi::flush_headers() { assert(cgigw); if(headers_flushed) return; for(kingate::headers::const_iterator i=headers.begin();i!=headers.end();i++) cgigw->out() << i->first << ": " << i->second << "\n"; cgigw->out() << "\n"; headers_flushed = true; } } diff --git a/src/Makefile.am b/src/Makefile.am index 2ec650d..e6fb31a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -5,33 +5,33 @@ bin_PROGRAMS += sitecing-fastcgi endif if HAVE_PLAINCGI bin_PROGRAMS += sitecing-plaincgi endif INCLUDES = -I${top_srcdir}/include ${KINGATE_CFLAGS} ${DOTCONF_CFLAGS} \ ${PCREPP_CFLAGS} LIBS += ${top_builddir}/lib/libsitecing.la ${DOTCONF_LIBS} \ ${PCREPP_LIBS} sitecing_fastcgi_SOURCES = sitecing-fastcgi.cc \ COPYING.cc sitecing_fastcgi_LDADD = ${KINGATE_FCGI_LIBS} sitecing_fastcgi_LDFLAGS = -rdynamic sitecing_fastcgi_DEPENDENCIES = ${top_builddir}/lib/libsitecing.la sitecing_plaincgi_SOURCES = sitecing-plaincgi.cc \ COPYING.cc sitecing_plaincgi_LDFLAGS = -rdynamic sitecing_plaincgi_LDADD = ${KINGATE_PLAINCGI_LIBS} sitecing_plaincgi_DEPENDENCIES = ${top_builddir}/lib/libsitecing.la sitecing_build_SOURCES = sitecing-build.cc \ COPYING.cc sitecing_build_LDADD = ${KINGATE_LIBS} sitecing_build_DEPENDENCIES = ${top_builddir}/lib/libsitecing.la COPYING.cc: ${top_srcdir}/COPYING echo "const char * COPYING =" >$@ || (rm $@;exit 1) sed 's/"/\\"/g' $< | sed 's/^/\"/' | sed 's/$$/\\n\"/' >>$@ || (rm $@;exit 1) echo ";" >>$@ || (rm $@;exit 1) -EXTRA_DIST = ${sitecing_fastcgi_SOURCES} ${sitecing_PLAINCGI_SOURCES} +EXTRA_DIST = ${sitecing_fastcgi_SOURCES} ${sitecing_plaincgi_SOURCES} |