/*** analog 4.13 http://www.analog.cx/ ***/ /*** This program is copyright (c) Stephen R. E. Turner 1995 - 2000 except as *** stated otherwise. Distribution, usage and modification of this program is *** subject to the conditions of the Licence which you should have received *** with it. This program comes with no warranty, expressed or implied. ***/ /*** output2.c; subsiduary output functions ***/ #include "anlghea3.h" extern unsigned int *rep2lng; void pagetop(FILE *outf, Outchoices *od, Dateman *dman) { extern timecode_t starttimec; char *datestr; double t0; int t1, t2; if (od->cgi) { if (od->outstyle == HTML) fprintf(outf, "Content-Type: text/html; charset=%s\n\n", od->lngstr[charset_]); else fprintf(outf, "Content-Type: text/plain\n\n"); } if (od->outstyle == HTML) { fputs("\n", outf); fputs("\n
\n", outf); fprintf(outf, "\n", od->lngstr[charset_]); if (od->norobots) fputs("\n", outf); fprintf(outf, "\n", VERSION); fprintf(outf, "\n", outf);
fputs("outstyle, FALSE, od->imagedir, &(od->html), FALSE);
fputs("html2.gif\"\n", outf);
fputs("alt=\"HTML 2.0 Conformant!\">\n", outf);
}
if (od->outstyle == HTML)
fputs("\n\n", outf);
}
/* Print "goto"s. Assume outstyle == HTML and want-gotos already tested. */
void gotos(FILE *outf, int code, logical *repq, char **lngstr,
choice *reporder) {
extern char *anchorname[];
int i;
fprintf(outf, "
(%s", lngstr[goto_]); fprintf(outf, ": %s", lngstr[top_]); for (i = 0; reporder[i] != -1; i++) { if (reporder[i] == code) fprintf(outf, "%s %s", lngstr[colon_], lngstr[rep2lng[reporder[i]]]); else if (repq[reporder[i]]) fprintf(outf, "%s %s", lngstr[colon_], anchorname[reporder[i]], lngstr[rep2lng[reporder[i]]]); } fputs(")\n", outf); } void report_title(FILE *outf, char *name, int code, choice gotoq, logical *repq, char **lngstr, choice *reporder, choice outstyle) { extern char *anchorname[]; if (outstyle == HTML) { fprintf(outf, "
\n", outf); mprintf(outf, pagewidth, "%s (", lngstr[eachunit_]); if (ISLOWER(graphby) || outstyle != HTML) mprintf(outf, pagewidth, "%c", markchar); else mprintf(outf, pagewidth, "", imagedir, barstyle, markchar); mprintf(outf, pagewidth, ") %s ", lngstr[represents_]); if (graphby == 'R' || graphby == 'r') { ppcol += f3printf(outf, outstyle, unit, 0, sepchar); mprintf(outf, pagewidth, " "); if (unit == 1.) mprintf(outf, pagewidth, "%s.", lngstr[request_]); else mprintf(outf, pagewidth, "%s %s.", lngstr[requests_], lngstr[partof_]); } else if (graphby == 'P' || graphby == 'p') { ppcol += f3printf(outf, outstyle, unit, 0, sepchar); mprintf(outf, pagewidth, " "); if (unit == 1.) mprintf(outf, pagewidth, "%s.", lngstr[pagereq_]); else mprintf(outf, pagewidth, "%s %s.", lngstr[pagereqs_], lngstr[partof_]); } else { if (bmult > 0) { doublemprintf(outf, outstyle, pagewidth, unit, decpt); mprintf(outf, pagewidth, " "); mprintf(outf, pagewidth, "%c", byteprefix[bmult]); } else { ppcol += f3printf(outf, outstyle, unit, 0, sepchar); mprintf(outf, pagewidth, " "); } mprintf(outf, pagewidth, "%s %s.", lngstr[bytes_], lngstr[partof_]); } mprintf(outf, 0, NULL); } } void whatincluded(FILE *outf, choice rep, choice outstyle, unsigned long n, unsigned int pagewidth, Floor *floor, choice sortby, char decpt, char *compsep, char *gens, char *genp, char gender, choice requests, choice date, timecode_t firsttime, char **monthname, char **dayname, unsigned int monthlen, unsigned int daylen, char **lngstr) { extern unsigned int *method2sing, *method2pl, *method2date, *method2pc; extern unsigned int *method2relpc, *method2sort; extern char repcodes[]; int firsts, firstds, alls, sorted, alphsort, unsort; char *datestr; unsigned long temp = 0; timecode_t tempd; if (outstyle == HTML || outstyle == ASCII) { if (gender == 'm') { firsts = firstsm_; firstds = firstdsm_; alls = allsm_; sorted = sortedm_; alphsort = STREQ(gens, lngstr[codegs_])?numsortm_:alphasortm_; unsort = unsortedm_; /* quickest kludge for only one report */ } else if (gender == 'f') { firsts = firstsf_; firstds = firstdsf_; alls = allsf_; sorted = sortedf_; alphsort = STREQ(gens, lngstr[codegs_])?numsortf_:alphasortf_; unsort = unsortedf_; } else { /* gender == 'n' */ firsts = firstsn_; firstds = firstdsn_; alls = allsn_; sorted = sortedn_; alphsort = STREQ(gens, lngstr[codegs_])?numsortn_:alphasortn_; unsort = unsortedn_; } /* see also report_floor() in settings.c */ if (outstyle == HTML) fputs("
\n", outf);
if (floor->min < 0 && n < (unsigned long)(-floor->min + EPSILON))
floor->min = 0; /* not enough items for requested -ve floor */
if (floor->min < 0) {
temp = (unsigned long)(-floor->min + EPSILON);
if (temp == 1)
mprintf(outf, pagewidth, lngstr[firsts], gens);
else
mprintf(outf, pagewidth, lngstr[firstds], temp, genp);
mprintf(outf, pagewidth, " %s ", lngstr[floorby_]);
if (floor->floorby == REQUESTS)
mprintf(outf, pagewidth, lngstr[method2sort[requests]]);
else if (floor->floorby == DATESORT)
mprintf(outf, pagewidth, lngstr[method2sort[date]]);
else
mprintf(outf, pagewidth, lngstr[method2sort[floor->floorby]]);
}
else { /* floor->min >= 0 */
mprintf(outf, pagewidth, lngstr[alls], genp);
if (floor->floorby == DATESORT) {
tempd = (timecode_t)(floor->min + EPSILON);
if (tempd > firsttime) {
mprintf(outf, pagewidth, " %s ", lngstr[method2date[date]]);
datestr = (char *)xmalloc((size_t)datefmtlen(lngstr[whatincfmt_],
monthlen, daylen, NULL,
FALSE) + 1);
mprintf(outf, pagewidth,
datesprintf(datestr, lngstr[whatincfmt_], outstyle,
tempd / 1440, (tempd % 1440) / 60, tempd % 60,
0, 0, monthname, dayname, 0, 0, NULL, FALSE));
free((void *)datestr);
}
}
else if (floor->min > EPSILON) {
mprintf(outf, pagewidth, " %s ", lngstr[atleast_]);
if (floor->qual == '\0') {
temp = (unsigned long)(floor->min + EPSILON);
mprintf(outf, pagewidth, "%lu ", temp);
if (floor->floorby == REQUESTS)
mprintf(outf, pagewidth, (temp == 1)?lngstr[method2sing[requests]]:
lngstr[method2pl[requests]]);
else
mprintf(outf, pagewidth, (temp == 1)?
lngstr[method2sing[floor->floorby]]:
lngstr[method2pl[floor->floorby]]);
}
else { /* floor->qual != '\0' */
doublemprintf(outf, outstyle, pagewidth, floor->min, decpt);
if (floor->qual == '%') {
if (floor->floorby == REQUESTS)
mprintf(outf, pagewidth, lngstr[method2pc[requests]]);
else
mprintf(outf, pagewidth, lngstr[method2pc[floor->floorby]]);
}
else if (floor->qual == ':') {
if (floor->floorby == REQUESTS)
mprintf(outf, pagewidth, lngstr[method2relpc[requests]]);
else
mprintf(outf, pagewidth, lngstr[method2relpc[floor->floorby]]);
}
else { /* if qual is anything else, must be (k|M|G|T)bytes */
mprintf(outf, pagewidth, " ");
mprintf(outf, pagewidth, "%c%s", floor->qual, lngstr[bytes_]);
}
} /* end floor->qual != '\0' */
} /* end floor->min > EPSILON */
} /* end floor->min > 0 */
/* That completes the floor; now we are just left with the sortby */
if (floor->min >= 0 || temp != 1) { /* else only one item, so no sort */
if (floor->min < 0 && sortby == RANDOM)
sortby = floor->floorby;
mprintf(outf, pagewidth, ", ");
if (sortby == ALPHABETICAL)
mprintf(outf, pagewidth, lngstr[alphsort]);
else if (sortby == RANDOM)
mprintf(outf, pagewidth, lngstr[unsort]);
else {
mprintf(outf, pagewidth, lngstr[sorted]);
mprintf(outf, pagewidth, " ");
if (sortby == REQUESTS)
mprintf(outf, pagewidth, lngstr[method2sort[requests]]);
else if (sortby == DATESORT)
mprintf(outf, pagewidth, lngstr[method2sort[date]]);
else
mprintf(outf, pagewidth, lngstr[method2sort[sortby]]);
}
}
mprintf(outf, pagewidth, ".");
mprintf(outf, 0, NULL);
}
else { /* outstyle == COMPUTER */
fprintf(outf, "%c%sf%s", repcodes[rep], compsep, compsep);
if (floor->min < 0)
fprintf(outf, "-%lu", (unsigned long)(-floor->min + EPSILON));
else if (floor->floorby == DATESORT) {
datestr = (char *)xmalloc((size_t)datefmtlen("%Y%M%D:%H%n", monthlen,
daylen, NULL, TRUE) + 1);
tempd = (timecode_t)(floor->min + EPSILON);
fputs(datesprintf(datestr, "%Y%M%D:%H%n", outstyle, tempd / 1440,
(tempd % 1440) / 60, tempd % 60, 0, 0, monthname,
dayname, 0, 0, NULL, TRUE), outf);
free((void *)datestr);
}
else if (floor->qual == '\0')
fprintf(outf, "%lu", (unsigned long)(floor->min + EPSILON));
else
fprintf(outf, "%f", floor->min);
if (floor->qual != '\0')
putc(floor->qual, outf);
if (floor->floorby == REQUESTS)
putc('R', outf);
else if (floor->floorby == PAGES)
putc('P', outf);
else if (floor->floorby == BYTES)
putc('B', outf);
else /* floor->floorby == DATESORT */
putc('D', outf);
/* now the sortby */
if (floor->min < 0 && sortby == RANDOM)
sortby = floor->floorby;
fprintf(outf, "%s", compsep);
if (sortby == ALPHABETICAL)
putc('a', outf);
else if (sortby == BYTES)
putc('b', outf);
else if (sortby == DATESORT)
putc('d', outf);
else if (sortby == PAGES)
putc('p', outf);
else if (sortby == REQUESTS)
putc('r', outf);
else if (sortby == RANDOM)
putc('x', outf);
putc('\n', outf);
}
}
void busyprintf(FILE *outf, choice outstyle, char *datefmt,
unsigned long reqs, unsigned long pages, double bys,
datecode_t date, unsigned int hr, unsigned int min,
unsigned int newhr, unsigned int newmin, char graphby,
char sepchar, char decpt, logical rawbytes, char **lngstr,
char **monthname, char **dayname, unsigned int monthlen,
unsigned int daylen, char *busystr) {
extern char byteprefix[];
char *datestr;
unsigned int bmult;
if (outstyle == ASCII || outstyle == HTML) {
if (outstyle == ASCII)
putc('\n', outf);
datestr = (char *)xmalloc((size_t)datefmtlen(datefmt, monthlen, daylen,
NULL, FALSE) + 1);
fprintf(outf, "%s %s (", busystr,
datesprintf(datestr, datefmt, outstyle, date, hr, min,
(newmin == 0)?(hr + 1):hr, (unsigned int)newmin,
monthname, dayname, 0, 0, NULL, FALSE));
free((void *)datestr);
if (graphby == 'R' || graphby == 'r') {
f3printf(outf, outstyle, (double)reqs, 0, sepchar);
fprintf(outf, " %s).\n", (reqs == 1)?lngstr[request_]:lngstr[requests_]);
}
else if (graphby == 'P' || graphby == 'p') {
f3printf(outf, outstyle, (double)pages, 0, sepchar);
fprintf(outf, " %s).\n",
(pages == 1)?lngstr[pagereq_]:lngstr[pagereqs_]);
}
else /* graphby == 'B' or 'b' */ {
if (rawbytes)
bmult = 0;
else
bmult = findbmult(bys);
printbytes(outf, outstyle, bys, bmult, 0, sepchar, decpt);
putc(' ', outf);
if (bmult >= 1)
putc(byteprefix[bmult], outf);
fprintf(outf, "%s).\n", lngstr[bytes_]);
}
}
}
void pccol(FILE *outf, choice outstyle, double n, double tot,
unsigned int width, char decpt) {
double pc;
unsigned int pc1, pc2;
int i;
if (outstyle == COMPUTER)
fprintf(outf, "%.3f", (tot == 0)?0.0:(n * 100.0 / tot));
else {
for (i = 0; i < (int)width - 6; i++)
putc(' ', outf);
if (tot == 0)
pc = 0.0;
else
pc = n * 10000.0 / tot;
if (pc >= 9999.5)
fputs(" 100%", outf);
else if (pc < 0.5)
fputs(" ", outf);
else {
pc1 = ((int)(pc + 0.5)) / 100;
pc2 = ((int)(pc + 0.5)) % 100;
fprintf(outf, "%2d", pc1);
myputc(outf, decpt, outstyle);
fprintf(outf, "%02d%%", pc2);
}
}
}
void barchart(FILE *outf, choice outstyle, char graphby, unsigned long reqs,
unsigned long pages, double bys, double unit, char barstyle,
char markchar, char *imagedir) {
int i, j;
double x;
int y;
logical first = TRUE;
if (graphby == 'P' || graphby == 'p')
x = (double)pages - 0.5;
else if (graphby == 'R' || graphby == 'r')
x = (double)reqs - 0.5;
else
x = bys;
x /= unit;
x += 1;
y = (int)x;
if (ISLOWER(graphby) || outstyle != HTML) {
for (i = 0; i < y; i++)
myputc(outf, markchar, outstyle);
}
else {
for (j = 32; j >= 1; j /= 2) {
while (y >= j) {
fprintf(outf, "", outf);
y -= j;
}
}
}
}
void colheads(FILE *outf, choice *cols, choice outstyle, unsigned int width[],
unsigned int bmult, char *name, logical name1st, char **lngstr) {
extern unsigned int *col2colhead;
extern char byteprefix[];
int len;
unsigned int c, i;
if (outstyle == HTML || outstyle == ASCII) {
if (name1st)
fprintf(outf, "%*s: ", width[COL_TITLE] + strlen(name)
- htmlstrlen(name, outstyle), name);
for (c = 0; cols[c] != COL_NUMBER; c++) {
if (cols[c] == COL_BYTES) {
len = (int)htmlstrlen(lngstr[col2colhead[cols[c]]], outstyle) +
(int)(bmult != 0);
for (i = width[cols[c]] - len; i > 0; i--)
putc(' ', outf);
if (bmult != 0)
putc(byteprefix[bmult], outf);
fprintf(outf, "%s: ", lngstr[col2colhead[cols[c]]]);
}
else
fprintf(outf, "%*s: ", width[cols[c]]
+ strlen(lngstr[col2colhead[cols[c]]])
- htmlstrlen(lngstr[col2colhead[cols[c]]], outstyle),
lngstr[col2colhead[cols[c]]]);
}
if (!name1st)
fputs(name, outf);
putc('\n', outf);
if (name1st) {
for (i = 0; i < width[COL_TITLE]; i++)
putc('-', outf);
fputs(": ", outf);
}
for (c = 0; cols[c] != COL_NUMBER; c++) {
for (i = width[cols[c]] ; i > 0; i--)
putc('-', outf);
fputs(": ", outf);
}
if (!name1st)
matchlength(outf, outstyle, name, '-');
fputc('\n', outf);
}
}
void printcols(FILE *outf, choice rep, choice *cols, choice outstyle,
logical multibyte, unsigned long reqs, unsigned long pages,
double bys, long index, int level,
unsigned long totr, unsigned long totp, double totb,
unsigned int width[], unsigned int bmult, char graphby,
double unit, char barstyle, char markchar, char repsepchar,
char decpt, char *compsep, logical name1st, logical timegraph,
char *imagedir, logical *html, char *name, logical ispage,
unsigned int spaces, Alias *aliashead, Include *linkhead,
char *baseurl, char *datefmt, char *timefmt,
datecode_t date, unsigned int hr,
unsigned int min, unsigned int newhr, unsigned int newmin,
char **monthname, char **dayname, unsigned int monthlen,
unsigned int daylen, unsigned int plainmonthlen,
unsigned int plaindaylen) {
/* NB multibyte only used if name1st == FALSE; so not needed for time reps */
/* 'level' is -1 for time reports, 0 for other non-hierarchical reports
(although both are currently ignored). */
extern char *workspace; /* see top of alias.c */
extern char repcodes[];
static char *datestr = NULL;
static size_t len = 0, need;
int c, i;
if (outstyle == COMPUTER) {
fprintf(outf, "%c%s", repcodes[rep], compsep);
if (level >= 1)
putc('l', outf);
for (c = 0; cols[c] != COL_NUMBER; c++) {
switch(cols[c]) {
case COL_REQS:
putc('R', outf);
break;
case COL_PREQS:
putc('r', outf);
break;
case COL_PAGES:
putc('P', outf);
break;
case COL_PPAGES:
putc('p', outf);
break;
case COL_BYTES:
putc('B', outf);
break;
case COL_PBYTES:
putc('b', outf);
break;
case COL_DATE:
putc('d', outf);
break;
case COL_TIME:
putc('D', outf);
break;
case COL_INDEX:
putc('N', outf);
break;
}
}
fputs(compsep, outf);
}
else if (name1st) {
if (IS_EMPTY_STRING(name)) {
need = datefmtlen(datefmt, plainmonthlen, plaindaylen, NULL, FALSE) + 1;
ENSURE_LEN(datestr, len, need);
name = datesprintf(datestr, datefmt, outstyle, date, hr, min, newhr,
newmin, monthname, dayname, monthlen, daylen, NULL,
FALSE);
}
for (i = (int)width[COL_TITLE] - (int)htmlstrlen(name, outstyle); i > 0;
i--)
putc(' ', outf);
fprintf(outf, "%s: ", name);
}
if (outstyle == COMPUTER && level >= 1)
fprintf(outf, "%d%s", level, compsep);
for (c = 0; cols[c] != COL_NUMBER; c++) {
switch(cols[c]) {
case COL_REQS:
f3printf(outf, outstyle, (double)reqs, width[cols[c]], repsepchar);
break;
case COL_PREQS:
pccol(outf, outstyle, (double)reqs, (double)totr, width[cols[c]],
decpt);
break;
case COL_PAGES:
f3printf(outf, outstyle, (double)pages, width[cols[c]], repsepchar);
break;
case COL_PPAGES:
pccol(outf, outstyle, (double)pages, (double)totp, width[cols[c]],
decpt);
break;
case COL_BYTES:
printbytes(outf, outstyle, bys, bmult, width[cols[c]], repsepchar,
decpt);
break;
case COL_PBYTES:
pccol(outf, outstyle, bys, totb, width[cols[c]], decpt);
break;
case COL_DATE:
case COL_TIME:
need = datefmtlen((cols[c] == COL_DATE)?datefmt:timefmt,
plainmonthlen, plaindaylen, compsep,
(logical)(outstyle == COMPUTER)) + 1;
ENSURE_LEN(datestr, len, need);
(void)datesprintf(datestr, (cols[c] == COL_DATE)?datefmt:timefmt,
outstyle, date, hr, min, newhr, newmin,
monthname, dayname, monthlen, daylen, compsep,
(logical)(outstyle == COMPUTER));
for (i = (int)width[cols[c]] - (int)htmlstrlen(datestr, outstyle);
i > 0; i--)
putc(' ', outf);
fprintf(outf, "%s", datestr);
break;
case COL_INDEX:
if (index > 0)
f3printf(outf, outstyle, (double)index, width[cols[c]], repsepchar);
else for (i = (int)width[cols[c]]; i > 0; i--)
putc(' ', outf);
break;
}
if (outstyle == HTML || outstyle == ASCII)
fputs(": ", outf);
else
fputs(compsep, outf);
}
if (timegraph && (outstyle == HTML || outstyle == ASCII)) {
for (i = 0; i < (int)bmult; i++)
bys /= 1024;
barchart(outf, outstyle, graphby, reqs, pages, bys, unit, barstyle,
markchar, imagedir);
}
else if (!name1st) {
if (name == NULL)
return; /* calling function supplies name and newline */
if (outstyle != COMPUTER) {
if (width[COL_TITLE] == 0) {
for (i = 0; i < (int)spaces; i++)
putc(' ', outf);
}
else {
for (i = (int)width[COL_TITLE] - (int)htmlstrlen(name, outstyle) -
(int)spaces; i > 0; i--)
putc(' ', outf);
}
}
strcpy(workspace, name);
do_aliasx(workspace, aliashead);
if (linkhead != NULL && outstyle == HTML &&
included(name, ispage, linkhead)) {
fputs("", outf);
htmlfprintf(outf, outstyle, multibyte, workspace, html, TRUE);
fputs("", outf);
}
else
htmlfprintf(outf, outstyle, multibyte, workspace, html, TRUE);
}
/* The previous htmlfprintf's have userinput = TRUE because of aliases,
particularly accents in domains: cf do_aliasr(). Note also that for
multibyte charsets, some necessary conversions may not take place.
There's not much we can do about this because the source of the name may
be a URL etc. which we should convert, but may be a lngstr, OUTPUTALIAS
etc. which we shouldn't. We play conservative, not converting entities,
and setting html == FALSE (in finalinit(), init.c). */
else if (outstyle == COMPUTER) {
if (IS_EMPTY_STRING(name)) {
need = datefmtlen(datefmt, plainmonthlen, plaindaylen, compsep, TRUE) + 1;
ENSURE_LEN(datestr, len, need);
name = datesprintf(datestr, datefmt, outstyle, date, hr, min, newhr,
newmin, monthname, dayname, monthlen, daylen, compsep,
TRUE);
}
fprintf(outf, "%s", name);
}
fputc('\n', outf);
}
void lastseven(FILE *outf, choice outstyle, timecode_t last7to, char *compsep,
char **monthname, char **dayname, unsigned int monthlen,
unsigned int daylen, char **lngstr) {
char *datestr;
datestr = (char *)xmalloc((size_t)datefmtlen(lngstr[datefmt1_], monthlen,
daylen, compsep,
(logical)(outstyle == COMPUTER))
+ 1);
if (outstyle == HTML)
fputs("
", outf); if (outstyle == COMPUTER) fprintf(outf, "x%sE7%s%s\n", compsep, compsep, datesprintf(datestr, lngstr[datefmt1_], outstyle, last7to / 1440, (last7to % 1440) / 60, last7to % 60, 0, 0, NULL, NULL, 0, 0, compsep, TRUE)); else fprintf(outf, "(%s %s %s).\n", lngstr[brackets_], lngstr[sevendaysto_], datesprintf(datestr, lngstr[datefmt1_], outstyle, last7to / 1440, (last7to % 1440) / 60, last7to % 60, 0, 0, monthname, dayname, 0, 0, NULL, FALSE)); free((void *)datestr); } /*** Now some stuff for the general summary ***/ void distcount(Hashindex *gooditems, Hashindex *baditems, unsigned long *tot, unsigned long *tot7) { Hashindex *p; for (p = gooditems, *tot = 0, *tot7 = 0; p != NULL; TO_NEXT(p)) { if (p->own != NULL && p->own->data[REQUESTS] > 0) { (*tot)++; *tot7 += (unsigned long)(p->own->last7); } } for (p = baditems; p != NULL; TO_NEXT(p)) { if (p->own != NULL && p->own->data[REQUESTS] > 0) { (*tot)++; *tot7 += (unsigned long)(p->own->last7); } } } void gensumline(FILE *outf, choice outstyle, int namecode, unsigned long x, unsigned long x7, char sepchar, char *compsep, logical p, char **lngstr) { if ((x > 0 || namecode == succreqs_) && x != (unsigned long)UNSET) { if (outstyle == HTML) { if (p) fprintf(outf, "
%s%s ", lngstr[namecode], lngstr[colon_]);
else
fprintf(outf, "
%s%s ", lngstr[namecode], lngstr[colon_]);
}
else if (outstyle == ASCII)
fprintf(outf, "%s%s ", lngstr[namecode], lngstr[colon_]);
else
fprintf(outf, "x%s%c%c%s", compsep, lngstr[namecode][0],
lngstr[namecode][1], compsep);
f3printf(outf, outstyle, (double)x, 0, sepchar);
if (x7 != (unsigned long)(-1)) {
if (outstyle == COMPUTER) {
fprintf(outf, "\nx%s%c%c%s", compsep, lngstr[namecode][2],
lngstr[namecode][3], compsep);
f3printf(outf, outstyle, (double)x7, 0, sepchar);
}
else {
fputs(" (", outf);
f3printf(outf, outstyle, (double)x7, 0, sepchar);
putc(')', outf);
}
}
putc('\n', outf);
}
}
void gensumlineb(FILE *outf, choice outstyle, int namecode, double x,
double x7, logical rawbytes, char sepchar, char decpt,
char *compsep, char **lngstr) {
/* same as gensumline() but for bytes */
extern char byteprefix[];
unsigned int j;
if (x > 0) {
if (outstyle == HTML)
fprintf(outf, "
%s%s ", lngstr[namecode], lngstr[colon_]);
else if (outstyle == ASCII)
fprintf(outf, "%s%s ", lngstr[namecode], lngstr[colon_]);
else
fprintf(outf, "x%s%c%c%s", compsep, lngstr[namecode][0],
lngstr[namecode][1], compsep);
j = rawbytes?0:findbmult(x);
printbytes(outf, outstyle, x, j, 0, sepchar, decpt);
if (outstyle == HTML || outstyle == ASCII) {
if (j > 0)
fprintf(outf, " %c%s", byteprefix[j], lngstr[bytes_]);
else
fprintf(outf, " %s", lngstr[bytes_]);
}
if (x7 != UNSET) {
if (outstyle == COMPUTER) {
fprintf(outf, "\nx%s%c%c%s", compsep, lngstr[namecode][2],
lngstr[namecode][3], compsep);
f3printf(outf, outstyle, (double)x7, 0, sepchar);
}
else {
fputs(" (", outf);
j = rawbytes?0:findbmult(x7);
printbytes(outf, outstyle, x7, j, 0, sepchar, decpt);
if (j > 0)
fprintf(outf, " %c%s)", byteprefix[j], lngstr[bytes_]);
else
fprintf(outf, " %s)", lngstr[bytes_]);
}
}
putc('\n', outf);
}
}
logical checkonerep(Hashindex *gp, choice requests) {
for ( ; gp != NULL; TO_NEXT(gp)) {
if (gp->own != NULL && gp->own->data[requests] > 0)
return(TRUE);
}
return(FALSE);
}
logical checksearchrep(Hashindex *gp, choice requests, Strpair *list) {
/* it's a bit complicated whether the Search Reports have anything in them,
so the easiest thing is to let their routines check */
char *name, *nameend;
for ( ; gp != NULL; TO_NEXT(gp)) {
if (gp->own != NULL && gp->own->data[requests] > 0) {
name = NULL;
nnextname(&name, &nameend, gp->name, list);
if (name != NULL)
return(TRUE);
}
}
return(FALSE);
}
logical checktreerep(Hashtable *tp, choice requests) {
unsigned long i;
for (i = 0; i < tp->size; i++) {
if (checkonerep(tp->head[i], requests))
return(TRUE);
}
return(FALSE);
}
logical checkarrayrep(Arraydata *array) {
choice i;
for (i = 0; ; i++) {
if (array[i].reqs > 0)
return(TRUE);
if (array[i].threshold < -0.5)
return(FALSE);
}
}
void checkreps(Outchoices *od, logical *repq, Dateman *dman, choice *alltrees,
choice *alldervs, Hashindex **gooditems, Tree **trees,
Derv **dervs, Arraydata **arraydata) {
extern choice *rep2type, *rep2reqs;
extern char *repname[];
int i, j;
choice ok;
if (dman->currdp == NULL) {
for (i = 0; i < DATEREP_NUMBER; i++) {
if (repq[i]) {
warn('R', TRUE, "Turning off empty time reports");
for ( ; i < DATEREP_NUMBER; i++)
repq[i] = FALSE;
}
}
}
for (i = FIRST_GENREP; i <= LAST_NORMALREP; i++) {
for (ok = 0, j = 0; alltrees[j] != REP_NUMBER; j++) {
if (i == alltrees[j])
ok = 1;
}
for (j = 0; alldervs[j] != REP_NUMBER; j++) {
if (i == alldervs[j])
ok = 2;
}
if (ok == 1) {
if (!checktreerep(trees[G(i)]->tree, rep2reqs[G(i)])) {
/* alltrees implies repq so don't have to check that */
warn('R', TRUE, "Turning off empty %s", repname[i]);
repq[i] = FALSE;
}
}
else if (ok == 2) {
if (!checktreerep(dervs[i - FIRST_DERVREP]->table, rep2reqs[G(i)])) {
/* again, alldervs implies repq */
warn('R', TRUE, "Turning off empty %s", repname[i]);
repq[i] = FALSE;
}
}
else if (i == REP_SEARCHREP || i == REP_SEARCHSUM) {
if (repq[i] && !checksearchrep(gooditems[rep2type[i]], rep2reqs[G(i)],
*(od->derv[REP_SEARCHSUM - FIRST_DERVREP]->list))) {
warn('R', TRUE, "Turning off empty %s", repname[i]);
repq[i] = FALSE;
}
}
else if (repq[i] && !checkonerep(gooditems[rep2type[i]], rep2reqs[G(i)])) {
warn('R', TRUE, "Turning off empty %s", repname[i]);
repq[i] = FALSE;
}
}
for ( ; i < REP_NUMBER; i++) {
if (repq[i] && !checkarrayrep(arraydata[i - FIRST_ARRAYREP])) {
warn('R', TRUE, "Turning off empty %s", repname[i]);
repq[i] = FALSE;
}
}
}