+ fprintf(stderr, "usage: %s [-V] [-S] [-T term] capname\n", prg_name);
+ ExitProgram(EXIT_FAILURE);
+}
+
+static void
+check_aliases(const char *name)
+{
+ is_init = same_program(name, PROG_INIT);
+ is_reset = same_program(name, PROG_RESET);
+}
+
+/*
+ * Lookup the type of call we should make to tparm(). This ignores the actual
+ * terminfo capability (bad, because it is not extensible), but makes this
+ * code portable to platforms where sizeof(int) != sizeof(char *).
+ *
+ * FIXME: If we want extensibility, analyze the capability string as we do
+ * in tparm() to decide how to parse the varargs list.
+ */
+static TParams
+tparm_type(const char *name)
+{
+#define TD(code, longname, ti, tc) {code,longname},{code,ti},{code,tc}
+ TParams result = Numbers;
+ /* *INDENT-OFF* */
+ static const struct {
+ TParams code;
+ const char *name;
+ } table[] = {
+ TD(Num_Str, "pkey_key", "pfkey", "pk"),
+ TD(Num_Str, "pkey_local", "pfloc", "pl"),
+ TD(Num_Str, "pkey_xmit", "pfx", "px"),
+ TD(Num_Str, "plab_norm", "pln", "pn"),
+ TD(Num_Str_Str, "pkey_plab", "pfxl", "xl"),
+ };
+ /* *INDENT-ON* */
+
+ unsigned n;
+ for (n = 0; n < SIZEOF(table); n++) {
+ if (!strcmp(name, table[n].name)) {
+ result = table[n].code;
+ break;
+ }
+ }
+ 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;