X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/agedu/blobdiff_plain/444c684cc23aa1fbc8a75901a0a77283c082b4aa..353bc75ddcc747e241296418a985ad2b265a86cf:/agedu.c diff --git a/agedu.c b/agedu.c index d7d9126..83f8ead 100644 --- a/agedu.c +++ b/agedu.c @@ -20,6 +20,7 @@ #include #include +#include "agedu.h" #include "du.h" #include "trie.h" #include "index.h" @@ -28,10 +29,6 @@ #include "httpd.h" #include "fgetline.h" -#define PNAME "agedu" - -#define lenof(x) (sizeof((x))/sizeof(*(x))) - /* * Path separator. This global variable affects the behaviour of * various parts of the code when they need to deal with path @@ -185,9 +182,6 @@ static void text_query(const void *mappedfile, const char *querydir, if (s1 == s2) return; /* no space taken up => no display */ - /* Display in units of 1Kb */ - printf("%-11llu %s\n", (s2 - s1) / 1024, querydir); - if (depth > 0) { /* * Now scan for first-level subdirectories and report @@ -201,6 +195,9 @@ static void text_query(const void *mappedfile, const char *querydir, xi1 = trie_before(mappedfile, pathbuf); } } + + /* Display in units of 1Kb */ + printf("%-11llu %s\n", (s2 - s1) / 1024, querydir); } /* @@ -302,6 +299,8 @@ static void text_query(const void *mappedfile, const char *querydir, HELPARG("wildcard") HELPOPT("[--scan] prune files matching pattern") \ VAL(PRUNEPATH) LONG(prune_path) \ HELPARG("wildcard") HELPOPT("[--scan] prune pathnames matching pattern") \ + VAL(TQDEPTH) LONG(depth) LONG(max_depth) LONG(maximum_depth) \ + HELPARG("levels") HELPOPT("[--text] recurse to this many levels") \ VAL(MINAGE) SHORT(a) LONG(age) LONG(min_age) LONG(minimum_age) \ HELPARG("age") HELPOPT("[--text] include only files older than this") \ VAL(AGERANGE) SHORT(r) LONG(age_range) LONG(range) LONG(ages) \ @@ -459,6 +458,7 @@ int main(int argc, char **argv) struct inclusion_exclusion *inex = NULL; int ninex = 0, inexsize = 0; int crossfs = 0; + int tqdepth = 1; #ifdef DEBUG_MAD_OPTION_PARSING_MACROS { @@ -601,7 +601,15 @@ int main(int argc, char **argv) printf("FIXME: version();\n"); return 0; case OPT_LICENCE: - printf("FIXME: licence();\n"); + { + extern const char *const licence[]; + int i; + + for (i = 0; licence[i]; i++) + fputs(licence[i], stdout); + + return 0; + } return 0; case OPT_SCAN: if (nactions >= actionsize) { @@ -684,6 +692,9 @@ int main(int argc, char **argv) case OPT_DATAFILE: filename = optval; break; + case OPT_TQDEPTH: + tqdepth = atoi(optval); + break; case OPT_MINAGE: textcutoff = parse_age(now, optval); break; @@ -1046,7 +1057,7 @@ int main(int argc, char **argv) if (pathlen > 0 && querydir[pathlen-1] == pathsep) querydir[--pathlen] = '\0'; - text_query(mappedfile, querydir, textcutoff, 1); + text_query(mappedfile, querydir, textcutoff, tqdepth); } else if (mode == HTML) { char *querydir = actions[action].arg; size_t pathlen;