Re: ftpget is adding cr nl to the end of the lines

From: Christian Krackowizer <kra1@dont-contact.us>
Date: Thu, 25 Sep 1997 09:03:37 +0200

At 15:45 24.09.97 -0700, you wrote:
>On Sep 24, 1:02pm, Lars.Slettjord@cc.uit.no wrote:
>} Subject: Re: ftpget is adding cr nl to the end of the lines
>} I got basically the same hint from 3 of you, and I found the cause of my
>} problems.
>}
>} In the src/ftp.c file there is a ftpTransferMode function which uses the
>} table in include/mime_table.h to switch between ASCII and Binary mode for
>} the FTP transfer based on the MIME type of the file.
>}
>} For testing purposes I have modified the function like this:
>}
>} static const char *
>} ftpTransferMode(const char *urlpath)
>} {
>} const char *const ftpASCII = "A";
>} const char *const ftpBinary = "I";
>} /*
>} * char *ext = NULL;
>} * const ext_table_entry *mime = NULL;
>} * int len;
>} * len = strlen(urlpath);
>} * if (*(urlpath + len - 1) == '/')
>} * return ftpASCII;
>} * if ((ext = strrchr(urlpath, '.')) == NULL)
>} * return ftpBinary;
>} * if ((mime = mime_ext_to_type(++ext)) == NULL)
>} * return ftpBinary;
>} * if (!strcmp(mime->mime_encoding, "7bit"))
>} * return ftpASCII;
>} */
>} return ftpBinary;
>} }
>}
>} And it will probably solve my specific problem (I'll know tomorrow when I
>} have restarted my cache).
>}
>} But does this break anything else? There is probably a reason why it is
>} done like this in the first place, even though it causes certain files to
>} be modified during the transfer.
>
>It will break as soon as you transfer a text file from a machine that
>has a different line termination standard. For instance if you transfer
>a something.TXT from an NT server, you'll be see CR/LF again. If you
>fetch a file from a MAC, you'll see something else. If you fetch a file
>from a Unix server and your client is a PC, then the line termination
>won't be right.
>
>If you're fetching a text file, the only sane thing to do is to do an
>ASCII mode tranfer which always changes the line termination to CR/LF.
>Your browser should then see the MIME type text/plain or whatever and
>translate the CR/LF into the native line termination for your platform.
>
>

Workaround:

We're using Browser's on NT and Win 3.11. When we 'ftped' an ascii file
with incorrect endings, we ftp (with 'real' ftp-client) it to our
UNIX-based anonymous server. Using binary-to and ascii-back or vice-versa
always led to a readable file.

regards

+-----------------------------------------------------------------+
| Krackowizer Christian mailto:kra1@technodat.co.at |
| TECHNODAT Phone: ++43-(0)662-454944-0 |
| CAD/CAM - Systeme fuer Moebel GmbH FAX: ++43-(0)662-454944-9 |
| Jakob-Haringer-Strasse 6 http://www.technodat.co.at/ |
| A-5020 Salzburg / Austria |
+-----------------------------------------------------------------+
Received on Thu Sep 25 1997 - 00:14:48 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:37:10 MST