Skip to content
Snippets Groups Projects
Commit e3a42e8e authored by Wuttke, Joachim's avatar Wuttke, Joachim Committed by Wuttke, Joachim
Browse files

Test whether Gnuplot supports X11.

parent 32e77712
No related branches found
No related tags found
No related merge requests found
......@@ -40,6 +40,13 @@ CPlot::CPlot( int _iPlot, bool _logx, bool _logy ) :
if (mkfifo( fn_fifo.c_str(), 0666 ))
throw "SYSTEM ERROR cannot make fifo "+fn_fifo+": will not be able to print";
// Check that Gnuplot supports X11.
string out = triv::system_read( "gnuplot -e 'help X11' 2>&1 < /dev/null" );
if ( out.substr(0,5)=="Sorry" || out.length()<80 ) {
cerr << "Gnuplot seems not to support X11\n";
exit(1);
}
// Start a Gnuplot that will read from our pipe.
triv::system( "gnuplot -title "+S(iPlot)+" -noraise < "+fn_fifo+"&" );
......
......@@ -40,6 +40,23 @@ void triv::system( string cmd, bool debug )
cout << "DEBUG system call -> return value " << ret << "\n";
}
//! Execute operation system call, and return its stdout.
string triv::system_read( string cmd, bool debug )
{
if( debug )
cout << "DEBUG system call '" + cmd + "'\n";
FILE *f = ::popen( cmd.c_str(), "r" );
string ret;
char buf[1024];
while( fgets( buf, 1024, f ) )
ret += buf;
pclose( f );
return ret;
}
//**************************************************************************//
//* file names, globbing *//
......
......@@ -11,14 +11,12 @@ namespace triv {
// Improved libc calls:
void system( string cmd, bool debug=false );
string system_read( string cmd, bool debug=false );
// File names, globbing:
bool file_exists( const string& fname );
void fname_divide( const string& fname, string *fdir,
string *fshort, string *fext);
void glob_file_list( const string& pattern,
const string& extension,
vector<string> *fnames );
void fname_divide( const string& fname, string *fdir, string *fshort, string *fext);
void glob_file_list( const string& pattern, const string& extension, vector<string> *fnames );
string wordexp_unique( const string& s );
string next_tmp_file( const string& path_format );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment