/****************************************************************************
- * Copyright (c) 2007-2010,2017 Free Software Foundation, Inc. *
+ * Copyright 2020,2022 Thomas E. Dickey *
+ * Copyright 2007-2010,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
* authorization. *
****************************************************************************/
/*
- * $Id: test_arrays.c,v 1.8 2017/10/07 23:55:21 tom Exp $
+ * $Id: test_arrays.c,v 1.13 2022/12/10 23:23:27 tom Exp $
*
* Author: Thomas E Dickey
*
}
static void
-usage(void)
+usage(int ok)
{
static const char *msg[] =
{
- "Usage: test_arrays [options]",
- "",
- "If no options are given, print all (boolean, numeric, string)",
- "capability names showing their index within the tables.",
- "",
- "Options:",
- " -C print termcap names",
- " -T print terminfo names",
- " -c print termcap names",
- " -f print full terminfo names",
- " -n print short terminfo names",
- " -t print the result as CSV table",
+ "Usage: test_arrays [options]"
+ ,""
+ ,"If no options are given, print all (boolean, numeric, string)"
+ ,"capability names showing their index within the tables."
+ ,""
+ ,USAGE_COMMON
+ ,"Options:"
+ ," -C print termcap names"
+ ," -T print terminfo names"
+ ," -c print termcap names"
+ ," -f print full terminfo names"
+ ," -n print short terminfo names"
+ ," -t print the result as CSV table"
};
unsigned 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, char *argv[])
{
- int n;
+ int ch;
- while ((n = getopt(argc, argv, "CTcfnt")) != -1) {
- switch (n) {
+ while ((ch = getopt(argc, argv, OPTS_COMMON "CTcfnt")) != -1) {
+ switch (ch) {
case 'C':
opt_C = TRUE;
break;
case 't':
opt_t = TRUE;
break;
+ case OPTS_VERSION:
+ show_version(argv);
+ ExitProgram(EXIT_SUCCESS);
default:
- usage();
+ usage(ch == OPTS_USAGE);
/* NOTREACHED */
}
}
if (optind < argc)
- usage();
+ usage(FALSE);
if (!(opt_T || opt_C)) {
opt_T = opt_C = TRUE;
#else
int
-main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
+main(void)
{
printf("This program requires the terminfo arrays\n");
ExitProgram(EXIT_FAILURE);
#endif
#else /* !HAVE_TIGETSTR */
int
-main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
+main(void)
{
printf("This program requires the terminfo functions such as tigetstr\n");
ExitProgram(EXIT_FAILURE);