Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-6]: src/usr.sbin/pkg_install/lib Pull up revision 1.47 (request...



details:   https://anonhg.NetBSD.org/src/rev/dcf9e23caf78
branches:  netbsd-1-6
changeset: 529533:dcf9e23caf78
user:      tron <tron%NetBSD.org@localhost>
date:      Sun Nov 24 22:36:03 2002 +0000

description:
Pull up revision 1.47 (requested by jschauma in ticket #1011):
Properly re-implement hilighting of the dialogue with the ftp(1)
process.
Thanks again for the throughout notification I got before that
was removed! :(

diffstat:

 usr.sbin/pkg_install/lib/ftpio.c |  27 ++++++++++++++++++++++-----
 1 files changed, 22 insertions(+), 5 deletions(-)

diffs (81 lines):

diff -r bf8cdf7c53b2 -r dcf9e23caf78 usr.sbin/pkg_install/lib/ftpio.c
--- a/usr.sbin/pkg_install/lib/ftpio.c  Sun Nov 24 22:35:41 2002 +0000
+++ b/usr.sbin/pkg_install/lib/ftpio.c  Sun Nov 24 22:36:03 2002 +0000
@@ -1,8 +1,8 @@
-/*     $NetBSD: ftpio.c,v 1.35.2.9 2002/11/24 22:35:41 tron Exp $      */
+/*     $NetBSD: ftpio.c,v 1.35.2.10 2002/11/24 22:36:03 tron Exp $     */
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: ftpio.c,v 1.35.2.9 2002/11/24 22:35:41 tron Exp $");
+__RCSID("$NetBSD: ftpio.c,v 1.35.2.10 2002/11/24 22:36:03 tron Exp $");
 #endif
 
 /*
@@ -48,6 +48,7 @@
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <termcap.h>
 #include <unistd.h>
 #ifdef EXPECT_DEBUG
 #include <vis.h>
@@ -84,6 +85,9 @@
 static int      ftp_started=0;
 static fds      ftpio;
 static int      ftp_pid;
+static char     term[1024];
+static char     bold_on[1024];
+static char     bold_off[1024];
 
 /*
  * expect "str" (a regular expression) on file descriptor "fd", storing
@@ -219,11 +223,14 @@
 int
 ftp_cmd(const char *cmd, const char *expectstr)
 {
-    int rc=0;
+    int rc=0, verbose_ftp=0;
     int len;
 
     if (Verbose)
-           fprintf(stderr, "\nftp> %s", cmd);
+           verbose_ftp=1;
+    
+    if (verbose_ftp)
+           fprintf(stderr, "\n%sftp> %s%s", bold_on, cmd, bold_off);
     
     fflush(stdout);
     len = write(ftpio.command, cmd, strlen(cmd));
@@ -301,7 +308,7 @@
            setbuf(stdout, NULL);
            
            if (Verbose)
-                   fprintf(stderr, "ftp -detv %s\n", base);
+                   fprintf(stderr, "%sftp -detv %s%s\n", bold_on, base, bold_off);
            rc1 = execlp(FTP_CMD, argv0, "-detv", base, NULL);
            warn("setupCoproc: execlp() failed");
            exit(1);
@@ -404,12 +411,22 @@
 ftp_start(char *base)
 {
        const char *tmp1, *tmp2;
+       char *p;
        int rc;
        char newHost[MAXHOSTNAMELEN];
        const char *newDir;
        const char *currentHost=getenv(PKG_FTPIO_CURRENTHOST);
        const char *currentDir=getenv(PKG_FTPIO_CURRENTDIR);
        int urllen;
+
+       /* talk to termcap for bold on/off escape sequences */
+       if (tgetent(term, getenv("TERM")) < 0) {
+               bold_on[0]  = '\0';
+               bold_off[0] = '\0';
+       } else {
+               p = bold_on;  tgetstr("md", &p);
+               p = bold_off; tgetstr("me", &p);
+       }
        
        fileURLHost(base, newHost, sizeof(newHost));
        urllen = URLlength(base);



Home | Main Index | Thread Index | Old Index