getopt.h: no_argument, required_argument, and optional_argument.
static struct option const long_options[] =
{
- {"recursive", 0, 0, 'R'},
- {"changes", 0, 0, 'c'},
- {"silent", 0, 0, 'f'},
- {"quiet", 0, 0, 'f'},
- {"verbose", 0, 0, 'v'},
+ {"recursive", no_argument, 0, 'R'},
+ {"changes", no_argument, 0, 'c'},
+ {"silent", no_argument, 0, 'f'},
+ {"quiet", no_argument, 0, 'f'},
+ {"verbose", no_argument, 0, 'v'},
{0, 0, 0, 0}
};
static struct option const long_options[] =
{
- {"recursive", 0, 0, 'R'},
- {"changes", 0, 0, 'c'},
- {"silent", 0, 0, 'f'},
- {"quiet", 0, 0, 'f'},
- {"verbose", 0, 0, 'v'},
+ {"recursive", no_argument, 0, 'R'},
+ {"changes", no_argument, 0, 'c'},
+ {"silent", no_argument, 0, 'f'},
+ {"quiet", no_argument, 0, 'f'},
+ {"verbose", no_argument, 0, 'v'},
{0, 0, 0, 0}
};
static struct option const long_opts[] =
{
- {"archive", 0, NULL, 'a'},
- {"backup", 0, NULL, 'b'},
- {"force", 0, NULL, 'f'},
- {"interactive", 0, NULL, 'i'},
- {"link", 0, NULL, 'l'},
- {"no-dereference", 0, &flag_dereference, 0},
- {"one-file-system", 0, &flag_one_file_system, 1},
- {"path", 0, &flag_path, 1},
- {"preserve", 0, &flag_preserve, 1},
- {"recursive", 0, NULL, 'R'},
- {"suffix", 1, NULL, 'S'},
- {"symbolic-link", 0, NULL, 's'},
- {"update", 0, &flag_update, 1},
- {"verbose", 0, &flag_verbose, 1},
- {"version-control", 1, NULL, 'V'},
+ {"archive", no_argument, NULL, 'a'},
+ {"backup", no_argument, NULL, 'b'},
+ {"force", no_argument, NULL, 'f'},
+ {"interactive", no_argument, NULL, 'i'},
+ {"link", no_argument, NULL, 'l'},
+ {"no-dereference", no_argument, &flag_dereference, 0},
+ {"one-file-system", no_argument, &flag_one_file_system, 1},
+ {"path", no_argument, &flag_path, 1},
+ {"preserve", no_argument, &flag_preserve, 1},
+ {"recursive", no_argument, NULL, 'R'},
+ {"suffix", required_argument, NULL, 'S'},
+ {"symbolic-link", no_argument, NULL, 's'},
+ {"update", no_argument, &flag_update, 1},
+ {"verbose", no_argument, &flag_verbose, 1},
+ {"version-control", required_argument, NULL, 'V'},
{NULL, 0, NULL, 0}
};
\f
static struct option const long_options[] =
{
- {"all", 0, &show_all_fs, 1},
- {"inodes", 0, &inode_format, 1},
- {"kilobytes", 0, &kilobyte_blocks, 1},
- {"portability", 0, &posix_format, 1},
- {"type", 1, 0, 't'},
+ {"all", no_argument, &show_all_fs, 1},
+ {"inodes", no_argument, &inode_format, 1},
+ {"kilobytes", no_argument, &kilobyte_blocks, 1},
+ {"portability", no_argument, &posix_format, 1},
+ {"type", required_argument, 0, 't'},
{NULL, 0, NULL, 0}
};
static struct option const long_options[] =
{
- {"all", 0, &opt_all, 1},
- {"bytes", 0, NULL, 'b'},
- {"count-links", 0, &opt_count_all, 1},
- {"dereference", 0, NULL, 'L'},
- {"dereference-args", 0, &opt_dereference_arguments, 1},
- {"kilobytes", 0, NULL, 'k'},
- {"one-file-system", 0, &opt_one_file_system, 1},
- {"separate-dirs", 0, &opt_separate_dirs, 1},
- {"summarize", 0, &opt_summarize_only, 1},
- {"total", 0, &opt_combined_arguments, 1},
+ {"all", no_argument, &opt_all, 1},
+ {"bytes", no_argument, NULL, 'b'},
+ {"count-links", no_argument, &opt_count_all, 1},
+ {"dereference", no_argument, NULL, 'L'},
+ {"dereference-args", no_argument, &opt_dereference_arguments, 1},
+ {"kilobytes", no_argument, NULL, 'k'},
+ {"one-file-system", no_argument, &opt_one_file_system, 1},
+ {"separate-dirs", no_argument, &opt_separate_dirs, 1},
+ {"summarize", no_argument, &opt_summarize_only, 1},
+ {"total", no_argument, &opt_combined_arguments, 1},
{NULL, 0, NULL, 0}
};
static struct option const long_options[] =
{
- {"strip", 0, NULL, 's'},
- {"directory", 0, NULL, 'd'},
- {"group", 1, NULL, 'g'},
- {"mode", 1, NULL, 'm'},
- {"owner", 1, NULL, 'o'},
+ {"strip", no_argument, NULL, 's'},
+ {"directory", no_argument, NULL, 'd'},
+ {"group", required_argument, NULL, 'g'},
+ {"mode", required_argument, NULL, 'm'},
+ {"owner", required_argument, NULL, 'o'},
{NULL, 0, NULL, 0}
};
static struct option const long_options[] =
{
- {"backup", 0, NULL, 'b'},
- {"directory", 0, &hard_dir_link, 1},
- {"force", 0, NULL, 'f'},
- {"interactive", 0, NULL, 'i'},
- {"suffix", 1, NULL, 'S'},
- {"symbolic", 0, &symbolic_link, 1},
- {"verbose", 0, &verbose, 1},
- {"version-control", 1, NULL, 'V'},
+ {"backup", no_argument, NULL, 'b'},
+ {"directory", no_argument, &hard_dir_link, 1},
+ {"force", no_argument, NULL, 'f'},
+ {"interactive", no_argument, NULL, 'i'},
+ {"suffix", required_argument, NULL, 'S'},
+ {"symbolic", no_argument, &symbolic_link, 1},
+ {"verbose", no_argument, &verbose, 1},
+ {"version-control", required_argument, NULL, 'V'},
{NULL, 0, NULL, 0}
};
\f
static struct option const long_options[] =
{
- {"all", 0, 0, 'a'},
- {"escape", 0, 0, 'b'},
- {"directory", 0, 0, 'd'},
- {"inode", 0, 0, 'i'},
- {"kilobytes", 0, 0, 'k'},
- {"numeric-uid-gid", 0, 0, 'n'},
- {"hide-control-chars", 0, 0, 'q'},
- {"reverse", 0, 0, 'r'},
- {"size", 0, 0, 's'},
- {"width", 1, 0, 'w'},
- {"almost-all", 0, 0, 'A'},
- {"ignore-backups", 0, 0, 'B'},
- {"classify", 0, 0, 'F'},
- {"file-type", 0, 0, 'F'},
- {"ignore", 1, 0, 'I'},
- {"dereference", 0, 0, 'L'},
- {"literal", 0, 0, 'N'},
- {"quote-name", 0, 0, 'Q'},
- {"recursive", 0, 0, 'R'},
- {"format", 1, 0, 12},
- {"sort", 1, 0, 10},
- {"tabsize", 1, 0, 'T'},
- {"time", 1, 0, 11},
+ {"all", no_argument, 0, 'a'},
+ {"escape", no_argument, 0, 'b'},
+ {"directory", no_argument, 0, 'd'},
+ {"inode", no_argument, 0, 'i'},
+ {"kilobytes", no_argument, 0, 'k'},
+ {"numeric-uid-gid", no_argument, 0, 'n'},
+ {"hide-control-chars", no_argument, 0, 'q'},
+ {"reverse", no_argument, 0, 'r'},
+ {"size", no_argument, 0, 's'},
+ {"width", required_argument, 0, 'w'},
+ {"almost-all", no_argument, 0, 'A'},
+ {"ignore-backups", no_argument, 0, 'B'},
+ {"classify", no_argument, 0, 'F'},
+ {"file-type", no_argument, 0, 'F'},
+ {"ignore", required_argument, 0, 'I'},
+ {"dereference", no_argument, 0, 'L'},
+ {"literal", no_argument, 0, 'N'},
+ {"quote-name", no_argument, 0, 'Q'},
+ {"recursive", no_argument, 0, 'R'},
+ {"format", required_argument, 0, 12},
+ {"sort", required_argument, 0, 10},
+ {"tabsize", required_argument, 0, 'T'},
+ {"time", required_argument, 0, 11},
{0, 0, 0, 0}
};
static struct option const longopts[] =
{
- {"mode", 1, NULL, 'm'},
- {"path", 0, &path_mode, 1},
+ {"mode", required_argument, NULL, 'm'},
+ {"path", no_argument, &path_mode, 1},
{NULL, 0, NULL, 0}
};
static struct option const longopts[] =
{
- {"mode", 1, NULL, 'm'},
+ {"mode", required_argument, NULL, 'm'},
{NULL, 0, NULL, 0}
};
static struct option const longopts[] =
{
- {"mode", 1, NULL, 'm'},
+ {"mode", required_argument, NULL, 'm'},
{NULL, 0, NULL, 0}
};
static struct option const long_options[] =
{
- {"backup", 0, NULL, 'b'},
- {"force", 0, NULL, 'f'},
- {"interactive", 0, NULL, 'i'},
- {"suffix", 1, NULL, 'S'},
- {"update", 0, &update, 1},
- {"verbose", 0, &verbose, 1},
- {"version-control", 1, NULL, 'V'},
+ {"backup", no_argument, NULL, 'b'},
+ {"force", no_argument, NULL, 'f'},
+ {"interactive", no_argument, NULL, 'i'},
+ {"suffix", required_argument, NULL, 'S'},
+ {"update", no_argument, &update, 1},
+ {"verbose", no_argument, &verbose, 1},
+ {"version-control", required_argument, NULL, 'V'},
{NULL, 0, NULL, 0}
};
static struct option const long_opts[] =
{
- {"directory", 0, &unlink_dirs, 1},
- {"force", 0, NULL, 'f'},
- {"interactive", 0, NULL, 'i'},
- {"recursive", 0, &recursive, 1},
- {"verbose", 0, &verbose, 1},
+ {"directory", no_argument, &unlink_dirs, 1},
+ {"force", no_argument, NULL, 'f'},
+ {"interactive", no_argument, NULL, 'i'},
+ {"recursive", no_argument, &recursive, 1},
+ {"verbose", no_argument, &verbose, 1},
{NULL, 0, NULL, 0}
};
static struct option const longopts[] =
{
- {"path", 0, &empty_paths, 1},
+ {"path", no_argument, &empty_paths, 1},
{NULL, 0, NULL, 0}
};
static struct option const longopts[] =
{
- {"time", 1, 0, 130},
- {"no-create", 0, 0, 'c'},
- {"date", 1, 0, 'd'},
- {"file", 1, 0, 'r'},
+ {"time", required_argument, 0, 130},
+ {"no-create", no_argument, 0, 'c'},
+ {"date", required_argument, 0, 'd'},
+ {"file", required_argument, 0, 'r'},
{0, 0, 0, 0}
};