--- x10events.cc.ORIG 2005-11-21 16:27:19.000000000 -0500 +++ x10events.cc 2005-12-07 14:10:58.000000000 -0500 @@ -40,29 +40,29 @@ // 29 16 * * * /usr/local/bin/heyu turn office on # set 0.1 // 12 00 * * * /usr/local/bin/heyu turn office off # abs 00:30 0.5 -#include -#include -#include +#include +#include +#include #include #include #include #include -#include +#include #include "ephem.h" -void print_modifed(ostream *out, int minute, int hour, +void print_modifed(std::ostream *out, int minute, int hour, char* day, char* month, char* dow, char* command, char* tag, double fmean, char* mean, double fvar, char* var) { out->width(2); out->fill('0'); - out->setf(ios::right); + out->setf(std::ios::right); (*out) << minute << " "; out->width(2); out->fill('0'); - out->setf(ios::right); + out->setf(std::ios::right); (*out) << hour << " "; (*out) << day; @@ -72,7 +72,7 @@ (*out) << tag; if (fmean!=0.0 || fvar!=0.0) (*out) << " " << mean; if (fvar!=0.0) (*out) << " " << var; - (*out) << endl; + (*out) << std::endl; } double wrap(double time) @@ -121,21 +121,18 @@ void usage() { - cerr << "usage: x10events"; - cerr << " [crontab_file]"; - cerr << " [lat(deg) long(deg) zone(hrs)]"; - cerr << endl; + std::cerr << "usage: x10events"; + std::cerr << " [crontab_file]"; + std::cerr << " [lat(deg) long(deg) zone(hrs)]"; + std::cerr << std::endl; exit(1); } int main (int argc, char *argv[]) { - // this is stupid, but dynamic ostrstream doesnt seem to work - // properly on large strings - arggg!! JAVAJAVAJAVAJAVA - char *outbuf = new char[1000000]; - ostrstream out(outbuf, 1000000); + std::ostringstream out; - istream *in = &cin; + std::istream *in = &std::cin; char *filename = (char*)NULL; double latitude = 41.196013; @@ -160,10 +157,10 @@ if ((argc==2) || (argc==5)) { filename = argv[arg]; - ifstream* fin = new ifstream(filename); + std::ifstream* fin = new std::ifstream(filename); if (!fin->is_open()) { - cerr << "non-existant input file" << endl; + std::cerr << "non-existant input file" << std::endl; usage(); } in = fin; @@ -235,7 +232,7 @@ in->getline(buf, buflen, '\n'); if (buf[0] == '#') { - out << buf << endl; + out << buf << std::endl; } else { @@ -305,13 +302,13 @@ if (filename == (char*) NULL) { - cout << out.str(); + std::cout << out.str(); } else { - ((ifstream*) in)->close(); + ((std::ifstream*) in)->close(); sleep(2); // wait a bit so cron doesn't think the file is unchanged - ofstream fout(filename, ios::out | ios::trunc); + std::ofstream fout(filename, std::ios::out | std::ios::trunc); fout << out.str(); fout.close(); }