X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;ds=sidebyside;f=adu.c;h=b3ec80e2377c49e8df37ee2288530212a0e200fa;hb=d57433c49f849c9de60d6c7c592268760697b56a;hp=02bfa302779ccdf5bc299e8a6a81f5b3c2fb8f60;hpb=cecbe8525740b4a899cb1a6c91064e195ae1ada2;p=adu.git diff --git a/adu.c b/adu.c index 02bfa30..b3ec80e 100644 --- a/adu.c +++ b/adu.c @@ -1,6 +1,9 @@ +/** \file adu.c The main functions used by all modes of operation. */ #include "adu.h" #include /* readdir() */ #include +#include "format.h" +#include "select.h" #include "gcc-compat.h" #include "cmdline.h" @@ -8,7 +11,6 @@ #include "string.h" #include "error.h" #include "portable_io.h" -#include "select.cmdline.h" DEFINE_ERRLIST; int osl_errno; @@ -140,6 +142,15 @@ static struct osl_table_description dir_table_desc = { .column_descriptions = dir_table_cols, }; +/* + * The columns of the per-user tables. + * + * Adu tracks disk usage on a per-user basis. For each user, a user table is + * being created. The rows of the user table have three columns: The directory + * number that may be resolved to the path using the directory table, the + * number of bytes and the number of files in that directory owned by the given + * user. + */ static struct osl_column_description user_table_cols[] = { [UT_DIR_NUM] = { .storage_type = OSL_MAPPED_STORAGE, @@ -168,7 +179,7 @@ static struct osl_column_description user_table_cols[] = { * The log function. * * \param ll Loglevel. - * \param fml Usual format string. + * \param fmt Usual format string. * * All XXX_LOG() macros use this function. */ @@ -458,18 +469,56 @@ static int check_args(void) return 1; } +static int print_complete_help_and_die(void) +{ + const char **line; + select_cmdline_parser_init(&select_conf); + + printf("%s-%s\n", CMDLINE_PARSER_PACKAGE, CMDLINE_PARSER_VERSION); + printf("%s\n\n", gengetopt_args_info_purpose); + printf("%s\n\n", gengetopt_args_info_usage); + + if (conf.help_given) + line = gengetopt_args_info_help; + else + line = gengetopt_args_info_detailed_help; + for (; *line; line++) + printf("%s\n", *line); + + if (conf.help_given) + line = select_args_info_help; + else + line = select_args_info_detailed_help; + printf("Select options:\n"); + for (; *line; line++) + printf("%s\n", *line); + + printf("Interactive commands:\n"); + print_interactive_help(); + exit(EXIT_FAILURE); +} + int main(int argc, char **argv) { int ret; struct cmdline_parser_params params = { .override = 0, .initialize = 1, - .check_required = 1, - .check_ambiguity = 1, - .print_errors = 1 + .check_required = 0, + .check_ambiguity = 0, + .print_errors = 0 }; + /* ignore errors and print complete help if --help was given */ + cmdline_parser_ext(argc, argv, &conf, ¶ms); + if (conf.help_given || conf.detailed_help_given) + print_complete_help_and_die(); + params.check_required = 1; + params.check_ambiguity = 1; + params.print_errors = 1; + ret = cmdline_parser_ext(argc, argv, &conf, ¶ms); + if (ret) + exit(EXIT_FAILURE); - cmdline_parser_ext(argc, argv, &conf, ¶ms); /* aborts on errors */ ret = check_args(); if (ret < 0) goto out;