*****************************************************************************/
#include "skin_parser.hpp"
+#include "../src/os_factory.hpp"
#include <math.h>
+#include <libxml/catalog.h>
+#include <sys/stat.h>
// Current DTD version
#define SKINS_DTD_VERSION "2.0"
+// Static variable to avoid initializing catalogs twice
+bool SkinParser::m_initialized = false;
+
SkinParser::SkinParser( intf_thread_t *pIntf, const string &rFileName,
const string &rPath ):
XMLParser( pIntf, rFileName ), m_xOffset( 0 ), m_yOffset( 0 ),
m_path( rPath )
{
+ // Avoid duplicate initialization (mutex needed ?)
+ if( !m_initialized )
+ {
+ // Initialize XML catalog support
+ xmlInitializeCatalog();
+
+ // Get the resource path and look for the DTD
+ OSFactory *pOSFactory = OSFactory::instance( getIntf() );
+ const list<string> &resPath = pOSFactory->getResourcePath();
+ const string &sep = pOSFactory->getDirSeparator();
+ list<string>::const_iterator it;
+ struct stat statBuf;
+ for( it = resPath.begin(); it != resPath.end(); it++ )
+ {
+ string path = (*it) + sep + "skin.dtd";
+ if( !stat( path.c_str(), &statBuf ) )
+ {
+ // DTD found
+ msg_Dbg( getIntf(), "Using DTD %s", path.c_str() );
+ // Add an entry in the default catalog
+ xmlCatalogAdd( (xmlChar*)"public",
+ (xmlChar*)("-//VideoLAN//DTD VLC Skins V"
+ SKINS_DTD_VERSION "//EN"),
+ (xmlChar*)path.c_str() );
+ break;
+ }
+ }
+ if( it == resPath.end() )
+ {
+ msg_Err( getIntf(), "Cannot find the skins DTD !");
+ }
+ m_initialized = true;
+ }
}