X-Git-Url: http://sjero.net/git/?p=wget;a=blobdiff_plain;f=src%2Fftp-basic.c;h=0e11a8d3353a66d9385373dd47ea81be0e6690ad;hp=5f250959fcb62b521c45494e0a165f6632490d88;hb=d5e283b1a75c5f8249300b465b4e7b55130bec49;hpb=8e9a3e805fd758eadfc1bad6a4ef3e971de35ec4 diff --git a/src/ftp-basic.c b/src/ftp-basic.c index 5f250959..0e11a8d3 100644 --- a/src/ftp-basic.c +++ b/src/ftp-basic.c @@ -889,6 +889,42 @@ ftp_cwd (int csock, const char *dir) return FTPOK; } +/* Sends DELE command to the FTP server. */ +uerr_t +ftp_dele (int csock, const char *file) +{ + char *request, *respline; + int nwritten; + uerr_t err; + + /* Send DELE request. */ + request = ftp_request ("DELE", file); + nwritten = fd_write (csock, request, strlen (request), -1.0); + if (nwritten < 0) + { + xfree (request); + return WRITEFAILED; + } + xfree (request); + /* Get appropriate response. */ + err = ftp_response (csock, &respline); + if (err != FTPOK) + return err; /* Return with early bad status. */ + + /* All OK, so far. */ + if (*respline == '5') + { + err = FTPNSFOD; /* Permanent Negative Completion. */ + } + else if (*respline != '2') /* Success might be 226 or 250 (or ???). */ + { + err = FTPRERR; /* Not Positive Completion. */ + } + + xfree (respline); /* Free "respline" storage. */ + return err; /* Return response-based status code. */ +} + /* Sends REST command to the FTP server. */ uerr_t ftp_rest (int csock, wgint offset) @@ -958,7 +994,7 @@ ftp_retr (int csock, const char *file) /* Sends the LIST command to the server. If FILE is NULL, send just `LIST' (no space). */ uerr_t -ftp_list (int csock, const char *file) +ftp_list (int csock, const char *file, enum stype rs) { char *request, *respline; int nwritten; @@ -969,6 +1005,13 @@ ftp_list (int csock, const char *file) const char *list_commands[] = { "LIST -a", "LIST" }; + /* 2008-01-29 SMS. For a VMS FTP server, where "LIST -a" may not + fail, but will never do what is desired here, skip directly to the + simple "LIST" command (assumed to be the last one in the list). + */ + if (rs == ST_VMS) + i = countof (list_commands)- 1; + do { /* Send request. */ request = ftp_request (list_commands[i], file);