X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/agedu/blobdiff_plain/72bd16db96dde42675538efcd53492be69c0bdec..3f9402602d4c670acdc58dc91e4a451797d6f5b1:/html.c diff --git a/html.c b/html.c index db6c25b..5ca85e0 100644 --- a/html.c +++ b/html.c @@ -19,7 +19,8 @@ struct html { char *href; size_t hreflen; const char *format; - unsigned long long thresholds[MAXCOLOUR-1]; + unsigned long long thresholds[MAXCOLOUR]; + char *titletexts[MAXCOLOUR+1]; time_t now; }; @@ -171,13 +172,10 @@ static void get_indices(const void *t, char *path, path[pathlen-1] = c2; } -static unsigned long long fetch_size(const void *t, char *path, +static unsigned long long fetch_size(const void *t, + unsigned long xi1, unsigned long xi2, unsigned long long atime) { - unsigned long xi1, xi2; - - get_indices(t, path, &xi1, &xi2); - return index_query(t, xi2, atime) - index_query(t, xi1, atime); } @@ -213,7 +211,6 @@ static void begin_colour_bar(struct html *ctx) static void add_to_colour_bar(struct html *ctx, int colour, int pixels) { int r, g, b; - char buf[80]; if (colour >= 0 && colour < 256) /* red -> yellow fade */ r = 255, g = colour, b = 0; @@ -222,26 +219,12 @@ static void add_to_colour_bar(struct html *ctx, int colour, int pixels) else /* background grey */ r = g = b = 240; - if (colour < 0) { - /* no title text here */ - } else if (colour == 0) { - strcpy(buf, "< "); - round_and_format_age(ctx, ctx->thresholds[0], buf+5, 0); - } else if (colour == MAXCOLOUR) { - strcpy(buf, "> "); - round_and_format_age(ctx, ctx->thresholds[MAXCOLOUR-1], buf+5, 0); - } else { - unsigned long long midrange = - (ctx->thresholds[colour] + ctx->thresholds[colour+1]) / 2; - round_and_format_age(ctx, midrange, buf, 0); - } - if (pixels > 0) { htprintf(ctx, "
Key to colour coding (mouse over for more detail):\n"); htprintf(ctx, "
totalsize = fetch_size(t, path, ULLONG_MAX); + get_indices(t, path, &xi1, &xi2); + ctx->totalsize = fetch_size(t, xi1, xi2, ULLONG_MAX); /* * Generate a report line for the whole subdirectory.