=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ftp/util.c,v retrieving revision 1.6 retrieving revision 1.7 diff -c -r1.6 -r1.7 *** src/usr.bin/ftp/util.c 1997/04/16 05:02:59 1.6 --- src/usr.bin/ftp/util.c 1997/04/23 20:33:24 1.7 *************** *** 1,4 **** ! /* $OpenBSD: util.c,v 1.6 1997/04/16 05:02:59 millert Exp $ */ /* $NetBSD: util.c,v 1.7 1997/04/14 09:09:24 lukem Exp $ */ /* --- 1,4 ---- ! /* $OpenBSD: util.c,v 1.7 1997/04/23 20:33:24 deraadt Exp $ */ /* $NetBSD: util.c,v 1.7 1997/04/14 09:09:24 lukem Exp $ */ /* *************** *** 35,41 **** */ #ifndef lint ! static char rcsid[] = "$OpenBSD: util.c,v 1.6 1997/04/16 05:02:59 millert Exp $"; #endif /* not lint */ /* --- 35,41 ---- */ #ifndef lint ! static char rcsid[] = "$OpenBSD: util.c,v 1.7 1997/04/23 20:33:24 deraadt Exp $"; #endif /* not lint */ /* *************** *** 74,80 **** short port; if (connected) { ! printf("Already connected to %s, use close first.\n", hostname); code = -1; return; --- 74,80 ---- short port; if (connected) { ! fprintf(ttyout, "Already connected to %s, use close first.\n", hostname); code = -1; return; *************** *** 82,88 **** if (argc < 2) (void)another(&argc, &argv, "to"); if (argc < 2 || argc > 3) { ! printf("usage: %s host-name [port]\n", argv[0]); code = -1; return; } --- 82,88 ---- if (argc < 2) (void)another(&argc, &argv, "to"); if (argc < 2 || argc > 3) { ! fprintf(ttyout, "usage: %s host-name [port]\n", argv[0]); code = -1; return; } *************** *** 90,97 **** if (argc > 2) { port = atoi(argv[2]); if (port <= 0) { ! printf("%s: bad port number '%s'.\n", argv[1], argv[2]); ! printf("usage: %s host-name [port]\n", argv[0]); code = -1; return; } --- 90,97 ---- if (argc > 2) { port = atoi(argv[2]); if (port <= 0) { ! fprintf(ttyout, "%s: bad port number '%s'.\n", argv[1], argv[2]); ! fprintf(ttyout, "usage: %s host-name [port]\n", argv[0]); code = -1; return; } *************** *** 135,141 **** *cp = '\0'; } ! printf("Remote system type is %s.\n", reply_string + 4); if (cp) *cp = c; } --- 135,141 ---- *cp = '\0'; } ! fprintf(ttyout, "Remote system type is %s.\n", reply_string + 4); if (cp) *cp = c; } *************** *** 153,160 **** type = 0; (void)strcpy(typename, "binary"); if (overbose) ! printf("Using %s mode to transfer files.\n", ! typename); } else { if (proxy) unix_proxy = 0; --- 153,160 ---- type = 0; (void)strcpy(typename, "binary"); if (overbose) ! fprintf(ttyout, "Using %s mode to transfer files.\n", ! typename); } else { if (proxy) unix_proxy = 0; *************** *** 162,169 **** unix_server = 0; if (overbose && !strncmp(reply_string, "215 TOPS20", 10)) ! puts( ! "Remember to set tenex mode when transferring binary files from this machine."); } verbose = overbose; #endif /* unix || BSD */ --- 162,170 ---- unix_server = 0; if (overbose && !strncmp(reply_string, "215 TOPS20", 10)) ! fputs( ! "Remember to set tenex mode when transferring binary files from this machine.\n", ! ttyout); } verbose = overbose; #endif /* unix || BSD */ *************** *** 232,240 **** myname = pp->pw_name; } if (myname) ! printf("Name (%s:%s): ", host, myname); else ! printf("Name (%s): ", host); (void)fgets(tmp, sizeof(tmp) - 1, stdin); tmp[strlen(tmp) - 1] = '\0'; if (*tmp == '\0') --- 233,241 ---- myname = pp->pw_name; } if (myname) ! fprintf(ttyout, "Name (%s:%s): ", host, myname); else ! fprintf(ttyout, "Name (%s): ", host); (void)fgets(tmp, sizeof(tmp) - 1, stdin); tmp[strlen(tmp) - 1] = '\0'; if (*tmp == '\0') *************** *** 288,297 **** int len = strlen(line), ret; if (len >= sizeof(line) - 3) { ! puts("sorry, arguments too long."); intr(); } ! printf("(%s) ", prompt); line[len++] = ' '; if (fgets(&line[len], sizeof(line) - len, stdin) == NULL) intr(); --- 289,298 ---- int len = strlen(line), ret; if (len >= sizeof(line) - 3) { ! fputs("sorry, arguments too long.\n", ttyout); intr(); } ! fprintf(ttyout, "(%s) ", prompt); line[len++] = ' '; if (fgets(&line[len], sizeof(line) - len, stdin) == NULL) intr(); *************** *** 382,388 **** (void)unlink(temp); if (ftemp == NULL) { if (errbuf == NULL) ! puts("can't find list of remote files, oops."); else *errbuf = "can't find list of remote files, oops."; --- 383,390 ---- (void)unlink(temp); if (ftemp == NULL) { if (errbuf == NULL) ! fputs("can't find list of remote files, oops.\n", ! ttyout); else *errbuf = "can't find list of remote files, oops."; *************** *** 407,414 **** if (!interactive || confirmrest) return (1); ! printf("%s %s? ", cmd, file); ! (void)fflush(stdout); if (fgets(line, sizeof(line), stdin) == NULL) return (0); switch (tolower(*line)) { --- 409,416 ---- if (!interactive || confirmrest) return (1); ! fprintf(ttyout, "%s %s? ", cmd, file); ! (void)fflush(ttyout); if (fgets(line, sizeof(line), stdin) == NULL) return (0); switch (tolower(*line)) { *************** *** 416,426 **** return (0); case 'p': interactive = 0; ! puts("Interactive mode: off."); break; case 'a': confirmrest = 1; ! printf("Prompting off for duration of %s.\n", cmd); break; } return (1); --- 418,428 ---- return (0); case 'p': interactive = 0; ! fputs("Interactive mode: off.\n", ttyout); break; case 'a': confirmrest = 1; ! fprintf(ttyout, "Prompting off for duration of %s.\n", cmd); break; } return (1); *************** *** 472,479 **** verbose = -1; if (command("SIZE %s", file) == COMPLETE) sscanf(reply_string, "%*s %qd", &size); ! else if (noisy && debug == 0) ! puts(reply_string); verbose = overbose; return (size); } --- 474,483 ---- verbose = -1; if (command("SIZE %s", file) == COMPLETE) sscanf(reply_string, "%*s %qd", &size); ! else if (noisy && debug == 0) { ! fputs(reply_string, ttyout); ! fputs("\n", ttyout); ! } verbose = overbose; return (size); } *************** *** 508,518 **** timebuf.tm_isdst = -1; rtime = mktime(&timebuf); if (rtime == -1 && (noisy || debug != 0)) ! printf("Can't convert %s to a time.\n", reply_string); else rtime += timebuf.tm_gmtoff; /* conv. local -> GMT */ ! } else if (noisy && debug == 0) ! puts(reply_string); verbose = overbose; return (rtime); } --- 512,524 ---- timebuf.tm_isdst = -1; rtime = mktime(&timebuf); if (rtime == -1 && (noisy || debug != 0)) ! fprintf(ttyout, "Can't convert %s to a time.\n", reply_string); else rtime += timebuf.tm_gmtoff; /* conv. local -> GMT */ ! } else if (noisy && debug == 0) { ! fputs(reply_string, ttyout); ! fputs("\n", ttyout); ! } verbose = overbose; return (rtime); } *************** *** 623,638 **** snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "%02d:%02d ETA", i / 60, i % 60); } ! (void)write(STDOUT_FILENO, buf, strlen(buf)); if (flag == -1) { (void)signal(SIGALRM, updateprogressmeter); alarmtimer(1); /* set alarm timer for 1 Hz */ } else if (flag == 1) { alarmtimer(0); ! (void)putchar('\n'); } ! fflush(stdout); } /* --- 629,644 ---- snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "%02d:%02d ETA", i / 60, i % 60); } ! (void)write(fileno(ttyout), buf, strlen(buf)); if (flag == -1) { (void)signal(SIGALRM, updateprogressmeter); alarmtimer(1); /* set alarm timer for 1 Hz */ } else if (flag == 1) { alarmtimer(0); ! (void)putc('\n', ttyout); } ! fflush(ttyout); } /* *************** *** 641,647 **** * direction to be defined by xfer routines, and filesize and bytes * to be updated by xfer routines * If siginfo is nonzero, an ETA is displayed, and the output goes to STDERR ! * instead of STDOUT. */ void ptransfer(siginfo) --- 647,653 ---- * direction to be defined by xfer routines, and filesize and bytes * to be updated by xfer routines * If siginfo is nonzero, an ETA is displayed, and the output goes to STDERR ! * instead of TTYOUT. */ void ptransfer(siginfo) *************** *** 676,682 **** " ETA: %02d:%02d:%02d\n", hh, remaining / 60, remaining % 60); } ! (void)write(siginfo ? STDERR_FILENO : STDOUT_FILENO, buf, strlen(buf)); } /* --- 682,688 ---- " ETA: %02d:%02d:%02d\n", hh, remaining / 60, remaining % 60); } ! (void)write(siginfo ? STDERR_FILENO : fileno(ttyout), buf, strlen(buf)); } /* *************** *** 707,721 **** for (j = 0; j < columns; j++) { p = sl->sl_str[j * lines + i]; if (p) ! fputs(p, stdout); if (j * lines + i + lines >= sl->sl_cur) { ! putchar('\n'); break; } w = strlen(p); while (w < width) { w = (w + 8) &~ 7; ! (void)putchar('\t'); } } } --- 713,727 ---- for (j = 0; j < columns; j++) { p = sl->sl_str[j * lines + i]; if (p) ! fputs(p, ttyout); if (j * lines + i + lines >= sl->sl_cur) { ! putc('\n', ttyout); break; } w = strlen(p); while (w < width) { w = (w + 8) &~ 7; ! (void)putc('\t', ttyout); } } } *************** *** 730,736 **** { struct winsize winsize; ! if (ioctl(fileno(stdout), TIOCGWINSZ, &winsize) != -1) ttywidth = winsize.ws_col; else ttywidth = 80; --- 736,742 ---- { struct winsize winsize; ! if (ioctl(fileno(ttyout), TIOCGWINSZ, &winsize) != -1) ttywidth = winsize.ws_col; else ttywidth = 80; *************** *** 759,765 **** controlediting() { if (editing && el == NULL && hist == NULL) { ! el = el_init(__progname, stdin, stdout); /* init editline */ hist = history_init(); /* init the builtin history */ history(hist, H_EVENT, 100); /* remember 100 events */ el_set(el, EL_HIST, history, hist); /* use history */ --- 765,771 ---- controlediting() { if (editing && el == NULL && hist == NULL) { ! el = el_init(__progname, stdin, ttyout); /* init editline */ hist = history_init(); /* init the builtin history */ history(hist, H_EVENT, 100); /* remember 100 events */ el_set(el, EL_HIST, history, hist); /* use history */