/* Program start time, and logfile start and end times */ void xml_timings(FILE *outf, Outchoices *od, Dateman *dman) { unsigned int year, month, day; XML_TRACE(0); code2date( dman->firsttime/1440, &day, &month, &year); XML_OUT( XMLDBG"<timespan from=\"%04d%02d%02d%02d%02d\" ", year, month+1, day, (int)((dman->firsttime%1440)/60), (int)(dman->firsttime%60) ); code2date( dman->lasttime/1440, &day, &month, &year); XML_OUT( "to=\"%04d%02d%02d%02d%02d\" days=\"%f\"/>", year, month+1, day, (int)((dman->lasttime%1440)/60), (int)(dman->lasttime%60), (dman->lasttime-dman->firsttime)/1440.0+0.005 ); }
/* The time period spanned by the report */ void xml_reportspan(FILE *outf, Outchoices *od, choice rep, timecode_t maxd, timecode_t mind) { unsigned int year, month, day; XML_TRACE(0); code2date( mind/1440, &day, &month, &year); XML_OUT( XMLDBG"<timespan from=\"%04d%02d%02d%02d%02d\" ", year, month+1, day, (int)((mind%1440)/60), (int)(mind%60) ); code2date( maxd/1440, &day, &month, &year); XML_OUT( "to=\"%04d%02d%02d%02d%02d\" days=\"%f\"/>", year, month+1, day, (int)((maxd%1440)/60), (int)(maxd%60), (maxd-mind)/1440.0+0.005 ); }
/* Stuff this output style needs in the page header */ void xml_stylehead(FILE *outf, Outchoices *od) { extern timecode_t starttimec; unsigned int year, month, day, i; struct tm temptime; char *xmlversion = "1.0"; char *encoding = "UTF-8"; time_t t; char buffer[256]; // borrow a copy of the outfile handle *outfp=outf; // KLUDGE!!!! opts=(Options*)((int)od-offsetof(Options,outopts)); t=time(0); strftime( buffer, 256, "%Y%m%d%H%M%S", gmtime(&t) ); XML_OUT("<?xml version=\"%s\" encoding=\"%s\" standalone=\"no\" ?>" XMLDBG "<!DOCTYPE analog-data PUBLIC \"::timian/analog-data::\" \"%s\">" XMLDBG "<analog-data version=\"%s\" timestamp=\"%s\">" XMLDBG "<analog>", xmlversion, encoding, od->xmldtd, VNUMBER, // VERSION instead? VERSION includes platform it was built. buffer ); // set up appropriate defaults for XML output. xml_defaults( opts ); // extract a build timestamp from __DATE__ and __TIME__ -- locale dependent?! need to force "C" locale ? strptime( __DATE__" "__TIME__, "%b%n%d%n%Y%n%T", &temptime ); sprintf( buffer, "%04d%02d%02d%02d%02d", temptime.tm_year+1900, temptime.tm_mon+1, temptime.tm_mday, temptime.tm_hour, temptime.tm_min ); code2date( starttimec/1440, &day, &month, &year); XML_OUT( XMLDBG "<property name=\"version\" content=\"%s\"/>", VERSION ); XML_OUT( XMLDBG "<property name=\"built\" content=\"%s\"/>", buffer ); XML_OUT( XMLDBG "<property name=\"starttime\" content=\"%04d%02d%02d%02d%02d\"/> ", year, month+1, day, (int)((starttimec%1440)/60), (int)(starttimec%60) ); // XML_OUT( XMLDBG "<property name=\"304issuccess\" content=\"%s\"/>", opts.succ304?"yes":"no" ); // XML_OUT( XMLDBG "<property name=\"logtimeoffset\" content=\"%d\"/>", stz ); i=i; // mustn't upset the compiler :-) }
/* "Last seven" explanation line */ void xml_lastseven(FILE *outf, Outchoices *od, timecode_t last7to) { unsigned int year, month, day; XML_TRACE(0); code2date( last7to/1440, &day, &month, &year); XML_OUT( XMLDBG "<!-- lastseven: %04d%02d%02d%02d%02d -->", year, month+1, day, (int)((last7to%1440)/60), (int)(last7to%60) ); }
/* "Busiest time period" line */ void xml_busyprintf(FILE *outf, Outchoices *od, choice rep, char *datefmt, unsigned long reqs, unsigned long pages, double bys, datecode_t date, unsigned int hr, unsigned int min, datecode_t newdate, unsigned int newhr, unsigned int newmin, char graphby) { unsigned int year, month, day; XML_TRACE(0); code2date( date, &day, &month, &year); XML_OUT( XMLDBG"<busiest time=\"%04d%02d%02d%02d%02d\" ", year, month+1, day, hr, min ); switch( graphby ) { case 'R': case 'r': XML_OUT( "reqs=\"%lu\"", reqs ); break; case 'P': case 'p': XML_OUT( "pages=\"%lu\"", pages ); break; case 'B': case 'b': XML_OUT( "bytes=\"%f\"", bys ); break; default: // what happens to busiest time when no graphby is set? assert(0); break; } XML_OUT( "/>" ); #if 0 extern unsigned int *rep2busystr; char **lngstr = od->lngstr; char sepchar = od->sepchar; unsigned int bmult; char *s; fprintf(outf, "%s %s (", lngstr[rep2busystr[rep]], datesprintf(od, datefmt, date, hr, min, newdate, newhr, newmin, TRUE, UNSET)); if (TOLOWER(graphby) == 'r') { f3printf(outf, od, (double)reqs, 0, sepchar); fprintf(outf, " %s).\n", (reqs == 1)?lngstr[request_]:lngstr[requests_]); } else if (TOLOWER(graphby) == 'p') { f3printf(outf, od, (double)pages, 0, sepchar); fprintf(outf, " %s).\n", (pages == 1)?lngstr[pagereq_]:lngstr[pagereqs_]); } else /* TOLOWER(graphby) == 'b' */ { if (od->rawbytes) bmult = 0; else bmult = findbmult(bys, od->bytesdp); printbytes(outf, od, bys, bmult, 0, sepchar); putc(' ', outf); if (bmult >= 1) { s = strchr(lngstr[xbytes_], '?'); /* checked in initialisation */ *s = '\0'; fprintf(outf, "%s%s%s).\n", lngstr[xbytes_], lngstr[byteprefix_ + bmult], s + 1); *s = '?'; } else fprintf(outf, "%s).\n", lngstr[bytes_]); } #endif }