/*****************************************************************************
* xmlparser.cpp
*****************************************************************************
- * Copyright (C) 2004 VideoLAN
+ * Copyright (C) 2004 the VideoLAN team
* $Id$
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "xmlparser.hpp"
#include "../src/os_factory.hpp"
-#include <sys/stat.h>
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
// Static variable to avoid initializing catalogs twice
static bool m_initialized = false;
-XMLParser::XMLParser( intf_thread_t *pIntf, const string &rFileName ):
+XMLParser::XMLParser( intf_thread_t *pIntf, const string &rFileName,
+ bool useDTD ):
SkinObject( pIntf )
{
+ m_pReader = NULL;
+ m_pStream = NULL;
+
m_pXML = xml_Create( pIntf );
if( !m_pXML )
{
- msg_Err( getIntf(), "Failed to open XML parser" );
- m_pReader = NULL;
+ msg_Err( getIntf(), "failed to open XML parser" );
return;
}
m_initialized = true;
}
- m_pReader = xml_ReaderCreate( m_pXML, rFileName.c_str() );
+ m_pStream = stream_UrlNew( pIntf, rFileName.c_str() );
+ if( !m_pStream )
+ {
+ msg_Err( getIntf(), "failed to open %s for reading",
+ rFileName.c_str() );
+ return;
+ }
+ m_pReader = xml_ReaderCreate( m_pXML, m_pStream );
if( !m_pReader )
{
- msg_Err( getIntf(), "Failed to open %s for parsing",
+ msg_Err( getIntf(), "failed to open %s for parsing",
rFileName.c_str() );
return;
}
+
+ xml_ReaderUseDTD( m_pReader, useDTD ? VLC_TRUE : VLC_FALSE );
+
}
{
if( m_pReader && m_pXML ) xml_ReaderDelete( m_pXML, m_pReader );
if( m_pXML ) xml_Delete( m_pXML );
+ if( m_pStream ) stream_Delete( m_pStream );
}
const list<string> &resPath = pOSFactory->getResourcePath();
const string &sep = pOSFactory->getDirSeparator();
list<string>::const_iterator it;
+
+#ifdef HAVE_SYS_STAT_H
struct stat statBuf;
// Try to load the catalog first (needed at least on win32 where
if( !stat( path.c_str(), &statBuf ) )
{
// DTD found
- msg_Dbg( getIntf(), "Using DTD %s", path.c_str() );
+ msg_Dbg( getIntf(), "using DTD %s", path.c_str() );
// Add an entry in the default catalog
xml_CatalogAdd( m_pXML, "public",
}
if( it == resPath.end() )
{
- msg_Err( getIntf(), "Cannot find the skins DTD !");
+ msg_Err( getIntf(), "cannot find the skins DTD");
}
+#endif
}
bool XMLParser::parse()
}
handleBeginElement( eltName, attributes );
+ free( eltName );
map<const char*, const char*, ltstr> ::iterator it =
attributes.begin();
while( it != attributes.end() )
{
+ free( (char *)it->first );
free( (char *)it->second );
it++;
}