* 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

@ -10,6 +10,8 @@ NEW the chi^2 calculation in single-histogram and asymmetry fits is parallelized
if musrfit is built using a compiler supporting OpenMP (e.g. GCC >= 4.2) if musrfit is built using a compiler supporting OpenMP (e.g. GCC >= 4.2)
Using --disable-omp this feature can be disabled on the configure level. Using --disable-omp this feature can be disabled on the configure level.
NEW any2many: force the user to define the exact NeXus ouput format (HDF4,HDF5,XML) NEW any2many: force the user to define the exact NeXus ouput format (HDF4,HDF5,XML)
FIXED a linking problem when only shared libraries are built on Cygwin
FIXED the problem that in certain environments XML files could not be parsed (MUSR-122)
FIXED crash of musrview in case the XML startup file is present but cannot be parsed correctly FIXED crash of musrview in case the XML startup file is present but cannot be parsed correctly
FIXED crash in case a non-existing userFcn is called from an existing library (MUSR-159) FIXED crash in case a non-existing userFcn is called from an existing library (MUSR-159)
FIXED slightly wrong chisq since the 0-bin entries were treated wrongly for scaled N0/Bkg data (MUSR-193) FIXED slightly wrong chisq since the 0-bin entries were treated wrongly for scaled N0/Bkg data (MUSR-193)

View File

@ -418,6 +418,9 @@ int main(int argc, char *argv[])
} }
// read startup file // read startup file
fstream xmlFile;
unsigned int xmlSize = 0;
char *xmlBuffer = 0;
char startup_path_name[128]; char startup_path_name[128];
TSAXParser *saxParser = new TSAXParser(); TSAXParser *saxParser = new TSAXParser();
PStartupHandler *startupHandler = new PStartupHandler(); PStartupHandler *startupHandler = new PStartupHandler();
@ -436,7 +439,23 @@ int main(int argc, char *argv[])
} else { } else {
strcpy(startup_path_name, startupHandler->GetStartupFilePath().Data()); strcpy(startup_path_name, startupHandler->GetStartupFilePath().Data());
saxParser->ConnectToHandler("PStartupHandler", startupHandler); saxParser->ConnectToHandler("PStartupHandler", startupHandler);
status = saxParser->ParseFile(startup_path_name); //status = saxParser->ParseFile(startup_path_name);
// 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, 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 = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer
delete[] xmlBuffer; // free the buffer memory
xmlBuffer = 0;
}
// check for parse errors // check for parse errors
if (status) { // error if (status) { // error
cerr << endl << ">> any2many **WARNING** Reading/parsing musrfit_startup.xml failed."; cerr << endl << ">> any2many **WARNING** Reading/parsing musrfit_startup.xml failed.";

View File

@ -89,7 +89,7 @@ CLEANFILES = *Dict.cpp *Dict.h *~ core
lib_LTLIBRARIES = libPMusr.la libPUserFcnBase.la lib_LTLIBRARIES = libPMusr.la libPUserFcnBase.la
libPMusr_la_SOURCES = $(h_sources) $(cpp_sources) $(dict_h_sources) $(dict_cpp_sources) 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) 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) 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() int PMsr2Data::ParseXmlStartupFile()
{ {
fstream xmlFile;
unsigned int xmlSize = 0;
char *xmlBuffer = 0;
int status; int status;
fSaxParser = new TSAXParser(); fSaxParser = new TSAXParser();
fStartupHandler = new PStartupHandler(); fStartupHandler = new PStartupHandler();
string startup_path_name(fStartupHandler->GetStartupFilePath().Data()); string startup_path_name(fStartupHandler->GetStartupFilePath().Data());
fSaxParser->ConnectToHandler("PStartupHandler", fStartupHandler); 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 // check for parse errors
if (status) { // error if (status) { // error
cerr << endl << ">> msr2data: **WARNING** Reading/parsing musrfit_startup.xml failed." << endl; cerr << endl << ">> msr2data: **WARNING** Reading/parsing musrfit_startup.xml failed." << endl;

View File

@ -33,6 +33,7 @@
#include <cmath> #include <cmath>
#include <iostream> #include <iostream>
#include <fstream>
using namespace std; using namespace std;
#include <TSAXParser.h> #include <TSAXParser.h>
@ -64,10 +65,30 @@ PMagProximityFitterGlobal::PMagProximityFitterGlobal()
PMPStartupHandler *fStartupHandler = new PMPStartupHandler(); PMPStartupHandler *fStartupHandler = new PMPStartupHandler();
strcpy(startup_path_name, fStartupHandler->GetStartupFilePath().Data()); strcpy(startup_path_name, fStartupHandler->GetStartupFilePath().Data());
saxParser->ConnectToHandler("PMPStartupHandler", fStartupHandler); saxParser->ConnectToHandler("PMPStartupHandler", fStartupHandler);
Int_t status = saxParser->ParseFile(startup_path_name); //Int_t status = saxParser->ParseFile(startup_path_name);
// parsing the file as above seems to lead to problems in certain environments; try working around through a buffer as follows
fstream xmlFile;
unsigned int xmlSize = 0;
char *xmlBuffer = 0;
xmlFile.open(startup_path_name, 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
}
Int_t status;
if (!xmlBuffer) { // file has not been read into the buffer
status = 1;
} else {
status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer
delete[] xmlBuffer; // free the buffer memory
xmlBuffer = 0;
}
// check for parse errors // check for parse errors
if (status) { // error if (status) { // error
cout << endl << ">> PMagProximityFitterGlobal::PMagProximityFitterGlobal: **WARNING** reading/parsing mag_proximity_startup.xml."; cout << endl << ">> PMagProximityFitterGlobal::PMagProximityFitterGlobal: **WARNING** Reading/parsing mag_proximity_startup.xml failed.";
cout << endl; cout << endl;
fValid = false; fValid = false;
} }

View File

@ -33,6 +33,7 @@
#include <cmath> #include <cmath>
#include <iostream> #include <iostream>
#include <fstream>
using namespace std; using namespace std;
#include <TSAXParser.h> #include <TSAXParser.h>
@ -63,10 +64,30 @@ PNL_PippardFitterGlobal::PNL_PippardFitterGlobal()
PNL_StartupHandler *fStartupHandler = new PNL_StartupHandler(); PNL_StartupHandler *fStartupHandler = new PNL_StartupHandler();
strcpy(startup_path_name, fStartupHandler->GetStartupFilePath().Data()); strcpy(startup_path_name, fStartupHandler->GetStartupFilePath().Data());
saxParser->ConnectToHandler("PNL_StartupHandler", fStartupHandler); saxParser->ConnectToHandler("PNL_StartupHandler", fStartupHandler);
Int_t status = saxParser->ParseFile(startup_path_name); //Int_t status = saxParser->ParseFile(startup_path_name);
// parsing the file as above seems to lead to problems in certain environments; try working around through a buffer as follows
fstream xmlFile;
unsigned int xmlSize = 0;
char *xmlBuffer = 0;
xmlFile.open(startup_path_name, 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
}
Int_t status;
if (!xmlBuffer) { // file has not been read into the buffer
status = 1;
} else {
status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer
delete[] xmlBuffer; // free the buffer memory
xmlBuffer = 0;
}
// check for parse errors // check for parse errors
if (status) { // error if (status) { // error
cout << endl << ">> PNL_PippardFitterGlobal::PNL_PippardFitterGlobal: **WARNING** reading/parsing nonlocal_startup.xml."; cout << endl << ">> PNL_PippardFitterGlobal::PNL_PippardFitterGlobal: **WARNING** Reading/parsing nonlocal_startup.xml failed.";
cout << endl; cout << endl;
fValid = false; fValid = false;
} }

View File

@ -30,6 +30,7 @@
#include "TLondon1D.h" #include "TLondon1D.h"
#include <iostream> #include <iostream>
#include <fstream>
#include <cassert> #include <cassert>
#include <cmath> #include <cmath>
using namespace std; using namespace std;
@ -153,7 +154,27 @@ TLondon1DHS::TLondon1DHS() : fCalcNeeded(true), fFirstCall(true) {
TSAXParser *saxParser = new TSAXParser(); TSAXParser *saxParser = new TSAXParser();
BMWStartupHandler *startupHandler = new BMWStartupHandler(); BMWStartupHandler *startupHandler = new BMWStartupHandler();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler); saxParser->ConnectToHandler("BMWStartupHandler", startupHandler);
int status (saxParser->ParseFile(startup_path_name.c_str())); //int status (saxParser->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
fstream xmlFile;
unsigned int xmlSize = 0;
char *xmlBuffer = 0;
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
}
int status;
if (!xmlBuffer) { // file has not been read into the buffer
status = 1;
} else {
status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer
delete[] xmlBuffer; // free the buffer memory
xmlBuffer = 0;
}
// check for parse errors // check for parse errors
if (status) { // error if (status) { // error
cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \ cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
@ -301,7 +322,27 @@ TLondon1D1L::TLondon1D1L() : fCalcNeeded(true), fFirstCall(true) {
TSAXParser *saxParser = new TSAXParser(); TSAXParser *saxParser = new TSAXParser();
BMWStartupHandler *startupHandler = new BMWStartupHandler(); BMWStartupHandler *startupHandler = new BMWStartupHandler();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler); saxParser->ConnectToHandler("BMWStartupHandler", startupHandler);
int status (saxParser->ParseFile(startup_path_name.c_str())); //int status (saxParser->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
fstream xmlFile;
unsigned int xmlSize = 0;
char *xmlBuffer = 0;
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
}
int status;
if (!xmlBuffer) { // file has not been read into the buffer
status = 1;
} else {
status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer
delete[] xmlBuffer; // free the buffer memory
xmlBuffer = 0;
}
// check for parse errors // check for parse errors
if (status) { // error if (status) { // error
cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \ cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
@ -484,7 +525,27 @@ TLondon1D2L::TLondon1D2L() : fCalcNeeded(true), fFirstCall(true) {
TSAXParser *saxParser = new TSAXParser(); TSAXParser *saxParser = new TSAXParser();
BMWStartupHandler *startupHandler = new BMWStartupHandler(); BMWStartupHandler *startupHandler = new BMWStartupHandler();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler); saxParser->ConnectToHandler("BMWStartupHandler", startupHandler);
int status (saxParser->ParseFile(startup_path_name.c_str())); //int status (saxParser->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
fstream xmlFile;
unsigned int xmlSize = 0;
char *xmlBuffer = 0;
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
}
int status;
if (!xmlBuffer) { // file has not been read into the buffer
status = 1;
} else {
status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer
delete[] xmlBuffer; // free the buffer memory
xmlBuffer = 0;
}
// check for parse errors // check for parse errors
if (status) { // error if (status) { // error
cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \ cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
@ -654,7 +715,27 @@ TProximity1D1LHS::TProximity1D1LHS() : fCalcNeeded(true), fFirstCall(true) {
TSAXParser *saxParser = new TSAXParser(); TSAXParser *saxParser = new TSAXParser();
BMWStartupHandler *startupHandler = new BMWStartupHandler(); BMWStartupHandler *startupHandler = new BMWStartupHandler();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler); saxParser->ConnectToHandler("BMWStartupHandler", startupHandler);
int status (saxParser->ParseFile(startup_path_name.c_str())); //int status (saxParser->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
fstream xmlFile;
unsigned int xmlSize = 0;
char *xmlBuffer = 0;
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
}
int status;
if (!xmlBuffer) { // file has not been read into the buffer
status = 1;
} else {
status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer
delete[] xmlBuffer; // free the buffer memory
xmlBuffer = 0;
}
// check for parse errors // check for parse errors
if (status) { // error if (status) { // error
cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \ cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
@ -801,7 +882,27 @@ TLondon1D3L::TLondon1D3L() : fCalcNeeded(true), fFirstCall(true) {
TSAXParser *saxParser = new TSAXParser(); TSAXParser *saxParser = new TSAXParser();
BMWStartupHandler *startupHandler = new BMWStartupHandler(); BMWStartupHandler *startupHandler = new BMWStartupHandler();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler); saxParser->ConnectToHandler("BMWStartupHandler", startupHandler);
int status (saxParser->ParseFile(startup_path_name.c_str())); //int status (saxParser->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
fstream xmlFile;
unsigned int xmlSize = 0;
char *xmlBuffer = 0;
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
}
int status;
if (!xmlBuffer) { // file has not been read into the buffer
status = 1;
} else {
status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer
delete[] xmlBuffer; // free the buffer memory
xmlBuffer = 0;
}
// check for parse errors // check for parse errors
if (status) { // error if (status) { // error
cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \ cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
@ -970,7 +1071,27 @@ TLondon1D3LS::TLondon1D3LS() : fCalcNeeded(true), fFirstCall(true) {
TSAXParser *saxParser = new TSAXParser(); TSAXParser *saxParser = new TSAXParser();
BMWStartupHandler *startupHandler = new BMWStartupHandler(); BMWStartupHandler *startupHandler = new BMWStartupHandler();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler); saxParser->ConnectToHandler("BMWStartupHandler", startupHandler);
int status (saxParser->ParseFile(startup_path_name.c_str())); //int status (saxParser->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
fstream xmlFile;
unsigned int xmlSize = 0;
char *xmlBuffer = 0;
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
}
int status;
if (!xmlBuffer) { // file has not been read into the buffer
status = 1;
} else {
status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer
delete[] xmlBuffer; // free the buffer memory
xmlBuffer = 0;
}
// check for parse errors // check for parse errors
if (status) { // error if (status) { // error
cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \ cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
@ -1139,7 +1260,27 @@ double TLondon1D3LS::operator()(double t, const vector<double> &par) const {
// TSAXParser *saxParser = new TSAXParser(); // TSAXParser *saxParser = new TSAXParser();
// BMWStartupHandler *startupHandler = new BMWStartupHandler(); // BMWStartupHandler *startupHandler = new BMWStartupHandler();
// saxParser->ConnectToHandler("BMWStartupHandler", startupHandler); // saxParser->ConnectToHandler("BMWStartupHandler", startupHandler);
// int status (saxParser->ParseFile(startup_path_name.c_str())); // //int status (saxParser->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
// fstream xmlFile;
// unsigned int xmlSize = 0;
// char *xmlBuffer = 0;
// 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
// }
// int status;
// if (!xmlBuffer) { // file has not been read into the buffer
// status = 1;
// } else {
// status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer
// delete[] xmlBuffer; // free the buffer memory
// xmlBuffer = 0;
// }
// // check for parse errors // // check for parse errors
// if (status) { // error // if (status) { // error
// cout << endl << "**WARNING** Reading/parsing " << startup_path_name << " failed." << endl; // cout << endl << "**WARNING** Reading/parsing " << startup_path_name << " failed." << endl;

View File

@ -30,6 +30,7 @@
#include "TVortex.h" #include "TVortex.h"
#include <iostream> #include <iostream>
#include <fstream>
#include <cassert> #include <cassert>
#include <cmath> #include <cmath>
using namespace std; using namespace std;
@ -165,7 +166,27 @@ TBulkTriVortexLondon::TBulkTriVortexLondon() : fCalcNeeded(true), fFirstCall(tru
TSAXParser *saxParser = new TSAXParser(); TSAXParser *saxParser = new TSAXParser();
BMWStartupHandler *startupHandler = new BMWStartupHandler(); BMWStartupHandler *startupHandler = new BMWStartupHandler();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler); saxParser->ConnectToHandler("BMWStartupHandler", startupHandler);
int status (saxParser->ParseFile(startup_path_name.c_str())); //int status (saxParser->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
fstream xmlFile;
unsigned int xmlSize = 0;
char *xmlBuffer = 0;
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
}
int status;
if (!xmlBuffer) { // file has not been read into the buffer
status = 1;
} else {
status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer
delete[] xmlBuffer; // free the buffer memory
xmlBuffer = 0;
}
// check for parse errors // check for parse errors
if (status) { // error if (status) { // error
cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \ cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
@ -222,7 +243,27 @@ TBulkSqVortexLondon::TBulkSqVortexLondon() : fCalcNeeded(true), fFirstCall(true)
TSAXParser *saxParser = new TSAXParser(); TSAXParser *saxParser = new TSAXParser();
BMWStartupHandler *startupHandler = new BMWStartupHandler(); BMWStartupHandler *startupHandler = new BMWStartupHandler();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler); saxParser->ConnectToHandler("BMWStartupHandler", startupHandler);
int status (saxParser->ParseFile(startup_path_name.c_str())); //int status (saxParser->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
fstream xmlFile;
unsigned int xmlSize = 0;
char *xmlBuffer = 0;
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
}
int status;
if (!xmlBuffer) { // file has not been read into the buffer
status = 1;
} else {
status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer
delete[] xmlBuffer; // free the buffer memory
xmlBuffer = 0;
}
// check for parse errors // check for parse errors
if (status) { // error if (status) { // error
cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \ cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
@ -449,7 +490,27 @@ TBulkTriVortexML::TBulkTriVortexML() : fCalcNeeded(true), fFirstCall(true) {
TSAXParser *saxParser = new TSAXParser(); TSAXParser *saxParser = new TSAXParser();
BMWStartupHandler *startupHandler = new BMWStartupHandler(); BMWStartupHandler *startupHandler = new BMWStartupHandler();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler); saxParser->ConnectToHandler("BMWStartupHandler", startupHandler);
int status (saxParser->ParseFile(startup_path_name.c_str())); //int status (saxParser->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
fstream xmlFile;
unsigned int xmlSize = 0;
char *xmlBuffer = 0;
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
}
int status;
if (!xmlBuffer) { // file has not been read into the buffer
status = 1;
} else {
status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer
delete[] xmlBuffer; // free the buffer memory
xmlBuffer = 0;
}
// check for parse errors // check for parse errors
if (status) { // error if (status) { // error
cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \ cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
@ -585,7 +646,27 @@ TBulkTriVortexAGL::TBulkTriVortexAGL() : fCalcNeeded(true), fFirstCall(true) {
TSAXParser *saxParser = new TSAXParser(); TSAXParser *saxParser = new TSAXParser();
BMWStartupHandler *startupHandler = new BMWStartupHandler(); BMWStartupHandler *startupHandler = new BMWStartupHandler();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler); saxParser->ConnectToHandler("BMWStartupHandler", startupHandler);
int status (saxParser->ParseFile(startup_path_name.c_str())); //int status (saxParser->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
fstream xmlFile;
unsigned int xmlSize = 0;
char *xmlBuffer = 0;
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
}
int status;
if (!xmlBuffer) { // file has not been read into the buffer
status = 1;
} else {
status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer
delete[] xmlBuffer; // free the buffer memory
xmlBuffer = 0;
}
// check for parse errors // check for parse errors
if (status) { // error if (status) { // error
cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \ cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
@ -720,7 +801,27 @@ TBulkTriVortexAGLII::TBulkTriVortexAGLII() : fCalcNeeded(true), fFirstCall(true)
TSAXParser *saxParser = new TSAXParser(); TSAXParser *saxParser = new TSAXParser();
BMWStartupHandler *startupHandler = new BMWStartupHandler(); BMWStartupHandler *startupHandler = new BMWStartupHandler();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler); saxParser->ConnectToHandler("BMWStartupHandler", startupHandler);
int status (saxParser->ParseFile(startup_path_name.c_str())); //int status (saxParser->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
fstream xmlFile;
unsigned int xmlSize = 0;
char *xmlBuffer = 0;
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
}
int status;
if (!xmlBuffer) { // file has not been read into the buffer
status = 1;
} else {
status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer
delete[] xmlBuffer; // free the buffer memory
xmlBuffer = 0;
}
// check for parse errors // check for parse errors
if (status) { // error if (status) { // error
cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \ cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
@ -868,7 +969,27 @@ TBulkTriVortexNGL::TBulkTriVortexNGL() : fCalcNeeded(true), fFirstCall(true) {
TSAXParser *saxParser = new TSAXParser(); TSAXParser *saxParser = new TSAXParser();
BMWStartupHandler *startupHandler = new BMWStartupHandler(); BMWStartupHandler *startupHandler = new BMWStartupHandler();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler); saxParser->ConnectToHandler("BMWStartupHandler", startupHandler);
int status (saxParser->ParseFile(startup_path_name.c_str())); //int status (saxParser->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
fstream xmlFile;
unsigned int xmlSize = 0;
char *xmlBuffer = 0;
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
}
int status;
if (!xmlBuffer) { // file has not been read into the buffer
status = 1;
} else {
status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer
delete[] xmlBuffer; // free the buffer memory
xmlBuffer = 0;
}
// check for parse errors // check for parse errors
if (status) { // error if (status) { // error
cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \ cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
@ -1020,7 +1141,27 @@ TBulkAnisotropicTriVortexLondonGlobal::TBulkAnisotropicTriVortexLondonGlobal() :
TSAXParser *saxParser = new TSAXParser(); TSAXParser *saxParser = new TSAXParser();
BMWStartupHandler *startupHandler = new BMWStartupHandler(); BMWStartupHandler *startupHandler = new BMWStartupHandler();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler); saxParser->ConnectToHandler("BMWStartupHandler", startupHandler);
int status (saxParser->ParseFile(startup_path_name.c_str())); //int status (saxParser->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
fstream xmlFile;
unsigned int xmlSize = 0;
char *xmlBuffer = 0;
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
}
int status;
if (!xmlBuffer) { // file has not been read into the buffer
status = 1;
} else {
status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer
delete[] xmlBuffer; // free the buffer memory
xmlBuffer = 0;
}
// check for parse errors // check for parse errors
if (status) { // error if (status) { // error
cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \ cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
@ -1259,7 +1400,27 @@ TBulkAnisotropicTriVortexMLGlobal::TBulkAnisotropicTriVortexMLGlobal() : fCalcNe
TSAXParser *saxParser = new TSAXParser(); TSAXParser *saxParser = new TSAXParser();
BMWStartupHandler *startupHandler = new BMWStartupHandler(); BMWStartupHandler *startupHandler = new BMWStartupHandler();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler); saxParser->ConnectToHandler("BMWStartupHandler", startupHandler);
int status (saxParser->ParseFile(startup_path_name.c_str())); //int status (saxParser->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
fstream xmlFile;
unsigned int xmlSize = 0;
char *xmlBuffer = 0;
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
}
int status;
if (!xmlBuffer) { // file has not been read into the buffer
status = 1;
} else {
status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer
delete[] xmlBuffer; // free the buffer memory
xmlBuffer = 0;
}
// check for parse errors // check for parse errors
if (status) { // error if (status) { // error
cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \ cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
@ -1498,7 +1659,27 @@ TBulkAnisotropicTriVortexAGLGlobal::TBulkAnisotropicTriVortexAGLGlobal() : fCalc
TSAXParser *saxParser = new TSAXParser(); TSAXParser *saxParser = new TSAXParser();
BMWStartupHandler *startupHandler = new BMWStartupHandler(); BMWStartupHandler *startupHandler = new BMWStartupHandler();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler); saxParser->ConnectToHandler("BMWStartupHandler", startupHandler);
int status (saxParser->ParseFile(startup_path_name.c_str())); //int status (saxParser->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
fstream xmlFile;
unsigned int xmlSize = 0;
char *xmlBuffer = 0;
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
}
int status;
if (!xmlBuffer) { // file has not been read into the buffer
status = 1;
} else {
status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer
delete[] xmlBuffer; // free the buffer memory
xmlBuffer = 0;
}
// check for parse errors // check for parse errors
if (status) { // error if (status) { // error
cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \ cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \

View File

@ -35,6 +35,7 @@
#include <cassert> #include <cassert>
#include <sys/time.h> #include <sys/time.h>
#include <iostream> #include <iostream>
#include <fstream>
#include <cmath> #include <cmath>
#ifdef HAVE_GOMP #ifdef HAVE_GOMP
@ -201,7 +202,27 @@ TLFDynGssKT::TLFDynGssKT() : fCalcNeeded(true), fFirstCall(true), fCounter(0) {
TSAXParser *saxParser = new TSAXParser(); TSAXParser *saxParser = new TSAXParser();
BMWStartupHandler *startupHandler = new BMWStartupHandler(); BMWStartupHandler *startupHandler = new BMWStartupHandler();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler); saxParser->ConnectToHandler("BMWStartupHandler", startupHandler);
int status (saxParser->ParseFile(startup_path_name.c_str())); //int status (saxParser->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
fstream xmlFile;
unsigned int xmlSize = 0;
char *xmlBuffer = 0;
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
}
int status;
if (!xmlBuffer) { // file has not been read into the buffer
status = 1;
} else {
status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer
delete[] xmlBuffer; // free the buffer memory
xmlBuffer = 0;
}
// check for parse errors // check for parse errors
if (status) { // error if (status) { // error
cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \ cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
@ -523,7 +544,27 @@ TLFDynExpKT::TLFDynExpKT() : fCalcNeeded(true), fFirstCall(true), fCounter(0), f
TSAXParser *saxParser = new TSAXParser(); TSAXParser *saxParser = new TSAXParser();
BMWStartupHandler *startupHandler = new BMWStartupHandler(); BMWStartupHandler *startupHandler = new BMWStartupHandler();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler); saxParser->ConnectToHandler("BMWStartupHandler", startupHandler);
int status (saxParser->ParseFile(startup_path_name.c_str())); //int status (saxParser->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
fstream xmlFile;
unsigned int xmlSize = 0;
char *xmlBuffer = 0;
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
}
int status;
if (!xmlBuffer) { // file has not been read into the buffer
status = 1;
} else {
status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer
delete[] xmlBuffer; // free the buffer memory
xmlBuffer = 0;
}
// check for parse errors // check for parse errors
if (status) { // error if (status) { // error
cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \ cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \

View File

@ -424,6 +424,9 @@ int main(int argc, char *argv[])
} }
// read startup file // read startup file
fstream xmlFile;
unsigned int xmlSize = 0;
char *xmlBuffer = 0;
char startup_path_name[128]; char startup_path_name[128];
TSAXParser *saxParser = new TSAXParser(); TSAXParser *saxParser = new TSAXParser();
PStartupHandler *startupHandler = new PStartupHandler(); PStartupHandler *startupHandler = new PStartupHandler();
@ -442,7 +445,23 @@ int main(int argc, char *argv[])
} else { } else {
strcpy(startup_path_name, startupHandler->GetStartupFilePath().Data()); strcpy(startup_path_name, startupHandler->GetStartupFilePath().Data());
saxParser->ConnectToHandler("PStartupHandler", startupHandler); saxParser->ConnectToHandler("PStartupHandler", startupHandler);
status = saxParser->ParseFile(startup_path_name); //status = saxParser->ParseFile(startup_path_name);
// 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, 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 = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer
delete[] xmlBuffer; // free the buffer memory
xmlBuffer = 0;
}
// check for parse errors // check for parse errors
if (status) { // error if (status) { // error
cerr << endl << ">> musrfit **WARNING** Reading/parsing musrfit_startup.xml failed."; cerr << endl << ">> musrfit **WARNING** Reading/parsing musrfit_startup.xml failed.";

View File

@ -34,6 +34,7 @@
#include <string.h> #include <string.h>
#include <iostream> #include <iostream>
#include <fstream>
using namespace std; using namespace std;
#include <TApplication.h> #include <TApplication.h>
@ -275,6 +276,9 @@ Int_t main(Int_t argc, Char_t *argv[])
} }
// read startup file // read startup file
fstream xmlFile;
unsigned int xmlSize = 0;
char *xmlBuffer = 0;
Char_t startup_path_name[128]; Char_t startup_path_name[128];
TSAXParser *saxParser = new TSAXParser(); TSAXParser *saxParser = new TSAXParser();
PStartupHandler *startupHandler = new PStartupHandler(); PStartupHandler *startupHandler = new PStartupHandler();
@ -293,10 +297,26 @@ Int_t main(Int_t argc, Char_t *argv[])
} else { } else {
strcpy(startup_path_name, startupHandler->GetStartupFilePath().Data()); strcpy(startup_path_name, startupHandler->GetStartupFilePath().Data());
saxParser->ConnectToHandler("PStartupHandler", startupHandler); saxParser->ConnectToHandler("PStartupHandler", startupHandler);
status = saxParser->ParseFile(startup_path_name); //status = saxParser->ParseFile(startup_path_name);
// 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, 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 = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer
delete[] xmlBuffer; // free the buffer memory
xmlBuffer = 0;
}
// check for parse errors // check for parse errors
if (status) { // error if (status) { // error
cerr << endl << ">> musrt0 **WARNING** reading/parsing musrfit_startup.xml."; cerr << endl << ">> musrt0 **WARNING** Reading/parsing musrfit_startup.xml failed.";
cerr << endl; cerr << endl;
// clean up // clean up
if (saxParser) { if (saxParser) {

View File

@ -34,6 +34,7 @@
#include <string.h> #include <string.h>
#include <iostream> #include <iostream>
#include <fstream>
using namespace std; using namespace std;
#include <TApplication.h> #include <TApplication.h>
@ -158,6 +159,9 @@ int main(int argc, char *argv[])
} }
// read startup file // read startup file
fstream xmlFile;
unsigned int xmlSize = 0;
char *xmlBuffer = 0;
char startup_path_name[128]; char startup_path_name[128];
TSAXParser *saxParser = new TSAXParser(); TSAXParser *saxParser = new TSAXParser();
PStartupHandler *startupHandler = new PStartupHandler(); PStartupHandler *startupHandler = new PStartupHandler();
@ -176,7 +180,23 @@ int main(int argc, char *argv[])
} else { } else {
strcpy(startup_path_name, startupHandler->GetStartupFilePath().Data()); strcpy(startup_path_name, startupHandler->GetStartupFilePath().Data());
saxParser->ConnectToHandler("PStartupHandler", startupHandler); saxParser->ConnectToHandler("PStartupHandler", startupHandler);
status = saxParser->ParseFile(startup_path_name); //status = saxParser->ParseFile(startup_path_name);
// 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, 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 = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer
delete[] xmlBuffer; // free the buffer memory
xmlBuffer = 0;
}
// check for parse errors // check for parse errors
if (status) { // error if (status) { // error
cerr << endl << ">> musrview **WARNING** Reading/parsing musrfit_startup.xml failed."; cerr << endl << ">> musrview **WARNING** Reading/parsing musrfit_startup.xml failed.";