[mareframe] Annotation of /trunk/gadget/runid.cc
Annotation of /trunk/gadget/runid.cc
Parent Directory
| Revision Log
Revision 1 -
(view)
(download)
1 : |
agomez |
1 |
#include "runid.h" |
2 : |
|
|
#include "gadget.h" |
3 : |
|
|
|
4 : |
|
|
extern int gethostname(char*, int);
|
5 : |
|
|
|
6 : |
|
|
RunID::RunID() {
|
7 : |
|
|
hostname = new char[MaxStrLength];
|
8 : |
|
|
strncpy(hostname, "", MaxStrLength);
|
9 : |
|
|
timestring = new char[MaxStrLength];
|
10 : |
|
|
strncpy(timestring, "", MaxStrLength);
|
11 : |
|
|
|
12 : |
|
|
if (uname(&host) != -1)
|
13 : |
|
|
strcpy(hostname, host.nodename);
|
14 : |
|
|
if (time(&runtime))
|
15 : |
|
|
strcpy(timestring, ctime(&runtime));
|
16 : |
|
|
}
|
17 : |
|
|
|
18 : |
|
|
RunID::~RunID() {
|
19 : |
|
|
delete[] hostname;
|
20 : |
|
|
delete[] timestring;
|
21 : |
|
|
}
|
22 : |
|
|
|
23 : |
|
|
|
24 : |
|
|
void RunID::Print(ostream& o) {
|
25 : |
|
|
o << "Gadget version " << GADGETVERSION << " running on " << hostname << sep << timestring;
|
26 : |
|
|
o.flush();
|
27 : |
|
|
}
|
28 : |
|
|
|
29 : |
|
|
void RunID::printTime(ostream& o) {
|
30 : |
|
|
time_t stoptime;
|
31 : |
|
|
o << difftime(time(&stoptime), runtime) << " seconds" << endl;
|
32 : |
|
|
o.flush();
|
33 : |
|
|
}
|
|