#include #include #include #include "user_log.c++.h" #include "file_lock.h" void usage(char* myname, FILE* puthere) { fprintf(puthere, "Usage: %s LOGFILE\n", myname); fprintf(puthere, " LOGFILE Read from this logfile\n"); } int main(int argc, char* argv[]) { char* logfile = argv[1]; // check arguments if( !logfile ) { usage(argv[0], stderr); return 1; } if( !strncmp(logfile, "-h", 2) || !strcmp(logfile, "--help") ) { usage(argv[0], stdout); return 0; } int done; ReadUserLog rul(logfile); ULogEvent* e = NULL; done = 0; while( !done ) { ULogEventOutcome outcome = rul.readEvent(e); cout << ULogEventOutcomeNames[outcome]; switch( outcome ) { case ULOG_NO_EVENT: case ULOG_RD_ERROR: case ULOG_UNK_ERROR: done = 1; cout << endl; break; case ULOG_OK: cout << " " << ULogEventNumberNames[e->eventNumber] << endl; switch(e->eventNumber) { case ULOG_SUBMIT: { SubmitEvent *submitEvent = (SubmitEvent *)e; cout << "This job was successfully submitted at "; cout << asctime(&submitEvent->eventTime); cout << " from host " << submitEvent->submitHost; cout << endl; } break; default: break; } break; default: cout << "Eek, shouldn't get here" << endl; break; } } }