* Suggestion how to "solve" the XML-reading problems in certain environments:

A workaround has been implemented where it is not tried any more to "directly
  parse the file" but rather the file is read into a memory buffer which then
  is parsed.
  For further information, see MUSR-122.

* Fixed a linking problem when only shared libraries are built on Cygwin
  (introduced with the split-off of libPUserFcnBase).
This commit is contained in:
Bastian M. Wojek
2011-06-16 22:00:33 +00:00
parent e244d2093a
commit dc48ea9712
12 changed files with 533 additions and 29 deletions

View File

@@ -89,7 +89,7 @@ CLEANFILES = *Dict.cpp *Dict.h *~ core
lib_LTLIBRARIES = libPMusr.la libPUserFcnBase.la
libPMusr_la_SOURCES = $(h_sources) $(cpp_sources) $(dict_h_sources) $(dict_cpp_sources)
libPMusr_la_LIBADD = $(LEM_LIBS) $(PSIBIN_LIBS) $(MUD_LIBS) $(PNEXUS_LIBS) $(FFTW3_LIBS) $(GSL_LIBS) $(ROOT_LIBS)
libPMusr_la_LIBADD = libPUserFcnBase.la $(LEM_LIBS) $(PSIBIN_LIBS) $(MUD_LIBS) $(PNEXUS_LIBS) $(FFTW3_LIBS) $(GSL_LIBS) $(ROOT_LIBS)
libPMusr_la_LDFLAGS = -version-info $(MUSR_LIBRARY_VERSION) -release $(MUSR_RELEASE) $(AM_LDFLAGS)
libPUserFcnBase_la_SOURCES = $(h_sources_userFcn) $(cpp_sources_userFcn) $(dict_h_sources_userFcn) $(dict_cpp_sources_userFcn)

View File

@@ -419,12 +419,31 @@ int PMsr2Data::SetRunNumbers(const string &runListFile)
*/
int PMsr2Data::ParseXmlStartupFile()
{
fstream xmlFile;
unsigned int xmlSize = 0;
char *xmlBuffer = 0;
int status;
fSaxParser = new TSAXParser();
fStartupHandler = new PStartupHandler();
string startup_path_name(fStartupHandler->GetStartupFilePath().Data());
fSaxParser->ConnectToHandler("PStartupHandler", fStartupHandler);
status = fSaxParser->ParseFile(startup_path_name.c_str());
//status = fSaxParser->ParseFile(startup_path_name.c_str());
// parsing the file as above seems to lead to problems in certain environments; try working around through a buffer as follows
xmlFile.open(startup_path_name.c_str(), ios::in | ios::ate); // open file for reading and go to the end of the file
if (xmlFile.is_open()) { // check if file has been opened successfully
xmlSize = xmlFile.tellg(); // get the position within the stream == size of the file (since we are at the end)
xmlFile.seekg(0, ios::beg); // go back to the beginning of the stream
xmlBuffer = new char[xmlSize]; // allocate buffer memory for the whole XML file
xmlFile.read(xmlBuffer, xmlSize); // read in the whole XML file into the buffer
xmlFile.close(); // close the XML file
}
if (!xmlBuffer) { // file has not been read into the buffer
status = 1;
} else {
status = fSaxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer
delete[] xmlBuffer; // free the buffer memory
xmlBuffer = 0;
}
// check for parse errors
if (status) { // error
cerr << endl << ">> msr2data: **WARNING** Reading/parsing musrfit_startup.xml failed." << endl;