/****************************************************************************
- * Copyright (c) 2006-2017,2019 Free Software Foundation, Inc. *
+ * Copyright 2019-2020,2022 Thomas E. Dickey *
+ * Copyright 2006-2014,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: echochar.c,v 1.20 2019/12/14 23:25:29 tom Exp $
+ * $Id: echochar.c,v 1.25 2022/12/10 22:28:50 tom Exp $
*
* Demonstrate the echochar function (compare to dots.c).
* Thomas Dickey - 2006/11/4
}
}
+static void
+usage(int ok)
+{
+ static const char *msg[] =
+ {
+ "Usage: echochar"
+ ,""
+ ,USAGE_COMMON
+ ,"Options:"
+ ," -r use addch/refresh rather than echochar()"
+ };
+ size_t n;
+
+ for (n = 0; n < SIZEOF(msg); n++)
+ fprintf(stderr, "%s\n", msg[n]);
+
+ ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
+
int
-main(int argc GCC_UNUSED,
- char *argv[]GCC_UNUSED)
+main(int argc, char *argv[])
{
int ch;
double r;
int last_fg = 0;
int last_bg = 0;
- while ((ch = getopt(argc, argv, "r")) != -1) {
+ while ((ch = getopt(argc, argv, OPTS_COMMON "r")) != -1) {
switch (ch) {
case 'r':
opt_r = TRUE;
break;
+ case OPTS_VERSION:
+ show_version(argv);
+ ExitProgram(EXIT_SUCCESS);
default:
- fprintf(stderr, "Usage: echochar [-r]\n");
- ExitProgram(EXIT_FAILURE);
+ usage(ch == OPTS_USAGE);
+ /* NOTREACHED */
}
}