From 5daac18e96c40ea7eea639f03c1b643f89cf3440 Mon Sep 17 00:00:00 2001 From: Micah Cowan Date: Sat, 4 Jul 2009 18:42:59 -0700 Subject: [PATCH] Adjust some typos from vms merge, and remove some elements we don't want to include without further consideration first. --- src/convert.c | 4 +-- src/ftp-basic.c | 36 ------------------------ src/ftp.h | 1 - src/retr.c | 74 +++---------------------------------------------- src/retr.h | 3 +- 5 files changed, 7 insertions(+), 111 deletions(-) diff --git a/src/convert.c b/src/convert.c index 1bf9d274..280d1b0c 100644 --- a/src/convert.c +++ b/src/convert.c @@ -444,9 +444,9 @@ write_backup_file (const char *file, downloaded_file_t downloaded_file_return) else /* downloaded_file_return == FILE_DOWNLOADED_NORMALLY */ { /* Append ".orig" to the name. */ - filename_plus_orig_suffix = alloca (filename_len + sizeof ("ORIG_SFX")); + filename_plus_orig_suffix = alloca (filename_len + sizeof (ORIG_SFX)); strcpy (filename_plus_orig_suffix, file); - strcpy (filename_plus_orig_suffix + filename_len, "ORIG_SFX"); + strcpy (filename_plus_orig_suffix + filename_len, ORIG_SFX); } if (!converted_files) diff --git a/src/ftp-basic.c b/src/ftp-basic.c index 0e11a8d3..8d3342c0 100644 --- a/src/ftp-basic.c +++ b/src/ftp-basic.c @@ -889,42 +889,6 @@ 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) diff --git a/src/ftp.h b/src/ftp.h index 9aa88d8b..f0d5dc08 100644 --- a/src/ftp.h +++ b/src/ftp.h @@ -58,7 +58,6 @@ uerr_t ftp_epsv (int, ip_address *, int *); #endif uerr_t ftp_type (int, int); uerr_t ftp_cwd (int, const char *); -uerr_t ftp_dele (int, const char *); uerr_t ftp_retr (int, const char *); uerr_t ftp_rest (int, wgint); uerr_t ftp_list (int, const char *, enum stype); diff --git a/src/retr.c b/src/retr.c index 39627e4b..b667ca2f 100644 --- a/src/retr.c +++ b/src/retr.c @@ -143,10 +143,8 @@ limit_bandwidth (wgint bytes, struct ptimer *timer) static int write_data (FILE *out, const char *buf, int bufsize, wgint *skip, - wgint *written, int flags) + wgint *written) { - static int cr_pending = 0; /* Found CR in ASCII FTP data. */ - if (!out) return 1; if (*skip > bufsize) @@ -163,72 +161,8 @@ write_data (FILE *out, const char *buf, int bufsize, wgint *skip, return 1; } -/* Note: This code assumes that "\n" is the universal line ending - character, as on UNIX and VMS. If this is not true, then here's - where to change it. -*/ - -#if 1 -# define EOL_STRING "\n" -#else /* 1 */ -# define EOL_STRING "\r\n" -#endif /* 1 [else] */ -#define EOL_STRING_LEN (sizeof( EOL_STRING)- 1) - - if (flags & rb_ftp_ascii) - { - const char *bufend; - - /* ASCII transfer. Put out lines delimited by CRLF. */ - bufend = buf+ bufsize; - while (buf < bufend) - { - /* If CR, put out any pending CR, then set CR-pending flag. */ - if (*buf == '\r') - { - if (cr_pending) - { - fwrite ("\r", 1, 1, out); - *written += 1; - } - cr_pending = 1; - buf++; - continue; - } - - if (cr_pending) - { - if (*buf == '\n') - { - /* Found FTP EOL (CRLF). Put out local EOL. */ - fwrite (EOL_STRING, 1, EOL_STRING_LEN, out); - *written += EOL_STRING_LEN; - } - else - { - /* Normal character. Put out pending CR and it. */ - fwrite ("\r", 1, 1, out); - fwrite (buf, 1, 1, out); - *written += 2; - } - buf++; - cr_pending = 0; - } - else - { - /* Normal character. Put it out. */ - fwrite (buf, 1, 1, out); - *written += 1; - buf++; - } - } - } - else - { - /* Image transfer. Put out buffer. */ - fwrite (buf, 1, bufsize, out); - *written += bufsize; - } + fwrite (buf, 1, bufsize, out); + *written += bufsize; /* Immediately flush the downloaded data. This should not hinder performance: fast downloads will arrive in large 16K chunks @@ -376,7 +310,7 @@ fd_read_body (int fd, FILE *out, wgint toread, wgint startpos, if (ret > 0) { sum_read += ret; - if (!write_data (out, dlbuf, ret, &skip, &sum_written, flags)) + if (!write_data (out, dlbuf, ret, &skip, &sum_written)) { ret = -2; goto out; diff --git a/src/retr.h b/src/retr.h index 89a50221..8854b684 100644 --- a/src/retr.h +++ b/src/retr.h @@ -43,8 +43,7 @@ extern bool output_stream_regular; /* Flags for fd_read_body. */ enum { rb_read_exactly = 1, - rb_skip_startpos = 2, - rb_ftp_ascii = 4 + rb_skip_startpos = 2 }; int fd_read_body (int, FILE *, wgint, wgint, wgint *, wgint *, double *, int);