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)
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)
#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);
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)
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
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;