2 * This program is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU General Public
4 * License v2 as published by the Free Software Foundation.
6 * This program is distributed in the hope that it will be useful,
7 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9 * General Public License for more details.
11 * You should have received a copy of the GNU General Public
12 * License along with this program; if not, write to the
13 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
14 * Boston, MA 021110-1307, USA.
17 #ifndef __BTRFS_HELP_H__
18 #define __BTRFS_HELP_H__
20 #define GETOPT_VAL_SI 256
21 #define GETOPT_VAL_IEC 257
22 #define GETOPT_VAL_RAW 258
23 #define GETOPT_VAL_HUMAN_READABLE 259
24 #define GETOPT_VAL_KBYTES 260
25 #define GETOPT_VAL_MBYTES 261
26 #define GETOPT_VAL_GBYTES 262
27 #define GETOPT_VAL_TBYTES 263
29 #define GETOPT_VAL_HELP 270
31 #define ARGV0_BUF_SIZE PATH_MAX
33 #define HELPINFO_UNITS_LONG \
34 "--raw raw numbers in bytes", \
35 "--human-readable human friendly numbers, base 1024 (default)", \
36 "--iec use 1024 as a base (KiB, MiB, GiB, TiB)", \
37 "--si use 1000 as a base (kB, MB, GB, TB)", \
38 "--kbytes show sizes in KiB, or kB with --si", \
39 "--mbytes show sizes in MiB, or MB with --si", \
40 "--gbytes show sizes in GiB, or GB with --si", \
41 "--tbytes show sizes in TiB, or TB with --si"
43 #define HELPINFO_UNITS_SHORT_LONG \
44 "-b|--raw raw numbers in bytes", \
45 "-h|--human-readable", \
46 " human friendly numbers, base 1024 (default)", \
47 "-H human friendly numbers, base 1000", \
48 "--iec use 1024 as a base (KiB, MiB, GiB, TiB)", \
49 "--si use 1000 as a base (kB, MB, GB, TB)", \
50 "-k|--kbytes show sizes in KiB, or kB with --si", \
51 "-m|--mbytes show sizes in MiB, or MB with --si", \
52 "-g|--gbytes show sizes in GiB, or GB with --si", \
53 "-t|--tbytes show sizes in TiB, or TB with --si"
58 void usage(const char * const *usagestr) __attribute__((noreturn));
59 void usage_command(const struct cmd_struct *cmd, int full, int err);
60 void usage_command_group(const struct cmd_group *grp, int all, int err);
61 void usage_command_group_short(const struct cmd_group *grp);
63 void help_unknown_token(const char *arg, const struct cmd_group *grp) __attribute__((noreturn));
64 void help_ambiguous_token(const char *arg, const struct cmd_group *grp) __attribute__((noreturn));
66 void help_command_group(const struct cmd_group *grp, int argc, char **argv);
68 int check_argc_exact(int nargs, int expected);
69 int check_argc_min(int nargs, int expected);
70 int check_argc_max(int nargs, int expected);
71 void clean_args_no_options(int argc, char *argv[], const char * const *usage);
72 void clean_args_no_options_relaxed(int argc, char *argv[],
73 const char * const *usagestr);
75 void fixup_argv0(char **argv, const char *token);
76 void set_argv0(char **argv);
77 const char *get_argv0_buf(void);