From 80b004a57d6fe8ce2d2fceb29b6eb4a7101da958 Mon Sep 17 00:00:00 2001
From: Daniel Stenberg <daniel@haxx.se>
Date: Thu, 28 Feb 2002 23:31:23 +0000
Subject: Wesley Laxton's CURLOPT_PREQUOTE work

---
 lib/ftp.c     | 12 ++++++++++++
 lib/url.c     | 10 ++++++++--
 lib/urldata.h |  3 ++-
 3 files changed, 22 insertions(+), 3 deletions(-)

(limited to 'lib')

diff --git a/lib/ftp.c b/lib/ftp.c
index 5ec23aafe..92f62638e 100644
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -1618,6 +1618,12 @@ CURLcode ftp_perform(struct connectdata *conn)
     if(result)
       return result;
 
+    /* Send any PREQUOTE strings after transfer type is set? (Wesley Laxton)*/
+    if(data->set.prequote) {
+      if ((result = ftp_sendquote(conn, data->set.prequote)) != CURLE_OK)
+        return result;
+    }
+
     if(conn->resume_from) {
       /* we're about to continue the uploading of a file */
       /* 1. get already existing file's size. We use the SIZE
@@ -1803,6 +1809,12 @@ CURLcode ftp_perform(struct connectdata *conn)
       if(result)
         return result;
 
+      /* Send any PREQUOTE strings after transfer type is set? (Wesley Laxton)*/
+      if(data->set.prequote) {
+        if ((result = ftp_sendquote(conn, data->set.prequote)) != CURLE_OK)
+          return result;
+      }
+
       /* Attempt to get the size, it'll be useful in some cases: for resumed
          downloads and when talking to servers that don't give away the size
          in the RETR response line. */
diff --git a/lib/url.c b/lib/url.c
index fc2031c94..e88a65e85 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -735,6 +735,12 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option, ...)
      */
     data->set.postquote = va_arg(param, struct curl_slist *);
     break;
+  case CURLOPT_PREQUOTE:
+    /*
+     * List of RAW FTP commands to use prior to RETR (Wesley Laxton)
+     */
+    data->set.prequote = va_arg(param, struct curl_slist *);
+    break;
   case CURLOPT_QUOTE:
     /*
      * List of RAW FTP commands to use before a transfer 
@@ -1983,8 +1989,8 @@ static CURLcode CreateConnection(struct SessionHandle *data,
     conn = conn_temp;        /* use this connection from now on */
 
     /* we need these pointers if we speak over a proxy */
-    conn->hostname = old_conn->gname;
-    conn->name = old_conn->name;
+    conn->hostname = conn->gname;
+    conn->name = &conn->gname[old_conn->name - old_conn->gname];
 
     free(conn->path);    /* free the previously allocated path pointer */
 
diff --git a/lib/urldata.h b/lib/urldata.h
index cd667fade..c2778a8e3 100644
--- a/lib/urldata.h
+++ b/lib/urldata.h
@@ -604,8 +604,9 @@ struct UserDefined {
   char *crypto_engine;  /* name of the crypto engine to use */
   char *cookiejar;      /* dump all cookies to this file */
   bool crlf;            /* convert crlf on ftp upload(?) */
-  struct curl_slist *quote;     /* before the transfer */
+  struct curl_slist *quote;     /* after connection is established */
   struct curl_slist *postquote; /* after the transfer */
+  struct curl_slist *prequote; /* before the transfer, after type (Wesley Laxton)*/
   struct curl_slist *telnet_options; /* linked list of telnet options */
   curl_TimeCond timecondition; /* kind of time/date comparison */
   time_t timevalue;       /* what time to compare with */
-- 
cgit v1.2.3