+#define KEEP(s) s "\n"
+ static const char msg[] =
+ {
+ KEEP("")
+ KEEP("Options:")
+ KEEP(" -S << read commands from standard input")
+ KEEP(" -T TERM use this instead of $TERM")
+ KEEP(" -V print curses-version")
+ KEEP(" -x do not try to clear scrollback")
+ KEEP("")
+ KEEP("Commands:")
+ KEEP(" clear clear the screen")
+ KEEP(" init initialize the terminal")
+ KEEP(" reset reinitialize the terminal")
+ KEEP(" capname unlike clear/init/reset, print value for capability \"capname\"")
+ };
+#undef KEEP
+ (void) fprintf(stderr, "Usage: %s [options] [command]\n", prg_name);
+ fputs(msg, stderr);
+ ExitProgram(ErrUsage);
+}
+
+static char *
+check_aliases(char *name, bool program)
+{
+ static char my_init[] = "init";
+ static char my_reset[] = "reset";
+ static char my_clear[] = "clear";
+
+ char *result = name;
+ if ((is_init = same_program(name, program ? PROG_INIT : my_init)))
+ result = my_init;
+ if ((is_reset = same_program(name, program ? PROG_RESET : my_reset)))
+ result = my_reset;
+ if ((is_clear = same_program(name, program ? PROG_CLEAR : my_clear)))
+ result = my_clear;
+ return result;
+}
+
+static int
+exit_code(int token, int value)
+{
+ int result = 99;
+
+ switch (token) {
+ case BOOLEAN:
+ result = !value; /* TRUE=0, FALSE=1 */
+ break;
+ case NUMBER:
+ result = 0; /* always zero */
+ break;
+ case STRING:
+ result = value; /* 0=normal, 1=missing */
+ break;
+ }
+ return result;