00001
00002
00003
00004
00005
00006
00007
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 # include "zipstreamer.hpp"
00041 # include "flow/buffers/filebuffer.hpp"
00042 # include "processor/xmlprocessor.hpp"
00043 # include "processor/xmlflowcontext.hpp"
00044
00045 BEGIN_XDFLENGINE_NS
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056 ZipStreamer::ZipStreamer( const XMLStreamerFactory* p_pParent, StreamerParams* p_pParameters, XMLFlowContext* p_pContext, XMLStreamConsumer* p_pOutput)
00057 :XMLStreamer( p_pParent, p_pParameters, p_pContext, p_pOutput)
00058 {
00059 m_pBufOut = 0;
00060 DEBUG_CREATE(ZipStreamer)
00061 }
00062
00063
00064
00065
00066 ZipStreamer::~ZipStreamer()
00067 {
00068 DEBUG_DEL(ZipStreamer)
00069 if(m_pBufOut) delete m_pBufOut;
00070 }
00071
00072
00073
00074
00075
00076
00077 bool ZipStreamer::initStream()
00078 {
00079
00080 const char* l_pszFilePath;
00081 const char* l_pszHeader;
00082 const char* l_pszAction;
00083
00084
00085 DEBUG_IN(ZipStreamer::initStream)
00086
00087
00088 l_pszFilePath = getParamValue(m_pParameters, ZIPSTREAMER_TARGET);
00089
00090 if( strlen(l_pszFilePath)>0 )
00091 {
00092
00093 l_pszHeader = getParamValue(m_pParameters, ZIPSTREAMER_HEADER,ZIPSTREAMER_HEADER_DEF);
00094 l_pszAction = getParamValue(m_pParameters, ZIPSTREAMER_ACTION, ZIPSTREAMER_ACTION_DEF);
00095
00096 if ( strcmp( l_pszAction, ZIPSTREAMER_ACTION_DELETE) != 0 )
00097 {
00098 m_pBufOut = new ZipBuffer( l_pszFilePath, false);
00099
00100 if ( strcmp( l_pszAction, ZIPSTREAMER_ACTION_FLUSH) == 0 ) m_pBufOut->flush();
00101 if( strlen(l_pszHeader)>0) (*m_pBufOut) << l_pszHeader << "\n";
00102 }
00103 else
00104 {
00105 remove( l_pszFilePath);
00106 }
00107 }
00108 else
00109 {
00110 m_pBufOut = 0;
00111 }
00112
00113
00114 DEBUG_OUT(ZipStreamer::initStream)
00115
00116 return true;
00117 }
00118
00119
00120
00121
00122 void ZipStreamer::writeData( const char* p_pszData, unsigned int p_uiDataLen)
00123 {
00124 DEBUG_IN(ZipStreamer::writeData)
00125
00126 if(m_pBufOut) m_pBufOut -> writeData( p_pszData, p_uiDataLen);
00127 if(m_pOutput) m_pOutput -> writeData( p_pszData, p_uiDataLen);
00128
00129 DEBUG_OUT(ZipStreamer::writeData)
00130 }
00131
00132
00133
00134
00135 bool ZipStreamer::commitStream(bool p_fFinal)
00136 {
00137 DEBUG_IN(ZipStreamer::commitStream)
00138
00139 bool m_fOK;
00140 bool m_fOK2;
00141
00142 if(m_pBufOut) m_fOK = m_pBufOut->commitStream(false);
00143 if(m_pOutput) m_fOK2 = m_pOutput->commitStream(false);
00144
00145 DEBUG_OUT(ZipStreamer::commitStream)
00146
00147 return m_fOK;
00148
00149
00150 }
00151
00152
00153
00154
00155
00156
00157
00158
00159 ZipStreamerFactory::ZipStreamerFactory()
00160 {
00161 logout.display_version( "ZLIB", "'zlib' general purpose compression library", ZLIB_VERSION, "Copyright (C) 1995-2002 Jean-loup Gailly and Mark Adler");
00162 }
00163
00164 XMLStreamer* ZipStreamerFactory::getStreamer(
00165 StreamerParams* p_pParameters,
00166 XMLFlowContext* p_pStreamContext,
00167 XMLStreamConsumer* p_pStreamConsumer) const
00168 {
00169 DEBUG_FUNC(ZipStreamerFactory::getStreamer)
00170
00171
00172 return (XMLStreamer*) new ZipStreamer( this, p_pParameters, p_pStreamContext, p_pStreamConsumer);
00173 }
00174
00175
00176
00177
00178
00179 END_XDFLENGINE_NS
00180
00181