- if (reset && reset_1string != NULL) {
- PUTS(reset_1string);
- } else if (init_1string != NULL) {
- PUTS(init_1string);
- }
- FLUSH;
-
- if (reset && reset_2string != NULL) {
- PUTS(reset_2string);
- } else if (init_2string != NULL) {
- PUTS(init_2string);
- }
- FLUSH;
-
- if (set_lr_margin != NULL) {
- PUTS(tparm(set_lr_margin, 0, columns - 1));
- } else if (set_left_margin_parm != NULL
- && set_right_margin_parm != NULL) {
- PUTS(tparm(set_left_margin_parm, 0));
- PUTS(tparm(set_right_margin_parm, columns - 1));
- } else if (clear_margins != NULL && set_left_margin != NULL
- && set_right_margin != NULL) {
- PUTS(clear_margins);
- if (carriage_return != NULL) {
- PUTS(carriage_return);
- } else {
- PUTCHAR('\r');
- }
- PUTS(set_left_margin);
- if (parm_right_cursor) {
- PUTS(tparm(parm_right_cursor, columns - 1));
- } else {
- for(i = 0; i < columns - 1; i++) {
- PUTCHAR(' ');
- }
- }
- PUTS(set_right_margin);
- if (carriage_return != NULL) {
- PUTS(carriage_return);
- } else {
- PUTCHAR('\r');
- }
- }
- FLUSH;
-
- if (init_tabs != 8) {
- if (clear_all_tabs != NULL && set_tab != NULL) {
- for(i = 0; i < columns - 1; i += 8) {
- if (parm_right_cursor) {
- PUTS(tparm(parm_right_cursor, 8));
- } else {
- for(j = 0; j < 8; j++)
- PUTCHAR(' ');
- }
- PUTS(set_tab);
- }
- FLUSH;
- }
- }
-
- if (reset && reset_file != NULL) {
- f = fopen(reset_file, "r");
- if (f == NULL) {
- quit(errno, "Can't open reset_file: '%s'", reset_file);
- }
- while((c = fgetc(f)) != EOF) {
- PUTCHAR(c);
- }
- fclose(f);
- } else if (init_file != NULL) {
- f = fopen(init_file, "r");
- if (f == NULL) {
- quit(errno, "Can't open init_file: '%s'", init_file);
- }
- while((c = fgetc(f)) != EOF) {
- PUTCHAR(c);
- }
- fclose(f);
- }
- FLUSH;
-
- if (reset && reset_3string != NULL) {
- PUTS(reset_3string);
- } else if (init_2string != NULL) {
- PUTS(init_2string);
- }
- FLUSH;
- return 0;
- }
-
- if (strcmp(argv[0], "longname") == 0) {
- PUTS(longname());
- return 0;
+/*
+ * Returns nonzero on error.
+ */
+static int
+tput_cmd(int fd, TTY * settings, bool opt_x, int argc, char **argv, int *used)
+{
+ NCURSES_CONST char *name;
+ char *s;
+ int status;
+#if !PURE_TERMINFO
+ bool termcap = FALSE;
+#endif
+
+ name = check_aliases(argv[0], FALSE);
+ *used = 1;
+ if (is_reset || is_init) {
+ TTY oldmode;
+
+ int terasechar = -1; /* new erase character */
+ int intrchar = -1; /* new interrupt character */
+ int tkillchar = -1; /* new kill character */
+
+ if (is_reset) {
+ reset_start(stdout, TRUE, FALSE);
+ reset_tty_settings(fd, settings, FALSE);
+ } else {
+ reset_start(stdout, FALSE, TRUE);