#include <time.h> #ifndef NONAMESPACE #include <iostream> using namespace std; #else #include <iostream.h> #endif #include <string> #include "timestamp.h" #define DEFUSAGE false #define DEFDETAIL false #define DEFLOGFILE "log" #define DEFBEGIN "1990/01/01 00:00:00" #define DEFEND "2029/12/31 23:59:59" int ParseArgs( int argc, char **argv, bool *usage, bool *detail, time_t *begints, time_t *endts, string *p4logfile ) { string name; string value; int iscan; int rc; *usage = DEFUSAGE; *detail = DEFDETAIL; str2time( DEFBEGIN, begints ); str2time( DEFEND, endts ); *p4logfile = DEFLOGFILE; argc--; argv++; while( argc ) { name = *argv; if( ( iscan = name.find( "=" ) ) != name.npos ) { value = name.substr( iscan + 1 ); name.erase( iscan ); } else { value.erase(); } if( name == "--help" || name == "-h" ) { *usage = true; } else if( name == "--detail" ) { *detail = true; } else if( name == "--begin" ) { if( !value.empty() ) if( rc = str2time( value, begints ) ) { cout << "Invalid begin time!\n"; return rc; } } else if( name == "--end" ) { if( !value.empty() ) if( rc = str2time( value, endts ) ) { cout << "Invalid end time!\n"; return rc; } } else { *p4logfile = *argv; } argc--; argv++; } return 0; } int PrintArgs( bool detail, time_t begints, time_t endts, string p4logfile ) { string tsstr; cout << "Printing detail: "; if( detail ) cout << "yes\n"; else cout << "no\n"; time2str( begints, &tsstr ); cout << "Begin time: " << tsstr << "\n"; time2str( endts, &tsstr ); cout << "End time: " << tsstr << "\n"; cout << "p4d server log: " << p4logfile << "\n"; return 0; }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#2 | 1722 | Michael Shields |
p4loga builds for freebsd4 (play), hpux11 (hell), linux24x86 (duey), and solaris26 (shucks). A bit of porting was required for the hpux11 build (aCC as configured on hell isn't quite up to speed with respect to namespaces). |
||
#1 | 1610 | Michael Shields |
Adding p4d log analyzer concocted by myself. Compiles and executes on Red Hat 6.0, 7.0, and probably a few other operating systems with perhaps a little help. Still needs comments. |