sitecopy extension: new option ftp lsla

Heiko Schlittermann <[email protected]> Tue, 12 Sep 2006 23:17:21 +0200
Newsgroups gmane.comp.web.sitecopy
Organization schlittermann -- internet & unix support
Message-ID <[email protected]>
Hello,

----- Forwarded message from Heiko Schlittermann <[email protected]> -----

Hello Joe,

I've had problems using sitecopy against some Strato-FTP-Server.  The
server didn't like LIST options and slashes in directory names.

Now sitecopyrc understands a new option

    ftp lsla -	    # do not use any options for LIST
    ftp lsla -la    # use -la as options for LIST (default)


If you're interested in my solution *AND* if you would put it into
the official release (of course, after a review), please let me know.


----- End forwarded message -----
----- Forwarded message from Joe Orton <[email protected]> -----

On Mon, Sep 11, 2006 at 03:45:31PM +0200, Heiko Schlittermann wrote:
> If you're interested in my solution *AND* if you would put it into
> the official release (of course, after a review), please let me know.

Hi, sounds interesting - can you send it in to the mailing list for 
review?  [email protected]

...

Regards,

joe

----- End forwarded message -----

So I'm doing it now.  The patch is appended.


    Best regards from Dresden
    Viele Grüße aus Dresden
    Heiko Schlittermann
-- 
 SCHLITTERMANN.de ---------------------------- internet & unix support -
 Heiko Schlittermann HS12-RIPE -----------------------------------------
 gnupg encrypted messages are welcome - key ID: 48D0359B ---------------
 gnupg fingerprint: 3061 CFBF 2D88 F034 E8D2  7E92 EE4E AC98 48D0 359B -

_______________________________________________
sitecopy maillist  -  [email protected]
http://dav.lyra.org/mailman/listinfo/sitecopy
diff.hs (text/x-haskell, 2.5 KB)
diff -ruN sitecopy-0.16.3/src/ftp.c sitecopy-0.16.3.hs/src/ftp.c
--- sitecopy-0.16.3/src/ftp.c	2005-12-30 14:18:29.000000000 +0100
+++ sitecopy-0.16.3.hs/src/ftp.c	2006-09-11 15:38:11.000000000 +0200
@@ -71,6 +71,7 @@
     unsigned int use_cwd; /* CWD before STOR */
 
     int connected; /* true when open */
+    const char *lsla; /* options for LIST */
 
     /* Userdata passed to fe_authenticate call */
     void *feauth_userdata;
@@ -559,6 +560,11 @@
     sess->use_cwd = use_cwd;
 }
 
+void ftp_set_lsla(ftp_session *sess, const char* lsla)
+{
+    sess->lsla = lsla;
+}
+
 int ftp_set_server(ftp_session *sess, struct site_host *server)
 {
     if (server->username) {
@@ -1124,7 +1130,10 @@
     struct ls_context *lsctx;
     int ret;
 
-    if ((ret = ftp_data_open(sess, "LIST -la %s", startdir)) != FTP_READY) {
+    if ((ret = ftp_data_open(sess, "LIST %*s%s", 
+	    sess->lsla ? -1*(1+strlen(sess->lsla)) : 0,
+	    sess->lsla ? sess->lsla : "",
+	    startdir)) != FTP_READY) {
         return FTP_ERROR;
     }
 
diff -ruN sitecopy-0.16.3/src/ftpdriver.c sitecopy-0.16.3.hs/src/ftpdriver.c
--- sitecopy-0.16.3/src/ftpdriver.c	2005-04-04 19:36:38.000000000 +0200
+++ sitecopy-0.16.3.hs/src/ftpdriver.c	2006-09-11 15:26:01.000000000 +0200
@@ -58,6 +58,7 @@
 	if (site->ftp_use_cwd) {
 	    ftp_set_usecwd(sess, 1);
 	}
+	ftp_set_lsla(sess, site->ftp_lsla);
 	ret = ftp_open(sess);
     }
     *session = sess;
diff -ruN sitecopy-0.16.3/src/rcfile.c sitecopy-0.16.3.hs/src/rcfile.c
--- sitecopy-0.16.3/src/rcfile.c	2006-02-04 13:16:36.000000000 +0100
+++ sitecopy-0.16.3.hs/src/rcfile.c	2006-09-11 15:35:51.000000000 +0200
@@ -114,6 +114,7 @@
 
     default_site.ftp_pasv_mode = true;
     default_site.ftp_use_cwd = false;
+    default_site.ftp_lsla = "-la";
     
     last_site = this_site = NULL;
     rcfile_linenum = 0;
@@ -454,7 +455,12 @@
 		ret = RC_CORRUPT;
 	    }
 	} else {
-	    {
+	    if (strcmp(key, "ftp") == 0) {
+		if (strcmp(val, "lsla") == 0) {
+		    if (strlen(val2) > 1) this_site->ftp_lsla = strdup(val2);
+		    else this_site->ftp_lsla = NULL;
+		}
+	    } else {
 		ret = RC_CORRUPT;
 	    }
 	}
diff -ruN sitecopy-0.16.3/src/sites.h sitecopy-0.16.3.hs/src/sites.h
--- sitecopy-0.16.3/src/sites.h	2006-02-04 13:16:36.000000000 +0100
+++ sitecopy-0.16.3.hs/src/sites.h	2006-09-11 15:21:04.000000000 +0200
@@ -374,6 +374,7 @@
     unsigned int ftp_echo_quit;
     unsigned int ftp_forcecd;
     unsigned int ftp_use_cwd;
+    const char *ftp_lsla;
     unsigned int http_use_expect;
     unsigned int http_limit;
     unsigned int http_secure;
signature.asc (application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)

iD8DBQFFByPg7k6smEjQNZsRApBGAKCWFtUCpFyzsNDMnBFIgTUhjW4YUwCbBhXF
k4nkt1sBQIroG/pevwiZozE=
=muyT
-----END PGP SIGNATURE-----