[mareframe] View of /trunk/gadget/runid.cc
View of /trunk/gadget/runid.cc
Parent Directory
| Revision Log
Revision 1 -
( download)
( annotate)
Mon Feb 10 17:09:07 2014 UTC
(10 years, 5 months ago)
by agomez
File size: 723 byte(s)
Initial version based on Gadget 2.2.00
#include "runid.h"
#include "gadget.h"
extern int gethostname(char*, int);
RunID::RunID() {
hostname = new char[MaxStrLength];
strncpy(hostname, "", MaxStrLength);
timestring = new char[MaxStrLength];
strncpy(timestring, "", MaxStrLength);
if (uname(&host) != -1)
strcpy(hostname, host.nodename);
if (time(&runtime))
strcpy(timestring, ctime(&runtime));
}
RunID::~RunID() {
delete[] hostname;
delete[] timestring;
}
void RunID::Print(ostream& o) {
o << "Gadget version " << GADGETVERSION << " running on " << hostname << sep << timestring;
o.flush();
}
void RunID::printTime(ostream& o) {
time_t stoptime;
o << difftime(time(&stoptime), runtime) << " seconds" << endl;
o.flush();
}
|