getopt.h: no_argument, required_argument, and optional_argument.
static struct option const long_options[] =
{
- {"number-nonblank", 0, NULL, 'b'},
- {"number", 0, NULL, 'n'},
- {"squeeze-blank", 0, NULL, 's'},
- {"show-nonprinting", 0, NULL, 'v'},
- {"show-ends", 0, NULL, 'E'},
- {"show-tabs", 0, NULL, 'T'},
- {"show-all", 0, NULL, 'A'},
+ {"number-nonblank", no_argument, NULL, 'b'},
+ {"number", no_argument, NULL, 'n'},
+ {"squeeze-blank", no_argument, NULL, 's'},
+ {"show-nonprinting", no_argument, NULL, 'v'},
+ {"show-ends", no_argument, NULL, 'E'},
+ {"show-tabs", no_argument, NULL, 'T'},
+ {"show-all", no_argument, NULL, 'A'},
{NULL, 0, NULL, 0}
};
static struct option const longopts[] =
{
- {"digits", 1, NULL, 'n'},
- {"quiet", 0, NULL, 's'},
- {"silent", 0, NULL, 's'},
- {"keep-files", 0, NULL, 'k'},
- {"prefix", 1, NULL, 'f'},
+ {"digits", required_argument, NULL, 'n'},
+ {"quiet", no_argument, NULL, 's'},
+ {"silent", no_argument, NULL, 's'},
+ {"keep-files", no_argument, NULL, 'k'},
+ {"prefix", required_argument, NULL, 'f'},
{NULL, 0, NULL, 0}
};
static struct option const longopts[] =
{
- {"bytes", 1, 0, 'b'},
- {"characters", 1, 0, 'c'},
- {"fields", 1, 0, 'f'},
- {"delimiter", 1, 0, 'd'},
- {"only-delimited", 0, 0, 's'},
+ {"bytes", required_argument, 0, 'b'},
+ {"characters", required_argument, 0, 'c'},
+ {"fields", required_argument, 0, 'f'},
+ {"delimiter", required_argument, 0, 'd'},
+ {"only-delimited", no_argument, 0, 's'},
{0, 0, 0, 0}
};
static struct option const longopts[] =
{
- {"tabs", 1, NULL, 't'},
- {"initial", 0, NULL, 'i'},
+ {"tabs", required_argument, NULL, 't'},
+ {"initial", no_argument, NULL, 'i'},
{NULL, 0, NULL, 0}
};
static struct option const longopts[] =
{
- {"bytes", 0, NULL, 'b'},
- {"spaces", 0, NULL, 's'},
- {"width", 1, NULL, 'w'},
+ {"bytes", no_argument, NULL, 'b'},
+ {"spaces", no_argument, NULL, 's'},
+ {"width", required_argument, NULL, 'w'},
{NULL, 0, NULL, 0}
};
\f
static struct option const long_options[] =
{
- {"bytes", 1, NULL, 'c'},
- {"lines", 1, NULL, 'n'},
- {"quiet", 0, NULL, 'q'},
- {"silent", 0, NULL, 'q'},
- {"verbose", 0, NULL, 'v'},
+ {"bytes", required_argument, NULL, 'c'},
+ {"lines", required_argument, NULL, 'n'},
+ {"quiet", no_argument, NULL, 'q'},
+ {"silent", no_argument, NULL, 'q'},
+ {"verbose", no_argument, NULL, 'v'},
{NULL, 0, NULL, 0}
};
a character that is a short option. */
static struct option const longopts[] =
{
- {"j", 1, NULL, 'j'},
- {"j1", 1, NULL, '1'},
- {"j2", 1, NULL, '2'},
+ {"j", required_argument, NULL, 'j'},
+ {"j1", required_argument, NULL, '1'},
+ {"j2", required_argument, NULL, '2'},
{NULL, 0, NULL, 0}
};
\f
static struct option const longopts[] =
{
- {"header-numbering", 1, NULL, 'h'},
- {"body-numbering", 1, NULL, 'b'},
- {"footer-numbering", 1, NULL, 'f'},
- {"first-page", 1, NULL, 'v'},
- {"page-increment", 1, NULL, 'i'},
- {"no-renumber", 0, NULL, 'p'},
- {"join-blank-lines", 1, NULL, 'l'},
- {"number-separator", 1, NULL, 's'},
- {"number-width", 1, NULL, 'w'},
- {"number-format", 1, NULL, 'n'},
- {"section-delimiter", 1, NULL, 'd'},
+ {"header-numbering", required_argument, NULL, 'h'},
+ {"body-numbering", required_argument, NULL, 'b'},
+ {"footer-numbering", required_argument, NULL, 'f'},
+ {"first-page", required_argument, NULL, 'v'},
+ {"page-increment", required_argument, NULL, 'i'},
+ {"no-renumber", no_argument, NULL, 'p'},
+ {"join-blank-lines", required_argument, NULL, 'l'},
+ {"number-separator", required_argument, NULL, 's'},
+ {"number-width", required_argument, NULL, 'w'},
+ {"number-format", required_argument, NULL, 'n'},
+ {"section-delimiter", required_argument, NULL, 'd'},
{NULL, 0, NULL, 0}
};
static struct option const long_options[] =
{
/* POSIX options. */
- {"skip-bytes", 1, NULL, 'j'},
- {"address-radix", 1, NULL, 'A'},
- {"read-bytes", 1, NULL, 'N'},
- {"format", 1, NULL, 't'},
- {"output-duplicates", 0, NULL, 'v'},
+ {"skip-bytes", required_argument, NULL, 'j'},
+ {"address-radix", required_argument, NULL, 'A'},
+ {"read-bytes", required_argument, NULL, 'N'},
+ {"format", required_argument, NULL, 't'},
+ {"output-duplicates", no_argument, NULL, 'v'},
/* non-POSIX options. */
- {"strings", 2, NULL, 's'},
- {"width", 2, NULL, 'w'},
+ {"strings", optional_argument, NULL, 's'},
+ {"width", optional_argument, NULL, 'w'},
{NULL, 0, NULL, 0}
};
static struct option const longopts[] =
{
- {"serial", 0, 0, 's'},
- {"delimiters", 1, 0, 'd'},
+ {"serial", no_argument, 0, 's'},
+ {"delimiters", required_argument, 0, 'd'},
{0, 0, 0, 0}
};
\f
static struct option const longopts[] =
{
- {"bytes", 1, NULL, 'b'},
- {"lines", 1, NULL, 'l'},
- {"line-bytes", 1, NULL, 'C'},
+ {"bytes", required_argument, NULL, 'b'},
+ {"lines", required_argument, NULL, 'l'},
+ {"line-bytes", required_argument, NULL, 'C'},
{NULL, 0, NULL, 0}
};
static struct option const longopts[] =
{
- {"sysv", 0, NULL, 's'},
+ {"sysv", no_argument, NULL, 's'},
{NULL, 0, NULL, 0}
};
static struct option const longopts[] =
{
- {"before", 0, &separator_ends_record, 0},
- {"regex", 0, &sentinel_length, 0},
- {"separator", 1, NULL, 's'},
+ {"before", no_argument, &separator_ends_record, 0},
+ {"regex", no_argument, &sentinel_length, 0},
+ {"separator", required_argument, NULL, 's'},
{NULL, 0, NULL, 0}
};
static struct option const long_options[] =
{
- {"bytes", 1, NULL, 'c'},
- {"follow", 0, NULL, 'f'},
- {"lines", 1, NULL, 'n'},
- {"quiet", 0, NULL, 'q'},
- {"silent", 0, NULL, 'q'},
- {"verbose", 0, NULL, 'v'},
+ {"bytes", required_argument, NULL, 'c'},
+ {"follow", no_argument, NULL, 'f'},
+ {"lines", required_argument, NULL, 'n'},
+ {"quiet", no_argument, NULL, 'q'},
+ {"silent", no_argument, NULL, 'q'},
+ {"verbose", no_argument, NULL, 'v'},
{NULL, 0, NULL, 0}
};
static struct option const long_options[] =
{
- {"complement", 0, NULL, 'c'},
- {"delete", 0, NULL, 'd'},
- {"squeeze-repeats", 0, NULL, 's'},
- {"truncate-set1", 0, NULL, 't'},
+ {"complement", no_argument, NULL, 'c'},
+ {"delete", no_argument, NULL, 'd'},
+ {"squeeze-repeats", no_argument, NULL, 's'},
+ {"truncate-set1", no_argument, NULL, 't'},
{NULL, 0, NULL, 0}
};
\f
static struct option const longopts[] =
{
- {"tabs", 1, NULL, 't'},
- {"all", 0, NULL, 'a'},
+ {"tabs", required_argument, NULL, 't'},
+ {"all", no_argument, NULL, 'a'},
{NULL, 0, NULL, 0}
};
static struct option const longopts[] =
{
- {"count", 0, NULL, 'c'},
- {"repeated", 0, NULL, 'd'},
- {"unique", 0, NULL, 'u'},
- {"skip-fields", 1, NULL, 'f'},
- {"skip-chars", 1, NULL, 's'},
- {"check-chars", 1, NULL, 'w'},
+ {"count", no_argument, NULL, 'c'},
+ {"repeated", no_argument, NULL, 'd'},
+ {"unique", no_argument, NULL, 'u'},
+ {"skip-fields", required_argument, NULL, 'f'},
+ {"skip-chars", required_argument, NULL, 's'},
+ {"check-chars", required_argument, NULL, 'w'},
{NULL, 0, NULL, 0}
};
\f
static struct option const longopts[] =
{
- {"bytes", 0, NULL, 'c'},
- {"chars", 0, NULL, 'c'},
- {"lines", 0, NULL, 'l'},
- {"words", 0, NULL, 'w'},
+ {"bytes", no_argument, NULL, 'c'},
+ {"chars", no_argument, NULL, 'c'},
+ {"lines", no_argument, NULL, 'l'},
+ {"words", no_argument, NULL, 'w'},
{NULL, 0, NULL, 0}
};