/* ** probe_enq_ok() ** ** does the terminal do enq/ack handshaking? */ static void probe_enq_ok(void) { int tc, len, ulen; put_str("Testing ENQ/ACK, standby..."); fflush(stdout); can_test("u8 u9", FLAG_TESTED); tty_ENQ = user9 ? user9 : "\005"; tc_putp(tty_ENQ); event_start(TIME_SYNC); /* start the timer */ read_key(tty_ACK, TTY_ACK_SIZE - 1); if (event_time(TIME_SYNC) > 400000 || tty_ACK[0] == '\0') { /* These characters came from the user. Sigh. */ tty_can_sync = SYNC_FAILED; ptext("\nThis program expects the ENQ sequence to be"); ptext(" answered with the ACK character. This will help"); ptext(" the program reestablish synchronization when"); ptextln(" the terminal is overrun with data."); ptext("\nENQ sequence from (u9): "); putln(expand(tty_ENQ)); ptext("ACK received: "); putln(expand(tty_ACK)); len = user8 ? strlen(user8) : 0; sprintf(temp, "Length of ACK %d. Expected length of ACK %d.", (int) strlen(tty_ACK), len); ptextln(temp); if (len) { temp[0] = user8[len - 1]; temp[1] = '\0'; ptext("Terminating character found in (u8): "); putln(expand(temp)); } return; } tty_can_sync = SYNC_TESTED; if ((len = strlen(tty_ACK)) == 1) { /* single character acknowledge string */ ACK_terminator = tty_ACK[0]; ACK_length = 4096; return; } tc = tty_ACK[len - 1]; if (user8) { ulen = strlen(user8); if (tc == user8[ulen - 1]) { /* ANSI style acknowledge string */ ACK_terminator = tc; ACK_length = 4096; return; } } /* fixed length acknowledge string */ ACK_length = len; ACK_terminator = -2; }
static void validate_export(nfs_export *exp) { /* Check that the given export point is potentially exportable. * We just give warnings here, don't cause anything to fail. * If a path doesn't exist, or is not a dir or file, give an warning * otherwise trial-export to '-test-client-' and check for failure. */ struct stat stb; char *path = exp->m_export.e_path; struct statfs64 stf; int fs_has_fsid = 0; if (stat(path, &stb) < 0) { xlog(L_ERROR, "Failed to stat %s: %m", path); return; } if (!S_ISDIR(stb.st_mode) && !S_ISREG(stb.st_mode)) { xlog(L_ERROR, "%s is neither a directory nor a file. " "Remote access will fail", path); return; } if (!can_test()) return; if (!statfs64(path, &stf) && (stf.f_fsid.__val[0] || stf.f_fsid.__val[1])) fs_has_fsid = 1; if ((exp->m_export.e_flags & NFSEXP_FSID) || exp->m_export.e_uuid || fs_has_fsid) { if ( !test_export(path, 1)) { xlog(L_ERROR, "%s does not support NFS export", path); return; } } else if ( ! test_export(path, 0)) { if (test_export(path, 1)) xlog(L_ERROR, "%s requires fsid= for NFS export", path); else xlog(L_ERROR, "%s does not support NFS export", path); return; } }
void reset_init(void) { /* send the reset and init strings */ int i; ptext("Terminal reset"); i = char_count; put_name(reset_1string, " (rs1)"); put_name(reset_2string, " (rs2)"); /* run the reset file */ if (reset_file && reset_file[0]) { FILE *fp; int ch; can_test("rf", FLAG_TESTED); if ((fp = fopen(reset_file, "r"))) { /* send the reset file */ sprintf(temp, " (rf) %s", reset_file); ptextln(temp); while (1) { ch = getc(fp); if (ch == EOF) break; put_this(ch); } fclose(fp); } else { sprintf(temp, "\nCannot open reset file (rf) %s", reset_file); ptextln(temp); } } put_name(reset_3string, " (rs3)"); if (i != char_count) { put_crlf(); } ptext(" init"); put_name(init_1string, " (is1)"); put_name(init_2string, " (is2)"); if (set_tab && clear_all_tabs && init_tabs != 8) { put_crlf(); tc_putp(clear_all_tabs); for (char_count = 0; char_count < columns; char_count++) { put_this(' '); if ((char_count & 7) == 7) { tc_putp(set_tab); } } put_cr(); } /* run the initialization file */ if (init_file && init_file[0]) { FILE *fp; int ch; can_test("if", FLAG_TESTED); if ((fp = fopen(init_file, "r"))) { /* send the init file */ sprintf(temp, " (if) %s", init_file); ptextln(temp); while (1) { ch = getc(fp); if (ch == EOF) break; put_this(ch); } fclose(fp); } else { sprintf(temp, "\nCannot open init file (if) %s", init_file); ptextln(temp); } } if (init_prog) { can_test("iprog", FLAG_TESTED); (void) system(init_prog); } put_name(init_3string, " (is3)"); fflush(stdout); }
/* ** curses_setup(exec_name) ** ** Startup ncurses */ void curses_setup( char *exec_name) { int status; static TERMTYPE term; char tty_filename[2048]; tty_init(); /** See if the terminal is in the terminfo data base. This call has two useful benefits, 1) it returns the filename of the terminfo entry, and 2) it searches only terminfo's. This allows us to abort before ncurses starts scanning the termcap file. **/ if ((status = _nc_read_entry(tty_basename, tty_filename, &term)) == 0) { const TERMTYPE *fallback = _nc_fallback(tty_basename); if (fallback) { term = *fallback; sprintf(tty_filename, "(fallback)%s", tty_basename); status = 1; } else { fprintf(stderr, "Terminal not found: TERM=%s\n", tty_basename); show_usage(exec_name); exit(1); } } if (status == -1) { fprintf(stderr, "Terminfo database is inaccessible\n"); exit(1); } /** This call will load the terminfo data base and set the cur-term variable. Only terminals that actually exist will get here so its OK to ignore errors. This is a good thing since ncurses does not permit (os) or (gn) to be set. **/ setupterm(tty_basename, 1, &status); /** Get the current terminal definitions. This must be done before getting the baudrate. **/ _nc_get_curterm(&cur_term->Nttyb); tty_baud_rate = baudrate(); tty_cps = (tty_baud_rate << 1) / tty_frame_size; /* set up the defaults */ replace_mode = TRUE; scan_mode = 0; char_count = 0; select_delay_type = debug_level = 0; char_mask = (meta_on && meta_on[0] == '\0') ? ALLOW_PARITY : STRIP_PARITY; /* Don't change the XON/XOFF modes yet. */ select_xon_xoff = initial_stty_query(TTY_XON_XOFF) ? 1 : needs_xon_xoff; fflush(stdout); /* flush any output */ tty_set(); go_home(); /* set can_go_home */ put_clear(); /* set can_clear_screen */ if (send_reset_init) { reset_init(); } /* I assume that the reset and init strings may not have the correct pads. (Because that part of the test comes much later.) Because of this, I allow the terminal some time to catch up. */ fflush(stdout); /* waste some time */ sleep(1); /* waste more time */ charset_can_test(); can_test("lines cols cr nxon rf if iprog rmp smcup rmcup", FLAG_CAN_TEST); edit_init(); /* initialize the edit data base */ if (send_reset_init && enter_ca_mode) { tc_putp(enter_ca_mode); put_clear(); /* just in case we switched pages */ } put_crlf(); ptext("Using terminfo from: "); ptextln(tty_filename); put_crlf(); if (tty_can_sync == SYNC_NEEDED) { verify_time(); } display_basic(); }
/* ** crum_move(test_list, status, ch) ** ** (*) test all cursor move commands */ static void crum_move( struct test_list *t, int *state, int *ch) { char buf[80]; int n; switch (n = (t->flags & 15)) { case 0: sprintf(buf, " (cr) (nel) (cub1)%s", cursor_home ? " (home)" : (cursor_up ? " (cuu1)" : "")); break; case 1: sprintf(buf, "%s%s%s%s", cursor_left ? " (cub1)" : "", cursor_down ? " (cud1)" : "", cursor_right ? " (cuf1)" : "", cursor_up ? " (cuu1)" : ""); if (buf[0] == '\0') { ptext(" (cub1) (cud1) (cuf1) (cuu1) not defined."); } break; case 2: sprintf(buf, "%s%s%s%s", parm_left_cursor ? " (cub)" : "", parm_down_cursor ? " (cud)" : "", parm_right_cursor ? " (cuf)" : "", parm_up_cursor ? " (cuu)" : ""); if (buf[0] == '\0') { ptext(" (cub) (cud) (cuf) (cuu) not defined."); } break; case 3: sprintf(buf, "%s%s", row_address ? " (vpa)" : "", column_address ? " (hpa)" : ""); if (buf[0] == '\0') { ptext(" (vpa) (hpa) not defined."); } break; case 4: if (!cursor_address) { ptext(" (cup) not defined. "); generic_done_message(t, state, ch); return; } strcpy(buf, " (cup)"); break; } if (buf[0] == '\0') { put_str(" Done. "); } else { can_test(buf, FLAG_TESTED); strcpy(crum_text[n], &buf[2]); crum_text[n][strlen(buf) - 3] = '\0'; display_it(1 << n, buf); } *ch = wait_here(); if (*ch != 'r') { put_clear(); } }