/usr/include/eclib/reader.h is in libec-dev 20160101-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | // reader.h: class for reading curves from file/tty
//////////////////////////////////////////////////////////////////////////
//
// Copyright 1990-2012 John Cremona
//
// This file is part of the eclib package.
//
// eclib is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2 of the License, or (at your
// option) any later version.
//
// eclib is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License
// along with eclib; if not, write to the Free Software Foundation,
// Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
//
//////////////////////////////////////////////////////////////////////////
#include <fstream>
#include <cstring> // for gcc >= 4.3
#define TTY "/dev/tty"
class CurveReader {
private:
int tty_input;
ifstream in;
public:
CurveReader()
{
tty_input=0;
string filename;
cerr << "Enter a filename for curve input (or tty): ";
cin >> filename;
cerr<<"filename entered is "<<filename<<endl;
tty_input = (filename==string("tty"));
if(tty_input)
cerr<<"Taking input from terminal"<<endl;
else
{
cerr<<"using filename "<<filename<<endl;
in.open(filename.c_str());
if(!in)
{
cerr<<"Failed to open input file "<<filename<<endl;
exit(1);
}
}
}
~CurveReader() {if(!tty_input) in.close();}
int operator>>(Curve& c)
{
if(tty_input)
{
cerr<<"Enter a curve (null to exit): "<<flush;
cin>>ws; if(cin.eof()) {cerr<<endl; return 0;}
cin>>c;
}
else
{
in>>ws; if(in.eof()) return 0;
in >> c;
}
return !c.isnull();
}
};
|