* authorization. *
****************************************************************************/
/*
- * $Id: color_content.c,v 1.14 2022/05/21 20:00:04 tom Exp $
+ * $Id: color_content.c,v 1.17 2022/12/04 00:40:11 tom Exp $
*/
#define NEED_TIME_H
#endif
static void
-usage(void)
+usage(int ok)
{
static const char *msg[] =
{
"Usage: color_content [options]"
,""
+ ,USAGE_COMMON
,"Options:"
," -f COLOR first color value to test (default: 0)"
," -i interactive, showing test-progress"
size_t n;
for (n = 0; n < SIZEOF(msg); n++)
fprintf(stderr, "%s\n", msg[n]);
- ExitProgram(EXIT_FAILURE);
+ ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
int
main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
{
- int i;
+ int ch;
- while ((i = getopt(argc, argv, "f:il:npr:sx")) != -1) {
- switch (i) {
+ while ((ch = getopt(argc, argv, OPTS_COMMON "f:il:npr:sx")) != -1) {
+ switch (ch) {
case 'f':
if ((f_opt = atoi(optarg)) <= 0)
- usage();
+ usage(FALSE);
break;
case 'i':
i_opt = 1;
break;
case 'l':
if ((l_opt = atoi(optarg)) <= 0)
- usage();
+ usage(FALSE);
break;
case 'n':
n_opt = 1;
break;
case 'r':
if ((r_opt = atoi(optarg)) <= 0)
- usage();
+ usage(FALSE);
break;
case 's':
s_opt = 1;
x_opt = 1;
break;
#endif
+ case OPTS_VERSION:
+ show_version(argv);
+ ExitProgram(EXIT_SUCCESS);
default:
- usage();
+ usage(ch == OPTS_USAGE);
+ /* NOTREACHED */
}
}
if (optind < argc)
- usage();
+ usage(FALSE);
if (r_opt <= 0)
r_opt = 1;
setup_test();
if (p_opt) {
+ int i;
endwin();
for (i = 0; i < COLORS; ++i) {
my_color_t r, g, b;