Major destabilisation, phase 1. In this phase I've moved (I think)
[u/mdw/putty] / psftp.c
diff --git a/psftp.c b/psftp.c
index 6f849d4..f3f4c5b 100644 (file)
--- a/psftp.c
+++ b/psftp.c
@@ -1457,6 +1457,19 @@ void fatalbox(char *fmt, ...)
 
     cleanup_exit(1);
 }
+void modalfatalbox(char *fmt, ...)
+{
+    char str[0x100];                  /* Make the size big enough */
+    va_list ap;
+    va_start(ap, fmt);
+    strcpy(str, "Fatal:");
+    vsprintf(str + strlen(str), fmt, ap);
+    va_end(ap);
+    strcat(str, "\n");
+    fputs(str, stderr);
+
+    cleanup_exit(1);
+}
 void connection_fatal(char *fmt, ...)
 {
     char str[0x100];                  /* Make the size big enough */
@@ -1509,7 +1522,7 @@ static unsigned char *outptr;            /* where to put the data */
 static unsigned outlen;                       /* how much data required */
 static unsigned char *pending = NULL;  /* any spare data */
 static unsigned pendlen = 0, pendsize = 0;     /* length and phys. size of buffer */
-int from_backend(int is_stderr, char *data, int datalen)
+int from_backend(void *frontend, int is_stderr, char *data, int datalen)
 {
     unsigned char *p = (unsigned char *) data;
     unsigned len = (unsigned) datalen;
@@ -1732,6 +1745,21 @@ static int psftp_connect(char *userhost, char *user, int portnumber)
      */
     cfg.host[strcspn(cfg.host, ":")] = '\0';
 
+    /*
+     * Remove any remaining whitespace from the hostname.
+     */
+    {
+       int p1 = 0, p2 = 0;
+       while (cfg.host[p2] != '\0') {
+           if (cfg.host[p2] != ' ' && cfg.host[p2] != '\t') {
+               cfg.host[p1] = cfg.host[p2];
+               p1++;
+           }
+           p2++;
+       }
+       cfg.host[p1] = '\0';
+    }
+
     /* Set username */
     if (user != NULL && user[0] != '\0') {
        strncpy(cfg.username, user, sizeof(cfg.username) - 1);
@@ -1794,7 +1822,7 @@ static int psftp_connect(char *userhost, char *user, int portnumber)
 
     back = &ssh_backend;
 
-    err = back->init(cfg.host, cfg.port, &realhost, 0);
+    err = back->init(NULL, cfg.host, cfg.port, &realhost, 0);
     if (err != NULL) {
        fprintf(stderr, "ssh_init: %s\n", err);
        return 1;